Prepare for release
Some checks failed
Create Release on Tag Push / build (push) Has been cancelled

This commit is contained in:
MassiveBox 2025-04-05 23:23:45 +02:00
parent d8cc4f8caf
commit 0bc89f4a72
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
7 changed files with 48 additions and 22 deletions

View file

@ -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");
}

View file

@ -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: `
<iframe
style="width: 100%; height: 100%; background-color: white"
src="https://notes.massive.box/YRpTbbxLiD"
/>
`
})
}
}
function extractID(html: string): string | null {