@tmagic/editor 1.8.5 → 1.8.7

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.
Files changed (291) hide show
  1. package/dist/es/{Editor.vue_vue_type_script_setup_true_lang.js → Editor.vue.js} +9 -9
  2. package/dist/es/{Editor.js → Editor2.vue.js} +1 -1
  3. package/dist/es/components/{CodeBlockEditor.vue_vue_type_script_setup_true_lang.js → CodeBlockEditor.vue.js} +5 -5
  4. package/dist/es/components/{CodeBlockEditor.js → CodeBlockEditor2.vue.js} +1 -1
  5. package/dist/es/components/{CodeParams.js → CodeParams2.vue.js} +1 -1
  6. package/dist/es/components/{CompareForm.js → CompareForm2.vue.js} +1 -1
  7. package/dist/es/components/{ContentMenu.vue_vue_type_script_setup_true_lang.js → ContentMenu.vue.js} +2 -2
  8. package/dist/es/components/{ContentMenu.js → ContentMenu2.vue.js} +1 -1
  9. package/dist/es/components/{FloatingBox.vue_vue_type_script_setup_true_lang.js → FloatingBox.vue.js} +2 -2
  10. package/dist/es/components/{FloatingBox.js → FloatingBox2.vue.js} +1 -1
  11. package/dist/es/components/{Icon.js → Icon2.vue.js} +1 -1
  12. package/dist/es/components/{Resizer.js → Resizer2.vue.js} +1 -1
  13. package/dist/es/components/{ScrollBar.js → ScrollBar2.vue.js} +1 -1
  14. package/dist/es/components/{ScrollViewer.vue_vue_type_script_setup_true_lang.js → ScrollViewer.vue.js} +3 -3
  15. package/dist/es/components/{ScrollViewer.js → ScrollViewer2.vue.js} +1 -1
  16. package/dist/es/components/{SearchInput.js → SearchInput2.vue.js} +1 -1
  17. package/dist/es/components/{SplitView.vue_vue_type_script_setup_true_lang.js → SplitView.vue.js} +1 -1
  18. package/dist/es/components/{SplitView.js → SplitView2.vue.js} +1 -1
  19. package/dist/es/components/{ToolButton.vue_vue_type_script_setup_true_lang.js → ToolButton.vue.js} +3 -3
  20. package/dist/es/components/{ToolButton.js → ToolButton2.vue.js} +1 -1
  21. package/dist/es/components/{Tree.vue_vue_type_script_setup_true_lang.js → Tree.vue.js} +1 -1
  22. package/dist/es/components/{Tree.js → Tree2.vue.js} +1 -1
  23. package/dist/es/components/{TreeNode.vue_vue_type_script_setup_true_lang.js → TreeNode.vue.js} +2 -2
  24. package/dist/es/components/{TreeNode.js → TreeNode2.vue.js} +1 -1
  25. package/dist/es/components/{ViewForm.js → ViewForm2.vue.js} +1 -1
  26. package/dist/es/fields/{Code.vue_vue_type_script_setup_true_lang.js → Code.vue.js} +1 -1
  27. package/dist/es/fields/{Code.js → Code2.vue.js} +1 -1
  28. package/dist/es/fields/{CodeLink.js → CodeLink2.vue.js} +1 -1
  29. package/dist/es/fields/{CodeSelect.js → CodeSelect2.vue.js} +1 -1
  30. package/dist/es/fields/{CodeSelectCol.vue_vue_type_script_setup_true_lang.js → CodeSelectCol.vue.js} +7 -7
  31. package/dist/es/fields/{CodeSelectCol.js → CodeSelectCol2.vue.js} +1 -1
  32. package/dist/es/fields/{CondOpSelect.js → CondOpSelect2.vue.js} +1 -1
  33. package/dist/es/fields/DataSourceFieldSelect/{FieldSelect.vue_vue_type_script_setup_true_lang.js → FieldSelect.vue.js} +55 -14
  34. package/dist/es/fields/DataSourceFieldSelect/{FieldSelect.js → FieldSelect2.vue.js} +1 -1
  35. package/dist/es/fields/DataSourceFieldSelect/{Index.vue_vue_type_script_setup_true_lang.js → Index.vue.js} +7 -7
  36. package/dist/es/fields/DataSourceFieldSelect/{Index.js → Index2.vue.js} +1 -1
  37. package/dist/es/fields/{DataSourceFields.vue_vue_type_script_setup_true_lang.js → DataSourceFields.vue.js} +50 -17
  38. package/dist/es/fields/{DataSourceFields.js → DataSourceFields2.vue.js} +1 -1
  39. package/dist/es/fields/{DataSourceInput.vue_vue_type_script_setup_true_lang.js → DataSourceInput.vue.js} +5 -5
  40. package/dist/es/fields/{DataSourceInput.js → DataSourceInput2.vue.js} +1 -1
  41. package/dist/es/fields/{DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js → DataSourceMethodSelect.vue.js} +7 -7
  42. package/dist/es/fields/{DataSourceMethodSelect.js → DataSourceMethodSelect2.vue.js} +1 -1
  43. package/dist/es/fields/{DataSourceMethods.vue_vue_type_script_setup_true_lang.js → DataSourceMethods.vue.js} +3 -3
  44. package/dist/es/fields/{DataSourceMethods.js → DataSourceMethods2.vue.js} +1 -1
  45. package/dist/es/fields/{DataSourceMocks.vue_vue_type_script_setup_true_lang.js → DataSourceMocks.vue.js} +8 -8
  46. package/dist/es/fields/{DataSourceMocks.js → DataSourceMocks2.vue.js} +1 -1
  47. package/dist/es/fields/{DataSourceSelect.vue_vue_type_script_setup_true_lang.js → DataSourceSelect.vue.js} +5 -5
  48. package/dist/es/fields/{DataSourceSelect.js → DataSourceSelect2.vue.js} +1 -1
  49. package/dist/es/fields/{DisplayConds.js → DisplayConds2.vue.js} +1 -1
  50. package/dist/es/fields/{EventSelect.js → EventSelect2.vue.js} +1 -1
  51. package/dist/es/fields/{KeyValue.vue_vue_type_script_setup_true_lang.js → KeyValue.vue.js} +3 -3
  52. package/dist/es/fields/{KeyValue.js → KeyValue2.vue.js} +1 -1
  53. package/dist/es/fields/{PageFragmentSelect.vue_vue_type_script_setup_true_lang.js → PageFragmentSelect.vue.js} +4 -4
  54. package/dist/es/fields/{PageFragmentSelect.js → PageFragmentSelect2.vue.js} +1 -1
  55. package/dist/es/fields/StyleSetter/{Index.vue_vue_type_script_setup_true_lang.js → Index.vue.js} +7 -7
  56. package/dist/es/fields/StyleSetter/{Index.js → Index2.vue.js} +1 -1
  57. package/dist/es/fields/StyleSetter/components/{BackgroundPosition.js → BackgroundPosition2.vue.js} +1 -1
  58. package/dist/es/fields/StyleSetter/components/{Border.js → Border2.vue.js} +1 -1
  59. package/dist/es/fields/StyleSetter/components/{Box.js → Box2.vue.js} +1 -1
  60. package/dist/es/fields/StyleSetter/configs.js +43 -43
  61. package/dist/es/fields/StyleSetter/pro/{Background.js → Background2.vue.js} +1 -1
  62. package/dist/es/fields/StyleSetter/pro/{Border.vue_vue_type_script_setup_true_lang.js → Border.vue.js} +3 -3
  63. package/dist/es/fields/StyleSetter/pro/{Border.js → Border2.vue.js} +1 -1
  64. package/dist/es/fields/StyleSetter/pro/{Font.js → Font2.vue.js} +1 -1
  65. package/dist/es/fields/StyleSetter/pro/{Layout.vue_vue_type_script_setup_true_lang.js → Layout.vue.js} +4 -4
  66. package/dist/es/fields/StyleSetter/pro/{Layout.js → Layout2.vue.js} +1 -1
  67. package/dist/es/fields/StyleSetter/pro/{Position.js → Position2.vue.js} +1 -1
  68. package/dist/es/fields/StyleSetter/pro/{Transform.js → Transform2.vue.js} +1 -1
  69. package/dist/es/fields/{UISelect.js → UISelect2.vue.js} +1 -1
  70. package/dist/es/fields/configs/codeSelect.js +2 -2
  71. package/dist/es/fields/configs/displayConds.js +1 -1
  72. package/dist/es/fields/configs/eventSelect.js +3 -3
  73. package/dist/es/fields/headless-validation.js +1 -1
  74. package/dist/es/hooks/use-code-block-edit.js +1 -1
  75. package/dist/es/hooks/use-compare-form.js +1 -1
  76. package/dist/es/hooks/use-editor-content-height.js +1 -1
  77. package/dist/es/hooks/use-filter.js +2 -2
  78. package/dist/es/hooks/use-float-box.js +1 -1
  79. package/dist/es/hooks/use-form-context.js +1 -1
  80. package/dist/es/hooks/use-node-status.js +1 -1
  81. package/dist/es/hooks/use-stage.js +28 -3
  82. package/dist/es/icons/{CenterIcon.js → CenterIcon2.vue.js} +1 -1
  83. package/dist/es/icons/{CodeIcon.js → CodeIcon2.vue.js} +1 -1
  84. package/dist/es/icons/{FolderMinusIcon.js → FolderMinusIcon2.vue.js} +1 -1
  85. package/dist/es/index.js +47 -47
  86. package/dist/es/initService.js +9 -9
  87. package/dist/es/layouts/{AddPageBox.vue_vue_type_script_setup_true_lang.js → AddPageBox.vue.js} +4 -4
  88. package/dist/es/layouts/{AddPageBox.js → AddPageBox2.vue.js} +1 -1
  89. package/dist/es/layouts/{CodeEditor.vue_vue_type_script_setup_true_lang.js → CodeEditor.vue.js} +5 -5
  90. package/dist/es/layouts/{CodeEditor.js → CodeEditor2.vue.js} +1 -1
  91. package/dist/es/layouts/{Framework.vue_vue_type_script_setup_true_lang.js → Framework.vue.js} +5 -5
  92. package/dist/es/layouts/{Framework.js → Framework2.vue.js} +1 -1
  93. package/dist/es/layouts/{NavMenu.vue_vue_type_script_setup_true_lang.js → NavMenu.vue.js} +5 -5
  94. package/dist/es/layouts/{NavMenu.js → NavMenu2.vue.js} +1 -1
  95. package/dist/es/layouts/{NavMenuColumn.vue_vue_type_script_setup_true_lang.js → NavMenuColumn.vue.js} +14 -6
  96. package/dist/es/layouts/{NavMenuColumn.js → NavMenuColumn2.vue.js} +1 -1
  97. package/dist/es/layouts/history-list/{Bucket.vue_vue_type_script_setup_true_lang.js → Bucket.vue.js} +23 -7
  98. package/dist/es/layouts/history-list/{Bucket.js → Bucket2.vue.js} +1 -1
  99. package/dist/es/layouts/history-list/{BucketTab.vue_vue_type_script_setup_true_lang.js → BucketTab.vue.js} +9 -4
  100. package/dist/es/layouts/history-list/{BucketTab.js → BucketTab2.vue.js} +1 -1
  101. package/dist/es/layouts/history-list/{GroupRow.js → GroupRow2.vue.js} +1 -1
  102. package/dist/es/layouts/history-list/{HistoryDiffDialog.vue_vue_type_script_setup_true_lang.js → HistoryDiffDialog.vue.js} +3 -3
  103. package/dist/es/layouts/history-list/{HistoryDiffDialog.js → HistoryDiffDialog2.vue.js} +1 -1
  104. package/dist/es/layouts/history-list/{HistoryListPanel.vue_vue_type_script_setup_true_lang.js → HistoryListPanel.vue.js} +24 -6
  105. package/dist/es/layouts/history-list/{HistoryListPanel.js → HistoryListPanel2.vue.js} +1 -1
  106. package/dist/es/layouts/history-list/{InitialRow.vue_vue_type_script_setup_true_lang.js → InitialRow.vue.js} +16 -5
  107. package/dist/es/layouts/history-list/{InitialRow.js → InitialRow2.vue.js} +1 -1
  108. package/dist/es/layouts/history-list/{PageTab.vue_vue_type_script_setup_true_lang.js → PageTab.vue.js} +20 -8
  109. package/dist/es/layouts/history-list/{PageTab.js → PageTab2.vue.js} +1 -1
  110. package/dist/es/layouts/history-list/composables.js +1 -1
  111. package/dist/es/layouts/history-list/useHistoryList.js +1 -1
  112. package/dist/es/layouts/history-list/useHistoryRevert.js +3 -3
  113. package/dist/es/layouts/page-bar/{AddButton.vue_vue_type_script_setup_true_lang.js → AddButton.vue.js} +6 -6
  114. package/dist/es/layouts/page-bar/{AddButton.js → AddButton2.vue.js} +1 -1
  115. package/dist/es/layouts/page-bar/{PageBar.vue_vue_type_script_setup_true_lang.js → PageBar.vue.js} +8 -8
  116. package/dist/es/layouts/page-bar/{PageBar.js → PageBar2.vue.js} +1 -1
  117. package/dist/es/layouts/page-bar/{PageBarScrollContainer.vue_vue_type_script_setup_true_lang.js → PageBarScrollContainer.vue.js} +2 -2
  118. package/dist/es/layouts/page-bar/{PageBarScrollContainer.js → PageBarScrollContainer2.vue.js} +1 -1
  119. package/dist/es/layouts/page-bar/{PageList.vue_vue_type_script_setup_true_lang.js → PageList.vue.js} +3 -3
  120. package/dist/es/layouts/page-bar/{PageList.js → PageList2.vue.js} +1 -1
  121. package/dist/es/layouts/page-bar/{Search.vue_vue_type_script_setup_true_lang.js → Search.vue.js} +3 -3
  122. package/dist/es/layouts/page-bar/{Search.js → Search2.vue.js} +1 -1
  123. package/dist/es/layouts/props-panel/{FormPanel.vue_vue_type_script_setup_true_lang.js → FormPanel.vue.js} +7 -7
  124. package/dist/es/layouts/props-panel/{FormPanel.js → FormPanel2.vue.js} +1 -1
  125. package/dist/es/layouts/props-panel/{PropsPanel.vue_vue_type_script_setup_true_lang.js → PropsPanel.vue.js} +7 -7
  126. package/dist/es/layouts/props-panel/{PropsPanel.js → PropsPanel2.vue.js} +1 -1
  127. package/dist/es/layouts/props-panel/use-style-panel.js +1 -1
  128. package/dist/es/layouts/sidebar/{ComponentListPanel.vue_vue_type_script_setup_true_lang.js → ComponentListPanel.vue.js} +7 -7
  129. package/dist/es/layouts/sidebar/{ComponentListPanel.js → ComponentListPanel2.vue.js} +1 -1
  130. package/dist/es/layouts/sidebar/{Sidebar.vue_vue_type_script_setup_true_lang.js → Sidebar.vue.js} +8 -8
  131. package/dist/es/layouts/sidebar/{Sidebar.js → Sidebar2.vue.js} +1 -1
  132. package/dist/es/layouts/sidebar/code-block/{CodeBlockList.vue_vue_type_script_setup_true_lang.js → CodeBlockList.vue.js} +5 -5
  133. package/dist/es/layouts/sidebar/code-block/{CodeBlockList.js → CodeBlockList2.vue.js} +1 -1
  134. package/dist/es/layouts/sidebar/code-block/{CodeBlockListPanel.vue_vue_type_script_setup_true_lang.js → CodeBlockListPanel.vue.js} +6 -6
  135. package/dist/es/layouts/sidebar/code-block/{CodeBlockListPanel.js → CodeBlockListPanel2.vue.js} +1 -1
  136. package/dist/es/layouts/sidebar/code-block/useContentMenu.js +1 -1
  137. package/dist/es/layouts/sidebar/data-source/{DataSourceAddButton.vue_vue_type_script_setup_true_lang.js → DataSourceAddButton.vue.js} +2 -2
  138. package/dist/es/layouts/sidebar/data-source/{DataSourceAddButton.js → DataSourceAddButton2.vue.js} +1 -1
  139. package/dist/es/layouts/sidebar/data-source/{DataSourceConfigPanel.vue_vue_type_script_setup_true_lang.js → DataSourceConfigPanel.vue.js} +4 -4
  140. package/dist/es/layouts/sidebar/data-source/{DataSourceConfigPanel.js → DataSourceConfigPanel2.vue.js} +1 -1
  141. package/dist/es/layouts/sidebar/data-source/{DataSourceList.vue_vue_type_script_setup_true_lang.js → DataSourceList.vue.js} +5 -5
  142. package/dist/es/layouts/sidebar/data-source/{DataSourceList.js → DataSourceList2.vue.js} +1 -1
  143. package/dist/es/layouts/sidebar/data-source/{DataSourceListPanel.vue_vue_type_script_setup_true_lang.js → DataSourceListPanel.vue.js} +8 -8
  144. package/dist/es/layouts/sidebar/data-source/{DataSourceListPanel.js → DataSourceListPanel2.vue.js} +1 -1
  145. package/dist/es/layouts/sidebar/data-source/useContentMenu.js +1 -1
  146. package/dist/es/layouts/sidebar/layer/{LayerMenu.vue_vue_type_script_setup_true_lang.js → LayerMenu.vue.js} +5 -5
  147. package/dist/es/layouts/sidebar/layer/{LayerMenu.js → LayerMenu2.vue.js} +1 -1
  148. package/dist/es/layouts/sidebar/layer/{LayerNodeContent.vue_vue_type_script_setup_true_lang.js → LayerNodeContent.vue.js} +3 -3
  149. package/dist/es/layouts/sidebar/layer/{LayerNodeContent.js → LayerNodeContent2.vue.js} +1 -1
  150. package/dist/es/layouts/sidebar/layer/{LayerNodeTool.js → LayerNodeTool2.vue.js} +1 -1
  151. package/dist/es/layouts/sidebar/layer/{LayerPanel.vue_vue_type_script_setup_true_lang.js → LayerPanel.vue.js} +7 -7
  152. package/dist/es/layouts/sidebar/layer/{LayerPanel.js → LayerPanel2.vue.js} +1 -1
  153. package/dist/es/layouts/sidebar/layer/use-click.js +3 -3
  154. package/dist/es/layouts/sidebar/layer/use-drag.js +1 -1
  155. package/dist/es/layouts/sidebar/layer/use-keybinding.js +1 -1
  156. package/dist/es/layouts/sidebar/layer/use-node-status.js +2 -2
  157. package/dist/es/layouts/workspace/{Breadcrumb.js → Breadcrumb2.vue.js} +1 -1
  158. package/dist/es/layouts/workspace/{Workspace.vue_vue_type_script_setup_true_lang.js → Workspace.vue.js} +3 -3
  159. package/dist/es/layouts/workspace/{Workspace.js → Workspace2.vue.js} +1 -1
  160. package/dist/es/layouts/workspace/viewer/{NodeListMenu.vue_vue_type_script_setup_true_lang.js → NodeListMenu.vue.js} +5 -5
  161. package/dist/es/layouts/workspace/viewer/{NodeListMenu.js → NodeListMenu2.vue.js} +1 -1
  162. package/dist/es/layouts/workspace/viewer/{Stage.vue_vue_type_script_setup_true_lang.js → Stage.vue.js} +70 -55
  163. package/dist/es/layouts/workspace/viewer/{Stage.js → Stage2.vue.js} +1 -1
  164. package/dist/es/layouts/workspace/viewer/{StageOverlay.vue_vue_type_script_setup_true_lang.js → StageOverlay.vue.js} +3 -3
  165. package/dist/es/layouts/workspace/viewer/{StageOverlay.js → StageOverlay2.vue.js} +1 -1
  166. package/dist/es/layouts/workspace/viewer/{ViewerMenu.vue_vue_type_script_setup_true_lang.js → ViewerMenu.vue.js} +6 -6
  167. package/dist/es/layouts/workspace/viewer/{ViewerMenu.js → ViewerMenu2.vue.js} +1 -1
  168. package/dist/es/plugin.js +24 -24
  169. package/dist/es/sdk/index.js +2 -2
  170. package/dist/es/sdk/services/CodeBlock.js +18 -18
  171. package/dist/es/sdk/services/DataSource.js +17 -17
  172. package/dist/es/sdk/services/Dep.js +3 -3
  173. package/dist/es/sdk/services/Editor.js +116 -81
  174. package/dist/es/sdk/services/Events.js +2 -2
  175. package/dist/es/sdk/services/History.js +45 -7
  176. package/dist/es/sdk/services/Props.js +6 -6
  177. package/dist/es/sdk/services/WebStorage.js +1 -1
  178. package/dist/es/sdk/utils/dep.js +2 -2
  179. package/dist/es/sdk/utils/operator.js +3 -3
  180. package/dist/es/sdk/validate/index.js +4 -4
  181. package/dist/es/sdk/wiring.js +2 -2
  182. package/dist/es/services/keybinding.js +2 -2
  183. package/dist/es/services/stageOverlay.js +2 -2
  184. package/dist/es/services/ui.js +2 -2
  185. package/dist/es/utils/code-block.js +2 -2
  186. package/dist/es/utils/content-menu.js +3 -3
  187. package/dist/es/utils/data-source/index.js +88 -5
  188. package/dist/es/utils/dep/collect-worker-client.js +1 -1
  189. package/dist/es/utils/dep/idle-task.js +1 -1
  190. package/dist/es/utils/editor.js +7 -6
  191. package/dist/es/utils/event.js +1 -1
  192. package/dist/es/utils/history.js +29 -10
  193. package/dist/es/utils/operator.js +1 -1
  194. package/dist/es/utils/page.js +21 -0
  195. package/dist/es/utils/props.js +1 -1
  196. package/dist/es/utils/type-match-rules.js +4 -4
  197. package/dist/es/utils/undo-redo.js +57 -9
  198. package/dist/tmagic-editor-headless.umd.cjs +257 -87
  199. package/dist/tmagic-editor-sdk.umd.cjs +225 -84
  200. package/dist/tmagic-editor.umd.cjs +814 -241
  201. package/package.json +8 -8
  202. package/src/fields/DataSourceFieldSelect/FieldSelect.vue +68 -9
  203. package/src/fields/DataSourceFields.vue +53 -10
  204. package/src/fields/DataSourceMocks.vue +2 -2
  205. package/src/hooks/use-stage.ts +26 -1
  206. package/src/layouts/NavMenuColumn.vue +8 -1
  207. package/src/layouts/history-list/Bucket.vue +30 -16
  208. package/src/layouts/history-list/BucketTab.vue +8 -1
  209. package/src/layouts/history-list/HistoryListPanel.vue +27 -0
  210. package/src/layouts/history-list/InitialRow.vue +17 -5
  211. package/src/layouts/history-list/PageTab.vue +32 -18
  212. package/src/layouts/workspace/viewer/Stage.vue +77 -57
  213. package/src/sdk/services/Editor.ts +56 -26
  214. package/src/sdk/services/History.ts +58 -11
  215. package/src/type.ts +19 -3
  216. package/src/utils/data-source/index.ts +151 -6
  217. package/src/utils/editor.ts +4 -0
  218. package/src/utils/history.ts +35 -10
  219. package/src/utils/page.ts +32 -0
  220. package/src/utils/undo-redo.ts +76 -12
  221. package/types/headless.d.ts +14 -3
  222. package/types/index.d.ts +234 -314
  223. package/types/sdk.d.ts +79 -59
  224. package/dist/es/components/{CodeParams.vue_vue_type_script_setup_true_lang.js → CodeParams.vue.js} +2 -2
  225. package/dist/es/components/{CompareForm.vue_vue_type_script_setup_true_lang.js → CompareForm.vue.js} +3 -3
  226. package/dist/es/components/{Icon.vue_vue_type_script_setup_true_lang.js → Icon.vue.js} +1 -1
  227. package/dist/es/components/{Resizer.vue_vue_type_script_setup_true_lang.js → Resizer.vue.js} +1 -1
  228. package/dist/es/components/{ScrollBar.vue_vue_type_script_setup_true_lang.js → ScrollBar.vue.js} +0 -0
  229. package/dist/es/components/{SearchInput.vue_vue_type_script_setup_true_lang.js → SearchInput.vue.js} +1 -1
  230. package/dist/es/components/{ViewForm.vue_vue_type_script_setup_true_lang.js → ViewForm.vue.js} +2 -2
  231. package/dist/es/fields/{CodeLink.vue_vue_type_script_setup_true_lang.js → CodeLink.vue.js} +1 -1
  232. package/dist/es/fields/{CodeSelect.vue_vue_type_script_setup_true_lang.js → CodeSelect.vue.js} +2 -2
  233. package/dist/es/fields/{CondOpSelect.vue_vue_type_script_setup_true_lang.js → CondOpSelect.vue.js} +3 -3
  234. package/dist/es/fields/{DisplayConds.vue_vue_type_script_setup_true_lang.js → DisplayConds.vue.js} +2 -2
  235. package/dist/es/fields/{EventSelect.vue_vue_type_script_setup_true_lang.js → EventSelect.vue.js} +2 -2
  236. package/dist/es/fields/StyleSetter/components/{BackgroundPosition.vue_vue_type_script_setup_true_lang.js → BackgroundPosition.vue.js} +1 -1
  237. package/dist/es/fields/StyleSetter/components/{Border.vue_vue_type_script_setup_true_lang.js → Border.vue.js} +2 -2
  238. package/dist/es/fields/StyleSetter/components/{Box.vue_vue_type_script_setup_true_lang.js → Box.vue.js} +0 -0
  239. package/dist/es/fields/StyleSetter/icons/align-items/{Baseline.js → Baseline.vue.js} +1 -1
  240. package/dist/es/fields/StyleSetter/icons/align-items/{Center.js → Center.vue.js} +1 -1
  241. package/dist/es/fields/StyleSetter/icons/align-items/{End.js → End.vue.js} +1 -1
  242. package/dist/es/fields/StyleSetter/icons/align-items/{FlexEnd.js → FlexEnd.vue.js} +1 -1
  243. package/dist/es/fields/StyleSetter/icons/align-items/{FlexStart.js → FlexStart.vue.js} +1 -1
  244. package/dist/es/fields/StyleSetter/icons/align-items/{Normal.js → Normal.vue.js} +1 -1
  245. package/dist/es/fields/StyleSetter/icons/align-items/{SpaceAround.js → SpaceAround.vue.js} +1 -1
  246. package/dist/es/fields/StyleSetter/icons/align-items/{SpaceBetween.js → SpaceBetween.vue.js} +1 -1
  247. package/dist/es/fields/StyleSetter/icons/align-items/{Start.js → Start.vue.js} +1 -1
  248. package/dist/es/fields/StyleSetter/icons/align-items/{Stretch.js → Stretch.vue.js} +1 -1
  249. package/dist/es/fields/StyleSetter/icons/background-repeat/{NoRepeat.js → NoRepeat.vue.js} +1 -1
  250. package/dist/es/fields/StyleSetter/icons/background-repeat/{Repeat.js → Repeat.vue.js} +1 -1
  251. package/dist/es/fields/StyleSetter/icons/background-repeat/{RepeatX.js → RepeatX.vue.js} +1 -1
  252. package/dist/es/fields/StyleSetter/icons/background-repeat/{RepeatY.js → RepeatY.vue.js} +1 -1
  253. package/dist/es/fields/StyleSetter/icons/background-repeat/{Round.js → Round.vue.js} +1 -1
  254. package/dist/es/fields/StyleSetter/icons/background-repeat/{Space.js → Space.vue.js} +1 -1
  255. package/dist/es/fields/StyleSetter/icons/display/{Block.js → Block.vue.js} +1 -1
  256. package/dist/es/fields/StyleSetter/icons/display/{Flex.js → Flex.vue.js} +1 -1
  257. package/dist/es/fields/StyleSetter/icons/display/{Grid.js → Grid.vue.js} +1 -1
  258. package/dist/es/fields/StyleSetter/icons/display/{Inline.js → Inline.vue.js} +1 -1
  259. package/dist/es/fields/StyleSetter/icons/display/{InlineBlock.js → InlineBlock.vue.js} +1 -1
  260. package/dist/es/fields/StyleSetter/icons/display/{InlineFlex.js → InlineFlex.vue.js} +1 -1
  261. package/dist/es/fields/StyleSetter/icons/display/{InlineGrid.js → InlineGrid.vue.js} +1 -1
  262. package/dist/es/fields/StyleSetter/icons/display/{None.js → None.vue.js} +1 -1
  263. package/dist/es/fields/StyleSetter/icons/flex-direction/{Column.js → Column.vue.js} +1 -1
  264. package/dist/es/fields/StyleSetter/icons/flex-direction/{ColumnReverse.js → ColumnReverse.vue.js} +1 -1
  265. package/dist/es/fields/StyleSetter/icons/flex-direction/{Row.js → Row.vue.js} +1 -1
  266. package/dist/es/fields/StyleSetter/icons/flex-direction/{RowReverse.js → RowReverse.vue.js} +1 -1
  267. package/dist/es/fields/StyleSetter/icons/justify-content/{Center.js → Center.vue.js} +1 -1
  268. package/dist/es/fields/StyleSetter/icons/justify-content/{FlexEnd.js → FlexEnd.vue.js} +1 -1
  269. package/dist/es/fields/StyleSetter/icons/justify-content/{FlexStart.js → FlexStart.vue.js} +1 -1
  270. package/dist/es/fields/StyleSetter/icons/justify-content/{SpaceAround.js → SpaceAround.vue.js} +1 -1
  271. package/dist/es/fields/StyleSetter/icons/justify-content/{SpaceBetween.js → SpaceBetween.vue.js} +1 -1
  272. package/dist/es/fields/StyleSetter/icons/justify-content/{SpaceEvenly.js → SpaceEvenly.vue.js} +1 -1
  273. package/dist/es/fields/StyleSetter/icons/text-align/{Center.js → Center.vue.js} +1 -1
  274. package/dist/es/fields/StyleSetter/icons/text-align/{End.js → End.vue.js} +1 -1
  275. package/dist/es/fields/StyleSetter/icons/text-align/{Justify.js → Justify.vue.js} +1 -1
  276. package/dist/es/fields/StyleSetter/icons/text-align/{Left.js → Left.vue.js} +1 -1
  277. package/dist/es/fields/StyleSetter/icons/text-align/{MatchParent.js → MatchParent.vue.js} +1 -1
  278. package/dist/es/fields/StyleSetter/icons/text-align/{Right.js → Right.vue.js} +1 -1
  279. package/dist/es/fields/StyleSetter/icons/text-align/{Start.js → Start.vue.js} +1 -1
  280. package/dist/es/fields/StyleSetter/pro/{Background.vue_vue_type_script_setup_true_lang.js → Background.vue.js} +2 -2
  281. package/dist/es/fields/StyleSetter/pro/{Font.vue_vue_type_script_setup_true_lang.js → Font.vue.js} +2 -2
  282. package/dist/es/fields/StyleSetter/pro/{Position.vue_vue_type_script_setup_true_lang.js → Position.vue.js} +2 -2
  283. package/dist/es/fields/StyleSetter/pro/{Transform.vue_vue_type_script_setup_true_lang.js → Transform.vue.js} +2 -2
  284. package/dist/es/fields/{UISelect.vue_vue_type_script_setup_true_lang.js → UISelect.vue.js} +5 -5
  285. package/dist/es/icons/{CenterIcon.vue_vue_type_script_setup_true_lang.js → CenterIcon.vue.js} +0 -0
  286. package/dist/es/icons/{CodeIcon.vue_vue_type_script_setup_true_lang.js → CodeIcon.vue.js} +0 -0
  287. package/dist/es/icons/{DatasourceIcon.js → DatasourceIcon.vue.js} +1 -1
  288. package/dist/es/icons/{FolderMinusIcon.vue_vue_type_script_setup_true_lang.js → FolderMinusIcon.vue.js} +0 -0
  289. package/dist/es/layouts/history-list/{GroupRow.vue_vue_type_script_setup_true_lang.js → GroupRow.vue.js} +1 -1
  290. package/dist/es/layouts/sidebar/layer/{LayerNodeTool.vue_vue_type_script_setup_true_lang.js → LayerNodeTool.vue.js} +2 -2
  291. package/dist/es/layouts/workspace/{Breadcrumb.vue_vue_type_script_setup_true_lang.js → Breadcrumb.vue.js} +2 -2
@@ -21,12 +21,14 @@
21
21
  var __getProtoOf = Object.getPrototypeOf;
22
22
  var __hasOwnProp = Object.prototype.hasOwnProperty;
23
23
  var __copyProps = (to, from, except, desc) => {
24
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
25
- key = keys[i];
26
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
27
- get: ((k) => from[k]).bind(null, key),
28
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
- });
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ desc = __getOwnPropDesc(from, key);
27
+ __defProp(to, key, {
28
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
29
+ enumerable: !desc || desc.enumerable
30
+ });
31
+ }
30
32
  }
31
33
  return to;
32
34
  };
@@ -280,7 +282,7 @@
280
282
  * _.isObject(null);
281
283
  * // => false
282
284
  */
283
- function isObject(value) {
285
+ function isObject$1(value) {
284
286
  var type = typeof value;
285
287
  return value != null && (type == "object" || type == "function");
286
288
  }
@@ -321,9 +323,9 @@
321
323
  function toNumber(value) {
322
324
  if (typeof value == "number") return value;
323
325
  if (isSymbol(value)) return NAN;
324
- if (isObject(value)) {
326
+ if (isObject$1(value)) {
325
327
  var other = typeof value.valueOf == "function" ? value.valueOf() : value;
326
- value = isObject(other) ? other + "" : other;
328
+ value = isObject$1(other) ? other + "" : other;
327
329
  }
328
330
  if (typeof value != "string") return value === 0 ? value : +value;
329
331
  value = baseTrim(value);
@@ -374,7 +376,7 @@
374
376
  * // => false
375
377
  */
376
378
  function isFunction(value) {
377
- if (!isObject(value)) return false;
379
+ if (!isObject$1(value)) return false;
378
380
  var tag = baseGetTag(value);
379
381
  return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
380
382
  }
@@ -444,7 +446,7 @@
444
446
  * else `false`.
445
447
  */
446
448
  function baseIsNative(value) {
447
- if (!isObject(value) || isMasked(value)) return false;
449
+ if (!isObject$1(value) || isMasked(value)) return false;
448
450
  return (isFunction(value) ? reIsNative : reIsHostCtor).test(toSource(value));
449
451
  }
450
452
  // node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js
@@ -488,7 +490,7 @@
488
490
  var baseCreate = function() {
489
491
  function object() {}
490
492
  return function(proto) {
491
- if (!isObject(proto)) return {};
493
+ if (!isObject$1(proto)) return {};
492
494
  if (objectCreate) return objectCreate(proto);
493
495
  object.prototype = proto;
494
496
  var result = new object();
@@ -707,7 +709,7 @@
707
709
  }
708
710
  // node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js
709
711
  /** Used as references for various `Number` constants. */
710
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
712
+ var MAX_SAFE_INTEGER$1 = 0x1fffffffffffff;
711
713
  /** Used to detect unsigned integer values. */
712
714
  var reIsUint = /^(?:0|[1-9]\d*)$/;
713
715
  /**
@@ -856,7 +858,7 @@
856
858
  }
857
859
  // node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/isLength.js
858
860
  /** Used as references for various `Number` constants. */
859
- var MAX_SAFE_INTEGER = 9007199254740991;
861
+ var MAX_SAFE_INTEGER = 0x1fffffffffffff;
860
862
  /**
861
863
  * Checks if `value` is a valid array-like length.
862
864
  *
@@ -927,7 +929,7 @@
927
929
  * else `false`.
928
930
  */
929
931
  function isIterateeCall(value, index, object) {
930
- if (!isObject(object)) return false;
932
+ if (!isObject$1(object)) return false;
931
933
  var type = typeof index;
932
934
  if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) return eq(object[index], value);
933
935
  return false;
@@ -1264,7 +1266,7 @@
1264
1266
  * @returns {Array} Returns the array of property names.
1265
1267
  */
1266
1268
  function baseKeysIn(object) {
1267
- if (!isObject(object)) return nativeKeysIn(object);
1269
+ if (!isObject$1(object)) return nativeKeysIn(object);
1268
1270
  var isProto = isPrototype(object), result = [];
1269
1271
  for (var key in object) if (!(key == "constructor" && (isProto || !hasOwnProperty$8.call(object, key)))) result.push(key);
1270
1272
  return result;
@@ -2587,7 +2589,7 @@
2587
2589
  var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
2588
2590
  if (customizer) result = object ? customizer(value, key, object, stack) : customizer(value);
2589
2591
  if (result !== void 0) return result;
2590
- if (!isObject(value)) return value;
2592
+ if (!isObject$1(value)) return value;
2591
2593
  var isArr = isArray(value);
2592
2594
  if (isArr) {
2593
2595
  result = initCloneArray(value);
@@ -3167,7 +3169,7 @@
3167
3169
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
3168
3170
  if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT$1);
3169
3171
  wait = toNumber(wait) || 0;
3170
- if (isObject(options)) {
3172
+ if (isObject$1(options)) {
3171
3173
  leading = !!options.leading;
3172
3174
  maxing = "maxWait" in options;
3173
3175
  maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
@@ -3356,7 +3358,7 @@
3356
3358
  } else if (isPlainObject$1(srcValue) || isArguments(srcValue)) {
3357
3359
  newValue = objValue;
3358
3360
  if (isArguments(objValue)) newValue = toPlainObject(objValue);
3359
- else if (!isObject(objValue) || isFunction(objValue)) newValue = initCloneObject(srcValue);
3361
+ else if (!isObject$1(objValue) || isFunction(objValue)) newValue = initCloneObject(srcValue);
3360
3362
  } else isCommon = false;
3361
3363
  }
3362
3364
  if (isCommon) {
@@ -3382,7 +3384,7 @@
3382
3384
  if (object === source) return;
3383
3385
  baseFor(source, function(srcValue, key) {
3384
3386
  stack || (stack = new Stack());
3385
- if (isObject(srcValue)) baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3387
+ if (isObject$1(srcValue)) baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3386
3388
  else {
3387
3389
  var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : void 0;
3388
3390
  if (newValue === void 0) newValue = srcValue;
@@ -3577,7 +3579,7 @@
3577
3579
  * @returns {Object} Returns `object`.
3578
3580
  */
3579
3581
  function baseSet(object, path, value, customizer) {
3580
- if (!isObject(object)) return object;
3582
+ if (!isObject$1(object)) return object;
3581
3583
  path = castPath(path, object);
3582
3584
  var index = -1, length = path.length, lastIndex = length - 1, nested = object;
3583
3585
  while (nested != null && ++index < length) {
@@ -3586,7 +3588,7 @@
3586
3588
  if (index != lastIndex) {
3587
3589
  var objValue = nested[key];
3588
3590
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
3589
- if (newValue === void 0) newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
3591
+ if (newValue === void 0) newValue = isObject$1(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
3590
3592
  }
3591
3593
  assignValue(nested, key, newValue);
3592
3594
  nested = nested[key];
@@ -3697,7 +3699,7 @@
3697
3699
  function throttle(func, wait, options) {
3698
3700
  var leading = true, trailing = true;
3699
3701
  if (typeof func != "function") throw new TypeError(FUNC_ERROR_TEXT);
3700
- if (isObject(options)) {
3702
+ if (isObject$1(options)) {
3701
3703
  leading = "leading" in options ? !!options.leading : leading;
3702
3704
  trailing = "trailing" in options ? !!options.trailing : trailing;
3703
3705
  }
@@ -4014,6 +4016,7 @@
4014
4016
  if (el && parentEl) {
4015
4017
  const calcParentOffsetWidth = (0, _tmagic_utils.calcValueByFontsize)(doc, parentEl.offsetWidth);
4016
4018
  const calcElOffsetWidth = (0, _tmagic_utils.calcValueByFontsize)(doc, el.offsetWidth);
4019
+ if (calcElOffsetWidth > calcParentOffsetWidth) return config.style.left;
4017
4020
  if (calcElOffsetWidth + left > calcParentOffsetWidth) return calcParentOffsetWidth - calcElOffsetWidth;
4018
4021
  }
4019
4022
  return config.style.left;
@@ -4039,7 +4042,7 @@
4039
4042
  var isIncludeDataSourceByDiffAddResult = (diffResult) => {
4040
4043
  for (const value of Object.values(diffResult)) {
4041
4044
  if ((0, _tmagic_utils.isValueIncludeDataSource)(value)) return true;
4042
- if (isObject(value)) return isIncludeDataSourceByDiffAddResult(value);
4045
+ if (isObject$1(value)) return isIncludeDataSourceByDiffAddResult(value);
4043
4046
  }
4044
4047
  return false;
4045
4048
  };
@@ -4047,7 +4050,7 @@
4047
4050
  for (const [key, value] of Object.entries(diffResult)) {
4048
4051
  if ((0, _tmagic_utils.isValueIncludeDataSource)(value)) return true;
4049
4052
  if ((0, _tmagic_utils.isValueIncludeDataSource)(oldNode[key])) return true;
4050
- if (isObject(value)) return isIncludeDataSourceByDiffUpdatedResult(value, oldNode[key]);
4053
+ if (isObject$1(value)) return isIncludeDataSourceByDiffUpdatedResult(value, oldNode[key]);
4051
4054
  }
4052
4055
  return false;
4053
4056
  };
@@ -4185,7 +4188,7 @@
4185
4188
  */
4186
4189
  var editorNodeMergeCustomizer = (objValue, srcValue, key, _object, source) => {
4187
4190
  if (typeof srcValue === "undefined" && Object.hasOwn(source, key)) return "";
4188
- if (isObject(srcValue) && Array.isArray(objValue)) return srcValue;
4191
+ if (isObject$1(srcValue) && Array.isArray(objValue)) return srcValue;
4189
4192
  if (Array.isArray(srcValue)) return srcValue;
4190
4193
  };
4191
4194
  /**
@@ -4279,6 +4282,13 @@
4279
4282
  }
4280
4283
  };
4281
4284
  // packages/editor/src/utils/undo-redo.ts
4285
+ /** 各历史栈 index 0 的 initial 是撤销下限(见 utils/history.ts 的 undoFloor),裁剪时不能把它挤掉。 */
4286
+ var isInitialStep = (step) => step?.opType === "initial";
4287
+ /**
4288
+ * 容量按「真实步骤数」计算:index 0 的 initial 基线额外占一个位置,不挤掉真实记录。
4289
+ * 只要真实步骤没超限,最老一条的 oldSchema 仍指向加载时的 DSL,「回到初始」就是可达的。
4290
+ */
4291
+ var maxLength = (list, listMaxSize) => listMaxSize + (isInitialStep(list[0]) ? 1 : 0);
4282
4292
  var UndoRedo = class UndoRedo {
4283
4293
  /**
4284
4294
  * 由 {@link UndoRedo.serialize} 产出的快照重建一个 UndoRedo 实例。
@@ -4289,13 +4299,9 @@
4289
4299
  */
4290
4300
  static fromSerialized(data, options = {}) {
4291
4301
  const undoRedo = new UndoRedo(data.listMaxSize);
4302
+ undoRedo.initialReachable = data.initialReachable !== false;
4292
4303
  const list = Array.isArray(data.elementList) ? data.elementList.map((item) => cloneDeep(item)) : [];
4293
4304
  let cursor = Number.isFinite(data.listCursor) ? data.listCursor : list.length;
4294
- const overflow = list.length - undoRedo.listMaxSize;
4295
- if (overflow > 0) {
4296
- list.splice(0, overflow);
4297
- cursor -= overflow;
4298
- }
4299
4305
  if (options.isSavedStep) {
4300
4306
  for (let i = list.length - 1; i >= 0; i--) if (options.isSavedStep(list[i])) {
4301
4307
  cursor = i + 1;
@@ -4309,7 +4315,9 @@
4309
4315
  elementList;
4310
4316
  listCursor;
4311
4317
  listMaxSize;
4312
- constructor(listMaxSize = 100) {
4318
+ /** 容量裁剪是否删掉过已应用的真实步骤(撤销链已断,「回到初始」不可达)。 */
4319
+ initialReachable = true;
4320
+ constructor(listMaxSize = 1e3) {
4313
4321
  const minListMaxSize = 2;
4314
4322
  this.elementList = [];
4315
4323
  this.listCursor = 0;
@@ -4323,16 +4331,55 @@
4323
4331
  return {
4324
4332
  elementList: this.elementList.map((item) => cloneDeep(item)),
4325
4333
  listCursor: this.listCursor,
4326
- listMaxSize: this.listMaxSize
4334
+ listMaxSize: this.listMaxSize,
4335
+ initialReachable: this.initialReachable
4327
4336
  };
4328
4337
  }
4329
4338
  pushElement(element) {
4330
4339
  this.elementList.splice(this.listCursor, this.elementList.length - this.listCursor, cloneDeep(element));
4331
4340
  this.listCursor += 1;
4332
- if (this.elementList.length > this.listMaxSize) {
4333
- this.elementList.shift();
4341
+ }
4342
+ /**
4343
+ * 把栈裁剪到容量上限(`listMaxSize` 条真实步骤,index 0 的 initial 基线额外占一个位置)。
4344
+ *
4345
+ * 只在保存后调用(见 historyService.markSaved):保存前不裁剪,避免用户还没落库就丢掉可撤销的历史。
4346
+ * **永不删除** initial 基线与「整体设置 root」产生的记录(`rootStep`);
4347
+ * 受保护记录本身占满容量时栈保持超限。
4348
+ *
4349
+ * 分两个阶段删除,保证撤销链与重做链各自连续:
4350
+ * 1. 先从最旧的记录开始删**已应用**区(游标之前)的可删记录,撤销链仍然连续;
4351
+ * 2. 已应用区删无可删仍超限时,溢出量落在重做区。重做链必须连续——后一条是按前一条的 DSL 打的补丁,
4352
+ * 只删掉开头几条会让留下的步骤叠在缺失的基线上,因此整段丢弃游标之后的步骤。
4353
+ * (不从重做区末尾往前删:重做区里可能有受保护的 `rootStep`,跳过它去删它前面的步骤同样会留空洞。)
4354
+ *
4355
+ * 「回到初始」是否仍可达,取决于被删的已应用步骤相对最早一条 `rootStep` 的位置:
4356
+ * - 位于其**之后**:撤销链完整——一直撤销会退到这条整页快照,再撤销它即回到加载时的 DSL,仍可达;
4357
+ * - 位于其**之前**(或栈内没有 `rootStep`):撤到底只能停在中途版本,标记为不可达。
4358
+ * 只删掉重做区记录时不影响可达性。
4359
+ */
4360
+ trim() {
4361
+ let overflow = this.elementList.length - maxLength(this.elementList, this.listMaxSize);
4362
+ if (overflow <= 0) return;
4363
+ let seenRootStep = false;
4364
+ let brokenChain = false;
4365
+ for (let index = 0; index < this.listCursor && overflow > 0;) {
4366
+ const step = this.elementList[index];
4367
+ if (isInitialStep(step)) {
4368
+ index += 1;
4369
+ continue;
4370
+ }
4371
+ if (step?.rootStep === true) {
4372
+ seenRootStep = true;
4373
+ index += 1;
4374
+ continue;
4375
+ }
4376
+ this.elementList.splice(index, 1);
4377
+ overflow -= 1;
4334
4378
  this.listCursor -= 1;
4379
+ if (!seenRootStep) brokenChain = true;
4335
4380
  }
4381
+ if (overflow > 0 && this.elementList.length > this.listCursor) this.elementList.length = this.listCursor;
4382
+ if (brokenChain) this.initialReachable = false;
4336
4383
  }
4337
4384
  canUndo() {
4338
4385
  return this.listCursor > 0;
@@ -4399,6 +4446,10 @@
4399
4446
  getLength() {
4400
4447
  return this.elementList.length;
4401
4448
  }
4449
+ /** 「回到初始」是否可达:容量裁剪删掉已应用的真实步骤后撤销链断开,返回 false。 */
4450
+ isInitialReachable() {
4451
+ return this.initialReachable;
4452
+ }
4402
4453
  };
4403
4454
  // packages/editor/src/utils/history.ts
4404
4455
  /**
@@ -4462,6 +4513,11 @@
4462
4513
  extra: payload.extra
4463
4514
  };
4464
4515
  };
4516
+ /**
4517
+ * 把栈当前游标所在的记录标记为「已保存」,随后把栈裁剪到容量上限(见 {@link UndoRedo.trim})。
4518
+ * 入栈与还原都不裁剪,只有保存后才收敛,避免用户在落库前丢掉可撤销的历史;
4519
+ * initial 基线与「整体设置 root」产生的记录(`rootStep`)不会被裁掉。
4520
+ */
4465
4521
  var markStackSaved = (undoRedo) => {
4466
4522
  if (!undoRedo) return;
4467
4523
  undoRedo.updateElements((element) => {
@@ -4470,6 +4526,7 @@
4470
4526
  undoRedo.updateCurrentElement((element) => {
4471
4527
  element.saved = true;
4472
4528
  });
4529
+ undoRedo.trim();
4473
4530
  };
4474
4531
  /**
4475
4532
  * 把单个历史栈(页面 / 代码块 / 数据源 / 扩展类型)的步骤列表按"目标"做相邻合并:
@@ -4581,20 +4638,33 @@
4581
4638
  *
4582
4639
  * 与 {@link serializeStacks} 相反:当传入 `parse`(parseDSL)时,把每条 step 中以字符串形式存储的 `diff`
4583
4640
  * 解析回真实对象(含函数);不含 `diff` 的元素(如通用栈)原样透传。
4641
+ *
4642
+ * 单个栈解析失败只丢弃该栈,其余栈照常还原:一条损坏的快照不应该让整份本地历史都不可用。
4643
+ * 结构性损坏(`elementList` 不是数组)同样按空栈处理,交给 {@link UndoRedo.fromSerialized} 兜底。
4644
+ * 全部栈都失败时抛出首个错误,避免调用方把「什么都没恢复」当成一次成功的还原。
4584
4645
  */
4585
4646
  var deserializeStacks = (stacks = {}, parse) => {
4586
4647
  const result = {};
4648
+ let firstError;
4649
+ let failedCount = 0;
4587
4650
  Object.entries(stacks).forEach(([id, serialized]) => {
4588
4651
  if (!serialized) return;
4589
- const elementList = parse ? serialized.elementList.map((step) => {
4590
- const { diff } = step;
4591
- return typeof diff === "string" ? Object.assign({}, step, { diff: parse(`(${diff})`) }) : step;
4592
- }) : serialized.elementList;
4593
- result[id] = UndoRedo.fromSerialized({
4594
- ...serialized,
4595
- elementList
4596
- }, { isSavedStep: (element) => element.saved === true });
4652
+ const source = Array.isArray(serialized.elementList) ? serialized.elementList : [];
4653
+ try {
4654
+ const elementList = parse ? source.map((step) => {
4655
+ const { diff } = step;
4656
+ return typeof diff === "string" ? Object.assign({}, step, { diff: parse(`(${diff})`) }) : step;
4657
+ }) : source;
4658
+ result[id] = UndoRedo.fromSerialized({
4659
+ ...serialized,
4660
+ elementList
4661
+ }, { isSavedStep: (element) => element.saved === true });
4662
+ } catch (error) {
4663
+ failedCount += 1;
4664
+ firstError ??= error;
4665
+ }
4597
4666
  });
4667
+ if (failedCount > 0 && Object.keys(result).length === 0) throw firstError;
4598
4668
  return result;
4599
4669
  };
4600
4670
  /**
@@ -5638,18 +5708,47 @@
5638
5708
  ...values
5639
5709
  };
5640
5710
  };
5641
- var getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"]) => {
5711
+ /** 数组下标固定提供 0–19,不随 mock 或默认值的长度变化 */
5712
+ var ARRAY_INDEX_COUNT = 20;
5713
+ var appendArrayIndexOptions = (field, dataSourceFieldType, typeSet, includesAny, context) => {
5714
+ const elementFields = field.fields;
5715
+ const taken = new Set((elementFields || []).map((item) => item.name));
5716
+ const elementType = elementFields?.length ? "object" : "any";
5717
+ if (!elementFields?.length && !includesAny) return [];
5718
+ const children = getCascaderOptionsFromFields(elementFields, dataSourceFieldType, {}, context);
5719
+ if (!(includesAny || typeSet.has(elementType)) && !children.length) return [];
5720
+ const indexNodes = [];
5721
+ for (let index = 0; index < ARRAY_INDEX_COUNT; index++) {
5722
+ const name = `${index}`;
5723
+ if (taken.has(name)) continue;
5724
+ indexNodes.push({
5725
+ label: `[${index}]`,
5726
+ value: index,
5727
+ arrayIndex: true,
5728
+ ...children.length ? { children } : {}
5729
+ });
5730
+ }
5731
+ return indexNodes;
5732
+ };
5733
+ var getCascaderOptionsFromFields = (fields = [], dataSourceFieldType = ["any"], data, context = {}) => {
5642
5734
  const typeSet = new Set(dataSourceFieldType.length ? dataSourceFieldType : ["any"]);
5643
5735
  const includesAny = typeSet.has("any");
5644
5736
  const result = [];
5645
5737
  for (const field of fields) {
5646
5738
  const fieldType = field.type || "any";
5647
5739
  const isContainerType = fieldType === "any" || fieldType === "array" || fieldType === "object";
5648
- const children = isContainerType ? getCascaderOptionsFromFields(field.fields, dataSourceFieldType) : [];
5740
+ const showElementFields = fieldType !== "array" || context.directArrayElements !== false;
5741
+ const nestedData = data ? {} : void 0;
5742
+ let children = isContainerType && showElementFields ? getCascaderOptionsFromFields(field.fields, dataSourceFieldType, nestedData, context) : [];
5743
+ if (fieldType === "array" && data) {
5744
+ const indexNodes = appendArrayIndexOptions(field, dataSourceFieldType, typeSet, includesAny, context);
5745
+ children = [...children, ...indexNodes];
5746
+ }
5649
5747
  if (includesAny || typeSet.has(fieldType) || isContainerType && children.length) result.push({
5650
5748
  label: `${field.title || field.name}(${field.type})`,
5651
5749
  value: field.name,
5652
- children
5750
+ children,
5751
+ fieldType
5653
5752
  });
5654
5753
  }
5655
5754
  return result;
@@ -6639,6 +6738,14 @@
6639
6738
  return parentNode;
6640
6739
  };
6641
6740
  // packages/editor/src/sdk/services/Editor.ts
6741
+ /**
6742
+ * 撤销 / 重做回放的内部标记键:不导出,也不出现在公开的 {@link HistoryOpOptions} 里。
6743
+ * 回放链路用它把 `isHistoryOp` 带进 `change` 事件;外部调用方即使传同名字符串字段也不会被读取,
6744
+ * 避免一次真实编辑被误标成历史回放,从而绕过业务侧的加锁 / 埋点 / 自动保存。
6745
+ */
6746
+ var HISTORY_OP = Symbol("isHistoryOp");
6747
+ /** 读取仅供编辑器内部使用的回放标记。 */
6748
+ var isReplay = (options) => options[HISTORY_OP] === true;
6642
6749
  /** 把插入下标收敛到 [0, length]:非整数取整,非法 / 越界(含未记录)一律追加到末尾 */
6643
6750
  var clampIndex = (index, length) => {
6644
6751
  const normalized = typeof index === "number" ? Math.trunc(index) : length;
@@ -6715,7 +6822,7 @@
6715
6822
  if (name === "nodes" && Array.isArray(value)) this.set("node", value[0]);
6716
6823
  if (name === "root") {
6717
6824
  if (Array.isArray(value)) throw new Error("root 不能为数组");
6718
- if (value && isObject(value)) {
6825
+ if (value && isObject$1(value)) {
6719
6826
  const app = value;
6720
6827
  this.state.pageLength = getPageList(app).length || 0;
6721
6828
  this.state.pageFragmentLength = getPageFragmentList(app).length || 0;
@@ -6929,14 +7036,16 @@
6929
7036
  root: cloneDeep(root),
6930
7037
  index: insertIndex
6931
7038
  });
6932
- const newStyle = fixNodePosition(node, parent, stage);
6933
- if (newStyle && (newStyle.top !== node.style.top || newStyle.left !== node.style.left)) {
6934
- node.style = newStyle;
6935
- await stage?.update({
6936
- config: cloneDeep(node),
6937
- parentId: parent.id,
6938
- root: cloneDeep(root)
6939
- });
7039
+ if (!options.doNotFixPosition) {
7040
+ const newStyle = fixNodePosition(node, parent, stage);
7041
+ if (newStyle && (newStyle.top !== node.style.top || newStyle.left !== node.style.left)) {
7042
+ node.style = newStyle;
7043
+ await stage?.update({
7044
+ config: cloneDeep(node),
7045
+ parentId: parent.id,
7046
+ root: cloneDeep(root)
7047
+ });
7048
+ }
6940
7049
  }
6941
7050
  this.addModifiedNodeId(node.id);
6942
7051
  return node;
@@ -6951,6 +7060,7 @@
6951
7060
  async add(addNode, parent, options = {}) {
6952
7061
  this.captureSelectionBeforeOp();
6953
7062
  const { doNotSelect = false, doNotSwitchPage = false, doNotPushHistory = false, historyDescription, historySource } = options;
7063
+ const isHistoryOp = isReplay(options);
6954
7064
  const stage = this.get("stage");
6955
7065
  const addNodes = [];
6956
7066
  if (!Array.isArray(addNode)) {
@@ -7028,7 +7138,8 @@
7028
7138
  page: this.getPageOfNode(node.id)
7029
7139
  })),
7030
7140
  historySource,
7031
- doNotPushHistory
7141
+ doNotPushHistory,
7142
+ isHistoryOp
7032
7143
  });
7033
7144
  const addedPages = newNodes.filter((node) => (0, _tmagic_utils.isPageOrFragment)(node));
7034
7145
  if (addedPages.length) this.ctx.history.notifyPageStructureChange({
@@ -7099,6 +7210,7 @@
7099
7210
  */
7100
7211
  async remove(nodeOrNodeList, options = {}) {
7101
7212
  const { doNotPushHistory = false, historyDescription, historySource } = options;
7213
+ const isHistoryOp = isReplay(options);
7102
7214
  this.captureSelectionBeforeOp();
7103
7215
  const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
7104
7216
  const changeItems = nodes.map((node) => ({
@@ -7138,7 +7250,8 @@
7138
7250
  type: "remove",
7139
7251
  data: changeItems,
7140
7252
  historySource,
7141
- doNotPushHistory
7253
+ doNotPushHistory,
7254
+ isHistoryOp
7142
7255
  });
7143
7256
  const removedPages = nodes.filter((node) => (0, _tmagic_utils.isPageOrFragment)(node));
7144
7257
  if (removedPages.length) this.ctx.history.notifyPageStructureChange({
@@ -7202,6 +7315,7 @@
7202
7315
  async update(config, data = {}) {
7203
7316
  this.captureSelectionBeforeOp();
7204
7317
  const { doNotPushHistory = false, changeRecordList, changeRecords, historyDescription, historySource, invalidInfo } = data;
7318
+ const isHistoryOp = isReplay(data);
7205
7319
  const nodes = Array.isArray(config) ? config : [config];
7206
7320
  const commitInvalid = await this.runGuard(() => this.ctx.validator.guardUpdate(nodes, { replace: data.replace }));
7207
7321
  const updateData = await Promise.all(nodes.map((node, index) => {
@@ -7241,7 +7355,8 @@
7241
7355
  page: this.getPageOfNode(node.newNode.id)
7242
7356
  })),
7243
7357
  historySource,
7244
- doNotPushHistory
7358
+ doNotPushHistory,
7359
+ isHistoryOp
7245
7360
  });
7246
7361
  return Array.isArray(config) ? updateData.map((item) => item.newNode) : updateData[0].newNode;
7247
7362
  }
@@ -7334,9 +7449,7 @@
7334
7449
  const parent = this.getParentById(config.id);
7335
7450
  if (!parent) throw new Error("找不到父节点");
7336
7451
  const node = cloneDeep(this.toRaw(config));
7337
- const layout = await this.getLayout(parent, node);
7338
- const doc = this.get("stage")?.renderer?.contentWindow?.document;
7339
- const newStyle = calcAlignCenterStyle(node, parent, layout, doc);
7452
+ const newStyle = calcAlignCenterStyle(node, parent, await this.getLayout(parent, node), this.get("stage")?.renderer?.contentWindow?.document);
7340
7453
  if (!newStyle) return config;
7341
7454
  node.style = newStyle;
7342
7455
  return node;
@@ -7371,7 +7484,9 @@
7371
7484
  * @param options 可选配置
7372
7485
  * @param options.doNotPushHistory 是否不写入历史记录(默认 false)
7373
7486
  */
7374
- async moveLayer(offset, { doNotPushHistory = false, historyDescription, historySource } = {}) {
7487
+ async moveLayer(offset, options = {}) {
7488
+ const { doNotPushHistory = false, historyDescription, historySource } = options;
7489
+ const isHistoryOp = isReplay(options);
7375
7490
  this.captureSelectionBeforeOp();
7376
7491
  const root = this.get("root");
7377
7492
  if (!root) throw new Error("root为空");
@@ -7418,7 +7533,8 @@
7418
7533
  }],
7419
7534
  offset,
7420
7535
  historySource,
7421
- doNotPushHistory
7536
+ doNotPushHistory,
7537
+ isHistoryOp
7422
7538
  });
7423
7539
  }
7424
7540
  /**
@@ -7491,7 +7607,9 @@
7491
7607
  } else this.selectionBeforeOp = null;
7492
7608
  return isBatch ? newConfigs : newConfigs[0];
7493
7609
  }
7494
- async dragTo(config, targetParent, targetIndex, { doNotPushHistory = false, historyDescription, historySource } = {}) {
7610
+ async dragTo(config, targetParent, targetIndex, options = {}) {
7611
+ const { doNotPushHistory = false, historyDescription, historySource } = options;
7612
+ const isHistoryOp = isReplay(options);
7495
7613
  this.captureSelectionBeforeOp();
7496
7614
  if (!targetParent || !Array.isArray(targetParent.items)) return;
7497
7615
  const configs = Array.isArray(config) ? config : [config];
@@ -7558,7 +7676,8 @@
7558
7676
  targetIndex,
7559
7677
  targetParent,
7560
7678
  historySource,
7561
- doNotPushHistory
7679
+ doNotPushHistory,
7680
+ isHistoryOp
7562
7681
  });
7563
7682
  }
7564
7683
  /**
@@ -7658,7 +7777,8 @@
7658
7777
  * @returns 反向后产生的新 step;目标不存在 / 未应用 / 反向失败时返回 null
7659
7778
  */
7660
7779
  async revertPageStep(index) {
7661
- const entry = this.ctx.history.getStepList("page", this.get("page")?.id)[index];
7780
+ const pageId = this.get("page")?.id;
7781
+ const entry = this.ctx.history.getStepList("page", pageId)[index];
7662
7782
  if (!entry?.applied) return null;
7663
7783
  const { step } = entry;
7664
7784
  if (step.opType === "initial") return null;
@@ -7668,10 +7788,10 @@
7668
7788
  if (!items.length || !items.every((item) => item.changeRecords?.length)) return null;
7669
7789
  }
7670
7790
  let revertedStep = null;
7671
- const captureRevert = (_pageId, s) => {
7672
- revertedStep = s;
7791
+ const captureRevert = (s, type, id) => {
7792
+ if (type === "page" && id === pageId && !revertedStep) revertedStep = s;
7673
7793
  };
7674
- this.ctx.history.once("change", captureRevert);
7794
+ this.ctx.history.on("change", captureRevert);
7675
7795
  const historyDescription = `回滚 #${index + 1}: ${describeStepForRevert(step)}`;
7676
7796
  const opts = {
7677
7797
  doNotSelect: true,
@@ -7981,9 +8101,11 @@
7981
8101
  /**
7982
8102
  * 构造一条页面级「set root」历史记录(不携带选区 / modifiedNodeIds 上下文)并落到该页面自己的栈。
7983
8103
  *
7984
- * 连续 set root 替换:若该页栈最新一条已是**同来源**的 set root 记录({@link StepValue.rootStep} 且 `source` 相同),
7985
- * 则用本次记录**替换**它而非新增,避免源码反复保存 / 外部重设 DSL 时堆积多条 root 记录;
7986
- * 来源不同则照常新增(initial 基线不是 rootStep,不在此列)。
8104
+ * 连续 set root 替换:若该页栈最新一条已是**同来源、同为整页 update**的 set root 记录
8105
+ * ({@link StepValue.rootStep} 且 `source` 相同),则用本次记录**替换**它而非新增,避免源码反复保存时堆积记录。
8106
+ * 替换时必须把 `oldSchema` 追溯到最早那一跳,并沿用原 uuid:否则只剩「上一版 → 本版」,
8107
+ * 撤销到基线时 DSL 会停在中途版本且无法继续回退,已发出的 historyId 也会失效。
8108
+ * 其余情况(来源不同 / 页面增删)照常新增,保留完整变更链条。
7987
8109
  */
7988
8110
  pushPageDiffStep(opType, page, diffItem, source) {
7989
8111
  const step = {
@@ -8003,8 +8125,19 @@
8003
8125
  };
8004
8126
  if (source) step.source = source;
8005
8127
  const top = this.ctx.history.getCurrentPageStep(page.id);
8006
- if (top?.rootStep && top.source === source) this.ctx.history.replaceCurrentStep("page", step, page.id);
8007
- else this.ctx.history.push("page", step, page.id);
8128
+ const earliestOldSchema = top?.diff?.[0]?.oldSchema;
8129
+ if (top?.rootStep && top.source === source && opType === "update" && top.opType === "update" && earliestOldSchema) {
8130
+ this.ctx.history.replaceCurrentStep("page", {
8131
+ ...step,
8132
+ uuid: top.uuid,
8133
+ diff: [{
8134
+ ...diffItem,
8135
+ oldSchema: earliestOldSchema
8136
+ }]
8137
+ }, page.id);
8138
+ return;
8139
+ }
8140
+ this.ctx.history.push("page", step, page.id);
8008
8141
  }
8009
8142
  pushOpHistory(opType, { diff, pageData, historyDescription, source }) {
8010
8143
  const step = {
@@ -8036,8 +8169,8 @@
8036
8169
  * 「重新插回节点」(撤销 remove / 重做 add)需按 step 记录的 parentId / index 精确还原,
8037
8170
  * 不走 this.add,由手工 splice + stage.add 完成后补发等价的 add / change 事件(见 emitHistoryInsertEvents)。
8038
8171
  *
8039
- * 注意:这些路径都会发出 add / remove / update / change 事件,业务侧若需要区分"用户操作"与"撤销重做触发",
8040
- * 请监听 `history-change` 事件配合判断。
8172
+ * 注意:这些路径都会发出 add / remove / update / change 事件,且 `change` 事件带 `isHistoryOp: true`,
8173
+ * 业务侧可据此跳过仅针对「用户主动编辑」的副作用(加锁 / 埋点 / 自动保存等)。
8041
8174
  *
8042
8175
  * @param step 操作记录
8043
8176
  * @param reverse true = 撤销,false = 重做
@@ -8051,6 +8184,7 @@
8051
8184
  doNotSelect: true,
8052
8185
  doNotSwitchPage: true,
8053
8186
  doNotPushHistory: true,
8187
+ [HISTORY_OP]: true,
8054
8188
  historySource: step.source
8055
8189
  };
8056
8190
  switch (step.opType) {
@@ -8134,10 +8268,7 @@
8134
8268
  }
8135
8269
  return cloneDeep(reverse ? oldNode : newNode);
8136
8270
  });
8137
- if (configs.length) await this.update(configs, {
8138
- doNotPushHistory: true,
8139
- historySource: step.source
8140
- });
8271
+ if (configs.length) await this.update(configs, commonOpts);
8141
8272
  break;
8142
8273
  }
8143
8274
  }
@@ -8175,7 +8306,8 @@
8175
8306
  page: this.getPageOfNode(node.id)
8176
8307
  })),
8177
8308
  historySource: source,
8178
- doNotPushHistory: true
8309
+ doNotPushHistory: true,
8310
+ isHistoryOp: true
8179
8311
  });
8180
8312
  }
8181
8313
  /** 经由 reactivity 注入的 toRaw(默认是 Vue 的 toRaw) */
@@ -8322,8 +8454,9 @@
8322
8454
  * 注册一个扩展历史类型,使其可与内置 `page` / `codeBlock` / `dataSource` 一样走统一的
8323
8455
  * {@link push} / {@link undo} / {@link redo}(按 id 分栈、独立 undo/redo)。
8324
8456
  *
8457
+ * 扩展类型与内置类型一样统一派发 `change` 事件,无需(也不支持)单独指定事件名。
8458
+ *
8325
8459
  * @param stepType 自定义历史类型标识(勿与内置类型重名)
8326
- * @param options.event push/undo/redo 后派发的事件名,缺省为 `${stepType}-history-change`
8327
8460
  * @param options.name 历史面板中的展示名称(tab / 分组标题等),缺省回退到 stepType 本身
8328
8461
  */
8329
8462
  registerStepType(stepType, options = {}) {
@@ -8407,11 +8540,20 @@
8407
8540
  const first = this.state.steps[stepType]?.[id]?.getElementList()[0];
8408
8541
  return first?.opType === "initial" ? first : void 0;
8409
8542
  }
8543
+ /**
8544
+ * 目标栈「回到初始」是否可达:容量裁剪删掉已应用的真实步骤后撤销链断开,返回 false。
8545
+ * 与是否存在 {@link getMarker} 基线无关——没有基线的栈同样可能因裁剪回不到加载时的 DSL,
8546
+ * 历史面板的各 tab 统一用它判断初始行是否可高亮 / 可点击。
8547
+ */
8548
+ isInitialReachable(stepType, id) {
8549
+ if (!this.isValidStackId(id)) return true;
8550
+ return this.state.steps[stepType]?.[id]?.isInitialReachable() ?? true;
8551
+ }
8410
8552
  push(stepType, step, id) {
8411
8553
  if (!this.isValidStackId(id)) return null;
8412
8554
  this.fillStepMeta(step);
8413
8555
  getOrCreateStack(this.getStepBucket(stepType), id).pushElement(step);
8414
- this.emit("change", step, stepType, id);
8556
+ this.emitStepChange(step, stepType, id);
8415
8557
  return step;
8416
8558
  }
8417
8559
  undo(stepType, id) {
@@ -8420,7 +8562,7 @@
8420
8562
  if (!undoRedo) return null;
8421
8563
  if (undoRedo.getCursor() <= undoFloor(undoRedo)) return null;
8422
8564
  const step = undoRedo.undo();
8423
- if (step) this.emit("change", step, stepType, id);
8565
+ if (step) this.emitStepChange(step, stepType, id, true);
8424
8566
  return step;
8425
8567
  }
8426
8568
  redo(stepType, id) {
@@ -8428,7 +8570,7 @@
8428
8570
  const undoRedo = this.state.steps[stepType]?.[id];
8429
8571
  if (!undoRedo) return null;
8430
8572
  const step = undoRedo.redo();
8431
- if (step) this.emit("change", step, stepType, id);
8573
+ if (step) this.emitStepChange(step, stepType, id, true);
8432
8574
  return step;
8433
8575
  }
8434
8576
  /**
@@ -8464,7 +8606,7 @@
8464
8606
  const undoRedo = getOrCreateStack(this.getStepBucket(stepType), id);
8465
8607
  this.fillStepMeta(state);
8466
8608
  if (!undoRedo.replaceCurrentElement(state)) return null;
8467
- this.emit("change", state, stepType, id);
8609
+ this.emitStepChange(state, stepType, id);
8468
8610
  return state;
8469
8611
  }
8470
8612
  destroy() {
@@ -8501,6 +8643,9 @@
8501
8643
  *
8502
8644
  * 同一栈内任意时刻最多只有一条记录为 `saved`;从 IndexedDB 恢复时游标会被定位到最近一条已保存记录之后。
8503
8645
  *
8646
+ * 标记后把对应栈裁剪到容量上限({@link markStackSaved} → {@link UndoRedo.trim}):入栈与还原都不裁剪,
8647
+ * 只有保存后才收敛,避免用户在落库前丢掉可撤销的历史;initial 基线与 set root 产生的记录不会被裁掉。
8648
+ *
8504
8649
  * @param stepType 历史类型
8505
8650
  * @param id 目标栈 id;缺省表示标记全部类型 / 全部栈
8506
8651
  */
@@ -8571,6 +8716,10 @@
8571
8716
  }
8572
8717
  /**
8573
8718
  * 用 {@link serialize} 导出的快照重建全部撤销/重做栈,会整体覆盖当前内存中的历史状态。
8719
+ *
8720
+ * 单个栈 / 单个类型的快照损坏只丢弃该部分,其余照常还原;
8721
+ * 快照里的栈全部还原失败时抛出首个错误,此时内存中的历史状态保持不变
8722
+ * (不会把「什么都没恢复」当成一次成功的还原)。
8574
8723
  */
8575
8724
  restore(snapshot) {
8576
8725
  const steps = {
@@ -8578,9 +8727,20 @@
8578
8727
  codeBlock: {},
8579
8728
  dataSource: {}
8580
8729
  };
8730
+ let firstError;
8731
+ let stackCount = 0;
8732
+ let restoredStackCount = 0;
8581
8733
  Object.entries(snapshot.steps).forEach(([stepType, bucket]) => {
8582
- steps[stepType] = deserializeStacks(convertExtraMaps(bucket, true), this.ctx.parseDSL);
8734
+ try {
8735
+ const restored = deserializeStacks(convertExtraMaps(bucket, true), this.ctx.parseDSL);
8736
+ steps[stepType] = restored;
8737
+ restoredStackCount += Object.keys(restored).length;
8738
+ } catch (error) {
8739
+ firstError ??= error;
8740
+ }
8741
+ stackCount += Object.keys(bucket ?? {}).length;
8583
8742
  });
8743
+ if (firstError && stackCount > 0 && restoredStackCount === 0) throw firstError;
8584
8744
  this.state.steps = steps;
8585
8745
  return snapshot;
8586
8746
  }
@@ -8676,6 +8836,16 @@
8676
8836
  return super.emit(eventName, ...args);
8677
8837
  }
8678
8838
  /**
8839
+ * 所有历史类型统一派发 `change`(签名 `(step, stepType, id, isHistoryOp)`);
8840
+ * 代码块 / 数据源额外派发文档约定的同构事件(签名 `(id, step, isHistoryOp)`)。
8841
+ * `isHistoryOp` 仅在 `undo` / `redo` 时为 true,供业务侧跳过历史回放触发的副作用。
8842
+ */
8843
+ emitStepChange(step, stepType, id, isHistoryOp = false) {
8844
+ this.emit("change", step, stepType, id, isHistoryOp);
8845
+ if (stepType === "codeBlock") this.emit("code-block-history-change", id, step, isHistoryOp);
8846
+ else if (stepType === "dataSource") this.emit("data-source-history-change", id, step, isHistoryOp);
8847
+ }
8848
+ /**
8679
8849
  * 取出指定历史类型的栈桶(`Record<id, UndoRedo>`);不存在时按需创建空桶,
8680
8850
  * 从而支持通过 {@link registerStepType} 或首次 push 动态扩展历史类型。
8681
8851
  */