Vanessa 2025-08-12 11:28:22 +08:00
parent 1edd35029e
commit e103b5c2f0
2 changed files with 14 additions and 1 deletions

View file

@ -155,8 +155,19 @@ export class Plugin {
} }
public addIcons(svg: string) { 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>`); <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: { public addTopBar(options: {

View file

@ -62,6 +62,8 @@ export const uninstall = (app: App, name: string, isUninstall = false) => {
}); });
// rm plugin // rm plugin
app.plugins.splice(index, 1); app.plugins.splice(index, 1);
// rm icons
document.querySelector(`svg[data-name="${plugin.name}"]`)?.remove();
// rm protyle toolbar // rm protyle toolbar
getAllEditor().forEach(editor => { getAllEditor().forEach(editor => {
editor.protyle.toolbar.update(editor.protyle); editor.protyle.toolbar.update(editor.protyle);