mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
0d389f3a25
commit
599c90e0a8
5 changed files with 36 additions and 18 deletions
|
|
@ -273,11 +273,13 @@ export class Wnd {
|
|||
return;
|
||||
}
|
||||
|
||||
const nextTabHeaderElement = (Array.from(it.firstElementChild.childNodes).find((item: HTMLElement) => {
|
||||
let nextTabHeaderElement: HTMLElement;
|
||||
Array.from(it.firstElementChild.childNodes).find((item: HTMLElement) => {
|
||||
if (item.style?.opacity === "0.38") {
|
||||
nextTabHeaderElement = item.nextElementSibling as HTMLElement;
|
||||
return true;
|
||||
}
|
||||
}) as HTMLElement)?.nextElementSibling;
|
||||
});
|
||||
|
||||
if (!it.contains(oldTab.headElement)) {
|
||||
// 从其他 Wnd 拖动过来
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ export class Gutter {
|
|||
rowElement.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconCheck");
|
||||
updateHeader(rowElement as HTMLElement);
|
||||
avElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(item => {
|
||||
const groupId = (hasClosestByClassName(item, "av__body") as HTMLElement)?.dataset.groupId || "";
|
||||
const avBodyElement = hasClosestByClassName(item, "av__body") as HTMLElement;
|
||||
const groupId = (avBodyElement ? avBodyElement.dataset.groupId : "") || "";
|
||||
selectIds.push(item.getAttribute("data-id") + (groupId ? "@" + groupId : ""));
|
||||
selectElements.push(item);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,13 +118,13 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||
|
||||
// bq || callout
|
||||
const isCallout = blockElement.parentElement.classList.contains("callout-content");
|
||||
const parentBlockElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement;
|
||||
if (editableElement.textContent.replace(Constants.ZWSP, "").replace("\n", "") === "" &&
|
||||
((blockElement.nextElementSibling && blockElement.nextElementSibling.classList.contains("protyle-attr") &&
|
||||
blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote") ||
|
||||
(isCallout && !blockElement.nextElementSibling))) {
|
||||
range.insertNode(document.createElement("wbr"));
|
||||
const topElement = getTopEmptyElement(blockElement);
|
||||
const parentElement = isCallout ? blockElement.parentElement.parentElement : blockElement.parentElement;
|
||||
const blockId = blockElement.getAttribute("data-node-id");
|
||||
const topId = topElement.getAttribute("data-node-id");
|
||||
const doInsert: IOperation = {
|
||||
|
|
@ -138,9 +138,9 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||
data: topElement.outerHTML,
|
||||
};
|
||||
if (topId === blockId) {
|
||||
doInsert.previousID = parentElement.getAttribute("data-node-id");
|
||||
doInsert.previousID = parentBlockElement.getAttribute("data-node-id");
|
||||
undoInsert.previousID = blockElement.previousElementSibling.getAttribute("data-node-id");
|
||||
parentElement.after(blockElement);
|
||||
parentBlockElement.after(blockElement);
|
||||
} else {
|
||||
doInsert.previousID = topElement.previousElementSibling ? topElement.previousElementSibling.getAttribute("data-node-id") : undefined;
|
||||
doInsert.parentID = topElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID;
|
||||
|
|
@ -156,8 +156,8 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||
action: "delete",
|
||||
id: blockId,
|
||||
}, undoInsert]);
|
||||
if (topId === blockId && parentElement.classList.contains("sb") &&
|
||||
parentElement.getAttribute("data-sb-layout") === "col") {
|
||||
if (topId === blockId && parentBlockElement.classList.contains("sb") &&
|
||||
parentBlockElement.getAttribute("data-sb-layout") === "col") {
|
||||
turnsIntoOneTransaction({
|
||||
protyle,
|
||||
selectsElement: [blockElement.previousElementSibling, blockElement],
|
||||
|
|
@ -197,7 +197,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||
data: newElement.outerHTML,
|
||||
id: newId,
|
||||
previousID: blockElement.previousElementSibling ? blockElement.previousElementSibling.getAttribute("data-node-id") : "",
|
||||
parentID: (hasClosestBlock(blockElement.parentElement) as HTMLElement)?.getAttribute("data-node-id") || protyle.block.parentID
|
||||
parentID: parentBlockElement.getAttribute("data-node-id") || protyle.block.parentID
|
||||
}], [{
|
||||
action: "delete",
|
||||
id: newId,
|
||||
|
|
@ -209,7 +209,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||
}
|
||||
range.insertNode(document.createElement("wbr"));
|
||||
const html = blockElement.outerHTML;
|
||||
const parentHTML = (hasClosestBlock(blockElement.parentElement) as HTMLElement)?.outerHTML;
|
||||
const parentHTML = parentBlockElement.outerHTML;
|
||||
if (range.toString() !== "") {
|
||||
// 选中数学公式后回车取消选中 https://github.com/siyuan-note/siyuan/issues/12637#issuecomment-2381106949
|
||||
const mathElement = hasClosestByAttribute(range.startContainer, "data-type", "inline-math");
|
||||
|
|
@ -347,8 +347,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||
}
|
||||
}
|
||||
transaction(protyle, doOperation, undoOperation);
|
||||
const parentElement = currentElement.parentElement;
|
||||
if (parentElement.classList.contains("sb") && parentElement.getAttribute("data-sb-layout") === "col") {
|
||||
if (currentElement.parentElement.classList.contains("sb") && currentElement.parentElement.getAttribute("data-sb-layout") === "col") {
|
||||
turnsIntoOneTransaction({
|
||||
protyle,
|
||||
selectsElement,
|
||||
|
|
|
|||
|
|
@ -358,7 +358,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
} else if (!selectElements[0].parentElement.classList.contains("protyle-wysiwyg")) {
|
||||
hideElements(["select"], protyle);
|
||||
(hasClosestBlock(selectElements[0].parentElement) as HTMLElement)?.classList.add("protyle-wysiwyg--select");
|
||||
const parentBlockElement = hasClosestBlock(selectElements[0].parentElement);
|
||||
if (parentBlockElement) {
|
||||
parentBlockElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -384,7 +387,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
} else if (!selectLastElement.parentElement.classList.contains("protyle-wysiwyg")) {
|
||||
hideElements(["select"], protyle);
|
||||
(hasClosestBlock(selectLastElement.parentElement) as HTMLElement)?.classList.add("protyle-wysiwyg--select");
|
||||
const parentBlockElement = hasClosestBlock(selectLastElement.parentElement);
|
||||
if (parentBlockElement) {
|
||||
parentBlockElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -409,7 +415,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
} else if (!startEndElement.endElement.parentElement.classList.contains("protyle-wysiwyg")) {
|
||||
hideElements(["select"], protyle);
|
||||
(hasClosestBlock(startEndElement.endElement.parentElement) as HTMLElement)?.classList.add("protyle-wysiwyg--select");
|
||||
const parentBlockElement = hasClosestBlock(startEndElement.endElement.parentElement);
|
||||
if (parentBlockElement) {
|
||||
parentBlockElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
startEndElement.endElement.classList.remove("protyle-wysiwyg--select");
|
||||
|
|
@ -443,7 +452,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (nextElement.getBoundingClientRect().width === 0) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/11194
|
||||
hideElements(["select"], protyle);
|
||||
(hasClosestBlock(startEndElement.endElement.parentElement) as HTMLElement)?.classList.add("protyle-wysiwyg--select");
|
||||
const parentBlockElement = hasClosestBlock(startEndElement.endElement.parentElement);
|
||||
if (parentBlockElement) {
|
||||
parentBlockElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
} else {
|
||||
nextElement.classList.add("protyle-wysiwyg--select");
|
||||
nextElement.setAttribute("select-end", "true");
|
||||
|
|
@ -456,7 +468,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
} else if (!startEndElement.endElement.parentElement.classList.contains("protyle-wysiwyg")) {
|
||||
hideElements(["select"], protyle);
|
||||
(hasClosestBlock(startEndElement.endElement.parentElement) as HTMLElement)?.classList.add("protyle-wysiwyg--select");
|
||||
const parentBlockElement = hasClosestBlock(startEndElement.endElement.parentElement);
|
||||
if (parentBlockElement) {
|
||||
parentBlockElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
startEndElement.endElement.classList.remove("protyle-wysiwyg--select");
|
||||
|
|
|
|||
|
|
@ -126,12 +126,13 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
|
|||
}
|
||||
previousID = unfoldData[foldId].previousID;
|
||||
}
|
||||
const parentElement = hasClosestBlock(topElement.parentElement);
|
||||
inserts.push({
|
||||
action: "insert",
|
||||
data,
|
||||
id,
|
||||
previousID,
|
||||
parentID: (hasClosestBlock(topElement.parentElement) as HTMLElement)?.getAttribute("data-node-id") || protyle.block.parentID
|
||||
parentID: (parentElement ? parentElement.getAttribute("data-node-id") : null) || protyle.block.parentID
|
||||
});
|
||||
if (topElement.getAttribute("data-subtype") === "o" && topElement.classList.contains("li")) {
|
||||
listElement = topElement.parentElement;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue