This commit is contained in:
Vanessa 2023-11-02 11:20:47 +08:00
parent 05a4fc839e
commit 9736ed09f5
7 changed files with 31 additions and 33 deletions

View file

@ -28,7 +28,7 @@ export const initBlockPopover = (app: App) => {
if (aElement.classList.contains("av__celltext")) {
if (aElement.scrollWidth > aElement.parentElement.clientWidth - 11) {
if (aElement.querySelector(".av__cellicon")) {
tip = `${aElement.firstChild.textContent} ➡️ ${aElement.lastChild.textContent}`
tip = `${aElement.firstChild.textContent} ➡️ ${aElement.lastChild.textContent}`;
} else {
tip = aElement.textContent;
}

View file

@ -25,16 +25,16 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
if (hasClosestByClassName(range.startContainer, "protyle", true)) {
return false;
}
let element: HTMLElement
let dialog: Dialog
let edit
let config: ISearchOption
let element: HTMLElement;
let dialog: Dialog;
let edit;
let config: ISearchOption;
window.siyuan.dialogs.find((item) => {
if (item.element.contains(range.startContainer) && item.element.querySelector("#searchList")) {
element = item.element.querySelector(".b3-dialog__body");
dialog = item
config = dialog.data
edit = dialog.editor
dialog = item;
config = dialog.data;
edit = dialog.editor;
return true;
}
});
@ -43,7 +43,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
if (item.element.contains(range.startContainer)) {
element = item.element;
edit = item.edit;
config = item.config
config = item.config;
return true;
}
});
@ -52,7 +52,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
return false;
}
const assetsElement = element.querySelector("#searchAssets");
const isAsset = !assetsElement.classList.contains("fn__none")
const isAsset = !assetsElement.classList.contains("fn__none");
const listElement = isAsset ? assetsElement.querySelector("#searchAssetList") : element.querySelector("#searchList");
let currentList: HTMLElement = listElement.querySelector(".b3-list-item--focus");
if (!currentList) {
@ -63,7 +63,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
newFileByName(app, searchInputElement.value);
return true;
}
const targetId = (event.target as HTMLElement).id
const targetId = (event.target as HTMLElement).id;
const historyElement = element.querySelector("#searchHistoryList");
const replaceHistoryElement = element.querySelector("#replaceHistoryList");
const replaceInputElement = element.querySelector("#replaceInput") as HTMLInputElement;
@ -82,14 +82,14 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
}
return true;
}
const assetLocal = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] as ISearchAssetOption
const assetLocal = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] as ISearchAssetOption;
let history;
if (!historyElement.classList.contains("fn__none")) {
history = "history"
history = "history";
} else if (!replaceHistoryElement.classList.contains("fn__none")) {
history = "replaceHistory"
history = "replaceHistory";
} else if (isAsset && !assetHistoryElement.classList.contains("fn__none")) {
history = "assetHistory"
history = "assetHistory";
}
if (history) {
if (event.key === "Escape") {
@ -155,7 +155,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
});
return true;
}
const id = currentList.getAttribute("data-node-id")
const id = currentList.getAttribute("data-node-id");
if (matchHotKey("⌘/", event)) {
const currentRect = currentList.getBoundingClientRect();
initSearchMenu(id).popup({
@ -215,12 +215,12 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
}
}
}
return true
return true;
}
if (Constants.KEYCODELIST[event.keyCode] === "PageDown") {
if (isAsset) {
if (!assetsElement.querySelector('[data-type="assetNext"]').getAttribute("disabled")) {
const assetPages = assetsElement.querySelector("#searchAssetResult .fn__flex-center").textContent.split("/")
const assetPages = assetsElement.querySelector("#searchAssetResult .fn__flex-center").textContent.split("/");
let currentPage = parseInt(assetPages[0]);
if (currentPage < parseInt(assetPages[1])) {
currentPage++;
@ -236,7 +236,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
}
}
}
return true
return true;
}
if (!window.siyuan.menus.menu.element.classList.contains("fn__none")) {
return false;
@ -298,7 +298,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
edit,
});
}
return true
return true;
}
if (event.key === "ArrowUp") {
currentList.classList.remove("b3-list-item--focus");

View file

@ -131,7 +131,7 @@ export const bindCardEvent = (options: {
}
let index = 0;
if (typeof options.index === "number") {
index = options.index
index = options.index;
}
const editor = new Protyle(options.app, options.element.querySelector("[data-type='render']") as HTMLElement, {
blockId: "",

View file

@ -2,7 +2,6 @@ import {needLogin, needSubscribe} from "../util/needSubscribe";
import {fetchPost} from "../util/fetch";
import {showMessage} from "../dialog/message";
import {bindSyncCloudListEvent, getSyncCloudList} from "../sync/syncGuide";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {processSync} from "../dialog/processSystem";
import {getCloudURL} from "./util/about";
@ -436,7 +435,7 @@ export const repos = {
repos.element.firstElementChild.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
while (target && target !== repos.element) {
const action = target.getAttribute("data-action")
const action = target.getAttribute("data-action");
if (action === "config") {
if (syncConfigElement.classList.contains("fn__none")) {
getSyncCloudList(syncConfigElement, true);
@ -444,7 +443,7 @@ export const repos = {
} else {
syncConfigElement.classList.add("fn__none");
}
break
break;
} else if (action === "togglePassword") {
const isEye = target.firstElementChild.getAttribute("xlink:href") === "#iconEye";
target.firstElementChild.setAttribute("xlink:href", isEye ? "#iconEyeoff" : "#iconEye");
@ -453,10 +452,10 @@ export const repos = {
} else if (action === "exportData") {
fetchPost(target.getAttribute("data-type") === "s3" ? "/api/sync/exportSyncProviderS3" : "/api/sync/exportSyncProviderWebDAV", {}, response => {
window.location.href = response.data.zip;
})
});
break;
}
target = target.parentElement
target = target.parentElement;
}
});
},

View file

@ -84,11 +84,11 @@ const renderAssetList = (element: Element, k: string, position: IPosition, exts:
inputElement.select();
}
});
}
};
export const assetMenu = (protyle: IProtyle, position: IPosition, callback?: (url: string) => void, exts?: string[]) => {
window.siyuan.menus.menu.remove();
const menu = new Menu()
const menu = new Menu();
menu.addItem({
iconHTML: "",
type: "readonly",
@ -185,8 +185,8 @@ export const assetMenu = (protyle: IProtyle, position: IPosition, callback?: (ur
});
renderAssetList(element, "", position, exts);
}
})
}
});
};
export const fileAnnotationRefMenu = (protyle: IProtyle, refElement: HTMLElement) => {
const nodeElement = hasClosestBlock(refElement);

View file

@ -21,7 +21,7 @@ import {highlightRender} from "../render/highlightRender";
import {getContenteditableElement, hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
import {processRender} from "../util/processCode";
import {BlockRef} from "./BlockRef";
import {hintRenderAssets, hintRenderTemplate, hintRenderWidget} from "../hint/extend";
import {hintRenderTemplate, hintRenderWidget} from "../hint/extend";
import {blockRender} from "../render/blockRender";
/// #if !BROWSER
import {openBy} from "../../editor/util";
@ -35,7 +35,6 @@ import * as dayjs from "dayjs";
import {insertEmptyBlock} from "../../block/util";
import {matchHotKey} from "../util/hotKey";
import {hideElements} from "../ui/hideElements";
import {renderAssetsPreview} from "../../asset/renderAssets";
import {electronUndo} from "../undo";
import {previewTemplate} from "./util";
import {hideMessage, showMessage} from "../../dialog/message";

View file

@ -110,7 +110,7 @@ export const openSearch = async (options: {
sort: localData.sort,
types: Object.assign({}, localData.types),
page: options.key ? 1 : localData.page
}
};
const edit = genSearch(options.app, config, dialog.element.querySelector(".b3-dialog__body"), () => {
dialog.destroy({focus: "false"});
});