@tmagic/editor 1.8.0-beta.1 → 1.8.0-beta.3
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 +20 -2
- package/dist/es/components/CodeBlockEditor.vue_vue_type_script_setup_true_lang.js +18 -110
- package/dist/es/components/CodeParams.vue_vue_type_script_setup_true_lang.js +6 -0
- package/dist/es/components/CompareForm.js +5 -0
- package/dist/es/components/CompareForm.vue_vue_type_script_setup_true_lang.js +171 -0
- package/dist/es/editorProps.js +2 -0
- package/dist/es/fields/Code.vue_vue_type_script_setup_true_lang.js +19 -3
- package/dist/es/fields/CodeLink.vue_vue_type_script_setup_true_lang.js +2 -5
- package/dist/es/fields/CodeSelect.vue_vue_type_script_setup_true_lang.js +18 -2
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +37 -6
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +3 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +14 -6
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +3 -1
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +15 -7
- package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +14 -6
- package/dist/es/fields/DataSourceSelect.vue_vue_type_script_setup_true_lang.js +3 -1
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +58 -11
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +11 -6
- package/dist/es/fields/UISelect.vue_vue_type_script_setup_true_lang.js +8 -5
- package/dist/es/hooks/use-code-block-edit.js +2 -2
- package/dist/es/hooks/use-stage.js +17 -8
- package/dist/es/index.js +5 -1
- package/dist/es/initService.js +6 -6
- package/dist/es/layouts/CodeEditor.vue_vue_type_script_setup_true_lang.js +6 -5
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +12 -7
- package/dist/es/layouts/NavMenu.vue_vue_type_script_setup_true_lang.js +8 -0
- package/dist/es/layouts/history-list/Bucket.js +5 -0
- package/dist/es/layouts/history-list/Bucket.vue_vue_type_script_setup_true_lang.js +103 -0
- 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 +73 -0
- package/dist/es/layouts/history-list/GroupRow.js +5 -0
- package/dist/es/layouts/history-list/GroupRow.vue_vue_type_script_setup_true_lang.js +198 -0
- package/dist/es/layouts/history-list/HistoryDiffDialog.js +5 -0
- package/dist/es/layouts/history-list/HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js +245 -0
- package/dist/es/layouts/history-list/HistoryListPanel.js +5 -0
- package/dist/es/layouts/history-list/HistoryListPanel.vue_vue_type_script_setup_true_lang.js +340 -0
- package/dist/es/layouts/history-list/InitialRow.js +5 -0
- package/dist/es/layouts/history-list/InitialRow.vue_vue_type_script_setup_true_lang.js +54 -0
- package/dist/es/layouts/history-list/PageTab.js +5 -0
- package/dist/es/layouts/history-list/PageTab.vue_vue_type_script_setup_true_lang.js +105 -0
- package/dist/es/layouts/history-list/composables.js +172 -0
- package/dist/es/layouts/sidebar/layer/use-node-status.js +1 -1
- package/dist/es/services/BaseService.js +31 -68
- package/dist/es/services/codeBlock.js +205 -8
- package/dist/es/services/componentList.js +2 -2
- package/dist/es/services/dataSource.js +217 -8
- package/dist/es/services/dep.js +21 -9
- package/dist/es/services/editor.js +350 -160
- package/dist/es/services/events.js +2 -2
- package/dist/es/services/history.js +410 -12
- package/dist/es/services/keybinding.js +2 -2
- package/dist/es/services/props.js +8 -8
- package/dist/es/services/stageOverlay.js +2 -2
- package/dist/es/services/storage.js +2 -2
- package/dist/es/services/ui.js +2 -2
- package/dist/es/style.css +379 -1
- package/dist/es/utils/code-block.js +122 -0
- package/dist/es/utils/content-menu.js +4 -5
- package/dist/es/utils/dep/worker.js +1 -1
- package/dist/es/utils/editor.js +2 -2
- package/dist/es/utils/undo-redo.js +20 -0
- package/dist/style.css +379 -1
- package/dist/tmagic-editor.umd.cjs +3331 -787
- package/package.json +7 -7
- package/src/Editor.vue +15 -0
- package/src/components/CodeBlockEditor.vue +20 -109
- package/src/components/CodeParams.vue +6 -0
- package/src/components/CompareForm.vue +238 -0
- package/src/editorProps.ts +9 -0
- package/src/fields/Code.vue +19 -3
- package/src/fields/CodeLink.vue +2 -5
- package/src/fields/CodeSelect.vue +17 -1
- package/src/fields/CodeSelectCol.vue +30 -2
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +7 -1
- package/src/fields/DataSourceFieldSelect/Index.vue +2 -2
- package/src/fields/DataSourceFields.vue +12 -3
- package/src/fields/DataSourceMethodSelect.vue +4 -1
- package/src/fields/DataSourceMethods.vue +14 -4
- package/src/fields/DataSourceMocks.vue +13 -3
- package/src/fields/DataSourceSelect.vue +4 -1
- package/src/fields/EventSelect.vue +57 -8
- package/src/fields/KeyValue.vue +17 -4
- package/src/fields/UISelect.vue +5 -2
- package/src/hooks/use-code-block-edit.ts +5 -2
- package/src/hooks/use-stage.ts +24 -7
- package/src/index.ts +3 -0
- package/src/layouts/CodeEditor.vue +17 -5
- package/src/layouts/Framework.vue +10 -5
- package/src/layouts/NavMenu.vue +9 -0
- package/src/layouts/history-list/Bucket.vue +124 -0
- package/src/layouts/history-list/BucketTab.vue +77 -0
- package/src/layouts/history-list/GroupRow.vue +242 -0
- package/src/layouts/history-list/HistoryDiffDialog.vue +231 -0
- package/src/layouts/history-list/HistoryListPanel.vue +380 -0
- package/src/layouts/history-list/InitialRow.vue +52 -0
- package/src/layouts/history-list/PageTab.vue +108 -0
- package/src/layouts/history-list/composables.ts +226 -0
- package/src/layouts/sidebar/layer/use-node-status.ts +9 -6
- package/src/services/BaseService.ts +35 -86
- package/src/services/codeBlock.ts +256 -5
- package/src/services/dataSource.ts +257 -6
- package/src/services/dep.ts +32 -9
- package/src/services/editor.ts +454 -171
- package/src/services/history.ts +455 -8
- package/src/services/props.ts +2 -2
- package/src/theme/history-list-panel.scss +462 -0
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +269 -6
- package/src/utils/code-block.ts +150 -0
- package/src/utils/content-menu.ts +8 -5
- package/src/utils/dep/worker.ts +5 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/undo-redo.ts +23 -0
- package/types/index.d.ts +2274 -819
- package/dist/es/utils/compose.js +0 -44
- package/dist/es/utils/editor-history.js +0 -100
- package/src/utils/compose.ts +0 -52
- package/src/utils/editor-history.ts +0 -138
package/dist/es/style.css
CHANGED
|
@@ -126,7 +126,10 @@
|
|
|
126
126
|
.m-form-container.has-tip .tmagic-design-form-item {
|
|
127
127
|
flex: 1;
|
|
128
128
|
}
|
|
129
|
-
.m-form-container .tmagic-design-form-item.show-diff {
|
|
129
|
+
.m-form-container .tmagic-design-form-item.show-after-diff {
|
|
130
|
+
background: rgb(225, 243, 216);
|
|
131
|
+
}
|
|
132
|
+
.m-form-container .tmagic-design-form-item.show-before-diff {
|
|
130
133
|
background: #f7dadd;
|
|
131
134
|
}
|
|
132
135
|
|
|
@@ -578,6 +581,381 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
578
581
|
background-color: transparent;
|
|
579
582
|
}
|
|
580
583
|
|
|
584
|
+
.m-editor-history-list-popover {
|
|
585
|
+
padding: 0 !important;
|
|
586
|
+
}
|
|
587
|
+
.m-editor-history-list-popover .m-editor-history-list {
|
|
588
|
+
position: relative;
|
|
589
|
+
padding: 4px 8px 8px;
|
|
590
|
+
}
|
|
591
|
+
.m-editor-history-list-popover .m-editor-history-list-close {
|
|
592
|
+
position: absolute;
|
|
593
|
+
top: 4px;
|
|
594
|
+
right: 4px;
|
|
595
|
+
z-index: 1;
|
|
596
|
+
display: flex;
|
|
597
|
+
align-items: center;
|
|
598
|
+
height: 40px;
|
|
599
|
+
margin: 0;
|
|
600
|
+
color: #909399;
|
|
601
|
+
}
|
|
602
|
+
.m-editor-history-list-popover .m-editor-history-list-close:hover {
|
|
603
|
+
color: #409eff;
|
|
604
|
+
}
|
|
605
|
+
.m-editor-history-list-popover .m-editor-history-list-tabs .el-tabs__header,
|
|
606
|
+
.m-editor-history-list-popover .m-editor-history-list-tabs .t-tabs__header {
|
|
607
|
+
margin-bottom: 4px;
|
|
608
|
+
}
|
|
609
|
+
.m-editor-history-list-popover .m-editor-history-list-empty {
|
|
610
|
+
padding: 24px 0;
|
|
611
|
+
text-align: center;
|
|
612
|
+
color: #909399;
|
|
613
|
+
font-size: 12px;
|
|
614
|
+
}
|
|
615
|
+
.m-editor-history-list-popover .m-editor-history-list-ul {
|
|
616
|
+
margin: 0;
|
|
617
|
+
padding: 0;
|
|
618
|
+
list-style: none;
|
|
619
|
+
}
|
|
620
|
+
.m-editor-history-list-popover .m-editor-history-list-item {
|
|
621
|
+
display: flex;
|
|
622
|
+
align-items: center;
|
|
623
|
+
gap: 6px;
|
|
624
|
+
padding: 6px 8px;
|
|
625
|
+
border-radius: 4px;
|
|
626
|
+
font-size: 12px;
|
|
627
|
+
line-height: 1.4;
|
|
628
|
+
color: #303133;
|
|
629
|
+
cursor: default;
|
|
630
|
+
}
|
|
631
|
+
.m-editor-history-list-popover .m-editor-history-list-item:not(.m-editor-history-list-group.is-merged):hover {
|
|
632
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
633
|
+
}
|
|
634
|
+
.m-editor-history-list-popover .m-editor-history-list-item.is-undone {
|
|
635
|
+
color: #c0c4cc;
|
|
636
|
+
}
|
|
637
|
+
.m-editor-history-list-popover .m-editor-history-list-item.is-undone .m-editor-history-list-item-op {
|
|
638
|
+
opacity: 0.5;
|
|
639
|
+
}
|
|
640
|
+
.m-editor-history-list-popover .m-editor-history-list-item.is-current:not(.m-editor-history-list-group.is-merged) {
|
|
641
|
+
background-color: rgba(64, 158, 255, 0.1);
|
|
642
|
+
box-shadow: inset 2px 0 0 #409eff;
|
|
643
|
+
}
|
|
644
|
+
.m-editor-history-list-popover .m-editor-history-list-item.is-current:not(.m-editor-history-list-group.is-merged):hover {
|
|
645
|
+
background-color: rgba(64, 158, 255, 0.16);
|
|
646
|
+
}
|
|
647
|
+
.m-editor-history-list-popover .m-editor-history-list-item.is-current:not(.m-editor-history-list-group.is-merged) .m-editor-history-list-item-desc {
|
|
648
|
+
font-weight: 600;
|
|
649
|
+
color: #409eff;
|
|
650
|
+
}
|
|
651
|
+
.m-editor-history-list-popover .m-editor-history-list-group {
|
|
652
|
+
flex-direction: column;
|
|
653
|
+
align-items: stretch;
|
|
654
|
+
gap: 0;
|
|
655
|
+
}
|
|
656
|
+
.m-editor-history-list-popover .m-editor-history-list-group .m-editor-history-list-group-head {
|
|
657
|
+
display: flex;
|
|
658
|
+
align-items: center;
|
|
659
|
+
gap: 6px;
|
|
660
|
+
cursor: default;
|
|
661
|
+
}
|
|
662
|
+
.m-editor-history-list-popover .m-editor-history-list-group .m-editor-history-list-group-head.is-clickable {
|
|
663
|
+
cursor: pointer;
|
|
664
|
+
}
|
|
665
|
+
.m-editor-history-list-popover .m-editor-history-list-group .m-editor-history-list-group-toggle {
|
|
666
|
+
flex: 0 0 auto;
|
|
667
|
+
width: 16px;
|
|
668
|
+
text-align: center;
|
|
669
|
+
color: #909399;
|
|
670
|
+
font-size: 12px;
|
|
671
|
+
user-select: none;
|
|
672
|
+
transition: transform 0.15s ease;
|
|
673
|
+
pointer-events: none;
|
|
674
|
+
}
|
|
675
|
+
.m-editor-history-list-popover .m-editor-history-list-group .m-editor-history-list-group-toggle.is-expanded {
|
|
676
|
+
transform: rotate(180deg);
|
|
677
|
+
}
|
|
678
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged {
|
|
679
|
+
margin: 4px 0;
|
|
680
|
+
padding: 4px 8px 6px;
|
|
681
|
+
background-color: rgba(47, 84, 235, 0.06);
|
|
682
|
+
border: 1px solid rgba(47, 84, 235, 0.18);
|
|
683
|
+
border-left: 3px solid #2f54eb;
|
|
684
|
+
border-radius: 4px;
|
|
685
|
+
}
|
|
686
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged:hover {
|
|
687
|
+
background-color: rgba(47, 84, 235, 0.1);
|
|
688
|
+
}
|
|
689
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged .m-editor-history-list-group-head {
|
|
690
|
+
font-weight: 600;
|
|
691
|
+
color: #1d39c4;
|
|
692
|
+
}
|
|
693
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged.is-undone {
|
|
694
|
+
background-color: rgba(192, 196, 204, 0.08);
|
|
695
|
+
border-color: rgba(192, 196, 204, 0.4);
|
|
696
|
+
border-left-color: #c0c4cc;
|
|
697
|
+
}
|
|
698
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged.is-undone .m-editor-history-list-group-head {
|
|
699
|
+
color: #c0c4cc;
|
|
700
|
+
}
|
|
701
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged.is-current {
|
|
702
|
+
background-color: rgba(64, 158, 255, 0.08);
|
|
703
|
+
border-color: rgba(64, 158, 255, 0.3);
|
|
704
|
+
border-left-color: #409eff;
|
|
705
|
+
box-shadow: none;
|
|
706
|
+
}
|
|
707
|
+
.m-editor-history-list-popover .m-editor-history-list-group.is-merged.is-current .m-editor-history-list-group-head {
|
|
708
|
+
color: #409eff;
|
|
709
|
+
}
|
|
710
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps {
|
|
711
|
+
margin: 6px 0 0 6px;
|
|
712
|
+
padding: 0;
|
|
713
|
+
list-style: none;
|
|
714
|
+
border-left: 1px dashed rgba(47, 84, 235, 0.45);
|
|
715
|
+
}
|
|
716
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps li {
|
|
717
|
+
display: flex;
|
|
718
|
+
align-items: center;
|
|
719
|
+
gap: 6px;
|
|
720
|
+
padding: 3px 8px;
|
|
721
|
+
font-size: 11px;
|
|
722
|
+
color: #606266;
|
|
723
|
+
cursor: default;
|
|
724
|
+
border-radius: 3px;
|
|
725
|
+
}
|
|
726
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps li.is-clickable {
|
|
727
|
+
cursor: pointer;
|
|
728
|
+
}
|
|
729
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps li.is-clickable:hover {
|
|
730
|
+
background-color: rgba(47, 84, 235, 0.1);
|
|
731
|
+
}
|
|
732
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps li.is-undone {
|
|
733
|
+
color: #c0c4cc;
|
|
734
|
+
}
|
|
735
|
+
.m-editor-history-list-popover .m-editor-history-list-substeps li.is-current {
|
|
736
|
+
color: #409eff;
|
|
737
|
+
font-weight: 600;
|
|
738
|
+
background-color: rgba(64, 158, 255, 0.08);
|
|
739
|
+
border-radius: 3px;
|
|
740
|
+
}
|
|
741
|
+
.m-editor-history-list-popover .m-editor-history-list-item-current {
|
|
742
|
+
flex: 0 0 auto;
|
|
743
|
+
padding: 0 6px;
|
|
744
|
+
border-radius: 2px;
|
|
745
|
+
font-size: 10px;
|
|
746
|
+
line-height: 16px;
|
|
747
|
+
color: #fff;
|
|
748
|
+
background-color: #409eff;
|
|
749
|
+
font-weight: 500;
|
|
750
|
+
}
|
|
751
|
+
.m-editor-history-list-popover .m-editor-history-list-item-index {
|
|
752
|
+
flex: 0 0 auto;
|
|
753
|
+
color: #909399;
|
|
754
|
+
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
|
755
|
+
font-size: 11px;
|
|
756
|
+
font-weight: 400;
|
|
757
|
+
white-space: nowrap;
|
|
758
|
+
}
|
|
759
|
+
.m-editor-history-list-popover .m-editor-history-list-item-time {
|
|
760
|
+
flex: 0 0 auto;
|
|
761
|
+
color: #a8abb2;
|
|
762
|
+
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
|
763
|
+
font-size: 11px;
|
|
764
|
+
font-weight: 400;
|
|
765
|
+
white-space: nowrap;
|
|
766
|
+
}
|
|
767
|
+
.m-editor-history-list-popover .m-editor-history-list-item-op {
|
|
768
|
+
flex: 0 0 auto;
|
|
769
|
+
padding: 0 6px;
|
|
770
|
+
border-radius: 2px;
|
|
771
|
+
font-size: 11px;
|
|
772
|
+
line-height: 18px;
|
|
773
|
+
color: #fff;
|
|
774
|
+
background-color: #909399;
|
|
775
|
+
}
|
|
776
|
+
.m-editor-history-list-popover .m-editor-history-list-item-op.op-add {
|
|
777
|
+
background-color: #67c23a;
|
|
778
|
+
}
|
|
779
|
+
.m-editor-history-list-popover .m-editor-history-list-item-op.op-remove {
|
|
780
|
+
background-color: #f56c6c;
|
|
781
|
+
}
|
|
782
|
+
.m-editor-history-list-popover .m-editor-history-list-item-op.op-update {
|
|
783
|
+
background-color: #e6a23c;
|
|
784
|
+
}
|
|
785
|
+
.m-editor-history-list-popover .m-editor-history-list-item-op.op-initial {
|
|
786
|
+
background-color: #909399;
|
|
787
|
+
}
|
|
788
|
+
.m-editor-history-list-popover .m-editor-history-list-initial {
|
|
789
|
+
cursor: default;
|
|
790
|
+
color: #606266;
|
|
791
|
+
border-top: 1px dashed #dcdfe6;
|
|
792
|
+
margin-top: 4px;
|
|
793
|
+
padding-top: 8px;
|
|
794
|
+
}
|
|
795
|
+
.m-editor-history-list-popover .m-editor-history-list-initial.is-clickable {
|
|
796
|
+
cursor: pointer;
|
|
797
|
+
}
|
|
798
|
+
.m-editor-history-list-popover .m-editor-history-list-initial .m-editor-history-list-item-desc {
|
|
799
|
+
font-style: italic;
|
|
800
|
+
}
|
|
801
|
+
.m-editor-history-list-popover .m-editor-history-list-item-desc {
|
|
802
|
+
flex: 1 1 auto;
|
|
803
|
+
overflow: hidden;
|
|
804
|
+
text-overflow: ellipsis;
|
|
805
|
+
white-space: nowrap;
|
|
806
|
+
}
|
|
807
|
+
.m-editor-history-list-popover .m-editor-history-list-item-merge {
|
|
808
|
+
flex: 0 0 auto;
|
|
809
|
+
padding: 0 8px;
|
|
810
|
+
border-radius: 8px;
|
|
811
|
+
font-size: 10px;
|
|
812
|
+
line-height: 16px;
|
|
813
|
+
color: #fff;
|
|
814
|
+
background-color: #2f54eb;
|
|
815
|
+
font-weight: 500;
|
|
816
|
+
letter-spacing: 0.2px;
|
|
817
|
+
}
|
|
818
|
+
.m-editor-history-list-popover .m-editor-history-list-item-diff {
|
|
819
|
+
flex: 0 0 auto;
|
|
820
|
+
padding: 0 6px;
|
|
821
|
+
border-radius: 2px;
|
|
822
|
+
font-size: 10px;
|
|
823
|
+
line-height: 16px;
|
|
824
|
+
color: #409eff;
|
|
825
|
+
background-color: rgba(64, 158, 255, 0.1);
|
|
826
|
+
cursor: pointer;
|
|
827
|
+
user-select: none;
|
|
828
|
+
}
|
|
829
|
+
.m-editor-history-list-popover .m-editor-history-list-item-diff:hover {
|
|
830
|
+
background-color: rgba(64, 158, 255, 0.2);
|
|
831
|
+
}
|
|
832
|
+
.m-editor-history-list-popover .m-editor-history-list-item-goto {
|
|
833
|
+
flex: 0 0 auto;
|
|
834
|
+
padding: 0 6px;
|
|
835
|
+
border-radius: 2px;
|
|
836
|
+
font-size: 10px;
|
|
837
|
+
line-height: 16px;
|
|
838
|
+
color: #606266;
|
|
839
|
+
background-color: rgba(96, 98, 102, 0.1);
|
|
840
|
+
cursor: pointer;
|
|
841
|
+
user-select: none;
|
|
842
|
+
}
|
|
843
|
+
.m-editor-history-list-popover .m-editor-history-list-item-goto:hover {
|
|
844
|
+
background-color: rgba(96, 98, 102, 0.18);
|
|
845
|
+
}
|
|
846
|
+
.m-editor-history-list-popover .m-editor-history-list-item-revert {
|
|
847
|
+
flex: 0 0 auto;
|
|
848
|
+
padding: 0 6px;
|
|
849
|
+
border-radius: 2px;
|
|
850
|
+
font-size: 10px;
|
|
851
|
+
line-height: 16px;
|
|
852
|
+
color: #f56c6c;
|
|
853
|
+
background-color: rgba(245, 108, 108, 0.12);
|
|
854
|
+
cursor: pointer;
|
|
855
|
+
user-select: none;
|
|
856
|
+
}
|
|
857
|
+
.m-editor-history-list-popover .m-editor-history-list-item-revert:hover {
|
|
858
|
+
background-color: rgba(245, 108, 108, 0.25);
|
|
859
|
+
}
|
|
860
|
+
.m-editor-history-list-popover .m-editor-history-list-substep-desc {
|
|
861
|
+
flex: 1 1 auto;
|
|
862
|
+
overflow: hidden;
|
|
863
|
+
text-overflow: ellipsis;
|
|
864
|
+
white-space: nowrap;
|
|
865
|
+
}
|
|
866
|
+
.m-editor-history-list-popover .m-editor-history-list-bucket {
|
|
867
|
+
margin-bottom: 8px;
|
|
868
|
+
}
|
|
869
|
+
.m-editor-history-list-popover .m-editor-history-list-bucket:last-child {
|
|
870
|
+
margin-bottom: 0;
|
|
871
|
+
}
|
|
872
|
+
.m-editor-history-list-popover .m-editor-history-list-bucket-title {
|
|
873
|
+
display: flex;
|
|
874
|
+
align-items: center;
|
|
875
|
+
gap: 6px;
|
|
876
|
+
padding: 4px 8px;
|
|
877
|
+
font-size: 12px;
|
|
878
|
+
font-weight: 500;
|
|
879
|
+
color: #606266;
|
|
880
|
+
background-color: #f5f7fa;
|
|
881
|
+
border-radius: 4px;
|
|
882
|
+
}
|
|
883
|
+
.m-editor-history-list-popover .m-editor-history-list-bucket-title code {
|
|
884
|
+
flex: 1 1 auto;
|
|
885
|
+
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
|
886
|
+
font-size: 11px;
|
|
887
|
+
color: #409eff;
|
|
888
|
+
overflow: hidden;
|
|
889
|
+
text-overflow: ellipsis;
|
|
890
|
+
white-space: nowrap;
|
|
891
|
+
}
|
|
892
|
+
.m-editor-history-list-popover .m-editor-history-list-bucket-count {
|
|
893
|
+
flex: 0 0 auto;
|
|
894
|
+
color: #909399;
|
|
895
|
+
font-weight: 400;
|
|
896
|
+
font-size: 11px;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-body {
|
|
900
|
+
display: flex;
|
|
901
|
+
flex-direction: column;
|
|
902
|
+
}
|
|
903
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-notice {
|
|
904
|
+
margin-bottom: 8px;
|
|
905
|
+
padding: 8px 12px;
|
|
906
|
+
background-color: #fdf6ec;
|
|
907
|
+
border: 1px solid #faecd8;
|
|
908
|
+
border-radius: 4px;
|
|
909
|
+
color: #e6a23c;
|
|
910
|
+
font-size: 13px;
|
|
911
|
+
line-height: 1.5;
|
|
912
|
+
}
|
|
913
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-header {
|
|
914
|
+
display: flex;
|
|
915
|
+
align-items: center;
|
|
916
|
+
justify-content: space-between;
|
|
917
|
+
margin-bottom: 8px;
|
|
918
|
+
padding: 8px 12px;
|
|
919
|
+
background-color: #f5f7fa;
|
|
920
|
+
border-radius: 4px;
|
|
921
|
+
gap: 12px;
|
|
922
|
+
}
|
|
923
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-controls {
|
|
924
|
+
display: flex;
|
|
925
|
+
align-items: center;
|
|
926
|
+
flex: 0 0 auto;
|
|
927
|
+
gap: 8px;
|
|
928
|
+
}
|
|
929
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-view,
|
|
930
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-mode {
|
|
931
|
+
flex: 0 0 auto;
|
|
932
|
+
}
|
|
933
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-target {
|
|
934
|
+
flex: 1 1 auto;
|
|
935
|
+
font-size: 13px;
|
|
936
|
+
font-weight: 500;
|
|
937
|
+
color: #303133;
|
|
938
|
+
overflow: hidden;
|
|
939
|
+
text-overflow: ellipsis;
|
|
940
|
+
white-space: nowrap;
|
|
941
|
+
}
|
|
942
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-legend {
|
|
943
|
+
display: flex;
|
|
944
|
+
align-items: center;
|
|
945
|
+
gap: 6px;
|
|
946
|
+
margin-bottom: 12px;
|
|
947
|
+
padding: 0 4px;
|
|
948
|
+
}
|
|
949
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-arrow {
|
|
950
|
+
color: #909399;
|
|
951
|
+
font-size: 12px;
|
|
952
|
+
}
|
|
953
|
+
.m-editor-history-diff-dialog .m-editor-history-diff-dialog-tip {
|
|
954
|
+
margin-left: 8px;
|
|
955
|
+
color: #e6a23c;
|
|
956
|
+
font-size: 12px;
|
|
957
|
+
}
|
|
958
|
+
|
|
581
959
|
.m-editor {
|
|
582
960
|
display: flex;
|
|
583
961
|
flex-direction: column;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { getEditorConfig } from "./config.js";
|
|
2
|
+
import { defineFormConfig, defineFormItem } from "@tmagic/form";
|
|
3
|
+
import { tMagicMessage } from "@tmagic/design";
|
|
4
|
+
//#region packages/editor/src/utils/code-block.ts
|
|
5
|
+
/** 默认的"参数类型"列配置:数字 / 字符串 / 组件 三选一。 */
|
|
6
|
+
var defaultParamColConfig = () => defineFormItem({
|
|
7
|
+
type: "row",
|
|
8
|
+
label: "参数类型",
|
|
9
|
+
items: [{
|
|
10
|
+
text: "参数类型",
|
|
11
|
+
labelWidth: "70px",
|
|
12
|
+
type: "select",
|
|
13
|
+
name: "type",
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
text: "数字",
|
|
17
|
+
label: "数字",
|
|
18
|
+
value: "number"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
text: "字符串",
|
|
22
|
+
label: "字符串",
|
|
23
|
+
value: "text"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
text: "组件",
|
|
27
|
+
label: "组件",
|
|
28
|
+
value: "ui-select"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}]
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* 生成代码块表单配置。返回的是普通对象数组,可直接传给 `<MForm :config>`;
|
|
35
|
+
* 如需响应式的 props 变化(如切换 dataSourceType),调用方在 `computed` 中再次调用本函数即可。
|
|
36
|
+
*/
|
|
37
|
+
var getCodeBlockFormConfig = (options = {}) => {
|
|
38
|
+
const { paramColConfig, isDataSource, dataSourceType, codeOptions = {}, editable = true } = options;
|
|
39
|
+
return defineFormConfig([
|
|
40
|
+
{
|
|
41
|
+
text: "名称",
|
|
42
|
+
name: "name",
|
|
43
|
+
...editable ? { rules: [{
|
|
44
|
+
required: true,
|
|
45
|
+
message: "请输入名称",
|
|
46
|
+
trigger: "blur"
|
|
47
|
+
}] } : {}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
text: "描述",
|
|
51
|
+
name: "desc"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
text: "执行时机",
|
|
55
|
+
name: "timing",
|
|
56
|
+
type: "select",
|
|
57
|
+
options: () => {
|
|
58
|
+
const list = [{
|
|
59
|
+
text: "初始化前",
|
|
60
|
+
value: "beforeInit"
|
|
61
|
+
}, {
|
|
62
|
+
text: "初始化后",
|
|
63
|
+
value: "afterInit"
|
|
64
|
+
}];
|
|
65
|
+
if (dataSourceType?.() !== "base") {
|
|
66
|
+
list.push({
|
|
67
|
+
text: "请求前",
|
|
68
|
+
value: "beforeRequest"
|
|
69
|
+
});
|
|
70
|
+
list.push({
|
|
71
|
+
text: "请求后",
|
|
72
|
+
value: "afterRequest"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return list;
|
|
76
|
+
},
|
|
77
|
+
display: () => Boolean(isDataSource?.())
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: "table",
|
|
81
|
+
border: true,
|
|
82
|
+
text: "参数",
|
|
83
|
+
enableFullscreen: false,
|
|
84
|
+
enableToggleMode: false,
|
|
85
|
+
name: "params",
|
|
86
|
+
dropSort: false,
|
|
87
|
+
items: [
|
|
88
|
+
{
|
|
89
|
+
type: "text",
|
|
90
|
+
label: "参数名",
|
|
91
|
+
name: "name"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: "text",
|
|
95
|
+
label: "描述",
|
|
96
|
+
name: "extra"
|
|
97
|
+
},
|
|
98
|
+
paramColConfig || defaultParamColConfig()
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "content",
|
|
103
|
+
type: "vs-code",
|
|
104
|
+
options: codeOptions,
|
|
105
|
+
autosize: {
|
|
106
|
+
minRows: 10,
|
|
107
|
+
maxRows: 30
|
|
108
|
+
},
|
|
109
|
+
...editable ? { onChange: (_formState, code) => {
|
|
110
|
+
try {
|
|
111
|
+
getEditorConfig("parseDSL")(code);
|
|
112
|
+
return code;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
tMagicMessage.error(error.message);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
} } : {}
|
|
118
|
+
}
|
|
119
|
+
]);
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
export { getCodeBlockFormConfig };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COPY_STORAGE_KEY } from "./editor.js";
|
|
2
2
|
import { calcValueByFontsize, isPage, isPageFragment } from "@tmagic/utils";
|
|
3
|
-
import { NodeType } from "@tmagic/core";
|
|
3
|
+
import { NodeType, cloneDeep } from "@tmagic/core";
|
|
4
4
|
import { computed, markRaw } from "vue";
|
|
5
5
|
import { CopyDocument, Delete, DocumentCopy } from "@element-plus/icons-vue";
|
|
6
6
|
//#region packages/editor/src/utils/content-menu.ts
|
|
@@ -47,12 +47,11 @@ var usePasteMenu = (menu) => ({
|
|
|
47
47
|
} else editorService.paste();
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
var moveTo = (id, { editorService }) => {
|
|
50
|
+
var moveTo = async (id, { editorService }) => {
|
|
51
51
|
const nodes = editorService.get("nodes") || [];
|
|
52
52
|
const parent = editorService.getNodeById(id);
|
|
53
|
-
if (!parent) return;
|
|
54
|
-
editorService.
|
|
55
|
-
editorService.remove(nodes);
|
|
53
|
+
if (!parent || nodes.length === 0) return;
|
|
54
|
+
await editorService.moveToContainer(cloneDeep(nodes), parent.id, { doNotSwitchPage: true });
|
|
56
55
|
};
|
|
57
56
|
var useMoveToMenu = ({ editorService }) => {
|
|
58
57
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region packages/editor/src/utils/dep/worker.ts?worker&inline
|
|
2
|
-
var jsContent = "(function() {\n //#region packages/schema/src/index.ts\n const NODE_CONDS_KEY = \"displayConds\";\n const NODE_DISABLE_DATA_SOURCE_KEY = \"_tmagic_node_disabled_data_source\";\n const NODE_DISABLE_CODE_BLOCK_KEY = \"_tmagic_node_disabled_code_block\";\n let HookType = /* @__PURE__ */ function(HookType) {\n /** 代码块钩子标识 */\n HookType[\"CODE\"] = \"code\";\n return HookType;\n }({});\n //#endregion\n //#region packages/utils/src/const.ts\n const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = \"ds-field::\";\n //#endregion\n //#region packages/utils/src/index.ts\n const isObject = (obj) => Object.prototype.toString.call(obj) === \"[object Object]\";\n const getKeysArray = (keys) => `${keys}`.replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\");\n const dataSourceTemplateRegExp = /\\$\\{([\\s\\S]+?)\\}/g;\n //#endregion\n //#region packages/dep/src/types.ts\n /** 依赖收集的目标类型 */\n let DepTargetType = /* @__PURE__ */ function(DepTargetType) {\n DepTargetType[\"DEFAULT\"] = \"default\";\n /** 代码块 */\n DepTargetType[\"CODE_BLOCK\"] = \"code-block\";\n /** 数据源 */\n DepTargetType[\"DATA_SOURCE\"] = \"data-source\";\n /** 数据源方法 */\n DepTargetType[\"DATA_SOURCE_METHOD\"] = \"data-source-method\";\n /** 数据源条件 */\n DepTargetType[\"DATA_SOURCE_COND\"] = \"data-source-cond\";\n return DepTargetType;\n }({});\n //#endregion\n //#region packages/dep/src/Target.ts\n /**\n * 需要收集依赖的目标\n * 例如:一个代码块可以为一个目标\n */\n var Target = class {\n /**\n * 如何识别目标\n */\n isTarget;\n /**\n * 目标id,不可重复\n * 例如目标是代码块,则为代码块id\n */\n id;\n /**\n * 目标名称,用于显示在依赖列表中\n */\n name;\n /**\n * 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type\n */\n type = DepTargetType.DEFAULT;\n /**\n * 依赖详情\n * 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }\n */\n deps = {};\n /**\n * 是否默认收集,默认为true,当值为false时需要传入type参数给collect方法才会被收集\n */\n isCollectByDefault;\n constructor(options) {\n this.isTarget = options.isTarget;\n this.id = options.id;\n this.name = options.name;\n this.isCollectByDefault = options.isCollectByDefault ?? true;\n if (options.type) this.type = options.type;\n if (options.initialDeps) this.deps = options.initialDeps;\n }\n /**\n * 更新依赖\n * @param option 节点配置\n * @param key 哪个key配置了这个目标的id\n */\n updateDep({ id, name, key, data }) {\n const dep = this.deps[id] || {\n name,\n keys: []\n };\n dep.name = name;\n dep.data = data;\n this.deps[id] = dep;\n if (!dep.keys.includes(key)) dep.keys.push(key);\n }\n /**\n * 删除依赖\n * @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖\n * @param key 节点下哪个key需要移除,如果为空,则移除改节点下的所有依赖key\n * @returns void\n */\n removeDep(id, key) {\n if (typeof id === \"undefined\") {\n Object.keys(this.deps).forEach((depKey) => {\n delete this.deps[depKey];\n });\n return;\n }\n const dep = this.deps[id];\n if (!dep) return;\n if (key) {\n const index = dep.keys.indexOf(key);\n dep.keys.splice(index, 1);\n if (dep.keys.length === 0) delete this.deps[id];\n } else delete this.deps[id];\n }\n /**\n * 判断指定节点下的指定key是否存在在依赖列表中\n * @param node 哪个节点\n * @param key 哪个key\n * @returns boolean\n */\n hasDep(id, key) {\n return this.deps[id]?.keys.includes(key) ?? false;\n }\n destroy() {\n this.deps = {};\n }\n };\n //#endregion\n //#region packages/dep/src/utils.ts\n const INTEGER_REGEXP = /^\\d+$/;\n const createCodeBlockTarget = (id, codeBlock, initialDeps = {}) => new Target({\n type: DepTargetType.CODE_BLOCK,\n id,\n initialDeps,\n name: codeBlock.name,\n isTarget: (_key, value) => {\n if (id === value) return true;\n if (value?.hookType === HookType.CODE && Array.isArray(value.hookData)) return value.hookData.some((item) => item.codeId === id);\n return false;\n }\n });\n /**\n * ['array'] ['array', '0'] ['array', '0', 'a'] 这种返回false\n * ['array', 'a'] 这种返回true\n * @param keys\n * @param fields\n * @returns boolean\n */\n const isIncludeArrayField = (keys, fields) => {\n let f = fields;\n return keys.some((key, index) => {\n const field = f.find(({ name }) => name === key);\n f = field?.fields || [];\n return field?.type === \"array\" && index < keys.length - 1 && !INTEGER_REGEXP.test(keys[index + 1]);\n });\n };\n /**\n * 判断模板(value)是不是使用数据源Id(dsId),如:`xxx${dsId.field}xxx${dsId.field}`\n * @param value any\n * @param dsId string | number\n * @param hasArray boolean true: 一定要包含有需要迭代的模板; false: 一定要包含普通模板;\n * @returns boolean\n */\n const isDataSourceTemplate = (value, ds, hasArray = false) => {\n const templates = value.match(dataSourceTemplateRegExp) || [];\n if (templates.length <= 0) return false;\n for (const tpl of templates) {\n const keys = getKeysArray(tpl.substring(2, tpl.length - 1));\n const dsId = keys.shift();\n if (!dsId || dsId !== ds.id) continue;\n if (hasArray === isIncludeArrayField(keys, ds.fields)) return true;\n }\n return false;\n };\n /**\n * 指定数据源的字符串模板,如:{ isBindDataSourceField: true, dataSourceId: 'id', template: `xxx${field}xxx`}\n * @param value any\n * @param dsId string | number\n * @returns boolean\n */\n const isSpecificDataSourceTemplate = (value, dsId) => value?.isBindDataSourceField && value.dataSourceId && value.dataSourceId === dsId && typeof value.template === \"string\";\n /**\n * 关联数据源字段,格式为 [前缀+数据源ID, 字段名]\n * 使用data-source-field-select value: 'value' 可以配置出来\n * @param value any[]\n * @param id string | number\n * @returns boolean\n */\n const isUseDataSourceField = (value, id) => {\n if (!Array.isArray(value) || typeof value[0] !== \"string\") return false;\n const [prefixId] = value;\n const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);\n if (prefixIndex === -1) return false;\n return prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length) === id;\n };\n const isDataSourceTarget = (ds, key, value, hasArray = false) => {\n if (!value) return false;\n const valueType = typeof value;\n if (valueType !== \"string\" && valueType !== \"object\") return false;\n if (`${key}`.startsWith(\"displayConds\")) return false;\n if (valueType === \"string\") return isDataSourceTemplate(value, ds, hasArray);\n if (isObject(value) && value.isBindDataSource && value.dataSourceId === ds.id) return true;\n if (isSpecificDataSourceTemplate(value, ds.id)) return true;\n if (isUseDataSourceField(value, ds.id)) {\n const [, ...keys] = value;\n const includeArray = isIncludeArrayField(keys, ds.fields);\n return hasArray ? includeArray : !includeArray;\n }\n return false;\n };\n const isDataSourceCondTarget = (ds, key, value, hasArray = false) => {\n if (!Array.isArray(value) || !ds) return false;\n const [dsId, ...keys] = value;\n if (dsId !== ds.id || !`${key}`.startsWith(\"displayConds\")) return false;\n if (ds.fields?.some((field) => field.name === keys[0])) {\n const includeArray = isIncludeArrayField(keys, ds.fields);\n return hasArray ? includeArray : !includeArray;\n }\n return false;\n };\n const createDataSourceTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceTarget(ds, key, value)\n });\n const createDataSourceCondTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_COND,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceCondTarget(ds, key, value)\n });\n const createDataSourceMethodTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_METHOD,\n id: ds.id,\n initialDeps,\n isTarget: (_key, value) => {\n if (!Array.isArray(value)) return false;\n const [dsId, methodName] = value;\n if (!methodName || dsId !== ds.id) return false;\n if (ds.methods?.some((method) => method.name === methodName)) return true;\n if (ds.fields?.some((field) => field.name === methodName)) return false;\n return true;\n }\n });\n const traverseTarget = (targetsList, cb, type) => {\n if (type) {\n const targets = targetsList[type];\n if (targets) for (const target of Object.values(targets)) cb(target);\n return;\n }\n for (const targets of Object.values(targetsList)) for (const target of Object.values(targets)) cb(target);\n };\n //#endregion\n //#region packages/dep/src/Watcher.ts\n const DATA_SOURCE_TARGET_TYPES = new Set([\n DepTargetType.DATA_SOURCE,\n DepTargetType.DATA_SOURCE_COND,\n DepTargetType.DATA_SOURCE_METHOD\n ]);\n var Watcher = class {\n targetsList = {};\n childrenProp = \"items\";\n idProp = \"id\";\n nameProp = \"name\";\n constructor(options) {\n if (options?.initialTargets) this.targetsList = options.initialTargets;\n if (options?.childrenProp) this.childrenProp = options.childrenProp;\n }\n getTargetsList() {\n return this.targetsList;\n }\n /**\n * 获取指定类型中的所有target\n * @param type 分类\n * @returns Target[]\n */\n getTargets(type = DepTargetType.DEFAULT) {\n return this.targetsList[type] || {};\n }\n /**\n * 添加新的目标\n * @param target Target\n */\n addTarget(target) {\n const targets = this.getTargets(target.type) || {};\n this.targetsList[target.type] = targets;\n targets[target.id] = target;\n }\n /**\n * 获取指定id的target\n * @param id target id\n * @returns Target\n */\n getTarget(id, type = DepTargetType.DEFAULT) {\n return this.getTargets(type)[id];\n }\n /**\n * 判断是否存在指定id的target\n * @param id target id\n * @returns boolean\n */\n hasTarget(id, type = DepTargetType.DEFAULT) {\n return Boolean(this.getTarget(id, type));\n }\n /**\n * 判断是否存在指定类型的target\n * @param type target type\n * @returns boolean\n */\n hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {\n return Object.keys(this.getTargets(type)).length > 0;\n }\n /**\n * 删除指定id的target\n * @param id target id\n */\n removeTarget(id, type = DepTargetType.DEFAULT) {\n const targets = this.getTargets(type);\n if (targets[id]) {\n targets[id].destroy();\n delete targets[id];\n }\n }\n /**\n * 删除指定分类的所有target\n * @param type 分类\n * @returns void\n */\n removeTargets(type = DepTargetType.DEFAULT) {\n const targets = this.targetsList[type];\n if (!targets) return;\n for (const target of Object.values(targets)) target.destroy();\n delete this.targetsList[type];\n }\n /**\n * 删除所有target\n */\n clearTargets() {\n for (const key of Object.keys(this.targetsList)) delete this.targetsList[key];\n }\n /**\n * 收集依赖\n * @param nodes 需要收集的节点\n * @param deep 是否需要收集子节点\n * @param type 强制收集指定类型的依赖\n */\n collect(nodes, depExtendedData = {}, deep = false, type) {\n this.collectByCallback(nodes, type, ({ node, target }) => {\n this.removeTargetDep(target, node);\n this.collectItem(node, target, depExtendedData, deep);\n });\n }\n collectByCallback(nodes, type, cb) {\n traverseTarget(this.targetsList, (target) => {\n if (!type && !target.isCollectByDefault) return;\n for (const node of nodes) cb({\n node,\n target\n });\n }, type);\n }\n /**\n * 清除所有目标的依赖\n * @param nodes 需要清除依赖的节点\n */\n clear(nodes, type) {\n let { targetsList } = this;\n if (type) targetsList = { [type]: this.getTargets(type) };\n const clearedItemsNodeIds = /* @__PURE__ */ new Set();\n traverseTarget(targetsList, (target) => {\n if (nodes) for (const node of nodes) {\n target.removeDep(node[this.idProp]);\n if (Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length && !clearedItemsNodeIds.has(node[this.idProp])) {\n clearedItemsNodeIds.add(node[this.idProp]);\n this.clear(node[this.childrenProp]);\n }\n }\n else target.removeDep();\n });\n }\n /**\n * 清除指定类型的依赖\n * @param type 类型\n * @param nodes 需要清除依赖的节点\n */\n clearByType(type, nodes) {\n this.clear(nodes, type);\n }\n collectItem(node, target, depExtendedData = {}, deep = false) {\n if (node[\"_tmagic_node_disabled_data_source\"] && DATA_SOURCE_TARGET_TYPES.has(target.type)) return;\n if (node[\"_tmagic_node_disabled_code_block\"] && target.type === DepTargetType.CODE_BLOCK) return;\n const collectTarget = (config, prop = \"\") => {\n const doCollect = (key, value) => {\n const keyIsItems = key === this.childrenProp;\n const fullKey = prop ? `${prop}.${key}` : key;\n if (target.isTarget(fullKey, value)) target.updateDep({\n id: node[this.idProp],\n name: `${node[this.nameProp] || node[this.idProp]}`,\n data: depExtendedData,\n key: fullKey\n });\n else if (!keyIsItems && Array.isArray(value)) for (let i = 0, l = value.length; i < l; i++) {\n const item = value[i];\n if (isObject(item)) collectTarget(item, `${fullKey}[${i}]`);\n }\n else if (isObject(value)) collectTarget(value, fullKey);\n if (keyIsItems && deep && Array.isArray(value)) for (const child of value) this.collectItem(child, target, depExtendedData, deep);\n };\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === \"undefined\" || value === \"\") continue;\n doCollect(key, value);\n }\n };\n collectTarget(node);\n }\n removeTargetDep(target, node, key) {\n target.removeDep(node[this.idProp], key);\n if (typeof key === \"undefined\" && Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length) for (const item of node[this.childrenProp]) this.removeTargetDep(target, item, key);\n }\n };\n //#endregion\n //#region packages/editor/src/utils/logger.ts\n const error = (...args) => {\n if (process.env.NODE_ENV === \"development\") console.error(\"magic editor: \", ...args);\n };\n //#endregion\n //#region packages/editor/src/utils/dep/worker.ts\n onmessage = (e) => {\n const watcher = new Watcher({ initialTargets: {} });\n const { dsl } = e.data;\n try {\n const mApp = eval(`(${dsl})`);\n if (!mApp) postMessage({});\n watcher.clearTargets();\n if (mApp.codeBlocks) for (const [id, code] of Object.entries(mApp.codeBlocks)) watcher.addTarget(createCodeBlockTarget(id, code));\n if (mApp.dataSources) for (const ds of mApp.dataSources) {\n watcher.addTarget(createDataSourceTarget(ds, {}));\n watcher.addTarget(createDataSourceMethodTarget(ds, {}));\n watcher.addTarget(createDataSourceCondTarget(ds, {}));\n }\n watcher.collectByCallback(mApp.items, void 0, ({ node, target }) => {\n watcher.collectItem(node, target, { pageId: node.id }, true);\n });\n const data = {\n [DepTargetType.DATA_SOURCE]: {},\n [DepTargetType.DATA_SOURCE_METHOD]: {},\n [DepTargetType.DATA_SOURCE_COND]: {},\n [DepTargetType.CODE_BLOCK]: {}\n };\n traverseTarget(watcher.getTargetsList(), (target) => {\n data[target.type][target.id] = target.deps;\n });\n postMessage(data);\n } catch (e) {\n error(e);\n postMessage({});\n }\n };\n //#endregion\n})();\n";
|
|
2
|
+
var jsContent = "(function() {\n //#region packages/schema/src/index.ts\n const NODE_CONDS_KEY = \"displayConds\";\n const NODE_DISABLE_DATA_SOURCE_KEY = \"_tmagic_node_disabled_data_source\";\n const NODE_DISABLE_CODE_BLOCK_KEY = \"_tmagic_node_disabled_code_block\";\n let HookType = /* @__PURE__ */ function(HookType) {\n /** 代码块钩子标识 */\n HookType[\"CODE\"] = \"code\";\n return HookType;\n }({});\n //#endregion\n //#region packages/utils/src/const.ts\n const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = \"ds-field::\";\n //#endregion\n //#region packages/utils/src/index.ts\n const isObject = (obj) => Object.prototype.toString.call(obj) === \"[object Object]\";\n const getKeysArray = (keys) => `${keys}`.replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\");\n const dataSourceTemplateRegExp = /\\$\\{([\\s\\S]+?)\\}/g;\n //#endregion\n //#region packages/dep/src/types.ts\n /** 依赖收集的目标类型 */\n let DepTargetType = /* @__PURE__ */ function(DepTargetType) {\n DepTargetType[\"DEFAULT\"] = \"default\";\n /** 代码块 */\n DepTargetType[\"CODE_BLOCK\"] = \"code-block\";\n /** 数据源 */\n DepTargetType[\"DATA_SOURCE\"] = \"data-source\";\n /** 数据源方法 */\n DepTargetType[\"DATA_SOURCE_METHOD\"] = \"data-source-method\";\n /** 数据源条件 */\n DepTargetType[\"DATA_SOURCE_COND\"] = \"data-source-cond\";\n return DepTargetType;\n }({});\n //#endregion\n //#region packages/dep/src/Target.ts\n /**\n * 需要收集依赖的目标\n * 例如:一个代码块可以为一个目标\n */\n var Target = class {\n /**\n * 如何识别目标\n */\n isTarget;\n /**\n * 目标id,不可重复\n * 例如目标是代码块,则为代码块id\n */\n id;\n /**\n * 目标名称,用于显示在依赖列表中\n */\n name;\n /**\n * 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type\n */\n type = DepTargetType.DEFAULT;\n /**\n * 依赖详情\n * 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }\n */\n deps = {};\n /**\n * 是否默认收集,默认为true,当值为false时需要传入type参数给collect方法才会被收集\n */\n isCollectByDefault;\n constructor(options) {\n this.isTarget = options.isTarget;\n this.id = options.id;\n this.name = options.name;\n this.isCollectByDefault = options.isCollectByDefault ?? true;\n if (options.type) this.type = options.type;\n if (options.initialDeps) this.deps = options.initialDeps;\n }\n /**\n * 更新依赖\n * @param option 节点配置\n * @param key 哪个key配置了这个目标的id\n */\n updateDep({ id, name, key, data }) {\n const dep = this.deps[id] || {\n name,\n keys: []\n };\n dep.name = name;\n dep.data = data;\n this.deps[id] = dep;\n if (!dep.keys.includes(key)) dep.keys.push(key);\n }\n /**\n * 删除依赖\n * @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖\n * @param key 节点下哪个key需要移除,如果为空,则移除改节点下的所有依赖key\n * @returns void\n */\n removeDep(id, key) {\n if (typeof id === \"undefined\") {\n Object.keys(this.deps).forEach((depKey) => {\n delete this.deps[depKey];\n });\n return;\n }\n const dep = this.deps[id];\n if (!dep) return;\n if (key) {\n const index = dep.keys.indexOf(key);\n dep.keys.splice(index, 1);\n if (dep.keys.length === 0) delete this.deps[id];\n } else delete this.deps[id];\n }\n /**\n * 判断指定节点下的指定key是否存在在依赖列表中\n * @param node 哪个节点\n * @param key 哪个key\n * @returns boolean\n */\n hasDep(id, key) {\n return this.deps[id]?.keys.includes(key) ?? false;\n }\n destroy() {\n this.deps = {};\n }\n };\n //#endregion\n //#region packages/dep/src/utils.ts\n const INTEGER_REGEXP = /^\\d+$/;\n const createCodeBlockTarget = (id, codeBlock, initialDeps = {}) => new Target({\n type: DepTargetType.CODE_BLOCK,\n id,\n initialDeps,\n name: codeBlock.name,\n isTarget: (_key, value) => {\n if (id === value) return true;\n if (value?.hookType === HookType.CODE && Array.isArray(value.hookData)) return value.hookData.some((item) => item.codeId === id);\n return false;\n }\n });\n /**\n * ['array'] ['array', '0'] ['array', '0', 'a'] 这种返回false\n * ['array', 'a'] 这种返回true\n * @param keys\n * @param fields\n * @returns boolean\n */\n const isIncludeArrayField = (keys, fields) => {\n let f = fields;\n return keys.some((key, index) => {\n const field = f.find(({ name }) => name === key);\n f = field?.fields || [];\n return field?.type === \"array\" && index < keys.length - 1 && !INTEGER_REGEXP.test(keys[index + 1]);\n });\n };\n /**\n * 判断模板(value)是不是使用数据源Id(dsId),如:`xxx${dsId.field}xxx${dsId.field}`\n * @param value any\n * @param dsId string | number\n * @param hasArray boolean true: 一定要包含有需要迭代的模板; false: 一定要包含普通模板;\n * @returns boolean\n */\n const isDataSourceTemplate = (value, ds, hasArray = false) => {\n const templates = value.match(dataSourceTemplateRegExp) || [];\n if (templates.length <= 0) return false;\n for (const tpl of templates) {\n const keys = getKeysArray(tpl.substring(2, tpl.length - 1));\n const dsId = keys.shift();\n if (!dsId || dsId !== ds.id) continue;\n if (hasArray === isIncludeArrayField(keys, ds.fields)) return true;\n }\n return false;\n };\n /**\n * 指定数据源的字符串模板,如:{ isBindDataSourceField: true, dataSourceId: 'id', template: `xxx${field}xxx`}\n * @param value any\n * @param dsId string | number\n * @returns boolean\n */\n const isSpecificDataSourceTemplate = (value, dsId) => value?.isBindDataSourceField && value.dataSourceId && value.dataSourceId === dsId && typeof value.template === \"string\";\n /**\n * 关联数据源字段,格式为 [前缀+数据源ID, 字段名]\n * 使用data-source-field-select value: 'value' 可以配置出来\n * @param value any[]\n * @param id string | number\n * @returns boolean\n */\n const isUseDataSourceField = (value, id) => {\n if (!Array.isArray(value) || typeof value[0] !== \"string\") return false;\n const [prefixId] = value;\n const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);\n if (prefixIndex === -1) return false;\n return prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length) === id;\n };\n const isDataSourceTarget = (ds, key, value, hasArray = false) => {\n if (!value) return false;\n const valueType = typeof value;\n if (valueType !== \"string\" && valueType !== \"object\") return false;\n if (`${key}`.startsWith(\"displayConds\")) return false;\n if (valueType === \"string\") return isDataSourceTemplate(value, ds, hasArray);\n if (isObject(value) && value.isBindDataSource && value.dataSourceId === ds.id) return true;\n if (isSpecificDataSourceTemplate(value, ds.id)) return true;\n if (isUseDataSourceField(value, ds.id)) {\n const [, ...keys] = value;\n const includeArray = isIncludeArrayField(keys, ds.fields);\n return hasArray ? includeArray : !includeArray;\n }\n return false;\n };\n const isDataSourceCondTarget = (ds, key, value, hasArray = false) => {\n if (!Array.isArray(value) || !ds) return false;\n const [dsId, ...keys] = value;\n if (dsId !== ds.id || !`${key}`.startsWith(\"displayConds\")) return false;\n if (ds.fields?.some((field) => field.name === keys[0])) {\n const includeArray = isIncludeArrayField(keys, ds.fields);\n return hasArray ? includeArray : !includeArray;\n }\n return false;\n };\n const createDataSourceTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceTarget(ds, key, value)\n });\n const createDataSourceCondTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_COND,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceCondTarget(ds, key, value)\n });\n const createDataSourceMethodTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_METHOD,\n id: ds.id,\n initialDeps,\n isTarget: (_key, value) => {\n if (!Array.isArray(value)) return false;\n const [dsId, methodName] = value;\n if (!methodName || dsId !== ds.id) return false;\n if (ds.methods?.some((method) => method.name === methodName)) return true;\n if (ds.fields?.some((field) => field.name === methodName)) return false;\n return true;\n }\n });\n const traverseTarget = (targetsList, cb, type) => {\n if (type) {\n const targets = targetsList[type];\n if (targets) for (const target of Object.values(targets)) cb(target);\n return;\n }\n for (const targets of Object.values(targetsList)) for (const target of Object.values(targets)) cb(target);\n };\n //#endregion\n //#region packages/dep/src/Watcher.ts\n const DATA_SOURCE_TARGET_TYPES = new Set([\n DepTargetType.DATA_SOURCE,\n DepTargetType.DATA_SOURCE_COND,\n DepTargetType.DATA_SOURCE_METHOD\n ]);\n var Watcher = class {\n targetsList = {};\n childrenProp = \"items\";\n idProp = \"id\";\n nameProp = \"name\";\n constructor(options) {\n if (options?.initialTargets) this.targetsList = options.initialTargets;\n if (options?.childrenProp) this.childrenProp = options.childrenProp;\n }\n getTargetsList() {\n return this.targetsList;\n }\n /**\n * 获取指定类型中的所有target\n * @param type 分类\n * @returns Target[]\n */\n getTargets(type = DepTargetType.DEFAULT) {\n return this.targetsList[type] || {};\n }\n /**\n * 添加新的目标\n * @param target Target\n */\n addTarget(target) {\n const targets = this.getTargets(target.type) || {};\n this.targetsList[target.type] = targets;\n targets[target.id] = target;\n }\n /**\n * 获取指定id的target\n * @param id target id\n * @returns Target\n */\n getTarget(id, type = DepTargetType.DEFAULT) {\n return this.getTargets(type)[id];\n }\n /**\n * 判断是否存在指定id的target\n * @param id target id\n * @returns boolean\n */\n hasTarget(id, type = DepTargetType.DEFAULT) {\n return Boolean(this.getTarget(id, type));\n }\n /**\n * 判断是否存在指定类型的target\n * @param type target type\n * @returns boolean\n */\n hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {\n return Object.keys(this.getTargets(type)).length > 0;\n }\n /**\n * 删除指定id的target\n * @param id target id\n */\n removeTarget(id, type = DepTargetType.DEFAULT) {\n const targets = this.getTargets(type);\n if (targets[id]) {\n targets[id].destroy();\n delete targets[id];\n }\n }\n /**\n * 删除指定分类的所有target\n * @param type 分类\n * @returns void\n */\n removeTargets(type = DepTargetType.DEFAULT) {\n const targets = this.targetsList[type];\n if (!targets) return;\n for (const target of Object.values(targets)) target.destroy();\n delete this.targetsList[type];\n }\n /**\n * 删除所有target\n */\n clearTargets() {\n for (const key of Object.keys(this.targetsList)) delete this.targetsList[key];\n }\n /**\n * 收集依赖\n * @param nodes 需要收集的节点\n * @param deep 是否需要收集子节点\n * @param type 强制收集指定类型的依赖\n */\n collect(nodes, depExtendedData = {}, deep = false, type) {\n const targets = this.getCollectableTargets(type);\n if (!targets.length) return;\n for (const node of nodes) {\n this.removeTargetsDep(targets, node);\n this.collectItems(node, targets, depExtendedData, deep);\n }\n }\n /**\n * 获取本次需要参与收集的 target(过滤规则与 collectByCallback 一致)\n *\n * 注:供 editor 的 dep service / worker 跨包批量收集时复用,因此为 public。\n * @param type 强制收集指定类型的依赖\n */\n getCollectableTargets(type) {\n const targets = [];\n traverseTarget(this.targetsList, (target) => {\n if (!type && !target.isCollectByDefault) return;\n targets.push(target);\n }, type);\n return targets;\n }\n collectByCallback(nodes, type, cb) {\n traverseTarget(this.targetsList, (target) => {\n if (!type && !target.isCollectByDefault) return;\n for (const node of nodes) cb({\n node,\n target\n });\n }, type);\n }\n /**\n * 清除所有目标的依赖\n * @param nodes 需要清除依赖的节点\n */\n clear(nodes, type) {\n let { targetsList } = this;\n if (type) targetsList = { [type]: this.getTargets(type) };\n const clearedItemsNodeIds = /* @__PURE__ */ new Set();\n traverseTarget(targetsList, (target) => {\n if (nodes) for (const node of nodes) {\n target.removeDep(node[this.idProp]);\n if (Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length && !clearedItemsNodeIds.has(node[this.idProp])) {\n clearedItemsNodeIds.add(node[this.idProp]);\n this.clear(node[this.childrenProp]);\n }\n }\n else target.removeDep();\n });\n }\n /**\n * 清除指定类型的依赖\n * @param type 类型\n * @param nodes 需要清除依赖的节点\n */\n clearByType(type, nodes) {\n this.clear(nodes, type);\n }\n /**\n * 收集单个 target 的依赖,等价于 collectItems(node, [target], ...)\n */\n collectItem(node, target, depExtendedData = {}, deep = false) {\n this.collectItems(node, [target], depExtendedData, deep);\n }\n removeTargetDep(target, node, key) {\n target.removeDep(node[this.idProp], key);\n if (typeof key === \"undefined\" && Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length) for (const item of node[this.childrenProp]) this.removeTargetDep(target, item, key);\n }\n /**\n * 与 removeTargetDep 等价,但一次子树递归同时处理多个 target,\n * 把删除阶段的结构遍历从 ×targets 降到 ×1。\n *\n * 注:供 editor 的 dep service 跨包批量删除时复用,因此为 public。\n */\n removeTargetsDep(targets, node, key) {\n const id = node[this.idProp];\n for (const target of targets) target.removeDep(id, key);\n if (typeof key === \"undefined\" && Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length) for (const item of node[this.childrenProp]) this.removeTargetsDep(targets, item, key);\n }\n /**\n * 与 collectItem 等价,但一次遍历同时处理多个 target(不含删除阶段)。\n *\n * 关键优化:原实现对每个 target 都完整遍历一遍节点树(O(targets × 树规模)),大页面 + 大量数据源时,\n * 结构遍历(Object.entries / 递归 / fullKey 字符串拼接)会被重复 targets 次。这里改为「整棵树只遍历一次,\n * 在每个属性上检查所有 target」,把结构遍历开销从 ×targets 降到 ×1,isTarget 调用次数不变,收集结果完全一致。\n *\n * 注:供 editor 的 dep service / worker 跨包批量收集时复用,因此为 public。\n */\n collectItems(node, targets, depExtendedData = {}, deep = false) {\n const activeTargets = this.filterTargetsByNode(node, targets);\n if (!activeTargets.length) return;\n this.collectTargetForTargets(node, node, \"\", activeTargets, depExtendedData, deep);\n }\n filterTargetsByNode(node, targets) {\n const disableDataSource = Boolean(node[NODE_DISABLE_DATA_SOURCE_KEY]);\n const disableCodeBlock = Boolean(node[NODE_DISABLE_CODE_BLOCK_KEY]);\n if (!disableDataSource && !disableCodeBlock) return targets;\n return targets.filter((target) => {\n if (disableDataSource && DATA_SOURCE_TARGET_TYPES.has(target.type)) return false;\n if (disableCodeBlock && target.type === DepTargetType.CODE_BLOCK) return false;\n return true;\n });\n }\n collectTargetForTargets(node, config, prop, targets, depExtendedData, deep) {\n const id = node[this.idProp];\n const name = `${node[this.nameProp] || node[this.idProp]}`;\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === \"undefined\" || value === \"\") continue;\n const keyIsItems = key === this.childrenProp;\n const fullKey = prop ? `${prop}.${key}` : key;\n let notMatched = null;\n for (let i = 0, l = targets.length; i < l; i++) {\n const target = targets[i];\n if (target.isTarget(fullKey, value, config)) target.updateDep({\n id,\n name,\n data: depExtendedData,\n key: fullKey\n });\n else (notMatched || (notMatched = [])).push(target);\n }\n if (notMatched) {\n if (!keyIsItems && Array.isArray(value)) for (let i = 0, l = value.length; i < l; i++) {\n const item = value[i];\n if (isObject(item)) this.collectTargetForTargets(node, item, `${fullKey}[${i}]`, notMatched, depExtendedData, deep);\n }\n else if (isObject(value)) this.collectTargetForTargets(node, value, fullKey, notMatched, depExtendedData, deep);\n }\n if (keyIsItems && deep && Array.isArray(value)) for (const child of value) this.collectItems(child, targets, depExtendedData, deep);\n }\n }\n };\n //#endregion\n //#region packages/editor/src/utils/logger.ts\n const error = (...args) => {\n if (process.env.NODE_ENV === \"development\") console.error(\"magic editor: \", ...args);\n };\n //#endregion\n //#region packages/editor/src/utils/dep/worker.ts\n onmessage = (e) => {\n const watcher = new Watcher({ initialTargets: {} });\n const { dsl } = e.data;\n try {\n const mApp = eval(`(${dsl})`);\n if (!mApp) postMessage({});\n watcher.clearTargets();\n if (mApp.codeBlocks) for (const [id, code] of Object.entries(mApp.codeBlocks)) watcher.addTarget(createCodeBlockTarget(id, code));\n if (mApp.dataSources) for (const ds of mApp.dataSources) {\n watcher.addTarget(createDataSourceTarget(ds, {}));\n watcher.addTarget(createDataSourceMethodTarget(ds, {}));\n watcher.addTarget(createDataSourceCondTarget(ds, {}));\n }\n const targets = watcher.getCollectableTargets();\n for (const page of mApp.items) watcher.collectItems(page, targets, { pageId: page.id }, true);\n const data = {\n [DepTargetType.DATA_SOURCE]: {},\n [DepTargetType.DATA_SOURCE_METHOD]: {},\n [DepTargetType.DATA_SOURCE_COND]: {},\n [DepTargetType.CODE_BLOCK]: {}\n };\n traverseTarget(watcher.getTargetsList(), (target) => {\n data[target.type][target.id] = target.deps;\n });\n postMessage(data);\n } catch (e) {\n error(e);\n postMessage({});\n }\n };\n //#endregion\n})();\n";
|
|
3
3
|
var blob = typeof self !== "undefined" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
4
4
|
function WorkerWrapper(options) {
|
|
5
5
|
let objURL;
|
package/dist/es/utils/editor.js
CHANGED
|
@@ -2,7 +2,7 @@ import { LayerOffset, Layout } from "../type.js";
|
|
|
2
2
|
import { isFixed } from "@tmagic/stage";
|
|
3
3
|
import { calcValueByFontsize, getElById, getNodePath, isNumber, isPage, isPageFragment, isPop, isValueIncludeDataSource } from "@tmagic/utils";
|
|
4
4
|
import { NODE_CONDS_KEY, Target, Watcher } from "@tmagic/core";
|
|
5
|
-
import { cloneDeep, get, isObject } from "lodash-es";
|
|
5
|
+
import { cloneDeep as cloneDeep$1, get, isObject } from "lodash-es";
|
|
6
6
|
import serialize from "serialize-javascript";
|
|
7
7
|
import { detailedDiff } from "deep-object-diff";
|
|
8
8
|
//#region packages/editor/src/utils/editor.ts
|
|
@@ -287,7 +287,7 @@ var resolveSelectedNode = (config, getNodeInfoFn, rootId) => {
|
|
|
287
287
|
* @returns 处理后的节点配置(深拷贝)
|
|
288
288
|
*/
|
|
289
289
|
var toggleFixedPosition = async (dist, src, root, getLayoutFn) => {
|
|
290
|
-
const newConfig = cloneDeep(dist);
|
|
290
|
+
const newConfig = cloneDeep$1(dist);
|
|
291
291
|
if (!isPop(src) && newConfig.style?.position) {
|
|
292
292
|
if (isFixed(newConfig.style) && !isFixed(src.style || {})) newConfig.style = change2Fixed(newConfig, root);
|
|
293
293
|
else if (!isFixed(newConfig.style) && isFixed(src.style || {})) newConfig.style = await Fixed2Other(newConfig, root, getLayoutFn);
|
|
@@ -41,6 +41,26 @@ var UndoRedo = class {
|
|
|
41
41
|
if (this.listCursor < 1) return null;
|
|
42
42
|
return cloneDeep(this.elementList[this.listCursor - 1]);
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* 返回栈内全部元素的浅克隆数组(按时间顺序,索引 0 为最早一步)。
|
|
46
|
+
* 仅用于历史面板等只读展示场景,不应直接修改返回值。
|
|
47
|
+
*/
|
|
48
|
+
getElementList() {
|
|
49
|
+
return this.elementList.slice();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 当前游标位置:表示已应用的步骤数量。
|
|
53
|
+
* - cursor === 0 表示全部已撤销
|
|
54
|
+
* - cursor === length 表示已重做到末尾
|
|
55
|
+
* 历史面板用于区分"已应用 / 已撤销"两段。
|
|
56
|
+
*/
|
|
57
|
+
getCursor() {
|
|
58
|
+
return this.listCursor;
|
|
59
|
+
}
|
|
60
|
+
/** 栈内总步数。 */
|
|
61
|
+
getLength() {
|
|
62
|
+
return this.elementList.length;
|
|
63
|
+
}
|
|
44
64
|
};
|
|
45
65
|
//#endregion
|
|
46
66
|
export { UndoRedo };
|