Improve error handling and code structure

This commit is contained in:
MassiveBox 2025-04-23 09:52:45 +02:00
parent f35342a791
commit 8d4779b8fe
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
5 changed files with 116 additions and 67 deletions

View file

@ -29,12 +29,12 @@ export default class DrawJSPlugin extends Plugin {
id: "insert-drawing",
filter: ["Insert Drawing", "Add drawing", "whiteboard", "freehand", "graphics", "jsdraw"],
html: getMenuHTML("iconDraw", this.i18n.insertDrawing),
callback: (protyle: Protyle) => {
callback: async (protyle: Protyle) => {
void this.analytics.sendEvent('create');
const fileID = generateRandomString();
const syncID = generateTimeString() + '-' + generateRandomString();
protyle.insert(getMarkdownBlock(fileID, syncID), true, false);
new EditorManager(fileID, this.config.getDefaultEditorOptions()).open(this);
(await EditorManager.create(fileID, this)).open(this);
}
}];
@ -44,9 +44,9 @@ export default class DrawJSPlugin extends Plugin {
e.detail.menu.addItem({
icon: "iconDraw",
label: this.i18n.editDrawing,
click: () => {
click: async () => {
void this.analytics.sendEvent('edit');
new EditorManager(ids.fileID, this.config.getDefaultEditorOptions()).open(this);
(await EditorManager.create(ids.fileID, this)).open(this);
}
})
})