mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-19 23:06:09 +01:00
This commit is contained in:
parent
74195b70eb
commit
c03eed5049
1 changed files with 20 additions and 5 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue