mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
5c641120ae
commit
82ce65fa7e
2 changed files with 5 additions and 1 deletions
|
|
@ -73,6 +73,10 @@ export class Plugin {
|
||||||
position?: "right" | "left",
|
position?: "right" | "left",
|
||||||
callback: (evt: MouseEvent) => void
|
callback: (evt: MouseEvent) => void
|
||||||
}) {
|
}) {
|
||||||
|
if (!options.icon.startsWith("icon") && !options.icon.startsWith("<svg")) {
|
||||||
|
console.error(`plugin ${this.name} addTopBar error: icon must be svg id or svg tag`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const iconElement = document.createElement("div");
|
const iconElement = document.createElement("div");
|
||||||
iconElement.setAttribute("data-menu", "true");
|
iconElement.setAttribute("data-menu", "true");
|
||||||
iconElement.addEventListener("click", options.callback);
|
iconElement.addEventListener("click", options.callback);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ const loadPluginJS = async (app: App, item: IPluginData) => {
|
||||||
try {
|
try {
|
||||||
runCode(item.js, "plugin:" + encodeURIComponent(item.name))(getObject, moduleObj, exportsObj);
|
runCode(item.js, "plugin:" + encodeURIComponent(item.name))(getObject, moduleObj, exportsObj);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`eval plugin ${item.name} error:`, e);
|
console.error(`plugin ${item.name} run error:`, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pluginClass = (moduleObj.exports || exportsObj).default || moduleObj.exports;
|
const pluginClass = (moduleObj.exports || exportsObj).default || moduleObj.exports;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue