This commit is contained in:
parent
450e862f92
commit
ee21fd8d96
4 changed files with 16 additions and 28 deletions
|
@ -292,6 +292,7 @@ export abstract class Constants {
|
|||
copyID: {default: "", custom: ""},
|
||||
copyProtocolInMd: {default: "", custom: ""},
|
||||
netImg2LocalAsset: {default: "", custom: ""},
|
||||
netAssets2LocalAssets: {default: "", custom: ""},
|
||||
optimizeTypography: {default: "", custom: ""},
|
||||
hLayout: {default: "", custom: ""},
|
||||
vLayout: {default: "", custom: ""},
|
||||
|
|
|
@ -9,34 +9,13 @@ import {hasClosestByClassName} from "../util/hasClosest";
|
|||
import {reloadProtyle} from "../util/reload";
|
||||
import {resize} from "../util/resize";
|
||||
|
||||
export const netAssets2LocalAssets = (protyle: IProtyle) => {
|
||||
export const net2LocalAssets = (protyle: IProtyle, type: "Assets" | "Img") => {
|
||||
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;
|
||||
}
|
||||
addLoading(protyle);
|
||||
hideElements(["toolbar"], protyle);
|
||||
fetchPost("/api/format/netImg2LocalAssets", {
|
||||
fetchPost(`/api/format/net${type}2LocalAssets`, {
|
||||
id: protyle.block.rootID
|
||||
}, () => {
|
||||
/// #if MOBILE
|
||||
|
|
|
@ -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, netAssets2LocalAssets, netImg2LocalAssets} from "./action";
|
||||
import {fullscreen, net2LocalAssets} from "./action";
|
||||
import {openFileAttr} from "../../menus/commonMenuItem";
|
||||
import {setEditMode} from "../util/setEditMode";
|
||||
import {RecordMedia} from "../util/RecordMedia";
|
||||
|
@ -338,14 +338,15 @@ export class Breadcrumb {
|
|||
icon: "iconTransform",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom,
|
||||
click() {
|
||||
netImg2LocalAssets(protyle);
|
||||
net2LocalAssets(protyle, "Img");
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.netAssets2LocalAssets,
|
||||
icon: "iconTransform",
|
||||
accelerator: window.siyuan.config.keymap.editor.general.netAssets2LocalAssets.custom,
|
||||
click() {
|
||||
netAssets2LocalAssets(protyle);
|
||||
net2LocalAssets(protyle, "Assets");
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
getSelectionOffset,
|
||||
setFirstNodeRange,
|
||||
} from "../util/selection";
|
||||
import {netImg2LocalAssets} from "../breadcrumb/action";
|
||||
import {getContenteditableElement, hasNextSibling, hasPreviousSibling} from "./getBlock";
|
||||
import {hasClosestByMatchTag} from "../util/hasClosest";
|
||||
import {hideElements} from "../ui/hideElements";
|
||||
|
@ -16,6 +15,7 @@ import {transaction, updateTransaction} from "./transaction";
|
|||
import {onGet} from "../util/onGet";
|
||||
import {Constants} from "../../constants";
|
||||
import * as dayjs from "dayjs";
|
||||
import {net2LocalAssets} from "../breadcrumb/action";
|
||||
|
||||
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {
|
||||
|
@ -30,7 +30,14 @@ export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElemen
|
|||
}
|
||||
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {
|
||||
netImg2LocalAssets(protyle);
|
||||
net2LocalAssets(protyle, "Img");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.netAssets2LocalAssets.custom, event)) {
|
||||
net2LocalAssets(protyle, "Assets");
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue