mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-12 02:04:20 +01:00
🎨 Support importing markdown zip on the browser (#14950)
This commit is contained in:
parent
88c7a66e68
commit
12cc17bd06
3 changed files with 122 additions and 17 deletions
|
|
@ -761,24 +761,43 @@ export const genImportMenu = (notebookId: string, pathString: string) => {
|
|||
id: "import",
|
||||
icon: "iconDownload",
|
||||
label: window.siyuan.languages.import,
|
||||
submenu: [{
|
||||
id: "importSiYuanZip",
|
||||
icon: "iconSiYuan",
|
||||
label: 'SiYuan .sy.zip<input class="b3-form__upload" type="file" accept="application/zip">',
|
||||
bind: (element) => {
|
||||
element.querySelector(".b3-form__upload").addEventListener("change", (event: InputEvent & {
|
||||
target: HTMLInputElement
|
||||
}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", event.target.files[0]);
|
||||
formData.append("notebook", notebookId);
|
||||
formData.append("toPath", pathString);
|
||||
fetchPost("/api/import/importSY", formData, () => {
|
||||
reloadDocTree();
|
||||
submenu: [
|
||||
{
|
||||
id: "importSiYuanZip",
|
||||
icon: "iconSiYuan",
|
||||
label: 'SiYuan .sy.zip<input class="b3-form__upload" type="file" accept="application/zip">',
|
||||
bind: (element) => {
|
||||
element.querySelector(".b3-form__upload").addEventListener("change", (event: InputEvent & {
|
||||
target: HTMLInputElement
|
||||
}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", event.target.files[0]);
|
||||
formData.append("notebook", notebookId);
|
||||
formData.append("toPath", pathString);
|
||||
fetchPost("/api/import/importSY", formData, () => {
|
||||
reloadDocTree();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "importMarkdownZip",
|
||||
icon: "iconMarkdown",
|
||||
label: 'Markdown .zip<input class="b3-form__upload" type="file" accept="application/zip">',
|
||||
bind: (element) => {
|
||||
element.querySelector(".b3-form__upload").addEventListener("change", (event: InputEvent & {
|
||||
target: HTMLInputElement
|
||||
}) => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", event.target.files[0]);
|
||||
formData.append("notebook", notebookId);
|
||||
formData.append("toPath", pathString);
|
||||
fetchPost("/api/import/importZipMd", formData, () => {
|
||||
reloadDocTree();
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
/// #if !BROWSER
|
||||
importstdmd("Markdown " + window.siyuan.languages.doc, true),
|
||||
importstdmd("Markdown " + window.siyuan.languages.folder)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue