@gct-paas/word 1.0.1 → 1.0.3-beta.0
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/README.md +20 -11
- package/dist/browser.js +1 -1
- package/dist/chunks/{ModelEditor-GzaLnnX8.js → ModelEditor-DqavEAJg.js} +114 -5
- package/dist/chunks/ModelEditor-DqavEAJg.js.map +1 -0
- package/dist/chunks/NodeFactory-DzFnWaWf.js +500 -0
- package/dist/chunks/NodeFactory-DzFnWaWf.js.map +1 -0
- package/dist/chunks/{browser-CP0ycXqN.js → browser-OAJIVM8O.js} +420 -192
- package/dist/chunks/browser-OAJIVM8O.js.map +1 -0
- package/dist/chunks/{change-set-DNOw1FXo.js → change-set-DgfKTJ6d.js} +12 -2
- package/dist/chunks/change-set-DgfKTJ6d.js.map +1 -0
- package/dist/chunks/legacy-template-converter-DFsd-elN.js +125 -0
- package/dist/chunks/legacy-template-converter-DFsd-elN.js.map +1 -0
- package/dist/chunks/migrate-YJTylIpz.js +5193 -0
- package/dist/chunks/migrate-YJTylIpz.js.map +1 -0
- package/dist/chunks/{sdk-DH5c-Bbt.js → sdk-BmwE5mZn.js} +1082 -628
- package/dist/chunks/sdk-BmwE5mZn.js.map +1 -0
- package/dist/chunks/src-BFXPGLus.js +3338 -0
- package/dist/chunks/src-BFXPGLus.js.map +1 -0
- package/dist/chunks/{table-borders-Dwuj7lFp.js → table-borders-B9bZMj5o.js} +2 -2
- package/dist/chunks/{table-borders-Dwuj7lFp.js.map → table-borders-B9bZMj5o.js.map} +1 -1
- package/dist/chunks/templates-Djcl21k4.js.map +1 -1
- package/dist/chunks/{types-XXuIIZ9e.js → types-CMkQ6Lvg.js} +123 -7
- package/dist/chunks/types-CMkQ6Lvg.js.map +1 -0
- package/dist/chunks/{NodeFactory-D9gVGSok.js → validation-DkCy8wHI.js} +10 -495
- package/dist/chunks/validation-DkCy8wHI.js.map +1 -0
- package/dist/docx.js +3 -2
- package/dist/docx.js.map +1 -1
- package/dist/index.js +7 -6
- package/dist/legacy.js +1 -0
- package/dist/platform.js +4 -3
- package/dist/platform.js.map +1 -1
- package/dist/style.css +864 -584
- package/dist/types/adapters/browser/canvas/CanvasPages.d.ts +1 -1
- package/dist/types/adapters/browser/canvas/paint-context.d.ts +4 -0
- package/dist/types/adapters/browser/canvas/paint-signature.d.ts +4 -0
- package/dist/types/adapters/browser/input/SignatureFieldInput.d.ts +10 -1
- package/dist/types/adapters/browser/input/signature-panel.d.ts +6 -0
- package/dist/types/adapters/browser/input/validation/CanvasValidationPanel.d.ts +1 -1
- package/dist/types/adapters/browser/input/word-error-text.d.ts +8 -2
- package/dist/types/adapters/platform/index.d.ts +1 -0
- package/dist/types/adapters/platform/templates.d.ts +11 -1
- package/dist/types/adapters/vue/GctWordPrintRenderer.vue.d.ts +1 -1
- package/dist/types/adapters/vue/GctWordTemplateDesigner.vue.d.ts +3 -0
- package/dist/types/adapters/vue/SignatureCardReader.vue.d.ts +1 -0
- package/dist/types/adapters/vue/SignatureVisual.vue.d.ts +10 -0
- package/dist/types/adapters/vue/WordFeedback.vue.d.ts +11 -0
- package/dist/types/adapters/vue/WordLayoutNotices.vue.d.ts +8 -0
- package/dist/types/adapters/vue/WordOperationError.vue.d.ts +11 -0
- package/dist/types/adapters/vue/field-properties/dependency-strategies.d.ts +7 -0
- package/dist/types/adapters/vue/index.d.ts +1 -0
- package/dist/types/adapters/vue/layout-notices.d.ts +15 -0
- package/dist/types/adapters/vue/legacy-template-converter.d.ts +14 -0
- package/dist/types/adapters/vue/region-properties/WordBusinessRegion.vue.d.ts +3 -0
- package/dist/types/adapters/vue/region-properties/WordDataLockConfig.vue.d.ts +16 -0
- package/dist/types/adapters/vue/useWordWorkspace.d.ts +6 -3
- package/dist/types/adapters/vue/word-feedback.d.ts +21 -0
- package/dist/types/data/DataManager.d.ts +2 -2
- package/dist/types/data/rows/copy-row.d.ts +5 -0
- package/dist/types/data/services/DataDependencies.d.ts +2 -2
- package/dist/types/data/types/manager.d.ts +2 -0
- package/dist/types/data/types/rules.d.ts +8 -1
- package/dist/types/import/legacy/autofill.d.ts +3 -0
- package/dist/types/import/legacy/bindings.d.ts +9 -0
- package/dist/types/import/legacy/boundary.d.ts +10 -0
- package/dist/types/import/legacy/business-fields.d.ts +25 -0
- package/dist/types/import/legacy/context.d.ts +61 -0
- package/dist/types/import/legacy/data-sources.d.ts +29 -0
- package/dist/types/import/legacy/document-rules.d.ts +38 -0
- package/dist/types/import/legacy/document-signature.d.ts +16 -0
- package/dist/types/import/legacy/fields.d.ts +34 -0
- package/dist/types/import/legacy/index.d.ts +3 -0
- package/dist/types/import/legacy/initialization.d.ts +34 -0
- package/dist/types/import/legacy/json-data.d.ts +25 -0
- package/dist/types/import/legacy/materials.d.ts +40 -0
- package/dist/types/import/legacy/media.d.ts +18 -0
- package/dist/types/import/legacy/metadata.d.ts +23 -0
- package/dist/types/import/legacy/migrate.d.ts +9 -0
- package/dist/types/import/legacy/page-widgets.d.ts +30 -0
- package/dist/types/import/legacy/relations.d.ts +25 -0
- package/dist/types/import/legacy/scalar-fields.d.ts +7 -0
- package/dist/types/import/legacy/styles.d.ts +52 -0
- package/dist/types/import/legacy/table-variants.d.ts +18 -0
- package/dist/types/import/legacy/tables.d.ts +27 -0
- package/dist/types/import/legacy/trace-fields.d.ts +21 -0
- package/dist/types/import/legacy/types.d.ts +141 -0
- package/dist/types/import/legacy/widget-presentation.d.ts +10 -0
- package/dist/types/layout/engine/atoms/control-text.d.ts +16 -0
- package/dist/types/layout/engine/atoms/field-control.d.ts +0 -13
- package/dist/types/layout/engine/atoms/signatures.d.ts +2 -2
- package/dist/types/layout/engine/blocks/placement-types.d.ts +7 -0
- package/dist/types/layout/engine/pagination/content-flow.d.ts +8 -0
- package/dist/types/layout/engine/tables/place-table-window.d.ts +3 -2
- package/dist/types/layout/engine/tables/row-flow.d.ts +3 -2
- package/dist/types/layout/engine/tables/table-flow.d.ts +3 -1
- package/dist/types/layout/geometry/control-brackets.d.ts +4 -0
- package/dist/types/layout/types/presentation/controls.d.ts +13 -0
- package/dist/types/layout/types/presentation/images.d.ts +8 -0
- package/dist/types/layout/types/presentation/signatures.d.ts +6 -0
- package/dist/types/model/business/business-types.d.ts +9 -1
- package/dist/types/model/business/data-lock-config.d.ts +27 -0
- package/dist/types/runtime/form/business/signatures/NativeSignatures.d.ts +3 -1
- package/dist/types/runtime/form/business/signatures/device-signature-lock.d.ts +2 -0
- package/dist/types/runtime/form/business/tables/row-fields.d.ts +1 -1
- package/dist/types/runtime/form/copy-field-paths.d.ts +3 -0
- package/dist/types/runtime/form/fields/core/rules/CommonFieldRules.d.ts +5 -1
- package/dist/types/runtime/form/shared/identity.d.ts +0 -1
- package/dist/types/runtime/form/shared/row.d.ts +0 -1
- package/dist/types/runtime/form/validation/NativeFieldValidation.d.ts +14 -2
- package/dist/types/runtime/form/validation/targets.d.ts +1 -1
- package/dist/types/runtime/form/validation/types.d.ts +2 -0
- package/dist/types/runtime/interaction/EditorController.d.ts +2 -0
- package/dist/types/runtime/interaction/browse/types.d.ts +5 -0
- package/dist/types/runtime/interaction/design/format/EditorFormat.d.ts +2 -2
- package/dist/types/runtime/interaction/design/format/summary.d.ts +1 -2
- package/dist/types/runtime/interaction/design/format/targets.d.ts +11 -0
- package/dist/types/runtime/interaction/design/format/types.d.ts +3 -3
- package/dist/types/runtime/interaction/design/tables/regions/definitions.d.ts +7 -0
- package/dist/types/runtime/interaction/field-signature.d.ts +3 -0
- package/dist/types/runtime/presentation/fields/signatures.d.ts +5 -2
- package/dist/types/shared/form-config/identity.d.ts +3 -0
- package/dist/types/shared/identity.d.ts +3 -0
- package/dist/types/shared/platform-gct/form-credentials.d.ts +0 -1
- package/dist/types/shared/platform-gct/templates.d.ts +2 -0
- package/dist/types/shared/signature-graphic.d.ts +27 -0
- package/dist/types/shared/text/shading.d.ts +12 -0
- package/dist/types/shared/ui/select/src/select.types.d.ts +2 -0
- package/dist/types/shared/ui/tree-select/src/unified-tree-select.vue.d.ts +1 -1
- package/dist/vue.js +2140 -4498
- package/dist/vue.js.map +1 -1
- package/package.json +9 -3
- package/dist/chunks/ModelEditor-GzaLnnX8.js.map +0 -1
- package/dist/chunks/NodeFactory-D9gVGSok.js.map +0 -1
- package/dist/chunks/browser-CP0ycXqN.js.map +0 -1
- package/dist/chunks/change-set-DNOw1FXo.js.map +0 -1
- package/dist/chunks/sdk-DH5c-Bbt.js.map +0 -1
- package/dist/chunks/types-XXuIIZ9e.js.map +0 -1
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { $ as rowRule, A as cellRule, D as blockRule, E as bindingRule, F as inlineRule, G as overlayRule, I as isObject, J as partRule, L as mergeRule, M as columnRule, O as boolean, P as imageAssetRule, R as nonempty, T as attachmentRule, U as optional, V as object, Z as regionRule, et as sectionRule, g as copyInputData, h as copyData, m as cloneJsonData, o as ConfigRegistry, p as ModelEditError, r as validateFieldConditions, t as validateDocument } from "./validation-DkCy8wHI.js";
|
|
2
|
+
import { isFunction, isNull, isString, isUndefined } from "es-toolkit/predicate";
|
|
3
|
+
import isObjectValue from "es-toolkit/compat/isObject";
|
|
4
|
+
import isArray from "es-toolkit/compat/isArray";
|
|
5
|
+
import isInteger from "es-toolkit/compat/isInteger";
|
|
6
|
+
import includes from "es-toolkit/compat/includes";
|
|
7
|
+
// src/model/serialization/codec.ts
|
|
8
|
+
/**
|
|
9
|
+
* @file 原生文档读写边界:解析字符串、读取对象、保存同形 JSON,并统一抛出结构化校验错误。
|
|
10
|
+
* 阅读定位:serialization/ · 原生文档和片段的读写边界。
|
|
11
|
+
*/
|
|
12
|
+
var DocumentValidationError = class extends Error {
|
|
13
|
+
issues;
|
|
14
|
+
/** 将全部结构化错误保留在异常上,message 只提供便于日志阅读的路径摘要。 */
|
|
15
|
+
constructor(issues) {
|
|
16
|
+
super(issues.map((issue) => `${issue.path || "/"}: ${issue.message}`).join("\n"));
|
|
17
|
+
this.name = "DocumentValidationError";
|
|
18
|
+
this.issues = issues;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** 统一读取/保存边界校验,失败抛出结构化错误;不修改或自动修复输入。 */
|
|
22
|
+
function checked(value, options) {
|
|
23
|
+
const result = validateDocument(value, options);
|
|
24
|
+
if (!result.valid) throw new DocumentValidationError(result.issues);
|
|
25
|
+
return result.document;
|
|
26
|
+
}
|
|
27
|
+
/** 读取文件字符串并校验原生协议;保留原 ID,语法错误也转换为结构化异常。 */
|
|
28
|
+
function parseDocument(json, options) {
|
|
29
|
+
let value;
|
|
30
|
+
try {
|
|
31
|
+
value = JSON.parse(json);
|
|
32
|
+
} catch {
|
|
33
|
+
throw new DocumentValidationError([{
|
|
34
|
+
path: "",
|
|
35
|
+
code: "json_syntax",
|
|
36
|
+
message: "Invalid JSON document"
|
|
37
|
+
}]);
|
|
38
|
+
}
|
|
39
|
+
return checked(value, options);
|
|
40
|
+
}
|
|
41
|
+
/** 读取 API 对象并隔离调用者持有的数据;内存和保存仍使用同一种结构。 */
|
|
42
|
+
function readDocument(value, options) {
|
|
43
|
+
return JSON.parse(JSON.stringify(checked(value, options)));
|
|
44
|
+
}
|
|
45
|
+
/** 保存前校验同形文档;不转 XML,不夹带索引/历史,也不展开继承默认配置。 */
|
|
46
|
+
function serializeDocument(document, options) {
|
|
47
|
+
checked(document, options);
|
|
48
|
+
return JSON.stringify(document, null, options?.space);
|
|
49
|
+
}
|
|
50
|
+
// src/model/editor/factory-validation.ts
|
|
51
|
+
/**
|
|
52
|
+
* @file 创建与删除参数校验:拒绝未知选项,统一字段绑定来源、删除策略及局部载荷检查。
|
|
53
|
+
* 阅读定位:editor/ · 创建、编辑、事务、差量与历史。
|
|
54
|
+
*/
|
|
55
|
+
/** 所有高层删除入口使用同一组布尔选项,false 明确保留候选定义,未知键直接拒绝。 */
|
|
56
|
+
function readRemovalOptions(input) {
|
|
57
|
+
const value = readFactoryOptions(input, ["removeUnusedBindings", "removeUnusedAssets"]);
|
|
58
|
+
checkFactoryValue(value, object({
|
|
59
|
+
removeUnusedBindings: optional(boolean),
|
|
60
|
+
removeUnusedAssets: optional(boolean)
|
|
61
|
+
}));
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
/** 按现有协议规则检查局部值,失败携带完整结构化诊断。 */
|
|
65
|
+
function checkFactoryValue(value, rule, path = "") {
|
|
66
|
+
const issues = [];
|
|
67
|
+
rule(value, path, issues);
|
|
68
|
+
if (issues.length) throw new DocumentValidationError(issues);
|
|
69
|
+
}
|
|
70
|
+
/** 已完成 JSON 隔离的内部参数只核对对象形状和允许的键,不再复制。 */
|
|
71
|
+
function checkFactoryOptions(value, keys) {
|
|
72
|
+
if (!isObject(value)) throw new ModelEditError("factory_options", "Expected plain options object");
|
|
73
|
+
for (const key of Object.keys(value)) if (!includes(keys, key)) throw new ModelEditError("factory_options", `Unknown option: ${key}`);
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
/** 公开参数先隔离 JSON,再核对原始键,未知键即使值为 undefined 也不静默丢弃。 */
|
|
77
|
+
function readFactoryOptions(input, keys) {
|
|
78
|
+
const value = copyInputData(input);
|
|
79
|
+
checkFactoryOptions(input, keys);
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
/** 绑定参数只允许一个来源,返回隔离后的明确声明或已有引用。 */
|
|
83
|
+
function readFieldBinding(input) {
|
|
84
|
+
return checkFieldBinding(readFactoryOptions(input, ["binding", "bindingId"]));
|
|
85
|
+
}
|
|
86
|
+
/** 已隔离的字段声明只检查绑定来源及其业务结构。 */
|
|
87
|
+
function checkFieldBinding(value) {
|
|
88
|
+
if (Object.hasOwn(value, "binding") === Object.hasOwn(value, "bindingId")) throw new ModelEditError("binding_input", "Provide binding or bindingId");
|
|
89
|
+
if ("binding" in value) checkFactoryValue(value.binding, bindingRule, "/binding");
|
|
90
|
+
else checkFactoryValue(value.bindingId, nonempty, "/bindingId");
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
// src/model/editor/NodeFactory.ts
|
|
94
|
+
/**
|
|
95
|
+
* @file 节点工厂:构造节点及必要的绑定或资产增量;插入文档和记录历史由编辑器负责。
|
|
96
|
+
* 阅读定位:editor/ · 创建、编辑、事务、差量与历史。
|
|
97
|
+
*/
|
|
98
|
+
/** 普通常用字段的明确白名单,不根据业务字段名猜测组件。 */
|
|
99
|
+
var commonFieldWidgets = [
|
|
100
|
+
"input",
|
|
101
|
+
"number",
|
|
102
|
+
"checkbox",
|
|
103
|
+
"choice",
|
|
104
|
+
"date",
|
|
105
|
+
"time",
|
|
106
|
+
"date-time",
|
|
107
|
+
"file",
|
|
108
|
+
"image",
|
|
109
|
+
"seal",
|
|
110
|
+
"signature",
|
|
111
|
+
"user",
|
|
112
|
+
"org",
|
|
113
|
+
"relation",
|
|
114
|
+
"rdo-relation",
|
|
115
|
+
"sop-version"
|
|
116
|
+
];
|
|
117
|
+
var textKeys = ["textStyleId", "textStyle"];
|
|
118
|
+
var appearanceKeys = [
|
|
119
|
+
...textKeys,
|
|
120
|
+
"preferredSizePx",
|
|
121
|
+
"policy",
|
|
122
|
+
"attachments"
|
|
123
|
+
];
|
|
124
|
+
/** 只负责构造普通节点数据;一个工厂服务一批创建,不给每个节点再套类。 */
|
|
125
|
+
var NodeFactory = class {
|
|
126
|
+
/** 创建过的身份,防止外部工厂重复分配;不持有生成节点。 */
|
|
127
|
+
issued = /* @__PURE__ */ new Set();
|
|
128
|
+
/** 唯一的外部分配入口,销毁时释放闭包。 */
|
|
129
|
+
createId;
|
|
130
|
+
/** 闭合配置依赖,不保存计算结果。 */
|
|
131
|
+
registry;
|
|
132
|
+
/** 依赖外部 ID 工厂;不创建随机身份、默认文档或运行时包装。 */
|
|
133
|
+
constructor(options) {
|
|
134
|
+
if (!isFunction(options.createId)) throw new ModelEditError("id_factory", "createId is required");
|
|
135
|
+
this.createId = options.createId;
|
|
136
|
+
this.registry = options.registry ?? new ConfigRegistry();
|
|
137
|
+
}
|
|
138
|
+
/** 创建完整文字片段,不按字符拆对象;显式样式与调用方数据隔离。 */
|
|
139
|
+
createText(text, options = {}) {
|
|
140
|
+
const copied = readFactoryOptions(options, textKeys);
|
|
141
|
+
return this.checkNode({
|
|
142
|
+
id: this.allocateId(),
|
|
143
|
+
kind: "text",
|
|
144
|
+
text,
|
|
145
|
+
...copied
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/** 创建空段或已有行内内容的段落,不生成空白占位符或展开默认样式。 */
|
|
149
|
+
createParagraph(options = {}) {
|
|
150
|
+
const copied = readFactoryOptions(options, [
|
|
151
|
+
...textKeys,
|
|
152
|
+
"paragraphStyleId",
|
|
153
|
+
"paragraphStyle",
|
|
154
|
+
"content"
|
|
155
|
+
]);
|
|
156
|
+
if (!isUndefined(copied.content) && !isArray(copied.content)) throw new ModelEditError("factory_options", "content must be an array");
|
|
157
|
+
return this.checkNode({
|
|
158
|
+
...copied,
|
|
159
|
+
id: this.allocateId(),
|
|
160
|
+
kind: "paragraph",
|
|
161
|
+
content: [...copied.content ?? []]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/** 创建完整矩形物理网格;空格用空 blocks 表达,不凭空增加段落和文字。 */
|
|
165
|
+
createTable(options) {
|
|
166
|
+
const copied = readFactoryOptions(options, [
|
|
167
|
+
"rowCount",
|
|
168
|
+
"columnCount",
|
|
169
|
+
"columnWidthsPx",
|
|
170
|
+
"rowHeight",
|
|
171
|
+
"tableStyleId",
|
|
172
|
+
"style",
|
|
173
|
+
"cellStyle"
|
|
174
|
+
]);
|
|
175
|
+
for (const count of [copied.rowCount, copied.columnCount]) if (!isInteger(count) || count < 1) throw new ModelEditError("table_size", "Table dimensions must be positive integers");
|
|
176
|
+
if (!isUndefined(copied.columnWidthsPx) && (!isArray(copied.columnWidthsPx) || copied.columnWidthsPx.length !== copied.columnCount)) throw new ModelEditError("table_size", "Column widths must match columnCount");
|
|
177
|
+
const node = {
|
|
178
|
+
id: this.allocateId(),
|
|
179
|
+
kind: "table",
|
|
180
|
+
columns: [],
|
|
181
|
+
rows: [],
|
|
182
|
+
merges: [],
|
|
183
|
+
regions: [],
|
|
184
|
+
...isUndefined(copied.tableStyleId) ? {} : { tableStyleId: copied.tableStyleId },
|
|
185
|
+
...isUndefined(copied.style) ? {} : { style: copied.style }
|
|
186
|
+
};
|
|
187
|
+
for (let col = 0; col < copied.columnCount; col++) node.columns.push({
|
|
188
|
+
id: this.allocateId(),
|
|
189
|
+
...isUndefined(copied.columnWidthsPx) ? {} : { widthPx: copied.columnWidthsPx[col] }
|
|
190
|
+
});
|
|
191
|
+
for (let row = 0; row < copied.rowCount; row++) node.rows.push(this.createEmptyRow(copied.columnCount, isUndefined(copied.rowHeight) ? void 0 : cloneJsonData(copied.rowHeight), copied.cellStyle));
|
|
192
|
+
return this.checkNode(node);
|
|
193
|
+
}
|
|
194
|
+
/** 创建实际新格,不为内部检查分配段落或表格身份。 */
|
|
195
|
+
createCell(options = {}) {
|
|
196
|
+
const copied = readFactoryOptions(options, ["blocks", "style"]);
|
|
197
|
+
if (!isUndefined(copied.blocks) && !isArray(copied.blocks)) throw new ModelEditError("factory_options", "blocks must be an array");
|
|
198
|
+
return this.checkNode({
|
|
199
|
+
id: this.allocateId(),
|
|
200
|
+
kind: "cell",
|
|
201
|
+
blocks: [...copied.blocks ?? []],
|
|
202
|
+
...isUndefined(copied.style) ? {} : { style: copied.style }
|
|
203
|
+
}, cellRule);
|
|
204
|
+
}
|
|
205
|
+
/** 创建完整物理行及空格,所有实际实体只分配一次身份。 */
|
|
206
|
+
createRow(options) {
|
|
207
|
+
const copied = readFactoryOptions(options, [
|
|
208
|
+
"columnCount",
|
|
209
|
+
"height",
|
|
210
|
+
"cellStyle"
|
|
211
|
+
]);
|
|
212
|
+
if (!isInteger(copied.columnCount) || copied.columnCount < 1) throw new ModelEditError("table_size", "columnCount must be a positive integer");
|
|
213
|
+
return this.checkNode(this.createEmptyRow(copied.columnCount, copied.height, copied.cellStyle), rowRule);
|
|
214
|
+
}
|
|
215
|
+
/** 创建列宽的唯一声明,不在各格重复保存宽度。 */
|
|
216
|
+
createColumn(options = {}) {
|
|
217
|
+
const copied = readFactoryOptions(options, ["widthPx"]);
|
|
218
|
+
return this.checkNode({
|
|
219
|
+
id: this.allocateId(),
|
|
220
|
+
...copied
|
|
221
|
+
}, columnRule);
|
|
222
|
+
}
|
|
223
|
+
/** 创建合并范围,主从格关系仍在查询时从物理网格派生。 */
|
|
224
|
+
createMerge(range) {
|
|
225
|
+
return this.checkNode({
|
|
226
|
+
id: this.allocateId(),
|
|
227
|
+
range: copyData(range)
|
|
228
|
+
}, mergeRule);
|
|
229
|
+
}
|
|
230
|
+
/** 创建已注册业务区域声明,不生成单元格上的反向标记。 */
|
|
231
|
+
createRegion(options) {
|
|
232
|
+
const copied = readFactoryOptions(options, [
|
|
233
|
+
"type",
|
|
234
|
+
"name",
|
|
235
|
+
"range",
|
|
236
|
+
"binding",
|
|
237
|
+
"configVersion",
|
|
238
|
+
"config",
|
|
239
|
+
"variant",
|
|
240
|
+
"parentRegionId",
|
|
241
|
+
"targetRegionId"
|
|
242
|
+
]);
|
|
243
|
+
return this.checkNode({
|
|
244
|
+
id: this.allocateId(),
|
|
245
|
+
...copied
|
|
246
|
+
}, regionRule);
|
|
247
|
+
}
|
|
248
|
+
/** 创建常用或注册扩展字段及绑定增量;choice 只补必需 options,扩展必须明确配置版本。 */
|
|
249
|
+
createField(options) {
|
|
250
|
+
const copied = readFactoryOptions(options, [
|
|
251
|
+
"widget",
|
|
252
|
+
"config",
|
|
253
|
+
"configVersion",
|
|
254
|
+
"binding",
|
|
255
|
+
"bindingId",
|
|
256
|
+
...appearanceKeys
|
|
257
|
+
]);
|
|
258
|
+
if (!isString(copied.widget) || !includes(commonFieldWidgets, copied.widget) && !includes(copied.widget, ":")) throw new ModelEditError("field_widget", "Expected common or registered field widget");
|
|
259
|
+
if (!isUndefined(copied.config) && (isNull(copied.config) || !isObjectValue(copied.config) || isFunction(copied.config) || isArray(copied.config))) throw new ModelEditError("field_config", "config must be an object");
|
|
260
|
+
const input = checkFieldBinding(copied);
|
|
261
|
+
const bindings = Object.create(null);
|
|
262
|
+
const bindingId = "binding" in input ? this.allocateId() : input.bindingId;
|
|
263
|
+
if ("binding" in input) bindings[bindingId] = input.binding;
|
|
264
|
+
const config = copied.widget === "choice" ? {
|
|
265
|
+
...copied.config,
|
|
266
|
+
options: copied.config?.options ?? []
|
|
267
|
+
} : copied.config;
|
|
268
|
+
const node = {
|
|
269
|
+
id: this.allocateId(),
|
|
270
|
+
kind: "field",
|
|
271
|
+
widget: copied.widget,
|
|
272
|
+
bindingId,
|
|
273
|
+
...Object.hasOwn(copied, "configVersion") ? { configVersion: copied.configVersion } : {},
|
|
274
|
+
...isUndefined(config) ? {} : { config }
|
|
275
|
+
};
|
|
276
|
+
for (const key of appearanceKeys) if (Object.hasOwn(copied, key)) Object.defineProperty(node, key, {
|
|
277
|
+
value: copied[key],
|
|
278
|
+
enumerable: true,
|
|
279
|
+
configurable: true,
|
|
280
|
+
writable: true
|
|
281
|
+
});
|
|
282
|
+
return {
|
|
283
|
+
node: this.checkNode(node),
|
|
284
|
+
bindings
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** 创建图片及局部资产增量,明确引用不复制资源,不读取或下载二进制文件。 */
|
|
288
|
+
createImage(options) {
|
|
289
|
+
const copied = readFactoryOptions(options, [
|
|
290
|
+
"asset",
|
|
291
|
+
"assetId",
|
|
292
|
+
"alt",
|
|
293
|
+
"preferredSizePx",
|
|
294
|
+
"fit"
|
|
295
|
+
]);
|
|
296
|
+
if (Object.hasOwn(copied, "asset") === Object.hasOwn(copied, "assetId")) throw new ModelEditError("asset_input", "Provide asset or assetId");
|
|
297
|
+
const assets = Object.create(null);
|
|
298
|
+
let assetId;
|
|
299
|
+
if ("asset" in copied) {
|
|
300
|
+
checkFactoryValue(copied.asset, imageAssetRule, "/asset");
|
|
301
|
+
assetId = this.allocateId();
|
|
302
|
+
assets[assetId] = copied.asset;
|
|
303
|
+
} else {
|
|
304
|
+
checkFactoryValue(copied.assetId, nonempty, "/assetId");
|
|
305
|
+
assetId = copied.assetId;
|
|
306
|
+
}
|
|
307
|
+
const node = {
|
|
308
|
+
id: this.allocateId(),
|
|
309
|
+
kind: "image",
|
|
310
|
+
assetId,
|
|
311
|
+
...isUndefined(copied.alt) ? {} : { alt: copied.alt },
|
|
312
|
+
...isUndefined(copied.fit) ? {} : { fit: copied.fit },
|
|
313
|
+
...isUndefined(copied.preferredSizePx) ? {} : { preferredSizePx: copied.preferredSizePx }
|
|
314
|
+
};
|
|
315
|
+
return {
|
|
316
|
+
node: this.checkNode(node),
|
|
317
|
+
assets
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/** 创建页码或已注册的页面组件,配置和默认能力仍由同一注册表解释。 */
|
|
321
|
+
createPageWidget(options) {
|
|
322
|
+
const copied = readFactoryOptions(options, [
|
|
323
|
+
"widget",
|
|
324
|
+
"config",
|
|
325
|
+
"configVersion",
|
|
326
|
+
...textKeys,
|
|
327
|
+
"preferredSizePx",
|
|
328
|
+
"policy"
|
|
329
|
+
]);
|
|
330
|
+
return this.checkNode({
|
|
331
|
+
id: this.allocateId(),
|
|
332
|
+
kind: "pageWidget",
|
|
333
|
+
...copied
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/** 创建显式换行或分页,不把自动排版结果保存进模型。 */
|
|
337
|
+
createBreak(breakType) {
|
|
338
|
+
return this.checkNode({
|
|
339
|
+
id: this.allocateId(),
|
|
340
|
+
kind: "break",
|
|
341
|
+
breakType
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
/** 创建共享页眉/页脚拥有内容,不为各章节重复创建同一部件。 */
|
|
345
|
+
createPart(kind, options = {}) {
|
|
346
|
+
const copied = readFactoryOptions(options, ["blocks"]);
|
|
347
|
+
if (!isUndefined(copied.blocks) && !isArray(copied.blocks)) throw new ModelEditError("factory_options", "blocks must be an array");
|
|
348
|
+
return this.checkNode({
|
|
349
|
+
id: this.allocateId(),
|
|
350
|
+
kind,
|
|
351
|
+
blocks: [...copied.blocks ?? []]
|
|
352
|
+
}, partRule);
|
|
353
|
+
}
|
|
354
|
+
/** 创建锚定浮层,优先尺寸与层级均只保存调用方明确设置的值。 */
|
|
355
|
+
createOverlay(options) {
|
|
356
|
+
const copied = readFactoryOptions(options, [
|
|
357
|
+
"anchor",
|
|
358
|
+
"blocks",
|
|
359
|
+
"preferredSizePx",
|
|
360
|
+
"zIndex"
|
|
361
|
+
]);
|
|
362
|
+
if (!isUndefined(copied.blocks) && !isArray(copied.blocks)) throw new ModelEditError("factory_options", "blocks must be an array");
|
|
363
|
+
return this.checkNode({
|
|
364
|
+
...copied,
|
|
365
|
+
id: this.allocateId(),
|
|
366
|
+
kind: "overlay",
|
|
367
|
+
blocks: [...copied.blocks ?? []]
|
|
368
|
+
}, overlayRule);
|
|
369
|
+
}
|
|
370
|
+
/** 创建实际章节及已有拥有内容,不默认生成空段落、部件或分页对象。 */
|
|
371
|
+
createSection(options) {
|
|
372
|
+
const copied = readFactoryOptions(options, [
|
|
373
|
+
"page",
|
|
374
|
+
"headerSlots",
|
|
375
|
+
"footerSlots",
|
|
376
|
+
"blocks",
|
|
377
|
+
"overlays"
|
|
378
|
+
]);
|
|
379
|
+
for (const value of [copied.blocks, copied.overlays]) if (!isUndefined(value) && !isArray(value)) throw new ModelEditError("factory_options", "Owned content must be an array");
|
|
380
|
+
return this.checkNode({
|
|
381
|
+
...copied,
|
|
382
|
+
id: this.allocateId(),
|
|
383
|
+
kind: "section",
|
|
384
|
+
blocks: [...copied.blocks ?? []],
|
|
385
|
+
overlays: [...copied.overlays ?? []]
|
|
386
|
+
}, sectionRule);
|
|
387
|
+
}
|
|
388
|
+
/** 创建一个新选项;局部 ID 在默认项和附属条件中复用,不保存 defaultSelected 副本。 */
|
|
389
|
+
createChoiceOption(options) {
|
|
390
|
+
const copied = readFactoryOptions(options, [
|
|
391
|
+
"label",
|
|
392
|
+
"value",
|
|
393
|
+
"display"
|
|
394
|
+
]);
|
|
395
|
+
const option = {
|
|
396
|
+
id: this.allocateId(),
|
|
397
|
+
...copied
|
|
398
|
+
};
|
|
399
|
+
const issues = [];
|
|
400
|
+
this.registry.validate("field", "choice", 1, { options: [option] }, "/config", issues);
|
|
401
|
+
if (issues.length) throw new DocumentValidationError(issues);
|
|
402
|
+
return option;
|
|
403
|
+
}
|
|
404
|
+
/** 创建附属内容容器,条件与父字段是否匹配由编辑器提交时检查。 */
|
|
405
|
+
createAttachment(when, blocks = []) {
|
|
406
|
+
const node = {
|
|
407
|
+
id: this.allocateId(),
|
|
408
|
+
kind: "attachment",
|
|
409
|
+
when: copyData(when),
|
|
410
|
+
blocks: copyInputData([...blocks])
|
|
411
|
+
};
|
|
412
|
+
return this.checkNode(node);
|
|
413
|
+
}
|
|
414
|
+
/** 释放身份集合与外部回调,已有返回节点不受影响。 */
|
|
415
|
+
dispose() {
|
|
416
|
+
this.issued.clear();
|
|
417
|
+
this.createId = void 0;
|
|
418
|
+
this.registry = void 0;
|
|
419
|
+
}
|
|
420
|
+
/** 为一个新实体分配身份;坏工厂直接失败,不循环猜测或重试。 */
|
|
421
|
+
allocateId() {
|
|
422
|
+
this.requireRegistry();
|
|
423
|
+
const id = this.createId();
|
|
424
|
+
checkFactoryValue(id, nonempty, "/id");
|
|
425
|
+
if (this.issued.has(id)) throw new ModelEditError("id_factory", "createId returned a duplicate ID");
|
|
426
|
+
this.issued.add(id);
|
|
427
|
+
return id;
|
|
428
|
+
}
|
|
429
|
+
/** 仅构造已隔离参数的空行;createRow/createTable 在返回前统一校验完整子树。 */
|
|
430
|
+
createEmptyRow(columnCount, height, cellStyle) {
|
|
431
|
+
const row = {
|
|
432
|
+
id: this.allocateId(),
|
|
433
|
+
kind: "row",
|
|
434
|
+
cells: [],
|
|
435
|
+
...isUndefined(height) ? {} : { height }
|
|
436
|
+
};
|
|
437
|
+
for (let column = 0; column < columnCount; column++) row.cells.push({
|
|
438
|
+
id: this.allocateId(),
|
|
439
|
+
kind: "cell",
|
|
440
|
+
blocks: [],
|
|
441
|
+
...isUndefined(cellStyle) ? {} : { style: cloneJsonData(cellStyle) }
|
|
442
|
+
});
|
|
443
|
+
return row;
|
|
444
|
+
}
|
|
445
|
+
/** 工厂销毁后明确拒绝所有创建。 */
|
|
446
|
+
requireRegistry() {
|
|
447
|
+
if (!this.registry || !this.createId) throw new ModelEditError("disposed", "NodeFactory is disposed");
|
|
448
|
+
return this.registry;
|
|
449
|
+
}
|
|
450
|
+
/** 检查局部形状、拥有身份与业务配置;外部样式、资产和绑定引用在插入时整体校验。 */
|
|
451
|
+
checkNode(node, rule) {
|
|
452
|
+
const registry = this.requireRegistry();
|
|
453
|
+
const kind = "kind" in node ? node.kind : void 0;
|
|
454
|
+
checkFactoryValue(node, rule ?? (kind === "attachment" ? attachmentRule : kind === "paragraph" || kind === "table" ? blockRule : inlineRule));
|
|
455
|
+
const issues = [], ids = /* @__PURE__ */ new Set();
|
|
456
|
+
/** 遍历新建子树的拥有关系,不展开共享定义。 */
|
|
457
|
+
const visit = (value, path = "") => {
|
|
458
|
+
const item = value;
|
|
459
|
+
if (ids.has(item.id)) issues.push({
|
|
460
|
+
path: `${path}/id`,
|
|
461
|
+
code: "duplicate_id",
|
|
462
|
+
message: `Duplicate ID: ${item.id}`
|
|
463
|
+
});
|
|
464
|
+
ids.add(item.id);
|
|
465
|
+
if (item.kind === "field" || item.kind === "pageWidget") {
|
|
466
|
+
const before = issues.length;
|
|
467
|
+
const field = value;
|
|
468
|
+
registry.validate(field.kind, field.widget, field.configVersion ?? 1, field.config ?? {}, `${path}/config`, issues);
|
|
469
|
+
if (includes(field.widget, ":") && isUndefined(field.configVersion)) issues.push({
|
|
470
|
+
path: `${path}/configVersion`,
|
|
471
|
+
code: "required",
|
|
472
|
+
message: "Extension needs explicit configVersion"
|
|
473
|
+
});
|
|
474
|
+
if (item.kind === "field") validateFieldConditions(value, path, issues, issues.length === before);
|
|
475
|
+
}
|
|
476
|
+
if ("type" in item && "range" in item) {
|
|
477
|
+
const region = value;
|
|
478
|
+
registry.validate("region", region.type, region.configVersion ?? 1, region.config ?? {}, `${path}/config`, issues);
|
|
479
|
+
if (region.variant) registry.validate("variant", region.variant.name, region.variant.version, region.variant.config, `${path}/variant/config`, issues, region.type);
|
|
480
|
+
}
|
|
481
|
+
for (const key of [
|
|
482
|
+
"content",
|
|
483
|
+
"rows",
|
|
484
|
+
"cells",
|
|
485
|
+
"columns",
|
|
486
|
+
"merges",
|
|
487
|
+
"regions",
|
|
488
|
+
"blocks",
|
|
489
|
+
"attachments",
|
|
490
|
+
"overlays"
|
|
491
|
+
]) item[key]?.forEach((child, i) => visit(child, `${path}/${key}/${i}`));
|
|
492
|
+
};
|
|
493
|
+
visit(node);
|
|
494
|
+
if (issues.length) throw new DocumentValidationError(issues);
|
|
495
|
+
return node;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
export { readFactoryOptions as a, DocumentValidationError as c, serializeDocument as d, checkFactoryValue as i, parseDocument as l, commonFieldWidgets as n, readFieldBinding as o, checkFactoryOptions as r, readRemovalOptions as s, NodeFactory as t, readDocument as u };
|
|
499
|
+
|
|
500
|
+
//# sourceMappingURL=NodeFactory-DzFnWaWf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeFactory-DzFnWaWf.js","names":[],"sources":["../../src/model/serialization/codec.ts","../../src/model/editor/factory-validation.ts","../../src/model/editor/NodeFactory.ts"],"sourcesContent":["/**\n * @file 原生文档读写边界:解析字符串、读取对象、保存同形 JSON,并统一抛出结构化校验错误。\n * 阅读定位:serialization/ · 原生文档和片段的读写边界。\n */\n\nimport { validateDocument } from '../validation/validation';\n\nimport type { DocumentDefinition } from '../types';\nimport type { ValidationIssue } from '../validation/schema';\nimport type { ValidationOptions } from '../validation/validation';\n\nexport class DocumentValidationError extends Error {\n readonly issues: readonly ValidationIssue[];\n /** 将全部结构化错误保留在异常上,message 只提供便于日志阅读的路径摘要。 */\n constructor(issues: readonly ValidationIssue[]) {\n super(issues.map((issue) => `${issue.path || '/'}: ${issue.message}`).join('\\n'));\n this.name = 'DocumentValidationError';\n this.issues = issues;\n }\n}\n\n/** 统一读取/保存边界校验,失败抛出结构化错误;不修改或自动修复输入。 */\nfunction checked(value: unknown, options?: ValidationOptions): DocumentDefinition {\n const result = validateDocument(value, options);\n if (!result.valid) throw new DocumentValidationError(result.issues);\n return result.document;\n}\n\n/** 读取文件字符串并校验原生协议;保留原 ID,语法错误也转换为结构化异常。 */\nexport function parseDocument(json: string, options?: ValidationOptions): DocumentDefinition {\n let value: unknown;\n try {\n value = JSON.parse(json);\n } catch {\n throw new DocumentValidationError([\n { path: '', code: 'json_syntax', message: 'Invalid JSON document' },\n ]);\n }\n return checked(value, options);\n}\n\n/** 读取 API 对象并隔离调用者持有的数据;内存和保存仍使用同一种结构。 */\nexport function readDocument(value: unknown, options?: ValidationOptions): DocumentDefinition {\n return JSON.parse(JSON.stringify(checked(value, options))) as DocumentDefinition;\n}\n\n/** 保存前校验同形文档;不转 XML,不夹带索引/历史,也不展开继承默认配置。 */\nexport function serializeDocument(\n document: DocumentDefinition,\n options?: ValidationOptions & {\n /** JSON 序列化缩进空格数。 */\n space?: number;\n },\n): string {\n checked(document, options);\n return JSON.stringify(document, null, options?.space);\n}\n","/**\n * @file 创建与删除参数校验:拒绝未知选项,统一字段绑定来源、删除策略及局部载荷检查。\n * 阅读定位:editor/ · 创建、编辑、事务、差量与历史。\n */\n\nimport includes from 'es-toolkit/compat/includes';\n\nimport { copyInputData, ModelEditError } from './editor-data';\nimport { DocumentValidationError } from '../serialization/codec';\nimport { bindingRule, boolean, isObject, nonempty, object, optional } from '../validation/schema';\n\nimport type { FieldBindingInput, FieldRemovalOptions } from './factory-types';\nimport type { Rule, ValidationIssue } from '../validation/schema';\n\n/** 所有高层删除入口使用同一组布尔选项,false 明确保留候选定义,未知键直接拒绝。 */\nexport function readRemovalOptions(input: FieldRemovalOptions): FieldRemovalOptions {\n const value = readFactoryOptions(input, ['removeUnusedBindings', 'removeUnusedAssets']);\n checkFactoryValue(\n value,\n object({ removeUnusedBindings: optional(boolean), removeUnusedAssets: optional(boolean) }),\n );\n return value;\n}\n\n/** 按现有协议规则检查局部值,失败携带完整结构化诊断。 */\nexport function checkFactoryValue(value: unknown, rule: Rule, path = ''): void {\n const issues: ValidationIssue[] = [];\n rule(value, path, issues);\n if (issues.length) throw new DocumentValidationError(issues);\n}\n\n/** 已完成 JSON 隔离的内部参数只核对对象形状和允许的键,不再复制。 */\nexport function checkFactoryOptions<T extends object>(value: T, keys: readonly string[]): T {\n if (!isObject(value))\n throw new ModelEditError('factory_options', 'Expected plain options object');\n for (const key of Object.keys(value))\n if (!includes(keys, key)) throw new ModelEditError('factory_options', `Unknown option: ${key}`);\n return value;\n}\n\n/** 公开参数先隔离 JSON,再核对原始键,未知键即使值为 undefined 也不静默丢弃。 */\nexport function readFactoryOptions<T extends object>(input: T, keys: readonly string[]): T {\n const value = copyInputData(input);\n checkFactoryOptions(input, keys);\n return value;\n}\n\n/** 绑定参数只允许一个来源,返回隔离后的明确声明或已有引用。 */\nexport function readFieldBinding(input: FieldBindingInput): FieldBindingInput {\n return checkFieldBinding(readFactoryOptions(input, ['binding', 'bindingId']));\n}\n\n/** 已隔离的字段声明只检查绑定来源及其业务结构。 */\nexport function checkFieldBinding(value: FieldBindingInput): FieldBindingInput {\n if (Object.hasOwn(value, 'binding') === Object.hasOwn(value, 'bindingId'))\n throw new ModelEditError('binding_input', 'Provide binding or bindingId');\n if ('binding' in value) checkFactoryValue(value.binding, bindingRule, '/binding');\n else checkFactoryValue(value.bindingId, nonempty, '/bindingId');\n return value;\n}\n","/**\n * @file 节点工厂:构造节点及必要的绑定或资产增量;插入文档和记录历史由编辑器负责。\n * 阅读定位:editor/ · 创建、编辑、事务、差量与历史。\n */\n\nimport includes from 'es-toolkit/compat/includes';\nimport isArray from 'es-toolkit/compat/isArray';\nimport isInteger from 'es-toolkit/compat/isInteger';\nimport isObjectValue from 'es-toolkit/compat/isObject';\nimport { isFunction, isNull, isString, isUndefined } from 'es-toolkit/predicate';\n\nimport { cloneJsonData, copyData, copyInputData, ModelEditError } from './editor-data';\nimport { checkFactoryValue, checkFieldBinding, readFactoryOptions } from './factory-validation';\nimport { ConfigRegistry } from '../config/config-registry';\nimport { DocumentValidationError } from '../serialization/codec';\nimport {\n attachmentRule,\n blockRule,\n cellRule,\n columnRule,\n imageAssetRule,\n inlineRule,\n mergeRule,\n nonempty,\n overlayRule,\n partRule,\n regionRule,\n rowRule,\n sectionRule,\n} from '../validation/schema';\nimport { validateFieldConditions } from '../validation/validation';\n\nimport type {\n Attachment,\n Block,\n BreakNode,\n Cell,\n CellRange,\n ChoiceOption,\n FieldNode,\n ImageNode,\n Inline,\n Merge,\n Overlay,\n PageWidget,\n Paragraph,\n Part,\n Region,\n Row,\n Section,\n StyledText,\n Table,\n TextNode,\n} from '../types';\nimport type {\n ChoiceCreationConfig,\n CreateChoiceOption,\n CreatedField,\n CreateParagraphOptions,\n CreateTableOptions,\n NodeFactoryOptions,\n} from './factory-types';\nimport type {\n BreakType,\n CreateAnyFieldOptions,\n CreatedImage,\n CreateExtensionFieldOptions,\n CreateImageOptions,\n CreateOverlayOptions,\n CreatePageWidgetOptions,\n CreatePartOptions,\n CreateSectionOptions,\n} from './node-edit-types';\nimport type {\n CreateCellOptions,\n CreateColumnOptions,\n CreateRegionOptions,\n CreateRowOptions,\n} from './table-edit-types';\nimport type { Rule, ValidationIssue } from '../validation/schema';\n\n/** 普通常用字段的明确白名单,不根据业务字段名猜测组件。 */\nexport const commonFieldWidgets = [\n 'input',\n 'number',\n 'checkbox',\n 'choice',\n 'date',\n 'time',\n 'date-time',\n 'file',\n 'image',\n 'seal',\n 'signature',\n 'user',\n 'org',\n 'relation',\n 'rdo-relation',\n 'sop-version',\n] as const;\nconst textKeys = ['textStyleId', 'textStyle'];\nconst appearanceKeys = [...textKeys, 'preferredSizePx', 'policy', 'attachments'];\n\n/** 只负责构造普通节点数据;一个工厂服务一批创建,不给每个节点再套类。 */\nexport class NodeFactory {\n /** 创建过的身份,防止外部工厂重复分配;不持有生成节点。 */\n private readonly issued = new Set<string>();\n /** 唯一的外部分配入口,销毁时释放闭包。 */\n private createId?: () => string;\n /** 闭合配置依赖,不保存计算结果。 */\n private registry?: ConfigRegistry;\n\n /** 依赖外部 ID 工厂;不创建随机身份、默认文档或运行时包装。 */\n constructor(options: NodeFactoryOptions) {\n if (!isFunction(options.createId))\n throw new ModelEditError('id_factory', 'createId is required');\n this.createId = options.createId;\n this.registry = options.registry ?? new ConfigRegistry();\n }\n\n /** 创建完整文字片段,不按字符拆对象;显式样式与调用方数据隔离。 */\n createText(text: string, options: StyledText = {}): TextNode {\n const copied = readFactoryOptions(options, textKeys);\n return this.checkNode({ id: this.allocateId(), kind: 'text', text, ...copied });\n }\n\n /** 创建空段或已有行内内容的段落,不生成空白占位符或展开默认样式。 */\n createParagraph(options: CreateParagraphOptions = {}): Paragraph {\n const copied = readFactoryOptions(options, [\n ...textKeys,\n 'paragraphStyleId',\n 'paragraphStyle',\n 'content',\n ]);\n if (!isUndefined(copied.content) && !isArray(copied.content))\n throw new ModelEditError('factory_options', 'content must be an array');\n return this.checkNode({\n ...copied,\n id: this.allocateId(),\n kind: 'paragraph',\n content: [...(copied.content ?? [])],\n });\n }\n\n /** 创建完整矩形物理网格;空格用空 blocks 表达,不凭空增加段落和文字。 */\n createTable(options: CreateTableOptions): Table {\n const copied = readFactoryOptions(options, [\n 'rowCount',\n 'columnCount',\n 'columnWidthsPx',\n 'rowHeight',\n 'tableStyleId',\n 'style',\n 'cellStyle',\n ]);\n for (const count of [copied.rowCount, copied.columnCount])\n if (!isInteger(count) || count < 1)\n throw new ModelEditError('table_size', 'Table dimensions must be positive integers');\n if (\n !isUndefined(copied.columnWidthsPx) &&\n (!isArray(copied.columnWidthsPx) || copied.columnWidthsPx.length !== copied.columnCount)\n )\n throw new ModelEditError('table_size', 'Column widths must match columnCount');\n const node: Table = {\n id: this.allocateId(),\n kind: 'table',\n columns: [],\n rows: [],\n merges: [],\n regions: [],\n ...(isUndefined(copied.tableStyleId) ? {} : { tableStyleId: copied.tableStyleId }),\n ...(isUndefined(copied.style) ? {} : { style: copied.style }),\n };\n for (let col = 0; col < copied.columnCount; col++)\n node.columns.push({\n id: this.allocateId(),\n ...(isUndefined(copied.columnWidthsPx) ? {} : { widthPx: copied.columnWidthsPx[col]! }),\n });\n for (let row = 0; row < copied.rowCount; row++) {\n node.rows.push(\n this.createEmptyRow(\n copied.columnCount,\n isUndefined(copied.rowHeight) ? undefined : cloneJsonData(copied.rowHeight),\n copied.cellStyle,\n ),\n );\n }\n return this.checkNode(node);\n }\n\n /** 创建实际新格,不为内部检查分配段落或表格身份。 */\n createCell(options: CreateCellOptions = {}): Cell {\n const copied = readFactoryOptions(options, ['blocks', 'style']);\n if (!isUndefined(copied.blocks) && !isArray(copied.blocks))\n throw new ModelEditError('factory_options', 'blocks must be an array');\n return this.checkNode(\n {\n id: this.allocateId(),\n kind: 'cell',\n blocks: [...(copied.blocks ?? [])],\n ...(isUndefined(copied.style) ? {} : { style: copied.style }),\n },\n cellRule,\n );\n }\n\n /** 创建完整物理行及空格,所有实际实体只分配一次身份。 */\n createRow(options: CreateRowOptions): Row {\n const copied = readFactoryOptions(options, ['columnCount', 'height', 'cellStyle']);\n if (!isInteger(copied.columnCount) || copied.columnCount < 1)\n throw new ModelEditError('table_size', 'columnCount must be a positive integer');\n return this.checkNode(\n this.createEmptyRow(copied.columnCount, copied.height, copied.cellStyle),\n rowRule,\n );\n }\n\n /** 创建列宽的唯一声明,不在各格重复保存宽度。 */\n createColumn(options: CreateColumnOptions = {}): Table['columns'][number] {\n const copied = readFactoryOptions(options, ['widthPx']);\n return this.checkNode({ id: this.allocateId(), ...copied }, columnRule);\n }\n\n /** 创建合并范围,主从格关系仍在查询时从物理网格派生。 */\n createMerge(range: CellRange): Merge {\n return this.checkNode({ id: this.allocateId(), range: copyData(range) }, mergeRule);\n }\n\n /** 创建已注册业务区域声明,不生成单元格上的反向标记。 */\n createRegion(options: CreateRegionOptions): Region {\n const copied = readFactoryOptions(options, [\n 'type',\n 'name',\n 'range',\n 'binding',\n 'configVersion',\n 'config',\n 'variant',\n 'parentRegionId',\n 'targetRegionId',\n ]);\n return this.checkNode({ id: this.allocateId(), ...copied }, regionRule);\n }\n\n /** 创建常用或注册扩展字段及绑定增量;choice 只补必需 options,扩展必须明确配置版本。 */\n createField(options: CreateAnyFieldOptions): CreatedField {\n const copied = readFactoryOptions(options, [\n 'widget',\n 'config',\n 'configVersion',\n 'binding',\n 'bindingId',\n ...appearanceKeys,\n ]);\n if (\n !isString(copied.widget) ||\n (!includes(commonFieldWidgets, copied.widget as (typeof commonFieldWidgets)[number]) &&\n !includes(copied.widget, ':'))\n )\n throw new ModelEditError('field_widget', 'Expected common or registered field widget');\n if (\n !isUndefined(copied.config) &&\n (isNull(copied.config) ||\n !isObjectValue(copied.config) ||\n isFunction(copied.config) ||\n isArray(copied.config))\n )\n throw new ModelEditError('field_config', 'config must be an object');\n const input = checkFieldBinding(copied);\n const bindings: CreatedField['bindings'] = Object.create(null);\n const bindingId = 'binding' in input ? this.allocateId() : input.bindingId;\n if ('binding' in input) bindings[bindingId] = input.binding!;\n const config =\n copied.widget === 'choice'\n ? {\n ...copied.config,\n options: (copied.config as ChoiceCreationConfig | undefined)?.options ?? [],\n }\n : copied.config;\n const node = {\n id: this.allocateId(),\n kind: 'field',\n widget: copied.widget,\n bindingId,\n ...(Object.hasOwn(copied, 'configVersion')\n ? { configVersion: (copied as CreateExtensionFieldOptions).configVersion }\n : {}),\n ...(isUndefined(config) ? {} : { config }),\n } as FieldNode;\n for (const key of appearanceKeys)\n if (Object.hasOwn(copied, key))\n Object.defineProperty(node, key, {\n value: copied[key as keyof typeof copied],\n enumerable: true,\n configurable: true,\n writable: true,\n });\n return { node: this.checkNode(node), bindings };\n }\n\n /** 创建图片及局部资产增量,明确引用不复制资源,不读取或下载二进制文件。 */\n createImage(options: CreateImageOptions): CreatedImage {\n const copied = readFactoryOptions(options, [\n 'asset',\n 'assetId',\n 'alt',\n 'preferredSizePx',\n 'fit',\n ]);\n if (Object.hasOwn(copied, 'asset') === Object.hasOwn(copied, 'assetId'))\n throw new ModelEditError('asset_input', 'Provide asset or assetId');\n const assets: CreatedImage['assets'] = Object.create(null);\n let assetId: string;\n if ('asset' in copied) {\n checkFactoryValue(copied.asset, imageAssetRule, '/asset');\n assetId = this.allocateId();\n assets[assetId] = copied.asset!;\n } else {\n checkFactoryValue(copied.assetId, nonempty, '/assetId');\n assetId = copied.assetId;\n }\n const node: ImageNode = {\n id: this.allocateId(),\n kind: 'image',\n assetId,\n ...(isUndefined(copied.alt) ? {} : { alt: copied.alt }),\n ...(isUndefined(copied.fit) ? {} : { fit: copied.fit }),\n ...(isUndefined(copied.preferredSizePx) ? {} : { preferredSizePx: copied.preferredSizePx }),\n };\n return { node: this.checkNode(node), assets };\n }\n\n /** 创建页码或已注册的页面组件,配置和默认能力仍由同一注册表解释。 */\n createPageWidget(options: CreatePageWidgetOptions): PageWidget {\n const copied = readFactoryOptions(options, [\n 'widget',\n 'config',\n 'configVersion',\n ...textKeys,\n 'preferredSizePx',\n 'policy',\n ]);\n return this.checkNode({ id: this.allocateId(), kind: 'pageWidget', ...copied } as PageWidget);\n }\n\n /** 创建显式换行或分页,不把自动排版结果保存进模型。 */\n createBreak(breakType: BreakType): BreakNode {\n return this.checkNode({ id: this.allocateId(), kind: 'break', breakType });\n }\n\n /** 创建共享页眉/页脚拥有内容,不为各章节重复创建同一部件。 */\n createPart(kind: Part['kind'], options: CreatePartOptions = {}): Part {\n const copied = readFactoryOptions(options, ['blocks']);\n if (!isUndefined(copied.blocks) && !isArray(copied.blocks))\n throw new ModelEditError('factory_options', 'blocks must be an array');\n return this.checkNode(\n { id: this.allocateId(), kind, blocks: [...(copied.blocks ?? [])] },\n partRule,\n );\n }\n\n /** 创建锚定浮层,优先尺寸与层级均只保存调用方明确设置的值。 */\n createOverlay(options: CreateOverlayOptions): Overlay {\n const copied = readFactoryOptions(options, ['anchor', 'blocks', 'preferredSizePx', 'zIndex']);\n if (!isUndefined(copied.blocks) && !isArray(copied.blocks))\n throw new ModelEditError('factory_options', 'blocks must be an array');\n return this.checkNode(\n { ...copied, id: this.allocateId(), kind: 'overlay', blocks: [...(copied.blocks ?? [])] },\n overlayRule,\n );\n }\n\n /** 创建实际章节及已有拥有内容,不默认生成空段落、部件或分页对象。 */\n createSection(options: CreateSectionOptions): Section {\n const copied = readFactoryOptions(options, [\n 'page',\n 'headerSlots',\n 'footerSlots',\n 'blocks',\n 'overlays',\n ]);\n for (const value of [copied.blocks, copied.overlays])\n if (!isUndefined(value) && !isArray(value))\n throw new ModelEditError('factory_options', 'Owned content must be an array');\n return this.checkNode(\n {\n ...copied,\n id: this.allocateId(),\n kind: 'section',\n blocks: [...(copied.blocks ?? [])],\n overlays: [...(copied.overlays ?? [])],\n },\n sectionRule,\n );\n }\n\n /** 创建一个新选项;局部 ID 在默认项和附属条件中复用,不保存 defaultSelected 副本。 */\n createChoiceOption(options: CreateChoiceOption): ChoiceOption {\n const copied = readFactoryOptions(options, ['label', 'value', 'display']);\n const option = { id: this.allocateId(), ...copied };\n const issues: ValidationIssue[] = [];\n this.registry!.validate('field', 'choice', 1, { options: [option] }, '/config', issues);\n if (issues.length) throw new DocumentValidationError(issues);\n return option;\n }\n\n /** 创建附属内容容器,条件与父字段是否匹配由编辑器提交时检查。 */\n createAttachment(when: Attachment['when'], blocks: readonly Block[] = []): Attachment {\n const node: Attachment = {\n id: this.allocateId(),\n kind: 'attachment',\n when: copyData(when),\n blocks: copyInputData([...blocks]),\n };\n return this.checkNode(node);\n }\n\n /** 释放身份集合与外部回调,已有返回节点不受影响。 */\n dispose(): void {\n this.issued.clear();\n this.createId = undefined;\n this.registry = undefined;\n }\n\n /** 为一个新实体分配身份;坏工厂直接失败,不循环猜测或重试。 */\n private allocateId(): string {\n this.requireRegistry();\n const id = this.createId!();\n checkFactoryValue(id, nonempty, '/id');\n if (this.issued.has(id))\n throw new ModelEditError('id_factory', 'createId returned a duplicate ID');\n this.issued.add(id);\n return id;\n }\n\n /** 仅构造已隔离参数的空行;createRow/createTable 在返回前统一校验完整子树。 */\n private createEmptyRow(\n columnCount: number,\n height?: Row['height'],\n cellStyle?: Cell['style'],\n ): Row {\n const row: Row = {\n id: this.allocateId(),\n kind: 'row',\n cells: [],\n ...(isUndefined(height) ? {} : { height }),\n };\n for (let column = 0; column < columnCount; column++)\n row.cells.push({\n id: this.allocateId(),\n kind: 'cell',\n blocks: [],\n ...(isUndefined(cellStyle) ? {} : { style: cloneJsonData(cellStyle) }),\n });\n return row;\n }\n\n /** 工厂销毁后明确拒绝所有创建。 */\n private requireRegistry(): ConfigRegistry {\n if (!this.registry || !this.createId)\n throw new ModelEditError('disposed', 'NodeFactory is disposed');\n return this.registry;\n }\n\n /** 检查局部形状、拥有身份与业务配置;外部样式、资产和绑定引用在插入时整体校验。 */\n private checkNode<\n T extends\n | Inline\n | Block\n | Attachment\n | Cell\n | Row\n | Merge\n | Region\n | Part\n | Section\n | Overlay\n | Table['columns'][number],\n >(node: T, rule?: Rule): T {\n const registry = this.requireRegistry();\n const kind = 'kind' in node ? node.kind : undefined;\n checkFactoryValue(\n node,\n rule ??\n (kind === 'attachment'\n ? attachmentRule\n : kind === 'paragraph' || kind === 'table'\n ? blockRule\n : inlineRule),\n );\n const issues: ValidationIssue[] = [],\n ids = new Set<string>();\n /** 遍历新建子树的拥有关系,不展开共享定义。 */\n const visit = (value: object, path = ''): void => {\n const item = value as Record<string, unknown> & { id: string };\n if (ids.has(item.id))\n issues.push({\n path: `${path}/id`,\n code: 'duplicate_id',\n message: `Duplicate ID: ${item.id}`,\n });\n ids.add(item.id);\n if (item.kind === 'field' || item.kind === 'pageWidget') {\n const before = issues.length;\n const field = value as FieldNode | PageWidget;\n registry.validate(\n field.kind,\n field.widget,\n field.configVersion ?? 1,\n field.config ?? {},\n `${path}/config`,\n issues,\n );\n if (includes(field.widget, ':') && isUndefined(field.configVersion))\n issues.push({\n path: `${path}/configVersion`,\n code: 'required',\n message: 'Extension needs explicit configVersion',\n });\n if (item.kind === 'field')\n validateFieldConditions(value as FieldNode, path, issues, issues.length === before);\n }\n if ('type' in item && 'range' in item) {\n const region = value as Region;\n registry.validate(\n 'region',\n region.type,\n region.configVersion ?? 1,\n region.config ?? {},\n `${path}/config`,\n issues,\n );\n if (region.variant)\n registry.validate(\n 'variant',\n region.variant.name,\n region.variant.version,\n region.variant.config,\n `${path}/variant/config`,\n issues,\n region.type,\n );\n }\n for (const key of [\n 'content',\n 'rows',\n 'cells',\n 'columns',\n 'merges',\n 'regions',\n 'blocks',\n 'attachments',\n 'overlays',\n ])\n (item[key] as readonly object[] | undefined)?.forEach((child, i) =>\n visit(child, `${path}/${key}/${i}`),\n );\n };\n visit(node);\n if (issues.length) throw new DocumentValidationError(issues);\n return node;\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,0BAAb,cAA6C,MAAM;CACjD;;CAEA,YAAY,QAAoC;EAC9C,MAAM,OAAO,KAAK,UAAU,GAAG,MAAM,QAAQ,IAAI,IAAI,MAAM,SAAS,CAAC,CAAC,KAAK,IAAI,CAAC;EAChF,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;;AAGA,SAAS,QAAQ,OAAgB,SAAiD;CAChF,MAAM,SAAS,iBAAiB,OAAO,OAAO;CAC9C,IAAI,CAAC,OAAO,OAAO,MAAM,IAAI,wBAAwB,OAAO,MAAM;CAClE,OAAO,OAAO;AAChB;;AAGA,SAAgB,cAAc,MAAc,SAAiD;CAC3F,IAAI;CACJ,IAAI;EACF,QAAQ,KAAK,MAAM,IAAI;CACzB,QAAQ;EACN,MAAM,IAAI,wBAAwB,CAChC;GAAE,MAAM;GAAI,MAAM;GAAe,SAAS;EAAwB,CACpE,CAAC;CACH;CACA,OAAO,QAAQ,OAAO,OAAO;AAC/B;;AAGA,SAAgB,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