@tmagic/editor 1.8.1 → 1.8.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 +17 -25
- package/dist/es/editorProps.js +3 -0
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/DataSourceFieldSelect/FieldSelect.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceInput.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +1 -1
- package/dist/es/fields/StyleSetter/configs.js +1 -1
- package/dist/es/fields/configs/codeSelect.js +5 -7
- package/dist/es/fields/configs/displayConds.js +8 -9
- package/dist/es/fields/configs/eventSelect.js +30 -27
- package/dist/es/hooks/use-stage.js +18 -18
- package/dist/es/index.js +9 -16
- package/dist/es/initService.js +33 -106
- package/dist/es/layouts/Framework.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/layouts/props-panel/FormPanel.vue_vue_type_script_setup_true_lang.js +8 -6
- package/dist/es/layouts/props-panel/PropsPanel.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/es/layouts/props-panel/use-style-panel.js +1 -1
- package/dist/es/sdk/index.js +151 -0
- package/dist/es/{services → sdk/services}/BaseService.js +1 -1
- package/dist/es/{services/codeBlock.js → sdk/services/CodeBlock.js} +37 -40
- package/dist/es/{services/componentList.js → sdk/services/ComponentList.js} +5 -6
- package/dist/es/{services/dataSource.js → sdk/services/DataSource.js} +38 -37
- package/dist/es/{services/dep.js → sdk/services/Dep.js} +24 -14
- package/dist/es/{services/editor.js → sdk/services/Editor.js} +124 -87
- package/dist/es/{services/events.js → sdk/services/Events.js} +13 -13
- package/dist/es/{services/history.js → sdk/services/History.js} +86 -33
- package/dist/es/{services/props.js → sdk/services/Props.js} +25 -26
- package/dist/es/{services/storage.js → sdk/services/WebStorage.js} +31 -8
- package/dist/es/sdk/utils/dep.js +100 -0
- package/dist/es/sdk/utils/operator.js +70 -0
- package/dist/es/sdk/utils/position.js +8 -0
- package/dist/es/sdk/utils/props.js +281 -0
- package/dist/es/sdk/validate/index.js +286 -0
- package/dist/es/sdk/wiring.js +163 -0
- package/dist/es/sdk.js +15 -0
- package/dist/es/services/keybinding.js +21 -21
- package/dist/es/services/sdk-instance.js +37 -0
- package/dist/es/services/stageOverlay.js +14 -14
- package/dist/es/services/ui.js +6 -6
- package/dist/es/utils/data-source/formConfigs/base.js +1 -1
- package/dist/es/utils/data-source/formConfigs/http.js +1 -1
- package/dist/es/utils/editor.js +2 -2
- package/dist/es/utils/event.js +25 -21
- package/dist/es/utils/operator.js +11 -57
- package/dist/es/utils/props.js +12 -282
- package/dist/es/utils/type-match-rules.js +10 -12
- package/dist/tmagic-editor-headless.umd.cjs +4690 -2891
- package/dist/tmagic-editor-sdk.umd.cjs +9911 -0
- package/dist/tmagic-editor.umd.cjs +14200 -13381
- package/package.json +12 -7
- package/src/Editor.vue +17 -10
- package/src/editorProps.ts +5 -2
- package/src/fields/configs/codeSelect.ts +6 -9
- package/src/fields/configs/displayConds.ts +10 -9
- package/src/fields/configs/eventSelect.ts +40 -25
- package/src/hooks/use-stage.ts +1 -1
- package/src/index.ts +11 -9
- package/src/initService.ts +59 -188
- package/src/layouts/Framework.vue +1 -1
- package/src/layouts/props-panel/FormPanel.vue +8 -5
- package/src/layouts/props-panel/PropsPanel.vue +8 -3
- package/src/layouts/props-panel/use-style-panel.ts +1 -1
- package/src/sdk/index.ts +264 -0
- package/src/{services/codeBlock.ts → sdk/services/CodeBlock.ts} +43 -38
- package/src/{services/componentList.ts → sdk/services/ComponentList.ts} +8 -7
- package/src/{services/dataSource.ts → sdk/services/DataSource.ts} +38 -32
- package/src/{services/dep.ts → sdk/services/Dep.ts} +24 -11
- package/src/{services/editor.ts → sdk/services/Editor.ts} +175 -86
- package/src/{services/events.ts → sdk/services/Events.ts} +15 -12
- package/src/{services/history.ts → sdk/services/History.ts} +100 -28
- package/src/{services/props.ts → sdk/services/Props.ts} +25 -25
- package/src/{services/storage.ts → sdk/services/WebStorage.ts} +41 -7
- package/src/sdk/type.ts +191 -0
- package/src/sdk/utils/dep.ts +196 -0
- package/src/sdk/utils/operator.ts +114 -0
- package/src/sdk/utils/position.ts +23 -0
- package/src/sdk/utils/props.ts +368 -0
- package/src/sdk/validate/index.ts +501 -0
- package/src/sdk/wiring.ts +211 -0
- package/src/sdk.ts +19 -0
- package/src/services/keybinding.ts +2 -2
- package/src/services/sdk-instance.ts +66 -0
- package/src/services/stageOverlay.ts +2 -2
- package/src/services/ui.ts +3 -3
- package/src/type.ts +9 -9
- package/src/utils/data-source/formConfigs/base.ts +1 -1
- package/src/utils/data-source/formConfigs/http.ts +1 -1
- package/src/utils/dep/collect-worker-client.ts +9 -6
- package/src/utils/dep/worker.ts +5 -0
- package/src/utils/editor.ts +2 -1
- package/src/utils/event.ts +36 -18
- package/src/utils/operator.ts +21 -87
- package/src/utils/props.ts +17 -332
- package/src/utils/type-match-rules.ts +1 -3
- package/types/index.d.ts +742 -528
- package/types/sdk.d.ts +2572 -0
- /package/src/{services → sdk/services}/BaseService.ts +0 -0
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import tablePlugin from "@tmagic/table";
|
|
|
3
3
|
import StageCore, { CanDropIn, ContainerHighlightType, CustomizeMoveableOptions, GuidesOptions, RenderType, UpdateDragEl, default as StageCore$1 } from "@tmagic/stage";
|
|
4
4
|
import designPlugin, { ButtonProps, DesignPluginOptions, FieldSize } from "@tmagic/design";
|
|
5
5
|
import Gesto, { OnDrag, OnDrag as OnDrag$1 } from "gesto";
|
|
6
|
-
import { CodeBlockContent, CodeBlockDSL, DataSchema, DataSourceFieldType, DataSourceSchema, DepData, DepExtendedData, DepTargetType, DepTargetType as DepTargetType$1, DisplayCond, EventOption, Id, MApp, MContainer, MNode, MPage, MPageFragment, NodeType, Target, TargetOptions } from "@tmagic/core";
|
|
6
|
+
import { CodeBlockContent, CodeBlockDSL, DataSchema, DataSourceFieldType, DataSourceSchema, DepData, DepExtendedData, DepTargetType, DepTargetType as DepTargetType$1, DisplayCond, EventOption, Id, MApp, MContainer, MNode, MPage, MPageFragment, NodeType, Target, TargetDescriptor, TargetNode, TargetOptions } from "@tmagic/core";
|
|
7
7
|
import { App, AppContext, CSSProperties, Component, ComputedRef, Ref, ShallowRef } from "vue";
|
|
8
8
|
import EventEmitter$1, { EventEmitter } from "events";
|
|
9
9
|
import * as Monaco from "monaco-editor";
|
|
@@ -17,7 +17,22 @@ export * from "@tmagic/table";
|
|
|
17
17
|
export * from "@tmagic/stage";
|
|
18
18
|
export * from "@tmagic/design";
|
|
19
19
|
export * from "@tmagic/utils";
|
|
20
|
-
//#region temp/packages/editor/src/
|
|
20
|
+
//#region temp/packages/editor/src/utils/dep/worker.d.ts
|
|
21
|
+
type DepsData = Record<string, Record<Id, DepData>>;
|
|
22
|
+
interface CollectWorkerResult {
|
|
23
|
+
deps: DepsData;
|
|
24
|
+
nodeIds: Id[];
|
|
25
|
+
}
|
|
26
|
+
interface CollectWorkerPayload {
|
|
27
|
+
/** 待收集的节点 */
|
|
28
|
+
nodes: TargetNode[];
|
|
29
|
+
/** 参与本次收集的 target 描述,worker 中据此重建 target */
|
|
30
|
+
targets: TargetDescriptor[];
|
|
31
|
+
depExtendedData: DepExtendedData;
|
|
32
|
+
deep: boolean;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region temp/packages/editor/src/sdk/services/BaseService.d.ts
|
|
21
36
|
/**
|
|
22
37
|
* 对Class进行扩展
|
|
23
38
|
* 给Class中的每个方法都添加before after两个钩子
|
|
@@ -61,239 +76,10 @@ declare class BaseService extends EventEmitter {
|
|
|
61
76
|
private doTask;
|
|
62
77
|
}
|
|
63
78
|
//#endregion
|
|
64
|
-
//#region temp/packages/editor/src/services/
|
|
65
|
-
declare const canUsePluginMethods$8: {
|
|
66
|
-
async: readonly ["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"];
|
|
67
|
-
sync: string[];
|
|
68
|
-
};
|
|
69
|
-
type AsyncMethodName$4 = Writable<(typeof canUsePluginMethods$8)['async']>;
|
|
70
|
-
declare class CodeBlock extends BaseService {
|
|
71
|
-
private state;
|
|
72
|
-
/**
|
|
73
|
-
* 最近一次写入历史栈的代码块历史记录 uuid(单条写入场景:新增 / 更新)。
|
|
74
|
-
* 供 setCodeDslById(Sync)AndGetHistoryId 取回,普通方法不读取它。
|
|
75
|
-
*/
|
|
76
|
-
private lastPushedHistoryId;
|
|
77
|
-
/**
|
|
78
|
-
* deleteCodeDslByIds 一次删除多个代码块时,按写入顺序收集的历史记录 uuid 列表。
|
|
79
|
-
* 在 deleteCodeDslByIds 入口处重置,供 deleteCodeDslByIdsAndGetHistoryId 取回。
|
|
80
|
-
*/
|
|
81
|
-
private lastDeletedHistoryIds;
|
|
82
|
-
constructor();
|
|
83
|
-
/**
|
|
84
|
-
* 设置活动的代码块dsl数据源
|
|
85
|
-
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
86
|
-
* @returns {void}
|
|
87
|
-
*/
|
|
88
|
-
setCodeDsl(codeDsl: CodeBlockDSL): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* 获取活动的代码块dsl数据源(默认从dsl中的codeBlocks字段读取)
|
|
91
|
-
* 方法要支持钩子添加扩展,会被重写为异步方法,因此这里显示写为异步以提醒调用者需以异步形式调用
|
|
92
|
-
* @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
|
|
93
|
-
* @returns {CodeBlockDSL | null}
|
|
94
|
-
*/
|
|
95
|
-
getCodeDsl(): CodeBlockDSL | null;
|
|
96
|
-
/**
|
|
97
|
-
* 根据代码块id获取代码块内容
|
|
98
|
-
* @param {Id} id 代码块id
|
|
99
|
-
* @returns {CodeBlockContent | null}
|
|
100
|
-
*/
|
|
101
|
-
getCodeContentById(id: Id): CodeBlockContent | null;
|
|
102
|
-
/**
|
|
103
|
-
* 设置代码块ID和代码内容到源dsl
|
|
104
|
-
* @param {Id} id 代码块id
|
|
105
|
-
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
106
|
-
* @param options 可选配置
|
|
107
|
-
* @param options.changeRecords form 端 propPath/value 列表,用于历史记录的精细化撤销/重做
|
|
108
|
-
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
109
|
-
* @returns {void}
|
|
110
|
-
*/
|
|
111
|
-
setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* 为了兼容历史原因
|
|
114
|
-
* 设置代码块ID和代码内容到源dsl
|
|
115
|
-
* @param {Id} id 代码块id
|
|
116
|
-
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
117
|
-
* @param {boolean} force 是否强制写入,默认true
|
|
118
|
-
* @param options 可选配置
|
|
119
|
-
* @param options.changeRecords form 端 propPath/value 列表,用于历史记录的精细化撤销/重做
|
|
120
|
-
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
121
|
-
* @param options.historyDescription 入栈时附带的人类可读描述,用于历史面板展示
|
|
122
|
-
* @returns {void}
|
|
123
|
-
*/
|
|
124
|
-
setCodeDslByIdSync(id: Id, codeConfig: Partial<CodeBlockContent>, force?: boolean, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): void;
|
|
125
|
-
/**
|
|
126
|
-
* 根据代码块id数组获取代码dsl
|
|
127
|
-
* @param {string[]} ids 代码块id数组
|
|
128
|
-
* @returns {CodeBlockDSL}
|
|
129
|
-
*/
|
|
130
|
-
getCodeDslByIds(ids: string[]): CodeBlockDSL;
|
|
131
|
-
/**
|
|
132
|
-
* 获取编辑状态
|
|
133
|
-
* @returns {boolean} 是否可编辑
|
|
134
|
-
*/
|
|
135
|
-
getEditStatus(): boolean;
|
|
136
|
-
/**
|
|
137
|
-
* 设置编辑状态
|
|
138
|
-
* @param {boolean} status 是否可编辑
|
|
139
|
-
* @returns {void}
|
|
140
|
-
*/
|
|
141
|
-
setEditStatus(status: boolean): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* 设置当前选中组件已关联绑定的代码块id数组
|
|
144
|
-
* @param {string[]} ids 代码块id数组
|
|
145
|
-
* @returns {void}
|
|
146
|
-
*/
|
|
147
|
-
setCombineIds(ids: string[]): Promise<void>;
|
|
148
|
-
/**
|
|
149
|
-
* 获取当前选中组件已关联绑定的代码块id数组
|
|
150
|
-
* @returns {string[]}
|
|
151
|
-
*/
|
|
152
|
-
getCombineIds(): string[];
|
|
153
|
-
/**
|
|
154
|
-
* 获取不可删除列表
|
|
155
|
-
* @returns {Id[]}
|
|
156
|
-
*/
|
|
157
|
-
getUndeletableList(): Id[];
|
|
158
|
-
/**
|
|
159
|
-
* 设置不可删除列表:为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除)
|
|
160
|
-
* @param {Id[]} codeIds 代码块id数组
|
|
161
|
-
* @returns {void}
|
|
162
|
-
*/
|
|
163
|
-
setUndeleteableList(codeIds: Id[]): Promise<void>;
|
|
164
|
-
/**
|
|
165
|
-
* 设置代码草稿
|
|
166
|
-
*/
|
|
167
|
-
setCodeDraft(codeId: Id, content: string): void;
|
|
168
|
-
/**
|
|
169
|
-
* 获取代码草稿
|
|
170
|
-
*/
|
|
171
|
-
getCodeDraft(codeId: Id): string | null;
|
|
172
|
-
/**
|
|
173
|
-
* 删除代码草稿
|
|
174
|
-
*/
|
|
175
|
-
removeCodeDraft(codeId: Id): void;
|
|
176
|
-
/**
|
|
177
|
-
* 在dsl数据源中删除指定id的代码块
|
|
178
|
-
* @param {Id[]} codeIds 需要删除的代码块id数组
|
|
179
|
-
* @param options 可选配置
|
|
180
|
-
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
181
|
-
*/
|
|
182
|
-
deleteCodeDslByIds(codeIds: Id[], { doNotPushHistory, historyDescription, historySource }?: HistoryOpOptions): Promise<void>;
|
|
183
|
-
/**
|
|
184
|
-
* 下列 *AndGetHistoryId 方法与对应的写入方法行为完全一致,
|
|
185
|
-
* 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入的历史 uuid 列表,
|
|
186
|
-
* 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
|
|
187
|
-
*
|
|
188
|
-
* 当本次操作未写入历史(doNotPushHistory 为 true、或无对应记录)时 historyIds 为 `[]`。
|
|
189
|
-
*/
|
|
190
|
-
/** 等价于 {@link setCodeDslById},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
191
|
-
setCodeDslByIdAndGetHistoryId(id: Id, codeConfig: Partial<CodeBlockContent>, options?: HistoryOpOptionsWithChangeRecords): Promise<DslOpWithHistoryIdsResult<void>>;
|
|
192
|
-
/** 等价于 {@link setCodeDslByIdSync},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
193
|
-
setCodeDslByIdSyncAndGetHistoryId(id: Id, codeConfig: Partial<CodeBlockContent>, force?: boolean, options?: HistoryOpOptionsWithChangeRecords): DslOpWithHistoryIdsResult<void>;
|
|
194
|
-
/**
|
|
195
|
-
* 等价于 {@link deleteCodeDslByIds},并额外返回本次写入的全部历史记录 uuid(按删除顺序)。
|
|
196
|
-
* 一次删除多个代码块会产生多条历史记录;未写入任何历史时 historyIds 为 `[]`。
|
|
197
|
-
*/
|
|
198
|
-
deleteCodeDslByIdsAndGetHistoryId(codeIds: Id[], options?: HistoryOpOptions): Promise<DslOpWithHistoryIdsResult<void>>;
|
|
199
|
-
setParamsColConfig(config: TableColumnConfig): void;
|
|
200
|
-
getParamsColConfig(): TableColumnConfig | undefined;
|
|
201
|
-
/**
|
|
202
|
-
* 撤销指定代码块的最近一次变更。
|
|
203
|
-
*
|
|
204
|
-
* 内部走 setCodeDslByIdSync / deleteCodeDslByIds,因此会自动触发 codeBlockService 的
|
|
205
|
-
* `addOrUpdate` / `remove` 事件,由 initService 中的 handler 重新维护 dep target
|
|
206
|
-
* (DepTargetType.CODE_BLOCK 的 add / remove)。所有写回都带 `doNotPushHistory: true`,
|
|
207
|
-
* 确保不会在历史栈里产生新的记录。
|
|
208
|
-
*
|
|
209
|
-
* @param id 代码块 id
|
|
210
|
-
* @returns 撤销的 step;栈不存在或已无可撤销时返回 null
|
|
211
|
-
*/
|
|
212
|
-
undo(id: Id): Promise<CodeBlockStepValue | null>;
|
|
213
|
-
/**
|
|
214
|
-
* 重做指定代码块的下一次变更。
|
|
215
|
-
* @param id 代码块 id
|
|
216
|
-
* @returns 重做的 step;栈不存在或已无可重做时返回 null
|
|
217
|
-
*/
|
|
218
|
-
redo(id: Id): Promise<CodeBlockStepValue | null>;
|
|
219
|
-
/** 是否可对指定代码块撤销。 */
|
|
220
|
-
canUndo(id: Id): boolean;
|
|
221
|
-
/** 是否可对指定代码块重做。 */
|
|
222
|
-
canRedo(id: Id): boolean;
|
|
223
|
-
/**
|
|
224
|
-
* 跳转指定代码块的历史栈到目标游标。语义同 editor.gotoPageStep。
|
|
225
|
-
*
|
|
226
|
-
* @param id 代码块 id
|
|
227
|
-
* @param targetCursor 目标游标位置(已应用步骤数量)
|
|
228
|
-
* @returns 实际移动到的最终游标位置
|
|
229
|
-
*/
|
|
230
|
-
goto(id: Id, targetCursor: number): Promise<number>;
|
|
231
|
-
/**
|
|
232
|
-
* 「回滚」指定代码块历史步骤(类 git revert 语义):
|
|
233
|
-
* - 不动原始栈结构(不移动 cursor、不丢弃任何步骤);
|
|
234
|
-
* - 把目标 step 的修改**反向应用**一次,并作为**新步骤**追加到栈顶;
|
|
235
|
-
* - 仅对已应用的步骤生效。
|
|
236
|
-
*
|
|
237
|
-
* @param id 代码块 id
|
|
238
|
-
* @param index 目标 step 在该栈中的索引(0 为最早),通常由历史面板传入
|
|
239
|
-
* @returns 反向后产生的新 step;目标不存在 / 未应用时返回 null
|
|
240
|
-
*/
|
|
241
|
-
revert(id: Id, index: number): Promise<CodeBlockStepValue | null>;
|
|
242
|
-
/**
|
|
243
|
-
* 通过历史记录 uuid 回滚代码块历史步骤,语义同 {@link revert},
|
|
244
|
-
* 仅无需调用方再传 codeBlockId 与 index:内部会按 uuid 在全部代码块栈中定位对应步骤后再回滚。
|
|
245
|
-
* 按数组顺序依次回滚,返回与入参同序的结果列表(某项失败时为 `null`)。
|
|
246
|
-
*
|
|
247
|
-
* @param uuids 目标历史记录的 uuid 列表,通常由 {@link setCodeDslByIdAndGetHistoryId} 等方法返回的 `historyIds`
|
|
248
|
-
*/
|
|
249
|
-
revertById(uuids: string[]): Promise<(CodeBlockStepValue | null)[]>;
|
|
250
|
-
/**
|
|
251
|
-
* 生成代码块唯一id
|
|
252
|
-
* @returns {Id} 代码块唯一id
|
|
253
|
-
*/
|
|
254
|
-
getUniqueId(): Promise<string>;
|
|
255
|
-
/**
|
|
256
|
-
* 复制时会带上组件关联的代码块
|
|
257
|
-
* @param config 组件节点配置
|
|
258
|
-
* @returns
|
|
259
|
-
*/
|
|
260
|
-
copyWithRelated(config: MNode | MNode[], collectorOptions?: TargetOptions): void;
|
|
261
|
-
/**
|
|
262
|
-
* 粘贴代码块
|
|
263
|
-
* @returns
|
|
264
|
-
*/
|
|
265
|
-
paste(): void;
|
|
266
|
-
resetState(): void;
|
|
267
|
-
destroy(): void;
|
|
268
|
-
usePlugin(options: AsyncHookPlugin<AsyncMethodName$4, CodeBlock>): void;
|
|
269
|
-
/**
|
|
270
|
-
* 反向应用一个 step 并以新 step 入栈。逻辑与 applyHistoryStep(reverse=true) 同构,
|
|
271
|
-
* 差异仅在于通过公开的 setCodeDslByIdSync / deleteCodeDslByIds 触发 push。
|
|
272
|
-
*/
|
|
273
|
-
private applyRevertStep;
|
|
274
|
-
/**
|
|
275
|
-
* 把一条历史 step 应用到当前代码块服务上。
|
|
276
|
-
*
|
|
277
|
-
* 复用现有的 setCodeDslByIdSync / deleteCodeDslByIds,目的是借助它们发出的事件
|
|
278
|
-
* 触发 initService 中的 dep target 维护(CODE_BLOCK 的 add / remove)。
|
|
279
|
-
* 所有写回都带 `doNotPushHistory: true`,确保不会在历史栈里产生新的记录。
|
|
280
|
-
*
|
|
281
|
-
* - oldContent=null, newContent≠null:原始为新增 → undo 删除;redo 再次 setCodeDslByIdSync
|
|
282
|
-
* - oldContent≠null, newContent=null:原始为删除 → undo 还原写入;redo 再次删除
|
|
283
|
-
* - 两侧都有:原始为更新 → 按 changeRecords 局部 patch;缺省退化为整内容替换
|
|
284
|
-
*
|
|
285
|
-
* @param step 历史 step
|
|
286
|
-
* @param reverse true=撤销,false=重做
|
|
287
|
-
*/
|
|
288
|
-
private applyHistoryStep;
|
|
289
|
-
}
|
|
290
|
-
type CodeBlockService = CodeBlock;
|
|
291
|
-
declare const _default$40: CodeBlock;
|
|
292
|
-
//#endregion
|
|
293
|
-
//#region temp/packages/editor/src/services/componentList.d.ts
|
|
79
|
+
//#region temp/packages/editor/src/sdk/services/ComponentList.d.ts
|
|
294
80
|
declare class ComponentList extends BaseService {
|
|
295
81
|
private state;
|
|
296
|
-
constructor();
|
|
82
|
+
constructor(ctx: SdkContext);
|
|
297
83
|
/**
|
|
298
84
|
* @param componentGroupList 组件列表配置
|
|
299
85
|
*/
|
|
@@ -303,9 +89,8 @@ declare class ComponentList extends BaseService {
|
|
|
303
89
|
destroy(): void;
|
|
304
90
|
}
|
|
305
91
|
type ComponentListService = ComponentList;
|
|
306
|
-
declare const _default$41: ComponentList;
|
|
307
92
|
//#endregion
|
|
308
|
-
//#region temp/packages/editor/src/services/
|
|
93
|
+
//#region temp/packages/editor/src/sdk/services/DataSource.d.ts
|
|
309
94
|
interface State$2 {
|
|
310
95
|
datasourceTypeList: DatasourceTypeOption[];
|
|
311
96
|
dataSources: DataSourceSchema[];
|
|
@@ -316,12 +101,13 @@ interface State$2 {
|
|
|
316
101
|
methods: Record<string, EventOption[]>;
|
|
317
102
|
}
|
|
318
103
|
type StateKey$1 = keyof State$2;
|
|
319
|
-
declare const canUsePluginMethods$
|
|
104
|
+
declare const canUsePluginMethods$8: {
|
|
320
105
|
async: never[];
|
|
321
106
|
sync: readonly ["getFormConfig", "setFormConfig", "getFormValue", "setFormValue", "getFormEvent", "setFormEvent", "getFormMethod", "setFormMethod", "add", "update", "remove", "createId"];
|
|
322
107
|
};
|
|
323
|
-
type SyncMethodName$5 = Writable<(typeof canUsePluginMethods$
|
|
108
|
+
type SyncMethodName$5 = Writable<(typeof canUsePluginMethods$8)['sync']>;
|
|
324
109
|
declare class DataSource extends BaseService {
|
|
110
|
+
private ctx;
|
|
325
111
|
private state;
|
|
326
112
|
/**
|
|
327
113
|
* 最近一次写入历史栈的数据源历史记录 uuid。
|
|
@@ -329,7 +115,7 @@ declare class DataSource extends BaseService {
|
|
|
329
115
|
* 普通方法不读取它,调用前由 *AndGetHistoryId 重置为 null。
|
|
330
116
|
*/
|
|
331
117
|
private lastPushedHistoryId;
|
|
332
|
-
constructor();
|
|
118
|
+
constructor(ctx: SdkContext);
|
|
333
119
|
set<K extends StateKey$1, T extends State$2[K]>(name: K, value: T): void;
|
|
334
120
|
get<K extends StateKey$1>(name: K): State$2[K];
|
|
335
121
|
getFormConfig(type?: string): FormConfig;
|
|
@@ -474,12 +260,8 @@ declare class DataSource extends BaseService {
|
|
|
474
260
|
private applyHistoryStep;
|
|
475
261
|
}
|
|
476
262
|
type DataSourceService = DataSource;
|
|
477
|
-
declare const _default$42: DataSource;
|
|
478
|
-
//#endregion
|
|
479
|
-
//#region temp/packages/editor/src/utils/dep/worker.d.ts
|
|
480
|
-
type DepsData = Record<string, Record<Id, DepData>>;
|
|
481
263
|
//#endregion
|
|
482
|
-
//#region temp/packages/editor/src/services/
|
|
264
|
+
//#region temp/packages/editor/src/sdk/services/Dep.d.ts
|
|
483
265
|
interface DepEvents {
|
|
484
266
|
'add-target': [target: Target];
|
|
485
267
|
'remove-target': [id: string | number, type: string | DepTargetType$1];
|
|
@@ -492,6 +274,7 @@ interface State$1 {
|
|
|
492
274
|
}
|
|
493
275
|
type StateKey = keyof State$1;
|
|
494
276
|
declare class Dep extends BaseService {
|
|
277
|
+
private ctx;
|
|
495
278
|
private state;
|
|
496
279
|
private idleTask;
|
|
497
280
|
private collectWorker;
|
|
@@ -500,7 +283,7 @@ declare class Dep extends BaseService {
|
|
|
500
283
|
private resolveWaitingWorker?;
|
|
501
284
|
private workerGeneration;
|
|
502
285
|
private activeBatches;
|
|
503
|
-
constructor();
|
|
286
|
+
constructor(ctx: SdkContext);
|
|
504
287
|
set<K extends StateKey, T extends State$1[K]>(name: K, value: T): void;
|
|
505
288
|
get<K extends StateKey>(name: K): State$1[K];
|
|
506
289
|
removeTargets(type?: string): void;
|
|
@@ -562,10 +345,14 @@ declare class Dep extends BaseService {
|
|
|
562
345
|
private updateCollectingState;
|
|
563
346
|
}
|
|
564
347
|
type DepService = Dep;
|
|
565
|
-
declare const _default$44: Dep;
|
|
566
348
|
//#endregion
|
|
567
|
-
//#region temp/packages/editor/src/services/
|
|
349
|
+
//#region temp/packages/editor/src/sdk/services/Editor.d.ts
|
|
350
|
+
interface EditorServiceConfig {
|
|
351
|
+
disabledPageFragment?: boolean;
|
|
352
|
+
canDropIn?: CanDropInFunction;
|
|
353
|
+
}
|
|
568
354
|
declare class Editor extends BaseService {
|
|
355
|
+
private ctx;
|
|
569
356
|
state: StoreState;
|
|
570
357
|
private selectionBeforeOp;
|
|
571
358
|
/**
|
|
@@ -584,7 +371,9 @@ declare class Editor extends BaseService {
|
|
|
584
371
|
* 仅在选中节点未变化时复用(连续 add / doNotSelect / 批量粘贴),选中变化后自动失效,无需手动清理。
|
|
585
372
|
*/
|
|
586
373
|
private lastAdded;
|
|
587
|
-
|
|
374
|
+
/** 与编辑器 props 中 `disabledPageFragment` / `canDropIn` 对应,供结构合法性校验使用 */
|
|
375
|
+
private config;
|
|
376
|
+
constructor(ctx: SdkContext);
|
|
588
377
|
/**
|
|
589
378
|
* 设置当前指点节点配置
|
|
590
379
|
* @param name 'root' | 'page' | 'parent' | 'node' | 'highlightNode' | 'nodes' | 'stage' | 'modifiedNodeIds' | 'invalidNodeIds' | 'pageLength' | 'pageFragmentLength
|
|
@@ -652,6 +441,9 @@ declare class Editor extends BaseService {
|
|
|
652
441
|
*/
|
|
653
442
|
multiSelect(ids: Id[]): void;
|
|
654
443
|
selectRoot(): void;
|
|
444
|
+
/** 设置结构合法性校验用到的配置,只覆盖传入的字段 */
|
|
445
|
+
setConfig(config: Partial<EditorServiceConfig>): void;
|
|
446
|
+
getConfig(): Readonly<EditorServiceConfig>;
|
|
655
447
|
doAdd(node: MNode, parent: MContainer, _options?: DslOpOptions): Promise<MNode>;
|
|
656
448
|
/**
|
|
657
449
|
* 向指点容器添加组件节点
|
|
@@ -863,6 +655,11 @@ declare class Editor extends BaseService {
|
|
|
863
655
|
* 供 `change` 事件携带「变更节点对应的 page」(而非编辑器当前选中页)。
|
|
864
656
|
*/
|
|
865
657
|
private getPageOfNode;
|
|
658
|
+
/**
|
|
659
|
+
* 执行校验。校验不通过(strict 抛错)时操作不会继续,必须清掉 captureSelectionBeforeOp 留下的快照,
|
|
660
|
+
* 否则下一次成功的操作会沿用这份过期快照,写出错误的 selectedBefore / invalidNodeIdsBefore。
|
|
661
|
+
*/
|
|
662
|
+
private runGuard;
|
|
866
663
|
private captureSelectionBeforeOp;
|
|
867
664
|
/**
|
|
868
665
|
* 比较「上一次 root」与「新 root」的页面 / 页面片,按页面粒度把整体替换拆成历史记录:
|
|
@@ -904,19 +701,22 @@ declare class Editor extends BaseService {
|
|
|
904
701
|
* 这里补齐与 this.add 等价的 add / change 事件,保证撤销/重做路径的事件行为与正向操作一致。
|
|
905
702
|
*/
|
|
906
703
|
private emitHistoryInsertEvents;
|
|
704
|
+
/** 经由 reactivity 注入的 toRaw(默认是 Vue 的 toRaw) */
|
|
705
|
+
private toRaw;
|
|
907
706
|
}
|
|
908
707
|
type EditorService = Editor;
|
|
909
|
-
declare const _default$45: Editor;
|
|
910
708
|
//#endregion
|
|
911
|
-
//#region temp/packages/editor/src/services/
|
|
912
|
-
declare const canUsePluginMethods$
|
|
709
|
+
//#region temp/packages/editor/src/sdk/services/Events.d.ts
|
|
710
|
+
declare const canUsePluginMethods$7: {
|
|
913
711
|
async: readonly [];
|
|
914
712
|
sync: readonly ["setEvent", "getEvent", "setMethod", "getMethod"];
|
|
915
713
|
};
|
|
916
|
-
type AsyncMethodName$
|
|
917
|
-
type SyncMethodName$4 = Writable<(typeof canUsePluginMethods$
|
|
714
|
+
type AsyncMethodName$4 = Writable<(typeof canUsePluginMethods$7)['async']>;
|
|
715
|
+
type SyncMethodName$4 = Writable<(typeof canUsePluginMethods$7)['sync']>;
|
|
918
716
|
declare class Events extends BaseService {
|
|
919
|
-
|
|
717
|
+
private eventMap;
|
|
718
|
+
private methodMap;
|
|
719
|
+
constructor(ctx: SdkContext);
|
|
920
720
|
setEvents(events: Record<string, EventOption[]>): void;
|
|
921
721
|
setEvent(type: string, events: EventOption[]): void;
|
|
922
722
|
getEvent(type: string, _data?: {
|
|
@@ -930,96 +730,19 @@ declare class Events extends BaseService {
|
|
|
930
730
|
}): EventOption[];
|
|
931
731
|
resetState(): void;
|
|
932
732
|
destroy(): void;
|
|
933
|
-
usePlugin(options: AsyncHookPlugin<AsyncMethodName$
|
|
733
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName$4, Events> & SyncHookPlugin<SyncMethodName$4, Events>): void;
|
|
934
734
|
}
|
|
935
735
|
type EventsService = Events;
|
|
936
|
-
declare const _default$46: Events;
|
|
937
736
|
//#endregion
|
|
938
|
-
//#region temp/packages/editor/src/
|
|
939
|
-
|
|
940
|
-
* UndoRedo 栈的可序列化快照,用于持久化(如写入 IndexedDB)后再还原。
|
|
941
|
-
*/
|
|
942
|
-
export interface SerializedUndoRedo<T = any> {
|
|
943
|
-
/** 栈内全部元素(按时间正序,索引 0 为最早一步)。 */
|
|
944
|
-
elementList: T[];
|
|
945
|
-
/** 游标位置(已应用步骤数量)。 */
|
|
946
|
-
listCursor: number;
|
|
947
|
-
/** 栈容量上限。 */
|
|
948
|
-
listMaxSize: number;
|
|
949
|
-
}
|
|
950
|
-
export declare class UndoRedo<T = any> {
|
|
951
|
-
/**
|
|
952
|
-
* 由 {@link UndoRedo.serialize} 产出的快照重建一个 UndoRedo 实例。
|
|
953
|
-
* 游标会被夹紧到 [0, length] 区间,避免脏数据导致越界。
|
|
954
|
-
*
|
|
955
|
-
* @param options.isSavedStep 可选谓词:若提供,则把游标定位到「最近一条满足该谓词的记录」之后
|
|
956
|
-
* (即恢复到最近一个已保存点);找不到匹配记录时退回快照中的原游标。
|
|
957
|
-
*/
|
|
958
|
-
static fromSerialized<T = any>(data: SerializedUndoRedo<T>, options?: {
|
|
959
|
-
isSavedStep?: (element: T) => boolean;
|
|
960
|
-
}): UndoRedo<T>;
|
|
961
|
-
private elementList;
|
|
962
|
-
private listCursor;
|
|
963
|
-
private listMaxSize;
|
|
964
|
-
constructor(listMaxSize?: number);
|
|
965
|
-
/**
|
|
966
|
-
* 导出当前栈的可序列化快照(深克隆,避免外部改动污染内部状态)。
|
|
967
|
-
* 配合 {@link UndoRedo.fromSerialized} 可在持久化后完整还原撤销/重做栈。
|
|
968
|
-
*/
|
|
969
|
-
serialize(): SerializedUndoRedo<T>;
|
|
970
|
-
pushElement(element: T): void;
|
|
971
|
-
canUndo(): boolean;
|
|
972
|
-
/** 返回被撤销的操作 */
|
|
973
|
-
undo(): T | null;
|
|
974
|
-
canRedo(): boolean;
|
|
975
|
-
/** 返回被重做的操作 */
|
|
976
|
-
redo(): T | null;
|
|
977
|
-
getCurrentElement(): T | null;
|
|
978
|
-
/**
|
|
979
|
-
* 用 `element` 替换当前游标所在元素(cursor - 1),并丢弃其后的重做尾部(与 {@link pushElement} 的丢尾一致),
|
|
980
|
-
* 游标位置保持不变(元素数量不增)。cursor 为 0(无已应用元素)时不做任何操作并返回 false。
|
|
981
|
-
* 用于「连续同类记录合并」等就地替换最新一条的场景。
|
|
982
|
-
*/
|
|
983
|
-
replaceCurrentElement(element: T): boolean;
|
|
984
|
-
/**
|
|
985
|
-
* 对当前游标所在元素(cursor - 1)做就地更新;cursor 为 0(全部已撤销)时不做任何操作。
|
|
986
|
-
* 用于给「当前步骤」打标记(如标记为已保存)等元数据写入场景。
|
|
987
|
-
*/
|
|
988
|
-
updateCurrentElement(updater: (element: T) => void): void;
|
|
989
|
-
/** 对栈内全部元素做就地更新。用于批量清理元数据(如清空所有元素的已保存标记)。 */
|
|
990
|
-
updateElements(updater: (element: T, index: number) => void): void;
|
|
991
|
-
/**
|
|
992
|
-
* 返回栈内全部元素的浅克隆数组(按时间顺序,索引 0 为最早一步)。
|
|
993
|
-
* 仅用于历史面板等只读展示场景,不应直接修改返回值。
|
|
994
|
-
*/
|
|
995
|
-
getElementList(): T[];
|
|
996
|
-
/**
|
|
997
|
-
* 当前游标位置:表示已应用的步骤数量。
|
|
998
|
-
* - cursor === 0 表示全部已撤销
|
|
999
|
-
* - cursor === length 表示已重做到末尾
|
|
1000
|
-
* 历史面板用于区分"已应用 / 已撤销"两段。
|
|
1001
|
-
*/
|
|
1002
|
-
getCursor(): number;
|
|
1003
|
-
/** 栈内总步数。 */
|
|
1004
|
-
getLength(): number;
|
|
1005
|
-
}
|
|
1006
|
-
//#endregion
|
|
1007
|
-
//#region temp/packages/editor/src/services/history.d.ts
|
|
1008
|
-
declare const canUsePluginMethods$5: {
|
|
737
|
+
//#region temp/packages/editor/src/sdk/services/History.d.ts
|
|
738
|
+
declare const canUsePluginMethods$6: {
|
|
1009
739
|
sync: readonly ["push", "undo", "redo"];
|
|
1010
740
|
};
|
|
1011
|
-
type SyncMethodName$3 = Writable<(typeof canUsePluginMethods$
|
|
741
|
+
type SyncMethodName$3 = Writable<(typeof canUsePluginMethods$6)['sync']>;
|
|
1012
742
|
declare class History extends BaseService {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
page: Record<Id, UndoRedo<StepValue>>;
|
|
1017
|
-
codeBlock: Record<Id, UndoRedo<CodeBlockStepValue>>;
|
|
1018
|
-
dataSource: Record<Id, UndoRedo<DataSourceStepValue>>;
|
|
1019
|
-
};
|
|
1020
|
-
stepNames: Record<string, string>;
|
|
1021
|
-
};
|
|
1022
|
-
constructor();
|
|
743
|
+
private ctx;
|
|
744
|
+
state: HistoryState;
|
|
745
|
+
constructor(ctx: SdkContext);
|
|
1023
746
|
/**
|
|
1024
747
|
* 注册一个扩展历史类型,使其可与内置 `page` / `codeBlock` / `dataSource` 一样走统一的
|
|
1025
748
|
* {@link push} / {@link undo} / {@link redo}(按 id 分栈、独立 undo/redo)。
|
|
@@ -1175,6 +898,17 @@ declare class History extends BaseService {
|
|
|
1175
898
|
* - 不支持 IndexedDB 的环境(如 SSR)会 reject。
|
|
1176
899
|
*/
|
|
1177
900
|
saveToIndexedDB(options?: HistoryPersistOptions): Promise<PersistedHistoryState>;
|
|
901
|
+
/**
|
|
902
|
+
* 把当前内存中的全部历史栈导出成可持久化的快照(纯同步,不依赖 IndexedDB),
|
|
903
|
+
* 可用于无状态调用:下次通过 {@link restore} 或 `createDslSdk({ history })` 还原。
|
|
904
|
+
*/
|
|
905
|
+
serialize({ jsonSafe }?: {
|
|
906
|
+
jsonSafe?: boolean;
|
|
907
|
+
}): PersistedHistoryState;
|
|
908
|
+
/**
|
|
909
|
+
* 用 {@link serialize} 导出的快照重建全部撤销/重做栈,会整体覆盖当前内存中的历史状态。
|
|
910
|
+
*/
|
|
911
|
+
restore(snapshot: PersistedHistoryState): PersistedHistoryState;
|
|
1178
912
|
/**
|
|
1179
913
|
* 从本地 IndexedDB 读取此前保存的历史快照并重建全部撤销/重做栈。
|
|
1180
914
|
*
|
|
@@ -1258,14 +992,561 @@ declare class History extends BaseService {
|
|
|
1258
992
|
private isValidStackId;
|
|
1259
993
|
/** 清空全部历史栈内容(保留已注册的类型键,使扩展类型在 reset 后仍可用)。 */
|
|
1260
994
|
private clearAllSteps;
|
|
995
|
+
private getPersistence;
|
|
1261
996
|
/**
|
|
1262
997
|
* 把基础 dbName 与当前 DSL(root app)的 id 拼成最终库名,实现不同应用历史隔离。
|
|
1263
998
|
* 取不到 app id(如尚未加载 DSL)时退回基础 dbName。
|
|
1264
999
|
*/
|
|
1265
|
-
private resolveDbName;
|
|
1000
|
+
private resolveDbName;
|
|
1001
|
+
}
|
|
1002
|
+
type HistoryService = History;
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region temp/packages/editor/src/sdk/services/Props.d.ts
|
|
1005
|
+
declare const canUsePluginMethods$5: {
|
|
1006
|
+
async: readonly ["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "fillConfig", "getDefaultPropsValue"];
|
|
1007
|
+
sync: readonly ["createId", "setNewItemId"];
|
|
1008
|
+
};
|
|
1009
|
+
type AsyncMethodName$3 = Writable<(typeof canUsePluginMethods$5)['async']>;
|
|
1010
|
+
type SyncMethodName$2 = Writable<(typeof canUsePluginMethods$5)['sync']>;
|
|
1011
|
+
declare class Props extends BaseService {
|
|
1012
|
+
private ctx;
|
|
1013
|
+
private state;
|
|
1014
|
+
constructor(ctx: SdkContext);
|
|
1015
|
+
setDisabledDataSource(disabled: boolean): void;
|
|
1016
|
+
setDisabledCodeBlock(disabled: boolean): void;
|
|
1017
|
+
getDisabledDataSource(): boolean;
|
|
1018
|
+
getDisabledCodeBlock(): boolean;
|
|
1019
|
+
/** 批量设置组件属性表单配置,返回的 Promise 在全部配置处理完(含异步的)后 resolve */
|
|
1020
|
+
setPropsConfigs(configs: Record<string, FormConfig | PropsFormConfigFunction>): Promise<void>;
|
|
1021
|
+
getPropsConfigs(): Record<string, FormConfig>;
|
|
1022
|
+
fillConfig(config: FormConfig, labelWidth?: string): Promise<FormConfig>;
|
|
1023
|
+
setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction): Promise<void>;
|
|
1024
|
+
/**
|
|
1025
|
+
* 获取指点类型的组件属性表单配置
|
|
1026
|
+
* @param type 组件类型
|
|
1027
|
+
* @returns 组件属性表单配置
|
|
1028
|
+
*/
|
|
1029
|
+
getPropsConfig(type: string, data?: {
|
|
1030
|
+
node?: MNode | null;
|
|
1031
|
+
}): Promise<FormConfig>;
|
|
1032
|
+
hasPropsConfig(type: string): boolean;
|
|
1033
|
+
setPropsValues(values: Record<string, Partial<MNode> | PropsFormValueFunction>): Promise<void[]>;
|
|
1034
|
+
getPropsValues(): Record<string, Partial<MNode>>;
|
|
1035
|
+
/**
|
|
1036
|
+
* 为指点类型组件设置组件初始值
|
|
1037
|
+
* @param type 组件类型
|
|
1038
|
+
* @param value 组件初始值
|
|
1039
|
+
*/
|
|
1040
|
+
setPropsValue(type: string, value: Partial<MNode> | PropsFormValueFunction): Promise<void>;
|
|
1041
|
+
/**
|
|
1042
|
+
* 获取指定类型的组件初始值
|
|
1043
|
+
* @param type 组件类型
|
|
1044
|
+
* @returns 组件初始值
|
|
1045
|
+
*/
|
|
1046
|
+
getPropsValue(componentType: string, { inputEvent, ...defaultValue }?: Record<string, any>): Promise<any>;
|
|
1047
|
+
hasPropsValue(type: string): boolean;
|
|
1048
|
+
createId(type: string | number): string;
|
|
1049
|
+
/**
|
|
1050
|
+
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
1051
|
+
* 如果没有相同ID并且force为false则保持不变
|
|
1052
|
+
* @param {Object} config 组件配置
|
|
1053
|
+
* @param {Boolean} force 是否强制设置新的ID
|
|
1054
|
+
*/
|
|
1055
|
+
setNewItemId(config: MNode, force?: boolean): MNode;
|
|
1056
|
+
/**
|
|
1057
|
+
* 获取默认属性配置
|
|
1058
|
+
* @param type 组件类型
|
|
1059
|
+
* @returns Object
|
|
1060
|
+
*/
|
|
1061
|
+
getDefaultPropsValue(type: string): {
|
|
1062
|
+
type: string;
|
|
1063
|
+
layout: string;
|
|
1064
|
+
style: {};
|
|
1065
|
+
name: string;
|
|
1066
|
+
items: never[];
|
|
1067
|
+
} | {
|
|
1068
|
+
type: string;
|
|
1069
|
+
style: {};
|
|
1070
|
+
name: string;
|
|
1071
|
+
layout?: undefined;
|
|
1072
|
+
items?: undefined;
|
|
1073
|
+
};
|
|
1074
|
+
resetState(): void;
|
|
1075
|
+
/**
|
|
1076
|
+
* 替换关联ID
|
|
1077
|
+
* @param originConfigs 原组件配置
|
|
1078
|
+
* @param targetConfigs 待替换的组件配置
|
|
1079
|
+
*/
|
|
1080
|
+
replaceRelateId(originConfigs: MNode[], targetConfigs: MNode[], collectorOptions: TargetOptions): void;
|
|
1081
|
+
/**
|
|
1082
|
+
* 清除setNewItemId前后映射关系
|
|
1083
|
+
*/
|
|
1084
|
+
clearRelateId(): void;
|
|
1085
|
+
destroy(): void;
|
|
1086
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName$3, Props> & SyncHookPlugin<SyncMethodName$2, Props>): void;
|
|
1087
|
+
/**
|
|
1088
|
+
* 获取setNewItemId前后映射关系
|
|
1089
|
+
* @param oldId 原组件ID
|
|
1090
|
+
* @returns 新旧ID映射
|
|
1091
|
+
*/
|
|
1092
|
+
private getRelateIdMap;
|
|
1093
|
+
/**
|
|
1094
|
+
* 记录setNewItemId前后映射关系
|
|
1095
|
+
* @param oldId 原组件ID
|
|
1096
|
+
* @param newId 分配的新ID
|
|
1097
|
+
*/
|
|
1098
|
+
private setRelateId;
|
|
1099
|
+
}
|
|
1100
|
+
type PropsService = Props;
|
|
1101
|
+
//#endregion
|
|
1102
|
+
//#region temp/packages/editor/src/sdk/services/WebStorage.d.ts
|
|
1103
|
+
interface Options$1 {
|
|
1104
|
+
namespace?: string;
|
|
1105
|
+
protocol?: Protocol;
|
|
1106
|
+
}
|
|
1107
|
+
declare enum Protocol {
|
|
1108
|
+
OBJECT = "object",
|
|
1109
|
+
JSON = "json",
|
|
1110
|
+
STRING = "string",
|
|
1111
|
+
NUMBER = "number",
|
|
1112
|
+
BOOLEAN = "boolean"
|
|
1113
|
+
}
|
|
1114
|
+
declare const canUsePluginMethods$4: {
|
|
1115
|
+
async: never[];
|
|
1116
|
+
sync: readonly ["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"];
|
|
1117
|
+
};
|
|
1118
|
+
type SyncMethodName$1 = Writable<(typeof canUsePluginMethods$4)['sync']>;
|
|
1119
|
+
/**
|
|
1120
|
+
* 数据存储服务
|
|
1121
|
+
*/
|
|
1122
|
+
declare class WebStorage extends BaseService {
|
|
1123
|
+
private ctx;
|
|
1124
|
+
private storage;
|
|
1125
|
+
private namespace;
|
|
1126
|
+
constructor(ctx: SdkContext, storage?: StorageLike);
|
|
1127
|
+
/**
|
|
1128
|
+
* 获取数据存储对象,可以通过
|
|
1129
|
+
* const storageService = new StorageService();
|
|
1130
|
+
* storageService.usePlugin({
|
|
1131
|
+
* // 替换存储对象为 sessionStorage
|
|
1132
|
+
* async afterGetStorage(): Promise<StorageLike> {
|
|
1133
|
+
* return window.sessionStorage;
|
|
1134
|
+
* },
|
|
1135
|
+
* });
|
|
1136
|
+
*/
|
|
1137
|
+
getStorage(): StorageLike;
|
|
1138
|
+
getNamespace(): string;
|
|
1139
|
+
/**
|
|
1140
|
+
* 清理,支持storageService.usePlugin
|
|
1141
|
+
*/
|
|
1142
|
+
clear(): void;
|
|
1143
|
+
/**
|
|
1144
|
+
* 获取存储项,支持storageService.usePlugin
|
|
1145
|
+
*/
|
|
1146
|
+
getItem(key: string, options?: Options$1): any;
|
|
1147
|
+
/**
|
|
1148
|
+
* 获取指定索引位置的key
|
|
1149
|
+
*/
|
|
1150
|
+
key(index: number): string | null;
|
|
1151
|
+
/**
|
|
1152
|
+
* 移除存储项,支持storageService.usePlugin
|
|
1153
|
+
*/
|
|
1154
|
+
removeItem(key: string, options?: Options$1): void;
|
|
1155
|
+
/**
|
|
1156
|
+
* 设置存储项,支持storageService.usePlugin
|
|
1157
|
+
*/
|
|
1158
|
+
setItem(key: string, value: any, options?: Options$1): void;
|
|
1159
|
+
destroy(): void;
|
|
1160
|
+
usePlugin(options: SyncHookPlugin<SyncMethodName$1, WebStorage>): void;
|
|
1161
|
+
private getValueAndProtocol;
|
|
1162
|
+
}
|
|
1163
|
+
type StorageService = WebStorage;
|
|
1164
|
+
//#endregion
|
|
1165
|
+
//#region temp/packages/editor/src/sdk/validate/index.d.ts
|
|
1166
|
+
/**
|
|
1167
|
+
* `record` 模式下,校验结果要等到修改落进 DSL 之后再写入 `invalidNodeIds`(修改过程中会先清掉旧记录),
|
|
1168
|
+
* 因此 guard 返回一个提交函数交给调用方在合适的时机调用;`strict` 抛错,`off` 返回空。
|
|
1169
|
+
*/
|
|
1170
|
+
type GuardCommit = (() => void) | undefined;
|
|
1171
|
+
interface Validator {
|
|
1172
|
+
/** 校验 DSL 中已有节点:结构(类型 / 父子关系)+ 属性表单 */
|
|
1173
|
+
node(id: Id): Promise<DslValidationResult>;
|
|
1174
|
+
/** 校验 DSL 中已有的数据源 */
|
|
1175
|
+
dataSource(id: Id): Promise<DslValidationResult>;
|
|
1176
|
+
/** 校验整份 DSL */
|
|
1177
|
+
dsl(): Promise<DslValidationResult>;
|
|
1178
|
+
/** 校验一个节点配置的属性表单(不要求它已经在 DSL 中) */
|
|
1179
|
+
checkNodeProps(node: MNode): Promise<DslValidationIssue[]>;
|
|
1180
|
+
/** 同步的结构校验:新增 */
|
|
1181
|
+
checkAddStructure(node: MNode, parent: MContainer | null | undefined): DslValidationIssue[];
|
|
1182
|
+
/** 同步的结构校验:移动 */
|
|
1183
|
+
checkMoveStructure(sourceIds: Id[], target: MContainer, scene: CanDropInScene): DslValidationIssue[];
|
|
1184
|
+
/** 同步的结构校验:数据源配置 */
|
|
1185
|
+
checkDataSourceStructure(config: DataSourceSchema, isNew: boolean): DslValidationIssue[];
|
|
1186
|
+
/** 供 service 在修改前调用:按 `validateMode` 抛出 / 记录 / 忽略。 */
|
|
1187
|
+
guardAdd(items: {
|
|
1188
|
+
node: MNode;
|
|
1189
|
+
parentNode: MContainer;
|
|
1190
|
+
}[]): Promise<GuardCommit>;
|
|
1191
|
+
/** `replace` 与 `editor.update` 的同名选项一致:为 true 时整节点替换,否则与旧节点深合并 */
|
|
1192
|
+
guardUpdate(nodes: MNode[], options?: {
|
|
1193
|
+
replace?: boolean;
|
|
1194
|
+
}): Promise<GuardCommit>;
|
|
1195
|
+
guardMove(sourceIds: Id[], target: MContainer, scene: CanDropInScene): Promise<void>;
|
|
1196
|
+
guardDataSource(config: DataSourceSchema, isNew: boolean): void;
|
|
1197
|
+
}
|
|
1198
|
+
//#endregion
|
|
1199
|
+
//#region temp/packages/editor/src/sdk/type.d.ts
|
|
1200
|
+
/**
|
|
1201
|
+
* 响应式实现,默认直接使用 Vue 的 `reactive` / `shallowReactive` / `toRaw` / `nextTick`;
|
|
1202
|
+
* 可通过 `SdkOptions.reactivity` 覆盖。
|
|
1203
|
+
*/
|
|
1204
|
+
interface Reactivity {
|
|
1205
|
+
reactive: <T extends object>(target: T) => T;
|
|
1206
|
+
shallowReactive: <T extends object>(target: T) => T;
|
|
1207
|
+
toRaw: <T>(value: T) => T;
|
|
1208
|
+
nextTick: () => Promise<void>;
|
|
1209
|
+
}
|
|
1210
|
+
/** 存储适配器接口,`localStorage` 天然满足 */
|
|
1211
|
+
interface StorageLike {
|
|
1212
|
+
readonly length: number;
|
|
1213
|
+
clear(): void;
|
|
1214
|
+
getItem(key: string): string | null;
|
|
1215
|
+
key(index: number): string | null;
|
|
1216
|
+
removeItem(key: string): void;
|
|
1217
|
+
setItem(key: string, value: string): void;
|
|
1218
|
+
}
|
|
1219
|
+
/** 历史快照的持久化适配器(浏览器端对应 IndexedDB)。不提供则 `saveToIndexedDB` / `restoreFromIndexedDB` 会 reject */
|
|
1220
|
+
interface HistoryPersistence {
|
|
1221
|
+
get<T = unknown>(dbName: string, storeName: string, key: IDBValidKey): Promise<T | undefined>;
|
|
1222
|
+
set(dbName: string, storeName: string, key: IDBValidKey, value: unknown): Promise<void>;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* 依赖收集 worker 适配器。浏览器端注入基于 Web Worker 的实现,Node 下不提供,
|
|
1226
|
+
* 依赖收集会退回主线程的空闲队列(`IdleTask`,Node 下由 setTimeout 驱动)。
|
|
1227
|
+
*/
|
|
1228
|
+
interface CollectWorkerLike {
|
|
1229
|
+
readonly isSupported: boolean;
|
|
1230
|
+
collectDsl(dsl: MApp): Promise<DepsData | null>;
|
|
1231
|
+
collect(payload: CollectWorkerPayload): Promise<CollectWorkerResult | null>;
|
|
1232
|
+
terminate(): void;
|
|
1233
|
+
abort(): void;
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* 校验模式
|
|
1237
|
+
* - `strict`:修改前校验,不通过抛出 {@link DslValidationError},DSL 不被修改
|
|
1238
|
+
* - `record`:只把校验结果写进 `invalidNodeIds`
|
|
1239
|
+
* - `off`:不做额外校验
|
|
1240
|
+
*/
|
|
1241
|
+
type ValidateMode = 'strict' | 'record' | 'off';
|
|
1242
|
+
interface DslValidationIssue {
|
|
1243
|
+
/** 出错对象类型 */
|
|
1244
|
+
target: 'node' | 'data-source' | 'code-block' | 'dsl';
|
|
1245
|
+
/** 出错对象 id */
|
|
1246
|
+
id?: Id;
|
|
1247
|
+
/** 出错属性路径,结构性错误时为空 */
|
|
1248
|
+
path?: string;
|
|
1249
|
+
/** 错误分类:structure 为结构合法性,props 为属性表单校验 */
|
|
1250
|
+
kind: 'structure' | 'props';
|
|
1251
|
+
message: string;
|
|
1252
|
+
/** 可选的修正建议(如可选值列表) */
|
|
1253
|
+
suggestion?: string;
|
|
1254
|
+
}
|
|
1255
|
+
interface DslValidationResult {
|
|
1256
|
+
valid: boolean;
|
|
1257
|
+
errors: DslValidationIssue[];
|
|
1258
|
+
}
|
|
1259
|
+
interface SdkOptions {
|
|
1260
|
+
/** 初始 DSL,会被深拷贝,不会修改传入的对象 */
|
|
1261
|
+
dsl?: MApp | null;
|
|
1262
|
+
/** 此前通过 `history.serialize()` 导出的历史快照 */
|
|
1263
|
+
history?: PersistedHistoryState | null;
|
|
1264
|
+
reactivity?: Partial<Reactivity>;
|
|
1265
|
+
/** 存储适配器,默认内存实现 */
|
|
1266
|
+
storage?: StorageLike;
|
|
1267
|
+
/** 把序列化后的字符串还原成值(含函数),默认 `JSON.parse`;浏览器端传入 `eval` 实现 */
|
|
1268
|
+
parseDSL?: (code: string) => any;
|
|
1269
|
+
historyPersistence?: HistoryPersistence;
|
|
1270
|
+
collectWorker?: CollectWorkerLike;
|
|
1271
|
+
/** 提示信息,默认不做任何事 */
|
|
1272
|
+
notify?: (type: 'success' | 'error' | 'warning' | 'info', message: string) => void;
|
|
1273
|
+
/** 复制文本到剪贴板,默认不做任何事 */
|
|
1274
|
+
copyText?: (text: string) => Promise<void> | void;
|
|
1275
|
+
/** 校验模式,默认 `strict` */
|
|
1276
|
+
validateMode?: ValidateMode;
|
|
1277
|
+
/** 是否自动绑定依赖收集连线,默认 true;浏览器默认实例传 false,由 initService 挂载时绑定 */
|
|
1278
|
+
autoWiring?: boolean;
|
|
1279
|
+
componentGroupList?: ComponentGroup[];
|
|
1280
|
+
propsConfigs?: Record<string, FormConfig | PropsFormConfigFunction>;
|
|
1281
|
+
propsValues?: Record<string, Partial<MNode> | PropsFormValueFunction>;
|
|
1282
|
+
eventMethodList?: Record<string, {
|
|
1283
|
+
events: EventOption[];
|
|
1284
|
+
methods: EventOption[];
|
|
1285
|
+
}>;
|
|
1286
|
+
datasourceList?: DatasourceTypeOption[];
|
|
1287
|
+
datasourceConfigs?: Record<string, FormConfig>;
|
|
1288
|
+
datasourceValues?: Record<string, Partial<DataSourceSchema>>;
|
|
1289
|
+
datasourceEventMethodList?: Record<string, {
|
|
1290
|
+
events: EventOption[];
|
|
1291
|
+
methods: EventOption[];
|
|
1292
|
+
}>;
|
|
1293
|
+
disabledCodeBlock?: boolean;
|
|
1294
|
+
disabledDataSource?: boolean;
|
|
1295
|
+
disabledPageFragment?: boolean;
|
|
1296
|
+
disabledMultiSelect?: boolean;
|
|
1297
|
+
alwaysMultiSelect?: boolean;
|
|
1298
|
+
canDropIn?: CanDropInFunction;
|
|
1299
|
+
}
|
|
1300
|
+
/** service 之间互相访问的上下文,用懒 getter 解开循环依赖 */
|
|
1301
|
+
interface SdkContext {
|
|
1302
|
+
readonly reactivity: Reactivity;
|
|
1303
|
+
readonly storage: WebStorage;
|
|
1304
|
+
readonly editor: Editor;
|
|
1305
|
+
readonly props: Props;
|
|
1306
|
+
readonly history: History;
|
|
1307
|
+
readonly dataSource: DataSource;
|
|
1308
|
+
readonly codeBlock: CodeBlock;
|
|
1309
|
+
readonly dep: Dep;
|
|
1310
|
+
readonly events: Events;
|
|
1311
|
+
readonly componentList: ComponentList;
|
|
1312
|
+
readonly options: Readonly<SdkOptions>;
|
|
1313
|
+
/** 校验模式,可在运行时通过 `sdk.ctx.validateMode = ...` 切换 */
|
|
1314
|
+
validateMode: ValidateMode;
|
|
1315
|
+
/** 校验器,`createDslSdk` 之后可用 */
|
|
1316
|
+
validator: Validator;
|
|
1317
|
+
/** 登记表全部就绪后 resolve */
|
|
1318
|
+
ready: Promise<void>;
|
|
1319
|
+
parseDSL: (code: string) => any;
|
|
1320
|
+
}
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region temp/packages/editor/src/sdk/services/CodeBlock.d.ts
|
|
1323
|
+
declare const canUsePluginMethods$3: {
|
|
1324
|
+
async: readonly ["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"];
|
|
1325
|
+
sync: string[];
|
|
1326
|
+
};
|
|
1327
|
+
type AsyncMethodName$2 = Writable<(typeof canUsePluginMethods$3)['async']>;
|
|
1328
|
+
declare class CodeBlock extends BaseService {
|
|
1329
|
+
private ctx;
|
|
1330
|
+
private state;
|
|
1331
|
+
/**
|
|
1332
|
+
* 最近一次写入历史栈的代码块历史记录 uuid(单条写入场景:新增 / 更新)。
|
|
1333
|
+
* 供 setCodeDslById(Sync)AndGetHistoryId 取回,普通方法不读取它。
|
|
1334
|
+
*/
|
|
1335
|
+
private lastPushedHistoryId;
|
|
1336
|
+
/**
|
|
1337
|
+
* deleteCodeDslByIds 一次删除多个代码块时,按写入顺序收集的历史记录 uuid 列表。
|
|
1338
|
+
* 在 deleteCodeDslByIds 入口处重置,供 deleteCodeDslByIdsAndGetHistoryId 取回。
|
|
1339
|
+
*/
|
|
1340
|
+
private lastDeletedHistoryIds;
|
|
1341
|
+
constructor(ctx: SdkContext);
|
|
1342
|
+
/**
|
|
1343
|
+
* 设置活动的代码块dsl数据源
|
|
1344
|
+
* @param {CodeBlockDSL} codeDsl 代码DSL
|
|
1345
|
+
* @returns {void}
|
|
1346
|
+
*/
|
|
1347
|
+
setCodeDsl(codeDsl: CodeBlockDSL): Promise<void>;
|
|
1348
|
+
/**
|
|
1349
|
+
* 获取活动的代码块dsl数据源(默认从dsl中的codeBlocks字段读取)
|
|
1350
|
+
* 方法要支持钩子添加扩展,会被重写为异步方法,因此这里显示写为异步以提醒调用者需以异步形式调用
|
|
1351
|
+
* @param {boolean} forceRefresh 是否强制从活动dsl拉取刷新
|
|
1352
|
+
* @returns {CodeBlockDSL | null}
|
|
1353
|
+
*/
|
|
1354
|
+
getCodeDsl(): CodeBlockDSL | null;
|
|
1355
|
+
/**
|
|
1356
|
+
* 根据代码块id获取代码块内容
|
|
1357
|
+
* @param {Id} id 代码块id
|
|
1358
|
+
* @returns {CodeBlockContent | null}
|
|
1359
|
+
*/
|
|
1360
|
+
getCodeContentById(id: Id): CodeBlockContent | null;
|
|
1361
|
+
/**
|
|
1362
|
+
* 设置代码块ID和代码内容到源dsl
|
|
1363
|
+
* @param {Id} id 代码块id
|
|
1364
|
+
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
1365
|
+
* @param options 可选配置
|
|
1366
|
+
* @param options.changeRecords form 端 propPath/value 列表,用于历史记录的精细化撤销/重做
|
|
1367
|
+
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
1368
|
+
* @returns {void}
|
|
1369
|
+
*/
|
|
1370
|
+
setCodeDslById(id: Id, codeConfig: Partial<CodeBlockContent>, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): Promise<void>;
|
|
1371
|
+
/**
|
|
1372
|
+
* 为了兼容历史原因
|
|
1373
|
+
* 设置代码块ID和代码内容到源dsl
|
|
1374
|
+
* @param {Id} id 代码块id
|
|
1375
|
+
* @param {CodeBlockContent} codeConfig 代码块内容配置信息
|
|
1376
|
+
* @param {boolean} force 是否强制写入,默认true
|
|
1377
|
+
* @param options 可选配置
|
|
1378
|
+
* @param options.changeRecords form 端 propPath/value 列表,用于历史记录的精细化撤销/重做
|
|
1379
|
+
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
1380
|
+
* @param options.historyDescription 入栈时附带的人类可读描述,用于历史面板展示
|
|
1381
|
+
* @returns {void}
|
|
1382
|
+
*/
|
|
1383
|
+
setCodeDslByIdSync(id: Id, codeConfig: Partial<CodeBlockContent>, force?: boolean, { changeRecords, doNotPushHistory, historyDescription, historySource }?: HistoryOpOptionsWithChangeRecords): void;
|
|
1384
|
+
/**
|
|
1385
|
+
* 根据代码块id数组获取代码dsl
|
|
1386
|
+
* @param {string[]} ids 代码块id数组
|
|
1387
|
+
* @returns {CodeBlockDSL}
|
|
1388
|
+
*/
|
|
1389
|
+
getCodeDslByIds(ids: string[]): CodeBlockDSL;
|
|
1390
|
+
/**
|
|
1391
|
+
* 获取编辑状态
|
|
1392
|
+
* @returns {boolean} 是否可编辑
|
|
1393
|
+
*/
|
|
1394
|
+
getEditStatus(): boolean;
|
|
1395
|
+
/**
|
|
1396
|
+
* 设置编辑状态
|
|
1397
|
+
* @param {boolean} status 是否可编辑
|
|
1398
|
+
* @returns {void}
|
|
1399
|
+
*/
|
|
1400
|
+
setEditStatus(status: boolean): Promise<void>;
|
|
1401
|
+
/**
|
|
1402
|
+
* 设置当前选中组件已关联绑定的代码块id数组
|
|
1403
|
+
* @param {string[]} ids 代码块id数组
|
|
1404
|
+
* @returns {void}
|
|
1405
|
+
*/
|
|
1406
|
+
setCombineIds(ids: string[]): Promise<void>;
|
|
1407
|
+
/**
|
|
1408
|
+
* 获取当前选中组件已关联绑定的代码块id数组
|
|
1409
|
+
* @returns {string[]}
|
|
1410
|
+
*/
|
|
1411
|
+
getCombineIds(): string[];
|
|
1412
|
+
/**
|
|
1413
|
+
* 获取不可删除列表
|
|
1414
|
+
* @returns {Id[]}
|
|
1415
|
+
*/
|
|
1416
|
+
getUndeletableList(): Id[];
|
|
1417
|
+
/**
|
|
1418
|
+
* 设置不可删除列表:为业务逻辑预留的不可删除的代码块列表,由业务逻辑维护(如代码块上线后不可删除)
|
|
1419
|
+
* @param {Id[]} codeIds 代码块id数组
|
|
1420
|
+
* @returns {void}
|
|
1421
|
+
*/
|
|
1422
|
+
setUndeleteableList(codeIds: Id[]): Promise<void>;
|
|
1423
|
+
/**
|
|
1424
|
+
* 设置代码草稿
|
|
1425
|
+
*/
|
|
1426
|
+
setCodeDraft(codeId: Id, content: string): void;
|
|
1427
|
+
/**
|
|
1428
|
+
* 获取代码草稿
|
|
1429
|
+
*/
|
|
1430
|
+
getCodeDraft(codeId: Id): string | null;
|
|
1431
|
+
/**
|
|
1432
|
+
* 删除代码草稿
|
|
1433
|
+
*/
|
|
1434
|
+
removeCodeDraft(codeId: Id): void;
|
|
1435
|
+
/**
|
|
1436
|
+
* 在dsl数据源中删除指定id的代码块
|
|
1437
|
+
* @param {Id[]} codeIds 需要删除的代码块id数组
|
|
1438
|
+
* @param options 可选配置
|
|
1439
|
+
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
1440
|
+
*/
|
|
1441
|
+
deleteCodeDslByIds(codeIds: Id[], { doNotPushHistory, historyDescription, historySource }?: HistoryOpOptions): Promise<void>;
|
|
1442
|
+
/**
|
|
1443
|
+
* 下列 *AndGetHistoryId 方法与对应的写入方法行为完全一致,
|
|
1444
|
+
* 返回值在 {@link DslOpWithHistoryIdsResult} 中同时包含原操作结果与本次写入的历史 uuid 列表,
|
|
1445
|
+
* 可用于精确引用 / 定位该条历史记录(埋点、revert、跨端同步等)。
|
|
1446
|
+
*
|
|
1447
|
+
* 当本次操作未写入历史(doNotPushHistory 为 true、或无对应记录)时 historyIds 为 `[]`。
|
|
1448
|
+
*/
|
|
1449
|
+
/** 等价于 {@link setCodeDslById},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
1450
|
+
setCodeDslByIdAndGetHistoryId(id: Id, codeConfig: Partial<CodeBlockContent>, options?: HistoryOpOptionsWithChangeRecords): Promise<DslOpWithHistoryIdsResult<void>>;
|
|
1451
|
+
/** 等价于 {@link setCodeDslByIdSync},并额外返回本次写入历史记录的 uuid 列表(未入栈时 historyIds 为 `[]`)。 */
|
|
1452
|
+
setCodeDslByIdSyncAndGetHistoryId(id: Id, codeConfig: Partial<CodeBlockContent>, force?: boolean, options?: HistoryOpOptionsWithChangeRecords): DslOpWithHistoryIdsResult<void>;
|
|
1453
|
+
/**
|
|
1454
|
+
* 等价于 {@link deleteCodeDslByIds},并额外返回本次写入的全部历史记录 uuid(按删除顺序)。
|
|
1455
|
+
* 一次删除多个代码块会产生多条历史记录;未写入任何历史时 historyIds 为 `[]`。
|
|
1456
|
+
*/
|
|
1457
|
+
deleteCodeDslByIdsAndGetHistoryId(codeIds: Id[], options?: HistoryOpOptions): Promise<DslOpWithHistoryIdsResult<void>>;
|
|
1458
|
+
setParamsColConfig(config: TableColumnConfig): void;
|
|
1459
|
+
getParamsColConfig(): TableColumnConfig | undefined;
|
|
1460
|
+
/**
|
|
1461
|
+
* 撤销指定代码块的最近一次变更。
|
|
1462
|
+
*
|
|
1463
|
+
* 内部走 setCodeDslByIdSync / deleteCodeDslByIds,因此会自动触发 codeBlockService 的
|
|
1464
|
+
* `addOrUpdate` / `remove` 事件,由 initService 中的 handler 重新维护 dep target
|
|
1465
|
+
* (DepTargetType.CODE_BLOCK 的 add / remove)。所有写回都带 `doNotPushHistory: true`,
|
|
1466
|
+
* 确保不会在历史栈里产生新的记录。
|
|
1467
|
+
*
|
|
1468
|
+
* @param id 代码块 id
|
|
1469
|
+
* @returns 撤销的 step;栈不存在或已无可撤销时返回 null
|
|
1470
|
+
*/
|
|
1471
|
+
undo(id: Id): Promise<CodeBlockStepValue | null>;
|
|
1472
|
+
/**
|
|
1473
|
+
* 重做指定代码块的下一次变更。
|
|
1474
|
+
* @param id 代码块 id
|
|
1475
|
+
* @returns 重做的 step;栈不存在或已无可重做时返回 null
|
|
1476
|
+
*/
|
|
1477
|
+
redo(id: Id): Promise<CodeBlockStepValue | null>;
|
|
1478
|
+
/** 是否可对指定代码块撤销。 */
|
|
1479
|
+
canUndo(id: Id): boolean;
|
|
1480
|
+
/** 是否可对指定代码块重做。 */
|
|
1481
|
+
canRedo(id: Id): boolean;
|
|
1482
|
+
/**
|
|
1483
|
+
* 跳转指定代码块的历史栈到目标游标。语义同 editor.gotoPageStep。
|
|
1484
|
+
*
|
|
1485
|
+
* @param id 代码块 id
|
|
1486
|
+
* @param targetCursor 目标游标位置(已应用步骤数量)
|
|
1487
|
+
* @returns 实际移动到的最终游标位置
|
|
1488
|
+
*/
|
|
1489
|
+
goto(id: Id, targetCursor: number): Promise<number>;
|
|
1490
|
+
/**
|
|
1491
|
+
* 「回滚」指定代码块历史步骤(类 git revert 语义):
|
|
1492
|
+
* - 不动原始栈结构(不移动 cursor、不丢弃任何步骤);
|
|
1493
|
+
* - 把目标 step 的修改**反向应用**一次,并作为**新步骤**追加到栈顶;
|
|
1494
|
+
* - 仅对已应用的步骤生效。
|
|
1495
|
+
*
|
|
1496
|
+
* @param id 代码块 id
|
|
1497
|
+
* @param index 目标 step 在该栈中的索引(0 为最早),通常由历史面板传入
|
|
1498
|
+
* @returns 反向后产生的新 step;目标不存在 / 未应用时返回 null
|
|
1499
|
+
*/
|
|
1500
|
+
revert(id: Id, index: number): Promise<CodeBlockStepValue | null>;
|
|
1501
|
+
/**
|
|
1502
|
+
* 通过历史记录 uuid 回滚代码块历史步骤,语义同 {@link revert},
|
|
1503
|
+
* 仅无需调用方再传 codeBlockId 与 index:内部会按 uuid 在全部代码块栈中定位对应步骤后再回滚。
|
|
1504
|
+
* 按数组顺序依次回滚,返回与入参同序的结果列表(某项失败时为 `null`)。
|
|
1505
|
+
*
|
|
1506
|
+
* @param uuids 目标历史记录的 uuid 列表,通常由 {@link setCodeDslByIdAndGetHistoryId} 等方法返回的 `historyIds`
|
|
1507
|
+
*/
|
|
1508
|
+
revertById(uuids: string[]): Promise<(CodeBlockStepValue | null)[]>;
|
|
1509
|
+
/**
|
|
1510
|
+
* 生成代码块唯一id
|
|
1511
|
+
* @returns {Id} 代码块唯一id
|
|
1512
|
+
*/
|
|
1513
|
+
getUniqueId(): Promise<string>;
|
|
1514
|
+
/**
|
|
1515
|
+
* 复制时会带上组件关联的代码块
|
|
1516
|
+
* @param config 组件节点配置
|
|
1517
|
+
* @returns
|
|
1518
|
+
*/
|
|
1519
|
+
copyWithRelated(config: MNode | MNode[], collectorOptions?: TargetOptions): void;
|
|
1520
|
+
/**
|
|
1521
|
+
* 粘贴代码块
|
|
1522
|
+
* @returns
|
|
1523
|
+
*/
|
|
1524
|
+
paste(): void;
|
|
1525
|
+
resetState(): void;
|
|
1526
|
+
destroy(): void;
|
|
1527
|
+
usePlugin(options: AsyncHookPlugin<AsyncMethodName$2, CodeBlock>): void;
|
|
1528
|
+
/**
|
|
1529
|
+
* 反向应用一个 step 并以新 step 入栈。逻辑与 applyHistoryStep(reverse=true) 同构,
|
|
1530
|
+
* 差异仅在于通过公开的 setCodeDslByIdSync / deleteCodeDslByIds 触发 push。
|
|
1531
|
+
*/
|
|
1532
|
+
private applyRevertStep;
|
|
1533
|
+
/**
|
|
1534
|
+
* 把一条历史 step 应用到当前代码块服务上。
|
|
1535
|
+
*
|
|
1536
|
+
* 复用现有的 setCodeDslByIdSync / deleteCodeDslByIds,目的是借助它们发出的事件
|
|
1537
|
+
* 触发 initService 中的 dep target 维护(CODE_BLOCK 的 add / remove)。
|
|
1538
|
+
* 所有写回都带 `doNotPushHistory: true`,确保不会在历史栈里产生新的记录。
|
|
1539
|
+
*
|
|
1540
|
+
* - oldContent=null, newContent≠null:原始为新增 → undo 删除;redo 再次 setCodeDslByIdSync
|
|
1541
|
+
* - oldContent≠null, newContent=null:原始为删除 → undo 还原写入;redo 再次删除
|
|
1542
|
+
* - 两侧都有:原始为更新 → 按 changeRecords 局部 patch;缺省退化为整内容替换
|
|
1543
|
+
*
|
|
1544
|
+
* @param step 历史 step
|
|
1545
|
+
* @param reverse true=撤销,false=重做
|
|
1546
|
+
*/
|
|
1547
|
+
private applyHistoryStep;
|
|
1266
1548
|
}
|
|
1267
|
-
type
|
|
1268
|
-
declare const _default$47: History;
|
|
1549
|
+
type CodeBlockService = CodeBlock;
|
|
1269
1550
|
//#endregion
|
|
1270
1551
|
//#region temp/packages/editor/src/services/keybinding.d.ts
|
|
1271
1552
|
declare class Keybinding extends BaseService {
|
|
@@ -1304,111 +1585,14 @@ declare class Keybinding extends BaseService {
|
|
|
1304
1585
|
private getKeyconKeys;
|
|
1305
1586
|
}
|
|
1306
1587
|
type KeybindingService = Keybinding;
|
|
1307
|
-
declare const _default$
|
|
1308
|
-
//#endregion
|
|
1309
|
-
//#region temp/packages/editor/src/services/props.d.ts
|
|
1310
|
-
declare const canUsePluginMethods$4: {
|
|
1311
|
-
async: readonly ["setPropsConfig", "getPropsConfig", "setPropsValue", "getPropsValue", "fillConfig", "getDefaultPropsValue"];
|
|
1312
|
-
sync: readonly ["createId", "setNewItemId"];
|
|
1313
|
-
};
|
|
1314
|
-
type AsyncMethodName$2 = Writable<(typeof canUsePluginMethods$4)['async']>;
|
|
1315
|
-
type SyncMethodName$2 = Writable<(typeof canUsePluginMethods$4)['sync']>;
|
|
1316
|
-
declare class Props extends BaseService {
|
|
1317
|
-
private state;
|
|
1318
|
-
constructor();
|
|
1319
|
-
setDisabledDataSource(disabled: boolean): void;
|
|
1320
|
-
setDisabledCodeBlock(disabled: boolean): void;
|
|
1321
|
-
getDisabledDataSource(): boolean;
|
|
1322
|
-
getDisabledCodeBlock(): boolean;
|
|
1323
|
-
setPropsConfigs(configs: Record<string, FormConfig | PropsFormConfigFunction>): void;
|
|
1324
|
-
getPropsConfigs(): Record<string, FormConfig>;
|
|
1325
|
-
fillConfig(config: FormConfig, labelWidth?: string): Promise<FormConfig>;
|
|
1326
|
-
setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction): Promise<void>;
|
|
1327
|
-
/**
|
|
1328
|
-
* 获取指点类型的组件属性表单配置
|
|
1329
|
-
* @param type 组件类型
|
|
1330
|
-
* @returns 组件属性表单配置
|
|
1331
|
-
*/
|
|
1332
|
-
getPropsConfig(type: string, data?: {
|
|
1333
|
-
node?: MNode | null;
|
|
1334
|
-
}): Promise<FormConfig>;
|
|
1335
|
-
hasPropsConfig(type: string): boolean;
|
|
1336
|
-
setPropsValues(values: Record<string, Partial<MNode> | PropsFormValueFunction>): void;
|
|
1337
|
-
getPropsValues(): Record<string, Partial<MNode>>;
|
|
1338
|
-
/**
|
|
1339
|
-
* 为指点类型组件设置组件初始值
|
|
1340
|
-
* @param type 组件类型
|
|
1341
|
-
* @param value 组件初始值
|
|
1342
|
-
*/
|
|
1343
|
-
setPropsValue(type: string, value: Partial<MNode> | PropsFormValueFunction): Promise<void>;
|
|
1344
|
-
/**
|
|
1345
|
-
* 获取指定类型的组件初始值
|
|
1346
|
-
* @param type 组件类型
|
|
1347
|
-
* @returns 组件初始值
|
|
1348
|
-
*/
|
|
1349
|
-
getPropsValue(componentType: string, { inputEvent, ...defaultValue }?: Record<string, any>): Promise<any>;
|
|
1350
|
-
hasPropsValue(type: string): boolean;
|
|
1351
|
-
createId(type: string | number): string;
|
|
1352
|
-
/**
|
|
1353
|
-
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
|
1354
|
-
* 如果没有相同ID并且force为false则保持不变
|
|
1355
|
-
* @param {Object} config 组件配置
|
|
1356
|
-
* @param {Boolean} force 是否强制设置新的ID
|
|
1357
|
-
*/
|
|
1358
|
-
setNewItemId(config: MNode, force?: boolean): MNode;
|
|
1359
|
-
/**
|
|
1360
|
-
* 获取默认属性配置
|
|
1361
|
-
* @param type 组件类型
|
|
1362
|
-
* @returns Object
|
|
1363
|
-
*/
|
|
1364
|
-
getDefaultPropsValue(type: string): {
|
|
1365
|
-
type: string;
|
|
1366
|
-
layout: string;
|
|
1367
|
-
style: {};
|
|
1368
|
-
name: string;
|
|
1369
|
-
items: never[];
|
|
1370
|
-
} | {
|
|
1371
|
-
type: string;
|
|
1372
|
-
style: {};
|
|
1373
|
-
name: string;
|
|
1374
|
-
layout?: undefined;
|
|
1375
|
-
items?: undefined;
|
|
1376
|
-
};
|
|
1377
|
-
resetState(): void;
|
|
1378
|
-
/**
|
|
1379
|
-
* 替换关联ID
|
|
1380
|
-
* @param originConfigs 原组件配置
|
|
1381
|
-
* @param targetConfigs 待替换的组件配置
|
|
1382
|
-
*/
|
|
1383
|
-
replaceRelateId(originConfigs: MNode[], targetConfigs: MNode[], collectorOptions: TargetOptions): void;
|
|
1384
|
-
/**
|
|
1385
|
-
* 清除setNewItemId前后映射关系
|
|
1386
|
-
*/
|
|
1387
|
-
clearRelateId(): void;
|
|
1388
|
-
destroy(): void;
|
|
1389
|
-
usePlugin(options: AsyncHookPlugin<AsyncMethodName$2, Props> & SyncHookPlugin<SyncMethodName$2, Props>): void;
|
|
1390
|
-
/**
|
|
1391
|
-
* 获取setNewItemId前后映射关系
|
|
1392
|
-
* @param oldId 原组件ID
|
|
1393
|
-
* @returns 新旧ID映射
|
|
1394
|
-
*/
|
|
1395
|
-
private getRelateIdMap;
|
|
1396
|
-
/**
|
|
1397
|
-
* 记录setNewItemId前后映射关系
|
|
1398
|
-
* @param oldId 原组件ID
|
|
1399
|
-
* @param newId 分配的新ID
|
|
1400
|
-
*/
|
|
1401
|
-
private setRelateId;
|
|
1402
|
-
}
|
|
1403
|
-
type PropsService = Props;
|
|
1404
|
-
declare const _default$50: Props;
|
|
1588
|
+
declare const _default$41: Keybinding;
|
|
1405
1589
|
//#endregion
|
|
1406
1590
|
//#region temp/packages/editor/src/services/stageOverlay.d.ts
|
|
1407
|
-
declare const canUsePluginMethods$
|
|
1591
|
+
declare const canUsePluginMethods$2: {
|
|
1408
1592
|
async: never[];
|
|
1409
1593
|
sync: readonly ["openOverlay", "closeOverlay", "updateOverlay", "createStage"];
|
|
1410
1594
|
};
|
|
1411
|
-
type SyncMethodName
|
|
1595
|
+
type SyncMethodName = Writable<(typeof canUsePluginMethods$2)['sync']>;
|
|
1412
1596
|
declare class StageOverlay extends BaseService {
|
|
1413
1597
|
private state;
|
|
1414
1598
|
constructor();
|
|
@@ -1418,7 +1602,7 @@ declare class StageOverlay extends BaseService {
|
|
|
1418
1602
|
closeOverlay(): void;
|
|
1419
1603
|
updateOverlay(): void;
|
|
1420
1604
|
createStage(stageOptions?: StageOptions): StageCore$1;
|
|
1421
|
-
usePlugin(options: SyncHookPlugin<SyncMethodName
|
|
1605
|
+
usePlugin(options: SyncHookPlugin<SyncMethodName, StageOverlay>): void;
|
|
1422
1606
|
private createContentEl;
|
|
1423
1607
|
private copyDocumentElement;
|
|
1424
1608
|
private render;
|
|
@@ -1428,70 +1612,7 @@ declare class StageOverlay extends BaseService {
|
|
|
1428
1612
|
private updateSelectStatus;
|
|
1429
1613
|
}
|
|
1430
1614
|
type StageOverlayService = StageOverlay;
|
|
1431
|
-
declare const _default$
|
|
1432
|
-
//#endregion
|
|
1433
|
-
//#region temp/packages/editor/src/services/storage.d.ts
|
|
1434
|
-
interface Options$1 {
|
|
1435
|
-
namespace?: string;
|
|
1436
|
-
protocol?: Protocol;
|
|
1437
|
-
}
|
|
1438
|
-
declare enum Protocol {
|
|
1439
|
-
OBJECT = "object",
|
|
1440
|
-
JSON = "json",
|
|
1441
|
-
STRING = "string",
|
|
1442
|
-
NUMBER = "number",
|
|
1443
|
-
BOOLEAN = "boolean"
|
|
1444
|
-
}
|
|
1445
|
-
declare const canUsePluginMethods$2: {
|
|
1446
|
-
async: never[];
|
|
1447
|
-
sync: readonly ["getStorage", "getNamespace", "clear", "getItem", "removeItem", "setItem"];
|
|
1448
|
-
};
|
|
1449
|
-
type SyncMethodName = Writable<(typeof canUsePluginMethods$2)['sync']>;
|
|
1450
|
-
/**
|
|
1451
|
-
* 数据存储服务
|
|
1452
|
-
*/
|
|
1453
|
-
declare class WebStorage extends BaseService {
|
|
1454
|
-
private storage;
|
|
1455
|
-
private namespace;
|
|
1456
|
-
constructor();
|
|
1457
|
-
/**
|
|
1458
|
-
* 获取数据存储对象,可以通过
|
|
1459
|
-
* const storageService = new StorageService();
|
|
1460
|
-
* storageService.usePlugin({
|
|
1461
|
-
* // 替换存储对象为 sessionStorage
|
|
1462
|
-
* async afterGetStorage(): Promise<Storage> {
|
|
1463
|
-
* return window.sessionStorage;
|
|
1464
|
-
* },
|
|
1465
|
-
* });
|
|
1466
|
-
*/
|
|
1467
|
-
getStorage(): Storage;
|
|
1468
|
-
getNamespace(): string;
|
|
1469
|
-
/**
|
|
1470
|
-
* 清理,支持storageService.usePlugin
|
|
1471
|
-
*/
|
|
1472
|
-
clear(): void;
|
|
1473
|
-
/**
|
|
1474
|
-
* 获取存储项,支持storageService.usePlugin
|
|
1475
|
-
*/
|
|
1476
|
-
getItem(key: string, options?: Options$1): any;
|
|
1477
|
-
/**
|
|
1478
|
-
* 获取指定索引位置的key
|
|
1479
|
-
*/
|
|
1480
|
-
key(index: number): string | null;
|
|
1481
|
-
/**
|
|
1482
|
-
* 移除存储项,支持storageService.usePlugin
|
|
1483
|
-
*/
|
|
1484
|
-
removeItem(key: string, options?: Options$1): void;
|
|
1485
|
-
/**
|
|
1486
|
-
* 设置存储项,支持storageService.usePlugin
|
|
1487
|
-
*/
|
|
1488
|
-
setItem(key: string, value: any, options?: Options$1): void;
|
|
1489
|
-
destroy(): void;
|
|
1490
|
-
usePlugin(options: SyncHookPlugin<SyncMethodName, WebStorage>): void;
|
|
1491
|
-
private getValueAndProtocol;
|
|
1492
|
-
}
|
|
1493
|
-
type StorageService = WebStorage;
|
|
1494
|
-
declare const _default$52: WebStorage;
|
|
1615
|
+
declare const _default$43: StageOverlay;
|
|
1495
1616
|
//#endregion
|
|
1496
1617
|
//#region temp/packages/editor/src/services/ui.d.ts
|
|
1497
1618
|
declare const canUsePluginMethods$1: {
|
|
@@ -1511,7 +1632,76 @@ declare class Ui extends BaseService {
|
|
|
1511
1632
|
private setStageRect;
|
|
1512
1633
|
}
|
|
1513
1634
|
type UiService = Ui;
|
|
1514
|
-
declare const _default$
|
|
1635
|
+
declare const _default$44: Ui;
|
|
1636
|
+
//#endregion
|
|
1637
|
+
//#region temp/packages/editor/src/utils/undo-redo.d.ts
|
|
1638
|
+
/**
|
|
1639
|
+
* UndoRedo 栈的可序列化快照,用于持久化(如写入 IndexedDB)后再还原。
|
|
1640
|
+
*/
|
|
1641
|
+
export interface SerializedUndoRedo<T = any> {
|
|
1642
|
+
/** 栈内全部元素(按时间正序,索引 0 为最早一步)。 */
|
|
1643
|
+
elementList: T[];
|
|
1644
|
+
/** 游标位置(已应用步骤数量)。 */
|
|
1645
|
+
listCursor: number;
|
|
1646
|
+
/** 栈容量上限。 */
|
|
1647
|
+
listMaxSize: number;
|
|
1648
|
+
}
|
|
1649
|
+
export declare class UndoRedo<T = any> {
|
|
1650
|
+
/**
|
|
1651
|
+
* 由 {@link UndoRedo.serialize} 产出的快照重建一个 UndoRedo 实例。
|
|
1652
|
+
* 游标会被夹紧到 [0, length] 区间,避免脏数据导致越界。
|
|
1653
|
+
*
|
|
1654
|
+
* @param options.isSavedStep 可选谓词:若提供,则把游标定位到「最近一条满足该谓词的记录」之后
|
|
1655
|
+
* (即恢复到最近一个已保存点);找不到匹配记录时退回快照中的原游标。
|
|
1656
|
+
*/
|
|
1657
|
+
static fromSerialized<T = any>(data: SerializedUndoRedo<T>, options?: {
|
|
1658
|
+
isSavedStep?: (element: T) => boolean;
|
|
1659
|
+
}): UndoRedo<T>;
|
|
1660
|
+
private elementList;
|
|
1661
|
+
private listCursor;
|
|
1662
|
+
private listMaxSize;
|
|
1663
|
+
constructor(listMaxSize?: number);
|
|
1664
|
+
/**
|
|
1665
|
+
* 导出当前栈的可序列化快照(深克隆,避免外部改动污染内部状态)。
|
|
1666
|
+
* 配合 {@link UndoRedo.fromSerialized} 可在持久化后完整还原撤销/重做栈。
|
|
1667
|
+
*/
|
|
1668
|
+
serialize(): SerializedUndoRedo<T>;
|
|
1669
|
+
pushElement(element: T): void;
|
|
1670
|
+
canUndo(): boolean;
|
|
1671
|
+
/** 返回被撤销的操作 */
|
|
1672
|
+
undo(): T | null;
|
|
1673
|
+
canRedo(): boolean;
|
|
1674
|
+
/** 返回被重做的操作 */
|
|
1675
|
+
redo(): T | null;
|
|
1676
|
+
getCurrentElement(): T | null;
|
|
1677
|
+
/**
|
|
1678
|
+
* 用 `element` 替换当前游标所在元素(cursor - 1),并丢弃其后的重做尾部(与 {@link pushElement} 的丢尾一致),
|
|
1679
|
+
* 游标位置保持不变(元素数量不增)。cursor 为 0(无已应用元素)时不做任何操作并返回 false。
|
|
1680
|
+
* 用于「连续同类记录合并」等就地替换最新一条的场景。
|
|
1681
|
+
*/
|
|
1682
|
+
replaceCurrentElement(element: T): boolean;
|
|
1683
|
+
/**
|
|
1684
|
+
* 对当前游标所在元素(cursor - 1)做就地更新;cursor 为 0(全部已撤销)时不做任何操作。
|
|
1685
|
+
* 用于给「当前步骤」打标记(如标记为已保存)等元数据写入场景。
|
|
1686
|
+
*/
|
|
1687
|
+
updateCurrentElement(updater: (element: T) => void): void;
|
|
1688
|
+
/** 对栈内全部元素做就地更新。用于批量清理元数据(如清空所有元素的已保存标记)。 */
|
|
1689
|
+
updateElements(updater: (element: T, index: number) => void): void;
|
|
1690
|
+
/**
|
|
1691
|
+
* 返回栈内全部元素的浅克隆数组(按时间顺序,索引 0 为最早一步)。
|
|
1692
|
+
* 仅用于历史面板等只读展示场景,不应直接修改返回值。
|
|
1693
|
+
*/
|
|
1694
|
+
getElementList(): T[];
|
|
1695
|
+
/**
|
|
1696
|
+
* 当前游标位置:表示已应用的步骤数量。
|
|
1697
|
+
* - cursor === 0 表示全部已撤销
|
|
1698
|
+
* - cursor === length 表示已重做到末尾
|
|
1699
|
+
* 历史面板用于区分"已应用 / 已撤销"两段。
|
|
1700
|
+
*/
|
|
1701
|
+
getCursor(): number;
|
|
1702
|
+
/** 栈内总步数。 */
|
|
1703
|
+
getLength(): number;
|
|
1704
|
+
}
|
|
1515
1705
|
//#endregion
|
|
1516
1706
|
//#region temp/packages/editor/src/type.d.ts
|
|
1517
1707
|
export type EditorSlots = FrameworkSlots & WorkspaceSlots & SidebarSlots & PropsPanelSlots & {
|
|
@@ -3010,7 +3200,7 @@ declare const isGlobalFlat: import("@vue/reactivity").Ref<boolean, boolean>;
|
|
|
3010
3200
|
declare const setEditorConfig: (option: EditorInstallOptions) => void;
|
|
3011
3201
|
declare const getEditorConfig: <K extends keyof EditorInstallOptions>(key: K) => EditorInstallOptions[K];
|
|
3012
3202
|
//#endregion
|
|
3013
|
-
//#region temp/packages/editor/src/utils/props.d.ts
|
|
3203
|
+
//#region temp/packages/editor/src/sdk/utils/props.d.ts
|
|
3014
3204
|
export declare const arrayOptions: {
|
|
3015
3205
|
text: string;
|
|
3016
3206
|
value: string;
|
|
@@ -3041,11 +3231,22 @@ export declare const displayTabConfig: TabPaneConfig<DisplayCondsConfig>;
|
|
|
3041
3231
|
* @param config 组件属性配置
|
|
3042
3232
|
* @returns Object
|
|
3043
3233
|
*/
|
|
3044
|
-
export
|
|
3234
|
+
export interface FillConfigOptions {
|
|
3045
3235
|
labelWidth?: string;
|
|
3046
3236
|
disabledDataSource?: boolean;
|
|
3047
3237
|
disabledCodeBlock?: boolean;
|
|
3048
|
-
|
|
3238
|
+
/** 点击 ID 后面的复制按钮时调用,Node 下不提供则按钮不做任何事 */
|
|
3239
|
+
copyText?: (text: string) => Promise<void> | void;
|
|
3240
|
+
/** 复制结果提示 */
|
|
3241
|
+
notify?: (type: 'success' | 'error', message: string) => void;
|
|
3242
|
+
}
|
|
3243
|
+
//#endregion
|
|
3244
|
+
//#region temp/packages/editor/src/utils/props.d.ts
|
|
3245
|
+
/** 浏览器端默认用 `navigator.clipboard` 复制,并用 `tMagicMessage` 提示 */
|
|
3246
|
+
export declare const copyTextToClipboard: (text: string) => Promise<void>;
|
|
3247
|
+
export declare const notifyByDesign: (type: "success" | "error" | "warning" | "info", message: string) => void;
|
|
3248
|
+
/** 与 SDK 的 `fillConfig` 一致,区别是默认接入浏览器的剪贴板与消息提示 */
|
|
3249
|
+
export declare const fillConfig: (config?: FormConfig, options?: FillConfigOptions) => FormConfig;
|
|
3049
3250
|
//#endregion
|
|
3050
3251
|
//#region temp/packages/editor/src/utils/code-block.d.ts
|
|
3051
3252
|
/**
|
|
@@ -3491,6 +3692,8 @@ export declare const validateDataSourceFieldSelect: (value: any, context: TypeMa
|
|
|
3491
3692
|
export declare const editorTypeMatchRules: Record<string, TypeMatchValidator>;
|
|
3492
3693
|
//#endregion
|
|
3493
3694
|
//#region temp/packages/editor/src/utils/event.d.ts
|
|
3695
|
+
/** 事件相关工具函数依赖的服务,可由表单上下文(`mForm.services`)注入 */
|
|
3696
|
+
export type EventUtilServices = Pick<Services, 'editorService' | 'eventsService' | 'dataSourceService'>;
|
|
3494
3697
|
export declare const EVENT_NAME_VALUE_SEPARATOR = ".";
|
|
3495
3698
|
export type EventNameSelectOption = {
|
|
3496
3699
|
text: string;
|
|
@@ -3504,7 +3707,7 @@ export declare const normalizeCompActionValue: (value: unknown) => string;
|
|
|
3504
3707
|
/**
|
|
3505
3708
|
* 组装事件名称下拉/级联 options,与 EventSelect 默认 eventNameConfig.options 逻辑一致。
|
|
3506
3709
|
*/
|
|
3507
|
-
export declare const getEventNameOptions: (src: string | undefined, formValue?: Record<string, any
|
|
3710
|
+
export declare const getEventNameOptions: (src: string | undefined, formValue?: Record<string, any>, services?: EventUtilServices) => EventNameOption[];
|
|
3508
3711
|
/** 将 select / cascader options 展平为最终写入 name 的字符串集合(cascader 用 `.` 拼接) */
|
|
3509
3712
|
export declare const collectEventNameOptionValues: (options: EventNameOption[], checkStrictly: boolean, prefix?: any[], result?: Set<string>) => Set<string>;
|
|
3510
3713
|
/**
|
|
@@ -3516,11 +3719,11 @@ export declare const getEventNameAllowedValues: (config?: {
|
|
|
3516
3719
|
eventNameConfig?: {
|
|
3517
3720
|
options?: unknown;
|
|
3518
3721
|
};
|
|
3519
|
-
}, formValue?: Record<string, any
|
|
3722
|
+
}, formValue?: Record<string, any>, services?: EventUtilServices) => Set<string> | null;
|
|
3520
3723
|
/**
|
|
3521
3724
|
* 组装联动组件动作下拉/级联 options,与 EventSelect 默认 compActionConfig.options 逻辑一致。
|
|
3522
3725
|
*/
|
|
3523
|
-
export declare const getCompActionOptions: (toId?: Id) => EventNameOption[];
|
|
3726
|
+
export declare const getCompActionOptions: (toId?: Id, services?: EventUtilServices) => EventNameOption[];
|
|
3524
3727
|
/**
|
|
3525
3728
|
* 解析 event-select 联动组件动作允许的 method 集合。
|
|
3526
3729
|
* 自定义 compActionConfig.options 时返回 null(跳过枚举校验)。
|
|
@@ -3532,10 +3735,10 @@ export declare const getCompActionAllowedValues: (config?: {
|
|
|
3532
3735
|
};
|
|
3533
3736
|
}, model?: {
|
|
3534
3737
|
to?: Id;
|
|
3535
|
-
}) => Set<string> | null;
|
|
3738
|
+
}, services?: EventUtilServices) => Set<string> | null;
|
|
3536
3739
|
//#endregion
|
|
3537
3740
|
//#region temp/packages/editor/src/utils/monaco-editor.d.ts
|
|
3538
|
-
declare const _default$
|
|
3741
|
+
declare const _default$42: () => Promise<typeof import("monaco-editor")>;
|
|
3539
3742
|
//#endregion
|
|
3540
3743
|
//#region temp/packages/form/src/schema.d.ts
|
|
3541
3744
|
interface ChangeRecord$1 {
|
|
@@ -4673,30 +4876,30 @@ declare const __VLS_base$12: import("@vue/runtime-core").DefineComponent<EditorP
|
|
|
4673
4876
|
[key: string]: any;
|
|
4674
4877
|
};
|
|
4675
4878
|
renderType: import("@tmagic/stage").RenderType;
|
|
4676
|
-
|
|
4879
|
+
componentGroupList: ComponentGroup[];
|
|
4880
|
+
propsConfigs: Record<string, import("@tmagic/form-schema").FormConfig>;
|
|
4881
|
+
propsValues: Record<string, Partial<import("@tmagic/schema").MNode>>;
|
|
4882
|
+
eventMethodList: Record<string, {
|
|
4883
|
+
events: import("@tmagic/core").EventOption[];
|
|
4884
|
+
methods: import("@tmagic/core").EventOption[];
|
|
4885
|
+
}>;
|
|
4886
|
+
datasourceList: DatasourceTypeOption[];
|
|
4887
|
+
datasourceConfigs: Record<string, import("@tmagic/form-schema").FormConfig>;
|
|
4888
|
+
datasourceValues: Record<string, Partial<import("@tmagic/schema").DataSourceSchema>>;
|
|
4677
4889
|
disabledCodeBlock: boolean;
|
|
4890
|
+
disabledDataSource: boolean;
|
|
4891
|
+
disabledPageFragment: boolean;
|
|
4678
4892
|
disabledMultiSelect: boolean;
|
|
4679
4893
|
alwaysMultiSelect: boolean;
|
|
4680
4894
|
disabledFlashTip: boolean;
|
|
4681
|
-
disabledPageFragment: boolean;
|
|
4682
4895
|
historyListExtraTabs: HistoryListExtraTab[];
|
|
4683
4896
|
disabledShowSrc: boolean;
|
|
4684
4897
|
customContentMenu: CustomContentMenuFunction;
|
|
4685
4898
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
4686
4899
|
isContainer: (el: HTMLElement) => boolean | Promise<boolean>;
|
|
4687
4900
|
containerHighlightClassName: string;
|
|
4688
|
-
componentGroupList: ComponentGroup[];
|
|
4689
4901
|
stageContentMenu: (MenuButton | MenuComponent)[];
|
|
4690
4902
|
disabledStageOverlay: boolean;
|
|
4691
|
-
datasourceList: DatasourceTypeOption[];
|
|
4692
|
-
propsConfigs: Record<string, import("@tmagic/form-schema").FormConfig>;
|
|
4693
|
-
propsValues: Record<string, Partial<import("@tmagic/schema").MNode>>;
|
|
4694
|
-
eventMethodList: Record<string, {
|
|
4695
|
-
events: import("@tmagic/core").EventOption[];
|
|
4696
|
-
methods: import("@tmagic/core").EventOption[];
|
|
4697
|
-
}>;
|
|
4698
|
-
datasourceValues: Record<string, Partial<import("@tmagic/schema").DataSourceSchema>>;
|
|
4699
|
-
datasourceConfigs: Record<string, import("@tmagic/form-schema").FormConfig>;
|
|
4700
4903
|
containerHighlightDuration: number;
|
|
4701
4904
|
containerHighlightType: import("@tmagic/stage").ContainerHighlightType;
|
|
4702
4905
|
containerHighlightAddOnly: boolean;
|
|
@@ -4751,6 +4954,17 @@ declare const __VLS_export$38: import("@vue/runtime-core").DefineComponent<__VLS
|
|
|
4751
4954
|
}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
|
|
4752
4955
|
declare const _default$34: typeof __VLS_export$38;
|
|
4753
4956
|
//#endregion
|
|
4957
|
+
//#region temp/packages/editor/src/services/sdk-instance.d.ts
|
|
4958
|
+
export declare const editorService: Editor;
|
|
4959
|
+
export declare const historyService: History;
|
|
4960
|
+
export declare const propsService: Props;
|
|
4961
|
+
export declare const dataSourceService: DataSource;
|
|
4962
|
+
export declare const codeBlockService: CodeBlock;
|
|
4963
|
+
export declare const depService: Dep;
|
|
4964
|
+
export declare const eventsService: Events;
|
|
4965
|
+
export declare const storageService: WebStorage;
|
|
4966
|
+
export declare const componentListService: ComponentList;
|
|
4967
|
+
//#endregion
|
|
4754
4968
|
//#region temp/packages/editor/src/layouts/sidebar/ComponentListPanel.vue.d.ts
|
|
4755
4969
|
type __VLS_Slots$11 = ComponentListPanelSlots;
|
|
4756
4970
|
declare const __VLS_base$11: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
|
|
@@ -6859,8 +7073,8 @@ declare const _default$33: typeof __VLS_export;
|
|
|
6859
7073
|
export declare const editorFields: Record<string, HeadlessFieldOptions>;
|
|
6860
7074
|
//#endregion
|
|
6861
7075
|
//#region temp/packages/editor/src/plugin.d.ts
|
|
6862
|
-
declare const _default$
|
|
7076
|
+
declare const _default$40: {
|
|
6863
7077
|
install: (app: App, opt?: Partial<EditorInstallOptions | DesignPluginOptions | FormInstallOptions>) => void;
|
|
6864
7078
|
};
|
|
6865
7079
|
//#endregion
|
|
6866
|
-
export { _default as CodeBlockEditor, _default$1 as CodeBlockList, _default$2 as CodeBlockListPanel, _default$3 as CodeSelect, _default$4 as CodeSelectCol, _default$5 as CompareForm, _default$6 as ComponentListPanel, _default$7 as CondOpSelect, _default$8 as ContentMenu, _default$9 as DataSourceAddButton, _default$10 as DataSourceConfigPanel, _default$11 as DataSourceFieldSelect, _default$12 as DataSourceFields, _default$13 as DataSourceInput, _default$14 as DataSourceMethodSelect, _default$15 as DataSourceMethods, _default$16 as DataSourceMocks, _default$17 as DataSourceSelect, DepTargetType, _default$18 as DisplayConds, _default$19 as EventSelect, _default$20 as FloatingBox, _default$21 as HistoryDiffDialog, _default$22 as HistoryListBucket, _default$23 as HistoryListBucketTab, _default$24 as Icon, _default$25 as KeyValue, _default$26 as LayerNodeContent, _default$27 as LayerPanel, _default$28 as LayoutContainer, _default$28 as SplitView, type OnDrag, _default$29 as PageFragmentSelect, _default$30 as PropsFormPanel, _default$31 as PropsPanel, _default$32 as Resizer, StageCore, _default$33 as StyleSetter, _default$34 as TMagicCodeEditor, _default$35 as TMagicEditor, _default$36 as ToolButton, _default$37 as Tree, _default$38 as TreeNode, type TypeMatchValidateContext, _default$39 as ViewForm, _default$40 as
|
|
7080
|
+
export { _default as CodeBlockEditor, _default$1 as CodeBlockList, _default$2 as CodeBlockListPanel, _default$3 as CodeSelect, _default$4 as CodeSelectCol, _default$5 as CompareForm, _default$6 as ComponentListPanel, _default$7 as CondOpSelect, _default$8 as ContentMenu, _default$9 as DataSourceAddButton, _default$10 as DataSourceConfigPanel, _default$11 as DataSourceFieldSelect, _default$12 as DataSourceFields, _default$13 as DataSourceInput, _default$14 as DataSourceMethodSelect, _default$15 as DataSourceMethods, _default$16 as DataSourceMocks, _default$17 as DataSourceSelect, DepTargetType, _default$18 as DisplayConds, _default$19 as EventSelect, _default$20 as FloatingBox, _default$21 as HistoryDiffDialog, _default$22 as HistoryListBucket, _default$23 as HistoryListBucketTab, _default$24 as Icon, _default$25 as KeyValue, _default$26 as LayerNodeContent, _default$27 as LayerPanel, _default$28 as LayoutContainer, _default$28 as SplitView, type OnDrag, _default$29 as PageFragmentSelect, _default$30 as PropsFormPanel, _default$31 as PropsPanel, _default$32 as Resizer, StageCore, _default$33 as StyleSetter, _default$34 as TMagicCodeEditor, _default$35 as TMagicEditor, _default$36 as ToolButton, _default$37 as Tree, _default$38 as TreeNode, type TypeMatchValidateContext, _default$39 as ViewForm, _default$40 as default, designPlugin, formPlugin, getEditorConfig, isGlobalFlat, _default$41 as keybindingService, _default$42 as loadMonaco, setEditorConfig, _default$43 as stageOverlayService, tablePlugin, _default$44 as uiService };
|