@yudaocode/univer-docs-ui 1.6.215 → 1.6.216

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/lib/es/index.js CHANGED
@@ -116,6 +116,14 @@ function isDocSdtKindAllowed(features, kind) {
116
116
  if (!features?.allowedSdtKinds || features.allowedSdtKinds.length === 0) return true;
117
117
  return features.allowedSdtKinds.includes(kind);
118
118
  }
119
+ function cloneIoModalConfig(cfg) {
120
+ if (!cfg) return void 0;
121
+ return {
122
+ ...cfg.tabs ? { tabs: [...cfg.tabs] } : {},
123
+ ...cfg.defaultTab !== void 0 ? { defaultTab: cfg.defaultTab } : {},
124
+ ...cfg.showPipelineBadge !== void 0 ? { showPipelineBadge: cfg.showPipelineBadge } : {}
125
+ };
126
+ }
119
127
  function resolveDocsUIFeatures(raw) {
120
128
  return {
121
129
  sdtControls: Boolean(raw?.sdtControls),
@@ -149,40 +157,91 @@ function resolveDocsUIFeatures(raw) {
149
157
  paragraphAdvancedLayout: raw?.paragraphAdvancedLayout ?? true,
150
158
  legacyFormatIo: raw?.legacyFormatIo ?? true,
151
159
  bookmarks: raw?.bookmarks ?? true,
152
- ...raw?.allowedSdtKinds ? { allowedSdtKinds: [...raw.allowedSdtKinds] } : {}
160
+ ...raw?.allowedSdtKinds ? { allowedSdtKinds: [...raw.allowedSdtKinds] } : {},
161
+ ...raw?.ioModal ? { ioModal: cloneIoModalConfig(raw.ioModal) } : {}
153
162
  };
154
163
  }
155
164
  var IDocsUIFeatureService = createIdentifier(
156
165
  "yudao.univer-docs-ui.feature.service"
157
166
  );
158
167
  var DocsUIFeatureService = class extends Disposable {
159
- constructor(initial) {
168
+ constructor(initial, initialIoModal) {
160
169
  super();
161
170
  this._modalOpen$ = new BehaviorSubject(false);
162
- this._modalTab$ = new BehaviorSubject("preview");
163
171
  this.modalOpen$ = this._modalOpen$.asObservable();
164
- this.modalTab$ = this._modalTab$.asObservable();
165
- this._features$ = new BehaviorSubject(resolveDocsUIFeatures(initial));
172
+ const resolvedFeatures = resolveDocsUIFeatures(initial);
173
+ this._baseIoModal = cloneIoModalConfig(initialIoModal ?? resolvedFeatures.ioModal);
174
+ const initTab = this._resolveValidTab(void 0, this._baseIoModal);
175
+ this._features$ = new BehaviorSubject(resolvedFeatures);
176
+ this._modalTab$ = new BehaviorSubject(initTab);
177
+ this._ioModal$ = new BehaviorSubject(
178
+ cloneIoModalConfig(this._baseIoModal)
179
+ );
166
180
  this.features$ = this._features$.asObservable();
181
+ this.modalTab$ = this._modalTab$.asObservable();
182
+ this.ioModal$ = this._ioModal$.asObservable();
167
183
  this.disposeWithMe({
168
184
  dispose: () => {
169
185
  this._features$.complete();
170
186
  this._modalOpen$.complete();
171
187
  this._modalTab$.complete();
188
+ this._ioModal$.complete();
172
189
  }
173
190
  });
174
191
  }
192
+ _mergeIoModal(override) {
193
+ const featIoModal = this._features$.getValue().ioModal;
194
+ const base = this._baseIoModal ?? featIoModal;
195
+ if (!base && !override) return void 0;
196
+ return cloneIoModalConfig({
197
+ ...base ?? {},
198
+ ...override ?? {}
199
+ });
200
+ }
201
+ _resolveValidTab(requestedTab, cfg) {
202
+ const raw = requestedTab || cfg?.defaultTab || "preview";
203
+ const allowed = cfg?.tabs;
204
+ if (allowed && allowed.length > 0) {
205
+ if (allowed.includes(raw)) {
206
+ return raw;
207
+ }
208
+ if (raw === "preview") {
209
+ if (allowed.includes("export")) return "export";
210
+ if (allowed.includes("print")) return "print";
211
+ }
212
+ return allowed[0];
213
+ }
214
+ return raw;
215
+ }
175
216
  getFeatures() {
176
217
  return this._features$.getValue();
177
218
  }
178
219
  setFeatures(features) {
179
- this._features$.next(resolveDocsUIFeatures(features));
220
+ const next = resolveDocsUIFeatures(features);
221
+ this._features$.next(next);
222
+ if (features.ioModal !== void 0) {
223
+ this._ioModal$.next(this._mergeIoModal());
224
+ }
180
225
  }
181
226
  patchFeatures(patch) {
182
227
  this._features$.next({
183
228
  ...this._features$.getValue(),
184
229
  ...patch
185
230
  });
231
+ if (patch.ioModal !== void 0) {
232
+ this._ioModal$.next(this._mergeIoModal());
233
+ }
234
+ }
235
+ getIoModalConfig() {
236
+ return this._ioModal$.getValue();
237
+ }
238
+ setIoModalConfig(config) {
239
+ this._baseIoModal = cloneIoModalConfig(config);
240
+ const merged = this._mergeIoModal();
241
+ this._ioModal$.next(merged);
242
+ if (!this._modalOpen$.getValue()) {
243
+ this._modalTab$.next(this._resolveValidTab(void 0, merged));
244
+ }
186
245
  }
187
246
  isModalOpen() {
188
247
  return this._modalOpen$.getValue();
@@ -190,15 +249,17 @@ var DocsUIFeatureService = class extends Disposable {
190
249
  getModalTab() {
191
250
  return this._modalTab$.getValue();
192
251
  }
193
- openModal(tab = "preview") {
194
- this._modalTab$.next(tab);
252
+ openModal(tab, ioModal) {
253
+ const merged = this._mergeIoModal(ioModal);
254
+ this._ioModal$.next(merged);
255
+ this._modalTab$.next(this._resolveValidTab(tab, merged));
195
256
  this._modalOpen$.next(true);
196
257
  }
197
258
  closeModal() {
198
259
  this._modalOpen$.next(false);
199
260
  }
200
261
  setModalTab(tab) {
201
- this._modalTab$.next(tab);
262
+ this._modalTab$.next(this._resolveValidTab(tab, this._ioModal$.getValue()));
202
263
  }
203
264
  };
204
265
 
@@ -234,7 +295,7 @@ var OpenDocModalOperation = {
234
295
  if (featureService.getFeatures().builtinPreviewModal === false) {
235
296
  return false;
236
297
  }
237
- featureService.openModal(params?.tab ?? "preview");
298
+ featureService.openModal(params?.tab, params?.ioModal);
238
299
  return true;
239
300
  }
240
301
  };
@@ -334,15 +395,19 @@ var ImportDocFileOperation = {
334
395
  UniverInstanceType.UNIVER_DOC
335
396
  );
336
397
  if (!docModel) return false;
337
- void ioService.importDoc(params.file, docModel.getUnitId(), {
338
- target: params.target
339
- }).then((parsed) => {
398
+ void ioService.importDoc(
399
+ params.file,
400
+ docModel.getUnitId(),
401
+ params.signal ? { target: params.target, signal: params.signal } : { target: params.target }
402
+ ).then((parsed) => {
403
+ if (params.signal?.aborted) return;
340
404
  if (parsed.body) {
341
405
  commandService.syncExecuteCommand(ReplaceDocUnitSnapshotCommand.id, {
342
406
  unitId: docModel.getUnitId(),
343
407
  snapshot: parsed
344
408
  });
345
409
  }
410
+ }).catch(() => {
346
411
  });
347
412
  return true;
348
413
  }
@@ -350,14 +415,17 @@ var ImportDocFileOperation = {
350
415
  if (accessor.has(IDocsUIFeatureService)) {
351
416
  const featureService = accessor.get(IDocsUIFeatureService);
352
417
  if (featureService.getFeatures().builtinPreviewModal !== false) {
353
- featureService.openModal("import");
418
+ featureService.openModal("import", params?.ioModal);
354
419
  return true;
355
420
  }
356
421
  return false;
357
422
  }
358
423
  } catch {
359
424
  }
360
- return commandService.syncExecuteCommand(OpenDocModalOperation.id, { tab: "import" });
425
+ return commandService.syncExecuteCommand(OpenDocModalOperation.id, {
426
+ tab: "import",
427
+ ...params?.ioModal ? { ioModal: params.ioModal } : {}
428
+ });
361
429
  }
362
430
  };
363
431
  var QuickInsertDocSdtOperation = {
@@ -576,6 +644,9 @@ var UpdateDocsUIFeaturesOperation = {
576
644
  } else if (params?.patch) {
577
645
  featureService.patchFeatures(params.patch);
578
646
  }
647
+ if (params?.ioModal !== void 0) {
648
+ featureService.setIoModalConfig(params.ioModal);
649
+ }
579
650
  return true;
580
651
  }
581
652
  };
@@ -4964,6 +5035,84 @@ var MODAL_PEN_COLORS = [
4964
5035
  { hex: "#2C53F1", label: "\u7B7E\u5B57\u84DD" },
4965
5036
  { hex: "#DC2626", label: "\u6731\u7802\u7EA2" }
4966
5037
  ];
5038
+ async function runGuardedStagedImport(params) {
5039
+ const {
5040
+ file,
5041
+ unitId,
5042
+ activeTarget,
5043
+ ioService,
5044
+ importReqSeqRef,
5045
+ importAbortRef,
5046
+ onStaged,
5047
+ onError
5048
+ } = params;
5049
+ importAbortRef.current?.abort();
5050
+ const abortController = new AbortController();
5051
+ importAbortRef.current = abortController;
5052
+ const reqSeq = ++importReqSeqRef.current;
5053
+ try {
5054
+ const outcome = await ioService.importDocWithReport(file, {
5055
+ unitId,
5056
+ target: activeTarget,
5057
+ signal: abortController.signal
5058
+ });
5059
+ if (reqSeq !== importReqSeqRef.current || abortController.signal.aborted) {
5060
+ return;
5061
+ }
5062
+ const stagedSnap = outcome.snapshot ?? outcome.documentData;
5063
+ onStaged({
5064
+ snapshot: stagedSnap,
5065
+ warnings: outcome.warnings,
5066
+ executedBy: outcome.executedBy,
5067
+ fileName: outcome.fileName || file.name
5068
+ });
5069
+ } catch (err) {
5070
+ if (reqSeq !== importReqSeqRef.current || abortController.signal.aborted || err?.name === "AbortError") {
5071
+ return;
5072
+ }
5073
+ const message = err?.message || String(err);
5074
+ onError({
5075
+ operation: "import",
5076
+ failedTarget: activeTarget,
5077
+ message
5078
+ });
5079
+ }
5080
+ }
5081
+ function confirmStagedDocImport(params) {
5082
+ const { commandService, unitId, pendingImport } = params;
5083
+ if (!pendingImport.snapshot?.body) {
5084
+ const missingBodyMsg = "\u5BFC\u5165\u5FEB\u7167\u7F3A\u5C11\u6709\u6548\u6B63\u6587\u7ED3\u6784\uFF08body\uFF09\uFF0C\u65E0\u6CD5\u8986\u76D6\u5F53\u524D\u8BBE\u8BA1\u5668\u6587\u6863";
5085
+ return {
5086
+ ok: false,
5087
+ ioError: {
5088
+ operation: "import",
5089
+ failedTarget: pendingImport.executedBy,
5090
+ message: missingBodyMsg
5091
+ },
5092
+ statusTip: `\u5BFC\u5165\u5E94\u7528\u5931\u8D25: ${missingBodyMsg}`
5093
+ };
5094
+ }
5095
+ const applied = commandService.syncExecuteCommand(ReplaceDocUnitSnapshotCommand3.id, {
5096
+ unitId,
5097
+ snapshot: pendingImport.snapshot
5098
+ });
5099
+ if (!applied) {
5100
+ const applyErrMsg = "\u5E94\u7528\u5BFC\u5165\u5FEB\u7167\u5230\u5F53\u524D\u8BBE\u8BA1\u5668\u5931\u8D25\uFF08\u6587\u6863\u5904\u4E8E\u53EA\u8BFB\u6A21\u5F0F\u6216\u5FEB\u7167\u7ED3\u6784\u4E0D\u5408\u6CD5\uFF09";
5101
+ return {
5102
+ ok: false,
5103
+ ioError: {
5104
+ operation: "import",
5105
+ failedTarget: pendingImport.executedBy,
5106
+ message: applyErrMsg
5107
+ },
5108
+ statusTip: `\u5BFC\u5165\u5E94\u7528\u5931\u8D25: ${applyErrMsg}`
5109
+ };
5110
+ }
5111
+ return {
5112
+ ok: true,
5113
+ statusTip: "\u5DF2\u5E94\u7528\u5230\u5F53\u524D\u8BBE\u8BA1\u5668\uFF0C\u8BF7\u7531\u5BBF\u4E3B\u4FDD\u5B58"
5114
+ };
5115
+ }
4967
5116
  function inferExtFromFileName(fileName) {
4968
5117
  const m = fileName.trim().toLowerCase().match(/\.([^.]+)$/);
4969
5118
  if (!m) return "docx";
@@ -5001,6 +5150,10 @@ var DocPreviewAndIoModal = () => {
5001
5150
  const open = useObservable3(featureService.modalOpen$, featureService.isModalOpen());
5002
5151
  const tab = useObservable3(featureService.modalTab$, featureService.getModalTab());
5003
5152
  const features = useObservable3(featureService.features$, featureService.getFeatures());
5153
+ const ioModalConfig = useObservable3(
5154
+ featureService.ioModal$,
5155
+ featureService.getIoModalConfig()
5156
+ );
5004
5157
  const ioAdapter = useObservable3(ioService.adapter$, ioService.getAdapter());
5005
5158
  const unit = useObservable3(
5006
5159
  () => instanceService.getCurrentTypeOfUnit$(UniverInstanceType4.UNIVER_DOC),
@@ -5030,8 +5183,16 @@ var DocPreviewAndIoModal = () => {
5030
5183
  const fileInputRef = useRef(null);
5031
5184
  const sigCanvasRef = useRef(null);
5032
5185
  const iframeRef = useRef(null);
5186
+ const importReqSeqRef = useRef(0);
5187
+ const importAbortRef = useRef(null);
5033
5188
  useEffect3(() => {
5034
- if (!open || !unit) return;
5189
+ if (!open) {
5190
+ importReqSeqRef.current += 1;
5191
+ importAbortRef.current?.abort();
5192
+ importAbortRef.current = null;
5193
+ return;
5194
+ }
5195
+ if (!unit) return;
5035
5196
  const snap = unit.getSnapshot();
5036
5197
  const meta = sdtService.getTemplateMetadata(unit.getUnitId());
5037
5198
  const initialData = meta.sampleData ?? {};
@@ -5061,7 +5222,16 @@ var DocPreviewAndIoModal = () => {
5061
5222
  const isCustomBackendAdapter = Boolean(
5062
5223
  ioAdapter.exportDoc || ioAdapter.importDoc || ioAdapter.onSave
5063
5224
  );
5064
- const activeCapabilityOp = tab === "import" ? "import" : "export";
5225
+ const hasCompactTabs = Boolean(ioModalConfig?.tabs && ioModalConfig.tabs.length > 0);
5226
+ const visibleTabs = hasCompactTabs ? ioModalConfig.tabs : [
5227
+ "import",
5228
+ "preview",
5229
+ ...features.sdtControls ? ["form"] : [],
5230
+ "json"
5231
+ ];
5232
+ const effectiveTab = visibleTabs.includes(tab) ? tab : tab === "preview" && visibleTabs.includes("export") ? "export" : tab === "preview" && visibleTabs.includes("print") ? "print" : visibleTabs[0] ?? "preview";
5233
+ const showPipelineBadge = ioModalConfig?.showPipelineBadge !== false;
5234
+ const activeCapabilityOp = effectiveTab === "import" ? "import" : "export";
5065
5235
  const activeFormatMatrix = ioCaps.formats[activeCapabilityOp];
5066
5236
  const browserSupportedFormats = DOC_IO_CAPABILITY_FORMATS.filter(
5067
5237
  (fmt) => activeFormatMatrix[fmt]?.browser
@@ -5194,35 +5364,29 @@ var DocPreviewAndIoModal = () => {
5194
5364
  setSelectedImportFile(file);
5195
5365
  setIoError(null);
5196
5366
  setPendingImport(null);
5197
- try {
5198
- const outcome = await ioService.importDocWithReport(file, {
5199
- unitId: unit.getUnitId(),
5200
- target: activeTarget
5201
- });
5202
- const stagedSnap = outcome.snapshot ?? outcome.documentData;
5203
- setPendingImport({
5204
- snapshot: stagedSnap,
5205
- warnings: outcome.warnings,
5206
- executedBy: outcome.executedBy,
5207
- fileName: outcome.fileName || file.name
5208
- });
5209
- if (stagedSnap.body) {
5210
- setPreviewHtml(
5211
- exportDocHtmlString(stagedSnap, void 0, { printFieldsOnly })
5367
+ await runGuardedStagedImport({
5368
+ file,
5369
+ unitId: unit.getUnitId(),
5370
+ activeTarget,
5371
+ ioService,
5372
+ importReqSeqRef,
5373
+ importAbortRef,
5374
+ onStaged: (staged) => {
5375
+ setPendingImport(staged);
5376
+ if (staged.snapshot.body) {
5377
+ setPreviewHtml(
5378
+ exportDocHtmlString(staged.snapshot, void 0, { printFieldsOnly })
5379
+ );
5380
+ }
5381
+ setStatusTip(
5382
+ `\u5DF2\u5B8C\u6210\u300C${staged.fileName}\u300D\u9884\u89E3\u6790\uFF08\u5C1A\u672A\u8986\u76D6\u5F53\u524D\u8BBE\u8BA1\u5668\u6587\u6863\uFF0C\u8BF7\u786E\u8BA4\u540E\u5E94\u7528\uFF09`
5212
5383
  );
5384
+ },
5385
+ onError: (errState) => {
5386
+ setIoError(errState);
5387
+ setStatusTip(`\u5BFC\u5165\u5931\u8D25: ${errState.message}`);
5213
5388
  }
5214
- setStatusTip(
5215
- `\u5DF2\u5B8C\u6210\u300C${outcome.fileName || file.name}\u300D\u9884\u89E3\u6790\uFF08\u5C1A\u672A\u8986\u76D6\u5F53\u524D\u8BBE\u8BA1\u5668\u6587\u6863\uFF0C\u8BF7\u786E\u8BA4\u540E\u5E94\u7528\uFF09`
5216
- );
5217
- } catch (err) {
5218
- const message = err?.message || String(err);
5219
- setIoError({
5220
- operation: "import",
5221
- failedTarget: activeTarget,
5222
- message
5223
- });
5224
- setStatusTip(`\u5BFC\u5165\u5931\u8D25: ${message}`);
5225
- }
5389
+ });
5226
5390
  };
5227
5391
  const handleFileInputChange = (e) => {
5228
5392
  const file = e.target.files?.[0];
@@ -5240,18 +5404,26 @@ var DocPreviewAndIoModal = () => {
5240
5404
  };
5241
5405
  const handleConfirmStagedImport = () => {
5242
5406
  if (!pendingImport) return;
5243
- if (pendingImport.snapshot.body) {
5244
- commandService.syncExecuteCommand(ReplaceDocUnitSnapshotCommand3.id, {
5245
- unitId: unit.getUnitId(),
5246
- snapshot: pendingImport.snapshot
5247
- });
5407
+ const result = confirmStagedDocImport({
5408
+ commandService,
5409
+ unitId: unit.getUnitId(),
5410
+ pendingImport
5411
+ });
5412
+ if (!result.ok) {
5413
+ setIoError(result.ioError);
5414
+ setStatusTip(result.statusTip);
5415
+ return;
5248
5416
  }
5249
5417
  setPendingImport(null);
5418
+ setIoError(null);
5250
5419
  setJsonEditorText(JSON.stringify(unit.getSnapshot(), null, 2));
5251
5420
  setPreviewHtml(exportDocHtmlString(unit.getSnapshot(), void 0, { printFieldsOnly }));
5252
- setStatusTip("\u5DF2\u5E94\u7528\u5230\u5F53\u524D\u8BBE\u8BA1\u5668\uFF0C\u8BF7\u7531\u5BBF\u4E3B\u4FDD\u5B58");
5421
+ setStatusTip(result.statusTip);
5253
5422
  };
5254
5423
  const handleCancelStagedImport = () => {
5424
+ importReqSeqRef.current += 1;
5425
+ importAbortRef.current?.abort();
5426
+ importAbortRef.current = null;
5255
5427
  setPendingImport(null);
5256
5428
  setPreviewHtml(exportDocHtmlString(unit.getSnapshot(), void 0, { printFieldsOnly }));
5257
5429
  setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u6587\u6863\u672A\u505A\u4FEE\u6539");
@@ -5281,7 +5453,7 @@ var DocPreviewAndIoModal = () => {
5281
5453
  }
5282
5454
  };
5283
5455
  const stagedStats = pendingImport?.snapshot?.body ? getDocumentStats2(pendingImport.snapshot) : null;
5284
- const renderIoControlCard = () => /* @__PURE__ */ jsxs4(
5456
+ const renderIoControlCard = (opts) => /* @__PURE__ */ jsxs4(
5285
5457
  "div",
5286
5458
  {
5287
5459
  style: {
@@ -5356,49 +5528,51 @@ var DocPreviewAndIoModal = () => {
5356
5528
  }
5357
5529
  )
5358
5530
  ] }),
5359
- /* @__PURE__ */ jsx4(
5360
- "input",
5361
- {
5362
- ref: fileInputRef,
5363
- type: "file",
5364
- "data-testid": "yudao-io-file-input",
5365
- accept: DOC_IMPORT_ACCEPT_EXTENSIONS,
5366
- style: { display: "none" },
5367
- onChange: handleFileInputChange
5368
- }
5369
- ),
5370
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
5531
+ !opts?.hideFilePicker && /* @__PURE__ */ jsxs4(Fragment3, { children: [
5371
5532
  /* @__PURE__ */ jsx4(
5372
- "button",
5533
+ "input",
5373
5534
  {
5374
- type: "button",
5375
- "data-testid": "yudao-io-pick-file",
5376
- className: "yudao-doc-mini-btn",
5377
- style: { flex: 1 },
5378
- onClick: () => {
5379
- if (fileInputRef.current) {
5380
- fileInputRef.current.value = "";
5381
- fileInputRef.current.click();
5382
- }
5383
- },
5384
- children: "\u9009\u62E9\u6587\u4EF6\u9884\u5BFC\u5165"
5535
+ ref: fileInputRef,
5536
+ type: "file",
5537
+ "data-testid": "yudao-io-file-input",
5538
+ accept: DOC_IMPORT_ACCEPT_EXTENSIONS,
5539
+ style: { display: "none" },
5540
+ onChange: handleFileInputChange
5385
5541
  }
5386
5542
  ),
5387
- selectedImportFile && !pendingImport && /* @__PURE__ */ jsx4(
5388
- "span",
5389
- {
5390
- style: {
5391
- fontSize: 10.5,
5392
- color: "#4e5565",
5393
- maxWidth: 130,
5394
- overflow: "hidden",
5395
- textOverflow: "ellipsis",
5396
- whiteSpace: "nowrap"
5397
- },
5398
- title: selectedImportFile.name,
5399
- children: selectedImportFile.name
5400
- }
5401
- )
5543
+ /* @__PURE__ */ jsxs4("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
5544
+ /* @__PURE__ */ jsx4(
5545
+ "button",
5546
+ {
5547
+ type: "button",
5548
+ "data-testid": "yudao-io-pick-file",
5549
+ className: "yudao-doc-mini-btn",
5550
+ style: { flex: 1 },
5551
+ onClick: () => {
5552
+ if (fileInputRef.current) {
5553
+ fileInputRef.current.value = "";
5554
+ fileInputRef.current.click();
5555
+ }
5556
+ },
5557
+ children: "\u9009\u62E9\u6587\u4EF6\u9884\u5BFC\u5165"
5558
+ }
5559
+ ),
5560
+ selectedImportFile && !pendingImport && /* @__PURE__ */ jsx4(
5561
+ "span",
5562
+ {
5563
+ style: {
5564
+ fontSize: 10.5,
5565
+ color: "#4e5565",
5566
+ maxWidth: 130,
5567
+ overflow: "hidden",
5568
+ textOverflow: "ellipsis",
5569
+ whiteSpace: "nowrap"
5570
+ },
5571
+ title: selectedImportFile.name,
5572
+ children: selectedImportFile.name
5573
+ }
5574
+ )
5575
+ ] })
5402
5576
  ] }),
5403
5577
  pendingImport && /* @__PURE__ */ jsxs4(
5404
5578
  "div",
@@ -5527,6 +5701,17 @@ var DocPreviewAndIoModal = () => {
5527
5701
  ]
5528
5702
  }
5529
5703
  );
5704
+ const tabLabels = {
5705
+ import: "\u6587\u6863\u5BFC\u5165",
5706
+ export: "\u6587\u6863\u5BFC\u51FA",
5707
+ print: "\u6253\u5370\u9884\u89C8",
5708
+ preview: "\u5957\u6253\u9884\u89C8\u4E0E\u5BFC\u51FA",
5709
+ form: "\u7ED3\u6784\u5316\u8868\u5355\u6821\u9A8C\u4E0E\u53D6\u503C",
5710
+ json: "{ } Univer IDocumentData \u5951\u7EA6"
5711
+ };
5712
+ const isSplitPaneTab = effectiveTab === "import" || effectiveTab === "export" || effectiveTab === "print" || effectiveTab === "preview";
5713
+ const showPrintSettingsSection = !hasCompactTabs || effectiveTab === "print" || effectiveTab === "preview";
5714
+ const showExportActionsSection = !hasCompactTabs || effectiveTab === "export" || effectiveTab === "print" || effectiveTab === "preview";
5530
5715
  return /* @__PURE__ */ jsx4("div", { className: "yudao-doc-modal-backdrop", onClick: () => featureService.closeModal(), children: /* @__PURE__ */ jsxs4(
5531
5716
  "div",
5532
5717
  {
@@ -5535,48 +5720,22 @@ var DocPreviewAndIoModal = () => {
5535
5720
  onClick: (e) => e.stopPropagation(),
5536
5721
  children: [
5537
5722
  /* @__PURE__ */ jsxs4("div", { className: "yudao-doc-modal-header", children: [
5538
- /* @__PURE__ */ jsxs4("div", { className: "yudao-doc-modal-tabs", children: [
5539
- /* @__PURE__ */ jsx4(
5540
- "button",
5541
- {
5542
- type: "button",
5543
- className: `yudao-doc-modal-tab ${tab === "import" ? "is-active" : ""}`,
5544
- onClick: () => featureService.setModalTab("import"),
5545
- children: "\u6587\u6863\u5BFC\u5165"
5546
- }
5547
- ),
5548
- /* @__PURE__ */ jsx4(
5549
- "button",
5550
- {
5551
- type: "button",
5552
- className: `yudao-doc-modal-tab ${tab === "preview" ? "is-active" : ""}`,
5553
- onClick: () => featureService.setModalTab("preview"),
5554
- children: "\u5957\u6253\u9884\u89C8\u4E0E\u5BFC\u51FA"
5555
- }
5556
- ),
5557
- features.sdtControls && /* @__PURE__ */ jsx4(
5558
- "button",
5559
- {
5560
- type: "button",
5561
- className: `yudao-doc-modal-tab ${tab === "form" ? "is-active" : ""}`,
5562
- onClick: () => featureService.setModalTab("form"),
5563
- children: "\u7ED3\u6784\u5316\u8868\u5355\u6821\u9A8C\u4E0E\u53D6\u503C"
5564
- }
5565
- ),
5566
- /* @__PURE__ */ jsx4(
5567
- "button",
5568
- {
5569
- type: "button",
5570
- className: `yudao-doc-modal-tab ${tab === "json" ? "is-active" : ""}`,
5571
- onClick: () => featureService.setModalTab("json"),
5572
- children: `{ } Univer IDocumentData \u5951\u7EA6`
5573
- }
5574
- )
5575
- ] }),
5723
+ /* @__PURE__ */ jsx4("div", { className: "yudao-doc-modal-tabs", children: visibleTabs.map((tabKey) => /* @__PURE__ */ jsx4(
5724
+ "button",
5725
+ {
5726
+ type: "button",
5727
+ "data-testid": `yudao-io-tab-${tabKey}`,
5728
+ className: `yudao-doc-modal-tab ${effectiveTab === tabKey ? "is-active" : ""}`,
5729
+ onClick: () => featureService.setModalTab(tabKey),
5730
+ children: tabLabels[tabKey]
5731
+ },
5732
+ tabKey
5733
+ )) }),
5576
5734
  /* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
5577
- /* @__PURE__ */ jsxs4(
5735
+ showPipelineBadge && /* @__PURE__ */ jsxs4(
5578
5736
  "span",
5579
5737
  {
5738
+ "data-testid": "yudao-io-pipeline-badge",
5580
5739
  style: {
5581
5740
  fontSize: 11,
5582
5741
  padding: "3px 8px",
@@ -5603,7 +5762,7 @@ var DocPreviewAndIoModal = () => {
5603
5762
  )
5604
5763
  ] })
5605
5764
  ] }),
5606
- tab === "import" || tab === "preview" ? /* @__PURE__ */ jsxs4("div", { style: { flex: 1, minHeight: 0, display: "flex" }, children: [
5765
+ isSplitPaneTab ? /* @__PURE__ */ jsxs4("div", { style: { flex: 1, minHeight: 0, display: "flex" }, children: [
5607
5766
  /* @__PURE__ */ jsxs4(
5608
5767
  "div",
5609
5768
  {
@@ -5618,7 +5777,8 @@ var DocPreviewAndIoModal = () => {
5618
5777
  overflowY: "auto"
5619
5778
  },
5620
5779
  children: [
5621
- tab === "import" && renderIoControlCard(),
5780
+ effectiveTab === "import" && renderIoControlCard(),
5781
+ hasCompactTabs && effectiveTab === "export" && renderIoControlCard({ hideFilePicker: true }),
5622
5782
  features.datasetBinding ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
5623
5783
  /* @__PURE__ */ jsx4("div", { style: { fontSize: 12, fontWeight: 600, color: "#1b1c1f" }, children: "\u4E1A\u52A1\u6570\u636E\u96C6 JSON\uFF08\u652F\u6301\u5355\u6761\u5BF9\u8C61\u6216\u6279\u91CF\u6570\u7EC4 [...]\uFF09" }),
5624
5784
  /* @__PURE__ */ jsx4(
@@ -5652,7 +5812,7 @@ var DocPreviewAndIoModal = () => {
5652
5812
  /* @__PURE__ */ jsx4("code", { children: ".md" }),
5653
5813
  " \u7B49\u6587\u6863\u683C\u5F0F\u3002"
5654
5814
  ] }),
5655
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: 6, paddingTop: 4, borderTop: "1px solid #e3e5ea" }, children: [
5815
+ showPrintSettingsSection && /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: 6, paddingTop: 4, borderTop: "1px solid #e3e5ea" }, children: [
5656
5816
  /* @__PURE__ */ jsx4(
5657
5817
  "input",
5658
5818
  {
@@ -5862,8 +6022,9 @@ var DocPreviewAndIoModal = () => {
5862
6022
  )
5863
6023
  ] })
5864
6024
  ] }),
5865
- tab !== "import" && renderIoControlCard(),
5866
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 2 }, children: [
6025
+ !hasCompactTabs && effectiveTab !== "import" && renderIoControlCard(),
6026
+ hasCompactTabs && effectiveTab === "preview" && renderIoControlCard(),
6027
+ showExportActionsSection && /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 2 }, children: [
5867
6028
  /* @__PURE__ */ jsxs4("div", { style: { display: "flex", gap: 6 }, children: [
5868
6029
  /* @__PURE__ */ jsxs4(
5869
6030
  "select",
@@ -5946,6 +6107,7 @@ var DocPreviewAndIoModal = () => {
5946
6107
  "button",
5947
6108
  {
5948
6109
  type: "button",
6110
+ "data-testid": "yudao-io-print-btn",
5949
6111
  className: "yudao-doc-mini-btn yudao-doc-export-btn",
5950
6112
  style: { gridColumn: "1 / -1" },
5951
6113
  onClick: () => {
@@ -6000,7 +6162,7 @@ var DocPreviewAndIoModal = () => {
6000
6162
  }
6001
6163
  }
6002
6164
  ) })
6003
- ] }) : tab === "form" ? /* @__PURE__ */ jsxs4("div", { style: { flex: 1, minHeight: 0, padding: 18, display: "flex", gap: 16 }, children: [
6165
+ ] }) : effectiveTab === "form" ? /* @__PURE__ */ jsxs4("div", { style: { flex: 1, minHeight: 0, padding: 18, display: "flex", gap: 16 }, children: [
6004
6166
  /* @__PURE__ */ jsxs4("div", { style: { width: 320, display: "flex", flexDirection: "column", gap: 10 }, children: [
6005
6167
  /* @__PURE__ */ jsx4(
6006
6168
  "div",
@@ -6085,10 +6247,19 @@ var DocPreviewAndIoModal = () => {
6085
6247
  onClick: () => {
6086
6248
  try {
6087
6249
  const parsed = JSON.parse(jsonEditorText);
6088
- commandService.syncExecuteCommand(ReplaceDocUnitSnapshotCommand3.id, {
6089
- unitId: unit.getUnitId(),
6090
- snapshot: parsed
6091
- });
6250
+ const ok = commandService.syncExecuteCommand(
6251
+ ReplaceDocUnitSnapshotCommand3.id,
6252
+ {
6253
+ unitId: unit.getUnitId(),
6254
+ snapshot: parsed
6255
+ }
6256
+ );
6257
+ if (!ok) {
6258
+ setStatusTip(
6259
+ "\u5E94\u7528 JSON \u5FEB\u7167\u5931\u8D25\uFF1A\u5FEB\u7167\u7ED3\u6784\u4E0D\u5408\u6CD5\u6216\u5F53\u524D\u6587\u6863\u5904\u4E8E\u53EA\u8BFB\u6A21\u5F0F"
6260
+ );
6261
+ return;
6262
+ }
6092
6263
  setStatusTip("\u5DF2\u5E94\u7528 JSON \u5FEB\u7167\uFF08\u652F\u6301 Ctrl+Z \u64A4\u9500\uFF09\uFF01");
6093
6264
  } catch (err) {
6094
6265
  setStatusTip(`JSON \u683C\u5F0F\u6709\u8BEF: ${err?.message || String(err)}`);
@@ -8256,7 +8427,7 @@ var UniverDocsExtUIPlugin = class extends Plugin {
8256
8427
  this._injector.add([
8257
8428
  IDocsUIFeatureService,
8258
8429
  {
8259
- useFactory: () => new DocsUIFeatureService(this._config.features)
8430
+ useFactory: () => new DocsUIFeatureService(this._config.features, this._config.ioModal)
8260
8431
  }
8261
8432
  ]);
8262
8433
  this._injector.add([
@@ -8299,11 +8470,13 @@ export {
8299
8470
  UniverDocsExtUIPlugin,
8300
8471
  UpdateDocsUIFeaturesOperation,
8301
8472
  YUDAO_DOC_FIELD_DND_MIME,
8473
+ confirmStagedDocImport,
8302
8474
  en_US_default as enUS,
8303
8475
  isDocSdtKindAllowed,
8304
8476
  openDocInspectorSidebar,
8305
8477
  resolveDocsUIFeatures,
8306
8478
  resolveEffectiveSdtDatasetBinding,
8479
+ runGuardedStagedImport,
8307
8480
  zh_CN_default as zhCN
8308
8481
  };
8309
8482
  //# sourceMappingURL=index.js.map