🎨 Paste code from IDE no longer escape <
and >
Fix https://github.com/siyuan-note/siyuan/issues/8340
This commit is contained in:
parent
4704284ad2
commit
528283001b
1 changed files with 3 additions and 1 deletions
|
@ -29,10 +29,12 @@ export const processPasteCode = (html: string, text: string) => {
|
|||
}
|
||||
|
||||
if (isCode) {
|
||||
const code = text || html;
|
||||
let code = text || html;
|
||||
if (/\n/.test(code)) {
|
||||
return `<div data-type="NodeCodeBlock" class="code-block" data-node-id="${Lute.NewNodeID()}"><div class="protyle-action"><span class="protyle-action--first protyle-action__language" contenteditable="false">${window.siyuan.storage[Constants.LOCAL_CODELANG]}</span><span class="fn__flex-1"></span><span class="protyle-icon protyle-icon--first protyle-action__copy"><svg><use xlink:href="#iconCopy"></use></svg></span><span class="protyle-icon protyle-icon--last protyle-action__menu"><svg><use xlink:href="#iconMore"></use></svg></span></div><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${code.replace(/&/g, "&").replace(/</g, "<")}<wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
|
||||
} else {
|
||||
// Paste code from IDE no longer escape `<` and `>` https://github.com/siyuan-note/siyuan/issues/8340
|
||||
code = code.replace("<", "<").replace('>', ">");
|
||||
return "`" + code + "`";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue