This commit is contained in:
parent
47c2bc91a8
commit
f6f358f1eb
1 changed files with 6 additions and 10 deletions
|
@ -119,7 +119,10 @@ export class WYSIWYG {
|
|||
// 使用 inlineElement.innerHTML 会出现 https://ld246.com/article/1627185027423 中的第2个问题
|
||||
dataLength = 4;
|
||||
}
|
||||
// https://github.com/siyuan-note/siyuan/issues/5924
|
||||
if (currentTypes.length > 0 && range.toString() === "" && range.startOffset === inputData.length && inlineElement.tagName === "SPAN" &&
|
||||
inlineElement.textContent.replace(Constants.ZWSP, "") !== inputData &&
|
||||
inlineElement.textContent.replace(Constants.ZWSP, "").length >= inputData.length&&
|
||||
!hasPreviousSibling(range.startContainer) && !hasPreviousSibling(inlineElement)) {
|
||||
const html = inlineElement.innerHTML.replace(Constants.ZWSP, "");
|
||||
inlineElement.innerHTML = html.substr(dataLength);
|
||||
|
@ -131,15 +134,14 @@ export class WYSIWYG {
|
|||
}
|
||||
if (// 表格行内公式之前无法插入文字 https://github.com/siyuan-note/siyuan/issues/3908
|
||||
inlineElement.tagName === "SPAN" &&
|
||||
inlineElement.textContent.replace(Constants.ZWSP, "") !== inputData &&
|
||||
inlineElement.textContent !== inputData &&
|
||||
range.toString() === "" && range.startContainer.nodeType === 3 &&
|
||||
(currentTypes.includes("inline-memo") || currentTypes.includes("text") || currentTypes.includes("block-ref") || currentTypes.includes("file-annotation-ref") || currentTypes.includes("a")) &&
|
||||
!hasNextSibling(range.startContainer) && range.startContainer.textContent.length === range.startOffset &&
|
||||
inlineElement.textContent.replace(Constants.ZWSP, "").length >= inputData.length // 为空的时候需要等于
|
||||
inlineElement.textContent.length > inputData.length
|
||||
) {
|
||||
const position = getSelectionOffset(inlineElement, protyle.wysiwyg.element, range);
|
||||
// ctrl+k 会产生 ZWSP,需要移除
|
||||
const html = inlineElement.innerHTML.replace(Constants.ZWSP, "");
|
||||
const html = inlineElement.innerHTML;
|
||||
if (position.start === inlineElement.textContent.length) {
|
||||
// 使用 inlineElement.textContent **$a$b** 中数学公式消失
|
||||
inlineElement.innerHTML = html.substr(0, html.length - dataLength);
|
||||
|
@ -147,12 +149,6 @@ export class WYSIWYG {
|
|||
inlineElement.after(textNode);
|
||||
range.selectNodeContents(textNode);
|
||||
range.collapse(false);
|
||||
} else if (position.start === inputData.length) {
|
||||
inlineElement.innerHTML = html.substr(dataLength);
|
||||
const textNode = document.createTextNode(inputData);
|
||||
inlineElement.before(textNode);
|
||||
range.selectNodeContents(textNode);
|
||||
range.collapse(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue