mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 table 中禁止插入代码块
This commit is contained in:
parent
61e16c8743
commit
5b50a4d853
1 changed files with 14 additions and 12 deletions
|
|
@ -1381,19 +1381,21 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.insert.code.custom, event) &&
|
||||
!["NodeCodeBlock", "NodeHeading", "NodeTable"].includes(nodeElement.getAttribute("data-type"))) {
|
||||
const id = nodeElement.getAttribute("data-node-id");
|
||||
const html = nodeElement.outerHTML;
|
||||
const editElement = getContenteditableElement(nodeElement);
|
||||
// 需要 EscapeHTMLStr https://github.com/siyuan-note/siyuan/issues/11451
|
||||
editElement.innerHTML = "```" + window.siyuan.storage[Constants.LOCAL_CODELANG] + "\n" + Lute.EscapeHTMLStr(editElement.textContent) + "<wbr>\n```";
|
||||
const newHTML = protyle.lute.SpinBlockDOM(nodeElement.outerHTML);
|
||||
nodeElement.outerHTML = newHTML;
|
||||
const newNodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`);
|
||||
updateTransaction(protyle, id, newHTML, html);
|
||||
highlightRender(newNodeElement);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
if (editElement) {
|
||||
const id = nodeElement.getAttribute("data-node-id");
|
||||
const html = nodeElement.outerHTML;
|
||||
// 需要 EscapeHTMLStr https://github.com/siyuan-note/siyuan/issues/11451
|
||||
editElement.innerHTML = "```" + window.siyuan.storage[Constants.LOCAL_CODELANG] + "\n" + Lute.EscapeHTMLStr(editElement.textContent) + "<wbr>\n```";
|
||||
const newHTML = protyle.lute.SpinBlockDOM(nodeElement.outerHTML);
|
||||
nodeElement.outerHTML = newHTML;
|
||||
const newNodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`);
|
||||
updateTransaction(protyle, id, newHTML, html);
|
||||
highlightRender(newNodeElement);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// toolbar action
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue