This commit is contained in:
Vanessa 2023-08-18 20:03:04 +08:00
parent 798a2970f9
commit 4406dc687b
9 changed files with 22 additions and 21 deletions

View file

@ -12,7 +12,6 @@ import {MenuItem} from "../menus/Menu";
import {escapeHtml} from "../util/escape";
/// #if !MOBILE
import {openFile} from "../editor/util";
import {newCardModel} from "./newCardTab";
/// #endif
import {getDisplayName, movePathTo} from "../util/pathName";
import {App} from "../index";

View file

@ -15,6 +15,7 @@ import {onGet} from "../protyle/util/onGet";
/// #if !BROWSER
import {shell} from "electron";
import {BrowserWindow, getCurrentWindow} from "@electron/remote";
import {newCardModel} from "../card/newCardTab";
/// #endif
import {pushBack} from "../util/backForward";
import {Asset} from "../asset";
@ -28,7 +29,6 @@ import {objEquals} from "../util/functions";
import {resize} from "../protyle/util/resize";
import {Search} from "../search";
import {App} from "../index";
import {newCardModel} from "../card/newCardTab";
export const openFileById = async (options: {
app: App,
@ -444,7 +444,7 @@ const newTab = (options: IOpenFileOptions) => {
}));
return true;
}
})
});
}
} else {
// plugin 0.8.3 历史兼容

View file

@ -118,4 +118,4 @@ export const toggleDockBar = (useElement:Element)=> {
});
resizeTabs();
resetFloatDockSize();
}
};

View file

@ -1,5 +1,5 @@
/// #if !MOBILE
import {getDockByType, resizeTabs} from "./util";
import {getDockByType} from "./util";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {fetchPost} from "../util/fetch";
import {mountHelp} from "../util/mount";

View file

@ -308,7 +308,7 @@ export const bindMenuKeydown = (event: KeyboardEvent) => {
if (!currentElement) {
return true;
}
const parentItemElement = hasClosestByClassName(currentElement, "b3-menu__item--show")
const parentItemElement = hasClosestByClassName(currentElement, "b3-menu__item--show");
if (parentItemElement) {
parentItemElement.classList.remove("b3-menu__item--show");
parentItemElement.classList.add("b3-menu__item--current");

View file

@ -4,13 +4,13 @@ import {fetchPost} from "../util/fetch";
import {isMobile, isWindow} from "../util/functions";
/// #if !MOBILE
import {Custom} from "../layout/dock/Custom";
import {getAllModels} from "../layout/getAll";
/// #endif
import {Tab} from "../layout/Tab";
import {getDockByType, setPanelFocus} from "../layout/util";
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
import {BlockPanel} from "../block/Panel";
import {Setting} from "./Setting";
import {getAllModels} from "../layout/getAll";
export class Plugin {
private app: App;
@ -182,16 +182,18 @@ export class Plugin {
}
public getOpenedTab() {
const tabs: { [key: string]: Custom[] } = {}
const modelKeys = Object.keys(this.models)
const tabs: { [key: string]: Custom[] } = {};
const modelKeys = Object.keys(this.models);
modelKeys.forEach(item => {
tabs[item.replace(this.name, "")] = []
})
tabs[item.replace(this.name, "")] = [];
});
/// #if !MOBILE
getAllModels().custom.find(item => {
if (modelKeys.includes(item.type)) {
tabs[item.type.replace(this.name, "")].push(item);
}
})
});
/// #endif
return tabs;
}

View file

@ -159,8 +159,8 @@ export const getLocalStorage = (cb: () => void) => {
k: "",
};
Constants.SIYUAN_ASSETS_SEARCH.forEach(type => {
defaultStorage[Constants.LOCAL_SEARCHASSET].types[type] = true
})
defaultStorage[Constants.LOCAL_SEARCHASSET].types[type] = true;
});
defaultStorage[Constants.LOCAL_SEARCHKEYS] = {
keys: [],
replaceKeys: [],

View file

@ -407,7 +407,7 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
}
window.siyuan.menus.menu.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchAssetMore");
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHASSET]
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHASSET];
const sortMenu = [{
iconHTML: Constants.ZWSP,
label: window.siyuan.languages.sortByRankAsc,
@ -457,7 +457,7 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
current: localData.layout === 0,
click() {
element.querySelector(".search__layout").classList.remove("search__layout--row");
const previewElement = element.querySelector("#searchAssetPreview") as HTMLElement
const previewElement = element.querySelector("#searchAssetPreview") as HTMLElement;
previewElement.style.width = "";
if (localData.row) {
previewElement.style.height = localData.row;
@ -473,11 +473,11 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
label: window.siyuan.languages.leftRightLayout,
current: localData.layout === 1,
click() {
const previewElement = element.querySelector("#searchAssetPreview") as HTMLElement
const previewElement = element.querySelector("#searchAssetPreview") as HTMLElement;
element.querySelector(".search__layout").classList.add("search__layout--row");
previewElement.style.height = "";
if (localData.col) {
previewElement.style.width = localData.col
previewElement.style.width = localData.col;
previewElement.classList.remove("fn__flex-1");
} else {
previewElement.classList.add("fn__flex-1");
@ -493,10 +493,10 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
click() {
element.nextElementSibling.classList.remove("fn__none");
fetchPost("/api/asset/fullReindexAssetContent", {}, () => {
assetInputEvent(element, localData)
assetInputEvent(element, localData);
});
},
}).element);
const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true);
}
};

View file

@ -640,7 +640,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
assetMoreMenu(target, assetsElement, () => {
assetInputEvent(assetsElement);
setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
})
});
event.stopPropagation();
event.preventDefault();
break;