@gct-paas/word 0.1.47-beta.4 → 0.1.47-beta.6
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.
|
@@ -3,6 +3,7 @@ import { Doc } from '../../view/Doc';
|
|
|
3
3
|
import { Wr, Wp, Wtbl, Wtr, Wtc } from '../../model/document';
|
|
4
4
|
import { RawElement } from '../../model/types/raw';
|
|
5
5
|
import { CursorManager } from '../../cursor/CursorManager';
|
|
6
|
+
import { LayoutNode } from '../../view/base/LayoutNode';
|
|
6
7
|
export declare const SelectionMode: {
|
|
7
8
|
readonly PP: "PP";
|
|
8
9
|
readonly PTr: "PTr";
|
|
@@ -209,5 +210,7 @@ export declare abstract class CommandBase<T extends CommandType = CommandType> i
|
|
|
209
210
|
modelIndex: number;
|
|
210
211
|
modelParent: Wp;
|
|
211
212
|
} | undefined;
|
|
213
|
+
/** 设计态删除字段组件后,清理 DataManager 中该字段的 defaults / rawData / 依赖 */
|
|
214
|
+
protected cleanupDesignFieldBinding(run?: LayoutNode): void;
|
|
212
215
|
}
|
|
213
216
|
export {};
|
|
@@ -290,6 +290,18 @@ export declare class DataManager {
|
|
|
290
290
|
* 获取父路径
|
|
291
291
|
*/
|
|
292
292
|
private getParentPath;
|
|
293
|
+
/**
|
|
294
|
+
* 设计态删除字段后,清理该字段在 DataManager 中的绑定数据
|
|
295
|
+
* @param designValuePath 设计时 valuePath(可含 [n] / [n_y][n_x] 通配符)
|
|
296
|
+
* @param runtimeValuePath 版面解析后的具体路径(可选)
|
|
297
|
+
*/
|
|
298
|
+
removeFieldBindingData(designValuePath: JsonPath, runtimeValuePath?: JsonPath): void;
|
|
299
|
+
/** 收集与字段绑定相关的路径(含 value / label / href 及通配符变体) */
|
|
300
|
+
private collectFieldBindingPaths;
|
|
301
|
+
/** 收集可从 rawData 删除的具体路径(跳过含通配符的设计路径) */
|
|
302
|
+
private collectConcreteRawDataPaths;
|
|
303
|
+
/** 移除字段注册的组件依赖 */
|
|
304
|
+
private removeFieldDependencies;
|
|
293
305
|
/**
|
|
294
306
|
* 设置默认值
|
|
295
307
|
* @param path jsonpath 路径 (支持 [n] 数组索引和 [n] 通配符)
|
package/dist/index.es.js
CHANGED
|
@@ -31535,6 +31535,14 @@ class CommandBase {
|
|
|
31535
31535
|
modelParent: wp
|
|
31536
31536
|
};
|
|
31537
31537
|
}
|
|
31538
|
+
/** 设计态删除字段组件后,清理 DataManager 中该字段的 defaults / rawData / 依赖 */
|
|
31539
|
+
cleanupDesignFieldBinding(run) {
|
|
31540
|
+
if (!run?.isWidgetRun) return;
|
|
31541
|
+
const textWidget = run;
|
|
31542
|
+
const designValuePath = textWidget.widgetMeta?.field?.valuePath;
|
|
31543
|
+
if (!designValuePath) return;
|
|
31544
|
+
this.doc.dataManager.removeFieldBindingData(designValuePath, textWidget.valuePath);
|
|
31545
|
+
}
|
|
31538
31546
|
}
|
|
31539
31547
|
class Backspace extends CommandBase {
|
|
31540
31548
|
constructor(doc, payload) {
|
|
@@ -31730,6 +31738,7 @@ class Backspace extends CommandBase {
|
|
|
31730
31738
|
const wrPrev = modelWr.getPrev();
|
|
31731
31739
|
const wrNext = modelWr.getNext();
|
|
31732
31740
|
modelWr.remove();
|
|
31741
|
+
this.cleanupDesignFieldBinding(run);
|
|
31733
31742
|
return this.buildResultAfterEmpty(wrPrev, wrNext, modelWp, run);
|
|
31734
31743
|
}
|
|
31735
31744
|
if (position === -1) {
|
|
@@ -32150,6 +32159,7 @@ class Delete extends CommandBase {
|
|
|
32150
32159
|
return null;
|
|
32151
32160
|
}
|
|
32152
32161
|
modelWr.remove();
|
|
32162
|
+
this.cleanupDesignFieldBinding(run);
|
|
32153
32163
|
const wrPrev = modelWr.getPrev();
|
|
32154
32164
|
const wrNext = modelWr.getNext();
|
|
32155
32165
|
return this.buildResultAfterEmpty(wrPrev, wrNext, modelWp);
|
|
@@ -49856,6 +49866,78 @@ class DataManager {
|
|
|
49856
49866
|
const lastSeparatorIndex = Math.max(lastDotIndex, lastBracketIndex);
|
|
49857
49867
|
return path2.substring(0, lastSeparatorIndex);
|
|
49858
49868
|
}
|
|
49869
|
+
/**
|
|
49870
|
+
* 设计态删除字段后,清理该字段在 DataManager 中的绑定数据
|
|
49871
|
+
* @param designValuePath 设计时 valuePath(可含 [n] / [n_y][n_x] 通配符)
|
|
49872
|
+
* @param runtimeValuePath 版面解析后的具体路径(可选)
|
|
49873
|
+
*/
|
|
49874
|
+
removeFieldBindingData(designValuePath, runtimeValuePath) {
|
|
49875
|
+
if (!designValuePath) return;
|
|
49876
|
+
const bindingPaths = this.collectFieldBindingPaths(designValuePath);
|
|
49877
|
+
for (const path2 of bindingPaths) {
|
|
49878
|
+
this.defaults.delete(path2);
|
|
49879
|
+
this.fieldRuntimeConfigByPath.delete(path2);
|
|
49880
|
+
this.subscriptions.delete(path2);
|
|
49881
|
+
}
|
|
49882
|
+
for (const path2 of this.collectConcreteRawDataPaths(designValuePath, runtimeValuePath)) {
|
|
49883
|
+
this.delete(path2);
|
|
49884
|
+
}
|
|
49885
|
+
this.removeFieldDependencies(designValuePath);
|
|
49886
|
+
}
|
|
49887
|
+
/** 收集与字段绑定相关的路径(含 value / label / href 及通配符变体) */
|
|
49888
|
+
collectFieldBindingPaths(designValuePath) {
|
|
49889
|
+
const bases = [
|
|
49890
|
+
designValuePath,
|
|
49891
|
+
getLabelPath(designValuePath),
|
|
49892
|
+
getHrefPath(designValuePath)
|
|
49893
|
+
];
|
|
49894
|
+
const wildcardKeys = new Set(bases.map((path2) => this.convertPathToWildcard(path2)));
|
|
49895
|
+
const result = new Set(bases);
|
|
49896
|
+
const scanTargets = [
|
|
49897
|
+
...this.defaults.keys(),
|
|
49898
|
+
...this.fieldRuntimeConfigByPath.keys(),
|
|
49899
|
+
...this.subscriptions.keys()
|
|
49900
|
+
];
|
|
49901
|
+
for (const path2 of scanTargets) {
|
|
49902
|
+
if (wildcardKeys.has(this.convertPathToWildcard(path2))) {
|
|
49903
|
+
result.add(path2);
|
|
49904
|
+
}
|
|
49905
|
+
}
|
|
49906
|
+
return result;
|
|
49907
|
+
}
|
|
49908
|
+
/** 收集可从 rawData 删除的具体路径(跳过含通配符的设计路径) */
|
|
49909
|
+
collectConcreteRawDataPaths(designValuePath, runtimeValuePath) {
|
|
49910
|
+
const paths = /* @__PURE__ */ new Set();
|
|
49911
|
+
for (const path2 of [designValuePath, runtimeValuePath]) {
|
|
49912
|
+
if (!path2 || path2.includes("[n")) continue;
|
|
49913
|
+
paths.add(path2);
|
|
49914
|
+
paths.add(getLabelPath(path2));
|
|
49915
|
+
paths.add(getHrefPath(path2));
|
|
49916
|
+
}
|
|
49917
|
+
return [...paths];
|
|
49918
|
+
}
|
|
49919
|
+
/** 移除字段注册的组件依赖 */
|
|
49920
|
+
removeFieldDependencies(designValuePath) {
|
|
49921
|
+
const wildcardKeys = new Set(
|
|
49922
|
+
[designValuePath, getLabelPath(designValuePath), getHrefPath(designValuePath)].map(
|
|
49923
|
+
(path2) => this.convertPathToWildcard(path2)
|
|
49924
|
+
)
|
|
49925
|
+
);
|
|
49926
|
+
const nodes = this.collectDepNodes();
|
|
49927
|
+
const removedKeys = /* @__PURE__ */ new Set();
|
|
49928
|
+
const remaining = [];
|
|
49929
|
+
for (const node of nodes.values()) {
|
|
49930
|
+
if (wildcardKeys.has(this.convertPathToWildcard(node.targetPath))) {
|
|
49931
|
+
removedKeys.add(node.key);
|
|
49932
|
+
continue;
|
|
49933
|
+
}
|
|
49934
|
+
remaining.push(node);
|
|
49935
|
+
}
|
|
49936
|
+
for (const key of removedKeys) {
|
|
49937
|
+
this.ranImmediateDepKeys.delete(key);
|
|
49938
|
+
}
|
|
49939
|
+
this.rebuildDepGraphIndex(remaining);
|
|
49940
|
+
}
|
|
49859
49941
|
/**
|
|
49860
49942
|
* 设置默认值
|
|
49861
49943
|
* @param path jsonpath 路径 (支持 [n] 数组索引和 [n] 通配符)
|
|
@@ -111969,6 +112051,21 @@ const _sfc_main$23 = /* @__PURE__ */ defineComponent({
|
|
|
111969
112051
|
};
|
|
111970
112052
|
}
|
|
111971
112053
|
});
|
|
112054
|
+
function resolveTableModelId(table) {
|
|
112055
|
+
return table?.raw?.modelRef?.id ?? table?.id;
|
|
112056
|
+
}
|
|
112057
|
+
function resolveTableRowModelIndex(tableRow) {
|
|
112058
|
+
const realRowIndex = tableRow?.raw?.realRowIndex;
|
|
112059
|
+
if (typeof realRowIndex === "number" && realRowIndex >= 0) {
|
|
112060
|
+
return realRowIndex;
|
|
112061
|
+
}
|
|
112062
|
+
const fallback = tableRow?.line?.tableRowIndex ?? tableRow?.pathIndex?.at(-1);
|
|
112063
|
+
return fallback === void 0 ? void 0 : fallback;
|
|
112064
|
+
}
|
|
112065
|
+
function resolveTableColModelIndex(tableCell) {
|
|
112066
|
+
const colIndex = tableCell?.line?.tableCellIndex ?? tableCell?.pathIndex?.at(-1);
|
|
112067
|
+
return colIndex === void 0 ? void 0 : colIndex;
|
|
112068
|
+
}
|
|
111972
112069
|
const _hoisted_1$1q = { class: "item-suffix" };
|
|
111973
112070
|
const _hoisted_2$U = { class: "item-suffix" };
|
|
111974
112071
|
const _hoisted_3$F = { class: "item-suffix" };
|
|
@@ -111984,9 +112081,9 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
|
|
|
111984
112081
|
const { docInst } = useDocPubApiContext();
|
|
111985
112082
|
const { interaction } = useTableSelection();
|
|
111986
112083
|
const props = __props;
|
|
111987
|
-
const tableId = props.table
|
|
111988
|
-
const rowIndex = props.tableRow
|
|
111989
|
-
const colIndex = props.tableCell
|
|
112084
|
+
const tableId = computed(() => resolveTableModelId(props.table));
|
|
112085
|
+
const rowIndex = computed(() => resolveTableRowModelIndex(props.tableRow));
|
|
112086
|
+
const colIndex = computed(() => resolveTableColModelIndex(props.tableCell));
|
|
111990
112087
|
const insertBeforeColCount = ref(1);
|
|
111991
112088
|
const insertAfterColCount = ref(1);
|
|
111992
112089
|
const insertBeforeRowCount = ref(1);
|
|
@@ -112013,35 +112110,35 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
|
|
|
112013
112110
|
const handleAction = (type4, options) => {
|
|
112014
112111
|
switch (type4) {
|
|
112015
112112
|
case "add-col":
|
|
112016
|
-
if (!tableId || colIndex === void 0) return;
|
|
112113
|
+
if (!tableId.value || colIndex.value === void 0) return;
|
|
112017
112114
|
docInst?.value?.execute(CommandType.insertCol, {
|
|
112018
|
-
tableId,
|
|
112019
|
-
colIndex,
|
|
112115
|
+
tableId: tableId.value,
|
|
112116
|
+
colIndex: colIndex.value,
|
|
112020
112117
|
position: options,
|
|
112021
112118
|
count: options === "before" ? insertBeforeColCount.value : insertAfterColCount.value
|
|
112022
112119
|
});
|
|
112023
112120
|
break;
|
|
112024
112121
|
case "delete-col":
|
|
112025
|
-
if (!tableId || colIndex === void 0) return;
|
|
112122
|
+
if (!tableId.value || colIndex.value === void 0) return;
|
|
112026
112123
|
docInst.value.execute(CommandType.deleteCol, {
|
|
112027
|
-
tableId,
|
|
112028
|
-
colIndex
|
|
112124
|
+
tableId: tableId.value,
|
|
112125
|
+
colIndex: colIndex.value
|
|
112029
112126
|
});
|
|
112030
112127
|
break;
|
|
112031
112128
|
case "add-row":
|
|
112032
|
-
if (!tableId || rowIndex === void 0) return;
|
|
112129
|
+
if (!tableId.value || rowIndex.value === void 0) return;
|
|
112033
112130
|
docInst?.value?.execute(CommandType.insertRow, {
|
|
112034
|
-
tableId,
|
|
112035
|
-
rowIndex,
|
|
112131
|
+
tableId: tableId.value,
|
|
112132
|
+
rowIndex: rowIndex.value,
|
|
112036
112133
|
position: options,
|
|
112037
112134
|
count: options === "before" ? insertBeforeRowCount.value : insertAfterRowCount.value
|
|
112038
112135
|
});
|
|
112039
112136
|
break;
|
|
112040
112137
|
case "delete-row":
|
|
112041
|
-
if (!tableId || rowIndex === void 0) return;
|
|
112138
|
+
if (!tableId.value || rowIndex.value === void 0) return;
|
|
112042
112139
|
docInst?.value?.execute(CommandType.deleteRow, {
|
|
112043
|
-
tableId,
|
|
112044
|
-
rowIndex
|
|
112140
|
+
tableId: tableId.value,
|
|
112141
|
+
rowIndex: rowIndex.value
|
|
112045
112142
|
});
|
|
112046
112143
|
break;
|
|
112047
112144
|
case "data-group":
|
|
@@ -112196,7 +112293,7 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
|
|
|
112196
112293
|
};
|
|
112197
112294
|
}
|
|
112198
112295
|
});
|
|
112199
|
-
const TableMenu = /* @__PURE__ */ _export_sfc(_sfc_main$22, [["__scopeId", "data-v-
|
|
112296
|
+
const TableMenu = /* @__PURE__ */ _export_sfc(_sfc_main$22, [["__scopeId", "data-v-243eee50"]]);
|
|
112200
112297
|
const OFFSET = 4;
|
|
112201
112298
|
const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
112202
112299
|
__name: "index",
|
|
@@ -112211,6 +112308,7 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
|
112211
112308
|
const contextMenuRef = ref(null);
|
|
112212
112309
|
const menuProps = ref({});
|
|
112213
112310
|
const menuComponent = ref(null);
|
|
112311
|
+
const menuKey = ref(0);
|
|
112214
112312
|
const show = (params) => {
|
|
112215
112313
|
const {
|
|
112216
112314
|
x: x2,
|
|
@@ -112220,15 +112318,10 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
|
112220
112318
|
tableRow,
|
|
112221
112319
|
tableCell
|
|
112222
112320
|
} = params;
|
|
112223
|
-
|
|
112224
|
-
menuProps.value = {
|
|
112225
|
-
table,
|
|
112226
|
-
tableRow,
|
|
112227
|
-
tableCell
|
|
112228
|
-
};
|
|
112229
|
-
}
|
|
112321
|
+
menuProps.value = type4 === "table" ? { table, tableRow, tableCell } : {};
|
|
112230
112322
|
pos.value = { x: x2, y: y2 };
|
|
112231
112323
|
menuComponent.value = menuMap[type4];
|
|
112324
|
+
menuKey.value += 1;
|
|
112232
112325
|
menuVisible.value = true;
|
|
112233
112326
|
nextTick(() => {
|
|
112234
112327
|
if (!contextMenuRef.value) return;
|
|
@@ -112242,17 +112335,18 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
|
112242
112335
|
};
|
|
112243
112336
|
});
|
|
112244
112337
|
};
|
|
112245
|
-
|
|
112338
|
+
let scrollContainer = null;
|
|
112246
112339
|
const hide = () => {
|
|
112247
112340
|
menuVisible.value = false;
|
|
112248
112341
|
};
|
|
112249
112342
|
onMounted(() => {
|
|
112343
|
+
scrollContainer = document.querySelector(".render-container");
|
|
112250
112344
|
window.addEventListener("click", hide);
|
|
112251
|
-
|
|
112345
|
+
scrollContainer?.addEventListener("scroll", hide);
|
|
112252
112346
|
});
|
|
112253
112347
|
onBeforeUnmount(() => {
|
|
112254
112348
|
window.removeEventListener("click", hide);
|
|
112255
|
-
|
|
112349
|
+
scrollContainer?.removeEventListener("scroll", hide);
|
|
112256
112350
|
});
|
|
112257
112351
|
__expose({
|
|
112258
112352
|
show,
|
|
@@ -112266,7 +112360,7 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
|
|
|
112266
112360
|
class: "context-menu",
|
|
112267
112361
|
style: normalizeStyle({ left: pos.value.x + "px", top: pos.value.y + "px" })
|
|
112268
112362
|
}, [
|
|
112269
|
-
(openBlock(), createBlock(resolveDynamicComponent(menuComponent.value),
|
|
112363
|
+
(openBlock(), createBlock(resolveDynamicComponent(menuComponent.value), mergeProps({ key: menuKey.value }, menuProps.value), null, 16))
|
|
112270
112364
|
], 4)) : createCommentVNode("", true);
|
|
112271
112365
|
};
|
|
112272
112366
|
}
|
|
@@ -122433,7 +122527,7 @@ const _sfc_main$Y = /* @__PURE__ */ defineComponent({
|
|
|
122433
122527
|
};
|
|
122434
122528
|
}
|
|
122435
122529
|
});
|
|
122436
|
-
const BoolOptEditor = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-
|
|
122530
|
+
const BoolOptEditor = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["__scopeId", "data-v-647b5798"]]);
|
|
122437
122531
|
const _hoisted_1$P = { class: "panel-field-boolean-config" };
|
|
122438
122532
|
const _sfc_main$X = /* @__PURE__ */ defineComponent({
|
|
122439
122533
|
__name: "field-boolean-config",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 从布局元数据解析表格模型 id */
|
|
2
|
+
export declare function resolveTableModelId(table?: any): string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* 解析表格模型行索引。
|
|
5
|
+
* 分页后 pathIndex / line.tableRowIndex 仅为当前页片段索引,需优先使用 realRowIndex。
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveTableRowModelIndex(tableRow?: any): number | undefined;
|
|
8
|
+
/** 解析表格模型列索引 */
|
|
9
|
+
export declare function resolveTableColModelIndex(tableCell?: any): number | undefined;
|
package/dist/word.css
CHANGED
|
@@ -9202,7 +9202,7 @@ ul li .widget-icon[data-v-393cb2aa] {
|
|
|
9202
9202
|
line-height: 22px;
|
|
9203
9203
|
}
|
|
9204
9204
|
|
|
9205
|
-
[data-v-
|
|
9205
|
+
[data-v-243eee50] .gct-input-number {
|
|
9206
9206
|
text-align: center;
|
|
9207
9207
|
width: 48px;
|
|
9208
9208
|
}
|
|
@@ -10968,34 +10968,36 @@ svg.portrait-icon[data-v-8bdb451e] {
|
|
|
10968
10968
|
padding: 4px;
|
|
10969
10969
|
border-color: transparent;
|
|
10970
10970
|
}
|
|
10971
|
-
.option-container[data-v-
|
|
10971
|
+
.option-container[data-v-647b5798] {
|
|
10972
10972
|
position: relative;
|
|
10973
10973
|
display: flex;
|
|
10974
10974
|
flex-direction: column;
|
|
10975
10975
|
gap: 4px;
|
|
10976
10976
|
}
|
|
10977
|
-
.option-container .option-item[data-v-
|
|
10977
|
+
.option-container .option-item[data-v-647b5798] {
|
|
10978
10978
|
position: relative;
|
|
10979
10979
|
border-radius: 4px;
|
|
10980
10980
|
background: #f0f0f0;
|
|
10981
10981
|
overflow: hidden;
|
|
10982
10982
|
}
|
|
10983
|
-
.option-container .option[data-v-
|
|
10983
|
+
.option-container .option[data-v-647b5798] {
|
|
10984
10984
|
padding: 4px;
|
|
10985
10985
|
display: flex;
|
|
10986
10986
|
align-items: center;
|
|
10987
10987
|
}
|
|
10988
|
-
.option-container .option__label[data-v-
|
|
10988
|
+
.option-container .option__label[data-v-647b5798] {
|
|
10989
10989
|
width: 20px;
|
|
10990
10990
|
flex-shrink: 0;
|
|
10991
10991
|
padding-left: 4px;
|
|
10992
|
+
box-sizing: content-box;
|
|
10992
10993
|
}
|
|
10993
|
-
.option-container .option__checkbox[data-v-
|
|
10994
|
+
.option-container .option__checkbox[data-v-647b5798] {
|
|
10994
10995
|
width: 24px;
|
|
10995
10996
|
flex-shrink: 0;
|
|
10996
10997
|
padding-left: 4px;
|
|
10998
|
+
box-sizing: content-box;
|
|
10997
10999
|
}
|
|
10998
|
-
.option-container .option__attach-field[data-v-
|
|
11000
|
+
.option-container .option__attach-field[data-v-647b5798] {
|
|
10999
11001
|
margin-top: 0;
|
|
11000
11002
|
}
|
|
11001
11003
|
.panel-field-boolean-config[data-v-e4a0e34d] {
|