@gct-paas/word 1.0.1 → 1.0.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +20 -11
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{ModelEditor-GzaLnnX8.js → ModelEditor-DqavEAJg.js} +114 -5
  4. package/dist/chunks/ModelEditor-DqavEAJg.js.map +1 -0
  5. package/dist/chunks/NodeFactory-DzFnWaWf.js +500 -0
  6. package/dist/chunks/NodeFactory-DzFnWaWf.js.map +1 -0
  7. package/dist/chunks/{browser-CP0ycXqN.js → browser-OAJIVM8O.js} +420 -192
  8. package/dist/chunks/browser-OAJIVM8O.js.map +1 -0
  9. package/dist/chunks/{change-set-DNOw1FXo.js → change-set-DgfKTJ6d.js} +12 -2
  10. package/dist/chunks/change-set-DgfKTJ6d.js.map +1 -0
  11. package/dist/chunks/legacy-template-converter-DFsd-elN.js +125 -0
  12. package/dist/chunks/legacy-template-converter-DFsd-elN.js.map +1 -0
  13. package/dist/chunks/migrate-YJTylIpz.js +5193 -0
  14. package/dist/chunks/migrate-YJTylIpz.js.map +1 -0
  15. package/dist/chunks/{sdk-DH5c-Bbt.js → sdk-BmwE5mZn.js} +1082 -628
  16. package/dist/chunks/sdk-BmwE5mZn.js.map +1 -0
  17. package/dist/chunks/src-BFXPGLus.js +3338 -0
  18. package/dist/chunks/src-BFXPGLus.js.map +1 -0
  19. package/dist/chunks/{table-borders-Dwuj7lFp.js → table-borders-B9bZMj5o.js} +2 -2
  20. package/dist/chunks/{table-borders-Dwuj7lFp.js.map → table-borders-B9bZMj5o.js.map} +1 -1
  21. package/dist/chunks/templates-Djcl21k4.js.map +1 -1
  22. package/dist/chunks/{types-XXuIIZ9e.js → types-CMkQ6Lvg.js} +123 -7
  23. package/dist/chunks/types-CMkQ6Lvg.js.map +1 -0
  24. package/dist/chunks/{NodeFactory-D9gVGSok.js → validation-DkCy8wHI.js} +10 -495
  25. package/dist/chunks/validation-DkCy8wHI.js.map +1 -0
  26. package/dist/docx.js +3 -2
  27. package/dist/docx.js.map +1 -1
  28. package/dist/index.js +7 -6
  29. package/dist/legacy.js +1 -0
  30. package/dist/platform.js +4 -3
  31. package/dist/platform.js.map +1 -1
  32. package/dist/style.css +864 -584
  33. package/dist/types/adapters/browser/canvas/CanvasPages.d.ts +1 -1
  34. package/dist/types/adapters/browser/canvas/paint-context.d.ts +4 -0
  35. package/dist/types/adapters/browser/canvas/paint-signature.d.ts +4 -0
  36. package/dist/types/adapters/browser/input/SignatureFieldInput.d.ts +10 -1
  37. package/dist/types/adapters/browser/input/signature-panel.d.ts +6 -0
  38. package/dist/types/adapters/browser/input/validation/CanvasValidationPanel.d.ts +1 -1
  39. package/dist/types/adapters/browser/input/word-error-text.d.ts +8 -2
  40. package/dist/types/adapters/platform/index.d.ts +1 -0
  41. package/dist/types/adapters/platform/templates.d.ts +11 -1
  42. package/dist/types/adapters/vue/GctWordPrintRenderer.vue.d.ts +1 -1
  43. package/dist/types/adapters/vue/GctWordTemplateDesigner.vue.d.ts +3 -0
  44. package/dist/types/adapters/vue/SignatureCardReader.vue.d.ts +1 -0
  45. package/dist/types/adapters/vue/SignatureVisual.vue.d.ts +10 -0
  46. package/dist/types/adapters/vue/WordFeedback.vue.d.ts +11 -0
  47. package/dist/types/adapters/vue/WordLayoutNotices.vue.d.ts +8 -0
  48. package/dist/types/adapters/vue/WordOperationError.vue.d.ts +11 -0
  49. package/dist/types/adapters/vue/field-properties/dependency-strategies.d.ts +7 -0
  50. package/dist/types/adapters/vue/index.d.ts +1 -0
  51. package/dist/types/adapters/vue/layout-notices.d.ts +15 -0
  52. package/dist/types/adapters/vue/legacy-template-converter.d.ts +14 -0
  53. package/dist/types/adapters/vue/region-properties/WordBusinessRegion.vue.d.ts +3 -0
  54. package/dist/types/adapters/vue/region-properties/WordDataLockConfig.vue.d.ts +16 -0
  55. package/dist/types/adapters/vue/useWordWorkspace.d.ts +6 -3
  56. package/dist/types/adapters/vue/word-feedback.d.ts +21 -0
  57. package/dist/types/data/DataManager.d.ts +2 -2
  58. package/dist/types/data/rows/copy-row.d.ts +5 -0
  59. package/dist/types/data/services/DataDependencies.d.ts +2 -2
  60. package/dist/types/data/types/manager.d.ts +2 -0
  61. package/dist/types/data/types/rules.d.ts +8 -1
  62. package/dist/types/import/legacy/autofill.d.ts +3 -0
  63. package/dist/types/import/legacy/bindings.d.ts +9 -0
  64. package/dist/types/import/legacy/boundary.d.ts +10 -0
  65. package/dist/types/import/legacy/business-fields.d.ts +25 -0
  66. package/dist/types/import/legacy/context.d.ts +61 -0
  67. package/dist/types/import/legacy/data-sources.d.ts +29 -0
  68. package/dist/types/import/legacy/document-rules.d.ts +38 -0
  69. package/dist/types/import/legacy/document-signature.d.ts +16 -0
  70. package/dist/types/import/legacy/fields.d.ts +34 -0
  71. package/dist/types/import/legacy/index.d.ts +3 -0
  72. package/dist/types/import/legacy/initialization.d.ts +34 -0
  73. package/dist/types/import/legacy/json-data.d.ts +25 -0
  74. package/dist/types/import/legacy/materials.d.ts +40 -0
  75. package/dist/types/import/legacy/media.d.ts +18 -0
  76. package/dist/types/import/legacy/metadata.d.ts +23 -0
  77. package/dist/types/import/legacy/migrate.d.ts +9 -0
  78. package/dist/types/import/legacy/page-widgets.d.ts +30 -0
  79. package/dist/types/import/legacy/relations.d.ts +25 -0
  80. package/dist/types/import/legacy/scalar-fields.d.ts +7 -0
  81. package/dist/types/import/legacy/styles.d.ts +52 -0
  82. package/dist/types/import/legacy/table-variants.d.ts +18 -0
  83. package/dist/types/import/legacy/tables.d.ts +27 -0
  84. package/dist/types/import/legacy/trace-fields.d.ts +21 -0
  85. package/dist/types/import/legacy/types.d.ts +141 -0
  86. package/dist/types/import/legacy/widget-presentation.d.ts +10 -0
  87. package/dist/types/layout/engine/atoms/control-text.d.ts +16 -0
  88. package/dist/types/layout/engine/atoms/field-control.d.ts +0 -13
  89. package/dist/types/layout/engine/atoms/signatures.d.ts +2 -2
  90. package/dist/types/layout/engine/blocks/placement-types.d.ts +7 -0
  91. package/dist/types/layout/engine/pagination/content-flow.d.ts +8 -0
  92. package/dist/types/layout/engine/tables/place-table-window.d.ts +3 -2
  93. package/dist/types/layout/engine/tables/row-flow.d.ts +3 -2
  94. package/dist/types/layout/engine/tables/table-flow.d.ts +3 -1
  95. package/dist/types/layout/geometry/control-brackets.d.ts +4 -0
  96. package/dist/types/layout/types/presentation/controls.d.ts +13 -0
  97. package/dist/types/layout/types/presentation/images.d.ts +8 -0
  98. package/dist/types/layout/types/presentation/signatures.d.ts +6 -0
  99. package/dist/types/model/business/business-types.d.ts +9 -1
  100. package/dist/types/model/business/data-lock-config.d.ts +27 -0
  101. package/dist/types/runtime/form/business/signatures/NativeSignatures.d.ts +3 -1
  102. package/dist/types/runtime/form/business/signatures/device-signature-lock.d.ts +2 -0
  103. package/dist/types/runtime/form/business/tables/row-fields.d.ts +1 -1
  104. package/dist/types/runtime/form/copy-field-paths.d.ts +3 -0
  105. package/dist/types/runtime/form/fields/core/rules/CommonFieldRules.d.ts +5 -1
  106. package/dist/types/runtime/form/shared/identity.d.ts +0 -1
  107. package/dist/types/runtime/form/shared/row.d.ts +0 -1
  108. package/dist/types/runtime/form/validation/NativeFieldValidation.d.ts +14 -2
  109. package/dist/types/runtime/form/validation/targets.d.ts +1 -1
  110. package/dist/types/runtime/form/validation/types.d.ts +2 -0
  111. package/dist/types/runtime/interaction/EditorController.d.ts +2 -0
  112. package/dist/types/runtime/interaction/browse/types.d.ts +5 -0
  113. package/dist/types/runtime/interaction/design/format/EditorFormat.d.ts +2 -2
  114. package/dist/types/runtime/interaction/design/format/summary.d.ts +1 -2
  115. package/dist/types/runtime/interaction/design/format/targets.d.ts +11 -0
  116. package/dist/types/runtime/interaction/design/format/types.d.ts +3 -3
  117. package/dist/types/runtime/interaction/design/tables/regions/definitions.d.ts +7 -0
  118. package/dist/types/runtime/interaction/field-signature.d.ts +3 -0
  119. package/dist/types/runtime/presentation/fields/signatures.d.ts +5 -2
  120. package/dist/types/shared/form-config/identity.d.ts +3 -0
  121. package/dist/types/shared/identity.d.ts +3 -0
  122. package/dist/types/shared/platform-gct/form-credentials.d.ts +0 -1
  123. package/dist/types/shared/platform-gct/templates.d.ts +2 -0
  124. package/dist/types/shared/signature-graphic.d.ts +27 -0
  125. package/dist/types/shared/text/shading.d.ts +12 -0
  126. package/dist/types/shared/ui/select/src/select.types.d.ts +2 -0
  127. package/dist/types/shared/ui/tree-select/src/unified-tree-select.vue.d.ts +1 -1
  128. package/dist/vue.js +2140 -4498
  129. package/dist/vue.js.map +1 -1
  130. package/package.json +9 -3
  131. package/dist/chunks/ModelEditor-GzaLnnX8.js.map +0 -1
  132. package/dist/chunks/NodeFactory-D9gVGSok.js.map +0 -1
  133. package/dist/chunks/browser-CP0ycXqN.js.map +0 -1
  134. package/dist/chunks/change-set-DNOw1FXo.js.map +0 -1
  135. package/dist/chunks/sdk-DH5c-Bbt.js.map +0 -1
  136. package/dist/chunks/types-XXuIIZ9e.js.map +0 -1
@@ -1,6 +1,8 @@
1
- import { C as snapshotSealDefinition, D as snapshotPageWidgetDragDefinition, E as snapshotFieldDragDefinition, En as wordClipboardType, Gt as resourceUrl, I as designRegionTypes, L as designRegionVariants, Ln as assertLayoutTextMeasureRequest, Nn as layoutImageSourceKey, On as parseTsv, Pn as LayoutContractError, Rn as assertLayoutTextMeasurement, W as sameBusinessField, Wt as resourceName, h as sameFieldSignatureInput, jn as sameLayoutVersion, kn as tsvClipboardLimits, qt as validateResourceFiles, r as sameFieldTextInput, t as nativeTableRowBatchLimit, v as sameFieldChoiceInput, y as sameFieldOptionInput } from "./types-XXuIIZ9e.js";
1
+ import { Bn as assertLayoutTextMeasureRequest, C as snapshotSealDefinition, D as snapshotPageWidgetDragDefinition, E as snapshotFieldDragDefinition, G as sameBusinessField, I as designRegionLabel, In as layoutImageSourceKey, Jt as resourceUrl, L as designRegionTypes, Ln as LayoutContractError, Mn as tsvClipboardLimits, Pn as sameLayoutVersion, R as designRegionVariants, Vn as assertLayoutTextMeasurement, Xt as validateResourceFiles, h as sameFieldSignatureInput, it as signatureGraphicUrl, jn as parseTsv, kn as wordClipboardType, qt as resourceName, r as sameFieldTextInput, rt as signatureGraphic, t as nativeTableRowBatchLimit, v as sameFieldChoiceInput, y as sameFieldOptionInput } from "./types-CMkQ6Lvg.js";
2
+ import { u as createUuid } from "./change-set-DgfKTJ6d.js";
2
3
  import { t as waitForAbortable } from "./abortable-D4G3Ib7H.js";
3
- import { C as ModelEditError, c as DocumentValidationError, t as NodeFactory } from "./NodeFactory-D9gVGSok.js";
4
+ import { c as DocumentValidationError, t as NodeFactory } from "./NodeFactory-DzFnWaWf.js";
5
+ import { p as ModelEditError } from "./validation-DkCy8wHI.js";
4
6
  import { a as getGctFieldIcon, o as GCT_BASE_FIELD_TYPES, s as GCT_BUSINESS_FIELD_TYPES } from "./fields-CAcm6X98.js";
5
7
  import { groupBy, minBy, sortBy, uniq, uniqBy } from "es-toolkit/array";
6
8
  import { isEqual, isPlainObject } from "es-toolkit/predicate";
