mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
2ec4cf8fb8
commit
6fd5bef8ac
5 changed files with 25 additions and 16 deletions
|
|
@ -69,6 +69,7 @@ export abstract class Constants {
|
|||
public static readonly LOCAL_EXPORTPDF = "local-exportpdf";
|
||||
public static readonly LOCAL_EXPORTWORD = "local-exportword";
|
||||
public static readonly LOCAL_BAZAAR = "local-bazaar";
|
||||
public static readonly LOCAL_PANEL = "local-panel";
|
||||
|
||||
// timeout
|
||||
public static readonly TIMEOUT_DBLCLICK = 190;
|
||||
|
|
|
|||
|
|
@ -148,6 +148,8 @@ export const exportLayout = (reload: boolean, cb?: () => void) => {
|
|||
cb();
|
||||
}
|
||||
});
|
||||
|
||||
// TODO save panel
|
||||
};
|
||||
|
||||
const JSONToDock = (json: any) => {
|
||||
|
|
|
|||
|
|
@ -309,6 +309,10 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
|
|||
if (topSourceElement.isSameNode(item)) {
|
||||
topSourceElement = undefined;
|
||||
}
|
||||
if (topSourceElement.contains(item) && topSourceElement.contains(targetElement)) {
|
||||
// * * 1 列表项拖拽到父级列表项下 https://ld246.com/article/1665448570858
|
||||
topSourceElement = targetElement;
|
||||
}
|
||||
}
|
||||
undoOperations.push({
|
||||
action: "move",
|
||||
|
|
@ -381,6 +385,10 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
|
|||
if (topSourceElement.isSameNode(item)) {
|
||||
topSourceElement = undefined;
|
||||
}
|
||||
if (topSourceElement.contains(item) && topSourceElement.contains(targetElement)) {
|
||||
// * * 1 列表项拖拽到父级列表项上 https://ld246.com/article/1665448570858
|
||||
topSourceElement = targetElement;
|
||||
}
|
||||
}
|
||||
undoOperations.push({
|
||||
action: "move",
|
||||
|
|
@ -621,7 +629,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
// 反链提及有高亮,如果拖拽到正文的话,应移除
|
||||
item.querySelectorAll('[data-type="search-mark"]').forEach(markItem => {
|
||||
markItem.outerHTML = markItem.innerHTML;
|
||||
})
|
||||
});
|
||||
});
|
||||
if (event.altKey) {
|
||||
focusByRange(document.caretRangeFromPoint(event.clientX, event.clientY));
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export const setTableAlign = (protyle: IProtyle, cellElements: HTMLElement[], no
|
|||
});
|
||||
}
|
||||
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
|
||||
focusByWbr(tableElement, range)
|
||||
focusByWbr(tableElement, range);
|
||||
};
|
||||
|
||||
export const insertRow = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element) => {
|
||||
|
|
@ -186,7 +186,7 @@ export const deleteRow = (protyle: IProtyle, range: Range, cellElement: HTMLElem
|
|||
const tbodyElement = cellElement.parentElement.parentElement;
|
||||
let previousTrElement = tbodyElement.previousElementSibling.lastElementChild as HTMLTableRowElement;
|
||||
if (cellElement.parentElement.previousElementSibling) {
|
||||
previousTrElement = cellElement.parentElement.previousElementSibling as HTMLTableRowElement
|
||||
previousTrElement = cellElement.parentElement.previousElementSibling as HTMLTableRowElement;
|
||||
}
|
||||
|
||||
if (tbodyElement.childElementCount === 1) {
|
||||
|
|
@ -208,7 +208,7 @@ export const deleteColumn = (protyle: IProtyle, range: Range, nodeElement: Eleme
|
|||
const html = nodeElement.outerHTML;
|
||||
wbrElement.remove();
|
||||
const index = getColIndex(cellElement);
|
||||
const sideCellElement = (cellElement.previousElementSibling || cellElement.nextElementSibling) as HTMLElement
|
||||
const sideCellElement = (cellElement.previousElementSibling || cellElement.nextElementSibling) as HTMLElement;
|
||||
if (sideCellElement) {
|
||||
range.selectNodeContents(sideCellElement);
|
||||
range.collapse(true);
|
||||
|
|
|
|||
|
|
@ -447,16 +447,10 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
return;
|
||||
}
|
||||
if (operation.action === "move") {
|
||||
let cloneRange;
|
||||
let range;
|
||||
if (focus && getSelection().rangeCount > 0) {
|
||||
range = getSelection().getRangeAt(0);
|
||||
cloneRange = {
|
||||
startContainer: range.startContainer,
|
||||
startOffset: range.startOffset,
|
||||
endContainer: range.endContainer,
|
||||
endOffset: range.endOffset,
|
||||
};
|
||||
range.insertNode(document.createElement("wbr"))
|
||||
}
|
||||
/// #if !MOBILE
|
||||
if (updateElements.length === 0) {
|
||||
|
|
@ -502,13 +496,17 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
removeTopElement(item, protyle);
|
||||
}
|
||||
});
|
||||
if (focus && cloneRange && range) {
|
||||
if (focus && range) {
|
||||
if (operation.data === "focus") {
|
||||
focusBlock(updateElements[0]);
|
||||
// 标记需要 focus,https://ld246.com/article/1650018446988/comment/1650081404993?r=Vanessa#comments
|
||||
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`)).find(item => {
|
||||
if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {
|
||||
focusBlock(item);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
range.setStart(cloneRange.startContainer, cloneRange.startOffset);
|
||||
range.setEnd(cloneRange.endContainer, cloneRange.endOffset);
|
||||
focusByRange(range);
|
||||
focusByWbr(protyle.wysiwyg.element, range);
|
||||
}
|
||||
}
|
||||
// 更新 ws 嵌入块
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue