mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
🚨
This commit is contained in:
parent
d650696409
commit
87a5ce001f
4 changed files with 29 additions and 31 deletions
|
|
@ -239,7 +239,7 @@ const setHTML = (options: {
|
|||
/// #endif
|
||||
}
|
||||
if (options.isSyncing) {
|
||||
disabledForeverProtyle(protyle)
|
||||
disabledForeverProtyle(protyle);
|
||||
} else {
|
||||
if (protyle.disabled) {
|
||||
disabledProtyle(protyle);
|
||||
|
|
@ -288,10 +288,10 @@ const setHTML = (options: {
|
|||
export const disabledForeverProtyle = (protyle: IProtyle) => {
|
||||
disabledProtyle(protyle);
|
||||
if (protyle.breadcrumb) {
|
||||
protyle.breadcrumb.element.querySelector(".b3-button").textContent = window.siyuan.languages["_kernel"][81]
|
||||
protyle.breadcrumb.element.querySelector(".b3-button").textContent = window.siyuan.languages["_kernel"][81];
|
||||
}
|
||||
protyle.element.setAttribute("disabled-forever", "true");
|
||||
}
|
||||
};
|
||||
|
||||
/** 禁用编辑器 */
|
||||
export const disabledProtyle = (protyle: IProtyle) => {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export const upSelect = (options: {
|
|||
countBlockWord(ids, options.protyle.block.rootID);
|
||||
options.event.stopPropagation();
|
||||
options.event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
export const downSelect = (options: {
|
||||
protyle: IProtyle,
|
||||
|
|
@ -153,7 +153,7 @@ export const downSelect = (options: {
|
|||
if (selectElements.length === 0) {
|
||||
options.nodeElement.classList.add("protyle-wysiwyg--select");
|
||||
} else {
|
||||
options.cb(selectElements)
|
||||
options.cb(selectElements);
|
||||
}
|
||||
const ids: string[] = [];
|
||||
options.protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => {
|
||||
|
|
@ -162,29 +162,29 @@ export const downSelect = (options: {
|
|||
countBlockWord(ids, options.protyle.block.rootID);
|
||||
options.event.stopPropagation();
|
||||
options.event.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
export const getStartEndElement = (selectElements: NodeListOf<Element>) => {
|
||||
let startElement
|
||||
let endElement
|
||||
let startElement;
|
||||
let endElement;
|
||||
selectElements.forEach(item => {
|
||||
if (item.getAttribute("select-start")) {
|
||||
startElement = item
|
||||
startElement = item;
|
||||
}
|
||||
if (item.getAttribute("select-end")) {
|
||||
endElement = item
|
||||
endElement = item;
|
||||
}
|
||||
});
|
||||
if (!startElement) {
|
||||
startElement = selectElements[0]
|
||||
startElement.setAttribute("select-start", "true")
|
||||
startElement = selectElements[0];
|
||||
startElement.setAttribute("select-start", "true");
|
||||
}
|
||||
if (!endElement) {
|
||||
endElement = selectElements[selectElements.length - 1]
|
||||
endElement.setAttribute("select-end", "true")
|
||||
endElement = selectElements[selectElements.length - 1];
|
||||
endElement.setAttribute("select-end", "true");
|
||||
}
|
||||
return {
|
||||
startElement,
|
||||
endElement
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import {
|
|||
getEditorRange,
|
||||
getSelectionOffset, getSelectionPosition,
|
||||
selectAll,
|
||||
setFirstNodeRange,
|
||||
setLastNodeRange
|
||||
} from "../util/selection";
|
||||
import {
|
||||
hasClosestBlock,
|
||||
|
|
@ -292,8 +290,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (previousElement && previousElement.getAttribute("data-node-id")) {
|
||||
previousElement.classList.add("protyle-wysiwyg--select");
|
||||
selectElements.forEach(item => {
|
||||
item.removeAttribute("select-end")
|
||||
})
|
||||
item.removeAttribute("select-end");
|
||||
});
|
||||
previousElement.setAttribute("select-end", "true");
|
||||
const top = previousElement.getBoundingClientRect().top - protyle.contentElement.getBoundingClientRect().top;
|
||||
if (top < 0) {
|
||||
|
|
@ -318,8 +316,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (nextElement && nextElement.getAttribute("data-node-id")) {
|
||||
nextElement.classList.add("protyle-wysiwyg--select");
|
||||
selectElements.forEach(item => {
|
||||
item.removeAttribute("select-end")
|
||||
})
|
||||
item.removeAttribute("select-end");
|
||||
});
|
||||
nextElement.setAttribute("select-end", "true");
|
||||
const bottom = nextElement.getBoundingClientRect().bottom - protyle.contentElement.getBoundingClientRect().bottom;
|
||||
if (bottom > 0) {
|
||||
|
|
@ -331,7 +329,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
selectLastElement.parentElement.classList.add("protyle-wysiwyg--select");
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +337,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
upSelect({
|
||||
protyle, event, nodeElement, editorElement, range,
|
||||
cb(selectElements) {
|
||||
const startEndElement = getStartEndElement(selectElements)
|
||||
const startEndElement = getStartEndElement(selectElements);
|
||||
if (startEndElement.startElement.getBoundingClientRect().top >= startEndElement.endElement.getBoundingClientRect().top) {
|
||||
const previousElement = startEndElement.endElement.previousElementSibling as HTMLElement;
|
||||
if (previousElement && previousElement.getAttribute("data-node-id")) {
|
||||
|
|
@ -360,11 +358,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
startEndElement.endElement.removeAttribute("select-end");
|
||||
const previousElement = getPreviousBlock(startEndElement.endElement);
|
||||
if (previousElement) {
|
||||
previousElement.setAttribute("select-end", "true")
|
||||
previousElement.setAttribute("select-end", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +370,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
downSelect({
|
||||
protyle, event, nodeElement, editorElement, range,
|
||||
cb(selectElements) {
|
||||
const startEndElement = getStartEndElement(selectElements)
|
||||
const startEndElement = getStartEndElement(selectElements);
|
||||
if (startEndElement.startElement.getBoundingClientRect().top <= startEndElement.endElement.getBoundingClientRect().top) {
|
||||
const nextElement = startEndElement.endElement.nextElementSibling as HTMLElement;
|
||||
if (nextElement && nextElement.getAttribute("data-node-id")) {
|
||||
|
|
@ -393,11 +391,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
startEndElement.endElement.removeAttribute("select-end");
|
||||
const nextElement = getNextBlock(startEndElement.endElement);
|
||||
if (nextElement) {
|
||||
nextElement.setAttribute("select-end", "true")
|
||||
nextElement.setAttribute("select-end", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -743,8 +743,8 @@ export const turnsIntoTransaction = (options: {
|
|||
setFold(options.protyle, item);
|
||||
}
|
||||
item.classList.remove("protyle-wysiwyg--select");
|
||||
item.removeAttribute("select-start")
|
||||
item.removeAttribute("select-end")
|
||||
item.removeAttribute("select-start");
|
||||
item.removeAttribute("select-end");
|
||||
html += item.outerHTML;
|
||||
const id = item.getAttribute("data-node-id");
|
||||
undoOperations.push({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue