This commit is contained in:
parent
b75be56ac0
commit
6b64a031f0
4 changed files with 48 additions and 29 deletions
|
@ -116,6 +116,7 @@ export abstract class Constants {
|
|||
},
|
||||
editor: {
|
||||
general: {
|
||||
netImg2LocalAsset: {default: "", custom: ""},
|
||||
hLayout: {default: "", custom: ""},
|
||||
vLayout: {default: "", custom: ""},
|
||||
refBottom: {default: "⇧>", custom: "⇧>"},
|
||||
|
|
|
@ -1,7 +1,42 @@
|
|||
/// #if !MOBILE
|
||||
import {getAllModels} from "../../layout/getAll";
|
||||
/// #endif
|
||||
import {setPadding} from "../ui/initUI";
|
||||
import {addLoading, setPadding} from "../ui/initUI";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {Constants} from "../../constants";
|
||||
import {onGet} from "../util/onGet";
|
||||
|
||||
export const netImg2LocalAssets = (protyle: IProtyle) => {
|
||||
if (protyle.element.querySelector(".fn__loading")) {
|
||||
return;
|
||||
}
|
||||
addLoading(protyle);
|
||||
fetchPost("/api/format/netImg2LocalAssets", {
|
||||
id: protyle.block.rootID
|
||||
}, () => {
|
||||
/// #if MOBILE
|
||||
fetchPost("/api/filetree/getDoc", {
|
||||
id: protyle.block.id,
|
||||
mode: 0,
|
||||
size: Constants.SIZE_GET,
|
||||
}, getResponse => {
|
||||
onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
|
||||
});
|
||||
/// #else
|
||||
getAllModels().editor.forEach(item => {
|
||||
if (item.editor.protyle.block.rootID === protyle.block.rootID) {
|
||||
fetchPost("/api/filetree/getDoc", {
|
||||
id: item.editor.protyle.block.rootID,
|
||||
mode: 0,
|
||||
size: Constants.SIZE_GET,
|
||||
}, getResponse => {
|
||||
onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
|
||||
});
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
});
|
||||
}
|
||||
|
||||
export const fullscreen = (element: Element, btnElement?: Element) => {
|
||||
const isFullscreen = element.className.includes("fullscreen");
|
||||
|
|
|
@ -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} from "./action";
|
||||
import {fullscreen, netImg2LocalAssets} from "./action";
|
||||
import {exportMd} from "../../menus/commonMenuItem";
|
||||
import {setEditMode} from "../util/setEditMode";
|
||||
import {RecordMedia} from "../util/RecordMedia";
|
||||
|
@ -217,32 +217,9 @@ export class Breadcrumb {
|
|||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.netImg2LocalAsset,
|
||||
icon: "iconTransform",
|
||||
click: () => {
|
||||
fetchPost("/api/format/netImg2LocalAssets", {
|
||||
id: protyle.block.rootID
|
||||
}, () => {
|
||||
/// #if MOBILE
|
||||
fetchPost("/api/filetree/getDoc", {
|
||||
id: protyle.block.id,
|
||||
mode: 0,
|
||||
size: Constants.SIZE_GET,
|
||||
}, getResponse => {
|
||||
onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
|
||||
});
|
||||
/// #else
|
||||
getAllModels().editor.forEach(item => {
|
||||
if (item.editor.protyle.block.rootID === protyle.block.rootID) {
|
||||
fetchPost("/api/filetree/getDoc", {
|
||||
id: item.editor.protyle.block.rootID,
|
||||
mode: 0,
|
||||
size: Constants.SIZE_GET,
|
||||
}, getResponse => {
|
||||
onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
|
||||
});
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
});
|
||||
accelerator: window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom,
|
||||
click () {
|
||||
netImg2LocalAssets(protyle)
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
|
@ -2,7 +2,7 @@ import {matchHotKey} from "../util/hotKey";
|
|||
import {fetchPost} from "../../util/fetch";
|
||||
import {writeText} from "../util/compatibility";
|
||||
import {focusByOffset, getSelectionOffset} from "../util/selection";
|
||||
import {fullscreen} from "../breadcrumb/action";
|
||||
import {fullscreen, netImg2LocalAssets} from "../breadcrumb/action";
|
||||
import {addLoading, setPadding} from "../ui/initUI";
|
||||
import {Constants} from "../../constants";
|
||||
import {onGet} from "../util/onGet";
|
||||
|
@ -42,6 +42,12 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
|
|||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {
|
||||
netImg2LocalAssets(protyle)
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (protyle.model) {
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
|
||||
event.preventDefault();
|
||||
|
|
Loading…
Add table
Reference in a new issue