This commit is contained in:
Vanessa 2023-06-19 21:04:56 +08:00
parent 887443c321
commit 39f9aaca82
11 changed files with 45 additions and 46 deletions

View file

@ -251,32 +251,32 @@ export const initWindow = (app: App) => {
ipcRenderer.on(Constants.SIYUAN_OPENURL, (event, url) => { ipcRenderer.on(Constants.SIYUAN_OPENURL, (event, url) => {
if (/^siyuan:\/\/plugins\//.test(url)) { if (/^siyuan:\/\/plugins\//.test(url)) {
// siyuan://plugins/plugin-samplecustom_tab?title=自定义页签&icon=iconFace&data={"text": "This is the custom plugin tab I opened via protocol."} // siyuan://plugins/plugin-samplecustom_tab?title=自定义页签&icon=iconFace&data={"text": "This is the custom plugin tab I opened via protocol."}
const pluginId = url.replace("siyuan://plugins/", "").split("?")[0] const pluginId = url.replace("siyuan://plugins/", "").split("?")[0];
app.plugins.find(plugin => { app.plugins.find(plugin => {
const match = Object.keys(plugin.models).find(key => { const match = Object.keys(plugin.models).find(key => {
if (key === pluginId) { if (key === pluginId) {
let data = getSearch("data", url) let data = getSearch("data", url);
try { try {
data = JSON.parse(data || "{}"); data = JSON.parse(data || "{}");
} catch (e) { } catch (e) {
console.log("Error open plugin tab with protocol:", e) console.log("Error open plugin tab with protocol:", e);
} }
openFile({ openFile({
app, app,
custom: { custom: {
title: getSearch("title", url), title: getSearch("title", url),
icon: getSearch("icon", url), icon: getSearch("icon", url),
data: JSON.parse(getSearch("data", url) || "{}"), data,
fn: plugin.models[key] fn: plugin.models[key]
}, },
}); });
return true return true;
} }
}) });
if (match) { if (match) {
return true return true;
} }
}) });
return; return;
} }
if (isSYProtocol(url)) { if (isSYProtocol(url)) {

View file

@ -360,11 +360,11 @@ export const repos = {
}); });
const syncModeElement = repos.element.querySelector("#syncMode") as HTMLSelectElement; const syncModeElement = repos.element.querySelector("#syncMode") as HTMLSelectElement;
syncModeElement.addEventListener("change", () => { syncModeElement.addEventListener("change", () => {
fetchPost("/api/sync/setSyncMode", {mode: parseInt(syncModeElement.value, 10)}, (response) => { fetchPost("/api/sync/setSyncMode", {mode: parseInt(syncModeElement.value, 10)}, () => {
if (syncModeElement.value === "1") { if (syncModeElement.value === "1") {
syncPerceptionElement.parentElement.classList.remove("fn__none") syncPerceptionElement.parentElement.classList.remove("fn__none");
} else { } else {
syncPerceptionElement.parentElement.classList.add("fn__none") syncPerceptionElement.parentElement.classList.add("fn__none");
} }
window.siyuan.config.sync.mode = parseInt(syncModeElement.value, 10); window.siyuan.config.sync.mode = parseInt(syncModeElement.value, 10);
}); });

View file

@ -204,7 +204,7 @@ export abstract class Constants {
220: "\\", 220: "\\",
221: "]", 221: "]",
222: "'", 222: "'",
} };
// 冲突不使用 "⌘S/Q" // 冲突不使用 "⌘S/Q"
// "⌘", "⇧", "⌥", "⌃" // "⌘", "⇧", "⌥", "⌃"
// "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", // "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←",

View file

@ -26,7 +26,7 @@ export const showTooltip = (message: string, target: Element, error = false) =>
messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161 messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161
} }
let left = targetRect.left; let left = targetRect.left;
let topSpace = 8 let topSpace = 8;
const position = target.getAttribute("data-position"); const position = target.getAttribute("data-position");
if (position === "right") { if (position === "right") {
left = targetRect.right - messageElement.clientWidth; left = targetRect.right - messageElement.clientWidth;

View file

@ -580,18 +580,18 @@ export class Wnd {
Array.from(this.headersElement.children).forEach((item: HTMLElement) => { Array.from(this.headersElement.children).forEach((item: HTMLElement) => {
const iconElement = item.querySelector(".item__icon"); const iconElement = item.querySelector(".item__icon");
const graphicElement = item.querySelector(".item__graphic"); const graphicElement = item.querySelector(".item__graphic");
let iconHTML = undefined let iconHTML = undefined;
if (iconElement) { if (iconElement) {
if (iconElement.firstElementChild?.tagName === "IMG") { if (iconElement.firstElementChild?.tagName === "IMG") {
// 图标为图片的文档 // 图标为图片的文档
iconHTML = `<img src="${iconElement.firstElementChild.getAttribute("src")}" class="b3-menu__icon">` iconHTML = `<img src="${iconElement.firstElementChild.getAttribute("src")}" class="b3-menu__icon">`;
} else { } else {
// 有图标的文档 // 有图标的文档
iconHTML = `<span class="b3-menu__icon">${iconElement.innerHTML}</span>` iconHTML = `<span class="b3-menu__icon">${iconElement.innerHTML}</span>`;
} }
} else if (!graphicElement) { } else if (!graphicElement) {
// 没有图标的文档 // 没有图标的文档
iconHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE, "b3-menu__icon", true) iconHTML = unicode2Emoji(Constants.SIYUAN_IMAGE_FILE, "b3-menu__icon", true);
} }
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
label: escapeHtml(item.querySelector(".item__text").textContent), label: escapeHtml(item.querySelector(".item__text").textContent),

View file

@ -106,12 +106,12 @@ export class Outline extends Model {
click: (element: HTMLElement) => { click: (element: HTMLElement) => {
const id = element.getAttribute("data-node-id"); const id = element.getAttribute("data-node-id");
if (this.isPreview) { if (this.isPreview) {
const headElement = document.getElementById(id) const headElement = document.getElementById(id);
if (headElement) { if (headElement) {
const tabElement = hasTopClosestByClassName(headElement, "protyle") const tabElement = hasTopClosestByClassName(headElement, "protyle");
if (tabElement) { if (tabElement) {
const tab = getInstanceById(tabElement.getAttribute("data-id")) as Tab const tab = getInstanceById(tabElement.getAttribute("data-id")) as Tab;
tab.parent.switchTab(tab.headElement) tab.parent.switchTab(tab.headElement);
} }
headElement.scrollIntoView(); headElement.scrollIntoView();
} else { } else {
@ -337,7 +337,7 @@ export class Outline extends Model {
if (this.isPreview) { if (this.isPreview) {
this.tree.element.querySelectorAll(".popover__block").forEach(item => { this.tree.element.querySelectorAll(".popover__block").forEach(item => {
item.classList.remove("popover__block"); item.classList.remove("popover__block");
}) });
} }
if (currentId) { if (currentId) {

View file

@ -17,7 +17,6 @@ import {Constants} from "../constants";
import {isBrowser, isWindow} from "../util/functions"; import {isBrowser, isWindow} from "../util/functions";
import {Menu} from "../plugin/Menu"; import {Menu} from "../plugin/Menu";
import {fetchPost} from "../util/fetch"; import {fetchPost} from "../util/fetch";
import {escapeAttr} from "../util/escape";
import {needSubscribe} from "../util/needSubscribe"; import {needSubscribe} from "../util/needSubscribe";
import * as dayjs from "dayjs"; import * as dayjs from "dayjs";
@ -236,30 +235,30 @@ export const initBar = (app: App) => {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
fetchPost("/api/sync/getSyncInfo", {}, (response) => { fetchPost("/api/sync/getSyncInfo", {}, (response) => {
let html = "" let html = "";
if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) { if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) {
html = response.data.stat; html = response.data.stat;
} else { } else {
html = window.siyuan.languages._kernel[82].replace("%s", dayjs(response.data.synced).format("YYYY-MM-DD HH:mm")) + "<br>" html = window.siyuan.languages._kernel[82].replace("%s", dayjs(response.data.synced).format("YYYY-MM-DD HH:mm")) + "<br>";
html += " " + response.data.stat; html += " " + response.data.stat;
if (response.data.kernels.length > 0) { if (response.data.kernels.length > 0) {
html += "<br>" html += "<br>";
html += window.siyuan.languages.currentKernel + "<br>" html += window.siyuan.languages.currentKernel + "<br>";
html += " " + response.data.kernel + "/" + window.siyuan.config.system.kernelVersion + " (" + window.siyuan.config.system.os + "/" + window.siyuan.config.system.name + ")<br>" html += " " + response.data.kernel + "/" + window.siyuan.config.system.kernelVersion + " (" + window.siyuan.config.system.os + "/" + window.siyuan.config.system.name + ")<br>";
html += window.siyuan.languages.otherOnlineKernels + "<br>" html += window.siyuan.languages.otherOnlineKernels + "<br>";
response.data.kernels.forEach((item: { response.data.kernels.forEach((item: {
os: string; os: string;
ver: string; ver: string;
hostname: string; hostname: string;
id: string; id: string;
}) => { }) => {
html += ` ${item.id}/${item.ver} (${item.os}/${item.hostname}) <br>` html += ` ${item.id}/${item.ver} (${item.os}/${item.hostname}) <br>`;
}) });
} }
} }
barSyncElement.setAttribute("aria-label", html); barSyncElement.setAttribute("aria-label", html);
}) });
}) });
barSyncElement.setAttribute("aria-label", window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom))); barSyncElement.setAttribute("aria-label", window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom)));
}; };

View file

@ -126,4 +126,4 @@ export const copyPNG = (imgElement: HTMLImageElement) => {
}; };
tempElement.src = imgElement.getAttribute("src"); tempElement.src = imgElement.getAttribute("src");
} }
} };

View file

@ -139,7 +139,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {
} }
if (!isWindow() || isMobile()) { if (!isWindow() || isMobile()) {
const pluginMenu: IMenu[] = [] const pluginMenu: IMenu[] = [];
plugin.topBarIcons.forEach(element => { plugin.topBarIcons.forEach(element => {
if (isMobile()) { if (isMobile()) {
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) { if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
@ -149,7 +149,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {
click() { click() {
element.dispatchEvent(new CustomEvent("click")); element.dispatchEvent(new CustomEvent("click"));
} }
}) });
} else { } else {
document.querySelector("#menuAbout").after(element); document.querySelector("#menuAbout").after(element);
} }
@ -161,17 +161,17 @@ export const afterLoadPlugin = (plugin: Plugin) => {
} }
}); });
if (isMobile() && pluginMenu.length > 0) { if (isMobile() && pluginMenu.length > 0) {
const pluginElement = document.createElement("div") const pluginElement = document.createElement("div");
pluginElement.classList.add("b3-menu__item") pluginElement.classList.add("b3-menu__item");
pluginElement.setAttribute("data-menu", "true") pluginElement.setAttribute("data-menu", "true");
pluginElement.innerHTML = `<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>` pluginElement.innerHTML = `<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>`;
pluginElement.addEventListener("click", () => { pluginElement.addEventListener("click", () => {
const menu = new Menu() const menu = new Menu();
pluginMenu.forEach(item => { pluginMenu.forEach(item => {
menu.addItem(item) menu.addItem(item);
}) });
menu.fullscreen(); menu.fullscreen();
}) });
document.querySelector("#menuAbout").after(pluginElement); document.querySelector("#menuAbout").after(pluginElement);
} }
} }

View file

@ -1,7 +1,7 @@
import {setStorageVal, updateHotkeyTip} from "../util/compatibility"; import {setStorageVal, updateHotkeyTip} from "../util/compatibility";
import {ToolbarItem} from "./ToolbarItem"; import {ToolbarItem} from "./ToolbarItem";
import {setPosition} from "../../util/setPosition"; import {setPosition} from "../../util/setPosition";
import {focusBlock, focusByRange, getSelectionPosition} from "../util/selection"; import {focusByRange, getSelectionPosition} from "../util/selection";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest"; import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
import {updateBatchTransaction} from "../wysiwyg/transaction"; import {updateBatchTransaction} from "../wysiwyg/transaction";

View file

@ -227,7 +227,7 @@ export const saveCriterion = (config: ISearchOption,
criteriaElement.firstElementChild.insertAdjacentHTML("beforeend", `<div data-type="set-criteria" class="b3-chip b3-chip--middle b3-chip--pointer b3-chip--${["secondary", "primary", "info", "success", "warning", "error", ""][(criteriaElement.firstElementChild.childElementCount) % 7]}">${criterion.name}<svg class="b3-chip__close" data-type="remove-criteria"><use xlink:href="#iconCloseRound"></use></svg></div>`); criteriaElement.firstElementChild.insertAdjacentHTML("beforeend", `<div data-type="set-criteria" class="b3-chip b3-chip--middle b3-chip--pointer b3-chip--${["secondary", "primary", "info", "success", "warning", "error", ""][(criteriaElement.firstElementChild.childElementCount) % 7]}">${criterion.name}<svg class="b3-chip__close" data-type="remove-criteria"><use xlink:href="#iconCloseRound"></use></svg></div>`);
}); });
}); });
} };
export const moreMenu = async (config: ISearchOption, export const moreMenu = async (config: ISearchOption,
criteriaData: ISearchOption[], criteriaData: ISearchOption[],