diff --git a/app/src/constants.ts b/app/src/constants.ts index 04d0d448e..db0661269 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -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; diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index b01d53ab1..33759d790 100644 --- a/app/src/layout/util.ts +++ b/app/src/layout/util.ts @@ -148,6 +148,8 @@ export const exportLayout = (reload: boolean, cb?: () => void) => { cb(); } }); + + // TODO save panel }; const JSONToDock = (json: any) => { diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index ab9102010..bb540976c 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -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)); diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts index 556aaa0cb..bb1578b8b 100644 --- a/app/src/protyle/util/table.ts +++ b/app/src/protyle/util/table.ts @@ -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); diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 94d45b961..ab4f027fd 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -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 嵌入块