mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 18:26:09 +01:00
This commit is contained in:
parent
dae6158860
commit
8cfe987d82
1 changed files with 13 additions and 8 deletions
|
|
@ -290,7 +290,8 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
|||
let id = blockElement.getAttribute("data-node-id");
|
||||
range.insertNode(document.createElement("wbr"));
|
||||
let oldHTML = blockElement.outerHTML;
|
||||
const isNodeCodeBlock = blockElement.getAttribute("data-type") === "NodeCodeBlock";
|
||||
const type = blockElement.getAttribute("data-type");
|
||||
const isNodeCodeBlock = type === "NodeCodeBlock";
|
||||
const editableElement = getContenteditableElement(blockElement);
|
||||
if (!isBlock &&
|
||||
(isNodeCodeBlock || protyle.toolbar.getCurrentType(range).includes("code"))) {
|
||||
|
|
@ -348,8 +349,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
|||
}
|
||||
const tempElement = document.createElement("template");
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/14162
|
||||
if (html.startsWith(">") && editableElement.textContent.replace(Constants.ZWSP, "") !== "") {
|
||||
// https://github.com/siyuan-note/siyuan/issues/14162 & https://github.com/siyuan-note/siyuan/issues/14162
|
||||
if (/^\s*>|\*|-|\+|\d*.|\[ \]|[x]/.test(html) &&
|
||||
editableElement.textContent.replace(Constants.ZWSP, "") !== "") {
|
||||
unSpinHTML = html;
|
||||
}
|
||||
|
||||
|
|
@ -360,19 +362,22 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
|||
innerHTML = innerHTML.replace(/;;;lt;;;/g, "<").replace(/;;;gt;;;/g, ">");
|
||||
tempElement.innerHTML = innerHTML;
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/14114
|
||||
let heading2text = false;
|
||||
if ((editableElement.textContent.replace(Constants.ZWSP, "") !== "" || blockElement.getAttribute("data-type") === "NodeHeading") &&
|
||||
let block2text = false;
|
||||
if ((
|
||||
editableElement.textContent.replace(Constants.ZWSP, "") !== "" ||
|
||||
type === "NodeHeading"
|
||||
) &&
|
||||
tempElement.content.childElementCount === 1 &&
|
||||
tempElement.content.firstChild.nodeType !== 3 &&
|
||||
tempElement.content.firstElementChild.getAttribute("data-type") === "NodeHeading") {
|
||||
// https://github.com/siyuan-note/siyuan/issues/14114
|
||||
isBlock = false;
|
||||
heading2text = true;
|
||||
block2text = true;
|
||||
}
|
||||
|
||||
// 使用 lute 方法会添加 p 元素,只有一个 p 元素或者只有一个字符串或者为 <u>b</u> 时的时候只拷贝内部
|
||||
if (!isBlock) {
|
||||
if (tempElement.content.firstChild.nodeType === 3 || heading2text ||
|
||||
if (tempElement.content.firstChild.nodeType === 3 || block2text ||
|
||||
(tempElement.content.firstChild.nodeType !== 3 &&
|
||||
((tempElement.content.firstElementChild.classList.contains("p") && tempElement.content.childElementCount === 1) ||
|
||||
tempElement.content.firstElementChild.tagName !== "DIV"))) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue