Dropped migration legacy code
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 58s
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 58s
This commit is contained in:
parent
eaf4a8e39e
commit
3874378824
2 changed files with 0 additions and 67 deletions
|
@ -6,7 +6,6 @@ import {
|
||||||
findImgSrc,
|
findImgSrc,
|
||||||
imgSrcToIDs, generateTimeString, generateRandomString
|
imgSrcToIDs, generateTimeString, generateRandomString
|
||||||
} from "@/helper";
|
} from "@/helper";
|
||||||
import {migrate} from "@/migration";
|
|
||||||
import {EditorManager} from "@/editor";
|
import {EditorManager} from "@/editor";
|
||||||
import {PluginConfig, PluginConfigViewer} from "@/config";
|
import {PluginConfig, PluginConfigViewer} from "@/config";
|
||||||
import {Analytics} from "@/analytics";
|
import {Analytics} from "@/analytics";
|
||||||
|
@ -22,7 +21,6 @@ export default class DrawJSPlugin extends Plugin {
|
||||||
new ErrorReporter(this.i18n);
|
new ErrorReporter(this.i18n);
|
||||||
loadIcons(this);
|
loadIcons(this);
|
||||||
EditorManager.registerTab(this);
|
EditorManager.registerTab(this);
|
||||||
migrate()
|
|
||||||
|
|
||||||
await this.startConfig();
|
await this.startConfig();
|
||||||
await this.startAnalytics();
|
await this.startAnalytics();
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
import {sql} from "@/api";
|
|
||||||
import {PluginAsset, PluginFile} 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();
|
|
||||||
const found = blocks.length > 0;
|
|
||||||
|
|
||||||
for(const block of blocks) {
|
|
||||||
const oldFileID = extractID(block.markdown);
|
|
||||||
if(oldFileID) {
|
|
||||||
const oldFile = new PluginFile(DATA_PATH + ASSETS_PATH, oldFileID + '.svg', SVG_MIME);
|
|
||||||
await oldFile.loadFromSiYuanFS();
|
|
||||||
const newFile = new PluginAsset(generateRandomString(), oldFileID, SVG_MIME);
|
|
||||||
newFile.setContent(oldFile.getContent());
|
|
||||||
await newFile.save();
|
|
||||||
const newMarkdown = getMarkdownBlock(newFile.getFileID(), newFile.getSyncID());
|
|
||||||
if(await replaceBlockContent(block.id, block.markdown, newMarkdown)) {
|
|
||||||
await oldFile.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
// Match the pattern: id= followed by characters until & or quote
|
|
||||||
const regex = /id=([^&"']+)/;
|
|
||||||
const match = html.match(regex);
|
|
||||||
return match ? match[1] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function findEmbedBlocks() {
|
|
||||||
|
|
||||||
const sqlQuery = `
|
|
||||||
SELECT id, markdown
|
|
||||||
FROM blocks
|
|
||||||
WHERE markdown like '%src="/plugins/siyuan-jsdraw-plugin/webapp/%'
|
|
||||||
`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return await sql(sqlQuery);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error searching for embed blocks:', error);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue