🚨
This commit is contained in:
parent
887443c321
commit
39f9aaca82
11 changed files with 45 additions and 46 deletions
|
@ -251,32 +251,32 @@ export const initWindow = (app: App) => {
|
|||
ipcRenderer.on(Constants.SIYUAN_OPENURL, (event, 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."}
|
||||
const pluginId = url.replace("siyuan://plugins/", "").split("?")[0]
|
||||
const pluginId = url.replace("siyuan://plugins/", "").split("?")[0];
|
||||
app.plugins.find(plugin => {
|
||||
const match = Object.keys(plugin.models).find(key => {
|
||||
if (key === pluginId) {
|
||||
let data = getSearch("data", url)
|
||||
let data = getSearch("data", url);
|
||||
try {
|
||||
data = JSON.parse(data || "{}");
|
||||
} catch (e) {
|
||||
console.log("Error open plugin tab with protocol:", e)
|
||||
console.log("Error open plugin tab with protocol:", e);
|
||||
}
|
||||
openFile({
|
||||
app,
|
||||
custom: {
|
||||
title: getSearch("title", url),
|
||||
icon: getSearch("icon", url),
|
||||
data: JSON.parse(getSearch("data", url) || "{}"),
|
||||
data,
|
||||
fn: plugin.models[key]
|
||||
},
|
||||
});
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (match) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (isSYProtocol(url)) {
|
||||
|
|
|
@ -360,11 +360,11 @@ export const repos = {
|
|||
});
|
||||
const syncModeElement = repos.element.querySelector("#syncMode") as HTMLSelectElement;
|
||||
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") {
|
||||
syncPerceptionElement.parentElement.classList.remove("fn__none")
|
||||
syncPerceptionElement.parentElement.classList.remove("fn__none");
|
||||
} else {
|
||||
syncPerceptionElement.parentElement.classList.add("fn__none")
|
||||
syncPerceptionElement.parentElement.classList.add("fn__none");
|
||||
}
|
||||
window.siyuan.config.sync.mode = parseInt(syncModeElement.value, 10);
|
||||
});
|
||||
|
|
|
@ -204,7 +204,7 @@ export abstract class Constants {
|
|||
220: "\\",
|
||||
221: "]",
|
||||
222: "'",
|
||||
}
|
||||
};
|
||||
// 冲突不使用 "⌘S/Q"
|
||||
// "⌘", "⇧", "⌥", "⌃"
|
||||
// "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
let left = targetRect.left;
|
||||
let topSpace = 8
|
||||
let topSpace = 8;
|
||||
const position = target.getAttribute("data-position");
|
||||
if (position === "right") {
|
||||
left = targetRect.right - messageElement.clientWidth;
|
||||
|
|
|
@ -580,18 +580,18 @@ export class Wnd {
|
|||
Array.from(this.headersElement.children).forEach((item: HTMLElement) => {
|
||||
const iconElement = item.querySelector(".item__icon");
|
||||
const graphicElement = item.querySelector(".item__graphic");
|
||||
let iconHTML = undefined
|
||||
let iconHTML = undefined;
|
||||
if (iconElement) {
|
||||
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 {
|
||||
// 有图标的文档
|
||||
iconHTML = `<span class="b3-menu__icon">${iconElement.innerHTML}</span>`
|
||||
iconHTML = `<span class="b3-menu__icon">${iconElement.innerHTML}</span>`;
|
||||
}
|
||||
} 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({
|
||||
label: escapeHtml(item.querySelector(".item__text").textContent),
|
||||
|
|
|
@ -106,12 +106,12 @@ export class Outline extends Model {
|
|||
click: (element: HTMLElement) => {
|
||||
const id = element.getAttribute("data-node-id");
|
||||
if (this.isPreview) {
|
||||
const headElement = document.getElementById(id)
|
||||
const headElement = document.getElementById(id);
|
||||
if (headElement) {
|
||||
const tabElement = hasTopClosestByClassName(headElement, "protyle")
|
||||
const tabElement = hasTopClosestByClassName(headElement, "protyle");
|
||||
if (tabElement) {
|
||||
const tab = getInstanceById(tabElement.getAttribute("data-id")) as Tab
|
||||
tab.parent.switchTab(tab.headElement)
|
||||
const tab = getInstanceById(tabElement.getAttribute("data-id")) as Tab;
|
||||
tab.parent.switchTab(tab.headElement);
|
||||
}
|
||||
headElement.scrollIntoView();
|
||||
} else {
|
||||
|
@ -337,7 +337,7 @@ export class Outline extends Model {
|
|||
if (this.isPreview) {
|
||||
this.tree.element.querySelectorAll(".popover__block").forEach(item => {
|
||||
item.classList.remove("popover__block");
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (currentId) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import {Constants} from "../constants";
|
|||
import {isBrowser, isWindow} from "../util/functions";
|
||||
import {Menu} from "../plugin/Menu";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {escapeAttr} from "../util/escape";
|
||||
import {needSubscribe} from "../util/needSubscribe";
|
||||
import * as dayjs from "dayjs";
|
||||
|
||||
|
@ -236,30 +235,30 @@ export const initBar = (app: App) => {
|
|||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
fetchPost("/api/sync/getSyncInfo", {}, (response) => {
|
||||
let html = ""
|
||||
let html = "";
|
||||
if (!window.siyuan.config.sync.enabled || (0 === window.siyuan.config.sync.provider && needSubscribe(""))) {
|
||||
html = response.data.stat;
|
||||
} 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;
|
||||
if (response.data.kernels.length > 0) {
|
||||
html += "<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 += window.siyuan.languages.otherOnlineKernels + "<br>"
|
||||
html += "<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 += window.siyuan.languages.otherOnlineKernels + "<br>";
|
||||
response.data.kernels.forEach((item: {
|
||||
os: string;
|
||||
ver: string;
|
||||
hostname: 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", window.siyuan.config.sync.stat || (window.siyuan.languages.syncNow + " " + updateHotkeyTip(window.siyuan.config.keymap.general.syncNow.custom)));
|
||||
};
|
||||
|
||||
|
|
|
@ -126,4 +126,4 @@ export const copyPNG = (imgElement: HTMLImageElement) => {
|
|||
};
|
||||
tempElement.src = imgElement.getAttribute("src");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -139,7 +139,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
|||
}
|
||||
|
||||
if (!isWindow() || isMobile()) {
|
||||
const pluginMenu: IMenu[] = []
|
||||
const pluginMenu: IMenu[] = [];
|
||||
plugin.topBarIcons.forEach(element => {
|
||||
if (isMobile()) {
|
||||
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
|
||||
|
@ -149,7 +149,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
|||
click() {
|
||||
element.dispatchEvent(new CustomEvent("click"));
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
document.querySelector("#menuAbout").after(element);
|
||||
}
|
||||
|
@ -161,17 +161,17 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
|||
}
|
||||
});
|
||||
if (isMobile() && pluginMenu.length > 0) {
|
||||
const pluginElement = document.createElement("div")
|
||||
pluginElement.classList.add("b3-menu__item")
|
||||
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>`
|
||||
const pluginElement = document.createElement("div");
|
||||
pluginElement.classList.add("b3-menu__item");
|
||||
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.addEventListener("click", () => {
|
||||
const menu = new Menu()
|
||||
const menu = new Menu();
|
||||
pluginMenu.forEach(item => {
|
||||
menu.addItem(item)
|
||||
})
|
||||
menu.addItem(item);
|
||||
});
|
||||
menu.fullscreen();
|
||||
})
|
||||
});
|
||||
document.querySelector("#menuAbout").after(pluginElement);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {setStorageVal, updateHotkeyTip} from "../util/compatibility";
|
||||
import {ToolbarItem} from "./ToolbarItem";
|
||||
import {setPosition} from "../../util/setPosition";
|
||||
import {focusBlock, focusByRange, getSelectionPosition} from "../util/selection";
|
||||
import {focusByRange, getSelectionPosition} from "../util/selection";
|
||||
import {Constants} from "../../constants";
|
||||
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
|
||||
import {updateBatchTransaction} from "../wysiwyg/transaction";
|
||||
|
|
|
@ -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>`);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const moreMenu = async (config: ISearchOption,
|
||||
criteriaData: ISearchOption[],
|
||||
|
|
Loading…
Add table
Reference in a new issue