mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
6bf910d776
commit
99ad9f8042
6 changed files with 58 additions and 39 deletions
|
|
@ -71,6 +71,7 @@ import {filterHotkey} from "./commonHotkey";
|
||||||
import {setReadOnly} from "../../config/util/setReadOnly";
|
import {setReadOnly} from "../../config/util/setReadOnly";
|
||||||
import {copyPNGByLink} from "../../menus/util";
|
import {copyPNGByLink} from "../../menus/util";
|
||||||
import {globalCommand} from "./command/global";
|
import {globalCommand} from "./command/global";
|
||||||
|
import {duplicateCompletely} from "../../protyle/render/av/action";
|
||||||
|
|
||||||
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
const switchDialogEvent = (app: App, event: MouseEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -357,19 +357,6 @@ export abstract class Constants {
|
||||||
duplicate: {default: "⌘D", custom: "⌘D"},
|
duplicate: {default: "⌘D", custom: "⌘D"},
|
||||||
expandDown: {default: "⌥⇧↓", custom: "⌥⇧↓"},
|
expandDown: {default: "⌥⇧↓", custom: "⌥⇧↓"},
|
||||||
expandUp: {default: "⌥⇧↑", custom: "⌥⇧↑"},
|
expandUp: {default: "⌥⇧↑", custom: "⌥⇧↑"},
|
||||||
copyPlainText: {default: "", custom: ""},
|
|
||||||
copyID: {default: "", custom: ""},
|
|
||||||
copyProtocolInMd: {default: "", custom: ""},
|
|
||||||
netImg2LocalAsset: {default: "", custom: ""},
|
|
||||||
netAssets2LocalAssets: {default: "", custom: ""},
|
|
||||||
optimizeTypography: {default: "", custom: ""},
|
|
||||||
hLayout: {default: "", custom: ""},
|
|
||||||
vLayout: {default: "", custom: ""},
|
|
||||||
refPopover: {default: "", custom: ""},
|
|
||||||
copyText: {default: "", custom: ""},
|
|
||||||
exitFocus: {default: "", custom: ""},
|
|
||||||
ai: {default: "", custom: ""},
|
|
||||||
switchReadonly: {default: "", custom: ""},
|
|
||||||
expand: {default: "⌘↓", custom: "⌘↓"},
|
expand: {default: "⌘↓", custom: "⌘↓"},
|
||||||
collapse: {default: "⌘↑", custom: "⌘↑"},
|
collapse: {default: "⌘↑", custom: "⌘↑"},
|
||||||
insertBottom: {default: "⌥⌘.", custom: "⌥⌘."},
|
insertBottom: {default: "⌥⌘.", custom: "⌥⌘."},
|
||||||
|
|
@ -406,7 +393,21 @@ export abstract class Constants {
|
||||||
jumpToParentPrev: {default: "⇧⌘M", custom: "⇧⌘M"},
|
jumpToParentPrev: {default: "⇧⌘M", custom: "⇧⌘M"},
|
||||||
jumpToParent: {default: "⇧⌘J", custom: "⇧⌘J"},
|
jumpToParent: {default: "⇧⌘J", custom: "⇧⌘J"},
|
||||||
moveToUp: {default: "⇧⌘↑", custom: "⇧⌘↑"},
|
moveToUp: {default: "⇧⌘↑", custom: "⇧⌘↑"},
|
||||||
moveToDown: {default: "⇧⌘↓", custom: "⇧⌘↓"}
|
moveToDown: {default: "⇧⌘↓", custom: "⇧⌘↓"},
|
||||||
|
duplicateCompletely: {default: "", custom: ""},
|
||||||
|
copyPlainText: {default: "", custom: ""},
|
||||||
|
copyID: {default: "", custom: ""},
|
||||||
|
copyProtocolInMd: {default: "", custom: ""},
|
||||||
|
netImg2LocalAsset: {default: "", custom: ""},
|
||||||
|
netAssets2LocalAssets: {default: "", custom: ""},
|
||||||
|
optimizeTypography: {default: "", custom: ""},
|
||||||
|
hLayout: {default: "", custom: ""},
|
||||||
|
vLayout: {default: "", custom: ""},
|
||||||
|
refPopover: {default: "", custom: ""},
|
||||||
|
copyText: {default: "", custom: ""},
|
||||||
|
exitFocus: {default: "", custom: ""},
|
||||||
|
ai: {default: "", custom: ""},
|
||||||
|
switchReadonly: {default: "", custom: ""},
|
||||||
},
|
},
|
||||||
insert: {
|
insert: {
|
||||||
appearance: {default: "⌥⌘X", custom: "⌥⌘X"},
|
appearance: {default: "⌥⌘X", custom: "⌥⌘X"},
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ export const openAttr = (nodeElement: Element, focusName = "bookmark", protyle?:
|
||||||
|
|
||||||
export const copySubMenu = (id: string, accelerator = true, focusElement?: Element) => {
|
export const copySubMenu = (id: string, accelerator = true, focusElement?: Element) => {
|
||||||
return [{
|
return [{
|
||||||
icon: "iconRef",
|
iconHTML: "",
|
||||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockRef.custom : undefined,
|
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockRef.custom : undefined,
|
||||||
label: window.siyuan.languages.copyBlockRef,
|
label: window.siyuan.languages.copyBlockRef,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -384,7 +384,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSQL",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyBlockEmbed,
|
label: window.siyuan.languages.copyBlockEmbed,
|
||||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom : undefined,
|
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyBlockEmbed.custom : undefined,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -394,7 +394,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSiYuan",
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyProtocol,
|
label: window.siyuan.languages.copyProtocol,
|
||||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocol.custom : undefined,
|
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocol.custom : undefined,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -404,6 +404,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyProtocolInMd,
|
label: window.siyuan.languages.copyProtocolInMd,
|
||||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom : undefined,
|
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyProtocolInMd.custom : undefined,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -415,6 +416,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyHPath,
|
label: window.siyuan.languages.copyHPath,
|
||||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined,
|
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyHPath.custom : undefined,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
@ -425,6 +427,7 @@ export const copySubMenu = (id: string, accelerator = true, focusElement?: Eleme
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyID,
|
label: window.siyuan.languages.copyID,
|
||||||
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyID.custom : undefined,
|
accelerator: accelerator ? window.siyuan.config.keymap.editor.general.copyID.custom : undefined,
|
||||||
click: () => {
|
click: () => {
|
||||||
|
|
|
||||||
|
|
@ -424,6 +424,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
icon: "iconCopy",
|
icon: "iconCopy",
|
||||||
submenu: (copySubMenu(id, false) as IMenu[]).concat([{
|
submenu: (copySubMenu(id, false) as IMenu[]).concat([{
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.duplicate,
|
label: window.siyuan.languages.duplicate,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.duplicate.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.duplicate.custom,
|
||||||
click() {
|
click() {
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,10 @@ import {setPosition} from "../../util/setPosition";
|
||||||
import {avRender} from "../render/av/render";
|
import {avRender} from "../render/av/render";
|
||||||
import {emitOpenMenu} from "../../plugin/EventBus";
|
import {emitOpenMenu} from "../../plugin/EventBus";
|
||||||
import {insertAttrViewBlockAnimation} from "../render/av/row";
|
import {insertAttrViewBlockAnimation} from "../render/av/row";
|
||||||
import {avContextmenu} from "../render/av/action";
|
import {avContextmenu, duplicateCompletely} from "../render/av/action";
|
||||||
import {getPlainText} from "../util/paste";
|
import {getPlainText} from "../util/paste";
|
||||||
import {Menu} from "../../plugin/Menu";
|
import {Menu} from "../../plugin/Menu";
|
||||||
import {addEditorToDatabase} from "../render/av/addToDatabase";
|
import {addEditorToDatabase} from "../render/av/addToDatabase";
|
||||||
import {scrollCenter} from "../../util/highlightById";
|
|
||||||
|
|
||||||
export class Gutter {
|
export class Gutter {
|
||||||
public element: HTMLElement;
|
public element: HTMLElement;
|
||||||
|
|
@ -757,6 +756,7 @@ export class Gutter {
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
const copyMenu: IMenu[] = [{
|
const copyMenu: IMenu[] = [{
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copy,
|
label: window.siyuan.languages.copy,
|
||||||
accelerator: "⌘C",
|
accelerator: "⌘C",
|
||||||
click() {
|
click() {
|
||||||
|
|
@ -768,6 +768,7 @@ export class Gutter {
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyPlainText,
|
label: window.siyuan.languages.copyPlainText,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.copyPlainText.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.copyPlainText.custom,
|
||||||
click() {
|
click() {
|
||||||
|
|
@ -779,6 +780,7 @@ export class Gutter {
|
||||||
focusBlock(selectsElement[0]);
|
focusBlock(selectsElement[0]);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.duplicate,
|
label: window.siyuan.languages.duplicate,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.duplicate.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.duplicate.custom,
|
||||||
disabled: protyle.disabled,
|
disabled: protyle.disabled,
|
||||||
|
|
@ -1213,6 +1215,7 @@ export class Gutter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const copyMenu = (copySubMenu(id, true, nodeElement) as IMenu[]).concat([{
|
const copyMenu = (copySubMenu(id, true, nodeElement) as IMenu[]).concat([{
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.copyPlainText,
|
label: window.siyuan.languages.copyPlainText,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.copyPlainText.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.copyPlainText.custom,
|
||||||
click() {
|
click() {
|
||||||
|
|
@ -1220,6 +1223,7 @@ export class Gutter {
|
||||||
focusBlock(nodeElement);
|
focusBlock(nodeElement);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: type === "NodeAttributeView" ? window.siyuan.languages.copyMirror : window.siyuan.languages.copy,
|
label: type === "NodeAttributeView" ? window.siyuan.languages.copyMirror : window.siyuan.languages.copy,
|
||||||
accelerator: "⌘C",
|
accelerator: "⌘C",
|
||||||
click() {
|
click() {
|
||||||
|
|
@ -1231,6 +1235,7 @@ export class Gutter {
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
iconHTML: "",
|
||||||
label: type === "NodeAttributeView" ? window.siyuan.languages.duplicateMirror : window.siyuan.languages.duplicate,
|
label: type === "NodeAttributeView" ? window.siyuan.languages.duplicateMirror : window.siyuan.languages.duplicate,
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.duplicate.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.duplicate.custom,
|
||||||
disabled: protyle.disabled,
|
disabled: protyle.disabled,
|
||||||
|
|
@ -1240,27 +1245,10 @@ export class Gutter {
|
||||||
}]);
|
}]);
|
||||||
if (type === "NodeAttributeView") {
|
if (type === "NodeAttributeView") {
|
||||||
copyMenu.push({
|
copyMenu.push({
|
||||||
|
iconHTML: "",
|
||||||
label: window.siyuan.languages.duplicateCompletely,
|
label: window.siyuan.languages.duplicateCompletely,
|
||||||
click() {
|
click() {
|
||||||
fetchPost("/api/av/duplicateAttributeViewBlock", {avID: nodeElement.getAttribute("data-av-id")}, (response) => {
|
duplicateCompletely(protyle, nodeElement as HTMLElement);
|
||||||
const tempElement = document.createElement("template");
|
|
||||||
tempElement.innerHTML = protyle.lute.SpinBlockDOM(`<div data-node-id="${response.data.blockID}" data-av-id="${response.data.avID}" data-type="NodeAttributeView" data-av-type="table"></div>`)
|
|
||||||
const cloneElement = tempElement.content.firstElementChild;
|
|
||||||
nodeElement.after(cloneElement);
|
|
||||||
avRender(cloneElement, protyle, () => {
|
|
||||||
focusBlock(cloneElement);
|
|
||||||
});
|
|
||||||
scrollCenter(protyle);
|
|
||||||
transaction(protyle, [{
|
|
||||||
action: "insert",
|
|
||||||
data: cloneElement.outerHTML,
|
|
||||||
id: response.data.blockID,
|
|
||||||
previousID: id,
|
|
||||||
}], [{
|
|
||||||
action: "delete",
|
|
||||||
id: response.data.blockID,
|
|
||||||
}]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2008,6 +1996,7 @@ export class Gutter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
iconHTML: "",
|
||||||
accelerator: window.siyuan.config.keymap.editor.general.copyText.custom,
|
accelerator: window.siyuan.config.keymap.editor.general.copyText.custom,
|
||||||
label: window.siyuan.languages.copyText,
|
label: window.siyuan.languages.copyText,
|
||||||
click() {
|
click() {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import {deleteRow, insertRows, selectRow, setPageSize, updateHeader} from "./row
|
||||||
import {emitOpenMenu} from "../../../plugin/EventBus";
|
import {emitOpenMenu} from "../../../plugin/EventBus";
|
||||||
import {openMenuPanel} from "./openMenuPanel";
|
import {openMenuPanel} from "./openMenuPanel";
|
||||||
import {hintRef} from "../../hint/extend";
|
import {hintRef} from "../../hint/extend";
|
||||||
import {focusByRange} from "../../util/selection";
|
import {focusBlock, focusByRange} from "../../util/selection";
|
||||||
import {showMessage} from "../../../dialog/message";
|
import {showMessage} from "../../../dialog/message";
|
||||||
import {previewImage} from "../../preview/image";
|
import {previewImage} from "../../preview/image";
|
||||||
import {unicode2Emoji} from "../../../emoji";
|
import {unicode2Emoji} from "../../../emoji";
|
||||||
|
|
@ -31,6 +31,8 @@ import {isOnlyMeta, writeText} from "../../util/compatibility";
|
||||||
import {openSearchAV} from "./relation";
|
import {openSearchAV} from "./relation";
|
||||||
import {Constants} from "../../../constants";
|
import {Constants} from "../../../constants";
|
||||||
import {hideElements} from "../../ui/hideElements";
|
import {hideElements} from "../../ui/hideElements";
|
||||||
|
import {fetchPost} from "../../../util/fetch";
|
||||||
|
import {scrollCenter} from "../../../util/highlightById";
|
||||||
|
|
||||||
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
|
export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
|
||||||
if (isOnlyMeta(event)) {
|
if (isOnlyMeta(event)) {
|
||||||
|
|
@ -489,3 +491,25 @@ export const removeAttrViewColAnimation = (blockElement: Element, id: string) =>
|
||||||
item.remove();
|
item.remove();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const duplicateCompletely = (protyle:IProtyle, nodeElement:HTMLElement) => {
|
||||||
|
fetchPost("/api/av/duplicateAttributeViewBlock", {avID: nodeElement.getAttribute("data-av-id")}, (response) => {
|
||||||
|
const tempElement = document.createElement("template");
|
||||||
|
tempElement.innerHTML = protyle.lute.SpinBlockDOM(`<div data-node-id="${response.data.blockID}" data-av-id="${response.data.avID}" data-type="NodeAttributeView" data-av-type="table"></div>`)
|
||||||
|
const cloneElement = tempElement.content.firstElementChild;
|
||||||
|
nodeElement.after(cloneElement);
|
||||||
|
avRender(cloneElement, protyle, () => {
|
||||||
|
focusBlock(cloneElement);
|
||||||
|
});
|
||||||
|
scrollCenter(protyle);
|
||||||
|
transaction(protyle, [{
|
||||||
|
action: "insert",
|
||||||
|
data: cloneElement.outerHTML,
|
||||||
|
id: response.data.blockID,
|
||||||
|
previousID: nodeElement.dataset.nodeId,
|
||||||
|
}], [{
|
||||||
|
action: "delete",
|
||||||
|
id: response.data.blockID,
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue