@gct-paas/word 1.0.2 → 1.0.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -13
- package/dist/browser.js +1 -1
- package/dist/chunks/{ModelEditor-CXoezurC.js → ModelEditor-DqavEAJg.js} +113 -4
- package/dist/chunks/ModelEditor-DqavEAJg.js.map +1 -0
- package/dist/chunks/NodeFactory-DzFnWaWf.js +500 -0
- package/dist/chunks/NodeFactory-DzFnWaWf.js.map +1 -0
- package/dist/chunks/QuickFillPanel-BNZwXlnL.js +336 -0
- package/dist/chunks/QuickFillPanel-BNZwXlnL.js.map +1 -0
- package/dist/chunks/{browser-DY0wE3Uz.js → browser-DkEIriBA.js} +1462 -772
- package/dist/chunks/browser-DkEIriBA.js.map +1 -0
- package/dist/chunks/legacy-template-converter-DFsd-elN.js +125 -0
- package/dist/chunks/legacy-template-converter-DFsd-elN.js.map +1 -0
- package/dist/chunks/migrate-YJTylIpz.js +5193 -0
- package/dist/chunks/migrate-YJTylIpz.js.map +1 -0
- package/dist/chunks/{sdk-Dz96Ca_-.js → sdk-D9n5KeaD.js} +1284 -660
- package/dist/chunks/sdk-D9n5KeaD.js.map +1 -0
- package/dist/chunks/src-BFXPGLus.js +3338 -0
- package/dist/chunks/src-BFXPGLus.js.map +1 -0
- package/dist/chunks/{table-borders-Dwuj7lFp.js → table-borders-B9bZMj5o.js} +2 -2
- package/dist/chunks/{table-borders-Dwuj7lFp.js.map → table-borders-B9bZMj5o.js.map} +1 -1
- package/dist/chunks/templates-Djcl21k4.js.map +1 -1
- package/dist/chunks/{types-Bq4hbWKT.js → types-CzOaf1gP.js} +90 -56
- package/dist/chunks/types-CzOaf1gP.js.map +1 -0
- package/dist/chunks/{NodeFactory-D9gVGSok.js → validation-DkCy8wHI.js} +10 -495
- package/dist/chunks/validation-DkCy8wHI.js.map +1 -0
- package/dist/docx.js +3 -2
- package/dist/docx.js.map +1 -1
- package/dist/index.js +6 -5
- package/dist/legacy.js +1 -0
- package/dist/platform.js +2 -2
- package/dist/style.css +1066 -679
- package/dist/types/adapters/browser/canvas/CanvasPages.d.ts +1 -1
- package/dist/types/adapters/browser/canvas/paint-context.d.ts +4 -0
- package/dist/types/adapters/browser/canvas/paint-signature.d.ts +4 -0
- package/dist/types/adapters/browser/index.d.ts +1 -0
- package/dist/types/adapters/browser/input/CanvasFieldBrackets.d.ts +10 -0
- package/dist/types/adapters/browser/input/CanvasTextInput.d.ts +5 -2
- package/dist/types/adapters/browser/input/ChoiceFieldInput.d.ts +7 -2
- package/dist/types/adapters/browser/input/FieldInputValidation.d.ts +1 -1
- package/dist/types/adapters/browser/input/InlineFieldInput.d.ts +1 -1
- package/dist/types/adapters/browser/input/SignatureFieldInput.d.ts +10 -1
- package/dist/types/adapters/browser/input/business/FieldPopover.d.ts +6 -0
- package/dist/types/adapters/browser/input/business/materials/CanvasMaterialTableActions.d.ts +3 -0
- package/dist/types/adapters/browser/input/business/materials/attach-canvas-materials.d.ts +3 -1
- package/dist/types/adapters/browser/input/business/tables/CanvasBusinessTableActions.d.ts +3 -0
- package/dist/types/adapters/browser/input/business/tables/CanvasBusinessTablePanel.d.ts +4 -0
- package/dist/types/adapters/browser/input/business/tables/CanvasQuickFillDialog.d.ts +9 -8
- package/dist/types/adapters/browser/input/business/tables/attach-canvas-business-table.d.ts +4 -1
- package/dist/types/adapters/browser/input/business/tables/quick-fill-panel.d.ts +22 -0
- package/dist/types/adapters/browser/input/business/tables/table-action-anchors.d.ts +3 -3
- package/dist/types/adapters/browser/input/business/tables/table-action-pages.d.ts +26 -0
- package/dist/types/adapters/browser/input/business/tables/table-actions-renderer.d.ts +4 -0
- package/dist/types/adapters/browser/input/field-panel-geometry.d.ts +12 -0
- package/dist/types/adapters/browser/input/signature-panel.d.ts +6 -0
- package/dist/types/adapters/browser/input/types.d.ts +4 -4
- package/dist/types/adapters/browser/input/validation/CanvasValidationComments.d.ts +19 -0
- package/dist/types/adapters/browser/input/validation/CanvasValidationPanel.d.ts +12 -8
- package/dist/types/adapters/browser/input/validation/validation-issue-key.d.ts +3 -0
- package/dist/types/adapters/browser/input/word-error-text.d.ts +12 -2
- package/dist/types/adapters/document/types.d.ts +2 -1
- package/dist/types/adapters/platform/field-catalog/field-business-rules.d.ts +1 -1
- package/dist/types/adapters/platform/index.d.ts +1 -0
- package/dist/types/adapters/platform/template-reference-migration.d.ts +6 -0
- package/dist/types/adapters/platform/templates.d.ts +13 -1
- package/dist/types/adapters/vue/GctWordPrintRenderer.vue.d.ts +1 -1
- package/dist/types/adapters/vue/GctWordTemplateDesigner.vue.d.ts +3 -0
- package/dist/types/adapters/vue/QuickFillPanel.vue.d.ts +12 -0
- package/dist/types/adapters/vue/SignatureCardReader.vue.d.ts +1 -0
- package/dist/types/adapters/vue/SignatureFieldPanel.vue.d.ts +0 -1
- package/dist/types/adapters/vue/SignatureVisual.vue.d.ts +12 -0
- package/dist/types/adapters/vue/WordFeedback.vue.d.ts +11 -0
- package/dist/types/adapters/vue/WordLayoutNotices.vue.d.ts +8 -0
- package/dist/types/adapters/vue/WordOperationError.vue.d.ts +11 -0
- package/dist/types/adapters/vue/field-properties/dependency-strategies.d.ts +7 -0
- package/dist/types/adapters/vue/index.d.ts +2 -0
- package/dist/types/adapters/vue/layout-notices.d.ts +15 -0
- package/dist/types/adapters/vue/legacy-template-converter.d.ts +14 -0
- package/dist/types/adapters/vue/quick-fill-container.d.ts +2 -0
- package/dist/types/adapters/vue/quick-fill-data.d.ts +8 -0
- package/dist/types/adapters/vue/quick-fill-merge.d.ts +49 -0
- package/dist/types/adapters/vue/quick-fill-panel.d.ts +4 -0
- package/dist/types/adapters/vue/region-properties/WordBusinessRegion.vue.d.ts +3 -0
- package/dist/types/adapters/vue/region-properties/WordDataLockConfig.vue.d.ts +16 -0
- package/dist/types/adapters/vue/useWordWorkspace.d.ts +6 -3
- package/dist/types/adapters/vue/word-feedback.d.ts +21 -0
- package/dist/types/data/DataManager.d.ts +2 -2
- package/dist/types/data/rows/copy-row.d.ts +5 -0
- package/dist/types/data/services/DataDependencies.d.ts +2 -2
- package/dist/types/data/types/manager.d.ts +2 -0
- package/dist/types/data/types/rules.d.ts +8 -1
- package/dist/types/import/legacy/autofill.d.ts +3 -0
- package/dist/types/import/legacy/bindings.d.ts +9 -0
- package/dist/types/import/legacy/boundary.d.ts +10 -0
- package/dist/types/import/legacy/business-fields.d.ts +25 -0
- package/dist/types/import/legacy/context.d.ts +61 -0
- package/dist/types/import/legacy/data-sources.d.ts +29 -0
- package/dist/types/import/legacy/document-rules.d.ts +38 -0
- package/dist/types/import/legacy/document-signature.d.ts +16 -0
- package/dist/types/import/legacy/fields.d.ts +34 -0
- package/dist/types/import/legacy/index.d.ts +3 -0
- package/dist/types/import/legacy/initialization.d.ts +34 -0
- package/dist/types/import/legacy/json-data.d.ts +25 -0
- package/dist/types/import/legacy/materials.d.ts +40 -0
- package/dist/types/import/legacy/media.d.ts +18 -0
- package/dist/types/import/legacy/metadata.d.ts +23 -0
- package/dist/types/import/legacy/migrate.d.ts +9 -0
- package/dist/types/import/legacy/page-widgets.d.ts +30 -0
- package/dist/types/import/legacy/relations.d.ts +25 -0
- package/dist/types/import/legacy/scalar-fields.d.ts +7 -0
- package/dist/types/import/legacy/styles.d.ts +52 -0
- package/dist/types/import/legacy/table-variants.d.ts +18 -0
- package/dist/types/import/legacy/tables.d.ts +27 -0
- package/dist/types/import/legacy/trace-fields.d.ts +21 -0
- package/dist/types/import/legacy/types.d.ts +141 -0
- package/dist/types/import/legacy/widget-presentation.d.ts +10 -0
- package/dist/types/layout/engine/atoms/control-text.d.ts +16 -0
- package/dist/types/layout/engine/atoms/field-control.d.ts +2 -13
- package/dist/types/layout/engine/atoms/fit-atomic.d.ts +1 -1
- package/dist/types/layout/engine/atoms/signatures.d.ts +2 -2
- package/dist/types/layout/engine/blocks/placement-types.d.ts +7 -0
- package/dist/types/layout/engine/pagination/content-flow.d.ts +8 -0
- package/dist/types/layout/engine/tables/place-table-window.d.ts +3 -2
- package/dist/types/layout/engine/tables/row-flow.d.ts +3 -2
- package/dist/types/layout/engine/tables/table-flow.d.ts +3 -1
- package/dist/types/layout/geometry/control-brackets.d.ts +4 -0
- package/dist/types/layout/types/presentation/controls.d.ts +13 -0
- package/dist/types/layout/types/presentation/images.d.ts +8 -0
- package/dist/types/layout/types/presentation/signatures.d.ts +6 -0
- package/dist/types/model/business/business-types.d.ts +9 -1
- package/dist/types/model/business/data-lock-config.d.ts +27 -0
- package/dist/types/runtime/form/business/signatures/NativeSignatures.d.ts +3 -1
- package/dist/types/runtime/form/business/signatures/device-signature-lock.d.ts +2 -0
- package/dist/types/runtime/form/business/tables/row-fields.d.ts +1 -1
- package/dist/types/runtime/form/copy-field-paths.d.ts +3 -0
- package/dist/types/runtime/form/fields/core/declaration-changes.d.ts +2 -2
- package/dist/types/runtime/form/fields/core/rules/CommonFieldRules.d.ts +5 -1
- package/dist/types/runtime/form/validation/NativeFieldValidation.d.ts +16 -2
- package/dist/types/runtime/form/validation/description.d.ts +8 -4
- package/dist/types/runtime/form/validation/targets.d.ts +1 -1
- package/dist/types/runtime/form/validation/types.d.ts +2 -0
- package/dist/types/runtime/interaction/EditorController.d.ts +5 -1
- package/dist/types/runtime/interaction/browse/types.d.ts +1 -1
- package/dist/types/runtime/interaction/design/format/EditorFormat.d.ts +2 -2
- package/dist/types/runtime/interaction/design/format/summary.d.ts +1 -2
- package/dist/types/runtime/interaction/design/format/targets.d.ts +11 -0
- package/dist/types/runtime/interaction/design/format/types.d.ts +3 -3
- package/dist/types/runtime/interaction/design/tables/regions/EditorTableRegions.d.ts +3 -1
- package/dist/types/runtime/interaction/design/tables/regions/definitions.d.ts +7 -0
- package/dist/types/runtime/interaction/field-signature.d.ts +3 -0
- package/dist/types/runtime/interaction/field-text.d.ts +5 -5
- package/dist/types/runtime/interaction/validation/types.d.ts +2 -0
- package/dist/types/runtime/presentation/fields/signatures.d.ts +5 -2
- package/dist/types/shared/platform-gct/form-credentials.d.ts +0 -1
- package/dist/types/shared/platform-gct/templates.d.ts +2 -0
- package/dist/types/shared/signature-graphic.d.ts +27 -0
- package/dist/types/shared/text/shading.d.ts +12 -0
- package/dist/types/shared/text/word-navigation.d.ts +1 -0
- package/dist/types/shared/ui/select/src/select.types.d.ts +2 -0
- package/dist/types/shared/ui/tree-select/src/unified-tree-select.vue.d.ts +1 -1
- package/dist/types/shared/word-shortcuts.d.ts +28 -0
- package/dist/vue.js +2482 -4573
- package/dist/vue.js.map +1 -1
- package/package.json +10 -3
- package/dist/chunks/ModelEditor-CXoezurC.js.map +0 -1
- package/dist/chunks/NodeFactory-D9gVGSok.js.map +0 -1
- package/dist/chunks/browser-DY0wE3Uz.js.map +0 -1
- package/dist/chunks/sdk-Dz96Ca_-.js.map +0 -1
- package/dist/chunks/types-Bq4hbWKT.js.map +0 -1
- package/dist/types/adapters/browser/input/business/tables/fixed-quick-fill-grid.d.ts +0 -19
- package/dist/types/adapters/browser/input/validation/CanvasValidationMarks.d.ts +0 -15
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as snapshotPageWidgetDragDefinition, An as parseTsv, B as designRegionTypes, Bn as assertLayoutTextMeasurement, E as snapshotSealDefinition, Fn as layoutImageSourceKey, In as LayoutContractError, J as sameBusinessField, Kt as resourceName, Nn as sameLayoutVersion, On as wordClipboardType, S as sameFieldOptionInput, V as designRegionVariants, Yt as validateResourceFiles, h as sameFieldSignatureInput, jn as tsvClipboardLimits, k as snapshotFieldDragDefinition, qt as resourceUrl, r as sameFieldTextInput, t as nativeTableRowBatchLimit, tt as wordNavigationOffset, x as sameFieldChoiceInput, z as designRegionLabel, zn as assertLayoutTextMeasureRequest } from "./types-CzOaf1gP.js";
|
|
2
2
|
import { u as createUuid } from "./change-set-DgfKTJ6d.js";
|
|
3
3
|
import { t as waitForAbortable } from "./abortable-D4G3Ib7H.js";
|
|
4
|
-
import {
|
|
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
|
-
/**
|
|
769
|
-
function
|
|
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 } =
|
|
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
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
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 +
|
|
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,
|
|
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
|
-
/**
|
|
1605
|
+
/** 在布局阶段定位整页,避免分数 transform 让已绘制的 Canvas 再次插值。 */
|
|
1527
1606
|
alignSurface(slot, canvas, cssWidth, cssHeight, options) {
|
|
1528
1607
|
if (!options.alignToPixels) {
|
|
1529
|
-
if (slot.offsetX || slot.offsetY)
|
|
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.
|
|
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
|
}
|
|
@@ -2037,6 +2120,46 @@ function choicePanelRect(anchor, viewport) {
|
|
|
2037
2120
|
height
|
|
2038
2121
|
};
|
|
2039
2122
|
}
|
|
2123
|
+
// src/adapters/browser/input/field-panel-geometry.ts
|
|
2124
|
+
/** @file 字段浮层只合并会移动纸张的滚动和尺寸变化,关闭后撤销未执行的定位。 */
|
|
2125
|
+
var FieldPanelGeometry = class {
|
|
2126
|
+
view;
|
|
2127
|
+
frame;
|
|
2128
|
+
refresh;
|
|
2129
|
+
lifetime = new AbortController();
|
|
2130
|
+
constructor(host, refresh) {
|
|
2131
|
+
const owner = host.ownerDocument;
|
|
2132
|
+
const view = owner.defaultView;
|
|
2133
|
+
this.view = view;
|
|
2134
|
+
this.refresh = refresh;
|
|
2135
|
+
owner.addEventListener("scroll", (event) => {
|
|
2136
|
+
if (event.target === owner || event.target instanceof view.Element && event.target.contains(host)) this.schedule();
|
|
2137
|
+
}, {
|
|
2138
|
+
capture: true,
|
|
2139
|
+
passive: true,
|
|
2140
|
+
signal: this.lifetime.signal
|
|
2141
|
+
});
|
|
2142
|
+
view.addEventListener("resize", () => this.schedule(), { signal: this.lifetime.signal });
|
|
2143
|
+
}
|
|
2144
|
+
schedule() {
|
|
2145
|
+
if (!this.view || this.frame !== void 0) return;
|
|
2146
|
+
this.frame = this.view.requestAnimationFrame(() => {
|
|
2147
|
+
this.frame = void 0;
|
|
2148
|
+
this.refresh?.();
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
/** 宿主已经完成本帧绘制时直接定位,撤销该帧重复排队的工作。 */
|
|
2152
|
+
cancel() {
|
|
2153
|
+
if (this.frame !== void 0) this.view?.cancelAnimationFrame(this.frame);
|
|
2154
|
+
this.frame = void 0;
|
|
2155
|
+
}
|
|
2156
|
+
dispose() {
|
|
2157
|
+
this.cancel();
|
|
2158
|
+
this.lifetime.abort();
|
|
2159
|
+
this.refresh = void 0;
|
|
2160
|
+
this.view = void 0;
|
|
2161
|
+
}
|
|
2162
|
+
};
|
|
2040
2163
|
// src/adapters/browser/input/overlay-layer.ts
|
|
2041
2164
|
/** @file 原生输入使用视口坐标挂在 body,层级跟随当前画布的抽屉或弹框。 */
|
|
2042
2165
|
/** 保留输入、选区、下拉及错误提示之间的相对顺序,不改动宿主层级或定位。 */
|
|
@@ -2063,6 +2186,11 @@ var FieldPopover = class {
|
|
|
2063
2186
|
paused = false;
|
|
2064
2187
|
observer;
|
|
2065
2188
|
mutationObserver;
|
|
2189
|
+
geometry;
|
|
2190
|
+
measureDirty = true;
|
|
2191
|
+
measuredViewportWidth;
|
|
2192
|
+
contentHeight = 0;
|
|
2193
|
+
layoutRevision;
|
|
2066
2194
|
/** 同一次打开只扩不缩;仅持有展示宽度,不缓存候选数据。 */
|
|
2067
2195
|
contentWidth = 0;
|
|
2068
2196
|
size;
|
|
@@ -2120,15 +2248,10 @@ var FieldPopover = class {
|
|
|
2120
2248
|
}
|
|
2121
2249
|
}
|
|
2122
2250
|
}, { signal });
|
|
2123
|
-
|
|
2124
|
-
capture: true,
|
|
2125
|
-
passive: true,
|
|
2126
|
-
signal
|
|
2127
|
-
});
|
|
2128
|
-
owner.defaultView?.addEventListener("resize", () => this.refresh(), { signal });
|
|
2251
|
+
this.geometry = new FieldPanelGeometry(options.host, () => this.refresh());
|
|
2129
2252
|
const Observer = owner.defaultView?.ResizeObserver;
|
|
2130
2253
|
if (Observer) {
|
|
2131
|
-
this.observer = new Observer(() => this.
|
|
2254
|
+
this.observer = new Observer(() => this.contentChanged());
|
|
2132
2255
|
this.observer.observe(this.content);
|
|
2133
2256
|
}
|
|
2134
2257
|
this.observeContentWidth();
|
|
@@ -2143,7 +2266,7 @@ var FieldPopover = class {
|
|
|
2143
2266
|
const Mutations = this.content.ownerDocument.defaultView?.MutationObserver;
|
|
2144
2267
|
if (Mutations) {
|
|
2145
2268
|
this.mutationObserver = new Mutations(() => {
|
|
2146
|
-
if (typeof this.size.width !== "number") this.
|
|
2269
|
+
if (typeof this.size.width !== "number") this.contentChanged();
|
|
2147
2270
|
});
|
|
2148
2271
|
this.mutationObserver.observe(this.content, {
|
|
2149
2272
|
childList: true,
|
|
@@ -2152,12 +2275,17 @@ var FieldPopover = class {
|
|
|
2152
2275
|
});
|
|
2153
2276
|
}
|
|
2154
2277
|
}
|
|
2278
|
+
contentChanged() {
|
|
2279
|
+
this.measureDirty = true;
|
|
2280
|
+
this.geometry?.schedule();
|
|
2281
|
+
}
|
|
2155
2282
|
resize(width) {
|
|
2156
2283
|
if (typeof width === "number") {
|
|
2157
2284
|
if (!Number.isFinite(width) || width <= 0) return;
|
|
2158
2285
|
} else if (!Number.isFinite(width.minWidth) || !Number.isFinite(width.maxWidth) || width.minWidth <= 0 || width.maxWidth < width.minWidth) return;
|
|
2159
2286
|
if (typeof width === "number" || typeof this.size.width === "number" || width.minWidth !== this.size.width.minWidth || width.maxWidth !== this.size.width.maxWidth) this.contentWidth = 0;
|
|
2160
2287
|
this.size.width = width;
|
|
2288
|
+
this.measureDirty = true;
|
|
2161
2289
|
this.observeContentWidth();
|
|
2162
2290
|
this.refresh();
|
|
2163
2291
|
}
|
|
@@ -2170,6 +2298,7 @@ var FieldPopover = class {
|
|
|
2170
2298
|
}
|
|
2171
2299
|
const minimum = Math.min(size.minWidth, viewportWidth);
|
|
2172
2300
|
const maximum = Math.min(size.maxWidth, viewportWidth);
|
|
2301
|
+
if (!this.measureDirty && this.measuredViewportWidth === viewportWidth) return Math.min(maximum, this.contentWidth);
|
|
2173
2302
|
Object.assign(root.style, {
|
|
2174
2303
|
width: "max-content",
|
|
2175
2304
|
minWidth: `${minimum}px`,
|
|
@@ -2180,9 +2309,15 @@ var FieldPopover = class {
|
|
|
2180
2309
|
return Math.min(maximum, this.contentWidth);
|
|
2181
2310
|
}
|
|
2182
2311
|
refresh(placement) {
|
|
2312
|
+
this.geometry?.cancel();
|
|
2183
2313
|
if (placement) this.placement = placement;
|
|
2184
2314
|
const root = this.root, options = this.options, selection = this.selection;
|
|
2185
2315
|
if (!root || !options || !selection) return;
|
|
2316
|
+
const revision = options.layout.getCurrentSnapshot()?.result.version.layoutRevision;
|
|
2317
|
+
if (revision !== this.layoutRevision) {
|
|
2318
|
+
this.layoutRevision = revision;
|
|
2319
|
+
this.measureDirty = true;
|
|
2320
|
+
}
|
|
2186
2321
|
root.style.zIndex = inputOverlayZIndex(options.host, 10);
|
|
2187
2322
|
const anchor = choiceAnchor(options, selection, this.placement);
|
|
2188
2323
|
if (anchor.kind !== "ready") {
|
|
@@ -2199,7 +2334,12 @@ var FieldPopover = class {
|
|
|
2199
2334
|
const gap = 4, viewport = anchor.viewport, inset = typeof this.size.width === "number" ? 0 : Math.min(8, viewport.width / 2), width = this.width(root, Math.max(0, viewport.width - inset * 2)), below = viewport.top + viewport.height - anchor.rect.top - anchor.rect.height - gap, above = anchor.rect.top - viewport.top - gap;
|
|
2200
2335
|
root.style.width = `${width}px`;
|
|
2201
2336
|
root.style.maxHeight = `${Math.max(80, viewport.height - 8)}px`;
|
|
2202
|
-
|
|
2337
|
+
if (this.measureDirty || this.measuredViewportWidth !== viewport.width - inset * 2) {
|
|
2338
|
+
this.contentHeight = root.scrollHeight || this.size.height;
|
|
2339
|
+
this.measuredViewportWidth = Math.max(0, viewport.width - inset * 2);
|
|
2340
|
+
this.measureDirty = false;
|
|
2341
|
+
}
|
|
2342
|
+
const desired = Math.min(this.contentHeight, viewport.height - 8), down = below >= desired || below >= above, height = Math.min(desired, Math.max(80, down ? below : above));
|
|
2203
2343
|
root.style.setProperty("--gct-select-available-height", `${Math.max(80, down ? below : above)}px`);
|
|
2204
2344
|
Object.assign(root.style, {
|
|
2205
2345
|
left: `${Math.max(viewport.left + inset, Math.min(anchor.rect.left, viewport.left + viewport.width - inset - width))}px`,
|
|
@@ -2224,6 +2364,8 @@ var FieldPopover = class {
|
|
|
2224
2364
|
}
|
|
2225
2365
|
}
|
|
2226
2366
|
dispose() {
|
|
2367
|
+
this.geometry?.dispose();
|
|
2368
|
+
this.geometry = void 0;
|
|
2227
2369
|
this.observer?.disconnect();
|
|
2228
2370
|
this.observer = void 0;
|
|
2229
2371
|
this.mutationObserver?.disconnect();
|
|
@@ -2735,13 +2877,6 @@ var ResourceFieldInput = class {
|
|
|
2735
2877
|
drop.addEventListener("dragover", () => drop.classList.add("dragover"), { signal: this.lifetime.signal });
|
|
2736
2878
|
drop.addEventListener("dragleave", () => drop.classList.remove("dragover"), { signal: this.lifetime.signal });
|
|
2737
2879
|
drop.addEventListener("drop", () => drop.classList.remove("dragover"), { signal: this.lifetime.signal });
|
|
2738
|
-
const clear = this.button("清空", () => {
|
|
2739
|
-
this.clear();
|
|
2740
|
-
this.dirty = true;
|
|
2741
|
-
this.render();
|
|
2742
|
-
});
|
|
2743
|
-
clear.style.marginRight = "auto";
|
|
2744
|
-
if (options.kind === "file") actions.append(clear);
|
|
2745
2880
|
}
|
|
2746
2881
|
actions.append(this.button(options.editable ? "取消" : "关闭", () => this.options?.cancel()));
|
|
2747
2882
|
if (options.editable) {
|
|
@@ -2895,15 +3030,6 @@ var ResourceFieldInput = class {
|
|
|
2895
3030
|
meta.className = "gct-word-resource-meta";
|
|
2896
3031
|
meta.append(name, size);
|
|
2897
3032
|
row.append(icon, meta);
|
|
2898
|
-
if (url) {
|
|
2899
|
-
const download = owner.createElement("a");
|
|
2900
|
-
download.textContent = "下载";
|
|
2901
|
-
download.href = url;
|
|
2902
|
-
download.download = item.name;
|
|
2903
|
-
download.target = "_blank";
|
|
2904
|
-
download.rel = "noopener noreferrer";
|
|
2905
|
-
row.append(download);
|
|
2906
|
-
}
|
|
2907
3033
|
this.sizes.show(size, url, item.size);
|
|
2908
3034
|
}
|
|
2909
3035
|
if (item.status === "uploading" || item.status === "queued") {
|
|
@@ -2936,7 +3062,7 @@ var ResourceFieldInput = class {
|
|
|
2936
3062
|
}));
|
|
2937
3063
|
}
|
|
2938
3064
|
if (options.editable) {
|
|
2939
|
-
const remove = this.button(
|
|
3065
|
+
const remove = this.button("", () => {
|
|
2940
3066
|
item.controller?.abort();
|
|
2941
3067
|
this.releasePreview(item);
|
|
2942
3068
|
item.file = void 0;
|
|
@@ -2946,15 +3072,13 @@ var ResourceFieldInput = class {
|
|
|
2946
3072
|
this.render();
|
|
2947
3073
|
this.pump();
|
|
2948
3074
|
});
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
remove.setAttribute("aria-label", `移除 ${item.name}`);
|
|
2957
|
-
}
|
|
3075
|
+
const icon = owner.createElement("span");
|
|
3076
|
+
remove.className = image ? "gct-word-resource-remove" : "gct-word-field-button gct-word-resource-delete";
|
|
3077
|
+
icon.className = image ? "gct-word-resource-remove-icon" : "gct-word-resource-delete-icon";
|
|
3078
|
+
icon.setAttribute("aria-hidden", "true");
|
|
3079
|
+
remove.append(icon);
|
|
3080
|
+
remove.title = `${image ? "移除" : "删除"} ${item.name}`;
|
|
3081
|
+
remove.setAttribute("aria-label", remove.title);
|
|
2958
3082
|
row.append(remove);
|
|
2959
3083
|
}
|
|
2960
3084
|
this.list.append(row);
|
|
@@ -3005,27 +3129,15 @@ var ResourceFieldInput = class {
|
|
|
3005
3129
|
actions() {
|
|
3006
3130
|
const options = this.options;
|
|
3007
3131
|
if (!options) return [];
|
|
3008
|
-
return [
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
}] : [],
|
|
3018
|
-
{
|
|
3019
|
-
label: options.editable ? "取消" : "关闭",
|
|
3020
|
-
run: () => this.options?.cancel()
|
|
3021
|
-
},
|
|
3022
|
-
...options.editable ? [{
|
|
3023
|
-
label: options.kind === "image" ? "确认" : "确定",
|
|
3024
|
-
primary: true,
|
|
3025
|
-
disabled: this.items.some((item) => item.status !== "done"),
|
|
3026
|
-
run: () => this.apply()
|
|
3027
|
-
}] : []
|
|
3028
|
-
];
|
|
3132
|
+
return [{
|
|
3133
|
+
label: options.editable ? "取消" : "关闭",
|
|
3134
|
+
run: () => this.options?.cancel()
|
|
3135
|
+
}, ...options.editable ? [{
|
|
3136
|
+
label: options.kind === "image" ? "确认" : "确定",
|
|
3137
|
+
primary: true,
|
|
3138
|
+
disabled: this.items.some((item) => item.status !== "done"),
|
|
3139
|
+
run: () => this.apply()
|
|
3140
|
+
}] : []];
|
|
3029
3141
|
}
|
|
3030
3142
|
/** 正在上传或失败时不能提交半份列表;单纯打开再确定只关闭,不重写数据。 */
|
|
3031
3143
|
apply() {
|
|
@@ -3618,16 +3730,18 @@ var ResourceFieldPreview = class {
|
|
|
3618
3730
|
this.popover = popover;
|
|
3619
3731
|
const root = popover.content, owner = root.ownerDocument;
|
|
3620
3732
|
root.className = "gct-word-media-preview-list";
|
|
3621
|
-
if (preview.kind
|
|
3622
|
-
const
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3733
|
+
if (preview.kind === "image") root.classList.add("is-images");
|
|
3734
|
+
const entries = preview.entries.map((entry) => ({
|
|
3735
|
+
...entry,
|
|
3736
|
+
url: resourceUrl(entry.url, owner.baseURI)
|
|
3737
|
+
}));
|
|
3738
|
+
const imageEntries = entries.filter((entry) => entry.url);
|
|
3739
|
+
const images = imageEntries.map((entry) => ({
|
|
3740
|
+
name: entry.name,
|
|
3741
|
+
url: entry.url
|
|
3742
|
+
}));
|
|
3743
|
+
for (const entry of entries) {
|
|
3744
|
+
const url = entry.url;
|
|
3631
3745
|
if (preview.kind === "file") {
|
|
3632
3746
|
const card = owner.createElement("a"), icon = owner.createElement("img"), name = owner.createElement("span"), meta = owner.createElement("div"), size = owner.createElement("small");
|
|
3633
3747
|
card.className = "gct-word-media-file";
|
|
@@ -3664,7 +3778,7 @@ var ResourceFieldPreview = class {
|
|
|
3664
3778
|
this.viewer = openImageViewer({
|
|
3665
3779
|
container: root,
|
|
3666
3780
|
images,
|
|
3667
|
-
index:
|
|
3781
|
+
index: imageEntries.indexOf(entry),
|
|
3668
3782
|
signal: task.signal,
|
|
3669
3783
|
onClose: () => {
|
|
3670
3784
|
this.viewer = void 0;
|
|
@@ -3714,6 +3828,132 @@ var ResourceFieldPreview = class {
|
|
|
3714
3828
|
this.lifetime.abort();
|
|
3715
3829
|
}
|
|
3716
3830
|
};
|
|
3831
|
+
// src/adapters/browser/input/CanvasFieldBrackets.ts
|
|
3832
|
+
/** @file 活动字段的首尾括号与纸张同层滚动,重复几何通知不重建括号或重查片段。 */
|
|
3833
|
+
/** 只保留两端 DOM 和当前挂载表面的尺寸,不保留字段值或排版快照。 */
|
|
3834
|
+
var CanvasFieldBrackets = class {
|
|
3835
|
+
layers = /* @__PURE__ */ new Map();
|
|
3836
|
+
nodes = /* @__PURE__ */ new Map();
|
|
3837
|
+
rendered;
|
|
3838
|
+
refresh(host, snapshot, controller) {
|
|
3839
|
+
const selection = controller.getState().selection;
|
|
3840
|
+
if (!snapshot || selection?.kind !== "field" || host.ownerDocument.hidden || controller.getFieldTarget()?.state.editable !== true) {
|
|
3841
|
+
this.clear();
|
|
3842
|
+
return;
|
|
3843
|
+
}
|
|
3844
|
+
const pages = inputScreenPages(host, snapshot);
|
|
3845
|
+
const dimensions = [...pages.values()].flatMap(({ canvas, page, rect }) => canvas.parentElement ? [{
|
|
3846
|
+
canvas,
|
|
3847
|
+
parent: canvas.parentElement,
|
|
3848
|
+
width: Number.parseFloat(canvas.style.width) || canvas.clientWidth || rect.width * ((page.bodyTableOverflow?.right ?? page.width) / page.width),
|
|
3849
|
+
height: Number.parseFloat(canvas.style.height) || canvas.clientHeight || rect.height
|
|
3850
|
+
}] : []);
|
|
3851
|
+
const previous = this.rendered;
|
|
3852
|
+
if (previous?.revision === snapshot.result.version.layoutRevision && previous.fieldId === selection.fieldId && previous.instanceKey === selection.instanceKey && previous.pages.length === dimensions.length && dimensions.every((page, index) => {
|
|
3853
|
+
const old = previous.pages[index];
|
|
3854
|
+
return page.canvas === old.canvas && page.parent === old.parent && page.width === old.width && page.height === old.height;
|
|
3855
|
+
}) && [...this.layers.values()].every((layer) => layer.isConnected)) return;
|
|
3856
|
+
const fragments = snapshot.query.findBySource({
|
|
3857
|
+
nodeId: selection.fieldId,
|
|
3858
|
+
instanceKey: selection.instanceKey
|
|
3859
|
+
}).filter((fragment) => fragment.kind === "atom" && !!fragment.fieldControl);
|
|
3860
|
+
const brackets = fragments.flatMap((fragment) => {
|
|
3861
|
+
if (fragment.kind !== "atom" || !fragment.fieldControl) return [];
|
|
3862
|
+
const style = snapshot.result.paintStyles[fragment.fieldControl.paintStyleKey];
|
|
3863
|
+
return style ? controlBracketFrames(fragment.fieldControl, style).map((bracket) => ({
|
|
3864
|
+
fragment,
|
|
3865
|
+
bracket,
|
|
3866
|
+
style
|
|
3867
|
+
})) : [];
|
|
3868
|
+
});
|
|
3869
|
+
const activePages = /* @__PURE__ */ new Set(), activeSides = /* @__PURE__ */ new Set();
|
|
3870
|
+
for (const side of ["start", "end"]) {
|
|
3871
|
+
const bracket = side === "start" ? brackets.find((item) => item.bracket.side === side) : [...brackets].reverse().find((item) => item.bracket.side === side);
|
|
3872
|
+
const fragment = bracket?.fragment ?? (side === "start" ? fragments[0] : fragments.at(-1));
|
|
3873
|
+
if (fragment?.kind !== "atom" || !fragment.fieldControl) continue;
|
|
3874
|
+
const pageId = snapshot.query.getFragmentPageId(fragment.id);
|
|
3875
|
+
const surface = pages.get(pageId), dimension = dimensions.find((page) => page.canvas === surface?.canvas);
|
|
3876
|
+
const style = bracket?.style ?? snapshot.result.paintStyles[fragment.fieldControl.paintStyleKey];
|
|
3877
|
+
if (!surface || !dimension || !style) continue;
|
|
3878
|
+
const frame = bracket ? {
|
|
3879
|
+
...bracket.bracket.frame,
|
|
3880
|
+
x: fragment.frame.x + bracket.bracket.frame.x,
|
|
3881
|
+
y: fragment.frame.y + bracket.bracket.frame.y
|
|
3882
|
+
} : {
|
|
3883
|
+
x: fragment.frame.x + (side === "start" ? -4 : fragment.frame.width),
|
|
3884
|
+
y: fragment.frame.y,
|
|
3885
|
+
width: 4,
|
|
3886
|
+
height: fragment.frame.height
|
|
3887
|
+
};
|
|
3888
|
+
const scaleX = dimension.width / (surface.page.bodyTableOverflow?.right ?? surface.page.width);
|
|
3889
|
+
const scaleY = dimension.height / surface.page.height;
|
|
3890
|
+
let layer = this.layers.get(pageId);
|
|
3891
|
+
if (!layer) {
|
|
3892
|
+
layer = host.ownerDocument.createElement("div");
|
|
3893
|
+
layer.className = "gct-word-field-brackets";
|
|
3894
|
+
layer.dataset.wordBracketPage = pageId;
|
|
3895
|
+
layer.setAttribute("aria-hidden", "true");
|
|
3896
|
+
Object.assign(layer.style, {
|
|
3897
|
+
position: "absolute",
|
|
3898
|
+
inset: "0",
|
|
3899
|
+
pointerEvents: "none",
|
|
3900
|
+
zIndex: "6"
|
|
3901
|
+
});
|
|
3902
|
+
this.layers.set(pageId, layer);
|
|
3903
|
+
}
|
|
3904
|
+
if (layer.parentElement !== dimension.parent) dimension.parent.append(layer);
|
|
3905
|
+
let node = this.nodes.get(side);
|
|
3906
|
+
if (!node) {
|
|
3907
|
+
node = host.ownerDocument.createElement("div");
|
|
3908
|
+
node.className = "gct-word-input-field-active";
|
|
3909
|
+
node.dataset.side = side;
|
|
3910
|
+
const stroke = host.ownerDocument.createElement("div");
|
|
3911
|
+
Object.assign(stroke.style, {
|
|
3912
|
+
width: "100%",
|
|
3913
|
+
height: "100%",
|
|
3914
|
+
boxSizing: "border-box",
|
|
3915
|
+
borderTop: "2px solid currentColor",
|
|
3916
|
+
borderBottom: "2px solid currentColor",
|
|
3917
|
+
...side === "start" ? { borderLeft: "2px solid currentColor" } : { borderRight: "2px solid currentColor" }
|
|
3918
|
+
});
|
|
3919
|
+
node.append(stroke);
|
|
3920
|
+
this.nodes.set(side, node);
|
|
3921
|
+
}
|
|
3922
|
+
Object.assign(node.style, {
|
|
3923
|
+
position: "absolute",
|
|
3924
|
+
left: `${surface.canvas.offsetLeft + frame.x * scaleX}px`,
|
|
3925
|
+
top: `${surface.canvas.offsetTop + frame.y * scaleY}px`,
|
|
3926
|
+
width: `${frame.width * scaleX}px`,
|
|
3927
|
+
height: `${frame.height * scaleY}px`,
|
|
3928
|
+
background: surface.page.backgroundColor ?? "#fff"
|
|
3929
|
+
});
|
|
3930
|
+
node.firstElementChild.style.color = fragment.fieldControl.decoration?.markerColor ?? style.color;
|
|
3931
|
+
if (node.parentElement !== layer) layer.append(node);
|
|
3932
|
+
activePages.add(pageId);
|
|
3933
|
+
activeSides.add(side);
|
|
3934
|
+
}
|
|
3935
|
+
for (const [side, node] of this.nodes) if (!activeSides.has(side)) {
|
|
3936
|
+
node.remove();
|
|
3937
|
+
this.nodes.delete(side);
|
|
3938
|
+
}
|
|
3939
|
+
for (const [id, layer] of this.layers) if (!activePages.has(id)) {
|
|
3940
|
+
layer.remove();
|
|
3941
|
+
this.layers.delete(id);
|
|
3942
|
+
}
|
|
3943
|
+
this.rendered = {
|
|
3944
|
+
revision: snapshot.result.version.layoutRevision,
|
|
3945
|
+
fieldId: selection.fieldId,
|
|
3946
|
+
instanceKey: selection.instanceKey,
|
|
3947
|
+
pages: dimensions
|
|
3948
|
+
};
|
|
3949
|
+
}
|
|
3950
|
+
clear() {
|
|
3951
|
+
for (const layer of this.layers.values()) layer.remove();
|
|
3952
|
+
this.layers.clear();
|
|
3953
|
+
this.nodes.clear();
|
|
3954
|
+
this.rendered = void 0;
|
|
3955
|
+
}
|
|
3956
|
+
};
|
|
3717
3957
|
// src/adapters/browser/input/CanvasOptionInput.ts
|
|
3718
3958
|
/** @file 画布选项只拥有当前激活和可撤销逻辑意图,不创建逐选项 DOM 或缓存页面。 */
|
|
3719
3959
|
/** radio/checkbox 的直接点击与键盘清空,显示继续由 Canvas 统一绘制。 */
|
|
@@ -3870,12 +4110,334 @@ var CanvasOptionInput = class {
|
|
|
3870
4110
|
} catch {}
|
|
3871
4111
|
}
|
|
3872
4112
|
};
|
|
4113
|
+
// src/shared/word-shortcuts.ts
|
|
4114
|
+
/** 截图中的重复场景共用同一个物理键位;未实现的产品动作也先预留。 */
|
|
4115
|
+
var productWordShortcuts = [
|
|
4116
|
+
{
|
|
4117
|
+
id: "copy",
|
|
4118
|
+
label: "复制",
|
|
4119
|
+
code: "KeyC",
|
|
4120
|
+
primary: true,
|
|
4121
|
+
state: "ready"
|
|
4122
|
+
},
|
|
4123
|
+
{
|
|
4124
|
+
id: "cut",
|
|
4125
|
+
label: "剪切",
|
|
4126
|
+
code: "KeyX",
|
|
4127
|
+
primary: true,
|
|
4128
|
+
state: "ready"
|
|
4129
|
+
},
|
|
4130
|
+
{
|
|
4131
|
+
id: "paste",
|
|
4132
|
+
label: "粘贴",
|
|
4133
|
+
code: "KeyV",
|
|
4134
|
+
primary: true,
|
|
4135
|
+
state: "ready"
|
|
4136
|
+
},
|
|
4137
|
+
{
|
|
4138
|
+
id: "undo",
|
|
4139
|
+
label: "撤销",
|
|
4140
|
+
code: "KeyZ",
|
|
4141
|
+
primary: true,
|
|
4142
|
+
state: "ready"
|
|
4143
|
+
},
|
|
4144
|
+
{
|
|
4145
|
+
id: "redo",
|
|
4146
|
+
label: "重做",
|
|
4147
|
+
code: "KeyZ",
|
|
4148
|
+
primary: true,
|
|
4149
|
+
shift: true,
|
|
4150
|
+
state: "ready"
|
|
4151
|
+
},
|
|
4152
|
+
{
|
|
4153
|
+
id: "save",
|
|
4154
|
+
label: "保存",
|
|
4155
|
+
code: "KeyS",
|
|
4156
|
+
primary: true,
|
|
4157
|
+
state: "reserved"
|
|
4158
|
+
},
|
|
4159
|
+
{
|
|
4160
|
+
id: "insertTable",
|
|
4161
|
+
label: "插入表格",
|
|
4162
|
+
code: "KeyT",
|
|
4163
|
+
primary: true,
|
|
4164
|
+
state: "reserved"
|
|
4165
|
+
},
|
|
4166
|
+
{
|
|
4167
|
+
id: "mergeCells",
|
|
4168
|
+
label: "合并/拆分单元格",
|
|
4169
|
+
code: "KeyD",
|
|
4170
|
+
alt: true,
|
|
4171
|
+
shift: true,
|
|
4172
|
+
state: "reserved"
|
|
4173
|
+
},
|
|
4174
|
+
{
|
|
4175
|
+
id: "tableHeader",
|
|
4176
|
+
label: "添加表头",
|
|
4177
|
+
code: "KeyT",
|
|
4178
|
+
alt: true,
|
|
4179
|
+
state: "reserved"
|
|
4180
|
+
},
|
|
4181
|
+
{
|
|
4182
|
+
id: "fixedTable",
|
|
4183
|
+
label: "添加固定表",
|
|
4184
|
+
code: "KeyG",
|
|
4185
|
+
alt: true,
|
|
4186
|
+
state: "reserved"
|
|
4187
|
+
},
|
|
4188
|
+
{
|
|
4189
|
+
id: "dynamicTable",
|
|
4190
|
+
label: "添加动态表",
|
|
4191
|
+
code: "KeyD",
|
|
4192
|
+
alt: true,
|
|
4193
|
+
state: "reserved"
|
|
4194
|
+
},
|
|
4195
|
+
{
|
|
4196
|
+
id: "matrixTable",
|
|
4197
|
+
label: "添加二维表",
|
|
4198
|
+
code: "KeyE",
|
|
4199
|
+
alt: true,
|
|
4200
|
+
state: "reserved"
|
|
4201
|
+
},
|
|
4202
|
+
{
|
|
4203
|
+
id: "dataGroup",
|
|
4204
|
+
label: "数据分组",
|
|
4205
|
+
code: "KeyF",
|
|
4206
|
+
alt: true,
|
|
4207
|
+
state: "reserved"
|
|
4208
|
+
},
|
|
4209
|
+
{
|
|
4210
|
+
id: "dynamicRelation",
|
|
4211
|
+
label: "动态关联",
|
|
4212
|
+
code: "KeyL",
|
|
4213
|
+
alt: true,
|
|
4214
|
+
state: "reserved"
|
|
4215
|
+
},
|
|
4216
|
+
{
|
|
4217
|
+
id: "indent",
|
|
4218
|
+
label: "正文增加缩进",
|
|
4219
|
+
code: "Tab",
|
|
4220
|
+
state: "table"
|
|
4221
|
+
},
|
|
4222
|
+
{
|
|
4223
|
+
id: "outdent",
|
|
4224
|
+
label: "正文减少缩进",
|
|
4225
|
+
code: "Tab",
|
|
4226
|
+
shift: true,
|
|
4227
|
+
state: "table"
|
|
4228
|
+
},
|
|
4229
|
+
{
|
|
4230
|
+
id: "paragraph",
|
|
4231
|
+
label: "分段",
|
|
4232
|
+
code: "Enter",
|
|
4233
|
+
state: "ready"
|
|
4234
|
+
},
|
|
4235
|
+
{
|
|
4236
|
+
id: "lineBreak",
|
|
4237
|
+
label: "软换行",
|
|
4238
|
+
code: "Enter",
|
|
4239
|
+
shift: true,
|
|
4240
|
+
state: "ready"
|
|
4241
|
+
},
|
|
4242
|
+
{
|
|
4243
|
+
id: "bold",
|
|
4244
|
+
label: "加粗",
|
|
4245
|
+
code: "KeyB",
|
|
4246
|
+
primary: true,
|
|
4247
|
+
state: "reserved"
|
|
4248
|
+
},
|
|
4249
|
+
{
|
|
4250
|
+
id: "italic",
|
|
4251
|
+
label: "倾斜",
|
|
4252
|
+
code: "KeyI",
|
|
4253
|
+
primary: true,
|
|
4254
|
+
state: "reserved"
|
|
4255
|
+
},
|
|
4256
|
+
{
|
|
4257
|
+
id: "underline",
|
|
4258
|
+
label: "下划线",
|
|
4259
|
+
code: "KeyU",
|
|
4260
|
+
primary: true,
|
|
4261
|
+
state: "reserved"
|
|
4262
|
+
},
|
|
4263
|
+
{
|
|
4264
|
+
id: "strike",
|
|
4265
|
+
label: "删除线",
|
|
4266
|
+
code: "KeyX",
|
|
4267
|
+
primary: true,
|
|
4268
|
+
shift: true,
|
|
4269
|
+
state: "reserved"
|
|
4270
|
+
},
|
|
4271
|
+
{
|
|
4272
|
+
id: "fontColor",
|
|
4273
|
+
label: "字体颜色",
|
|
4274
|
+
code: "KeyC",
|
|
4275
|
+
primary: true,
|
|
4276
|
+
alt: true,
|
|
4277
|
+
state: "reserved"
|
|
4278
|
+
},
|
|
4279
|
+
{
|
|
4280
|
+
id: "background",
|
|
4281
|
+
label: "背景颜色",
|
|
4282
|
+
code: "KeyH",
|
|
4283
|
+
primary: true,
|
|
4284
|
+
alt: true,
|
|
4285
|
+
state: "reserved"
|
|
4286
|
+
},
|
|
4287
|
+
{
|
|
4288
|
+
id: "alignLeft",
|
|
4289
|
+
label: "左对齐",
|
|
4290
|
+
code: "KeyL",
|
|
4291
|
+
primary: true,
|
|
4292
|
+
shift: true,
|
|
4293
|
+
state: "reserved"
|
|
4294
|
+
},
|
|
4295
|
+
{
|
|
4296
|
+
id: "alignRight",
|
|
4297
|
+
label: "右对齐",
|
|
4298
|
+
code: "KeyR",
|
|
4299
|
+
primary: true,
|
|
4300
|
+
shift: true,
|
|
4301
|
+
state: "reserved"
|
|
4302
|
+
},
|
|
4303
|
+
{
|
|
4304
|
+
id: "alignCenter",
|
|
4305
|
+
label: "居中对齐",
|
|
4306
|
+
code: "KeyC",
|
|
4307
|
+
primary: true,
|
|
4308
|
+
shift: true,
|
|
4309
|
+
state: "reserved"
|
|
4310
|
+
},
|
|
4311
|
+
{
|
|
4312
|
+
id: "alignJustify",
|
|
4313
|
+
label: "两端对齐",
|
|
4314
|
+
code: "KeyJ",
|
|
4315
|
+
primary: true,
|
|
4316
|
+
shift: true,
|
|
4317
|
+
state: "reserved"
|
|
4318
|
+
},
|
|
4319
|
+
{
|
|
4320
|
+
id: "rowBefore",
|
|
4321
|
+
label: "在上方插入行",
|
|
4322
|
+
code: "ArrowUp",
|
|
4323
|
+
alt: true,
|
|
4324
|
+
state: "reserved"
|
|
4325
|
+
},
|
|
4326
|
+
{
|
|
4327
|
+
id: "rowAfter",
|
|
4328
|
+
label: "在下方插入行",
|
|
4329
|
+
code: "ArrowDown",
|
|
4330
|
+
alt: true,
|
|
4331
|
+
state: "reserved"
|
|
4332
|
+
},
|
|
4333
|
+
{
|
|
4334
|
+
id: "columnBefore",
|
|
4335
|
+
label: "在左侧插入列",
|
|
4336
|
+
code: "ArrowLeft",
|
|
4337
|
+
alt: true,
|
|
4338
|
+
state: "reserved"
|
|
4339
|
+
},
|
|
4340
|
+
{
|
|
4341
|
+
id: "columnAfter",
|
|
4342
|
+
label: "在右侧插入列",
|
|
4343
|
+
code: "ArrowRight",
|
|
4344
|
+
alt: true,
|
|
4345
|
+
state: "reserved"
|
|
4346
|
+
},
|
|
4347
|
+
{
|
|
4348
|
+
id: "removeRows",
|
|
4349
|
+
label: "删除所选行",
|
|
4350
|
+
code: "Minus",
|
|
4351
|
+
alt: true,
|
|
4352
|
+
shift: true,
|
|
4353
|
+
state: "reserved"
|
|
4354
|
+
},
|
|
4355
|
+
{
|
|
4356
|
+
id: "removeColumns",
|
|
4357
|
+
label: "删除所选列",
|
|
4358
|
+
code: "Minus",
|
|
4359
|
+
primary: true,
|
|
4360
|
+
alt: true,
|
|
4361
|
+
state: "reserved"
|
|
4362
|
+
},
|
|
4363
|
+
{
|
|
4364
|
+
id: "up",
|
|
4365
|
+
label: "光标上移",
|
|
4366
|
+
code: "ArrowUp",
|
|
4367
|
+
state: "ready"
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
id: "down",
|
|
4371
|
+
label: "光标下移",
|
|
4372
|
+
code: "ArrowDown",
|
|
4373
|
+
state: "ready"
|
|
4374
|
+
},
|
|
4375
|
+
{
|
|
4376
|
+
id: "left",
|
|
4377
|
+
label: "光标左移",
|
|
4378
|
+
code: "ArrowLeft",
|
|
4379
|
+
state: "ready"
|
|
4380
|
+
},
|
|
4381
|
+
{
|
|
4382
|
+
id: "right",
|
|
4383
|
+
label: "光标右移",
|
|
4384
|
+
code: "ArrowRight",
|
|
4385
|
+
state: "ready"
|
|
4386
|
+
},
|
|
4387
|
+
{
|
|
4388
|
+
id: "help",
|
|
4389
|
+
label: "打开/关闭快捷键面板",
|
|
4390
|
+
code: "Slash",
|
|
4391
|
+
primary: true,
|
|
4392
|
+
state: "reserved"
|
|
4393
|
+
}
|
|
4394
|
+
];
|
|
4395
|
+
/** Option 会改变字母的 event.key;优先使用物理 code,合成设备缺少 code 时才回退。 */
|
|
4396
|
+
function keyCode(event) {
|
|
4397
|
+
if (event.code && event.code !== "Unidentified") return event.code === "NumpadEnter" ? "Enter" : event.code === "NumpadSubtract" ? "Minus" : event.code;
|
|
4398
|
+
if (/^[a-z]$/i.test(event.key)) return `Key${event.key.toUpperCase()}`;
|
|
4399
|
+
if ([
|
|
4400
|
+
"-",
|
|
4401
|
+
"_",
|
|
4402
|
+
"−"
|
|
4403
|
+
].includes(event.key)) return "Minus";
|
|
4404
|
+
if (event.key === "/" || event.key === "?") return "Slash";
|
|
4405
|
+
return event.key;
|
|
4406
|
+
}
|
|
4407
|
+
function matches(event, shortcut) {
|
|
4408
|
+
return keyCode(event) === shortcut.code && Number(event.ctrlKey) + Number(event.metaKey) === (shortcut.primary ? 1 : 0) && event.altKey === !!shortcut.alt && event.shiftKey === !!shortcut.shift;
|
|
4409
|
+
}
|
|
4410
|
+
function productWordShortcut(event) {
|
|
4411
|
+
return productWordShortcuts.find((shortcut) => matches(event, shortcut));
|
|
4412
|
+
}
|
|
4413
|
+
/** 原字段 Tab 顺序迁移到主修饰键加 Enter;Shift 反向,普通 Tab 留给产品。 */
|
|
4414
|
+
function isFieldNavigationShortcut(event) {
|
|
4415
|
+
return matches(event, {
|
|
4416
|
+
code: "Enter",
|
|
4417
|
+
primary: true,
|
|
4418
|
+
shift: event.shiftKey || void 0
|
|
4419
|
+
});
|
|
4420
|
+
}
|
|
4421
|
+
/** 原 Option 方向键迁移为主修饰键 + Option + Shift + 方向键,Shift 在这里属于组合本身。 */
|
|
4422
|
+
function localNavigationShortcut(event) {
|
|
4423
|
+
for (const [code, action] of [
|
|
4424
|
+
["ArrowUp", "up"],
|
|
4425
|
+
["ArrowDown", "down"],
|
|
4426
|
+
["ArrowLeft", "wordLeft"],
|
|
4427
|
+
["ArrowRight", "wordRight"]
|
|
4428
|
+
]) if (matches(event, {
|
|
4429
|
+
code,
|
|
4430
|
+
primary: true,
|
|
4431
|
+
alt: true,
|
|
4432
|
+
shift: true
|
|
4433
|
+
})) return action;
|
|
4434
|
+
}
|
|
3873
4435
|
// src/adapters/browser/input/ChoiceFieldInput.ts
|
|
3874
4436
|
/** @file 选择字段只协调当前发生、锚点和受控写入;下拉 UI 由宿主注入。 */
|
|
3875
4437
|
var ChoiceFieldInput = class {
|
|
3876
4438
|
options;
|
|
3877
4439
|
restoreFocus;
|
|
3878
|
-
|
|
4440
|
+
navigateField;
|
|
3879
4441
|
lifetime;
|
|
3880
4442
|
active;
|
|
3881
4443
|
panel;
|
|
@@ -3885,10 +4447,15 @@ var ChoiceFieldInput = class {
|
|
|
3885
4447
|
focusPending = false;
|
|
3886
4448
|
paused = false;
|
|
3887
4449
|
observer;
|
|
3888
|
-
|
|
4450
|
+
geometry;
|
|
4451
|
+
measureDirty = true;
|
|
4452
|
+
measuredWidth = 0;
|
|
4453
|
+
contentHeight = 320;
|
|
4454
|
+
rendered;
|
|
4455
|
+
constructor(options, restoreFocus, navigateField) {
|
|
3889
4456
|
this.options = options;
|
|
3890
4457
|
this.restoreFocus = restoreFocus;
|
|
3891
|
-
this.
|
|
4458
|
+
this.navigateField = navigateField;
|
|
3892
4459
|
}
|
|
3893
4460
|
isOpenFor(selection) {
|
|
3894
4461
|
return !!this.active && this.active.base.selection.fieldId === selection.fieldId && this.active.base.selection.instanceKey === selection.instanceKey;
|
|
@@ -3921,6 +4488,7 @@ var ChoiceFieldInput = class {
|
|
|
3921
4488
|
pointerEvents: "none"
|
|
3922
4489
|
});
|
|
3923
4490
|
owner.body.append(panel);
|
|
4491
|
+
this.geometry = new FieldPanelGeometry(options.host, () => this.refresh());
|
|
3924
4492
|
this.view = options.renderChoicePanel({
|
|
3925
4493
|
container: panel,
|
|
3926
4494
|
state,
|
|
@@ -3933,7 +4501,10 @@ var ChoiceFieldInput = class {
|
|
|
3933
4501
|
});
|
|
3934
4502
|
const Observer = owner.defaultView?.ResizeObserver;
|
|
3935
4503
|
if (Observer && panel.firstElementChild) {
|
|
3936
|
-
this.observer = new Observer(() =>
|
|
4504
|
+
this.observer = new Observer(() => {
|
|
4505
|
+
this.measureDirty = true;
|
|
4506
|
+
this.geometry?.schedule();
|
|
4507
|
+
});
|
|
3937
4508
|
this.observer.observe(panel.firstElementChild);
|
|
3938
4509
|
}
|
|
3939
4510
|
panel.addEventListener("keydown", (event) => {
|
|
@@ -3942,7 +4513,11 @@ var ChoiceFieldInput = class {
|
|
|
3942
4513
|
event.preventDefault();
|
|
3943
4514
|
event.stopPropagation();
|
|
3944
4515
|
this.close(true);
|
|
3945
|
-
} else if (event
|
|
4516
|
+
} else if (isFieldNavigationShortcut(event)) {
|
|
4517
|
+
event.preventDefault();
|
|
4518
|
+
event.stopPropagation();
|
|
4519
|
+
this.navigateField?.(event);
|
|
4520
|
+
}
|
|
3946
4521
|
}, {
|
|
3947
4522
|
capture: true,
|
|
3948
4523
|
signal
|
|
@@ -3958,12 +4533,6 @@ var ChoiceFieldInput = class {
|
|
|
3958
4533
|
capture: true,
|
|
3959
4534
|
signal
|
|
3960
4535
|
});
|
|
3961
|
-
owner.addEventListener("scroll", () => this.refresh(), {
|
|
3962
|
-
capture: true,
|
|
3963
|
-
passive: true,
|
|
3964
|
-
signal
|
|
3965
|
-
});
|
|
3966
|
-
owner.defaultView?.addEventListener("resize", () => this.refresh(), { signal });
|
|
3967
4536
|
owner.defaultView?.addEventListener("blur", () => this.close(), { signal });
|
|
3968
4537
|
owner.addEventListener("visibilitychange", () => {
|
|
3969
4538
|
if (owner.hidden) this.close();
|
|
@@ -3972,6 +4541,7 @@ var ChoiceFieldInput = class {
|
|
|
3972
4541
|
return true;
|
|
3973
4542
|
}
|
|
3974
4543
|
refresh() {
|
|
4544
|
+
this.geometry?.cancel();
|
|
3975
4545
|
const options = this.options, active = this.active, panel = this.panel;
|
|
3976
4546
|
if (!options || !active || !panel || this.writing) return;
|
|
3977
4547
|
panel.style.zIndex = inputOverlayZIndex(options.host, 10);
|
|
@@ -4002,7 +4572,13 @@ var ChoiceFieldInput = class {
|
|
|
4002
4572
|
if (anchor.kind === "ready" && rect) {
|
|
4003
4573
|
active.placement = anchor.placement;
|
|
4004
4574
|
const available = anchor.viewport.top + anchor.viewport.height;
|
|
4005
|
-
|
|
4575
|
+
if (this.measureDirty || this.measuredWidth !== rect.width) {
|
|
4576
|
+
panel.style.width = `${rect.width}px`;
|
|
4577
|
+
this.contentHeight = panel.scrollHeight || 320;
|
|
4578
|
+
this.measuredWidth = rect.width;
|
|
4579
|
+
this.measureDirty = false;
|
|
4580
|
+
}
|
|
4581
|
+
const desired = Math.min(this.contentHeight, anchor.viewport.height - 8);
|
|
4006
4582
|
const below = available - anchor.rect.top - anchor.rect.height - 4;
|
|
4007
4583
|
const above = anchor.rect.top - anchor.viewport.top - 4;
|
|
4008
4584
|
const down = below >= desired || below >= above;
|
|
@@ -4021,7 +4597,13 @@ var ChoiceFieldInput = class {
|
|
|
4021
4597
|
panel.inert = disabled;
|
|
4022
4598
|
panel.toggleAttribute("inert", disabled);
|
|
4023
4599
|
panel.setAttribute("aria-busy", String(current.pending));
|
|
4024
|
-
this.
|
|
4600
|
+
if (!this.rendered || this.rendered.disabled !== disabled || !isEqual(this.rendered.state, current)) {
|
|
4601
|
+
this.view?.update(current, disabled);
|
|
4602
|
+
this.rendered = {
|
|
4603
|
+
state: current,
|
|
4604
|
+
disabled
|
|
4605
|
+
};
|
|
4606
|
+
}
|
|
4025
4607
|
if (this.focusPending && !disabled) {
|
|
4026
4608
|
this.focusPending = false;
|
|
4027
4609
|
this.view?.focus();
|
|
@@ -4056,6 +4638,11 @@ var ChoiceFieldInput = class {
|
|
|
4056
4638
|
}
|
|
4057
4639
|
}
|
|
4058
4640
|
close(restore = false) {
|
|
4641
|
+
this.geometry?.dispose();
|
|
4642
|
+
this.geometry = void 0;
|
|
4643
|
+
this.rendered = void 0;
|
|
4644
|
+
this.measureDirty = true;
|
|
4645
|
+
this.measuredWidth = 0;
|
|
4059
4646
|
this.observer?.disconnect();
|
|
4060
4647
|
this.observer = void 0;
|
|
4061
4648
|
this.active = void 0;
|
|
@@ -4073,7 +4660,7 @@ var ChoiceFieldInput = class {
|
|
|
4073
4660
|
this.close();
|
|
4074
4661
|
this.options = void 0;
|
|
4075
4662
|
this.restoreFocus = void 0;
|
|
4076
|
-
this.
|
|
4663
|
+
this.navigateField = void 0;
|
|
4077
4664
|
}
|
|
4078
4665
|
};
|
|
4079
4666
|
// src/adapters/browser/input/clipboard/html-style.ts
|
|
@@ -4744,15 +5331,15 @@ var FieldInputValidation = class {
|
|
|
4744
5331
|
}, 300);
|
|
4745
5332
|
}
|
|
4746
5333
|
async run(controller, check, publish) {
|
|
4747
|
-
let
|
|
5334
|
+
let messages;
|
|
4748
5335
|
try {
|
|
4749
|
-
|
|
5336
|
+
messages = await check(controller.signal);
|
|
4750
5337
|
} catch {
|
|
4751
|
-
|
|
5338
|
+
messages = ["数值校验未完成,请重试"];
|
|
4752
5339
|
}
|
|
4753
5340
|
if (!controller.signal.aborted && this.controller === controller) {
|
|
4754
5341
|
this.controller = void 0;
|
|
4755
|
-
publish(
|
|
5342
|
+
publish(messages);
|
|
4756
5343
|
}
|
|
4757
5344
|
}
|
|
4758
5345
|
cancel() {
|
|
@@ -4936,66 +5523,6 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
|
|
|
4936
5523
|
});
|
|
4937
5524
|
children.push(node);
|
|
4938
5525
|
}
|
|
4939
|
-
if (fieldActive && state.selection?.kind === "field") {
|
|
4940
|
-
const fragments = snapshot.query.findBySource({
|
|
4941
|
-
nodeId: state.selection.fieldId,
|
|
4942
|
-
instanceKey: state.selection.instanceKey
|
|
4943
|
-
}).filter((fragment) => fragment.kind === "atom" && !!fragment.fieldControl);
|
|
4944
|
-
const brackets = fragments.flatMap((fragment) => {
|
|
4945
|
-
if (fragment.kind !== "atom" || !fragment.fieldControl) return [];
|
|
4946
|
-
const control = fragment.fieldControl;
|
|
4947
|
-
const style = snapshot.result.paintStyles[control.paintStyleKey];
|
|
4948
|
-
return style ? (control.bracketTexts ?? []).map((text) => ({
|
|
4949
|
-
fragment,
|
|
4950
|
-
text,
|
|
4951
|
-
style,
|
|
4952
|
-
control
|
|
4953
|
-
})) : [];
|
|
4954
|
-
});
|
|
4955
|
-
for (const side of ["start", "end"]) {
|
|
4956
|
-
const bracket = side === "start" ? brackets.find((item) => item.text.text === "[") : [...brackets].reverse().find((item) => item.text.text === "]");
|
|
4957
|
-
const fragment = bracket?.fragment ?? (side === "start" ? fragments[0] : fragments.at(-1));
|
|
4958
|
-
if (fragment?.kind !== "atom" || !fragment.fieldControl) continue;
|
|
4959
|
-
const pageId = snapshot.query.getFragmentPageId(fragment.id);
|
|
4960
|
-
const page = pageId && pages.get(pageId);
|
|
4961
|
-
const style = bracket?.style ?? snapshot.result.paintStyles[fragment.fieldControl.paintStyleKey];
|
|
4962
|
-
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
|
|
4970
|
-
}, page);
|
|
4971
|
-
const screen = clipInputRect(rect, clip);
|
|
4972
|
-
if (!screen) continue;
|
|
4973
|
-
const node = owner.createElement("div");
|
|
4974
|
-
const stroke = owner.createElement("div");
|
|
4975
|
-
node.className = "gct-word-input-field-active";
|
|
4976
|
-
node.dataset.side = side;
|
|
4977
|
-
Object.assign(node.style, {
|
|
4978
|
-
position: "fixed",
|
|
4979
|
-
left: `${rect.left}px`,
|
|
4980
|
-
top: `${rect.top}px`,
|
|
4981
|
-
width: `${rect.width}px`,
|
|
4982
|
-
height: `${rect.height}px`,
|
|
4983
|
-
background: page.page.backgroundColor ?? "#fff",
|
|
4984
|
-
clipPath: `inset(${screen.top - rect.top}px ${rect.left + rect.width - screen.left - screen.width}px ${rect.top + rect.height - screen.top - screen.height}px ${screen.left - rect.left}px)`
|
|
4985
|
-
});
|
|
4986
|
-
Object.assign(stroke.style, {
|
|
4987
|
-
width: "100%",
|
|
4988
|
-
height: "100%",
|
|
4989
|
-
boxSizing: "border-box",
|
|
4990
|
-
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" }
|
|
4994
|
-
});
|
|
4995
|
-
node.append(stroke);
|
|
4996
|
-
children.push(node);
|
|
4997
|
-
}
|
|
4998
|
-
}
|
|
4999
5526
|
const caret = visual.compositionCaret ?? visual.caret, page = caret && pages.get(caret.pageId);
|
|
5000
5527
|
if (!caret || !page || !inputVersionMatches(caret.version, snapshot)) {
|
|
5001
5528
|
layer.replaceChildren(...children);
|
|
@@ -5094,6 +5621,79 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
|
|
|
5094
5621
|
layer.replaceChildren(...children);
|
|
5095
5622
|
return state.composition ? typingScreen : screen;
|
|
5096
5623
|
}
|
|
5624
|
+
// src/runtime/interaction/editor-diagnostic.ts
|
|
5625
|
+
/** @file 从异常读取稳定的诊断代码,界面决定如何显示,不传递调试路径和原始描述。 */
|
|
5626
|
+
/** 未识别的外部异常由调用者决定如何兜底。 */
|
|
5627
|
+
function readEditorDiagnostic(error) {
|
|
5628
|
+
if (error instanceof DocumentValidationError) return {
|
|
5629
|
+
kind: "validation",
|
|
5630
|
+
codes: error.issues.map(({ code }) => code)
|
|
5631
|
+
};
|
|
5632
|
+
if (error instanceof ModelEditError) return {
|
|
5633
|
+
kind: "model",
|
|
5634
|
+
code: error.code
|
|
5635
|
+
};
|
|
5636
|
+
}
|
|
5637
|
+
// src/adapters/browser/input/word-error-text.ts
|
|
5638
|
+
/** @file 把 Word 可识别的失败转换为可展示的中文,原始异常仍留给宿主诊断。 */
|
|
5639
|
+
/** 当前草稿不能提交时,明确切换操作使用宿主的警告消息。 */
|
|
5640
|
+
var FieldInputBlockedError = class extends Error {
|
|
5641
|
+
constructor() {
|
|
5642
|
+
super("当前字段的输入不符合要求,暂时无法切换到其他字段,请先修正或按 Esc 取消输入。");
|
|
5643
|
+
this.name = "FieldInputBlockedError";
|
|
5644
|
+
}
|
|
5645
|
+
};
|
|
5646
|
+
/** 编辑器可以明确告诉用户如何修正的模型错误。 */
|
|
5647
|
+
var modelMessages = {
|
|
5648
|
+
table_merge: "请选择完整的单元格矩形,已有合并格需完整包含",
|
|
5649
|
+
table_range: "请选择同一张表内的有效单元格范围",
|
|
5650
|
+
table_size: "请检查表格的行列数量和列宽",
|
|
5651
|
+
table_region: "当前操作会影响表格的区域设置,请先检查选区",
|
|
5652
|
+
range: "操作范围或数量无效,请检查选区和输入值",
|
|
5653
|
+
content_flow: "当前选区跨越了不同内容区域,请重新选择"
|
|
5654
|
+
};
|
|
5655
|
+
/** 文档结构和属性校验的中文提示,合并相同原因。 */
|
|
5656
|
+
var validationMessages = {
|
|
5657
|
+
nested_table: "当前位置不允许插入嵌套表格",
|
|
5658
|
+
number: "请输入有效的数值,宽度和高度须大于 0,内边距和边框宽度可为 0",
|
|
5659
|
+
enum: "当前设置值不可用,请重新选择",
|
|
5660
|
+
type: "输入值的格式不正确,请检查设置"
|
|
5661
|
+
};
|
|
5662
|
+
/** 识别已经适合展示的中文,结构化错误优先使用稳定的代码。 */
|
|
5663
|
+
function readWordErrorText(error) {
|
|
5664
|
+
const diagnostic = readEditorDiagnostic(error);
|
|
5665
|
+
if (diagnostic?.kind === "validation") {
|
|
5666
|
+
const messages = new Set(diagnostic.codes.flatMap((code) => Object.hasOwn(validationMessages, code) ? validationMessages[code] ?? [] : []));
|
|
5667
|
+
return messages.size ? [...messages].join("。") : void 0;
|
|
5668
|
+
}
|
|
5669
|
+
if (diagnostic?.kind === "model") return Object.hasOwn(modelMessages, diagnostic.code) ? modelMessages[diagnostic.code] : void 0;
|
|
5670
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
5671
|
+
if (/^\p{Script=Han}[^\n]*$/u.test(message)) return message;
|
|
5672
|
+
}
|
|
5673
|
+
/** 模型校验和用户输入错误用警告,其余未知故障由界面使用错误提示。 */
|
|
5674
|
+
function isWordValidationError(error) {
|
|
5675
|
+
const diagnostic = readEditorDiagnostic(error);
|
|
5676
|
+
return error instanceof FieldInputBlockedError || diagnostic?.kind === "validation" || diagnostic?.kind === "model" && Object.hasOwn(modelMessages, diagnostic.code);
|
|
5677
|
+
}
|
|
5678
|
+
/** 主动取消和已撤销的请求属于正常清理,不需要用户处理。 */
|
|
5679
|
+
function isWordCancellation(error) {
|
|
5680
|
+
return !!error && typeof error === "object" && "name" in error && error.name === "AbortError";
|
|
5681
|
+
}
|
|
5682
|
+
/** 隐藏的备用面板不能接管当前用户看不到的反馈。 */
|
|
5683
|
+
function hasLocalWordFeedback(node) {
|
|
5684
|
+
return !!node?.isConnected && !node.closest("[hidden]");
|
|
5685
|
+
}
|
|
5686
|
+
/** 面板是当前操作的反馈位置,已有全局回调也不撤掉局部错误。 */
|
|
5687
|
+
function wordPanelErrorText(error, fallback) {
|
|
5688
|
+
return isWordCancellation(error) ? "" : readWordErrorText(error) ?? fallback;
|
|
5689
|
+
}
|
|
5690
|
+
/** 已显示在当前弹框/面板的错误就地消化,缺少局部位置才交给宿主。 */
|
|
5691
|
+
function reportUnhandledWordError(error, handled, report) {
|
|
5692
|
+
if (handled || isWordCancellation(error)) return;
|
|
5693
|
+
try {
|
|
5694
|
+
report?.(error);
|
|
5695
|
+
} catch {}
|
|
5696
|
+
}
|
|
5097
5697
|
// src/adapters/browser/input/InlineFieldInput.ts
|
|
5098
5698
|
/** @file 单个活动文本/数字字段的无边框原位编辑,候选与未完成数字只存在当前 DOM 草稿。 */
|
|
5099
5699
|
/** 一份 DOM 输入支持当前字段,切换字段、关闭或外部换值后撤销旧事件。 */
|
|
@@ -5138,7 +5738,7 @@ var InlineFieldInput = class {
|
|
|
5138
5738
|
measurer;
|
|
5139
5739
|
/** 独占测量背板在退出时归零。 */
|
|
5140
5740
|
measureCanvas;
|
|
5141
|
-
/**
|
|
5741
|
+
/** 正文与原位字段共用产品键位预留和字段导航,新输入会撤销等待。 */
|
|
5142
5742
|
keyboard;
|
|
5143
5743
|
/** 创建固定的活动输入,不初始化业务值或加载资源。 */
|
|
5144
5744
|
constructor(options, keyboard) {
|
|
@@ -5331,7 +5931,7 @@ var InlineFieldInput = class {
|
|
|
5331
5931
|
layer.style.pointerEvents = "none";
|
|
5332
5932
|
return;
|
|
5333
5933
|
}
|
|
5334
|
-
this.showMessage(this.composing ? void 0 : this.failure ?? (!active.dirty && !(active.base.widget === "input" && active.preview) ? state.
|
|
5934
|
+
this.showMessage(this.composing ? void 0 : this.failure ?? (!active.dirty && !(active.base.widget === "input" && active.preview) ? state.validationMessages?.length ? state.validationMessages : void 0 : void 0), geometry.caret.left, geometry.caret.top + geometry.caret.height + 5);
|
|
5335
5935
|
active.placement = {
|
|
5336
5936
|
fragmentId: geometry.fragment.id,
|
|
5337
5937
|
pageId: geometry.pageId
|
|
@@ -5362,10 +5962,11 @@ var InlineFieldInput = class {
|
|
|
5362
5962
|
transform: `scale(${geometry.scaleX},${geometry.scaleY})`
|
|
5363
5963
|
});
|
|
5364
5964
|
const marks = [], owner = input.ownerDocument;
|
|
5365
|
-
|
|
5965
|
+
const focused = owner.activeElement === input || this.focusPending;
|
|
5966
|
+
for (const rect of focused ? fieldSelectionRects(options, snapshot, {
|
|
5366
5967
|
...state,
|
|
5367
5968
|
text: active.preview ? input.value : state.text
|
|
5368
|
-
}, input.selectionStart, input.selectionEnd, this.textMeasurer())) {
|
|
5969
|
+
}, input.selectionStart, input.selectionEnd, this.textMeasurer()) : []) {
|
|
5369
5970
|
const mark = owner.createElement("div");
|
|
5370
5971
|
mark.className = "gct-word-inline-selection";
|
|
5371
5972
|
Object.assign(mark.style, {
|
|
@@ -5378,7 +5979,7 @@ var InlineFieldInput = class {
|
|
|
5378
5979
|
});
|
|
5379
5980
|
marks.push(mark);
|
|
5380
5981
|
}
|
|
5381
|
-
if (input.selectionStart === input.selectionEnd) {
|
|
5982
|
+
if (focused && input.selectionStart === input.selectionEnd) {
|
|
5382
5983
|
const caret = this.caret ??= owner.createElement("div");
|
|
5383
5984
|
caret.className = "gct-word-inline-caret";
|
|
5384
5985
|
Object.assign(caret.style, {
|
|
@@ -5437,7 +6038,9 @@ var InlineFieldInput = class {
|
|
|
5437
6038
|
this.cancel();
|
|
5438
6039
|
return true;
|
|
5439
6040
|
}
|
|
5440
|
-
|
|
6041
|
+
const ready = this.commitSync();
|
|
6042
|
+
if (!ready && this.writeBlocked && this.failure) this.fail(new FieldInputBlockedError());
|
|
6043
|
+
return ready;
|
|
5441
6044
|
}
|
|
5442
6045
|
/** 指针切换前同步提交已有有效草稿,未准备或无效数字时保留当前焦点。 */
|
|
5443
6046
|
commitSync() {
|
|
@@ -5575,7 +6178,7 @@ var InlineFieldInput = class {
|
|
|
5575
6178
|
const options = this.options, input = this.input, active = this.active;
|
|
5576
6179
|
if (!options || !input || !active) return;
|
|
5577
6180
|
const text = input.value;
|
|
5578
|
-
this.validation.schedule((signal) => options.controller.
|
|
6181
|
+
this.validation.schedule((signal) => options.controller.validateFieldTextMessages(text, active.base, signal), (messages) => {
|
|
5579
6182
|
if (this.active !== active || this.input !== input || this.composing || !active.dirty && active.base.widget === "number" || input.value !== text) return;
|
|
5580
6183
|
try {
|
|
5581
6184
|
if (!this.current()) return;
|
|
@@ -5583,10 +6186,10 @@ var InlineFieldInput = class {
|
|
|
5583
6186
|
this.cancel();
|
|
5584
6187
|
return;
|
|
5585
6188
|
}
|
|
5586
|
-
this.failure =
|
|
6189
|
+
this.failure = messages;
|
|
5587
6190
|
this.draftChecked = true;
|
|
5588
|
-
input.setCustomValidity(
|
|
5589
|
-
this.preview(!!
|
|
6191
|
+
input.setCustomValidity(messages?.join(";") ?? "");
|
|
6192
|
+
this.preview(!!messages?.length);
|
|
5590
6193
|
});
|
|
5591
6194
|
}
|
|
5592
6195
|
/** 草稿参加同一视图的流式排版,未完成数字及候选不会发布为业务数据。 */
|
|
@@ -5640,17 +6243,21 @@ var InlineFieldInput = class {
|
|
|
5640
6243
|
} catch (error) {
|
|
5641
6244
|
this.writeBlocked = true;
|
|
5642
6245
|
this.draftChecked = true;
|
|
5643
|
-
this.failure = error instanceof Error && error.name === "FieldNumberError" ? error.message : active.base.widget === "number" ? "请输入完整有效的数字" : "当前内容未能保存,请检查输入";
|
|
5644
|
-
input.setCustomValidity(this.failure);
|
|
6246
|
+
this.failure = [error instanceof Error && error.name === "FieldNumberError" ? error.message : active.base.widget === "number" ? "请输入完整有效的数字" : readWordErrorText(error) ?? "当前内容未能保存,请检查输入"];
|
|
6247
|
+
input.setCustomValidity(this.failure.join(";"));
|
|
5645
6248
|
input.setAttribute("aria-invalid", "true");
|
|
6249
|
+
if (active.base.widget === "number" && input.ownerDocument.activeElement !== input) {
|
|
6250
|
+
this.focusPending = true;
|
|
6251
|
+
this.revealPending = true;
|
|
6252
|
+
this.caretPosition = void 0;
|
|
6253
|
+
}
|
|
5646
6254
|
this.refresh();
|
|
5647
|
-
if (active.base.widget !== "number") this.fail(error);
|
|
5648
6255
|
return false;
|
|
5649
6256
|
} finally {
|
|
5650
6257
|
this.writing = false;
|
|
5651
6258
|
}
|
|
5652
6259
|
}
|
|
5653
|
-
showMessage(
|
|
6260
|
+
showMessage(messages, left, top) {
|
|
5654
6261
|
const input = this.input, options = this.options;
|
|
5655
6262
|
if (!input || !options) return;
|
|
5656
6263
|
const blurred = !!this.options?.onFieldInputValidation && input.ownerDocument.activeElement !== input && !this.focusPending;
|
|
@@ -5660,11 +6267,14 @@ var InlineFieldInput = class {
|
|
|
5660
6267
|
valuePath: state.validationPath,
|
|
5661
6268
|
label: state.validationDescription?.label ?? "字段",
|
|
5662
6269
|
context: state.validationDescription?.context,
|
|
5663
|
-
|
|
6270
|
+
modelName: state.validationDescription?.modelName,
|
|
6271
|
+
modelKind: state.validationDescription?.modelKind,
|
|
6272
|
+
message: messages?.join(";"),
|
|
6273
|
+
messages,
|
|
5664
6274
|
blocked: this.writeBlocked
|
|
5665
6275
|
});
|
|
5666
|
-
if (blurred)
|
|
5667
|
-
if (!
|
|
6276
|
+
if (blurred) messages = void 0;
|
|
6277
|
+
if (!messages?.length) {
|
|
5668
6278
|
if (this.message) this.message.hidden = true;
|
|
5669
6279
|
input.removeAttribute("aria-describedby");
|
|
5670
6280
|
if (!this.failure) input.removeAttribute("aria-invalid");
|
|
@@ -5678,24 +6288,24 @@ var InlineFieldInput = class {
|
|
|
5678
6288
|
message.setAttribute("role", "alert");
|
|
5679
6289
|
owner.body.append(message);
|
|
5680
6290
|
}
|
|
5681
|
-
const description = this.active?.base.validationDescription;
|
|
5682
6291
|
const cancelHint = this.active?.base.widget === "number" ? "按 Esc 取消本次输入,恢复原值" : void 0;
|
|
5683
|
-
const key = JSON.stringify([
|
|
5684
|
-
description,
|
|
5685
|
-
text,
|
|
5686
|
-
cancelHint
|
|
5687
|
-
]);
|
|
6292
|
+
const key = JSON.stringify([messages, cancelHint]);
|
|
5688
6293
|
if (message.dataset.content !== key) {
|
|
5689
|
-
const
|
|
5690
|
-
title.textContent = description ? `${description.label} · ${description.context}` : "字段校验";
|
|
5691
|
-
Object.assign(title.style, {
|
|
5692
|
-
color: "#4b5563",
|
|
5693
|
-
fontSize: "12px",
|
|
5694
|
-
marginBottom: "4px"
|
|
5695
|
-
});
|
|
6294
|
+
const body = owner.createElement("ul");
|
|
5696
6295
|
body.className = "gct-word-field-input-message-text";
|
|
5697
|
-
|
|
5698
|
-
|
|
6296
|
+
const multiple = messages.length > 1;
|
|
6297
|
+
Object.assign(body.style, {
|
|
6298
|
+
margin: "0",
|
|
6299
|
+
paddingLeft: multiple ? "14px" : "0",
|
|
6300
|
+
listStyleType: multiple ? "disc" : "none"
|
|
6301
|
+
});
|
|
6302
|
+
for (const text of messages) {
|
|
6303
|
+
const item = owner.createElement("li");
|
|
6304
|
+
item.className = "gct-word-field-input-message-item";
|
|
6305
|
+
item.textContent = text;
|
|
6306
|
+
body.append(item);
|
|
6307
|
+
}
|
|
6308
|
+
message.replaceChildren(body);
|
|
5699
6309
|
if (cancelHint) {
|
|
5700
6310
|
const help = owner.createElement("div");
|
|
5701
6311
|
help.className = "gct-word-field-input-message-help";
|
|
@@ -5734,6 +6344,19 @@ var InlineFieldInput = class {
|
|
|
5734
6344
|
/** 数字和单行 Enter 在此提交,多行 Enter 和原生选区/剪贴继续由同一个 textarea 处理。 */
|
|
5735
6345
|
keyDown(event) {
|
|
5736
6346
|
if (event.isComposing || event.keyCode === 229 || this.composing) return;
|
|
6347
|
+
const navigation = localNavigationShortcut(event);
|
|
6348
|
+
if (navigation && this.input) {
|
|
6349
|
+
event.preventDefault();
|
|
6350
|
+
this.keyboard?.edited();
|
|
6351
|
+
if (navigation === "up" || navigation === "down") this.moveCaret(event, false);
|
|
6352
|
+
else {
|
|
6353
|
+
const input = this.input, direction = navigation === "wordLeft" ? -1 : 1;
|
|
6354
|
+
const offset = input.selectionStart !== input.selectionEnd ? direction === -1 ? input.selectionStart : input.selectionEnd : wordNavigationOffset(input.value, input.selectionStart, direction);
|
|
6355
|
+
this.setRange(offset, offset);
|
|
6356
|
+
}
|
|
6357
|
+
return;
|
|
6358
|
+
}
|
|
6359
|
+
if (this.keyboard?.shortcut(event)) return;
|
|
5737
6360
|
if (!event.ctrlKey && !event.metaKey && !event.altKey && [
|
|
5738
6361
|
"ArrowUp",
|
|
5739
6362
|
"ArrowDown",
|
|
@@ -5752,12 +6375,11 @@ var InlineFieldInput = class {
|
|
|
5752
6375
|
event.preventDefault();
|
|
5753
6376
|
this.commit();
|
|
5754
6377
|
}
|
|
5755
|
-
if (event.key === "Tab") this.keyboard?.tab(event);
|
|
5756
6378
|
}
|
|
5757
6379
|
/** 同字段点击和拖选直接调整原生选区,未完成数值仍可回到中间修改。 */
|
|
5758
6380
|
pointerDown(event) {
|
|
5759
6381
|
const options = this.options, input = this.input;
|
|
5760
|
-
if (!options || !input || !this.active || this.composing || event.button !== 0 ||
|
|
6382
|
+
if (!options || !input || !this.active || this.composing || event.button !== 0 || !(event.target instanceof input.ownerDocument.defaultView.Element) || !event.target.closest("canvas[data-page-id]")) return;
|
|
5761
6383
|
const snapshot = options.layout.getCurrentSnapshot();
|
|
5762
6384
|
if (!snapshot) return;
|
|
5763
6385
|
const hit = fieldPointOffset(options, snapshot, {
|
|
@@ -5773,6 +6395,7 @@ var InlineFieldInput = class {
|
|
|
5773
6395
|
anchor
|
|
5774
6396
|
};
|
|
5775
6397
|
this.active.placement = hit.placement;
|
|
6398
|
+
this.focusPending = true;
|
|
5776
6399
|
this.setRange(anchor, hit.offset);
|
|
5777
6400
|
try {
|
|
5778
6401
|
options.host.setPointerCapture?.(event.pointerId);
|
|
@@ -5802,7 +6425,7 @@ var InlineFieldInput = class {
|
|
|
5802
6425
|
this.drag = void 0;
|
|
5803
6426
|
}
|
|
5804
6427
|
/** 原生左右键保留字素语义,上下和行首尾沿用 Canvas 的实际断行。 */
|
|
5805
|
-
moveCaret(event) {
|
|
6428
|
+
moveCaret(event, extend = event.shiftKey) {
|
|
5806
6429
|
const options = this.options, input = this.input, active = this.active, snapshot = options?.layout.getCurrentSnapshot();
|
|
5807
6430
|
if (!options || !input || !active || !snapshot) return false;
|
|
5808
6431
|
const focus = input.selectionDirection === "backward" ? input.selectionStart : input.selectionEnd, state = {
|
|
@@ -5823,7 +6446,7 @@ var InlineFieldInput = class {
|
|
|
5823
6446
|
}
|
|
5824
6447
|
if (offset === void 0) return false;
|
|
5825
6448
|
event.preventDefault();
|
|
5826
|
-
this.setRange(
|
|
6449
|
+
this.setRange(extend ? this.selectionAnchor() : offset, offset);
|
|
5827
6450
|
return true;
|
|
5828
6451
|
}
|
|
5829
6452
|
/** 保留反向选择的固定端。 */
|
|
@@ -5868,6 +6491,8 @@ var SignatureFieldInput = class {
|
|
|
5868
6491
|
restoreFocus;
|
|
5869
6492
|
/** 同次激活的基值,换字段、外部值或配置改变后撤销。 */
|
|
5870
6493
|
active;
|
|
6494
|
+
/** 尚未安装弹框的校验请求,关闭或切换时取消。 */
|
|
6495
|
+
opening;
|
|
5871
6496
|
/** 当前 DOM 监听的取消边界。 */
|
|
5872
6497
|
lifetime;
|
|
5873
6498
|
/** 当前认证请求,关闭立即撤销,不排队重放。 */
|
|
@@ -5876,6 +6501,8 @@ var SignatureFieldInput = class {
|
|
|
5876
6501
|
pending = false;
|
|
5877
6502
|
/** 服务发放的短期不透明预览,不进入持久化数据。 */
|
|
5878
6503
|
draft;
|
|
6504
|
+
completed = false;
|
|
6505
|
+
closeTimer;
|
|
5879
6506
|
/** 共用弹框只持有本次签署界面。 */
|
|
5880
6507
|
dialog;
|
|
5881
6508
|
view;
|
|
@@ -5891,6 +6518,7 @@ var SignatureFieldInput = class {
|
|
|
5891
6518
|
writing = false;
|
|
5892
6519
|
/** 认证、校验失败或取消的局部说明。 */
|
|
5893
6520
|
message = "";
|
|
6521
|
+
messageKind = "status";
|
|
5894
6522
|
/** 仅借用窄交互能力,不创建 DOM 或发起认证。 */
|
|
5895
6523
|
constructor(options, restoreFocus) {
|
|
5896
6524
|
this.options = options;
|
|
@@ -5898,22 +6526,69 @@ var SignatureFieldInput = class {
|
|
|
5898
6526
|
}
|
|
5899
6527
|
/** 点击真实可编辑签名时打开;查看/关闭本身不认证、不写值。 */
|
|
5900
6528
|
open() {
|
|
5901
|
-
const
|
|
5902
|
-
|
|
6529
|
+
const options = this.options;
|
|
6530
|
+
const state = options?.controller.getFieldSignatureInput();
|
|
6531
|
+
if (!options || !state || !state.editable && !state.pending) return false;
|
|
5903
6532
|
if (this.active?.selection === state.selection && sameFieldSignatureInput(state, this.active)) {
|
|
5904
6533
|
this.refresh();
|
|
5905
6534
|
return true;
|
|
5906
6535
|
}
|
|
5907
6536
|
this.close();
|
|
5908
6537
|
this.active = state;
|
|
6538
|
+
if (state.records.length || state.invalid) {
|
|
6539
|
+
this.install();
|
|
6540
|
+
this.refresh();
|
|
6541
|
+
this.dialog?.focus();
|
|
6542
|
+
return true;
|
|
6543
|
+
}
|
|
6544
|
+
const task = new AbortController();
|
|
6545
|
+
this.opening = task;
|
|
6546
|
+
if (state.pending) options.controller.whenFieldSettled(task.signal).then(() => this.startOpening(options, state, task)).catch((error) => this.failOpening(options, state, task, error));
|
|
6547
|
+
else this.startOpening(options, state, task);
|
|
6548
|
+
return true;
|
|
6549
|
+
}
|
|
6550
|
+
ownsOpening(options, state, task) {
|
|
6551
|
+
return this.options === options && this.active === state && this.opening === task && !task.signal.aborted;
|
|
6552
|
+
}
|
|
6553
|
+
startOpening(options, state, task) {
|
|
6554
|
+
if (!this.ownsOpening(options, state, task)) return;
|
|
6555
|
+
this.refresh();
|
|
6556
|
+
if (!this.ownsOpening(options, state, task)) return;
|
|
6557
|
+
try {
|
|
6558
|
+
const checking = options.controller.validateFieldSignature(state, task.signal);
|
|
6559
|
+
if (checking) checking.then(() => this.finishOpening(options, state, task)).catch((error) => this.failOpening(options, state, task, error));
|
|
6560
|
+
else this.finishOpening(options, state, task);
|
|
6561
|
+
} catch (error) {
|
|
6562
|
+
this.failOpening(options, state, task, error);
|
|
6563
|
+
}
|
|
6564
|
+
}
|
|
6565
|
+
finishOpening(options, state, task) {
|
|
6566
|
+
if (!this.ownsOpening(options, state, task)) return;
|
|
6567
|
+
const current = options.controller.getFieldSignatureInput();
|
|
6568
|
+
if (!current || !sameFieldSignatureInput(current, state) || !current.editable || current.pending || current.invalid) {
|
|
6569
|
+
this.close();
|
|
6570
|
+
return;
|
|
6571
|
+
}
|
|
5909
6572
|
this.install();
|
|
5910
6573
|
this.refresh();
|
|
6574
|
+
if (!this.ownsOpening(options, state, task)) return;
|
|
6575
|
+
this.active = current;
|
|
6576
|
+
this.opening = void 0;
|
|
6577
|
+
task.abort();
|
|
5911
6578
|
this.dialog?.focus();
|
|
5912
|
-
|
|
6579
|
+
}
|
|
6580
|
+
failOpening(options, state, task, error) {
|
|
6581
|
+
if (!this.ownsOpening(options, state, task)) return;
|
|
6582
|
+
this.refresh();
|
|
6583
|
+
if (!this.ownsOpening(options, state, task)) return;
|
|
6584
|
+
this.close();
|
|
6585
|
+
try {
|
|
6586
|
+
options.onError?.(error);
|
|
6587
|
+
} catch {}
|
|
5913
6588
|
}
|
|
5914
6589
|
/** 保存前不能忽略尚未完成的认证或已认证但未确认的预览。 */
|
|
5915
6590
|
canSubmit() {
|
|
5916
|
-
return !this.pending && !this.draft;
|
|
6591
|
+
return !this.opening && !this.pending && !this.draft;
|
|
5917
6592
|
}
|
|
5918
6593
|
/** 只复核当前业务发生,不依赖旧字段坐标;认证弹框转移焦点不会自动取消。 */
|
|
5919
6594
|
refresh() {
|
|
@@ -5926,28 +6601,36 @@ var SignatureFieldInput = class {
|
|
|
5926
6601
|
this.close();
|
|
5927
6602
|
return;
|
|
5928
6603
|
}
|
|
5929
|
-
if (!current || !sameFieldSignatureInput(current, active) || !current.editable && !current.pending) {
|
|
6604
|
+
if (!current || !sameFieldSignatureInput(current, active) || !this.completed && !current.editable && !current.pending) {
|
|
5930
6605
|
this.close();
|
|
5931
6606
|
return;
|
|
5932
6607
|
}
|
|
5933
|
-
const busy = this.pending || current.pending, disabled = busy || !current.editable || current.invalid;
|
|
6608
|
+
const busy = this.pending || current.pending, disabled = busy || this.completed || !current.editable || current.invalid;
|
|
5934
6609
|
if (this.authorizeButton) this.authorizeButton.disabled = disabled || !!this.draft || !current.multiple && !!current.records.length;
|
|
5935
6610
|
if (this.confirmButton) this.confirmButton.disabled = disabled || !this.draft;
|
|
5936
6611
|
for (const button of this.removeButtons) button.disabled = disabled || !!this.draft;
|
|
5937
6612
|
this.dialog?.content.setAttribute("aria-busy", String(busy));
|
|
5938
6613
|
this.view?.update({
|
|
6614
|
+
appearance: current.appearance,
|
|
5939
6615
|
records: current.records,
|
|
5940
6616
|
draft: this.draft,
|
|
5941
6617
|
busy,
|
|
5942
6618
|
canAuthorize: !disabled && !this.draft && (current.multiple || !current.records.length),
|
|
5943
6619
|
canConfirm: !disabled && !!this.draft,
|
|
5944
6620
|
canRemove: !disabled && !this.draft,
|
|
5945
|
-
|
|
6621
|
+
completed: this.completed,
|
|
6622
|
+
message: current.invalid ? "签名值格式异常,原值已保留" : this.message,
|
|
6623
|
+
messageKind: current.invalid ? "error" : this.messageKind
|
|
5946
6624
|
});
|
|
5947
6625
|
if (this.status) this.status.textContent = current.invalid ? "签名值格式异常,原值已保留" : this.message || (current.pending ? "正在准备字段规则…" : "点击签署进行认证,认证通过后确认保存。");
|
|
5948
6626
|
}
|
|
5949
6627
|
/** 先撤销旧事件与认证,再丢弃预览;取消不会删除已经保存的记录。 */
|
|
5950
6628
|
close(restore = false) {
|
|
6629
|
+
clearTimeout(this.closeTimer);
|
|
6630
|
+
this.closeTimer = void 0;
|
|
6631
|
+
this.completed = false;
|
|
6632
|
+
this.opening?.abort();
|
|
6633
|
+
this.opening = void 0;
|
|
5951
6634
|
this.active = void 0;
|
|
5952
6635
|
this.lifetime?.abort();
|
|
5953
6636
|
this.lifetime = void 0;
|
|
@@ -5965,6 +6648,7 @@ var SignatureFieldInput = class {
|
|
|
5965
6648
|
this.confirmButton = void 0;
|
|
5966
6649
|
this.removeButtons = [];
|
|
5967
6650
|
this.message = "";
|
|
6651
|
+
this.messageKind = "status";
|
|
5968
6652
|
if (restore) this.restoreFocus?.();
|
|
5969
6653
|
}
|
|
5970
6654
|
/** 幂等释放所有临时 DOM、等待和外部能力,不关闭借用的文档或认证服务。 */
|
|
@@ -5976,7 +6660,7 @@ var SignatureFieldInput = class {
|
|
|
5976
6660
|
/** 当前一次激活创建独立事件身份;已保存摘要与认证状态刷新不重建按钮。 */
|
|
5977
6661
|
install() {
|
|
5978
6662
|
const owner = this.options.host.ownerDocument, signal = (this.lifetime = new AbortController()).signal, dialog = new FieldDialog(owner, "签名", () => this.close(true), {
|
|
5979
|
-
width:
|
|
6663
|
+
width: 640,
|
|
5980
6664
|
className: "gct-word-signature-input",
|
|
5981
6665
|
render: this.options.renderFieldDialog
|
|
5982
6666
|
}), body = owner.createElement("div"), records = owner.createElement("div"), status = owner.createElement("p"), actions = owner.createElement("div");
|
|
@@ -5985,6 +6669,7 @@ var SignatureFieldInput = class {
|
|
|
5985
6669
|
this.view = this.options.renderSignaturePanel({
|
|
5986
6670
|
container: dialog.content,
|
|
5987
6671
|
state: {
|
|
6672
|
+
appearance: this.active.appearance,
|
|
5988
6673
|
records: this.active.records,
|
|
5989
6674
|
busy: false,
|
|
5990
6675
|
canAuthorize: false,
|
|
@@ -6044,11 +6729,12 @@ var SignatureFieldInput = class {
|
|
|
6044
6729
|
async authorize(authorization) {
|
|
6045
6730
|
this.refresh();
|
|
6046
6731
|
const options = this.options, active = this.active;
|
|
6047
|
-
if (!options || !active || this.pending || this.draft || this.authorizeButton?.disabled) return;
|
|
6732
|
+
if (!options || !active || this.pending || this.draft || this.completed || this.authorizeButton?.disabled) return;
|
|
6048
6733
|
const task = new AbortController();
|
|
6049
6734
|
this.authentication = task;
|
|
6050
6735
|
this.pending = true;
|
|
6051
6736
|
this.message = "正在等待签署认证…";
|
|
6737
|
+
this.messageKind = "status";
|
|
6052
6738
|
this.refresh();
|
|
6053
6739
|
try {
|
|
6054
6740
|
const draft = await options.controller.prepareFieldSignature(active, task.signal, ...authorization ? [authorization] : []);
|
|
@@ -6057,7 +6743,10 @@ var SignatureFieldInput = class {
|
|
|
6057
6743
|
return;
|
|
6058
6744
|
}
|
|
6059
6745
|
this.draft = draft;
|
|
6060
|
-
|
|
6746
|
+
if (draft && authorization) {
|
|
6747
|
+
this.pending = false;
|
|
6748
|
+
this.save(authorization.method === "CARD" ? 2e3 : 0, true);
|
|
6749
|
+
} else this.message = draft ? `已认证:${signatureSummary(draft.username, draft.time)}\n尚未保存,请确认。` : "已取消认证,原有签名未改变。";
|
|
6061
6750
|
} catch (error) {
|
|
6062
6751
|
if (!task.signal.aborted && this.active === active) this.fail(error);
|
|
6063
6752
|
} finally {
|
|
@@ -6073,7 +6762,7 @@ var SignatureFieldInput = class {
|
|
|
6073
6762
|
}
|
|
6074
6763
|
}
|
|
6075
6764
|
/** 明确确认后只提交服务发放的凭据;互斥失败仍保留原值并显示原因。 */
|
|
6076
|
-
save() {
|
|
6765
|
+
save(closeDelayMs = 0, releaseOnFailure = false) {
|
|
6077
6766
|
this.refresh();
|
|
6078
6767
|
const options = this.options, active = this.active, draft = this.draft;
|
|
6079
6768
|
if (!options || !active || !draft || this.pending || this.confirmButton?.disabled) return;
|
|
@@ -6081,8 +6770,19 @@ var SignatureFieldInput = class {
|
|
|
6081
6770
|
try {
|
|
6082
6771
|
if (!options.controller.commitFieldSignature(draft, active)) throw new Error("签名未能保存");
|
|
6083
6772
|
this.draft = void 0;
|
|
6084
|
-
|
|
6773
|
+
const current = options.controller.getFieldSignatureInput();
|
|
6774
|
+
if (closeDelayMs && current) {
|
|
6775
|
+
this.active = current;
|
|
6776
|
+
this.completed = true;
|
|
6777
|
+
this.message = "签名成功";
|
|
6778
|
+
this.messageKind = "status";
|
|
6779
|
+
this.closeTimer = setTimeout(() => this.close(true), closeDelayMs);
|
|
6780
|
+
} else this.close(true);
|
|
6085
6781
|
} catch (error) {
|
|
6782
|
+
if (releaseOnFailure) {
|
|
6783
|
+
options.controller.discardFieldSignature(draft);
|
|
6784
|
+
this.draft = void 0;
|
|
6785
|
+
}
|
|
6086
6786
|
this.fail(error);
|
|
6087
6787
|
} finally {
|
|
6088
6788
|
this.writing = false;
|
|
@@ -6105,13 +6805,11 @@ var SignatureFieldInput = class {
|
|
|
6105
6805
|
this.refresh();
|
|
6106
6806
|
}
|
|
6107
6807
|
}
|
|
6108
|
-
/**
|
|
6808
|
+
/** 签名错误由当前弹框展示,不再交给工作区重复显示。 */
|
|
6109
6809
|
fail(error) {
|
|
6110
6810
|
this.message = error instanceof Error ? error.message : "签名操作失败";
|
|
6811
|
+
this.messageKind = "error";
|
|
6111
6812
|
this.refresh();
|
|
6112
|
-
try {
|
|
6113
|
-
this.options?.onError?.(error);
|
|
6114
|
-
} catch {}
|
|
6115
6813
|
}
|
|
6116
6814
|
};
|
|
6117
6815
|
// src/adapters/browser/input/CanvasTextInput.ts
|
|
@@ -6128,6 +6826,7 @@ var CanvasTextInput = class {
|
|
|
6128
6826
|
input;
|
|
6129
6827
|
/** 独立高亮层,移动光标不重画页面。 */
|
|
6130
6828
|
overlay;
|
|
6829
|
+
fieldBrackets = new CanvasFieldBrackets();
|
|
6131
6830
|
/** 自有临时样式,关闭时移除。 */
|
|
6132
6831
|
style;
|
|
6133
6832
|
/** 未注入文字度量时,仅在组合输入需要字体框时创建,关闭时释放。 */
|
|
@@ -6185,13 +6884,13 @@ var CanvasTextInput = class {
|
|
|
6185
6884
|
this.overlay = overlay;
|
|
6186
6885
|
this.style = style;
|
|
6187
6886
|
this.fields = new InlineFieldInput(options, {
|
|
6188
|
-
|
|
6887
|
+
shortcut: (event) => this.fieldShortcut(event),
|
|
6189
6888
|
paste: (event) => {
|
|
6190
6889
|
this.pasteBusinessMatrix(event);
|
|
6191
6890
|
},
|
|
6192
6891
|
edited: () => this.cancelTab()
|
|
6193
6892
|
});
|
|
6194
|
-
this.choices = new ChoiceFieldInput(options, () => this.input?.focus({ preventScroll: true }), (event) => this.
|
|
6893
|
+
this.choices = new ChoiceFieldInput(options, () => this.input?.focus({ preventScroll: true }), (event) => this.navigateField(event));
|
|
6195
6894
|
this.mediaPreview = new ResourceFieldPreview(options);
|
|
6196
6895
|
this.signatures = new SignatureFieldInput(options, () => this.input?.focus({ preventScroll: true }));
|
|
6197
6896
|
this.business = new BusinessFieldInput(options, () => this.input?.focus({ preventScroll: true }));
|
|
@@ -6334,6 +7033,7 @@ var CanvasTextInput = class {
|
|
|
6334
7033
|
this.mediaPreview?.refresh();
|
|
6335
7034
|
this.business?.refresh();
|
|
6336
7035
|
this.optionInput?.refresh();
|
|
7036
|
+
this.fieldBrackets.refresh(options.host, options.layout.getCurrentSnapshot(), options.controller);
|
|
6337
7037
|
const rect = paintInputOverlay(options.host, overlay, input, options.layout.getCurrentSnapshot(), options.controller, input.ownerDocument.activeElement === input && !input.ownerDocument.hidden, this.revealPending, options.objectHandles, options.textMeasurer ?? this.measurer ?? (state.composition ? this.textMeasurer() : void 0));
|
|
6338
7038
|
if (rect && this.revealPending) {
|
|
6339
7039
|
this.revealPending = false;
|
|
@@ -6341,6 +7041,7 @@ var CanvasTextInput = class {
|
|
|
6341
7041
|
}
|
|
6342
7042
|
} catch (error) {
|
|
6343
7043
|
overlay.replaceChildren();
|
|
7044
|
+
this.fieldBrackets.clear();
|
|
6344
7045
|
this.fail(error);
|
|
6345
7046
|
}
|
|
6346
7047
|
}
|
|
@@ -6376,6 +7077,7 @@ var CanvasTextInput = class {
|
|
|
6376
7077
|
}
|
|
6377
7078
|
/** 幂等解除原生事件、临时层和等待;不关闭外部控制器、排版或共享资源。 */
|
|
6378
7079
|
dispose() {
|
|
7080
|
+
this.fieldBrackets.clear();
|
|
6379
7081
|
const options = this.options;
|
|
6380
7082
|
this.options = void 0;
|
|
6381
7083
|
this.setTableCursor();
|
|
@@ -6712,10 +7414,12 @@ var CanvasTextInput = class {
|
|
|
6712
7414
|
host.releasePointerCapture(pointer);
|
|
6713
7415
|
} catch {}
|
|
6714
7416
|
}
|
|
6715
|
-
/**
|
|
6716
|
-
|
|
7417
|
+
/** 主修饰键加 Enter 按原字段顺序导航;首尾停留,不落成换行或提交宿主表单。 */
|
|
7418
|
+
navigateField(event) {
|
|
6717
7419
|
const controller = this.options?.controller, source = event.target;
|
|
6718
|
-
if (!controller || !source || event
|
|
7420
|
+
if (!controller || !source || !isFieldNavigationShortcut(event)) return;
|
|
7421
|
+
event.preventDefault();
|
|
7422
|
+
event.stopPropagation();
|
|
6719
7423
|
this.cancelTab();
|
|
6720
7424
|
const direction = event.shiftKey ? -1 : 1;
|
|
6721
7425
|
this.run(() => {
|
|
@@ -6766,12 +7470,29 @@ var CanvasTextInput = class {
|
|
|
6766
7470
|
this.tabTask?.abort();
|
|
6767
7471
|
this.tabTask = void 0;
|
|
6768
7472
|
}
|
|
7473
|
+
/** 原位字段与正文共用预留规则;普通输入、复制和原生撤销仍由原处理者执行。 */
|
|
7474
|
+
fieldShortcut(event) {
|
|
7475
|
+
if (isFieldNavigationShortcut(event)) {
|
|
7476
|
+
this.clearEcho();
|
|
7477
|
+
this.navigateField(event);
|
|
7478
|
+
return true;
|
|
7479
|
+
}
|
|
7480
|
+
const shortcut = productWordShortcut(event);
|
|
7481
|
+
if (!shortcut || shortcut.state === "ready") return false;
|
|
7482
|
+
event.preventDefault();
|
|
7483
|
+
event.stopPropagation();
|
|
7484
|
+
this.clearEcho();
|
|
7485
|
+
this.cancelTab();
|
|
7486
|
+
return true;
|
|
7487
|
+
}
|
|
6769
7488
|
/** 编辑快捷键走逻辑命令,浏览器字段原生事件由自己的 textarea 处理。 */
|
|
6770
7489
|
keyDown(event) {
|
|
6771
7490
|
if (!this.options || event.isComposing || event.keyCode === 229 || this.composing) return;
|
|
6772
7491
|
if (event.key === "Tab") {
|
|
6773
|
-
if (
|
|
6774
|
-
|
|
7492
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
7493
|
+
this.cancelTab();
|
|
7494
|
+
this.clearEcho();
|
|
7495
|
+
if (this.options.controller.canEditText()) {
|
|
6775
7496
|
this.run((controller) => {
|
|
6776
7497
|
if (controller.design.tables.tabCell(event.shiftKey ? -1 : 1)) {
|
|
6777
7498
|
event.preventDefault();
|
|
@@ -6780,10 +7501,18 @@ var CanvasTextInput = class {
|
|
|
6780
7501
|
});
|
|
6781
7502
|
if (event.defaultPrevented) return;
|
|
6782
7503
|
}
|
|
6783
|
-
this.
|
|
7504
|
+
this.fieldShortcut(event);
|
|
7505
|
+
return;
|
|
7506
|
+
}
|
|
7507
|
+
if (this.fieldShortcut(event)) return;
|
|
7508
|
+
this.cancelTab();
|
|
7509
|
+
const localNavigation = localNavigationShortcut(event);
|
|
7510
|
+
if (localNavigation) {
|
|
7511
|
+
event.preventDefault();
|
|
7512
|
+
this.clearEcho();
|
|
7513
|
+
this.run((controller) => controller.move(localNavigation, false), true);
|
|
6784
7514
|
return;
|
|
6785
7515
|
}
|
|
6786
|
-
this.cancelTab();
|
|
6787
7516
|
if (this.optionInput?.keyDown(event)) return;
|
|
6788
7517
|
if (this.options.controller.getState().selection?.kind === "cells" && event.key === "Enter" && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
6789
7518
|
event.preventDefault();
|
|
@@ -7074,99 +7803,9 @@ var CanvasTextInput = class {
|
|
|
7074
7803
|
} catch {}
|
|
7075
7804
|
}
|
|
7076
7805
|
};
|
|
7077
|
-
// src/adapters/browser/input/business/tables/fixed-quick-fill-grid.ts
|
|
7078
|
-
/** @file 固定表弹框只渲染原生网格和局部草稿,写入仍由业务命令统一预检。 */
|
|
7079
|
-
/** 完整检查物理矩形后才返回草稿补丁;合并从格的空占位不制造字段。 */
|
|
7080
|
-
function fixedQuickFillPaste(layout, text, row, column) {
|
|
7081
|
-
const matrix = parseTsv(text, {
|
|
7082
|
-
rows: layout.rowCount - row,
|
|
7083
|
-
columns: layout.columnCount - column
|
|
7084
|
-
});
|
|
7085
|
-
const patches = [];
|
|
7086
|
-
for (const [y, values] of matrix.entries()) for (const [x, value] of values.entries()) {
|
|
7087
|
-
const cell = layout.cells.find((cell) => cell.row === row + y && cell.column === column + x);
|
|
7088
|
-
if (!cell?.field || cell.slot === void 0) {
|
|
7089
|
-
if (value) throw Error("粘贴位置没有可填写字段或属于合并从格");
|
|
7090
|
-
continue;
|
|
7091
|
-
}
|
|
7092
|
-
if (!cell.editable) throw Error("粘贴范围包含不可编辑字段");
|
|
7093
|
-
patches.push({
|
|
7094
|
-
slot: cell.slot,
|
|
7095
|
-
key: cell.field.key,
|
|
7096
|
-
value
|
|
7097
|
-
});
|
|
7098
|
-
}
|
|
7099
|
-
return patches;
|
|
7100
|
-
}
|
|
7101
|
-
function renderFixedQuickFillGrid(options) {
|
|
7102
|
-
const { owner, layout, signal } = options, start = options.page * 20, end = Math.min(layout.rowCount, start + 20), table = owner.createElement("table"), body = owner.createElement("tbody");
|
|
7103
|
-
table.setAttribute("aria-label", "快速填报输入表格");
|
|
7104
|
-
table.style.cssText = "border-collapse:collapse;width:max-content;min-width:100%";
|
|
7105
|
-
let anchor;
|
|
7106
|
-
const selected = /* @__PURE__ */ new Set();
|
|
7107
|
-
for (let row = start; row < end; row++) {
|
|
7108
|
-
const tr = owner.createElement("tr");
|
|
7109
|
-
for (const cell of layout.cells.filter((cell) => Math.max(cell.row, start) === row && cell.row + cell.rowSpan > start)) {
|
|
7110
|
-
const td = owner.createElement("td");
|
|
7111
|
-
td.rowSpan = Math.min(cell.row + cell.rowSpan, end) - row;
|
|
7112
|
-
td.colSpan = cell.columnSpan;
|
|
7113
|
-
td.dataset.row = String(cell.row);
|
|
7114
|
-
td.dataset.column = String(cell.column);
|
|
7115
|
-
td.style.cssText = "border:1px solid #d9d9d9;padding:4px";
|
|
7116
|
-
if (cell.field && cell.slot !== void 0) {
|
|
7117
|
-
const input = owner.createElement("textarea"), slot = cell.slot, key = cell.field.key;
|
|
7118
|
-
input.rows = 1;
|
|
7119
|
-
input.readOnly = options.disabled || !cell.editable;
|
|
7120
|
-
input.value = options.value(slot, key);
|
|
7121
|
-
input.setAttribute("aria-label", `第 ${slot + 1} 行 · ${cell.field.label}`);
|
|
7122
|
-
input.style.cssText = "min-width:130px;width:160px;resize:vertical;box-sizing:border-box";
|
|
7123
|
-
input.addEventListener("input", () => options.input(slot, key, input.value), { signal });
|
|
7124
|
-
input.addEventListener("paste", (event) => {
|
|
7125
|
-
if (!event.clipboardData?.types.includes("text/plain")) return;
|
|
7126
|
-
event.preventDefault();
|
|
7127
|
-
options.paste(event.clipboardData.getData("text/plain"), cell.row, cell.column);
|
|
7128
|
-
}, { signal });
|
|
7129
|
-
td.append(input);
|
|
7130
|
-
} else td.textContent = cell.text;
|
|
7131
|
-
td.addEventListener("pointerdown", (event) => {
|
|
7132
|
-
if (!event.shiftKey || !anchor) {
|
|
7133
|
-
for (const item of selected) item.style.backgroundColor = "";
|
|
7134
|
-
selected.clear();
|
|
7135
|
-
anchor = cell;
|
|
7136
|
-
return;
|
|
7137
|
-
}
|
|
7138
|
-
event.preventDefault();
|
|
7139
|
-
for (const item of selected) item.style.backgroundColor = "";
|
|
7140
|
-
selected.clear();
|
|
7141
|
-
for (const item of table.querySelectorAll("td")) {
|
|
7142
|
-
const y = Number(item.dataset.row), x = Number(item.dataset.column);
|
|
7143
|
-
if (y >= Math.min(anchor.row, cell.row) && y <= Math.max(anchor.row, cell.row) && x >= Math.min(anchor.column, cell.column) && x <= Math.max(anchor.column, cell.column)) {
|
|
7144
|
-
selected.add(item);
|
|
7145
|
-
item.style.backgroundColor = "#e6f4ff";
|
|
7146
|
-
}
|
|
7147
|
-
}
|
|
7148
|
-
}, { signal });
|
|
7149
|
-
tr.append(td);
|
|
7150
|
-
}
|
|
7151
|
-
body.append(tr);
|
|
7152
|
-
}
|
|
7153
|
-
table.append(body);
|
|
7154
|
-
table.addEventListener("keydown", (event) => {
|
|
7155
|
-
if (options.disabled || !selected.size || !["Delete", "Backspace"].includes(event.key)) return;
|
|
7156
|
-
event.preventDefault();
|
|
7157
|
-
for (const td of selected) {
|
|
7158
|
-
const cell = layout.cells.find((cell) => cell.row === Number(td.dataset.row) && cell.column === Number(td.dataset.column));
|
|
7159
|
-
if (!cell?.field || cell.slot === void 0 || !cell.editable) continue;
|
|
7160
|
-
options.input(cell.slot, cell.field.key, "");
|
|
7161
|
-
const input = td.querySelector("textarea");
|
|
7162
|
-
if (input) input.value = "";
|
|
7163
|
-
}
|
|
7164
|
-
}, { signal });
|
|
7165
|
-
return table;
|
|
7166
|
-
}
|
|
7167
7806
|
// src/adapters/browser/input/business/tables/CanvasQuickFillDialog.ts
|
|
7168
|
-
/** @file
|
|
7169
|
-
/** 动态草稿最多 200
|
|
7807
|
+
/** @file 快速填报协调插件草稿和原生命令,不实现表格选择或填充交互。 */
|
|
7808
|
+
/** 动态草稿最多 200 行,固定表按原生容量;虚拟滚动和交互由插件负责。 */
|
|
7170
7809
|
var CanvasQuickFillDialog = class {
|
|
7171
7810
|
/** 可解除的当前装配。 */
|
|
7172
7811
|
options;
|
|
@@ -7184,16 +7823,16 @@ var CanvasQuickFillDialog = class {
|
|
|
7184
7823
|
rows = [];
|
|
7185
7824
|
/** 原生端口只交付当前可见字段的文本,草稿不复制业务行。 */
|
|
7186
7825
|
initialRows = [];
|
|
7187
|
-
/** 仅 UI 分页,不作为业务下标。 */
|
|
7188
|
-
page = 0;
|
|
7189
7826
|
/** 原始来源是否已经过期,过期时保留草稿供查看。 */
|
|
7190
7827
|
stale = false;
|
|
7191
7828
|
/** 当前局部提示,不存错误对象。 */
|
|
7192
7829
|
message = "";
|
|
7193
7830
|
/** 自身同步提交不被自己的通知误标为过期。 */
|
|
7194
7831
|
writing = false;
|
|
7195
|
-
/**
|
|
7196
|
-
|
|
7832
|
+
/** 插件只属于当前弹框,关闭时释放全部草稿和监听。 */
|
|
7833
|
+
view;
|
|
7834
|
+
submitting = false;
|
|
7835
|
+
applyButton;
|
|
7197
7836
|
/** 可更新的轻量反馈。 */
|
|
7198
7837
|
status;
|
|
7199
7838
|
/** 关闭后返回当前仍连接的原生按钮。 */
|
|
@@ -7214,23 +7853,53 @@ var CanvasQuickFillDialog = class {
|
|
|
7214
7853
|
const opening = new AbortController();
|
|
7215
7854
|
this.opening = opening;
|
|
7216
7855
|
try {
|
|
7217
|
-
if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("快速填报已取消")))
|
|
7856
|
+
if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("快速填报已取消"))) return;
|
|
7218
7857
|
if (opening.signal.aborted || this.options !== options) return;
|
|
7219
7858
|
const source = options.controller.businessTables.readQuickFill(expected.regionId, expected.anchorInstanceKey);
|
|
7220
7859
|
if (!source?.enabled || !isEqual(source.selection, expected.selection) || !isEqual(source.occurrence, expected.occurrence)) throw Error("当前行或快速填报规则已变化,请重新操作");
|
|
7860
|
+
if (!options.renderQuickFillPanel) throw Error("尚未接入快速填报表格面板");
|
|
7221
7861
|
this.source = source;
|
|
7222
7862
|
this.initialRows = source.layout ? options.controller.businessTables.quickFillValues(source) : [];
|
|
7223
|
-
this.rows = Array.from({ length: source.
|
|
7224
|
-
this.page = 0;
|
|
7863
|
+
this.rows = Array.from({ length: source.limit }, () => ({}));
|
|
7225
7864
|
this.stale = false;
|
|
7226
7865
|
this.message = "";
|
|
7227
7866
|
this.returnFocus = options.host.ownerDocument.activeElement instanceof options.host.ownerDocument.defaultView.HTMLElement ? options.host.ownerDocument.activeElement : void 0;
|
|
7228
7867
|
this.dialog = new FieldDialog(options.host.ownerDocument, "快速填报", () => this.close(), {
|
|
7229
|
-
width:
|
|
7868
|
+
width: 1060,
|
|
7869
|
+
className: "gct-word-quick-fill-dialog",
|
|
7230
7870
|
render: options.renderFieldDialog
|
|
7231
7871
|
});
|
|
7232
|
-
this.
|
|
7233
|
-
this.
|
|
7872
|
+
this.controls = new AbortController();
|
|
7873
|
+
const container = this.render();
|
|
7874
|
+
const signal = this.controls.signal;
|
|
7875
|
+
const view = await options.renderQuickFillPanel({
|
|
7876
|
+
container,
|
|
7877
|
+
state: {
|
|
7878
|
+
columns: source.columns,
|
|
7879
|
+
limit: source.limit,
|
|
7880
|
+
layout: source.layout
|
|
7881
|
+
},
|
|
7882
|
+
values: this.initialRows,
|
|
7883
|
+
signal,
|
|
7884
|
+
change: (patches) => {
|
|
7885
|
+
if (signal.aborted || this.stale) return;
|
|
7886
|
+
for (const patch of patches) {
|
|
7887
|
+
const row = this.rows[patch.slot];
|
|
7888
|
+
if (row) row[patch.key] = patch.value;
|
|
7889
|
+
}
|
|
7890
|
+
},
|
|
7891
|
+
error: (error) => {
|
|
7892
|
+
if (!signal.aborted) this.report(error);
|
|
7893
|
+
}
|
|
7894
|
+
});
|
|
7895
|
+
if (signal.aborted || this.options !== options) {
|
|
7896
|
+
view.dispose();
|
|
7897
|
+
return;
|
|
7898
|
+
}
|
|
7899
|
+
this.view = view;
|
|
7900
|
+
view.setReadonly(this.stale);
|
|
7901
|
+
if (this.status) this.status.textContent = this.message;
|
|
7902
|
+
this.updateActions();
|
|
7234
7903
|
} catch (error) {
|
|
7235
7904
|
if (!opening.signal.aborted && this.options === options) this.report(error);
|
|
7236
7905
|
} finally {
|
|
@@ -7244,7 +7913,9 @@ var CanvasQuickFillDialog = class {
|
|
|
7244
7913
|
if (!isEqual(current, this.source)) {
|
|
7245
7914
|
this.stale = true;
|
|
7246
7915
|
this.message = "来源已变化,请关闭后重新打开快速填报";
|
|
7247
|
-
this.
|
|
7916
|
+
if (this.status) this.status.textContent = this.message;
|
|
7917
|
+
this.view?.setReadonly(true);
|
|
7918
|
+
this.updateActions();
|
|
7248
7919
|
}
|
|
7249
7920
|
}
|
|
7250
7921
|
/** 明确取消只丢弃临时输入,不写仓库或新增行。 */
|
|
@@ -7253,15 +7924,18 @@ var CanvasQuickFillDialog = class {
|
|
|
7253
7924
|
this.opening = void 0;
|
|
7254
7925
|
this.controls?.abort();
|
|
7255
7926
|
this.controls = void 0;
|
|
7927
|
+
this.view?.dispose();
|
|
7928
|
+
this.view = void 0;
|
|
7256
7929
|
this.dialog?.dispose();
|
|
7257
7930
|
this.dialog = void 0;
|
|
7258
|
-
this.
|
|
7931
|
+
this.applyButton = void 0;
|
|
7259
7932
|
this.status = void 0;
|
|
7260
7933
|
this.source = void 0;
|
|
7261
7934
|
this.initialRows = [];
|
|
7262
7935
|
this.rows = [];
|
|
7263
7936
|
this.message = "";
|
|
7264
7937
|
this.stale = false;
|
|
7938
|
+
this.submitting = false;
|
|
7265
7939
|
const focus = this.returnFocus;
|
|
7266
7940
|
this.returnFocus = void 0;
|
|
7267
7941
|
if (focus?.isConnected) focus.focus({ preventScroll: true });
|
|
@@ -7273,158 +7947,68 @@ var CanvasQuickFillDialog = class {
|
|
|
7273
7947
|
this.unsubscribe = void 0;
|
|
7274
7948
|
this.options = void 0;
|
|
7275
7949
|
}
|
|
7276
|
-
/**
|
|
7950
|
+
/** 与旧版相同的说明区和整张网格,确认/取消使用公共弹框底部。 */
|
|
7277
7951
|
render() {
|
|
7278
|
-
const root = this.dialog
|
|
7279
|
-
if (!root || !source) return;
|
|
7952
|
+
const root = this.dialog.content, source = this.source, owner = root.ownerDocument;
|
|
7280
7953
|
root.classList.add("gct-word-table-quick-fill");
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
const
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7954
|
+
const info = owner.createElement("ol");
|
|
7955
|
+
info.className = "gct-word-quick-fill-tips";
|
|
7956
|
+
for (const text of [
|
|
7957
|
+
"可将 Excel 内容粘贴到表格中,支持使用复制、粘贴、删除快捷键和拖拽填充。",
|
|
7958
|
+
"支持文本、数字、日期、时间、批次及枚举字段,多选值以逗号分隔。",
|
|
7959
|
+
`${source.layout ? "编辑固定表已有分组" : `从当前第 ${(source.rowOrdinal ?? 0) + 1} 行开始填写`},最多 ${source.limit} 行。点击确定后应用,未编辑的字段保留原值。`
|
|
7960
|
+
]) {
|
|
7961
|
+
const item = owner.createElement("li");
|
|
7962
|
+
item.textContent = text;
|
|
7963
|
+
info.append(item);
|
|
7964
|
+
}
|
|
7965
|
+
const grid = owner.createElement("div");
|
|
7966
|
+
grid.className = "gct-word-quick-fill-panel";
|
|
7287
7967
|
this.status = owner.createElement("p");
|
|
7968
|
+
this.status.className = "gct-word-quick-fill-status";
|
|
7288
7969
|
this.status.setAttribute("role", "status");
|
|
7289
|
-
this.status.textContent =
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
this.
|
|
7304
|
-
this.
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
this.render();
|
|
7314
|
-
}, !!source.layout || this.rows.length >= source.limit || this.stale);
|
|
7315
|
-
add("清空输入草稿", () => {
|
|
7316
|
-
this.rows = Array.from({ length: source.layout ? source.limit : Math.min(10, source.limit) }, () => ({}));
|
|
7317
|
-
this.page = 0;
|
|
7318
|
-
this.message = "";
|
|
7319
|
-
this.render();
|
|
7320
|
-
}, this.stale);
|
|
7321
|
-
if (source.layout) add("清空可编辑字段", () => {
|
|
7322
|
-
for (const cell of source.layout.cells) if (cell.editable && cell.field && cell.slot !== void 0 && cell.slot < this.rows.length) this.rows[cell.slot][cell.field.key] = "";
|
|
7323
|
-
this.render();
|
|
7324
|
-
}, this.stale);
|
|
7325
|
-
if (!this.dialog?.setActions([{
|
|
7970
|
+
this.status.textContent = "正在加载表格…";
|
|
7971
|
+
root.append(info, grid, this.status);
|
|
7972
|
+
if (!this.updateActions()) {
|
|
7973
|
+
const footer = owner.createElement("div"), cancel = owner.createElement("button");
|
|
7974
|
+
footer.className = "gct-word-field-actions";
|
|
7975
|
+
cancel.type = "button";
|
|
7976
|
+
cancel.className = "gct-word-field-button";
|
|
7977
|
+
cancel.textContent = "取消";
|
|
7978
|
+
cancel.addEventListener("click", () => this.close(), { signal: this.controls.signal });
|
|
7979
|
+
this.applyButton = owner.createElement("button");
|
|
7980
|
+
this.applyButton.type = "button";
|
|
7981
|
+
this.applyButton.className = "gct-word-field-button primary";
|
|
7982
|
+
this.applyButton.textContent = "确定";
|
|
7983
|
+
this.applyButton.disabled = true;
|
|
7984
|
+
this.applyButton.addEventListener("click", () => void this.apply(), { signal: this.controls.signal });
|
|
7985
|
+
footer.append(cancel, this.applyButton);
|
|
7986
|
+
root.append(footer);
|
|
7987
|
+
}
|
|
7988
|
+
return grid;
|
|
7989
|
+
}
|
|
7990
|
+
updateActions() {
|
|
7991
|
+
const disabled = !this.view || this.stale || this.submitting;
|
|
7992
|
+
if (this.applyButton) this.applyButton.disabled = disabled;
|
|
7993
|
+
return this.dialog?.setActions([{
|
|
7326
7994
|
label: "取消",
|
|
7327
7995
|
run: () => this.close()
|
|
7328
7996
|
}, {
|
|
7329
7997
|
label: "确定",
|
|
7330
7998
|
primary: true,
|
|
7331
|
-
disabled
|
|
7332
|
-
run: () => this.apply()
|
|
7333
|
-
}])
|
|
7334
|
-
const count = owner.createElement("span");
|
|
7335
|
-
count.textContent = `第 ${this.page + 1} 页 · 草稿 ${this.rows.length} 行`;
|
|
7336
|
-
tools.append(count);
|
|
7337
|
-
this.grid = owner.createElement("div");
|
|
7338
|
-
this.grid.style.cssText = "overflow:auto;max-height:55vh";
|
|
7339
|
-
if (source.layout) {
|
|
7340
|
-
this.grid.append(renderFixedQuickFillGrid({
|
|
7341
|
-
owner,
|
|
7342
|
-
layout: source.layout,
|
|
7343
|
-
page: this.page,
|
|
7344
|
-
signal,
|
|
7345
|
-
disabled: this.stale,
|
|
7346
|
-
value: (slot, key) => this.rows[slot]?.[key] ?? this.initialRows[slot]?.[key] ?? "",
|
|
7347
|
-
input: (slot, key, value) => {
|
|
7348
|
-
if (this.rows[slot]) this.rows[slot][key] = value;
|
|
7349
|
-
},
|
|
7350
|
-
paste: (text, row, column) => {
|
|
7351
|
-
if (this.stale) return;
|
|
7352
|
-
try {
|
|
7353
|
-
const patches = fixedQuickFillPaste(source.layout, text, row, column);
|
|
7354
|
-
if (patches.some((patch) => patch.slot >= this.rows.length)) throw Error("粘贴超过当前可填写容量");
|
|
7355
|
-
for (const patch of patches) this.rows[patch.slot][patch.key] = patch.value;
|
|
7356
|
-
this.message = "已粘贴到固定表草稿";
|
|
7357
|
-
this.render();
|
|
7358
|
-
} catch (error) {
|
|
7359
|
-
this.report(error);
|
|
7360
|
-
}
|
|
7361
|
-
}
|
|
7362
|
-
}));
|
|
7363
|
-
root.append(info, this.status, tools, this.grid);
|
|
7364
|
-
return;
|
|
7365
|
-
}
|
|
7366
|
-
const table = owner.createElement("table");
|
|
7367
|
-
table.setAttribute("aria-label", "快速填报输入表格");
|
|
7368
|
-
table.style.cssText = "border-collapse:collapse;width:max-content;min-width:100%";
|
|
7369
|
-
const head = owner.createElement("thead"), header = owner.createElement("tr");
|
|
7370
|
-
for (const title of ["序号", ...source.columns.map((column) => column.label)]) {
|
|
7371
|
-
const cell = owner.createElement("th");
|
|
7372
|
-
cell.textContent = title;
|
|
7373
|
-
header.append(cell);
|
|
7374
|
-
}
|
|
7375
|
-
head.append(header);
|
|
7376
|
-
table.append(head);
|
|
7377
|
-
const body = owner.createElement("tbody");
|
|
7378
|
-
for (let rowIndex = this.page * 20; rowIndex < Math.min(this.rows.length, (this.page + 1) * 20); rowIndex++) {
|
|
7379
|
-
const row = owner.createElement("tr"), index = owner.createElement("th");
|
|
7380
|
-
index.textContent = String(rowIndex + 1);
|
|
7381
|
-
row.append(index);
|
|
7382
|
-
for (const [columnIndex, column] of source.columns.entries()) {
|
|
7383
|
-
const cell = owner.createElement("td"), input = owner.createElement("textarea");
|
|
7384
|
-
input.rows = 1;
|
|
7385
|
-
input.readOnly = this.stale;
|
|
7386
|
-
input.value = this.rows[rowIndex][column.key] ?? "";
|
|
7387
|
-
input.setAttribute("aria-label", `第 ${rowIndex + 1} 行 · ${column.label}`);
|
|
7388
|
-
input.style.cssText = "min-width:130px;width:160px;resize:vertical;box-sizing:border-box";
|
|
7389
|
-
input.addEventListener("input", () => {
|
|
7390
|
-
this.rows[rowIndex][column.key] = input.value;
|
|
7391
|
-
}, { signal });
|
|
7392
|
-
input.addEventListener("paste", (event) => {
|
|
7393
|
-
const clipboard = event.clipboardData;
|
|
7394
|
-
if (!clipboard?.types.includes("text/plain")) return;
|
|
7395
|
-
const text = clipboard.getData("text/plain");
|
|
7396
|
-
event.preventDefault();
|
|
7397
|
-
this.paste(text, rowIndex, columnIndex);
|
|
7398
|
-
}, { signal });
|
|
7399
|
-
cell.append(input);
|
|
7400
|
-
row.append(cell);
|
|
7401
|
-
}
|
|
7402
|
-
body.append(row);
|
|
7403
|
-
}
|
|
7404
|
-
table.append(body);
|
|
7405
|
-
this.grid.append(table);
|
|
7406
|
-
root.append(info, this.status, tools, this.grid);
|
|
7407
|
-
}
|
|
7408
|
-
/** 粘贴先完整解析并检查矩形容量,失败保留旧矩阵,成功才更新草稿。 */
|
|
7409
|
-
paste(text, startRow, startColumn) {
|
|
7410
|
-
if (this.stale || !this.source) return;
|
|
7411
|
-
try {
|
|
7412
|
-
const matrix = parseTsv(text, {
|
|
7413
|
-
rows: this.source.limit - startRow,
|
|
7414
|
-
columns: this.source.columns.length - startColumn
|
|
7415
|
-
});
|
|
7416
|
-
while (this.rows.length < startRow + matrix.length) this.rows.push({});
|
|
7417
|
-
for (const [offset, row] of matrix.entries()) for (const [columnOffset, value] of row.entries()) this.rows[startRow + offset][this.source.columns[startColumn + columnOffset].key] = value;
|
|
7418
|
-
this.message = `已粘贴 ${matrix.length} 行`;
|
|
7419
|
-
this.render();
|
|
7420
|
-
} catch (error) {
|
|
7421
|
-
this.report(error);
|
|
7422
|
-
}
|
|
7999
|
+
disabled,
|
|
8000
|
+
run: () => void this.apply()
|
|
8001
|
+
}]) ?? false;
|
|
7423
8002
|
}
|
|
7424
8003
|
/** 只有显式应用才提交,所有输入继续使用统一字段规范化和后端协议。 */
|
|
7425
|
-
apply() {
|
|
7426
|
-
if (this.stale || !this.options || !this.source) return;
|
|
8004
|
+
async apply() {
|
|
8005
|
+
if (this.stale || this.submitting || !this.options || !this.source || !this.view) return;
|
|
8006
|
+
const source = this.source, view = this.view;
|
|
8007
|
+
this.submitting = true;
|
|
8008
|
+
this.updateActions();
|
|
7427
8009
|
try {
|
|
8010
|
+
await view.flush();
|
|
8011
|
+
if (this.source !== source || this.view !== view || this.stale || !this.options) return;
|
|
7428
8012
|
const rows = this.source.layout ? this.rows : this.rows.filter((row) => Object.keys(row).length > 0);
|
|
7429
8013
|
if (!rows.some((row) => Object.keys(row).length > 0)) throw Error("请输入需要填报的数据");
|
|
7430
8014
|
this.writing = true;
|
|
@@ -7432,18 +8016,20 @@ var CanvasQuickFillDialog = class {
|
|
|
7432
8016
|
this.close();
|
|
7433
8017
|
this.options?.onApplied?.(result);
|
|
7434
8018
|
} catch (error) {
|
|
7435
|
-
this.report(error);
|
|
8019
|
+
if (this.source === source && this.view === view) this.report(error);
|
|
7436
8020
|
} finally {
|
|
7437
8021
|
this.writing = false;
|
|
8022
|
+
if (this.source === source && this.view === view) {
|
|
8023
|
+
this.submitting = false;
|
|
8024
|
+
this.updateActions();
|
|
8025
|
+
}
|
|
7438
8026
|
}
|
|
7439
8027
|
}
|
|
7440
8028
|
/** 只保留可读错误文字,异常反馈不影响取消与释放。 */
|
|
7441
8029
|
report(error) {
|
|
7442
|
-
this.message = error
|
|
8030
|
+
this.message = wordPanelErrorText(error, "操作未完成,请重试");
|
|
7443
8031
|
if (this.status) this.status.textContent = this.message;
|
|
7444
|
-
|
|
7445
|
-
this.options?.onError?.(error);
|
|
7446
|
-
} catch {}
|
|
8032
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
7447
8033
|
}
|
|
7448
8034
|
};
|
|
7449
8035
|
// src/adapters/browser/input/business/tables/CanvasTableScanDialog.ts
|
|
@@ -7510,7 +8096,7 @@ var CanvasTableScanDialog = class {
|
|
|
7510
8096
|
const opening = new AbortController();
|
|
7511
8097
|
this.opening = opening;
|
|
7512
8098
|
try {
|
|
7513
|
-
if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("扫码打开已取消")))
|
|
8099
|
+
if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(opening.signal)), opening.signal, () => Error("扫码打开已取消"))) return;
|
|
7514
8100
|
if (opening.signal.aborted || this.options !== options) return;
|
|
7515
8101
|
const source = options.controller.businessTables.readScan(expected.regionId, expected.anchorInstanceKey);
|
|
7516
8102
|
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 +8349,8 @@ var CanvasTableScanDialog = class {
|
|
|
7763
8349
|
}
|
|
7764
8350
|
/** 仅保留文字供修正,来源对象和异常链不会进入草稿。 */
|
|
7765
8351
|
report(error) {
|
|
7766
|
-
this.message = error
|
|
7767
|
-
this.
|
|
8352
|
+
this.message = wordPanelErrorText(error, "操作未完成,请重试");
|
|
8353
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
7768
8354
|
this.update();
|
|
7769
8355
|
}
|
|
7770
8356
|
};
|
|
@@ -7908,7 +8494,7 @@ var CanvasBusinessTablePanel = class {
|
|
|
7908
8494
|
count.min = "1";
|
|
7909
8495
|
count.max = String(nativeTableRowBatchLimit);
|
|
7910
8496
|
count.step = "1";
|
|
7911
|
-
count.disabled = !state.
|
|
8497
|
+
count.disabled = !state.allowed.insert && !state.allowed.copy;
|
|
7912
8498
|
count.value = this.countText;
|
|
7913
8499
|
count.setAttribute("aria-label", "操作行数");
|
|
7914
8500
|
count.style.width = "70px";
|
|
@@ -7972,7 +8558,7 @@ var CanvasBusinessTablePanel = class {
|
|
|
7972
8558
|
try {
|
|
7973
8559
|
const count = Number(this.countText);
|
|
7974
8560
|
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("业务表操作已取消")))
|
|
8561
|
+
if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(task.signal)), task.signal, () => Error("业务表操作已取消"))) return;
|
|
7976
8562
|
if (task.signal.aborted || this.options !== options) return;
|
|
7977
8563
|
const api = options.controller.businessTables, current = api.read(expected.regionId);
|
|
7978
8564
|
if (!current || !isEqual(current.version, expected.version) || !isEqual(current.selection, expected.selection) || !isEqual(current.occurrence, expected.occurrence)) throw Error("业务表或当前输入已变化,请重新操作");
|
|
@@ -7998,10 +8584,8 @@ var CanvasBusinessTablePanel = class {
|
|
|
7998
8584
|
}
|
|
7999
8585
|
/** 失败只保留可展示文字,外部反馈异常不能保留整个异常链。 */
|
|
8000
8586
|
report(error) {
|
|
8001
|
-
this.message = error
|
|
8002
|
-
|
|
8003
|
-
this.options?.onError?.(error);
|
|
8004
|
-
} catch {}
|
|
8587
|
+
this.message = wordPanelErrorText(error, "操作未完成,请重试");
|
|
8588
|
+
reportUnhandledWordError(error, !!this.state && hasLocalWordFeedback(this.root), this.options?.onError);
|
|
8005
8589
|
if (!this.task) this.render();
|
|
8006
8590
|
}
|
|
8007
8591
|
};
|
|
@@ -8038,17 +8622,19 @@ function attachCanvasTextInput(context, options) {
|
|
|
8038
8622
|
throw error;
|
|
8039
8623
|
}
|
|
8040
8624
|
}
|
|
8041
|
-
// src/adapters/browser/input/validation/
|
|
8042
|
-
/** @file 校验批注的字段描边和页边编号,只读取当前布局,不占正文空间。 */
|
|
8043
|
-
/** 同一字段的多条规则共用编号,重复行以实际业务路径区分。 */
|
|
8625
|
+
// src/adapters/browser/input/validation/validation-issue-key.ts
|
|
8044
8626
|
function validationIssueKey(issue) {
|
|
8045
8627
|
return JSON.stringify([issue.fieldId ?? issue.regionId ?? issue.code, issue.valuePath]);
|
|
8046
8628
|
}
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8629
|
+
// src/adapters/browser/input/validation/CanvasValidationComments.ts
|
|
8630
|
+
/** @file 纸张右侧的字段校验卡片,只投影当前诊断与已绘制几何,不保存填写值。 */
|
|
8631
|
+
/** 每个字段发生一张卡片,多个错误合并展示;当前输入字段让位于贴近提示。 */
|
|
8632
|
+
var CanvasValidationComments = class {
|
|
8050
8633
|
options;
|
|
8051
8634
|
navigate;
|
|
8635
|
+
layers = [];
|
|
8636
|
+
lifetime;
|
|
8637
|
+
rendered;
|
|
8052
8638
|
constructor(options, navigate) {
|
|
8053
8639
|
this.options = {
|
|
8054
8640
|
pageHost: options.pageHost,
|
|
@@ -8058,124 +8644,164 @@ var CanvasValidationMarks = class {
|
|
|
8058
8644
|
this.navigate = navigate;
|
|
8059
8645
|
}
|
|
8060
8646
|
refresh(report, activeKey, inputFocus, focusOnly = false) {
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
const
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
return;
|
|
8067
|
-
}
|
|
8068
|
-
const revision = snapshot.result.version.layoutRevision;
|
|
8069
|
-
const pages = inputScreenPages(pageHost, snapshot);
|
|
8070
|
-
const canvases = [...pages.values()].map((page) => page.canvas);
|
|
8647
|
+
const options = this.options, snapshot = options?.layout.getCurrentSnapshot();
|
|
8648
|
+
if (!options || !snapshot) return;
|
|
8649
|
+
const pages = inputScreenPages(options.pageHost, snapshot);
|
|
8650
|
+
const clip = viewportClip(options.pageHost);
|
|
8651
|
+
const canvases = [...pages.values()].map((surface) => surface.canvas);
|
|
8071
8652
|
const key = JSON.stringify([
|
|
8653
|
+
snapshot.result.version.layoutRevision,
|
|
8072
8654
|
report.issues,
|
|
8073
8655
|
activeKey,
|
|
8074
8656
|
inputFocus,
|
|
8075
|
-
focusOnly
|
|
8657
|
+
focusOnly,
|
|
8658
|
+
[...pages.values()].map((surface) => [
|
|
8659
|
+
surface.rect.width,
|
|
8660
|
+
surface.rect.height,
|
|
8661
|
+
surface.canvas.offsetLeft,
|
|
8662
|
+
surface.canvas.offsetTop,
|
|
8663
|
+
clip.left + clip.width - surface.rect.left
|
|
8664
|
+
])
|
|
8076
8665
|
]);
|
|
8077
|
-
if (this.rendered?.
|
|
8666
|
+
if (this.rendered?.key === key && canvases.length === this.rendered.canvases.length && canvases.every((canvas, index) => canvas === this.rendered.canvases[index]) && this.layers.every((layer) => layer.isConnected && canvases.some((canvas) => canvas.parentElement === layer.parentElement))) return;
|
|
8078
8667
|
this.clear();
|
|
8079
|
-
|
|
8080
|
-
const
|
|
8081
|
-
const
|
|
8668
|
+
this.lifetime = new AbortController();
|
|
8669
|
+
const locations = options.controller.validationLocations(report.issues, report.versions);
|
|
8670
|
+
const groups = /* @__PURE__ */ new Map();
|
|
8082
8671
|
for (const [index, issue] of report.issues.entries()) {
|
|
8083
|
-
const
|
|
8084
|
-
if ((issue.displayOnly || focusOnly) &&
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
const
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
boxSizing: "border-box",
|
|
8115
|
-
pointerEvents: "none",
|
|
8116
|
-
outline: `${active ? 2 : 1}px ${active ? "solid" : "dashed"} ${color}`,
|
|
8117
|
-
outlineOffset: "2px",
|
|
8118
|
-
background: active ? "#fff1f040" : "transparent",
|
|
8119
|
-
borderRadius: "2px",
|
|
8120
|
-
left: `${frame.x / surface.page.width * 100}%`,
|
|
8121
|
-
top: `${frame.y / surface.page.height * 100}%`,
|
|
8122
|
-
width: `${frame.width / surface.page.width * 100}%`,
|
|
8123
|
-
height: `${frame.height / surface.page.height * 100}%`
|
|
8124
|
-
});
|
|
8125
|
-
layer.append(mark);
|
|
8126
|
-
const badgeKey = JSON.stringify([pageId, identity]);
|
|
8127
|
-
if (badges.has(badgeKey)) continue;
|
|
8128
|
-
badges.add(badgeKey);
|
|
8129
|
-
const top = Math.max(frame.y + frame.height / 2 - 10, badgeTops.get(pageId) ?? 0);
|
|
8130
|
-
badgeTops.set(pageId, top + 23);
|
|
8131
|
-
const rightMargin = surface.page.width - surface.page.contentFrame.x - surface.page.contentFrame.width;
|
|
8132
|
-
const badgeLeft = rightMargin >= 28 ? surface.page.width - Math.min(42, rightMargin - 4) : surface.page.width + 6;
|
|
8133
|
-
const badge = owner.createElement("button");
|
|
8134
|
-
badge.type = "button";
|
|
8135
|
-
badge.className = `gct-word-validation-anchor${active ? " is-active" : ""}`;
|
|
8136
|
-
badge.dataset.validationNumber = String(number);
|
|
8137
|
-
badge.textContent = String(number);
|
|
8138
|
-
badge.setAttribute("aria-label", `校验批注 ${number}:${issue.label}`);
|
|
8139
|
-
Object.assign(badge.style, {
|
|
8140
|
-
position: "absolute",
|
|
8141
|
-
pointerEvents: "auto",
|
|
8142
|
-
boxSizing: "border-box",
|
|
8143
|
-
left: `${badgeLeft / surface.page.width * 100}%`,
|
|
8144
|
-
top: `${Math.min(top, surface.page.height - 24) / surface.page.height * 100}%`,
|
|
8145
|
-
width: "20px",
|
|
8146
|
-
height: "20px",
|
|
8147
|
-
padding: "0",
|
|
8148
|
-
borderRadius: "6px",
|
|
8149
|
-
border: `1px solid ${color}`,
|
|
8150
|
-
background: active ? color : "#fff5f5",
|
|
8151
|
-
color: active ? "#fff" : color,
|
|
8152
|
-
font: "600 11px/18px sans-serif",
|
|
8153
|
-
cursor: "pointer"
|
|
8154
|
-
});
|
|
8155
|
-
badge.addEventListener("pointerdown", (event) => {
|
|
8156
|
-
event.preventDefault();
|
|
8157
|
-
event.stopPropagation();
|
|
8158
|
-
badge.focus({ preventScroll: true });
|
|
8159
|
-
this.navigate?.(index);
|
|
8160
|
-
});
|
|
8161
|
-
badge.addEventListener("click", (event) => {
|
|
8162
|
-
if (event.detail === 0) {
|
|
8163
|
-
badge.focus({ preventScroll: true });
|
|
8164
|
-
this.navigate?.(index);
|
|
8672
|
+
const key = validationIssueKey(issue);
|
|
8673
|
+
if ((issue.displayOnly || focusOnly) && key !== activeKey) continue;
|
|
8674
|
+
if (inputFocus && issue.fieldId === inputFocus.fieldId && issue.valuePath === inputFocus.valuePath) continue;
|
|
8675
|
+
const group = groups.get(key);
|
|
8676
|
+
if (group) group.issues.push(issue);
|
|
8677
|
+
else groups.set(key, {
|
|
8678
|
+
index,
|
|
8679
|
+
issues: [issue]
|
|
8680
|
+
});
|
|
8681
|
+
}
|
|
8682
|
+
let previousBottom = -Infinity;
|
|
8683
|
+
for (const [pageId, surface] of pages) {
|
|
8684
|
+
const parent = surface.canvas.parentElement;
|
|
8685
|
+
if (!parent) continue;
|
|
8686
|
+
const scaleX = surface.rect.width / surface.page.width;
|
|
8687
|
+
const scaleY = surface.rect.height / surface.page.height;
|
|
8688
|
+
const entries = [...groups.entries()].flatMap(([key, group]) => {
|
|
8689
|
+
const frames = locations.get(group.issues[0])?.filter((item) => item.pageId === pageId).map((item) => item.frame);
|
|
8690
|
+
if (!frames?.length) return [];
|
|
8691
|
+
const x = Math.min(...frames.map((frame) => frame.x));
|
|
8692
|
+
const y = Math.min(...frames.map((frame) => frame.y));
|
|
8693
|
+
const right = Math.max(...frames.map((frame) => frame.x + frame.width));
|
|
8694
|
+
const bottom = Math.max(...frames.map((frame) => frame.y + frame.height));
|
|
8695
|
+
return [{
|
|
8696
|
+
key,
|
|
8697
|
+
group,
|
|
8698
|
+
frame: {
|
|
8699
|
+
x,
|
|
8700
|
+
y,
|
|
8701
|
+
width: right - x,
|
|
8702
|
+
height: bottom - y
|
|
8165
8703
|
}
|
|
8704
|
+
}];
|
|
8705
|
+
}).sort((a, b) => a.frame.y - b.frame.y || a.frame.x - b.frame.x);
|
|
8706
|
+
if (!entries.length) continue;
|
|
8707
|
+
const owner = parent.ownerDocument, layer = owner.createElement("div");
|
|
8708
|
+
layer.className = "gct-word-validation-comments";
|
|
8709
|
+
Object.assign(layer.style, {
|
|
8710
|
+
position: "absolute",
|
|
8711
|
+
left: `${surface.canvas.offsetLeft}px`,
|
|
8712
|
+
top: `${surface.canvas.offsetTop}px`,
|
|
8713
|
+
width: `${surface.rect.width}px`,
|
|
8714
|
+
height: `${surface.rect.height}px`,
|
|
8715
|
+
pointerEvents: "none",
|
|
8716
|
+
zIndex: "4"
|
|
8717
|
+
});
|
|
8718
|
+
parent.append(layer);
|
|
8719
|
+
this.layers.push(layer);
|
|
8720
|
+
const paperRight = (surface.page.bodyTableOverflow?.right ?? surface.page.width) * scaleX;
|
|
8721
|
+
for (const { key, group, frame } of entries) {
|
|
8722
|
+
const card = this.card(owner, group, key === activeKey);
|
|
8723
|
+
card.dataset.validationKey = key;
|
|
8724
|
+
const fieldRight = (frame.x + frame.width) * scaleX;
|
|
8725
|
+
const left = Math.max(paperRight + 32, fieldRight + 32);
|
|
8726
|
+
const room = clip.left + clip.width - surface.rect.left - left - 12;
|
|
8727
|
+
card.style.width = `${Math.max(180, Math.min(260, room))}px`;
|
|
8728
|
+
layer.append(card);
|
|
8729
|
+
const height = card.offsetHeight || 82 + (group.issues.length - 1) * 30;
|
|
8730
|
+
const top = Math.max(16, frame.y * scaleY - height, previousBottom + 16 - surface.rect.top);
|
|
8731
|
+
Object.assign(card.style, {
|
|
8732
|
+
left: `${left}px`,
|
|
8733
|
+
top: `${top}px`
|
|
8166
8734
|
});
|
|
8167
|
-
|
|
8735
|
+
previousBottom = surface.rect.top + top + height;
|
|
8736
|
+
const y = (frame.y + frame.height) * scaleY + 1;
|
|
8737
|
+
const middle = left - 16;
|
|
8738
|
+
this.line(layer, frame.x * scaleX, y, middle, y);
|
|
8739
|
+
this.line(layer, middle, y, left, top + 16);
|
|
8168
8740
|
}
|
|
8169
8741
|
}
|
|
8170
8742
|
this.rendered = {
|
|
8171
|
-
revision,
|
|
8172
8743
|
key,
|
|
8173
8744
|
canvases
|
|
8174
8745
|
};
|
|
8175
8746
|
}
|
|
8747
|
+
card(owner, group, active) {
|
|
8748
|
+
const issue = group.issues[0];
|
|
8749
|
+
const card = owner.createElement("div"), header = owner.createElement("div"), title = owner.createElement("strong");
|
|
8750
|
+
card.className = `gct-word-validation-comment${active ? " is-active" : ""}`;
|
|
8751
|
+
card.dataset.validationComment = "";
|
|
8752
|
+
card.tabIndex = -1;
|
|
8753
|
+
card.setAttribute("role", "group");
|
|
8754
|
+
card.setAttribute("aria-label", `${issue.label}校验错误`);
|
|
8755
|
+
if (issue.valuePath) card.dataset.validationPath = issue.valuePath;
|
|
8756
|
+
header.className = "gct-word-validation-comment-header";
|
|
8757
|
+
title.textContent = issue.label;
|
|
8758
|
+
header.append(title);
|
|
8759
|
+
card.append(header);
|
|
8760
|
+
card.addEventListener("pointerdown", (event) => {
|
|
8761
|
+
event.preventDefault();
|
|
8762
|
+
event.stopPropagation();
|
|
8763
|
+
if (event.button !== 0) return;
|
|
8764
|
+
this.navigate?.(group.index);
|
|
8765
|
+
}, { signal: this.lifetime.signal });
|
|
8766
|
+
card.addEventListener("click", (event) => {
|
|
8767
|
+
event.stopPropagation();
|
|
8768
|
+
if (event.detail === 0) this.navigate?.(group.index);
|
|
8769
|
+
}, { signal: this.lifetime.signal });
|
|
8770
|
+
card.addEventListener("dblclick", (event) => event.stopPropagation(), { signal: this.lifetime.signal });
|
|
8771
|
+
for (const item of group.issues) {
|
|
8772
|
+
const button = owner.createElement("button"), bullet = owner.createElement("span"), message = owner.createElement("span");
|
|
8773
|
+
button.type = "button";
|
|
8774
|
+
button.className = "gct-word-validation-comment-message";
|
|
8775
|
+
button.setAttribute("aria-label", `${item.label} ${item.message}`);
|
|
8776
|
+
bullet.className = "gct-word-validation-comment-bullet";
|
|
8777
|
+
bullet.setAttribute("aria-hidden", "true");
|
|
8778
|
+
bullet.textContent = "•";
|
|
8779
|
+
message.textContent = item.message;
|
|
8780
|
+
message.className = "gct-word-validation-comment-error";
|
|
8781
|
+
button.append(bullet, message);
|
|
8782
|
+
card.append(button);
|
|
8783
|
+
}
|
|
8784
|
+
return card;
|
|
8785
|
+
}
|
|
8786
|
+
line(layer, x1, y1, x2, y2) {
|
|
8787
|
+
const line = layer.ownerDocument.createElement("span");
|
|
8788
|
+
line.className = "gct-word-validation-comment-line";
|
|
8789
|
+
line.setAttribute("aria-hidden", "true");
|
|
8790
|
+
Object.assign(line.style, {
|
|
8791
|
+
position: "absolute",
|
|
8792
|
+
left: `${x1}px`,
|
|
8793
|
+
top: `${y1}px`,
|
|
8794
|
+
width: `${Math.hypot(x2 - x1, y2 - y1)}px`,
|
|
8795
|
+
transform: `rotate(${Math.atan2(y2 - y1, x2 - x1)}rad)`,
|
|
8796
|
+
transformOrigin: "0 0"
|
|
8797
|
+
});
|
|
8798
|
+
layer.append(line);
|
|
8799
|
+
}
|
|
8176
8800
|
clear() {
|
|
8177
|
-
|
|
8178
|
-
this.
|
|
8801
|
+
this.lifetime?.abort();
|
|
8802
|
+
this.lifetime = void 0;
|
|
8803
|
+
for (const layer of this.layers) layer.remove();
|
|
8804
|
+
this.layers.length = 0;
|
|
8179
8805
|
this.rendered = void 0;
|
|
8180
8806
|
}
|
|
8181
8807
|
dispose() {
|
|
@@ -8185,7 +8811,7 @@ var CanvasValidationMarks = class {
|
|
|
8185
8811
|
}
|
|
8186
8812
|
};
|
|
8187
8813
|
// src/adapters/browser/input/validation/CanvasValidationPanel.ts
|
|
8188
|
-
/** @file
|
|
8814
|
+
/** @file 校验列表与纸张右侧批注只借用当前视图和轻量诊断。 */
|
|
8189
8815
|
/** 检查仅保存轻量问题;换数据、关闭和重检会立即撤掉旧标记。 */
|
|
8190
8816
|
var CanvasValidationPanel = class {
|
|
8191
8817
|
/** 关闭后解除宿主、服务和输入能力。 */
|
|
@@ -8200,22 +8826,24 @@ var CanvasValidationPanel = class {
|
|
|
8200
8826
|
report;
|
|
8201
8827
|
/** 只读详情跟随外部数据,保留当前展示校验策略。 */
|
|
8202
8828
|
displayEnabled = false;
|
|
8203
|
-
/**
|
|
8204
|
-
|
|
8829
|
+
/** 其他批注查看期间让出连线和卡片,报告仍可通过校验列表读取。 */
|
|
8830
|
+
commentsVisible = true;
|
|
8205
8831
|
/** 同一批同步写入只排一次展示校验。 */
|
|
8206
8832
|
displayQueued = false;
|
|
8207
|
-
|
|
8833
|
+
comments;
|
|
8208
8834
|
/** 取消后清空会话变更监听。 */
|
|
8209
8835
|
unsubscribe;
|
|
8210
8836
|
unsubscribeFeedback;
|
|
8211
8837
|
live = false;
|
|
8212
8838
|
checking = false;
|
|
8213
|
-
/**
|
|
8839
|
+
/** 点击只读异常字段、定位入口或手动检查才能打开独立清单。 */
|
|
8214
8840
|
opened = false;
|
|
8215
8841
|
checkMode = "submit";
|
|
8216
8842
|
inputValidation;
|
|
8217
8843
|
inputFocus;
|
|
8218
8844
|
activeKey;
|
|
8845
|
+
/** 查看卡片时忽略原编辑选区的重复通知,真正重新点选字段后再跟随编辑。 */
|
|
8846
|
+
viewedSelection;
|
|
8219
8847
|
/** 只读异常的查看焦点独立于编辑选区,不激活输入或业务弹框。 */
|
|
8220
8848
|
focusedDisplay = false;
|
|
8221
8849
|
unsubscribeSelection;
|
|
@@ -8223,7 +8851,7 @@ var CanvasValidationPanel = class {
|
|
|
8223
8851
|
constructor(handle, options) {
|
|
8224
8852
|
this.handle = handle;
|
|
8225
8853
|
this.options = options;
|
|
8226
|
-
this.
|
|
8854
|
+
this.comments = new CanvasValidationComments(options, (index) => void this.navigate(index, false));
|
|
8227
8855
|
options.host.hidden = true;
|
|
8228
8856
|
options.host.classList.add("gct-word-validation-panel");
|
|
8229
8857
|
options.host.addEventListener("click", (event) => {
|
|
@@ -8256,14 +8884,26 @@ var CanvasValidationPanel = class {
|
|
|
8256
8884
|
this.opened = false;
|
|
8257
8885
|
this.clear();
|
|
8258
8886
|
if (change.kind === "environment") this.displayEnabled = false;
|
|
8259
|
-
} else if (this.report)
|
|
8260
|
-
if (change.kind === "data" && options.feedback && !this.displayEnabled) this.clearMarks();
|
|
8261
|
-
else this.clear(change.kind === "data" && !this.displayEnabled ? "填写数据已变化,请重新校验。" : void 0);
|
|
8262
|
-
}
|
|
8887
|
+
} else if (this.report && (change.kind !== "data" || !options.feedback || this.displayEnabled)) this.clear(change.kind === "data" && !this.displayEnabled ? "填写数据已变化,请重新校验。" : void 0);
|
|
8263
8888
|
if (this.displayEnabled) this.queueDisplay();
|
|
8264
8889
|
else if (options.feedback) queueMicrotask(() => this.showLive());
|
|
8265
8890
|
});
|
|
8266
|
-
this.unsubscribeFeedback = options.feedback?.subscribe(() =>
|
|
8891
|
+
this.unsubscribeFeedback = options.feedback?.subscribe((reason) => {
|
|
8892
|
+
if (reason === "check") {
|
|
8893
|
+
this.task?.abort();
|
|
8894
|
+
this.task = void 0;
|
|
8895
|
+
this.checking = false;
|
|
8896
|
+
this.inputValidation = void 0;
|
|
8897
|
+
this.inputFocus = void 0;
|
|
8898
|
+
this.displayEnabled = false;
|
|
8899
|
+
this.focusedDisplay = false;
|
|
8900
|
+
this.activeKey = void 0;
|
|
8901
|
+
this.opened = true;
|
|
8902
|
+
this.live = true;
|
|
8903
|
+
this.checkMode = "submit";
|
|
8904
|
+
}
|
|
8905
|
+
this.showLive();
|
|
8906
|
+
});
|
|
8267
8907
|
this.unsubscribeSelection = options.controller.subscribe(() => this.syncActiveField());
|
|
8268
8908
|
}
|
|
8269
8909
|
/** 输入中只在字段旁提示;离开后使用独立批注栏,不覆盖其他字段。 */
|
|
@@ -8284,13 +8924,14 @@ var CanvasValidationPanel = class {
|
|
|
8284
8924
|
const matches = (issue) => issue.fieldId === input.fieldId && issue.valuePath === input.valuePath;
|
|
8285
8925
|
const first = issues.findIndex(matches);
|
|
8286
8926
|
for (let index = issues.length - 1; index >= 0; index--) if (matches(issues[index])) issues.splice(index, 1);
|
|
8287
|
-
|
|
8927
|
+
const messages = input.messages ?? (input.message ? [input.message] : []);
|
|
8928
|
+
issues.splice(first < 0 ? issues.length : first, 0, ...messages.map((message) => ({
|
|
8288
8929
|
...input,
|
|
8289
8930
|
stage: "fields",
|
|
8290
8931
|
kind: "value",
|
|
8291
8932
|
code: "field_input_draft",
|
|
8292
|
-
message
|
|
8293
|
-
});
|
|
8933
|
+
message
|
|
8934
|
+
})));
|
|
8294
8935
|
}
|
|
8295
8936
|
const report = {
|
|
8296
8937
|
...stored,
|
|
@@ -8302,7 +8943,7 @@ var CanvasValidationPanel = class {
|
|
|
8302
8943
|
this.refresh();
|
|
8303
8944
|
return;
|
|
8304
8945
|
}
|
|
8305
|
-
this.
|
|
8946
|
+
this.clearComments();
|
|
8306
8947
|
this.live = true;
|
|
8307
8948
|
if (!report.issues.length) {
|
|
8308
8949
|
this.clear();
|
|
@@ -8319,12 +8960,14 @@ var CanvasValidationPanel = class {
|
|
|
8319
8960
|
this.live = true;
|
|
8320
8961
|
this.showLive();
|
|
8321
8962
|
}
|
|
8322
|
-
/**
|
|
8963
|
+
/** 当前字段聚焦后使用贴近提示,其他字段的错误卡片继续显示。 */
|
|
8323
8964
|
setInputFocus(field) {
|
|
8324
8965
|
if (JSON.stringify(this.inputFocus) === JSON.stringify(field)) return;
|
|
8325
8966
|
this.inputFocus = field;
|
|
8326
8967
|
if (!this.options) return;
|
|
8327
8968
|
if (field) {
|
|
8969
|
+
this.viewedSelection = void 0;
|
|
8970
|
+
this.syncActiveField();
|
|
8328
8971
|
this.refresh();
|
|
8329
8972
|
if (this.opened) this.renderEditing();
|
|
8330
8973
|
} else if (this.report && !this.live && this.versionCurrent(this.report)) {
|
|
@@ -8391,26 +9034,28 @@ var CanvasValidationPanel = class {
|
|
|
8391
9034
|
} catch (error) {
|
|
8392
9035
|
if (!this.current(task)) return;
|
|
8393
9036
|
this.clear("本次校验未完成,请重试。");
|
|
8394
|
-
options.
|
|
9037
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(options.host.querySelector("[role=\"status\"]") ?? void 0), options.onError);
|
|
8395
9038
|
} finally {
|
|
8396
|
-
this.
|
|
8397
|
-
|
|
8398
|
-
this.
|
|
8399
|
-
|
|
9039
|
+
if (this.task === task) {
|
|
9040
|
+
this.checking = false;
|
|
9041
|
+
if (this.inputValidation) {
|
|
9042
|
+
this.live = true;
|
|
9043
|
+
this.showLive();
|
|
9044
|
+
}
|
|
9045
|
+
this.end(task);
|
|
8400
9046
|
}
|
|
8401
|
-
this.end(task);
|
|
8402
9047
|
}
|
|
8403
9048
|
}
|
|
8404
9049
|
/** Canvas 完成绘制后再映射标记,不触发排版、数据写入或整页重绘。 */
|
|
8405
9050
|
refresh() {
|
|
8406
9051
|
const options = this.options, report = this.report;
|
|
8407
|
-
if (!options || !report || !report.issues.length || !this.
|
|
8408
|
-
this.
|
|
9052
|
+
if (!options || !report || !report.issues.length || !this.commentsVisible || !this.versionCurrent(report)) return;
|
|
9053
|
+
this.comments.refresh(report, this.activeKey, this.inputFocus, this.focusedDisplay);
|
|
8409
9054
|
}
|
|
8410
9055
|
/** 只按当前已绘制发生查看展示异常,空白或其他字段的点击收起这份按需详情。 */
|
|
8411
9056
|
inspectPointer(request) {
|
|
8412
9057
|
const options = this.options, report = this.report;
|
|
8413
|
-
if (!options || !report || !this.
|
|
9058
|
+
if (!options || !report || !this.commentsVisible || !this.versionCurrent(report)) return;
|
|
8414
9059
|
const candidates = report.issues.filter((issue) => issue.displayOnly);
|
|
8415
9060
|
const locations = options.controller.validationLocations(candidates, report.versions);
|
|
8416
9061
|
const issue = request && candidates.find((candidate) => locations.get(candidate)?.some(({ pageId, frame }) => pageId === request.pageId && request.x >= frame.x && request.x <= frame.x + frame.width && request.y >= frame.y && request.y <= frame.y + frame.height));
|
|
@@ -8421,12 +9066,12 @@ var CanvasValidationPanel = class {
|
|
|
8421
9066
|
this.renderPanel(report);
|
|
8422
9067
|
this.refresh();
|
|
8423
9068
|
}
|
|
8424
|
-
/**
|
|
9069
|
+
/** 批注和校验使用同一画布,只展示当前操作所需的连线和卡片。 */
|
|
8425
9070
|
setMarksVisible(visible) {
|
|
8426
|
-
if (visible === this.
|
|
8427
|
-
this.
|
|
9071
|
+
if (visible === this.commentsVisible) return;
|
|
9072
|
+
this.commentsVisible = visible;
|
|
8428
9073
|
if (visible) this.refresh();
|
|
8429
|
-
else this.
|
|
9074
|
+
else this.clearComments();
|
|
8430
9075
|
}
|
|
8431
9076
|
/** 宿主的校验清单也使用当前稳定位置。 */
|
|
8432
9077
|
async navigatePath(path, display) {
|
|
@@ -8438,17 +9083,22 @@ var CanvasValidationPanel = class {
|
|
|
8438
9083
|
if (index >= 0) await this.navigate(index);
|
|
8439
9084
|
}
|
|
8440
9085
|
/** 使用列表中的精确发生跳转,不自动打开签署或选择弹框。 */
|
|
8441
|
-
async navigate(index,
|
|
9086
|
+
async navigate(index, showPanel = true) {
|
|
8442
9087
|
const options = this.options, live = this.live;
|
|
8443
9088
|
let report = this.report, issue = report?.issues[index];
|
|
8444
9089
|
if (!options || !report || !issue || !this.versionCurrent(report)) return;
|
|
9090
|
+
this.viewedSelection = showPanel ? void 0 : options.controller.getState().selection;
|
|
8445
9091
|
this.activeKey = validationIssueKey(issue);
|
|
8446
|
-
this.opened = true;
|
|
9092
|
+
if (showPanel) this.opened = true;
|
|
8447
9093
|
this.renderPanel(report);
|
|
8448
9094
|
this.updateActiveCards();
|
|
8449
9095
|
this.refresh();
|
|
9096
|
+
if (!showPanel) {
|
|
9097
|
+
this.revealIssue(issue, report, false);
|
|
9098
|
+
return;
|
|
9099
|
+
}
|
|
8450
9100
|
if (issue.code === "field_input_draft") {
|
|
8451
|
-
|
|
9101
|
+
options.focusInput?.();
|
|
8452
9102
|
return;
|
|
8453
9103
|
}
|
|
8454
9104
|
const requested = issue;
|
|
@@ -8467,22 +9117,31 @@ var CanvasValidationPanel = class {
|
|
|
8467
9117
|
this.renderPanel(report);
|
|
8468
9118
|
}
|
|
8469
9119
|
if (!committed || !this.current(task) || this.report !== report || !this.versionCurrent(report)) return;
|
|
8470
|
-
|
|
8471
|
-
if (!snapshot) return;
|
|
8472
|
-
for (const location of options.controller.validationLocations([issue], report.versions).get(issue) ?? []) {
|
|
8473
|
-
const page = inputPageLocation(options.pageHost, snapshot, location.pageId);
|
|
8474
|
-
if (!page) continue;
|
|
8475
|
-
revealInputRect(options.pageHost, inputScreenRect(location.frame, page));
|
|
8476
|
-
if (!this.displayEnabled && !issue.displayOnly && issue.fieldId && location.instanceKey) options.controller.selectField(issue.fieldId, location.instanceKey);
|
|
8477
|
-
return;
|
|
8478
|
-
}
|
|
8479
|
-
this.setStatus("当前画面中没有可定位的对应位置。");
|
|
9120
|
+
this.revealIssue(issue, report, true);
|
|
8480
9121
|
} catch (error) {
|
|
8481
|
-
if (this.current(task))
|
|
9122
|
+
if (this.current(task)) {
|
|
9123
|
+
this.setStatus(wordPanelErrorText(error, "当前无法定位,请重试。"));
|
|
9124
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(options.host.querySelector("[role=\"status\"]") ?? void 0), options.onError);
|
|
9125
|
+
}
|
|
8482
9126
|
} finally {
|
|
8483
9127
|
this.end(task);
|
|
8484
9128
|
}
|
|
8485
9129
|
}
|
|
9130
|
+
/** 查看卡片与清单共用真实发生几何,只有清单导航可以改变编辑选区。 */
|
|
9131
|
+
revealIssue(issue, report, select) {
|
|
9132
|
+
const options = this.options;
|
|
9133
|
+
if (!options) return;
|
|
9134
|
+
const snapshot = options.layout.getCurrentSnapshot() ?? options.layout.flush();
|
|
9135
|
+
if (!snapshot) return;
|
|
9136
|
+
for (const location of options.controller.validationLocations([issue], report.versions).get(issue) ?? []) {
|
|
9137
|
+
const page = inputPageLocation(options.pageHost, snapshot, location.pageId);
|
|
9138
|
+
if (!page) continue;
|
|
9139
|
+
revealInputRect(options.pageHost, inputScreenRect(location.frame, page));
|
|
9140
|
+
if (select && !this.displayEnabled && !issue.displayOnly && issue.fieldId && location.instanceKey) options.controller.selectField(issue.fieldId, location.instanceKey);
|
|
9141
|
+
return;
|
|
9142
|
+
}
|
|
9143
|
+
this.setStatus("当前画面中没有可定位的对应位置。");
|
|
9144
|
+
}
|
|
8486
9145
|
/** 模型和数据必须仍与校验一致,字体和缩放重绘使用新几何。 */
|
|
8487
9146
|
versionCurrent(report) {
|
|
8488
9147
|
const handle = this.handle;
|
|
@@ -8545,7 +9204,7 @@ var CanvasValidationPanel = class {
|
|
|
8545
9204
|
this.setStatus(title);
|
|
8546
9205
|
const note = owner.createElement("p");
|
|
8547
9206
|
note.className = "gct-word-validation-note";
|
|
8548
|
-
note.textContent = this.focusedDisplay ? "只读异常仅展示,不影响提交。" : this.live ? "
|
|
9207
|
+
note.textContent = this.focusedDisplay ? "只读异常仅展示,不影响提交。" : this.live ? "错误卡片与字段通过连线对应,点击可定位字段。" : this.checkMode === "save" ? "仅检查草稿能否保存;未修正的字段问题继续保留,正式提交仍需通过完整校验。" : "提交前完整校验,包含必填、字段和业务规则。";
|
|
8549
9208
|
if (displayed && !this.focusedDisplay) note.textContent += "只读异常仅展示,不影响提交。";
|
|
8550
9209
|
host.append(note);
|
|
8551
9210
|
if (report.issues.length) host.append(list);
|
|
@@ -8583,6 +9242,10 @@ var CanvasValidationPanel = class {
|
|
|
8583
9242
|
const options = this.options, report = this.report;
|
|
8584
9243
|
if (!options || !report || this.focusedDisplay) return;
|
|
8585
9244
|
const selection = options.controller.getState().selection;
|
|
9245
|
+
if (this.viewedSelection !== void 0) {
|
|
9246
|
+
if (selection === this.viewedSelection) return;
|
|
9247
|
+
this.viewedSelection = void 0;
|
|
9248
|
+
}
|
|
8586
9249
|
const state = selection?.kind === "field" ? options.controller.getFieldTextInput() : void 0;
|
|
8587
9250
|
let issue = report.issues.find((item) => state && item.fieldId === state.selection.fieldId && item.valuePath === state.validationPath);
|
|
8588
9251
|
if (!state && selection?.kind === "field") {
|
|
@@ -8627,7 +9290,7 @@ var CanvasValidationPanel = class {
|
|
|
8627
9290
|
/** 清空列表和当前几何。 */
|
|
8628
9291
|
clear(text) {
|
|
8629
9292
|
this.report = void 0;
|
|
8630
|
-
this.
|
|
9293
|
+
this.clearComments();
|
|
8631
9294
|
const host = this.options?.host;
|
|
8632
9295
|
if (!host) return;
|
|
8633
9296
|
host.replaceChildren();
|
|
@@ -8638,8 +9301,8 @@ var CanvasValidationPanel = class {
|
|
|
8638
9301
|
}
|
|
8639
9302
|
}
|
|
8640
9303
|
/** 移除各页透明层,释放页面节点。 */
|
|
8641
|
-
|
|
8642
|
-
this.
|
|
9304
|
+
clearComments() {
|
|
9305
|
+
this.comments.clear();
|
|
8643
9306
|
}
|
|
8644
9307
|
/** 同时最多有一次用户请求。 */
|
|
8645
9308
|
begin() {
|
|
@@ -8669,9 +9332,10 @@ var CanvasValidationPanel = class {
|
|
|
8669
9332
|
this.inputValidation = void 0;
|
|
8670
9333
|
this.inputFocus = void 0;
|
|
8671
9334
|
this.focusedDisplay = false;
|
|
9335
|
+
this.viewedSelection = void 0;
|
|
8672
9336
|
this.opened = false;
|
|
8673
9337
|
this.clear();
|
|
8674
|
-
this.
|
|
9338
|
+
this.comments.dispose();
|
|
8675
9339
|
this.options = void 0;
|
|
8676
9340
|
this.handle = void 0;
|
|
8677
9341
|
}
|
|
@@ -10260,58 +10924,6 @@ var FieldAttachmentsPanel = class {
|
|
|
10260
10924
|
this.options = void 0;
|
|
10261
10925
|
}
|
|
10262
10926
|
};
|
|
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
10927
|
// src/adapters/browser/input/design/settings/builders.ts
|
|
10316
10928
|
/** 用户明确新增设置时生成必需值,未展开的可选属性保持缺省。 */
|
|
10317
10929
|
function initialSettingValue(setting) {
|
|
@@ -10418,7 +11030,12 @@ var dependencies = listSetting("dependencies", "字段联动", objectSetting("",
|
|
|
10418
11030
|
], false),
|
|
10419
11031
|
textSetting("expression", "表达式"),
|
|
10420
11032
|
textSetting("expressionLabel", "表达式说明"),
|
|
10421
|
-
enumSetting("
|
|
11033
|
+
enumSetting("assignmentType", "赋值类型", ["formula", "clear"]),
|
|
11034
|
+
enumSetting("strategy", "赋值覆盖策略", [
|
|
11035
|
+
"alwaysCover",
|
|
11036
|
+
"notCovered",
|
|
11037
|
+
"notCoveredForever"
|
|
11038
|
+
]),
|
|
10422
11039
|
booleanSetting("value", "固定真假值")
|
|
10423
11040
|
], false));
|
|
10424
11041
|
/** 范围端点显式切换 none/fixed/expression,避免同时留下互斥参数。 */
|
|
@@ -10770,8 +11387,11 @@ var StructuredSettingsPanel = class {
|
|
|
10770
11387
|
disabled: "禁用",
|
|
10771
11388
|
required: "必填",
|
|
10772
11389
|
assignment: "赋值",
|
|
11390
|
+
formula: "公式计算",
|
|
11391
|
+
clear: "清空",
|
|
10773
11392
|
alwaysCover: "始终覆盖",
|
|
10774
|
-
notCovered: "
|
|
11393
|
+
notCovered: "不覆盖已修改(本次编辑有效)",
|
|
11394
|
+
notCoveredForever: "不覆盖已修改(永久有效)",
|
|
10775
11395
|
ge: "大于或等于 ≥",
|
|
10776
11396
|
gt: "大于 >",
|
|
10777
11397
|
le: "小于或等于 ≤",
|
|
@@ -11149,10 +11769,8 @@ var CanvasFieldDesignPanel = class {
|
|
|
11149
11769
|
this.reload();
|
|
11150
11770
|
} catch (error) {
|
|
11151
11771
|
this.writing = false;
|
|
11152
|
-
if (this.status) this.status.textContent = wordPanelErrorText(error,
|
|
11153
|
-
|
|
11154
|
-
this.options?.onError?.(error);
|
|
11155
|
-
} catch {}
|
|
11772
|
+
if (this.status) this.status.textContent = wordPanelErrorText(error, "字段设置未完成,请重试");
|
|
11773
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
11156
11774
|
}
|
|
11157
11775
|
}
|
|
11158
11776
|
/** 移除订阅、全部事件和配置引用;旧侧栏节点不继续持有文档。 */
|
|
@@ -11581,10 +12199,8 @@ var CanvasFormatPanel = class {
|
|
|
11581
12199
|
}
|
|
11582
12200
|
/** 错误不回滚已提交事务,也不能使外部反馈产生未处理异常。 */
|
|
11583
12201
|
report(error) {
|
|
11584
|
-
if (this.status) this.status.textContent = wordPanelErrorText(error,
|
|
11585
|
-
|
|
11586
|
-
this.options?.onError?.(error);
|
|
11587
|
-
} catch {}
|
|
12202
|
+
if (this.status) this.status.textContent = wordPanelErrorText(error, "格式设置未完成,请重试");
|
|
12203
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
11588
12204
|
}
|
|
11589
12205
|
/** 解除订阅和所有事件,保留旧输入、按钮或解除函数都不能反向保留文档。 */
|
|
11590
12206
|
dispose() {
|
|
@@ -12133,13 +12749,6 @@ var CanvasFieldCatalogPanel = class {
|
|
|
12133
12749
|
const label = owner.createElement("span");
|
|
12134
12750
|
button.type = "button";
|
|
12135
12751
|
button.className = "gct-word-catalog-field";
|
|
12136
|
-
const subModel = field.definition.binding.source.subFieldKey;
|
|
12137
|
-
const scope = subModel ? "子表 " + subModel : "主表";
|
|
12138
|
-
button.title = [
|
|
12139
|
-
field.label,
|
|
12140
|
-
scope,
|
|
12141
|
-
field.description
|
|
12142
|
-
].filter(Boolean).join(" · ");
|
|
12143
12752
|
icon.className = "gct-word-catalog-field-icon iconfont " + catalogFieldIcon(field);
|
|
12144
12753
|
icon.setAttribute("aria-hidden", "true");
|
|
12145
12754
|
label.className = "gct-word-catalog-field-label";
|
|
@@ -12174,12 +12783,10 @@ var CanvasFieldCatalogPanel = class {
|
|
|
12174
12783
|
/** 目录失败不改变模板,也不把异常对象保存到面板状态。 */
|
|
12175
12784
|
report(error) {
|
|
12176
12785
|
if (this.status) {
|
|
12177
|
-
this.status.textContent = wordPanelErrorText(error,
|
|
12786
|
+
this.status.textContent = wordPanelErrorText(error, "字段目录加载失败,请重试");
|
|
12178
12787
|
this.status.hidden = !this.status.textContent;
|
|
12179
12788
|
}
|
|
12180
|
-
|
|
12181
|
-
this.options?.onError?.(error);
|
|
12182
|
-
} catch {}
|
|
12789
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
12183
12790
|
}
|
|
12184
12791
|
/** 解除目录/控制器订阅、等待、拖入来源、DOM 和外部回调。 */
|
|
12185
12792
|
dispose() {
|
|
@@ -12507,10 +13114,8 @@ var CanvasTableDesignPanel = class {
|
|
|
12507
13114
|
if (this.status) this.status.textContent = error.message;
|
|
12508
13115
|
return;
|
|
12509
13116
|
}
|
|
12510
|
-
if (this.status
|
|
12511
|
-
|
|
12512
|
-
this.options?.onError?.(error);
|
|
12513
|
-
} catch {}
|
|
13117
|
+
if (this.status) this.status.textContent = readWordErrorText(error) ?? "表格操作未完成,请重试";
|
|
13118
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
12514
13119
|
}
|
|
12515
13120
|
}
|
|
12516
13121
|
/** 关闭撤销旧按钮、旧控件和订阅,旧面板不继续持有文档。 */
|
|
@@ -12603,7 +13208,7 @@ function regionMetadataForm(options) {
|
|
|
12603
13208
|
name.disabled = useDefault.checked;
|
|
12604
13209
|
const path = text("区域数据路径", state?.binding?.pathTemplate ?? "");
|
|
12605
13210
|
path.placeholder = "例如 $.items 或 $.checks:samples";
|
|
12606
|
-
const parent = select("所属父区域"), target = select("
|
|
13211
|
+
const parent = select("所属父区域"), target = select("关联表格区域"), variant = select("业务类型");
|
|
12607
13212
|
/** 根据真实类型切换可用关系,不默认选中任意父区域或关联主体。 */
|
|
12608
13213
|
const updateType = () => {
|
|
12609
13214
|
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 +13245,7 @@ function regionMetadataForm(options) {
|
|
|
12640
13245
|
form.append(hint);
|
|
12641
13246
|
const apply = owner.createElement("button");
|
|
12642
13247
|
apply.type = "button";
|
|
12643
|
-
apply.textContent = state ? "应用区域类型与来源" : "
|
|
13248
|
+
apply.textContent = state ? "应用区域类型与来源" : "创建表格区域";
|
|
12644
13249
|
apply.addEventListener("click", () => {
|
|
12645
13250
|
const typeValue = type.value, definition = designRegionTypes.find((item) => item.type === typeValue);
|
|
12646
13251
|
options.apply({
|
|
@@ -12819,7 +13424,7 @@ var CanvasRegionDesignPanel = class {
|
|
|
12819
13424
|
constructor(options) {
|
|
12820
13425
|
this.options = options;
|
|
12821
13426
|
this.root = options.host.ownerDocument.createElement("section");
|
|
12822
|
-
this.root.setAttribute("aria-label", "
|
|
13427
|
+
this.root.setAttribute("aria-label", "表格区域设计");
|
|
12823
13428
|
options.host.append(this.root);
|
|
12824
13429
|
try {
|
|
12825
13430
|
this.unsubscribe = options.controller.subscribe(() => this.refresh());
|
|
@@ -12848,7 +13453,7 @@ var CanvasRegionDesignPanel = class {
|
|
|
12848
13453
|
if (this.dirty) {
|
|
12849
13454
|
this.stale = true;
|
|
12850
13455
|
if (this.form) this.form.disabled = true;
|
|
12851
|
-
if (this.status) this.status.textContent = "
|
|
13456
|
+
if (this.status) this.status.textContent = "表格、区域或选区已变化,草稿已保留;请重新加载表格区域。";
|
|
12852
13457
|
return;
|
|
12853
13458
|
}
|
|
12854
13459
|
if (table && this.table && isEqual(items, this.items) && isEqual({
|
|
@@ -12878,7 +13483,7 @@ var CanvasRegionDesignPanel = class {
|
|
|
12878
13483
|
}
|
|
12879
13484
|
/** 工具栏打开新建表单时保护已编辑的草稿,不直接创建模型节点。 */
|
|
12880
13485
|
startCreation(preset) {
|
|
12881
|
-
if (this.dirty) throw Error("
|
|
13486
|
+
if (this.dirty) throw Error("请先应用或放弃当前表格区域草稿。");
|
|
12882
13487
|
if (!this.options?.controller.design.tables.readCurrent()?.editable) throw Error("请先选择可编辑的表格单元格。");
|
|
12883
13488
|
this.regionId = void 0;
|
|
12884
13489
|
this.preset = preset;
|
|
@@ -12922,21 +13527,21 @@ var CanvasRegionDesignPanel = class {
|
|
|
12922
13527
|
const root = this.root, table = this.table, options = this.options, owner = root.ownerDocument;
|
|
12923
13528
|
options.onRegionChange?.();
|
|
12924
13529
|
if (!table) {
|
|
12925
|
-
root.textContent = "
|
|
13530
|
+
root.textContent = "先点击表格或选择物理格范围,再创建和配置表格区域。";
|
|
12926
13531
|
return;
|
|
12927
13532
|
}
|
|
12928
13533
|
const heading = owner.createElement("h3"), status = owner.createElement("p"), form = owner.createElement("fieldset");
|
|
12929
|
-
heading.textContent = "
|
|
13534
|
+
heading.textContent = this.state ? designRegionLabel(this.state) : "表格区域";
|
|
12930
13535
|
status.setAttribute("role", "status");
|
|
12931
13536
|
status.textContent = `当前第 ${table.rectangle.top + 1}–${table.rectangle.bottom + 1} 行,第 ${table.rectangle.left + 1}–${table.rectangle.right + 1} 列。`;
|
|
12932
13537
|
this.status = status;
|
|
12933
|
-
root.append(heading, status, this.button("
|
|
12934
|
-
form.setAttribute("aria-label", "
|
|
13538
|
+
root.append(heading, status, this.button("重新加载表格区域", () => this.reload(), void 0, true), form);
|
|
13539
|
+
form.setAttribute("aria-label", "表格区域配置");
|
|
12935
13540
|
form.disabled = !table.editable;
|
|
12936
13541
|
form.style.cssText = "border:0;padding:0;display:grid;gap:10px;min-width:0";
|
|
12937
13542
|
this.form = form;
|
|
12938
13543
|
const regions = options.controller.design.tables.regions, items = this.items, chooser = owner.createElement("select");
|
|
12939
|
-
chooser.setAttribute("aria-label", "
|
|
13544
|
+
chooser.setAttribute("aria-label", "当前表格区域");
|
|
12940
13545
|
this.chooser = chooser;
|
|
12941
13546
|
for (const [value, label] of [["", "新建区域"], ...items.map((item) => [item.regionId, regionItemLabel(item)])]) {
|
|
12942
13547
|
const option = owner.createElement("option");
|
|
@@ -13089,10 +13694,8 @@ var CanvasRegionDesignPanel = class {
|
|
|
13089
13694
|
this.reload();
|
|
13090
13695
|
} catch (error) {
|
|
13091
13696
|
this.writing = false;
|
|
13092
|
-
if (this.status) this.status.textContent = wordPanelErrorText(error,
|
|
13093
|
-
|
|
13094
|
-
this.options?.onError?.(error);
|
|
13095
|
-
} catch {}
|
|
13697
|
+
if (this.status) this.status.textContent = wordPanelErrorText(error, "表格区域设置未完成,请重试");
|
|
13698
|
+
reportUnhandledWordError(error, hasLocalWordFeedback(this.status), this.options?.onError);
|
|
13096
13699
|
}
|
|
13097
13700
|
}
|
|
13098
13701
|
/** 关闭释放订阅、结构草稿及旧 DOM;保留面板/API 不继续拥有文档。 */
|
|
@@ -13425,10 +14028,8 @@ var CanvasMaterialsPanel = class {
|
|
|
13425
14028
|
}
|
|
13426
14029
|
/** 只保留错误文字,反馈异常不能阻止资源释放。 */
|
|
13427
14030
|
report(error) {
|
|
13428
|
-
this.message = error
|
|
13429
|
-
|
|
13430
|
-
this.options?.onError?.(error);
|
|
13431
|
-
} catch {}
|
|
14031
|
+
this.message = wordPanelErrorText(error, "操作未完成,请重试");
|
|
14032
|
+
reportUnhandledWordError(error, !!this.state && hasLocalWordFeedback(this.root), this.options?.onError);
|
|
13432
14033
|
if (!this.task) this.render();
|
|
13433
14034
|
}
|
|
13434
14035
|
};
|
|
@@ -13450,8 +14051,8 @@ function attachCanvasMaterialsPanel(context, options) {
|
|
|
13450
14051
|
}
|
|
13451
14052
|
// src/adapters/browser/input/business/tables/table-action-anchors.ts
|
|
13452
14053
|
/** 动态表取每个业务组末格,固定表只取区域首行右上格。 */
|
|
13453
|
-
function tableActionAnchors(
|
|
13454
|
-
return regionActionAnchors(
|
|
14054
|
+
function tableActionAnchors(pages, layout, controller) {
|
|
14055
|
+
return regionActionAnchors(pages, layout, controller.businessTables.list(), (regionId, instanceKey, bounded) => {
|
|
13455
14056
|
let source = controller.businessTables.read(regionId, instanceKey);
|
|
13456
14057
|
if (!source && instanceKey) {
|
|
13457
14058
|
const empty = controller.businessTables.read(regionId);
|
|
@@ -13465,21 +14066,14 @@ function tableActionAnchors(host, layout, controller) {
|
|
|
13465
14066
|
});
|
|
13466
14067
|
}
|
|
13467
14068
|
/** 各领域只提供行准入,几何与真实行身份共用一次投影。 */
|
|
13468
|
-
function regionActionAnchors(
|
|
14069
|
+
function regionActionAnchors(pages, layout, regions, read) {
|
|
13469
14070
|
const snapshot = layout.getCurrentSnapshot();
|
|
13470
14071
|
if (!snapshot) return [];
|
|
13471
14072
|
if (!regions.length) return [];
|
|
13472
14073
|
const targets = [];
|
|
13473
|
-
const
|
|
13474
|
-
|
|
13475
|
-
const topLimit = viewport?.height ? Math.max(0, viewport.top) : 0;
|
|
13476
|
-
const bottomLimit = viewport?.height ? Math.min(view.innerHeight, viewport.bottom) : view.innerHeight;
|
|
13477
|
-
for (const canvas of host.querySelectorAll("canvas[data-page-id]")) {
|
|
13478
|
-
if (canvas.dataset.layoutRevision !== String(snapshot.result.version.layoutRevision)) continue;
|
|
13479
|
-
const page = snapshot.query.getPage(canvas.dataset.pageId ?? "");
|
|
14074
|
+
for (const surface of pages.values()) {
|
|
14075
|
+
const page = snapshot.query.getPage(surface.id);
|
|
13480
14076
|
if (!page) continue;
|
|
13481
|
-
const rect = canvas.getBoundingClientRect();
|
|
13482
|
-
if (!rect.width || !rect.height || rect.bottom < topLimit || rect.top > bottomLimit) continue;
|
|
13483
14077
|
const groups = /* @__PURE__ */ new Map();
|
|
13484
14078
|
function visit(blocks) {
|
|
13485
14079
|
for (const table of blocks) {
|
|
@@ -13513,9 +14107,8 @@ function regionActionAnchors(host, layout, regions, read) {
|
|
|
13513
14107
|
for (const [key, group] of groups) {
|
|
13514
14108
|
const source = read(group.regionId, group.instanceKey, group.bounded);
|
|
13515
14109
|
if (!source) continue;
|
|
13516
|
-
const left =
|
|
13517
|
-
const top =
|
|
13518
|
-
if (top + 32 > bottomLimit || top < topLimit || left + 24 > view.innerWidth || left < 0) continue;
|
|
14110
|
+
const left = surface.left + (group.frame.x + group.frame.width) * surface.width / (page.bodyTableOverflow?.right ?? page.width) + 4;
|
|
14111
|
+
const top = surface.top + (group.frame.y + group.frame.height / 2) * surface.height / page.height - 16;
|
|
13519
14112
|
targets.push({
|
|
13520
14113
|
pageId: page.id,
|
|
13521
14114
|
id: page.id + ":" + key,
|
|
@@ -13528,11 +14121,76 @@ function regionActionAnchors(host, layout, regions, read) {
|
|
|
13528
14121
|
}
|
|
13529
14122
|
return targets;
|
|
13530
14123
|
}
|
|
14124
|
+
// src/adapters/browser/input/business/tables/table-action-pages.ts
|
|
14125
|
+
/** @file 行按钮只借用已绘制纸张的局部尺寸;滚动不改变页内锚点或重新读取业务行。 */
|
|
14126
|
+
/** 只保存当前挂载表面的 DOM 和尺寸,不持有排版结果、模型或行数据。 */
|
|
14127
|
+
var TableActionPages = class {
|
|
14128
|
+
revision;
|
|
14129
|
+
pages = /* @__PURE__ */ new Map();
|
|
14130
|
+
/** 同一表面和局部尺寸不受屏幕坐标、滚动及纸张像素对齐偏移影响。 */
|
|
14131
|
+
update(host, layout) {
|
|
14132
|
+
const snapshot = layout.getCurrentSnapshot();
|
|
14133
|
+
const revision = snapshot?.result.version.layoutRevision;
|
|
14134
|
+
const next = /* @__PURE__ */ new Map();
|
|
14135
|
+
for (const canvas of host.querySelectorAll("canvas[data-page-id]")) {
|
|
14136
|
+
const id = canvas.dataset.pageId;
|
|
14137
|
+
if (!snapshot?.query.getPage(id) || canvas.dataset.layoutRevision !== String(revision)) continue;
|
|
14138
|
+
const parent = canvas.parentElement;
|
|
14139
|
+
if (!parent) continue;
|
|
14140
|
+
const width = Number.parseFloat(canvas.style.width) || canvas.clientWidth || canvas.getBoundingClientRect().width;
|
|
14141
|
+
const height = Number.parseFloat(canvas.style.height) || canvas.clientHeight || canvas.getBoundingClientRect().height;
|
|
14142
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) continue;
|
|
14143
|
+
next.set(id, {
|
|
14144
|
+
id,
|
|
14145
|
+
canvas,
|
|
14146
|
+
host: parent,
|
|
14147
|
+
width,
|
|
14148
|
+
height,
|
|
14149
|
+
left: canvas.offsetLeft,
|
|
14150
|
+
top: canvas.offsetTop
|
|
14151
|
+
});
|
|
14152
|
+
}
|
|
14153
|
+
const changed = revision !== this.revision || next.size !== this.pages.size || [...next].some(([id, page]) => {
|
|
14154
|
+
const previous = this.pages.get(id);
|
|
14155
|
+
return !previous || previous.canvas !== page.canvas || previous.host !== page.host || previous.width !== page.width || previous.height !== page.height || previous.left !== page.left || previous.top !== page.top;
|
|
14156
|
+
});
|
|
14157
|
+
this.revision = revision;
|
|
14158
|
+
if (changed) this.pages = next;
|
|
14159
|
+
return changed;
|
|
14160
|
+
}
|
|
14161
|
+
values() {
|
|
14162
|
+
return this.pages.values();
|
|
14163
|
+
}
|
|
14164
|
+
host(pageId) {
|
|
14165
|
+
return this.pages.get(pageId)?.host;
|
|
14166
|
+
}
|
|
14167
|
+
/** 排版已经发布但原画面仍在时,沿用现有菜单直到同一画面完成绘制。 */
|
|
14168
|
+
awaitingPaint(pageId, layout) {
|
|
14169
|
+
const page = this.pages.get(pageId);
|
|
14170
|
+
return !!page?.canvas.isConnected && page.canvas.dataset.layoutRevision !== String(layout.getCurrentSnapshot()?.result.version.layoutRevision);
|
|
14171
|
+
}
|
|
14172
|
+
/** 仅打开的菜单复核可见性;普通滚动不遍历行、不更新 Vue 状态。 */
|
|
14173
|
+
visible(anchor) {
|
|
14174
|
+
const page = this.pages.get(anchor.pageId);
|
|
14175
|
+
if (!page || !page.canvas.isConnected) return false;
|
|
14176
|
+
const rect = page.canvas.getBoundingClientRect();
|
|
14177
|
+
const clip = viewportClip(page.canvas);
|
|
14178
|
+
const scaleX = rect.width / page.width, scaleY = rect.height / page.height;
|
|
14179
|
+
const left = rect.left + (anchor.left - page.left) * scaleX;
|
|
14180
|
+
const top = rect.top + (anchor.top - page.top) * scaleY;
|
|
14181
|
+
return left >= clip.left && top >= clip.top && left + 24 * scaleX <= clip.left + clip.width && top + 32 * scaleY <= clip.top + clip.height;
|
|
14182
|
+
}
|
|
14183
|
+
dispose() {
|
|
14184
|
+
this.pages.clear();
|
|
14185
|
+
this.revision = void 0;
|
|
14186
|
+
}
|
|
14187
|
+
};
|
|
13531
14188
|
// src/adapters/browser/input/business/tables/CanvasBusinessTableActions.ts
|
|
13532
14189
|
/** @file 填报行旁菜单,复用原生行命令与版本门禁;菜单打开不改变字段选择。 */
|
|
13533
14190
|
var CanvasBusinessTableActions = class {
|
|
13534
14191
|
options;
|
|
13535
14192
|
view;
|
|
14193
|
+
pages = new TableActionPages();
|
|
13536
14194
|
quick;
|
|
13537
14195
|
scan;
|
|
13538
14196
|
targets = [];
|
|
@@ -13550,6 +14208,7 @@ var CanvasBusinessTableActions = class {
|
|
|
13550
14208
|
this.scan = new CanvasTableScanDialog(options);
|
|
13551
14209
|
this.view = options.renderActions({
|
|
13552
14210
|
container: options.host,
|
|
14211
|
+
pageHost: (id) => this.pages.host(id),
|
|
13553
14212
|
state: {
|
|
13554
14213
|
anchors: [],
|
|
13555
14214
|
busy: false
|
|
@@ -13564,12 +14223,12 @@ var CanvasBusinessTableActions = class {
|
|
|
13564
14223
|
});
|
|
13565
14224
|
this.unsubscribe = options.controller.subscribe(() => this.refresh());
|
|
13566
14225
|
const owner = options.host.ownerDocument, signal = this.lifetime.signal;
|
|
13567
|
-
owner.addEventListener("scroll", () => this.
|
|
14226
|
+
owner.addEventListener("scroll", () => this.refreshGeometry(), {
|
|
13568
14227
|
capture: true,
|
|
13569
14228
|
passive: true,
|
|
13570
14229
|
signal
|
|
13571
14230
|
});
|
|
13572
|
-
owner.defaultView?.addEventListener("resize", () => this.
|
|
14231
|
+
owner.defaultView?.addEventListener("resize", () => this.refreshGeometry(), { signal });
|
|
13573
14232
|
this.refresh();
|
|
13574
14233
|
}
|
|
13575
14234
|
refresh() {
|
|
@@ -13587,7 +14246,8 @@ var CanvasBusinessTableActions = class {
|
|
|
13587
14246
|
if (!snapshot) return;
|
|
13588
14247
|
const selectedCanvas = this.selected && [...options.canvasHost.querySelectorAll("canvas[data-page-id]")].find((canvas) => canvas.dataset.pageId === this.selected.pageId);
|
|
13589
14248
|
if (selectedCanvas && selectedCanvas.dataset.layoutRevision !== String(snapshot.result.version.layoutRevision)) return;
|
|
13590
|
-
this.
|
|
14249
|
+
this.pages.update(options.canvasHost, options.layout);
|
|
14250
|
+
this.targets = tableActionAnchors(this.pages, options.layout, options.controller);
|
|
13591
14251
|
if (this.confirming && !isEqual(options.controller.businessTables.read(this.confirming.regionId, this.confirming.anchorInstanceKey), this.confirming)) this.cancelConfirmation();
|
|
13592
14252
|
if (this.selected) {
|
|
13593
14253
|
const next = this.targets.find((item) => item.id === this.selected.id);
|
|
@@ -13600,6 +14260,18 @@ var CanvasBusinessTableActions = class {
|
|
|
13600
14260
|
}
|
|
13601
14261
|
this.render();
|
|
13602
14262
|
}
|
|
14263
|
+
/** 已挂载纸张只随原生滚动移动;表面或尺寸变化才重新投影行按钮。 */
|
|
14264
|
+
refreshGeometry() {
|
|
14265
|
+
const options = this.options;
|
|
14266
|
+
if (!options || this.writing) return;
|
|
14267
|
+
if (this.selected && this.pages.awaitingPaint(this.selected.pageId, options.layout)) return;
|
|
14268
|
+
if (this.pages.update(options.canvasHost, options.layout)) this.refresh();
|
|
14269
|
+
else if (this.selected && !this.pages.visible(this.selected)) {
|
|
14270
|
+
this.task?.abort();
|
|
14271
|
+
this.selected = void 0;
|
|
14272
|
+
this.render();
|
|
14273
|
+
}
|
|
14274
|
+
}
|
|
13603
14275
|
canSubmit() {
|
|
13604
14276
|
return !this.confirmation && (this.quick?.canSubmit() ?? true) && (this.scan?.canSubmit() ?? true);
|
|
13605
14277
|
}
|
|
@@ -13611,6 +14283,7 @@ var CanvasBusinessTableActions = class {
|
|
|
13611
14283
|
this.quick?.dispose();
|
|
13612
14284
|
this.scan?.dispose();
|
|
13613
14285
|
this.view?.dispose();
|
|
14286
|
+
this.pages.dispose();
|
|
13614
14287
|
this.options = void 0;
|
|
13615
14288
|
this.view = void 0;
|
|
13616
14289
|
this.quick = void 0;
|
|
@@ -13633,9 +14306,11 @@ var CanvasBusinessTableActions = class {
|
|
|
13633
14306
|
await options.controller.businessTables.whenSettled(task.signal);
|
|
13634
14307
|
await waitForAbortable(new Promise((resolve) => options.host.ownerDocument.defaultView.requestAnimationFrame(() => resolve())), task.signal, () => Error("业务表操作已取消"));
|
|
13635
14308
|
if (task.signal.aborted || this.options !== options) return;
|
|
13636
|
-
this.
|
|
14309
|
+
this.pages.update(options.canvasHost, options.layout);
|
|
14310
|
+
this.targets = tableActionAnchors(this.pages, options.layout, options.controller);
|
|
13637
14311
|
this.selected = this.targets.find((item) => item.id === id);
|
|
13638
14312
|
if (!this.selected && target.source.rowCount === 0) this.selected = this.targets.find((item) => item.source.regionId === target.source.regionId && item.source.rowCount === 1 && item.source.rowOrdinal === 0);
|
|
14313
|
+
if (this.selected && !this.pages.visible(this.selected)) this.selected = void 0;
|
|
13639
14314
|
} catch (error) {
|
|
13640
14315
|
if (!task.signal.aborted && this.options === options) options.onError?.(error);
|
|
13641
14316
|
} finally {
|
|
@@ -13655,8 +14330,9 @@ var CanvasBusinessTableActions = class {
|
|
|
13655
14330
|
const quick = source && options.controller.businessTables.readQuickFill(source.regionId, source.anchorInstanceKey);
|
|
13656
14331
|
const scan = source && options.controller.businessTables.readScan(source.regionId, source.anchorInstanceKey);
|
|
13657
14332
|
this.view?.update({
|
|
13658
|
-
anchors: this.targets.map(({ id, label, left, top }) => ({
|
|
14333
|
+
anchors: this.targets.map(({ id, pageId, label, left, top }) => ({
|
|
13659
14334
|
id,
|
|
14335
|
+
pageId,
|
|
13660
14336
|
label,
|
|
13661
14337
|
left,
|
|
13662
14338
|
top
|
|
@@ -13698,7 +14374,7 @@ var CanvasBusinessTableActions = class {
|
|
|
13698
14374
|
this.render();
|
|
13699
14375
|
try {
|
|
13700
14376
|
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("业务表操作已取消")))
|
|
14377
|
+
if (options.beforeAction && !await waitForAbortable(Promise.resolve(options.beforeAction(task.signal)), task.signal, () => Error("业务表操作已取消"))) return;
|
|
13702
14378
|
if (task.signal.aborted || this.options !== options) return;
|
|
13703
14379
|
const api = options.controller.businessTables, current = api.read(expected.regionId, expected.anchorInstanceKey);
|
|
13704
14380
|
if (!current || !sameRowData(current, expected)) throw Error("业务行或当前输入已变化,请重新操作");
|
|
@@ -13741,10 +14417,8 @@ var CanvasBusinessTableActions = class {
|
|
|
13741
14417
|
options.onApplied?.(result);
|
|
13742
14418
|
} catch (error) {
|
|
13743
14419
|
if (!task.signal.aborted && this.options === options) {
|
|
13744
|
-
this.message = error
|
|
13745
|
-
|
|
13746
|
-
options.onError?.(error);
|
|
13747
|
-
} catch {}
|
|
14420
|
+
this.message = wordPanelErrorText(error, "业务表操作未完成,请重试");
|
|
14421
|
+
reportUnhandledWordError(error, !!this.selected && !!this.view, options.onError);
|
|
13748
14422
|
}
|
|
13749
14423
|
} finally {
|
|
13750
14424
|
this.writing = false;
|
|
@@ -13767,6 +14441,7 @@ function sameRowData(a, b) {
|
|
|
13767
14441
|
var CanvasMaterialTableActions = class {
|
|
13768
14442
|
options;
|
|
13769
14443
|
view;
|
|
14444
|
+
pages = new TableActionPages();
|
|
13770
14445
|
targets = [];
|
|
13771
14446
|
selected;
|
|
13772
14447
|
task;
|
|
@@ -13782,6 +14457,7 @@ var CanvasMaterialTableActions = class {
|
|
|
13782
14457
|
this.options = options;
|
|
13783
14458
|
this.view = options.renderActions({
|
|
13784
14459
|
container: options.host,
|
|
14460
|
+
pageHost: (id) => this.pages.host(id),
|
|
13785
14461
|
state: {
|
|
13786
14462
|
anchors: [],
|
|
13787
14463
|
busy: false
|
|
@@ -13795,12 +14471,12 @@ var CanvasMaterialTableActions = class {
|
|
|
13795
14471
|
}
|
|
13796
14472
|
});
|
|
13797
14473
|
this.unsubscribe = options.controller.subscribe(() => this.refresh());
|
|
13798
|
-
options.host.ownerDocument.addEventListener("scroll", () => this.
|
|
14474
|
+
options.host.ownerDocument.addEventListener("scroll", () => this.refreshGeometry(), {
|
|
13799
14475
|
capture: true,
|
|
13800
14476
|
passive: true,
|
|
13801
14477
|
signal: this.lifetime.signal
|
|
13802
14478
|
});
|
|
13803
|
-
options.host.ownerDocument.defaultView?.addEventListener("resize", () => this.
|
|
14479
|
+
options.host.ownerDocument.defaultView?.addEventListener("resize", () => this.refreshGeometry(), { signal: this.lifetime.signal });
|
|
13804
14480
|
this.refresh();
|
|
13805
14481
|
}
|
|
13806
14482
|
canSubmit() {
|
|
@@ -13832,12 +14508,25 @@ var CanvasMaterialTableActions = class {
|
|
|
13832
14508
|
}
|
|
13833
14509
|
this.render();
|
|
13834
14510
|
}
|
|
14511
|
+
/** 滚动复用页内位置,不重新读取物耗行或发布相同的 Vue 状态。 */
|
|
14512
|
+
refreshGeometry() {
|
|
14513
|
+
const options = this.options;
|
|
14514
|
+
if (!options || this.writing) return;
|
|
14515
|
+
if (this.selected && this.pages.awaitingPaint(this.selected.pageId, options.layout)) return;
|
|
14516
|
+
if (this.pages.update(options.canvasHost, options.layout)) this.refresh();
|
|
14517
|
+
else if (this.selected && !this.pages.visible(this.selected)) {
|
|
14518
|
+
this.task?.abort();
|
|
14519
|
+
this.selected = void 0;
|
|
14520
|
+
this.render();
|
|
14521
|
+
}
|
|
14522
|
+
}
|
|
13835
14523
|
dispose() {
|
|
13836
14524
|
this.lifetime.abort();
|
|
13837
14525
|
this.task?.abort();
|
|
13838
14526
|
this.unsubscribe?.();
|
|
13839
14527
|
this.closeDialog();
|
|
13840
14528
|
this.view?.dispose();
|
|
14529
|
+
this.pages.dispose();
|
|
13841
14530
|
this.options = void 0;
|
|
13842
14531
|
this.view = void 0;
|
|
13843
14532
|
this.selected = void 0;
|
|
@@ -13846,7 +14535,8 @@ var CanvasMaterialTableActions = class {
|
|
|
13846
14535
|
}
|
|
13847
14536
|
readTargets() {
|
|
13848
14537
|
const options = this.options;
|
|
13849
|
-
|
|
14538
|
+
this.pages.update(options.canvasHost, options.layout);
|
|
14539
|
+
return regionActionAnchors(this.pages, options.layout, options.controller.materials.list(), (id, anchor) => {
|
|
13850
14540
|
const source = options.controller.materials.read(id, anchor);
|
|
13851
14541
|
return source?.editable && Object.values(source.allowed).some(Boolean) ? source : void 0;
|
|
13852
14542
|
});
|
|
@@ -13870,6 +14560,7 @@ var CanvasMaterialTableActions = class {
|
|
|
13870
14560
|
if (!await this.settle(task)) return;
|
|
13871
14561
|
this.targets = this.readTargets();
|
|
13872
14562
|
this.selected = this.targets.find((item) => item.id === id) ?? (target.source.rowCount === 0 ? this.targets.find((item) => item.source.regionId === target.source.regionId && item.source.rowCount === 1) : void 0);
|
|
14563
|
+
if (this.selected && !this.pages.visible(this.selected)) this.selected = void 0;
|
|
13873
14564
|
} catch (error) {
|
|
13874
14565
|
if (!task.signal.aborted && this.options === options) this.report(error);
|
|
13875
14566
|
} finally {
|
|
@@ -13886,8 +14577,9 @@ var CanvasMaterialTableActions = class {
|
|
|
13886
14577
|
render() {
|
|
13887
14578
|
const source = this.selected?.source;
|
|
13888
14579
|
this.view?.update({
|
|
13889
|
-
anchors: this.targets.map(({ id, label, left, top }) => ({
|
|
14580
|
+
anchors: this.targets.map(({ id, pageId, label, left, top }) => ({
|
|
13890
14581
|
id,
|
|
14582
|
+
pageId,
|
|
13891
14583
|
label,
|
|
13892
14584
|
left,
|
|
13893
14585
|
top
|
|
@@ -14024,16 +14716,14 @@ var CanvasMaterialTableActions = class {
|
|
|
14024
14716
|
this.render();
|
|
14025
14717
|
}
|
|
14026
14718
|
report(error) {
|
|
14027
|
-
this.message = error
|
|
14719
|
+
this.message = wordPanelErrorText(error, "操作未完成,请重试");
|
|
14028
14720
|
this.success = false;
|
|
14029
|
-
|
|
14030
|
-
this.options?.onError?.(error);
|
|
14031
|
-
} catch {}
|
|
14721
|
+
reportUnhandledWordError(error, !!this.selected && !!this.view, this.options?.onError);
|
|
14032
14722
|
}
|
|
14033
14723
|
};
|
|
14034
14724
|
function sameRow(current, previous) {
|
|
14035
14725
|
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
14726
|
}
|
|
14037
|
-
export {
|
|
14727
|
+
export { readWordErrorText as A, inputScreenRect as B, CanvasBusinessTablePanel as C, FieldInputBlockedError as D, CanvasTextInput as E, openImageViewer as F, loadBrowserImage as G, viewportClip as H, clipInputRect as I, NativeFontResources as J, CanvasImageResources as K, inputPageLocation as L, revealInputRect as M, ResourceFileSizes as N, isWordCancellation as O, resourceFileIcon as P, applyCanvasTextStyle as Q, inputPointerRequest as R, attachCanvasBusinessTablePanel as S, CanvasQuickFillDialog as T, paintPage as U, CanvasPages as V, paintSignatureGraphic as W, browserAbortable as X, NativeFontError as Y, CanvasTextMeasurer 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, wordPanelErrorText as j, isWordValidationError as k, CanvasTableDesignPanel as l, CanvasFieldDesignPanel as m, CanvasBusinessTableActions as n, attachCanvasRegionDesignPanel as o, CanvasFormatPanel as p, layoutImages 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, inputScreenPages as z };
|
|
14038
14728
|
|
|
14039
|
-
//# sourceMappingURL=browser-
|
|
14729
|
+
//# sourceMappingURL=browser-DkEIriBA.js.map
|