Vanessa 2025-09-22 16:43:29 +08:00
parent 7735a018f3
commit 980e1bd9d5
3 changed files with 14 additions and 3 deletions

View file

@ -34,9 +34,8 @@ export const genRenderFrame = (renderElement: Element) => {
};
export const processClonePHElement = (item: Element) => {
if (item.getAttribute("data-type") === "NodeHTMLBlock") {
const phElement = item.querySelector("protyle-html");
item.querySelectorAll("protyle-html").forEach((phElement) => {
phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(phElement.getAttribute("data-content")));
}
});
return item;
};

View file

@ -20,6 +20,7 @@ import {input} from "../wysiwyg/input";
import {fetchPost} from "../../util/fetch";
import {isIncludeCell} from "./table";
import {getFieldIdByCellElement} from "../render/av/row";
import {processClonePHElement} from "../render/util";
const processAV = (range: Range, html: string, protyle: IProtyle, blockElement: HTMLElement) => {
const tempElement = document.createElement("template");
@ -492,6 +493,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
});
}
if (!hasParentHeading) {
processClonePHElement(item);
if (insertBefore) {
blockElement.before(item);
} else {

View file

@ -78,6 +78,16 @@ export const getContenteditableElement = (element: Element) => {
};
export const isNotEditBlock = (element: Element) => {
if (element.classList.contains("sb")) {
let hasEditable = false;
Array.from(element.querySelectorAll("[data-node-id]")).find(item => {
if (!isNotEditBlock(item)) {
hasEditable = true;
return true;
}
});
return !hasEditable;
}
return ["NodeBlockQueryEmbed", "NodeThematicBreak", "NodeMathBlock", "NodeHTMLBlock", "NodeIFrame", "NodeWidget", "NodeVideo", "NodeAudio"].includes(element.getAttribute("data-type")) ||
(element.getAttribute("data-type") === "NodeCodeBlock" && element.classList.contains("render-node"));
};