@yudaocode/univer-pdfs-ui 1.6.214 → 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
@@ -466,6 +466,63 @@ import {
466
466
  // src/services/pdfs-ui-feature.service.ts
467
467
  import { createIdentifier, Disposable } from "@univerjs/core";
468
468
  import { BehaviorSubject } from "rxjs";
469
+ var ALL_PDF_IO_MODAL_TABS = [
470
+ "preview",
471
+ "import",
472
+ "export",
473
+ "json"
474
+ ];
475
+ function isValidPdfModalTab(val) {
476
+ return val === "preview" || val === "import" || val === "export" || val === "json";
477
+ }
478
+ function resolvePdfIoModalConfig(raw, base) {
479
+ let tabs;
480
+ let hasExplicitTabs;
481
+ if (Array.isArray(raw?.tabs)) {
482
+ const deduped = [];
483
+ for (const item of raw.tabs) {
484
+ if (isValidPdfModalTab(item) && !deduped.includes(item)) {
485
+ deduped.push(item);
486
+ }
487
+ }
488
+ if (deduped.length > 0) {
489
+ tabs = deduped;
490
+ hasExplicitTabs = true;
491
+ } else {
492
+ tabs = base?.tabs ? [...base.tabs] : [...ALL_PDF_IO_MODAL_TABS];
493
+ hasExplicitTabs = Boolean(base?.hasExplicitTabs);
494
+ }
495
+ } else {
496
+ tabs = base?.tabs ? [...base.tabs] : [...ALL_PDF_IO_MODAL_TABS];
497
+ hasExplicitTabs = Boolean(base?.hasExplicitTabs);
498
+ }
499
+ const candidateDefault = raw?.defaultTab ?? base?.defaultTab ?? "preview";
500
+ let defaultTab;
501
+ if (isValidPdfModalTab(candidateDefault) && tabs.includes(candidateDefault)) {
502
+ defaultTab = candidateDefault;
503
+ } else if ((candidateDefault === "import" || candidateDefault === "export") && tabs.includes("preview")) {
504
+ defaultTab = "preview";
505
+ } else {
506
+ defaultTab = tabs[0] ?? "preview";
507
+ }
508
+ return {
509
+ tabs,
510
+ defaultTab,
511
+ showPipelineBadge: raw?.showPipelineBadge ?? base?.showPipelineBadge ?? true,
512
+ hasExplicitTabs
513
+ };
514
+ }
515
+ function clampPdfModalTab(requested, config) {
516
+ if (isValidPdfModalTab(requested)) {
517
+ if (config.tabs.includes(requested)) {
518
+ return requested;
519
+ }
520
+ if ((requested === "import" || requested === "export") && config.tabs.includes("preview")) {
521
+ return "preview";
522
+ }
523
+ }
524
+ return config.defaultTab;
525
+ }
469
526
  function resolvePdfsUIFeatures(raw) {
470
527
  const rw = raw?.reportWidgets;
471
528
  const qrcode = typeof rw === "boolean" ? rw : Boolean(rw?.qrcode);
@@ -511,20 +568,24 @@ var IPdfsUIFeatureService = createIdentifier(
511
568
  "yudao.univer-pdfs-ui.feature.service"
512
569
  );
513
570
  var PdfsUIFeatureService = class extends Disposable {
514
- constructor(initial, editorEnabled = true) {
571
+ constructor(initial, editorEnabled = true, ioModal) {
515
572
  super();
516
- this._modalTab$ = new BehaviorSubject("preview");
517
- this.modalTab$ = this._modalTab$.asObservable();
573
+ this._baseIoModal = resolvePdfIoModalConfig(ioModal);
518
574
  this._features$ = new BehaviorSubject(resolvePdfsUIFeatures(initial));
575
+ this._modalTab$ = new BehaviorSubject(this._baseIoModal.defaultTab);
519
576
  this._editorEnabled$ = new BehaviorSubject(editorEnabled);
577
+ this._ioModal$ = new BehaviorSubject(this._baseIoModal);
520
578
  this.features$ = this._features$.asObservable();
579
+ this.modalTab$ = this._modalTab$.asObservable();
521
580
  this.editorEnabled$ = this._editorEnabled$.asObservable();
581
+ this.ioModal$ = this._ioModal$.asObservable();
522
582
  }
523
583
  dispose() {
524
584
  super.dispose();
525
585
  this._features$.complete();
526
586
  this._modalTab$.complete();
527
587
  this._editorEnabled$.complete();
588
+ this._ioModal$.complete();
528
589
  }
529
590
  getFeatures() {
530
591
  return this._features$.getValue();
@@ -542,7 +603,27 @@ var PdfsUIFeatureService = class extends Disposable {
542
603
  return this._modalTab$.getValue();
543
604
  }
544
605
  setModalTab(tab) {
545
- this._modalTab$.next(tab);
606
+ this._modalTab$.next(clampPdfModalTab(tab, this._ioModal$.getValue()));
607
+ }
608
+ getIoModalConfig() {
609
+ const cur = this._ioModal$.getValue();
610
+ return {
611
+ ...cur,
612
+ tabs: [...cur.tabs]
613
+ };
614
+ }
615
+ setIoModalConfig(config) {
616
+ this._baseIoModal = resolvePdfIoModalConfig(config);
617
+ this._ioModal$.next(this._baseIoModal);
618
+ this._modalTab$.next(clampPdfModalTab(this._modalTab$.getValue(), this._baseIoModal));
619
+ }
620
+ applyModalOpenConfig(override) {
621
+ const resolved = override ? resolvePdfIoModalConfig(override, this._baseIoModal) : {
622
+ ...this._baseIoModal,
623
+ tabs: [...this._baseIoModal.tabs]
624
+ };
625
+ this._ioModal$.next(resolved);
626
+ return resolved;
546
627
  }
547
628
  isEditorEnabled() {
548
629
  return this._editorEnabled$.getValue();
@@ -585,7 +666,9 @@ var OpenPdfPreviewOperation = {
585
666
  const selectionService = accessor.get(IPdfSelectionService);
586
667
  selectionService.commitActiveEditing();
587
668
  selectionService.setEditingElement(null);
588
- accessor.get(IPdfsUIFeatureService).setModalTab(params?.tab ?? "preview");
669
+ const featureService = accessor.get(IPdfsUIFeatureService);
670
+ const effectiveIoModal = featureService.applyModalOpenConfig(params?.ioModal);
671
+ featureService.setModalTab(clampPdfModalTab(params?.tab, effectiveIoModal));
589
672
  selectionService.setPreviewOpen(true);
590
673
  return true;
591
674
  }
@@ -593,7 +676,8 @@ var OpenPdfPreviewOperation = {
593
676
  async function readBrowserFileAsOverlayOutcome(file, options) {
594
677
  const validated = await importPdfSource(file, {
595
678
  fileName: file.name,
596
- password: options?.password
679
+ password: options?.password,
680
+ signal: options?.signal
597
681
  });
598
682
  return {
599
683
  mode: "overlay",
@@ -612,7 +696,8 @@ var UploadBasePdfOperation = {
612
696
  selectionService.commitActiveEditing();
613
697
  selectionService.setEditingElement(null);
614
698
  if (!params?.file) {
615
- featureService.setModalTab("import");
699
+ const effectiveIoModal = featureService.applyModalOpenConfig(params?.ioModal);
700
+ featureService.setModalTab(clampPdfModalTab("import", effectiveIoModal));
616
701
  selectionService.setPreviewOpen(true);
617
702
  return true;
618
703
  }
@@ -625,8 +710,12 @@ var UploadBasePdfOperation = {
625
710
  unitId: unit.getUnitId(),
626
711
  snapshot: unit.save(),
627
712
  target: params.target,
628
- password: params.password
713
+ password: params.password,
714
+ signal: params.signal
629
715
  }).then((outcome) => {
716
+ if (params.signal?.aborted) {
717
+ return false;
718
+ }
630
719
  if (outcome.mode === "snapshot") {
631
720
  return commandService.syncExecuteCommand(ReplacePdfSnapshotCommand.id, {
632
721
  unitId: unit.getUnitId(),
@@ -916,6 +1005,9 @@ var UpdatePdfUIFeaturesOperation = {
916
1005
  if (typeof params?.editorEnabled === "boolean") {
917
1006
  featureService.setEditorEnabled(params.editorEnabled);
918
1007
  }
1008
+ if (params?.ioModal !== void 0) {
1009
+ featureService.setIoModalConfig(params.ioModal);
1010
+ }
919
1011
  return true;
920
1012
  }
921
1013
  };
@@ -1053,19 +1145,53 @@ function loadPdfDocument(dataUri, overrideAssets) {
1053
1145
  const effectiveAssets = overrideAssets ?? configuredAssets ?? resolveGlobalPdfjsAssets();
1054
1146
  ensurePdfjsWorker(effectiveAssets);
1055
1147
  const bytes = dataUriToUint8Array(dataUri);
1056
- const cacheKey = computePdfPayloadDigest(bytes);
1148
+ const cacheKey = `${computePdfPayloadDigest(bytes)}|${effectiveAssets?.cMapUrl ?? ""}`;
1057
1149
  const existing = docCache.get(cacheKey);
1058
- if (existing) {
1150
+ if (existing && existing.cMapFailures.length === 0) {
1059
1151
  touchCacheEntry(cacheKey, existing);
1060
- return existing.promise;
1152
+ return { promise: existing.promise, entry: existing, cacheKey };
1061
1153
  }
1154
+ const cMapFailures = [];
1062
1155
  const docInitParams = {
1063
1156
  data: bytes.slice(),
1064
1157
  isEvalSupported: false
1065
1158
  };
1066
1159
  if (effectiveAssets?.cMapUrl) {
1067
- docInitParams.cMapUrl = effectiveAssets.cMapUrl;
1068
- docInitParams.cMapPacked = effectiveAssets.cMapPacked ?? true;
1160
+ const cMapUrl = effectiveAssets.cMapUrl;
1161
+ const cMapPacked = effectiveAssets.cMapPacked ?? true;
1162
+ const normalizedBase = cMapUrl.endsWith("/") ? cMapUrl : `${cMapUrl}/`;
1163
+ docInitParams.cMapUrl = normalizedBase;
1164
+ docInitParams.cMapPacked = cMapPacked;
1165
+ docInitParams.CMapReaderFactory = class BgTrackedCMapReaderFactory {
1166
+ constructor(params) {
1167
+ this.baseUrl = params?.baseUrl ?? normalizedBase;
1168
+ this.isCompressed = params?.isCompressed ?? cMapPacked;
1169
+ }
1170
+ async fetch({ name }) {
1171
+ const base = this.baseUrl.endsWith("/") ? this.baseUrl : `${this.baseUrl}/`;
1172
+ const url = `${base}${name}${this.isCompressed ? ".bcmap" : ""}`;
1173
+ let resp;
1174
+ try {
1175
+ resp = await fetch(url);
1176
+ } catch (err) {
1177
+ const reason = err?.message || String(err);
1178
+ cMapFailures.push({ name, url, reason });
1179
+ throw new Error(`Unable to load CMap at ${url}: ${reason}`);
1180
+ }
1181
+ if (!resp.ok) {
1182
+ const reason = `HTTP ${resp.status}`;
1183
+ cMapFailures.push({ name, url, reason });
1184
+ throw new Error(`Unable to load CMap at ${url}: ${reason}`);
1185
+ }
1186
+ const buf = new Uint8Array(await resp.arrayBuffer());
1187
+ if (buf.byteLength === 0) {
1188
+ const reason = "Empty CMap payload";
1189
+ cMapFailures.push({ name, url, reason });
1190
+ throw new Error(`Unable to load CMap at ${url}: ${reason}`);
1191
+ }
1192
+ return { cMapData: buf, isCompressed: this.isCompressed };
1193
+ }
1194
+ };
1069
1195
  }
1070
1196
  if (effectiveAssets?.standardFontDataUrl) {
1071
1197
  docInitParams.standardFontDataUrl = effectiveAssets.standardFontDataUrl;
@@ -1075,6 +1201,7 @@ function loadPdfDocument(dataUri, overrideAssets) {
1075
1201
  }
1076
1202
  const loadingTask = pdfjsLib.getDocument(docInitParams);
1077
1203
  const entry = {
1204
+ cMapFailures,
1078
1205
  promise: loadingTask.promise.then((doc) => {
1079
1206
  entry.resolvedDoc = doc;
1080
1207
  return doc;
@@ -1087,10 +1214,11 @@ function loadPdfDocument(dataUri, overrideAssets) {
1087
1214
  };
1088
1215
  docCache.set(cacheKey, entry);
1089
1216
  evictOverflowCacheEntries();
1090
- return entry.promise;
1217
+ return { promise: entry.promise, entry, cacheKey };
1091
1218
  }
1092
1219
  async function inspectSourcePdfPages(dataUri, assets) {
1093
- const doc = await loadPdfDocument(dataUri, assets);
1220
+ const { promise: docPromise } = loadPdfDocument(dataUri, assets);
1221
+ const doc = await docPromise;
1094
1222
  const sizes = [];
1095
1223
  for (let i = 1; i <= doc.numPages; i++) {
1096
1224
  const page = await doc.getPage(i);
@@ -1122,7 +1250,8 @@ async function renderSourcePdfPageToCanvas(canvas, dataUri, pageNumber, targetWi
1122
1250
  } catch {
1123
1251
  }
1124
1252
  }
1125
- const doc = await loadPdfDocument(dataUri, assets);
1253
+ const { promise: docPromise, entry: docEntry, cacheKey } = loadPdfDocument(dataUri, assets);
1254
+ const doc = await docPromise;
1126
1255
  if (activeCanvasRenderTasks.has(canvas)) {
1127
1256
  return;
1128
1257
  }
@@ -1143,6 +1272,17 @@ async function renderSourcePdfPageToCanvas(canvas, dataUri, pageNumber, targetWi
1143
1272
  activeCanvasRenderTasks.set(canvas, renderTask);
1144
1273
  try {
1145
1274
  await renderTask.promise;
1275
+ if (docEntry.cMapFailures.length > 0) {
1276
+ const f = docEntry.cMapFailures[0];
1277
+ if (docCache.get(cacheKey) === docEntry) {
1278
+ docCache.delete(cacheKey);
1279
+ }
1280
+ const err = new Error(
1281
+ `PDF \u4E2D\u6587\u5B57\u4F53 CMap \u8D44\u6E90\u52A0\u8F7D\u5931\u8D25\uFF08${f.name}\uFF1A${f.url}\uFF0C${f.reason}\uFF09`
1282
+ );
1283
+ err.code = "CMAP_LOAD_FAILED";
1284
+ throw err;
1285
+ }
1146
1286
  } catch (err) {
1147
1287
  if (isRenderingCancelledError(err)) {
1148
1288
  return;
@@ -8261,6 +8401,69 @@ function resolveFallbackTarget(err, attemptedTarget) {
8261
8401
  }
8262
8402
  return attemptedTarget === "server" ? "browser" : "server";
8263
8403
  }
8404
+ async function executeGuardedStagedImport(params) {
8405
+ params.importAbortRef?.current?.abort();
8406
+ const reqSeq = ++params.importReqSeqRef.current;
8407
+ const controller = typeof AbortController === "function" ? new AbortController() : null;
8408
+ if (params.importAbortRef) {
8409
+ params.importAbortRef.current = controller;
8410
+ }
8411
+ params.onStart?.();
8412
+ try {
8413
+ const report = await params.ioService.importPdfWithReport(params.file, {
8414
+ unitId: params.unitId,
8415
+ target: params.target,
8416
+ ...controller ? { signal: controller.signal } : {}
8417
+ });
8418
+ if (reqSeq !== params.importReqSeqRef.current || controller?.signal.aborted) {
8419
+ return null;
8420
+ }
8421
+ params.onSuccess(report);
8422
+ return report;
8423
+ } catch (err) {
8424
+ if (reqSeq !== params.importReqSeqRef.current || controller?.signal.aborted || err?.name === "AbortError") {
8425
+ return null;
8426
+ }
8427
+ const fallbackTarget = resolveFallbackTarget(err, params.target);
8428
+ const msg = err?.message || String(err);
8429
+ params.onError({
8430
+ operation: "import",
8431
+ message: `PDF \u5BFC\u5165\u89E3\u6790\u5931\u8D25: ${msg}`,
8432
+ failedTarget: params.target,
8433
+ fallbackTarget
8434
+ });
8435
+ return null;
8436
+ } finally {
8437
+ if (reqSeq === params.importReqSeqRef.current) {
8438
+ if (params.importAbortRef && params.importAbortRef.current === controller) {
8439
+ params.importAbortRef.current = null;
8440
+ }
8441
+ params.onSettled?.();
8442
+ }
8443
+ }
8444
+ }
8445
+ function applyStagedPdfImportToUnit(commandService, unitId, staged) {
8446
+ const applied = staged.outcome.mode === "overlay" ? commandService.syncExecuteCommand(ImportPdfSourceCommand2.id, {
8447
+ unitId,
8448
+ sourceDocumentRef: staged.outcome.sourceDocumentRef,
8449
+ pageSizes: staged.outcome.pageSizes
8450
+ }) : commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
8451
+ unitId,
8452
+ snapshot: staged.snapshot
8453
+ });
8454
+ if (!applied) {
8455
+ return {
8456
+ applied: false,
8457
+ error: {
8458
+ operation: "import",
8459
+ message: "\u5E94\u7528\u5BFC\u5165\u5FEB\u7167\u5230\u8BBE\u8BA1\u5668\u5931\u8D25\uFF1A\u547D\u4EE4\u6267\u884C\u8FD4\u56DE false\uFF0C\u5F53\u524D\u6587\u6863\u672A\u88AB\u4FEE\u6539\u3002",
8460
+ failedTarget: staged.executedBy,
8461
+ fallbackTarget: staged.executedBy === "server" ? "browser" : "server"
8462
+ }
8463
+ };
8464
+ }
8465
+ return { applied: true };
8466
+ }
8264
8467
  function uint8ToDataUri(bytes) {
8265
8468
  let binary = "";
8266
8469
  const chunkSize = 32768;
@@ -8355,6 +8558,7 @@ var PdfUnifiedIoSection = ({
8355
8558
  serverAvailable,
8356
8559
  snapSizeKb,
8357
8560
  editorEnabled,
8561
+ showImportSection = true,
8358
8562
  importing,
8359
8563
  rendering,
8360
8564
  selectedFileName,
@@ -8426,7 +8630,7 @@ var PdfUnifiedIoSection = ({
8426
8630
  ]
8427
8631
  }
8428
8632
  ),
8429
- editorEnabled && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-io-import-box", children: [
8633
+ editorEnabled && showImportSection && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-io-import-box", children: [
8430
8634
  /* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
8431
8635
  /* @__PURE__ */ jsx6("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "PDF / \u6A21\u677F\u5206\u9636\u6BB5\u5BFC\u5165" }),
8432
8636
  selectedFileName && !pendingImport && /* @__PURE__ */ jsx6(
@@ -8556,6 +8760,7 @@ var PdfPreviewModal = () => {
8556
8760
  const featureService = useDependency5(IPdfsUIFeatureService);
8557
8761
  const features = useObservable5(featureService.features$, featureService.getFeatures());
8558
8762
  const editorEnabled = useObservable5(featureService.editorEnabled$, featureService.isEditorEnabled());
8763
+ const ioModal = useObservable5(featureService.ioModal$, featureService.getIoModalConfig());
8559
8764
  const ioAdapter = useObservable5(ioService.adapter$, ioService.getAdapter());
8560
8765
  const open = useObservable5(selectionService.previewOpen$, false);
8561
8766
  const modalTab = useObservable5(featureService.modalTab$, featureService.getModalTab());
@@ -8566,6 +8771,8 @@ var PdfPreviewModal = () => {
8566
8771
  [instanceService]
8567
8772
  );
8568
8773
  const fileInputRef = useRef3(null);
8774
+ const importReqSeqRef = useRef3(0);
8775
+ const importAbortRef = useRef3(null);
8569
8776
  const [sampleJsonText, setSampleJsonText] = useState5("{}");
8570
8777
  const [pdfBytesState, setPdfBytesState] = useState5(null);
8571
8778
  const [rendering, setRendering] = useState5(false);
@@ -8723,29 +8930,30 @@ var PdfPreviewModal = () => {
8723
8930
  const runStagedImport = async (file, overrideTarget) => {
8724
8931
  if (!unit) return;
8725
8932
  const effectiveTarget = overrideTarget ?? ioTarget;
8726
- setImporting(true);
8727
- setIoError(null);
8728
- setPendingImport(null);
8729
- setStatusTip("");
8730
- try {
8731
- const report = await ioService.importPdfWithReport(file, {
8732
- unitId: unit.getUnitId(),
8733
- target: effectiveTarget
8734
- });
8735
- setPendingImport(report);
8736
- } catch (err) {
8737
- setPendingImport(null);
8738
- const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8739
- const msg = err?.message || String(err);
8740
- setIoError({
8741
- operation: "import",
8742
- message: `PDF \u5BFC\u5165\u89E3\u6790\u5931\u8D25: ${msg}`,
8743
- failedTarget: effectiveTarget,
8744
- fallbackTarget
8745
- });
8746
- } finally {
8747
- setImporting(false);
8748
- }
8933
+ await executeGuardedStagedImport({
8934
+ file,
8935
+ unitId: unit.getUnitId(),
8936
+ target: effectiveTarget,
8937
+ ioService,
8938
+ importReqSeqRef,
8939
+ importAbortRef,
8940
+ onStart: () => {
8941
+ setImporting(true);
8942
+ setIoError(null);
8943
+ setPendingImport(null);
8944
+ setStatusTip("");
8945
+ },
8946
+ onSuccess: (report) => {
8947
+ setPendingImport(report);
8948
+ },
8949
+ onError: (errState) => {
8950
+ setPendingImport(null);
8951
+ setIoError(errState);
8952
+ },
8953
+ onSettled: () => {
8954
+ setImporting(false);
8955
+ }
8956
+ });
8749
8957
  };
8750
8958
  const handleImportFileChange = (e) => {
8751
8959
  const file = e.target.files?.[0];
@@ -8757,17 +8965,11 @@ var PdfPreviewModal = () => {
8757
8965
  const handleConfirmStagedImport = () => {
8758
8966
  if (!unit || !pendingImport) return;
8759
8967
  const staged = pendingImport;
8760
- if (staged.outcome.mode === "overlay") {
8761
- commandService.syncExecuteCommand(ImportPdfSourceCommand2.id, {
8762
- unitId: unit.getUnitId(),
8763
- sourceDocumentRef: staged.outcome.sourceDocumentRef,
8764
- pageSizes: staged.outcome.pageSizes
8765
- });
8766
- } else {
8767
- commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
8768
- unitId: unit.getUnitId(),
8769
- snapshot: staged.snapshot
8770
- });
8968
+ const outcomeResult = applyStagedPdfImportToUnit(commandService, unit.getUnitId(), staged);
8969
+ if (!outcomeResult.applied) {
8970
+ setIoError(outcomeResult.error ?? null);
8971
+ setStatusTip("");
8972
+ return;
8771
8973
  }
8772
8974
  setPendingImport(null);
8773
8975
  setIoError(null);
@@ -8792,6 +8994,10 @@ var PdfPreviewModal = () => {
8792
8994
  );
8793
8995
  };
8794
8996
  const handleCancelStagedImport = () => {
8997
+ importReqSeqRef.current += 1;
8998
+ importAbortRef.current?.abort();
8999
+ importAbortRef.current = null;
9000
+ setImporting(false);
8795
9001
  setPendingImport(null);
8796
9002
  setIoError(null);
8797
9003
  setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u5185\u5BB9\u672A\u53D8\u66F4");
@@ -8800,7 +9006,7 @@ var PdfPreviewModal = () => {
8800
9006
  setIoTarget(nextTarget);
8801
9007
  setIoError(null);
8802
9008
  setPdfBytesState(null);
8803
- if (modalTab === "preview") {
9009
+ if (modalTab === "preview" || modalTab === "export") {
8804
9010
  void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8805
9011
  } else if (modalTab === "import") {
8806
9012
  const caps = ioService.getIoCapabilities();
@@ -8823,8 +9029,19 @@ var PdfPreviewModal = () => {
8823
9029
  await generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8824
9030
  }
8825
9031
  };
9032
+ useEffect4(() => {
9033
+ return () => {
9034
+ importReqSeqRef.current += 1;
9035
+ importAbortRef.current?.abort();
9036
+ importAbortRef.current = null;
9037
+ };
9038
+ }, []);
8826
9039
  useEffect4(() => {
8827
9040
  if (!open) {
9041
+ importReqSeqRef.current += 1;
9042
+ importAbortRef.current?.abort();
9043
+ importAbortRef.current = null;
9044
+ setImporting(false);
8828
9045
  setPendingImport(null);
8829
9046
  setSelectedImportFile(null);
8830
9047
  setIoError(null);
@@ -8838,7 +9055,8 @@ var PdfPreviewModal = () => {
8838
9055
  const initialPdfA = Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant);
8839
9056
  const initialPdfUa = Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged);
8840
9057
  const caps = ioService.getIoCapabilities();
8841
- const initialTarget = resolveInitialModalIoTarget(caps, featureService.getModalTab());
9058
+ const activeTab = clampPdfModalTab(featureService.getModalTab(), ioModal);
9059
+ const initialTarget = resolveInitialModalIoTarget(caps, activeTab);
8842
9060
  setSampleJsonText(initialSampleText);
8843
9061
  setWatermarkText(initialWm);
8844
9062
  setExcludeBasePdf(initialStripBg);
@@ -8847,8 +9065,7 @@ var PdfPreviewModal = () => {
8847
9065
  setIoTarget(initialTarget);
8848
9066
  setIoError(null);
8849
9067
  setStatusTip("");
8850
- const activeTab = featureService.getModalTab();
8851
- if (activeTab === "preview") {
9068
+ if (activeTab === "preview" || activeTab === "export") {
8852
9069
  void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
8853
9070
  pdfACompliant: initialPdfA,
8854
9071
  accessibilityTagged: initialPdfUa
@@ -9070,7 +9287,14 @@ var PdfPreviewModal = () => {
9070
9287
  setStatusTip("\u672A\u8BC6\u522B\u7684 JSON \u683C\u5F0F\uFF1A\u8BF7\u63D0\u4F9B Univer IPdfUnitData \u6216 pdfme Template JSON");
9071
9288
  return;
9072
9289
  }
9073
- commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, { snapshot: nextSnapshot });
9290
+ const applied = commandService.syncExecuteCommand(ReplacePdfSnapshotCommand4.id, {
9291
+ unitId: unit.getUnitId(),
9292
+ snapshot: nextSnapshot
9293
+ });
9294
+ if (!applied) {
9295
+ setStatusTip("\u5E94\u7528\u6A21\u677F JSON \u5931\u8D25\uFF1AReplacePdfSnapshotCommand \u6267\u884C\u8FD4\u56DE false");
9296
+ return;
9297
+ }
9074
9298
  setStatusTip("\u5DF2\u6210\u529F\u5E94\u7528\u6A21\u677F JSON\uFF08\u652F\u6301 Ctrl+Z \u64A4\u9500\uFF09\uFF01");
9075
9299
  } catch (err) {
9076
9300
  setStatusTip(`JSON \u89E3\u6790\u9519\u8BEF: ${err?.message || String(err)}`);
@@ -9080,9 +9304,24 @@ var PdfPreviewModal = () => {
9080
9304
  const ioCaps = ioService.getIoCapabilities();
9081
9305
  const pdfCapReport = inspectPdfExportCapabilities(unit.save());
9082
9306
  const snapSizeKb = (pdfCapReport.snapshotByteSize / 1024).toFixed(1);
9083
- const isUnifiedIoTab = modalTab === "preview" || modalTab === "import";
9084
- const browserAvailable = modalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.browser) : Boolean(ioCaps.formats.export.pdf?.browser);
9085
- const serverAvailable = modalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.server) : Boolean(ioCaps.formats.export.pdf?.server);
9307
+ const effectiveModalTab = clampPdfModalTab(modalTab, ioModal);
9308
+ const isUnifiedIoTab = !(effectiveModalTab === "json" && ioModal.tabs.includes("json"));
9309
+ const showImportControls = !ioModal.hasExplicitTabs ? ioModal.tabs.includes("import") : effectiveModalTab === "import";
9310
+ const showExportControls = !ioModal.hasExplicitTabs ? ioModal.tabs.includes("export") : effectiveModalTab === "export";
9311
+ const browserAvailable = effectiveModalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.browser) : Boolean(ioCaps.formats.export.pdf?.browser);
9312
+ const serverAvailable = effectiveModalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.server) : Boolean(ioCaps.formats.export.pdf?.server);
9313
+ const tabLabelFor = (tabKey) => {
9314
+ switch (tabKey) {
9315
+ case "preview":
9316
+ return "PDF \u9884\u89C8";
9317
+ case "import":
9318
+ return "PDF \u5BFC\u5165";
9319
+ case "export":
9320
+ return "PDF \u5BFC\u51FA";
9321
+ case "json":
9322
+ return "{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)";
9323
+ }
9324
+ };
9086
9325
  const unifiedIoSection = /* @__PURE__ */ jsx6(
9087
9326
  PdfUnifiedIoSection,
9088
9327
  {
@@ -9091,6 +9330,7 @@ var PdfPreviewModal = () => {
9091
9330
  serverAvailable,
9092
9331
  snapSizeKb,
9093
9332
  editorEnabled,
9333
+ showImportSection: showImportControls,
9094
9334
  importing,
9095
9335
  rendering,
9096
9336
  selectedFileName: selectedImportFile?.name,
@@ -9115,11 +9355,12 @@ var PdfPreviewModal = () => {
9115
9355
  onClick: (e) => e.stopPropagation(),
9116
9356
  children: [
9117
9357
  /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-header", children: [
9118
- /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-modal-tabs", children: [
9358
+ /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-tabs", children: !ioModal.hasExplicitTabs ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
9119
9359
  /* @__PURE__ */ jsxs6(
9120
9360
  "button",
9121
9361
  {
9122
9362
  type: "button",
9363
+ "data-testid": "yudao-io-tab-preview",
9123
9364
  className: `univer-pdf-modal-tab ${isUnifiedIoTab ? "is-active" : ""}`,
9124
9365
  style: { display: "inline-flex", alignItems: "center", gap: 5 },
9125
9366
  onClick: () => featureService.setModalTab("preview"),
@@ -9129,20 +9370,36 @@ var PdfPreviewModal = () => {
9129
9370
  ]
9130
9371
  }
9131
9372
  ),
9132
- /* @__PURE__ */ jsx6(
9373
+ ioModal.tabs.includes("json") && /* @__PURE__ */ jsx6(
9133
9374
  "button",
9134
9375
  {
9135
9376
  type: "button",
9136
- className: `univer-pdf-modal-tab ${modalTab === "json" ? "is-active" : ""}`,
9377
+ "data-testid": "yudao-io-tab-json",
9378
+ className: `univer-pdf-modal-tab ${effectiveModalTab === "json" ? "is-active" : ""}`,
9137
9379
  onClick: () => featureService.setModalTab("json"),
9138
9380
  children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
9139
9381
  }
9140
9382
  )
9141
- ] }),
9383
+ ] }) : ioModal.tabs.map((tabKey) => /* @__PURE__ */ jsxs6(
9384
+ "button",
9385
+ {
9386
+ type: "button",
9387
+ "data-testid": `yudao-io-tab-${tabKey}`,
9388
+ className: `univer-pdf-modal-tab ${effectiveModalTab === tabKey ? "is-active" : ""}`,
9389
+ style: { display: "inline-flex", alignItems: "center", gap: 5 },
9390
+ onClick: () => featureService.setModalTab(tabKey),
9391
+ children: [
9392
+ tabKey !== "json" && /* @__PURE__ */ jsx6(UiFilePdfIcon, {}),
9393
+ /* @__PURE__ */ jsx6("span", { children: tabLabelFor(tabKey) })
9394
+ ]
9395
+ },
9396
+ tabKey
9397
+ )) }),
9142
9398
  /* @__PURE__ */ jsxs6("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
9143
- /* @__PURE__ */ jsxs6(
9399
+ ioModal.showPipelineBadge && /* @__PURE__ */ jsxs6(
9144
9400
  "span",
9145
9401
  {
9402
+ "data-testid": "yudao-io-pipeline-badge",
9146
9403
  style: {
9147
9404
  fontSize: 11,
9148
9405
  padding: "3px 8px",
@@ -9506,7 +9763,7 @@ var PdfPreviewModal = () => {
9506
9763
  }
9507
9764
  )
9508
9765
  ] }),
9509
- splitMergeQuickBox,
9766
+ showExportControls && splitMergeQuickBox,
9510
9767
  /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-btn-row", children: [
9511
9768
  /* @__PURE__ */ jsx6(
9512
9769
  "button",
@@ -9518,41 +9775,43 @@ var PdfPreviewModal = () => {
9518
9775
  children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
9519
9776
  }
9520
9777
  ),
9521
- /* @__PURE__ */ jsx6(
9522
- "button",
9523
- {
9524
- type: "button",
9525
- className: "univer-pdf-mini-btn",
9526
- disabled: rendering,
9527
- onClick: () => {
9528
- const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
9529
- const batchArr = [1, 2, 3].map((n) => ({
9530
- ...baseObj,
9531
- orderNo: `BATCH-2026-00${n}`,
9532
- batchSeq: n
9533
- }));
9534
- const txt = JSON.stringify(batchArr, null, 2);
9535
- setSampleJsonText(txt);
9536
- void generatePreview(txt);
9537
- },
9538
- children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
9539
- }
9540
- ),
9541
- /* @__PURE__ */ jsxs6(
9542
- "button",
9543
- {
9544
- type: "button",
9545
- "data-testid": "yudao-io-export-download",
9546
- className: "univer-pdf-mini-btn",
9547
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9548
- disabled: rendering,
9549
- onClick: () => void handleExportAndDownload(),
9550
- children: [
9551
- /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9552
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
9553
- ]
9554
- }
9555
- ),
9778
+ showExportControls && /* @__PURE__ */ jsxs6(Fragment4, { children: [
9779
+ /* @__PURE__ */ jsx6(
9780
+ "button",
9781
+ {
9782
+ type: "button",
9783
+ className: "univer-pdf-mini-btn",
9784
+ disabled: rendering,
9785
+ onClick: () => {
9786
+ const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
9787
+ const batchArr = [1, 2, 3].map((n) => ({
9788
+ ...baseObj,
9789
+ orderNo: `BATCH-2026-00${n}`,
9790
+ batchSeq: n
9791
+ }));
9792
+ const txt = JSON.stringify(batchArr, null, 2);
9793
+ setSampleJsonText(txt);
9794
+ void generatePreview(txt);
9795
+ },
9796
+ children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
9797
+ }
9798
+ ),
9799
+ /* @__PURE__ */ jsxs6(
9800
+ "button",
9801
+ {
9802
+ type: "button",
9803
+ "data-testid": "yudao-io-export-download",
9804
+ className: "univer-pdf-mini-btn",
9805
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9806
+ disabled: rendering,
9807
+ onClick: () => void handleExportAndDownload(),
9808
+ children: [
9809
+ /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9810
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
9811
+ ]
9812
+ }
9813
+ )
9814
+ ] }),
9556
9815
  features.print && /* @__PURE__ */ jsxs6(
9557
9816
  "button",
9558
9817
  {
@@ -9600,109 +9859,118 @@ var PdfPreviewModal = () => {
9600
9859
  /* @__PURE__ */ jsx6("div", { className: "univer-pdf-modal-label", children: "\u901A\u7528 PDF \u5BFC\u5165\u4E0E\u5BFC\u51FA\u5DE5\u4F5C\u53F0" }),
9601
9860
  /* @__PURE__ */ jsx6("div", { style: { fontSize: 12, color: "#4E5565", lineHeight: 1.55 }, children: "\u5F53\u524D\u5904\u4E8E\u901A\u7528 PDF \u6587\u6863/\u6279\u6CE8\u6A21\u5F0F\uFF08\u672A\u5F00\u542F\u6570\u636E\u96C6\u7ED1\u5B9A\uFF09\u3002\u53EF\u9009\u62E9\u6D4F\u89C8\u5668\u6216\u670D\u52A1\u7AEF\u901A\u9053\u5B8C\u6210 PDF \u5BFC\u5165\u5BA1\u6838\u4E0E\u5BFC\u51FA\u4E0B\u8F7D\u3002" }),
9602
9861
  unifiedIoSection,
9603
- /* @__PURE__ */ jsxs6(
9604
- "button",
9605
- {
9606
- type: "button",
9607
- "data-testid": "yudao-io-export-download",
9608
- className: "univer-pdf-mini-btn is-primary",
9609
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9610
- disabled: rendering,
9611
- onClick: () => void handleExportAndDownload(),
9612
- children: [
9613
- /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9614
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
9615
- ]
9616
- }
9617
- ),
9618
- /* @__PURE__ */ jsxs6(
9619
- "button",
9620
- {
9621
- type: "button",
9622
- className: "univer-pdf-mini-btn",
9623
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9624
- disabled: rendering,
9625
- onClick: handleDownloadCalibrationGrid,
9626
- children: [
9627
- /* @__PURE__ */ jsx6(UiRulerGridIcon, {}),
9628
- /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9629
- ]
9630
- }
9631
- ),
9632
- /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9633
- /* @__PURE__ */ jsx6(
9634
- "input",
9862
+ showExportControls && /* @__PURE__ */ jsxs6(Fragment4, { children: [
9863
+ /* @__PURE__ */ jsxs6(
9864
+ "button",
9635
9865
  {
9636
- type: "checkbox",
9637
- checked: enableAuditSeal,
9638
- onChange: (e) => {
9639
- const checked = e.target.checked;
9640
- setEnableAuditSeal(checked);
9641
- void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9642
- }
9866
+ type: "button",
9867
+ "data-testid": "yudao-io-export-download",
9868
+ className: "univer-pdf-mini-btn is-primary",
9869
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9870
+ disabled: rendering,
9871
+ onClick: () => void handleExportAndDownload(),
9872
+ children: [
9873
+ /* @__PURE__ */ jsx6(UiDownloadIcon, {}),
9874
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
9875
+ ]
9643
9876
  }
9644
9877
  ),
9645
- /* @__PURE__ */ jsx6(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9646
- /* @__PURE__ */ jsx6("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9647
- ] }),
9648
- /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9649
- /* @__PURE__ */ jsx6("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9650
- /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
9878
+ /* @__PURE__ */ jsxs6(
9879
+ "button",
9880
+ {
9881
+ type: "button",
9882
+ className: "univer-pdf-mini-btn",
9883
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9884
+ disabled: rendering,
9885
+ onClick: handleDownloadCalibrationGrid,
9886
+ children: [
9887
+ /* @__PURE__ */ jsx6(UiRulerGridIcon, {}),
9888
+ /* @__PURE__ */ jsx6("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9889
+ ]
9890
+ }
9891
+ ),
9892
+ /* @__PURE__ */ jsxs6("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9651
9893
  /* @__PURE__ */ jsx6(
9652
9894
  "input",
9653
9895
  {
9654
- type: "number",
9655
- step: "0.5",
9656
- title: "\u6C34\u5E73\u504F\u79FB X (mm)",
9657
- value: printerOffsetXMm,
9896
+ type: "checkbox",
9897
+ checked: enableAuditSeal,
9658
9898
  onChange: (e) => {
9659
- const nextX = Number(e.target.value) || 0;
9660
- setPrinterOffsetXMm(nextX);
9661
- void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9662
- printerOffsetXMm: nextX
9663
- });
9664
- },
9665
- style: {
9666
- width: "100%",
9667
- boxSizing: "border-box",
9668
- border: "1px solid #D5D8DF",
9669
- borderRadius: 4,
9670
- padding: "2px 4px",
9671
- fontSize: 11,
9672
- color: "#1B1C1F",
9673
- background: "#FFFFFF"
9899
+ const checked = e.target.checked;
9900
+ setEnableAuditSeal(checked);
9901
+ void generatePreview(
9902
+ sampleJsonText,
9903
+ watermarkText,
9904
+ excludeBasePdf,
9905
+ ioTarget,
9906
+ void 0,
9907
+ checked
9908
+ );
9674
9909
  }
9675
9910
  }
9676
9911
  ),
9677
- /* @__PURE__ */ jsx6(
9678
- "input",
9679
- {
9680
- type: "number",
9681
- step: "0.5",
9682
- title: "\u5782\u76F4\u504F\u79FB Y (mm)",
9683
- value: printerOffsetYMm,
9684
- onChange: (e) => {
9685
- const nextY = Number(e.target.value) || 0;
9686
- setPrinterOffsetYMm(nextY);
9687
- void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9688
- printerOffsetYMm: nextY
9689
- });
9690
- },
9691
- style: {
9692
- width: "100%",
9693
- boxSizing: "border-box",
9694
- border: "1px solid #D5D8DF",
9695
- borderRadius: 4,
9696
- padding: "2px 4px",
9697
- fontSize: 11,
9698
- color: "#1B1C1F",
9699
- background: "#FFFFFF"
9912
+ /* @__PURE__ */ jsx6(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9913
+ /* @__PURE__ */ jsx6("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9914
+ ] }),
9915
+ /* @__PURE__ */ jsxs6("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9916
+ /* @__PURE__ */ jsx6("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9917
+ /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
9918
+ /* @__PURE__ */ jsx6(
9919
+ "input",
9920
+ {
9921
+ type: "number",
9922
+ step: "0.5",
9923
+ title: "\u6C34\u5E73\u504F\u79FB X (mm)",
9924
+ value: printerOffsetXMm,
9925
+ onChange: (e) => {
9926
+ const nextX = Number(e.target.value) || 0;
9927
+ setPrinterOffsetXMm(nextX);
9928
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9929
+ printerOffsetXMm: nextX
9930
+ });
9931
+ },
9932
+ style: {
9933
+ width: "100%",
9934
+ boxSizing: "border-box",
9935
+ border: "1px solid #D5D8DF",
9936
+ borderRadius: 4,
9937
+ padding: "2px 4px",
9938
+ fontSize: 11,
9939
+ color: "#1B1C1F",
9940
+ background: "#FFFFFF"
9941
+ }
9700
9942
  }
9701
- }
9702
- )
9703
- ] })
9943
+ ),
9944
+ /* @__PURE__ */ jsx6(
9945
+ "input",
9946
+ {
9947
+ type: "number",
9948
+ step: "0.5",
9949
+ title: "\u5782\u76F4\u504F\u79FB Y (mm)",
9950
+ value: printerOffsetYMm,
9951
+ onChange: (e) => {
9952
+ const nextY = Number(e.target.value) || 0;
9953
+ setPrinterOffsetYMm(nextY);
9954
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9955
+ printerOffsetYMm: nextY
9956
+ });
9957
+ },
9958
+ style: {
9959
+ width: "100%",
9960
+ boxSizing: "border-box",
9961
+ border: "1px solid #D5D8DF",
9962
+ borderRadius: 4,
9963
+ padding: "2px 4px",
9964
+ fontSize: 11,
9965
+ color: "#1B1C1F",
9966
+ background: "#FFFFFF"
9967
+ }
9968
+ }
9969
+ )
9970
+ ] })
9971
+ ] }),
9972
+ splitMergeQuickBox
9704
9973
  ] }),
9705
- splitMergeQuickBox,
9706
9974
  features.print && /* @__PURE__ */ jsxs6(
9707
9975
  "button",
9708
9976
  {
@@ -9868,13 +10136,17 @@ function createBtn(config) {
9868
10136
  tooltip: config.tooltip ?? config.title,
9869
10137
  icon: config.icon,
9870
10138
  params: config.params,
9871
- hidden$: needsHiddenObs ? combineLatest([featService.features$, featService.editorEnabled$]).pipe(
9872
- map(([f, editorEnabled]) => {
10139
+ hidden$: needsHiddenObs ? combineLatest([
10140
+ featService.features$,
10141
+ featService.editorEnabled$,
10142
+ featService.ioModal$
10143
+ ]).pipe(
10144
+ map(([f, editorEnabled, ioModal]) => {
9873
10145
  if (requiresEditor && !editorEnabled) return true;
9874
10146
  if (config.elementTypeGate && !isPdfElementTypeAllowed(config.elementTypeGate, f)) {
9875
10147
  return true;
9876
10148
  }
9877
- return config.hiddenWhen ? config.hiddenWhen(f, editorEnabled) : false;
10149
+ return config.hiddenWhen ? config.hiddenWhen(f, editorEnabled, ioModal) : false;
9878
10150
  })
9879
10151
  ) : void 0
9880
10152
  };
@@ -10150,7 +10422,7 @@ var UploadBasePdfMenuFactory = createBtn({
10150
10422
  label: "pdfs.ribbon.importPdf",
10151
10423
  icon: "PdfUploadIcon",
10152
10424
  requiresEditor: true,
10153
- hiddenWhen: (f) => !f.basePdfOverlay
10425
+ hiddenWhen: (f, _editor, ioModal) => !f.basePdfOverlay || !ioModal.tabs.includes("import")
10154
10426
  });
10155
10427
  var OpenJsonExchangeMenuFactory = createBtn({
10156
10428
  id: "pdfs-ui.menu.open-json",
@@ -10159,7 +10431,8 @@ var OpenJsonExchangeMenuFactory = createBtn({
10159
10431
  label: "pdfs.ribbon.jsonExchange",
10160
10432
  icon: "PdfJsonIcon",
10161
10433
  params: { tab: "json" },
10162
- requiresEditor: true
10434
+ requiresEditor: true,
10435
+ hiddenWhen: (_f, _editor, ioModal) => !ioModal.tabs.includes("json")
10163
10436
  });
10164
10437
  var ToggleInspectorMenuFactory = createBtn({
10165
10438
  id: TogglePdfInspectorOperation.id,
@@ -10172,8 +10445,7 @@ var OpenPdfPreviewMenuFactory = createBtn({
10172
10445
  id: OpenPdfPreviewOperation.id,
10173
10446
  title: "pdfs.ribbon.previewPdf",
10174
10447
  label: "pdfs.ribbon.previewPdf",
10175
- icon: "PdfPreviewIcon",
10176
- params: { tab: "preview" }
10448
+ icon: "PdfPreviewIcon"
10177
10449
  });
10178
10450
  var PrintPdfMenuFactory = createBtn({
10179
10451
  id: PrintPdfOperation.id,
@@ -10492,7 +10764,7 @@ var UniverPdfsUIPlugin = class extends Plugin {
10492
10764
  this._injector.add([
10493
10765
  IPdfsUIFeatureService,
10494
10766
  {
10495
- useFactory: () => new PdfsUIFeatureService(this._config.features, editorEnabled)
10767
+ useFactory: () => new PdfsUIFeatureService(this._config.features, editorEnabled, this._config.ioModal)
10496
10768
  }
10497
10769
  ]);
10498
10770
  this._injector.add([
@@ -10512,6 +10784,7 @@ UniverPdfsUIPlugin = __decorateClass([
10512
10784
  __decorateParam(1, Inject2(Injector))
10513
10785
  ], UniverPdfsUIPlugin);
10514
10786
  export {
10787
+ ALL_PDF_IO_MODAL_TABS,
10515
10788
  AdjustPdfZoomOperation,
10516
10789
  IPdfsUIFeatureService,
10517
10790
  InsertPdfPresetElementOperation,
@@ -10545,9 +10818,12 @@ export {
10545
10818
  UniverPdfsUIPlugin,
10546
10819
  UpdatePdfUIFeaturesOperation,
10547
10820
  UploadBasePdfOperation,
10821
+ applyStagedPdfImportToUnit,
10822
+ clampPdfModalTab,
10548
10823
  clearPdfDocumentCache,
10549
10824
  computePdfDocumentCacheKey,
10550
10825
  configurePdfjsAssets,
10826
+ executeGuardedStagedImport,
10551
10827
  getPdfjsAssetsConfig,
10552
10828
  inspectSourcePdfPages,
10553
10829
  isPdfElementTypeAllowed,
@@ -10556,6 +10832,7 @@ export {
10556
10832
  readBrowserFileAsOverlayOutcome,
10557
10833
  renderSourcePdfPageToCanvas,
10558
10834
  resolveInitialModalIoTarget,
10835
+ resolvePdfIoModalConfig,
10559
10836
  resolvePdfsUIFeatures
10560
10837
  };
10561
10838
  //# sourceMappingURL=index.js.map