This commit is contained in:
Vanessa 2022-09-19 23:56:47 +08:00
parent 1ad3a1c505
commit 6851656c09
4 changed files with 13 additions and 13 deletions

View File

@ -11,7 +11,7 @@ import {
setFirstNodeRange,
setLastNodeRange
} from "../util/selection";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByMatchTag} from "../util/hasClosest";
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
import {Link} from "./Link";
import {setPosition} from "../../util/setPosition";
import {updateTransaction} from "../wysiwyg/transaction";
@ -859,33 +859,33 @@ export class Toolbar {
}
}
if (isInlineMemo) {
let inlineMemoElements
let inlineMemoElements;
if (updateElements) {
inlineMemoElements = updateElements
inlineMemoElements = updateElements;
} else {
inlineMemoElements = [renderElement]
inlineMemoElements = [renderElement];
}
inlineMemoElements.forEach((item, index) => {
if (!target.value) {
// https://github.com/siyuan-note/insider/issues/1046
const currentTypes = item.getAttribute("data-type").split(" ")
const currentTypes = item.getAttribute("data-type").split(" ");
if (currentTypes.length === 1 && currentTypes[0] === "inline-memo") {
item.outerHTML = item.innerHTML + (index === inlineMemoElements.length - 1 ? "<wbr>" : "");
focusByWbr(nodeElement, this.range);
} else {
currentTypes.find((typeItem, index) => {
if (typeItem === "inline-memo") {
currentTypes.splice(index, 1)
return true
currentTypes.splice(index, 1);
return true;
}
})
});
item.setAttribute("data-type", currentTypes.join(" "));
item.removeAttribute("data-inline-memo-content");
}
} else {
item.setAttribute("data-inline-memo-content", Lute.EscapeHTMLStr(target.value));
}
})
});
} else if (type === "NodeBlockQueryEmbed") {
blockRender(protyle, renderElement);
}

View File

@ -1,4 +1,4 @@
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName, hasClosestByMatchTag} from "./hasClosest";
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "./hasClosest";
import * as dayjs from "dayjs";
import {removeEmbed} from "../wysiwyg/removeEmbed";
import {transaction, updateTransaction} from "../wysiwyg/transaction";

View File

@ -45,7 +45,7 @@ export const fixTableRange = (range:Range) => {
}
}
}
}
};
export const selectAll = (protyle: IProtyle, nodeElement: Element, range: Range) => {
const editElement = getContenteditableElement(nodeElement);

View File

@ -846,12 +846,12 @@ export class WYSIWYG {
let cursorElement = hasClosestBlock(range.startContainer) as Element;
if (cursorElement) {
if (cursorElement.nextElementSibling?.classList.contains("table")) {
setLastNodeRange(getContenteditableElement(cursorElement), range, false)
setLastNodeRange(getContenteditableElement(cursorElement), range, false);
} else if (cursorElement.classList.contains("table")) {
const cellElements = cursorElement.querySelectorAll("th, td");
cursorElement = cellElements[cellElements.length - 1];
if (cursorElement.contains(range.startContainer)) {
setLastNodeRange(cursorElement, range, false)
setLastNodeRange(cursorElement, range, false);
}
}
}