@gct-paas/word 1.0.3-beta.0 → 1.0.3-beta.2
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 +8 -3
- package/dist/browser.js +1 -1
- package/dist/chunks/QuickFillPanel-BNZwXlnL.js +336 -0
- package/dist/chunks/QuickFillPanel-BNZwXlnL.js.map +1 -0
- package/dist/chunks/{browser-OAJIVM8O.js → browser-DkEIriBA.js} +1124 -661
- package/dist/chunks/browser-DkEIriBA.js.map +1 -0
- package/dist/chunks/{sdk-BmwE5mZn.js → sdk-DaWE1Ttf.js} +242 -63
- package/dist/chunks/sdk-DaWE1Ttf.js.map +1 -0
- package/dist/chunks/{types-CMkQ6Lvg.js → types-CzOaf1gP.js} +67 -149
- package/dist/chunks/types-CzOaf1gP.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/style.css +348 -241
- 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/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/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 +11 -7
- 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 +4 -0
- 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/reference-policies.d.ts +3 -1
- package/dist/types/adapters/platform/template-reference-migration.d.ts +6 -0
- package/dist/types/adapters/platform/templates.d.ts +2 -0
- package/dist/types/adapters/vue/QuickFillPanel.vue.d.ts +12 -0
- package/dist/types/adapters/vue/SignatureFieldPanel.vue.d.ts +0 -1
- package/dist/types/adapters/vue/SignatureVisual.vue.d.ts +2 -0
- package/dist/types/adapters/vue/index.d.ts +1 -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/layout/engine/atoms/field-control.d.ts +2 -0
- package/dist/types/layout/engine/atoms/fit-atomic.d.ts +1 -1
- package/dist/types/runtime/form/fields/core/declaration-changes.d.ts +2 -2
- package/dist/types/runtime/form/validation/NativeFieldValidation.d.ts +2 -0
- package/dist/types/runtime/form/validation/description.d.ts +8 -4
- package/dist/types/runtime/interaction/EditorController.d.ts +3 -1
- package/dist/types/runtime/interaction/browse/types.d.ts +1 -6
- package/dist/types/runtime/interaction/design/tables/regions/EditorTableRegions.d.ts +3 -1
- 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/shared/text/word-navigation.d.ts +1 -0
- package/dist/types/shared/word-shortcuts.d.ts +28 -0
- package/dist/vue.js +858 -571
- package/dist/vue.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunks/browser-OAJIVM8O.js.map +0 -1
- package/dist/chunks/sdk-BmwE5mZn.js.map +0 -1
- package/dist/chunks/types-CMkQ6Lvg.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,4 +1,4 @@
|
|
|
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
4
|
import { c as DocumentValidationError, t as NodeFactory } from "./NodeFactory-DzFnWaWf.js";
|
|
@@ -2120,6 +2120,46 @@ function choicePanelRect(anchor, viewport) {
|
|
|
2120
2120
|
height
|
|
2121
2121
|
};
|
|
2122
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
|
+
};
|
|
2123
2163
|
// src/adapters/browser/input/overlay-layer.ts
|
|
2124
2164
|
/** @file 原生输入使用视口坐标挂在 body,层级跟随当前画布的抽屉或弹框。 */
|
|
2125
2165
|
/** 保留输入、选区、下拉及错误提示之间的相对顺序,不改动宿主层级或定位。 */
|
|
@@ -2146,6 +2186,11 @@ var FieldPopover = class {
|
|
|
2146
2186
|
paused = false;
|
|
2147
2187
|
observer;
|
|
2148
2188
|
mutationObserver;
|
|
2189
|
+
geometry;
|
|
2190
|
+
measureDirty = true;
|
|
2191
|
+
measuredViewportWidth;
|
|
2192
|
+
contentHeight = 0;
|
|
2193
|
+
layoutRevision;
|
|
2149
2194
|
/** 同一次打开只扩不缩;仅持有展示宽度,不缓存候选数据。 */
|
|
2150
2195
|
contentWidth = 0;
|
|
2151
2196
|
size;
|
|
@@ -2203,15 +2248,10 @@ var FieldPopover = class {
|
|
|
2203
2248
|
}
|
|
2204
2249
|
}
|
|
2205
2250
|
}, { signal });
|
|
2206
|
-
|
|
2207
|
-
capture: true,
|
|
2208
|
-
passive: true,
|
|
2209
|
-
signal
|
|
2210
|
-
});
|
|
2211
|
-
owner.defaultView?.addEventListener("resize", () => this.refresh(), { signal });
|
|
2251
|
+
this.geometry = new FieldPanelGeometry(options.host, () => this.refresh());
|
|
2212
2252
|
const Observer = owner.defaultView?.ResizeObserver;
|
|
2213
2253
|
if (Observer) {
|
|
2214
|
-
this.observer = new Observer(() => this.
|
|
2254
|
+
this.observer = new Observer(() => this.contentChanged());
|
|
2215
2255
|
this.observer.observe(this.content);
|
|
2216
2256
|
}
|
|
2217
2257
|
this.observeContentWidth();
|
|
@@ -2226,7 +2266,7 @@ var FieldPopover = class {
|
|
|
2226
2266
|
const Mutations = this.content.ownerDocument.defaultView?.MutationObserver;
|
|
2227
2267
|
if (Mutations) {
|
|
2228
2268
|
this.mutationObserver = new Mutations(() => {
|
|
2229
|
-
if (typeof this.size.width !== "number") this.
|
|
2269
|
+
if (typeof this.size.width !== "number") this.contentChanged();
|
|
2230
2270
|
});
|
|
2231
2271
|
this.mutationObserver.observe(this.content, {
|
|
2232
2272
|
childList: true,
|
|
@@ -2235,12 +2275,17 @@ var FieldPopover = class {
|
|
|
2235
2275
|
});
|
|
2236
2276
|
}
|
|
2237
2277
|
}
|
|
2278
|
+
contentChanged() {
|
|
2279
|
+
this.measureDirty = true;
|
|
2280
|
+
this.geometry?.schedule();
|
|
2281
|
+
}
|
|
2238
2282
|
resize(width) {
|
|
2239
2283
|
if (typeof width === "number") {
|
|
2240
2284
|
if (!Number.isFinite(width) || width <= 0) return;
|
|
2241
2285
|
} else if (!Number.isFinite(width.minWidth) || !Number.isFinite(width.maxWidth) || width.minWidth <= 0 || width.maxWidth < width.minWidth) return;
|
|
2242
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;
|
|
2243
2287
|
this.size.width = width;
|
|
2288
|
+
this.measureDirty = true;
|
|
2244
2289
|
this.observeContentWidth();
|
|
2245
2290
|
this.refresh();
|
|
2246
2291
|
}
|
|
@@ -2253,6 +2298,7 @@ var FieldPopover = class {
|
|
|
2253
2298
|
}
|
|
2254
2299
|
const minimum = Math.min(size.minWidth, viewportWidth);
|
|
2255
2300
|
const maximum = Math.min(size.maxWidth, viewportWidth);
|
|
2301
|
+
if (!this.measureDirty && this.measuredViewportWidth === viewportWidth) return Math.min(maximum, this.contentWidth);
|
|
2256
2302
|
Object.assign(root.style, {
|
|
2257
2303
|
width: "max-content",
|
|
2258
2304
|
minWidth: `${minimum}px`,
|
|
@@ -2263,9 +2309,15 @@ var FieldPopover = class {
|
|
|
2263
2309
|
return Math.min(maximum, this.contentWidth);
|
|
2264
2310
|
}
|
|
2265
2311
|
refresh(placement) {
|
|
2312
|
+
this.geometry?.cancel();
|
|
2266
2313
|
if (placement) this.placement = placement;
|
|
2267
2314
|
const root = this.root, options = this.options, selection = this.selection;
|
|
2268
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
|
+
}
|
|
2269
2321
|
root.style.zIndex = inputOverlayZIndex(options.host, 10);
|
|
2270
2322
|
const anchor = choiceAnchor(options, selection, this.placement);
|
|
2271
2323
|
if (anchor.kind !== "ready") {
|
|
@@ -2282,7 +2334,12 @@ var FieldPopover = class {
|
|
|
2282
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;
|
|
2283
2335
|
root.style.width = `${width}px`;
|
|
2284
2336
|
root.style.maxHeight = `${Math.max(80, viewport.height - 8)}px`;
|
|
2285
|
-
|
|
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));
|
|
2286
2343
|
root.style.setProperty("--gct-select-available-height", `${Math.max(80, down ? below : above)}px`);
|
|
2287
2344
|
Object.assign(root.style, {
|
|
2288
2345
|
left: `${Math.max(viewport.left + inset, Math.min(anchor.rect.left, viewport.left + viewport.width - inset - width))}px`,
|
|
@@ -2307,6 +2364,8 @@ var FieldPopover = class {
|
|
|
2307
2364
|
}
|
|
2308
2365
|
}
|
|
2309
2366
|
dispose() {
|
|
2367
|
+
this.geometry?.dispose();
|
|
2368
|
+
this.geometry = void 0;
|
|
2310
2369
|
this.observer?.disconnect();
|
|
2311
2370
|
this.observer = void 0;
|
|
2312
2371
|
this.mutationObserver?.disconnect();
|
|
@@ -2818,13 +2877,6 @@ var ResourceFieldInput = class {
|
|
|
2818
2877
|
drop.addEventListener("dragover", () => drop.classList.add("dragover"), { signal: this.lifetime.signal });
|
|
2819
2878
|
drop.addEventListener("dragleave", () => drop.classList.remove("dragover"), { signal: this.lifetime.signal });
|
|
2820
2879
|
drop.addEventListener("drop", () => drop.classList.remove("dragover"), { signal: this.lifetime.signal });
|
|
2821
|
-
const clear = this.button("清空", () => {
|
|
2822
|
-
this.clear();
|
|
2823
|
-
this.dirty = true;
|
|
2824
|
-
this.render();
|
|
2825
|
-
});
|
|
2826
|
-
clear.style.marginRight = "auto";
|
|
2827
|
-
if (options.kind === "file") actions.append(clear);
|
|
2828
2880
|
}
|
|
2829
2881
|
actions.append(this.button(options.editable ? "取消" : "关闭", () => this.options?.cancel()));
|
|
2830
2882
|
if (options.editable) {
|
|
@@ -2978,15 +3030,6 @@ var ResourceFieldInput = class {
|
|
|
2978
3030
|
meta.className = "gct-word-resource-meta";
|
|
2979
3031
|
meta.append(name, size);
|
|
2980
3032
|
row.append(icon, meta);
|
|
2981
|
-
if (url) {
|
|
2982
|
-
const download = owner.createElement("a");
|
|
2983
|
-
download.textContent = "下载";
|
|
2984
|
-
download.href = url;
|
|
2985
|
-
download.download = item.name;
|
|
2986
|
-
download.target = "_blank";
|
|
2987
|
-
download.rel = "noopener noreferrer";
|
|
2988
|
-
row.append(download);
|
|
2989
|
-
}
|
|
2990
3033
|
this.sizes.show(size, url, item.size);
|
|
2991
3034
|
}
|
|
2992
3035
|
if (item.status === "uploading" || item.status === "queued") {
|
|
@@ -3019,7 +3062,7 @@ var ResourceFieldInput = class {
|
|
|
3019
3062
|
}));
|
|
3020
3063
|
}
|
|
3021
3064
|
if (options.editable) {
|
|
3022
|
-
const remove = this.button(
|
|
3065
|
+
const remove = this.button("", () => {
|
|
3023
3066
|
item.controller?.abort();
|
|
3024
3067
|
this.releasePreview(item);
|
|
3025
3068
|
item.file = void 0;
|
|
@@ -3029,15 +3072,13 @@ var ResourceFieldInput = class {
|
|
|
3029
3072
|
this.render();
|
|
3030
3073
|
this.pump();
|
|
3031
3074
|
});
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
remove.setAttribute("aria-label", `移除 ${item.name}`);
|
|
3040
|
-
}
|
|
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);
|
|
3041
3082
|
row.append(remove);
|
|
3042
3083
|
}
|
|
3043
3084
|
this.list.append(row);
|
|
@@ -3088,27 +3129,15 @@ var ResourceFieldInput = class {
|
|
|
3088
3129
|
actions() {
|
|
3089
3130
|
const options = this.options;
|
|
3090
3131
|
if (!options) return [];
|
|
3091
|
-
return [
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
}] : [],
|
|
3101
|
-
{
|
|
3102
|
-
label: options.editable ? "取消" : "关闭",
|
|
3103
|
-
run: () => this.options?.cancel()
|
|
3104
|
-
},
|
|
3105
|
-
...options.editable ? [{
|
|
3106
|
-
label: options.kind === "image" ? "确认" : "确定",
|
|
3107
|
-
primary: true,
|
|
3108
|
-
disabled: this.items.some((item) => item.status !== "done"),
|
|
3109
|
-
run: () => this.apply()
|
|
3110
|
-
}] : []
|
|
3111
|
-
];
|
|
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
|
+
}] : []];
|
|
3112
3141
|
}
|
|
3113
3142
|
/** 正在上传或失败时不能提交半份列表;单纯打开再确定只关闭,不重写数据。 */
|
|
3114
3143
|
apply() {
|
|
@@ -3671,7 +3700,6 @@ var ResourceFieldPreview = class {
|
|
|
3671
3700
|
this.task = task;
|
|
3672
3701
|
this.hit = hit;
|
|
3673
3702
|
this.pinned = pinned;
|
|
3674
|
-
let ownedMeasurer;
|
|
3675
3703
|
try {
|
|
3676
3704
|
const preview = await this.options.controller.readonlyActions.preview(hit, task.signal);
|
|
3677
3705
|
if (!preview || task.signal.aborted || this.task !== task) {
|
|
@@ -3688,10 +3716,7 @@ var ResourceFieldPreview = class {
|
|
|
3688
3716
|
fieldId: hit.fieldId,
|
|
3689
3717
|
instanceKey: hit.instanceKey
|
|
3690
3718
|
}, preview.label, {
|
|
3691
|
-
width:
|
|
3692
|
-
minWidth: 1,
|
|
3693
|
-
maxWidth: 420
|
|
3694
|
-
} : 280,
|
|
3719
|
+
width: 280,
|
|
3695
3720
|
height: 280,
|
|
3696
3721
|
autoFocus: pinned
|
|
3697
3722
|
}, () => {
|
|
@@ -3705,45 +3730,11 @@ var ResourceFieldPreview = class {
|
|
|
3705
3730
|
this.popover = popover;
|
|
3706
3731
|
const root = popover.content, owner = root.ownerDocument;
|
|
3707
3732
|
root.className = "gct-word-media-preview-list";
|
|
3708
|
-
if (preview.kind
|
|
3709
|
-
const entries = preview.entries.map((entry) => {
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
url,
|
|
3714
|
-
size: void 0
|
|
3715
|
-
};
|
|
3716
|
-
const appearance = preview.signature ?? {};
|
|
3717
|
-
if (url) return {
|
|
3718
|
-
...entry,
|
|
3719
|
-
url,
|
|
3720
|
-
size: {
|
|
3721
|
-
width: appearance.vertical ? appearance.height ?? 68 : appearance.width ?? 120,
|
|
3722
|
-
height: appearance.vertical ? appearance.width ?? 120 : appearance.height ?? 68
|
|
3723
|
-
}
|
|
3724
|
-
};
|
|
3725
|
-
const measurer = this.options.textMeasurer ?? (ownedMeasurer ??= new CanvasTextMeasurer());
|
|
3726
|
-
const graphic = signatureGraphic(entry.name, entry.signatureDate ?? "", appearance, (text, fontSizePx, fontWeight) => measurer.measureWidth({
|
|
3727
|
-
text,
|
|
3728
|
-
direction: "ltr",
|
|
3729
|
-
style: {
|
|
3730
|
-
fontFamily: "Arial",
|
|
3731
|
-
fontSizePx,
|
|
3732
|
-
fontWeight,
|
|
3733
|
-
fontStyle: "normal",
|
|
3734
|
-
letterSpacingPx: 0,
|
|
3735
|
-
kerning: "normal"
|
|
3736
|
-
}
|
|
3737
|
-
}));
|
|
3738
|
-
return {
|
|
3739
|
-
...entry,
|
|
3740
|
-
url: signatureGraphicUrl(graphic),
|
|
3741
|
-
size: {
|
|
3742
|
-
width: graphic.width,
|
|
3743
|
-
height: graphic.height
|
|
3744
|
-
}
|
|
3745
|
-
};
|
|
3746
|
-
});
|
|
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
|
+
}));
|
|
3747
3738
|
const imageEntries = entries.filter((entry) => entry.url);
|
|
3748
3739
|
const images = imageEntries.map((entry) => ({
|
|
3749
3740
|
name: entry.name,
|
|
@@ -3779,10 +3770,6 @@ var ResourceFieldPreview = class {
|
|
|
3779
3770
|
const image = owner.createElement("img");
|
|
3780
3771
|
image.src = url;
|
|
3781
3772
|
image.alt = entry.name;
|
|
3782
|
-
if (entry.size) {
|
|
3783
|
-
image.style.width = `${entry.size.width}px`;
|
|
3784
|
-
image.style.height = `${entry.size.height}px`;
|
|
3785
|
-
}
|
|
3786
3773
|
button.append(image);
|
|
3787
3774
|
button.addEventListener("click", () => {
|
|
3788
3775
|
this.pinned = true;
|
|
@@ -3810,8 +3797,6 @@ var ResourceFieldPreview = class {
|
|
|
3810
3797
|
this.options.onError?.(error);
|
|
3811
3798
|
} catch {}
|
|
3812
3799
|
}
|
|
3813
|
-
} finally {
|
|
3814
|
-
ownedMeasurer?.dispose();
|
|
3815
3800
|
}
|
|
3816
3801
|
}
|
|
3817
3802
|
refresh() {
|
|
@@ -3843,6 +3828,132 @@ var ResourceFieldPreview = class {
|
|
|
3843
3828
|
this.lifetime.abort();
|
|
3844
3829
|
}
|
|
3845
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
|
+
};
|
|
3846
3957
|
// src/adapters/browser/input/CanvasOptionInput.ts
|
|
3847
3958
|
/** @file 画布选项只拥有当前激活和可撤销逻辑意图,不创建逐选项 DOM 或缓存页面。 */
|
|
3848
3959
|
/** radio/checkbox 的直接点击与键盘清空,显示继续由 Canvas 统一绘制。 */
|
|
@@ -3999,12 +4110,334 @@ var CanvasOptionInput = class {
|
|
|
3999
4110
|
} catch {}
|
|
4000
4111
|
}
|
|
4001
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
|
+
}
|
|
4002
4435
|
// src/adapters/browser/input/ChoiceFieldInput.ts
|
|
4003
4436
|
/** @file 选择字段只协调当前发生、锚点和受控写入;下拉 UI 由宿主注入。 */
|
|
4004
4437
|
var ChoiceFieldInput = class {
|
|
4005
4438
|
options;
|
|
4006
4439
|
restoreFocus;
|
|
4007
|
-
|
|
4440
|
+
navigateField;
|
|
4008
4441
|
lifetime;
|
|
4009
4442
|
active;
|
|
4010
4443
|
panel;
|
|
@@ -4014,10 +4447,15 @@ var ChoiceFieldInput = class {
|
|
|
4014
4447
|
focusPending = false;
|
|
4015
4448
|
paused = false;
|
|
4016
4449
|
observer;
|
|
4017
|
-
|
|
4450
|
+
geometry;
|
|
4451
|
+
measureDirty = true;
|
|
4452
|
+
measuredWidth = 0;
|
|
4453
|
+
contentHeight = 320;
|
|
4454
|
+
rendered;
|
|
4455
|
+
constructor(options, restoreFocus, navigateField) {
|
|
4018
4456
|
this.options = options;
|
|
4019
4457
|
this.restoreFocus = restoreFocus;
|
|
4020
|
-
this.
|
|
4458
|
+
this.navigateField = navigateField;
|
|
4021
4459
|
}
|
|
4022
4460
|
isOpenFor(selection) {
|
|
4023
4461
|
return !!this.active && this.active.base.selection.fieldId === selection.fieldId && this.active.base.selection.instanceKey === selection.instanceKey;
|
|
@@ -4050,6 +4488,7 @@ var ChoiceFieldInput = class {
|
|
|
4050
4488
|
pointerEvents: "none"
|
|
4051
4489
|
});
|
|
4052
4490
|
owner.body.append(panel);
|
|
4491
|
+
this.geometry = new FieldPanelGeometry(options.host, () => this.refresh());
|
|
4053
4492
|
this.view = options.renderChoicePanel({
|
|
4054
4493
|
container: panel,
|
|
4055
4494
|
state,
|
|
@@ -4062,7 +4501,10 @@ var ChoiceFieldInput = class {
|
|
|
4062
4501
|
});
|
|
4063
4502
|
const Observer = owner.defaultView?.ResizeObserver;
|
|
4064
4503
|
if (Observer && panel.firstElementChild) {
|
|
4065
|
-
this.observer = new Observer(() =>
|
|
4504
|
+
this.observer = new Observer(() => {
|
|
4505
|
+
this.measureDirty = true;
|
|
4506
|
+
this.geometry?.schedule();
|
|
4507
|
+
});
|
|
4066
4508
|
this.observer.observe(panel.firstElementChild);
|
|
4067
4509
|
}
|
|
4068
4510
|
panel.addEventListener("keydown", (event) => {
|
|
@@ -4071,7 +4513,11 @@ var ChoiceFieldInput = class {
|
|
|
4071
4513
|
event.preventDefault();
|
|
4072
4514
|
event.stopPropagation();
|
|
4073
4515
|
this.close(true);
|
|
4074
|
-
} else if (event
|
|
4516
|
+
} else if (isFieldNavigationShortcut(event)) {
|
|
4517
|
+
event.preventDefault();
|
|
4518
|
+
event.stopPropagation();
|
|
4519
|
+
this.navigateField?.(event);
|
|
4520
|
+
}
|
|
4075
4521
|
}, {
|
|
4076
4522
|
capture: true,
|
|
4077
4523
|
signal
|
|
@@ -4087,12 +4533,6 @@ var ChoiceFieldInput = class {
|
|
|
4087
4533
|
capture: true,
|
|
4088
4534
|
signal
|
|
4089
4535
|
});
|
|
4090
|
-
owner.addEventListener("scroll", () => this.refresh(), {
|
|
4091
|
-
capture: true,
|
|
4092
|
-
passive: true,
|
|
4093
|
-
signal
|
|
4094
|
-
});
|
|
4095
|
-
owner.defaultView?.addEventListener("resize", () => this.refresh(), { signal });
|
|
4096
4536
|
owner.defaultView?.addEventListener("blur", () => this.close(), { signal });
|
|
4097
4537
|
owner.addEventListener("visibilitychange", () => {
|
|
4098
4538
|
if (owner.hidden) this.close();
|
|
@@ -4101,6 +4541,7 @@ var ChoiceFieldInput = class {
|
|
|
4101
4541
|
return true;
|
|
4102
4542
|
}
|
|
4103
4543
|
refresh() {
|
|
4544
|
+
this.geometry?.cancel();
|
|
4104
4545
|
const options = this.options, active = this.active, panel = this.panel;
|
|
4105
4546
|
if (!options || !active || !panel || this.writing) return;
|
|
4106
4547
|
panel.style.zIndex = inputOverlayZIndex(options.host, 10);
|
|
@@ -4131,7 +4572,13 @@ var ChoiceFieldInput = class {
|
|
|
4131
4572
|
if (anchor.kind === "ready" && rect) {
|
|
4132
4573
|
active.placement = anchor.placement;
|
|
4133
4574
|
const available = anchor.viewport.top + anchor.viewport.height;
|
|
4134
|
-
|
|
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);
|
|
4135
4582
|
const below = available - anchor.rect.top - anchor.rect.height - 4;
|
|
4136
4583
|
const above = anchor.rect.top - anchor.viewport.top - 4;
|
|
4137
4584
|
const down = below >= desired || below >= above;
|
|
@@ -4150,7 +4597,13 @@ var ChoiceFieldInput = class {
|
|
|
4150
4597
|
panel.inert = disabled;
|
|
4151
4598
|
panel.toggleAttribute("inert", disabled);
|
|
4152
4599
|
panel.setAttribute("aria-busy", String(current.pending));
|
|
4153
|
-
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
|
+
}
|
|
4154
4607
|
if (this.focusPending && !disabled) {
|
|
4155
4608
|
this.focusPending = false;
|
|
4156
4609
|
this.view?.focus();
|
|
@@ -4185,6 +4638,11 @@ var ChoiceFieldInput = class {
|
|
|
4185
4638
|
}
|
|
4186
4639
|
}
|
|
4187
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;
|
|
4188
4646
|
this.observer?.disconnect();
|
|
4189
4647
|
this.observer = void 0;
|
|
4190
4648
|
this.active = void 0;
|
|
@@ -4202,7 +4660,7 @@ var ChoiceFieldInput = class {
|
|
|
4202
4660
|
this.close();
|
|
4203
4661
|
this.options = void 0;
|
|
4204
4662
|
this.restoreFocus = void 0;
|
|
4205
|
-
this.
|
|
4663
|
+
this.navigateField = void 0;
|
|
4206
4664
|
}
|
|
4207
4665
|
};
|
|
4208
4666
|
// src/adapters/browser/input/clipboard/html-style.ts
|
|
@@ -4873,15 +5331,15 @@ var FieldInputValidation = class {
|
|
|
4873
5331
|
}, 300);
|
|
4874
5332
|
}
|
|
4875
5333
|
async run(controller, check, publish) {
|
|
4876
|
-
let
|
|
5334
|
+
let messages;
|
|
4877
5335
|
try {
|
|
4878
|
-
|
|
5336
|
+
messages = await check(controller.signal);
|
|
4879
5337
|
} catch {
|
|
4880
|
-
|
|
5338
|
+
messages = ["数值校验未完成,请重试"];
|
|
4881
5339
|
}
|
|
4882
5340
|
if (!controller.signal.aborted && this.controller === controller) {
|
|
4883
5341
|
this.controller = void 0;
|
|
4884
|
-
publish(
|
|
5342
|
+
publish(messages);
|
|
4885
5343
|
}
|
|
4886
5344
|
}
|
|
4887
5345
|
cancel() {
|
|
@@ -5065,67 +5523,6 @@ function paintInputOverlay(host, layer, input, snapshot, controller, focused, re
|
|
|
5065
5523
|
});
|
|
5066
5524
|
children.push(node);
|
|
5067
5525
|
}
|
|
5068
|
-
if (fieldActive && state.selection?.kind === "field") {
|
|
5069
|
-
const fragments = snapshot.query.findBySource({
|
|
5070
|
-
nodeId: state.selection.fieldId,
|
|
5071
|
-
instanceKey: state.selection.instanceKey
|
|
5072
|
-
}).filter((fragment) => fragment.kind === "atom" && !!fragment.fieldControl);
|
|
5073
|
-
const brackets = fragments.flatMap((fragment) => {
|
|
5074
|
-
if (fragment.kind !== "atom" || !fragment.fieldControl) return [];
|
|
5075
|
-
const control = fragment.fieldControl;
|
|
5076
|
-
const style = snapshot.result.paintStyles[control.paintStyleKey];
|
|
5077
|
-
return style ? controlBracketFrames(control, style).map((bracket) => ({
|
|
5078
|
-
fragment,
|
|
5079
|
-
bracket,
|
|
5080
|
-
style
|
|
5081
|
-
})) : [];
|
|
5082
|
-
});
|
|
5083
|
-
for (const side of ["start", "end"]) {
|
|
5084
|
-
const bracket = side === "start" ? brackets.find((item) => item.bracket.side === side) : [...brackets].reverse().find((item) => item.bracket.side === side);
|
|
5085
|
-
const fragment = bracket?.fragment ?? (side === "start" ? fragments[0] : fragments.at(-1));
|
|
5086
|
-
if (fragment?.kind !== "atom" || !fragment.fieldControl) continue;
|
|
5087
|
-
const pageId = snapshot.query.getFragmentPageId(fragment.id);
|
|
5088
|
-
const page = pageId && pages.get(pageId);
|
|
5089
|
-
const style = bracket?.style ?? snapshot.result.paintStyles[fragment.fieldControl.paintStyleKey];
|
|
5090
|
-
if (!page || !style) continue;
|
|
5091
|
-
const rect = inputScreenRect(bracket ? {
|
|
5092
|
-
...bracket.bracket.frame,
|
|
5093
|
-
x: fragment.frame.x + bracket.bracket.frame.x,
|
|
5094
|
-
y: fragment.frame.y + bracket.bracket.frame.y
|
|
5095
|
-
} : {
|
|
5096
|
-
x: fragment.frame.x + (side === "start" ? -4 : fragment.frame.width),
|
|
5097
|
-
y: fragment.frame.y,
|
|
5098
|
-
width: 4,
|
|
5099
|
-
height: fragment.frame.height
|
|
5100
|
-
}, page);
|
|
5101
|
-
const screen = clipInputRect(rect, clip);
|
|
5102
|
-
if (!screen) continue;
|
|
5103
|
-
const node = owner.createElement("div");
|
|
5104
|
-
const stroke = owner.createElement("div");
|
|
5105
|
-
node.className = "gct-word-input-field-active";
|
|
5106
|
-
node.dataset.side = side;
|
|
5107
|
-
Object.assign(node.style, {
|
|
5108
|
-
position: "fixed",
|
|
5109
|
-
left: `${rect.left}px`,
|
|
5110
|
-
top: `${rect.top}px`,
|
|
5111
|
-
width: `${rect.width}px`,
|
|
5112
|
-
height: `${rect.height}px`,
|
|
5113
|
-
background: page.page.backgroundColor ?? "#fff",
|
|
5114
|
-
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)`
|
|
5115
|
-
});
|
|
5116
|
-
Object.assign(stroke.style, {
|
|
5117
|
-
width: "100%",
|
|
5118
|
-
height: "100%",
|
|
5119
|
-
boxSizing: "border-box",
|
|
5120
|
-
color: fragment.fieldControl.decoration?.markerColor ?? style.color,
|
|
5121
|
-
borderTop: "2px solid currentColor",
|
|
5122
|
-
borderBottom: "2px solid currentColor",
|
|
5123
|
-
...side === "start" ? { borderLeft: "2px solid currentColor" } : { borderRight: "2px solid currentColor" }
|
|
5124
|
-
});
|
|
5125
|
-
node.append(stroke);
|
|
5126
|
-
children.push(node);
|
|
5127
|
-
}
|
|
5128
|
-
}
|
|
5129
5526
|
const caret = visual.compositionCaret ?? visual.caret, page = caret && pages.get(caret.pageId);
|
|
5130
5527
|
if (!caret || !page || !inputVersionMatches(caret.version, snapshot)) {
|
|
5131
5528
|
layer.replaceChildren(...children);
|
|
@@ -5239,6 +5636,13 @@ function readEditorDiagnostic(error) {
|
|
|
5239
5636
|
}
|
|
5240
5637
|
// src/adapters/browser/input/word-error-text.ts
|
|
5241
5638
|
/** @file 把 Word 可识别的失败转换为可展示的中文,原始异常仍留给宿主诊断。 */
|
|
5639
|
+
/** 当前草稿不能提交时,明确切换操作使用宿主的警告消息。 */
|
|
5640
|
+
var FieldInputBlockedError = class extends Error {
|
|
5641
|
+
constructor() {
|
|
5642
|
+
super("当前字段的输入不符合要求,暂时无法切换到其他字段,请先修正或按 Esc 取消输入。");
|
|
5643
|
+
this.name = "FieldInputBlockedError";
|
|
5644
|
+
}
|
|
5645
|
+
};
|
|
5242
5646
|
/** 编辑器可以明确告诉用户如何修正的模型错误。 */
|
|
5243
5647
|
var modelMessages = {
|
|
5244
5648
|
table_merge: "请选择完整的单元格矩形,已有合并格需完整包含",
|
|
@@ -5269,7 +5673,7 @@ function readWordErrorText(error) {
|
|
|
5269
5673
|
/** 模型校验和用户输入错误用警告,其余未知故障由界面使用错误提示。 */
|
|
5270
5674
|
function isWordValidationError(error) {
|
|
5271
5675
|
const diagnostic = readEditorDiagnostic(error);
|
|
5272
|
-
return diagnostic?.kind === "validation" || diagnostic?.kind === "model" && Object.hasOwn(modelMessages, diagnostic.code);
|
|
5676
|
+
return error instanceof FieldInputBlockedError || diagnostic?.kind === "validation" || diagnostic?.kind === "model" && Object.hasOwn(modelMessages, diagnostic.code);
|
|
5273
5677
|
}
|
|
5274
5678
|
/** 主动取消和已撤销的请求属于正常清理,不需要用户处理。 */
|
|
5275
5679
|
function isWordCancellation(error) {
|
|
@@ -5334,7 +5738,7 @@ var InlineFieldInput = class {
|
|
|
5334
5738
|
measurer;
|
|
5335
5739
|
/** 独占测量背板在退出时归零。 */
|
|
5336
5740
|
measureCanvas;
|
|
5337
|
-
/**
|
|
5741
|
+
/** 正文与原位字段共用产品键位预留和字段导航,新输入会撤销等待。 */
|
|
5338
5742
|
keyboard;
|
|
5339
5743
|
/** 创建固定的活动输入,不初始化业务值或加载资源。 */
|
|
5340
5744
|
constructor(options, keyboard) {
|
|
@@ -5527,7 +5931,7 @@ var InlineFieldInput = class {
|
|
|
5527
5931
|
layer.style.pointerEvents = "none";
|
|
5528
5932
|
return;
|
|
5529
5933
|
}
|
|
5530
|
-
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);
|
|
5531
5935
|
active.placement = {
|
|
5532
5936
|
fragmentId: geometry.fragment.id,
|
|
5533
5937
|
pageId: geometry.pageId
|
|
@@ -5558,10 +5962,11 @@ var InlineFieldInput = class {
|
|
|
5558
5962
|
transform: `scale(${geometry.scaleX},${geometry.scaleY})`
|
|
5559
5963
|
});
|
|
5560
5964
|
const marks = [], owner = input.ownerDocument;
|
|
5561
|
-
|
|
5965
|
+
const focused = owner.activeElement === input || this.focusPending;
|
|
5966
|
+
for (const rect of focused ? fieldSelectionRects(options, snapshot, {
|
|
5562
5967
|
...state,
|
|
5563
5968
|
text: active.preview ? input.value : state.text
|
|
5564
|
-
}, input.selectionStart, input.selectionEnd, this.textMeasurer())) {
|
|
5969
|
+
}, input.selectionStart, input.selectionEnd, this.textMeasurer()) : []) {
|
|
5565
5970
|
const mark = owner.createElement("div");
|
|
5566
5971
|
mark.className = "gct-word-inline-selection";
|
|
5567
5972
|
Object.assign(mark.style, {
|
|
@@ -5574,7 +5979,7 @@ var InlineFieldInput = class {
|
|
|
5574
5979
|
});
|
|
5575
5980
|
marks.push(mark);
|
|
5576
5981
|
}
|
|
5577
|
-
if (input.selectionStart === input.selectionEnd) {
|
|
5982
|
+
if (focused && input.selectionStart === input.selectionEnd) {
|
|
5578
5983
|
const caret = this.caret ??= owner.createElement("div");
|
|
5579
5984
|
caret.className = "gct-word-inline-caret";
|
|
5580
5985
|
Object.assign(caret.style, {
|
|
@@ -5633,7 +6038,9 @@ var InlineFieldInput = class {
|
|
|
5633
6038
|
this.cancel();
|
|
5634
6039
|
return true;
|
|
5635
6040
|
}
|
|
5636
|
-
|
|
6041
|
+
const ready = this.commitSync();
|
|
6042
|
+
if (!ready && this.writeBlocked && this.failure) this.fail(new FieldInputBlockedError());
|
|
6043
|
+
return ready;
|
|
5637
6044
|
}
|
|
5638
6045
|
/** 指针切换前同步提交已有有效草稿,未准备或无效数字时保留当前焦点。 */
|
|
5639
6046
|
commitSync() {
|
|
@@ -5771,7 +6178,7 @@ var InlineFieldInput = class {
|
|
|
5771
6178
|
const options = this.options, input = this.input, active = this.active;
|
|
5772
6179
|
if (!options || !input || !active) return;
|
|
5773
6180
|
const text = input.value;
|
|
5774
|
-
this.validation.schedule((signal) => options.controller.
|
|
6181
|
+
this.validation.schedule((signal) => options.controller.validateFieldTextMessages(text, active.base, signal), (messages) => {
|
|
5775
6182
|
if (this.active !== active || this.input !== input || this.composing || !active.dirty && active.base.widget === "number" || input.value !== text) return;
|
|
5776
6183
|
try {
|
|
5777
6184
|
if (!this.current()) return;
|
|
@@ -5779,10 +6186,10 @@ var InlineFieldInput = class {
|
|
|
5779
6186
|
this.cancel();
|
|
5780
6187
|
return;
|
|
5781
6188
|
}
|
|
5782
|
-
this.failure =
|
|
6189
|
+
this.failure = messages;
|
|
5783
6190
|
this.draftChecked = true;
|
|
5784
|
-
input.setCustomValidity(
|
|
5785
|
-
this.preview(!!
|
|
6191
|
+
input.setCustomValidity(messages?.join(";") ?? "");
|
|
6192
|
+
this.preview(!!messages?.length);
|
|
5786
6193
|
});
|
|
5787
6194
|
}
|
|
5788
6195
|
/** 草稿参加同一视图的流式排版,未完成数字及候选不会发布为业务数据。 */
|
|
@@ -5836,16 +6243,21 @@ var InlineFieldInput = class {
|
|
|
5836
6243
|
} catch (error) {
|
|
5837
6244
|
this.writeBlocked = true;
|
|
5838
6245
|
this.draftChecked = true;
|
|
5839
|
-
this.failure = error instanceof Error && error.name === "FieldNumberError" ? error.message : active.base.widget === "number" ? "请输入完整有效的数字" : readWordErrorText(error) ?? "当前内容未能保存,请检查输入";
|
|
5840
|
-
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(";"));
|
|
5841
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
|
+
}
|
|
5842
6254
|
this.refresh();
|
|
5843
6255
|
return false;
|
|
5844
6256
|
} finally {
|
|
5845
6257
|
this.writing = false;
|
|
5846
6258
|
}
|
|
5847
6259
|
}
|
|
5848
|
-
showMessage(
|
|
6260
|
+
showMessage(messages, left, top) {
|
|
5849
6261
|
const input = this.input, options = this.options;
|
|
5850
6262
|
if (!input || !options) return;
|
|
5851
6263
|
const blurred = !!this.options?.onFieldInputValidation && input.ownerDocument.activeElement !== input && !this.focusPending;
|
|
@@ -5855,11 +6267,14 @@ var InlineFieldInput = class {
|
|
|
5855
6267
|
valuePath: state.validationPath,
|
|
5856
6268
|
label: state.validationDescription?.label ?? "字段",
|
|
5857
6269
|
context: state.validationDescription?.context,
|
|
5858
|
-
|
|
6270
|
+
modelName: state.validationDescription?.modelName,
|
|
6271
|
+
modelKind: state.validationDescription?.modelKind,
|
|
6272
|
+
message: messages?.join(";"),
|
|
6273
|
+
messages,
|
|
5859
6274
|
blocked: this.writeBlocked
|
|
5860
6275
|
});
|
|
5861
|
-
if (blurred)
|
|
5862
|
-
if (!
|
|
6276
|
+
if (blurred) messages = void 0;
|
|
6277
|
+
if (!messages?.length) {
|
|
5863
6278
|
if (this.message) this.message.hidden = true;
|
|
5864
6279
|
input.removeAttribute("aria-describedby");
|
|
5865
6280
|
if (!this.failure) input.removeAttribute("aria-invalid");
|
|
@@ -5873,24 +6288,24 @@ var InlineFieldInput = class {
|
|
|
5873
6288
|
message.setAttribute("role", "alert");
|
|
5874
6289
|
owner.body.append(message);
|
|
5875
6290
|
}
|
|
5876
|
-
const description = this.active?.base.validationDescription;
|
|
5877
6291
|
const cancelHint = this.active?.base.widget === "number" ? "按 Esc 取消本次输入,恢复原值" : void 0;
|
|
5878
|
-
const key = JSON.stringify([
|
|
5879
|
-
description,
|
|
5880
|
-
text,
|
|
5881
|
-
cancelHint
|
|
5882
|
-
]);
|
|
6292
|
+
const key = JSON.stringify([messages, cancelHint]);
|
|
5883
6293
|
if (message.dataset.content !== key) {
|
|
5884
|
-
const
|
|
5885
|
-
title.textContent = description ? `${description.label} · ${description.context}` : "字段校验";
|
|
5886
|
-
Object.assign(title.style, {
|
|
5887
|
-
color: "#4b5563",
|
|
5888
|
-
fontSize: "12px",
|
|
5889
|
-
marginBottom: "4px"
|
|
5890
|
-
});
|
|
6294
|
+
const body = owner.createElement("ul");
|
|
5891
6295
|
body.className = "gct-word-field-input-message-text";
|
|
5892
|
-
|
|
5893
|
-
|
|
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);
|
|
5894
6309
|
if (cancelHint) {
|
|
5895
6310
|
const help = owner.createElement("div");
|
|
5896
6311
|
help.className = "gct-word-field-input-message-help";
|
|
@@ -5929,6 +6344,19 @@ var InlineFieldInput = class {
|
|
|
5929
6344
|
/** 数字和单行 Enter 在此提交,多行 Enter 和原生选区/剪贴继续由同一个 textarea 处理。 */
|
|
5930
6345
|
keyDown(event) {
|
|
5931
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;
|
|
5932
6360
|
if (!event.ctrlKey && !event.metaKey && !event.altKey && [
|
|
5933
6361
|
"ArrowUp",
|
|
5934
6362
|
"ArrowDown",
|
|
@@ -5947,12 +6375,11 @@ var InlineFieldInput = class {
|
|
|
5947
6375
|
event.preventDefault();
|
|
5948
6376
|
this.commit();
|
|
5949
6377
|
}
|
|
5950
|
-
if (event.key === "Tab") this.keyboard?.tab(event);
|
|
5951
6378
|
}
|
|
5952
6379
|
/** 同字段点击和拖选直接调整原生选区,未完成数值仍可回到中间修改。 */
|
|
5953
6380
|
pointerDown(event) {
|
|
5954
6381
|
const options = this.options, input = this.input;
|
|
5955
|
-
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;
|
|
5956
6383
|
const snapshot = options.layout.getCurrentSnapshot();
|
|
5957
6384
|
if (!snapshot) return;
|
|
5958
6385
|
const hit = fieldPointOffset(options, snapshot, {
|
|
@@ -5968,6 +6395,7 @@ var InlineFieldInput = class {
|
|
|
5968
6395
|
anchor
|
|
5969
6396
|
};
|
|
5970
6397
|
this.active.placement = hit.placement;
|
|
6398
|
+
this.focusPending = true;
|
|
5971
6399
|
this.setRange(anchor, hit.offset);
|
|
5972
6400
|
try {
|
|
5973
6401
|
options.host.setPointerCapture?.(event.pointerId);
|
|
@@ -5997,7 +6425,7 @@ var InlineFieldInput = class {
|
|
|
5997
6425
|
this.drag = void 0;
|
|
5998
6426
|
}
|
|
5999
6427
|
/** 原生左右键保留字素语义,上下和行首尾沿用 Canvas 的实际断行。 */
|
|
6000
|
-
moveCaret(event) {
|
|
6428
|
+
moveCaret(event, extend = event.shiftKey) {
|
|
6001
6429
|
const options = this.options, input = this.input, active = this.active, snapshot = options?.layout.getCurrentSnapshot();
|
|
6002
6430
|
if (!options || !input || !active || !snapshot) return false;
|
|
6003
6431
|
const focus = input.selectionDirection === "backward" ? input.selectionStart : input.selectionEnd, state = {
|
|
@@ -6018,7 +6446,7 @@ var InlineFieldInput = class {
|
|
|
6018
6446
|
}
|
|
6019
6447
|
if (offset === void 0) return false;
|
|
6020
6448
|
event.preventDefault();
|
|
6021
|
-
this.setRange(
|
|
6449
|
+
this.setRange(extend ? this.selectionAnchor() : offset, offset);
|
|
6022
6450
|
return true;
|
|
6023
6451
|
}
|
|
6024
6452
|
/** 保留反向选择的固定端。 */
|
|
@@ -6232,7 +6660,7 @@ var SignatureFieldInput = class {
|
|
|
6232
6660
|
/** 当前一次激活创建独立事件身份;已保存摘要与认证状态刷新不重建按钮。 */
|
|
6233
6661
|
install() {
|
|
6234
6662
|
const owner = this.options.host.ownerDocument, signal = (this.lifetime = new AbortController()).signal, dialog = new FieldDialog(owner, "签名", () => this.close(true), {
|
|
6235
|
-
width:
|
|
6663
|
+
width: 640,
|
|
6236
6664
|
className: "gct-word-signature-input",
|
|
6237
6665
|
render: this.options.renderFieldDialog
|
|
6238
6666
|
}), body = owner.createElement("div"), records = owner.createElement("div"), status = owner.createElement("p"), actions = owner.createElement("div");
|
|
@@ -6315,11 +6743,10 @@ var SignatureFieldInput = class {
|
|
|
6315
6743
|
return;
|
|
6316
6744
|
}
|
|
6317
6745
|
this.draft = draft;
|
|
6318
|
-
|
|
6319
|
-
if (draft && authorization?.method === "CARD") {
|
|
6746
|
+
if (draft && authorization) {
|
|
6320
6747
|
this.pending = false;
|
|
6321
|
-
this.save(2e3);
|
|
6322
|
-
}
|
|
6748
|
+
this.save(authorization.method === "CARD" ? 2e3 : 0, true);
|
|
6749
|
+
} else this.message = draft ? `已认证:${signatureSummary(draft.username, draft.time)}\n尚未保存,请确认。` : "已取消认证,原有签名未改变。";
|
|
6323
6750
|
} catch (error) {
|
|
6324
6751
|
if (!task.signal.aborted && this.active === active) this.fail(error);
|
|
6325
6752
|
} finally {
|
|
@@ -6335,7 +6762,7 @@ var SignatureFieldInput = class {
|
|
|
6335
6762
|
}
|
|
6336
6763
|
}
|
|
6337
6764
|
/** 明确确认后只提交服务发放的凭据;互斥失败仍保留原值并显示原因。 */
|
|
6338
|
-
save(closeDelayMs = 0) {
|
|
6765
|
+
save(closeDelayMs = 0, releaseOnFailure = false) {
|
|
6339
6766
|
this.refresh();
|
|
6340
6767
|
const options = this.options, active = this.active, draft = this.draft;
|
|
6341
6768
|
if (!options || !active || !draft || this.pending || this.confirmButton?.disabled) return;
|
|
@@ -6352,7 +6779,7 @@ var SignatureFieldInput = class {
|
|
|
6352
6779
|
this.closeTimer = setTimeout(() => this.close(true), closeDelayMs);
|
|
6353
6780
|
} else this.close(true);
|
|
6354
6781
|
} catch (error) {
|
|
6355
|
-
if (
|
|
6782
|
+
if (releaseOnFailure) {
|
|
6356
6783
|
options.controller.discardFieldSignature(draft);
|
|
6357
6784
|
this.draft = void 0;
|
|
6358
6785
|
}
|
|
@@ -6399,6 +6826,7 @@ var CanvasTextInput = class {
|
|
|
6399
6826
|
input;
|
|
6400
6827
|
/** 独立高亮层,移动光标不重画页面。 */
|
|
6401
6828
|
overlay;
|
|
6829
|
+
fieldBrackets = new CanvasFieldBrackets();
|
|
6402
6830
|
/** 自有临时样式,关闭时移除。 */
|
|
6403
6831
|
style;
|
|
6404
6832
|
/** 未注入文字度量时,仅在组合输入需要字体框时创建,关闭时释放。 */
|
|
@@ -6456,13 +6884,13 @@ var CanvasTextInput = class {
|
|
|
6456
6884
|
this.overlay = overlay;
|
|
6457
6885
|
this.style = style;
|
|
6458
6886
|
this.fields = new InlineFieldInput(options, {
|
|
6459
|
-
|
|
6887
|
+
shortcut: (event) => this.fieldShortcut(event),
|
|
6460
6888
|
paste: (event) => {
|
|
6461
6889
|
this.pasteBusinessMatrix(event);
|
|
6462
6890
|
},
|
|
6463
6891
|
edited: () => this.cancelTab()
|
|
6464
6892
|
});
|
|
6465
|
-
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));
|
|
6466
6894
|
this.mediaPreview = new ResourceFieldPreview(options);
|
|
6467
6895
|
this.signatures = new SignatureFieldInput(options, () => this.input?.focus({ preventScroll: true }));
|
|
6468
6896
|
this.business = new BusinessFieldInput(options, () => this.input?.focus({ preventScroll: true }));
|
|
@@ -6605,6 +7033,7 @@ var CanvasTextInput = class {
|
|
|
6605
7033
|
this.mediaPreview?.refresh();
|
|
6606
7034
|
this.business?.refresh();
|
|
6607
7035
|
this.optionInput?.refresh();
|
|
7036
|
+
this.fieldBrackets.refresh(options.host, options.layout.getCurrentSnapshot(), options.controller);
|
|
6608
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));
|
|
6609
7038
|
if (rect && this.revealPending) {
|
|
6610
7039
|
this.revealPending = false;
|
|
@@ -6612,6 +7041,7 @@ var CanvasTextInput = class {
|
|
|
6612
7041
|
}
|
|
6613
7042
|
} catch (error) {
|
|
6614
7043
|
overlay.replaceChildren();
|
|
7044
|
+
this.fieldBrackets.clear();
|
|
6615
7045
|
this.fail(error);
|
|
6616
7046
|
}
|
|
6617
7047
|
}
|
|
@@ -6647,6 +7077,7 @@ var CanvasTextInput = class {
|
|
|
6647
7077
|
}
|
|
6648
7078
|
/** 幂等解除原生事件、临时层和等待;不关闭外部控制器、排版或共享资源。 */
|
|
6649
7079
|
dispose() {
|
|
7080
|
+
this.fieldBrackets.clear();
|
|
6650
7081
|
const options = this.options;
|
|
6651
7082
|
this.options = void 0;
|
|
6652
7083
|
this.setTableCursor();
|
|
@@ -6983,10 +7414,12 @@ var CanvasTextInput = class {
|
|
|
6983
7414
|
host.releasePointerCapture(pointer);
|
|
6984
7415
|
} catch {}
|
|
6985
7416
|
}
|
|
6986
|
-
/**
|
|
6987
|
-
|
|
7417
|
+
/** 主修饰键加 Enter 按原字段顺序导航;首尾停留,不落成换行或提交宿主表单。 */
|
|
7418
|
+
navigateField(event) {
|
|
6988
7419
|
const controller = this.options?.controller, source = event.target;
|
|
6989
|
-
if (!controller || !source || event
|
|
7420
|
+
if (!controller || !source || !isFieldNavigationShortcut(event)) return;
|
|
7421
|
+
event.preventDefault();
|
|
7422
|
+
event.stopPropagation();
|
|
6990
7423
|
this.cancelTab();
|
|
6991
7424
|
const direction = event.shiftKey ? -1 : 1;
|
|
6992
7425
|
this.run(() => {
|
|
@@ -7037,12 +7470,29 @@ var CanvasTextInput = class {
|
|
|
7037
7470
|
this.tabTask?.abort();
|
|
7038
7471
|
this.tabTask = void 0;
|
|
7039
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
|
+
}
|
|
7040
7488
|
/** 编辑快捷键走逻辑命令,浏览器字段原生事件由自己的 textarea 处理。 */
|
|
7041
7489
|
keyDown(event) {
|
|
7042
7490
|
if (!this.options || event.isComposing || event.keyCode === 229 || this.composing) return;
|
|
7043
7491
|
if (event.key === "Tab") {
|
|
7044
|
-
if (
|
|
7045
|
-
|
|
7492
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
|
7493
|
+
this.cancelTab();
|
|
7494
|
+
this.clearEcho();
|
|
7495
|
+
if (this.options.controller.canEditText()) {
|
|
7046
7496
|
this.run((controller) => {
|
|
7047
7497
|
if (controller.design.tables.tabCell(event.shiftKey ? -1 : 1)) {
|
|
7048
7498
|
event.preventDefault();
|
|
@@ -7051,10 +7501,18 @@ var CanvasTextInput = class {
|
|
|
7051
7501
|
});
|
|
7052
7502
|
if (event.defaultPrevented) return;
|
|
7053
7503
|
}
|
|
7054
|
-
this.
|
|
7504
|
+
this.fieldShortcut(event);
|
|
7055
7505
|
return;
|
|
7056
7506
|
}
|
|
7507
|
+
if (this.fieldShortcut(event)) return;
|
|
7057
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);
|
|
7514
|
+
return;
|
|
7515
|
+
}
|
|
7058
7516
|
if (this.optionInput?.keyDown(event)) return;
|
|
7059
7517
|
if (this.options.controller.getState().selection?.kind === "cells" && event.key === "Enter" && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
7060
7518
|
event.preventDefault();
|
|
@@ -7345,99 +7803,9 @@ var CanvasTextInput = class {
|
|
|
7345
7803
|
} catch {}
|
|
7346
7804
|
}
|
|
7347
7805
|
};
|
|
7348
|
-
// src/adapters/browser/input/business/tables/fixed-quick-fill-grid.ts
|
|
7349
|
-
/** @file 固定表弹框只渲染原生网格和局部草稿,写入仍由业务命令统一预检。 */
|
|
7350
|
-
/** 完整检查物理矩形后才返回草稿补丁;合并从格的空占位不制造字段。 */
|
|
7351
|
-
function fixedQuickFillPaste(layout, text, row, column) {
|
|
7352
|
-
const matrix = parseTsv(text, {
|
|
7353
|
-
rows: layout.rowCount - row,
|
|
7354
|
-
columns: layout.columnCount - column
|
|
7355
|
-
});
|
|
7356
|
-
const patches = [];
|
|
7357
|
-
for (const [y, values] of matrix.entries()) for (const [x, value] of values.entries()) {
|
|
7358
|
-
const cell = layout.cells.find((cell) => cell.row === row + y && cell.column === column + x);
|
|
7359
|
-
if (!cell?.field || cell.slot === void 0) {
|
|
7360
|
-
if (value) throw Error("粘贴位置没有可填写字段或属于合并从格");
|
|
7361
|
-
continue;
|
|
7362
|
-
}
|
|
7363
|
-
if (!cell.editable) throw Error("粘贴范围包含不可编辑字段");
|
|
7364
|
-
patches.push({
|
|
7365
|
-
slot: cell.slot,
|
|
7366
|
-
key: cell.field.key,
|
|
7367
|
-
value
|
|
7368
|
-
});
|
|
7369
|
-
}
|
|
7370
|
-
return patches;
|
|
7371
|
-
}
|
|
7372
|
-
function renderFixedQuickFillGrid(options) {
|
|
7373
|
-
const { owner, layout, signal } = options, start = options.page * 20, end = Math.min(layout.rowCount, start + 20), table = owner.createElement("table"), body = owner.createElement("tbody");
|
|
7374
|
-
table.setAttribute("aria-label", "快速填报输入表格");
|
|
7375
|
-
table.style.cssText = "border-collapse:collapse;width:max-content;min-width:100%";
|
|
7376
|
-
let anchor;
|
|
7377
|
-
const selected = /* @__PURE__ */ new Set();
|
|
7378
|
-
for (let row = start; row < end; row++) {
|
|
7379
|
-
const tr = owner.createElement("tr");
|
|
7380
|
-
for (const cell of layout.cells.filter((cell) => Math.max(cell.row, start) === row && cell.row + cell.rowSpan > start)) {
|
|
7381
|
-
const td = owner.createElement("td");
|
|
7382
|
-
td.rowSpan = Math.min(cell.row + cell.rowSpan, end) - row;
|
|
7383
|
-
td.colSpan = cell.columnSpan;
|
|
7384
|
-
td.dataset.row = String(cell.row);
|
|
7385
|
-
td.dataset.column = String(cell.column);
|
|
7386
|
-
td.style.cssText = "border:1px solid #d9d9d9;padding:4px";
|
|
7387
|
-
if (cell.field && cell.slot !== void 0) {
|
|
7388
|
-
const input = owner.createElement("textarea"), slot = cell.slot, key = cell.field.key;
|
|
7389
|
-
input.rows = 1;
|
|
7390
|
-
input.readOnly = options.disabled || !cell.editable;
|
|
7391
|
-
input.value = options.value(slot, key);
|
|
7392
|
-
input.setAttribute("aria-label", `第 ${slot + 1} 行 · ${cell.field.label}`);
|
|
7393
|
-
input.style.cssText = "min-width:130px;width:160px;resize:vertical;box-sizing:border-box";
|
|
7394
|
-
input.addEventListener("input", () => options.input(slot, key, input.value), { signal });
|
|
7395
|
-
input.addEventListener("paste", (event) => {
|
|
7396
|
-
if (!event.clipboardData?.types.includes("text/plain")) return;
|
|
7397
|
-
event.preventDefault();
|
|
7398
|
-
options.paste(event.clipboardData.getData("text/plain"), cell.row, cell.column);
|
|
7399
|
-
}, { signal });
|
|
7400
|
-
td.append(input);
|
|
7401
|
-
} else td.textContent = cell.text;
|
|
7402
|
-
td.addEventListener("pointerdown", (event) => {
|
|
7403
|
-
if (!event.shiftKey || !anchor) {
|
|
7404
|
-
for (const item of selected) item.style.backgroundColor = "";
|
|
7405
|
-
selected.clear();
|
|
7406
|
-
anchor = cell;
|
|
7407
|
-
return;
|
|
7408
|
-
}
|
|
7409
|
-
event.preventDefault();
|
|
7410
|
-
for (const item of selected) item.style.backgroundColor = "";
|
|
7411
|
-
selected.clear();
|
|
7412
|
-
for (const item of table.querySelectorAll("td")) {
|
|
7413
|
-
const y = Number(item.dataset.row), x = Number(item.dataset.column);
|
|
7414
|
-
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)) {
|
|
7415
|
-
selected.add(item);
|
|
7416
|
-
item.style.backgroundColor = "#e6f4ff";
|
|
7417
|
-
}
|
|
7418
|
-
}
|
|
7419
|
-
}, { signal });
|
|
7420
|
-
tr.append(td);
|
|
7421
|
-
}
|
|
7422
|
-
body.append(tr);
|
|
7423
|
-
}
|
|
7424
|
-
table.append(body);
|
|
7425
|
-
table.addEventListener("keydown", (event) => {
|
|
7426
|
-
if (options.disabled || !selected.size || !["Delete", "Backspace"].includes(event.key)) return;
|
|
7427
|
-
event.preventDefault();
|
|
7428
|
-
for (const td of selected) {
|
|
7429
|
-
const cell = layout.cells.find((cell) => cell.row === Number(td.dataset.row) && cell.column === Number(td.dataset.column));
|
|
7430
|
-
if (!cell?.field || cell.slot === void 0 || !cell.editable) continue;
|
|
7431
|
-
options.input(cell.slot, cell.field.key, "");
|
|
7432
|
-
const input = td.querySelector("textarea");
|
|
7433
|
-
if (input) input.value = "";
|
|
7434
|
-
}
|
|
7435
|
-
}, { signal });
|
|
7436
|
-
return table;
|
|
7437
|
-
}
|
|
7438
7806
|
// src/adapters/browser/input/business/tables/CanvasQuickFillDialog.ts
|
|
7439
|
-
/** @file
|
|
7440
|
-
/** 动态草稿最多 200
|
|
7807
|
+
/** @file 快速填报协调插件草稿和原生命令,不实现表格选择或填充交互。 */
|
|
7808
|
+
/** 动态草稿最多 200 行,固定表按原生容量;虚拟滚动和交互由插件负责。 */
|
|
7441
7809
|
var CanvasQuickFillDialog = class {
|
|
7442
7810
|
/** 可解除的当前装配。 */
|
|
7443
7811
|
options;
|
|
@@ -7455,16 +7823,16 @@ var CanvasQuickFillDialog = class {
|
|
|
7455
7823
|
rows = [];
|
|
7456
7824
|
/** 原生端口只交付当前可见字段的文本,草稿不复制业务行。 */
|
|
7457
7825
|
initialRows = [];
|
|
7458
|
-
/** 仅 UI 分页,不作为业务下标。 */
|
|
7459
|
-
page = 0;
|
|
7460
7826
|
/** 原始来源是否已经过期,过期时保留草稿供查看。 */
|
|
7461
7827
|
stale = false;
|
|
7462
7828
|
/** 当前局部提示,不存错误对象。 */
|
|
7463
7829
|
message = "";
|
|
7464
7830
|
/** 自身同步提交不被自己的通知误标为过期。 */
|
|
7465
7831
|
writing = false;
|
|
7466
|
-
/**
|
|
7467
|
-
|
|
7832
|
+
/** 插件只属于当前弹框,关闭时释放全部草稿和监听。 */
|
|
7833
|
+
view;
|
|
7834
|
+
submitting = false;
|
|
7835
|
+
applyButton;
|
|
7468
7836
|
/** 可更新的轻量反馈。 */
|
|
7469
7837
|
status;
|
|
7470
7838
|
/** 关闭后返回当前仍连接的原生按钮。 */
|
|
@@ -7489,19 +7857,49 @@ var CanvasQuickFillDialog = class {
|
|
|
7489
7857
|
if (opening.signal.aborted || this.options !== options) return;
|
|
7490
7858
|
const source = options.controller.businessTables.readQuickFill(expected.regionId, expected.anchorInstanceKey);
|
|
7491
7859
|
if (!source?.enabled || !isEqual(source.selection, expected.selection) || !isEqual(source.occurrence, expected.occurrence)) throw Error("当前行或快速填报规则已变化,请重新操作");
|
|
7860
|
+
if (!options.renderQuickFillPanel) throw Error("尚未接入快速填报表格面板");
|
|
7492
7861
|
this.source = source;
|
|
7493
7862
|
this.initialRows = source.layout ? options.controller.businessTables.quickFillValues(source) : [];
|
|
7494
|
-
this.rows = Array.from({ length: source.
|
|
7495
|
-
this.page = 0;
|
|
7863
|
+
this.rows = Array.from({ length: source.limit }, () => ({}));
|
|
7496
7864
|
this.stale = false;
|
|
7497
7865
|
this.message = "";
|
|
7498
7866
|
this.returnFocus = options.host.ownerDocument.activeElement instanceof options.host.ownerDocument.defaultView.HTMLElement ? options.host.ownerDocument.activeElement : void 0;
|
|
7499
7867
|
this.dialog = new FieldDialog(options.host.ownerDocument, "快速填报", () => this.close(), {
|
|
7500
|
-
width:
|
|
7868
|
+
width: 1060,
|
|
7869
|
+
className: "gct-word-quick-fill-dialog",
|
|
7501
7870
|
render: options.renderFieldDialog
|
|
7502
7871
|
});
|
|
7503
|
-
this.
|
|
7504
|
-
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();
|
|
7505
7903
|
} catch (error) {
|
|
7506
7904
|
if (!opening.signal.aborted && this.options === options) this.report(error);
|
|
7507
7905
|
} finally {
|
|
@@ -7515,7 +7913,9 @@ var CanvasQuickFillDialog = class {
|
|
|
7515
7913
|
if (!isEqual(current, this.source)) {
|
|
7516
7914
|
this.stale = true;
|
|
7517
7915
|
this.message = "来源已变化,请关闭后重新打开快速填报";
|
|
7518
|
-
this.
|
|
7916
|
+
if (this.status) this.status.textContent = this.message;
|
|
7917
|
+
this.view?.setReadonly(true);
|
|
7918
|
+
this.updateActions();
|
|
7519
7919
|
}
|
|
7520
7920
|
}
|
|
7521
7921
|
/** 明确取消只丢弃临时输入,不写仓库或新增行。 */
|
|
@@ -7524,15 +7924,18 @@ var CanvasQuickFillDialog = class {
|
|
|
7524
7924
|
this.opening = void 0;
|
|
7525
7925
|
this.controls?.abort();
|
|
7526
7926
|
this.controls = void 0;
|
|
7927
|
+
this.view?.dispose();
|
|
7928
|
+
this.view = void 0;
|
|
7527
7929
|
this.dialog?.dispose();
|
|
7528
7930
|
this.dialog = void 0;
|
|
7529
|
-
this.
|
|
7931
|
+
this.applyButton = void 0;
|
|
7530
7932
|
this.status = void 0;
|
|
7531
7933
|
this.source = void 0;
|
|
7532
7934
|
this.initialRows = [];
|
|
7533
7935
|
this.rows = [];
|
|
7534
7936
|
this.message = "";
|
|
7535
7937
|
this.stale = false;
|
|
7938
|
+
this.submitting = false;
|
|
7536
7939
|
const focus = this.returnFocus;
|
|
7537
7940
|
this.returnFocus = void 0;
|
|
7538
7941
|
if (focus?.isConnected) focus.focus({ preventScroll: true });
|
|
@@ -7544,158 +7947,68 @@ var CanvasQuickFillDialog = class {
|
|
|
7544
7947
|
this.unsubscribe = void 0;
|
|
7545
7948
|
this.options = void 0;
|
|
7546
7949
|
}
|
|
7547
|
-
/**
|
|
7950
|
+
/** 与旧版相同的说明区和整张网格,确认/取消使用公共弹框底部。 */
|
|
7548
7951
|
render() {
|
|
7549
|
-
const root = this.dialog
|
|
7550
|
-
if (!root || !source) return;
|
|
7952
|
+
const root = this.dialog.content, source = this.source, owner = root.ownerDocument;
|
|
7551
7953
|
root.classList.add("gct-word-table-quick-fill");
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
const
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
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";
|
|
7558
7967
|
this.status = owner.createElement("p");
|
|
7968
|
+
this.status.className = "gct-word-quick-fill-status";
|
|
7559
7969
|
this.status.setAttribute("role", "status");
|
|
7560
|
-
this.status.textContent =
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
this.
|
|
7575
|
-
this.
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
this.render();
|
|
7585
|
-
}, !!source.layout || this.rows.length >= source.limit || this.stale);
|
|
7586
|
-
add("清空输入草稿", () => {
|
|
7587
|
-
this.rows = Array.from({ length: source.layout ? source.limit : Math.min(10, source.limit) }, () => ({}));
|
|
7588
|
-
this.page = 0;
|
|
7589
|
-
this.message = "";
|
|
7590
|
-
this.render();
|
|
7591
|
-
}, this.stale);
|
|
7592
|
-
if (source.layout) add("清空可编辑字段", () => {
|
|
7593
|
-
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] = "";
|
|
7594
|
-
this.render();
|
|
7595
|
-
}, this.stale);
|
|
7596
|
-
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([{
|
|
7597
7994
|
label: "取消",
|
|
7598
7995
|
run: () => this.close()
|
|
7599
7996
|
}, {
|
|
7600
7997
|
label: "确定",
|
|
7601
7998
|
primary: true,
|
|
7602
|
-
disabled
|
|
7603
|
-
run: () => this.apply()
|
|
7604
|
-
}])
|
|
7605
|
-
const count = owner.createElement("span");
|
|
7606
|
-
count.textContent = `第 ${this.page + 1} 页 · 草稿 ${this.rows.length} 行`;
|
|
7607
|
-
tools.append(count);
|
|
7608
|
-
this.grid = owner.createElement("div");
|
|
7609
|
-
this.grid.style.cssText = "overflow:auto;max-height:55vh";
|
|
7610
|
-
if (source.layout) {
|
|
7611
|
-
this.grid.append(renderFixedQuickFillGrid({
|
|
7612
|
-
owner,
|
|
7613
|
-
layout: source.layout,
|
|
7614
|
-
page: this.page,
|
|
7615
|
-
signal,
|
|
7616
|
-
disabled: this.stale,
|
|
7617
|
-
value: (slot, key) => this.rows[slot]?.[key] ?? this.initialRows[slot]?.[key] ?? "",
|
|
7618
|
-
input: (slot, key, value) => {
|
|
7619
|
-
if (this.rows[slot]) this.rows[slot][key] = value;
|
|
7620
|
-
},
|
|
7621
|
-
paste: (text, row, column) => {
|
|
7622
|
-
if (this.stale) return;
|
|
7623
|
-
try {
|
|
7624
|
-
const patches = fixedQuickFillPaste(source.layout, text, row, column);
|
|
7625
|
-
if (patches.some((patch) => patch.slot >= this.rows.length)) throw Error("粘贴超过当前可填写容量");
|
|
7626
|
-
for (const patch of patches) this.rows[patch.slot][patch.key] = patch.value;
|
|
7627
|
-
this.message = "已粘贴到固定表草稿";
|
|
7628
|
-
this.render();
|
|
7629
|
-
} catch (error) {
|
|
7630
|
-
this.report(error);
|
|
7631
|
-
}
|
|
7632
|
-
}
|
|
7633
|
-
}));
|
|
7634
|
-
root.append(info, this.status, tools, this.grid);
|
|
7635
|
-
return;
|
|
7636
|
-
}
|
|
7637
|
-
const table = owner.createElement("table");
|
|
7638
|
-
table.setAttribute("aria-label", "快速填报输入表格");
|
|
7639
|
-
table.style.cssText = "border-collapse:collapse;width:max-content;min-width:100%";
|
|
7640
|
-
const head = owner.createElement("thead"), header = owner.createElement("tr");
|
|
7641
|
-
for (const title of ["序号", ...source.columns.map((column) => column.label)]) {
|
|
7642
|
-
const cell = owner.createElement("th");
|
|
7643
|
-
cell.textContent = title;
|
|
7644
|
-
header.append(cell);
|
|
7645
|
-
}
|
|
7646
|
-
head.append(header);
|
|
7647
|
-
table.append(head);
|
|
7648
|
-
const body = owner.createElement("tbody");
|
|
7649
|
-
for (let rowIndex = this.page * 20; rowIndex < Math.min(this.rows.length, (this.page + 1) * 20); rowIndex++) {
|
|
7650
|
-
const row = owner.createElement("tr"), index = owner.createElement("th");
|
|
7651
|
-
index.textContent = String(rowIndex + 1);
|
|
7652
|
-
row.append(index);
|
|
7653
|
-
for (const [columnIndex, column] of source.columns.entries()) {
|
|
7654
|
-
const cell = owner.createElement("td"), input = owner.createElement("textarea");
|
|
7655
|
-
input.rows = 1;
|
|
7656
|
-
input.readOnly = this.stale;
|
|
7657
|
-
input.value = this.rows[rowIndex][column.key] ?? "";
|
|
7658
|
-
input.setAttribute("aria-label", `第 ${rowIndex + 1} 行 · ${column.label}`);
|
|
7659
|
-
input.style.cssText = "min-width:130px;width:160px;resize:vertical;box-sizing:border-box";
|
|
7660
|
-
input.addEventListener("input", () => {
|
|
7661
|
-
this.rows[rowIndex][column.key] = input.value;
|
|
7662
|
-
}, { signal });
|
|
7663
|
-
input.addEventListener("paste", (event) => {
|
|
7664
|
-
const clipboard = event.clipboardData;
|
|
7665
|
-
if (!clipboard?.types.includes("text/plain")) return;
|
|
7666
|
-
const text = clipboard.getData("text/plain");
|
|
7667
|
-
event.preventDefault();
|
|
7668
|
-
this.paste(text, rowIndex, columnIndex);
|
|
7669
|
-
}, { signal });
|
|
7670
|
-
cell.append(input);
|
|
7671
|
-
row.append(cell);
|
|
7672
|
-
}
|
|
7673
|
-
body.append(row);
|
|
7674
|
-
}
|
|
7675
|
-
table.append(body);
|
|
7676
|
-
this.grid.append(table);
|
|
7677
|
-
root.append(info, this.status, tools, this.grid);
|
|
7678
|
-
}
|
|
7679
|
-
/** 粘贴先完整解析并检查矩形容量,失败保留旧矩阵,成功才更新草稿。 */
|
|
7680
|
-
paste(text, startRow, startColumn) {
|
|
7681
|
-
if (this.stale || !this.source) return;
|
|
7682
|
-
try {
|
|
7683
|
-
const matrix = parseTsv(text, {
|
|
7684
|
-
rows: this.source.limit - startRow,
|
|
7685
|
-
columns: this.source.columns.length - startColumn
|
|
7686
|
-
});
|
|
7687
|
-
while (this.rows.length < startRow + matrix.length) this.rows.push({});
|
|
7688
|
-
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;
|
|
7689
|
-
this.message = `已粘贴 ${matrix.length} 行`;
|
|
7690
|
-
this.render();
|
|
7691
|
-
} catch (error) {
|
|
7692
|
-
this.report(error);
|
|
7693
|
-
}
|
|
7999
|
+
disabled,
|
|
8000
|
+
run: () => void this.apply()
|
|
8001
|
+
}]) ?? false;
|
|
7694
8002
|
}
|
|
7695
8003
|
/** 只有显式应用才提交,所有输入继续使用统一字段规范化和后端协议。 */
|
|
7696
|
-
apply() {
|
|
7697
|
-
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();
|
|
7698
8009
|
try {
|
|
8010
|
+
await view.flush();
|
|
8011
|
+
if (this.source !== source || this.view !== view || this.stale || !this.options) return;
|
|
7699
8012
|
const rows = this.source.layout ? this.rows : this.rows.filter((row) => Object.keys(row).length > 0);
|
|
7700
8013
|
if (!rows.some((row) => Object.keys(row).length > 0)) throw Error("请输入需要填报的数据");
|
|
7701
8014
|
this.writing = true;
|
|
@@ -7703,9 +8016,13 @@ var CanvasQuickFillDialog = class {
|
|
|
7703
8016
|
this.close();
|
|
7704
8017
|
this.options?.onApplied?.(result);
|
|
7705
8018
|
} catch (error) {
|
|
7706
|
-
this.report(error);
|
|
8019
|
+
if (this.source === source && this.view === view) this.report(error);
|
|
7707
8020
|
} finally {
|
|
7708
8021
|
this.writing = false;
|
|
8022
|
+
if (this.source === source && this.view === view) {
|
|
8023
|
+
this.submitting = false;
|
|
8024
|
+
this.updateActions();
|
|
8025
|
+
}
|
|
7709
8026
|
}
|
|
7710
8027
|
}
|
|
7711
8028
|
/** 只保留可读错误文字,异常反馈不影响取消与释放。 */
|
|
@@ -8305,17 +8622,19 @@ function attachCanvasTextInput(context, options) {
|
|
|
8305
8622
|
throw error;
|
|
8306
8623
|
}
|
|
8307
8624
|
}
|
|
8308
|
-
// src/adapters/browser/input/validation/
|
|
8309
|
-
/** @file 校验批注的字段描边和页边编号,只读取当前布局,不占正文空间。 */
|
|
8310
|
-
/** 同一字段的多条规则共用编号,重复行以实际业务路径区分。 */
|
|
8625
|
+
// src/adapters/browser/input/validation/validation-issue-key.ts
|
|
8311
8626
|
function validationIssueKey(issue) {
|
|
8312
8627
|
return JSON.stringify([issue.fieldId ?? issue.regionId ?? issue.code, issue.valuePath]);
|
|
8313
8628
|
}
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8629
|
+
// src/adapters/browser/input/validation/CanvasValidationComments.ts
|
|
8630
|
+
/** @file 纸张右侧的字段校验卡片,只投影当前诊断与已绘制几何,不保存填写值。 */
|
|
8631
|
+
/** 每个字段发生一张卡片,多个错误合并展示;当前输入字段让位于贴近提示。 */
|
|
8632
|
+
var CanvasValidationComments = class {
|
|
8317
8633
|
options;
|
|
8318
8634
|
navigate;
|
|
8635
|
+
layers = [];
|
|
8636
|
+
lifetime;
|
|
8637
|
+
rendered;
|
|
8319
8638
|
constructor(options, navigate) {
|
|
8320
8639
|
this.options = {
|
|
8321
8640
|
pageHost: options.pageHost,
|
|
@@ -8325,124 +8644,164 @@ var CanvasValidationMarks = class {
|
|
|
8325
8644
|
this.navigate = navigate;
|
|
8326
8645
|
}
|
|
8327
8646
|
refresh(report, activeKey, inputFocus, focusOnly = false) {
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
const
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
return;
|
|
8334
|
-
}
|
|
8335
|
-
const revision = snapshot.result.version.layoutRevision;
|
|
8336
|
-
const pages = inputScreenPages(pageHost, snapshot);
|
|
8337
|
-
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);
|
|
8338
8652
|
const key = JSON.stringify([
|
|
8653
|
+
snapshot.result.version.layoutRevision,
|
|
8339
8654
|
report.issues,
|
|
8340
8655
|
activeKey,
|
|
8341
8656
|
inputFocus,
|
|
8342
|
-
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
|
+
])
|
|
8343
8665
|
]);
|
|
8344
|
-
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;
|
|
8345
8667
|
this.clear();
|
|
8346
|
-
|
|
8347
|
-
const
|
|
8348
|
-
const
|
|
8668
|
+
this.lifetime = new AbortController();
|
|
8669
|
+
const locations = options.controller.validationLocations(report.issues, report.versions);
|
|
8670
|
+
const groups = /* @__PURE__ */ new Map();
|
|
8349
8671
|
for (const [index, issue] of report.issues.entries()) {
|
|
8350
|
-
const
|
|
8351
|
-
if ((issue.displayOnly || focusOnly) &&
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
const
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
boxSizing: "border-box",
|
|
8382
|
-
pointerEvents: "none",
|
|
8383
|
-
outline: `${active ? 2 : 1}px ${active ? "solid" : "dashed"} ${color}`,
|
|
8384
|
-
outlineOffset: "2px",
|
|
8385
|
-
background: active ? "#fff1f040" : "transparent",
|
|
8386
|
-
borderRadius: "2px",
|
|
8387
|
-
left: `${frame.x / surface.page.width * 100}%`,
|
|
8388
|
-
top: `${frame.y / surface.page.height * 100}%`,
|
|
8389
|
-
width: `${frame.width / surface.page.width * 100}%`,
|
|
8390
|
-
height: `${frame.height / surface.page.height * 100}%`
|
|
8391
|
-
});
|
|
8392
|
-
layer.append(mark);
|
|
8393
|
-
const badgeKey = JSON.stringify([pageId, identity]);
|
|
8394
|
-
if (badges.has(badgeKey)) continue;
|
|
8395
|
-
badges.add(badgeKey);
|
|
8396
|
-
const top = Math.max(frame.y + frame.height / 2 - 10, badgeTops.get(pageId) ?? 0);
|
|
8397
|
-
badgeTops.set(pageId, top + 23);
|
|
8398
|
-
const rightMargin = surface.page.width - surface.page.contentFrame.x - surface.page.contentFrame.width;
|
|
8399
|
-
const badgeLeft = rightMargin >= 28 ? surface.page.width - Math.min(42, rightMargin - 4) : surface.page.width + 6;
|
|
8400
|
-
const badge = owner.createElement("button");
|
|
8401
|
-
badge.type = "button";
|
|
8402
|
-
badge.className = `gct-word-validation-anchor${active ? " is-active" : ""}`;
|
|
8403
|
-
badge.dataset.validationNumber = String(number);
|
|
8404
|
-
badge.textContent = String(number);
|
|
8405
|
-
badge.setAttribute("aria-label", `校验批注 ${number}:${issue.label}`);
|
|
8406
|
-
Object.assign(badge.style, {
|
|
8407
|
-
position: "absolute",
|
|
8408
|
-
pointerEvents: "auto",
|
|
8409
|
-
boxSizing: "border-box",
|
|
8410
|
-
left: `${badgeLeft / surface.page.width * 100}%`,
|
|
8411
|
-
top: `${Math.min(top, surface.page.height - 24) / surface.page.height * 100}%`,
|
|
8412
|
-
width: "20px",
|
|
8413
|
-
height: "20px",
|
|
8414
|
-
padding: "0",
|
|
8415
|
-
borderRadius: "6px",
|
|
8416
|
-
border: `1px solid ${color}`,
|
|
8417
|
-
background: active ? color : "#fff5f5",
|
|
8418
|
-
color: active ? "#fff" : color,
|
|
8419
|
-
font: "600 11px/18px sans-serif",
|
|
8420
|
-
cursor: "pointer"
|
|
8421
|
-
});
|
|
8422
|
-
badge.addEventListener("pointerdown", (event) => {
|
|
8423
|
-
event.preventDefault();
|
|
8424
|
-
event.stopPropagation();
|
|
8425
|
-
badge.focus({ preventScroll: true });
|
|
8426
|
-
this.navigate?.(index);
|
|
8427
|
-
});
|
|
8428
|
-
badge.addEventListener("click", (event) => {
|
|
8429
|
-
if (event.detail === 0) {
|
|
8430
|
-
badge.focus({ preventScroll: true });
|
|
8431
|
-
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
|
|
8432
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`
|
|
8433
8734
|
});
|
|
8434
|
-
|
|
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);
|
|
8435
8740
|
}
|
|
8436
8741
|
}
|
|
8437
8742
|
this.rendered = {
|
|
8438
|
-
revision,
|
|
8439
8743
|
key,
|
|
8440
8744
|
canvases
|
|
8441
8745
|
};
|
|
8442
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
|
+
}
|
|
8443
8800
|
clear() {
|
|
8444
|
-
|
|
8445
|
-
this.
|
|
8801
|
+
this.lifetime?.abort();
|
|
8802
|
+
this.lifetime = void 0;
|
|
8803
|
+
for (const layer of this.layers) layer.remove();
|
|
8804
|
+
this.layers.length = 0;
|
|
8446
8805
|
this.rendered = void 0;
|
|
8447
8806
|
}
|
|
8448
8807
|
dispose() {
|
|
@@ -8452,7 +8811,7 @@ var CanvasValidationMarks = class {
|
|
|
8452
8811
|
}
|
|
8453
8812
|
};
|
|
8454
8813
|
// src/adapters/browser/input/validation/CanvasValidationPanel.ts
|
|
8455
|
-
/** @file
|
|
8814
|
+
/** @file 校验列表与纸张右侧批注只借用当前视图和轻量诊断。 */
|
|
8456
8815
|
/** 检查仅保存轻量问题;换数据、关闭和重检会立即撤掉旧标记。 */
|
|
8457
8816
|
var CanvasValidationPanel = class {
|
|
8458
8817
|
/** 关闭后解除宿主、服务和输入能力。 */
|
|
@@ -8467,22 +8826,24 @@ var CanvasValidationPanel = class {
|
|
|
8467
8826
|
report;
|
|
8468
8827
|
/** 只读详情跟随外部数据,保留当前展示校验策略。 */
|
|
8469
8828
|
displayEnabled = false;
|
|
8470
|
-
/**
|
|
8471
|
-
|
|
8829
|
+
/** 其他批注查看期间让出连线和卡片,报告仍可通过校验列表读取。 */
|
|
8830
|
+
commentsVisible = true;
|
|
8472
8831
|
/** 同一批同步写入只排一次展示校验。 */
|
|
8473
8832
|
displayQueued = false;
|
|
8474
|
-
|
|
8833
|
+
comments;
|
|
8475
8834
|
/** 取消后清空会话变更监听。 */
|
|
8476
8835
|
unsubscribe;
|
|
8477
8836
|
unsubscribeFeedback;
|
|
8478
8837
|
live = false;
|
|
8479
8838
|
checking = false;
|
|
8480
|
-
/**
|
|
8839
|
+
/** 点击只读异常字段、定位入口或手动检查才能打开独立清单。 */
|
|
8481
8840
|
opened = false;
|
|
8482
8841
|
checkMode = "submit";
|
|
8483
8842
|
inputValidation;
|
|
8484
8843
|
inputFocus;
|
|
8485
8844
|
activeKey;
|
|
8845
|
+
/** 查看卡片时忽略原编辑选区的重复通知,真正重新点选字段后再跟随编辑。 */
|
|
8846
|
+
viewedSelection;
|
|
8486
8847
|
/** 只读异常的查看焦点独立于编辑选区,不激活输入或业务弹框。 */
|
|
8487
8848
|
focusedDisplay = false;
|
|
8488
8849
|
unsubscribeSelection;
|
|
@@ -8490,7 +8851,7 @@ var CanvasValidationPanel = class {
|
|
|
8490
8851
|
constructor(handle, options) {
|
|
8491
8852
|
this.handle = handle;
|
|
8492
8853
|
this.options = options;
|
|
8493
|
-
this.
|
|
8854
|
+
this.comments = new CanvasValidationComments(options, (index) => void this.navigate(index, false));
|
|
8494
8855
|
options.host.hidden = true;
|
|
8495
8856
|
options.host.classList.add("gct-word-validation-panel");
|
|
8496
8857
|
options.host.addEventListener("click", (event) => {
|
|
@@ -8523,10 +8884,7 @@ var CanvasValidationPanel = class {
|
|
|
8523
8884
|
this.opened = false;
|
|
8524
8885
|
this.clear();
|
|
8525
8886
|
if (change.kind === "environment") this.displayEnabled = false;
|
|
8526
|
-
} else if (this.report)
|
|
8527
|
-
if (change.kind === "data" && options.feedback && !this.displayEnabled) this.clearMarks();
|
|
8528
|
-
else this.clear(change.kind === "data" && !this.displayEnabled ? "填写数据已变化,请重新校验。" : void 0);
|
|
8529
|
-
}
|
|
8887
|
+
} else if (this.report && (change.kind !== "data" || !options.feedback || this.displayEnabled)) this.clear(change.kind === "data" && !this.displayEnabled ? "填写数据已变化,请重新校验。" : void 0);
|
|
8530
8888
|
if (this.displayEnabled) this.queueDisplay();
|
|
8531
8889
|
else if (options.feedback) queueMicrotask(() => this.showLive());
|
|
8532
8890
|
});
|
|
@@ -8566,13 +8924,14 @@ var CanvasValidationPanel = class {
|
|
|
8566
8924
|
const matches = (issue) => issue.fieldId === input.fieldId && issue.valuePath === input.valuePath;
|
|
8567
8925
|
const first = issues.findIndex(matches);
|
|
8568
8926
|
for (let index = issues.length - 1; index >= 0; index--) if (matches(issues[index])) issues.splice(index, 1);
|
|
8569
|
-
|
|
8927
|
+
const messages = input.messages ?? (input.message ? [input.message] : []);
|
|
8928
|
+
issues.splice(first < 0 ? issues.length : first, 0, ...messages.map((message) => ({
|
|
8570
8929
|
...input,
|
|
8571
8930
|
stage: "fields",
|
|
8572
8931
|
kind: "value",
|
|
8573
8932
|
code: "field_input_draft",
|
|
8574
|
-
message
|
|
8575
|
-
});
|
|
8933
|
+
message
|
|
8934
|
+
})));
|
|
8576
8935
|
}
|
|
8577
8936
|
const report = {
|
|
8578
8937
|
...stored,
|
|
@@ -8584,7 +8943,7 @@ var CanvasValidationPanel = class {
|
|
|
8584
8943
|
this.refresh();
|
|
8585
8944
|
return;
|
|
8586
8945
|
}
|
|
8587
|
-
this.
|
|
8946
|
+
this.clearComments();
|
|
8588
8947
|
this.live = true;
|
|
8589
8948
|
if (!report.issues.length) {
|
|
8590
8949
|
this.clear();
|
|
@@ -8601,12 +8960,14 @@ var CanvasValidationPanel = class {
|
|
|
8601
8960
|
this.live = true;
|
|
8602
8961
|
this.showLive();
|
|
8603
8962
|
}
|
|
8604
|
-
/**
|
|
8963
|
+
/** 当前字段聚焦后使用贴近提示,其他字段的错误卡片继续显示。 */
|
|
8605
8964
|
setInputFocus(field) {
|
|
8606
8965
|
if (JSON.stringify(this.inputFocus) === JSON.stringify(field)) return;
|
|
8607
8966
|
this.inputFocus = field;
|
|
8608
8967
|
if (!this.options) return;
|
|
8609
8968
|
if (field) {
|
|
8969
|
+
this.viewedSelection = void 0;
|
|
8970
|
+
this.syncActiveField();
|
|
8610
8971
|
this.refresh();
|
|
8611
8972
|
if (this.opened) this.renderEditing();
|
|
8612
8973
|
} else if (this.report && !this.live && this.versionCurrent(this.report)) {
|
|
@@ -8688,13 +9049,13 @@ var CanvasValidationPanel = class {
|
|
|
8688
9049
|
/** Canvas 完成绘制后再映射标记,不触发排版、数据写入或整页重绘。 */
|
|
8689
9050
|
refresh() {
|
|
8690
9051
|
const options = this.options, report = this.report;
|
|
8691
|
-
if (!options || !report || !report.issues.length || !this.
|
|
8692
|
-
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);
|
|
8693
9054
|
}
|
|
8694
9055
|
/** 只按当前已绘制发生查看展示异常,空白或其他字段的点击收起这份按需详情。 */
|
|
8695
9056
|
inspectPointer(request) {
|
|
8696
9057
|
const options = this.options, report = this.report;
|
|
8697
|
-
if (!options || !report || !this.
|
|
9058
|
+
if (!options || !report || !this.commentsVisible || !this.versionCurrent(report)) return;
|
|
8698
9059
|
const candidates = report.issues.filter((issue) => issue.displayOnly);
|
|
8699
9060
|
const locations = options.controller.validationLocations(candidates, report.versions);
|
|
8700
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));
|
|
@@ -8705,12 +9066,12 @@ var CanvasValidationPanel = class {
|
|
|
8705
9066
|
this.renderPanel(report);
|
|
8706
9067
|
this.refresh();
|
|
8707
9068
|
}
|
|
8708
|
-
/**
|
|
9069
|
+
/** 批注和校验使用同一画布,只展示当前操作所需的连线和卡片。 */
|
|
8709
9070
|
setMarksVisible(visible) {
|
|
8710
|
-
if (visible === this.
|
|
8711
|
-
this.
|
|
9071
|
+
if (visible === this.commentsVisible) return;
|
|
9072
|
+
this.commentsVisible = visible;
|
|
8712
9073
|
if (visible) this.refresh();
|
|
8713
|
-
else this.
|
|
9074
|
+
else this.clearComments();
|
|
8714
9075
|
}
|
|
8715
9076
|
/** 宿主的校验清单也使用当前稳定位置。 */
|
|
8716
9077
|
async navigatePath(path, display) {
|
|
@@ -8722,17 +9083,22 @@ var CanvasValidationPanel = class {
|
|
|
8722
9083
|
if (index >= 0) await this.navigate(index);
|
|
8723
9084
|
}
|
|
8724
9085
|
/** 使用列表中的精确发生跳转,不自动打开签署或选择弹框。 */
|
|
8725
|
-
async navigate(index,
|
|
9086
|
+
async navigate(index, showPanel = true) {
|
|
8726
9087
|
const options = this.options, live = this.live;
|
|
8727
9088
|
let report = this.report, issue = report?.issues[index];
|
|
8728
9089
|
if (!options || !report || !issue || !this.versionCurrent(report)) return;
|
|
9090
|
+
this.viewedSelection = showPanel ? void 0 : options.controller.getState().selection;
|
|
8729
9091
|
this.activeKey = validationIssueKey(issue);
|
|
8730
|
-
this.opened = true;
|
|
9092
|
+
if (showPanel) this.opened = true;
|
|
8731
9093
|
this.renderPanel(report);
|
|
8732
9094
|
this.updateActiveCards();
|
|
8733
9095
|
this.refresh();
|
|
9096
|
+
if (!showPanel) {
|
|
9097
|
+
this.revealIssue(issue, report, false);
|
|
9098
|
+
return;
|
|
9099
|
+
}
|
|
8734
9100
|
if (issue.code === "field_input_draft") {
|
|
8735
|
-
|
|
9101
|
+
options.focusInput?.();
|
|
8736
9102
|
return;
|
|
8737
9103
|
}
|
|
8738
9104
|
const requested = issue;
|
|
@@ -8751,16 +9117,7 @@ var CanvasValidationPanel = class {
|
|
|
8751
9117
|
this.renderPanel(report);
|
|
8752
9118
|
}
|
|
8753
9119
|
if (!committed || !this.current(task) || this.report !== report || !this.versionCurrent(report)) return;
|
|
8754
|
-
|
|
8755
|
-
if (!snapshot) return;
|
|
8756
|
-
for (const location of options.controller.validationLocations([issue], report.versions).get(issue) ?? []) {
|
|
8757
|
-
const page = inputPageLocation(options.pageHost, snapshot, location.pageId);
|
|
8758
|
-
if (!page) continue;
|
|
8759
|
-
revealInputRect(options.pageHost, inputScreenRect(location.frame, page));
|
|
8760
|
-
if (!this.displayEnabled && !issue.displayOnly && issue.fieldId && location.instanceKey) options.controller.selectField(issue.fieldId, location.instanceKey);
|
|
8761
|
-
return;
|
|
8762
|
-
}
|
|
8763
|
-
this.setStatus("当前画面中没有可定位的对应位置。");
|
|
9120
|
+
this.revealIssue(issue, report, true);
|
|
8764
9121
|
} catch (error) {
|
|
8765
9122
|
if (this.current(task)) {
|
|
8766
9123
|
this.setStatus(wordPanelErrorText(error, "当前无法定位,请重试。"));
|
|
@@ -8770,6 +9127,21 @@ var CanvasValidationPanel = class {
|
|
|
8770
9127
|
this.end(task);
|
|
8771
9128
|
}
|
|
8772
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
|
+
}
|
|
8773
9145
|
/** 模型和数据必须仍与校验一致,字体和缩放重绘使用新几何。 */
|
|
8774
9146
|
versionCurrent(report) {
|
|
8775
9147
|
const handle = this.handle;
|
|
@@ -8832,7 +9204,7 @@ var CanvasValidationPanel = class {
|
|
|
8832
9204
|
this.setStatus(title);
|
|
8833
9205
|
const note = owner.createElement("p");
|
|
8834
9206
|
note.className = "gct-word-validation-note";
|
|
8835
|
-
note.textContent = this.focusedDisplay ? "只读异常仅展示,不影响提交。" : this.live ? "
|
|
9207
|
+
note.textContent = this.focusedDisplay ? "只读异常仅展示,不影响提交。" : this.live ? "错误卡片与字段通过连线对应,点击可定位字段。" : this.checkMode === "save" ? "仅检查草稿能否保存;未修正的字段问题继续保留,正式提交仍需通过完整校验。" : "提交前完整校验,包含必填、字段和业务规则。";
|
|
8836
9208
|
if (displayed && !this.focusedDisplay) note.textContent += "只读异常仅展示,不影响提交。";
|
|
8837
9209
|
host.append(note);
|
|
8838
9210
|
if (report.issues.length) host.append(list);
|
|
@@ -8870,6 +9242,10 @@ var CanvasValidationPanel = class {
|
|
|
8870
9242
|
const options = this.options, report = this.report;
|
|
8871
9243
|
if (!options || !report || this.focusedDisplay) return;
|
|
8872
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
|
+
}
|
|
8873
9249
|
const state = selection?.kind === "field" ? options.controller.getFieldTextInput() : void 0;
|
|
8874
9250
|
let issue = report.issues.find((item) => state && item.fieldId === state.selection.fieldId && item.valuePath === state.validationPath);
|
|
8875
9251
|
if (!state && selection?.kind === "field") {
|
|
@@ -8914,7 +9290,7 @@ var CanvasValidationPanel = class {
|
|
|
8914
9290
|
/** 清空列表和当前几何。 */
|
|
8915
9291
|
clear(text) {
|
|
8916
9292
|
this.report = void 0;
|
|
8917
|
-
this.
|
|
9293
|
+
this.clearComments();
|
|
8918
9294
|
const host = this.options?.host;
|
|
8919
9295
|
if (!host) return;
|
|
8920
9296
|
host.replaceChildren();
|
|
@@ -8925,8 +9301,8 @@ var CanvasValidationPanel = class {
|
|
|
8925
9301
|
}
|
|
8926
9302
|
}
|
|
8927
9303
|
/** 移除各页透明层,释放页面节点。 */
|
|
8928
|
-
|
|
8929
|
-
this.
|
|
9304
|
+
clearComments() {
|
|
9305
|
+
this.comments.clear();
|
|
8930
9306
|
}
|
|
8931
9307
|
/** 同时最多有一次用户请求。 */
|
|
8932
9308
|
begin() {
|
|
@@ -8956,9 +9332,10 @@ var CanvasValidationPanel = class {
|
|
|
8956
9332
|
this.inputValidation = void 0;
|
|
8957
9333
|
this.inputFocus = void 0;
|
|
8958
9334
|
this.focusedDisplay = false;
|
|
9335
|
+
this.viewedSelection = void 0;
|
|
8959
9336
|
this.opened = false;
|
|
8960
9337
|
this.clear();
|
|
8961
|
-
this.
|
|
9338
|
+
this.comments.dispose();
|
|
8962
9339
|
this.options = void 0;
|
|
8963
9340
|
this.handle = void 0;
|
|
8964
9341
|
}
|
|
@@ -12372,13 +12749,6 @@ var CanvasFieldCatalogPanel = class {
|
|
|
12372
12749
|
const label = owner.createElement("span");
|
|
12373
12750
|
button.type = "button";
|
|
12374
12751
|
button.className = "gct-word-catalog-field";
|
|
12375
|
-
const subModel = field.definition.binding.source.subFieldKey;
|
|
12376
|
-
const scope = subModel ? "子表 " + subModel : "主表";
|
|
12377
|
-
button.title = [
|
|
12378
|
-
field.label,
|
|
12379
|
-
scope,
|
|
12380
|
-
field.description
|
|
12381
|
-
].filter(Boolean).join(" · ");
|
|
12382
12752
|
icon.className = "gct-word-catalog-field-icon iconfont " + catalogFieldIcon(field);
|
|
12383
12753
|
icon.setAttribute("aria-hidden", "true");
|
|
12384
12754
|
label.className = "gct-word-catalog-field-label";
|
|
@@ -13681,8 +14051,8 @@ function attachCanvasMaterialsPanel(context, options) {
|
|
|
13681
14051
|
}
|
|
13682
14052
|
// src/adapters/browser/input/business/tables/table-action-anchors.ts
|
|
13683
14053
|
/** 动态表取每个业务组末格,固定表只取区域首行右上格。 */
|
|
13684
|
-
function tableActionAnchors(
|
|
13685
|
-
return regionActionAnchors(
|
|
14054
|
+
function tableActionAnchors(pages, layout, controller) {
|
|
14055
|
+
return regionActionAnchors(pages, layout, controller.businessTables.list(), (regionId, instanceKey, bounded) => {
|
|
13686
14056
|
let source = controller.businessTables.read(regionId, instanceKey);
|
|
13687
14057
|
if (!source && instanceKey) {
|
|
13688
14058
|
const empty = controller.businessTables.read(regionId);
|
|
@@ -13696,21 +14066,14 @@ function tableActionAnchors(host, layout, controller) {
|
|
|
13696
14066
|
});
|
|
13697
14067
|
}
|
|
13698
14068
|
/** 各领域只提供行准入,几何与真实行身份共用一次投影。 */
|
|
13699
|
-
function regionActionAnchors(
|
|
14069
|
+
function regionActionAnchors(pages, layout, regions, read) {
|
|
13700
14070
|
const snapshot = layout.getCurrentSnapshot();
|
|
13701
14071
|
if (!snapshot) return [];
|
|
13702
14072
|
if (!regions.length) return [];
|
|
13703
14073
|
const targets = [];
|
|
13704
|
-
const
|
|
13705
|
-
|
|
13706
|
-
const topLimit = viewport?.height ? Math.max(0, viewport.top) : 0;
|
|
13707
|
-
const bottomLimit = viewport?.height ? Math.min(view.innerHeight, viewport.bottom) : view.innerHeight;
|
|
13708
|
-
for (const canvas of host.querySelectorAll("canvas[data-page-id]")) {
|
|
13709
|
-
if (canvas.dataset.layoutRevision !== String(snapshot.result.version.layoutRevision)) continue;
|
|
13710
|
-
const page = snapshot.query.getPage(canvas.dataset.pageId ?? "");
|
|
14074
|
+
for (const surface of pages.values()) {
|
|
14075
|
+
const page = snapshot.query.getPage(surface.id);
|
|
13711
14076
|
if (!page) continue;
|
|
13712
|
-
const rect = canvas.getBoundingClientRect();
|
|
13713
|
-
if (!rect.width || !rect.height || rect.bottom < topLimit || rect.top > bottomLimit) continue;
|
|
13714
14077
|
const groups = /* @__PURE__ */ new Map();
|
|
13715
14078
|
function visit(blocks) {
|
|
13716
14079
|
for (const table of blocks) {
|
|
@@ -13744,9 +14107,8 @@ function regionActionAnchors(host, layout, regions, read) {
|
|
|
13744
14107
|
for (const [key, group] of groups) {
|
|
13745
14108
|
const source = read(group.regionId, group.instanceKey, group.bounded);
|
|
13746
14109
|
if (!source) continue;
|
|
13747
|
-
const left =
|
|
13748
|
-
const top =
|
|
13749
|
-
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;
|
|
13750
14112
|
targets.push({
|
|
13751
14113
|
pageId: page.id,
|
|
13752
14114
|
id: page.id + ":" + key,
|
|
@@ -13759,11 +14121,76 @@ function regionActionAnchors(host, layout, regions, read) {
|
|
|
13759
14121
|
}
|
|
13760
14122
|
return targets;
|
|
13761
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
|
+
};
|
|
13762
14188
|
// src/adapters/browser/input/business/tables/CanvasBusinessTableActions.ts
|
|
13763
14189
|
/** @file 填报行旁菜单,复用原生行命令与版本门禁;菜单打开不改变字段选择。 */
|
|
13764
14190
|
var CanvasBusinessTableActions = class {
|
|
13765
14191
|
options;
|
|
13766
14192
|
view;
|
|
14193
|
+
pages = new TableActionPages();
|
|
13767
14194
|
quick;
|
|
13768
14195
|
scan;
|
|
13769
14196
|
targets = [];
|
|
@@ -13781,6 +14208,7 @@ var CanvasBusinessTableActions = class {
|
|
|
13781
14208
|
this.scan = new CanvasTableScanDialog(options);
|
|
13782
14209
|
this.view = options.renderActions({
|
|
13783
14210
|
container: options.host,
|
|
14211
|
+
pageHost: (id) => this.pages.host(id),
|
|
13784
14212
|
state: {
|
|
13785
14213
|
anchors: [],
|
|
13786
14214
|
busy: false
|
|
@@ -13795,12 +14223,12 @@ var CanvasBusinessTableActions = class {
|
|
|
13795
14223
|
});
|
|
13796
14224
|
this.unsubscribe = options.controller.subscribe(() => this.refresh());
|
|
13797
14225
|
const owner = options.host.ownerDocument, signal = this.lifetime.signal;
|
|
13798
|
-
owner.addEventListener("scroll", () => this.
|
|
14226
|
+
owner.addEventListener("scroll", () => this.refreshGeometry(), {
|
|
13799
14227
|
capture: true,
|
|
13800
14228
|
passive: true,
|
|
13801
14229
|
signal
|
|
13802
14230
|
});
|
|
13803
|
-
owner.defaultView?.addEventListener("resize", () => this.
|
|
14231
|
+
owner.defaultView?.addEventListener("resize", () => this.refreshGeometry(), { signal });
|
|
13804
14232
|
this.refresh();
|
|
13805
14233
|
}
|
|
13806
14234
|
refresh() {
|
|
@@ -13818,7 +14246,8 @@ var CanvasBusinessTableActions = class {
|
|
|
13818
14246
|
if (!snapshot) return;
|
|
13819
14247
|
const selectedCanvas = this.selected && [...options.canvasHost.querySelectorAll("canvas[data-page-id]")].find((canvas) => canvas.dataset.pageId === this.selected.pageId);
|
|
13820
14248
|
if (selectedCanvas && selectedCanvas.dataset.layoutRevision !== String(snapshot.result.version.layoutRevision)) return;
|
|
13821
|
-
this.
|
|
14249
|
+
this.pages.update(options.canvasHost, options.layout);
|
|
14250
|
+
this.targets = tableActionAnchors(this.pages, options.layout, options.controller);
|
|
13822
14251
|
if (this.confirming && !isEqual(options.controller.businessTables.read(this.confirming.regionId, this.confirming.anchorInstanceKey), this.confirming)) this.cancelConfirmation();
|
|
13823
14252
|
if (this.selected) {
|
|
13824
14253
|
const next = this.targets.find((item) => item.id === this.selected.id);
|
|
@@ -13831,6 +14260,18 @@ var CanvasBusinessTableActions = class {
|
|
|
13831
14260
|
}
|
|
13832
14261
|
this.render();
|
|
13833
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
|
+
}
|
|
13834
14275
|
canSubmit() {
|
|
13835
14276
|
return !this.confirmation && (this.quick?.canSubmit() ?? true) && (this.scan?.canSubmit() ?? true);
|
|
13836
14277
|
}
|
|
@@ -13842,6 +14283,7 @@ var CanvasBusinessTableActions = class {
|
|
|
13842
14283
|
this.quick?.dispose();
|
|
13843
14284
|
this.scan?.dispose();
|
|
13844
14285
|
this.view?.dispose();
|
|
14286
|
+
this.pages.dispose();
|
|
13845
14287
|
this.options = void 0;
|
|
13846
14288
|
this.view = void 0;
|
|
13847
14289
|
this.quick = void 0;
|
|
@@ -13864,9 +14306,11 @@ var CanvasBusinessTableActions = class {
|
|
|
13864
14306
|
await options.controller.businessTables.whenSettled(task.signal);
|
|
13865
14307
|
await waitForAbortable(new Promise((resolve) => options.host.ownerDocument.defaultView.requestAnimationFrame(() => resolve())), task.signal, () => Error("业务表操作已取消"));
|
|
13866
14308
|
if (task.signal.aborted || this.options !== options) return;
|
|
13867
|
-
this.
|
|
14309
|
+
this.pages.update(options.canvasHost, options.layout);
|
|
14310
|
+
this.targets = tableActionAnchors(this.pages, options.layout, options.controller);
|
|
13868
14311
|
this.selected = this.targets.find((item) => item.id === id);
|
|
13869
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;
|
|
13870
14314
|
} catch (error) {
|
|
13871
14315
|
if (!task.signal.aborted && this.options === options) options.onError?.(error);
|
|
13872
14316
|
} finally {
|
|
@@ -13886,8 +14330,9 @@ var CanvasBusinessTableActions = class {
|
|
|
13886
14330
|
const quick = source && options.controller.businessTables.readQuickFill(source.regionId, source.anchorInstanceKey);
|
|
13887
14331
|
const scan = source && options.controller.businessTables.readScan(source.regionId, source.anchorInstanceKey);
|
|
13888
14332
|
this.view?.update({
|
|
13889
|
-
anchors: this.targets.map(({ id, label, left, top }) => ({
|
|
14333
|
+
anchors: this.targets.map(({ id, pageId, label, left, top }) => ({
|
|
13890
14334
|
id,
|
|
14335
|
+
pageId,
|
|
13891
14336
|
label,
|
|
13892
14337
|
left,
|
|
13893
14338
|
top
|
|
@@ -13996,6 +14441,7 @@ function sameRowData(a, b) {
|
|
|
13996
14441
|
var CanvasMaterialTableActions = class {
|
|
13997
14442
|
options;
|
|
13998
14443
|
view;
|
|
14444
|
+
pages = new TableActionPages();
|
|
13999
14445
|
targets = [];
|
|
14000
14446
|
selected;
|
|
14001
14447
|
task;
|
|
@@ -14011,6 +14457,7 @@ var CanvasMaterialTableActions = class {
|
|
|
14011
14457
|
this.options = options;
|
|
14012
14458
|
this.view = options.renderActions({
|
|
14013
14459
|
container: options.host,
|
|
14460
|
+
pageHost: (id) => this.pages.host(id),
|
|
14014
14461
|
state: {
|
|
14015
14462
|
anchors: [],
|
|
14016
14463
|
busy: false
|
|
@@ -14024,12 +14471,12 @@ var CanvasMaterialTableActions = class {
|
|
|
14024
14471
|
}
|
|
14025
14472
|
});
|
|
14026
14473
|
this.unsubscribe = options.controller.subscribe(() => this.refresh());
|
|
14027
|
-
options.host.ownerDocument.addEventListener("scroll", () => this.
|
|
14474
|
+
options.host.ownerDocument.addEventListener("scroll", () => this.refreshGeometry(), {
|
|
14028
14475
|
capture: true,
|
|
14029
14476
|
passive: true,
|
|
14030
14477
|
signal: this.lifetime.signal
|
|
14031
14478
|
});
|
|
14032
|
-
options.host.ownerDocument.defaultView?.addEventListener("resize", () => this.
|
|
14479
|
+
options.host.ownerDocument.defaultView?.addEventListener("resize", () => this.refreshGeometry(), { signal: this.lifetime.signal });
|
|
14033
14480
|
this.refresh();
|
|
14034
14481
|
}
|
|
14035
14482
|
canSubmit() {
|
|
@@ -14061,12 +14508,25 @@ var CanvasMaterialTableActions = class {
|
|
|
14061
14508
|
}
|
|
14062
14509
|
this.render();
|
|
14063
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
|
+
}
|
|
14064
14523
|
dispose() {
|
|
14065
14524
|
this.lifetime.abort();
|
|
14066
14525
|
this.task?.abort();
|
|
14067
14526
|
this.unsubscribe?.();
|
|
14068
14527
|
this.closeDialog();
|
|
14069
14528
|
this.view?.dispose();
|
|
14529
|
+
this.pages.dispose();
|
|
14070
14530
|
this.options = void 0;
|
|
14071
14531
|
this.view = void 0;
|
|
14072
14532
|
this.selected = void 0;
|
|
@@ -14075,7 +14535,8 @@ var CanvasMaterialTableActions = class {
|
|
|
14075
14535
|
}
|
|
14076
14536
|
readTargets() {
|
|
14077
14537
|
const options = this.options;
|
|
14078
|
-
|
|
14538
|
+
this.pages.update(options.canvasHost, options.layout);
|
|
14539
|
+
return regionActionAnchors(this.pages, options.layout, options.controller.materials.list(), (id, anchor) => {
|
|
14079
14540
|
const source = options.controller.materials.read(id, anchor);
|
|
14080
14541
|
return source?.editable && Object.values(source.allowed).some(Boolean) ? source : void 0;
|
|
14081
14542
|
});
|
|
@@ -14099,6 +14560,7 @@ var CanvasMaterialTableActions = class {
|
|
|
14099
14560
|
if (!await this.settle(task)) return;
|
|
14100
14561
|
this.targets = this.readTargets();
|
|
14101
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;
|
|
14102
14564
|
} catch (error) {
|
|
14103
14565
|
if (!task.signal.aborted && this.options === options) this.report(error);
|
|
14104
14566
|
} finally {
|
|
@@ -14115,8 +14577,9 @@ var CanvasMaterialTableActions = class {
|
|
|
14115
14577
|
render() {
|
|
14116
14578
|
const source = this.selected?.source;
|
|
14117
14579
|
this.view?.update({
|
|
14118
|
-
anchors: this.targets.map(({ id, label, left, top }) => ({
|
|
14580
|
+
anchors: this.targets.map(({ id, pageId, label, left, top }) => ({
|
|
14119
14581
|
id,
|
|
14582
|
+
pageId,
|
|
14120
14583
|
label,
|
|
14121
14584
|
left,
|
|
14122
14585
|
top
|
|
@@ -14261,6 +14724,6 @@ var CanvasMaterialTableActions = class {
|
|
|
14261
14724
|
function sameRow(current, previous) {
|
|
14262
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);
|
|
14263
14726
|
}
|
|
14264
|
-
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 };
|
|
14265
14728
|
|
|
14266
|
-
//# sourceMappingURL=browser-
|
|
14729
|
+
//# sourceMappingURL=browser-DkEIriBA.js.map
|