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"; import {escapeHtml} from "../util/escape";
/// #if !MOBILE /// #if !MOBILE
import {openFile} from "../editor/util"; import {openFile} from "../editor/util";
import {newCardModel} from "./newCardTab";
/// #endif /// #endif
import {getDisplayName, movePathTo} from "../util/pathName"; import {getDisplayName, movePathTo} from "../util/pathName";
import {App} from "../index"; import {App} from "../index";

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -159,8 +159,8 @@ export const getLocalStorage = (cb: () => void) => {
k: "", k: "",
}; };
Constants.SIYUAN_ASSETS_SEARCH.forEach(type => { Constants.SIYUAN_ASSETS_SEARCH.forEach(type => {
defaultStorage[Constants.LOCAL_SEARCHASSET].types[type] = true defaultStorage[Constants.LOCAL_SEARCHASSET].types[type] = true;
}) });
defaultStorage[Constants.LOCAL_SEARCHKEYS] = { defaultStorage[Constants.LOCAL_SEARCHKEYS] = {
keys: [], keys: [],
replaceKeys: [], 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.remove();
window.siyuan.menus.menu.element.setAttribute("data-name", "searchAssetMore"); 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 = [{ const sortMenu = [{
iconHTML: Constants.ZWSP, iconHTML: Constants.ZWSP,
label: window.siyuan.languages.sortByRankAsc, label: window.siyuan.languages.sortByRankAsc,
@ -457,7 +457,7 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
current: localData.layout === 0, current: localData.layout === 0,
click() { click() {
element.querySelector(".search__layout").classList.remove("search__layout--row"); 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 = ""; previewElement.style.width = "";
if (localData.row) { if (localData.row) {
previewElement.style.height = 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, label: window.siyuan.languages.leftRightLayout,
current: localData.layout === 1, current: localData.layout === 1,
click() { click() {
const previewElement = element.querySelector("#searchAssetPreview") as HTMLElement const previewElement = element.querySelector("#searchAssetPreview") as HTMLElement;
element.querySelector(".search__layout").classList.add("search__layout--row"); element.querySelector(".search__layout").classList.add("search__layout--row");
previewElement.style.height = ""; previewElement.style.height = "";
if (localData.col) { if (localData.col) {
previewElement.style.width = localData.col previewElement.style.width = localData.col;
previewElement.classList.remove("fn__flex-1"); previewElement.classList.remove("fn__flex-1");
} else { } else {
previewElement.classList.add("fn__flex-1"); previewElement.classList.add("fn__flex-1");
@ -493,10 +493,10 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
click() { click() {
element.nextElementSibling.classList.remove("fn__none"); element.nextElementSibling.classList.remove("fn__none");
fetchPost("/api/asset/fullReindexAssetContent", {}, () => { fetchPost("/api/asset/fullReindexAssetContent", {}, () => {
assetInputEvent(element, localData) assetInputEvent(element, localData);
}); });
}, },
}).element); }).element);
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); 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, () => { assetMoreMenu(target, assetsElement, () => {
assetInputEvent(assetsElement); assetInputEvent(assetsElement);
setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]); setStorageVal(Constants.LOCAL_SEARCHASSET, window.siyuan.storage[Constants.LOCAL_SEARCHASSET]);
}) });
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;