mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-18 04:58:06 +01:00
🎨 Support converting network assets to local https://github.com/siyuan-note/siyuan/issues/9826
This commit is contained in:
parent
e4ea32764f
commit
2e0b2ba967
9 changed files with 38 additions and 1 deletions
|
|
@ -9,6 +9,27 @@ import {hasClosestByClassName} from "../util/hasClosest";
|
|||
import {reloadProtyle} from "../util/reload";
|
||||
import {resize} from "../util/resize";
|
||||
|
||||
export const netAssets2LocalAssets = (protyle: IProtyle) => {
|
||||
if (protyle.element.querySelector(".wysiwygLoading")) {
|
||||
return;
|
||||
}
|
||||
addLoading(protyle);
|
||||
hideElements(["toolbar"], protyle);
|
||||
fetchPost("/api/format/netAssets2LocalAssets", {
|
||||
id: protyle.block.rootID
|
||||
}, () => {
|
||||
/// #if MOBILE
|
||||
reloadProtyle(protyle, false);
|
||||
/// #else
|
||||
getAllModels().editor.forEach(item => {
|
||||
if (item.editor.protyle.block.rootID === protyle.block.rootID) {
|
||||
reloadProtyle(item.editor.protyle, item.editor.protyle.element.isSameNode(protyle.element));
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
});
|
||||
};
|
||||
|
||||
export const netImg2LocalAssets = (protyle: IProtyle) => {
|
||||
if (protyle.element.querySelector(".wysiwygLoading")) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {getIconByType} from "../../editor/getIcon";
|
|||
import {fetchPost} from "../../util/fetch";
|
||||
import {Constants} from "../../constants";
|
||||
import {MenuItem} from "../../menus/Menu";
|
||||
import {fullscreen, netImg2LocalAssets} from "./action";
|
||||
import {fullscreen, netAssets2LocalAssets, netImg2LocalAssets} from "./action";
|
||||
import {openFileAttr} from "../../menus/commonMenuItem";
|
||||
import {setEditMode} from "../util/setEditMode";
|
||||
import {RecordMedia} from "../util/RecordMedia";
|
||||
|
|
@ -341,6 +341,13 @@ export class Breadcrumb {
|
|||
netImg2LocalAssets(protyle);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.netAssets2LocalAssets,
|
||||
icon: "iconTransform",
|
||||
click() {
|
||||
netAssets2LocalAssets(protyle);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.uploadAssets2CDN,
|
||||
icon: "iconCloudSucc",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue