mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-10 21:01:50 +08:00
This commit is contained in:
parent
b75be56ac0
commit
6b64a031f0
@ -116,6 +116,7 @@ export abstract class Constants {
|
|||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
general: {
|
general: {
|
||||||
|
netImg2LocalAsset: {default: "", custom: ""},
|
||||||
hLayout: {default: "", custom: ""},
|
hLayout: {default: "", custom: ""},
|
||||||
vLayout: {default: "", custom: ""},
|
vLayout: {default: "", custom: ""},
|
||||||
refBottom: {default: "⇧>", custom: "⇧>"},
|
refBottom: {default: "⇧>", custom: "⇧>"},
|
||||||
|
@ -1,7 +1,42 @@
|
|||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {getAllModels} from "../../layout/getAll";
|
import {getAllModels} from "../../layout/getAll";
|
||||||
/// #endif
|
/// #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) => {
|
export const fullscreen = (element: Element, btnElement?: Element) => {
|
||||||
const isFullscreen = element.className.includes("fullscreen");
|
const isFullscreen = element.className.includes("fullscreen");
|
||||||
|
@ -2,7 +2,7 @@ import {getIconByType} from "../../editor/getIcon";
|
|||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {MenuItem} from "../../menus/Menu";
|
import {MenuItem} from "../../menus/Menu";
|
||||||
import {fullscreen} from "./action";
|
import {fullscreen, netImg2LocalAssets} from "./action";
|
||||||
import {exportMd} from "../../menus/commonMenuItem";
|
import {exportMd} from "../../menus/commonMenuItem";
|
||||||
import {setEditMode} from "../util/setEditMode";
|
import {setEditMode} from "../util/setEditMode";
|
||||||
import {RecordMedia} from "../util/RecordMedia";
|
import {RecordMedia} from "../util/RecordMedia";
|
||||||
@ -217,32 +217,9 @@ export class Breadcrumb {
|
|||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.netImg2LocalAsset,
|
label: window.siyuan.languages.netImg2LocalAsset,
|
||||||
icon: "iconTransform",
|
icon: "iconTransform",
|
||||||
click: () => {
|
accelerator: window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom,
|
||||||
fetchPost("/api/format/netImg2LocalAssets", {
|
click () {
|
||||||
id: protyle.block.rootID
|
netImg2LocalAssets(protyle)
|
||||||
}, () => {
|
|
||||||
/// #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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
@ -2,7 +2,7 @@ import {matchHotKey} from "../util/hotKey";
|
|||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {writeText} from "../util/compatibility";
|
import {writeText} from "../util/compatibility";
|
||||||
import {focusByOffset, getSelectionOffset} from "../util/selection";
|
import {focusByOffset, getSelectionOffset} from "../util/selection";
|
||||||
import {fullscreen} from "../breadcrumb/action";
|
import {fullscreen, netImg2LocalAssets} from "../breadcrumb/action";
|
||||||
import {addLoading, setPadding} from "../ui/initUI";
|
import {addLoading, setPadding} from "../ui/initUI";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {onGet} from "../util/onGet";
|
import {onGet} from "../util/onGet";
|
||||||
@ -42,6 +42,12 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {
|
||||||
|
netImg2LocalAssets(protyle)
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (protyle.model) {
|
if (protyle.model) {
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.backlinks.custom, event)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user