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_EXPORTPDF = "local-exportpdf";
|
||||||
public static readonly LOCAL_EXPORTWORD = "local-exportword";
|
public static readonly LOCAL_EXPORTWORD = "local-exportword";
|
||||||
public static readonly LOCAL_BAZAAR = "local-bazaar";
|
public static readonly LOCAL_BAZAAR = "local-bazaar";
|
||||||
|
public static readonly LOCAL_PANEL = "local-panel";
|
||||||
|
|
||||||
// timeout
|
// timeout
|
||||||
public static readonly TIMEOUT_DBLCLICK = 190;
|
public static readonly TIMEOUT_DBLCLICK = 190;
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,8 @@ export const exportLayout = (reload: boolean, cb?: () => void) => {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO save panel
|
||||||
};
|
};
|
||||||
|
|
||||||
const JSONToDock = (json: any) => {
|
const JSONToDock = (json: any) => {
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,10 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
|
||||||
if (topSourceElement.isSameNode(item)) {
|
if (topSourceElement.isSameNode(item)) {
|
||||||
topSourceElement = undefined;
|
topSourceElement = undefined;
|
||||||
}
|
}
|
||||||
|
if (topSourceElement.contains(item) && topSourceElement.contains(targetElement)) {
|
||||||
|
// * * 1 列表项拖拽到父级列表项下 https://ld246.com/article/1665448570858
|
||||||
|
topSourceElement = targetElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
action: "move",
|
action: "move",
|
||||||
|
|
@ -381,6 +385,10 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
|
||||||
if (topSourceElement.isSameNode(item)) {
|
if (topSourceElement.isSameNode(item)) {
|
||||||
topSourceElement = undefined;
|
topSourceElement = undefined;
|
||||||
}
|
}
|
||||||
|
if (topSourceElement.contains(item) && topSourceElement.contains(targetElement)) {
|
||||||
|
// * * 1 列表项拖拽到父级列表项上 https://ld246.com/article/1665448570858
|
||||||
|
topSourceElement = targetElement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
undoOperations.push({
|
undoOperations.push({
|
||||||
action: "move",
|
action: "move",
|
||||||
|
|
@ -621,7 +629,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
// 反链提及有高亮,如果拖拽到正文的话,应移除
|
// 反链提及有高亮,如果拖拽到正文的话,应移除
|
||||||
item.querySelectorAll('[data-type="search-mark"]').forEach(markItem => {
|
item.querySelectorAll('[data-type="search-mark"]').forEach(markItem => {
|
||||||
markItem.outerHTML = markItem.innerHTML;
|
markItem.outerHTML = markItem.innerHTML;
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
if (event.altKey) {
|
if (event.altKey) {
|
||||||
focusByRange(document.caretRangeFromPoint(event.clientX, event.clientY));
|
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);
|
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) => {
|
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;
|
const tbodyElement = cellElement.parentElement.parentElement;
|
||||||
let previousTrElement = tbodyElement.previousElementSibling.lastElementChild as HTMLTableRowElement;
|
let previousTrElement = tbodyElement.previousElementSibling.lastElementChild as HTMLTableRowElement;
|
||||||
if (cellElement.parentElement.previousElementSibling) {
|
if (cellElement.parentElement.previousElementSibling) {
|
||||||
previousTrElement = cellElement.parentElement.previousElementSibling as HTMLTableRowElement
|
previousTrElement = cellElement.parentElement.previousElementSibling as HTMLTableRowElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tbodyElement.childElementCount === 1) {
|
if (tbodyElement.childElementCount === 1) {
|
||||||
|
|
@ -208,7 +208,7 @@ export const deleteColumn = (protyle: IProtyle, range: Range, nodeElement: Eleme
|
||||||
const html = nodeElement.outerHTML;
|
const html = nodeElement.outerHTML;
|
||||||
wbrElement.remove();
|
wbrElement.remove();
|
||||||
const index = getColIndex(cellElement);
|
const index = getColIndex(cellElement);
|
||||||
const sideCellElement = (cellElement.previousElementSibling || cellElement.nextElementSibling) as HTMLElement
|
const sideCellElement = (cellElement.previousElementSibling || cellElement.nextElementSibling) as HTMLElement;
|
||||||
if (sideCellElement) {
|
if (sideCellElement) {
|
||||||
range.selectNodeContents(sideCellElement);
|
range.selectNodeContents(sideCellElement);
|
||||||
range.collapse(true);
|
range.collapse(true);
|
||||||
|
|
|
||||||
|
|
@ -447,16 +447,10 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (operation.action === "move") {
|
if (operation.action === "move") {
|
||||||
let cloneRange;
|
|
||||||
let range;
|
let range;
|
||||||
if (focus && getSelection().rangeCount > 0) {
|
if (focus && getSelection().rangeCount > 0) {
|
||||||
range = getSelection().getRangeAt(0);
|
range = getSelection().getRangeAt(0);
|
||||||
cloneRange = {
|
range.insertNode(document.createElement("wbr"))
|
||||||
startContainer: range.startContainer,
|
|
||||||
startOffset: range.startOffset,
|
|
||||||
endContainer: range.endContainer,
|
|
||||||
endOffset: range.endOffset,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
if (updateElements.length === 0) {
|
if (updateElements.length === 0) {
|
||||||
|
|
@ -502,13 +496,17 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
||||||
removeTopElement(item, protyle);
|
removeTopElement(item, protyle);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (focus && cloneRange && range) {
|
if (focus && range) {
|
||||||
if (operation.data === "focus") {
|
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 {
|
} else {
|
||||||
range.setStart(cloneRange.startContainer, cloneRange.startOffset);
|
focusByWbr(protyle.wysiwyg.element, range);
|
||||||
range.setEnd(cloneRange.endContainer, cloneRange.endOffset);
|
|
||||||
focusByRange(range);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 更新 ws 嵌入块
|
// 更新 ws 嵌入块
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue