@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.
Files changed (128) hide show
  1. package/README.md +20 -11
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{ModelEditor-CXoezurC.js → ModelEditor-DqavEAJg.js} +113 -4
  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-DY0wE3Uz.js → browser-OAJIVM8O.js} +412 -185
  8. package/dist/chunks/browser-OAJIVM8O.js.map +1 -0
  9. package/dist/chunks/legacy-template-converter-DFsd-elN.js +125 -0
  10. package/dist/chunks/legacy-template-converter-DFsd-elN.js.map +1 -0
  11. package/dist/chunks/migrate-YJTylIpz.js +5193 -0
  12. package/dist/chunks/migrate-YJTylIpz.js.map +1 -0
  13. package/dist/chunks/{sdk-Dz96Ca_-.js → sdk-BmwE5mZn.js} +1069 -615
  14. package/dist/chunks/sdk-BmwE5mZn.js.map +1 -0
  15. package/dist/chunks/src-BFXPGLus.js +3338 -0
  16. package/dist/chunks/src-BFXPGLus.js.map +1 -0
  17. package/dist/chunks/{table-borders-Dwuj7lFp.js → table-borders-B9bZMj5o.js} +2 -2
  18. package/dist/chunks/{table-borders-Dwuj7lFp.js.map → table-borders-B9bZMj5o.js.map} +1 -1
  19. package/dist/chunks/templates-Djcl21k4.js.map +1 -1
  20. package/dist/chunks/{types-Bq4hbWKT.js → types-CMkQ6Lvg.js} +122 -6
  21. package/dist/chunks/types-CMkQ6Lvg.js.map +1 -0
  22. package/dist/chunks/{NodeFactory-D9gVGSok.js → validation-DkCy8wHI.js} +10 -495
  23. package/dist/chunks/validation-DkCy8wHI.js.map +1 -0
  24. package/dist/docx.js +3 -2
  25. package/dist/docx.js.map +1 -1
  26. package/dist/index.js +6 -5
  27. package/dist/legacy.js +1 -0
  28. package/dist/platform.js +2 -2
  29. package/dist/style.css +760 -480
  30. package/dist/types/adapters/browser/canvas/CanvasPages.d.ts +1 -1
  31. package/dist/types/adapters/browser/canvas/paint-context.d.ts +4 -0
  32. package/dist/types/adapters/browser/canvas/paint-signature.d.ts +4 -0
  33. package/dist/types/adapters/browser/input/SignatureFieldInput.d.ts +10 -1
  34. package/dist/types/adapters/browser/input/signature-panel.d.ts +6 -0
  35. package/dist/types/adapters/browser/input/validation/CanvasValidationPanel.d.ts +1 -1
  36. package/dist/types/adapters/browser/input/word-error-text.d.ts +8 -2
  37. package/dist/types/adapters/platform/index.d.ts +1 -0
  38. package/dist/types/adapters/platform/templates.d.ts +11 -1
  39. package/dist/types/adapters/vue/GctWordPrintRenderer.vue.d.ts +1 -1
  40. package/dist/types/adapters/vue/GctWordTemplateDesigner.vue.d.ts +3 -0
  41. package/dist/types/adapters/vue/SignatureCardReader.vue.d.ts +1 -0
  42. package/dist/types/adapters/vue/SignatureVisual.vue.d.ts +10 -0
  43. package/dist/types/adapters/vue/WordFeedback.vue.d.ts +11 -0
  44. package/dist/types/adapters/vue/WordLayoutNotices.vue.d.ts +8 -0
  45. package/dist/types/adapters/vue/WordOperationError.vue.d.ts +11 -0
  46. package/dist/types/adapters/vue/field-properties/dependency-strategies.d.ts +7 -0
  47. package/dist/types/adapters/vue/index.d.ts +1 -0
  48. package/dist/types/adapters/vue/layout-notices.d.ts +15 -0
  49. package/dist/types/adapters/vue/legacy-template-converter.d.ts +14 -0
  50. package/dist/types/adapters/vue/region-properties/WordBusinessRegion.vue.d.ts +3 -0
  51. package/dist/types/adapters/vue/region-properties/WordDataLockConfig.vue.d.ts +16 -0
  52. package/dist/types/adapters/vue/useWordWorkspace.d.ts +6 -3
  53. package/dist/types/adapters/vue/word-feedback.d.ts +21 -0
  54. package/dist/types/data/DataManager.d.ts +2 -2
  55. package/dist/types/data/rows/copy-row.d.ts +5 -0
  56. package/dist/types/data/services/DataDependencies.d.ts +2 -2
  57. package/dist/types/data/types/manager.d.ts +2 -0
  58. package/dist/types/data/types/rules.d.ts +8 -1
  59. package/dist/types/import/legacy/autofill.d.ts +3 -0
  60. package/dist/types/import/legacy/bindings.d.ts +9 -0
  61. package/dist/types/import/legacy/boundary.d.ts +10 -0
  62. package/dist/types/import/legacy/business-fields.d.ts +25 -0
  63. package/dist/types/import/legacy/context.d.ts +61 -0
  64. package/dist/types/import/legacy/data-sources.d.ts +29 -0
  65. package/dist/types/import/legacy/document-rules.d.ts +38 -0
  66. package/dist/types/import/legacy/document-signature.d.ts +16 -0
  67. package/dist/types/import/legacy/fields.d.ts +34 -0
  68. package/dist/types/import/legacy/index.d.ts +3 -0
  69. package/dist/types/import/legacy/initialization.d.ts +34 -0
  70. package/dist/types/import/legacy/json-data.d.ts +25 -0
  71. package/dist/types/import/legacy/materials.d.ts +40 -0
  72. package/dist/types/import/legacy/media.d.ts +18 -0
  73. package/dist/types/import/legacy/metadata.d.ts +23 -0
  74. package/dist/types/import/legacy/migrate.d.ts +9 -0
  75. package/dist/types/import/legacy/page-widgets.d.ts +30 -0
  76. package/dist/types/import/legacy/relations.d.ts +25 -0
  77. package/dist/types/import/legacy/scalar-fields.d.ts +7 -0
  78. package/dist/types/import/legacy/styles.d.ts +52 -0
  79. package/dist/types/import/legacy/table-variants.d.ts +18 -0
  80. package/dist/types/import/legacy/tables.d.ts +27 -0
  81. package/dist/types/import/legacy/trace-fields.d.ts +21 -0
  82. package/dist/types/import/legacy/types.d.ts +141 -0
  83. package/dist/types/import/legacy/widget-presentation.d.ts +10 -0
  84. package/dist/types/layout/engine/atoms/control-text.d.ts +16 -0
  85. package/dist/types/layout/engine/atoms/field-control.d.ts +0 -13
  86. package/dist/types/layout/engine/atoms/signatures.d.ts +2 -2
  87. package/dist/types/layout/engine/blocks/placement-types.d.ts +7 -0
  88. package/dist/types/layout/engine/pagination/content-flow.d.ts +8 -0
  89. package/dist/types/layout/engine/tables/place-table-window.d.ts +3 -2
  90. package/dist/types/layout/engine/tables/row-flow.d.ts +3 -2
  91. package/dist/types/layout/engine/tables/table-flow.d.ts +3 -1
  92. package/dist/types/layout/geometry/control-brackets.d.ts +4 -0
  93. package/dist/types/layout/types/presentation/controls.d.ts +13 -0
  94. package/dist/types/layout/types/presentation/images.d.ts +8 -0
  95. package/dist/types/layout/types/presentation/signatures.d.ts +6 -0
  96. package/dist/types/model/business/business-types.d.ts +9 -1
  97. package/dist/types/model/business/data-lock-config.d.ts +27 -0
  98. package/dist/types/runtime/form/business/signatures/NativeSignatures.d.ts +3 -1
  99. package/dist/types/runtime/form/business/signatures/device-signature-lock.d.ts +2 -0
  100. package/dist/types/runtime/form/business/tables/row-fields.d.ts +1 -1
  101. package/dist/types/runtime/form/copy-field-paths.d.ts +3 -0
  102. package/dist/types/runtime/form/fields/core/rules/CommonFieldRules.d.ts +5 -1
  103. package/dist/types/runtime/form/validation/NativeFieldValidation.d.ts +14 -2
  104. package/dist/types/runtime/form/validation/targets.d.ts +1 -1
  105. package/dist/types/runtime/form/validation/types.d.ts +2 -0
  106. package/dist/types/runtime/interaction/EditorController.d.ts +2 -0
  107. package/dist/types/runtime/interaction/browse/types.d.ts +5 -0
  108. package/dist/types/runtime/interaction/design/format/EditorFormat.d.ts +2 -2
  109. package/dist/types/runtime/interaction/design/format/summary.d.ts +1 -2
  110. package/dist/types/runtime/interaction/design/format/targets.d.ts +11 -0
  111. package/dist/types/runtime/interaction/design/format/types.d.ts +3 -3
  112. package/dist/types/runtime/interaction/design/tables/regions/definitions.d.ts +7 -0
  113. package/dist/types/runtime/interaction/field-signature.d.ts +3 -0
  114. package/dist/types/runtime/presentation/fields/signatures.d.ts +5 -2
  115. package/dist/types/shared/platform-gct/form-credentials.d.ts +0 -1
  116. package/dist/types/shared/platform-gct/templates.d.ts +2 -0
  117. package/dist/types/shared/signature-graphic.d.ts +27 -0
  118. package/dist/types/shared/text/shading.d.ts +12 -0
  119. package/dist/types/shared/ui/select/src/select.types.d.ts +2 -0
  120. package/dist/types/shared/ui/tree-select/src/unified-tree-select.vue.d.ts +1 -1
  121. package/dist/vue.js +2101 -4470
  122. package/dist/vue.js.map +1 -1
  123. package/package.json +9 -3
  124. package/dist/chunks/ModelEditor-CXoezurC.js.map +0 -1
  125. package/dist/chunks/NodeFactory-D9gVGSok.js.map +0 -1
  126. package/dist/chunks/browser-DY0wE3Uz.js.map +0 -1
  127. package/dist/chunks/sdk-Dz96Ca_-.js.map +0 -1
  128. package/dist/chunks/types-Bq4hbWKT.js.map +0 -1
@@ -1,7 +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-Bq4hbWKT.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
2
  import { u as createUuid } from "./change-set-DgfKTJ6d.js";
3
3
  import { t as waitForAbortable } from "./abortable-D4G3Ib7H.js";
4
- 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";
5
6
  import { a as getGctFieldIcon, o as GCT_BASE_FIELD_TYPES, s as GCT_BUSINESS_FIELD_TYPES } from "./fields-CAcm6X98.js";
6
7
  import { groupBy, minBy, sortBy, uniq, uniqBy } from "es-toolkit/array";
7
8
  import { isEqual, isPlainObject } from "es-toolkit/predicate";
@@ -385,7 +386,7 @@ var CanvasImageResources = class {
385
386
  for (const page of result.pages) {
386
387
  let sources = this.pageSources.get(page);
387
388
  if (!sources) {
388
- 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 })]));
389
390
  this.pageSources.set(page, sources);
390
391
  }
391
392
  this.sources.set(page.id, sources);
@@ -679,10 +680,48 @@ function fieldContentBackgroundFrame(control, style, width, height) {
679
680
  height: bottom - top
680
681
  };
681
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
+ }
682
717
  // src/adapters/browser/canvas/paint-image.ts
683
718
  /** @file 图片按已发布几何绘制;解码对象由外部资源端口借用,不在绘制中加载。 */
684
719
  /** contain 留白、cover 居中裁剪、fill 拉伸都只在目标框内绘制。 */
685
720
  function paintImage(context, image, provider) {
721
+ if (image.graphic) {
722
+ paintSignatureGraphic(context, image.graphic, image.frame);
723
+ return;
724
+ }
686
725
  const frame = image.frame, decoded = image.state === "ready" ? provider?.getImage(layoutImageSourceKey(image.source), image.revision) : void 0;
687
726
  if (frame.width <= 0 || frame.height <= 0) return;
688
727
  context.save();
@@ -691,13 +730,14 @@ function paintImage(context, image, provider) {
691
730
  context.rect(frame.x, frame.y, frame.width, frame.height);
692
731
  context.clip();
693
732
  if (!decoded) {
694
- context.fillStyle = image.state === "error" ? "#fff0f0" : "#edf1f5";
733
+ context.fillStyle = image.placeholder?.backgroundColor ?? (image.state === "error" ? "#fff0f0" : "#edf1f5");
695
734
  context.fillRect(frame.x, frame.y, frame.width, frame.height);
735
+ if (image.placeholder && !image.placeholder.text) return;
696
736
  context.fillStyle = image.state === "error" ? "#a84040" : "#758397";
697
737
  context.font = "12px sans-serif";
698
738
  context.textAlign = "left";
699
739
  context.textBaseline = "top";
700
- 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);
701
741
  return;
702
742
  }
703
743
  const { width, height, value } = decoded;
@@ -740,6 +780,19 @@ function paintSealDecoration(context, control, width, height) {
740
780
  context.stroke();
741
781
  context.setLineDash([]);
742
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
+ }
743
796
  // src/adapters/browser/canvas/paint-field.ts
744
797
  /** @file 字段只消费排版快照;普通字段按括号和状态底色绘制,不创建输入框。 */
745
798
  /** 单选圆与复选圆角框使用同一已解析配色,图形不参与独立事件监听。 */
@@ -765,8 +818,8 @@ function optionPath(context, x, y, width, height, radio, radius) {
765
818
  context.closePath();
766
819
  }
767
820
  }
768
- /** 选项边框在实际背板像素中对齐,包含字段原点、缩放及 DPR;旋转时保留矢量坐标。 */
769
- function optionPixels(context, frame) {
821
+ /** 控件边框在实际背板像素中对齐,包含字段原点、缩放及 DPR;旋转时保留矢量坐标。 */
822
+ function decorationPixels(context, frame) {
770
823
  const pixels = canvasPixels(context);
771
824
  if (!pixels) return {
772
825
  frame,
@@ -792,7 +845,7 @@ function optionPixels(context, frame) {
792
845
  function paintOption(context, marker, color) {
793
846
  context.save();
794
847
  try {
795
- const { frame, lineWidth, radius, checkWidth } = optionPixels(context, marker.frame);
848
+ const { frame, lineWidth, radius, checkWidth } = decorationPixels(context, marker.frame);
796
849
  const paint = marker.paint ?? {
797
850
  border: color,
798
851
  background: "#fff",
@@ -829,15 +882,34 @@ function paintOption(context, marker, color) {
829
882
  }
830
883
  /** 在控件原点按字段状态色绘制括号。 */
831
884
  function paintFieldBrackets(context, control, style) {
832
- if (!control.bracketTexts?.length) return;
833
- applyCanvasTextStyle(context, {
834
- ...style,
835
- fontWeight: 400,
836
- fontStyle: "normal",
837
- letterSpacingPx: 0
838
- }, "ltr");
839
- context.fillStyle = control.decoration?.markerColor ?? style.color;
840
- 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
+ }
841
913
  }
842
914
  /** 字段值、占位、括号、选项、签名和图片均沿用已分配的相对几何。 */
843
915
  function paintField(context, fragment, result, images, printBackground) {
@@ -857,7 +929,7 @@ function paintField(context, fragment, result, images, printBackground) {
857
929
  const empty = !control.texts.some((text) => text.text) && !control.images?.length && !control.markers.length && !control.seal;
858
930
  const bounds = fieldContentBackgroundFrame(control, style, width, height);
859
931
  const verticalPad = empty ? pad : decoration?.backgroundVerticalPaddingPx ?? pad;
860
- 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);
861
933
  } else for (const text of control.texts) context.fillRect(text.x, fieldTextBackgroundTop(text.baseline, style.fontSizePx), text.width, fieldTextBackgroundHeight(style.fontSizePx));
862
934
  }
863
935
  context.beginPath();
@@ -865,19 +937,26 @@ function paintField(context, fragment, result, images, printBackground) {
865
937
  context.clip();
866
938
  for (const image of control.images ?? []) paintImage(context, image, images);
867
939
  if (control.seal) paintSealDecoration(context, control, width, height);
868
- applyCanvasTextStyle(context, style, "ltr");
869
940
  const textStyle = {
870
941
  ...style,
871
942
  color: decoration?.color ?? style.color,
872
943
  ...decoration?.underlineColor ? { underline: "single" } : {}
873
944
  };
945
+ applyCanvasTextStyle(context, textStyle, "ltr");
874
946
  context.fillStyle = textStyle.color;
947
+ let currentStyle = textStyle;
875
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
+ }
876
955
  if (text.expansion) {
877
956
  const { offsets, x: origins } = text.expansion;
878
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]);
879
958
  } else paintMeasuredText(context, text.text, text.x, text.baseline, text.width);
880
- 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);
881
960
  }
882
961
  paintFieldBrackets(context, control, style);
883
962
  for (const marker of control.markers) paintOption(context, marker, style.color);
@@ -1523,10 +1602,13 @@ var CanvasPages = class {
1523
1602
  offsetY: 0
1524
1603
  };
1525
1604
  }
1526
- /** 仅平移整页显示,输入覆盖层继续按真实 Canvas DOM 边界换算。 */
1605
+ /** 在布局阶段定位整页,避免分数 transform 让已绘制的 Canvas 再次插值。 */
1527
1606
  alignSurface(slot, canvas, cssWidth, cssHeight, options) {
1528
1607
  if (!options.alignToPixels) {
1529
- 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
+ }
1530
1612
  slot.offsetX = slot.offsetY = 0;
1531
1613
  return;
1532
1614
  }
@@ -1534,7 +1616,8 @@ var CanvasPages = class {
1534
1616
  if (!Number.isFinite(scaleX) || !Number.isFinite(scaleY) || scaleX <= 0 || scaleY <= 0) return;
1535
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;
1536
1618
  if (slot.offsetX === x && slot.offsetY === y) return;
1537
- 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` : "";
1538
1621
  slot.offsetX = x;
1539
1622
  slot.offsetY = y;
1540
1623
  }
@@ -3588,6 +3671,7 @@ var ResourceFieldPreview = class {
3588
3671
  this.task = task;
3589
3672
  this.hit = hit;
3590
3673
  this.pinned = pinned;
3674
+ let ownedMeasurer;
3591
3675
  try {
3592
3676
  const preview = await this.options.controller.readonlyActions.preview(hit, task.signal);
3593
3677
  if (!preview || task.signal.aborted || this.task !== task) {
@@ -3604,7 +3688,10 @@ var ResourceFieldPreview = class {
3604
3688
  fieldId: hit.fieldId,
3605
3689
  instanceKey: hit.instanceKey
3606
3690
  }, preview.label, {
3607
- width: 280,
3691
+ width: preview.kind === "signature" ? {
3692
+ minWidth: 1,
3693
+ maxWidth: 420
3694
+ } : 280,
3608
3695
  height: 280,
3609
3696
  autoFocus: pinned
3610
3697
  }, () => {
@@ -3618,16 +3705,52 @@ var ResourceFieldPreview = class {
3618
3705
  this.popover = popover;
3619
3706
  const root = popover.content, owner = root.ownerDocument;
3620
3707
  root.className = "gct-word-media-preview-list";
3621
- if (preview.kind !== "file") root.classList.add("is-images");
3622
- 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) => {
3623
3710
  const url = resourceUrl(entry.url, owner.baseURI);
3624
- return url ? [{
3625
- name: entry.name,
3626
- url
3627
- }] : [];
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
+ };
3628
3746
  });
3629
- for (const entry of preview.entries) {
3630
- 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;
3631
3754
  if (preview.kind === "file") {
3632
3755
  const card = owner.createElement("a"), icon = owner.createElement("img"), name = owner.createElement("span"), meta = owner.createElement("div"), size = owner.createElement("small");
3633
3756
  card.className = "gct-word-media-file";
@@ -3656,6 +3779,10 @@ var ResourceFieldPreview = class {
3656
3779
  const image = owner.createElement("img");
3657
3780
  image.src = url;
3658
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
+ }
3659
3786
  button.append(image);
3660
3787
  button.addEventListener("click", () => {
3661
3788
  this.pinned = true;
@@ -3664,7 +3791,7 @@ var ResourceFieldPreview = class {
3664
3791
  this.viewer = openImageViewer({
3665
3792
  container: root,
3666
3793
  images,
3667
- index: images.findIndex((image) => image.url === url),
3794
+ index: imageEntries.indexOf(entry),
3668
3795
  signal: task.signal,
3669
3796
  onClose: () => {
3670
3797
  this.viewer = void 0;
@@ -3683,6 +3810,8 @@ var ResourceFieldPreview = class {
3683
3810
  this.options.onError?.(error);
3684
3811
  } catch {}
3685
3812
  }
3813
+ } finally {
3814
+ ownedMeasurer?.dispose();
3686
3815
  }
3687
3816
  }
3688
3817
  refresh() {
@@ -4945,28 +5074,29 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
4945
5074
  if (fragment.kind !== "atom" || !fragment.fieldControl) return [];
4946
5075
  const control = fragment.fieldControl;
4947
5076
  const style = snapshot.result.paintStyles[control.paintStyleKey];
4948
- return style ? (control.bracketTexts ?? []).map((text) => ({
5077
+ return style ? controlBracketFrames(control, style).map((bracket) => ({
4949
5078
  fragment,
4950
- text,
4951
- style,
4952
- control
5079
+ bracket,
5080
+ style
4953
5081
  })) : [];
4954
5082
  });
4955
5083
  for (const side of ["start", "end"]) {
4956
- 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);
4957
5085
  const fragment = bracket?.fragment ?? (side === "start" ? fragments[0] : fragments.at(-1));
4958
5086
  if (fragment?.kind !== "atom" || !fragment.fieldControl) continue;
4959
5087
  const pageId = snapshot.query.getFragmentPageId(fragment.id);
4960
5088
  const page = pageId && pages.get(pageId);
4961
5089
  const style = bracket?.style ?? snapshot.result.paintStyles[fragment.fieldControl.paintStyleKey];
4962
5090
  if (!page || !style) continue;
4963
- const height = style.fontSizePx + 1;
4964
- const width = bracket ? Math.max(3, bracket.text.width) : 4;
4965
- const rect = inputScreenRect({
4966
- x: fragment.frame.x + (bracket ? bracket.text.x : side === "start" ? -width : fragment.frame.width),
4967
- y: fragment.frame.y + (bracket ? bracket.text.baseline - style.fontSizePx * .8 - .5 : 0),
4968
- width,
4969
- 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
4970
5100
  }, page);
4971
5101
  const screen = clipInputRect(rect, clip);
4972
5102
  if (!screen) continue;
@@ -4988,9 +5118,9 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
4988
5118
  height: "100%",
4989
5119
  boxSizing: "border-box",
4990
5120
  color: fragment.fieldControl.decoration?.markerColor ?? style.color,
4991
- borderTop: "1px solid currentColor",
4992
- borderBottom: "1px solid currentColor",
4993
- ...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" }
4994
5124
  });
4995
5125
  node.append(stroke);
4996
5126
  children.push(node);
@@ -5094,6 +5224,72 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
5094
5224
  layer.replaceChildren(...children);
5095
5225
  return state.composition ? typingScreen : screen;
5096
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
+ }
5097
5293
  // src/adapters/browser/input/InlineFieldInput.ts
5098
5294
  /** @file 单个活动文本/数字字段的无边框原位编辑,候选与未完成数字只存在当前 DOM 草稿。 */
5099
5295
  /** 一份 DOM 输入支持当前字段,切换字段、关闭或外部换值后撤销旧事件。 */
@@ -5640,11 +5836,10 @@ var InlineFieldInput = class {
5640
5836
  } catch (error) {
5641
5837
  this.writeBlocked = true;
5642
5838
  this.draftChecked = true;
5643
- 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) ?? "当前内容未能保存,请检查输入";
5644
5840
  input.setCustomValidity(this.failure);
5645
5841
  input.setAttribute("aria-invalid", "true");
5646
5842
  this.refresh();
5647
- if (active.base.widget !== "number") this.fail(error);
5648
5843
  return false;
5649
5844
  } finally {
5650
5845
  this.writing = false;
@@ -5868,6 +6063,8 @@ var SignatureFieldInput = class {
5868
6063
  restoreFocus;
5869
6064
  /** 同次激活的基值,换字段、外部值或配置改变后撤销。 */
5870
6065
  active;
6066
+ /** 尚未安装弹框的校验请求,关闭或切换时取消。 */
6067
+ opening;
5871
6068
  /** 当前 DOM 监听的取消边界。 */
5872
6069
  lifetime;
5873
6070
  /** 当前认证请求,关闭立即撤销,不排队重放。 */
@@ -5876,6 +6073,8 @@ var SignatureFieldInput = class {
5876
6073
  pending = false;
5877
6074
  /** 服务发放的短期不透明预览,不进入持久化数据。 */
5878
6075
  draft;
6076
+ completed = false;
6077
+ closeTimer;
5879
6078
  /** 共用弹框只持有本次签署界面。 */
5880
6079
  dialog;
5881
6080
  view;
@@ -5891,6 +6090,7 @@ var SignatureFieldInput = class {
5891
6090
  writing = false;
5892
6091
  /** 认证、校验失败或取消的局部说明。 */
5893
6092
  message = "";
6093
+ messageKind = "status";
5894
6094
  /** 仅借用窄交互能力,不创建 DOM 或发起认证。 */
5895
6095
  constructor(options, restoreFocus) {
5896
6096
  this.options = options;
@@ -5898,22 +6098,69 @@ var SignatureFieldInput = class {
5898
6098
  }
5899
6099
  /** 点击真实可编辑签名时打开;查看/关闭本身不认证、不写值。 */
5900
6100
  open() {
5901
- const state = this.options?.controller.getFieldSignatureInput();
5902
- 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;
5903
6104
  if (this.active?.selection === state.selection && sameFieldSignatureInput(state, this.active)) {
5904
6105
  this.refresh();
5905
6106
  return true;
5906
6107
  }
5907
6108
  this.close();
5908
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
+ }
5909
6144
  this.install();
5910
6145
  this.refresh();
6146
+ if (!this.ownsOpening(options, state, task)) return;
6147
+ this.active = current;
6148
+ this.opening = void 0;
6149
+ task.abort();
5911
6150
  this.dialog?.focus();
5912
- 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 {}
5913
6160
  }
5914
6161
  /** 保存前不能忽略尚未完成的认证或已认证但未确认的预览。 */
5915
6162
  canSubmit() {
5916
- return !this.pending && !this.draft;
6163
+ return !this.opening && !this.pending && !this.draft;
5917
6164
  }
5918
6165
  /** 只复核当前业务发生,不依赖旧字段坐标;认证弹框转移焦点不会自动取消。 */
5919
6166
  refresh() {
@@ -5926,28 +6173,36 @@ var SignatureFieldInput = class {
5926
6173
  this.close();
5927
6174
  return;
5928
6175
  }
5929
- if (!current || !sameFieldSignatureInput(current, active) || !current.editable && !current.pending) {
6176
+ if (!current || !sameFieldSignatureInput(current, active) || !this.completed && !current.editable && !current.pending) {
5930
6177
  this.close();
5931
6178
  return;
5932
6179
  }
5933
- 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;
5934
6181
  if (this.authorizeButton) this.authorizeButton.disabled = disabled || !!this.draft || !current.multiple && !!current.records.length;
5935
6182
  if (this.confirmButton) this.confirmButton.disabled = disabled || !this.draft;
5936
6183
  for (const button of this.removeButtons) button.disabled = disabled || !!this.draft;
5937
6184
  this.dialog?.content.setAttribute("aria-busy", String(busy));
5938
6185
  this.view?.update({
6186
+ appearance: current.appearance,
5939
6187
  records: current.records,
5940
6188
  draft: this.draft,
5941
6189
  busy,
5942
6190
  canAuthorize: !disabled && !this.draft && (current.multiple || !current.records.length),
5943
6191
  canConfirm: !disabled && !!this.draft,
5944
6192
  canRemove: !disabled && !this.draft,
5945
- message: current.invalid ? "签名值格式异常,原值已保留" : this.message
6193
+ completed: this.completed,
6194
+ message: current.invalid ? "签名值格式异常,原值已保留" : this.message,
6195
+ messageKind: current.invalid ? "error" : this.messageKind
5946
6196
  });
5947
6197
  if (this.status) this.status.textContent = current.invalid ? "签名值格式异常,原值已保留" : this.message || (current.pending ? "正在准备字段规则…" : "点击签署进行认证,认证通过后确认保存。");
5948
6198
  }
5949
6199
  /** 先撤销旧事件与认证,再丢弃预览;取消不会删除已经保存的记录。 */
5950
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;
5951
6206
  this.active = void 0;
5952
6207
  this.lifetime?.abort();
5953
6208
  this.lifetime = void 0;
@@ -5965,6 +6220,7 @@ var SignatureFieldInput = class {
5965
6220
  this.confirmButton = void 0;
5966
6221
  this.removeButtons = [];
5967
6222
  this.message = "";
6223
+ this.messageKind = "status";
5968
6224
  if (restore) this.restoreFocus?.();
5969
6225
  }
5970
6226
  /** 幂等释放所有临时 DOM、等待和外部能力,不关闭借用的文档或认证服务。 */
@@ -5985,6 +6241,7 @@ var SignatureFieldInput = class {
5985
6241
  this.view = this.options.renderSignaturePanel({
5986
6242
  container: dialog.content,
5987
6243
  state: {
6244
+ appearance: this.active.appearance,
5988
6245
  records: this.active.records,
5989
6246
  busy: false,
5990
6247
  canAuthorize: false,
@@ -6044,11 +6301,12 @@ var SignatureFieldInput = class {
6044
6301
  async authorize(authorization) {
6045
6302
  this.refresh();
6046
6303
  const options = this.options, active = this.active;
6047
- 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;
6048
6305
  const task = new AbortController();
6049
6306
  this.authentication = task;
6050
6307
  this.pending = true;
6051
6308
  this.message = "正在等待签署认证…";
6309
+ this.messageKind = "status";
6052
6310
  this.refresh();
6053
6311
  try {
6054
6312
  const draft = await options.controller.prepareFieldSignature(active, task.signal, ...authorization ? [authorization] : []);
@@ -6058,6 +6316,10 @@ var SignatureFieldInput = class {
6058
6316
  }
6059
6317
  this.draft = draft;
6060
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
+ }
6061
6323
  } catch (error) {
6062
6324
  if (!task.signal.aborted && this.active === active) this.fail(error);
6063
6325
  } finally {
@@ -6073,7 +6335,7 @@ var SignatureFieldInput = class {
6073
6335
  }
6074
6336
  }
6075
6337
  /** 明确确认后只提交服务发放的凭据;互斥失败仍保留原值并显示原因。 */
6076
- save() {
6338
+ save(closeDelayMs = 0) {
6077
6339
  this.refresh();
6078
6340
  const options = this.options, active = this.active, draft = this.draft;
6079
6341
  if (!options || !active || !draft || this.pending || this.confirmButton?.disabled) return;
@@ -6081,8 +6343,19 @@ var SignatureFieldInput = class {
6081
6343
  try {
6082
6344
  if (!options.controller.commitFieldSignature(draft, active)) throw new Error("签名未能保存");
6083
6345
  this.draft = void 0;
6084
- 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);
6085
6354
  } catch (error) {
6355
+ if (closeDelayMs) {
6356
+ options.controller.discardFieldSignature(draft);
6357
+ this.draft = void 0;
6358
+ }
6086
6359
  this.fail(error);
6087
6360
  } finally {
6088
6361
  this.writing = false;
@@ -6105,13 +6378,11 @@ var SignatureFieldInput = class {
6105
6378
  this.refresh();
6106
6379
  }
6107
6380
  }
6108
- /** 错误只进入当前面板及宿主反馈,不将认证凭据或完整记录写到页面。 */
6381
+ /** 签名错误由当前弹框展示,不再交给工作区重复显示。 */
6109
6382
  fail(error) {
6110
6383
  this.message = error instanceof Error ? error.message : "签名操作失败";
6384
+ this.messageKind = "error";
6111
6385
  this.refresh();
6112
- try {
6113
- this.options?.onError?.(error);
6114
- } catch {}
6115
6386
  }
6116
6387
  };
6117
6388
  // src/adapters/browser/input/CanvasTextInput.ts
@@ -7214,7 +7485,7 @@ var CanvasQuickFillDialog = class {
7214
7485
  const opening = new AbortController();
7215
7486
  this.opening = opening;
7216
7487
  try {
7217
- 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;
7218
7489
  if (opening.signal.aborted || this.options !== options) return;
7219
7490
  const source = options.controller.businessTables.readQuickFill(expected.regionId, expected.anchorInstanceKey);
7220
7491
  if (!source?.enabled || !isEqual(source.selection, expected.selection) || !isEqual(source.occurrence, expected.occurrence)) throw Error("当前行或快速填报规则已变化,请重新操作");
@@ -7439,11 +7710,9 @@ var CanvasQuickFillDialog = class {
7439
7710
  }
7440
7711
  /** 只保留可读错误文字,异常反馈不影响取消与释放。 */
7441
7712
  report(error) {
7442
- this.message = error instanceof Error ? error.message : String(error);
7713
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
7443
7714
  if (this.status) this.status.textContent = this.message;
7444
- try {
7445
- this.options?.onError?.(error);
7446
- } catch {}
7715
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
7447
7716
  }
7448
7717
  };
7449
7718
  // src/adapters/browser/input/business/tables/CanvasTableScanDialog.ts
@@ -7510,7 +7779,7 @@ var CanvasTableScanDialog = class {
7510
7779
  const opening = new AbortController();
7511
7780
  this.opening = opening;
7512
7781
  try {
7513
- 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;
7514
7783
  if (opening.signal.aborted || this.options !== options) return;
7515
7784
  const source = options.controller.businessTables.readScan(expected.regionId, expected.anchorInstanceKey);
7516
7785
  if (!source?.enabled || source.sessionId !== expected.sessionId || source.documentId !== expected.documentId || !isEqual(source.selection, expected.selection) || !isEqual(source.occurrence, expected.occurrence)) throw Error("当前业务表或扫码来源已变化");
@@ -7763,8 +8032,8 @@ var CanvasTableScanDialog = class {
7763
8032
  }
7764
8033
  /** 仅保留文字供修正,来源对象和异常链不会进入草稿。 */
7765
8034
  report(error) {
7766
- this.message = error instanceof Error ? error.message : String(error);
7767
- this.notify(error);
8035
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
8036
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
7768
8037
  this.update();
7769
8038
  }
7770
8039
  };
@@ -7908,7 +8177,7 @@ var CanvasBusinessTablePanel = class {
7908
8177
  count.min = "1";
7909
8178
  count.max = String(nativeTableRowBatchLimit);
7910
8179
  count.step = "1";
7911
- count.disabled = !state.editable;
8180
+ count.disabled = !state.allowed.insert && !state.allowed.copy;
7912
8181
  count.value = this.countText;
7913
8182
  count.setAttribute("aria-label", "操作行数");
7914
8183
  count.style.width = "70px";
@@ -7972,7 +8241,7 @@ var CanvasBusinessTablePanel = class {
7972
8241
  try {
7973
8242
  const count = Number(this.countText);
7974
8243
  if (operation !== "remove" && (!Number.isSafeInteger(count) || count < 1 || count > 1e3)) throw Error(`行数必须是 1–${nativeTableRowBatchLimit} 的整数`);
7975
- 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;
7976
8245
  if (task.signal.aborted || this.options !== options) return;
7977
8246
  const api = options.controller.businessTables, current = api.read(expected.regionId);
7978
8247
  if (!current || !isEqual(current.version, expected.version) || !isEqual(current.selection, expected.selection) || !isEqual(current.occurrence, expected.occurrence)) throw Error("业务表或当前输入已变化,请重新操作");
@@ -7998,10 +8267,8 @@ var CanvasBusinessTablePanel = class {
7998
8267
  }
7999
8268
  /** 失败只保留可展示文字,外部反馈异常不能保留整个异常链。 */
8000
8269
  report(error) {
8001
- this.message = error instanceof Error ? error.message : String(error);
8002
- try {
8003
- this.options?.onError?.(error);
8004
- } catch {}
8270
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
8271
+ reportUnhandledWordError(error, !!this.state && hasLocalWordFeedback(this.root), this.options?.onError);
8005
8272
  if (!this.task) this.render();
8006
8273
  }
8007
8274
  };
@@ -8263,7 +8530,22 @@ var CanvasValidationPanel = class {
8263
8530
  if (this.displayEnabled) this.queueDisplay();
8264
8531
  else if (options.feedback) queueMicrotask(() => this.showLive());
8265
8532
  });
8266
- 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
+ });
8267
8549
  this.unsubscribeSelection = options.controller.subscribe(() => this.syncActiveField());
8268
8550
  }
8269
8551
  /** 输入中只在字段旁提示;离开后使用独立批注栏,不覆盖其他字段。 */
@@ -8391,14 +8673,16 @@ var CanvasValidationPanel = class {
8391
8673
  } catch (error) {
8392
8674
  if (!this.current(task)) return;
8393
8675
  this.clear("本次校验未完成,请重试。");
8394
- options.onError?.(error);
8676
+ reportUnhandledWordError(error, hasLocalWordFeedback(options.host.querySelector("[role=\"status\"]") ?? void 0), options.onError);
8395
8677
  } finally {
8396
- this.checking = false;
8397
- if (this.inputValidation) {
8398
- this.live = true;
8399
- 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);
8400
8685
  }
8401
- this.end(task);
8402
8686
  }
8403
8687
  }
8404
8688
  /** Canvas 完成绘制后再映射标记,不触发排版、数据写入或整页重绘。 */
@@ -8478,7 +8762,10 @@ var CanvasValidationPanel = class {
8478
8762
  }
8479
8763
  this.setStatus("当前画面中没有可定位的对应位置。");
8480
8764
  } catch (error) {
8481
- 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
+ }
8482
8769
  } finally {
8483
8770
  this.end(task);
8484
8771
  }
@@ -10260,58 +10547,6 @@ var FieldAttachmentsPanel = class {
10260
10547
  this.options = void 0;
10261
10548
  }
10262
10549
  };
10263
- // src/runtime/interaction/editor-diagnostic.ts
10264
- /** @file 从异常读取稳定的诊断代码,界面决定如何显示,不传递调试路径和原始描述。 */
10265
- /** 未识别的外部异常由调用者决定如何兜底。 */
10266
- function readEditorDiagnostic(error) {
10267
- if (error instanceof DocumentValidationError) return {
10268
- kind: "validation",
10269
- codes: error.issues.map(({ code }) => code)
10270
- };
10271
- if (error instanceof ModelEditError) return {
10272
- kind: "model",
10273
- code: error.code
10274
- };
10275
- }
10276
- // src/adapters/browser/input/word-error-text.ts
10277
- /** @file 把 Word 可识别的失败转换为可展示的中文,原始异常仍留给宿主诊断。 */
10278
- /** 编辑器可以明确告诉用户如何修正的模型错误。 */
10279
- var modelMessages = {
10280
- table_merge: "请选择完整的单元格矩形,已有合并格需完整包含",
10281
- table_range: "请选择同一张表内的有效单元格范围",
10282
- table_size: "请检查表格的行列数量和列宽",
10283
- table_region: "当前操作会影响表格的区域设置,请先检查选区",
10284
- range: "操作范围或数量无效,请检查选区和输入值",
10285
- content_flow: "当前选区跨越了不同内容区域,请重新选择"
10286
- };
10287
- /** 文档结构和属性校验的中文提示,合并相同原因。 */
10288
- var validationMessages = {
10289
- nested_table: "当前位置不允许插入嵌套表格",
10290
- number: "请输入有效的数值,宽度和高度须大于 0,内边距和边框宽度可为 0",
10291
- enum: "当前设置值不可用,请重新选择",
10292
- type: "输入值的格式不正确,请检查设置"
10293
- };
10294
- /** 识别已经适合展示的中文,结构化错误优先使用稳定的代码。 */
10295
- function readWordErrorText(error) {
10296
- const diagnostic = readEditorDiagnostic(error);
10297
- if (diagnostic?.kind === "validation") {
10298
- const messages = new Set(diagnostic.codes.flatMap((code) => Object.hasOwn(validationMessages, code) ? validationMessages[code] ?? [] : []));
10299
- return messages.size ? [...messages].join("。") : void 0;
10300
- }
10301
- if (diagnostic?.kind === "model") return Object.hasOwn(modelMessages, diagnostic.code) ? modelMessages[diagnostic.code] : void 0;
10302
- const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
10303
- if (/^\p{Script=Han}[^\n]*$/u.test(message)) return message;
10304
- }
10305
- /** 模型校验和用户输入错误用警告,其余未知故障由界面使用错误提示。 */
10306
- function isWordValidationError(error) {
10307
- const diagnostic = readEditorDiagnostic(error);
10308
- return diagnostic?.kind === "validation" || diagnostic?.kind === "model" && Object.hasOwn(modelMessages, diagnostic.code);
10309
- }
10310
- /** 已交给宿主弹框的异常不重复写入行内,只保留可直接修改的中文状态。 */
10311
- function wordPanelErrorText(error, reportsError, fallback) {
10312
- if (reportsError && isWordValidationError(error)) return "";
10313
- return readWordErrorText(error) ?? (reportsError ? "" : fallback);
10314
- }
10315
10550
  // src/adapters/browser/input/design/settings/builders.ts
10316
10551
  /** 用户明确新增设置时生成必需值,未展开的可选属性保持缺省。 */
10317
10552
  function initialSettingValue(setting) {
@@ -10418,7 +10653,12 @@ var dependencies = listSetting("dependencies", "字段联动", objectSetting("",
10418
10653
  ], false),
10419
10654
  textSetting("expression", "表达式"),
10420
10655
  textSetting("expressionLabel", "表达式说明"),
10421
- enumSetting("strategy", "赋值覆盖策略", ["alwaysCover", "notCovered"]),
10656
+ enumSetting("assignmentType", "赋值类型", ["formula", "clear"]),
10657
+ enumSetting("strategy", "赋值覆盖策略", [
10658
+ "alwaysCover",
10659
+ "notCovered",
10660
+ "notCoveredForever"
10661
+ ]),
10422
10662
  booleanSetting("value", "固定真假值")
10423
10663
  ], false));
10424
10664
  /** 范围端点显式切换 none/fixed/expression,避免同时留下互斥参数。 */
@@ -10770,8 +11010,11 @@ var StructuredSettingsPanel = class {
10770
11010
  disabled: "禁用",
10771
11011
  required: "必填",
10772
11012
  assignment: "赋值",
11013
+ formula: "公式计算",
11014
+ clear: "清空",
10773
11015
  alwaysCover: "始终覆盖",
10774
- notCovered: "仅未初始化时赋值",
11016
+ notCovered: "不覆盖已修改(本次编辑有效)",
11017
+ notCoveredForever: "不覆盖已修改(永久有效)",
10775
11018
  ge: "大于或等于 ≥",
10776
11019
  gt: "大于 >",
10777
11020
  le: "小于或等于 ≤",
@@ -11149,10 +11392,8 @@ var CanvasFieldDesignPanel = class {
11149
11392
  this.reload();
11150
11393
  } catch (error) {
11151
11394
  this.writing = false;
11152
- if (this.status) this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "字段设置未完成,请重试");
11153
- try {
11154
- this.options?.onError?.(error);
11155
- } catch {}
11395
+ if (this.status) this.status.textContent = wordPanelErrorText(error, "字段设置未完成,请重试");
11396
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
11156
11397
  }
11157
11398
  }
11158
11399
  /** 移除订阅、全部事件和配置引用;旧侧栏节点不继续持有文档。 */
@@ -11581,10 +11822,8 @@ var CanvasFormatPanel = class {
11581
11822
  }
11582
11823
  /** 错误不回滚已提交事务,也不能使外部反馈产生未处理异常。 */
11583
11824
  report(error) {
11584
- if (this.status) this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "格式设置未完成,请重试");
11585
- try {
11586
- this.options?.onError?.(error);
11587
- } catch {}
11825
+ if (this.status) this.status.textContent = wordPanelErrorText(error, "格式设置未完成,请重试");
11826
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
11588
11827
  }
11589
11828
  /** 解除订阅和所有事件,保留旧输入、按钮或解除函数都不能反向保留文档。 */
11590
11829
  dispose() {
@@ -12174,12 +12413,10 @@ var CanvasFieldCatalogPanel = class {
12174
12413
  /** 目录失败不改变模板,也不把异常对象保存到面板状态。 */
12175
12414
  report(error) {
12176
12415
  if (this.status) {
12177
- this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "字段目录加载失败,请重试");
12416
+ this.status.textContent = wordPanelErrorText(error, "字段目录加载失败,请重试");
12178
12417
  this.status.hidden = !this.status.textContent;
12179
12418
  }
12180
- try {
12181
- this.options?.onError?.(error);
12182
- } catch {}
12419
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
12183
12420
  }
12184
12421
  /** 解除目录/控制器订阅、等待、拖入来源、DOM 和外部回调。 */
12185
12422
  dispose() {
@@ -12507,10 +12744,8 @@ var CanvasTableDesignPanel = class {
12507
12744
  if (this.status) this.status.textContent = error.message;
12508
12745
  return;
12509
12746
  }
12510
- if (this.status && !this.options.onError) this.status.textContent = readWordErrorText(error) ?? "表格操作未完成,请重试";
12511
- try {
12512
- this.options?.onError?.(error);
12513
- } catch {}
12747
+ if (this.status) this.status.textContent = readWordErrorText(error) ?? "表格操作未完成,请重试";
12748
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
12514
12749
  }
12515
12750
  }
12516
12751
  /** 关闭撤销旧按钮、旧控件和订阅,旧面板不继续持有文档。 */
@@ -12603,7 +12838,7 @@ function regionMetadataForm(options) {
12603
12838
  name.disabled = useDefault.checked;
12604
12839
  const path = text("区域数据路径", state?.binding?.pathTemplate ?? "");
12605
12840
  path.placeholder = "例如 $.items 或 $.checks:samples";
12606
- const parent = select("所属父区域"), target = select("关联业务区域"), variant = select("业务类型");
12841
+ const parent = select("所属父区域"), target = select("关联表格区域"), variant = select("业务类型");
12607
12842
  /** 根据真实类型切换可用关系,不默认选中任意父区域或关联主体。 */
12608
12843
  const updateType = () => {
12609
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 || "";
@@ -12640,7 +12875,7 @@ function regionMetadataForm(options) {
12640
12875
  form.append(hint);
12641
12876
  const apply = owner.createElement("button");
12642
12877
  apply.type = "button";
12643
- apply.textContent = state ? "应用区域类型与来源" : "创建业务区域";
12878
+ apply.textContent = state ? "应用区域类型与来源" : "创建表格区域";
12644
12879
  apply.addEventListener("click", () => {
12645
12880
  const typeValue = type.value, definition = designRegionTypes.find((item) => item.type === typeValue);
12646
12881
  options.apply({
@@ -12819,7 +13054,7 @@ var CanvasRegionDesignPanel = class {
12819
13054
  constructor(options) {
12820
13055
  this.options = options;
12821
13056
  this.root = options.host.ownerDocument.createElement("section");
12822
- this.root.setAttribute("aria-label", "业务区域设计");
13057
+ this.root.setAttribute("aria-label", "表格区域设计");
12823
13058
  options.host.append(this.root);
12824
13059
  try {
12825
13060
  this.unsubscribe = options.controller.subscribe(() => this.refresh());
@@ -12848,7 +13083,7 @@ var CanvasRegionDesignPanel = class {
12848
13083
  if (this.dirty) {
12849
13084
  this.stale = true;
12850
13085
  if (this.form) this.form.disabled = true;
12851
- if (this.status) this.status.textContent = "表格、区域或选区已变化,草稿已保留;请重新加载业务区域。";
13086
+ if (this.status) this.status.textContent = "表格、区域或选区已变化,草稿已保留;请重新加载表格区域。";
12852
13087
  return;
12853
13088
  }
12854
13089
  if (table && this.table && isEqual(items, this.items) && isEqual({
@@ -12878,7 +13113,7 @@ var CanvasRegionDesignPanel = class {
12878
13113
  }
12879
13114
  /** 工具栏打开新建表单时保护已编辑的草稿,不直接创建模型节点。 */
12880
13115
  startCreation(preset) {
12881
- if (this.dirty) throw Error("请先应用或放弃当前业务区域草稿。");
13116
+ if (this.dirty) throw Error("请先应用或放弃当前表格区域草稿。");
12882
13117
  if (!this.options?.controller.design.tables.readCurrent()?.editable) throw Error("请先选择可编辑的表格单元格。");
12883
13118
  this.regionId = void 0;
12884
13119
  this.preset = preset;
@@ -12922,21 +13157,21 @@ var CanvasRegionDesignPanel = class {
12922
13157
  const root = this.root, table = this.table, options = this.options, owner = root.ownerDocument;
12923
13158
  options.onRegionChange?.();
12924
13159
  if (!table) {
12925
- root.textContent = "先点击表格或选择物理格范围,再创建和配置业务区域。";
13160
+ root.textContent = "先点击表格或选择物理格范围,再创建和配置表格区域。";
12926
13161
  return;
12927
13162
  }
12928
13163
  const heading = owner.createElement("h3"), status = owner.createElement("p"), form = owner.createElement("fieldset");
12929
- heading.textContent = "业务区域";
13164
+ heading.textContent = this.state ? designRegionLabel(this.state) : "表格区域";
12930
13165
  status.setAttribute("role", "status");
12931
13166
  status.textContent = `当前第 ${table.rectangle.top + 1}–${table.rectangle.bottom + 1} 行,第 ${table.rectangle.left + 1}–${table.rectangle.right + 1} 列。`;
12932
13167
  this.status = status;
12933
- root.append(heading, status, this.button("重新加载业务区域", () => this.reload(), void 0, true), form);
12934
- form.setAttribute("aria-label", "业务区域配置");
13168
+ root.append(heading, status, this.button("重新加载表格区域", () => this.reload(), void 0, true), form);
13169
+ form.setAttribute("aria-label", "表格区域配置");
12935
13170
  form.disabled = !table.editable;
12936
13171
  form.style.cssText = "border:0;padding:0;display:grid;gap:10px;min-width:0";
12937
13172
  this.form = form;
12938
13173
  const regions = options.controller.design.tables.regions, items = this.items, chooser = owner.createElement("select");
12939
- chooser.setAttribute("aria-label", "当前业务区域");
13174
+ chooser.setAttribute("aria-label", "当前表格区域");
12940
13175
  this.chooser = chooser;
12941
13176
  for (const [value, label] of [["", "新建区域"], ...items.map((item) => [item.regionId, regionItemLabel(item)])]) {
12942
13177
  const option = owner.createElement("option");
@@ -13089,10 +13324,8 @@ var CanvasRegionDesignPanel = class {
13089
13324
  this.reload();
13090
13325
  } catch (error) {
13091
13326
  this.writing = false;
13092
- if (this.status) this.status.textContent = wordPanelErrorText(error, !!this.options?.onError, "表格区域设置未完成,请重试");
13093
- try {
13094
- this.options?.onError?.(error);
13095
- } catch {}
13327
+ if (this.status) this.status.textContent = wordPanelErrorText(error, "表格区域设置未完成,请重试");
13328
+ reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
13096
13329
  }
13097
13330
  }
13098
13331
  /** 关闭释放订阅、结构草稿及旧 DOM;保留面板/API 不继续拥有文档。 */
@@ -13425,10 +13658,8 @@ var CanvasMaterialsPanel = class {
13425
13658
  }
13426
13659
  /** 只保留错误文字,反馈异常不能阻止资源释放。 */
13427
13660
  report(error) {
13428
- this.message = error instanceof Error ? error.message : String(error);
13429
- try {
13430
- this.options?.onError?.(error);
13431
- } catch {}
13661
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
13662
+ reportUnhandledWordError(error, !!this.state && hasLocalWordFeedback(this.root), this.options?.onError);
13432
13663
  if (!this.task) this.render();
13433
13664
  }
13434
13665
  };
@@ -13698,7 +13929,7 @@ var CanvasBusinessTableActions = class {
13698
13929
  this.render();
13699
13930
  try {
13700
13931
  if (!Number.isSafeInteger(count) || count < 1 || count > 1e3) throw Error(`行数必须是 1–${nativeTableRowBatchLimit} 的整数`);
13701
- 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;
13702
13933
  if (task.signal.aborted || this.options !== options) return;
13703
13934
  const api = options.controller.businessTables, current = api.read(expected.regionId, expected.anchorInstanceKey);
13704
13935
  if (!current || !sameRowData(current, expected)) throw Error("业务行或当前输入已变化,请重新操作");
@@ -13741,10 +13972,8 @@ var CanvasBusinessTableActions = class {
13741
13972
  options.onApplied?.(result);
13742
13973
  } catch (error) {
13743
13974
  if (!task.signal.aborted && this.options === options) {
13744
- this.message = error instanceof Error ? error.message : "业务表操作失败";
13745
- try {
13746
- options.onError?.(error);
13747
- } catch {}
13975
+ this.message = wordPanelErrorText(error, "业务表操作未完成,请重试");
13976
+ reportUnhandledWordError(error, !!this.selected && !!this.view, options.onError);
13748
13977
  }
13749
13978
  } finally {
13750
13979
  this.writing = false;
@@ -14024,16 +14253,14 @@ var CanvasMaterialTableActions = class {
14024
14253
  this.render();
14025
14254
  }
14026
14255
  report(error) {
14027
- this.message = error instanceof Error ? error.message : String(error);
14256
+ this.message = wordPanelErrorText(error, "操作未完成,请重试");
14028
14257
  this.success = false;
14029
- try {
14030
- this.options?.onError?.(error);
14031
- } catch {}
14258
+ reportUnhandledWordError(error, !!this.selected && !!this.view, this.options?.onError);
14032
14259
  }
14033
14260
  };
14034
14261
  function sameRow(current, previous) {
14035
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);
14036
14263
  }
14037
- 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 };
14038
14265
 
14039
- //# sourceMappingURL=browser-DY0wE3Uz.js.map
14266
+ //# sourceMappingURL=browser-OAJIVM8O.js.map