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