This commit is contained in:
Vanessa 2023-07-03 23:02:19 +08:00
parent edbfd54494
commit 0a915819f3
7 changed files with 76 additions and 12 deletions

View file

@ -7,6 +7,8 @@ import {mathRender} from "../render/mathRender";
import {Constants} from "../../constants";
import {highlightRender} from "../render/highlightRender";
import {scrollCenter} from "../../util/highlightById";
import {updateAVName} from "../render/av/action";
import {readText} from "./compatibility";
export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
// 移动端插入嵌入块时,获取到的 range 为旧值
@ -31,6 +33,22 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
if (!blockElement) {
return;
}
if (blockElement.classList.contains("av")) {
range.deleteContents();
const text = readText();
if (typeof text === "string") {
range.insertNode(document.createTextNode(text));
range.collapse(false);
updateAVName(protyle, blockElement);
} else {
text.then((t) => {
range.insertNode(document.createTextNode(t));
range.collapse(false);
updateAVName(protyle, blockElement);
});
}
return;
}
let id = blockElement.getAttribute("data-node-id");
range.insertNode(document.createElement("wbr"));
let oldHTML = blockElement.outerHTML;