@gct-paas/word 1.0.2 → 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-CXoezurC.js → ModelEditor-DqavEAJg.js} +113 -4
- 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-DY0wE3Uz.js → browser-OAJIVM8O.js} +412 -185
- package/dist/chunks/browser-OAJIVM8O.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-Dz96Ca_-.js → sdk-BmwE5mZn.js} +1069 -615
- 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-Bq4hbWKT.js → types-CMkQ6Lvg.js} +122 -6
- 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 +6 -5
- package/dist/legacy.js +1 -0
- package/dist/platform.js +2 -2
- package/dist/style.css +760 -480
- 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/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/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 +2101 -4470
- package/dist/vue.js.map +1 -1
- package/package.json +9 -3
- package/dist/chunks/ModelEditor-CXoezurC.js.map +0 -1
- package/dist/chunks/NodeFactory-D9gVGSok.js.map +0 -1
- package/dist/chunks/browser-DY0wE3Uz.js.map +0 -1
- package/dist/chunks/sdk-Dz96Ca_-.js.map +0 -1
- package/dist/chunks/types-Bq4hbWKT.js.map +0 -1
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as positionX, $t as isCommonField, A as selectionFallbacks, An as formatTsv, At as isReferenceScanField, B as fieldBehaviorDefault, Bn as assertLayoutTextMeasureRequest, Bt as authenticatedSignature, Cn as isClosedDataContainer, Ct as normalizeReferenceValue, Dn as isUninitializedDataValue, Dt as referenceIds, E as snapshotFieldDragDefinition, En as isRequiredDataValueMissing, Et as referenceContext, F as editingAllowed, Fn as snapshotLayoutVersion, Ft as isMaterialLotBinding, G as sameBusinessField, Gt as resourceContext, H as resolveBooleanOptionLabel, Ht as signatureValues, In as layoutImageSourceKey, It as isNamedLotBinding, J as resolveFieldTarget, K as afterFieldSettlement, Kt as resourceLimits, L as designRegionTypes, Ln as LayoutContractError, Lt as lotReference, M as assertAdaptiveImageCellWritable, Mn as tsvClipboardLimits, Mt as referenceScanUpdates, N as hasAdaptiveImageCell, Nn as sameLayoutIdentity, Nt as nativeObjectKey, O as freezeSelection, On as readDataValueInput, Ot as referenceOptions, P as assertOwnedEditingAllowed, Pn as sameLayoutVersion, Pt as nativeObjectRootField, Q as hitPosition, Qt as fieldBehavior, R as designRegionVariants, Rn as assertFiniteLayoutNumber, Rt as nativeSelectedReferenceValue, S as EditorObjects, Sn as dataValueState, St as parseSealValue, T as resolveFieldDrop, Tt as referenceBehavior, U as systemDate, Ut as normalizeResourceValue, V as fieldBehaviorLabel, Vn as assertLayoutTextMeasurement, Vt as signatureText, W as readBusinessField, Wt as resourceBehavior, X as TextFlow, Xt as validateResourceFiles, Y as writeFieldValue, Yt as resourceValues, Z as TextFlowError, Zt as commonFieldDeclaration, _ as readFieldOptionInput, _n as assertValidDataValue, _t as authenticatedSeal, a as writeGuardedFieldText, an as encodeDataFieldValue, at as positionSourceId, b as toggledFieldOptionIds, bn as invalidDataNumberText, bt as sealStampKeys, c as fieldNumberSettings, cn as readDataBoolean, ct as sameTextSource, d as isIncompleteFieldNumber, en as isFieldTextInput, et as rectDistance, f as validateFieldNumber, fn as resolveDataDefaultFrom, g as readFieldChoiceInput, gn as DataValueError, gt as pointsToLayoutPx, hn as shouldInitializeDataValue, ht as millimetersToLayoutPx, i as validateFieldTextDraft, in as encodeDataChoice, it as signatureGraphicUrl, j as adaptiveImageCellMessage, jn as parseTsv, jt as referenceScanPaths, k as mapSelection, kt as referenceValueIds, l as fieldNumberText, ln as encodeDataCollection, lt as textSourceId, m as readFieldSignatureInput, mn as resolveDataValueUpdate, n as readFieldTextInput, nn as assertDataNumberPrecision, nt as visualAffinity, o as fieldValidationDescription, on as normalizeDataBoolean, ot as sameDomain, p as assertFieldSignatureInput, pn as resolveDataDisplay, pt as layoutPxToMillimeters, q as readFieldTarget, qt as resourceName, r as sameFieldTextInput, rn as dataParameterNumberKind, rt as signatureGraphic, s as FieldNumberError, sn as normalizeDataParameterNumber, st as samePosition, t as nativeTableRowBatchLimit, tn as nativeFieldBehavior, tt as sourceBoundaryIndex, u as fieldNumberValue, un as emptyDataValue, vn as dataValueIssuesFromError, vt as nativeSealText, w as designFieldDefaults, wn as isEmptyDataValue, wt as recordReference, x as writeGuardedFieldChoice, xt as isSealPosition, yn as findInvalidDataNumbers, yt as nativeSealValueKind, z as choiceSelection, zn as assertLayoutSize, zt as referenceInputIdentity } from "./types-CMkQ6Lvg.js";
|
|
2
2
|
import { a as contentBlockLeaves, s as contentLeaves, u as createUuid } from "./change-set-DgfKTJ6d.js";
|
|
3
3
|
import { t as waitForAbortable } from "./abortable-D4G3Ib7H.js";
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as
|
|
4
|
+
import { _ as equalData, d as repeatingTableSettings, f as repeatingTableVariants, g as copyInputData, m as cloneJsonData, v as freezeData } from "./validation-DkCy8wHI.js";
|
|
5
|
+
import { _ as replacePathIndexPlaceholders, a as readParagraphFormatUpdate, c as indexTablePositions, d as rectangleFromPositions, g as parseValuePath, h as mergeStyle, i as patchTextDeclaration, l as intersectsRectangle, n as resolveKeepExceptionHighlight, o as readTextFormatUpdate, s as containsRectangle, t as ModelEditor, u as isOrdinaryTable } from "./ModelEditor-DqavEAJg.js";
|
|
6
|
+
import { n as commonFieldWidgets, o as readFieldBinding, t as NodeFactory } from "./NodeFactory-DzFnWaWf.js";
|
|
7
|
+
import { n as tableBorderWidthsPx, t as defaultTableBorderColor } from "./table-borders-B9bZMj5o.js";
|
|
7
8
|
import { groupBy, maxBy, sortBy, uniq } from "es-toolkit/array";
|
|
8
9
|
import { isEqual, isPlainObject } from "es-toolkit/predicate";
|
|
10
|
+
import dayjs from "dayjs";
|
|
9
11
|
import { cloneDeep, escapeRegExp, groupBy as groupBy$1, isEqual as isEqual$1, isPlainObject as isPlainObject$1, isPromise, omit, sortBy as sortBy$1, uniq as uniq$1 } from "es-toolkit";
|
|
10
12
|
import BigNumber from "bignumber.js";
|
|
11
13
|
import { cloneDeep as cloneDeep$1, omit as omit$1, pick } from "es-toolkit/object";
|
|
12
|
-
import { sum, sumBy } from "es-toolkit/math";
|
|
13
14
|
import sortedIndex from "es-toolkit/compat/sortedIndex";
|
|
14
15
|
import sortBy$2 from "es-toolkit/compat/sortBy";
|
|
16
|
+
import { sum, sumBy } from "es-toolkit/math";
|
|
15
17
|
import sortedLastIndex from "es-toolkit/compat/sortedLastIndex";
|
|
16
18
|
import sortedIndexBy from "es-toolkit/compat/sortedIndexBy";
|
|
17
19
|
import { escapeRegExp as escapeRegExp$1 } from "es-toolkit/string";
|
|
18
|
-
import dayjs from "dayjs";
|
|
19
20
|
import get from "es-toolkit/compat/get";
|
|
20
21
|
import set from "es-toolkit/compat/set";
|
|
21
22
|
import toPath from "es-toolkit/compat/toPath";
|
|
23
|
+
import { sha256 } from "js-sha256";
|
|
22
24
|
// src/runtime/interaction/browse/media-preview.ts
|
|
23
25
|
/** @file 预览只读取已有资源,打印与只读模式不走可编辑输入接口。 */
|
|
24
26
|
function mediaPreview(options, snapshot, fieldId, instanceKey) {
|
|
@@ -39,6 +41,7 @@ function mediaPreview(options, snapshot, fieldId, instanceKey) {
|
|
|
39
41
|
const entries = field.widget === "signature" ? signatureValues(target.value).map((record) => ({
|
|
40
42
|
reference: record.url ?? "",
|
|
41
43
|
name: record.username || "签名",
|
|
44
|
+
signatureDate: record.time !== void 0 && dayjs(record.time).isValid() ? dayjs(record.time).format("YYYY-MM-DD") : "",
|
|
42
45
|
url: record.url ? form.services.fields.signatureUrl(fieldId, target.valuePath, record.url) : void 0
|
|
43
46
|
})) : resourceValues(target.value).map((reference) => ({
|
|
44
47
|
reference,
|
|
@@ -48,7 +51,12 @@ function mediaPreview(options, snapshot, fieldId, instanceKey) {
|
|
|
48
51
|
return entries.length ? Object.freeze({
|
|
49
52
|
kind: field.widget,
|
|
50
53
|
label: field.config?.label ?? target.declaration.binding.source.fieldLink,
|
|
51
|
-
entries: Object.freeze(entries)
|
|
54
|
+
entries: Object.freeze(entries),
|
|
55
|
+
...field.widget === "signature" ? { signature: {
|
|
56
|
+
...target.declaration.field.preferredSizePx,
|
|
57
|
+
vertical: field.config?.imageDirection === "vertical",
|
|
58
|
+
fallback: field.config?.fallback ?? "name"
|
|
59
|
+
} } : {}
|
|
52
60
|
}) : void 0;
|
|
53
61
|
} catch {
|
|
54
62
|
return;
|
|
@@ -402,6 +410,21 @@ var UnsupportedLayoutError = class extends Error {
|
|
|
402
410
|
this.nodeId = nodeId;
|
|
403
411
|
}
|
|
404
412
|
};
|
|
413
|
+
// src/shared/text/shading.ts
|
|
414
|
+
/** clear 只显示底色,nil 明确取消底纹,solid 使用前景色。 */
|
|
415
|
+
function textShadingColor(shading) {
|
|
416
|
+
if (shading?.pattern === "nil") return "transparent";
|
|
417
|
+
if (shading?.pattern === "solid") return shading.color ?? "#000000";
|
|
418
|
+
return shading?.fill;
|
|
419
|
+
}
|
|
420
|
+
/** 纯色与明确取消底纹都已支持,只有实际图案需要报告外观差异。 */
|
|
421
|
+
function hasTextShadingPattern(shading) {
|
|
422
|
+
return !!shading?.pattern && ![
|
|
423
|
+
"clear",
|
|
424
|
+
"nil",
|
|
425
|
+
"solid"
|
|
426
|
+
].includes(shading.pattern);
|
|
427
|
+
}
|
|
405
428
|
// src/layout/styles/resolve-text-style.ts
|
|
406
429
|
/** @file 业务字段与原生文字共用有效绘制样式解释,不保存任何文档。 */
|
|
407
430
|
/** 按 Unicode 脚本选择实际字体,保持同脚本连续片段合并。 */
|
|
@@ -429,7 +452,7 @@ function resolvePaint(style, defaults, sample = "", fonts) {
|
|
|
429
452
|
fontStyle,
|
|
430
453
|
color: style.color ?? defaults.color,
|
|
431
454
|
letterSpacingPx: style.letterSpacingPx ?? defaults.letterSpacingPx,
|
|
432
|
-
backgroundColor: style.highlightColor ?? style.shading
|
|
455
|
+
backgroundColor: style.highlightColor ?? textShadingColor(style.shading) ?? defaults.backgroundColor,
|
|
433
456
|
underline: style.underline ?? defaults.underline,
|
|
434
457
|
strike: style.strike ?? defaults.strike,
|
|
435
458
|
doubleStrike: style.doubleStrike ?? defaults.doubleStrike,
|
|
@@ -438,9 +461,357 @@ function resolvePaint(style, defaults, sample = "", fonts) {
|
|
|
438
461
|
...style.kerningMinSizePt === void 0 ? {} : { kerning: size >= pointsToLayoutPx(style.kerningMinSizePt) ? "normal" : "none" }
|
|
439
462
|
};
|
|
440
463
|
}
|
|
464
|
+
// src/layout/engine/atoms/control-text.ts
|
|
465
|
+
/** 字素算法只持有分割器,不保留字段或文字。 */
|
|
466
|
+
var segments = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
467
|
+
/** 字段内按合法字素换行,空行保留;不创建字符节点或内部模型地址。 */
|
|
468
|
+
function wrapTextRanges(text, width, presentation, measurer) {
|
|
469
|
+
const lines = [];
|
|
470
|
+
for (const match of text.matchAll(/([^\r\n]*)(\r\n|[\r\n]|$)/g)) {
|
|
471
|
+
if (match.index === text.length && text.length > 0 && !/[\r\n]$/.test(text)) break;
|
|
472
|
+
const part = match[1];
|
|
473
|
+
const source = match.index;
|
|
474
|
+
if (!part.length) {
|
|
475
|
+
lines.push({
|
|
476
|
+
text: "",
|
|
477
|
+
from: source,
|
|
478
|
+
to: source
|
|
479
|
+
});
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const boundaries = [0, ...Array.from(segments.segment(part), (item) => item.index + item.segment.length)];
|
|
483
|
+
let begin = 0;
|
|
484
|
+
while (begin < boundaries.length - 1) {
|
|
485
|
+
let low = begin, high = boundaries.length - 1;
|
|
486
|
+
while (low < high) {
|
|
487
|
+
const middle = Math.ceil((low + high) / 2);
|
|
488
|
+
const advance = measurer.measureWidth({
|
|
489
|
+
text: part.slice(boundaries[begin], boundaries[middle]),
|
|
490
|
+
style: presentation.style,
|
|
491
|
+
direction: "ltr"
|
|
492
|
+
});
|
|
493
|
+
if (!Number.isFinite(advance) || advance < 0) throw new Error("字段文字度量返回无效宽度");
|
|
494
|
+
if (advance <= width) low = middle;
|
|
495
|
+
else high = middle - 1;
|
|
496
|
+
}
|
|
497
|
+
const end = Math.max(begin + 1, low);
|
|
498
|
+
lines.push({
|
|
499
|
+
text: part.slice(boundaries[begin], boundaries[end]),
|
|
500
|
+
from: source + boundaries[begin],
|
|
501
|
+
to: source + boundaries[end]
|
|
502
|
+
});
|
|
503
|
+
begin = end;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return lines;
|
|
507
|
+
}
|
|
508
|
+
/** 通用标签继续使用相同断行算法,字段额外保留原文区间供活动输入定位。 */
|
|
509
|
+
function wrapText(text, width, presentation, measurer) {
|
|
510
|
+
return wrapTextRanges(text, width, presentation, measurer).map((line) => line.text);
|
|
511
|
+
}
|
|
512
|
+
// src/layout/engine/atoms/diagonal.ts
|
|
513
|
+
/** @file 斜线表头的纯几何;两栏/四种三栏顶点共用最终尺寸与分区裁剪。 */
|
|
514
|
+
/** 整格斜线只用于唯一图形的单元格,不挤占或伸缩其他正文。 */
|
|
515
|
+
function isDiagonalCell(blocks) {
|
|
516
|
+
const block = blocks.length === 1 ? blocks[0] : void 0;
|
|
517
|
+
if (!block || typeof block !== "object" || !("kind" in block) || block.kind !== "paragraph" || !("content" in block) || !Array.isArray(block.content)) return false;
|
|
518
|
+
const content = block.content, node = content.length === 1 ? content[0] : void 0;
|
|
519
|
+
return !!node && typeof node === "object" && "kind" in node && node.kind === "pageWidget" && "widget" in node && node.widget === "diagonal";
|
|
520
|
+
}
|
|
521
|
+
/** 整格图形在行高最终分配后取真实尺寸,不把配置尺寸强行变成行高。 */
|
|
522
|
+
function fillCellDiagonal(blocks, width, height) {
|
|
523
|
+
const block = blocks.length === 1 ? blocks[0] : void 0, line = block?.kind === "paragraph" && block.lines.length === 1 ? block.lines[0] : void 0, piece = line?.pieces.length === 1 ? line.pieces[0] : void 0;
|
|
524
|
+
if (!block || block.kind !== "paragraph" || !line || piece?.kind !== "pageWidget" || piece.widget.content.kind !== "diagonal" || !piece.widget.content.fillCell) return blocks;
|
|
525
|
+
const widget = {
|
|
526
|
+
...piece.widget,
|
|
527
|
+
width,
|
|
528
|
+
height,
|
|
529
|
+
baseline: height
|
|
530
|
+
};
|
|
531
|
+
return [{
|
|
532
|
+
...block,
|
|
533
|
+
width,
|
|
534
|
+
height,
|
|
535
|
+
lines: [{
|
|
536
|
+
...line,
|
|
537
|
+
width,
|
|
538
|
+
availableWidth: width,
|
|
539
|
+
height,
|
|
540
|
+
baseline: height,
|
|
541
|
+
indent: 0,
|
|
542
|
+
pieces: [{
|
|
543
|
+
...piece,
|
|
544
|
+
widget
|
|
545
|
+
}]
|
|
546
|
+
}]
|
|
547
|
+
}];
|
|
548
|
+
}
|
|
549
|
+
/** 镜像角点名称与几何使用同一规则,避免文字分区与线条错位。 */
|
|
550
|
+
function cornerName(x, y) {
|
|
551
|
+
return `${y ? "bottom" : "top"}-${x ? "right" : "left"}`;
|
|
552
|
+
}
|
|
553
|
+
/** 按当前真实尺寸一次性计算线、文字和对应分区,绘制不重新解释配置。 */
|
|
554
|
+
function layoutDiagonal(content, width, height, paintStyleKey, paint, measurer) {
|
|
555
|
+
const w = width, h = height, three = content.columns === 3, flipX = three ? content.vertex.endsWith("right") : content.direction === "backward", flipY = three && content.vertex.startsWith("bottom");
|
|
556
|
+
/** 线条与分区顶点都从同一坐标变换得到。 */
|
|
557
|
+
function point(x, y) {
|
|
558
|
+
return {
|
|
559
|
+
x: flipX ? w - x : x,
|
|
560
|
+
y: flipY ? h - y : y
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
const origin = point(0, 0), endA = point(w, three ? h * .4 : h), endB = point(w * .4, h);
|
|
564
|
+
/** 统一的已解析线条,不借用旧 ImageWidget。 */
|
|
565
|
+
function line(end) {
|
|
566
|
+
return {
|
|
567
|
+
kind: "line",
|
|
568
|
+
x1: origin.x,
|
|
569
|
+
y1: origin.y,
|
|
570
|
+
x2: end.x,
|
|
571
|
+
y2: end.y,
|
|
572
|
+
widthPx: 1,
|
|
573
|
+
color: "#808080",
|
|
574
|
+
style: "solid"
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const regions = /* @__PURE__ */ new Map();
|
|
578
|
+
regions.set(cornerName(!flipX, flipY), [
|
|
579
|
+
origin,
|
|
580
|
+
point(w, 0),
|
|
581
|
+
endA
|
|
582
|
+
]);
|
|
583
|
+
if (three) {
|
|
584
|
+
regions.set(cornerName(!flipX, !flipY), [
|
|
585
|
+
origin,
|
|
586
|
+
endA,
|
|
587
|
+
point(w, h),
|
|
588
|
+
endB
|
|
589
|
+
]);
|
|
590
|
+
regions.set(cornerName(flipX, !flipY), [
|
|
591
|
+
origin,
|
|
592
|
+
endB,
|
|
593
|
+
point(0, h)
|
|
594
|
+
]);
|
|
595
|
+
} else regions.set(cornerName(flipX, !flipY), [
|
|
596
|
+
origin,
|
|
597
|
+
endA,
|
|
598
|
+
point(0, h)
|
|
599
|
+
]);
|
|
600
|
+
const corners = three ? {
|
|
601
|
+
"top-left": [
|
|
602
|
+
"top-right",
|
|
603
|
+
"bottom-right",
|
|
604
|
+
"bottom-left"
|
|
605
|
+
],
|
|
606
|
+
"top-right": [
|
|
607
|
+
"top-left",
|
|
608
|
+
"bottom-left",
|
|
609
|
+
"bottom-right"
|
|
610
|
+
],
|
|
611
|
+
"bottom-left": [
|
|
612
|
+
"top-left",
|
|
613
|
+
"top-right",
|
|
614
|
+
"bottom-right"
|
|
615
|
+
],
|
|
616
|
+
"bottom-right": [
|
|
617
|
+
"top-right",
|
|
618
|
+
"top-left",
|
|
619
|
+
"bottom-left"
|
|
620
|
+
]
|
|
621
|
+
}[content.vertex] : flipX ? ["top-left", "bottom-right"] : ["top-right", "bottom-left"];
|
|
622
|
+
const metrics = measurer.measure({
|
|
623
|
+
text: "",
|
|
624
|
+
style: paint,
|
|
625
|
+
direction: "ltr"
|
|
626
|
+
}), lineHeight = (metrics.ascent + metrics.descent) * 1.2, boxWidth = Math.max(1, Math.min(w * .5, w - 8));
|
|
627
|
+
return {
|
|
628
|
+
kind: "diagonal",
|
|
629
|
+
paintStyleKey,
|
|
630
|
+
lines: three ? [line(endA), line(endB)] : [line(endA)],
|
|
631
|
+
slots: corners.map((corner, index) => {
|
|
632
|
+
const rows = wrapText(content.labels[three ? index : index === 0 ? 0 : 2] ?? "", boxWidth, { style: paint }, measurer), right = corner.endsWith("right"), x = right ? w - 4 - boxWidth : 4, y = corner.startsWith("bottom") ? Math.max(4, h - 4 - rows.length * lineHeight) : 4;
|
|
633
|
+
return {
|
|
634
|
+
clip: regions.get(corner),
|
|
635
|
+
texts: rows.map((text, row) => {
|
|
636
|
+
const advance = measurer.measureWidth({
|
|
637
|
+
text,
|
|
638
|
+
style: paint,
|
|
639
|
+
direction: "ltr"
|
|
640
|
+
});
|
|
641
|
+
return {
|
|
642
|
+
text,
|
|
643
|
+
width: advance,
|
|
644
|
+
x: x + (right ? Math.max(0, boxWidth - advance) : 0),
|
|
645
|
+
baseline: y + metrics.ascent + row * lineHeight
|
|
646
|
+
};
|
|
647
|
+
})
|
|
648
|
+
};
|
|
649
|
+
})
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
// src/layout/engine/paragraph/justify-line.ts
|
|
653
|
+
/** @file 断行后的间距扩展;源字素、原子尺寸和结果片段保持,绘制与停靠共用最终几何。 */
|
|
654
|
+
/** 只扩展普通及全角空白,不把不换行空格当作可丢弃的尾随空白。 */
|
|
655
|
+
var space = (text) => /^[ \t\u3000]+$/u.test(text);
|
|
656
|
+
/** 东亚文本提供字间机会;连写脚本仅使用词间空白,不切断连接。 */
|
|
657
|
+
var eastAsian = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
658
|
+
/** 当前可识别的连写脚本不能被分散对齐拆出字内空隙。 */
|
|
659
|
+
var cursive = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Nko}\p{Script=Mandaic}\p{Script=Mongolian}\p{Script=Phags_Pa}]/u;
|
|
660
|
+
/** 一行的自然片段推进,不把对齐间隔写进控件或图片尺寸。 */
|
|
661
|
+
function width(piece) {
|
|
662
|
+
return piece.kind === "text" ? piece.metrics.advanceWidth : piece.kind === "control" ? piece.control.width : piece.kind === "image" ? piece.image.frame.width : piece.kind === "pageWidget" ? piece.widget.width : piece.advanceWidth ?? 0;
|
|
663
|
+
}
|
|
664
|
+
/** 普通文字直接借用源相对偏移,只有长度变换才使用额外的展示映射。 */
|
|
665
|
+
function displayOffset(piece, boundary) {
|
|
666
|
+
return piece.displayOffsets?.[boundary] ?? piece.metrics.caretMap.offsets[boundary] - piece.source.from;
|
|
667
|
+
}
|
|
668
|
+
/** 收集临时排版单位,段落内零宽锚点不引入额外分散机会。 */
|
|
669
|
+
function units$2(line) {
|
|
670
|
+
const result = [];
|
|
671
|
+
for (const [index, piece] of line.pieces.entries()) if (piece.kind === "text") for (let at = 1; at < piece.metrics.caretMap.offsets.length; at++) {
|
|
672
|
+
const text = piece.text.slice(displayOffset(piece, at - 1), displayOffset(piece, at));
|
|
673
|
+
if (text) result.push({
|
|
674
|
+
piece: index,
|
|
675
|
+
boundary: at,
|
|
676
|
+
text
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
else if (piece.kind === "anchor") {
|
|
680
|
+
if (width(piece)) result.push({
|
|
681
|
+
piece: index,
|
|
682
|
+
text: " "
|
|
683
|
+
});
|
|
684
|
+
} else result.push({
|
|
685
|
+
piece: index,
|
|
686
|
+
text: ""
|
|
687
|
+
});
|
|
688
|
+
return result;
|
|
689
|
+
}
|
|
690
|
+
/** 不在源字素内部、连接控制符或开闭标点禁止边界扩展;样式节点边界不改变机会。 */
|
|
691
|
+
function opportunity(a, b, distribute) {
|
|
692
|
+
if (/[\u00a0\u202f\u2060\ufeff]/u.test(a.text + b.text)) return false;
|
|
693
|
+
if ("([{([{《〈「『【〔〖“‘".includes(a.text) || ")]})]}》〉」』】〕〗”’、。,;:!?,.!?;:".includes(b.text)) return false;
|
|
694
|
+
if (a.text === " " || a.text === " ") return true;
|
|
695
|
+
if (space(a.text) || space(b.text)) return distribute;
|
|
696
|
+
if (cursive.test(a.text) || cursive.test(b.text)) return false;
|
|
697
|
+
return distribute || eastAsian.test(a.text) || eastAsian.test(b.text);
|
|
698
|
+
}
|
|
699
|
+
/** 按最终绘制段度量自然宽度,并把展示偏移映射回原合法源边界;不持有新文字节点。 */
|
|
700
|
+
function naturalText(piece, gaps, trim, measurer) {
|
|
701
|
+
const count = piece.metrics.caretMap.offsets.length - 1, cuts = sortBy$2(uniq([
|
|
702
|
+
0,
|
|
703
|
+
...gaps.keys(),
|
|
704
|
+
count
|
|
705
|
+
]), (value) => value), advances = [];
|
|
706
|
+
let advance = 0;
|
|
707
|
+
for (let index = 0; index < cuts.length - 1; index++) {
|
|
708
|
+
const from = cuts[index], to = cuts[index + 1], start = displayOffset(piece, from), measurement = measurer.measure({
|
|
709
|
+
text: piece.text.slice(start, displayOffset(piece, to)),
|
|
710
|
+
style: piece.paint,
|
|
711
|
+
direction: piece.direction
|
|
712
|
+
});
|
|
713
|
+
if (!Number.isFinite(measurement.advanceWidth) || measurement.advanceWidth < 0) throw new Error("对齐度量返回无效推进宽度");
|
|
714
|
+
for (let boundary = from; boundary <= to; boundary++) {
|
|
715
|
+
const offset = displayOffset(piece, boundary) - start, at = sortedIndex(measurement.caretMap.offsets, offset);
|
|
716
|
+
if (measurement.caretMap.offsets[at] !== offset) throw new Error("对齐度量缺少合法展示边界");
|
|
717
|
+
advances[boundary] = advance + (piece.direction === "rtl" ? measurement.advanceWidth - measurement.caretMap.x[at] : measurement.caretMap.x[at]);
|
|
718
|
+
}
|
|
719
|
+
advance += measurement.advanceWidth;
|
|
720
|
+
}
|
|
721
|
+
const naturalWidth = trim === void 0 ? advance : advances[trim];
|
|
722
|
+
return {
|
|
723
|
+
width: naturalWidth,
|
|
724
|
+
x: advances.map((value) => piece.direction === "rtl" ? naturalWidth - Math.min(value, naturalWidth) : Math.min(value, naturalWidth)),
|
|
725
|
+
starts: cuts.slice(0, -1)
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
/** 普通两端对齐只处理软换行;分散对齐也处理段末,无法扩展时居中,空白行原样保留。 */
|
|
729
|
+
function justifyFlowLine(line, alignment, measurer) {
|
|
730
|
+
if (alignment !== "justify" && alignment !== "distribute") return line;
|
|
731
|
+
if (alignment === "justify" && line.ending !== "wrap") return line;
|
|
732
|
+
const all = units$2(line);
|
|
733
|
+
let first = 0, last = all.length - 1;
|
|
734
|
+
while (first <= last && space(all[first].text)) first++;
|
|
735
|
+
while (last >= first && space(all[last].text)) last--;
|
|
736
|
+
if (first > last) return line;
|
|
737
|
+
const textGaps = /* @__PURE__ */ new Map(), atomicGaps = /* @__PURE__ */ new Map(), trims = /* @__PURE__ */ new Map(), trimmedAnchors = /* @__PURE__ */ new Set();
|
|
738
|
+
let count = 0;
|
|
739
|
+
for (let at = first; at < last; at++) {
|
|
740
|
+
const current = all[at];
|
|
741
|
+
if (!opportunity(current, all[at + 1], alignment === "distribute")) continue;
|
|
742
|
+
count++;
|
|
743
|
+
if (current.boundary !== void 0) {
|
|
744
|
+
let gaps = textGaps.get(current.piece);
|
|
745
|
+
if (!gaps) textGaps.set(current.piece, gaps = /* @__PURE__ */ new Map());
|
|
746
|
+
gaps.set(current.boundary, (gaps.get(current.boundary) ?? 0) + 1);
|
|
747
|
+
} else atomicGaps.set(current.piece, (atomicGaps.get(current.piece) ?? 0) + 1);
|
|
748
|
+
}
|
|
749
|
+
for (let at = last + 1; at < all.length; at++) {
|
|
750
|
+
const unit = all[at];
|
|
751
|
+
if (unit.boundary !== void 0 && !trims.has(unit.piece)) trims.set(unit.piece, unit.boundary - 1);
|
|
752
|
+
else if (unit.boundary === void 0) trimmedAnchors.add(unit.piece);
|
|
753
|
+
}
|
|
754
|
+
const plans = /* @__PURE__ */ new Map(), original = line.pieces.map((piece, index) => trimmedAnchors.has(index) && piece.kind === "anchor" ? {
|
|
755
|
+
...piece,
|
|
756
|
+
advanceWidth: 0
|
|
757
|
+
} : piece);
|
|
758
|
+
for (const [index, piece] of original.entries()) if (piece.kind === "text" && (textGaps.has(index) || trims.has(index))) plans.set(index, naturalText(piece, textGaps.get(index) ?? /* @__PURE__ */ new Map(), trims.get(index), measurer));
|
|
759
|
+
const naturalWidth = original.reduce((total, piece, index) => total + (plans.get(index)?.width ?? width(piece)), 0), free = line.availableWidth - naturalWidth;
|
|
760
|
+
if (!Number.isFinite(free) || free < 0) return line;
|
|
761
|
+
const step = count ? free / count : 0, pieces = original.map((piece, index) => {
|
|
762
|
+
const plan = plans.get(index);
|
|
763
|
+
if (piece.kind !== "text" || !plan) return piece;
|
|
764
|
+
const gaps = textGaps.get(index), extra = sumBy([...gaps?.values() ?? []], (value) => value) * step;
|
|
765
|
+
let addedGaps = 0;
|
|
766
|
+
const x = plan.x.map((value, boundary) => {
|
|
767
|
+
addedGaps += gaps?.get(boundary) ?? 0;
|
|
768
|
+
const added = addedGaps * step;
|
|
769
|
+
return value + (piece.direction === "rtl" ? extra - added : added);
|
|
770
|
+
});
|
|
771
|
+
return {
|
|
772
|
+
...piece,
|
|
773
|
+
metrics: {
|
|
774
|
+
...piece.metrics,
|
|
775
|
+
advanceWidth: plan.width + extra,
|
|
776
|
+
caretMap: {
|
|
777
|
+
offsets: piece.metrics.caretMap.offsets,
|
|
778
|
+
x
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
...plan.starts.length > 1 ? { expansion: {
|
|
782
|
+
offsets: plan.starts.map((boundary) => displayOffset(piece, boundary)),
|
|
783
|
+
x: plan.starts.map((boundary) => x[boundary])
|
|
784
|
+
} } : {}
|
|
785
|
+
};
|
|
786
|
+
});
|
|
787
|
+
let alignedPieceOffsets;
|
|
788
|
+
if (atomicGaps.size) {
|
|
789
|
+
alignedPieceOffsets = [];
|
|
790
|
+
let advance = 0;
|
|
791
|
+
for (const [index, piece] of pieces.entries()) {
|
|
792
|
+
alignedPieceOffsets.push(advance);
|
|
793
|
+
advance += width(piece) + (atomicGaps.get(index) ?? 0) * step;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
...line,
|
|
798
|
+
pieces,
|
|
799
|
+
width: count ? line.availableWidth : naturalWidth,
|
|
800
|
+
...alignedPieceOffsets ? { alignedPieceOffsets } : {},
|
|
801
|
+
...!count && alignment === "distribute" ? { alignmentOffsetPx: free / 2 } : {}
|
|
802
|
+
};
|
|
803
|
+
}
|
|
441
804
|
// src/layout/engine/atoms/control-decoration.ts
|
|
442
805
|
/** 在内容度量外分配括号空间;实际填写文字仍保留原值,不把括号混入编辑地址。 */
|
|
443
806
|
function measureDecoratedControl(presentation, availableWidth, measurer, calculate) {
|
|
807
|
+
if (presentation.signatureGallery?.items.length && presentation.preferredSizePx) presentation = {
|
|
808
|
+
...presentation,
|
|
809
|
+
signatureGallery: {
|
|
810
|
+
...presentation.signatureGallery,
|
|
811
|
+
imageSize: presentation.signatureGallery.imageSize ?? presentation.preferredSizePx
|
|
812
|
+
},
|
|
813
|
+
preferredSizePx: void 0
|
|
814
|
+
};
|
|
444
815
|
const decoration = presentation.decoration;
|
|
445
816
|
if (!decoration) return calculate(presentation, availableWidth);
|
|
446
817
|
const style = {
|
|
@@ -480,6 +851,15 @@ function measureDecoratedControl(presentation, availableWidth, measurer, calcula
|
|
|
480
851
|
baseline: control.layout.texts.at(-1)?.baseline ?? control.baseline,
|
|
481
852
|
width: right - 3
|
|
482
853
|
});
|
|
854
|
+
const bracketFrames = presentation.signatureGallery?.items.length ? bracketTexts.map((text) => ({
|
|
855
|
+
side: text.text === "[" ? "start" : "end",
|
|
856
|
+
frame: {
|
|
857
|
+
x: text.x,
|
|
858
|
+
y: 0,
|
|
859
|
+
width: text.width,
|
|
860
|
+
height: control.height
|
|
861
|
+
}
|
|
862
|
+
})) : void 0;
|
|
483
863
|
return {
|
|
484
864
|
...control,
|
|
485
865
|
width: control.width + left + right,
|
|
@@ -512,7 +892,7 @@ function measureDecoratedControl(presentation, availableWidth, measurer, calcula
|
|
|
512
892
|
x: image.frame.x + left
|
|
513
893
|
}
|
|
514
894
|
})) } : {},
|
|
515
|
-
...bracketTexts.length ? { bracketTexts } : {}
|
|
895
|
+
...bracketFrames?.length ? { bracketFrames } : bracketTexts.length ? { bracketTexts } : {}
|
|
516
896
|
}
|
|
517
897
|
};
|
|
518
898
|
}
|
|
@@ -659,93 +1039,121 @@ function measureSeal(presentation, measurer, assets) {
|
|
|
659
1039
|
};
|
|
660
1040
|
}
|
|
661
1041
|
// src/layout/engine/atoms/signatures.ts
|
|
662
|
-
/** @file
|
|
663
|
-
/**
|
|
1042
|
+
/** @file 签名沿旧版图片尺寸及日期几何排版;内部姓名图形仍由新绘制协议承载。 */
|
|
1043
|
+
/** 多人签名按整张图与跟随日期共同换行、分页,不把姓名降级成普通字段文字。 */
|
|
664
1044
|
function measureSignatures(presentation, availableWidth, measurer, assets) {
|
|
665
|
-
const gallery = presentation.signatureGallery
|
|
1045
|
+
const gallery = presentation.signatureGallery;
|
|
1046
|
+
const style = {
|
|
1047
|
+
fontFamily: "Arial",
|
|
1048
|
+
fontSizePx: presentation.style.fontSizePx,
|
|
1049
|
+
fontWeight: 400,
|
|
1050
|
+
fontStyle: "normal",
|
|
1051
|
+
letterSpacingPx: 0,
|
|
1052
|
+
color: "#000000",
|
|
1053
|
+
kerning: "normal"
|
|
1054
|
+
};
|
|
666
1055
|
const metrics = measurer.measure({
|
|
667
1056
|
text: "",
|
|
668
1057
|
style,
|
|
669
1058
|
direction: "ltr"
|
|
670
1059
|
});
|
|
671
|
-
const lineHeight = (metrics.ascent + metrics.descent) * 1.2, padding = presentation.appearance === "text" ? 0 : 4;
|
|
672
|
-
const width = Math.max(1, Math.min(availableWidth, presentation.preferredSizePx?.width ?? availableWidth)), inner = Math.max(1, width - padding * 2);
|
|
673
1060
|
const texts = [], images = [], rowFlow = [];
|
|
1061
|
+
const configured = gallery.imageSize ?? presentation.preferredSizePx;
|
|
1062
|
+
const inner = Math.max(1, availableWidth);
|
|
674
1063
|
let x = 0, y = 0, rowHeight = 0, usedWidth = 0, rowStart = 0;
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
width: measurer.measureWidth({
|
|
683
|
-
text: line,
|
|
684
|
-
style,
|
|
685
|
-
direction: "ltr"
|
|
686
|
-
})
|
|
687
|
-
}));
|
|
688
|
-
return lines.length * lineHeight;
|
|
689
|
-
};
|
|
1064
|
+
const finishRow = () => rowFlow.push({
|
|
1065
|
+
start: rowStart,
|
|
1066
|
+
end: y + rowHeight,
|
|
1067
|
+
textTo: texts.length,
|
|
1068
|
+
markerTo: 0,
|
|
1069
|
+
imageTo: images.length
|
|
1070
|
+
});
|
|
690
1071
|
for (const item of gallery.items) {
|
|
691
|
-
const
|
|
692
|
-
|
|
1072
|
+
const graphic = item.image ? void 0 : signatureGraphic(item.text, item.fallbackDate ?? "", {
|
|
1073
|
+
...configured,
|
|
1074
|
+
vertical: item.vertical,
|
|
1075
|
+
fallback: item.fallback
|
|
1076
|
+
}, (text, size, weight) => measurer.measureWidth({
|
|
1077
|
+
text,
|
|
1078
|
+
direction: "ltr",
|
|
1079
|
+
style: {
|
|
1080
|
+
fontFamily: "Arial",
|
|
1081
|
+
fontSizePx: size,
|
|
1082
|
+
fontWeight: weight,
|
|
1083
|
+
fontStyle: "normal",
|
|
1084
|
+
letterSpacingPx: 0,
|
|
1085
|
+
kerning: "normal"
|
|
1086
|
+
}
|
|
1087
|
+
}));
|
|
1088
|
+
const naturalWidth = graphic?.width ?? (item.vertical ? configured?.height ?? 68 : configured?.width ?? 120);
|
|
1089
|
+
const naturalHeight = graphic?.height ?? (item.vertical ? configured?.width ?? 120 : configured?.height ?? 68);
|
|
1090
|
+
const timeWidth = item.timeText ? measurer.measureWidth({
|
|
693
1091
|
text: item.timeText,
|
|
694
1092
|
style,
|
|
695
1093
|
direction: "ltr"
|
|
696
1094
|
}) : 0;
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
const
|
|
703
|
-
const
|
|
704
|
-
const itemWidth = Math.min(inner, beside ? primaryWidth + 4 + timeNatural : Math.max(primaryWidth, timeNatural));
|
|
1095
|
+
const timeHeight = item.timeText ? metrics.ascent + metrics.descent : 0;
|
|
1096
|
+
const beside = gallery.timePlacement === "inline" && !!item.timeText;
|
|
1097
|
+
const gap = item.timeText ? 2 : 0;
|
|
1098
|
+
const scale = Math.min(1, Math.max(1, inner - (beside ? timeWidth + gap : 0)) / naturalWidth);
|
|
1099
|
+
const primaryWidth = naturalWidth * scale, primaryHeight = naturalHeight * scale;
|
|
1100
|
+
const itemWidth = beside ? primaryWidth + gap + timeWidth : Math.max(primaryWidth, timeWidth);
|
|
1101
|
+
const itemHeight = beside ? Math.max(primaryHeight, timeHeight) : primaryHeight + gap + timeHeight;
|
|
705
1102
|
if (x && x + itemWidth > inner) {
|
|
706
|
-
|
|
707
|
-
start: rowStart,
|
|
708
|
-
end: padding + y + rowHeight,
|
|
709
|
-
textTo: texts.length,
|
|
710
|
-
markerTo: 0,
|
|
711
|
-
imageTo: images.length
|
|
712
|
-
});
|
|
1103
|
+
finishRow();
|
|
713
1104
|
x = 0;
|
|
714
|
-
y += rowHeight
|
|
715
|
-
rowStart =
|
|
1105
|
+
y += rowHeight;
|
|
1106
|
+
rowStart = y;
|
|
716
1107
|
rowHeight = 0;
|
|
717
1108
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
1109
|
+
const frame = {
|
|
1110
|
+
x: x + (beside ? 0 : Math.max(0, (timeWidth - primaryWidth) / 2)),
|
|
1111
|
+
y,
|
|
1112
|
+
width: primaryWidth,
|
|
1113
|
+
height: primaryHeight
|
|
1114
|
+
};
|
|
1115
|
+
images.push(graphic ? {
|
|
1116
|
+
source: {
|
|
1117
|
+
kind: "url",
|
|
1118
|
+
url: signatureGraphicUrl(graphic)
|
|
1119
|
+
},
|
|
1120
|
+
alt: item.text,
|
|
1121
|
+
state: "ready",
|
|
1122
|
+
revision: 0,
|
|
1123
|
+
fit: "contain",
|
|
1124
|
+
frame,
|
|
1125
|
+
graphic
|
|
1126
|
+
} : {
|
|
1127
|
+
...imageSnapshot(item.image, assets, frame, "contain"),
|
|
1128
|
+
placeholder: { backgroundColor: "#f3f3f3" }
|
|
1129
|
+
});
|
|
1130
|
+
if (item.timeText) texts.push({
|
|
1131
|
+
text: item.timeText,
|
|
1132
|
+
imageDecoration: {
|
|
1133
|
+
imageIndex: images.length - 1,
|
|
1134
|
+
placement: beside ? "right" : "bottom",
|
|
1135
|
+
gapPx: gap
|
|
1136
|
+
},
|
|
1137
|
+
style,
|
|
1138
|
+
fontMetrics: {
|
|
1139
|
+
ascent: metrics.ascent,
|
|
1140
|
+
descent: metrics.descent
|
|
1141
|
+
},
|
|
1142
|
+
x: x + (beside ? primaryWidth + gap : Math.max(0, (primaryWidth - timeWidth) / 2)),
|
|
1143
|
+
baseline: y + (beside ? (primaryHeight - timeHeight) / 2 : primaryHeight + gap) + metrics.ascent,
|
|
1144
|
+
width: timeWidth
|
|
1145
|
+
});
|
|
732
1146
|
usedWidth = Math.max(usedWidth, x + itemWidth);
|
|
733
1147
|
rowHeight = Math.max(rowHeight, itemHeight);
|
|
734
|
-
x += itemWidth
|
|
1148
|
+
x += itemWidth;
|
|
735
1149
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
start: rowStart,
|
|
739
|
-
end: height,
|
|
740
|
-
textTo: texts.length,
|
|
741
|
-
markerTo: 0,
|
|
742
|
-
imageTo: images.length
|
|
743
|
-
});
|
|
1150
|
+
finishRow();
|
|
1151
|
+
const height = y + rowHeight;
|
|
744
1152
|
return {
|
|
745
1153
|
rowFlow,
|
|
746
|
-
width:
|
|
1154
|
+
width: Math.max(1, usedWidth),
|
|
747
1155
|
height,
|
|
748
|
-
baseline: Math.
|
|
1156
|
+
baseline: Math.max(metrics.ascent, rowHeight - metrics.descent),
|
|
749
1157
|
layout: {
|
|
750
1158
|
appearance: presentation.appearance,
|
|
751
1159
|
design: presentation.design,
|
|
@@ -760,53 +1168,6 @@ function measureSignatures(presentation, availableWidth, measurer, assets) {
|
|
|
760
1168
|
}
|
|
761
1169
|
// src/layout/engine/atoms/field-control.ts
|
|
762
1170
|
/** @file 纯同步控件度量,控件作为整体参与正文断行,内部文字只生成行片段。 */
|
|
763
|
-
/** 字素算法只持有分割器,不保留字段或文字。 */
|
|
764
|
-
var segments = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
765
|
-
/** 字段内按合法字素换行,空行保留;不创建字符节点或内部模型地址。 */
|
|
766
|
-
function wrapTextRanges(text, width, presentation, measurer) {
|
|
767
|
-
const lines = [];
|
|
768
|
-
for (const match of text.matchAll(/([^\r\n]*)(\r\n|[\r\n]|$)/g)) {
|
|
769
|
-
if (match.index === text.length && text.length > 0 && !/[\r\n]$/.test(text)) break;
|
|
770
|
-
const part = match[1];
|
|
771
|
-
const source = match.index;
|
|
772
|
-
if (!part.length) {
|
|
773
|
-
lines.push({
|
|
774
|
-
text: "",
|
|
775
|
-
from: source,
|
|
776
|
-
to: source
|
|
777
|
-
});
|
|
778
|
-
continue;
|
|
779
|
-
}
|
|
780
|
-
const boundaries = [0, ...Array.from(segments.segment(part), (item) => item.index + item.segment.length)];
|
|
781
|
-
let begin = 0;
|
|
782
|
-
while (begin < boundaries.length - 1) {
|
|
783
|
-
let low = begin, high = boundaries.length - 1;
|
|
784
|
-
while (low < high) {
|
|
785
|
-
const middle = Math.ceil((low + high) / 2);
|
|
786
|
-
const advance = measurer.measureWidth({
|
|
787
|
-
text: part.slice(boundaries[begin], boundaries[middle]),
|
|
788
|
-
style: presentation.style,
|
|
789
|
-
direction: "ltr"
|
|
790
|
-
});
|
|
791
|
-
if (!Number.isFinite(advance) || advance < 0) throw new Error("字段文字度量返回无效宽度");
|
|
792
|
-
if (advance <= width) low = middle;
|
|
793
|
-
else high = middle - 1;
|
|
794
|
-
}
|
|
795
|
-
const end = Math.max(begin + 1, low);
|
|
796
|
-
lines.push({
|
|
797
|
-
text: part.slice(boundaries[begin], boundaries[end]),
|
|
798
|
-
from: source + boundaries[begin],
|
|
799
|
-
to: source + boundaries[end]
|
|
800
|
-
});
|
|
801
|
-
begin = end;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
return lines;
|
|
805
|
-
}
|
|
806
|
-
/** 通用标签继续使用相同断行算法,字段额外保留原文区间供活动输入定位。 */
|
|
807
|
-
function wrapText(text, width, presentation, measurer) {
|
|
808
|
-
return wrapTextRanges(text, width, presentation, measurer).map((line) => line.text);
|
|
809
|
-
}
|
|
810
1171
|
/** 控件尺寸和所有内部坐标在排版时决定,绘制阶段不读取业务数据或重新断行。 */
|
|
811
1172
|
function measureFieldControl(presentation, availableWidth, measurer, assets, cache) {
|
|
812
1173
|
return cache ? cache.measure(presentation, availableWidth, assets, (snapshot) => measureFieldControlFresh(presentation, availableWidth, measurer, snapshot)) : measureFieldControlFresh(presentation, availableWidth, measurer, assets);
|
|
@@ -826,7 +1187,7 @@ function measureFieldControlFresh(presentation, availableWidth, measurer, assets
|
|
|
826
1187
|
...control.layout,
|
|
827
1188
|
texts: control.layout.texts.map((text) => ({
|
|
828
1189
|
...text,
|
|
829
|
-
fontMetrics: {
|
|
1190
|
+
fontMetrics: text.fontMetrics ?? {
|
|
830
1191
|
ascent,
|
|
831
1192
|
descent
|
|
832
1193
|
}
|
|
@@ -1046,298 +1407,6 @@ function measureFieldContent(presentation, availableWidth, measurer, assets) {
|
|
|
1046
1407
|
}
|
|
1047
1408
|
};
|
|
1048
1409
|
}
|
|
1049
|
-
// src/layout/engine/atoms/diagonal.ts
|
|
1050
|
-
/** @file 斜线表头的纯几何;两栏/四种三栏顶点共用最终尺寸与分区裁剪。 */
|
|
1051
|
-
/** 整格斜线只用于唯一图形的单元格,不挤占或伸缩其他正文。 */
|
|
1052
|
-
function isDiagonalCell(blocks) {
|
|
1053
|
-
const block = blocks.length === 1 ? blocks[0] : void 0;
|
|
1054
|
-
if (!block || typeof block !== "object" || !("kind" in block) || block.kind !== "paragraph" || !("content" in block) || !Array.isArray(block.content)) return false;
|
|
1055
|
-
const content = block.content, node = content.length === 1 ? content[0] : void 0;
|
|
1056
|
-
return !!node && typeof node === "object" && "kind" in node && node.kind === "pageWidget" && "widget" in node && node.widget === "diagonal";
|
|
1057
|
-
}
|
|
1058
|
-
/** 整格图形在行高最终分配后取真实尺寸,不把配置尺寸强行变成行高。 */
|
|
1059
|
-
function fillCellDiagonal(blocks, width, height) {
|
|
1060
|
-
const block = blocks.length === 1 ? blocks[0] : void 0, line = block?.kind === "paragraph" && block.lines.length === 1 ? block.lines[0] : void 0, piece = line?.pieces.length === 1 ? line.pieces[0] : void 0;
|
|
1061
|
-
if (!block || block.kind !== "paragraph" || !line || piece?.kind !== "pageWidget" || piece.widget.content.kind !== "diagonal" || !piece.widget.content.fillCell) return blocks;
|
|
1062
|
-
const widget = {
|
|
1063
|
-
...piece.widget,
|
|
1064
|
-
width,
|
|
1065
|
-
height,
|
|
1066
|
-
baseline: height
|
|
1067
|
-
};
|
|
1068
|
-
return [{
|
|
1069
|
-
...block,
|
|
1070
|
-
width,
|
|
1071
|
-
height,
|
|
1072
|
-
lines: [{
|
|
1073
|
-
...line,
|
|
1074
|
-
width,
|
|
1075
|
-
availableWidth: width,
|
|
1076
|
-
height,
|
|
1077
|
-
baseline: height,
|
|
1078
|
-
indent: 0,
|
|
1079
|
-
pieces: [{
|
|
1080
|
-
...piece,
|
|
1081
|
-
widget
|
|
1082
|
-
}]
|
|
1083
|
-
}]
|
|
1084
|
-
}];
|
|
1085
|
-
}
|
|
1086
|
-
/** 镜像角点名称与几何使用同一规则,避免文字分区与线条错位。 */
|
|
1087
|
-
function cornerName(x, y) {
|
|
1088
|
-
return `${y ? "bottom" : "top"}-${x ? "right" : "left"}`;
|
|
1089
|
-
}
|
|
1090
|
-
/** 按当前真实尺寸一次性计算线、文字和对应分区,绘制不重新解释配置。 */
|
|
1091
|
-
function layoutDiagonal(content, width, height, paintStyleKey, paint, measurer) {
|
|
1092
|
-
const w = width, h = height, three = content.columns === 3, flipX = three ? content.vertex.endsWith("right") : content.direction === "backward", flipY = three && content.vertex.startsWith("bottom");
|
|
1093
|
-
/** 线条与分区顶点都从同一坐标变换得到。 */
|
|
1094
|
-
function point(x, y) {
|
|
1095
|
-
return {
|
|
1096
|
-
x: flipX ? w - x : x,
|
|
1097
|
-
y: flipY ? h - y : y
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
const origin = point(0, 0), endA = point(w, three ? h * .4 : h), endB = point(w * .4, h);
|
|
1101
|
-
/** 统一的已解析线条,不借用旧 ImageWidget。 */
|
|
1102
|
-
function line(end) {
|
|
1103
|
-
return {
|
|
1104
|
-
kind: "line",
|
|
1105
|
-
x1: origin.x,
|
|
1106
|
-
y1: origin.y,
|
|
1107
|
-
x2: end.x,
|
|
1108
|
-
y2: end.y,
|
|
1109
|
-
widthPx: 1,
|
|
1110
|
-
color: "#808080",
|
|
1111
|
-
style: "solid"
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
const regions = /* @__PURE__ */ new Map();
|
|
1115
|
-
regions.set(cornerName(!flipX, flipY), [
|
|
1116
|
-
origin,
|
|
1117
|
-
point(w, 0),
|
|
1118
|
-
endA
|
|
1119
|
-
]);
|
|
1120
|
-
if (three) {
|
|
1121
|
-
regions.set(cornerName(!flipX, !flipY), [
|
|
1122
|
-
origin,
|
|
1123
|
-
endA,
|
|
1124
|
-
point(w, h),
|
|
1125
|
-
endB
|
|
1126
|
-
]);
|
|
1127
|
-
regions.set(cornerName(flipX, !flipY), [
|
|
1128
|
-
origin,
|
|
1129
|
-
endB,
|
|
1130
|
-
point(0, h)
|
|
1131
|
-
]);
|
|
1132
|
-
} else regions.set(cornerName(flipX, !flipY), [
|
|
1133
|
-
origin,
|
|
1134
|
-
endA,
|
|
1135
|
-
point(0, h)
|
|
1136
|
-
]);
|
|
1137
|
-
const corners = three ? {
|
|
1138
|
-
"top-left": [
|
|
1139
|
-
"top-right",
|
|
1140
|
-
"bottom-right",
|
|
1141
|
-
"bottom-left"
|
|
1142
|
-
],
|
|
1143
|
-
"top-right": [
|
|
1144
|
-
"top-left",
|
|
1145
|
-
"bottom-left",
|
|
1146
|
-
"bottom-right"
|
|
1147
|
-
],
|
|
1148
|
-
"bottom-left": [
|
|
1149
|
-
"top-left",
|
|
1150
|
-
"top-right",
|
|
1151
|
-
"bottom-right"
|
|
1152
|
-
],
|
|
1153
|
-
"bottom-right": [
|
|
1154
|
-
"top-right",
|
|
1155
|
-
"top-left",
|
|
1156
|
-
"bottom-left"
|
|
1157
|
-
]
|
|
1158
|
-
}[content.vertex] : flipX ? ["top-left", "bottom-right"] : ["top-right", "bottom-left"];
|
|
1159
|
-
const metrics = measurer.measure({
|
|
1160
|
-
text: "",
|
|
1161
|
-
style: paint,
|
|
1162
|
-
direction: "ltr"
|
|
1163
|
-
}), lineHeight = (metrics.ascent + metrics.descent) * 1.2, boxWidth = Math.max(1, Math.min(w * .5, w - 8));
|
|
1164
|
-
return {
|
|
1165
|
-
kind: "diagonal",
|
|
1166
|
-
paintStyleKey,
|
|
1167
|
-
lines: three ? [line(endA), line(endB)] : [line(endA)],
|
|
1168
|
-
slots: corners.map((corner, index) => {
|
|
1169
|
-
const rows = wrapText(content.labels[three ? index : index === 0 ? 0 : 2] ?? "", boxWidth, { style: paint }, measurer), right = corner.endsWith("right"), x = right ? w - 4 - boxWidth : 4, y = corner.startsWith("bottom") ? Math.max(4, h - 4 - rows.length * lineHeight) : 4;
|
|
1170
|
-
return {
|
|
1171
|
-
clip: regions.get(corner),
|
|
1172
|
-
texts: rows.map((text, row) => {
|
|
1173
|
-
const advance = measurer.measureWidth({
|
|
1174
|
-
text,
|
|
1175
|
-
style: paint,
|
|
1176
|
-
direction: "ltr"
|
|
1177
|
-
});
|
|
1178
|
-
return {
|
|
1179
|
-
text,
|
|
1180
|
-
width: advance,
|
|
1181
|
-
x: x + (right ? Math.max(0, boxWidth - advance) : 0),
|
|
1182
|
-
baseline: y + metrics.ascent + row * lineHeight
|
|
1183
|
-
};
|
|
1184
|
-
})
|
|
1185
|
-
};
|
|
1186
|
-
})
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
// src/layout/engine/paragraph/justify-line.ts
|
|
1190
|
-
/** @file 断行后的间距扩展;源字素、原子尺寸和结果片段保持,绘制与停靠共用最终几何。 */
|
|
1191
|
-
/** 只扩展普通及全角空白,不把不换行空格当作可丢弃的尾随空白。 */
|
|
1192
|
-
var space = (text) => /^[ \t\u3000]+$/u.test(text);
|
|
1193
|
-
/** 东亚文本提供字间机会;连写脚本仅使用词间空白,不切断连接。 */
|
|
1194
|
-
var eastAsian = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
1195
|
-
/** 当前可识别的连写脚本不能被分散对齐拆出字内空隙。 */
|
|
1196
|
-
var cursive = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Nko}\p{Script=Mandaic}\p{Script=Mongolian}\p{Script=Phags_Pa}]/u;
|
|
1197
|
-
/** 一行的自然片段推进,不把对齐间隔写进控件或图片尺寸。 */
|
|
1198
|
-
function width(piece) {
|
|
1199
|
-
return piece.kind === "text" ? piece.metrics.advanceWidth : piece.kind === "control" ? piece.control.width : piece.kind === "image" ? piece.image.frame.width : piece.kind === "pageWidget" ? piece.widget.width : piece.advanceWidth ?? 0;
|
|
1200
|
-
}
|
|
1201
|
-
/** 普通文字直接借用源相对偏移,只有长度变换才使用额外的展示映射。 */
|
|
1202
|
-
function displayOffset(piece, boundary) {
|
|
1203
|
-
return piece.displayOffsets?.[boundary] ?? piece.metrics.caretMap.offsets[boundary] - piece.source.from;
|
|
1204
|
-
}
|
|
1205
|
-
/** 收集临时排版单位,段落内零宽锚点不引入额外分散机会。 */
|
|
1206
|
-
function units$2(line) {
|
|
1207
|
-
const result = [];
|
|
1208
|
-
for (const [index, piece] of line.pieces.entries()) if (piece.kind === "text") for (let at = 1; at < piece.metrics.caretMap.offsets.length; at++) {
|
|
1209
|
-
const text = piece.text.slice(displayOffset(piece, at - 1), displayOffset(piece, at));
|
|
1210
|
-
if (text) result.push({
|
|
1211
|
-
piece: index,
|
|
1212
|
-
boundary: at,
|
|
1213
|
-
text
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
else if (piece.kind === "anchor") {
|
|
1217
|
-
if (width(piece)) result.push({
|
|
1218
|
-
piece: index,
|
|
1219
|
-
text: " "
|
|
1220
|
-
});
|
|
1221
|
-
} else result.push({
|
|
1222
|
-
piece: index,
|
|
1223
|
-
text: ""
|
|
1224
|
-
});
|
|
1225
|
-
return result;
|
|
1226
|
-
}
|
|
1227
|
-
/** 不在源字素内部、连接控制符或开闭标点禁止边界扩展;样式节点边界不改变机会。 */
|
|
1228
|
-
function opportunity(a, b, distribute) {
|
|
1229
|
-
if (/[\u00a0\u202f\u2060\ufeff]/u.test(a.text + b.text)) return false;
|
|
1230
|
-
if ("([{([{《〈「『【〔〖“‘".includes(a.text) || ")]})]}》〉」』】〕〗”’、。,;:!?,.!?;:".includes(b.text)) return false;
|
|
1231
|
-
if (a.text === " " || a.text === " ") return true;
|
|
1232
|
-
if (space(a.text) || space(b.text)) return distribute;
|
|
1233
|
-
if (cursive.test(a.text) || cursive.test(b.text)) return false;
|
|
1234
|
-
return distribute || eastAsian.test(a.text) || eastAsian.test(b.text);
|
|
1235
|
-
}
|
|
1236
|
-
/** 按最终绘制段度量自然宽度,并把展示偏移映射回原合法源边界;不持有新文字节点。 */
|
|
1237
|
-
function naturalText(piece, gaps, trim, measurer) {
|
|
1238
|
-
const count = piece.metrics.caretMap.offsets.length - 1, cuts = sortBy$2(uniq([
|
|
1239
|
-
0,
|
|
1240
|
-
...gaps.keys(),
|
|
1241
|
-
count
|
|
1242
|
-
]), (value) => value), advances = [];
|
|
1243
|
-
let advance = 0;
|
|
1244
|
-
for (let index = 0; index < cuts.length - 1; index++) {
|
|
1245
|
-
const from = cuts[index], to = cuts[index + 1], start = displayOffset(piece, from), measurement = measurer.measure({
|
|
1246
|
-
text: piece.text.slice(start, displayOffset(piece, to)),
|
|
1247
|
-
style: piece.paint,
|
|
1248
|
-
direction: piece.direction
|
|
1249
|
-
});
|
|
1250
|
-
if (!Number.isFinite(measurement.advanceWidth) || measurement.advanceWidth < 0) throw new Error("对齐度量返回无效推进宽度");
|
|
1251
|
-
for (let boundary = from; boundary <= to; boundary++) {
|
|
1252
|
-
const offset = displayOffset(piece, boundary) - start, at = sortedIndex(measurement.caretMap.offsets, offset);
|
|
1253
|
-
if (measurement.caretMap.offsets[at] !== offset) throw new Error("对齐度量缺少合法展示边界");
|
|
1254
|
-
advances[boundary] = advance + (piece.direction === "rtl" ? measurement.advanceWidth - measurement.caretMap.x[at] : measurement.caretMap.x[at]);
|
|
1255
|
-
}
|
|
1256
|
-
advance += measurement.advanceWidth;
|
|
1257
|
-
}
|
|
1258
|
-
const naturalWidth = trim === void 0 ? advance : advances[trim];
|
|
1259
|
-
return {
|
|
1260
|
-
width: naturalWidth,
|
|
1261
|
-
x: advances.map((value) => piece.direction === "rtl" ? naturalWidth - Math.min(value, naturalWidth) : Math.min(value, naturalWidth)),
|
|
1262
|
-
starts: cuts.slice(0, -1)
|
|
1263
|
-
};
|
|
1264
|
-
}
|
|
1265
|
-
/** 普通两端对齐只处理软换行;分散对齐也处理段末,无法扩展时居中,空白行原样保留。 */
|
|
1266
|
-
function justifyFlowLine(line, alignment, measurer) {
|
|
1267
|
-
if (alignment !== "justify" && alignment !== "distribute") return line;
|
|
1268
|
-
if (alignment === "justify" && line.ending !== "wrap") return line;
|
|
1269
|
-
const all = units$2(line);
|
|
1270
|
-
let first = 0, last = all.length - 1;
|
|
1271
|
-
while (first <= last && space(all[first].text)) first++;
|
|
1272
|
-
while (last >= first && space(all[last].text)) last--;
|
|
1273
|
-
if (first > last) return line;
|
|
1274
|
-
const textGaps = /* @__PURE__ */ new Map(), atomicGaps = /* @__PURE__ */ new Map(), trims = /* @__PURE__ */ new Map(), trimmedAnchors = /* @__PURE__ */ new Set();
|
|
1275
|
-
let count = 0;
|
|
1276
|
-
for (let at = first; at < last; at++) {
|
|
1277
|
-
const current = all[at];
|
|
1278
|
-
if (!opportunity(current, all[at + 1], alignment === "distribute")) continue;
|
|
1279
|
-
count++;
|
|
1280
|
-
if (current.boundary !== void 0) {
|
|
1281
|
-
let gaps = textGaps.get(current.piece);
|
|
1282
|
-
if (!gaps) textGaps.set(current.piece, gaps = /* @__PURE__ */ new Map());
|
|
1283
|
-
gaps.set(current.boundary, (gaps.get(current.boundary) ?? 0) + 1);
|
|
1284
|
-
} else atomicGaps.set(current.piece, (atomicGaps.get(current.piece) ?? 0) + 1);
|
|
1285
|
-
}
|
|
1286
|
-
for (let at = last + 1; at < all.length; at++) {
|
|
1287
|
-
const unit = all[at];
|
|
1288
|
-
if (unit.boundary !== void 0 && !trims.has(unit.piece)) trims.set(unit.piece, unit.boundary - 1);
|
|
1289
|
-
else if (unit.boundary === void 0) trimmedAnchors.add(unit.piece);
|
|
1290
|
-
}
|
|
1291
|
-
const plans = /* @__PURE__ */ new Map(), original = line.pieces.map((piece, index) => trimmedAnchors.has(index) && piece.kind === "anchor" ? {
|
|
1292
|
-
...piece,
|
|
1293
|
-
advanceWidth: 0
|
|
1294
|
-
} : piece);
|
|
1295
|
-
for (const [index, piece] of original.entries()) if (piece.kind === "text" && (textGaps.has(index) || trims.has(index))) plans.set(index, naturalText(piece, textGaps.get(index) ?? /* @__PURE__ */ new Map(), trims.get(index), measurer));
|
|
1296
|
-
const naturalWidth = original.reduce((total, piece, index) => total + (plans.get(index)?.width ?? width(piece)), 0), free = line.availableWidth - naturalWidth;
|
|
1297
|
-
if (!Number.isFinite(free) || free < 0) return line;
|
|
1298
|
-
const step = count ? free / count : 0, pieces = original.map((piece, index) => {
|
|
1299
|
-
const plan = plans.get(index);
|
|
1300
|
-
if (piece.kind !== "text" || !plan) return piece;
|
|
1301
|
-
const gaps = textGaps.get(index), extra = sumBy([...gaps?.values() ?? []], (value) => value) * step;
|
|
1302
|
-
let addedGaps = 0;
|
|
1303
|
-
const x = plan.x.map((value, boundary) => {
|
|
1304
|
-
addedGaps += gaps?.get(boundary) ?? 0;
|
|
1305
|
-
const added = addedGaps * step;
|
|
1306
|
-
return value + (piece.direction === "rtl" ? extra - added : added);
|
|
1307
|
-
});
|
|
1308
|
-
return {
|
|
1309
|
-
...piece,
|
|
1310
|
-
metrics: {
|
|
1311
|
-
...piece.metrics,
|
|
1312
|
-
advanceWidth: plan.width + extra,
|
|
1313
|
-
caretMap: {
|
|
1314
|
-
offsets: piece.metrics.caretMap.offsets,
|
|
1315
|
-
x
|
|
1316
|
-
}
|
|
1317
|
-
},
|
|
1318
|
-
...plan.starts.length > 1 ? { expansion: {
|
|
1319
|
-
offsets: plan.starts.map((boundary) => displayOffset(piece, boundary)),
|
|
1320
|
-
x: plan.starts.map((boundary) => x[boundary])
|
|
1321
|
-
} } : {}
|
|
1322
|
-
};
|
|
1323
|
-
});
|
|
1324
|
-
let alignedPieceOffsets;
|
|
1325
|
-
if (atomicGaps.size) {
|
|
1326
|
-
alignedPieceOffsets = [];
|
|
1327
|
-
let advance = 0;
|
|
1328
|
-
for (const [index, piece] of pieces.entries()) {
|
|
1329
|
-
alignedPieceOffsets.push(advance);
|
|
1330
|
-
advance += width(piece) + (atomicGaps.get(index) ?? 0) * step;
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
return {
|
|
1334
|
-
...line,
|
|
1335
|
-
pieces,
|
|
1336
|
-
width: count ? line.availableWidth : naturalWidth,
|
|
1337
|
-
...alignedPieceOffsets ? { alignedPieceOffsets } : {},
|
|
1338
|
-
...!count && alignment === "distribute" ? { alignmentOffsetPx: free / 2 } : {}
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
1410
|
// src/layout/engine/atoms/code-widgets.ts
|
|
1342
1411
|
/** @file 条码的最终占位与静区几何;不执行公式或编码,不拉伸二维码模块。 */
|
|
1343
1412
|
/** 计算带静区的图形框。二维矩阵等比利用可用空间,一维条码沿用整数模块。 */
|
|
@@ -1880,8 +1949,8 @@ function prepareParagraph(paragraph, model, defaults, fields) {
|
|
|
1880
1949
|
}
|
|
1881
1950
|
const textNode = node;
|
|
1882
1951
|
const effective = model.query.resolveTextStyle(node.id);
|
|
1883
|
-
if (effective.smallCaps) pendingFeatures.add("小型大写");
|
|
1884
|
-
if (effective.shading
|
|
1952
|
+
if (effective.smallCaps && effective.textCase !== "uppercase" && /\p{Lowercase_Letter}/u.test(node.text)) pendingFeatures.add("小型大写");
|
|
1953
|
+
if (node.text.length && hasTextShadingPattern(effective.shading)) pendingFeatures.add("文字图案底纹");
|
|
1885
1954
|
let begin = 0;
|
|
1886
1955
|
let selected;
|
|
1887
1956
|
const paints = {
|
|
@@ -3525,7 +3594,7 @@ function windowRange(offsets, origin, window) {
|
|
|
3525
3594
|
// src/layout/engine/tables/place-table-window.ts
|
|
3526
3595
|
/** @file 原测量网格的几何窗口,只放置可见行/主格,不改变固定高度或重新排版。 */
|
|
3527
3596
|
/** 保留完整格中的图片尺寸、垂直对齐和内边距,续页仅平移原坐标并裁剪。 */
|
|
3528
|
-
function placeCellWindow(cell, originX, originY, visible, key, context, occurrence) {
|
|
3597
|
+
function placeCellWindow(cell, originX, originY, visible, key, context, placeBlocks, occurrence) {
|
|
3529
3598
|
const x = originX + cell.padding.left, fullTop = originY + cell.padding.top, top = Math.max(visible.y, fullTop), bottom = Math.min(visible.y + visible.height, originY + cell.height - cell.padding.bottom), contentFrame = {
|
|
3530
3599
|
x,
|
|
3531
3600
|
y: Math.min(visible.y + visible.height, Math.max(visible.y, top)),
|
|
@@ -3539,7 +3608,7 @@ function placeCellWindow(cell, originX, originY, visible, key, context, occurren
|
|
|
3539
3608
|
const fitted = context.fitCell(cell);
|
|
3540
3609
|
return {
|
|
3541
3610
|
contentFrame,
|
|
3542
|
-
blocks:
|
|
3611
|
+
blocks: placeBlocks(fitted.blocks, x, fullTop + fitted.shift, context, occurrence, {
|
|
3543
3612
|
top,
|
|
3544
3613
|
bottom,
|
|
3545
3614
|
key
|
|
@@ -3547,7 +3616,7 @@ function placeCellWindow(cell, originX, originY, visible, key, context, occurren
|
|
|
3547
3616
|
};
|
|
3548
3617
|
}
|
|
3549
3618
|
/** 嵌套表沿原几何截取,可见跨度按当前窗口重算,合并主格仍使用原实例和来源。 */
|
|
3550
|
-
function placeTableWindow(table, originX, y, window, context, occurrence) {
|
|
3619
|
+
function placeTableWindow(table, originX, y, window, context, placeBlocks, occurrence) {
|
|
3551
3620
|
const free = Math.max(0, table.availableWidth - table.width), x = originX + (table.alignment === "center" ? free / 2 : table.alignment === "right" ? free : table.indent), [from, to] = windowRange(table.rowOffsets, y, window), cellRows = Array.from({ length: to - from }, () => []), rows = table.rows.slice(from, to).map((row, index) => {
|
|
3552
3621
|
const actual = from + index, top = Math.max(window.top, y + table.rowOffsets[actual]), bottom = Math.min(window.bottom, y + table.rowOffsets[actual + 1]);
|
|
3553
3622
|
return {
|
|
@@ -3575,7 +3644,7 @@ function placeTableWindow(table, originX, y, window, context, occurrence) {
|
|
|
3575
3644
|
y: top,
|
|
3576
3645
|
width: cell.width,
|
|
3577
3646
|
height: bottom - top
|
|
3578
|
-
}, host = Math.max(row, from) - from, content = placeCellWindow(cell, frame.x, fullY, frame, window.key, context, occurrence), instance = occurrence?.(cell.instance) ?? cell.instance;
|
|
3647
|
+
}, host = Math.max(row, from) - from, content = placeCellWindow(cell, frame.x, fullY, frame, window.key, context, placeBlocks, occurrence), instance = occurrence?.(cell.instance) ?? cell.instance;
|
|
3579
3648
|
cellRows[host].push({
|
|
3580
3649
|
kind: "cell",
|
|
3581
3650
|
id: layoutIdentity(context.identityScope, "cell", instance.key, table.nodeId, "window", window.key),
|
|
@@ -3797,7 +3866,7 @@ function placeMeasuredBlocks(blocks, x, y, context, occurrence, window) {
|
|
|
3797
3866
|
}
|
|
3798
3867
|
/** 将一段连续显示行放在当前页;跨行主格已由分页组保证完整。 */
|
|
3799
3868
|
function placeTableRange(table, from, to, originX, y, context, options = {}) {
|
|
3800
|
-
if (options.window) return placeTableWindow(table, originX, y, options.window, context, options.occurrence);
|
|
3869
|
+
if (options.window) return placeTableWindow(table, originX, y, options.window, context, placeMeasuredBlocks, options.occurrence);
|
|
3801
3870
|
const session = context.identityScope, free = Math.max(0, table.availableWidth - table.width);
|
|
3802
3871
|
const x = originX + (table.alignment === "center" ? free / 2 : table.alignment === "right" ? free : table.indent), baseY = table.rowOffsets[from];
|
|
3803
3872
|
const rows = [];
|
|
@@ -4401,6 +4470,14 @@ function sliceControl(control, from, to) {
|
|
|
4401
4470
|
baseline: Math.min(height, control.baseline),
|
|
4402
4471
|
layout: {
|
|
4403
4472
|
...control.layout,
|
|
4473
|
+
...control.layout.bracketFrames ? { bracketFrames: control.layout.bracketFrames.map((bracket) => ({
|
|
4474
|
+
...bracket,
|
|
4475
|
+
frame: {
|
|
4476
|
+
...bracket.frame,
|
|
4477
|
+
y: 0,
|
|
4478
|
+
height
|
|
4479
|
+
}
|
|
4480
|
+
})) } : {},
|
|
4404
4481
|
...control.layout.textBox ? { textBox: {
|
|
4405
4482
|
...control.layout.textBox,
|
|
4406
4483
|
y: control.layout.textBox.y - start
|
|
@@ -4416,7 +4493,11 @@ function sliceControl(control, from, to) {
|
|
|
4416
4493
|
})) } : {},
|
|
4417
4494
|
texts: control.layout.texts.slice(first?.textTo ?? (control.rowFlow ? 0 : from), last?.textTo ?? to).map((text) => ({
|
|
4418
4495
|
...text,
|
|
4419
|
-
baseline: text.baseline - start
|
|
4496
|
+
baseline: text.baseline - start,
|
|
4497
|
+
...text.imageDecoration ? { imageDecoration: {
|
|
4498
|
+
...text.imageDecoration,
|
|
4499
|
+
imageIndex: text.imageDecoration.imageIndex - (first?.imageTo ?? 0)
|
|
4500
|
+
} } : {}
|
|
4420
4501
|
})),
|
|
4421
4502
|
markers: control.layout.markers.slice(first?.markerTo ?? 0, last?.markerTo ?? control.layout.markers.length).map((marker) => ({
|
|
4422
4503
|
...marker,
|
|
@@ -4451,14 +4532,29 @@ function graphicEnvelope(control, paint, context) {
|
|
|
4451
4532
|
text: "",
|
|
4452
4533
|
style: paint,
|
|
4453
4534
|
direction: "ltr"
|
|
4454
|
-
}), top = Math.min(...images.map((image) => image.frame.y)), bottom = Math.max(...images.map((image) => image.frame.y + image.frame.height)), band = bottom - top, originalBottom = Math.max(bottom, ...control.layout.texts.map((text) => text.baseline + metrics.descent), ...control.layout.markers.map((marker) => marker.frame.y + marker.frame.height)), padding = Math.min(control.layout.appearance === "text" ? 0 : 4, Math.max(0, control.height - originalBottom));
|
|
4455
|
-
/**
|
|
4535
|
+
}), top = Math.min(...images.map((image) => image.frame.y)), bottom = Math.max(...images.map((image) => image.frame.y + image.frame.height)), band = bottom - top, originalBottom = Math.max(bottom, ...control.layout.texts.map((text) => text.baseline + (text.fontMetrics ?? metrics).descent), ...control.layout.markers.map((marker) => marker.frame.y + marker.frame.height)), padding = Math.min(control.layout.appearance === "text" ? 0 : 4, Math.max(0, control.height - originalBottom));
|
|
4536
|
+
/** 无显式图片锚点的普通标签只在图形下方随图片上移。 */
|
|
4456
4537
|
function shift(y, scale) {
|
|
4457
4538
|
return y >= bottom - 1e-7 ? band * (1 - scale) : 0;
|
|
4458
4539
|
}
|
|
4540
|
+
/** 日期依赖实际图片框,缩图时重新居中,字形及 2px 跟随间距不缩放。 */
|
|
4541
|
+
function position(text, scale) {
|
|
4542
|
+
const decoration = text.imageDecoration, image = decoration && images[decoration.imageIndex];
|
|
4543
|
+
const font = text.fontMetrics ?? metrics;
|
|
4544
|
+
if (!image || !decoration) return {
|
|
4545
|
+
x: text.x,
|
|
4546
|
+
baseline: text.baseline - shift(text.baseline - font.ascent, scale)
|
|
4547
|
+
};
|
|
4548
|
+
const frame = image.frame, width = frame.width * scale, height = frame.height * scale;
|
|
4549
|
+
const x = frame.x + (frame.width - width) / 2, y = top + (frame.y - top) * scale;
|
|
4550
|
+
return {
|
|
4551
|
+
x: decoration.placement === "right" ? x + width + decoration.gapPx : x + (width - text.width) / 2,
|
|
4552
|
+
baseline: y + (decoration.placement === "right" ? (height - font.ascent - font.descent) / 2 : height + decoration.gapPx) + font.ascent
|
|
4553
|
+
};
|
|
4554
|
+
}
|
|
4459
4555
|
/** 当前比例下保留全部标签和图形所需的最小高度。 */
|
|
4460
4556
|
function height(scale) {
|
|
4461
|
-
return Math.max(top + band * scale, ...control.layout.texts.map((text) => text.baseline
|
|
4557
|
+
return Math.max(top + band * scale, ...control.layout.texts.map((text) => position(text, scale).baseline + (text.fontMetrics ?? metrics).descent), ...control.layout.markers.map((marker) => marker.frame.y - shift(marker.frame.y, scale) + marker.frame.height)) + padding;
|
|
4462
4558
|
}
|
|
4463
4559
|
const minimumScale = Math.min(1, 1 / Math.min(...images.flatMap((image) => [image.frame.width, image.frame.height])));
|
|
4464
4560
|
return {
|
|
@@ -4466,6 +4562,7 @@ function graphicEnvelope(control, paint, context) {
|
|
|
4466
4562
|
band,
|
|
4467
4563
|
shift,
|
|
4468
4564
|
height,
|
|
4565
|
+
position,
|
|
4469
4566
|
ascent: metrics.ascent,
|
|
4470
4567
|
minimumScale
|
|
4471
4568
|
};
|
|
@@ -4491,29 +4588,38 @@ function fitControl(control, paint, maximum, context) {
|
|
|
4491
4588
|
else high = scale;
|
|
4492
4589
|
}
|
|
4493
4590
|
const scale = low, height = envelope.height(scale);
|
|
4591
|
+
const fittedImages = control.layout.images.map((image) => ({
|
|
4592
|
+
...image,
|
|
4593
|
+
frame: {
|
|
4594
|
+
...image.frame,
|
|
4595
|
+
x: image.frame.x + image.frame.width * (1 - scale) / 2,
|
|
4596
|
+
y: envelope.top + (image.frame.y - envelope.top) * scale,
|
|
4597
|
+
width: image.frame.width * scale,
|
|
4598
|
+
height: image.frame.height * scale
|
|
4599
|
+
}
|
|
4600
|
+
}));
|
|
4494
4601
|
return {
|
|
4495
4602
|
...control,
|
|
4496
4603
|
height,
|
|
4497
4604
|
baseline: Math.min(control.baseline, height),
|
|
4498
4605
|
layout: {
|
|
4499
4606
|
...control.layout,
|
|
4500
|
-
images:
|
|
4501
|
-
|
|
4607
|
+
images: fittedImages,
|
|
4608
|
+
...control.layout.bracketFrames ? { bracketFrames: control.layout.bracketFrames.map((bracket) => ({
|
|
4609
|
+
...bracket,
|
|
4502
4610
|
frame: {
|
|
4503
|
-
...
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
width: image.frame.width * scale,
|
|
4507
|
-
height: image.frame.height * scale
|
|
4611
|
+
...bracket.frame,
|
|
4612
|
+
y: 0,
|
|
4613
|
+
height
|
|
4508
4614
|
}
|
|
4509
|
-
})),
|
|
4615
|
+
})) } : {},
|
|
4510
4616
|
...control.layout.bracketTexts ? { bracketTexts: control.layout.bracketTexts.map((text) => ({
|
|
4511
4617
|
...text,
|
|
4512
4618
|
baseline: text.baseline - envelope.shift(text.baseline - envelope.ascent, scale)
|
|
4513
4619
|
})) } : {},
|
|
4514
4620
|
texts: control.layout.texts.map((text) => ({
|
|
4515
4621
|
...text,
|
|
4516
|
-
|
|
4622
|
+
...envelope.position(text, scale)
|
|
4517
4623
|
})),
|
|
4518
4624
|
markers: control.layout.markers.map((marker) => ({
|
|
4519
4625
|
...marker,
|
|
@@ -4777,7 +4883,8 @@ var LineFlow = class {
|
|
|
4777
4883
|
return parts.map((part, index) => {
|
|
4778
4884
|
const piece = units[index];
|
|
4779
4885
|
if (!canFitAtomic(piece)) return part;
|
|
4780
|
-
const
|
|
4886
|
+
const controlMaximum = piece.kind === "control" ? piece.control.baseline > frameHeight - descent - (piece.paint.baselineShiftPx ?? 0) ? frameHeight - descent - (piece.paint.baselineShiftPx ?? 0) : frameHeight - baseline + piece.control.baseline + (piece.paint.baselineShiftPx ?? 0) : void 0;
|
|
4887
|
+
const fit = fitAtomic(piece, piece.kind === "control" ? controlMaximum : piece.kind === "pageWidget" ? baseline - (piece.widget.paint.baselineShiftPx ?? 0) : baseline, this.context);
|
|
4781
4888
|
return fit.issue ? {
|
|
4782
4889
|
...part,
|
|
4783
4890
|
piece: fit.piece,
|
|
@@ -4961,6 +5068,7 @@ var RowFlow = class {
|
|
|
4961
5068
|
table;
|
|
4962
5069
|
group;
|
|
4963
5070
|
context;
|
|
5071
|
+
contentFlow;
|
|
4964
5072
|
/** 当前源显示行。 */
|
|
4965
5073
|
index;
|
|
4966
5074
|
/** 物理页片段序号,不写入 model。 */
|
|
@@ -4974,10 +5082,11 @@ var RowFlow = class {
|
|
|
4974
5082
|
/** 每个合并主格只注册一次进度。 */
|
|
4975
5083
|
cells;
|
|
4976
5084
|
/** 借用本轮测量结果,不创建新原生网格或业务值副本。 */
|
|
4977
|
-
constructor(table, group, context) {
|
|
5085
|
+
constructor(table, group, context, contentFlow) {
|
|
4978
5086
|
this.table = table;
|
|
4979
5087
|
this.group = group;
|
|
4980
5088
|
this.context = context;
|
|
5089
|
+
this.contentFlow = contentFlow;
|
|
4981
5090
|
this.index = group.from;
|
|
4982
5091
|
for (let row = group.from; row < group.to; row++) {
|
|
4983
5092
|
this.remaining.set(row, table.rowOffsets[row + 1] - table.rowOffsets[row]);
|
|
@@ -4995,7 +5104,7 @@ var RowFlow = class {
|
|
|
4995
5104
|
to,
|
|
4996
5105
|
deadline,
|
|
4997
5106
|
flexible: deadline >= 0,
|
|
4998
|
-
...deadline >= 0 ? { cursor:
|
|
5107
|
+
...deadline >= 0 ? { cursor: this.contentFlow.create(cell, context) } : {},
|
|
4999
5108
|
started: false
|
|
5000
5109
|
});
|
|
5001
5110
|
}
|
|
@@ -5058,7 +5167,7 @@ var RowFlow = class {
|
|
|
5058
5167
|
to,
|
|
5059
5168
|
top,
|
|
5060
5169
|
ending,
|
|
5061
|
-
slice: state.cursor ?
|
|
5170
|
+
slice: state.cursor ? this.contentFlow.preview(state.cursor, Math.max(0, height - top - state.cell.padding.bottom), forceFirst, Math.max(1, frameHeight - top - state.cell.padding.bottom)) : FIXED_GEOMETRY_SLICE
|
|
5062
5171
|
});
|
|
5063
5172
|
}
|
|
5064
5173
|
return result;
|
|
@@ -5176,7 +5285,7 @@ var RowFlow = class {
|
|
|
5176
5285
|
height: Math.max(0, cellHeight - plan.top - bottom)
|
|
5177
5286
|
};
|
|
5178
5287
|
const sourceOffset = table.rowOffsets[rows[plan.from].index] - table.rowOffsets[plan.state.from] + (table.rowOffsets[rows[plan.from].index + 1] - table.rowOffsets[rows[plan.from].index] - this.remaining.get(rows[plan.from].index));
|
|
5179
|
-
const fixed = plan.state.flexible ? void 0 : placeCellWindow(cell, frame.x, cellY - sourceOffset, frame, pageId, context);
|
|
5288
|
+
const fixed = plan.state.flexible ? void 0 : placeCellWindow(cell, frame.x, cellY - sourceOffset, frame, pageId, context, placeMeasuredBlocks);
|
|
5180
5289
|
const fragment = {
|
|
5181
5290
|
kind: "cell",
|
|
5182
5291
|
id: layoutIdentity(context.identityScope, "cell", cell.instance.key, table.nodeId, "continuation", this.part),
|
|
@@ -5190,7 +5299,7 @@ var RowFlow = class {
|
|
|
5190
5299
|
backgroundColor: cell.backgroundColor,
|
|
5191
5300
|
frame,
|
|
5192
5301
|
contentFrame: fixed?.contentFrame ?? contentFrame,
|
|
5193
|
-
blocks: plan.state.flexible ?
|
|
5302
|
+
blocks: plan.state.flexible ? this.contentFlow.place(plan.slice, contentFrame.x, contentFrame.y, pageId, context) : fixed.blocks
|
|
5194
5303
|
};
|
|
5195
5304
|
cellRows[plan.from].push(fragment);
|
|
5196
5305
|
}
|
|
@@ -5404,6 +5513,7 @@ var NO_TABLE_HEADERS = Object.freeze([]);
|
|
|
5404
5513
|
var TableFlow = class {
|
|
5405
5514
|
table;
|
|
5406
5515
|
context;
|
|
5516
|
+
contentFlow;
|
|
5407
5517
|
/** 当前测量独占的表头与显式分页索引,完成后随游标释放。 */
|
|
5408
5518
|
indexed;
|
|
5409
5519
|
/** 当前尚未完成的行组下标。 */
|
|
@@ -5413,9 +5523,10 @@ var TableFlow = class {
|
|
|
5413
5523
|
/** 只保留当前候选涉及的行组进度,完成即释放。 */
|
|
5414
5524
|
flows = /* @__PURE__ */ new Map();
|
|
5415
5525
|
/** 借用同一次构建的测量及来源注册器,不创建全局状态。 */
|
|
5416
|
-
constructor(table, context) {
|
|
5526
|
+
constructor(table, context, contentFlow) {
|
|
5417
5527
|
this.table = table;
|
|
5418
5528
|
this.context = context;
|
|
5529
|
+
this.contentFlow = contentFlow;
|
|
5419
5530
|
}
|
|
5420
5531
|
/** 首次实际查询才建立规则,构造游标本身不创建中间索引。 */
|
|
5421
5532
|
get rules() {
|
|
@@ -5449,7 +5560,7 @@ var TableFlow = class {
|
|
|
5449
5560
|
if (existing) return existing;
|
|
5450
5561
|
const group = this.table.groups[index];
|
|
5451
5562
|
if (!group || !(this.table.hasPageBreak ? this.rules.needsFlow(index, frameHeight) : this.rangeHeight(group) > frameHeight)) return void 0;
|
|
5452
|
-
const flow = new RowFlow(this.table, group, this.context);
|
|
5563
|
+
const flow = new RowFlow(this.table, group, this.context, this.contentFlow);
|
|
5453
5564
|
this.flows.set(index, flow);
|
|
5454
5565
|
return flow;
|
|
5455
5566
|
}
|
|
@@ -5680,7 +5791,7 @@ var ContentFlowCursor = class {
|
|
|
5680
5791
|
tableFlow(table) {
|
|
5681
5792
|
let flow = this.tables.get(table);
|
|
5682
5793
|
if (!flow) {
|
|
5683
|
-
flow = new TableFlow(table, this.context);
|
|
5794
|
+
flow = new TableFlow(table, this.context, contentFlowOperations);
|
|
5684
5795
|
this.tables.set(table, flow);
|
|
5685
5796
|
}
|
|
5686
5797
|
return flow;
|
|
@@ -5827,6 +5938,12 @@ function placeContentFlow(slice, x, y, pageId, context) {
|
|
|
5827
5938
|
}
|
|
5828
5939
|
return result;
|
|
5829
5940
|
}
|
|
5941
|
+
/** 仅包含无状态函数,游标、候选和上下文仍由本轮分页拥有。 */
|
|
5942
|
+
var contentFlowOperations = {
|
|
5943
|
+
create: (source, context) => new ContentFlowCursor(source, context),
|
|
5944
|
+
preview: previewContentFlow,
|
|
5945
|
+
place: placeContentFlow
|
|
5946
|
+
};
|
|
5830
5947
|
// src/layout/engine/pagination/paragraph-pagination.ts
|
|
5831
5948
|
/** @file 正文段落直接消费统一内容流,文字、长控件和混排行共用分页进度。 */
|
|
5832
5949
|
/** 两种分页路径共用最终放置与诊断,始终使用本轮源块和实例。 */
|
|
@@ -5873,7 +5990,7 @@ function paginateParagraph(block, current, nextPage, context) {
|
|
|
5873
5990
|
/** @file 正文级表格分页:整行快路径与内容连续流共用页、表头和最终共享边。 */
|
|
5874
5991
|
/** 表头超过容量时优先推进实际内容,最终表格每页只发布一份组合结果。 */
|
|
5875
5992
|
function paginateTable(table, current, nextPage, context, reuse) {
|
|
5876
|
-
const flow = new TableFlow(table, context);
|
|
5993
|
+
const flow = new TableFlow(table, context, contentFlowOperations);
|
|
5877
5994
|
while (!flow.done) {
|
|
5878
5995
|
/** 本页段未命中时使用原分页推进,候选不被提前消费。 */
|
|
5879
5996
|
const calculate = () => {
|
|
@@ -7829,6 +7946,10 @@ function indexResult(result, reuse) {
|
|
|
7829
7946
|
if (box.lineHeightPx <= 0 || box.width <= 0 || box.height <= 0) throw new LayoutContractError("invalid_geometry", "字段输入内容框不能保证编辑进度");
|
|
7830
7947
|
}
|
|
7831
7948
|
for (const image of fragment.fieldControl.images ?? []) validateImage(image);
|
|
7949
|
+
for (const bracket of fragment.fieldControl.bracketFrames ?? []) {
|
|
7950
|
+
validateRect(bracket.frame);
|
|
7951
|
+
if (bracket.side !== "start" && bracket.side !== "end") throw new LayoutContractError("invalid_geometry", "字段括号方向无效");
|
|
7952
|
+
}
|
|
7832
7953
|
if (fragment.role !== "field") throw new LayoutContractError("invalid_geometry", "控件绘制描述必须属于字段");
|
|
7833
7954
|
validateFragmentStyles(fragment, result);
|
|
7834
7955
|
for (const text of [...fragment.fieldControl.texts, ...fragment.fieldControl.bracketTexts ?? []]) {
|
|
@@ -10692,7 +10813,7 @@ var EditorBusinessTables = class {
|
|
|
10692
10813
|
if (node?.kind !== "cell") continue;
|
|
10693
10814
|
const quickFill = this.require(source).tables.quickFill;
|
|
10694
10815
|
const current = quickFill.readMatrix(source.regionId, source.slotIndex);
|
|
10695
|
-
if (!current?.enabled) throw new TextFlowError("
|
|
10816
|
+
if (!current?.enabled) throw new TextFlowError("当前表格区域不允许矩形粘贴");
|
|
10696
10817
|
if (!isEqual(source.version, current.version)) throw new TextFlowError("当前业务格已变化,请重新粘贴");
|
|
10697
10818
|
this.require(source);
|
|
10698
10819
|
return quickFill.applyMatrix(current, {
|
|
@@ -10918,7 +11039,7 @@ function matrixTableProjection(query, table) {
|
|
|
10918
11039
|
const cell = grid.cells[row][column];
|
|
10919
11040
|
if (!cell.merge || cell.merge.isMaster) {
|
|
10920
11041
|
const previous = cells.get(cell.cellId);
|
|
10921
|
-
if (previous.regionId && previous.regionId !== region.id) throw new Error("
|
|
11042
|
+
if (previous.regionId && previous.regionId !== region.id) throw new Error("二维主体与其他表格区域的关联行带重叠");
|
|
10922
11043
|
cells.set(cell.cellId, {
|
|
10923
11044
|
sourceCellId: cell.cellId,
|
|
10924
11045
|
regionId: region.id,
|
|
@@ -10935,7 +11056,7 @@ function matrixTableProjection(query, table) {
|
|
|
10935
11056
|
const target = grid.cells[mapping.row][mapping.column];
|
|
10936
11057
|
if (target.merge && !target.merge.isMaster) continue;
|
|
10937
11058
|
const previous = cells.get(target.cellId);
|
|
10938
|
-
if (previous.regionId && previous.regionId !== region.id) throw new Error("
|
|
11059
|
+
if (previous.regionId && previous.regionId !== region.id) throw new Error("二维关联行带与其他表格区域发生重叠");
|
|
10939
11060
|
const source = grid.cells[mapping.sourceRow][mapping.sourceColumn];
|
|
10940
11061
|
cells.set(target.cellId, {
|
|
10941
11062
|
sourceCellId: source.merge?.masterCellId ?? source.cellId,
|
|
@@ -11008,7 +11129,7 @@ function assertClipboardBindings(fragment, blocks, inherited) {
|
|
|
11008
11129
|
const path = fragment.bindings[node.bindingId]?.pathTemplate;
|
|
11009
11130
|
if (path?.includes("[n")) {
|
|
11010
11131
|
const binding = parseValuePath(path);
|
|
11011
|
-
if (!inherited.has(binding.parentFieldPath) || binding.isLink && !inherited.has(binding.linkFieldPath)) throw new TextFlowError("
|
|
11132
|
+
if (!inherited.has(binding.parentFieldPath) || binding.isLink && !inherited.has(binding.linkFieldPath)) throw new TextFlowError("剪贴字段的子表绑定与目标表格区域不匹配");
|
|
11012
11133
|
}
|
|
11013
11134
|
for (const attachment of node.attachments ?? []) assertClipboardBindings(fragment, attachment.blocks, inherited);
|
|
11014
11135
|
}
|
|
@@ -12192,6 +12313,65 @@ function inputTextStyle(model, flow, selection, format) {
|
|
|
12192
12313
|
const patched = format ? patchTextDeclaration(declaration, format) : declaration;
|
|
12193
12314
|
return id ? model.query.resolveTextStyle(id, patched) : model.query.resolveDefaultTextStyle(patched);
|
|
12194
12315
|
}
|
|
12316
|
+
// src/runtime/interaction/design/format/targets.ts
|
|
12317
|
+
/** @file 文字与单元格选区共用格式目标;只借用真实内容,不把矩形伪造成连续文字范围。 */
|
|
12318
|
+
/** 格选择覆盖可见合并主格内的所有段落,空格仅在明确设置格式时由调用方物化。 */
|
|
12319
|
+
function* formatTargets(context, selection) {
|
|
12320
|
+
if (selection.kind === "text") {
|
|
12321
|
+
yield* context.flow().formatTargets(selection);
|
|
12322
|
+
return;
|
|
12323
|
+
}
|
|
12324
|
+
const model = context.handle().readModel(), { table, rectangle } = resolveCellSelection(model, selection), visited = /* @__PURE__ */ new Set();
|
|
12325
|
+
function* cell(id) {
|
|
12326
|
+
const master = model.query.getCellInfo(id).merge?.masterCellId ?? id;
|
|
12327
|
+
if (visited.has(master)) return;
|
|
12328
|
+
visited.add(master);
|
|
12329
|
+
yield* blocks(master, model.query.getEntity(master, "cell").blocks);
|
|
12330
|
+
}
|
|
12331
|
+
function* blocks(ownerId, content) {
|
|
12332
|
+
if (!content.length) yield {
|
|
12333
|
+
kind: "blockGap",
|
|
12334
|
+
parentId: ownerId,
|
|
12335
|
+
index: 0
|
|
12336
|
+
};
|
|
12337
|
+
for (const block of content) if (block.kind === "paragraph") yield {
|
|
12338
|
+
from: {
|
|
12339
|
+
paragraphId: block.id,
|
|
12340
|
+
index: 0
|
|
12341
|
+
},
|
|
12342
|
+
to: {
|
|
12343
|
+
paragraphId: block.id,
|
|
12344
|
+
index: block.content.length
|
|
12345
|
+
}
|
|
12346
|
+
};
|
|
12347
|
+
else for (const row of block.rows) for (const nested of row.cells) yield* cell(nested.id);
|
|
12348
|
+
}
|
|
12349
|
+
for (let row = rectangle.top; row <= rectangle.bottom; row++) for (let column = rectangle.left; column <= rectangle.right; column++) yield* cell(table.rows[row].cells[column].id);
|
|
12350
|
+
}
|
|
12351
|
+
/** 文字范围沿用原生投影;格选择只返回选中主格内的模板文字和原子声明。 */
|
|
12352
|
+
function formatInlines(context, selection) {
|
|
12353
|
+
if (selection.kind === "text") {
|
|
12354
|
+
const projection = context.flow().projection(selection);
|
|
12355
|
+
return [...projection.spans.map(({ source }) => {
|
|
12356
|
+
if (source.kind !== "modelText") throw new TextFlowError("格式不能修改字段填写值");
|
|
12357
|
+
return {
|
|
12358
|
+
id: source.nodeId,
|
|
12359
|
+
from: source.from,
|
|
12360
|
+
to: source.to
|
|
12361
|
+
};
|
|
12362
|
+
}), ...projection.nodes.map(({ nodeId }) => ({
|
|
12363
|
+
id: nodeId,
|
|
12364
|
+
from: 0,
|
|
12365
|
+
to: 1
|
|
12366
|
+
}))];
|
|
12367
|
+
}
|
|
12368
|
+
const query = context.handle().readModel().query;
|
|
12369
|
+
return [...formatTargets(context, selection)].flatMap((range) => "kind" in range ? [] : query.getEntity(range.from.paragraphId, "paragraph").content.map((node) => ({
|
|
12370
|
+
id: node.id,
|
|
12371
|
+
from: 0,
|
|
12372
|
+
to: node.kind === "text" ? node.text.length : 1
|
|
12373
|
+
})));
|
|
12374
|
+
}
|
|
12195
12375
|
// src/runtime/interaction/design/format/property-format.ts
|
|
12196
12376
|
/** @file 嵌套样式单属性更新,保留不同目标的相邻直接声明,不写入有效样式。 */
|
|
12197
12377
|
/** 单个对象属性覆盖/恢复继承,只隔离其所属小对象,绝不修改模型或输入调用者。 */
|
|
@@ -12227,12 +12407,12 @@ function setTextProperty(context, path, value) {
|
|
|
12227
12407
|
checkTextPath(path);
|
|
12228
12408
|
const model = context.handle().readModel(), flow = context.flow(), selection = context.selection();
|
|
12229
12409
|
readTextFormatUpdate(model.document, patch({}, path, value));
|
|
12230
|
-
if (flow.ordered(selection).collapsed) {
|
|
12410
|
+
if (selection.kind === "text" && flow.ordered(selection).collapsed) {
|
|
12231
12411
|
const update = patch(patchTextDeclaration(inputDeclaration(model, flow, selection).declaration, context.inputFormat() ?? {}).textStyle, path, value);
|
|
12232
12412
|
context.setInputFormat(mergeInputFormat(model, context.inputFormat(), update));
|
|
12233
12413
|
return null;
|
|
12234
12414
|
}
|
|
12235
|
-
const ranges = [...
|
|
12415
|
+
const ranges = [...formatTargets(context, selection)];
|
|
12236
12416
|
const emptyParagraphs = ranges.flatMap((range) => {
|
|
12237
12417
|
if ("kind" in range) return [];
|
|
12238
12418
|
const paragraph = model.query.getEntity(range.from.paragraphId, "paragraph");
|
|
@@ -12242,21 +12422,10 @@ function setTextProperty(context, path, value) {
|
|
|
12242
12422
|
next: patchTextDeclaration(paragraph, patch(paragraph.textStyle, path, value))
|
|
12243
12423
|
}];
|
|
12244
12424
|
});
|
|
12245
|
-
const
|
|
12246
|
-
|
|
12247
|
-
return
|
|
12248
|
-
|
|
12249
|
-
from: span.source.from,
|
|
12250
|
-
to: span.source.to
|
|
12251
|
-
};
|
|
12252
|
-
}), ...projection.nodes.filter((node) => {
|
|
12253
|
-
const entity = model.query.getEntity(node.nodeId);
|
|
12254
|
-
return entity && "kind" in entity && (entity.kind === "field" || entity.kind === "pageWidget");
|
|
12255
|
-
}).map((node) => ({
|
|
12256
|
-
id: node.nodeId,
|
|
12257
|
-
from: 0,
|
|
12258
|
-
to: 1
|
|
12259
|
-
}))];
|
|
12425
|
+
const targets = formatInlines(context, selection).filter((target) => {
|
|
12426
|
+
const entity = model.query.getEntity(target.id);
|
|
12427
|
+
return entity && "kind" in entity && (entity.kind === "text" || entity.kind === "field" || entity.kind === "pageWidget");
|
|
12428
|
+
});
|
|
12260
12429
|
for (const target of targets) if (model.query.getEntity(target.id, "field")?.config?.designLocked === true) throw new TextFlowError("所选字段配置已锁定");
|
|
12261
12430
|
const order = /* @__PURE__ */ new Map();
|
|
12262
12431
|
let index = 0;
|
|
@@ -12320,7 +12489,7 @@ function setParagraphProperty(context, path, value) {
|
|
|
12320
12489
|
]
|
|
12321
12490
|
}[path[0]]?.includes(path[1])) throw new TextFlowError("未知段落格式属性");
|
|
12322
12491
|
readParagraphFormatUpdate(context.handle().readModel().document, patch({}, path, value));
|
|
12323
|
-
const targets = [...
|
|
12492
|
+
const targets = [...formatTargets(context, context.selection())];
|
|
12324
12493
|
const model = context.handle().readModel();
|
|
12325
12494
|
const commands = targets.map((target) => ({
|
|
12326
12495
|
target,
|
|
@@ -12365,11 +12534,11 @@ function common(styles) {
|
|
|
12365
12534
|
}
|
|
12366
12535
|
/** 读取选择触达的真实文字/字段/页组件;下一段起点不串入当前格式摘要。 */
|
|
12367
12536
|
function readFormat(context, selection) {
|
|
12368
|
-
const handle = context.handle(), model = handle.readModel(), flow = context.flow(), typing = flow.ordered(selection).collapsed;
|
|
12537
|
+
const handle = context.handle(), model = handle.readModel(), flow = context.flow(), typing = selection.kind === "text" && flow.ordered(selection).collapsed;
|
|
12369
12538
|
const texts = [], paragraphs = [];
|
|
12370
12539
|
const inputFormat = context.inputFormat();
|
|
12371
|
-
if (typing) texts.push(inputTextStyle(model, flow, selection, inputFormat));
|
|
12372
|
-
for (const target of
|
|
12540
|
+
if (typing && selection.kind === "text") texts.push(inputTextStyle(model, flow, selection, inputFormat));
|
|
12541
|
+
for (const target of formatTargets(context, selection)) {
|
|
12373
12542
|
if ("kind" in target) {
|
|
12374
12543
|
paragraphs.push(model.query.resolveDefaultParagraphStyle());
|
|
12375
12544
|
if (!typing) texts.push(model.query.resolveDefaultTextStyle());
|
|
@@ -12414,22 +12583,22 @@ var EditorFormat = class {
|
|
|
12414
12583
|
constructor(context) {
|
|
12415
12584
|
this.context = context;
|
|
12416
12585
|
}
|
|
12417
|
-
/**
|
|
12586
|
+
/** 按当前文字或格选区读取小份格式,填报值不作为模板文字处理。 */
|
|
12418
12587
|
read() {
|
|
12419
12588
|
const selection = this.context?.selection();
|
|
12420
|
-
return selection?.kind === "text" ? readFormat(this.context, selection) : void 0;
|
|
12589
|
+
return selection?.kind === "text" || selection?.kind === "cells" ? readFormat(this.context, selection) : void 0;
|
|
12421
12590
|
}
|
|
12422
|
-
/**
|
|
12591
|
+
/** 折叠光标只发布输入意图;文字范围或格内内容通过原生 API 修改并保留选区。 */
|
|
12423
12592
|
applyText(expected, update) {
|
|
12424
|
-
const context = this.require(expected), model = context.handle().readModel(), flow = context.flow(), selection =
|
|
12593
|
+
const context = this.require(expected), model = context.handle().readModel(), flow = context.flow(), selection = expected.selection;
|
|
12425
12594
|
const patch = readTextFormatUpdate(model.document, update);
|
|
12426
|
-
if (flow.ordered(selection).collapsed) {
|
|
12595
|
+
if (selection.kind === "text" && flow.ordered(selection).collapsed) {
|
|
12427
12596
|
const merged = mergeInputFormat(model, context.inputFormat(), patch);
|
|
12428
12597
|
if (!isEqual(merged, context.inputFormat() ?? {})) context.setInputFormat(merged);
|
|
12429
12598
|
return null;
|
|
12430
12599
|
}
|
|
12431
|
-
for (const selected of
|
|
12432
|
-
const targets = [...
|
|
12600
|
+
for (const selected of formatInlines(context, selection)) if (model.query.getEntity(selected.id, "field")?.config?.designLocked === true) throw new TextFlowError("所选字段配置已锁定");
|
|
12601
|
+
const targets = [...formatTargets(context, selection)], empty = /* @__PURE__ */ new Map();
|
|
12433
12602
|
for (const target of targets) if (!("kind" in target)) {
|
|
12434
12603
|
const paragraph = model.query.getEntity(target.from.paragraphId, "paragraph");
|
|
12435
12604
|
if (!paragraph.content.length) empty.set(paragraph.id, {
|
|
@@ -12457,7 +12626,7 @@ var EditorFormat = class {
|
|
|
12457
12626
|
/** 段落格式作用于真实触达段落;空集合只有明确设置时才物化一个段落。 */
|
|
12458
12627
|
applyParagraph(expected, update) {
|
|
12459
12628
|
const context = this.require(expected), patch = readParagraphFormatUpdate(context.handle().readModel().document, update);
|
|
12460
|
-
const targets = [...
|
|
12629
|
+
const targets = [...formatTargets(context, expected.selection)];
|
|
12461
12630
|
return context.execute("修改段落格式", (editor) => {
|
|
12462
12631
|
for (const target of targets) if (!("kind" in target)) editor.ranges.formatParagraphs(target, patch);
|
|
12463
12632
|
else if (Object.keys(patch.set ?? {}).length || patch.paragraphStyleId != null) {
|
|
@@ -12741,7 +12910,7 @@ var EditorTableRegions = class {
|
|
|
12741
12910
|
assertRegionOwner(this.context.handle().readModel(), expected.selection.tableId);
|
|
12742
12911
|
this.assertCanCreate(options.type, options.variant?.name);
|
|
12743
12912
|
let id = "";
|
|
12744
|
-
this.context.execute("
|
|
12913
|
+
this.context.execute("创建表格区域", (editor) => {
|
|
12745
12914
|
id = editor.tables.addRegion(expected.selection.tableId, {
|
|
12746
12915
|
...options,
|
|
12747
12916
|
range: options.range === void 0 ? expected.range : options.range
|
|
@@ -12794,7 +12963,7 @@ var EditorTableRegions = class {
|
|
|
12794
12963
|
assertRegionOwner(this.context.handle().readModel(), expected.selection.tableId);
|
|
12795
12964
|
this.assertCanCreate(type, variantName);
|
|
12796
12965
|
}
|
|
12797
|
-
return this.context.execute("
|
|
12966
|
+
return this.context.execute("修改表格区域", (editor) => {
|
|
12798
12967
|
editor.tables.updateRegion(expected.regionId, update);
|
|
12799
12968
|
});
|
|
12800
12969
|
}
|
|
@@ -12808,7 +12977,7 @@ var EditorTableRegions = class {
|
|
|
12808
12977
|
/** 只删除区域声明;依赖默认拒绝,明确 remove 才级联,格内容始终由原生表格拥有。 */
|
|
12809
12978
|
remove(expected, options = {}) {
|
|
12810
12979
|
this.require(expected);
|
|
12811
|
-
return this.context.execute("
|
|
12980
|
+
return this.context.execute("删除表格区域", (editor) => {
|
|
12812
12981
|
editor.tables.removeRegion(expected.regionId, options);
|
|
12813
12982
|
});
|
|
12814
12983
|
}
|
|
@@ -13585,7 +13754,7 @@ var EditorPageWidgets = class {
|
|
|
13585
13754
|
if (binding?.pathTemplate.includes("[n")) {
|
|
13586
13755
|
const path = parseValuePath(binding.pathTemplate);
|
|
13587
13756
|
const axes = destinationAxes(this.context.handle().readModel(), node.id);
|
|
13588
|
-
if (!axes.has(path.parentFieldPath) || path.isLink && !axes.has(path.linkFieldPath)) throw new TextFlowError("
|
|
13757
|
+
if (!axes.has(path.parentFieldPath) || path.isLink && !axes.has(path.linkFieldPath)) throw new TextFlowError("该字段和当前组件所在表格区域不匹配");
|
|
13589
13758
|
}
|
|
13590
13759
|
return this.context.execute("绑定组件字段", (editor) => {
|
|
13591
13760
|
const bindingId = binding ? editor.ensureBinding({ binding }) : null;
|
|
@@ -14783,9 +14952,9 @@ var EditorController = class {
|
|
|
14783
14952
|
...options.style,
|
|
14784
14953
|
cellPaddingPx: options.style?.cellPaddingPx ?? {
|
|
14785
14954
|
top: 5,
|
|
14786
|
-
right:
|
|
14955
|
+
right: 8,
|
|
14787
14956
|
bottom: 5,
|
|
14788
|
-
left:
|
|
14957
|
+
left: 8
|
|
14789
14958
|
},
|
|
14790
14959
|
borders: options.style?.borders ?? {
|
|
14791
14960
|
top: edge,
|
|
@@ -15105,6 +15274,19 @@ var EditorController = class {
|
|
|
15105
15274
|
const options = this.requireOptions(), selection = this.state.selection;
|
|
15106
15275
|
return selection?.kind === "field" && options.form ? readFieldSignatureInput(this.requireHandle(), options, selection) : void 0;
|
|
15107
15276
|
}
|
|
15277
|
+
/** 弹框前预检查,不认证;无校验需求时保持同步。 */
|
|
15278
|
+
validateFieldSignature(expected, signal) {
|
|
15279
|
+
const options = this.requireOptions();
|
|
15280
|
+
const handle = this.requireHandle();
|
|
15281
|
+
assertFieldSignatureInput(handle, options, this.state.selection, expected);
|
|
15282
|
+
if (signal.aborted) throw new TextFlowError("签名前检查已取消");
|
|
15283
|
+
const checking = options.form.services.signatures.validateBeforeOpen(expected.selection.fieldId, expected.valuePath, signal);
|
|
15284
|
+
if (!checking) return;
|
|
15285
|
+
return checking.then(() => {
|
|
15286
|
+
if (signal.aborted || this.handle !== handle || this.options !== options) throw new TextFlowError("签名前检查已取消");
|
|
15287
|
+
assertFieldSignatureInput(this.requireHandle(), this.requireOptions(), this.state.selection, expected);
|
|
15288
|
+
});
|
|
15289
|
+
}
|
|
15108
15290
|
/** 用户明确认证后取得原业务服务的不透明预览;取消和过期结果不写入。 */
|
|
15109
15291
|
async prepareFieldSignature(expected, signal, authorization) {
|
|
15110
15292
|
const options = this.requireOptions();
|
|
@@ -15530,6 +15712,55 @@ function isCompanionIdPath(path) {
|
|
|
15530
15712
|
function isDerivedDataPath(path) {
|
|
15531
15713
|
return path.endsWith("_lb_") || path.endsWith("_href_") || isCompanionIdPath(path);
|
|
15532
15714
|
}
|
|
15715
|
+
// src/data/rows/copy-row.ts
|
|
15716
|
+
/** @file 复制载荷的字段清理,不读取业务模型或修改源行。 */
|
|
15717
|
+
/** 只清理已有属性,缺失嵌套对象不会因复制被创建。 */
|
|
15718
|
+
function clearCopiedFields(row, paths, emptyValue) {
|
|
15719
|
+
const dataPaths = new JsonDataPaths();
|
|
15720
|
+
for (const relative of paths) {
|
|
15721
|
+
const path = "$." + relative;
|
|
15722
|
+
const parts = dataPaths.parse(path);
|
|
15723
|
+
const leaf = parts.pop();
|
|
15724
|
+
const parent = dataPaths.read(row, formatPath(parts));
|
|
15725
|
+
if (parent !== null && typeof parent === "object" && Object.hasOwn(parent, leaf)) dataPaths.setProperty(parent, leaf, emptyValue ? emptyValue(relative) : null);
|
|
15726
|
+
for (const companion of [
|
|
15727
|
+
getLabelPath(path),
|
|
15728
|
+
getHrefPath(path),
|
|
15729
|
+
getIdPath(path)
|
|
15730
|
+
]) dataPaths.delete(row, companion);
|
|
15731
|
+
}
|
|
15732
|
+
}
|
|
15733
|
+
/** 克隆后清理,源行的值和派生属性保持原状。 */
|
|
15734
|
+
function cloneCopiedRow(source, paths) {
|
|
15735
|
+
const row = cloneDeep(source);
|
|
15736
|
+
clearCopiedFields(row, paths);
|
|
15737
|
+
return row;
|
|
15738
|
+
}
|
|
15739
|
+
// src/runtime/form/copy-field-paths.ts
|
|
15740
|
+
var nonCopyableTypes = /* @__PURE__ */ new Set([
|
|
15741
|
+
"signature",
|
|
15742
|
+
"electronic_signature",
|
|
15743
|
+
"reporter",
|
|
15744
|
+
"warehouse_manager"
|
|
15745
|
+
]);
|
|
15746
|
+
/** tableKey 不带 $.;二维交叉区直接使用 yKey:xKey。 */
|
|
15747
|
+
function collectNonCopyableFieldPaths(model, tableKey) {
|
|
15748
|
+
const result = /* @__PURE__ */ new Set();
|
|
15749
|
+
const collect = (binding, widget) => {
|
|
15750
|
+
if (!binding) return;
|
|
15751
|
+
const match = /^\$\.([^.[\]]+)(?:\[[^\]]+\])*\.(.+)$/.exec(binding.pathTemplate);
|
|
15752
|
+
if (match?.[1] !== tableKey || !match[2]) return;
|
|
15753
|
+
if (widget === "signature" || nonCopyableTypes.has(binding.source.fieldType) || nonCopyableTypes.has(binding.source.businessType ?? "")) result.add(match[2]);
|
|
15754
|
+
};
|
|
15755
|
+
for (const binding of Object.values(model.document.bindings)) collect(binding);
|
|
15756
|
+
for (const node of model.query.findEntities({ roles: ["field"] })) if ("kind" in node && node.kind === "field") collect(model.document.bindings[node.bindingId], node.widget);
|
|
15757
|
+
for (const { id } of model.query.findEntities({ roles: ["region"] })) {
|
|
15758
|
+
const region = model.query.getEntity(id, "region");
|
|
15759
|
+
const control = region?.config?.dataLockControlField;
|
|
15760
|
+
if ((region?.type === "bounded" || region?.type === "repeating" && !region.variant?.name) && region.binding?.pathTemplate === "$." + tableKey && typeof control === "string" && control.length > 0) result.add(control);
|
|
15761
|
+
}
|
|
15762
|
+
return result;
|
|
15763
|
+
}
|
|
15533
15764
|
// src/runtime/form/business/authentication-value.ts
|
|
15534
15765
|
/** @file 普通业务表与物耗行共用认证值保护,解释现有协议而不改写历史值。 */
|
|
15535
15766
|
/** 优先实际控件类型,业务源明确认证类型时同样参与保护。 */
|
|
@@ -15554,7 +15785,7 @@ function tableFieldInputAllowed(options, fieldId, path, existing) {
|
|
|
15554
15785
|
const field = options.fields.declaration(fieldId, path);
|
|
15555
15786
|
if (!field) return false;
|
|
15556
15787
|
const state = options.fields.state(fieldId, path);
|
|
15557
|
-
return existing ? state.editable : !state.readonly && !state.disabled && !state.pending && !field.field.config?.dependencies?.some((rule) => rule.effect === "assignment" && rule.strategy === "alwaysCover" && !!rule.expression);
|
|
15788
|
+
return existing ? state.editable : !state.readonly && !state.disabled && !state.pending && !field.field.config?.dependencies?.some((rule) => rule.effect === "assignment" && rule.assignmentType !== "clear" && (rule.strategy ?? "alwaysCover") === "alwaysCover" && !!rule.expression);
|
|
15558
15789
|
}
|
|
15559
15790
|
/** 借用当前真实字段引用,不缓存字段树或展开运行行。 */
|
|
15560
15791
|
function tableRowFields(options, tableId, regionId, axis) {
|
|
@@ -15582,16 +15813,24 @@ function authenticatedRow(options, fields, axis, index) {
|
|
|
15582
15813
|
}
|
|
15583
15814
|
/** 只修改隔离的复制载荷;认证为空用统一字段编码器,不展开未声明属性或默认值。 */
|
|
15584
15815
|
function clearCopiedAuthentication(options, fields, axis, index, row) {
|
|
15585
|
-
const root = `${axis}[${index}]`, paths = new JsonDataPaths();
|
|
15586
|
-
for (const declaration of fields)
|
|
15587
|
-
const
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15816
|
+
const root = `${axis}[${index}]`, paths = new JsonDataPaths(), additional = collectNonCopyableFieldPaths(options.handle.readModel(), axis.slice(2));
|
|
15817
|
+
for (const declaration of fields) {
|
|
15818
|
+
const kind = authenticationKind(declaration.field.widget, declaration.binding.source.fieldType);
|
|
15819
|
+
if (kind) {
|
|
15820
|
+
const path = rowFieldPath(declaration, axis, index), relative = "$" + path.slice(root.length);
|
|
15821
|
+
if (kind === "signature") clearCopiedFields(row, [relative.slice(2)], () => options.runtime.encodeBoundValue(path, null));
|
|
15822
|
+
else {
|
|
15823
|
+
paths.write(row, relative, options.runtime.encodeBoundValue(path, null));
|
|
15824
|
+
for (const derived of [
|
|
15825
|
+
getIdPath(path),
|
|
15826
|
+
getLabelPath(path),
|
|
15827
|
+
getHrefPath(path)
|
|
15828
|
+
]) paths.delete(row, "$" + derived.slice(root.length));
|
|
15829
|
+
}
|
|
15830
|
+
additional.delete(relative.slice(2));
|
|
15831
|
+
}
|
|
15594
15832
|
}
|
|
15833
|
+
clearCopiedFields(row, additional, (relative) => options.runtime.encodeBoundValue(`${root}.${relative}`, null));
|
|
15595
15834
|
}
|
|
15596
15835
|
/** 按真实槽位及附属条件筛选本行字段,新行只用空标记投影活动坐标。 */
|
|
15597
15836
|
function tableRowTargets(options, axis, index, fields, prospective = false, readAxis) {
|
|
@@ -15613,13 +15852,13 @@ function tableRowTargets(options, axis, index, fields, prospective = false, read
|
|
|
15613
15852
|
});
|
|
15614
15853
|
}
|
|
15615
15854
|
/** 轴复制会连带复制该轴全部交叉格,认证检查包含隐藏、超容量及其他关联区。 */
|
|
15616
|
-
function authenticatedMatrixRow(options, axis, index) {
|
|
15855
|
+
function authenticatedMatrixRow(options, axis, index, onlyKind) {
|
|
15617
15856
|
const data = options.runtime.dataManager, uid = data.getStoredValue(`${axis}[${index}].__gw_y_uid`);
|
|
15618
15857
|
if (typeof uid !== "string" || !uid) return false;
|
|
15619
15858
|
const records = /* @__PURE__ */ new Map(), paths = new JsonDataPaths();
|
|
15620
15859
|
for (const { field, binding } of options.runtime.query.structuralFields()) {
|
|
15621
15860
|
const kind = authenticationKind(field.widget, binding.source.fieldType);
|
|
15622
|
-
if (!kind || !binding.pathTemplate.startsWith(axis + ":")) continue;
|
|
15861
|
+
if (!kind || onlyKind && kind !== onlyKind || !binding.pathTemplate.startsWith(axis + ":")) continue;
|
|
15623
15862
|
const match = /^([^.[\]:]+)\[n_y\]\[n_x\](\..+)$/.exec(binding.pathTemplate.slice(axis.length + 1));
|
|
15624
15863
|
if (!match) continue;
|
|
15625
15864
|
const key = axis + ":" + match[1];
|
|
@@ -15694,7 +15933,7 @@ function planQuickFillMatrix(options, state, origin, matrix, indexes) {
|
|
|
15694
15933
|
const rows = /* @__PURE__ */ new Map();
|
|
15695
15934
|
for (const [y, values] of matrix.entries()) for (const [x, value] of values.entries()) {
|
|
15696
15935
|
const physicalRow = cell.rowIndex + (fixed ? y : 0), physicalColumn = cell.columnIndex + x, target = grid.cells[physicalRow]?.[physicalColumn];
|
|
15697
|
-
if (!target || physicalRow > region.bottom || physicalColumn > region.right || target.merge) throw Error("
|
|
15936
|
+
if (!target || physicalRow > region.bottom || physicalColumn > region.right || target.merge) throw Error("粘贴超出表格区域或触及合并格");
|
|
15698
15937
|
const placement = projection?.cells.get(target.cellId), slot = fixed ? placement?.slot : start + y;
|
|
15699
15938
|
if (slot === void 0 || fixed && placement?.regionId !== state.regionId) throw Error("粘贴位置没有实际业务槽位");
|
|
15700
15939
|
const cells = rows.get(slot) ?? [];
|
|
@@ -15746,6 +15985,92 @@ function quickFillInput(column, value) {
|
|
|
15746
15985
|
if (column.kind === "choice" && column.multiple) return (Array.isArray(value) ? value : typeof value === "string" ? value.split(/[;,]/).map((token) => token.trim()).filter(Boolean) : [value]).map((token) => optionValue(column, token));
|
|
15747
15986
|
return optionValue(column, value);
|
|
15748
15987
|
}
|
|
15988
|
+
// src/runtime/form/business/signatures/device-signature-lock.ts
|
|
15989
|
+
/** @file 固定表与普通动态表签名锁由当前模型配置和权威填写值派生。 */
|
|
15990
|
+
/** 按模型版本缓存声明;权限每次从当前行读取,签名确认和撤销立即可见。 */
|
|
15991
|
+
function createDeviceSignatureLocks(handle, data, environment) {
|
|
15992
|
+
let revision = -1;
|
|
15993
|
+
let rules = [];
|
|
15994
|
+
function current() {
|
|
15995
|
+
const next = handle.getModelRevision();
|
|
15996
|
+
if (revision === next) return rules;
|
|
15997
|
+
const { query } = handle.readModel();
|
|
15998
|
+
rules = query.findEntities({ roles: ["region"] }).flatMap(({ id }) => {
|
|
15999
|
+
const region = query.getEntity(id, "region");
|
|
16000
|
+
const axis = region?.binding?.pathTemplate;
|
|
16001
|
+
const control = region?.config?.dataLockControlField;
|
|
16002
|
+
if (region?.type !== "bounded" && (region?.type !== "repeating" || !!region.variant?.name) || !axis || !/^\$\.[^.[\]:]+$/.test(axis) || typeof control !== "string" || !control || region.type === "bounded" && control !== "inspector_" && control !== "reviewer_") return [];
|
|
16003
|
+
const fields = region.type === "bounded" ? region.config?.mainFieldBindings : void 0;
|
|
16004
|
+
const excluded = region.config?.excludedFields;
|
|
16005
|
+
return [{
|
|
16006
|
+
axis,
|
|
16007
|
+
control,
|
|
16008
|
+
mainFields: Array.isArray(fields) ? fields.filter((key) => typeof key === "string") : [],
|
|
16009
|
+
excludedFields: Array.isArray(excluded) ? excluded.filter((key) => typeof key === "string") : []
|
|
16010
|
+
}];
|
|
16011
|
+
});
|
|
16012
|
+
revision = next;
|
|
16013
|
+
return rules;
|
|
16014
|
+
}
|
|
16015
|
+
function withinRow(path) {
|
|
16016
|
+
const match = /^(\$\.[^.[\]:]+)\[(\d+)\]\.(.+)$/.exec(path);
|
|
16017
|
+
if (!match) return;
|
|
16018
|
+
const matches = current().filter(({ axis }) => axis === match[1]);
|
|
16019
|
+
return matches.length ? {
|
|
16020
|
+
rules: matches,
|
|
16021
|
+
row: match[1] + "[" + match[2] + "]",
|
|
16022
|
+
field: match[3]
|
|
16023
|
+
} : void 0;
|
|
16024
|
+
}
|
|
16025
|
+
function signed(rule, row) {
|
|
16026
|
+
if (data.getStoredValue(row + ".deleted_")) return false;
|
|
16027
|
+
const value = data.getStoredValue(row + "." + rule.control);
|
|
16028
|
+
return hasAuthenticationValue("signature", typeof value === "string" ? value.trim() : value);
|
|
16029
|
+
}
|
|
16030
|
+
return {
|
|
16031
|
+
/** 例外字段不解除整行锁;菜单和执行入口共用同一判断。 */
|
|
16032
|
+
rowLocked(axis, index) {
|
|
16033
|
+
if (environment().formChangeEditing || !Number.isSafeInteger(index) || index < 0) return false;
|
|
16034
|
+
return current().some((rule) => rule.axis === axis && signed(rule, `${axis}[${index}]`));
|
|
16035
|
+
},
|
|
16036
|
+
/** 给公共字段状态提供强制只读和禁用标记。 */
|
|
16037
|
+
flags(path) {
|
|
16038
|
+
if (environment().formChangeEditing) return {};
|
|
16039
|
+
const target = withinRow(path);
|
|
16040
|
+
if (target) {
|
|
16041
|
+
let readonly = false;
|
|
16042
|
+
let disabled = false;
|
|
16043
|
+
for (const rule of target.rules) {
|
|
16044
|
+
if (!signed(rule, target.row)) continue;
|
|
16045
|
+
if (target.field === rule.control) readonly = true;
|
|
16046
|
+
else disabled ||= !rule.excludedFields.includes(target.field);
|
|
16047
|
+
}
|
|
16048
|
+
return {
|
|
16049
|
+
readonly,
|
|
16050
|
+
disabled
|
|
16051
|
+
};
|
|
16052
|
+
}
|
|
16053
|
+
const mainKey = /^\$\.([^.[\]:]+)$/.exec(path)?.[1];
|
|
16054
|
+
if (mainKey && current().some((rule) => rule.mainFields.includes(mainKey) && data.getActiveSubtableRowIndexes(rule.axis).some((index) => signed(rule, rule.axis + "[" + index + "]")))) return { disabled: true };
|
|
16055
|
+
return {};
|
|
16056
|
+
},
|
|
16057
|
+
/** 第一次控制签名前检查参与校验的绑定主字段和同行路径。 */
|
|
16058
|
+
validationPaths(path, candidates) {
|
|
16059
|
+
if (environment().formChangeEditing) return [];
|
|
16060
|
+
const target = withinRow(path);
|
|
16061
|
+
if (!target || data.getStoredValue(target.row + ".deleted_")) return [];
|
|
16062
|
+
const rules = target.rules.filter((rule) => target.field === rule.control && !signed(rule, target.row));
|
|
16063
|
+
if (!rules.length) return [];
|
|
16064
|
+
const paths = /* @__PURE__ */ new Set();
|
|
16065
|
+
const allCandidates = [...candidates()];
|
|
16066
|
+
for (const rule of rules) {
|
|
16067
|
+
for (const key of rule.mainFields) if (key) paths.add("$." + key);
|
|
16068
|
+
for (const candidate of allCandidates) if (candidate !== path && candidate.startsWith(target.row + ".") && !rule.excludedFields.includes(candidate.slice(target.row.length + 1))) paths.add(candidate);
|
|
16069
|
+
}
|
|
16070
|
+
return [...paths];
|
|
16071
|
+
}
|
|
16072
|
+
};
|
|
16073
|
+
}
|
|
15749
16074
|
// src/runtime/form/business/tables/NativeTableQuickFill.ts
|
|
15750
16075
|
/** @file 动态表从当前行、固定表按实际组编辑的原生批量输入;不创建第二份 model 或仓库。 */
|
|
15751
16076
|
/** 读取仅投影列与数量;提交预检整批,再一次进入唯一 DataManager。 */
|
|
@@ -15787,6 +16112,7 @@ var NativeTableQuickFill = class {
|
|
|
15787
16112
|
columns.push(column);
|
|
15788
16113
|
}
|
|
15789
16114
|
const limit = table.type === "bounded" ? table.capacity ?? 0 : 200, configured = region.config?.quickFill === true;
|
|
16115
|
+
const signatureLocked = region.type === "repeating" && !region.variant?.name && table.rowIndex !== void 0 && createDeviceSignatureLocks(options.handle, options.runtime.dataManager, options.environment).rowLocked(table.axisPath, table.rowIndex);
|
|
15790
16116
|
const allowed = options.permission?.({
|
|
15791
16117
|
operation: "quick-fill",
|
|
15792
16118
|
regionId,
|
|
@@ -15801,7 +16127,7 @@ var NativeTableQuickFill = class {
|
|
|
15801
16127
|
...layout ? { layout } : {},
|
|
15802
16128
|
columns,
|
|
15803
16129
|
limit,
|
|
15804
|
-
enabled: configured && entryEditable && columns.length > 0 && limit > 0 && allowed !== false && (table.type === "bounded" || table.rowCount === 0 || table.rowIndex !== void 0) && isEqual(table.version, options.handle.getVersions())
|
|
16130
|
+
enabled: configured && !signatureLocked && entryEditable && columns.length > 0 && limit > 0 && allowed !== false && (table.type === "bounded" || table.rowCount === 0 || table.rowIndex !== void 0) && isEqual(table.version, options.handle.getVersions())
|
|
15805
16131
|
};
|
|
15806
16132
|
const result = copyInputData(state);
|
|
15807
16133
|
freezeData(result);
|
|
@@ -15867,7 +16193,11 @@ var NativeTableQuickFill = class {
|
|
|
15867
16193
|
/** 将原有表级授权、字段规范化、后端编码和一次轴写入供两个入口共用。 */
|
|
15868
16194
|
commit(options, state, declarations, activeCount, plan) {
|
|
15869
16195
|
const data = options.runtime.dataManager, patches = [], append = [], paths = new JsonDataPaths(), columns = new Map(state.columns.map((column) => [column.key, column])), model = options.handle.readModel().query, cellIds = /* @__PURE__ */ new Map();
|
|
16196
|
+
const region = model.getEntity(state.regionId, "region");
|
|
16197
|
+
const ordinaryDynamic = region?.type === "repeating" && !region.variant?.name;
|
|
16198
|
+
const locks = createDeviceSignatureLocks(options.handle, data, options.environment);
|
|
15870
16199
|
for (const [rowOrdinal, { index, existing, values: entries }] of plan.entries()) {
|
|
16200
|
+
if (existing && ordinaryDynamic && locks.rowLocked(state.axisPath, index)) continue;
|
|
15871
16201
|
const values = {}, rowPath = `${state.axisPath}[${index}]`;
|
|
15872
16202
|
if (data.getStoredValue(`${state.axisPath}[${index}].deleted_`) === true && existing) throw Error("已删除行不能快速填写");
|
|
15873
16203
|
const grant = options.permission?.({
|
|
@@ -15919,11 +16249,11 @@ var NativeTableQuickFill = class {
|
|
|
15919
16249
|
}
|
|
15920
16250
|
if (state.capacity !== void 0 && activeCount + append.length > state.capacity) throw Error("本次填报超过固定区域容量");
|
|
15921
16251
|
if (this.options !== options || options.handle.status === "closed" || options.environment().mode !== "fill" || !isEqual(state.version, options.handle.getVersions())) throw Error("快速填报来源已变化,请重新打开");
|
|
15922
|
-
data.applySubtableRows(state.axisPath, patches, append);
|
|
16252
|
+
if (patches.length || append.length) data.applySubtableRows(state.axisPath, patches, append);
|
|
15923
16253
|
return Object.freeze({
|
|
15924
16254
|
operation: "quick-fill",
|
|
15925
16255
|
regionId: state.regionId,
|
|
15926
|
-
count:
|
|
16256
|
+
count: patches.length + append.length,
|
|
15927
16257
|
updatedRows: patches.length,
|
|
15928
16258
|
insertedRows: append.length
|
|
15929
16259
|
});
|
|
@@ -16687,7 +17017,7 @@ var NativeBusinessTables = class {
|
|
|
16687
17017
|
if (!declaration) return;
|
|
16688
17018
|
const matrix = region.type === "2d-table" ? matrixAxes(region) : void 0;
|
|
16689
17019
|
const axisPath = matrix?.primary ?? region.binding?.pathTemplate;
|
|
16690
|
-
if (!axisPath || !/^\$\.[^.[\]:]+$/.test(axisPath)) throw Error("
|
|
17020
|
+
if (!axisPath || !/^\$\.[^.[\]:]+$/.test(axisPath)) throw Error("表格区域没有有效的单轴路径");
|
|
16691
17021
|
if (index !== void 0 && (!Number.isSafeInteger(index) || index < 0)) throw Error("业务行下标无效");
|
|
16692
17022
|
const version = handle.getVersions(), data = runtime.dataManager, indexes = data.getActiveSubtableRowIndexes(axisPath), rowOrdinal = index === void 0 ? -1 : indexes.indexOf(index), rowIndex = rowOrdinal < 0 ? void 0 : index, rowPath = rowIndex === void 0 ? void 0 : `${axisPath}[${rowIndex}]`, fields = tableRowFields(options, declaration.tableId, regionId, axisPath), pending = !runtime.isSettled();
|
|
16693
17023
|
const probe = index ?? indexes[0] ?? 0;
|
|
@@ -16708,10 +17038,13 @@ var NativeBusinessTables = class {
|
|
|
16708
17038
|
}));
|
|
16709
17039
|
}) : [];
|
|
16710
17040
|
const editable = options.environment().mode === "fill" && !pending && participation && data.getStoredValue(`${axisPath}[${probe}].deleted_`) !== true && (fields.some((field) => options.fields.state(field.field.id, rowFieldPath(field, axisPath, probe)).editable) || matrixFields.some(({ field, path }) => options.fields.state(field.field.id, path).editable));
|
|
17041
|
+
const signatureLocked = region.type === "repeating" && !region.variant?.name && rowIndex !== void 0 && createDeviceSignatureLocks(handle, data, options.environment).rowLocked(axisPath, rowIndex);
|
|
17042
|
+
const prospectiveIndex = (indexes.at(-1) ?? -1) + 1;
|
|
17043
|
+
const increasable = editable || signatureLocked && options.environment().mode === "fill" && !pending && participation && fields.some((field) => tableFieldInputAllowed(options, field.field.id, rowFieldPath(field, axisPath, prospectiveIndex), false));
|
|
16711
17044
|
const capacity = region.type === "bounded" ? runtime.query.boundedTable(declaration.tableId)?.capacities.get(region.id) : void 0;
|
|
16712
17045
|
const room = capacity === void 0 || indexes.length < capacity;
|
|
16713
17046
|
const matrixAuthenticated = !!matrix && rowIndex !== void 0 && authenticatedMatrixRow(options, axisPath, rowIndex);
|
|
16714
|
-
const removalBlockedReason = rowIndex !== void 0 && (authenticatedRow(options, fields, axisPath, rowIndex) || matrixAuthenticated || matrixFields.some(({ field, path }) => {
|
|
17047
|
+
const removalBlockedReason = rowIndex !== void 0 && (signatureLocked || authenticatedRow(options, fields, axisPath, rowIndex) || matrixAuthenticated || matrixFields.some(({ field, path }) => {
|
|
16715
17048
|
const kind = authenticationKind(field.field.widget, field.binding.source.fieldType);
|
|
16716
17049
|
return !!kind && hasAuthenticationValue(kind, data.getStoredValue(path));
|
|
16717
17050
|
})) ? "当前行已有签名或印章认证,请先按认证规则处理" : void 0;
|
|
@@ -16729,8 +17062,8 @@ var NativeBusinessTables = class {
|
|
|
16729
17062
|
};
|
|
16730
17063
|
const allowed = {
|
|
16731
17064
|
...region.variant?.name === "edhr:material-substitution" ? { batchInsert: false } : {},
|
|
16732
|
-
insert:
|
|
16733
|
-
copy:
|
|
17065
|
+
insert: increasable && room && permit("insert"),
|
|
17066
|
+
copy: increasable && !(matrixAuthenticated && authenticatedMatrixRow(options, axisPath, rowIndex, "seal")) && room && rowIndex !== void 0 && tableRowCopyAllowed(region.variant?.name) && permit("copy"),
|
|
16734
17067
|
remove: editable && rowIndex !== void 0 && !removalBlockedReason && permit("remove")
|
|
16735
17068
|
};
|
|
16736
17069
|
if (!isEqual(version, handle.getVersions())) {
|
|
@@ -17320,7 +17653,7 @@ var DataDependencies = class {
|
|
|
17320
17653
|
return activeRowIndexes(rows).map((index) => this.services.paths.read(rows[index], `$.${table[2]}`));
|
|
17321
17654
|
}
|
|
17322
17655
|
/** 注册一代可释放的规则,首次计算与后续依赖使用同一写回机制。 */
|
|
17323
|
-
register(path, expression, scope, callback, signal) {
|
|
17656
|
+
register(path, expression, scope, callback, signal, options) {
|
|
17324
17657
|
this.services.paths.parse(path);
|
|
17325
17658
|
if (!scope) throw new Error("依赖注册必须指定所有者身份");
|
|
17326
17659
|
if (!this.formula) throw new Error("未配置公式引擎");
|
|
@@ -17336,6 +17669,7 @@ var DataDependencies = class {
|
|
|
17336
17669
|
controller: new AbortController(),
|
|
17337
17670
|
evaluated: false,
|
|
17338
17671
|
lastValue: void 0,
|
|
17672
|
+
compare: options?.compare,
|
|
17339
17673
|
owner: this
|
|
17340
17674
|
};
|
|
17341
17675
|
/** 释放函数仅保留可清空槽,移除后不再持有数据模块。 */
|
|
@@ -17362,6 +17696,7 @@ var DataDependencies = class {
|
|
|
17362
17696
|
node.owner = void 0;
|
|
17363
17697
|
node.callback = void 0;
|
|
17364
17698
|
node.lastValue = void 0;
|
|
17699
|
+
node.lastInputs = void 0;
|
|
17365
17700
|
node.controller.abort("dependency-disposed");
|
|
17366
17701
|
node.releaseSignal?.();
|
|
17367
17702
|
node.releaseSignal = void 0;
|
|
@@ -17372,6 +17707,8 @@ var DataDependencies = class {
|
|
|
17372
17707
|
const dep = this.resolve(variable, node.path);
|
|
17373
17708
|
return path === "$" || dep === "$" || areRelatedDataPaths(path, dep);
|
|
17374
17709
|
})) {
|
|
17710
|
+
node.controller.abort("dependency-input-changed");
|
|
17711
|
+
node.controller = new AbortController();
|
|
17375
17712
|
this.pending.add(node);
|
|
17376
17713
|
if (!this.pendingSources.has(node) || source !== "hydrate") this.pendingSources.set(node, source);
|
|
17377
17714
|
}
|
|
@@ -17404,12 +17741,13 @@ var DataDependencies = class {
|
|
|
17404
17741
|
const value = await cancellable(Promise.resolve(formula.calculate(node.expression, cloneDeep(variables), signal)), signal);
|
|
17405
17742
|
if (!current()) return;
|
|
17406
17743
|
assertValidDataValue(value, path);
|
|
17407
|
-
if (node.evaluated && isEqual$1(node.lastValue, value)) return;
|
|
17408
|
-
const updates = await cancellable(Promise.resolve(node.callback?.(cloneDeep(value), path)), signal);
|
|
17744
|
+
if (node.evaluated && node.compare !== "none" && (node.compare === "inputs" ? isEqual$1(node.lastInputs, variables) : isEqual$1(node.lastValue, value))) return;
|
|
17745
|
+
const updates = await cancellable(Promise.resolve(node.callback?.(cloneDeep(value), path, cloneDeep(variables))), signal);
|
|
17409
17746
|
if (!current()) return;
|
|
17410
17747
|
if (updates) assertValidDataValue(updates);
|
|
17411
17748
|
node.evaluated = true;
|
|
17412
17749
|
node.lastValue = cloneDeep(value);
|
|
17750
|
+
if (node.compare === "inputs") node.lastInputs = cloneDeep(variables);
|
|
17413
17751
|
if (updates) this.services.values.setMany(updates, source === "hydrate" ? "hydrate" : "dependency");
|
|
17414
17752
|
} catch (error) {
|
|
17415
17753
|
if (!(error instanceof DataCancelled) && current()) throw error;
|
|
@@ -17441,6 +17779,7 @@ var DataDependencies = class {
|
|
|
17441
17779
|
node.controller = new AbortController();
|
|
17442
17780
|
node.evaluated = false;
|
|
17443
17781
|
node.lastValue = void 0;
|
|
17782
|
+
node.lastInputs = void 0;
|
|
17444
17783
|
}
|
|
17445
17784
|
this.pending.clear();
|
|
17446
17785
|
this.pendingSources.clear();
|
|
@@ -17710,8 +18049,9 @@ var DataMatrix = class {
|
|
|
17710
18049
|
for (const entry of this.crossKeys(tableKey).filter((entry) => entry.axis === axis)) {
|
|
17711
18050
|
const cells = this.services.values.raw[entry.key];
|
|
17712
18051
|
if (!Array.isArray(cells)) continue;
|
|
18052
|
+
const paths = this.services.lifetime.host?.collectNonCopyableFieldPaths?.(entry.key) ?? [];
|
|
17713
18053
|
const copies = cells.filter((cell) => isRecord(cell) && cell[uidField] === oldUid).map((cell) => {
|
|
17714
|
-
const copy =
|
|
18054
|
+
const copy = cloneCopiedRow(cell, paths);
|
|
17715
18055
|
copy[uidField] = newUid;
|
|
17716
18056
|
delete copy.id_;
|
|
17717
18057
|
delete copy.front_row_key_;
|
|
@@ -18582,8 +18922,8 @@ var DataManager = class {
|
|
|
18582
18922
|
await services.changes.whenSettled();
|
|
18583
18923
|
}
|
|
18584
18924
|
/** 注册可等待、可取消的公式,回调收到移动后的目标路径。 */
|
|
18585
|
-
registerScopedFieldDependency(path, expression, scope, callback, signal) {
|
|
18586
|
-
return this.active().dependencies.register(canonicalPath(path), expression, scope, callback, signal);
|
|
18925
|
+
registerScopedFieldDependency(path, expression, scope, callback, signal, options) {
|
|
18926
|
+
return this.active().dependencies.register(canonicalPath(path), expression, scope, callback, signal, options);
|
|
18587
18927
|
}
|
|
18588
18928
|
/** 重新计算所有已注册公式,并等待其产生的数据批次。 */
|
|
18589
18929
|
async flushAllFieldDependencies() {
|
|
@@ -19405,8 +19745,10 @@ var CommonFieldRules = class {
|
|
|
19405
19745
|
generation = 0;
|
|
19406
19746
|
/** 系统默认值按字段及配置缓存,避免普通输入导致时钟变化。 */
|
|
19407
19747
|
systemDefaults = /* @__PURE__ */ new Map();
|
|
19408
|
-
/**
|
|
19748
|
+
/** 以稳定业务行身份保存手填保护,插行或换序不会套用到其他行。 */
|
|
19409
19749
|
assignmentMarks = /* @__PURE__ */ new Map();
|
|
19750
|
+
/** 仅缓存实际公式输入,规则重建继续沿用;整份数据恢复时清除。 */
|
|
19751
|
+
assignmentEvaluations = /* @__PURE__ */ new Map();
|
|
19410
19752
|
/** 只保存注入能力。 */
|
|
19411
19753
|
constructor(options) {
|
|
19412
19754
|
this.options = options;
|
|
@@ -19439,18 +19781,22 @@ var CommonFieldRules = class {
|
|
|
19439
19781
|
}
|
|
19440
19782
|
/** 当前普通输入不重建全部字段,根/行身份/控制值变化才失效目标集合。 */
|
|
19441
19783
|
dataChanged(path, source) {
|
|
19784
|
+
if (path === "$") {
|
|
19785
|
+
this.assignmentMarks.clear();
|
|
19786
|
+
this.assignmentEvaluations.clear();
|
|
19787
|
+
}
|
|
19442
19788
|
const scope = this.scope;
|
|
19443
19789
|
if (!scope) return path === "$";
|
|
19444
|
-
if (source === "user" && scope.assignments.has(path))
|
|
19445
|
-
const key = this.assignmentIdentity(path);
|
|
19446
|
-
const previous = this.assignmentMarks.get(key) ?? {};
|
|
19447
|
-
this.assignmentMarks.set(key, {
|
|
19448
|
-
...previous,
|
|
19449
|
-
userEdited: true
|
|
19450
|
-
});
|
|
19451
|
-
}
|
|
19790
|
+
if (source === "user" && scope.assignments.has(path)) this.markAssignmentEdit(path, this.requireOptions().dataManager.getStoredValue(path));
|
|
19452
19791
|
return path === "$" || [...scope.controls].some((control) => isSameOrDescendantPath(control, path)) || [...scope.axes].some((axis) => nativeAxisChanged(path, axis));
|
|
19453
19792
|
}
|
|
19793
|
+
/** 所有用户写入共用空值语义,0 和 false 不解除保护。 */
|
|
19794
|
+
markAssignmentEdit(path, value) {
|
|
19795
|
+
this.assignmentMarks.set(this.assignmentIdentity(path), {
|
|
19796
|
+
userEdited: !isEmptyDataValue(value, { whitespace: "empty" }),
|
|
19797
|
+
permanentlyEdited: true
|
|
19798
|
+
});
|
|
19799
|
+
}
|
|
19454
19800
|
/** 主表按路径、行字段按稳定行键识别赋值所有权。 */
|
|
19455
19801
|
assignmentIdentity(path) {
|
|
19456
19802
|
const options = this.requireOptions();
|
|
@@ -19488,17 +19834,23 @@ var CommonFieldRules = class {
|
|
|
19488
19834
|
try {
|
|
19489
19835
|
const declarations = sortBy$1(options.query.structuralFields(), [(item) => options.query.attachmentConditions(item.field.id).length]);
|
|
19490
19836
|
const retained = /* @__PURE__ */ new Set();
|
|
19837
|
+
const retainedRules = /* @__PURE__ */ new Set();
|
|
19491
19838
|
const dateKeys = /* @__PURE__ */ new Set();
|
|
19492
19839
|
for (const declaration of declarations) {
|
|
19493
19840
|
for (const path of options.query.fieldTargets(declaration.field.id, {
|
|
19494
19841
|
readValue: (key) => options.dataManager.get(key),
|
|
19495
19842
|
readAxis: (key) => options.dataManager.getStoredValue(key),
|
|
19496
19843
|
includeInactive: true
|
|
19497
|
-
}).paths)
|
|
19844
|
+
}).paths) {
|
|
19845
|
+
const identity = this.assignmentIdentity(path);
|
|
19846
|
+
retained.add(identity);
|
|
19847
|
+
if (fieldConfig(declaration).dependencies?.some((rule) => rule.effect === "assignment" && rule.assignmentType !== "clear")) retainedRules.add(targetKey(declaration.field.id, identity));
|
|
19848
|
+
}
|
|
19498
19849
|
const dateKey = this.systemKey(declaration);
|
|
19499
19850
|
if (dateKey) dateKeys.add(dateKey);
|
|
19500
19851
|
}
|
|
19501
19852
|
for (const key of this.assignmentMarks.keys()) if (!retained.has(key)) this.assignmentMarks.delete(key);
|
|
19853
|
+
for (const key of this.assignmentEvaluations.keys()) if (!retainedRules.has(key)) this.assignmentEvaluations.delete(key);
|
|
19502
19854
|
for (const key of this.systemDefaults.keys()) if (!dateKeys.has(key)) this.systemDefaults.delete(key);
|
|
19503
19855
|
const groups = groupBy$1(declarations, (item) => options.query.attachmentConditions(item.field.id).length);
|
|
19504
19856
|
for (const group of Object.values(groups)) {
|
|
@@ -19579,9 +19931,9 @@ var CommonFieldRules = class {
|
|
|
19579
19931
|
if (!dependency.expression || dependency.effect !== "assignment" && dependency.value !== true || mode === "edit" || (mode === "print" || mode === "readonly") && dependency.effect === "assignment") continue;
|
|
19580
19932
|
if (dependency.effect === "required" && config.required === true || dependency.effect === "disabled" && config.disabled === true) continue;
|
|
19581
19933
|
if (dependency.effect === "assignment" && ["seal", "signature"].includes(declaration.field.widget)) continue;
|
|
19582
|
-
if (dependency.effect === "assignment") {
|
|
19934
|
+
if (dependency.effect === "assignment" && dependency.assignmentType !== "clear") {
|
|
19583
19935
|
scope.assignments.add(path);
|
|
19584
|
-
if (dependency.strategy === "alwaysCover") scope.assigned.add(path);
|
|
19936
|
+
if ((dependency.strategy ?? "alwaysCover") === "alwaysCover") scope.assigned.add(path);
|
|
19585
19937
|
}
|
|
19586
19938
|
const registration = options.dataManager.registerScopedFieldDependency(path, dependency.expression, JSON.stringify([
|
|
19587
19939
|
"field",
|
|
@@ -19589,27 +19941,57 @@ var CommonFieldRules = class {
|
|
|
19589
19941
|
declaration.field.id,
|
|
19590
19942
|
path,
|
|
19591
19943
|
index
|
|
19592
|
-
]), (value, currentPath) => this.apply(declaration, dependency, currentPath, value, scope, options), scope.signal);
|
|
19944
|
+
]), (value, currentPath, variables) => this.apply(declaration, dependency, currentPath, value, scope, options, variables), scope.signal, dependency.effect === "assignment" ? { compare: dependency.assignmentType === "clear" ? "none" : "inputs" } : void 0);
|
|
19593
19945
|
scope.registrations.push(registration);
|
|
19594
19946
|
await registration.ready;
|
|
19595
19947
|
}
|
|
19596
19948
|
}
|
|
19597
19949
|
/** 赋值写回唯一数据仓库;显示联动按字段实例隔离,避免共享绑定串状态。 */
|
|
19598
|
-
apply(declaration, dependency, path, value, scope, options) {
|
|
19950
|
+
apply(declaration, dependency, path, value, scope, options, variables) {
|
|
19599
19951
|
if (!this.current(scope)) return;
|
|
19600
19952
|
if (dependency.effect === "assignment") {
|
|
19953
|
+
if (dependency.assignmentType === "clear") {
|
|
19954
|
+
if (!(readDataBoolean(value) ?? !!value)) return;
|
|
19955
|
+
return { [path]: this.normalize(declaration, emptyDataValue(), path) };
|
|
19956
|
+
}
|
|
19957
|
+
const key = this.assignmentIdentity(path);
|
|
19958
|
+
const ruleKey = targetKey(declaration.field.id, key);
|
|
19959
|
+
const previous = this.assignmentEvaluations.get(ruleKey);
|
|
19960
|
+
const initial = !previous || previous.expression !== dependency.expression || previous.strategy !== dependency.strategy;
|
|
19961
|
+
const next = {
|
|
19962
|
+
expression: dependency.expression,
|
|
19963
|
+
strategy: dependency.strategy,
|
|
19964
|
+
inputs: cloneDeep(variables)
|
|
19965
|
+
};
|
|
19966
|
+
const stored = options.dataManager.getStoredValue(path);
|
|
19967
|
+
if (initial) {
|
|
19968
|
+
if (dependency.strategy === "notCoveredForever" && !isEmptyDataValue(stored, { whitespace: "empty" })) {
|
|
19969
|
+
const mark = this.assignmentMarks.get(key);
|
|
19970
|
+
this.assignmentMarks.set(key, {
|
|
19971
|
+
...mark,
|
|
19972
|
+
permanentlyEdited: true
|
|
19973
|
+
});
|
|
19974
|
+
}
|
|
19975
|
+
if (!isUninitializedDataValue(stored)) {
|
|
19976
|
+
this.assignmentEvaluations.set(ruleKey, next);
|
|
19977
|
+
return;
|
|
19978
|
+
}
|
|
19979
|
+
} else if (isEqual$1(previous.inputs, variables)) return;
|
|
19601
19980
|
if (resolveDataValueUpdate({
|
|
19602
19981
|
present: true,
|
|
19603
19982
|
value
|
|
19604
|
-
},
|
|
19605
|
-
|
|
19983
|
+
}, stored, { intent: "patch" }, path).action === "skip") {
|
|
19984
|
+
this.assignmentEvaluations.set(ruleKey, next);
|
|
19985
|
+
return;
|
|
19986
|
+
}
|
|
19606
19987
|
const mark = this.assignmentMarks.get(key);
|
|
19607
|
-
if (dependency.strategy === "notCovered" &&
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19988
|
+
if (dependency.strategy === "notCovered" && mark?.userEdited || dependency.strategy === "notCoveredForever" && mark?.permanentlyEdited) {
|
|
19989
|
+
this.assignmentEvaluations.set(ruleKey, next);
|
|
19990
|
+
return;
|
|
19991
|
+
}
|
|
19992
|
+
const normalized = this.normalize(declaration, value, path);
|
|
19993
|
+
this.assignmentEvaluations.set(ruleKey, next);
|
|
19994
|
+
return { [path]: normalized };
|
|
19613
19995
|
}
|
|
19614
19996
|
const key = targetKey(declaration.field.id, path);
|
|
19615
19997
|
const previous = scope.flags.get(key) ?? {};
|
|
@@ -19655,7 +20037,9 @@ var CommonFieldRules = class {
|
|
|
19655
20037
|
present: true,
|
|
19656
20038
|
value
|
|
19657
20039
|
}, options.dataManager.getStoredValue(path), { intent: "patch" }, path).action === "skip") return false;
|
|
19658
|
-
|
|
20040
|
+
const normalized = this.normalize(declaration, value, path);
|
|
20041
|
+
if (this.scope?.assignments.has(path)) this.markAssignmentEdit(path, normalized);
|
|
20042
|
+
return options.dataManager.set(path, normalized, "user");
|
|
19659
20043
|
}
|
|
19660
20044
|
/** 是否已有完整可发布的字段规则。 */
|
|
19661
20045
|
isReady() {
|
|
@@ -19667,6 +20051,7 @@ var CommonFieldRules = class {
|
|
|
19667
20051
|
this.options = void 0;
|
|
19668
20052
|
this.systemDefaults.clear();
|
|
19669
20053
|
this.assignmentMarks.clear();
|
|
20054
|
+
this.assignmentEvaluations.clear();
|
|
19670
20055
|
}
|
|
19671
20056
|
/** 关闭后拒绝旧业务门面的读写。 */
|
|
19672
20057
|
requireOptions() {
|
|
@@ -21728,7 +22113,7 @@ function protectedFillPaths(options, config) {
|
|
|
21728
22113
|
for (const query of config.queries ?? []) for (const mapping of query.mappings ?? []) for (const field of mapping.fields ?? []) protect(mapping.modelKey || options.modelKey, mapping.subFieldKey, field.fieldKey);
|
|
21729
22114
|
for (const declaration of options.runtime.query.structuralFields()) {
|
|
21730
22115
|
const { field, binding } = declaration;
|
|
21731
|
-
if (field.widget === "signature" || field.widget === "seal" || fieldConfig(declaration).dependencies?.some((rule) => rule.effect === "assignment" && rule.expression)) protectedPaths.add(logicalFillPath(binding.pathTemplate));
|
|
22116
|
+
if (field.widget === "signature" || field.widget === "seal" || fieldConfig(declaration).dependencies?.some((rule) => rule.effect === "assignment" && rule.assignmentType !== "clear" && rule.expression)) protectedPaths.add(logicalFillPath(binding.pathTemplate));
|
|
21732
22117
|
if ((field.widget === "relation" || field.widget === "rdo-relation") && field.config?.autofill?.enabled) for (const rule of field.config.autofill.rules) protect(rule.target.modelKey || options.modelKey, rule.target.subFieldKey, rule.target.fieldKey);
|
|
21733
22118
|
if (field.widget === "signature" && field.config?.autofill?.enabled) for (const rule of field.config.autofill.rules) protect(rule.target.modelKey || options.modelKey, rule.target.subFieldKey, rule.target.fieldKey);
|
|
21734
22119
|
}
|
|
@@ -26734,8 +27119,7 @@ var NativeReferences = class {
|
|
|
26734
27119
|
} catch (error) {
|
|
26735
27120
|
input = ["configuration", error instanceof Error ? error.message : String(error)];
|
|
26736
27121
|
}
|
|
26737
|
-
|
|
26738
|
-
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
27122
|
+
return sha256(JSON.stringify(input));
|
|
26739
27123
|
}
|
|
26740
27124
|
/** 完整字段检查才调用当前记录来源;不写值,迟到结果仍受规则、实际行和调用方版本保护。 */
|
|
26741
27125
|
async validateReference(fieldId, path, signal, withinBatch = false) {
|
|
@@ -27251,6 +27635,36 @@ var NativeSignatures = class {
|
|
|
27251
27635
|
for (const attempt of this.attempts) this.release(attempt);
|
|
27252
27636
|
});
|
|
27253
27637
|
}
|
|
27638
|
+
/** 打开签名框前只校验字段;无校验路径时保持同步返回。 */
|
|
27639
|
+
validateBeforeOpen(fieldId, instance, signal) {
|
|
27640
|
+
signal.throwIfAborted();
|
|
27641
|
+
const options = this.requireOptions();
|
|
27642
|
+
const before = businessTarget(options.handle, options.rules, fieldId, instance);
|
|
27643
|
+
if (before.declaration.field.widget !== "signature" || !before.state.editable) throw new Error("当前签名不可编辑");
|
|
27644
|
+
const paths = options.validationPaths?.(before.valuePath) ?? [];
|
|
27645
|
+
if (!paths.length) return;
|
|
27646
|
+
if (!options.validatePaths) throw new Error("尚未接入签名前字段校验");
|
|
27647
|
+
const controller = new AbortController();
|
|
27648
|
+
const abort = () => this.release(attempt);
|
|
27649
|
+
const attempt = {
|
|
27650
|
+
before,
|
|
27651
|
+
instance,
|
|
27652
|
+
owners: recordTargetOwners(instance, options.runtime.dataManager),
|
|
27653
|
+
controller,
|
|
27654
|
+
validationPaths: paths,
|
|
27655
|
+
unlink: () => signal.removeEventListener("abort", abort)
|
|
27656
|
+
};
|
|
27657
|
+
this.attempts.add(attempt);
|
|
27658
|
+
if (signal.aborted) this.release(attempt);
|
|
27659
|
+
else signal.addEventListener("abort", abort, { once: true });
|
|
27660
|
+
return scopedDataRequest([controller.signal], async (currentSignal) => {
|
|
27661
|
+
await options.validatePaths(paths, currentSignal, before.valuePath);
|
|
27662
|
+
if (!this.current(attempt)) throw new Error("签名目标已经变化,请重新操作");
|
|
27663
|
+
}).catch((error) => {
|
|
27664
|
+
if (controller.signal.aborted) throw new Error("签名前检查已取消或数据已变化,请重新点击签名");
|
|
27665
|
+
throw error;
|
|
27666
|
+
}).finally(() => this.release(attempt));
|
|
27667
|
+
}
|
|
27254
27668
|
/** 手动认证得到当前会话的不透明预览凭据,确认之前不写任何业务值。 */
|
|
27255
27669
|
async prepare(fieldId, instance, signal, authorization) {
|
|
27256
27670
|
const options = this.requireOptions(), before = businessTarget(options.handle, options.rules, fieldId, instance), field = before.declaration.field;
|
|
@@ -27274,7 +27688,7 @@ var NativeSignatures = class {
|
|
|
27274
27688
|
else signal.addEventListener("abort", abort, { once: true });
|
|
27275
27689
|
try {
|
|
27276
27690
|
controller.signal.throwIfAborted();
|
|
27277
|
-
if (attempt.validationPaths.length) await options.validatePaths?.(attempt.validationPaths, controller.signal);
|
|
27691
|
+
if (attempt.validationPaths.length) await options.validatePaths?.(attempt.validationPaths, controller.signal, before.valuePath);
|
|
27278
27692
|
controller.signal.throwIfAborted();
|
|
27279
27693
|
const result = await options.rules.authorizeSignature(fieldId, before.valuePath, controller.signal, ...authorization ? [authorization] : []);
|
|
27280
27694
|
if (!this.current(attempt)) throw new Error("签署目标已经变化");
|
|
@@ -28671,7 +29085,7 @@ function resolveValidationAdmission(input) {
|
|
|
28671
29085
|
// src/runtime/form/validation/targets.ts
|
|
28672
29086
|
/** @file 校验目标直接从原生结构、条件和运行权限求得,不读取 pages 或构造 WidgetMeta。 */
|
|
28673
29087
|
/** 展示沿用异常保留覆盖;其他模式沿用只读/禁用不进入校验门禁的既有规则。 */
|
|
28674
|
-
function nativeValidationTargets(options, mode, paths, widgets, blockedOnly = false, includeRequired = false) {
|
|
29088
|
+
function nativeValidationTargets(options, mode, paths, widgets, blockedOnly = false, includeRequired = false, requiredPaths) {
|
|
28675
29089
|
const entries = [];
|
|
28676
29090
|
if (options.environment().mode === "edit") return { entries };
|
|
28677
29091
|
const browsing = mode === "display";
|
|
@@ -28710,11 +29124,12 @@ function nativeValidationTargets(options, mode, paths, widgets, blockedOnly = fa
|
|
|
28710
29124
|
if (!state.active || !state.visible || state.pending) continue;
|
|
28711
29125
|
const effective = rules.declaration(declaration.field.id, path) ?? declaration, behavior = fieldBehavior(effective);
|
|
28712
29126
|
if (widgets && !widgets.has(behavior.widget)) continue;
|
|
29127
|
+
const continueRequired = includeRequired || requiredPaths?.has(path) === true;
|
|
28713
29128
|
const blocked = state.readonly || state.disabled;
|
|
28714
29129
|
if (blockedOnly && !blocked) continue;
|
|
28715
29130
|
const access = rules.accessState(declaration.field.id, path);
|
|
28716
29131
|
if (!browsing && (access.readonly || access.disabled)) continue;
|
|
28717
|
-
if (blocked && (mode === "change" || mode === "blur") && !
|
|
29132
|
+
if (blocked && (mode === "change" || mode === "blur") && !continueRequired) continue;
|
|
28718
29133
|
if (!browsing && recordReference(behavior) && !rules.referenceAvailable(declaration.field.id, path)) {
|
|
28719
29134
|
entries.push({
|
|
28720
29135
|
fieldId: declaration.field.id,
|
|
@@ -28781,7 +29196,7 @@ function nativeValidationTargets(options, mode, paths, widgets, blockedOnly = fa
|
|
|
28781
29196
|
valuePath: path,
|
|
28782
29197
|
value: data.get(path),
|
|
28783
29198
|
state,
|
|
28784
|
-
checkRequired:
|
|
29199
|
+
checkRequired: continueRequired || mode === "all" || mode === "manual" || mode === "display" && blocked,
|
|
28785
29200
|
checkValue: mode !== "manual"
|
|
28786
29201
|
});
|
|
28787
29202
|
}
|
|
@@ -28814,6 +29229,8 @@ var NativeValidator = class {
|
|
|
28814
29229
|
].includes(mode)) throw new Error("原生校验模式无效");
|
|
28815
29230
|
if (request.blockedOnly && mode !== "display") throw new Error("只读字段筛选仅用于展示校验");
|
|
28816
29231
|
if (request.includeRequired !== void 0 && mode !== "change" && mode !== "blur") throw new Error("持续必填检查只能用于输入或失焦校验");
|
|
29232
|
+
if (request.requiredPaths !== void 0 && mode !== "change" && mode !== "blur") throw new Error("局部持续必填检查只能用于输入或失焦校验");
|
|
29233
|
+
const requiredPaths = request.requiredPaths === void 0 ? void 0 : new Set(request.requiredPaths);
|
|
28817
29234
|
const draft = request.draft;
|
|
28818
29235
|
if (draft && mode !== "change" && mode !== "blur") throw new Error("字段草稿只能用于输入或失焦校验");
|
|
28819
29236
|
const paths = draft ? /* @__PURE__ */ new Set([draft.valuePath]) : request.paths === void 0 ? void 0 : new Set(request.paths);
|
|
@@ -28844,6 +29261,7 @@ var NativeValidator = class {
|
|
|
28844
29261
|
draft ? [draft.fieldId, draft.valuePath] : "stored",
|
|
28845
29262
|
request.blockedOnly,
|
|
28846
29263
|
request.includeRequired,
|
|
29264
|
+
requiredPaths && [...requiredPaths].sort(),
|
|
28847
29265
|
paths && [...paths].sort()
|
|
28848
29266
|
]), async (task) => {
|
|
28849
29267
|
const controller = new AbortController();
|
|
@@ -28854,7 +29272,7 @@ var NativeValidator = class {
|
|
|
28854
29272
|
request.signal?.addEventListener("abort", abort, { once: true });
|
|
28855
29273
|
if (task.signal.aborted || this.lifetime.signal.aborted || request.signal?.aborted) abort();
|
|
28856
29274
|
try {
|
|
28857
|
-
const selection = nativeValidationTargets(options, mode, paths, draft ? /* @__PURE__ */ new Set(["number", "input"]) : request.widgets && new Set(request.widgets), request.blockedOnly, request.includeRequired), issues = [];
|
|
29275
|
+
const selection = nativeValidationTargets(options, mode, paths, draft ? /* @__PURE__ */ new Set(["number", "input"]) : request.widgets && new Set(request.widgets), request.blockedOnly, request.includeRequired, requiredPaths), issues = [];
|
|
28858
29276
|
let targetCount = 0;
|
|
28859
29277
|
for (const target of selection.entries) {
|
|
28860
29278
|
if (controller.signal.aborted) throw new Error("原生校验已取消");
|
|
@@ -28956,6 +29374,7 @@ function attachSessionData(context, options = {}) {
|
|
|
28956
29374
|
...options,
|
|
28957
29375
|
host: {
|
|
28958
29376
|
...host,
|
|
29377
|
+
collectNonCopyableFieldPaths: (tableKey) => [.../* @__PURE__ */ new Set([...collectNonCopyableFieldPaths(handle.readModel(), tableKey), ...host?.collectNonCopyableFieldPaths?.(tableKey) ?? []])],
|
|
28959
29378
|
isActive: () => handle.status !== "closed" && (host?.isActive?.() ?? true),
|
|
28960
29379
|
dataWritten: (path, source) => {
|
|
28961
29380
|
handle.notifyData(source, [path]);
|
|
@@ -30461,68 +30880,6 @@ function referenceIdentityChanges(query, data, changes) {
|
|
|
30461
30880
|
}
|
|
30462
30881
|
return [...expanded.values()];
|
|
30463
30882
|
}
|
|
30464
|
-
// src/runtime/form/business/signatures/device-signature-lock.ts
|
|
30465
|
-
/** @file 设备固定表签名锁由当前模型配置和权威填写值派生。 */
|
|
30466
|
-
/** 按模型版本缓存声明;权限每次从当前行读取,签名确认和撤销立即可见。 */
|
|
30467
|
-
function createDeviceSignatureLocks(handle, data, environment) {
|
|
30468
|
-
let revision = -1;
|
|
30469
|
-
let rules = [];
|
|
30470
|
-
function current() {
|
|
30471
|
-
const next = handle.getModelRevision();
|
|
30472
|
-
if (revision === next) return rules;
|
|
30473
|
-
const { query } = handle.readModel();
|
|
30474
|
-
rules = query.findEntities({ roles: ["region"] }).flatMap(({ id }) => {
|
|
30475
|
-
const region = query.getEntity(id, "region");
|
|
30476
|
-
const axis = region?.binding?.pathTemplate;
|
|
30477
|
-
const control = region?.config?.dataLockControlField;
|
|
30478
|
-
if (region?.type !== "bounded" || !axis || !/^\$\.[^.[\]:]+$/.test(axis) || control !== "inspector_" && control !== "reviewer_") return [];
|
|
30479
|
-
const fields = region.config?.mainFieldBindings;
|
|
30480
|
-
return [{
|
|
30481
|
-
axis,
|
|
30482
|
-
control,
|
|
30483
|
-
mainFields: Array.isArray(fields) ? fields.filter((key) => typeof key === "string") : []
|
|
30484
|
-
}];
|
|
30485
|
-
});
|
|
30486
|
-
revision = next;
|
|
30487
|
-
return rules;
|
|
30488
|
-
}
|
|
30489
|
-
function withinRow(path) {
|
|
30490
|
-
const match = /^(\$\.[^.[\]:]+)\[(\d+)\]\.([^.[\]:]+)/.exec(path);
|
|
30491
|
-
if (!match) return;
|
|
30492
|
-
const rule = current().find(({ axis }) => axis === match[1]);
|
|
30493
|
-
return rule ? {
|
|
30494
|
-
rule,
|
|
30495
|
-
row: match[1] + "[" + match[2] + "]",
|
|
30496
|
-
field: match[3]
|
|
30497
|
-
} : void 0;
|
|
30498
|
-
}
|
|
30499
|
-
function signed(rule, row) {
|
|
30500
|
-
return hasAuthenticationValue("signature", data.getStoredValue(row + "." + rule.control));
|
|
30501
|
-
}
|
|
30502
|
-
return {
|
|
30503
|
-
/** 给公共字段状态提供强制只读和禁用标记。 */
|
|
30504
|
-
flags(path) {
|
|
30505
|
-
if (environment().formChangeEditing) return {};
|
|
30506
|
-
const target = withinRow(path);
|
|
30507
|
-
if (target && signed(target.rule, target.row)) {
|
|
30508
|
-
if (target.field !== target.rule.control) return { disabled: true };
|
|
30509
|
-
const id = data.getStoredValue(target.row + ".id_");
|
|
30510
|
-
return { readonly: typeof id === "string" && id.trim() !== "" || typeof id === "number" };
|
|
30511
|
-
}
|
|
30512
|
-
const mainKey = /^\$\.([^.[\]:]+)$/.exec(path)?.[1];
|
|
30513
|
-
if (mainKey && current().some((rule) => rule.mainFields.includes(mainKey) && data.getActiveSubtableRowIndexes(rule.axis).some((index) => signed(rule, rule.axis + "[" + index + "]")))) return { disabled: true };
|
|
30514
|
-
return {};
|
|
30515
|
-
},
|
|
30516
|
-
/** 第一次控制签名前检查参与校验的绑定主字段和同行路径。 */
|
|
30517
|
-
validationPaths(path, candidates) {
|
|
30518
|
-
const target = withinRow(path);
|
|
30519
|
-
if (!target || target.field !== target.rule.control || signed(target.rule, target.row)) return [];
|
|
30520
|
-
const paths = new Set(target.rule.mainFields.map((key) => "$." + key));
|
|
30521
|
-
for (const candidate of candidates()) if (candidate !== path && candidate.startsWith(target.row + ".")) paths.add(candidate);
|
|
30522
|
-
return [...paths];
|
|
30523
|
-
}
|
|
30524
|
-
};
|
|
30525
|
-
}
|
|
30526
30883
|
// src/runtime/form/business/tables/enrichers.ts
|
|
30527
30884
|
/** @file 业务表派生接入现有数据队列,不在画布、组件或保存时另建计算。 */
|
|
30528
30885
|
/** 只为原生物料/备件盘点区域注册规则;同名字段、普通表和其他业务变体不会被套用。 */
|
|
@@ -30955,6 +31312,8 @@ var NativeFieldValidation = class {
|
|
|
30955
31312
|
failure;
|
|
30956
31313
|
versions;
|
|
30957
31314
|
listeners = /* @__PURE__ */ new Set();
|
|
31315
|
+
scopedRequired = /* @__PURE__ */ new Set();
|
|
31316
|
+
requiredScopes = /* @__PURE__ */ new Map();
|
|
30958
31317
|
required = false;
|
|
30959
31318
|
constructor(options) {
|
|
30960
31319
|
this.options = options;
|
|
@@ -30970,10 +31329,13 @@ var NativeFieldValidation = class {
|
|
|
30970
31329
|
this.stop = options.handle.subscribeChanges((change) => {
|
|
30971
31330
|
if (change.kind === "environment" && change.reason !== "mode") return;
|
|
30972
31331
|
if (change.kind === "model") {
|
|
31332
|
+
this.clearScopedRequired();
|
|
30973
31333
|
this.referenceIssues = [];
|
|
30974
31334
|
this.referenceKeys.clear();
|
|
30975
31335
|
this.referenceVersions = void 0;
|
|
30976
|
-
}
|
|
31336
|
+
} else if (change.kind === "environment") this.clearScopedRequired();
|
|
31337
|
+
else if (change.paths.includes("$")) this.clearScopedRequired();
|
|
31338
|
+
else this.pruneScopedRequired(change);
|
|
30977
31339
|
this.request();
|
|
30978
31340
|
});
|
|
30979
31341
|
this.request();
|
|
@@ -30981,12 +31343,93 @@ var NativeFieldValidation = class {
|
|
|
30981
31343
|
/** 明确完整检查后继续保留必填诊断,后续编辑自动清除已修正的问题。 */
|
|
30982
31344
|
revealRequired() {
|
|
30983
31345
|
this.required = true;
|
|
31346
|
+
this.clearScopedRequired();
|
|
30984
31347
|
if (this.stop) this.request();
|
|
30985
31348
|
}
|
|
30986
31349
|
/** 活动草稿沿用已经启动的完整检查必填策略。 */
|
|
30987
31350
|
get checksRequired() {
|
|
30988
31351
|
return this.required;
|
|
30989
31352
|
}
|
|
31353
|
+
checksRequiredFor(path) {
|
|
31354
|
+
return this.required || this.scopedRequired.has(path);
|
|
31355
|
+
}
|
|
31356
|
+
/** 主字段和同行字段共用触发签名所在行的生命周期。 */
|
|
31357
|
+
rememberScopedRequired(sourcePath, paths) {
|
|
31358
|
+
const data = this.options?.runtime.dataManager;
|
|
31359
|
+
const rowPath = /^(\$\.[^.[\]:]+\[\d+\])\./.exec(sourcePath)?.[1];
|
|
31360
|
+
if (!data || !rowPath || data.getStoredValue(rowPath + ".deleted_")) return;
|
|
31361
|
+
this.requiredScopes.set(sourcePath, {
|
|
31362
|
+
rowPath,
|
|
31363
|
+
owner: data.getValueIdentity(rowPath),
|
|
31364
|
+
paths: [...new Set(paths)]
|
|
31365
|
+
});
|
|
31366
|
+
this.pruneScopedRequired();
|
|
31367
|
+
}
|
|
31368
|
+
/** 行换位、替换或软删后丢弃旧范围,普通字段修改继续保留提示。 */
|
|
31369
|
+
pruneScopedRequired(change) {
|
|
31370
|
+
const data = this.options?.runtime.dataManager;
|
|
31371
|
+
if (!data) return;
|
|
31372
|
+
const previous = new Set(this.scopedRequired);
|
|
31373
|
+
this.scopedRequired.clear();
|
|
31374
|
+
for (const [source, scope] of this.requiredScopes) {
|
|
31375
|
+
if (change && !change.paths.some((path) => areRelatedDataPaths(path, scope.rowPath))) {
|
|
31376
|
+
for (const path of scope.paths) this.scopedRequired.add(path);
|
|
31377
|
+
continue;
|
|
31378
|
+
}
|
|
31379
|
+
const owner = data.getValueIdentity(scope.rowPath);
|
|
31380
|
+
const replacesRow = change?.paths.some((path) => isSameOrDescendantPath(scope.rowPath, path));
|
|
31381
|
+
const materializing = scope.owner === void 0 && owner !== void 0 && !replacesRow && change?.source === "user" && change.paths.some((path) => path.startsWith(scope.rowPath + ".") && ![
|
|
31382
|
+
"id_",
|
|
31383
|
+
"front_row_key_",
|
|
31384
|
+
"deleted_"
|
|
31385
|
+
].includes(path.slice(scope.rowPath.length + 1)));
|
|
31386
|
+
if (scope.owner === void 0 && replacesRow || owner !== scope.owner && !materializing || data.getStoredValue(scope.rowPath + ".deleted_")) {
|
|
31387
|
+
this.requiredScopes.delete(source);
|
|
31388
|
+
continue;
|
|
31389
|
+
}
|
|
31390
|
+
if (materializing) this.requiredScopes.set(source, {
|
|
31391
|
+
...scope,
|
|
31392
|
+
owner
|
|
31393
|
+
});
|
|
31394
|
+
for (const path of scope.paths) this.scopedRequired.add(path);
|
|
31395
|
+
}
|
|
31396
|
+
this.dropScopedReferences(new Set([...previous].filter((path) => !this.scopedRequired.has(path))));
|
|
31397
|
+
}
|
|
31398
|
+
dropScopedReferences(paths) {
|
|
31399
|
+
if (this.required || !paths.size) return;
|
|
31400
|
+
this.referenceIssues = this.referenceIssues.filter((issue) => {
|
|
31401
|
+
if (!paths.has(issue.valuePath)) return true;
|
|
31402
|
+
this.referenceKeys.delete(referenceKey(issue));
|
|
31403
|
+
return false;
|
|
31404
|
+
});
|
|
31405
|
+
this.referenceVersions = void 0;
|
|
31406
|
+
}
|
|
31407
|
+
clearScopedRequired() {
|
|
31408
|
+
this.dropScopedReferences(this.scopedRequired);
|
|
31409
|
+
this.requiredScopes.clear();
|
|
31410
|
+
this.scopedRequired.clear();
|
|
31411
|
+
}
|
|
31412
|
+
/** 接收本轮完整字段结果,只保存路径和诊断,不保存填写值。 */
|
|
31413
|
+
followScopedCheck(sourcePath, paths, result, versions) {
|
|
31414
|
+
const options = this.options;
|
|
31415
|
+
const current = options?.handle.getVersions();
|
|
31416
|
+
if (!options || options.handle.status === "closed" || options.environment().mode !== "fill" || result.mode !== "all" || result.status === "stale" || result.modelRevision !== versions.model || current?.model !== versions.model || current.data !== versions.data || current.environment !== versions.environment) return false;
|
|
31417
|
+
if (!this.required) this.rememberScopedRequired(sourcePath, paths);
|
|
31418
|
+
this.controller?.abort();
|
|
31419
|
+
const scope = new Set(paths);
|
|
31420
|
+
const incoming = result.issues.filter((issue) => scope.has(issue.valuePath));
|
|
31421
|
+
for (const issue of this.referenceIssues) if (scope.has(issue.valuePath)) this.referenceKeys.delete(referenceKey(issue));
|
|
31422
|
+
const references = incoming.filter((issue) => issue.referenceCheck);
|
|
31423
|
+
this.referenceIssues = [...this.referenceIssues.filter((issue) => !scope.has(issue.valuePath)), ...references];
|
|
31424
|
+
for (const issue of references) this.referenceKeys.set(referenceKey(issue), options.rules.references.validationFingerprint(issue.fieldId, issue.valuePath));
|
|
31425
|
+
this.referenceVersions = void 0;
|
|
31426
|
+
this.issues = [...this.isCurrent() ? this.issues.filter((issue) => !scope.has(issue.valuePath)) : [], ...incoming];
|
|
31427
|
+
this.failure = void 0;
|
|
31428
|
+
this.versions = versions;
|
|
31429
|
+
this.publish(result.status === "valid" ? void 0 : "check");
|
|
31430
|
+
this.request();
|
|
31431
|
+
return true;
|
|
31432
|
+
}
|
|
30990
31433
|
/** 只接受同一代次真正执行过的完整字段检查;草稿、提前终止和取消不启用必填续查。 */
|
|
30991
31434
|
followCompleteCheck(result) {
|
|
30992
31435
|
const current = this.options?.handle.getVersions(), fields = result.checks.fields;
|
|
@@ -31038,6 +31481,7 @@ var NativeFieldValidation = class {
|
|
|
31038
31481
|
if (!options) return;
|
|
31039
31482
|
if (options.environment().mode === "edit") {
|
|
31040
31483
|
this.required = false;
|
|
31484
|
+
this.clearScopedRequired();
|
|
31041
31485
|
this.referenceIssues = [];
|
|
31042
31486
|
this.referenceKeys.clear();
|
|
31043
31487
|
this.referenceVersions = void 0;
|
|
@@ -31051,6 +31495,7 @@ var NativeFieldValidation = class {
|
|
|
31051
31495
|
const [result, display] = await Promise.all([options.validator.validate({
|
|
31052
31496
|
mode,
|
|
31053
31497
|
includeRequired: this.required,
|
|
31498
|
+
requiredPaths: this.scopedRequired,
|
|
31054
31499
|
signal: controller.signal
|
|
31055
31500
|
}), options.validator.validate({
|
|
31056
31501
|
mode: "display",
|
|
@@ -31143,8 +31588,8 @@ var NativeFieldValidation = class {
|
|
|
31143
31588
|
}
|
|
31144
31589
|
}
|
|
31145
31590
|
}
|
|
31146
|
-
publish() {
|
|
31147
|
-
for (const listener of this.listeners) listener();
|
|
31591
|
+
publish(reason) {
|
|
31592
|
+
for (const listener of this.listeners) listener(reason);
|
|
31148
31593
|
}
|
|
31149
31594
|
/** 环境变化可重排,但模型或填写值换代后不能显示旧错误。 */
|
|
31150
31595
|
message(fieldId, valuePath) {
|
|
@@ -31158,6 +31603,7 @@ var NativeFieldValidation = class {
|
|
|
31158
31603
|
else await Promise.resolve();
|
|
31159
31604
|
}
|
|
31160
31605
|
dispose() {
|
|
31606
|
+
this.clearScopedRequired();
|
|
31161
31607
|
this.options = void 0;
|
|
31162
31608
|
this.stop?.();
|
|
31163
31609
|
this.stop = void 0;
|
|
@@ -31394,13 +31840,16 @@ var NativeDataServices = class {
|
|
|
31394
31840
|
const [_, axis, index] = row;
|
|
31395
31841
|
return this.runtime.query.structuralFields().flatMap(({ binding }) => binding.pathTemplate.startsWith(axis + "[n].") ? [binding.pathTemplate.replace("[n]", "[" + index + "]")] : []);
|
|
31396
31842
|
}),
|
|
31397
|
-
validatePaths: async (paths, signal) => {
|
|
31843
|
+
validatePaths: async (paths, signal, sourcePath) => {
|
|
31844
|
+
await runtimeRequest(this.runtime.whenSettled(), signal);
|
|
31845
|
+
signal.throwIfAborted();
|
|
31846
|
+
const versions = handle.getVersions();
|
|
31398
31847
|
const result = await this.validator.validate({
|
|
31399
31848
|
paths,
|
|
31400
31849
|
signal,
|
|
31401
31850
|
mode: "all"
|
|
31402
31851
|
});
|
|
31403
|
-
if (
|
|
31852
|
+
if (signal.aborted || !this.fieldValidation.followScopedCheck(sourcePath, paths, result, versions)) throw new Error("相关字段已变化,请重新签名");
|
|
31404
31853
|
if (result.status !== "valid") throw new Error(result.issues[0]?.message ?? "请先完成签名前的字段校验");
|
|
31405
31854
|
}
|
|
31406
31855
|
});
|
|
@@ -31721,6 +32170,7 @@ function fieldDecoration(state, printing, placeholder, textColor, optionLabel, v
|
|
|
31721
32170
|
backgroundColor = optionLabel ? void 0 : colors.editable.background;
|
|
31722
32171
|
}
|
|
31723
32172
|
if (visual.hyperlink && !disabled) color = visual.validationError ? colors.validation.color : "#0000ff";
|
|
32173
|
+
if (optionLabel) color = disabled ? colors.disabled.color : textColor;
|
|
31724
32174
|
const markerColor = printing ? colors.marker.default : disabled ? colors.marker.disabled : readonly && required ? colors.requiredReadonly.placeholderColor : readonly ? colors.marker.readonly : required ? colors.required.placeholderColor : colors.marker.default;
|
|
31725
32175
|
return {
|
|
31726
32176
|
color,
|
|
@@ -31760,16 +32210,16 @@ function optionPaint(state, selected) {
|
|
|
31760
32210
|
var attachmentIconUrl = "data:image/svg+xml;base64,PHN2ZyB0PSIxNzg2MDkyOTgzMzc1IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjM0MDM2IiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48cGF0aCBkPSJNNjc1LjY5MzcxNCAxNjMuNjkzNzE0YTE4NC4zOTMxNDMgMTg0LjM5MzE0MyAwIDAgMSAyNjAuNzU0Mjg2IDI2MC44Mjc0MjlMNTAxLjAyODU3MSA4NjAuMDEzNzE0YTI1OC4zNDA1NzEgMjU4LjM0MDU3MSAwIDAgMS0zNjUuMjc1NDI4LTM2NS4yNzU0MjhsMzY1Ljg2MDU3MS0zNjUuODYwNTcyYTM2LjU3MTQyOSAzNi41NzE0MjkgMCAwIDEgNTEuNzEyIDUxLjcxMkwxODcuMzkyIDU0Ni4zNzcxNDNhMTg1LjE5NzcxNCAxODUuMTk3NzE0IDAgMCAwIDI2MS44NTE0MjkgMjYxLjg1MTQyOGw0MzUuNDkyNTcxLTQzNS40OTI1NzFhMTExLjI1MDI4NiAxMTEuMjUwMjg2IDAgMCAwLTE1Ny4zMzAyODYtMTU3LjQwMzQyOUwyOTEuODQgNjUwLjk3MTQyOWEzNy4zMDI4NTcgMzcuMzAyODU3IDAgMCAwIDUyLjg4MjI4NiA1Mi44MDkxNDJsMzY1LjcxNDI4NS0zNjUuNzE0Mjg1YTM2LjU3MTQyOSAzNi41NzE0MjkgMCAxIDEgNTEuNzEyIDUxLjYzODg1N2wtMzY1LjcxNDI4NSAzNjUuNzg3NDI4YTExMC41MTg4NTcgMTEwLjUxODg1NyAwIDAgMS0xNTYuMzA2Mjg2LTE1Ni4yMzMxNDJsNDM1LjQ5MjU3MS00MzUuNDkyNTcyeiIgcC1pZD0iMzQwMzciIGZpbGw9IiMwMjZBQzgiPjwvcGF0aD48L3N2Zz4=";
|
|
31761
32211
|
// src/runtime/presentation/fields/signatures.ts
|
|
31762
32212
|
/** @file 读取签名的显示声明,不认证、不改值、不创建姓名位图缓存。 */
|
|
31763
|
-
/**
|
|
31764
|
-
function signatureGallery(config, value, url) {
|
|
32213
|
+
/** 先解析姓名图形和跟随日期的声明,度量与绘制共用旧版显示规则。 */
|
|
32214
|
+
function signatureGallery(config, value, url, imageSize) {
|
|
31765
32215
|
try {
|
|
31766
32216
|
return {
|
|
32217
|
+
imageSize,
|
|
31767
32218
|
timePlacement: config?.displayDirection === "horizontal" ? "inline" : "below",
|
|
31768
32219
|
items: signatureValues(value).map((record) => {
|
|
31769
32220
|
const imageUrl = record.url ? url(record.url) : void 0;
|
|
31770
32221
|
const time = typeof record.time === "number" ? dayjs(record.time) : void 0;
|
|
31771
|
-
const
|
|
31772
|
-
const timeText = displayTime && time?.isValid() ? time.format(config.format === "date-time" ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD") : "";
|
|
32222
|
+
const timeText = config?.format && config.format !== "name" && config.autofill?.enabled !== true && time?.isValid() ? time.format(config.format === "date-time" ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD") : "";
|
|
31773
32223
|
const fallbackDate = config?.fallback === "name-and-date" && time?.isValid() ? time.format("YYYY-MM-DD") : "";
|
|
31774
32224
|
return {
|
|
31775
32225
|
image: imageUrl ? {
|
|
@@ -31779,9 +32229,11 @@ function signatureGallery(config, value, url) {
|
|
|
31779
32229
|
},
|
|
31780
32230
|
alt: record.username || "签名"
|
|
31781
32231
|
} : void 0,
|
|
31782
|
-
text:
|
|
32232
|
+
text: record.username || "签名图片不可用",
|
|
32233
|
+
fallback: config?.fallback ?? "name",
|
|
32234
|
+
fallbackDate,
|
|
31783
32235
|
timeText,
|
|
31784
|
-
vertical:
|
|
32236
|
+
vertical: config?.imageDirection === "vertical"
|
|
31785
32237
|
};
|
|
31786
32238
|
})
|
|
31787
32239
|
};
|
|
@@ -31906,6 +32358,7 @@ var NativeFieldPresenter = class {
|
|
|
31906
32358
|
if (target.state.display === "readonly-text" && !design) appearance = "text";
|
|
31907
32359
|
else if (choice) appearance = renderAs === "select" ? "select" : "options";
|
|
31908
32360
|
else if (reference) appearance = "select";
|
|
32361
|
+
if (!design && (printing || browse) && empty && config?.emptySymbol?.trim()) appearance = "text";
|
|
31909
32362
|
if (design && (!choice && empty || field.widget === "choice" && renderAs === "select")) {
|
|
31910
32363
|
text = config?.placeholder || config?.designPlaceholder || config?.label || target.declaration.binding.source.fieldLink || "--";
|
|
31911
32364
|
placeholder = true;
|
|
@@ -32007,7 +32460,7 @@ var NativeFieldPresenter = class {
|
|
|
32007
32460
|
};
|
|
32008
32461
|
} catch {}
|
|
32009
32462
|
if (field.widget === "signature" && !design && target.valuePath) {
|
|
32010
|
-
const gallery = signatureGallery(field.config, target.value, (value) => options.rules.signatureUrl(fieldId, target.valuePath, value));
|
|
32463
|
+
const gallery = signatureGallery(field.config, target.value, (value) => options.rules.signatureUrl(fieldId, target.valuePath, value), source.preferredSizePx);
|
|
32011
32464
|
if (gallery?.items.length) control = {
|
|
32012
32465
|
...control,
|
|
32013
32466
|
signatureGallery: gallery,
|
|
@@ -32028,10 +32481,11 @@ var NativeFieldPresenter = class {
|
|
|
32028
32481
|
};
|
|
32029
32482
|
if (plainView && !control.text && !control.imageGallery?.items.length && !control.signatureGallery?.items.length && !control.seal && control.appearance !== "options") control = {
|
|
32030
32483
|
...control,
|
|
32484
|
+
appearance: "text",
|
|
32031
32485
|
inlineText: false,
|
|
32032
32486
|
preferredSizePx: {
|
|
32033
32487
|
width: 21,
|
|
32034
|
-
height:
|
|
32488
|
+
height: control.style.fontSizePx * 1.1
|
|
32035
32489
|
}
|
|
32036
32490
|
};
|
|
32037
32491
|
const decoration = fieldDecoration(target.state, plainView, control.placeholder, control.style.color, appearance === "options", linked ? {
|
|
@@ -33882,4 +34336,4 @@ function attachNativeLayout(context, options) {
|
|
|
33882
34336
|
}
|
|
33883
34337
|
export { shouldInitializeDocumentData as $, NativeMaterialSelection as A, clippedFrame as At, logicalFillPath as B, NativeReferenceScopeError as C, compareFieldConfigurations as Ct, materialAutofillRegions as D, LayoutSessionError as Dt, tableSelectionKind as E, LayoutSession as Et, nativeProductReference as F, viewportRectToPage as Ft, attachNativeDataSources as G, nativeSourceWorkerCode as H, NativeInspectionInitialization as I, runtimeRequest as It, sourceParameters as J, copySourceValue as K, NativeResources as L, NativeMaterialObjects as M, pagePointToViewport as Mt, NativeMaterialInitialization as N, pageRectToViewport as Nt, productAutofillDetails as O, LayoutQuery as Ot, materialProductMatches as P, viewportPointToPage as Pt, isUninitialized as Q, NativeFieldFills as R, NativeReferences as S, compareDocumentContent as St, inventorySelection as T, isRecord as Tt, runNativeSourceScript as U, subtableFillColumn as V, NativeDataSources as W, NativeSourceError as X, sourceProperty as Y, hasPersistedDocumentData as Z, CHECK_TABLE_TYPE_TO_VALUE_FIELD as _, resizedDesignColumnWidth as _t, NativeDataServices as a, NativeDataRuntime as at, NativeSignatures as b, combineSessionSignals as bt, businessNumberMinimum as c, DataManager as ct, NativeValidator as d, NativeTableQuickFill as dt, NativeDataInitializer as et, attachNativeValidator as f, nativeQuickFillLimit as ft, createNativeSubmissionData as g, NestedTableInsertionError as gt, allocationNotices as h, EditorController as ht, attachSessionLayout as i, attachNativeParameterInitializer as it, getInvalidMaterialLotReason as j, UnsupportedLayoutError as jt, NativeMaterials as k, DocumentLayoutBuilder as kt, businessTableFieldDefaults as l, NativeBusinessTables as lt, attachNativeSubmissionCoordinator as m, attachNativeInteraction as mt, NativeLayoutPresentation as n, attachNativeDataInitializer as nt, attachNativeDataServices as o, attachNativeDataRuntime as ot, NativeSubmissionCoordinator as p, isDerivedDataPath as pt, sourceResult as q, choiceSpacingDefaults as r, NativeParameterInitializer as rt, NativeBusinessFields as s, NativeDataQuery as st, attachNativeLayout as t, NativeInitializationQueryError as tt, attachSessionData as u, NativeTableScan as ut, isSubmitExcludedKey as v, MissingSubTableHeaderTargetError as vt, validateNativeReference as w, validateTemplateSave as wt, NativeSeals as x, DocumentSession as xt, validateNativeSignatures as y, FieldPlacementError as yt, attachNativeFieldFills as z };
|
|
33884
34338
|
|
|
33885
|
-
//# sourceMappingURL=sdk-
|
|
34339
|
+
//# sourceMappingURL=sdk-BmwE5mZn.js.map
|