mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
1edd35029e
commit
e103b5c2f0
2 changed files with 14 additions and 1 deletions
|
@ -155,8 +155,19 @@ export class Plugin {
|
|||
}
|
||||
|
||||
public addIcons(svg: string) {
|
||||
document.body.insertAdjacentHTML("afterbegin", `<svg data-name="${this.name}" style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
const svgElement = document.querySelector(`svg[data-name="${this.name}"] defs`);
|
||||
if (svgElement) {
|
||||
svgElement.innerHTML = svg;
|
||||
} else {
|
||||
const lastSvgElement = document.querySelector("body > svg:last-of-type");
|
||||
if (lastSvgElement) {
|
||||
lastSvgElement.insertAdjacentHTML("afterend", `<svg data-name="${this.name}" style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>${svg}</defs></svg>`);
|
||||
} else {
|
||||
document.body.insertAdjacentHTML("afterbegin", `<svg data-name="${this.name}" style="position: absolute; width: 0; height: 0; overflow: hidden;" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>${svg}</defs></svg>`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public addTopBar(options: {
|
||||
|
|
|
@ -62,6 +62,8 @@ export const uninstall = (app: App, name: string, isUninstall = false) => {
|
|||
});
|
||||
// rm plugin
|
||||
app.plugins.splice(index, 1);
|
||||
// rm icons
|
||||
document.querySelector(`svg[data-name="${plugin.name}"]`)?.remove();
|
||||
// rm protyle toolbar
|
||||
getAllEditor().forEach(editor => {
|
||||
editor.protyle.toolbar.update(editor.protyle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue