@opentiny/fluent-editor 4.0.0-beta.1 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/config/i18n/en-us.es.js +0 -2
- package/es/config/i18n/en-us.es.js.map +1 -1
- package/es/config/i18n/zh-cn.es.js +0 -2
- package/es/config/i18n/zh-cn.es.js.map +1 -1
- package/es/fluent-editor.es.js +0 -6
- package/es/fluent-editor.es.js.map +1 -1
- package/es/index.es.js +0 -4
- package/es/index.es.js.map +1 -1
- package/es/modules/index.es.js +0 -4
- package/es/modules/index.es.js.map +1 -1
- package/es/modules/shortcut-key/index.es.js +0 -16
- package/es/modules/shortcut-key/index.es.js.map +1 -1
- package/es/ui/icons.config.es.js +0 -4
- package/es/ui/icons.config.es.js.map +1 -1
- package/es/ui/icons.es.js +2 -4
- package/es/ui/icons.es.js.map +1 -1
- package/lib/config/i18n/en-us.cjs.js +0 -2
- package/lib/config/i18n/en-us.cjs.js.map +1 -1
- package/lib/config/i18n/zh-cn.cjs.js +0 -2
- package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
- package/lib/fluent-editor.cjs.js +2 -8
- package/lib/fluent-editor.cjs.js.map +1 -1
- package/lib/index.cjs.js +5 -9
- package/lib/index.cjs.js.map +1 -1
- package/lib/modules/index.cjs.js +5 -9
- package/lib/modules/index.cjs.js.map +1 -1
- package/lib/modules/shortcut-key/index.cjs.js +0 -16
- package/lib/modules/shortcut-key/index.cjs.js.map +1 -1
- package/lib/ui/icons.cjs.js +1 -3
- package/lib/ui/icons.cjs.js.map +1 -1
- package/lib/ui/icons.config.cjs.js +0 -4
- package/lib/ui/icons.config.cjs.js.map +1 -1
- package/package.json +1 -3
- package/types/config/i18n/en-us.d.ts +0 -2
- package/types/config/i18n/zh-cn.d.ts +0 -2
- package/types/config/types/editor-modules.interface.d.ts +0 -4
- package/types/modules/index.d.ts +0 -2
- package/types/ui/icons.config.d.ts +0 -2
- package/es/modules/ai/constants.es.js +0 -50
- package/es/modules/ai/constants.es.js.map +0 -1
- package/es/modules/ai/icons.es.js +0 -319
- package/es/modules/ai/icons.es.js.map +0 -1
- package/es/modules/ai/index.es.js +0 -670
- package/es/modules/ai/index.es.js.map +0 -1
- package/es/modules/flow-chart/config-utils.es.js +0 -102
- package/es/modules/flow-chart/config-utils.es.js.map +0 -1
- package/es/modules/flow-chart/formats/flow-chart-blot.es.js +0 -369
- package/es/modules/flow-chart/formats/flow-chart-blot.es.js.map +0 -1
- package/es/modules/flow-chart/i18n/en-us.es.js +0 -30
- package/es/modules/flow-chart/i18n/en-us.es.js.map +0 -1
- package/es/modules/flow-chart/i18n/index.es.js +0 -12
- package/es/modules/flow-chart/i18n/index.es.js.map +0 -1
- package/es/modules/flow-chart/i18n/zh-cn.es.js +0 -30
- package/es/modules/flow-chart/i18n/zh-cn.es.js.map +0 -1
- package/es/modules/flow-chart/icons.es.js +0 -27
- package/es/modules/flow-chart/icons.es.js.map +0 -1
- package/es/modules/flow-chart/index.es.js +0 -45
- package/es/modules/flow-chart/index.es.js.map +0 -1
- package/es/modules/flow-chart/modules/context-menu.es.js +0 -184
- package/es/modules/flow-chart/modules/context-menu.es.js.map +0 -1
- package/es/modules/flow-chart/modules/control-panel.es.js +0 -286
- package/es/modules/flow-chart/modules/control-panel.es.js.map +0 -1
- package/es/modules/flow-chart/modules/custom-resize-action.es.js +0 -150
- package/es/modules/flow-chart/modules/custom-resize-action.es.js.map +0 -1
- package/es/modules/mind-map/config-utils.es.js +0 -108
- package/es/modules/mind-map/config-utils.es.js.map +0 -1
- package/es/modules/mind-map/formats/mind-map-blot.es.js +0 -356
- package/es/modules/mind-map/formats/mind-map-blot.es.js.map +0 -1
- package/es/modules/mind-map/i18n/en-us.es.js +0 -29
- package/es/modules/mind-map/i18n/en-us.es.js.map +0 -1
- package/es/modules/mind-map/i18n/index.es.js +0 -12
- package/es/modules/mind-map/i18n/index.es.js.map +0 -1
- package/es/modules/mind-map/i18n/zh-cn.es.js +0 -29
- package/es/modules/mind-map/i18n/zh-cn.es.js.map +0 -1
- package/es/modules/mind-map/icons.es.js +0 -45
- package/es/modules/mind-map/icons.es.js.map +0 -1
- package/es/modules/mind-map/index.es.js +0 -56
- package/es/modules/mind-map/index.es.js.map +0 -1
- package/es/modules/mind-map/modules/context-menu.es.js +0 -128
- package/es/modules/mind-map/modules/context-menu.es.js.map +0 -1
- package/es/modules/mind-map/modules/control-panel.es.js +0 -425
- package/es/modules/mind-map/modules/control-panel.es.js.map +0 -1
- package/es/modules/mind-map/modules/custom-resize-action.es.js +0 -161
- package/es/modules/mind-map/modules/custom-resize-action.es.js.map +0 -1
- package/flow-chart.css +0 -185
- package/lib/modules/ai/constants.cjs.js +0 -50
- package/lib/modules/ai/constants.cjs.js.map +0 -1
- package/lib/modules/ai/icons.cjs.js +0 -319
- package/lib/modules/ai/icons.cjs.js.map +0 -1
- package/lib/modules/ai/index.cjs.js +0 -670
- package/lib/modules/ai/index.cjs.js.map +0 -1
- package/lib/modules/flow-chart/config-utils.cjs.js +0 -102
- package/lib/modules/flow-chart/config-utils.cjs.js.map +0 -1
- package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js +0 -369
- package/lib/modules/flow-chart/formats/flow-chart-blot.cjs.js.map +0 -1
- package/lib/modules/flow-chart/i18n/en-us.cjs.js +0 -30
- package/lib/modules/flow-chart/i18n/en-us.cjs.js.map +0 -1
- package/lib/modules/flow-chart/i18n/index.cjs.js +0 -12
- package/lib/modules/flow-chart/i18n/index.cjs.js.map +0 -1
- package/lib/modules/flow-chart/i18n/zh-cn.cjs.js +0 -30
- package/lib/modules/flow-chart/i18n/zh-cn.cjs.js.map +0 -1
- package/lib/modules/flow-chart/icons.cjs.js +0 -27
- package/lib/modules/flow-chart/icons.cjs.js.map +0 -1
- package/lib/modules/flow-chart/index.cjs.js +0 -45
- package/lib/modules/flow-chart/index.cjs.js.map +0 -1
- package/lib/modules/flow-chart/modules/context-menu.cjs.js +0 -184
- package/lib/modules/flow-chart/modules/context-menu.cjs.js.map +0 -1
- package/lib/modules/flow-chart/modules/control-panel.cjs.js +0 -286
- package/lib/modules/flow-chart/modules/control-panel.cjs.js.map +0 -1
- package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js +0 -150
- package/lib/modules/flow-chart/modules/custom-resize-action.cjs.js.map +0 -1
- package/lib/modules/mind-map/config-utils.cjs.js +0 -108
- package/lib/modules/mind-map/config-utils.cjs.js.map +0 -1
- package/lib/modules/mind-map/formats/mind-map-blot.cjs.js +0 -356
- package/lib/modules/mind-map/formats/mind-map-blot.cjs.js.map +0 -1
- package/lib/modules/mind-map/i18n/en-us.cjs.js +0 -29
- package/lib/modules/mind-map/i18n/en-us.cjs.js.map +0 -1
- package/lib/modules/mind-map/i18n/index.cjs.js +0 -12
- package/lib/modules/mind-map/i18n/index.cjs.js.map +0 -1
- package/lib/modules/mind-map/i18n/zh-cn.cjs.js +0 -29
- package/lib/modules/mind-map/i18n/zh-cn.cjs.js.map +0 -1
- package/lib/modules/mind-map/icons.cjs.js +0 -45
- package/lib/modules/mind-map/icons.cjs.js.map +0 -1
- package/lib/modules/mind-map/index.cjs.js +0 -56
- package/lib/modules/mind-map/index.cjs.js.map +0 -1
- package/lib/modules/mind-map/modules/context-menu.cjs.js +0 -128
- package/lib/modules/mind-map/modules/context-menu.cjs.js.map +0 -1
- package/lib/modules/mind-map/modules/control-panel.cjs.js +0 -425
- package/lib/modules/mind-map/modules/control-panel.cjs.js.map +0 -1
- package/lib/modules/mind-map/modules/custom-resize-action.cjs.js +0 -161
- package/lib/modules/mind-map/modules/custom-resize-action.cjs.js.map +0 -1
- package/mind-map.css +0 -224
- package/types/modules/ai/constants.d.ts +0 -30
- package/types/modules/ai/icons.d.ts +0 -21
- package/types/modules/ai/index.d.ts +0 -96
- package/types/modules/ai/types.d.ts +0 -16
- package/types/modules/flow-chart/config-utils.d.ts +0 -10
- package/types/modules/flow-chart/formats/flow-chart-blot.d.ts +0 -43
- package/types/modules/flow-chart/i18n/en-us.d.ts +0 -26
- package/types/modules/flow-chart/i18n/index.d.ts +0 -1
- package/types/modules/flow-chart/i18n/zh-cn.d.ts +0 -26
- package/types/modules/flow-chart/icons.d.ts +0 -12
- package/types/modules/flow-chart/index.d.ts +0 -10
- package/types/modules/flow-chart/modules/context-menu.d.ts +0 -3
- package/types/modules/flow-chart/modules/control-panel.d.ts +0 -3
- package/types/modules/flow-chart/modules/custom-resize-action.d.ts +0 -22
- package/types/modules/flow-chart/options.d.ts +0 -29
- package/types/modules/mind-map/config-utils.d.ts +0 -12
- package/types/modules/mind-map/formats/mind-map-blot.d.ts +0 -44
- package/types/modules/mind-map/i18n/en-us.d.ts +0 -25
- package/types/modules/mind-map/i18n/index.d.ts +0 -1
- package/types/modules/mind-map/i18n/zh-cn.d.ts +0 -25
- package/types/modules/mind-map/icons.d.ts +0 -21
- package/types/modules/mind-map/index.d.ts +0 -10
- package/types/modules/mind-map/modules/context-menu.d.ts +0 -3
- package/types/modules/mind-map/modules/control-panel.d.ts +0 -3
- package/types/modules/mind-map/modules/custom-resize-action.d.ts +0 -23
- package/types/modules/mind-map/options.d.ts +0 -27
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import Quill from "quill";
|
|
5
|
-
import MindMapPlaceholderBlot from "./formats/mind-map-blot.es.js";
|
|
6
|
-
class MindMapModule {
|
|
7
|
-
constructor(quill, options) {
|
|
8
|
-
__publicField(this, "quill");
|
|
9
|
-
__publicField(this, "toolbar");
|
|
10
|
-
__publicField(this, "options");
|
|
11
|
-
quill.container.__quillInstance = quill;
|
|
12
|
-
this.quill = quill;
|
|
13
|
-
this.options = options;
|
|
14
|
-
this.toolbar = quill.getModule("toolbar");
|
|
15
|
-
if (this.toolbar) {
|
|
16
|
-
this.toolbar.addHandler("mind-map", () => {
|
|
17
|
-
this.insertMindMapEditor();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
static register() {
|
|
22
|
-
Quill.register("formats/mind-map", MindMapPlaceholderBlot, true);
|
|
23
|
-
}
|
|
24
|
-
insertMindMapEditor() {
|
|
25
|
-
const range = this.quill.getSelection();
|
|
26
|
-
if (range) {
|
|
27
|
-
const defaultData = {
|
|
28
|
-
data: {
|
|
29
|
-
text: "根节点",
|
|
30
|
-
expand: true,
|
|
31
|
-
uid: "36bae545-da0b-4c08-be14-ff05f7f05d0a",
|
|
32
|
-
isActive: false
|
|
33
|
-
},
|
|
34
|
-
children: [
|
|
35
|
-
{
|
|
36
|
-
data: {
|
|
37
|
-
text: "二级节点",
|
|
38
|
-
uid: "ef0895d2-b5cc-4214-b0ee-e29f8f02420d",
|
|
39
|
-
expand: true,
|
|
40
|
-
richText: false,
|
|
41
|
-
isActive: false
|
|
42
|
-
},
|
|
43
|
-
children: []
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
this.quill.insertText(range.index, "\n", "user");
|
|
48
|
-
this.quill.insertEmbed(range.index + 1, "mind-map", defaultData, "user");
|
|
49
|
-
this.quill.insertText(range.index + 2, "\n", "user");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
MindMapModule
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=index.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../src/modules/mind-map/index.ts"],"sourcesContent":["import type Quill from 'quill'\nimport type { MindMapOptions } from './options'\nimport Quills from 'quill'\nimport MindMapPlaceholderBlot from './formats/mind-map-blot'\n\nexport class MindMapModule {\n quill: Quill\n toolbar: any\n options: MindMapOptions\n\n static register() {\n Quills.register('formats/mind-map', MindMapPlaceholderBlot, true)\n }\n\n constructor(quill: Quill, options: MindMapOptions) {\n (quill.container as any).__quillInstance = quill\n this.quill = quill\n this.options = options\n this.toolbar = quill.getModule('toolbar')\n if (this.toolbar) {\n this.toolbar.addHandler('mind-map', () => {\n this.insertMindMapEditor()\n })\n }\n }\n\n public insertMindMapEditor(): void {\n const range = this.quill.getSelection()\n if (range) {\n const defaultData = {\n data: {\n text: '根节点',\n expand: true,\n uid: '36bae545-da0b-4c08-be14-ff05f7f05d0a',\n isActive: false,\n },\n children: [\n {\n data: {\n text: '二级节点',\n uid: 'ef0895d2-b5cc-4214-b0ee-e29f8f02420d',\n expand: true,\n richText: false,\n isActive: false,\n },\n children: [],\n },\n ],\n }\n this.quill.insertText(range.index, '\\n', 'user')\n this.quill.insertEmbed(range.index + 1, 'mind-map', defaultData, 'user')\n this.quill.insertText(range.index + 2, '\\n', 'user')\n }\n }\n}\n"],"names":["Quills"],"mappings":";;;;;AAKO,MAAM,cAAc;AAAA,EASzB,YAAY,OAAc,SAAyB;AARnD;AACA;AACA;AAOG,UAAM,UAAkB,kBAAkB;AAC3C,SAAK,QAAQ;AACb,SAAK,UAAU;AACf,SAAK,UAAU,MAAM,UAAU,SAAS;AACxC,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,WAAW,YAAY,MAAM;AACxC,aAAK,oBAAA;AAAA,MACP,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAdA,OAAO,WAAW;AAChBA,UAAO,SAAS,oBAAoB,wBAAwB,IAAI;AAAA,EAClE;AAAA,EAcO,sBAA4B;AACjC,UAAM,QAAQ,KAAK,MAAM,aAAA;AACzB,QAAI,OAAO;AACT,YAAM,cAAc;AAAA,QAClB,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,KAAK;AAAA,UACL,UAAU;AAAA,QAAA;AAAA,QAEZ,UAAU;AAAA,UACR;AAAA,YACE,MAAM;AAAA,cACJ,MAAM;AAAA,cACN,KAAK;AAAA,cACL,QAAQ;AAAA,cACR,UAAU;AAAA,cACV,UAAU;AAAA,YAAA;AAAA,YAEZ,UAAU,CAAA;AAAA,UAAC;AAAA,QACb;AAAA,MACF;AAEF,WAAK,MAAM,WAAW,MAAM,OAAO,MAAM,MAAM;AAC/C,WAAK,MAAM,YAAY,MAAM,QAAQ,GAAG,YAAY,aAAa,MAAM;AACvE,WAAK,MAAM,WAAW,MAAM,QAAQ,GAAG,MAAM,MAAM;AAAA,IACrD;AAAA,EACF;AACF;"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import "../../../config/index.es.js";
|
|
5
|
-
import { I18N } from "../../i18n.es.js";
|
|
6
|
-
import { registerMindMapI18N } from "../i18n/index.es.js";
|
|
7
|
-
import { CHANGE_LANGUAGE_EVENT } from "../../../config/editor.config.es.js";
|
|
8
|
-
class MindMapContextMenuHandler {
|
|
9
|
-
constructor(quill, blot) {
|
|
10
|
-
__publicField(this, "texts");
|
|
11
|
-
__publicField(this, "lang");
|
|
12
|
-
this.quill = quill;
|
|
13
|
-
this.blot = blot;
|
|
14
|
-
const i18nModule = this.quill.getModule("i18n");
|
|
15
|
-
registerMindMapI18N(I18N);
|
|
16
|
-
this.lang = i18nModule.options.lang;
|
|
17
|
-
this.texts = this.resolveTexts();
|
|
18
|
-
this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, (lang) => {
|
|
19
|
-
this.lang = lang;
|
|
20
|
-
this.texts = this.resolveTexts();
|
|
21
|
-
this.updateContextMenuItems();
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
getText(key) {
|
|
25
|
-
return this.texts[key];
|
|
26
|
-
}
|
|
27
|
-
resolveTexts() {
|
|
28
|
-
return {
|
|
29
|
-
copy: I18N.parserText("mindMap.contextMenu.copy", this.lang),
|
|
30
|
-
cut: I18N.parserText("mindMap.contextMenu.cut", this.lang),
|
|
31
|
-
paste: I18N.parserText("mindMap.contextMenu.paste", this.lang),
|
|
32
|
-
delete: I18N.parserText("mindMap.contextMenu.deleteContent", this.lang)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
updateContextMenuItems() {
|
|
36
|
-
if (!this.blot.contextMenu) return;
|
|
37
|
-
const menuItems = this.blot.contextMenu.querySelectorAll(".ql-mind-map-context-menu-item");
|
|
38
|
-
if (menuItems.length >= 4) {
|
|
39
|
-
menuItems[0].textContent = this.texts.copy;
|
|
40
|
-
menuItems[1].textContent = this.texts.cut;
|
|
41
|
-
menuItems[2].textContent = this.texts.paste;
|
|
42
|
-
menuItems[3].textContent = this.texts.delete;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const contextMenuHandlers = /* @__PURE__ */ new WeakMap();
|
|
47
|
-
function initContextMenu(blot, quill) {
|
|
48
|
-
blot.contextMenu = document.createElement("div");
|
|
49
|
-
blot.contextMenu.className = "ql-mind-map-context-menu";
|
|
50
|
-
blot.domNode.appendChild(blot.contextMenu);
|
|
51
|
-
const handler = new MindMapContextMenuHandler(quill, blot);
|
|
52
|
-
contextMenuHandlers.set(blot, handler);
|
|
53
|
-
addContextMenuItem(blot, handler.getText("copy"), () => handleCopy(blot));
|
|
54
|
-
addContextMenuItem(blot, handler.getText("cut"), () => handleCut(blot));
|
|
55
|
-
addContextMenuItem(blot, handler.getText("paste"), () => handlePaste(blot));
|
|
56
|
-
addContextMenuItem(blot, handler.getText("delete"), () => handleDeleteContent(blot));
|
|
57
|
-
if (blot.mindMap) {
|
|
58
|
-
blot.mindMap.on("node_contextmenu", (e, node) => {
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
e.stopPropagation();
|
|
61
|
-
blot.currentNode = node;
|
|
62
|
-
if (blot.contextMenu) {
|
|
63
|
-
blot.contextMenu.style.display = "block";
|
|
64
|
-
blot.contextMenu.style.left = `${e.clientX}px`;
|
|
65
|
-
blot.contextMenu.style.top = `${e.clientY}px`;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
const hideMenu = () => {
|
|
70
|
-
if (blot.contextMenu) {
|
|
71
|
-
blot.contextMenu.style.display = "none";
|
|
72
|
-
blot.currentNode = null;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
blot.mindMap.on("node_click", hideMenu);
|
|
76
|
-
blot.mindMap.on("draw_click", hideMenu);
|
|
77
|
-
blot.mindMap.on("expand_btn_click", hideMenu);
|
|
78
|
-
document.addEventListener("click", (e) => {
|
|
79
|
-
if (blot.contextMenu && !blot.contextMenu.contains(e.target)) {
|
|
80
|
-
hideMenu();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function addContextMenuItem(blot, text, onClick) {
|
|
85
|
-
const item = document.createElement("div");
|
|
86
|
-
item.className = "ql-mind-map-context-menu-item";
|
|
87
|
-
item.textContent = text;
|
|
88
|
-
item.style.padding = "5px 15px";
|
|
89
|
-
item.style.cursor = "pointer";
|
|
90
|
-
item.style.whiteSpace = "nowrap";
|
|
91
|
-
item.addEventListener("click", onClick);
|
|
92
|
-
item.addEventListener("mouseenter", () => {
|
|
93
|
-
item.style.background = "#f5f5f5";
|
|
94
|
-
});
|
|
95
|
-
item.addEventListener("mouseleave", () => {
|
|
96
|
-
item.style.background = "white";
|
|
97
|
-
});
|
|
98
|
-
blot.contextMenu.appendChild(item);
|
|
99
|
-
}
|
|
100
|
-
function handleCopy(blot) {
|
|
101
|
-
blot.mindMap.renderer.copy();
|
|
102
|
-
hideContextMenu(blot);
|
|
103
|
-
}
|
|
104
|
-
function handleCut(blot) {
|
|
105
|
-
blot.mindMap.renderer.cut();
|
|
106
|
-
hideContextMenu(blot);
|
|
107
|
-
}
|
|
108
|
-
function handlePaste(blot) {
|
|
109
|
-
blot.mindMap.renderer.paste();
|
|
110
|
-
hideContextMenu(blot);
|
|
111
|
-
}
|
|
112
|
-
function handleDeleteContent(blot) {
|
|
113
|
-
if (blot.currentNode) {
|
|
114
|
-
blot.currentNode.setText("");
|
|
115
|
-
blot.data = blot.mindMap.getData({});
|
|
116
|
-
blot.domNode.setAttribute("data-mind-map", JSON.stringify(blot.data));
|
|
117
|
-
}
|
|
118
|
-
hideContextMenu(blot);
|
|
119
|
-
}
|
|
120
|
-
function hideContextMenu(blot) {
|
|
121
|
-
if (blot.contextMenu) {
|
|
122
|
-
blot.contextMenu.style.display = "none";
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
export {
|
|
126
|
-
initContextMenu
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=context-menu.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.es.js","sources":["../../../../../src/modules/mind-map/modules/context-menu.ts"],"sourcesContent":["import type FluentEditor from '../../../core/fluent-editor'\nimport type MindMapPlaceholderBlot from '../formats/mind-map-blot'\nimport { CHANGE_LANGUAGE_EVENT } from '../../../config'\nimport { I18N } from '../../../modules/i18n'\nimport { registerMindMapI18N } from '../i18n'\n\nclass MindMapContextMenuHandler {\n private texts: Record<string, string>\n private lang: string\n getText(key: keyof Record<string, string>): string {\n return this.texts[key]\n }\n\n constructor(private quill: FluentEditor, private blot: MindMapPlaceholderBlot) {\n const i18nModule = this.quill.getModule('i18n') as I18N\n registerMindMapI18N(I18N)\n this.lang = i18nModule.options.lang\n this.texts = this.resolveTexts()\n this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, (lang: string) => {\n this.lang = lang\n this.texts = this.resolveTexts()\n this.updateContextMenuItems()\n })\n }\n\n resolveTexts() {\n return {\n copy: I18N.parserText('mindMap.contextMenu.copy', this.lang),\n cut: I18N.parserText('mindMap.contextMenu.cut', this.lang),\n paste: I18N.parserText('mindMap.contextMenu.paste', this.lang),\n delete: I18N.parserText('mindMap.contextMenu.deleteContent', this.lang),\n }\n }\n\n updateContextMenuItems() {\n if (!this.blot.contextMenu) return\n\n const menuItems = this.blot.contextMenu.querySelectorAll('.ql-mind-map-context-menu-item')\n if (menuItems.length >= 4) {\n menuItems[0].textContent = this.texts.copy\n menuItems[1].textContent = this.texts.cut\n menuItems[2].textContent = this.texts.paste\n menuItems[3].textContent = this.texts.delete\n }\n }\n}\n\nconst contextMenuHandlers = new WeakMap<MindMapPlaceholderBlot, MindMapContextMenuHandler>()\n\nexport function initContextMenu(blot: MindMapPlaceholderBlot, quill: FluentEditor): void {\n blot.contextMenu = document.createElement('div')\n blot.contextMenu.className = 'ql-mind-map-context-menu'\n blot.domNode.appendChild(blot.contextMenu)\n\n const handler = new MindMapContextMenuHandler(quill, blot)\n contextMenuHandlers.set(blot, handler)\n\n addContextMenuItem(blot, handler.getText('copy'), () => handleCopy(blot))\n addContextMenuItem(blot, handler.getText('cut'), () => handleCut(blot))\n addContextMenuItem(blot, handler.getText('paste'), () => handlePaste(blot))\n addContextMenuItem(blot, handler.getText('delete'), () => handleDeleteContent(blot))\n\n // 监听节点右键点击事件\n if (blot.mindMap) {\n blot.mindMap.on('node_contextmenu', (e: any, node: any) => {\n e.preventDefault()\n e.stopPropagation()\n blot.currentNode = node\n if (blot.contextMenu) {\n blot.contextMenu.style.display = 'block'\n blot.contextMenu.style.left = `${e.clientX}px`\n blot.contextMenu.style.top = `${e.clientY}px`\n }\n })\n }\n\n // 隐藏菜单的逻辑\n const hideMenu = () => {\n if (blot.contextMenu) {\n blot.contextMenu.style.display = 'none'\n blot.currentNode = null\n }\n }\n\n blot.mindMap.on('node_click', hideMenu)\n blot.mindMap.on('draw_click', hideMenu)\n blot.mindMap.on('expand_btn_click', hideMenu)\n document.addEventListener('click', (e) => {\n if (blot.contextMenu && !blot.contextMenu.contains(e.target as Node)) {\n hideMenu()\n }\n })\n}\n\nfunction addContextMenuItem(blot: MindMapPlaceholderBlot, text: string, onClick: () => void): void {\n const item = document.createElement('div')\n item.className = 'ql-mind-map-context-menu-item'\n item.textContent = text\n item.style.padding = '5px 15px'\n item.style.cursor = 'pointer'\n item.style.whiteSpace = 'nowrap'\n item.addEventListener('click', onClick)\n item.addEventListener('mouseenter', () => {\n item.style.background = '#f5f5f5'\n })\n item.addEventListener('mouseleave', () => {\n item.style.background = 'white'\n })\n blot.contextMenu!.appendChild(item)\n}\n\nfunction handleCopy(blot: MindMapPlaceholderBlot): void {\n blot.mindMap.renderer.copy()\n hideContextMenu(blot)\n}\n\nfunction handleCut(blot: MindMapPlaceholderBlot): void {\n blot.mindMap.renderer.cut()\n hideContextMenu(blot)\n}\n\nfunction handlePaste(blot: MindMapPlaceholderBlot): void {\n blot.mindMap.renderer.paste()\n hideContextMenu(blot)\n}\n\nfunction handleDeleteContent(blot: MindMapPlaceholderBlot): void {\n if (blot.currentNode) {\n blot.currentNode.setText('')\n blot.data = blot.mindMap.getData({})\n blot.domNode.setAttribute('data-mind-map', JSON.stringify(blot.data))\n }\n hideContextMenu(blot)\n}\n\nfunction hideContextMenu(blot: MindMapPlaceholderBlot): void {\n if (blot.contextMenu) {\n blot.contextMenu.style.display = 'none'\n }\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import "../../../config/index.es.js";
|
|
5
|
-
import { I18N } from "../../i18n.es.js";
|
|
6
|
-
import { getAllConfigs } from "../config-utils.es.js";
|
|
7
|
-
import { registerMindMapI18N } from "../i18n/index.es.js";
|
|
8
|
-
import { contractIcon, screenTypeIcon, setLayoutIcon, insertIconIcon, removeNodeIcon, insertParentNodeIcon, insertNodeIcon, insertChildNodeIcon, fitIcon, zoomInIcon, zoomOutIcon, forwardIcon, backIcon, logicalStructureIcon, catalogOrganizationIcon, mindMapIcon, organizationStructureIcon, timelineIcon, fishboneIcon, screenReduceIcon } from "../icons.es.js";
|
|
9
|
-
import { CHANGE_LANGUAGE_EVENT } from "../../../config/editor.config.es.js";
|
|
10
|
-
class MindMapControlPanelHandler {
|
|
11
|
-
constructor(quill, blot) {
|
|
12
|
-
__publicField(this, "texts");
|
|
13
|
-
__publicField(this, "lang");
|
|
14
|
-
this.quill = quill;
|
|
15
|
-
this.blot = blot;
|
|
16
|
-
const i18nModule = this.quill.getModule("i18n");
|
|
17
|
-
registerMindMapI18N(I18N);
|
|
18
|
-
this.lang = i18nModule.options.lang;
|
|
19
|
-
this.texts = this.resolveTexts();
|
|
20
|
-
this.quill.emitter.on(CHANGE_LANGUAGE_EVENT, (lang) => {
|
|
21
|
-
this.lang = lang;
|
|
22
|
-
this.texts = this.resolveTexts();
|
|
23
|
-
this.updateControlPanelTexts();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
getText(key) {
|
|
27
|
-
return this.texts[key];
|
|
28
|
-
}
|
|
29
|
-
resolveTexts() {
|
|
30
|
-
const textKeys = [
|
|
31
|
-
"zoomOutTitle",
|
|
32
|
-
"zoomInTitle",
|
|
33
|
-
"fitTitle",
|
|
34
|
-
"backTitle",
|
|
35
|
-
"forwardTitle",
|
|
36
|
-
"inserChildNodeTitle",
|
|
37
|
-
"inserNodeTitle",
|
|
38
|
-
"insertIconTitle",
|
|
39
|
-
"inserParentNodeTitle",
|
|
40
|
-
"removeNodeTitle",
|
|
41
|
-
"setLayoutTitle",
|
|
42
|
-
"logicalStructureLayout",
|
|
43
|
-
"catalogOrganizationLayout",
|
|
44
|
-
"mindMapLayout",
|
|
45
|
-
"organizationStructureLayout",
|
|
46
|
-
"timelineLayout",
|
|
47
|
-
"fishboneLayout",
|
|
48
|
-
"panelStatusTitle",
|
|
49
|
-
"screenTypeTitle"
|
|
50
|
-
];
|
|
51
|
-
return textKeys.reduce((acc, key) => {
|
|
52
|
-
if (!key.includes("Title")) {
|
|
53
|
-
acc[key] = I18N.parserText(`mindMap.layout.${key.replace("Layout", "")}`, this.lang);
|
|
54
|
-
} else {
|
|
55
|
-
acc[key] = I18N.parserText(`mindMap.controlPanel.${key}`, this.lang);
|
|
56
|
-
}
|
|
57
|
-
return acc;
|
|
58
|
-
}, {});
|
|
59
|
-
}
|
|
60
|
-
updateControlPanelTexts() {
|
|
61
|
-
const controlItems = this.blot.domNode.querySelectorAll(".ql-mind-map-control-item");
|
|
62
|
-
const controlItemMap = {
|
|
63
|
-
"zoom-out": "zoomOutTitle",
|
|
64
|
-
"zoom-in": "zoomInTitle",
|
|
65
|
-
"fit": "fitTitle",
|
|
66
|
-
"back": "backTitle",
|
|
67
|
-
"forward": "forwardTitle",
|
|
68
|
-
"insert-child-node": "inserChildNodeTitle",
|
|
69
|
-
"insert-node": "inserNodeTitle",
|
|
70
|
-
"insert-icon": "insertIconTitle",
|
|
71
|
-
"insert-parent-node": "inserParentNodeTitle",
|
|
72
|
-
"remove-node": "removeNodeTitle",
|
|
73
|
-
"set-layout-icon": "setLayoutTitle",
|
|
74
|
-
"panel-status": "panelStatusTitle",
|
|
75
|
-
"screen-type": "screenTypeTitle"
|
|
76
|
-
};
|
|
77
|
-
controlItems.forEach((item) => {
|
|
78
|
-
const controlType = item.dataset.controlType;
|
|
79
|
-
if (controlType && controlItemMap[controlType] && this.texts[controlItemMap[controlType]]) {
|
|
80
|
-
item.title = this.texts[controlItemMap[controlType]];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const controlPanelHandlers = /* @__PURE__ */ new WeakMap();
|
|
86
|
-
const DISABLED_OPACITY = "0.5";
|
|
87
|
-
const ENABLED_OPACITY = "1";
|
|
88
|
-
function createControlPanel(blot, quill) {
|
|
89
|
-
let isStart = true;
|
|
90
|
-
let isEnd = true;
|
|
91
|
-
let selectedNodes = [];
|
|
92
|
-
blot.mindMap.on("node_active", (...args) => {
|
|
93
|
-
selectedNodes = Array.isArray(args[1]) ? args[1] : [];
|
|
94
|
-
});
|
|
95
|
-
const controlPanel = document.createElement("div");
|
|
96
|
-
controlPanel.className = "ql-mind-map-control";
|
|
97
|
-
const controlRightUpPanel = document.createElement("div");
|
|
98
|
-
controlRightUpPanel.className = "ql-mind-map-right-up-control";
|
|
99
|
-
const controlLeftUpPanel = document.createElement("div");
|
|
100
|
-
controlLeftUpPanel.className = "ql-mind-map-left-up-control";
|
|
101
|
-
const handler = new MindMapControlPanelHandler(quill, blot);
|
|
102
|
-
controlPanelHandlers.set(blot, handler);
|
|
103
|
-
const zoomOutBtn = createControlItem("zoom-out", handler.getText("zoomOutTitle"), () => handleZoomOut(blot));
|
|
104
|
-
const zoomInBtn = createControlItem("zoom-in", handler.getText("zoomInTitle"), () => handleZoomIn(blot));
|
|
105
|
-
const resetBtn = createControlItem("fit", handler.getText("fitTitle"), () => handleResetZoom(blot));
|
|
106
|
-
const backBtn = createControlItem("back", handler.getText("backTitle"), () => {
|
|
107
|
-
if (!isStart) {
|
|
108
|
-
blot.mindMap.execCommand("BACK");
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
const forwardBtn = createControlItem("forward", handler.getText("forwardTitle"), () => {
|
|
112
|
-
if (!isEnd) {
|
|
113
|
-
blot.mindMap.execCommand("FORWARD");
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
const insertChildNode = createControlItem("insert-child-node", handler.getText("inserChildNodeTitle"), () => handleInsertChildNode(blot));
|
|
117
|
-
const insertNode = createControlItem("insert-node", handler.getText("inserNodeTitle"), () => handleInsertNode(blot));
|
|
118
|
-
const insertParentNode = createControlItem("insert-parent-node", handler.getText("inserParentNodeTitle"), () => handleInsertParentNode(blot));
|
|
119
|
-
const removeNode = createControlItem("remove-node", handler.getText("removeNodeTitle"), () => handleRemoveNode(blot));
|
|
120
|
-
const insertIconBtn = createControlItem("insert-icon", handler.getText("insertIconTitle"), () => handleInsertIcon(blot, selectedNodes));
|
|
121
|
-
const setLayoutBtn = createControlItem("set-layout-icon", handler.getText("setLayoutTitle"), () => handleSetLayoutBtn(blot));
|
|
122
|
-
const panelStatusBtn = createControlItem("panel-status", handler.getText("panelStatusTitle"));
|
|
123
|
-
const screenTypeBtn = createControlItem("screen-type", handler.getText("screenTypeTitle"), () => handleScreenTypeBtn(blot));
|
|
124
|
-
const updateButtonState = (index, len) => {
|
|
125
|
-
isStart = index <= 0;
|
|
126
|
-
isEnd = index >= len - 1;
|
|
127
|
-
backBtn.style.cursor = isStart ? "not-allowed" : "pointer";
|
|
128
|
-
backBtn.style.opacity = isStart ? DISABLED_OPACITY : ENABLED_OPACITY;
|
|
129
|
-
forwardBtn.style.cursor = isEnd ? "not-allowed" : "pointer";
|
|
130
|
-
forwardBtn.style.opacity = isEnd ? DISABLED_OPACITY : ENABLED_OPACITY;
|
|
131
|
-
};
|
|
132
|
-
blot.mindMap.on("back_forward", (index, len) => {
|
|
133
|
-
updateButtonState(index, len);
|
|
134
|
-
});
|
|
135
|
-
controlPanel.append(zoomOutBtn, zoomInBtn, resetBtn, screenTypeBtn, backBtn, forwardBtn);
|
|
136
|
-
blot.domNode.appendChild(controlPanel);
|
|
137
|
-
controlRightUpPanel.append(panelStatusBtn);
|
|
138
|
-
blot.domNode.appendChild(controlRightUpPanel);
|
|
139
|
-
controlLeftUpPanel.append(insertChildNode, insertNode, insertParentNode, removeNode, insertIconBtn, setLayoutBtn);
|
|
140
|
-
blot.domNode.appendChild(controlLeftUpPanel);
|
|
141
|
-
}
|
|
142
|
-
function createControlItem(iconClass, title, onClick, disabled = false) {
|
|
143
|
-
const controlItem = document.createElement("div");
|
|
144
|
-
controlItem.className = "ql-mind-map-control-item";
|
|
145
|
-
controlItem.title = title;
|
|
146
|
-
controlItem.dataset.controlType = iconClass;
|
|
147
|
-
controlItem.style.cursor = disabled ? "not-allowed" : "pointer";
|
|
148
|
-
controlItem.style.opacity = disabled ? DISABLED_OPACITY : ENABLED_OPACITY;
|
|
149
|
-
const iconMap = {
|
|
150
|
-
"back": backIcon,
|
|
151
|
-
"forward": forwardIcon,
|
|
152
|
-
"zoom-out": zoomOutIcon,
|
|
153
|
-
"zoom-in": zoomInIcon,
|
|
154
|
-
"fit": fitIcon,
|
|
155
|
-
"insert-child-node": insertChildNodeIcon,
|
|
156
|
-
"insert-node": insertNodeIcon,
|
|
157
|
-
"insert-parent-node": insertParentNodeIcon,
|
|
158
|
-
"remove-node": removeNodeIcon,
|
|
159
|
-
"insert-icon": insertIconIcon,
|
|
160
|
-
"set-layout-icon": setLayoutIcon,
|
|
161
|
-
"screen-type": screenTypeIcon,
|
|
162
|
-
"panel-status": contractIcon
|
|
163
|
-
};
|
|
164
|
-
const icon = document.createElement("i");
|
|
165
|
-
icon.innerHTML = iconMap[iconClass] || "";
|
|
166
|
-
controlItem.appendChild(icon);
|
|
167
|
-
if (!disabled) {
|
|
168
|
-
controlItem.addEventListener("click", onClick);
|
|
169
|
-
}
|
|
170
|
-
return controlItem;
|
|
171
|
-
}
|
|
172
|
-
function handleInsertChildNode(blot) {
|
|
173
|
-
blot.mindMap.execCommand("INSERT_CHILD_NODE");
|
|
174
|
-
}
|
|
175
|
-
function handleInsertNode(blot) {
|
|
176
|
-
blot.mindMap.execCommand("INSERT_NODE");
|
|
177
|
-
}
|
|
178
|
-
function handleInsertParentNode(blot) {
|
|
179
|
-
blot.mindMap.execCommand("INSERT_PARENT_NODE");
|
|
180
|
-
}
|
|
181
|
-
function handleRemoveNode(blot) {
|
|
182
|
-
blot.mindMap.execCommand("REMOVE_CURRENT_NODE");
|
|
183
|
-
}
|
|
184
|
-
function handleZoomIn(blot) {
|
|
185
|
-
if (blot.mindMap && blot.mindMap.view) {
|
|
186
|
-
const containerRect = blot.mindMap.el.getBoundingClientRect();
|
|
187
|
-
const cx = containerRect.width / 2;
|
|
188
|
-
const cy = containerRect.height / 2;
|
|
189
|
-
blot.mindMap.view.enlarge(cx, cy, false);
|
|
190
|
-
blot.zoomCount++;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function handleZoomOut(blot) {
|
|
194
|
-
if (blot.mindMap && blot.mindMap.view) {
|
|
195
|
-
const containerRect = blot.mindMap.el.getBoundingClientRect();
|
|
196
|
-
const cx = containerRect.width / 2;
|
|
197
|
-
const cy = containerRect.height / 2;
|
|
198
|
-
blot.mindMap.view.narrow(cx, cy, false);
|
|
199
|
-
blot.zoomCount--;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
function handleResetZoom(blot) {
|
|
203
|
-
blot.mindMap.renderer.setRootNodeCenter();
|
|
204
|
-
if (!blot.mindMap || !blot.mindMap.view || blot.zoomCount === 0) return;
|
|
205
|
-
const containerRect = blot.mindMap.el.getBoundingClientRect();
|
|
206
|
-
const centerX = containerRect.width / 2;
|
|
207
|
-
const centerY = containerRect.height / 2;
|
|
208
|
-
const operationCount = Math.abs(blot.zoomCount);
|
|
209
|
-
const isEnlarge = blot.zoomCount < 0;
|
|
210
|
-
for (let i = 0; i < operationCount; i++) {
|
|
211
|
-
if (isEnlarge) {
|
|
212
|
-
blot.mindMap.view.enlarge(centerX, centerY, false);
|
|
213
|
-
} else {
|
|
214
|
-
blot.mindMap.view.narrow(centerX, centerY, false);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
blot.zoomCount = 0;
|
|
218
|
-
}
|
|
219
|
-
function handleInsertIcon(blot, selectedNodes) {
|
|
220
|
-
blot.selectedNodes = selectedNodes;
|
|
221
|
-
const heightStr = blot.domNode.getAttribute("height") || "500px";
|
|
222
|
-
const height = Number.parseInt(heightStr.replace(/[^\d.]/g, ""), 10) || 500;
|
|
223
|
-
let iconList = [];
|
|
224
|
-
const { deps } = getAllConfigs(blot.quill);
|
|
225
|
-
iconList = deps.nodeIconList.nodeIconList ? deps.nodeIconList.nodeIconList : deps.nodeIconList;
|
|
226
|
-
const leftUpControl = blot.domNode.querySelector(".ql-mind-map-left-up-control");
|
|
227
|
-
let iconPanel = leftUpControl.querySelector(".ql-mind-map-icon-panel");
|
|
228
|
-
if (!iconPanel) {
|
|
229
|
-
iconPanel = document.createElement("div");
|
|
230
|
-
iconPanel.className = "ql-mind-map-icon-panel";
|
|
231
|
-
iconList == null ? void 0 : iconList.forEach((group) => {
|
|
232
|
-
const groupContainer = document.createElement("div");
|
|
233
|
-
groupContainer.className = "ql-mind-map-icon-group-container";
|
|
234
|
-
group.list.forEach((icon) => {
|
|
235
|
-
const iconItem = document.createElement("div");
|
|
236
|
-
iconItem.className = "ql-mind-map-icon-item";
|
|
237
|
-
iconItem.innerHTML = icon.icon;
|
|
238
|
-
iconItem.addEventListener("click", () => {
|
|
239
|
-
const currentSelectedNodes = blot.selectedNodes || [];
|
|
240
|
-
if (currentSelectedNodes.length > 0) {
|
|
241
|
-
const node = currentSelectedNodes[0];
|
|
242
|
-
if (node.getData("icon") && node.getData("icon")[0] === `${group.type}_${icon.name}`) {
|
|
243
|
-
node.setIcon([]);
|
|
244
|
-
} else {
|
|
245
|
-
node.setIcon([`${group.type}_${icon.name}`]);
|
|
246
|
-
}
|
|
247
|
-
blot.data = blot.mindMap.getData({});
|
|
248
|
-
blot.domNode.setAttribute("data-mind-map", JSON.stringify(blot.data));
|
|
249
|
-
}
|
|
250
|
-
iconPanel.style.display = "none";
|
|
251
|
-
});
|
|
252
|
-
groupContainer.appendChild(iconItem);
|
|
253
|
-
});
|
|
254
|
-
iconPanel.appendChild(groupContainer);
|
|
255
|
-
});
|
|
256
|
-
if (height < 395) {
|
|
257
|
-
iconPanel.style.height = `${height - 130}px`;
|
|
258
|
-
} else {
|
|
259
|
-
iconPanel.style.height = "270px";
|
|
260
|
-
}
|
|
261
|
-
leftUpControl.appendChild(iconPanel);
|
|
262
|
-
} else {
|
|
263
|
-
if (height < 395) {
|
|
264
|
-
iconPanel.style.height = `${height - 130}px`;
|
|
265
|
-
} else {
|
|
266
|
-
iconPanel.style.height = "270px";
|
|
267
|
-
}
|
|
268
|
-
iconPanel.style.display = "block";
|
|
269
|
-
}
|
|
270
|
-
const handleOutsideClick = (e) => {
|
|
271
|
-
let insertIconBtn = null;
|
|
272
|
-
const controlItems = leftUpControl.querySelectorAll(".ql-mind-map-control-item");
|
|
273
|
-
controlItems.forEach((item) => {
|
|
274
|
-
if (item.dataset.controlType === "insert-icon") {
|
|
275
|
-
insertIconBtn = item;
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
if (!iconPanel.contains(e.target) && (!insertIconBtn || !insertIconBtn.contains(e.target))) {
|
|
279
|
-
iconPanel.style.display = "none";
|
|
280
|
-
document.removeEventListener("click", handleOutsideClick);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
document.removeEventListener("click", handleOutsideClick);
|
|
284
|
-
document.addEventListener("click", handleOutsideClick);
|
|
285
|
-
}
|
|
286
|
-
function handleSetLayoutBtn(blot) {
|
|
287
|
-
const handler = controlPanelHandlers.get(blot);
|
|
288
|
-
const leftUpControl = blot.domNode.querySelector(".ql-mind-map-left-up-control");
|
|
289
|
-
let layoutPanel = leftUpControl.querySelector(".ql-mind-map-layout-panel");
|
|
290
|
-
const heightStr = blot.domNode.getAttribute("height") || "500";
|
|
291
|
-
const height = Number.parseInt(heightStr.replace(/[^\d.]/g, ""), 10) || 500;
|
|
292
|
-
if (!layoutPanel) {
|
|
293
|
-
layoutPanel = document.createElement("div");
|
|
294
|
-
layoutPanel.className = "ql-mind-map-layout-panel";
|
|
295
|
-
const layouts = [
|
|
296
|
-
{
|
|
297
|
-
name: "logicalStructure",
|
|
298
|
-
displayName: handler == null ? void 0 : handler.getText("logicalStructureLayout"),
|
|
299
|
-
icon: logicalStructureIcon
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: "catalogOrganization",
|
|
303
|
-
displayName: handler == null ? void 0 : handler.getText("catalogOrganizationLayout"),
|
|
304
|
-
icon: catalogOrganizationIcon
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
name: "mindMap",
|
|
308
|
-
displayName: handler == null ? void 0 : handler.getText("mindMapLayout"),
|
|
309
|
-
icon: mindMapIcon
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
name: "organizationStructure",
|
|
313
|
-
displayName: handler == null ? void 0 : handler.getText("organizationStructureLayout"),
|
|
314
|
-
icon: organizationStructureIcon
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
name: "timeline",
|
|
318
|
-
displayName: handler == null ? void 0 : handler.getText("timelineLayout"),
|
|
319
|
-
icon: timelineIcon
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
name: "fishbone",
|
|
323
|
-
displayName: handler == null ? void 0 : handler.getText("fishboneLayout"),
|
|
324
|
-
icon: fishboneIcon
|
|
325
|
-
}
|
|
326
|
-
];
|
|
327
|
-
layouts.forEach((layout) => {
|
|
328
|
-
const layoutItem = document.createElement("div");
|
|
329
|
-
layoutItem.className = "ql-mind-map-layout-item";
|
|
330
|
-
const iconContainer = document.createElement("div");
|
|
331
|
-
iconContainer.className = "ql-mind-map-layout-icon-container";
|
|
332
|
-
const img = document.createElement("div");
|
|
333
|
-
img.className = "ql-mind-map-layout-icon";
|
|
334
|
-
img.innerHTML = layout.icon;
|
|
335
|
-
img.style.display = "flex";
|
|
336
|
-
img.style.alignItems = "center";
|
|
337
|
-
img.style.justifyContent = "center";
|
|
338
|
-
const svgElement = img.querySelector("svg");
|
|
339
|
-
svgElement.style.maxWidth = "100%";
|
|
340
|
-
svgElement.style.maxHeight = "100%";
|
|
341
|
-
svgElement.style.width = "auto";
|
|
342
|
-
svgElement.style.height = "auto";
|
|
343
|
-
svgElement.removeAttribute("width");
|
|
344
|
-
svgElement.removeAttribute("height");
|
|
345
|
-
iconContainer.appendChild(img);
|
|
346
|
-
const nameText = document.createElement("div");
|
|
347
|
-
nameText.className = "ql-mind-map-layout-name";
|
|
348
|
-
nameText.textContent = layout.displayName;
|
|
349
|
-
layoutItem.appendChild(iconContainer);
|
|
350
|
-
layoutItem.appendChild(nameText);
|
|
351
|
-
layoutItem.addEventListener("click", () => {
|
|
352
|
-
blot.mindMap.setLayout(layout.name);
|
|
353
|
-
blot.data = blot.mindMap.getData({});
|
|
354
|
-
blot.domNode.setAttribute("data-mind-map", JSON.stringify(blot.data));
|
|
355
|
-
layoutPanel.style.display = "none";
|
|
356
|
-
});
|
|
357
|
-
layoutPanel.appendChild(layoutItem);
|
|
358
|
-
});
|
|
359
|
-
leftUpControl.appendChild(layoutPanel);
|
|
360
|
-
if (height < 395) {
|
|
361
|
-
layoutPanel.style.height = `${height - 130}px`;
|
|
362
|
-
} else {
|
|
363
|
-
layoutPanel.style.height = "270px";
|
|
364
|
-
}
|
|
365
|
-
} else {
|
|
366
|
-
if (height < 395) {
|
|
367
|
-
layoutPanel.style.height = `${height - 130}px`;
|
|
368
|
-
} else {
|
|
369
|
-
layoutPanel.style.height = "270px";
|
|
370
|
-
}
|
|
371
|
-
layoutPanel.style.display = "flex";
|
|
372
|
-
}
|
|
373
|
-
const handleOutsideClick = (e) => {
|
|
374
|
-
let setLayoutBtn = null;
|
|
375
|
-
const controlItems = leftUpControl.querySelectorAll(".ql-mind-map-control-item");
|
|
376
|
-
setLayoutBtn = Array.from(controlItems).find((item) => item.getAttribute("data-control-type") === "set-layout-icon");
|
|
377
|
-
if (!layoutPanel.contains(e.target) && (!setLayoutBtn || !setLayoutBtn.contains(e.target))) {
|
|
378
|
-
layoutPanel.style.display = "none";
|
|
379
|
-
document.removeEventListener("click", handleOutsideClick);
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
document.removeEventListener("click", handleOutsideClick);
|
|
383
|
-
document.addEventListener("click", handleOutsideClick);
|
|
384
|
-
}
|
|
385
|
-
function handleScreenTypeBtn(blot) {
|
|
386
|
-
const screenTypeBtn = blot.domNode.querySelector('[data-control-type="screen-type"]');
|
|
387
|
-
if (!screenTypeBtn || !blot.domNode) return;
|
|
388
|
-
const mindMapContainer = blot.domNode;
|
|
389
|
-
const isFullscreen = mindMapContainer.style.position === "fixed";
|
|
390
|
-
if (isFullscreen) {
|
|
391
|
-
const originalPosition = mindMapContainer.getAttribute("data-original-position");
|
|
392
|
-
const originalWidth = mindMapContainer.getAttribute("data-original-width");
|
|
393
|
-
const originalHeight = mindMapContainer.getAttribute("data-original-height");
|
|
394
|
-
if (originalWidth && originalHeight) {
|
|
395
|
-
mindMapContainer.style.position = originalPosition;
|
|
396
|
-
mindMapContainer.style.width = originalWidth;
|
|
397
|
-
mindMapContainer.style.height = originalHeight;
|
|
398
|
-
mindMapContainer.style.zIndex = "0";
|
|
399
|
-
}
|
|
400
|
-
const iconElement = screenTypeBtn.querySelector("i");
|
|
401
|
-
if (iconElement) {
|
|
402
|
-
iconElement.innerHTML = screenTypeIcon;
|
|
403
|
-
}
|
|
404
|
-
} else {
|
|
405
|
-
mindMapContainer.setAttribute("data-original-position", mindMapContainer.style.position || "");
|
|
406
|
-
mindMapContainer.setAttribute("data-original-width", mindMapContainer.style.width || "");
|
|
407
|
-
mindMapContainer.setAttribute("data-original-height", mindMapContainer.style.height || "");
|
|
408
|
-
mindMapContainer.style.position = "fixed";
|
|
409
|
-
mindMapContainer.style.top = "0";
|
|
410
|
-
mindMapContainer.style.left = "0";
|
|
411
|
-
mindMapContainer.style.width = "100vw";
|
|
412
|
-
mindMapContainer.style.height = "100vh";
|
|
413
|
-
mindMapContainer.style.zIndex = "100";
|
|
414
|
-
const iconElement = screenTypeBtn.querySelector("i");
|
|
415
|
-
if (iconElement) {
|
|
416
|
-
iconElement.innerHTML = screenReduceIcon;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
blot.mindMap.renderer.setRootNodeCenter();
|
|
420
|
-
blot.mindMap.resize();
|
|
421
|
-
}
|
|
422
|
-
export {
|
|
423
|
-
createControlPanel
|
|
424
|
-
};
|
|
425
|
-
//# sourceMappingURL=control-panel.es.js.map
|