@gct-paas/word 0.1.28 → 0.1.29

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/dist/index.es.js CHANGED
@@ -34074,7 +34074,7 @@ const _sfc_main$3q = /* @__PURE__ */ defineComponent({
34074
34074
  };
34075
34075
  }
34076
34076
  });
34077
- const GctCheckbox = /* @__PURE__ */ _export_sfc(_sfc_main$3q, [["__scopeId", "data-v-ca2102ea"]]);
34077
+ const GctCheckbox = /* @__PURE__ */ _export_sfc(_sfc_main$3q, [["__scopeId", "data-v-90f28e3c"]]);
34078
34078
  const _hoisted_1$2g = { class: "collapse" };
34079
34079
  const _hoisted_2$1t = { class: "header-text" };
34080
34080
  const _hoisted_3$18 = {
@@ -49218,16 +49218,32 @@ class RuntimeJsonBuilder {
49218
49218
  setPageSize(size, options) {
49219
49219
  const pgSz = this.findNode(this.json.document, "w:pgSz");
49220
49220
  if (!pgSz) return this;
49221
- if (size === PageSizeEnumConst.A3) {
49222
- pgSz["@attrs"]["w:w"] = "16838";
49223
- pgSz["@attrs"]["w:h"] = "23811";
49224
- } else if (size === PageSizeEnumConst.A5) {
49225
- pgSz["@attrs"]["w:w"] = "8391";
49226
- pgSz["@attrs"]["w:h"] = "11906";
49227
- } else if (size === PageSizeEnumConst.CUSTOM) {
49228
- pgSz["@attrs"]["w:w"] = UnitConverter.cmToTwip(options.width / 10);
49229
- pgSz["@attrs"]["w:h"] = UnitConverter.cmToTwip(options.height / 10);
49221
+ const direction = options?.direction ?? "portrait";
49222
+ let width = 11906;
49223
+ let height = 16838;
49224
+ switch (size) {
49225
+ case PageSizeEnumConst.A3:
49226
+ width = 16838;
49227
+ height = 23811;
49228
+ break;
49229
+ case PageSizeEnumConst.A5:
49230
+ width = 8391;
49231
+ height = 11906;
49232
+ break;
49233
+ case PageSizeEnumConst.CUSTOM:
49234
+ width = Number(UnitConverter.cmToTwip(options.width / 10));
49235
+ height = Number(UnitConverter.cmToTwip(options.height / 10));
49236
+ break;
49237
+ default:
49238
+ width = 11906;
49239
+ height = 16838;
49240
+ break;
49230
49241
  }
49242
+ if (direction === "landscape") {
49243
+ [width, height] = [height, width];
49244
+ }
49245
+ pgSz["@attrs"]["w:w"] = String(width);
49246
+ pgSz["@attrs"]["w:h"] = String(height);
49231
49247
  return this;
49232
49248
  }
49233
49249
  /**
@@ -49366,7 +49382,8 @@ class SingleTemplateStrategy extends DocRequestStrategy {
49366
49382
  if (!requestInfo.runtimeJson) {
49367
49383
  const json = new RuntimeJsonBuilder(DefaultDocxJson).setPageSize(requestInfo.paperSize, {
49368
49384
  width: requestInfo.width,
49369
- height: requestInfo.height
49385
+ height: requestInfo.height,
49386
+ direction: requestInfo.direction
49370
49387
  }).build();
49371
49388
  requestInfo.runtimeJson = JSON.stringify(json);
49372
49389
  }
@@ -51451,6 +51468,7 @@ function useDocumentFactory(props, payload) {
51451
51468
  () => finisher.value,
51452
51469
  () => {
51453
51470
  console.log("Document request success");
51471
+ payload.onDocumentLoadSuccess?.();
51454
51472
  }
51455
51473
  );
51456
51474
  async function mountDocument(result) {
@@ -51461,7 +51479,6 @@ function useDocumentFactory(props, payload) {
51461
51479
  docInfo.value = snapshotDocInfo(ins);
51462
51480
  };
51463
51481
  docInfo.value = initialized.docInfo;
51464
- payload.onDocumentLoadSuccess?.(result);
51465
51482
  }
51466
51483
  const hasData = computed(() => docIns.value !== null);
51467
51484
  function clear() {
@@ -57170,6 +57187,86 @@ function useDocController(factory2, ops) {
57170
57187
  );
57171
57188
  return controller;
57172
57189
  }
57190
+ const DEBOUNCE_MS = 300;
57191
+ function useDocLooperAutoSaveNotify(factory2, ops, options) {
57192
+ let suppress = true;
57193
+ let unsubscribeData = null;
57194
+ let stopWatchDoc = null;
57195
+ let stopWatchTick = null;
57196
+ let debounceTimer = null;
57197
+ function doNotify() {
57198
+ if (suppress) return;
57199
+ const { dirty } = ops.getUnsavedChanges({
57200
+ includeRawData: true
57201
+ });
57202
+ if (dirty) {
57203
+ options.onLooperAutoSave?.({
57204
+ changed: true
57205
+ });
57206
+ }
57207
+ }
57208
+ function flushNotify() {
57209
+ if (debounceTimer) {
57210
+ clearTimeout(debounceTimer);
57211
+ }
57212
+ debounceTimer = setTimeout(() => {
57213
+ debounceTimer = null;
57214
+ doNotify();
57215
+ }, DEBOUNCE_MS);
57216
+ }
57217
+ function cancelFlushNotify() {
57218
+ if (debounceTimer) {
57219
+ clearTimeout(debounceTimer);
57220
+ debounceTimer = null;
57221
+ }
57222
+ }
57223
+ function scheduleNotify() {
57224
+ if (suppress) return;
57225
+ flushNotify();
57226
+ }
57227
+ function disposeSubscriptions() {
57228
+ cancelFlushNotify();
57229
+ unsubscribeData?.();
57230
+ unsubscribeData = null;
57231
+ stopWatchTick?.();
57232
+ stopWatchTick = null;
57233
+ }
57234
+ function bindDoc() {
57235
+ disposeSubscriptions();
57236
+ suppress = true;
57237
+ const doc = factory2.docIns.value;
57238
+ if (!doc) return;
57239
+ unsubscribeData = doc.dataManager.subscribe("$", () => {
57240
+ scheduleNotify();
57241
+ });
57242
+ }
57243
+ function releaseSuppressOnLoad() {
57244
+ cancelFlushNotify();
57245
+ Promise.resolve().then(() => {
57246
+ suppress = false;
57247
+ });
57248
+ }
57249
+ stopWatchDoc = watch(
57250
+ () => factory2.docIns.value,
57251
+ (doc) => {
57252
+ if (!doc) {
57253
+ disposeSubscriptions();
57254
+ suppress = true;
57255
+ return;
57256
+ }
57257
+ bindDoc();
57258
+ },
57259
+ {
57260
+ immediate: true
57261
+ }
57262
+ );
57263
+ onBeforeUnmount(() => {
57264
+ stopWatchDoc?.();
57265
+ stopWatchDoc = null;
57266
+ disposeSubscriptions();
57267
+ });
57268
+ return releaseSuppressOnLoad;
57269
+ }
57173
57270
  var DeviceLink;
57174
57271
  ((DeviceLink2) => {
57175
57272
  ((TmplTypeEnum2) => {
@@ -57496,10 +57593,26 @@ function toDocPayload(options, ctx) {
57496
57593
  }
57497
57594
  function useWord(props, options) {
57498
57595
  const ctx = useDocSuite(options);
57499
- const factory2 = useDocumentFactory(toDocProps(props), toDocPayload(options, ctx));
57596
+ let releaseSuppressOnLoad;
57597
+ const factory2 = useDocumentFactory(
57598
+ toDocProps(props),
57599
+ toDocPayload(
57600
+ {
57601
+ ...options,
57602
+ onDocumentLoadSuccess: () => {
57603
+ options.onDocumentLoadSuccess?.();
57604
+ releaseSuppressOnLoad?.();
57605
+ }
57606
+ },
57607
+ ctx
57608
+ )
57609
+ );
57500
57610
  const ops = useDocOperations(factory2.docIns);
57501
57611
  const controller = useDocController(factory2, ops);
57502
57612
  useDocRuntimeProvider(factory2, controller);
57613
+ releaseSuppressOnLoad = useDocLooperAutoSaveNotify(factory2, ops, {
57614
+ onLooperAutoSave: options.onLooperAutoSave
57615
+ });
57503
57616
  const formTmplConfigController = useFormTmplConfig().provideController();
57504
57617
  return {
57505
57618
  controller,
@@ -61601,7 +61714,7 @@ const _sfc_main$20 = /* @__PURE__ */ defineComponent({
61601
61714
  };
61602
61715
  }
61603
61716
  });
61604
- const docDesignLayout = /* @__PURE__ */ _export_sfc(_sfc_main$20, [["__scopeId", "data-v-e6b0dcfe"]]);
61717
+ const docDesignLayout = /* @__PURE__ */ _export_sfc(_sfc_main$20, [["__scopeId", "data-v-041003c9"]]);
61605
61718
  function convertPxToPaperSize(pageSize, customSize) {
61606
61719
  if (pageSize === PageSizeEnumConst.A3) {
61607
61720
  return {
@@ -0,0 +1,18 @@
1
+ import { DocumentFactory } from '../factories/useDocumentFactory';
2
+ import { DocOperations } from './useDocOperations';
3
+ /** 与外部 nocode EmitterEnum.__on_looper_auto_save 对齐的事件名 */
4
+ export declare const DOC_LOOPER_AUTO_SAVE_EVENT: "__on_looper_auto_save";
5
+ export interface DocLooperAutoSavePayload {
6
+ changed?: boolean;
7
+ }
8
+ export interface UseDocLooperAutoSaveNotifyOptions {
9
+ onLooperAutoSave?: (payload?: DocLooperAutoSavePayload) => void;
10
+ }
11
+ /**
12
+ * 监听文档数据/模型变更,在用户停止输入后(防抖 300ms)检测 dirty 状态,
13
+ * 若有未保存改动则触发 onLooperAutoSave 回调。
14
+ *
15
+ * 返回 releaseSuppressOnLoad,需由外部在文档成功加载后调用,以准确控制
16
+ * suppress 的释放时机(避免初始化阶段的数据变更触发误报)。
17
+ */
18
+ export declare function useDocLooperAutoSaveNotify(factory: DocumentFactory, ops: DocOperations, options: UseDocLooperAutoSaveNotifyOptions): () => void;
@@ -6,9 +6,10 @@ export declare class RuntimeJsonBuilder {
6
6
  /**
7
7
  * 页面设置
8
8
  */
9
- setPageSize(size: PageSizeEnum, options?: {
9
+ setPageSize(size: PageSizeEnum, options: {
10
10
  width: number;
11
11
  height: number;
12
+ direction?: 'portrait' | 'landscape';
12
13
  }): this;
13
14
  /**
14
15
  * 构建
@@ -47,7 +47,7 @@ export interface IDocPayload extends IDocTemplatePayload, IDocInstancePayload {
47
47
  * 文档接口请求成功且引擎挂载完成后的回调(每轮成功加载触发一次)。
48
48
  * 不会在 requestId 为空、请求被丢弃、或初始化抛错时调用。
49
49
  */
50
- onDocumentLoadSuccess?: (result: Execute) => void;
50
+ onDocumentLoadSuccess?: () => void;
51
51
  }
52
52
  /** 文档加载工厂 — 只负责响应式加载与生命周期,不包含业务操作 */
53
53
  export interface DocumentFactory {
@@ -6,7 +6,6 @@ import { DocBaselineContext, DocUnsavedChanges, DocOperations, DocGetUnsavedChan
6
6
  import { OnlineFormInstanceResponse, OnlineFormTmplResponse } from '@gct-paas/api/apaas';
7
7
  import { FieldChangeItem } from '../../runtime/interface/change-diff';
8
8
  import { FormTmplConfigController } from '../../suites/edhr/panel-schema/data-load/hooks/form-tmpl-config';
9
- import { Execute } from '../doc-runtime/factories/useDocumentFactory';
10
9
  export type { DocUnsavedChanges, DocGetUnsavedChangesOptions, } from '../doc-runtime/composables/useDocOperations';
11
10
  export type { FieldModelQuery } from './field-model-query';
12
11
  /** 字段权限信息 */
@@ -193,7 +192,14 @@ export interface UseWordOptions {
193
192
  * 文档接口请求成功且引擎挂载完成后的回调(每轮成功加载触发一次)。
194
193
  * 不会在 requestId 为空、请求被丢弃、或初始化抛错时调用。
195
194
  */
196
- onDocumentLoadSuccess?: (result: Execute) => void;
195
+ onDocumentLoadSuccess?: () => void;
196
+ /**
197
+ * 文档数据发生变化(防抖 300ms 后)的回调,可在此处触发外部自动保存通知。
198
+ * 例:() => emitter.emit(EmitterEnum.__on_looper_auto_save)
199
+ */
200
+ onLooperAutoSave?: (payload?: {
201
+ changed?: boolean;
202
+ }) => void;
197
203
  /** 扩展字段 - 兼容其他未明确定义的负载参数 */
198
204
  [key: string]: any;
199
205
  }
package/dist/word.css CHANGED
@@ -5554,13 +5554,13 @@
5554
5554
  .slide-right-leave-active[data-v-3e5daf47] {
5555
5555
  transition: all 0.25s ease;
5556
5556
  }
5557
- .gct-checkbox[data-v-ca2102ea] {
5557
+ .gct-checkbox[data-v-90f28e3c] {
5558
5558
  display: inline-flex;
5559
5559
  align-items: center;
5560
5560
  cursor: pointer;
5561
5561
  font-size: 14px;
5562
5562
  }
5563
- .gct-checkbox-input[data-v-ca2102ea] {
5563
+ .gct-checkbox-input[data-v-90f28e3c] {
5564
5564
  width: 16px;
5565
5565
  height: 16px;
5566
5566
  border: 1px solid #d9d9d9;
@@ -5571,7 +5571,7 @@
5571
5571
  position: relative;
5572
5572
  transition: all 0.2s;
5573
5573
  }
5574
- .gct-checkbox-inner[data-v-ca2102ea] {
5574
+ .gct-checkbox-inner[data-v-90f28e3c] {
5575
5575
  position: absolute;
5576
5576
  left: 4px;
5577
5577
  top: 0px;
@@ -5582,15 +5582,16 @@
5582
5582
  border-left: 0;
5583
5583
  transform: rotate(45deg) scale(0);
5584
5584
  transition: transform 0.15s;
5585
+ box-sizing: content-box;
5585
5586
  }
5586
- .gct-checkbox-checked .gct-checkbox-input[data-v-ca2102ea] {
5587
+ .gct-checkbox-checked .gct-checkbox-input[data-v-90f28e3c] {
5587
5588
  background: #026ac8;
5588
5589
  border-color: #026ac8;
5589
5590
  }
5590
- .gct-checkbox-checked .gct-checkbox-inner[data-v-ca2102ea] {
5591
+ .gct-checkbox-checked .gct-checkbox-inner[data-v-90f28e3c] {
5591
5592
  transform: rotate(45deg) scale(1);
5592
5593
  }
5593
- .gct-checkbox-indeterminate .gct-checkbox-inner[data-v-ca2102ea] {
5594
+ .gct-checkbox-indeterminate .gct-checkbox-inner[data-v-90f28e3c] {
5594
5595
  width: 8px;
5595
5596
  height: 2px;
5596
5597
  left: 3px;
@@ -5599,38 +5600,38 @@
5599
5600
  background: #fff;
5600
5601
  transform: scale(1);
5601
5602
  }
5602
- .gct-checkbox-disabled[data-v-ca2102ea] {
5603
+ .gct-checkbox-disabled[data-v-90f28e3c] {
5603
5604
  cursor: not-allowed;
5604
5605
  color: #aaa;
5605
5606
  }
5606
- .gct-checkbox-disabled .gct-checkbox-input[data-v-ca2102ea] {
5607
+ .gct-checkbox-disabled .gct-checkbox-input[data-v-90f28e3c] {
5607
5608
  background: #f5f5f5;
5608
5609
  border-color: #d9d9d9;
5609
5610
  }
5610
- .gct-checkbox-disabled .gct-checkbox-input .gct-checkbox-inner[data-v-ca2102ea] {
5611
+ .gct-checkbox-disabled .gct-checkbox-input .gct-checkbox-inner[data-v-90f28e3c] {
5611
5612
  border-color: #d9d9d9;
5612
5613
  }
5613
- .gct-checkbox-small[data-v-ca2102ea] {
5614
+ .gct-checkbox-small[data-v-90f28e3c] {
5614
5615
  font-size: 12px;
5615
5616
  }
5616
- .gct-checkbox-small .gct-checkbox-input[data-v-ca2102ea] {
5617
+ .gct-checkbox-small .gct-checkbox-input[data-v-90f28e3c] {
5617
5618
  width: 14px;
5618
5619
  height: 14px;
5619
5620
  margin-right: 6px;
5620
5621
  }
5621
- .gct-checkbox-small .gct-checkbox-inner[data-v-ca2102ea] {
5622
+ .gct-checkbox-small .gct-checkbox-inner[data-v-90f28e3c] {
5622
5623
  width: 3px;
5623
5624
  height: 8px;
5624
5625
  }
5625
- .gct-checkbox-group-small .gct-checkbox[data-v-ca2102ea] {
5626
+ .gct-checkbox-group-small .gct-checkbox[data-v-90f28e3c] {
5626
5627
  font-size: 12px;
5627
5628
  }
5628
- .gct-checkbox-group-small .gct-checkbox-input[data-v-ca2102ea] {
5629
+ .gct-checkbox-group-small .gct-checkbox-input[data-v-90f28e3c] {
5629
5630
  width: 14px;
5630
5631
  height: 14px;
5631
5632
  margin-right: 6px;
5632
5633
  }
5633
- .gct-checkbox-group-small .gct-checkbox-inner[data-v-ca2102ea] {
5634
+ .gct-checkbox-group-small .gct-checkbox-inner[data-v-90f28e3c] {
5634
5635
  width: 3px;
5635
5636
  height: 8px;
5636
5637
  }
@@ -9134,40 +9135,40 @@ ul li .widget-icon[data-v-1e28101c] {
9134
9135
  position: relative;
9135
9136
  background-color: #f0f0f0;
9136
9137
  }
9137
- .doc-design-layout[data-v-e6b0dcfe] {
9138
+ .doc-design-layout[data-v-041003c9] {
9138
9139
  display: flex;
9139
9140
  flex-direction: column;
9140
9141
  width: 100%;
9141
9142
  height: 100%;
9142
9143
  }
9143
- .doc-design-layout.preview[data-v-e6b0dcfe] {
9144
+ .doc-design-layout.preview[data-v-041003c9] {
9144
9145
  pointer-events: none;
9145
9146
  }
9146
- .doc-design-layout .design-body[data-v-e6b0dcfe] {
9147
+ .doc-design-layout .design-body[data-v-041003c9] {
9147
9148
  flex: 1;
9148
9149
  display: flex;
9149
9150
  min-height: 0;
9150
9151
  }
9151
- .doc-design-layout .design-body .design-sidebar[data-v-e6b0dcfe] {
9152
+ .doc-design-layout .design-body .design-sidebar[data-v-041003c9] {
9152
9153
  position: relative;
9153
9154
  overflow: hidden;
9154
9155
  background: #fff;
9155
9156
  flex-shrink: 0;
9156
9157
  }
9157
- .doc-design-layout .design-body .design-sidebar.left[data-v-e6b0dcfe] {
9158
+ .doc-design-layout .design-body .design-sidebar.left[data-v-041003c9] {
9158
9159
  border-right: 1px solid #e0e0e0;
9159
9160
  }
9160
- .doc-design-layout .design-body .design-sidebar.right[data-v-e6b0dcfe] {
9161
+ .doc-design-layout .design-body .design-sidebar.right[data-v-041003c9] {
9161
9162
  border-left: 1px solid #e0e0e0;
9162
9163
  }
9163
- .doc-design-layout .design-body .design-sidebar .right-container[data-v-e6b0dcfe] {
9164
+ .doc-design-layout .design-body .design-sidebar .right-container[data-v-041003c9] {
9164
9165
  position: relative;
9165
9166
  display: flex;
9166
9167
  width: 100%;
9167
9168
  height: 100%;
9168
9169
  overflow: hidden;
9169
9170
  }
9170
- .doc-design-layout .design-body .design-sidebar .right-container .divider[data-v-e6b0dcfe] {
9171
+ .doc-design-layout .design-body .design-sidebar .right-container .divider[data-v-041003c9] {
9171
9172
  position: absolute;
9172
9173
  left: 0;
9173
9174
  top: 0;
@@ -9178,13 +9179,13 @@ ul li .widget-icon[data-v-1e28101c] {
9178
9179
  left: 46px;
9179
9180
  transform: translateX(-50%);
9180
9181
  }
9181
- .doc-design-layout .design-body .design-main[data-v-e6b0dcfe] {
9182
+ .doc-design-layout .design-body .design-main[data-v-041003c9] {
9182
9183
  position: relative;
9183
9184
  flex: 1;
9184
9185
  min-height: 0;
9185
9186
  overflow: hidden;
9186
9187
  }
9187
- .doc-design-layout .design-body .design-main .empty-container[data-v-e6b0dcfe] {
9188
+ .doc-design-layout .design-body .design-main .empty-container[data-v-041003c9] {
9188
9189
  position: absolute;
9189
9190
  top: 0;
9190
9191
  left: 50%;
@@ -9198,15 +9199,16 @@ ul li .widget-icon[data-v-1e28101c] {
9198
9199
  pointer-events: all;
9199
9200
  transform: translateX(-50%);
9200
9201
  }
9201
- .doc-design-layout .design-footer[data-v-e6b0dcfe] {
9202
+ .doc-design-layout .design-footer[data-v-041003c9] {
9202
9203
  flex-shrink: 0;
9203
9204
  display: flex;
9204
9205
  align-items: center;
9205
- height: 28px;
9206
+ height: 0px;
9206
9207
  padding: 0 12px;
9207
9208
  font-size: 12px;
9208
9209
  background: #f8f8f8;
9209
9210
  border-top: 1px solid #e0e0e0;
9211
+ border: none;
9210
9212
  }
9211
9213
  .render-container[data-v-c852bc0c] {
9212
9214
  overflow-y: auto;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",