@tmagic/editor 1.8.0-beta.2 → 1.8.0-beta.21
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/dist/es/Editor.vue_vue_type_script_setup_true_lang.js +43 -9
- package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +8 -4
- package/dist/es/components/CodeParams.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +22 -98
- package/dist/es/components/ContentMenu.vue_vue_type_script_setup_true_lang.js +32 -9
- package/dist/es/components/FloatingBox.vue_vue_type_script_setup_true_lang.js +68 -17
- package/dist/es/components/Icon.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/Resizer.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/ScrollBar.js +0 -1
- package/dist/es/components/ScrollBar.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/ScrollViewer.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/SearchInput.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/SplitView.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/ToolButton.vue_vue_type_script_setup_true_lang.js +7 -7
- package/dist/es/components/Tree.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/TreeNode.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/components/ViewForm.js +5 -0
- package/dist/es/components/ViewForm.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/es/editorProps.js +9 -1
- package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +16 -5
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +7 -7
- package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +81 -44
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +10 -3
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +7 -19
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +13 -6
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +11 -8
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +39 -12
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +11 -20
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +11 -6
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +30 -14
- package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +11 -4
- package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +38 -6
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +156 -155
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/PageFragmentSelect.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/StyleSetter/Index.vue_vue_type_script_setup_true_lang.js +8 -10
- package/dist/es/fields/StyleSetter/components/BackgroundPosition.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/fields/StyleSetter/components/Border.vue_vue_type_script_setup_true_lang.js +28 -6
- package/dist/es/fields/StyleSetter/components/Box.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/StyleSetter/icons/align-items/Center.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexEnd.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/FlexStart.js +31 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceAround.js +50 -0
- package/dist/es/fields/StyleSetter/icons/align-items/SpaceBetween.js +50 -0
- package/dist/es/fields/StyleSetter/icons/background-repeat/NoRepeat.js +7 -7
- package/dist/es/fields/StyleSetter/icons/background-repeat/Repeat.js +6 -3
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatX.js +29 -6
- package/dist/es/fields/StyleSetter/icons/background-repeat/RepeatY.js +32 -6
- package/dist/es/fields/StyleSetter/icons/display/Block.js +1 -1
- package/dist/es/fields/StyleSetter/icons/display/Flex.js +1 -1
- package/dist/es/fields/StyleSetter/icons/display/Inline.js +1 -1
- package/dist/es/fields/StyleSetter/icons/display/InlineBlock.js +1 -1
- package/dist/es/fields/StyleSetter/icons/display/None.js +1 -1
- package/dist/es/fields/StyleSetter/icons/flex-direction/Column.js +11 -3
- package/dist/es/fields/StyleSetter/icons/flex-direction/ColumnReverse.js +11 -3
- package/dist/es/fields/StyleSetter/icons/flex-direction/Row.js +11 -3
- package/dist/es/fields/StyleSetter/icons/flex-direction/RowReverse.js +11 -3
- package/dist/es/fields/StyleSetter/icons/justify-content/Center.js +17 -3
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexEnd.js +19 -3
- package/dist/es/fields/StyleSetter/icons/justify-content/FlexStart.js +19 -3
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceAround.js +37 -3
- package/dist/es/fields/StyleSetter/icons/justify-content/SpaceBetween.js +33 -3
- package/dist/es/fields/StyleSetter/icons/text-align/Center.js +1 -1
- package/dist/es/fields/StyleSetter/icons/text-align/Left.js +1 -1
- package/dist/es/fields/StyleSetter/icons/text-align/Right.js +1 -1
- package/dist/es/fields/StyleSetter/pro/Background.vue_vue_type_script_setup_true_lang.js +56 -30
- package/dist/es/fields/StyleSetter/pro/Border.vue_vue_type_script_setup_true_lang.js +7 -4
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +35 -26
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +76 -48
- package/dist/es/fields/StyleSetter/pro/Position.vue_vue_type_script_setup_true_lang.js +29 -23
- package/dist/es/fields/StyleSetter/pro/Transform.vue_vue_type_script_setup_true_lang.js +7 -4
- package/dist/es/fields/UISelect.js +0 -1
- package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +5 -2
- package/dist/es/hooks/use-code-block-edit.js +6 -3
- package/dist/es/hooks/use-compare-form.js +119 -0
- package/dist/es/hooks/use-data-source-edit.js +5 -2
- package/dist/es/hooks/use-stage.js +9 -4
- package/dist/es/icons/CenterIcon.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/icons/CodeIcon.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/icons/DatasourceIcon.js +17 -0
- package/dist/es/icons/FolderMinusIcon.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/index.js +24 -10
- package/dist/es/initService.js +19 -13
- package/dist/es/layouts/AddPageBox.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +24 -12
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +25 -18
- package/dist/es/layouts/NavMenu.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/es/layouts/NavMenuColumn.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +25 -38
- package/dist/es/layouts/history-list/BucketTab.js +5 -0
- package/dist/es/layouts/history-list/BucketTab.vue_vue_type_script_setup_true_lang.js +62 -0
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +177 -88
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +139 -37
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +164 -107
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +44 -9
- package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +49 -53
- package/dist/es/layouts/history-list/composables.js +138 -108
- package/dist/es/layouts/history-list/useHistoryList.js +56 -0
- package/dist/es/layouts/history-list/useHistoryRevert.js +317 -0
- package/dist/es/layouts/page-bar/AddButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/page-bar/PageBar.vue_vue_type_script_setup_true_lang.js +5 -3
- package/dist/es/layouts/page-bar/PageBarScrollContainer.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/page-bar/PageList.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/page-bar/Search.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/props-panel/FormPanel.vue_vue_type_script_setup_true_lang.js +50 -7
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +33 -13
- package/dist/es/layouts/props-panel/use-style-panel.js +3 -2
- package/dist/es/layouts/sidebar/ComponentListPanel.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/es/layouts/sidebar/Sidebar.vue_vue_type_script_setup_true_lang.js +26 -38
- package/dist/es/layouts/sidebar/code-block/CodeBlockList.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/es/layouts/sidebar/code-block/CodeBlockListPanel.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/es/layouts/sidebar/code-block/useContentMenu.js +19 -4
- package/dist/es/layouts/sidebar/data-source/DataSourceAddButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/sidebar/data-source/DataSourceConfigPanel.vue_vue_type_script_setup_true_lang.js +23 -6
- package/dist/es/layouts/sidebar/data-source/DataSourceList.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/sidebar/data-source/DataSourceListPanel.vue_vue_type_script_setup_true_lang.js +27 -5
- package/dist/es/layouts/sidebar/data-source/useContentMenu.js +19 -4
- package/dist/es/layouts/sidebar/layer/LayerMenu.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/es/layouts/sidebar/layer/LayerNodeContent.js +5 -0
- package/dist/es/layouts/sidebar/layer/LayerNodeContent.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/es/layouts/sidebar/layer/LayerNodeTool.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/sidebar/layer/LayerPanel.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/es/layouts/sidebar/layer/use-click.js +3 -3
- package/dist/es/layouts/sidebar/layer/use-node-status.js +2 -2
- package/dist/es/layouts/workspace/Breadcrumb.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/workspace/Workspace.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/workspace/viewer/NodeListMenu.vue_vue_type_script_setup_true_lang.js +9 -3
- package/dist/es/layouts/workspace/viewer/Stage.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/layouts/workspace/viewer/StageOverlay.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/workspace/viewer/ViewerMenu.vue_vue_type_script_setup_true_lang.js +16 -16
- package/dist/es/plugin.js +5 -2
- package/dist/es/services/codeBlock.js +137 -56
- package/dist/es/services/dataSource.js +122 -52
- package/dist/es/services/dep.js +162 -41
- package/dist/es/services/editor.js +613 -179
- package/dist/es/services/events.js +2 -2
- package/dist/es/services/history.js +350 -386
- package/dist/es/services/keybinding.js +6 -6
- package/dist/es/services/props.js +3 -2
- package/dist/es/services/storage.js +2 -2
- package/dist/es/services/ui.js +10 -2
- package/dist/es/style.css +549 -113
- package/dist/es/utils/config.js +4 -1
- package/dist/es/utils/const.js +2 -2
- package/dist/es/utils/content-menu.js +19 -11
- package/dist/es/utils/data-source/index.js +34 -11
- package/dist/es/utils/dep/collect-worker-client.js +114 -0
- package/dist/es/utils/dep/idle-task.js +70 -22
- package/dist/es/utils/dep/worker.js +1 -1
- package/dist/es/utils/editor.js +103 -49
- package/dist/es/utils/event.js +135 -0
- package/dist/es/utils/history.js +220 -0
- package/dist/es/utils/indexed-db.js +86 -0
- package/dist/es/utils/monaco-editor.js +22 -6
- package/dist/es/utils/operator.js +2 -2
- package/dist/es/utils/props.js +114 -33
- package/dist/es/utils/type-match-rules.js +367 -0
- package/dist/es/utils/undo-redo.js +60 -1
- package/dist/style.css +549 -113
- package/dist/themes/magic-admin.css +3028 -0
- package/dist/tmagic-editor.umd.cjs +14403 -10121
- package/package.json +8 -8
- package/src/Editor.vue +43 -2
- package/src/components/CodeBlockEditor.vue +3 -0
- package/src/components/CompareForm.vue +18 -146
- package/src/components/ContentMenu.vue +44 -8
- package/src/components/FloatingBox.vue +84 -9
- package/src/components/ScrollBar.vue +0 -67
- package/src/components/ToolButton.vue +2 -2
- package/src/components/ViewForm.vue +55 -0
- package/src/editorProps.ts +30 -0
- package/src/fields/Code.vue +10 -2
- package/src/fields/CodeLink.vue +2 -5
- package/src/fields/CodeSelect.vue +54 -40
- package/src/fields/CodeSelectCol.vue +8 -1
- package/src/fields/CondOpSelect.vue +2 -24
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +16 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +14 -5
- package/src/fields/DataSourceFields.vue +42 -8
- package/src/fields/DataSourceInput.vue +10 -28
- package/src/fields/DataSourceMethodSelect.vue +9 -4
- package/src/fields/DataSourceMethods.vue +42 -21
- package/src/fields/DataSourceMocks.vue +3 -0
- package/src/fields/DisplayConds.vue +18 -1
- package/src/fields/EventSelect.vue +152 -166
- package/src/fields/StyleSetter/Index.vue +3 -12
- package/src/fields/StyleSetter/components/Border.vue +15 -6
- package/src/fields/StyleSetter/icons/align-items/Center.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexEnd.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/FlexStart.vue +19 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceAround.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/SpaceBetween.vue +34 -0
- package/src/fields/StyleSetter/icons/align-items/index.ts +5 -0
- package/src/fields/StyleSetter/icons/background-repeat/NoRepeat.vue +20 -4
- package/src/fields/StyleSetter/icons/background-repeat/Repeat.vue +10 -28
- package/src/fields/StyleSetter/icons/background-repeat/RepeatX.vue +4 -5
- package/src/fields/StyleSetter/icons/background-repeat/RepeatY.vue +4 -5
- package/src/fields/StyleSetter/icons/flex-direction/Column.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/ColumnReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/Row.vue +4 -3
- package/src/fields/StyleSetter/icons/flex-direction/RowReverse.vue +4 -3
- package/src/fields/StyleSetter/icons/justify-content/Center.vue +5 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexEnd.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/FlexStart.vue +15 -2
- package/src/fields/StyleSetter/icons/justify-content/SpaceAround.vue +28 -3
- package/src/fields/StyleSetter/icons/justify-content/SpaceBetween.vue +28 -2
- package/src/fields/StyleSetter/pro/Background.vue +99 -55
- package/src/fields/StyleSetter/pro/Border.vue +9 -11
- package/src/fields/StyleSetter/pro/Font.vue +66 -64
- package/src/fields/StyleSetter/pro/Layout.vue +211 -139
- package/src/fields/StyleSetter/pro/Position.vue +69 -67
- package/src/fields/StyleSetter/pro/Transform.vue +23 -25
- package/src/fields/UISelect.vue +0 -12
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-code-block-edit.ts +4 -3
- package/src/hooks/use-compare-form.ts +187 -0
- package/src/hooks/use-data-source-edit.ts +2 -2
- package/src/hooks/use-stage.ts +5 -3
- package/src/icons/DatasourceIcon.vue +7 -0
- package/src/index.ts +12 -0
- package/src/initService.ts +26 -16
- package/src/layouts/CodeEditor.vue +34 -11
- package/src/layouts/Framework.vue +15 -8
- package/src/layouts/NavMenu.vue +3 -3
- package/src/layouts/history-list/Bucket.vue +33 -41
- package/src/layouts/history-list/BucketTab.vue +72 -0
- package/src/layouts/history-list/GroupRow.vue +190 -93
- package/src/layouts/history-list/HistoryDiffDialog.vue +169 -90
- package/src/layouts/history-list/HistoryListPanel.vue +191 -95
- package/src/layouts/history-list/InitialRow.vue +38 -8
- package/src/layouts/history-list/PageTab.vue +67 -43
- package/src/layouts/history-list/composables.ts +239 -125
- package/src/layouts/history-list/useHistoryList.ts +60 -0
- package/src/layouts/history-list/useHistoryRevert.ts +425 -0
- package/src/layouts/page-bar/PageBar.vue +4 -2
- package/src/layouts/props-panel/FormPanel.vue +72 -6
- package/src/layouts/props-panel/PropsPanel.vue +62 -18
- package/src/layouts/props-panel/use-style-panel.ts +4 -3
- package/src/layouts/sidebar/ComponentListPanel.vue +10 -6
- package/src/layouts/sidebar/Sidebar.vue +13 -6
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +5 -5
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +5 -2
- package/src/layouts/sidebar/code-block/useContentMenu.ts +14 -2
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +34 -2
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +29 -4
- package/src/layouts/sidebar/data-source/useContentMenu.ts +14 -2
- package/src/layouts/sidebar/layer/LayerMenu.vue +21 -13
- package/src/layouts/sidebar/layer/LayerNodeContent.vue +57 -0
- package/src/layouts/sidebar/layer/LayerNodeTool.vue +7 -4
- package/src/layouts/sidebar/layer/LayerPanel.vue +4 -1
- package/src/layouts/sidebar/layer/use-click.ts +3 -3
- package/src/layouts/sidebar/layer/use-node-status.ts +2 -2
- package/src/layouts/workspace/viewer/NodeListMenu.vue +4 -1
- package/src/layouts/workspace/viewer/Stage.vue +1 -1
- package/src/layouts/workspace/viewer/ViewerMenu.vue +15 -15
- package/src/plugin.ts +6 -3
- package/src/services/codeBlock.ts +152 -47
- package/src/services/dataSource.ts +120 -41
- package/src/services/dep.ts +292 -47
- package/src/services/editor.ts +820 -224
- package/src/services/events.ts +3 -3
- package/src/services/history.ts +449 -412
- package/src/services/keybinding.ts +6 -6
- package/src/services/ui.ts +33 -5
- package/src/theme/code-block.scss +37 -0
- package/src/theme/common/var.scss +1 -1
- package/src/theme/component-list-panel.scss +2 -2
- package/src/theme/data-source-field.scss +4 -0
- package/src/theme/display-conds.scss +11 -0
- package/src/theme/event.scss +70 -1
- package/src/theme/floating-box.scss +9 -1
- package/src/theme/framework.scss +4 -1
- package/src/theme/history-list-panel.scss +157 -23
- package/src/theme/layer-node-content.scss +14 -0
- package/src/theme/nav-menu.scss +5 -1
- package/src/theme/page-bar.scss +0 -4
- package/src/theme/props-panel.scss +5 -4
- package/src/theme/scroll-bar.scss +64 -0
- package/src/theme/style-setter/border.scss +17 -5
- package/src/theme/theme.scss +4 -0
- package/src/theme/themes/magic-admin/index.scss +214 -0
- package/src/theme/ui-select.scss +9 -0
- package/src/type.ts +668 -124
- package/src/utils/config.ts +9 -1
- package/src/utils/const.ts +3 -2
- package/src/utils/content-menu.ts +20 -11
- package/src/utils/data-source/index.ts +32 -12
- package/src/utils/dep/collect-worker-client.ts +149 -0
- package/src/utils/dep/idle-task.ts +104 -35
- package/src/utils/dep/worker.ts +113 -9
- package/src/utils/editor.ts +166 -60
- package/src/utils/event.ts +237 -0
- package/src/utils/history.ts +286 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/indexed-db.ts +122 -0
- package/src/utils/monaco-editor.ts +27 -0
- package/src/utils/operator.ts +2 -2
- package/src/utils/props.ts +114 -11
- package/src/utils/type-match-rules.ts +684 -0
- package/src/utils/undo-redo.ts +88 -0
- package/types/index.d.ts +1990 -517
- package/dist/es/layouts/history-list/CodeBlockTab.js +0 -5
- package/dist/es/layouts/history-list/CodeBlockTab.vue_vue_type_script_setup_true_lang.js +0 -62
- package/dist/es/layouts/history-list/DataSourceTab.js +0 -5
- package/dist/es/layouts/history-list/DataSourceTab.vue_vue_type_script_setup_true_lang.js +0 -62
- package/src/layouts/history-list/CodeBlockTab.vue +0 -61
- package/src/layouts/history-list/DataSourceTab.vue +0 -61
package/src/utils/editor.ts
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
isValueIncludeDataSource,
|
|
36
36
|
} from '@tmagic/utils';
|
|
37
37
|
|
|
38
|
-
import type { EditorNodeInfo } from '@editor/type';
|
|
38
|
+
import type { EditorNodeInfo, StepValue } from '@editor/type';
|
|
39
39
|
import { LayerOffset, Layout } from '@editor/type';
|
|
40
40
|
|
|
41
41
|
export const COPY_STORAGE_KEY = '$MagicEditorCopyData';
|
|
@@ -132,6 +132,34 @@ const getMiddleTop = (node: MNode, parentNode: MNode, stage: StageCore | null) =
|
|
|
132
132
|
return (Math.min(parentHeight, wrapperHeightDeal) - height) / 2;
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
+
// 同时存在一对相反的定位属性(如 left/right)时只保留一个,避免元素被拉伸
|
|
136
|
+
const removeConflictPosition = (style: Record<string, any>, primary: string, secondary: string) => {
|
|
137
|
+
// '' / 0 / undefined / null 视为无效值
|
|
138
|
+
const isInvalid = (value: any) => value === '' || value === 0 || value === undefined || value === null;
|
|
139
|
+
|
|
140
|
+
if (!(primary in style) || !(secondary in style)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const primaryValue = style[primary];
|
|
145
|
+
const secondaryValue = style[secondary];
|
|
146
|
+
const primaryInvalid = isInvalid(primaryValue);
|
|
147
|
+
const secondaryInvalid = isInvalid(secondaryValue);
|
|
148
|
+
|
|
149
|
+
if (primaryInvalid && !secondaryInvalid) {
|
|
150
|
+
delete style[primary];
|
|
151
|
+
} else if (secondaryInvalid && !primaryInvalid) {
|
|
152
|
+
delete style[secondary];
|
|
153
|
+
} else if (primaryInvalid && secondaryInvalid) {
|
|
154
|
+
// 都是无效值时优先保留 0,否则保留 primary(left/top)
|
|
155
|
+
if (secondaryValue === 0 && primaryValue !== 0) {
|
|
156
|
+
delete style[primary];
|
|
157
|
+
} else {
|
|
158
|
+
delete style[secondary];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
135
163
|
export const getInitPositionStyle = (style: Record<string, any> = {}, layout: Layout) => {
|
|
136
164
|
if (layout === Layout.ABSOLUTE) {
|
|
137
165
|
const newStyle: Record<string, any> = {
|
|
@@ -139,6 +167,9 @@ export const getInitPositionStyle = (style: Record<string, any> = {}, layout: La
|
|
|
139
167
|
position: 'absolute',
|
|
140
168
|
};
|
|
141
169
|
|
|
170
|
+
removeConflictPosition(newStyle, 'left', 'right');
|
|
171
|
+
removeConflictPosition(newStyle, 'top', 'bottom');
|
|
172
|
+
|
|
142
173
|
if (typeof newStyle.left === 'undefined' && typeof newStyle.right === 'undefined') {
|
|
143
174
|
newStyle.left = 0;
|
|
144
175
|
}
|
|
@@ -178,43 +209,68 @@ export const setLayout = (node: MNode, layout: Layout) => {
|
|
|
178
209
|
return node;
|
|
179
210
|
};
|
|
180
211
|
|
|
181
|
-
|
|
182
|
-
const style = {
|
|
183
|
-
...(node.style || {}),
|
|
184
|
-
};
|
|
212
|
+
type PositionKey = 'left' | 'top' | 'right' | 'bottom';
|
|
185
213
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
top: 0,
|
|
190
|
-
};
|
|
214
|
+
// 判断 style 是否显式设置了某个定位属性,使用 typeof 判断以避免将 0(如 right: 0)误判为未设置
|
|
215
|
+
const hasPositionValue = (style: Record<string, any> | undefined, key: PositionKey): boolean =>
|
|
216
|
+
typeof style?.[key] !== 'undefined' && style?.[key] !== '';
|
|
191
217
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
218
|
+
/**
|
|
219
|
+
* 沿节点路径累加(或抵消)某一方向上的定位偏移量
|
|
220
|
+
* 当路径上的祖先使用了反方向定位(例如计算 left 时祖先用了 right)或非数值定位时,
|
|
221
|
+
* 无法简单地通过求和换算坐标,此时返回 0 表示放弃补偿、保持原值
|
|
222
|
+
* @param path 从根到目标节点的路径(含节点自身)
|
|
223
|
+
* @param dir 需要累加的定位方向
|
|
224
|
+
* @param opposite 反方向定位属性
|
|
225
|
+
* @param sign change2Fixed 取 1(累加祖先偏移),Fixed2Other 取 -1(抵消祖先偏移)
|
|
226
|
+
* @param init 偏移量初始值
|
|
227
|
+
*/
|
|
228
|
+
const accumulatePositionOffset = (
|
|
229
|
+
path: MNode[],
|
|
230
|
+
dir: PositionKey,
|
|
231
|
+
opposite: PositionKey,
|
|
232
|
+
sign: 1 | -1,
|
|
233
|
+
init = 0,
|
|
234
|
+
): number => {
|
|
235
|
+
let offset = init;
|
|
236
|
+
for (const value of path) {
|
|
237
|
+
if (hasPositionValue(value.style, opposite) || !isNumber(value.style?.[dir] || 0)) {
|
|
238
|
+
return 0;
|
|
199
239
|
}
|
|
240
|
+
offset = offset + sign * Number(value.style?.[dir] || 0);
|
|
200
241
|
}
|
|
242
|
+
return offset;
|
|
243
|
+
};
|
|
201
244
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
offset.top = offset.top + Number(value.style?.top || 0);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
245
|
+
export const change2Fixed = (node: MNode, path: MNode[]) => {
|
|
246
|
+
const style = {
|
|
247
|
+
...(node.style || {}),
|
|
248
|
+
};
|
|
211
249
|
|
|
212
|
-
|
|
213
|
-
|
|
250
|
+
// 水平方向:以 left 锚定则累加祖先 left,以 right 锚定则累加祖先 right
|
|
251
|
+
if (!hasPositionValue(node.style, 'right') && isNumber(node.style?.left || 0)) {
|
|
252
|
+
const left = accumulatePositionOffset(path, 'left', 'right', 1);
|
|
253
|
+
if (left) {
|
|
254
|
+
style.left = left;
|
|
255
|
+
}
|
|
256
|
+
} else if (hasPositionValue(node.style, 'right') && isNumber(node.style?.right || 0)) {
|
|
257
|
+
const right = accumulatePositionOffset(path, 'right', 'left', 1);
|
|
258
|
+
if (right) {
|
|
259
|
+
style.right = right;
|
|
260
|
+
}
|
|
214
261
|
}
|
|
215
262
|
|
|
216
|
-
|
|
217
|
-
|
|
263
|
+
// 垂直方向:以 top 锚定则累加祖先 top,以 bottom 锚定则累加祖先 bottom
|
|
264
|
+
if (!hasPositionValue(node.style, 'bottom') && isNumber(node.style?.top || 0)) {
|
|
265
|
+
const top = accumulatePositionOffset(path, 'top', 'bottom', 1);
|
|
266
|
+
if (top) {
|
|
267
|
+
style.top = top;
|
|
268
|
+
}
|
|
269
|
+
} else if (hasPositionValue(node.style, 'bottom') && isNumber(node.style?.bottom || 0)) {
|
|
270
|
+
const bottom = accumulatePositionOffset(path, 'bottom', 'top', 1);
|
|
271
|
+
if (bottom) {
|
|
272
|
+
style.bottom = bottom;
|
|
273
|
+
}
|
|
218
274
|
}
|
|
219
275
|
|
|
220
276
|
return style;
|
|
@@ -222,34 +278,29 @@ export const change2Fixed = (node: MNode, root: MApp) => {
|
|
|
222
278
|
|
|
223
279
|
export const Fixed2Other = async (
|
|
224
280
|
node: MNode,
|
|
225
|
-
|
|
281
|
+
path: MNode[],
|
|
226
282
|
getLayout: (parent: MNode, node?: MNode) => Promise<Layout>,
|
|
227
283
|
) => {
|
|
228
|
-
const path = getNodePath(node.id, root.items);
|
|
229
284
|
const cur = path.pop();
|
|
230
285
|
const offset = {
|
|
231
|
-
left:
|
|
232
|
-
top:
|
|
286
|
+
left: 0,
|
|
287
|
+
top: 0,
|
|
288
|
+
right: 0,
|
|
289
|
+
bottom: 0,
|
|
233
290
|
};
|
|
234
291
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
offset.left = offset.left - Number(value.style?.left || 0);
|
|
242
|
-
}
|
|
292
|
+
// 水平方向:抵消祖先在对应锚定方向上的偏移量,初始值为节点自身的偏移
|
|
293
|
+
if (!hasPositionValue(node.style, 'right') && isNumber(node.style?.left || 0)) {
|
|
294
|
+
offset.left = accumulatePositionOffset(path, 'left', 'right', -1, Number(cur?.style?.left || 0));
|
|
295
|
+
} else if (hasPositionValue(node.style, 'right') && isNumber(node.style?.right || 0)) {
|
|
296
|
+
offset.right = accumulatePositionOffset(path, 'right', 'left', -1, Number(cur?.style?.right || 0));
|
|
243
297
|
}
|
|
244
298
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
offset.top = offset.top - Number(value.style?.top || 0);
|
|
252
|
-
}
|
|
299
|
+
// 垂直方向:同上
|
|
300
|
+
if (!hasPositionValue(node.style, 'bottom') && isNumber(node.style?.top || 0)) {
|
|
301
|
+
offset.top = accumulatePositionOffset(path, 'top', 'bottom', -1, Number(cur?.style?.top || 0));
|
|
302
|
+
} else if (hasPositionValue(node.style, 'bottom') && isNumber(node.style?.bottom || 0)) {
|
|
303
|
+
offset.bottom = accumulatePositionOffset(path, 'bottom', 'top', -1, Number(cur?.style?.bottom || 0));
|
|
253
304
|
}
|
|
254
305
|
|
|
255
306
|
const style = node.style || {};
|
|
@@ -269,6 +320,14 @@ export const Fixed2Other = async (
|
|
|
269
320
|
style.top = offset.top;
|
|
270
321
|
}
|
|
271
322
|
|
|
323
|
+
if (offset.right) {
|
|
324
|
+
style.right = offset.right;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (offset.bottom) {
|
|
328
|
+
style.bottom = offset.bottom;
|
|
329
|
+
}
|
|
330
|
+
|
|
272
331
|
return {
|
|
273
332
|
...style,
|
|
274
333
|
position: 'absolute',
|
|
@@ -316,11 +375,18 @@ export const fixNodePosition = (config: MNode, parent: MContainer, stage: StageC
|
|
|
316
375
|
return config.style;
|
|
317
376
|
}
|
|
318
377
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
378
|
+
const style = { ...(config.style || {}) };
|
|
379
|
+
const baseStyle = config.style || {};
|
|
380
|
+
|
|
381
|
+
if (!('right' in baseStyle)) {
|
|
382
|
+
style.left = fixNodeLeft(config, parent, stage?.renderer?.contentWindow?.document);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (!('top' in baseStyle) && !('bottom' in baseStyle)) {
|
|
386
|
+
style.top = getMiddleTop(config, parent, stage);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return style;
|
|
324
390
|
};
|
|
325
391
|
|
|
326
392
|
// 序列化配置
|
|
@@ -460,11 +526,11 @@ export const resolveSelectedNode = (
|
|
|
460
526
|
throw new Error('没有ID,无法选中');
|
|
461
527
|
}
|
|
462
528
|
|
|
463
|
-
const { node, parent, page } = getNodeInfoFn(id);
|
|
529
|
+
const { node, parent, page, path } = getNodeInfoFn(id);
|
|
464
530
|
if (!node) throw new Error('获取不到组件信息');
|
|
465
531
|
if (node.id === rootId) throw new Error('不能选根节点');
|
|
466
532
|
|
|
467
|
-
return { node, parent, page };
|
|
533
|
+
return { node, parent, page, path };
|
|
468
534
|
};
|
|
469
535
|
|
|
470
536
|
/**
|
|
@@ -479,16 +545,16 @@ export const resolveSelectedNode = (
|
|
|
479
545
|
export const toggleFixedPosition = async (
|
|
480
546
|
dist: MNode,
|
|
481
547
|
src: MNode,
|
|
482
|
-
|
|
548
|
+
path: MNode[],
|
|
483
549
|
getLayoutFn: (parent: MNode, node?: MNode | null) => Promise<Layout>,
|
|
484
550
|
): Promise<MNode> => {
|
|
485
551
|
const newConfig = cloneDeep(dist);
|
|
486
552
|
|
|
487
553
|
if (!isPop(src) && newConfig.style?.position) {
|
|
488
554
|
if (isFixed(newConfig.style) && !isFixed(src.style || {})) {
|
|
489
|
-
newConfig.style = change2Fixed(newConfig,
|
|
555
|
+
newConfig.style = change2Fixed(newConfig, path);
|
|
490
556
|
} else if (!isFixed(newConfig.style) && isFixed(src.style || {})) {
|
|
491
|
-
newConfig.style = await Fixed2Other(newConfig,
|
|
557
|
+
newConfig.style = await Fixed2Other(newConfig, path, getLayoutFn);
|
|
492
558
|
}
|
|
493
559
|
}
|
|
494
560
|
|
|
@@ -684,3 +750,43 @@ export const classifyDragSources = (
|
|
|
684
750
|
|
|
685
751
|
return { sameParentIndices, crossParentConfigs, aborted: false };
|
|
686
752
|
};
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* 给「回滚」生成的新 step 用的简短描述生成器。
|
|
756
|
+
* 与 UI 层 `describePageStep` 同义,但避免 service 反向依赖 layouts/,故放在此工具函数中。
|
|
757
|
+
*/
|
|
758
|
+
export const describeStepForRevert = (step: StepValue): string => {
|
|
759
|
+
const items = step.diff ?? [];
|
|
760
|
+
// 在可读名后拼接组件 id,便于在历史面板中精确定位被回滚的组件;id 缺失时退化为仅展示名称。
|
|
761
|
+
const withId = (node: MNode | undefined, label: string): string => {
|
|
762
|
+
const id = node?.id;
|
|
763
|
+
if (id === undefined || id === null || `${id}` === '') return label;
|
|
764
|
+
return label ? `${label}(id: ${id})` : `id: ${id}`;
|
|
765
|
+
};
|
|
766
|
+
switch (step.opType) {
|
|
767
|
+
case 'add': {
|
|
768
|
+
const count = items.length;
|
|
769
|
+
const node = items[0]?.newSchema;
|
|
770
|
+
const label = node?.name || node?.type || '';
|
|
771
|
+
return `撤回新增 ${count} 个节点${count === 1 ? `(${withId(node, label)})` : ''}`;
|
|
772
|
+
}
|
|
773
|
+
case 'remove': {
|
|
774
|
+
const count = items.length;
|
|
775
|
+
const node = items[0]?.oldSchema;
|
|
776
|
+
const label = node?.name || node?.type || '';
|
|
777
|
+
return `还原已删除的 ${count} 个节点${count === 1 ? `(${withId(node, label)})` : ''}`;
|
|
778
|
+
}
|
|
779
|
+
case 'update':
|
|
780
|
+
default: {
|
|
781
|
+
if (items.length === 1) {
|
|
782
|
+
const { newSchema, oldSchema, changeRecords } = items[0];
|
|
783
|
+
const node = newSchema || oldSchema;
|
|
784
|
+
const label = newSchema?.name || newSchema?.type || oldSchema?.name || oldSchema?.type || '';
|
|
785
|
+
const target = withId(node, label);
|
|
786
|
+
const propPath = changeRecords?.[0]?.propPath;
|
|
787
|
+
return propPath ? `还原 ${target} · ${propPath}` : `还原 ${target}`;
|
|
788
|
+
}
|
|
789
|
+
return `还原 ${items.length} 个节点的修改`;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { EventOption, Id, MComponent, MContainer } from '@tmagic/core';
|
|
20
|
+
import type { CascaderOption } from '@tmagic/form';
|
|
21
|
+
import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, traverseNode } from '@tmagic/utils';
|
|
22
|
+
|
|
23
|
+
import dataSourceService from '@editor/services/dataSource';
|
|
24
|
+
import editorService from '@editor/services/editor';
|
|
25
|
+
import eventsService from '@editor/services/events';
|
|
26
|
+
import { getCascaderOptionsFromFields } from '@editor/utils/data-source';
|
|
27
|
+
|
|
28
|
+
export const EVENT_NAME_VALUE_SEPARATOR = '.';
|
|
29
|
+
|
|
30
|
+
export type EventNameSelectOption = { text: string; value: string };
|
|
31
|
+
export type EventNameOption = EventOption | CascaderOption | EventNameSelectOption;
|
|
32
|
+
|
|
33
|
+
/** 与 EventSelect 中 checkStrictly 一致:component 为 false,其余为 true */
|
|
34
|
+
export const isEventNameCheckStrictly = (src?: string) => src !== 'component';
|
|
35
|
+
|
|
36
|
+
/** 将动作 method 值规范为与 collectEventNameOptionValues 一致的字符串(cascader 无 valueSeparator 时存数组) */
|
|
37
|
+
export const normalizeCompActionValue = (value: unknown): string => {
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
return value.map((item) => `${item}`).join(EVENT_NAME_VALUE_SEPARATOR);
|
|
40
|
+
}
|
|
41
|
+
if (value === null || value === undefined || value === '') {
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
return `${value}`;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 组装事件名称下拉/级联 options,与 EventSelect 默认 eventNameConfig.options 逻辑一致。
|
|
49
|
+
*/
|
|
50
|
+
export const getEventNameOptions = (
|
|
51
|
+
src: string | undefined,
|
|
52
|
+
formValue: Record<string, any> = {},
|
|
53
|
+
): EventNameOption[] => {
|
|
54
|
+
if (!formValue.type) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (src === 'component') {
|
|
59
|
+
const sourceNode = editorService.getNodeById(formValue.id);
|
|
60
|
+
let events: EventOption[] | CascaderOption[] = eventsService.getEvent(formValue.type, { node: sourceNode }) || [];
|
|
61
|
+
|
|
62
|
+
if (formValue.type === 'page-fragment-container' && formValue.pageFragmentId) {
|
|
63
|
+
const pageFragment = editorService.get('root')?.items?.find((page) => page.id === formValue.pageFragmentId);
|
|
64
|
+
if (!pageFragment) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
events = [
|
|
69
|
+
{
|
|
70
|
+
label: pageFragment.name || '页面片容器',
|
|
71
|
+
value: pageFragment.id,
|
|
72
|
+
children: events,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
(pageFragment.items || []).forEach((item) => {
|
|
77
|
+
traverseNode<MComponent | MContainer>(item, (current) => {
|
|
78
|
+
if (!current.type) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const node = editorService.getNodeById(current.id) || current;
|
|
83
|
+
const nodeEvents = eventsService.getEvent(current.type, { node }) || [];
|
|
84
|
+
(events as CascaderOption[]).push({
|
|
85
|
+
label: `${current.name}_${current.id}`,
|
|
86
|
+
value: `${current.id}`,
|
|
87
|
+
children: nodeEvents,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return events;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (events as EventOption[]).map((option) => ({
|
|
96
|
+
text: option.label,
|
|
97
|
+
value: option.value,
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (src === 'datasource') {
|
|
102
|
+
const events: EventNameOption[] = dataSourceService.getFormEvent(formValue.type) || [];
|
|
103
|
+
const dataSource = dataSourceService.getDataSourceById(formValue.id);
|
|
104
|
+
const fields = dataSource?.fields || [];
|
|
105
|
+
|
|
106
|
+
if (fields.length > 0) {
|
|
107
|
+
return [
|
|
108
|
+
...events,
|
|
109
|
+
{
|
|
110
|
+
label: '数据变化',
|
|
111
|
+
value: DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX,
|
|
112
|
+
children: getCascaderOptionsFromFields(fields),
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return events;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return [];
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** 将 select / cascader options 展平为最终写入 name 的字符串集合(cascader 用 `.` 拼接) */
|
|
124
|
+
export const collectEventNameOptionValues = (
|
|
125
|
+
options: EventNameOption[],
|
|
126
|
+
checkStrictly: boolean,
|
|
127
|
+
prefix: any[] = [],
|
|
128
|
+
result: Set<string> = new Set(),
|
|
129
|
+
): Set<string> => {
|
|
130
|
+
options.forEach((option) => {
|
|
131
|
+
if (typeof option?.value === 'undefined') {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const path = [...prefix, option.value];
|
|
136
|
+
const joined = path.map((item) => `${item}`).join(EVENT_NAME_VALUE_SEPARATOR);
|
|
137
|
+
const children = 'children' in option ? option.children : undefined;
|
|
138
|
+
|
|
139
|
+
if (Array.isArray(children) && children.length) {
|
|
140
|
+
if (checkStrictly) {
|
|
141
|
+
result.add(joined);
|
|
142
|
+
}
|
|
143
|
+
collectEventNameOptionValues(children as EventNameOption[], checkStrictly, path, result);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
result.add(joined);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return result;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 解析 event-select 允许的 name 集合。
|
|
155
|
+
* 自定义 eventNameConfig.options 时返回 null(跳过枚举校验)。
|
|
156
|
+
*/
|
|
157
|
+
export const getEventNameAllowedValues = (
|
|
158
|
+
config: { src?: string; eventNameConfig?: { options?: unknown } } = {},
|
|
159
|
+
formValue: Record<string, any> = {},
|
|
160
|
+
): Set<string> | null => {
|
|
161
|
+
if (typeof config.eventNameConfig?.options !== 'undefined') {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (config.src !== 'component' && config.src !== 'datasource') {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return collectEventNameOptionValues(getEventNameOptions(config.src, formValue), isEventNameCheckStrictly(config.src));
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 组装联动组件动作下拉/级联 options,与 EventSelect 默认 compActionConfig.options 逻辑一致。
|
|
174
|
+
*/
|
|
175
|
+
export const getCompActionOptions = (toId?: Id): EventNameOption[] => {
|
|
176
|
+
if (typeof toId === 'undefined' || toId === null || toId === '') {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const node = editorService.getNodeById(toId);
|
|
181
|
+
if (!node?.type) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let methods: EventOption[] | CascaderOption[] = eventsService.getMethod(node.type, { targetId: toId, node }) || [];
|
|
186
|
+
|
|
187
|
+
if (node.type === 'page-fragment-container' && node.pageFragmentId) {
|
|
188
|
+
const pageFragment = editorService.get('root')?.items?.find((page) => page.id === node.pageFragmentId);
|
|
189
|
+
if (!pageFragment) {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
methods = [];
|
|
194
|
+
(pageFragment.items || []).forEach((item: MComponent | MContainer) => {
|
|
195
|
+
traverseNode<MComponent | MContainer>(item, (current) => {
|
|
196
|
+
const node = editorService.getNodeById(current.id) || current;
|
|
197
|
+
|
|
198
|
+
if (!current.type) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const nodeMethods = eventsService.getMethod(current.type, { targetId: current.id, node }) || [];
|
|
203
|
+
if (!nodeMethods.length) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
(methods as CascaderOption[]).push({
|
|
208
|
+
label: `${current.name}_${current.id}`,
|
|
209
|
+
value: `${current.id}`,
|
|
210
|
+
children: nodeMethods,
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
return methods;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return (methods as EventOption[]).map((method) => ({
|
|
219
|
+
text: method.label,
|
|
220
|
+
value: method.value,
|
|
221
|
+
}));
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 解析 event-select 联动组件动作允许的 method 集合。
|
|
226
|
+
* 自定义 compActionConfig.options 时返回 null(跳过枚举校验)。
|
|
227
|
+
*/
|
|
228
|
+
export const getCompActionAllowedValues = (
|
|
229
|
+
config: { src?: string; compActionConfig?: { options?: unknown } } = {},
|
|
230
|
+
model: { to?: Id } = {},
|
|
231
|
+
): Set<string> | null => {
|
|
232
|
+
if (typeof config.compActionConfig?.options !== 'undefined') {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return collectEventNameOptionValues(getCompActionOptions(model.to), isEventNameCheckStrictly(config.src));
|
|
237
|
+
};
|