From 0bc89f4a72bd8853b1ce2f14a90fb34c14e6b94d Mon Sep 17 00:00:00 2001 From: MassiveBox Date: Sat, 5 Apr 2025 23:23:45 +0200 Subject: [PATCH] Prepare for release --- README.md | 14 +++++--------- package.json | 12 ++++++------ plugin.json | 2 +- public/webapp/error.html | 21 +++++++++++++++++++++ public/webapp/index.html | 2 +- src/file.ts | 2 -- src/migration.ts | 17 ++++++++++++++--- 7 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 public/webapp/error.html diff --git a/README.md b/README.md index c759374..f58614c 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,16 @@ # SiYuan js-draw Plugin -This plugin allows you to embed js-draw whiteboards anywhere in your SiYuan documents. +This plugin allows you to embed js-draw whiteboards anywhere in your SiYuan documents. ## Usage instructions -- Install the plugin from the marketplace. You can find it by searching for `js-draw`. -- To edit an SVG image that is already embedded in your document: - 1. Right-click on the image, select "Plugin" > "Edit with js-draw" in the menu - 2. The editor tab will open, edit your file as you like, then click the Save button and close the tab. - 3. The image is updated, but SiYuan will still show the cached (old) image. This will be fixed in future releases, - please be patient. Until them, you can refresh the editor or change the image path. +- Install the plugin from the marketplace. You can find it by searching for `js-draw`. - To add a new drawing to your document: 1. Type `/Insert Drawing` in your document, and select the correct menu entry 2. The whiteboard editor will open in a new tab. Draw as you like, then click the Save button and close the tab. - 3. Click the Gear icon > Refresh to refresh the drawing block. - 4. Click the drawing block to open the editor again. +- To edit the image later: + 1. Right-click on the image (or click the three dots on mobile), select "Plugin" > "Edit with js-draw" in the menu + 2. The editor tab will open, edit your file as you like, then click the Save button and close the tab. ## Planned features Check out the [Projects](https://git.massive.box/massivebox/siyuan-jsdraw-plugin/projects) tab! diff --git a/package.json b/package.json index 78f409d..f5dee54 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "plugin-sample-vite-svelte", - "version": "0.3.6", + "name": "siyuan-jsdraw-plugin", + "version": "0.2.0", "type": "module", - "description": "This is a sample plugin based on vite and svelte for Siyuan (https://b3log.org/siyuan)", - "repository": "", - "homepage": "", - "author": "frostime", + "description": "Include a whiteboard for freehand drawing anywhere in your documents.", + "repository": "https://git.massive.box/massivebox/siyuan-jsdraw-plugin", + "homepage": "https://git.massive.box/massivebox/siyuan-jsdraw-plugin", + "author": "massivebox", "license": "MIT", "scripts": { "dev": "cross-env NODE_ENV=development VITE_SOURCEMAP=inline vite build --watch", diff --git a/plugin.json b/plugin.json index 0b3987f..32dcc21 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "name": "siyuan-jsdraw-plugin", "author": "massivebox", "url": "https://git.massive.box/massivebox/siyuan-jsdraw-plugin", - "version": "0.1.1", + "version": "0.2.0", "minAppVersion": "3.0.12", "backends": [ "windows", diff --git a/public/webapp/error.html b/public/webapp/error.html new file mode 100644 index 0000000..2281841 --- /dev/null +++ b/public/webapp/error.html @@ -0,0 +1,21 @@ + + + + Error + + + +

It looks like an error occurred. You shouldn't be able to see this page.

+

No data has been deleted. Please excuse us for the inconvenience.

+

+ Try reloading SiYuan, and if the error persists, open an issue at + https://git.massive.box/massivebox/siyuan-jsdraw-plugin/issues + or contact the developer directly via e-mail at box@massive.box +

+ + \ No newline at end of file diff --git a/public/webapp/index.html b/public/webapp/index.html index cb4343c..9a02454 100644 --- a/public/webapp/index.html +++ b/public/webapp/index.html @@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', async () => { const editLink = document.createElement('a'); - editLink.href = getEditLink(path); + editLink.href = "./error.html"; document.body.appendChild(editLink); const htmlContainer = document.createElement('div'); diff --git a/src/file.ts b/src/file.ts index 25c012d..79e0e48 100644 --- a/src/file.ts +++ b/src/file.ts @@ -11,10 +11,8 @@ function toFile(title: string, content: string, mimeType: string){ export async function uploadAsset(fileID: string, mimeType: string, content: string) { const file = toFile(fileID + ".svg", content, mimeType); - console.log(1, file) let r = await upload('/' + ASSETS_PATH, [file]); - console.log(2, r) if(r.errFiles) { throw new Error("Failed to upload file"); } diff --git a/src/migration.ts b/src/migration.ts index 290b700..6ec3eac 100644 --- a/src/migration.ts +++ b/src/migration.ts @@ -3,11 +3,11 @@ import {getFile, uploadAsset} from "@/file"; import {ASSETS_PATH, DATA_PATH, SVG_MIME} from "@/const"; import {replaceBlockContent} from "@/protyle"; import {generateRandomString, getMarkdownBlock} from "@/helper"; +import {Dialog} from "siyuan"; export async function migrate() { let blocks = await findEmbedBlocks(); - console.log(blocks); const found = blocks.length > 0; for(const block of blocks) { @@ -15,14 +15,25 @@ export async function migrate() { if(oldFileID) { const newFileID = generateRandomString() + "-" + oldFileID; const file = await getFile(DATA_PATH + ASSETS_PATH + oldFileID + ".svg"); - console.log("file", file) const r = await uploadAsset(newFileID, SVG_MIME, file); - console.log("r", r); const newMarkdown = getMarkdownBlock(r.fileID, r.syncID); await replaceBlockContent(block.id, block.markdown, newMarkdown); } } + if(found) { + new Dialog({ + width: "90vw", + height: "90vh", + content: ` +