Ver código fonte

:art: https://github.com/siyuan-note/siyuan/issues/12335

Vanessa 6 meses atrás
pai
commit
b8fda7d67f
2 arquivos alterados com 12 adições e 9 exclusões
  1. 6 6
      app/src/search/toggleHistory.ts
  2. 6 3
      app/src/util/pathName.ts

+ 6 - 6
app/src/search/toggleHistory.ts

@@ -13,7 +13,7 @@ import {inputEvent} from "./util";
 
 
 export const toggleReplaceHistory = (replaceInputElement: HTMLInputElement) => {
 export const toggleReplaceHistory = (replaceInputElement: HTMLInputElement) => {
     const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
     const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
-    if (!list.replaceKeys || list.replaceKeys.length === 0) {
+    if (!list.replaceKeys || list.replaceKeys.length === 0 || (list.length === 1 && list[0] === replaceInputElement.value)) {
         return;
         return;
     }
     }
     const menu = new Menu("search-replace-history");
     const menu = new Menu("search-replace-history");
@@ -79,8 +79,9 @@ export const toggleReplaceHistory = (replaceInputElement: HTMLInputElement) => {
 };
 };
 
 
 export const toggleSearchHistory = (searchElement: Element, config: Config.IUILayoutTabSearchConfig, edit: Protyle) => {
 export const toggleSearchHistory = (searchElement: Element, config: Config.IUILayoutTabSearchConfig, edit: Protyle) => {
+    const searchInputElement = searchElement.querySelector("#searchInput, #toolbarSearch") as HTMLInputElement;
     const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
     const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
-    if (!list.keys || list.keys.length === 0) {
+    if (!list.keys || list.keys.length === 0 || (list.length === 1 && list[0] === searchInputElement.value)) {
         return;
         return;
     }
     }
     const menu = new Menu("search-history");
     const menu = new Menu("search-history");
@@ -98,7 +99,6 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILa
     });
     });
     const separatorElement = menu.addSeparator(1);
     const separatorElement = menu.addSeparator(1);
     let current = true;
     let current = true;
-    const searchInputElement = searchElement.querySelector("#searchInput, #toolbarSearch") as HTMLInputElement;
     list.keys.forEach((s: string) => {
     list.keys.forEach((s: string) => {
         if (s !== searchInputElement.value && s) {
         if (s !== searchInputElement.value && s) {
             const menuItem = menu.addItem({
             const menuItem = menu.addItem({
@@ -153,8 +153,9 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILa
 };
 };
 
 
 export const toggleAssetHistory = (assetElement: Element) => {
 export const toggleAssetHistory = (assetElement: Element) => {
+    const assetInputElement = assetElement.querySelector("#searchAssetInput") as HTMLInputElement;
     const keys = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].keys;
     const keys = window.siyuan.storage[Constants.LOCAL_SEARCHASSET].keys;
-    if (!keys || keys.length === 0) {
+    if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === assetInputElement.value)) {
         return;
         return;
     }
     }
     const menu = new Menu("search-asset-history");
     const menu = new Menu("search-asset-history");
@@ -172,7 +173,6 @@ export const toggleAssetHistory = (assetElement: Element) => {
     });
     });
     const separatorElement = menu.addSeparator(1);
     const separatorElement = menu.addSeparator(1);
     let current = true;
     let current = true;
-    const assetInputElement = assetElement.querySelector("#searchAssetInput") as HTMLInputElement;
     keys.forEach((s: string) => {
     keys.forEach((s: string) => {
         if (s !== assetInputElement.value && s) {
         if (s !== assetInputElement.value && s) {
             const menuItem = menu.addItem({
             const menuItem = menu.addItem({
@@ -233,7 +233,7 @@ export const saveKeyList = (type: "keys" | "replaceKeys", value: string) => {
     setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
     setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
 };
 };
 
 
-export const saveAssetKeyList = (inputElement:HTMLInputElement) => {
+export const saveAssetKeyList = (inputElement: HTMLInputElement) => {
     if (!inputElement.value) {
     if (!inputElement.value) {
         return;
         return;
     }
     }

+ 6 - 3
app/src/util/pathName.ts

@@ -154,8 +154,10 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
         return;
         return;
     }
     }
     const dialog = new Dialog({
     const dialog = new Dialog({
-        title: `${title || window.siyuan.languages.move}
-<div style="max-height: 16px;overflow: auto;line-height: 14px;-webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0, #000 6px);padding-bottom: 4px;margin-bottom: -4px" class="ft__smaller ft__on-surface fn__hidescrollbar"></div>`,
+        title: `<div style="padding: 8px;">
+    ${title || window.siyuan.languages.move}
+    <div style="max-height: 16px;overflow: auto;line-height: 14px;-webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0, #000 6px);padding-bottom: 4px;margin-bottom: -4px" class="ft__smaller ft__on-surface fn__hidescrollbar"></div>
+</div>`,
         content: `<div class="b3-form__icon" style="margin: 8px">
         content: `<div class="b3-form__icon" style="margin: 8px">
     <span data-menu="true" class="b3-form__icon-list fn__a b3-tooltips b3-tooltips__s" aria-label="${updateHotkeyTip("⌥↓")}">
     <span data-menu="true" class="b3-form__icon-list fn__a b3-tooltips b3-tooltips__s" aria-label="${updateHotkeyTip("⌥↓")}">
         <svg class="svg--mid"><use xlink:href="#iconSearch"></use></svg>
         <svg class="svg--mid"><use xlink:href="#iconSearch"></use></svg>
@@ -178,6 +180,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
             }
             }
         }
         }
     });
     });
+    dialog.element.querySelector(".b3-dialog__header").setAttribute("style", "padding:0");
     dialog.element.setAttribute("data-key", Constants.DIALOG_MOVEPATHTO);
     dialog.element.setAttribute("data-key", Constants.DIALOG_MOVEPATHTO);
     if (paths && paths.length > 0) {
     if (paths && paths.length > 0) {
         fetchPost("/api/filetree/getHPathsByPaths", {paths}, (response) => {
         fetchPost("/api/filetree/getHPathsByPaths", {paths}, (response) => {
@@ -260,7 +263,7 @@ export const movePathTo = (cb: (toPath: string[], toNotebook: string[]) => void,
 
 
     const toggleMovePathHistory = () => {
     const toggleMovePathHistory = () => {
         const keys = window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys;
         const keys = window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys;
-        if (!keys || keys.length === 0) {
+        if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === inputElement.value)) {
             return;
             return;
         }
         }
         const menu = new Menu("move-path-history");
         const menu = new Menu("move-path-history");