@tmagic/editor 1.7.7 → 1.7.8-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/LICENSE +235 -164
- package/dist/es/Editor.js +5 -0
- package/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +214 -0
- package/dist/es/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/es/components/CodeBlockEditor.js +5 -0
- package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +337 -0
- package/dist/es/components/CodeParams.js +5 -0
- package/dist/es/components/CodeParams.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/es/components/ContentMenu.js +5 -0
- package/dist/es/components/ContentMenu.vue_vue_type_script_setup_true_lang.js +160 -0
- package/dist/es/components/FloatingBox.js +5 -0
- package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/es/components/Icon.js +5 -0
- package/dist/es/components/Icon.vue_vue_type_script_setup_true_lang.js +39 -0
- package/dist/es/components/Resizer.js +5 -0
- package/dist/es/components/Resizer.vue_vue_type_script_setup_true_lang.js +20 -0
- package/dist/es/components/ScrollBar.js +6 -0
- package/dist/es/components/ScrollBar.vue_vue_type_script_setup_true_lang.js +72 -0
- package/dist/es/components/ScrollViewer.js +5 -0
- package/dist/es/components/ScrollViewer.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/es/components/SearchInput.js +5 -0
- package/dist/es/components/SearchInput.vue_vue_type_script_setup_true_lang.js +40 -0
- package/dist/es/components/SplitView.js +5 -0
- package/dist/es/components/SplitView.vue_vue_type_script_setup_true_lang.js +135 -0
- package/dist/es/components/ToolButton.js +5 -0
- package/dist/es/components/ToolButton.vue_vue_type_script_setup_true_lang.js +131 -0
- package/dist/es/components/Tree.js +5 -0
- package/dist/es/components/Tree.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/es/components/TreeNode.js +5 -0
- package/dist/es/components/TreeNode.vue_vue_type_script_setup_true_lang.js +126 -0
- package/dist/es/editorProps.js +34 -0
- package/dist/es/fields/Code.js +5 -0
- package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +54 -0
- package/dist/es/fields/CodeLink.js +5 -0
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +69 -0
- package/dist/es/fields/CodeSelect.js +5 -0
- package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/es/fields/CodeSelectCol.js +5 -0
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +145 -0
- package/dist/es/fields/CondOpSelect.js +5 -0
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +81 -0
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.js +5 -0
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +158 -0
- package/dist/es/fields/DataSourceFieldSelect/Index.js +5 -0
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +155 -0
- package/dist/es/fields/DataSourceFields.js +5 -0
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +390 -0
- package/dist/es/fields/DataSourceInput.js +5 -0
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +268 -0
- package/dist/es/fields/DataSourceMethodSelect.js +5 -0
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +144 -0
- package/dist/es/fields/DataSourceMethods.js +5 -0
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +148 -0
- package/dist/es/fields/DataSourceMocks.js +5 -0
- package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +259 -0
- package/dist/es/fields/DataSourceSelect.js +5 -0
- package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +101 -0
- package/dist/es/fields/DisplayConds.js +5 -0
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +156 -0
- package/dist/es/fields/EventSelect.js +5 -0
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +338 -0
- package/dist/es/fields/KeyValue.js +5 -0
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +158 -0
- package/dist/es/fields/PageFragmentSelect.js +5 -0
- package/dist/es/fields/PageFragmentSelect.vue_vue_type_script_setup_true_lang.js +81 -0
- package/dist/es/fields/StyleSetter/Index.js +5 -0
- package/dist/es/fields/StyleSetter/Index.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/es/fields/StyleSetter/components/BackgroundPosition.js +5 -0
- package/dist/es/fields/StyleSetter/components/BackgroundPosition.vue_vue_type_script_setup_true_lang.js +96 -0
- package/dist/es/fields/StyleSetter/components/Border.js +5 -0
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/es/fields/StyleSetter/components/Box.js +5 -0
- package/dist/es/fields/StyleSetter/components/Box.vue_vue_type_script_setup_true_lang.js +81 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/NoRepeat.js +17 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/Repeat.js +14 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatX.js +17 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatY.js +17 -0
- package/dist/es/fields/StyleSetter/icons/display/Block.js +14 -0
- package/dist/es/fields/StyleSetter/icons/display/Flex.js +14 -0
- package/dist/es/fields/StyleSetter/icons/display/Inline.js +14 -0
- package/dist/es/fields/StyleSetter/icons/display/InlineBlock.js +14 -0
- package/dist/es/fields/StyleSetter/icons/display/None.js +14 -0
- package/dist/es/fields/StyleSetter/icons/flex-direction/Column.js +14 -0
- package/dist/es/fields/StyleSetter/icons/flex-direction/ColumnReverse.js +14 -0
- package/dist/es/fields/StyleSetter/icons/flex-direction/Row.js +14 -0
- package/dist/es/fields/StyleSetter/icons/flex-direction/RowReverse.js +14 -0
- package/dist/es/fields/StyleSetter/icons/justify-content/Center.js +14 -0
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexEnd.js +14 -0
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexStart.js +14 -0
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceAround.js +14 -0
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceBetween.js +14 -0
- package/dist/es/fields/StyleSetter/icons/text-align/Center.js +14 -0
- package/dist/es/fields/StyleSetter/icons/text-align/Left.js +14 -0
- package/dist/es/fields/StyleSetter/icons/text-align/Right.js +14 -0
- package/dist/es/fields/StyleSetter/pro/Background.js +5 -0
- package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +114 -0
- package/dist/es/fields/StyleSetter/pro/Border.js +5 -0
- package/dist/es/fields/StyleSetter/pro/Border.vue_vue_type_script_setup_true_lang.js +50 -0
- package/dist/es/fields/StyleSetter/pro/Font.js +5 -0
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +98 -0
- package/dist/es/fields/StyleSetter/pro/Layout.js +5 -0
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +288 -0
- package/dist/es/fields/StyleSetter/pro/Position.js +5 -0
- package/dist/es/fields/StyleSetter/pro/Position.vue_vue_type_script_setup_true_lang.js +95 -0
- package/dist/es/fields/UISelect.js +6 -0
- package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/es/hooks/use-code-block-edit.js +54 -0
- package/dist/es/hooks/use-data-source-edit.js +29 -0
- package/dist/es/hooks/use-editor-content-height.js +17 -0
- package/dist/es/hooks/use-filter.js +35 -0
- package/dist/es/hooks/use-float-box.js +76 -0
- package/dist/es/hooks/use-getso.js +28 -0
- package/dist/es/hooks/use-next-float-box-position.js +27 -0
- package/dist/es/hooks/use-node-status.js +28 -0
- package/dist/es/hooks/use-services.js +9 -0
- package/dist/es/hooks/use-stage.js +107 -0
- package/dist/es/hooks/use-window-rect.js +19 -0
- package/dist/es/icons/CenterIcon.js +5 -0
- package/dist/es/icons/CenterIcon.vue_vue_type_script_setup_true_lang.js +40 -0
- package/dist/es/icons/CodeIcon.js +5 -0
- package/dist/es/icons/CodeIcon.vue_vue_type_script_setup_true_lang.js +19 -0
- package/dist/es/icons/FolderMinusIcon.js +5 -0
- package/dist/es/icons/FolderMinusIcon.vue_vue_type_script_setup_true_lang.js +27 -0
- package/dist/es/index.js +79 -0
- package/dist/es/initService.js +392 -0
- package/dist/es/layouts/AddPageBox.js +5 -0
- package/dist/es/layouts/AddPageBox.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/es/layouts/CodeEditor.js +5 -0
- package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +270 -0
- package/dist/es/layouts/Framework.js +5 -0
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +134 -0
- package/dist/es/layouts/NavMenu.js +5 -0
- package/dist/es/layouts/NavMenu.vue_vue_type_script_setup_true_lang.js +181 -0
- package/dist/es/layouts/page-bar/AddButton.js +5 -0
- package/dist/es/layouts/page-bar/AddButton.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/es/layouts/page-bar/PageBar.js +5 -0
- package/dist/es/layouts/page-bar/PageBar.vue_vue_type_script_setup_true_lang.js +135 -0
- package/dist/es/layouts/page-bar/PageBarScrollContainer.js +5 -0
- package/dist/es/layouts/page-bar/PageBarScrollContainer.vue_vue_type_script_setup_true_lang.js +119 -0
- package/dist/es/layouts/page-bar/PageList.js +5 -0
- package/dist/es/layouts/page-bar/PageList.vue_vue_type_script_setup_true_lang.js +54 -0
- package/dist/es/layouts/page-bar/Search.js +5 -0
- package/dist/es/layouts/page-bar/Search.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/es/layouts/props-panel/FormPanel.js +5 -0
- package/dist/es/layouts/props-panel/FormPanel.vue_vue_type_script_setup_true_lang.js +129 -0
- package/dist/es/layouts/props-panel/PropsPanel.js +5 -0
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +179 -0
- package/dist/es/layouts/props-panel/use-style-panel.js +40 -0
- package/dist/es/layouts/sidebar/ComponentListPanel.js +5 -0
- package/dist/es/layouts/sidebar/ComponentListPanel.vue_vue_type_script_setup_true_lang.js +121 -0
- package/dist/es/layouts/sidebar/Sidebar.js +5 -0
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +314 -0
- package/dist/es/layouts/sidebar/code-block/CodeBlockList.js +5 -0
- package/dist/es/layouts/sidebar/code-block/CodeBlockList.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/es/layouts/sidebar/code-block/CodeBlockListPanel.js +5 -0
- package/dist/es/layouts/sidebar/code-block/CodeBlockListPanel.vue_vue_type_script_setup_true_lang.js +113 -0
- package/dist/es/layouts/sidebar/code-block/useContentMenu.js +60 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceAddButton.js +5 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceAddButton.vue_vue_type_script_setup_true_lang.js +44 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceConfigPanel.js +5 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceConfigPanel.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceList.js +5 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceList.vue_vue_type_script_setup_true_lang.js +162 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.js +5 -0
- package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +133 -0
- package/dist/es/layouts/sidebar/data-source/useContentMenu.js +59 -0
- package/dist/es/layouts/sidebar/layer/LayerMenu.js +5 -0
- package/dist/es/layouts/sidebar/layer/LayerMenu.vue_vue_type_script_setup_true_lang.js +90 -0
- package/dist/es/layouts/sidebar/layer/LayerNodeTool.js +5 -0
- package/dist/es/layouts/sidebar/layer/LayerNodeTool.vue_vue_type_script_setup_true_lang.js +35 -0
- package/dist/es/layouts/sidebar/layer/LayerPanel.js +5 -0
- package/dist/es/layouts/sidebar/layer/LayerPanel.vue_vue_type_script_setup_true_lang.js +99 -0
- package/dist/es/layouts/sidebar/layer/use-click.js +68 -0
- package/dist/es/layouts/sidebar/layer/use-drag.js +118 -0
- package/dist/es/layouts/sidebar/layer/use-keybinding.js +36 -0
- package/dist/es/layouts/sidebar/layer/use-node-status.js +75 -0
- package/dist/es/layouts/workspace/Breadcrumb.js +5 -0
- package/dist/es/layouts/workspace/Breadcrumb.vue_vue_type_script_setup_true_lang.js +39 -0
- package/dist/es/layouts/workspace/Workspace.js +5 -0
- package/dist/es/layouts/workspace/Workspace.vue_vue_type_script_setup_true_lang.js +43 -0
- package/dist/es/layouts/workspace/viewer/NodeListMenu.js +5 -0
- package/dist/es/layouts/workspace/viewer/NodeListMenu.vue_vue_type_script_setup_true_lang.js +88 -0
- package/dist/es/layouts/workspace/viewer/Stage.js +5 -0
- package/dist/es/layouts/workspace/viewer/Stage.vue_vue_type_script_setup_true_lang.js +206 -0
- package/dist/es/layouts/workspace/viewer/StageOverlay.js +5 -0
- package/dist/es/layouts/workspace/viewer/StageOverlay.vue_vue_type_script_setup_true_lang.js +89 -0
- package/dist/es/layouts/workspace/viewer/ViewerMenu.js +5 -0
- package/dist/es/layouts/workspace/viewer/ViewerMenu.vue_vue_type_script_setup_true_lang.js +132 -0
- package/dist/es/plugin.js +61 -0
- package/dist/es/services/BaseService.js +148 -0
- package/dist/es/services/codeBlock.js +251 -0
- package/dist/es/services/componentList.js +29 -0
- package/dist/es/services/dataSource.js +157 -0
- package/dist/es/services/dep.js +173 -0
- package/dist/es/services/editor.js +752 -0
- package/dist/es/services/events.js +64 -0
- package/dist/es/services/history.js +84 -0
- package/dist/es/services/keybinding.js +182 -0
- package/dist/es/services/props.js +216 -0
- package/dist/es/services/stageOverlay.js +161 -0
- package/dist/es/services/storage.js +127 -0
- package/dist/es/services/ui.js +112 -0
- package/dist/es/style.css +1937 -0
- package/dist/es/type.js +90 -0
- package/dist/es/utils/compose.js +44 -0
- package/dist/es/utils/config.js +8 -0
- package/dist/es/utils/const.js +15 -0
- package/dist/es/utils/content-menu.js +76 -0
- package/dist/es/utils/data-source/formConfigs/base.js +28 -0
- package/dist/es/utils/data-source/formConfigs/http.js +74 -0
- package/dist/es/utils/data-source/index.js +202 -0
- package/dist/es/utils/dep/idle-task.js +76 -0
- package/dist/es/utils/dep/worker.js +19 -0
- package/dist/es/utils/editor.js +261 -0
- package/dist/es/utils/keybinding-config.js +106 -0
- package/dist/es/utils/logger.js +18 -0
- package/dist/es/utils/monaco-editor.js +13 -0
- package/dist/es/utils/operator.js +73 -0
- package/dist/es/utils/props.js +232 -0
- package/dist/es/utils/scroll-viewer.js +115 -0
- package/dist/es/utils/tree.js +11 -0
- package/dist/es/utils/undo-redo.js +43 -0
- package/dist/style.css +10 -10
- package/dist/tmagic-editor.umd.cjs +18430 -21979
- package/package.json +16 -12
- package/src/components/CodeBlockEditor.vue +2 -8
- package/src/fields/CodeLink.vue +2 -2
- package/src/fields/CodeSelectCol.vue +1 -1
- package/src/fields/DataSourceFieldSelect/Index.vue +16 -3
- package/src/fields/DataSourceFields.vue +4 -1
- package/src/fields/EventSelect.vue +11 -11
- package/src/fields/StyleSetter/components/BackgroundPosition.vue +2 -2
- package/src/fields/StyleSetter/pro/Layout.vue +8 -8
- package/src/index.ts +1 -73
- package/src/plugin.ts +92 -0
- package/src/services/props.ts +3 -1
- package/src/type.ts +1 -1
- package/src/utils/data-source/index.ts +71 -73
- package/src/utils/index.ts +1 -0
- package/src/utils/props.ts +9 -7
- package/types/index.d.ts +3369 -3319
- package/dist/tmagic-editor.js +0 -17053
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { getEditorConfig } from "../utils/config.js";
|
|
2
|
+
import monaco_editor_default from "../utils/monaco-editor.js";
|
|
3
|
+
import Icon_default from "../components/Icon.js";
|
|
4
|
+
import { TMagicButton } from "@tmagic/design";
|
|
5
|
+
import { Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, onUnmounted, openBlock, ref, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
6
|
+
import { throttle } from "lodash-es";
|
|
7
|
+
import serialize from "serialize-javascript";
|
|
8
|
+
import { FullScreen } from "@element-plus/icons-vue";
|
|
9
|
+
//#region packages/editor/src/layouts/CodeEditor.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
var _hoisted_1 = { class: "magic-code-editor" };
|
|
11
|
+
var _hoisted_2 = {
|
|
12
|
+
ref: "codeEditor",
|
|
13
|
+
class: "magic-code-editor-content"
|
|
14
|
+
};
|
|
15
|
+
var CodeEditor_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
16
|
+
name: "MEditorCodeEditor",
|
|
17
|
+
__name: "CodeEditor",
|
|
18
|
+
props: {
|
|
19
|
+
initValues: { default: "" },
|
|
20
|
+
modifiedValues: {},
|
|
21
|
+
type: {},
|
|
22
|
+
language: { default: "javascript" },
|
|
23
|
+
options: { default: () => ({ tabSize: 2 }) },
|
|
24
|
+
height: {},
|
|
25
|
+
autoSave: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
parse: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
disabledFullScreen: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
autosize: {},
|
|
38
|
+
editorCustomType: {}
|
|
39
|
+
},
|
|
40
|
+
emits: ["initd", "save"],
|
|
41
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
42
|
+
const props = __props;
|
|
43
|
+
const emit = __emit;
|
|
44
|
+
const autoHeight = ref("");
|
|
45
|
+
let cachedExtraHeight = null;
|
|
46
|
+
const computeHeight = computed(() => {
|
|
47
|
+
if (fullScreen.value) return "100%";
|
|
48
|
+
if (props.height) return props.height;
|
|
49
|
+
if (props.autosize) return autoHeight.value;
|
|
50
|
+
return "100%";
|
|
51
|
+
});
|
|
52
|
+
const calculateExtraHeight = () => {
|
|
53
|
+
let extraHeight = 10;
|
|
54
|
+
if (vsEditor && codeEditorEl.value) try {
|
|
55
|
+
const editorElement = codeEditorEl.value.querySelector(".monaco-editor");
|
|
56
|
+
const scrollableElement = codeEditorEl.value.querySelector(".monaco-scrollable-element");
|
|
57
|
+
if (editorElement && scrollableElement) {
|
|
58
|
+
const editorRect = editorElement.getBoundingClientRect();
|
|
59
|
+
const scrollableRect = scrollableElement.getBoundingClientRect();
|
|
60
|
+
extraHeight = Math.max(editorRect.height - scrollableRect.height, 0);
|
|
61
|
+
if (extraHeight === 0 && monaco) {
|
|
62
|
+
const editorOptions = vsEditor.getOptions();
|
|
63
|
+
const scrollBeyondLastLine = editorOptions.get(monaco.editor.EditorOption.scrollBeyondLastLine);
|
|
64
|
+
const padding = editorOptions.get(monaco.editor.EditorOption.padding);
|
|
65
|
+
const lineHeight = editorOptions.get(monaco.editor.EditorOption.lineHeight) || 20;
|
|
66
|
+
extraHeight = (scrollBeyondLastLine ? lineHeight : 0) + (padding?.top || 0) + (padding?.bottom || 0) + 10;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.warn("Failed to calculate editor extra height:", error);
|
|
71
|
+
}
|
|
72
|
+
return extraHeight;
|
|
73
|
+
};
|
|
74
|
+
const setAutoHeight = (v = "") => {
|
|
75
|
+
let lines = Math.max(v.split("\n").length, props.autosize?.minRows || 1);
|
|
76
|
+
if (v) {
|
|
77
|
+
if (props.autosize?.maxRows) lines = Math.min(lines, props.autosize.maxRows);
|
|
78
|
+
}
|
|
79
|
+
let lineHeight = 20;
|
|
80
|
+
if (vsEditor && monaco) lineHeight = vsEditor.getOptions().get(monaco.editor.EditorOption.lineHeight) || 20;
|
|
81
|
+
if (cachedExtraHeight === null) cachedExtraHeight = calculateExtraHeight();
|
|
82
|
+
const newHeight = `${lines * lineHeight + cachedExtraHeight}px`;
|
|
83
|
+
if (autoHeight.value !== newHeight) {
|
|
84
|
+
autoHeight.value = newHeight;
|
|
85
|
+
nextTick(() => {
|
|
86
|
+
vsEditor?.layout();
|
|
87
|
+
if (vsEditor) {
|
|
88
|
+
vsEditor.setScrollTop(0);
|
|
89
|
+
vsEditor.revealLine(1);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const toString = (v, language) => {
|
|
95
|
+
let value;
|
|
96
|
+
if (typeof v !== "string") if (language === "json") value = JSON.stringify(v, null, 2);
|
|
97
|
+
else value = serialize(v, {
|
|
98
|
+
space: 2,
|
|
99
|
+
unsafe: true
|
|
100
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
101
|
+
else value = v;
|
|
102
|
+
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) value = `(${value})`;
|
|
103
|
+
return value;
|
|
104
|
+
};
|
|
105
|
+
const parseCode = (v, language) => {
|
|
106
|
+
if (typeof v !== "string") return v;
|
|
107
|
+
if (language === "json") return JSON.parse(v);
|
|
108
|
+
return getEditorConfig("parseDSL")(v);
|
|
109
|
+
};
|
|
110
|
+
let monaco = null;
|
|
111
|
+
let vsEditor = null;
|
|
112
|
+
let vsDiffEditor = null;
|
|
113
|
+
const values = ref("");
|
|
114
|
+
const loading = ref(false);
|
|
115
|
+
const codeEditorEl = useTemplateRef("codeEditor");
|
|
116
|
+
const resizeObserver = new globalThis.ResizeObserver(throttle(() => {
|
|
117
|
+
vsEditor?.layout();
|
|
118
|
+
vsDiffEditor?.layout();
|
|
119
|
+
}, 300));
|
|
120
|
+
const setEditorValue = (v, m) => {
|
|
121
|
+
values.value = toString(v, props.language.toLocaleLowerCase());
|
|
122
|
+
setAutoHeight(values.value);
|
|
123
|
+
if (!monaco) return;
|
|
124
|
+
if (props.type === "diff") {
|
|
125
|
+
const originalModel = monaco.editor.createModel(values.value, "text/javascript");
|
|
126
|
+
const modifiedModel = monaco.editor.createModel(toString(m, props.language), "text/javascript");
|
|
127
|
+
const position = vsDiffEditor?.getPosition();
|
|
128
|
+
const result = vsDiffEditor?.setModel({
|
|
129
|
+
original: originalModel,
|
|
130
|
+
modified: modifiedModel
|
|
131
|
+
});
|
|
132
|
+
if (position) {
|
|
133
|
+
vsDiffEditor?.setPosition(position);
|
|
134
|
+
vsDiffEditor?.focus();
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
const position = vsEditor?.getPosition();
|
|
139
|
+
const result = vsEditor?.setValue(values.value);
|
|
140
|
+
if (position) {
|
|
141
|
+
vsEditor?.setPosition(position);
|
|
142
|
+
vsEditor?.focus();
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
};
|
|
146
|
+
const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
|
|
147
|
+
const handleKeyDown = (e) => {
|
|
148
|
+
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
const newValue = getEditorValue();
|
|
152
|
+
values.value = newValue;
|
|
153
|
+
emit("save", props.parse ? parseCode(newValue, props.language) : newValue);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const init = async () => {
|
|
157
|
+
if (!codeEditorEl.value) return;
|
|
158
|
+
if (codeEditorEl.value.clientHeight === 0) await nextTick();
|
|
159
|
+
cachedExtraHeight = null;
|
|
160
|
+
monaco = await monaco_editor_default();
|
|
161
|
+
const options = {
|
|
162
|
+
value: values.value,
|
|
163
|
+
language: props.language,
|
|
164
|
+
theme: "vs-dark",
|
|
165
|
+
editorCustomType: props.editorCustomType,
|
|
166
|
+
...props.options
|
|
167
|
+
};
|
|
168
|
+
if (props.type === "diff") {
|
|
169
|
+
vsDiffEditor = await getEditorConfig("customCreateMonacoDiffEditor")(monaco, codeEditorEl.value, options);
|
|
170
|
+
vsDiffEditor.getModifiedEditor().onDidChangeModelContent(() => {
|
|
171
|
+
if (props.autosize) setAutoHeight(getEditorValue());
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
vsEditor = await getEditorConfig("customCreateMonacoEditor")(monaco, codeEditorEl.value, options);
|
|
175
|
+
vsEditor.onDidChangeModelContent(() => {
|
|
176
|
+
if (props.autosize) setAutoHeight(getEditorValue());
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
setEditorValue(props.initValues, props.modifiedValues);
|
|
180
|
+
emit("initd", vsEditor);
|
|
181
|
+
codeEditorEl.value.addEventListener("keydown", handleKeyDown);
|
|
182
|
+
if (props.type !== "diff" && props.autoSave) vsEditor?.onDidBlurEditorWidget(() => {
|
|
183
|
+
const newValue = getEditorValue();
|
|
184
|
+
if (values.value !== newValue) {
|
|
185
|
+
values.value = newValue;
|
|
186
|
+
emit("save", props.parse ? parseCode(newValue, props.language) : newValue);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
resizeObserver.observe(codeEditorEl.value);
|
|
190
|
+
};
|
|
191
|
+
watch(() => props.initValues, (v, preV) => {
|
|
192
|
+
if (v !== preV) setEditorValue(props.initValues, props.modifiedValues);
|
|
193
|
+
}, {
|
|
194
|
+
deep: true,
|
|
195
|
+
immediate: true
|
|
196
|
+
});
|
|
197
|
+
watch(() => props.options, (v) => {
|
|
198
|
+
vsEditor?.updateOptions(v);
|
|
199
|
+
vsDiffEditor?.updateOptions(v);
|
|
200
|
+
}, { deep: true });
|
|
201
|
+
onMounted(async () => {
|
|
202
|
+
loading.value = true;
|
|
203
|
+
await init();
|
|
204
|
+
loading.value = false;
|
|
205
|
+
});
|
|
206
|
+
onBeforeUnmount(() => {
|
|
207
|
+
resizeObserver.disconnect();
|
|
208
|
+
vsEditor?.dispose();
|
|
209
|
+
vsDiffEditor?.dispose();
|
|
210
|
+
vsEditor = null;
|
|
211
|
+
vsDiffEditor = null;
|
|
212
|
+
monaco = null;
|
|
213
|
+
cachedExtraHeight = null;
|
|
214
|
+
});
|
|
215
|
+
onUnmounted(() => {
|
|
216
|
+
codeEditorEl.value?.removeEventListener("keydown", handleKeyDown);
|
|
217
|
+
});
|
|
218
|
+
const fullScreen = ref(false);
|
|
219
|
+
const fullScreenHandler = () => {
|
|
220
|
+
fullScreen.value = !fullScreen.value;
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
vsEditor?.focus();
|
|
223
|
+
vsEditor?.layout();
|
|
224
|
+
vsDiffEditor?.focus();
|
|
225
|
+
vsDiffEditor?.layout();
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
__expose({
|
|
229
|
+
values,
|
|
230
|
+
getEditor() {
|
|
231
|
+
return vsEditor || vsDiffEditor;
|
|
232
|
+
},
|
|
233
|
+
getVsEditor() {
|
|
234
|
+
return vsEditor;
|
|
235
|
+
},
|
|
236
|
+
getVsDiffEditor() {
|
|
237
|
+
return vsDiffEditor;
|
|
238
|
+
},
|
|
239
|
+
setEditorValue,
|
|
240
|
+
getEditorValue,
|
|
241
|
+
focus() {
|
|
242
|
+
vsEditor?.focus();
|
|
243
|
+
vsDiffEditor?.focus();
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return (_ctx, _cache) => {
|
|
247
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [(openBlock(), createBlock(Teleport, {
|
|
248
|
+
to: "body",
|
|
249
|
+
disabled: !fullScreen.value
|
|
250
|
+
}, [createElementVNode("div", {
|
|
251
|
+
class: normalizeClass({
|
|
252
|
+
"magic-code-editor-wrapper": true,
|
|
253
|
+
"full-screen": fullScreen.value
|
|
254
|
+
}),
|
|
255
|
+
style: normalizeStyle({ height: computeHeight.value })
|
|
256
|
+
}, [!__props.disabledFullScreen ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
257
|
+
key: 0,
|
|
258
|
+
class: "magic-code-editor-full-screen-icon",
|
|
259
|
+
circle: "",
|
|
260
|
+
size: "small",
|
|
261
|
+
onClick: fullScreenHandler
|
|
262
|
+
}, {
|
|
263
|
+
default: withCtx(() => [createVNode(Icon_default, { icon: unref(FullScreen) }, null, 8, ["icon"])]),
|
|
264
|
+
_: 1
|
|
265
|
+
})) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_2, null, 512)], 6)], 8, ["disabled"]))]);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
//#endregion
|
|
270
|
+
export { CodeEditor_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Framework_vue_vue_type_script_setup_true_lang_default from "./Framework.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/editor/src/layouts/Framework.vue
|
|
3
|
+
var Framework_default = Framework_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { Framework_default as default };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { getEditorConfig } from "../utils/config.js";
|
|
2
|
+
import { Protocol } from "../services/storage.js";
|
|
3
|
+
import { LEFT_COLUMN_WIDTH_STORAGE_KEY, RIGHT_COLUMN_WIDTH_STORAGE_KEY } from "../utils/const.js";
|
|
4
|
+
import { useServices } from "../hooks/use-services.js";
|
|
5
|
+
import SplitView_default from "../components/SplitView.js";
|
|
6
|
+
import PageBar_default from "./page-bar/PageBar.js";
|
|
7
|
+
import AddPageBox_default from "./AddPageBox.js";
|
|
8
|
+
import CodeEditor_default from "./CodeEditor.js";
|
|
9
|
+
import { computed, createCommentVNode, createElementBlock, createSlots, createVNode, defineComponent, inject, onBeforeUnmount, onMounted, openBlock, renderSlot, unref, useTemplateRef, vShow, watch, withCtx, withDirectives } from "vue";
|
|
10
|
+
//#region packages/editor/src/layouts/Framework.vue?vue&type=script&setup=true&lang.ts
|
|
11
|
+
var _hoisted_1 = {
|
|
12
|
+
class: "m-editor",
|
|
13
|
+
ref: "content",
|
|
14
|
+
style: { "min-width": "900px" }
|
|
15
|
+
};
|
|
16
|
+
var Framework_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
17
|
+
name: "MEditorFramework",
|
|
18
|
+
__name: "Framework",
|
|
19
|
+
props: {
|
|
20
|
+
disabledPageFragment: { type: Boolean },
|
|
21
|
+
pageBarSortOptions: {},
|
|
22
|
+
pageFilterFunction: { type: Function }
|
|
23
|
+
},
|
|
24
|
+
setup(__props) {
|
|
25
|
+
const codeOptions = inject("codeOptions", {});
|
|
26
|
+
const { editorService, uiService, storageService } = useServices();
|
|
27
|
+
const contentEl = useTemplateRef("content");
|
|
28
|
+
const splitViewRef = useTemplateRef("splitView");
|
|
29
|
+
const root = computed(() => editorService.get("root"));
|
|
30
|
+
const page = computed(() => editorService.get("page"));
|
|
31
|
+
const pageLength = computed(() => editorService.get("pageLength") || 0);
|
|
32
|
+
const showSrc = computed(() => uiService.get("showSrc"));
|
|
33
|
+
const columnWidth = computed(() => uiService.get("columnWidth"));
|
|
34
|
+
watch(pageLength, () => {
|
|
35
|
+
splitViewRef.value?.updateWidth();
|
|
36
|
+
});
|
|
37
|
+
watch(() => uiService.get("hideSlideBar"), (hideSlideBar) => {
|
|
38
|
+
uiService.set("columnWidth", {
|
|
39
|
+
...columnWidth.value,
|
|
40
|
+
left: hideSlideBar ? 0 : storageService.getItem("$MagicEditorLeftColumnWidthData", { protocol: Protocol.NUMBER }) || 310
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
const columnWidthChange = (columnW) => {
|
|
44
|
+
storageService.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, columnW.left, { protocol: Protocol.NUMBER });
|
|
45
|
+
storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnW.right, { protocol: Protocol.NUMBER });
|
|
46
|
+
uiService.set("columnWidth", columnW);
|
|
47
|
+
};
|
|
48
|
+
const frameworkRect = computed(() => uiService.get("frameworkRect"));
|
|
49
|
+
const resizerObserver = new ResizeObserver((entries) => {
|
|
50
|
+
const { contentRect } = entries[0];
|
|
51
|
+
uiService.set("frameworkRect", {
|
|
52
|
+
width: contentRect.width,
|
|
53
|
+
height: contentRect.height,
|
|
54
|
+
left: contentRect.left,
|
|
55
|
+
top: contentRect.top
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
if (contentEl.value) resizerObserver.observe(contentEl.value);
|
|
60
|
+
});
|
|
61
|
+
onBeforeUnmount(() => {
|
|
62
|
+
resizerObserver.disconnect();
|
|
63
|
+
});
|
|
64
|
+
const saveCode = (value) => {
|
|
65
|
+
try {
|
|
66
|
+
const parseDSL = getEditorConfig("parseDSL");
|
|
67
|
+
editorService.set("root", parseDSL(value));
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error(e);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return (_ctx, _cache) => {
|
|
73
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
74
|
+
renderSlot(_ctx.$slots, "header"),
|
|
75
|
+
renderSlot(_ctx.$slots, "nav"),
|
|
76
|
+
renderSlot(_ctx.$slots, "content-before"),
|
|
77
|
+
showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [createVNode(CodeEditor_default, {
|
|
78
|
+
class: "m-editor-content",
|
|
79
|
+
"editor-custom-type": "m-editor-content",
|
|
80
|
+
"init-values": root.value,
|
|
81
|
+
options: unref(codeOptions),
|
|
82
|
+
onSave: saveCode
|
|
83
|
+
}, null, 8, ["init-values", "options"])]) : createCommentVNode("v-if", true),
|
|
84
|
+
withDirectives(createVNode(SplitView_default, {
|
|
85
|
+
ref: "splitView",
|
|
86
|
+
class: "m-editor-content",
|
|
87
|
+
"left-class": "m-editor-framework-left",
|
|
88
|
+
"center-class": "m-editor-framework-center",
|
|
89
|
+
"right-class": "m-editor-framework-right",
|
|
90
|
+
left: columnWidth.value.left,
|
|
91
|
+
right: columnWidth.value.right,
|
|
92
|
+
"min-left": unref(200),
|
|
93
|
+
"min-right": unref(300),
|
|
94
|
+
"min-center": unref(400),
|
|
95
|
+
width: frameworkRect.value.width,
|
|
96
|
+
onChange: columnWidthChange
|
|
97
|
+
}, createSlots({
|
|
98
|
+
left: withCtx(() => [renderSlot(_ctx.$slots, "sidebar")]),
|
|
99
|
+
center: withCtx(() => [page.value ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [createVNode(AddPageBox_default, { "disabled-page-fragment": __props.disabledPageFragment }, null, 8, ["disabled-page-fragment"])]), renderSlot(_ctx.$slots, "page-bar", {}, () => [createVNode(PageBar_default, {
|
|
100
|
+
"disabled-page-fragment": __props.disabledPageFragment,
|
|
101
|
+
"page-bar-sort-options": __props.pageBarSortOptions,
|
|
102
|
+
"filter-function": __props.pageFilterFunction
|
|
103
|
+
}, {
|
|
104
|
+
"page-bar-add-button": withCtx(() => [renderSlot(_ctx.$slots, "page-bar-add-button")]),
|
|
105
|
+
"page-bar-title": withCtx(({ page }) => [renderSlot(_ctx.$slots, "page-bar-title", { page })]),
|
|
106
|
+
"page-bar-popover": withCtx(({ page }) => [renderSlot(_ctx.$slots, "page-bar-popover", { page })]),
|
|
107
|
+
"page-list-popover": withCtx(({ list }) => [renderSlot(_ctx.$slots, "page-list-popover", { list })]),
|
|
108
|
+
_: 3
|
|
109
|
+
}, 8, [
|
|
110
|
+
"disabled-page-fragment",
|
|
111
|
+
"page-bar-sort-options",
|
|
112
|
+
"filter-function"
|
|
113
|
+
])])]),
|
|
114
|
+
_: 2
|
|
115
|
+
}, [page.value ? {
|
|
116
|
+
name: "right",
|
|
117
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "props-panel")]),
|
|
118
|
+
key: "0"
|
|
119
|
+
} : void 0]), 1032, [
|
|
120
|
+
"left",
|
|
121
|
+
"right",
|
|
122
|
+
"min-left",
|
|
123
|
+
"min-right",
|
|
124
|
+
"min-center",
|
|
125
|
+
"width"
|
|
126
|
+
]), [[vShow, !showSrc.value]]),
|
|
127
|
+
renderSlot(_ctx.$slots, "content-after"),
|
|
128
|
+
renderSlot(_ctx.$slots, "footer")
|
|
129
|
+
], 512);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
//#endregion
|
|
134
|
+
export { Framework_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import NavMenu_vue_vue_type_script_setup_true_lang_default from "./NavMenu.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/editor/src/layouts/NavMenu.vue
|
|
3
|
+
var NavMenu_default = NavMenu_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { NavMenu_default as default };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { ColumnLayout } from "../type.js";
|
|
2
|
+
import { useServices } from "../hooks/use-services.js";
|
|
3
|
+
import ToolButton_default from "../components/ToolButton.js";
|
|
4
|
+
import { NodeType } from "@tmagic/core";
|
|
5
|
+
import { Fragment, computed, createBlock, createElementBlock, defineComponent, markRaw, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, renderList, unref, useTemplateRef } from "vue";
|
|
6
|
+
import { Back, Delete, FullScreen, Grid, Memo, Right, ScaleToOriginal, ZoomIn, ZoomOut } from "@element-plus/icons-vue";
|
|
7
|
+
//#region packages/editor/src/layouts/NavMenu.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
var NavMenu_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
9
|
+
name: "MEditorNavMenu",
|
|
10
|
+
__name: "NavMenu",
|
|
11
|
+
props: {
|
|
12
|
+
data: { default: () => ({}) },
|
|
13
|
+
height: { default: 35 }
|
|
14
|
+
},
|
|
15
|
+
setup(__props) {
|
|
16
|
+
const props = __props;
|
|
17
|
+
const { uiService, editorService, historyService } = useServices();
|
|
18
|
+
const columnWidth = computed(() => uiService.get("columnWidth"));
|
|
19
|
+
const keys = Object.values(ColumnLayout);
|
|
20
|
+
const showGuides = computed(() => uiService.get("showGuides"));
|
|
21
|
+
const showRule = computed(() => uiService.get("showRule"));
|
|
22
|
+
const zoom = computed(() => uiService.get("zoom"));
|
|
23
|
+
const ctrl = /mac os x/.test(navigator.userAgent.toLowerCase()) ? "Command" : "Ctrl";
|
|
24
|
+
const getConfig = (item) => {
|
|
25
|
+
if (typeof item !== "string") return [item];
|
|
26
|
+
const config = [];
|
|
27
|
+
switch (item) {
|
|
28
|
+
case "/":
|
|
29
|
+
config.push({
|
|
30
|
+
type: "divider",
|
|
31
|
+
className: "divider"
|
|
32
|
+
});
|
|
33
|
+
break;
|
|
34
|
+
case "zoom":
|
|
35
|
+
config.push(...getConfig("zoom-out"), ...getConfig(`${parseInt(`${zoom.value * 100}`, 10)}%`), ...getConfig("zoom-in"), ...getConfig("scale-to-original"), ...getConfig("scale-to-fit"));
|
|
36
|
+
break;
|
|
37
|
+
case "delete":
|
|
38
|
+
config.push({
|
|
39
|
+
type: "button",
|
|
40
|
+
className: "delete",
|
|
41
|
+
icon: markRaw(Delete),
|
|
42
|
+
tooltip: "刪除(Delete)",
|
|
43
|
+
disabled: () => editorService.get("node")?.type === NodeType.PAGE,
|
|
44
|
+
handler: () => {
|
|
45
|
+
const node = editorService.get("node");
|
|
46
|
+
node && editorService.remove(node);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
case "undo":
|
|
51
|
+
config.push({
|
|
52
|
+
type: "button",
|
|
53
|
+
className: "undo",
|
|
54
|
+
icon: markRaw(Back),
|
|
55
|
+
tooltip: `后退(${ctrl}+z)`,
|
|
56
|
+
disabled: () => !historyService.state.canUndo,
|
|
57
|
+
handler: () => editorService.undo()
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case "redo":
|
|
61
|
+
config.push({
|
|
62
|
+
type: "button",
|
|
63
|
+
className: "redo",
|
|
64
|
+
icon: markRaw(Right),
|
|
65
|
+
tooltip: `前进(${ctrl}+Shift+z)`,
|
|
66
|
+
disabled: () => !historyService.state.canRedo,
|
|
67
|
+
handler: () => editorService.redo()
|
|
68
|
+
});
|
|
69
|
+
break;
|
|
70
|
+
case "zoom-in":
|
|
71
|
+
config.push({
|
|
72
|
+
type: "button",
|
|
73
|
+
className: "zoom-in",
|
|
74
|
+
icon: markRaw(ZoomIn),
|
|
75
|
+
tooltip: `放大(${ctrl}+=)`,
|
|
76
|
+
handler: () => uiService?.zoom(.1)
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
case "zoom-out":
|
|
80
|
+
config.push({
|
|
81
|
+
type: "button",
|
|
82
|
+
className: "zoom-out",
|
|
83
|
+
icon: markRaw(ZoomOut),
|
|
84
|
+
tooltip: `縮小(${ctrl}+-)`,
|
|
85
|
+
handler: () => uiService?.zoom(-.1)
|
|
86
|
+
});
|
|
87
|
+
break;
|
|
88
|
+
case "scale-to-original":
|
|
89
|
+
config.push({
|
|
90
|
+
type: "button",
|
|
91
|
+
className: "scale-to-original",
|
|
92
|
+
icon: markRaw(ScaleToOriginal),
|
|
93
|
+
tooltip: `缩放到实际大小(${ctrl}+1)`,
|
|
94
|
+
handler: () => uiService?.set("zoom", 1)
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
97
|
+
case "scale-to-fit":
|
|
98
|
+
config.push({
|
|
99
|
+
type: "button",
|
|
100
|
+
className: "scale-to-fit",
|
|
101
|
+
icon: markRaw(FullScreen),
|
|
102
|
+
tooltip: `缩放以适应(${ctrl}+0)`,
|
|
103
|
+
handler: async () => uiService?.set("zoom", await uiService.calcZoom())
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
case "rule":
|
|
107
|
+
config.push({
|
|
108
|
+
type: "button",
|
|
109
|
+
className: "rule",
|
|
110
|
+
icon: markRaw(Memo),
|
|
111
|
+
tooltip: showRule.value ? "隐藏标尺" : "显示标尺",
|
|
112
|
+
handler: () => uiService?.set("showRule", !showRule.value)
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
case "guides":
|
|
116
|
+
config.push({
|
|
117
|
+
type: "button",
|
|
118
|
+
className: "guides",
|
|
119
|
+
icon: markRaw(Grid),
|
|
120
|
+
tooltip: showGuides.value ? "隐藏参考线" : "显示参考线",
|
|
121
|
+
handler: () => uiService?.set("showGuides", !showGuides.value)
|
|
122
|
+
});
|
|
123
|
+
break;
|
|
124
|
+
default: config.push({
|
|
125
|
+
type: "text",
|
|
126
|
+
text: item
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return config;
|
|
130
|
+
};
|
|
131
|
+
const buttons = computed(() => {
|
|
132
|
+
const data = {
|
|
133
|
+
[ColumnLayout.LEFT]: [],
|
|
134
|
+
[ColumnLayout.CENTER]: [],
|
|
135
|
+
[ColumnLayout.RIGHT]: []
|
|
136
|
+
};
|
|
137
|
+
keys.forEach((key) => {
|
|
138
|
+
(props.data[key] || []).forEach((item) => {
|
|
139
|
+
data[key].push(...getConfig(item));
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
return data;
|
|
143
|
+
});
|
|
144
|
+
const navMenuEl = useTemplateRef("navMenu");
|
|
145
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
146
|
+
const rect = navMenuEl.value?.getBoundingClientRect();
|
|
147
|
+
if (rect) uiService.set("navMenuRect", {
|
|
148
|
+
left: rect.left,
|
|
149
|
+
top: rect.top,
|
|
150
|
+
width: rect.width,
|
|
151
|
+
height: rect.height
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
onMounted(() => {
|
|
155
|
+
navMenuEl.value && resizeObserver.observe(navMenuEl.value);
|
|
156
|
+
});
|
|
157
|
+
onBeforeUnmount(() => {
|
|
158
|
+
resizeObserver.disconnect();
|
|
159
|
+
});
|
|
160
|
+
return (_ctx, _cache) => {
|
|
161
|
+
return openBlock(), createElementBlock("div", {
|
|
162
|
+
class: "m-editor-nav-menu",
|
|
163
|
+
style: normalizeStyle({ height: `${__props.height}px` }),
|
|
164
|
+
ref: "navMenu"
|
|
165
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(keys), (key) => {
|
|
166
|
+
return openBlock(), createElementBlock("div", {
|
|
167
|
+
class: normalizeClass(`menu-${key}`),
|
|
168
|
+
key,
|
|
169
|
+
style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
|
|
170
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
|
|
171
|
+
return openBlock(), createBlock(ToolButton_default, {
|
|
172
|
+
data: item,
|
|
173
|
+
key: index
|
|
174
|
+
}, null, 8, ["data"]);
|
|
175
|
+
}), 128))], 6);
|
|
176
|
+
}), 128))], 4);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
export { NavMenu_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import AddButton_vue_vue_type_script_setup_true_lang_default from "./AddButton.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/editor/src/layouts/page-bar/AddButton.vue
|
|
3
|
+
var AddButton_default = AddButton_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { AddButton_default as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { generatePageNameByApp } from "../../utils/editor.js";
|
|
2
|
+
import { useServices } from "../../hooks/use-services.js";
|
|
3
|
+
import Icon_default from "../../components/Icon.js";
|
|
4
|
+
import ToolButton_default from "../../components/ToolButton.js";
|
|
5
|
+
import { TMagicPopover } from "@tmagic/design";
|
|
6
|
+
import { NodeType } from "@tmagic/core";
|
|
7
|
+
import { computed, createElementBlock, createVNode, defineComponent, openBlock, toRaw, unref, withCtx } from "vue";
|
|
8
|
+
import { Plus } from "@element-plus/icons-vue";
|
|
9
|
+
//#region packages/editor/src/layouts/page-bar/AddButton.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
var _hoisted_1 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
id: "m-editor-page-bar-add-icon",
|
|
13
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon"
|
|
14
|
+
};
|
|
15
|
+
var _hoisted_2 = {
|
|
16
|
+
key: 1,
|
|
17
|
+
style: { "width": "21px" }
|
|
18
|
+
};
|
|
19
|
+
var AddButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
20
|
+
name: "MEditorPageBarAddButton",
|
|
21
|
+
__name: "AddButton",
|
|
22
|
+
setup(__props) {
|
|
23
|
+
const { editorService, uiService } = useServices();
|
|
24
|
+
const showAddPageButton = computed(() => uiService.get("showAddPageButton"));
|
|
25
|
+
const addPage = (type) => {
|
|
26
|
+
const root = toRaw(editorService.get("root"));
|
|
27
|
+
if (!root) throw new Error("root 不能为空");
|
|
28
|
+
const pageConfig = {
|
|
29
|
+
type,
|
|
30
|
+
name: generatePageNameByApp(root, type),
|
|
31
|
+
items: []
|
|
32
|
+
};
|
|
33
|
+
editorService.add(pageConfig);
|
|
34
|
+
};
|
|
35
|
+
return (_ctx, _cache) => {
|
|
36
|
+
return showAddPageButton.value ? (openBlock(), createElementBlock("div", _hoisted_1, [createVNode(unref(TMagicPopover), { "popper-class": "data-source-list-panel-add-menu" }, {
|
|
37
|
+
reference: withCtx(() => [createVNode(Icon_default, { icon: unref(Plus) }, null, 8, ["icon"])]),
|
|
38
|
+
default: withCtx(() => [createVNode(ToolButton_default, { data: {
|
|
39
|
+
type: "button",
|
|
40
|
+
text: "页面",
|
|
41
|
+
handler: () => {
|
|
42
|
+
addPage(unref(NodeType).PAGE);
|
|
43
|
+
}
|
|
44
|
+
} }, null, 8, ["data"]), createVNode(ToolButton_default, { data: {
|
|
45
|
+
type: "button",
|
|
46
|
+
text: "页面片",
|
|
47
|
+
handler: () => {
|
|
48
|
+
addPage(unref(NodeType).PAGE_FRAGMENT);
|
|
49
|
+
}
|
|
50
|
+
} }, null, 8, ["data"])]),
|
|
51
|
+
_: 1
|
|
52
|
+
})])) : (openBlock(), createElementBlock("div", _hoisted_2));
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
//#endregion
|
|
57
|
+
export { AddButton_vue_vue_type_script_setup_true_lang_default as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import PageBar_vue_vue_type_script_setup_true_lang_default from "./PageBar.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
//#region packages/editor/src/layouts/page-bar/PageBar.vue
|
|
3
|
+
var PageBar_default = PageBar_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { PageBar_default as default };
|