瀏覽代碼

:art: https://github.com/siyuan-note/siyuan/issues/5066 openTab

Vanessa 2 年之前
父節點
當前提交
e4b14a12c6

+ 3 - 3
app/src/editor/util.ts

@@ -45,9 +45,6 @@ export const openFileById = async (options: {
             showMessage(data.msg);
             return;
         }
-        if (typeof options.removeCurrentTab === "undefined") {
-            options.removeCurrentTab = true;
-        }
         openFile({
             app: options.app,
             fileName: data.data.rootTitle,
@@ -80,6 +77,9 @@ export const openAsset = (app: App, assetPath: string, page: number | string, po
 };
 
 export const openFile = (options: IOpenFileOptions) => {
+    if (typeof options.removeCurrentTab === "undefined") {
+        options.removeCurrentTab = true;
+    }
     const allModels = getAllModels();
     // 文档已打开
     if (options.assetPath) {

+ 1 - 1
app/src/layout/dock/Outline.ts

@@ -221,7 +221,7 @@ export class Outline extends Model {
                 if (getSelection().rangeCount > 0) {
                     const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
                     if (blockElement && blockElement.getAttribute("data-type") === "NodeHeading") {
-                        this.setCurrent(blockElement)
+                        this.setCurrent(blockElement);
                     }
                 }
             });

+ 19 - 19
app/src/layout/util.ts

@@ -584,43 +584,43 @@ export const resizeTopbar = () => {
     const dragElement = toolbarElement.querySelector("#drag") as HTMLElement;
 
     dragElement.style.padding = "";
-    const barMoreElement = toolbarElement.querySelector("#barMore")
-    barMoreElement.classList.remove("fn__none")
-    barMoreElement.removeAttribute("data-hideids")
+    const barMoreElement = toolbarElement.querySelector("#barMore");
+    barMoreElement.classList.remove("fn__none");
+    barMoreElement.removeAttribute("data-hideids");
 
     Array.from(toolbarElement.querySelectorAll('[data-hide="true"]')).forEach((item) => {
-        item.classList.remove("fn__none")
+        item.classList.remove("fn__none");
         item.removeAttribute("data-hide");
-    })
+    });
 
-    let afterDragElement = dragElement.nextElementSibling
-    const hideIds: string[] = []
+    let afterDragElement = dragElement.nextElementSibling;
+    const hideIds: string[] = [];
     while (toolbarElement.scrollWidth > toolbarElement.clientWidth + 2) {
-        hideIds.push(afterDragElement.id)
-        afterDragElement.classList.add("fn__none")
-        afterDragElement.setAttribute("data-hide", "true")
-        afterDragElement = afterDragElement.nextElementSibling
+        hideIds.push(afterDragElement.id);
+        afterDragElement.classList.add("fn__none");
+        afterDragElement.setAttribute("data-hide", "true");
+        afterDragElement = afterDragElement.nextElementSibling;
         if (afterDragElement.id === "barMore") {
             break;
         }
     }
 
-    let beforeDragElement = dragElement.previousElementSibling
+    let beforeDragElement = dragElement.previousElementSibling;
     while (toolbarElement.scrollWidth > toolbarElement.clientWidth + 2) {
-        hideIds.push(beforeDragElement.id)
-        beforeDragElement.classList.add("fn__none")
-        beforeDragElement.setAttribute("data-hide", "true")
-        beforeDragElement = beforeDragElement.previousElementSibling
+        hideIds.push(beforeDragElement.id);
+        beforeDragElement.classList.add("fn__none");
+        beforeDragElement.setAttribute("data-hide", "true");
+        beforeDragElement = beforeDragElement.previousElementSibling;
         if (beforeDragElement.id === "barWorkspace") {
             break;
         }
     }
     if (hideIds.length > 0) {
-        barMoreElement.classList.remove("fn__none")
+        barMoreElement.classList.remove("fn__none");
     } else {
-        barMoreElement.classList.add("fn__none")
+        barMoreElement.classList.add("fn__none");
     }
-    barMoreElement.setAttribute("data-hideids", hideIds.join(","))
+    barMoreElement.setAttribute("data-hideids", hideIds.join(","));
 
     const width = dragElement.clientWidth;
     const dragRect = dragElement.getBoundingClientRect();

+ 3 - 3
app/src/menus/protyle.ts

@@ -1190,16 +1190,16 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
             }
         });
     }
-    const isPinHead = nodeElement.getAttribute("custom-pinthead")
+    const isPinHead = nodeElement.getAttribute("custom-pinthead");
     menus.push({
         icon: "iconPin",
         label: isPinHead ? window.siyuan.languages.unpinTableHead : window.siyuan.languages.pinTableHead,
         click: () => {
             const html = nodeElement.outerHTML;
             if (isPinHead) {
-                nodeElement.removeAttribute("custom-pinthead")
+                nodeElement.removeAttribute("custom-pinthead");
             } else {
-                nodeElement.setAttribute("custom-pinthead", "true")
+                nodeElement.setAttribute("custom-pinthead", "true");
             }
             updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
         }

+ 1 - 1
app/src/plugin/API.ts

@@ -194,7 +194,7 @@ openTab = (options: {
         return;
     }
 
-}
+};
 /// #endif
 
 export const API = {

+ 1 - 1
app/src/protyle/util/processCode.ts

@@ -34,7 +34,7 @@ export const processPasteCode = (html: string, text: string) => {
             return `<div data-type="NodeCodeBlock" class="code-block" data-node-id="${Lute.NewNodeID()}"><div class="protyle-action"><span class="protyle-action--first protyle-action__language" contenteditable="false">${window.siyuan.storage[Constants.LOCAL_CODELANG]}</span><span class="fn__flex-1"></span><span class="protyle-icon protyle-icon--first protyle-action__copy"><svg><use xlink:href="#iconCopy"></use></svg></span><span class="protyle-icon protyle-icon--last protyle-action__menu"><svg><use xlink:href="#iconMore"></use></svg></span></div><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${code.replace(/&/g, "&amp;").replace(/</g, "&lt;")}<wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
         } else {
             // Paste code from IDE no longer escape `<` and `>` https://github.com/siyuan-note/siyuan/issues/8340
-            code = code.replace("<", "&lt;").replace('>', "&gt;");
+            code = code.replace("<", "&lt;").replace(">", "&gt;");
             return "`" + code + "`";
         }
     }

+ 3 - 0
app/src/search/index.ts

@@ -15,6 +15,9 @@ export class Search extends Model {
             app: options.app,
             id: options.tab.id,
         });
+        if (window.siyuan.config.fileTree.openFilesUseCurrentTab) {
+            options.tab.headElement?.classList.add("item--unupdate");
+        }
         this.element = options.tab.panelElement as HTMLElement;
         this.config = options.config;
         this.edit = genSearch(options.app, this.config, this.element);

+ 1 - 1
app/src/window/init.ts

@@ -66,4 +66,4 @@ const afterLayout = (app:App) => {
         const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
         tab.parent.switchTab(item, false, false);
     });
-}
+};