Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16680

Vanessac03eed504962
diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.ts
index 79a6a3a037..cef6d428c3 100644
--- a/app/src/protyle/wysiwyg/getBlock.ts
+++ b/app/src/protyle/wysiwyg/getBlock.ts
@@ -79,14 +79,29 @@ export const getNoContainerElement = (element: Element) => {
};
export const getContenteditableElement = (element: Element) => {
- if (!element || (element.getAttribute("contenteditable") === "true") && !element.classList.contains("protyle-wysiwyg")) {
+ if (!element) {
return element;
}
- const editableElement = element.querySelector('[contenteditable="true"]');
- if (editableElement && !hasClosestByAttribute(editableElement, "data-type", "NodeBlockQueryEmbed")) {
- return editableElement;
+ let blockElement = element;
+ if (!blockElement.getAttribute("data-node-id")) {
+ blockElement = element.querySelector("[data-node-id]");
+ if (!blockElement) {
+ blockElement = hasClosestBlock(blockElement) as Element;
+ }
+ }
+ if (!blockElement) {
+ return element;
+ }
+ const type = element.getAttribute("data-type");
+ if (["NodeParagraph", "NodeHeading"].includes(type)) {
+ return element.firstElementChild;
+ } else if ("NodeTable" === type) {
+ return element.querySelector("table");
+ } else if ("NodeCodeBlock" === type) {
+ return element.querySelector(".hljs").lastElementChild;
+ } else {
+ return element;
}
- return undefined;
};
export const isNotEditBlock = (element: Element) => {