This commit is contained in:
parent
d8cc4f8caf
commit
0bc89f4a72
7 changed files with 48 additions and 22 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue