Offer to edit images
Any SVG image in assets/ can now be edited with js-draw. It won't reload automatically (yet)
This commit is contained in:
parent
5c261b35f2
commit
8d1438de33
4 changed files with 240 additions and 18 deletions
32
src/index.ts
32
src/index.ts
|
@ -1,12 +1,11 @@
|
|||
import {Plugin, Protyle} from 'siyuan';
|
||||
import {getPreviewHTML, loadIcons, getMenuHTML, generateSiyuanId} from "@/helper";
|
||||
import {getPreviewHTML, loadIcons, getMenuHTML, generateSiyuanId, findImgSrc, extractFileID} from "@/helper";
|
||||
import {createEditor, openEditorTab} from "@/editorTab";
|
||||
|
||||
export default class DrawJSPlugin extends Plugin {
|
||||
onload() {
|
||||
|
||||
loadIcons(this);
|
||||
//const id = Math.random().toString(36).substring(7);
|
||||
this.addTab({
|
||||
'type': "whiteboard",
|
||||
init() {
|
||||
|
@ -25,20 +24,21 @@ export default class DrawJSPlugin extends Plugin {
|
|||
}
|
||||
}];
|
||||
|
||||
this.eventBus.on("open-menu-image", (e: any) => {
|
||||
const fileID = extractFileID(findImgSrc(e.detail.element));
|
||||
if(fileID === null) {
|
||||
return;
|
||||
}
|
||||
console.log("got ID" + fileID);
|
||||
e.detail.menu.addItem({
|
||||
icon: "iconDraw",
|
||||
label: "Edit with js-draw",
|
||||
click: () => {
|
||||
openEditorTab(this, fileID);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onLayoutReady() {
|
||||
// This function is automatically called when the layout is loaded.
|
||||
}
|
||||
|
||||
onunload() {
|
||||
// This function is automatically called when the plugin is disabled.
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
// This function is automatically called when the plugin is uninstalled.
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue