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.classList.contains("av__celltext")) {
if (aElement.scrollWidth > aElement.parentElement.clientWidth - 11) { if (aElement.scrollWidth > aElement.parentElement.clientWidth - 11) {
if (aElement.querySelector(".av__cellicon")) { if (aElement.querySelector(".av__cellicon")) {
tip = `${aElement.firstChild.textContent} ➡️ ${aElement.lastChild.textContent}` tip = `${aElement.firstChild.textContent} ➡️ ${aElement.lastChild.textContent}`;
} else { } else {
tip = aElement.textContent; tip = aElement.textContent;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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