@@ -154,7 +156,7 @@ var NativeFontResources = class {
154
156
  /** 关闭后解除宿主通知和字体集合引用。 */
155
157
  options;
156
158
  /** 每份文档使用独立前缀,两个文档加载同名字体也不会覆盖。 */
157
- prefix = `GCTFont_${globalThis.crypto.randomUUID().replaceAll("-", "")}`;
159
+ prefix = `GCTFont_${createUuid().replaceAll("-", "")}`;
158
160
  /** 替换同一文件时使用新别名,避免旧结果在相同名字下读到新字节。 */
159
161
  revision = 0;
160
162
  /** 当前拥有的已提交字体。 */
@@ -384,7 +386,7 @@ var CanvasImageResources = class {
384
386
  for (const page of result.pages) {
385
387
  let sources = this.pageSources.get(page);
386
388
  if (!sources) {
387
- sources = new Map([...pageLayoutImages(page)].map(({ source }) => [layoutImageSourceKey(source), Object.freeze({ ...source })]));
389
+ sources = new Map([...pageLayoutImages(page)].filter((image) => !image.graphic).map(({ source }) => [layoutImageSourceKey(source), Object.freeze({ ...source })]));
388
390
  this.pageSources.set(page, sources);
389
391
  }
390
392
  this.sources.set(page.id, sources);
@@ -678,10 +680,48 @@ function fieldContentBackgroundFrame(control, style, width, height) {
678
680
  height: bottom - top
679
681
  };
680
682
  }
683
+ // src/adapters/browser/canvas/paint-signature.ts
684
+ /** @file 姓名签名与旧版图形共用白底、黑字和 middle 基线,输出可独立编码同一图形。 */
685
+ function paintSignatureGraphic(context, graphic, frame) {
686
+ if (context.drawSignatureGraphic) {
687
+ context.drawSignatureGraphic(graphic, frame);
688
+ return;
689
+ }
690
+ context.save();
691
+ try {
692
+ context.translate(frame.x, frame.y);
693
+ context.scale(frame.width / graphic.width, frame.height / graphic.height);
694
+ context.beginPath();
695
+ context.rect(0, 0, graphic.width, graphic.height);
696
+ context.clip();
697
+ context.fillStyle = "#ffffff";
698
+ context.fillRect(0, 0, graphic.width, graphic.height);
699
+ context.fillStyle = "#000000";
700
+ context.textAlign = "left";
701
+ context.textBaseline = "middle";
702
+ context.direction = "ltr";
703
+ context.fontKerning = "normal";
704
+ context.letterSpacing = "0px";
705
+ for (const text of graphic.texts) {
706
+ context.font = `${text.fontWeight} ${text.fontSize}px Arial, sans-serif`;
707
+ context.save();
708
+ context.translate(text.x, text.y);
709
+ if (text.naturalWidth > text.width && text.naturalWidth > 0) context.scale(text.width / text.naturalWidth, 1);
710
+ paintMeasuredText(context, text.text, 0, 0, text.naturalWidth);
711
+ context.restore();
712
+ }
713
+ } finally {
714
+ context.restore();
715
+ }
716
+ }
681
717
  // src/adapters/browser/canvas/paint-image.ts
682
718
  /** @file 图片按已发布几何绘制;解码对象由外部资源端口借用,不在绘制中加载。 */
683
719
  /** contain 留白、cover 居中裁剪、fill 拉伸都只在目标框内绘制。 */
684
720
  function paintImage(context, image, provider) {
721
+ if (image.graphic) {
722
+ paintSignatureGraphic(context, image.graphic, image.frame);
723
+ return;
724
+ }
685
725
  const frame = image.frame, decoded = image.state === "ready" ? provider?.getImage(layoutImageSourceKey(image.source), image.revision) : void 0;
686
726
  if (frame.width <= 0 || frame.height <= 0) return;
687
727
  context.save();
@@ -690,13 +730,14 @@ function paintImage(context, image, provider) {
690
730
  context.rect(frame.x, frame.y, frame.width, frame.height);
691
731
  context.clip();
692
732
  if (!decoded) {
693
- context.fillStyle = image.state === "error" ? "#fff0f0" : "#edf1f5";
733
+ context.fillStyle = image.placeholder?.backgroundColor ?? (image.state === "error" ? "#fff0f0" : "#edf1f5");
694
734
  context.fillRect(frame.x, frame.y, frame.width, frame.height);
735
+ if (image.placeholder && !image.placeholder.text) return;
695
736
  context.fillStyle = image.state === "error" ? "#a84040" : "#758397";
696
737
  context.font = "12px sans-serif";
697
738
  context.textAlign = "left";
698
739
  context.textBaseline = "top";
699
- context.fillText(image.alt || (image.state === "error" ? "图片加载失败" : "图片加载中"), frame.x + 3, frame.y + 3);
740
+ context.fillText(image.placeholder?.text ?? (image.alt || (image.state === "error" ? "图片加载失败" : "图片加载中")), frame.x + 3, frame.y + 3);
700
741
  return;
701
742
  }
702
743
  const { width, height, value } = decoded;
@@ -739,6 +780,19 @@ function paintSealDecoration(context, control, width, height) {
739
780
  context.stroke();
740
781
  context.setLineDash([]);
741
782
  }
783
+ // src/layout/geometry/control-brackets.ts
784
+ function controlBracketFrames(control, style) {
785
+ if (control.bracketFrames?.length) return control.bracketFrames;
786
+ return (control.bracketTexts ?? []).flatMap((text) => text.text === "[" || text.text === "]" ? [{
787
+ side: text.text === "[" ? "start" : "end",
788
+ frame: {
789
+ x: text.x,
790
+ y: text.baseline - style.fontSizePx * .8 - .5,
791
+ width: text.width,
792
+ height: style.fontSizePx + 1
793
+ }
794
+ }] : []);
795
+ }
742
796
  // src/adapters/browser/canvas/paint-field.ts
743
797
  /** @file 字段只消费排版快照;普通字段按括号和状态底色绘制,不创建输入框。 */
744
798
  /** 单选圆与复选圆角框使用同一已解析配色,图形不参与独立事件监听。 */
@@ -764,8 +818,8 @@ function optionPath(context, x, y, width, height, radio, radius) {
764
818
  context.closePath();
765
819
  }
766
820
  }
767
- /** 选项边框在实际背板像素中对齐,包含字段原点、缩放及 DPR;旋转时保留矢量坐标。 */
768
- function optionPixels(context, frame) {
821
+ /** 控件边框在实际背板像素中对齐,包含字段原点、缩放及 DPR;旋转时保留矢量坐标。 */
822
+ function decorationPixels(context, frame) {
769
823
  const pixels = canvasPixels(context);
770
824
  if (!pixels) return {
771
825
  frame,
@@ -791,7 +845,7 @@ function optionPixels(context, frame) {
791
845
  function paintOption(context, marker, color) {
792
846
  context.save();
793
847
  try {
794
- const { frame, lineWidth, radius, checkWidth } = optionPixels(context, marker.frame);
848
+ const { frame, lineWidth, radius, checkWidth } = decorationPixels(context, marker.frame);
795
849
  const paint = marker.paint ?? {
796
850
  border: color,
797
851
  background: "#fff",
@@ -828,15 +882,34 @@ function paintOption(context, marker, color) {
828
882
  }
829
883
  /** 在控件原点按字段状态色绘制括号。 */
830
884
  function paintFieldBrackets(context, control, style) {
831
- if (!control.bracketTexts?.length) return;
832
- applyCanvasTextStyle(context, {
833
- ...style,
834
- fontWeight: 400,
835
- fontStyle: "normal",
836
- letterSpacingPx: 0
837
- }, "ltr");
838
- context.fillStyle = control.decoration?.markerColor ?? style.color;
839
- for (const text of control.bracketTexts) paintMeasuredText(context, text.text, text.x, text.baseline, text.width);
885
+ const brackets = controlBracketFrames(control, style);
886
+ if (!brackets.length) return;
887
+ context.save();
888
+ try {
889
+ const pixels = canvasPixels(context), lineWidth = pixels?.length(1) ?? 1;
890
+ if (pixels) context.setTransform(1, 0, 0, 1, 0, 0);
891
+ context.strokeStyle = control.decoration?.markerColor ?? style.color;
892
+ context.lineWidth = lineWidth;
893
+ context.lineCap = "butt";
894
+ context.setLineDash([]);
895
+ context.beginPath();
896
+ for (const bracket of brackets) {
897
+ const frame = bracket.frame;
898
+ const x = pixels?.x(frame.x) ?? frame.x, y = pixels?.y(frame.y) ?? frame.y;
899
+ const width = pixels?.width(frame.width) ?? frame.width, height = pixels?.height(frame.height) ?? frame.height;
900
+ const left = x + lineWidth / 2, right = x + width - lineWidth / 2;
901
+ const top = y + lineWidth / 2, bottom = y + height - lineWidth / 2;
902
+ const stem = bracket.side === "start" ? left : right;
903
+ const cap = bracket.side === "start" ? right : left;
904
+ context.moveTo(cap, top);
905
+ context.lineTo(stem, top);
906
+ context.lineTo(stem, bottom);
907
+ context.lineTo(cap, bottom);
908
+ }
909
+ context.stroke();
910
+ } finally {
911
+ context.restore();
912
+ }
840
913
  }
841
914
  /** 字段值、占位、括号、选项、签名和图片均沿用已分配的相对几何。 */
842
915
  function paintField(context, fragment, result, images, printBackground) {
@@ -856,7 +929,7 @@ function paintField(context, fragment, result, images, printBackground) {
856
929
  const empty = !control.texts.some((text) => text.text) && !control.images?.length && !control.markers.length && !control.seal;
857
930
  const bounds = fieldContentBackgroundFrame(control, style, width, height);
858
931
  const verticalPad = empty ? pad : decoration?.backgroundVerticalPaddingPx ?? pad;
859
- context.fillRect(bounds.x - (empty ? 0 : pad), bounds.y - verticalPad, bounds.width + (empty ? 0 : pad * 2), bounds.height + (empty ? 0 : verticalPad * 2));
932
+ context.fillRect(bounds.x - (empty ? 0 : pad), bounds.y - verticalPad, bounds.width + (empty ? 0 : pad * 2), bounds.height + verticalPad * 2);
860
933
  } else for (const text of control.texts) context.fillRect(text.x, fieldTextBackgroundTop(text.baseline, style.fontSizePx), text.width, fieldTextBackgroundHeight(style.fontSizePx));
861
934
  }
862
935
  context.beginPath();
@@ -864,19 +937,26 @@ function paintField(context, fragment, result, images, printBackground) {
864
937
  context.clip();
865
938
  for (const image of control.images ?? []) paintImage(context, image, images);
866
939
  if (control.seal) paintSealDecoration(context, control, width, height);
867
- applyCanvasTextStyle(context, style, "ltr");
868
940
  const textStyle = {
869
941
  ...style,
870
942
  color: decoration?.color ?? style.color,
871
943
  ...decoration?.underlineColor ? { underline: "single" } : {}
872
944
  };
945
+ applyCanvasTextStyle(context, textStyle, "ltr");
873
946
  context.fillStyle = textStyle.color;
947
+ let currentStyle = textStyle;
874
948
  for (const text of control.texts) {
949
+ const actualStyle = text.style ?? textStyle;
950
+ if (actualStyle !== currentStyle) {
951
+ applyCanvasTextStyle(context, actualStyle, "ltr");
952
+ context.fillStyle = actualStyle.color;
953
+ currentStyle = actualStyle;
954
+ }
875
955
  if (text.expansion) {
876
956
  const { offsets, x: origins } = text.expansion;
877
957
  for (let i = 0; i < offsets.length; i++) paintMeasuredText(context, text.text.slice(offsets[i], offsets[i + 1]), text.x + origins[i], text.baseline, (origins[i + 1] ?? text.width) - origins[i]);
878
958
  } else paintMeasuredText(context, text.text, text.x, text.baseline, text.width);
879
- paintTextDecorations(context, textStyle, text.x, text.baseline, text.width, decoration?.underlineColor);
959
+ paintTextDecorations(context, actualStyle, text.x, text.baseline, text.width, text.style ? void 0 : decoration?.underlineColor);
880
960
  }
881
961
  paintFieldBrackets(context, control, style);
882
962
  for (const marker of control.markers) paintOption(context, marker, style.color);
@@ -1522,10 +1602,13 @@ var CanvasPages = class {
1522
1602
  offsetY: 0
1523
1603
  };
1524
1604
  }
1525
- /** 仅平移整页显示,输入覆盖层继续按真实 Canvas DOM 边界换算。 */
1605
+ /** 在布局阶段定位整页,避免分数 transform 让已绘制的 Canvas 再次插值。 */
1526
1606
  alignSurface(slot, canvas, cssWidth, cssHeight, options) {
1527
1607
  if (!options.alignToPixels) {
1528
- if (slot.offsetX || slot.offsetY) slot.sheet.style.transform = "";
1608
+ if (slot.offsetX || slot.offsetY) {
1609
+ slot.sheet.style.left = "";
1610
+ slot.sheet.style.top = "";
1611
+ }
1529
1612
  slot.offsetX = slot.offsetY = 0;
1530
1613
  return;
1531
1614
  }
@@ -1533,7 +1616,8 @@ var CanvasPages = class {
1533
1616
  if (!Number.isFinite(scaleX) || !Number.isFinite(scaleY) || scaleX <= 0 || scaleY <= 0) return;
1534
1617
  const ratio = options.devicePixelRatio, left = frame.left - slot.offsetX * scaleX, top = frame.top - slot.offsetY * scaleY, x = Math.round((Math.round(left * ratio) / ratio - left) / scaleX * 1e6) / 1e6, y = Math.round((Math.round(top * ratio) / ratio - top) / scaleY * 1e6) / 1e6;
1535
1618
  if (slot.offsetX === x && slot.offsetY === y) return;
1536
- slot.sheet.style.transform = x || y ? `translate(${x}px, ${y}px)` : "";
1619
+ slot.sheet.style.left = x ? `${x}px` : "";
1620
+ slot.sheet.style.top = y ? `${y}px` : "";
1537
1621
  slot.offsetX = x;
1538
1622
  slot.offsetY = y;
1539
1623
  }
@@ -3587,6 +3671,7 @@ var ResourceFieldPreview = class {
3587
3671
  this.task = task;
3588
3672
  this.hit = hit;
3589
3673
  this.pinned = pinned;
3674
+ let ownedMeasurer;
3590
3675
  try {
3591
3676
  const preview = await this.options.controller.readonlyActions.preview(hit, task.signal);
3592
3677
  if (!preview || task.signal.aborted || this.task !== task) {
@@ -3603,7 +3688,10 @@ var ResourceFieldPreview = class {
3603
3688
  fieldId: hit.fieldId,
3604
3689
  instanceKey: hit.instanceKey
3605
3690
  }, preview.label, {
3606
- width: 280,
3691
+ width: preview.kind === "signature" ? {
3692
+ minWidth: 1,
3693
+ maxWidth: 420
3694
+ } : 280,
3607
3695
  height: 280,
3608
3696
  autoFocus: pinned
3609
3697
  }, () => {
@@ -3617,16 +3705,52 @@ var ResourceFieldPreview = class {
3617
3705
  this.popover = popover;
3618
3706
  const root = popover.content, owner = root.ownerDocument;
3619
3707
  root.className = "gct-word-media-preview-list";
3620
- if (preview.kind !== "file") root.classList.add("is-images");
3621
- const images = preview.entries.flatMap((entry) => {
3708
+ if (preview.kind !== "file") root.classList.add(preview.kind === "signature" ? "is-signatures" : "is-images");
3709
+ const entries = preview.entries.map((entry) => {
3622
3710
  const url = resourceUrl(entry.url, owner.baseURI);
3623
- return url ? [{
3624
- name: entry.name,
3625
- url
3626
- }] : [];
3711
+ if (preview.kind !== "signature") return {
3712
+ ...entry,
3713
+ url,
3714
+ size: void 0
3715
+ };
3716
+ const appearance = preview.signature ?? {};
3717
+ if (url) return {
3718
+ ...entry,
3719
+ url,
3720
+ size: {
3721
+ width: appearance.vertical ? appearance.height ?? 68 : appearance.width ?? 120,
3722
+ height: appearance.vertical ? appearance.width ?? 120 : appearance.height ?? 68
3723
+ }
3724
+ };
3725
+ const measurer = this.options.textMeasurer ?? (ownedMeasurer ??= new CanvasTextMeasurer());
3726
+ const graphic = signatureGraphic(entry.name, entry.signatureDate ?? "", appearance, (text, fontSizePx, fontWeight) => measurer.measureWidth({
3727
+ text,
3728
+ direction: "ltr",
3729
+ style: {
3730
+ fontFamily: "Arial",
3731
+ fontSizePx,
3732
+ fontWeight,
3733
+ fontStyle: "normal",
3734
+ letterSpacingPx: 0,
3735
+ kerning: "normal"
3736
+ }
3737
+ }));
3738
+ return {
3739
+ ...entry,
3740
+ url: signatureGraphicUrl(graphic),
3741
+ size: {
3742
+ width: graphic.width,
3743
+ height: graphic.height
3744
+ }
3745
+ };
3627
3746
  });
3628
- for (const entry of preview.entries) {
3629
- const url = resourceUrl(entry.url, owner.baseURI);
3747
+ const imageEntries = entries.filter((entry) => entry.url);
3748
+ const images = imageEntries.map((entry) => ({
3749
+ name: entry.name,
3750
+ url: entry.url
3751
+ }));
3752
+ for (const entry of entries) {
3753
+ const url = entry.url;
3630
3754
  if (preview.kind === "file") {
3631
3755
  const card = owner.createElement("a"), icon = owner.createElement("img"), name = owner.createElement("span"), meta = owner.createElement("div"), size = owner.createElement("small");
3632
3756
  card.className = "gct-word-media-file";
@@ -3655,6 +3779,10 @@ var ResourceFieldPreview = class {
3655
3779
  const image = owner.createElement("img");
3656
3780
  image.src = url;
3657
3781
  image.alt = entry.name;
3782
+ if (entry.size) {
3783
+ image.style.width = `${entry.size.width}px`;
3784
+ image.style.height = `${entry.size.height}px`;
3785
+ }
3658
3786
  button.append(image);
3659
3787
  button.addEventListener("click", () => {
3660
3788
  this.pinned = true;
@@ -3663,7 +3791,7 @@ var ResourceFieldPreview = class {
3663
3791
  this.viewer = openImageViewer({
3664
3792
  container: root,
3665
3793
  images,
3666
- index: images.findIndex((image) => image.url === url),
3794
+ index: imageEntries.indexOf(entry),
3667
3795
  signal: task.signal,
3668
3796
  onClose: () => {
3669
3797
  this.viewer = void 0;
@@ -3682,6 +3810,8 @@ var ResourceFieldPreview = class {
3682
3810
  this.options.onError?.(error);
3683
3811
  } catch {}
3684
3812
  }
3813
+ } finally {
3814
+ ownedMeasurer?.dispose();
3685
3815
  }
3686
3816
  }
3687
3817
  refresh() {
@@ -4944,28 +5074,29 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
4944
5074
  if (fragment.kind !== "atom" || !fragment.fieldControl) return [];
4945
5075
  const control = fragment.fieldControl;
4946
5076
  const style = snapshot.result.paintStyles[control.paintStyleKey];
4947
- return style ? (control.bracketTexts ?? []).map((text) => ({
5077
+ return style ? controlBracketFrames(control, style).map((bracket) => ({
4948
5078
  fragment,
4949
- text,
4950
- style,
4951
- control
5079
+ bracket,
5080
+ style
4952
5081
  })) : [];
4953
5082
  });
4954
5083
  for (const side of ["start", "end"]) {
4955
- const bracket = side === "start" ? brackets.find((item) => item.text.text === "[") : [...brackets].reverse().find((item) => item.text.text === "]");
5084
+ const bracket = side === "start" ? brackets.find((item) => item.bracket.side === side) : [...brackets].reverse().find((item) => item.bracket.side === side);
4956
5085
  const fragment = bracket?.fragment ?? (side === "start" ? fragments[0] : fragments.at(-1));
4957
5086
  if (fragment?.kind !== "atom" || !fragment.fieldControl) continue;
4958
5087
  const pageId = snapshot.query.getFragmentPageId(fragment.id);
4959
5088
  const page = pageId && pages.get(pageId);
4960
5089
  const style = bracket?.style ?? snapshot.result.paintStyles[fragment.fieldControl.paintStyleKey];
4961
5090
  if (!page || !style) continue;
4962
- const height = style.fontSizePx + 1;
4963
- const width = bracket ? Math.max(3, bracket.text.width) : 4;
4964
- const rect = inputScreenRect({
4965
- x: fragment.frame.x + (bracket ? bracket.text.x : side === "start" ? -width : fragment.frame.width),
4966
- y: fragment.frame.y + (bracket ? bracket.text.baseline - style.fontSizePx * .8 - .5 : 0),
4967
- width,
4968
- height: bracket ? height : fragment.frame.height
5091
+ const rect = inputScreenRect(bracket ? {
5092
+ ...bracket.bracket.frame,
5093
+ x: fragment.frame.x + bracket.bracket.frame.x,
5094
+ y: fragment.frame.y + bracket.bracket.frame.y
5095
+ } : {
5096
+ x: fragment.frame.x + (side === "start" ? -4 : fragment.frame.width),
5097
+ y: fragment.frame.y,
5098
+ width: 4,
5099
+ height: fragment.frame.height
4969
5100
  }, page);
4970
5101
  const screen = clipInputRect(rect, clip);
4971
5102
  if (!screen) continue;
@@ -4987,9 +5118,9 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
4987
5118
  height: "100%",
4988
5119
  boxSizing: "border-box",
4989
5120
  color: fragment.fieldControl.decoration?.markerColor ?? style.color,
4990
- borderTop: "1px solid currentColor",
4991
- borderBottom: "1px solid currentColor",
4992
- ...side === "start" ? { borderLeft: "1px solid currentColor" } : { borderRight: "1px solid currentColor" }
5121
+ borderTop: "2px solid currentColor",
5122
+ borderBottom: "2px solid currentColor",
5123
+ ...side === "start" ? { borderLeft: "2px solid currentColor" } : { borderRight: "2px solid currentColor" }
4993
5124
  });
4994
5125
  node.append(stroke);
4995
5126
  children.push(node);
@@ -5093,6 +5224,72 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
5093
5224
  layer.replaceChildren(...children);
5094
5225
  return state.composition ? typingScreen : screen;
5095
5226
  }
5227
+ // src/runtime/interaction/editor-diagnostic.ts
5228
+ /** @file 从异常读取稳定的诊断代码,界面决定如何显示,不传递调试路径和原始描述。 */
5229
+ /** 未识别的外部异常由调用者决定如何兜底。 */
5230
+ function readEditorDiagnostic(error) {
5231
+ if (error instanceof DocumentValidationError) return {
5232
+ kind: "validation",
5233
+ codes: error.issues.map(({ code }) => code)
5234
+ };
5235
+ if (error instanceof ModelEditError) return {
5236
+ kind: "model",
5237
+ code: error.code
5238
+ };
5239
+ }
5240
+ // src/adapters/browser/input/word-error-text.ts
5241
+ /** @file 把 Word 可识别的失败转换为可展示的中文,原始异常仍留给宿主诊断。 */
5242
+ /** 编辑器可以明确告诉用户如何修正的模型错误。 */
5243
+ var modelMessages = {
5244
+ table_merge: "请选择完整的单元格矩形,已有合并格需完整包含",
5245
+ table_range: "请选择同一张表内的有效单元格范围",
5246
+ table_size: "请检查表格的行列数量和列宽",
5247
+ table_region: "当前操作会影响表格的区域设置,请先检查选区",
5248
+ range: "操作范围或数量无效,请检查选区和输入值",
5249
+ content_flow: "当前选区跨越了不同内容区域,请重新选择"
5250
+ };
5251
+ /** 文档结构和属性校验的中文提示,合并相同原因。 */
5252
+ var validationMessages = {
5253
+ nested_table: "当前位置不允许插入嵌套表格",
5254
+ number: "请输入有效的数值,宽度和高度须大于 0,内边距和边框宽度可为 0",
5255
+ enum: "当前设置值不可用,请重新选择",
5256
+ type: "输入值的格式不正确,请检查设置"
5257
+ };
5258
+ /** 识别已经适合展示的中文,结构化错误优先使用稳定的代码。 */
5259
+ function readWordErrorText(error) {
5260
+ const diagnostic = readEditorDiagnostic(error);
5261
+ if (diagnostic?.kind === "validation") {
5262
+ const messages = new Set(diagnostic.codes.flatMap((code) => Object.hasOwn(validationMessages, code) ? validationMessages[code] ?? [] : []));
5263
+ return messages.size ? [...messages].join("。") : void 0;
5264
+ }
5265
+ if (diagnostic?.kind === "model") return Object.hasOwn(modelMessages, diagnostic.code) ? modelMessages[diagnostic.code] : void 0;
5266
+ const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
5267
+ if (/^\p{Script=Han}[^\n]*$/u.test(message)) return message;
5268
+ }
5269
+ /** 模型校验和用户输入错误用警告,其余未知故障由界面使用错误提示。 */
5270
+ function isWordValidationError(error) {
5271
+ const diagnostic = readEditorDiagnostic(error);
5272
+ return diagnostic?.kind === "validation" || diagnostic?.kind === "model" && Object.hasOwn(modelMessages, diagnostic.code);
5273
+ }
5274
+ /** 主动取消和已撤销的请求属于正常清理,不需要用户处理。 */
5275
+ function isWordCancellation(error) {
5276
+ return !!error && typeof error === "object" && "name" in error && error.name === "AbortError";
5277
+ }
5278
+ /** 隐藏的备用面板不能接管当前用户看不到的反馈。 */
5279
+ function hasLocalWordFeedback(node) {
5280
+ return !!node?.isConnected && !node.closest("[hidden]");
5281
+ }
5282
+ /** 面板是当前操作的反馈位置,已有全局回调也不撤掉局部错误。 */
5283
+ function wordPanelErrorText(error, fallback) {
5284
+ return isWordCancellation(error) ? "" : readWordErrorText(error) ?? fallback;
5285
+ }
5286
+ /** 已显示在当前弹框/面板的错误就地消化,缺少局部位置才交给宿主。 */
5287
+ function reportUnhandledWordError(error, handled, report) {
5288
+ if (handled || isWordCancellation(error)) return;
5289
+ try {
5290
+ report?.(error);
5291
+ } catch {}
5292
+ }
5096
5293
  // src/adapters/browser/input/InlineFieldInput.ts
5097
5294
  /** @file 单个活动文本/数字字段的无边框原位编辑,候选与未完成数字只存在当前 DOM 草稿。 */
5098
5295
  /** 一份 DOM 输入支持当前字段,切换字段、关闭或外部换值后撤销旧事件。 */
@@ -5639,11 +5836,10 @@ var InlineFieldInput = class {
5639
5836
  } catch (error) {
5640
5837
  this.writeBlocked = true;
5641
5838
  this.draftChecked = true;
5642
- this.failure = error instanceof Error && error.name === "FieldNumberError" ? error.message : active.base.widget === "number" ? "请输入完整有效的数字" : "当前内容未能保存,请检查输入";
5839
+ this.failure = error instanceof Error && error.name === "FieldNumberError" ? error.message : active.base.widget === "number" ? "请输入完整有效的数字" : readWordErrorText(error) ?? "当前内容未能保存,请检查输入";
5643
5840
  input.setCustomValidity(this.failure);
5644
5841
  input.setAttribute("aria-invalid", "true");
5645
5842
  this.refresh();
5646
- if (active.base.widget !== "number") this.fail(error);
5647
5843
  return false;
5648
5844
  } finally {
5649
5845
  this.writing = false;
@@ -5673,7 +5869,7 @@ var InlineFieldInput = class {
5673
5869
  const message = this.message ??= owner.createElement("div");
5674
5870
  if (!message.parentElement) {
5675
5871
  message.className = "gct-word-field-input-message";
5676
- message.id = `gct-word-field-message-${crypto.randomUUID()}`;
5872
+ message.id = `gct-word-field-message-${createUuid()}`;
5677
5873
  message.setAttribute("role", "alert");
5678
5874
  owner.body.append(message);
5679
5875
  }
@@ -5867,6 +6063,8 @@ var SignatureFieldInput = class {
5867
6063
  restoreFocus;
5868
6064
  /** 同次激活的基值,换字段、外部值或配置改变后撤销。 */
5869
6065
  active;
6066
+ /** 尚未安装弹框的校验请求,关闭或切换时取消。 */
6067
+ opening;
5870
6068
  /** 当前 DOM 监听的取消边界。 */
5871
6069
  lifetime;
5872
6070
  /** 当前认证请求,关闭立即撤销,不排队重放。 */
@@ -5875,6 +6073,8 @@ var SignatureFieldInput = class {
5875
6073
  pending = false;
5876
6074
  /** 服务发放的短期不透明预览,不进入持久化数据。 */
5877
6075
  draft;
6076
+ completed = false;
6077
+ closeTimer;
5878
6078
  /** 共用弹框只持有本次签署界面。 */
5879
6079
  dialog;
5880
6080
  view;
@@ -5890,6 +6090,7 @@ var SignatureFieldInput = class {
5890
6090
  writing = false;
5891
6091
  /** 认证、校验失败或取消的局部说明。 */
5892
6092
  message = "";
6093
+ messageKind = "status";
5893
6094
  /** 仅借用窄交互能力,不创建 DOM 或发起认证。 */
5894
6095
  constructor(options, restoreFocus) {
5895
6096
  this.options = options;
@@ -5897,22 +6098,69 @@ var SignatureFieldInput = class {
5897
6098
  }
5898
6099
  /** 点击真实可编辑签名时打开;查看/关闭本身不认证、不写值。 */
5899
6100
  open() {
5900
- const state = this.options?.controller.getFieldSignatureInput();
5901
- if (!state || !state.editable && !state.pending) return false;
6101
+ const options = this.options;
6102
+ const state = options?.controller.getFieldSignatureInput();
6103
+ if (!options || !state || !state.editable && !state.pending) return false;
5902
6104
  if (this.active?.selection === state.selection && sameFieldSignatureInput(state, this.active)) {
5903
6105
  this.refresh();
5904
6106
  return true;
5905
6107
  }
5906
6108
  this.close();
5907
6109
  this.active = state;
6110
+ if (state.records.length || state.invalid) {
6111
+ this.install();
6112
+ this.refresh();
6113
+ this.dialog?.focus();
6114
+ return true;
6115
+ }
6116
+ const task = new AbortController();
6117
+ this.opening = task;
6118
+ if (state.pending) options.controller.whenFieldSettled(task.signal).then(() => this.startOpening(options, state, task)).catch((error) => this.failOpening(options, state, task, error));
6119
+ else this.startOpening(options, state, task);
6120
+ return true;
6121
+ }
6122
+ ownsOpening(options, state, task) {
6123
+ return this.options === options && this.active === state && this.opening === task && !task.signal.aborted;
6124
+ }
6125
+ startOpening(options, state, task) {
6126
+ if (!this.ownsOpening(options, state, task)) return;
6127
+ this.refresh();
6128
+ if (!this.ownsOpening(options, state, task)) return;
6129
+ try {
6130
+ const checking = options.controller.validateFieldSignature(state, task.signal);
6131
+ if (checking) checking.then(() => this.finishOpening(options, state, task)).catch((error) => this.failOpening(options, state, task, error));
6132
+ else this.finishOpening(options, state, task);
6133
+ } catch (error) {
6134
+ this.failOpening(options, state, task, error);
6135
+ }
6136
+ }
6137
+ finishOpening(options, state, task) {
6138
+ if (!this.ownsOpening(options, state, task)) return;
6139
+ const current = options.controller.getFieldSignatureInput();
6140
+ if (!current || !sameFieldSignatureInput(current, state) || !current.editable || current.pending || current.invalid) {
6141
+ this.close();
6142
+ return;
6143
+ }
5908
6144
  this.install();
5909
6145
  this.refresh();
6146
+ if (!this.ownsOpening(options, state, task)) return;
6147
+ this.active = current;
6148
+ this.opening = void 0;
6149
+ task.abort();
5910
6150
  this.dialog?.focus();
5911
- return true;
6151
+ }
6152
+ failOpening(options, state, task, error) {
6153
+ if (!this.ownsOpening(options, state, task)) return;
6154
+ this.refresh();
6155
+ if (!this.ownsOpening(options, state, task)) return;
6156
+ this.close();
6157
+ try {
6158
+ options.onError?.(error);
6159
+ } catch {}
5912
6160
  }
5913
6161
  /** 保存前不能忽略尚未完成的认证或已认证但未确认的预览。 */
5914
6162
  canSubmit() {
5915
- return !this.pending && !this.draft;
6163
+ return !this.opening && !this.pending && !this.draft;
5916
6164
  }
5917
6165
  /** 只复核当前业务发生,不依赖旧字段坐标;认证弹框转移焦点不会自动取消。 */
5918
6166
  refresh() {
@@ -5925,28 +6173,36 @@ var SignatureFieldInput = class {
5925
6173
  this.close();
5926
6174
  return;
5927
6175
  }
5928
- if (!current || !sameFieldSignatureInput(current, active) || !current.editable && !current.pending) {
6176
+ if (!current || !sameFieldSignatureInput(current, active) || !this.completed && !current.editable && !current.pending) {
5929
6177
  this.close();
5930
6178
  return;
5931
6179
  }
5932
- const busy = this.pending || current.pending, disabled = busy || !current.editable || current.invalid;
6180
+ const busy = this.pending || current.pending, disabled = busy || this.completed || !current.editable || current.invalid;
5933
6181
  if (this.authorizeButton) this.authorizeButton.disabled = disabled || !!this.draft || !current.multiple && !!current.records.length;
5934
6182
  if (this.confirmButton) this.confirmButton.disabled = disabled || !this.draft;
5935
6183
  for (const button of this.removeButtons) button.disabled = disabled || !!this.draft;
5936
6184
  this.dialog?.content.setAttribute("aria-busy", String(busy));
5937
6185
  this.view?.update({
6186
+ appearance: current.appearance,
5938
6187
  records: current.records,
5939
6188
  draft: this.draft,
5940
6189
  busy,
5941
6190
  canAuthorize: !disabled && !this.draft && (current.multiple || !current.records.length),
5942
6191
  canConfirm: !disabled && !!this.draft,
5943
6192
  canRemove: !disabled && !this.draft,
5944
- message: current.invalid ? "签名值格式异常,原值已保留" : this.message
6193
+ completed: this.completed,
6194
+ message: current.invalid ? "签名值格式异常,原值已保留" : this.message,
6195
+ messageKind: current.invalid ? "error" : this.messageKind
5945
6196
  });
5946
6197
  if (this.status) this.status.textContent = current.invalid ? "签名值格式异常,原值已保留" : this.message || (current.pending ? "正在准备字段规则…" : "点击签署进行认证,认证通过后确认保存。");
5947
6198
  }
5948
6199
  /** 先撤销旧事件与认证,再丢弃预览;取消不会删除已经保存的记录。 */
5949
6200
  close(restore = false) {
6201
+ clearTimeout(this.closeTimer);
6202
+ this.closeTimer = void 0;
6203
+ this.completed = false;
6204
+ this.opening?.abort();
6205
+ this.opening = void 0;
5950
6206
  this.active = void 0;
5951
6207
  this.lifetime?.abort();
5952
6208
  this.lifetime = void 0;
@@ -5964,6 +6220,7 @@ var SignatureFieldInput = class {
5964
6220
  this.confirmButton = void 0;
5965
6221
  this.removeButtons = [];
5966
6222
  this.message = "";
6223
+ this.messageKind = "status";
5967
6224
  if (restore) this.restoreFocus?.();
5968
6225
  }
5969
6226
  /** 幂等释放所有临时 DOM、等待和外部能力,不关闭借用的文档或认证服务。 */
@@ -5984,6 +6241,7 @@ var SignatureFieldInput = class {
5984
6241
  this.view = this.options.renderSignaturePanel({
5985
6242
  container: dialog.content,
5986
6243
  state: {
6244
+ appearance: this.active.appearance,
5987
6245
  records: this.active.records,
5988
6246
  busy: false,
5989
6247
  canAuthorize: false,
@@ -6043,11 +6301,12 @@ var SignatureFieldInput = class {
6043
6301
  async authorize(authorization) {
6044
6302
  this.refresh();
6045
6303
  const options = this.options, active = this.active;
6046
- if (!options || !active || this.pending || this.draft || this.authorizeButton?.disabled) return;
6304
+ if (!options || !active || this.pending || this.draft || this.completed || this.authorizeButton?.disabled) return;
6047
6305
  const task = new AbortController();
6048
6306
  this.authentication = task;
6049
6307
  this.pending = true;
6050
6308
  this.message = "正在等待签署认证…";
6309
+ this.messageKind = "status";
6051
6310
  this.refresh();
6052
6311
  try {
6053
6312
  const draft = await options.controller.prepareFieldSignature(active, task.signal, ...authorization ? [authorization] : []);
@@ -6057,6 +6316,10 @@ var SignatureFieldInput = class {
6057
6316
  }
6058
6317
  this.draft = draft;
6059
6318
  this.message = draft ? `已认证:${signatureSummary(draft.username, draft.time)}\n尚未保存,请确认。` : "已取消认证,原有签名未改变。";
6319
+ if (draft && authorization?.method === "CARD") {
6320
+ this.pending = false;
6321
+ this.save(2e3);
6322
+ }
6060
6323
  } catch (error) {
6061
6324
  if (!task.signal.aborted && this.active === active) this.fail(error);
6062
6325
  } finally {
@@ -6072,7 +6335,7 @@ var SignatureFieldInput = class {
6072
6335
  }
6073
6336
  }
6074
6337
  /** 明确确认后只提交服务发放的凭据;互斥失败仍保留原值并显示原因。 */
6075
- save() {
6338
+ save(closeDelayMs = 0) {
6076
6339
  this.refresh();
6077
6340
  const options = this.options, active = this.active, draft = this.draft;
6078
6341
  if (!options || !active || !draft || this.pending || this.confirmButton?.disabled) return;
@@ -6080,8 +6343,19 @@ var SignatureFieldInput = class {
6080
6343
  try {
6081
6344
  if (!options.controller.commitFieldSignature(draft, active)) throw new Error("签名未能保存");
6082
6345
  this.draft = void 0;
6083
- this.close(true);
6346
+ const current = options.controller.getFieldSignatureInput();
6347
+ if (closeDelayMs && current) {
6348
+ this.active = current;
6349
+ this.completed = true;
6350
+ this.message = "签名成功";
6351
+ this.messageKind = "status";
6352
+ this.closeTimer = setTimeout(() => this.close(true), closeDelayMs);
6353
+ } else this.close(true);
6084
6354
  } catch (error) {
6355
+ if (closeDelayMs) {
6356
+ options.controller.discardFieldSignature(draft);
6357
+ this.draft = void 0;
6358
+ }
6085
6359
  this.fail(error);
6086
6360
  } finally {
6087
6361
  this.writing = false;
@@ -6104,13 +6378,11 @@ var SignatureFieldInput = class {
6104
6378
  this.refresh();
6105
6379
  }
6106
6380
  }
6107
- /** 错误只进入当前面板及宿主反馈,不将认证凭据或完整记录写到页面。 */
6381
+ /** 签名错误由当前弹框展示,不再交给工作区重复显示。 */
6108
6382
  fail(error) {
6109
6383
  this.message = error instanceof Error ? error.message : "签名操作失败";
6384
+ this.messageKind = "error";
6110
6385
  this.refresh();
6111
- try {
6112
- this.options?.onError?.(error);
6113
- } catch {}
6114
6386
  }
6115
6387
  };
6116
6388
  // src/adapters/browser/input/CanvasTextInput.ts
@@ -7213,7 +7485,7 @@ var CanvasQuickFillDialog = class {
7213
7485
  const opening = new AbortController();
7214
7486
  this.opening = opening;
7215
7487
  try {
7216
- if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("快速填报已取消"))) throw Error("请先确认或取消当前输入");
7488
+ if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("快速填报已取消"))) return;
7217
7489
  if (opening.signal.aborted || this.options !== options) return;
7218
7490
  const source = options.controller.businessTables.readQuickFill(expected.regionId, expected.anchorInstanceKey);
7219
7491
  if (!source?.enabled || !isEqual(source.selection, expected.selection) || !isEqual(source.occurrence, expected.occurrence)) throw Error("当前行或快速填报规则已变化,请重新操作");
@@ -7438,11 +7710,9 @@ var CanvasQuickFillDialog = class {
7438
7710
  }
7439
7711
  /** 只保留可读错误文字,异常反馈不影响取消与释放。 */
7440
7712
  report(error) {
7441
- this.message = error instanceof Error ? error.message : String(error);
7713
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
7442
7714
  if (this.status) this.status.textContent = this.message;
7443
- try {
7444
- this.options?.onError?.(error);
7445
- } catch {}
7715
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
7446
7716
  }
7447
7717
  };
7448
7718
  // src/adapters/browser/input/business/tables/CanvasTableScanDialog.ts
@@ -7509,7 +7779,7 @@ var CanvasTableScanDialog = class {
7509
7779
  const opening = new AbortController();
7510
7780
  this.opening = opening;
7511
7781
  try {
7512
- if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("扫码打开已取消"))) throw Error("请先确认或取消当前输入");
7782
+ if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("扫码打开已取消"))) return;
7513
7783
  if (opening.signal.aborted || this.options !== options) return;
7514
7784
  const source = options.controller.businessTables.readScan(expected.regionId, expected.anchorInstanceKey);
7515
7785
  if (!source?.enabled || source.sessionId !== expected.sessionId || source.documentId !== expected.documentId || !isEqual(source.selection, expected.selection) || !isEqual(source.occurrence, expected.occurrence)) throw Error("当前业务表或扫码来源已变化");
@@ -7762,8 +8032,8 @@ var CanvasTableScanDialog = class {
7762
8032
  }
7763
8033
  /** 仅保留文字供修正,来源对象和异常链不会进入草稿。 */
7764
8034
  report(error) {
7765
- this.message = error instanceof Error ? error.message : String(error);
7766
- this.notify(error);
8035
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
8036
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
7767
8037
  this.update();
7768
8038
  }
7769
8039
  };
@@ -7907,7 +8177,7 @@ var CanvasBusinessTablePanel = class {
7907
8177
  count.min = "1";
7908
8178
  count.max = String(nativeTableRowBatchLimit);
7909
8179
  count.step = "1";
7910
- count.disabled = !state.editable;
8180
+ count.disabled = !state.allowed.insert && !state.allowed.copy;
7911
8181
  count.value = this.countText;
7912
8182
  count.setAttribute("aria-label", "操作行数");
7913
8183
  count.style.width = "70px";
@@ -7971,7 +8241,7 @@ var CanvasBusinessTablePanel = class {
7971
8241
  try {
7972
8242
  const count = Number(this.countText);
7973
8243
  if (operation !== "remove" && (!Number.isSafeInteger(count) || count < 1 || count > 1e3)) throw Error(`行数必须是 1–${nativeTableRowBatchLimit} 的整数`);
7974
- if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(task.signal)), task.signal, () => Error("业务表操作已取消"))) throw Error("请先确认或取消当前输入");
8244
+ if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(task.signal)), task.signal, () => Error("业务表操作已取消"))) return;
7975
8245
  if (task.signal.aborted || this.options !== options) return;
7976
8246
  const api = options.controller.businessTables, current = api.read(expected.regionId);
7977
8247
  if (!current || !isEqual(current.version, expected.version) || !isEqual(current.selection, expected.selection) || !isEqual(current.occurrence, expected.occurrence)) throw Error("业务表或当前输入已变化,请重新操作");
@@ -7997,10 +8267,8 @@ var CanvasBusinessTablePanel = class {
7997
8267
  }
7998
8268
  /** 失败只保留可展示文字,外部反馈异常不能保留整个异常链。 */
7999
8269
  report(error) {
8000
- this.message = error instanceof Error ? error.message : String(error);
8001
- try {
8002
- this.options?.onError?.(error);
8003
- } catch {}
8270
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
8271
+ reportUnhandledWordError(error, !!this.state && hasLocalWordFeedback(this.root), this.options?.onError);
8004
8272
  if (!this.task) this.render();
8005
8273
  }
8006
8274
  };
@@ -8262,7 +8530,22 @@ var CanvasValidationPanel = class {
8262
8530
  if (this.displayEnabled) this.queueDisplay();
8263
8531
  else if (options.feedback) queueMicrotask(() => this.showLive());
8264
8532
  });
8265
- this.unsubscribeFeedback = options.feedback?.subscribe(() => this.showLive());
8533
+ this.unsubscribeFeedback = options.feedback?.subscribe((reason) => {
8534
+ if (reason === "check") {
8535
+ this.task?.abort();
8536
+ this.task = void 0;
8537
+ this.checking = false;
8538
+ this.inputValidation = void 0;
8539
+ this.inputFocus = void 0;
8540
+ this.displayEnabled = false;
8541
+ this.focusedDisplay = false;
8542
+ this.activeKey = void 0;
8543
+ this.opened = true;
8544
+ this.live = true;
8545
+ this.checkMode = "submit";
8546
+ }
8547
+ this.showLive();
8548
+ });
8266
8549
  this.unsubscribeSelection = options.controller.subscribe(() => this.syncActiveField());
8267
8550
  }
8268
8551
  /** 输入中只在字段旁提示;离开后使用独立批注栏,不覆盖其他字段。 */
@@ -8390,14 +8673,16 @@ var CanvasValidationPanel = class {
8390
8673
  } catch (error) {
8391
8674
  if (!this.current(task)) return;
8392
8675
  this.clear("本次校验未完成,请重试。");
8393
- options.onError?.(error);
8676
+ reportUnhandledWordError(error, hasLocalWordFeedback(options.host.querySelector("[role=\"status\"]") ?? void 0), options.onError);
8394
8677
  } finally {
8395
- this.checking = false;
8396
- if (this.inputValidation) {
8397
- this.live = true;
8398
- this.showLive();
8678
+ if (this.task === task) {
8679
+ this.checking = false;
8680
+ if (this.inputValidation) {
8681
+ this.live = true;
8682
+ this.showLive();
8683
+ }
8684
+ this.end(task);
8399
8685
  }
8400
- this.end(task);
8401
8686
  }
8402
8687
  }
8403
8688
  /** Canvas 完成绘制后再映射标记,不触发排版、数据写入或整页重绘。 */
@@ -8477,7 +8762,10 @@ var CanvasValidationPanel = class {
8477
8762
  }
8478
8763
  this.setStatus("当前画面中没有可定位的对应位置。");
8479
8764
  } catch (error) {
8480
- if (this.current(task)) options.onError?.(error);
8765
+ if (this.current(task)) {
8766
+ this.setStatus(wordPanelErrorText(error, "当前无法定位,请重试。"));
8767
+ reportUnhandledWordError(error, hasLocalWordFeedback(options.host.querySelector("[role=\"status\"]") ?? void 0), options.onError);
8768
+ }
8481
8769
  } finally {
8482
8770
  this.end(task);
8483
8771
  }
@@ -9238,7 +9526,7 @@ var CanvasFieldDrag = class {
9238
9526
  const binding = source.binding;
9239
9527
  const identity = {
9240
9528
  source,
9241
- token: crypto.randomUUID()
9529
+ token: createUuid()
9242
9530
  };
9243
9531
  let active;
9244
9532
  switch (binding.kind) {
@@ -9878,7 +10166,7 @@ var ChoiceOptionsPanel = class {
9878
10166
  const state = options.read();
9879
10167
  options.fields.appendOption(state, {
9880
10168
  label: "新选项",
9881
- value: `option-${crypto.randomUUID()}`
10169
+ value: `option-${createUuid()}`
9882
10170
  });
9883
10171
  });
9884
10172
  root.append(add);
@@ -10259,58 +10547,6 @@ var FieldAttachmentsPanel = class {
10259
10547
  this.options = void 0;
10260
10548
  }
10261
10549
  };
10262
- // src/runtime/interaction/editor-diagnostic.ts
10263
- /** @file 从异常读取稳定的诊断代码,界面决定如何显示,不传递调试路径和原始描述。 */
10264
- /** 未识别的外部异常由调用者决定如何兜底。 */
10265
- function readEditorDiagnostic(error) {
10266
- if (error instanceof DocumentValidationError) return {
10267
- kind: "validation",
10268
- codes: error.issues.map(({ code }) => code)
10269
- };
10270
- if (error instanceof ModelEditError) return {
10271
- kind: "model",
10272
- code: error.code
10273
- };
10274
- }
10275
- // src/adapters/browser/input/word-error-text.ts
10276
- /** @file 把 Word 可识别的失败转换为可展示的中文,原始异常仍留给宿主诊断。 */
10277
- /** 编辑器可以明确告诉用户如何修正的模型错误。 */
10278
- var modelMessages = {
10279
- table_merge: "请选择完整的单元格矩形,已有合并格需完整包含",
10280
- table_range: "请选择同一张表内的有效单元格范围",
10281
- table_size: "请检查表格的行列数量和列宽",
10282
- table_region: "当前操作会影响表格的区域设置,请先检查选区",
10283
- range: "操作范围或数量无效,请检查选区和输入值",
10284
- content_flow: "当前选区跨越了不同内容区域,请重新选择"
10285
- };
10286
- /** 文档结构和属性校验的中文提示,合并相同原因。 */
10287
- var validationMessages = {
10288
- nested_table: "当前位置不允许插入嵌套表格",
10289
- number: "请输入有效的数值,宽度和高度须大于 0,内边距和边框宽度可为 0",
10290
- enum: "当前设置值不可用,请重新选择",
10291
- type: "输入值的格式不正确,请检查设置"
10292
- };
10293
- /** 识别已经适合展示的中文,结构化错误优先使用稳定的代码。 */
10294
- function readWordErrorText(error) {
10295
- const diagnostic = readEditorDiagnostic(error);
10296
- if (diagnostic?.kind === "validation") {
10297
- const messages = new Set(diagnostic.codes.flatMap((code) => Object.hasOwn(validationMessages, code) ? validationMessages[code] ?? [] : []));
10298
- return messages.size ? [...messages].join("。") : void 0;
10299
- }
10300
- if (diagnostic?.kind === "model") return Object.hasOwn(modelMessages, diagnostic.code) ? modelMessages[diagnostic.code] : void 0;
10301
- const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
10302
- if (/^\p{Script=Han}[^\n]*$/u.test(message)) return message;
10303
- }
10304
- /** 模型校验和用户输入错误用警告,其余未知故障由界面使用错误提示。 */
10305
- function isWordValidationError(error) {
10306
- const diagnostic = readEditorDiagnostic(error);
10307
- return diagnostic?.kind === "validation" || diagnostic?.kind === "model" && Object.hasOwn(modelMessages, diagnostic.code);
10308
- }
10309
- /** 已交给宿主弹框的异常不重复写入行内,只保留可直接修改的中文状态。 */
10310
- function wordPanelErrorText(error, reportsError, fallback) {
10311
- if (reportsError && isWordValidationError(error)) return "";
10312
- return readWordErrorText(error) ?? (reportsError ? "" : fallback);
10313
- }
10314
10550
  // src/adapters/browser/input/design/settings/builders.ts
10315
10551
  /** 用户明确新增设置时生成必需值,未展开的可选属性保持缺省。 */
10316
10552
  function initialSettingValue(setting) {
@@ -10394,7 +10630,7 @@ function id() {
10394
10630
  key: "id",
10395
10631
  label: "规则 ID",
10396
10632
  kind: "id",
10397
- initial: () => crypto.randomUUID()
10633
+ initial: () => createUuid()
10398
10634
  };
10399
10635
  }
10400
10636
  /** 外部业务目标不要求已放入画布,也不引用运行时行索引。 */
@@ -10417,7 +10653,12 @@ var dependencies = listSetting("dependencies", "字段联动", objectSetting("",
10417
10653
  ], false),
10418
10654
  textSetting("expression", "表达式"),
10419
10655
  textSetting("expressionLabel", "表达式说明"),
10420
- enumSetting("strategy", "赋值覆盖策略", ["alwaysCover", "notCovered"]),
10656
+ enumSetting("assignmentType", "赋值类型", ["formula", "clear"]),
10657
+ enumSetting("strategy", "赋值覆盖策略", [
10658
+ "alwaysCover",
10659
+ "notCovered",
10660
+ "notCoveredForever"
10661
+ ]),
10421
10662
  booleanSetting("value", "固定真假值")
10422
10663
  ], false));
10423
10664
  /** 范围端点显式切换 none/fixed/expression,避免同时留下互斥参数。 */
@@ -10769,8 +11010,11 @@ var StructuredSettingsPanel = class {
10769
11010
  disabled: "禁用",
10770
11011
  required: "必填",
10771
11012
  assignment: "赋值",
11013
+ formula: "公式计算",
11014
+ clear: "清空",
10772
11015
  alwaysCover: "始终覆盖",
10773
- notCovered: "仅未初始化时赋值",
11016
+ notCovered: "不覆盖已修改(本次编辑有效)",
11017
+ notCoveredForever: "不覆盖已修改(永久有效)",
10774
11018
  ge: "大于或等于 ≥",
10775
11019
  gt: "大于 >",
10776
11020
  le: "小于或等于 ≤",
@@ -11057,8 +11301,8 @@ var CanvasFieldDesignPanel = class {
11057
11301
  if (state.status === "ready") for (const group of state.groups) for (const field of group.fields) {
11058
11302
  if (field.definition.widget !== this.state?.widget) continue;
11059
11303
  const option = owner.createElement("option");
11060
- let token = `catalog:${crypto.randomUUID()}`;
11061
- while ([...select.options].some((item) => item.value === token)) token = `catalog:${crypto.randomUUID()}`;
11304
+ let token = `catalog:${createUuid()}`;
11305
+ while ([...select.options].some((item) => item.value === token)) token = `catalog:${createUuid()}`;
11062
11306
  option.value = token;
11063
11307
  option.textContent = `${group.label} · ${field.label} · ${field.definition.binding.source.subFieldKey ? "子表" : "主表"}`;
11064
11308
  catalogFields.set(token, field);
@@ -11148,10 +11392,8 @@ var CanvasFieldDesignPanel = class {
11148
11392
  this.reload();
11149
11393
  } catch (error) {
11150
11394
  this.writing = false;
11151
- if (this.status) this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "字段设置未完成,请重试");
11152
- try {
11153
- this.options?.onError?.(error);
11154
- } catch {}
11395
+ if (this.status) this.status.textContent = wordPanelErrorText(error, "字段设置未完成,请重试");
11396
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
11155
11397
  }
11156
11398
  }
11157
11399
  /** 移除订阅、全部事件和配置引用;旧侧栏节点不继续持有文档。 */
@@ -11580,10 +11822,8 @@ var CanvasFormatPanel = class {
11580
11822
  }
11581
11823
  /** 错误不回滚已提交事务,也不能使外部反馈产生未处理异常。 */
11582
11824
  report(error) {
11583
- if (this.status) this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "格式设置未完成,请重试");
11584
- try {
11585
- this.options?.onError?.(error);
11586
- } catch {}
11825
+ if (this.status) this.status.textContent = wordPanelErrorText(error, "格式设置未完成,请重试");
11826
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
11587
11827
  }
11588
11828
  /** 解除订阅和所有事件,保留旧输入、按钮或解除函数都不能反向保留文档。 */
11589
11829
  dispose() {
@@ -12173,12 +12413,10 @@ var CanvasFieldCatalogPanel = class {
12173
12413
  /** 目录失败不改变模板,也不把异常对象保存到面板状态。 */
12174
12414
  report(error) {
12175
12415
  if (this.status) {
12176
- this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "字段目录加载失败,请重试");
12416
+ this.status.textContent = wordPanelErrorText(error, "字段目录加载失败,请重试");
12177
12417
  this.status.hidden = !this.status.textContent;
12178
12418
  }
12179
- try {
12180
- this.options?.onError?.(error);
12181
- } catch {}
12419
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
12182
12420
  }
12183
12421
  /** 解除目录/控制器订阅、等待、拖入来源、DOM 和外部回调。 */
12184
12422
  dispose() {
@@ -12506,10 +12744,8 @@ var CanvasTableDesignPanel = class {
12506
12744
  if (this.status) this.status.textContent = error.message;
12507
12745
  return;
12508
12746
  }
12509
- if (this.status && !this.options.onError) this.status.textContent = readWordErrorText(error) ?? "表格操作未完成,请重试";
12510
- try {
12511
- this.options?.onError?.(error);
12512
- } catch {}
12747
+ if (this.status) this.status.textContent = readWordErrorText(error) ?? "表格操作未完成,请重试";
12748
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
12513
12749
  }
12514
12750
  }
12515
12751
  /** 关闭撤销旧按钮、旧控件和订阅,旧面板不继续持有文档。 */
@@ -12602,7 +12838,7 @@ function regionMetadataForm(options) {
12602
12838
  name.disabled = useDefault.checked;
12603
12839
  const path = text("区域数据路径", state?.binding?.pathTemplate ?? "");
12604
12840
  path.placeholder = "例如 $.items 或 $.checks:samples";
12605
- const parent = select("所属父区域"), target = select("关联业务区域"), variant = select("业务类型");
12841
+ const parent = select("所属父区域"), target = select("关联表格区域"), variant = select("业务类型");
12606
12842
  /** 根据真实类型切换可用关系,不默认选中任意父区域或关联主体。 */
12607
12843
  const updateType = () => {
12608
12844
  const selected = type.value, definition = designRegionTypes.find((item) => item.type === selected), parentKind = selected === "bounded-item" ? "bounded" : selected === "data-group-2d" ? "matrix" : void 0, parentValue = parent.value || state?.parentRegionId || "", targetValue = target.value || state?.targetRegionId || "", variantValue = variant.value || state?.variant?.name || options.preset?.variantName || "";
@@ -12639,7 +12875,7 @@ function regionMetadataForm(options) {
12639
12875
  form.append(hint);
12640
12876
  const apply = owner.createElement("button");
12641
12877
  apply.type = "button";
12642
- apply.textContent = state ? "应用区域类型与来源" : "创建业务区域";
12878
+ apply.textContent = state ? "应用区域类型与来源" : "创建表格区域";
12643
12879
  apply.addEventListener("click", () => {
12644
12880
  const typeValue = type.value, definition = designRegionTypes.find((item) => item.type === typeValue);
12645
12881
  options.apply({
@@ -12818,7 +13054,7 @@ var CanvasRegionDesignPanel = class {
12818
13054
  constructor(options) {
12819
13055
  this.options = options;
12820
13056
  this.root = options.host.ownerDocument.createElement("section");
12821
- this.root.setAttribute("aria-label", "业务区域设计");
13057
+ this.root.setAttribute("aria-label", "表格区域设计");
12822
13058
  options.host.append(this.root);
12823
13059
  try {
12824
13060
  this.unsubscribe = options.controller.subscribe(() => this.refresh());
@@ -12847,7 +13083,7 @@ var CanvasRegionDesignPanel = class {
12847
13083
  if (this.dirty) {
12848
13084
  this.stale = true;
12849
13085
  if (this.form) this.form.disabled = true;
12850
- if (this.status) this.status.textContent = "表格、区域或选区已变化,草稿已保留;请重新加载业务区域。";
13086
+ if (this.status) this.status.textContent = "表格、区域或选区已变化,草稿已保留;请重新加载表格区域。";
12851
13087
  return;
12852
13088
  }
12853
13089
  if (table && this.table && isEqual(items, this.items) && isEqual({
@@ -12877,7 +13113,7 @@ var CanvasRegionDesignPanel = class {
12877
13113
  }
12878
13114
  /** 工具栏打开新建表单时保护已编辑的草稿,不直接创建模型节点。 */
12879
13115
  startCreation(preset) {
12880
- if (this.dirty) throw Error("请先应用或放弃当前业务区域草稿。");
13116
+ if (this.dirty) throw Error("请先应用或放弃当前表格区域草稿。");
12881
13117
  if (!this.options?.controller.design.tables.readCurrent()?.editable) throw Error("请先选择可编辑的表格单元格。");
12882
13118
  this.regionId = void 0;
12883
13119
  this.preset = preset;
@@ -12921,21 +13157,21 @@ var CanvasRegionDesignPanel = class {
12921
13157
  const root = this.root, table = this.table, options = this.options, owner = root.ownerDocument;
12922
13158
  options.onRegionChange?.();
12923
13159
  if (!table) {
12924
- root.textContent = "先点击表格或选择物理格范围,再创建和配置业务区域。";
13160
+ root.textContent = "先点击表格或选择物理格范围,再创建和配置表格区域。";
12925
13161
  return;
12926
13162
  }
12927
13163
  const heading = owner.createElement("h3"), status = owner.createElement("p"), form = owner.createElement("fieldset");
12928
- heading.textContent = "业务区域";
13164
+ heading.textContent = this.state ? designRegionLabel(this.state) : "表格区域";
12929
13165
  status.setAttribute("role", "status");
12930
13166
  status.textContent = `当前第 ${table.rectangle.top + 1}–${table.rectangle.bottom + 1} 行,第 ${table.rectangle.left + 1}–${table.rectangle.right + 1} 列。`;
12931
13167
  this.status = status;
12932
- root.append(heading, status, this.button("重新加载业务区域", () => this.reload(), void 0, true), form);
12933
- form.setAttribute("aria-label", "业务区域配置");
13168
+ root.append(heading, status, this.button("重新加载表格区域", () => this.reload(), void 0, true), form);
13169
+ form.setAttribute("aria-label", "表格区域配置");
12934
13170
  form.disabled = !table.editable;
12935
13171
  form.style.cssText = "border:0;padding:0;display:grid;gap:10px;min-width:0";
12936
13172
  this.form = form;
12937
13173
  const regions = options.controller.design.tables.regions, items = this.items, chooser = owner.createElement("select");
12938
- chooser.setAttribute("aria-label", "当前业务区域");
13174
+ chooser.setAttribute("aria-label", "当前表格区域");
12939
13175
  this.chooser = chooser;
12940
13176
  for (const [value, label] of [["", "新建区域"], ...items.map((item) => [item.regionId, regionItemLabel(item)])]) {
12941
13177
  const option = owner.createElement("option");
@@ -13088,10 +13324,8 @@ var CanvasRegionDesignPanel = class {
13088
13324
  this.reload();
13089
13325
  } catch (error) {
13090
13326
  this.writing = false;
13091
- if (this.status) this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "表格区域设置未完成,请重试");
13092
- try {
13093
- this.options?.onError?.(error);
13094
- } catch {}
13327
+ if (this.status) this.status.textContent = wordPanelErrorText(error, "表格区域设置未完成,请重试");
13328
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
13095
13329
  }
13096
13330
  }
13097
13331
  /** 关闭释放订阅、结构草稿及旧 DOM;保留面板/API 不继续拥有文档。 */
@@ -13424,10 +13658,8 @@ var CanvasMaterialsPanel = class {
13424
13658
  }
13425
13659
  /** 只保留错误文字,反馈异常不能阻止资源释放。 */
13426
13660
  report(error) {
13427
- this.message = error instanceof Error ? error.message : String(error);
13428
- try {
13429
- this.options?.onError?.(error);
13430
- } catch {}
13661
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
13662
+ reportUnhandledWordError(error, !!this.state && hasLocalWordFeedback(this.root), this.options?.onError);
13431
13663
  if (!this.task) this.render();
13432
13664
  }
13433
13665
  };
@@ -13697,7 +13929,7 @@ var CanvasBusinessTableActions = class {
13697
13929
  this.render();
13698
13930
  try {
13699
13931
  if (!Number.isSafeInteger(count) || count < 1 || count > 1e3) throw Error(`行数必须是 1–${nativeTableRowBatchLimit} 的整数`);
13700
- if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(task.signal)), task.signal, () => Error("业务表操作已取消"))) throw Error("请先确认或取消当前输入");
13932
+ if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(task.signal)), task.signal, () => Error("业务表操作已取消"))) return;
13701
13933
  if (task.signal.aborted || this.options !== options) return;
13702
13934
  const api = options.controller.businessTables, current = api.read(expected.regionId, expected.anchorInstanceKey);
13703
13935
  if (!current || !sameRowData(current, expected)) throw Error("业务行或当前输入已变化,请重新操作");
@@ -13740,10 +13972,8 @@ var CanvasBusinessTableActions = class {
13740
13972
  options.onApplied?.(result);
13741
13973
  } catch (error) {
13742
13974
  if (!task.signal.aborted && this.options === options) {
13743
- this.message = error instanceof Error ? error.message : "业务表操作失败";
13744
- try {
13745
- options.onError?.(error);
13746
- } catch {}
13975
+ this.message = wordPanelErrorText(error, "业务表操作未完成,请重试");
13976
+ reportUnhandledWordError(error, !!this.selected && !!this.view, options.onError);
13747
13977
  }
13748
13978
  } finally {
13749
13979
  this.writing = false;
@@ -14023,16 +14253,14 @@ var CanvasMaterialTableActions = class {
14023
14253
  this.render();
14024
14254
  }
14025
14255
  report(error) {
14026
- this.message = error instanceof Error ? error.message : String(error);
14256
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
14027
14257
  this.success = false;
14028
- try {
14029
- this.options?.onError?.(error);
14030
- } catch {}
14258
+ reportUnhandledWordError(error, !!this.selected && !!this.view, this.options?.onError);
14031
14259
  }
14032
14260
  };
14033
14261
  function sameRow(current, previous) {
14034
14262
  return !!current && current.sessionId === previous.sessionId && current.documentId === previous.documentId && current.regionId === previous.regionId && current.anchorInstanceKey === previous.anchorInstanceKey && current.rowIndex === previous.rowIndex && current.version.model === previous.version.model && current.version.data === previous.version.data && isEqual(current.selection, previous.selection) && isEqual(current.occurrence, previous.occurrence);
14035
14263
  }
14036
- export { revealInputRect as A, viewportClip as B, attachCanvasValidationPanel as C, CanvasTableScanDialog as D, CanvasBusinessTablePanel as E, inputPageLocation as F, NativeFontResources as G, loadBrowserImage as H, inputPointerRequest as I, CanvasTextMeasurer as J, NativeFontError as K, inputScreenPages as L, resourceFileIcon as M, openImageViewer as N, CanvasQuickFillDialog as O, clipInputRect as P, inputScreenRect as R, CanvasFieldDrag as S, attachCanvasBusinessTablePanel as T, CanvasImageResources as U, paintPage as V, layoutImages as W, applyCanvasTextStyle as Y, wordPanelErrorText as _, attachCanvasFieldDesignPanel as a, CanvasObjectHandles as b, attachCanvasTableDesignPanel as c, attachCanvasFieldCatalogPanel as d, CanvasFieldCatalogPanel as f, readWordErrorText as g, isWordValidationError as h, CanvasMaterialsPanel as i, ResourceFileSizes as j, CanvasTextInput as k, CanvasTableDesignPanel as l, CanvasFieldDesignPanel as m, CanvasBusinessTableActions as n, attachCanvasRegionDesignPanel as o, CanvasFormatPanel as p, browserAbortable as q, attachCanvasMaterialsPanel as r, CanvasRegionDesignPanel as s, CanvasMaterialTableActions as t, attachCanvasFormatPanel as u, fieldSettingControls as v, attachCanvasTextInput as w, attachCanvasFieldDrag as x, attachCanvasObjectHandles as y, CanvasPages as z };
14264
+ export { wordPanelErrorText as A, CanvasPages as B, CanvasBusinessTablePanel as C, isWordCancellation as D, CanvasTextInput as E, clipInputRect as F, CanvasImageResources as G, paintPage as H, inputPageLocation as I, NativeFontError as J, layoutImages as K, inputPointerRequest as L, ResourceFileSizes as M, resourceFileIcon as N, isWordValidationError as O, openImageViewer as P, inputScreenPages as R, attachCanvasBusinessTablePanel as S, CanvasQuickFillDialog as T, paintSignatureGraphic as U, viewportClip as V, loadBrowserImage as W, CanvasTextMeasurer as X, browserAbortable as Y, applyCanvasTextStyle as Z, CanvasObjectHandles as _, attachCanvasFieldDesignPanel as a, attachCanvasValidationPanel as b, attachCanvasTableDesignPanel as c, attachCanvasFieldCatalogPanel as d, CanvasFieldCatalogPanel as f, attachCanvasObjectHandles as g, fieldSettingControls as h, CanvasMaterialsPanel as i, revealInputRect as j, readWordErrorText as k, CanvasTableDesignPanel as l, CanvasFieldDesignPanel as m, CanvasBusinessTableActions as n, attachCanvasRegionDesignPanel as o, CanvasFormatPanel as p, NativeFontResources as q, attachCanvasMaterialsPanel as r, CanvasRegionDesignPanel as s, CanvasMaterialTableActions as t, attachCanvasFormatPanel as u, attachCanvasFieldDrag as v, CanvasTableScanDialog as w, attachCanvasTextInput as x, CanvasFieldDrag as y, inputScreenRect as z };
14037
14265
 
14038
- //# sourceMappingURL=browser-CP0ycXqN.js.map
14266
+ //# sourceMappingURL=browser-OAJIVM8O.js.map