@yudaocode/univer-pdfs-ui 1.6.210 → 1.6.211

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/cjs/index.js CHANGED
@@ -51,6 +51,7 @@ __export(src_exports, {
51
51
  PdfLeftSidebar: () => PdfLeftSidebar,
52
52
  PdfPreviewModal: () => PdfPreviewModal,
53
53
  PdfStatusBar: () => PdfStatusBar,
54
+ PdfUnifiedIoSection: () => PdfUnifiedIoSection,
54
55
  PdfsUIController: () => PdfsUIController,
55
56
  PdfsUIEnUS: () => en_US_default,
56
57
  PdfsUIFeatureService: () => PdfsUIFeatureService,
@@ -81,6 +82,7 @@ __export(src_exports, {
81
82
  openPdfInspectorSidebar: () => openPdfInspectorSidebar,
82
83
  readBrowserFileAsOverlayOutcome: () => readBrowserFileAsOverlayOutcome,
83
84
  renderSourcePdfPageToCanvas: () => renderSourcePdfPageToCanvas,
85
+ resolveInitialModalIoTarget: () => resolveInitialModalIoTarget,
84
86
  resolvePdfsUIFeatures: () => resolvePdfsUIFeatures
85
87
  });
86
88
  module.exports = __toCommonJS(src_exports);
@@ -654,47 +656,47 @@ async function readBrowserFileAsOverlayOutcome(file, options) {
654
656
  return {
655
657
  mode: "overlay",
656
658
  sourceDocumentRef: validated.sourceDocumentRef,
657
- pageSizes: validated.pageSizes
659
+ pageSizes: validated.pageSizes,
660
+ ...validated.warnings?.length ? { warnings: validated.warnings } : {}
658
661
  };
659
662
  }
660
663
  var UploadBasePdfOperation = {
661
664
  id: "pdfs-ui.operation.upload-base-pdf",
662
665
  type: import_core2.CommandType.OPERATION,
663
666
  handler: (accessor, params) => {
664
- if (typeof document === "undefined") return false;
665
667
  const featureService = accessor.get(IPdfsUIFeatureService);
666
668
  if (!featureService.isEditorEnabled()) return false;
669
+ const selectionService = accessor.get(import_univer_pdfs.IPdfSelectionService);
670
+ selectionService.commitActiveEditing();
671
+ selectionService.setEditingElement(null);
672
+ if (!params?.file) {
673
+ featureService.setModalTab("import");
674
+ selectionService.setPreviewOpen(true);
675
+ return true;
676
+ }
667
677
  const commandService = accessor.get(import_core2.ICommandService);
668
678
  const instanceService = accessor.get(import_core2.IUniverInstanceService);
669
679
  const ioService = accessor.get(import_univer_pdfs.IPdfIoService);
670
- const input = document.createElement("input");
671
- input.type = "file";
672
- input.accept = "application/pdf";
673
- input.onchange = async () => {
674
- const file = input.files?.[0];
675
- if (!file) return;
676
- const unit = instanceService.getCurrentUnitOfType(import_core2.UniverInstanceType.UNIVER_PDF);
677
- if (!unit) return;
678
- const outcome = await ioService.importPdf(file, {
679
- unitId: unit.getUnitId(),
680
- snapshot: unit.save(),
681
- defaultImport: (f) => readBrowserFileAsOverlayOutcome(f, { password: params?.password })
682
- });
680
+ const unit = params.unitId ? instanceService.getUnit(params.unitId, import_core2.UniverInstanceType.UNIVER_PDF) : instanceService.getCurrentUnitOfType(import_core2.UniverInstanceType.UNIVER_PDF);
681
+ if (!unit) return false;
682
+ return ioService.importPdf(params.file, {
683
+ unitId: unit.getUnitId(),
684
+ snapshot: unit.save(),
685
+ target: params.target,
686
+ password: params.password
687
+ }).then((outcome) => {
683
688
  if (outcome.mode === "snapshot") {
684
- commandService.syncExecuteCommand(import_univer_pdfs.ReplacePdfSnapshotCommand.id, {
689
+ return commandService.syncExecuteCommand(import_univer_pdfs.ReplacePdfSnapshotCommand.id, {
685
690
  unitId: unit.getUnitId(),
686
691
  snapshot: outcome.snapshot
687
692
  });
688
- } else {
689
- commandService.syncExecuteCommand(import_univer_pdfs.ImportPdfSourceCommand.id, {
690
- unitId: unit.getUnitId(),
691
- sourceDocumentRef: outcome.sourceDocumentRef,
692
- pageSizes: outcome.pageSizes
693
- });
694
693
  }
695
- };
696
- input.click();
697
- return true;
694
+ return commandService.syncExecuteCommand(import_univer_pdfs.ImportPdfSourceCommand.id, {
695
+ unitId: unit.getUnitId(),
696
+ sourceDocumentRef: outcome.sourceDocumentRef,
697
+ pageSizes: outcome.pageSizes
698
+ });
699
+ });
698
700
  }
699
701
  };
700
702
  var SavePdfToHostOperation = {
@@ -8205,15 +8207,42 @@ var import_ui6 = require("@univerjs/ui");
8205
8207
  var import_univer_pdfs7 = require("@yudaocode/univer-pdfs");
8206
8208
  var import_react5 = require("react");
8207
8209
  var import_jsx_runtime6 = require("react/jsx-runtime");
8210
+ function resolveInitialModalIoTarget(caps, tab = "preview") {
8211
+ if (caps.defaultIoTarget === "server") return "server";
8212
+ if (caps.defaultIoTarget === "browser") return "browser";
8213
+ const op = tab === "import" ? "import" : "export";
8214
+ return caps.formats?.[op]?.pdf?.defaultTarget ?? caps.recommendedDefaultTarget;
8215
+ }
8216
+ function resolveFallbackTarget(err, attemptedTarget) {
8217
+ if (err?.suggestedFallback === "browser" || err?.suggestedFallback === "server") {
8218
+ return err.suggestedFallback;
8219
+ }
8220
+ return attemptedTarget === "server" ? "browser" : "server";
8221
+ }
8208
8222
  function uint8ToDataUri(bytes) {
8209
8223
  let binary = "";
8210
8224
  const chunkSize = 32768;
8211
8225
  for (let i = 0; i < bytes.length; i += chunkSize) {
8212
8226
  binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
8213
8227
  }
8214
- return `data:application/pdf;base64,${btoa(binary)}`;
8228
+ if (typeof btoa === "function") {
8229
+ return `data:application/pdf;base64,${btoa(binary)}`;
8230
+ }
8231
+ return `data:application/pdf;base64,${Buffer.from(bytes).toString("base64")}`;
8232
+ }
8233
+ function triggerBlobDownload(bytes, fileName) {
8234
+ if (typeof document === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") {
8235
+ return;
8236
+ }
8237
+ const blob = new Blob([bytes.slice().buffer], { type: "application/pdf" });
8238
+ const url = URL.createObjectURL(blob);
8239
+ const a = document.createElement("a");
8240
+ a.href = url;
8241
+ a.download = fileName;
8242
+ a.click();
8243
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
8215
8244
  }
8216
- var PdfRenderedPagesViewer = ({ pdfBytes }) => {
8245
+ var PdfRenderedPagesViewer = ({ pdfBytes, hasError }) => {
8217
8246
  const [dataUri, setDataUri] = (0, import_react5.useState)("");
8218
8247
  const [pageSizes, setPageSizes] = (0, import_react5.useState)([]);
8219
8248
  const canvasRefs = (0, import_react5.useRef)([]);
@@ -8239,7 +8268,7 @@ var PdfRenderedPagesViewer = ({ pdfBytes }) => {
8239
8268
  });
8240
8269
  }, [dataUri, pageSizes]);
8241
8270
  if (!pdfBytes || pageSizes.length === 0) {
8242
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-empty-stage", children: "\u6B63\u5728\u7F16\u8BD1\u9AD8\u6E05 PDF \u9875\u9762..." });
8271
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-empty-stage", children: hasError ? "\u5F53\u524D\u901A\u9053\u672A\u751F\u6210 PDF \u9884\u89C8\uFF0C\u8BF7\u67E5\u770B\u5DE6\u4FA7\u63D0\u793A\u6216\u5207\u6362\u901A\u9053\u91CD\u8BD5" : "\u6B63\u5728\u7F16\u8BD1\u9AD8\u6E05 PDF \u9875\u9762..." });
8243
8272
  }
8244
8273
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8245
8274
  "div",
@@ -8278,6 +8307,205 @@ var PdfRenderedPagesViewer = ({ pdfBytes }) => {
8278
8307
  }
8279
8308
  );
8280
8309
  };
8310
+ var PdfUnifiedIoSection = ({
8311
+ ioTarget,
8312
+ browserAvailable,
8313
+ serverAvailable,
8314
+ snapSizeKb,
8315
+ editorEnabled,
8316
+ importing,
8317
+ rendering,
8318
+ selectedFileName,
8319
+ pendingImport,
8320
+ ioError,
8321
+ fileInputRef,
8322
+ onSelectTarget,
8323
+ onFileInputChange,
8324
+ onPickFileClick,
8325
+ onConfirmImport,
8326
+ onCancelImport,
8327
+ onSwitchAndRetry
8328
+ }) => {
8329
+ const stagedPageCount = pendingImport ? pendingImport.outcome.mode === "overlay" ? pendingImport.outcome.pageSizes.length || pendingImport.outcome.sourceDocumentRef.pageCount || pendingImport.snapshot.document.pageOrder.length : pendingImport.snapshot.document.pageOrder.length : 0;
8330
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
8331
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8332
+ "div",
8333
+ {
8334
+ style: {
8335
+ padding: "7px 9px",
8336
+ background: "#FFFFFF",
8337
+ border: "1px solid #E3E5EA",
8338
+ borderRadius: 6,
8339
+ display: "flex",
8340
+ flexDirection: "column",
8341
+ gap: 6
8342
+ },
8343
+ children: [
8344
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 11 }, children: [
8345
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontWeight: 600, color: "#1B1C1F" }, children: "\u5BFC\u5165\u5BFC\u51FA\u6267\u884C\u901A\u9053\uFF08\u6309\u6B21\u9009\u62E9\uFF09" }),
8346
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { style: { color: "#7D8698" }, children: [
8347
+ "\u5FEB\u7167 ",
8348
+ snapSizeKb,
8349
+ " KB"
8350
+ ] })
8351
+ ] }),
8352
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-segmented", children: [
8353
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8354
+ "button",
8355
+ {
8356
+ type: "button",
8357
+ "data-testid": "yudao-io-target-browser",
8358
+ "aria-pressed": ioTarget === "browser",
8359
+ className: `univer-pdf-segmented-item ${ioTarget === "browser" ? "is-active" : ""}`,
8360
+ onClick: () => onSelectTarget("browser"),
8361
+ children: [
8362
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiBrowserIcon, {}),
8363
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6D4F\u89C8\u5668\u5904\u7406" }),
8364
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `univer-pdf-io-badge ${browserAvailable ? "is-ready" : "is-unconfigured"}`, children: browserAvailable ? "\u53EF\u7528" : "\u672A\u63A5\u5165" })
8365
+ ]
8366
+ }
8367
+ ),
8368
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8369
+ "button",
8370
+ {
8371
+ type: "button",
8372
+ "data-testid": "yudao-io-target-server",
8373
+ "aria-pressed": ioTarget === "server",
8374
+ className: `univer-pdf-segmented-item ${ioTarget === "server" ? "is-active" : ""}`,
8375
+ onClick: () => onSelectTarget("server"),
8376
+ children: [
8377
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiServerIcon, {}),
8378
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u670D\u52A1\u7AEF\u5904\u7406" }),
8379
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: `univer-pdf-io-badge ${serverAvailable ? "is-ready" : "is-unconfigured"}`, children: serverAvailable ? "\u53EF\u7528" : "\u672A\u63A5\u5165" })
8380
+ ]
8381
+ }
8382
+ )
8383
+ ] })
8384
+ ]
8385
+ }
8386
+ ),
8387
+ editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-io-import-box", children: [
8388
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
8389
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "PDF / \u6A21\u677F\u5206\u9636\u6BB5\u5BFC\u5165" }),
8390
+ selectedFileName && !pendingImport && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8391
+ "span",
8392
+ {
8393
+ style: {
8394
+ fontSize: 10.5,
8395
+ color: "#4E5565",
8396
+ overflow: "hidden",
8397
+ textOverflow: "ellipsis",
8398
+ whiteSpace: "nowrap",
8399
+ maxWidth: 140
8400
+ },
8401
+ title: selectedFileName,
8402
+ children: selectedFileName
8403
+ }
8404
+ )
8405
+ ] }),
8406
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8407
+ "input",
8408
+ {
8409
+ ref: fileInputRef,
8410
+ type: "file",
8411
+ accept: "application/pdf,.pdf,.json",
8412
+ "data-testid": "yudao-io-file-input",
8413
+ style: { display: "none" },
8414
+ onChange: onFileInputChange
8415
+ }
8416
+ ),
8417
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8418
+ "button",
8419
+ {
8420
+ type: "button",
8421
+ "data-testid": "yudao-io-pick-file",
8422
+ className: "univer-pdf-mini-btn is-soft-primary",
8423
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 5 },
8424
+ disabled: importing || rendering,
8425
+ onClick: onPickFileClick,
8426
+ children: [
8427
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiFilePdfIcon, {}),
8428
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: importing ? "\u6B63\u5728\u89E3\u6790\u5BFC\u5165\u6587\u4EF6..." : "\u9009\u62E9 PDF \u5BFC\u5165" })
8429
+ ]
8430
+ }
8431
+ ),
8432
+ pendingImport && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-io-staged-card", "data-testid": "yudao-io-staged-result", children: [
8433
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
8434
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8435
+ "span",
8436
+ {
8437
+ style: {
8438
+ fontSize: 11.5,
8439
+ fontWeight: 600,
8440
+ color: "#1B1C1F",
8441
+ overflow: "hidden",
8442
+ textOverflow: "ellipsis",
8443
+ whiteSpace: "nowrap"
8444
+ },
8445
+ title: pendingImport.fileName || selectedFileName || "imported.pdf",
8446
+ children: pendingImport.fileName || selectedFileName || "imported.pdf"
8447
+ }
8448
+ ),
8449
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "univer-pdf-io-badge is-ready", children: pendingImport.executedBy === "server" ? "\u670D\u52A1\u7AEF\u5904\u7406" : "\u6D4F\u89C8\u5668\u5904\u7406" })
8450
+ ] }),
8451
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { fontSize: 11, color: "#4E5565" }, children: [
8452
+ "\u5171 ",
8453
+ stagedPageCount,
8454
+ " \u9875 \xB7 \u6A21\u5F0F\uFF1A",
8455
+ pendingImport.outcome.mode === "overlay" ? "\u5E95\u56FE\u53E0\u52A0" : "\u5B8C\u6574\u5FEB\u7167",
8456
+ "\uFF08\u5C1A\u672A\u4FEE\u6539\u5F53\u524D\u8BBE\u8BA1\u5668\uFF09"
8457
+ ] }),
8458
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8459
+ "div",
8460
+ {
8461
+ "data-testid": "yudao-io-warnings",
8462
+ className: `univer-pdf-io-warnings-box ${pendingImport.warnings.length === 0 ? "is-clean" : ""}`,
8463
+ children: pendingImport.warnings.length > 0 ? pendingImport.warnings.map((w, idx) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-warning-code": w.code, children: [
8464
+ "\u2022 ",
8465
+ w.message
8466
+ ] }, `${w.code}-${idx}`)) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u517C\u5BB9\u6027\u68C0\u67E5\u901A\u8FC7\uFF080 \u9879\u544A\u8B66\uFF09" })
8467
+ }
8468
+ ),
8469
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
8470
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8471
+ "button",
8472
+ {
8473
+ type: "button",
8474
+ "data-testid": "yudao-io-confirm-import",
8475
+ className: "univer-pdf-mini-btn is-primary",
8476
+ onClick: onConfirmImport,
8477
+ children: "\u786E\u8BA4\u5E94\u7528\u5230\u8BBE\u8BA1\u5668"
8478
+ }
8479
+ ),
8480
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8481
+ "button",
8482
+ {
8483
+ type: "button",
8484
+ "data-testid": "yudao-io-cancel-import",
8485
+ className: "univer-pdf-mini-btn",
8486
+ onClick: onCancelImport,
8487
+ children: "\u53D6\u6D88\u672C\u6B21\u5BFC\u5165"
8488
+ }
8489
+ )
8490
+ ] })
8491
+ ] })
8492
+ ] }),
8493
+ ioError && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-io-error-banner", "data-testid": "yudao-io-error-banner", role: "alert", children: [
8494
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: ioError.message }),
8495
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8496
+ "button",
8497
+ {
8498
+ type: "button",
8499
+ "data-testid": "yudao-io-switch-retry",
8500
+ className: "univer-pdf-mini-btn is-soft-primary",
8501
+ disabled: importing || rendering,
8502
+ onClick: onSwitchAndRetry,
8503
+ children: `\u5207\u6362\u4E3A\u300C${ioError.fallbackTarget === "browser" ? "\u6D4F\u89C8\u5668\u5904\u7406" : "\u670D\u52A1\u7AEF\u5904\u7406"}\u300D\u91CD\u8BD5`
8504
+ }
8505
+ )
8506
+ ] })
8507
+ ] });
8508
+ };
8281
8509
  var PdfPreviewModal = () => {
8282
8510
  const instanceService = (0, import_ui6.useDependency)(import_core7.IUniverInstanceService);
8283
8511
  const commandService = (0, import_ui6.useDependency)(import_core7.ICommandService);
@@ -8295,15 +8523,22 @@ var PdfPreviewModal = () => {
8295
8523
  false,
8296
8524
  [instanceService]
8297
8525
  );
8526
+ const fileInputRef = (0, import_react5.useRef)(null);
8298
8527
  const [sampleJsonText, setSampleJsonText] = (0, import_react5.useState)("{}");
8299
8528
  const [pdfBytesState, setPdfBytesState] = (0, import_react5.useState)(null);
8300
8529
  const [rendering, setRendering] = (0, import_react5.useState)(false);
8530
+ const [importing, setImporting] = (0, import_react5.useState)(false);
8531
+ const [selectedImportFile, setSelectedImportFile] = (0, import_react5.useState)(null);
8532
+ const [pendingImport, setPendingImport] = (0, import_react5.useState)(null);
8533
+ const [ioError, setIoError] = (0, import_react5.useState)(null);
8301
8534
  const [jsonFormat, setJsonFormat] = (0, import_react5.useState)("univer");
8302
8535
  const [jsonEditorValue, setJsonEditorValue] = (0, import_react5.useState)("");
8303
8536
  const [statusTip, setStatusTip] = (0, import_react5.useState)("");
8304
8537
  const [watermarkText, setWatermarkText] = (0, import_react5.useState)("");
8305
8538
  const [excludeBasePdf, setExcludeBasePdf] = (0, import_react5.useState)(false);
8306
- const [ioTarget, setIoTarget] = (0, import_react5.useState)("browser");
8539
+ const [ioTarget, setIoTarget] = (0, import_react5.useState)(
8540
+ () => resolveInitialModalIoTarget(ioService.getIoCapabilities(), featureService.getModalTab())
8541
+ );
8307
8542
  const [interactiveForm, setInteractiveForm] = (0, import_react5.useState)(false);
8308
8543
  const [cjkTextMode, setCjkTextMode] = (0, import_react5.useState)("raster-hd");
8309
8544
  const [customFontBytes, setCustomFontBytes] = (0, import_react5.useState)(void 0);
@@ -8316,24 +8551,10 @@ var PdfPreviewModal = () => {
8316
8551
  const [accessibilityTagged, setAccessibilityTagged] = (0, import_react5.useState)(false);
8317
8552
  const [splitStartPage, setSplitStartPage] = (0, import_react5.useState)(1);
8318
8553
  const [splitEndPage, setSplitEndPage] = (0, import_react5.useState)(1);
8319
- (0, import_react5.useEffect)(() => {
8320
- if (!open || !unit) return;
8321
- const snap = unit.save();
8322
- setSampleJsonText(JSON.stringify(snap.metadata?.sampleData ?? {}, null, 2));
8323
- setWatermarkText(String(snap.metadata?.watermarkText ?? ""));
8324
- setExcludeBasePdf(Boolean(snap.metadata?.excludeBasePdfOnExport));
8325
- setPdfACompliant(Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant));
8326
- setAccessibilityTagged(Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged));
8327
- setIoTarget(ioService.getIoCapabilities().recommendedDefaultTarget);
8328
- setJsonEditorValue(
8329
- jsonFormat === "univer" ? JSON.stringify(snap, null, 2) : JSON.stringify((0, import_univer_pdfs7.toPdfmeTemplate)(snap), null, 2)
8330
- );
8331
- setStatusTip("");
8332
- }, [open, unit, jsonFormat, ioService, ioAdapter]);
8333
- const generatePreview = async (customDataText, overrideWm, overrideStripBg, overrideTarget, overrideExportOpts, overrideSeal) => {
8334
- if (!unit) return;
8335
- setRendering(true);
8336
- setStatusTip("");
8554
+ const compileCurrentPdfBytes = async (customDataText, overrideWm, overrideStripBg, overrideTarget, overrideExportOpts, overrideSeal) => {
8555
+ if (!unit) {
8556
+ throw new Error("\u5F53\u524D\u6CA1\u6709\u6D3B\u52A8 PDF \u6587\u6863\u5B9E\u4F8B");
8557
+ }
8337
8558
  const effectiveTarget = overrideTarget ?? ioTarget;
8338
8559
  const useSeal = overrideSeal ?? enableAuditSeal;
8339
8560
  const exportOptions = {
@@ -8345,54 +8566,269 @@ var PdfPreviewModal = () => {
8345
8566
  pdfACompliant: overrideExportOpts?.pdfACompliant ?? pdfACompliant,
8346
8567
  accessibilityTagged: overrideExportOpts?.accessibilityTagged ?? accessibilityTagged
8347
8568
  };
8348
- try {
8349
- const parsedData = JSON.parse(customDataText ?? sampleJsonText);
8350
- const rawSnap = unit.save();
8351
- const snapWithPrintOpts = {
8352
- ...rawSnap,
8353
- metadata: {
8354
- ...rawSnap.metadata ?? {},
8355
- watermarkText: overrideWm ?? watermarkText,
8356
- excludeBasePdfOnExport: overrideStripBg ?? excludeBasePdf
8357
- }
8358
- };
8359
- if (useSeal && !Array.isArray(parsedData) && effectiveTarget === "browser") {
8360
- const sealed = await (0, import_univer_pdfs7.exportSignedPdfWithAuditSeal)(snapWithPrintOpts, parsedData, {
8361
- signer: auditSigner.trim() || "Univer PDF Audit Seal",
8362
- reason: "Document Export Verification",
8363
- exportOptions
8364
- });
8365
- setPdfBytesState(sealed.pdfBytes);
8366
- setStatusTip(`\u5DF2\u751F\u6210 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0 PDF\uFF01\u6458\u8981: ${sealed.digestHex.slice(0, 24)}...`);
8367
- } else if (Array.isArray(parsedData) && effectiveTarget === "browser") {
8368
- const bytes = await (0, import_univer_pdfs7.exportBatchPdfBytes)(snapWithPrintOpts, parsedData, exportOptions);
8369
- setPdfBytesState(bytes);
8370
- setStatusTip(`\u5DF2\u901A\u8FC7\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u6279\u91CF\u5408\u5E76\u6E32\u67D3 ${parsedData.length} \u6761\u4E1A\u52A1\u5355\u636E\u4E3A\u8FDE\u7EED\u591A\u9875 PDF\uFF01`);
8371
- } else {
8372
- const bytes = await ioService.exportPdf({
8373
- unitId: unit.getUnitId(),
8374
- snapshot: snapWithPrintOpts,
8375
- data: parsedData,
8376
- options: exportOptions,
8377
- target: effectiveTarget
8378
- });
8379
- setPdfBytesState(bytes);
8380
- const modeBadges = [
8381
- exportOptions.interactiveForm ? "AcroForm\u4EA4\u4E92\u57DF" : null,
8382
- exportOptions.cjkTextMode !== "raster-hd" ? `CJK:${exportOptions.cjkTextMode}` : null,
8383
- exportOptions.printerOffsetXMm || exportOptions.printerOffsetYMm ? `\u504F\u79FB(${exportOptions.printerOffsetXMm ?? 0},${exportOptions.printerOffsetYMm ?? 0}mm)` : null
8384
- ].filter(Boolean).join(" + ");
8385
- setStatusTip(
8386
- `\u5DF2\u901A\u8FC7 ${effectiveTarget === "server" ? `\u670D\u52A1\u7AEF (${ioAdapter.name})` : "\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE"} \u7F16\u8BD1 PDF${modeBadges ? ` [${modeBadges}]` : ""}\uFF01`
8387
- );
8569
+ const parsedData = JSON.parse(customDataText ?? sampleJsonText);
8570
+ const rawSnap = unit.save();
8571
+ const snapWithPrintOpts = {
8572
+ ...rawSnap,
8573
+ metadata: {
8574
+ ...rawSnap.metadata ?? {},
8575
+ watermarkText: overrideWm ?? watermarkText,
8576
+ excludeBasePdfOnExport: overrideStripBg ?? excludeBasePdf
8388
8577
  }
8578
+ };
8579
+ if (useSeal && !Array.isArray(parsedData) && effectiveTarget === "browser") {
8580
+ const sealed = await (0, import_univer_pdfs7.exportSignedPdfWithAuditSeal)(snapWithPrintOpts, parsedData, {
8581
+ signer: auditSigner.trim() || "Univer PDF Audit Seal",
8582
+ reason: "Document Export Verification",
8583
+ exportOptions
8584
+ });
8585
+ return {
8586
+ bytes: sealed.pdfBytes,
8587
+ tip: `\u5DF2\u751F\u6210 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0 PDF\uFF01\u6458\u8981: ${sealed.digestHex.slice(0, 24)}...`,
8588
+ target: effectiveTarget
8589
+ };
8590
+ }
8591
+ if (Array.isArray(parsedData) && effectiveTarget === "browser") {
8592
+ const bytes2 = await (0, import_univer_pdfs7.exportBatchPdfBytes)(snapWithPrintOpts, parsedData, exportOptions);
8593
+ return {
8594
+ bytes: bytes2,
8595
+ tip: `\u5DF2\u901A\u8FC7\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u6279\u91CF\u5408\u5E76\u6E32\u67D3 ${parsedData.length} \u6761\u4E1A\u52A1\u5355\u636E\u4E3A\u8FDE\u7EED\u591A\u9875 PDF\uFF01`,
8596
+ target: effectiveTarget
8597
+ };
8598
+ }
8599
+ const bytes = await ioService.exportPdf({
8600
+ unitId: unit.getUnitId(),
8601
+ snapshot: snapWithPrintOpts,
8602
+ data: parsedData,
8603
+ options: exportOptions,
8604
+ target: effectiveTarget
8605
+ });
8606
+ const modeBadges = [
8607
+ exportOptions.interactiveForm ? "AcroForm\u4EA4\u4E92\u57DF" : null,
8608
+ exportOptions.cjkTextMode !== "raster-hd" ? `CJK:${exportOptions.cjkTextMode}` : null,
8609
+ exportOptions.printerOffsetXMm || exportOptions.printerOffsetYMm ? `\u504F\u79FB(${exportOptions.printerOffsetXMm ?? 0},${exportOptions.printerOffsetYMm ?? 0}mm)` : null
8610
+ ].filter(Boolean).join(" + ");
8611
+ return {
8612
+ bytes,
8613
+ tip: `\u5DF2\u901A\u8FC7 ${effectiveTarget === "server" ? `\u670D\u52A1\u7AEF (${ioAdapter.name})` : "\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE"} \u7F16\u8BD1 PDF${modeBadges ? ` [${modeBadges}]` : ""}\uFF01`,
8614
+ target: effectiveTarget
8615
+ };
8616
+ };
8617
+ const generatePreview = async (customDataText, overrideWm, overrideStripBg, overrideTarget, overrideExportOpts, overrideSeal, preserveSuccessTip) => {
8618
+ if (!unit) return;
8619
+ const effectiveTarget = overrideTarget ?? ioTarget;
8620
+ setRendering(true);
8621
+ setIoError(null);
8622
+ if (!preserveSuccessTip) {
8623
+ setStatusTip("");
8624
+ }
8625
+ try {
8626
+ const compiled = await compileCurrentPdfBytes(
8627
+ customDataText,
8628
+ overrideWm,
8629
+ overrideStripBg,
8630
+ effectiveTarget,
8631
+ overrideExportOpts,
8632
+ overrideSeal
8633
+ );
8634
+ setPdfBytesState(compiled.bytes);
8635
+ setStatusTip(preserveSuccessTip ?? compiled.tip);
8636
+ } catch (err) {
8637
+ setPdfBytesState(null);
8638
+ const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8639
+ const msg = err?.message || String(err);
8640
+ setIoError({
8641
+ operation: "preview",
8642
+ message: `\u751F\u6210\u9884\u89C8\u5931\u8D25: ${msg}`,
8643
+ failedTarget: effectiveTarget,
8644
+ fallbackTarget
8645
+ });
8646
+ setStatusTip("");
8647
+ } finally {
8648
+ setRendering(false);
8649
+ }
8650
+ };
8651
+ const handleExportAndDownload = async (overrideTarget) => {
8652
+ if (!unit) return;
8653
+ const effectiveTarget = overrideTarget ?? ioTarget;
8654
+ setRendering(true);
8655
+ setIoError(null);
8656
+ setStatusTip("");
8657
+ try {
8658
+ const compiled = await compileCurrentPdfBytes(
8659
+ sampleJsonText,
8660
+ watermarkText,
8661
+ excludeBasePdf,
8662
+ effectiveTarget
8663
+ );
8664
+ setPdfBytesState(compiled.bytes);
8665
+ triggerBlobDownload(compiled.bytes, `${unit.getName() || "document"}.pdf`);
8666
+ setStatusTip(compiled.tip);
8389
8667
  } catch (err) {
8390
- const hint = err?.suggestedFallback === "server" ? "\uFF08\u672A\u9759\u9ED8\u964D\u7EA7\uFF0C\u53EF\u5207\u6362\u4E3A\u300C\u670D\u52A1\u7AEF\u5904\u7406\u300D\u91CD\u8BD5\uFF09" : "";
8391
- setStatusTip(`\u751F\u6210\u5931\u8D25: ${err?.message || String(err)}${hint}`);
8668
+ setPdfBytesState(null);
8669
+ const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8670
+ const msg = err?.message || String(err);
8671
+ setIoError({
8672
+ operation: "export",
8673
+ message: `PDF \u5BFC\u51FA\u5931\u8D25: ${msg}`,
8674
+ failedTarget: effectiveTarget,
8675
+ fallbackTarget
8676
+ });
8392
8677
  } finally {
8393
8678
  setRendering(false);
8394
8679
  }
8395
8680
  };
8681
+ const runStagedImport = async (file, overrideTarget) => {
8682
+ if (!unit) return;
8683
+ const effectiveTarget = overrideTarget ?? ioTarget;
8684
+ setImporting(true);
8685
+ setIoError(null);
8686
+ setPendingImport(null);
8687
+ setStatusTip("");
8688
+ try {
8689
+ const report = await ioService.importPdfWithReport(file, {
8690
+ unitId: unit.getUnitId(),
8691
+ target: effectiveTarget
8692
+ });
8693
+ setPendingImport(report);
8694
+ } catch (err) {
8695
+ setPendingImport(null);
8696
+ const fallbackTarget = resolveFallbackTarget(err, effectiveTarget);
8697
+ const msg = err?.message || String(err);
8698
+ setIoError({
8699
+ operation: "import",
8700
+ message: `PDF \u5BFC\u5165\u89E3\u6790\u5931\u8D25: ${msg}`,
8701
+ failedTarget: effectiveTarget,
8702
+ fallbackTarget
8703
+ });
8704
+ } finally {
8705
+ setImporting(false);
8706
+ }
8707
+ };
8708
+ const handleImportFileChange = (e) => {
8709
+ const file = e.target.files?.[0];
8710
+ e.target.value = "";
8711
+ if (!file) return;
8712
+ setSelectedImportFile(file);
8713
+ void runStagedImport(file, ioTarget);
8714
+ };
8715
+ const handleConfirmStagedImport = () => {
8716
+ if (!unit || !pendingImport) return;
8717
+ const staged = pendingImport;
8718
+ if (staged.outcome.mode === "overlay") {
8719
+ commandService.syncExecuteCommand(import_univer_pdfs7.ImportPdfSourceCommand.id, {
8720
+ unitId: unit.getUnitId(),
8721
+ sourceDocumentRef: staged.outcome.sourceDocumentRef,
8722
+ pageSizes: staged.outcome.pageSizes
8723
+ });
8724
+ } else {
8725
+ commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
8726
+ unitId: unit.getUnitId(),
8727
+ snapshot: staged.snapshot
8728
+ });
8729
+ }
8730
+ setPendingImport(null);
8731
+ setIoError(null);
8732
+ const updatedSnap = unit.save();
8733
+ const nextSampleJson = JSON.stringify(updatedSnap.metadata?.sampleData ?? {}, null, 2);
8734
+ setSampleJsonText(nextSampleJson);
8735
+ setJsonEditorValue(
8736
+ jsonFormat === "univer" ? JSON.stringify(updatedSnap, null, 2) : JSON.stringify((0, import_univer_pdfs7.toPdfmeTemplate)(updatedSnap), null, 2)
8737
+ );
8738
+ const confirmTip = "\u5DF2\u5E94\u7528\u5230\u5F53\u524D\u8BBE\u8BA1\u5668\uFF0C\u8BF7\u7531\u5BBF\u4E3B\u4FDD\u5B58";
8739
+ setStatusTip(confirmTip);
8740
+ const caps = ioService.getIoCapabilities();
8741
+ const refreshTarget = ioTarget === "server" && !caps.formats.export.pdf.server ? "browser" : ioTarget;
8742
+ void generatePreview(
8743
+ nextSampleJson,
8744
+ String(updatedSnap.metadata?.watermarkText ?? watermarkText),
8745
+ Boolean(updatedSnap.metadata?.excludeBasePdfOnExport ?? excludeBasePdf),
8746
+ refreshTarget,
8747
+ void 0,
8748
+ void 0,
8749
+ confirmTip
8750
+ );
8751
+ };
8752
+ const handleCancelStagedImport = () => {
8753
+ setPendingImport(null);
8754
+ setIoError(null);
8755
+ setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u5185\u5BB9\u672A\u53D8\u66F4");
8756
+ };
8757
+ const handleSelectTarget = (nextTarget) => {
8758
+ setIoTarget(nextTarget);
8759
+ setIoError(null);
8760
+ setPdfBytesState(null);
8761
+ if (modalTab === "preview") {
8762
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8763
+ } else if (modalTab === "import") {
8764
+ const caps = ioService.getIoCapabilities();
8765
+ if (nextTarget === "browser" && caps.formats.export.pdf.browser || nextTarget === "server" && caps.formats.export.pdf.server) {
8766
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8767
+ }
8768
+ }
8769
+ };
8770
+ const handleSwitchAndRetry = async () => {
8771
+ if (!ioError) return;
8772
+ const nextTarget = ioError.fallbackTarget;
8773
+ const failedOp = ioError.operation;
8774
+ setIoTarget(nextTarget);
8775
+ setIoError(null);
8776
+ if (failedOp === "import" && selectedImportFile) {
8777
+ await runStagedImport(selectedImportFile, nextTarget);
8778
+ } else if (failedOp === "export") {
8779
+ await handleExportAndDownload(nextTarget);
8780
+ } else {
8781
+ await generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
8782
+ }
8783
+ };
8784
+ (0, import_react5.useEffect)(() => {
8785
+ if (!open) {
8786
+ setPendingImport(null);
8787
+ setSelectedImportFile(null);
8788
+ setIoError(null);
8789
+ return;
8790
+ }
8791
+ if (!unit) return;
8792
+ const snap = unit.save();
8793
+ const initialSampleText = JSON.stringify(snap.metadata?.sampleData ?? {}, null, 2);
8794
+ const initialWm = String(snap.metadata?.watermarkText ?? "");
8795
+ const initialStripBg = Boolean(snap.metadata?.excludeBasePdfOnExport);
8796
+ const initialPdfA = Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant);
8797
+ const initialPdfUa = Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged);
8798
+ const caps = ioService.getIoCapabilities();
8799
+ const initialTarget = resolveInitialModalIoTarget(caps, featureService.getModalTab());
8800
+ setSampleJsonText(initialSampleText);
8801
+ setWatermarkText(initialWm);
8802
+ setExcludeBasePdf(initialStripBg);
8803
+ setPdfACompliant(initialPdfA);
8804
+ setAccessibilityTagged(initialPdfUa);
8805
+ setIoTarget(initialTarget);
8806
+ setIoError(null);
8807
+ setStatusTip("");
8808
+ const activeTab = featureService.getModalTab();
8809
+ if (activeTab === "preview") {
8810
+ void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
8811
+ pdfACompliant: initialPdfA,
8812
+ accessibilityTagged: initialPdfUa
8813
+ });
8814
+ } else if (activeTab === "import") {
8815
+ if (initialTarget === "browser" && caps.formats.export.pdf.browser || initialTarget === "server" && caps.formats.export.pdf.server) {
8816
+ void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
8817
+ pdfACompliant: initialPdfA,
8818
+ accessibilityTagged: initialPdfUa
8819
+ });
8820
+ } else {
8821
+ setPdfBytesState(null);
8822
+ }
8823
+ }
8824
+ }, [open, unit, ioService, ioAdapter]);
8825
+ (0, import_react5.useEffect)(() => {
8826
+ if (!open || !unit) return;
8827
+ const snap = unit.save();
8828
+ setJsonEditorValue(
8829
+ jsonFormat === "univer" ? JSON.stringify(snap, null, 2) : JSON.stringify((0, import_univer_pdfs7.toPdfmeTemplate)(snap), null, 2)
8830
+ );
8831
+ }, [open, unit, jsonFormat, modalTab]);
8396
8832
  const handleSilentPrint = async () => {
8397
8833
  if (!unit) return;
8398
8834
  setStatusTip("");
@@ -8423,23 +8859,7 @@ var PdfPreviewModal = () => {
8423
8859
  setStatusTip(`\u9759\u9ED8\u76F4\u6253\u672A\u6267\u884C: ${err?.message || String(err)}`);
8424
8860
  }
8425
8861
  };
8426
- (0, import_react5.useEffect)(() => {
8427
- if (open && modalTab === "preview" && unit) {
8428
- const snap = unit.save();
8429
- generatePreview(JSON.stringify(snap.metadata?.sampleData ?? {}, null, 2));
8430
- }
8431
- }, [open, modalTab, unit, ioAdapter]);
8432
8862
  if (!open || !unit) return null;
8433
- const handleDownloadPdf = () => {
8434
- if (!pdfBytesState) return;
8435
- const blob = new Blob([pdfBytesState.buffer], { type: "application/pdf" });
8436
- const url = URL.createObjectURL(blob);
8437
- const a = document.createElement("a");
8438
- a.href = url;
8439
- a.download = `${unit.getName() || "document"}.pdf`;
8440
- a.click();
8441
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8442
- };
8443
8863
  const handleBrowserPrint = () => {
8444
8864
  commandService.executeCommand(PrintPdfOperation.id, {
8445
8865
  unitId: unit.getUnitId(),
@@ -8454,13 +8874,10 @@ var PdfPreviewModal = () => {
8454
8874
  { startPage: Math.max(1, splitStartPage), endPage: Math.max(1, splitEndPage) }
8455
8875
  ]);
8456
8876
  setPdfBytesState(rangeBytes);
8457
- const blob = new Blob([rangeBytes.buffer], { type: "application/pdf" });
8458
- const url = URL.createObjectURL(blob);
8459
- const a = document.createElement("a");
8460
- a.href = url;
8461
- a.download = `${unit.getName() || "document"}-p${splitStartPage}-${splitEndPage}.pdf`;
8462
- a.click();
8463
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8877
+ triggerBlobDownload(
8878
+ rangeBytes,
8879
+ `${unit.getName() || "document"}-p${splitStartPage}-${splitEndPage}.pdf`
8880
+ );
8464
8881
  setStatusTip(`\u5DF2\u6309\u9875\u7801\u8303\u56F4 [${splitStartPage}..${splitEndPage}] \u62C6\u5206\u5E76\u4E0B\u8F7D\u72EC\u7ACB PDF\uFF01`);
8465
8882
  } catch (err) {
8466
8883
  setStatusTip(`\u62C6\u5206\u5931\u8D25: ${err?.message || String(err)}`);
@@ -8484,13 +8901,7 @@ var PdfPreviewModal = () => {
8484
8901
  const list = pdfBytesState ? [pdfBytesState, ...externalBuffers] : externalBuffers;
8485
8902
  const merged = await (0, import_univer_pdfs7.mergePdfBytes)(list);
8486
8903
  setPdfBytesState(merged);
8487
- const blob = new Blob([merged.buffer], { type: "application/pdf" });
8488
- const url = URL.createObjectURL(blob);
8489
- const a = document.createElement("a");
8490
- a.href = url;
8491
- a.download = `${unit.getName() || "document"}-merged.pdf`;
8492
- a.click();
8493
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8904
+ triggerBlobDownload(merged, `${unit.getName() || "document"}-merged.pdf`);
8494
8905
  setStatusTip(`\u5DF2\u6210\u529F\u5408\u5E76 ${list.length} \u4EFD PDF \u6587\u6863\u5E76\u4E0B\u8F7D\uFF01`);
8495
8906
  } catch (err) {
8496
8907
  setStatusTip(`\u5408\u5E76\u5931\u8D25: ${err?.message || String(err)}`);
@@ -8588,13 +8999,7 @@ var PdfPreviewModal = () => {
8588
8999
  try {
8589
9000
  const calBytes = await (0, import_univer_pdfs7.exportCalibrationGridPdfBytes)(unit.getDocument().pageSize);
8590
9001
  setPdfBytesState(calBytes);
8591
- const blob = new Blob([calBytes.buffer], { type: "application/pdf" });
8592
- const url = URL.createObjectURL(blob);
8593
- const a = document.createElement("a");
8594
- a.href = url;
8595
- a.download = `${unit.getName() || "document"}-calibration-grid.pdf`;
8596
- a.click();
8597
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
9002
+ triggerBlobDownload(calBytes, `${unit.getName() || "document"}-calibration-grid.pdf`);
8598
9003
  setStatusTip("\u5DF2\u751F\u6210\u5E76\u4E0B\u8F7D 1mm / 5mm / 10mm \u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF\uFF01\u53EF\u5957\u6253\u81F3\u7A7A\u767D\u8054\u8BFB\u53D6\u504F\u79FB\u91CF\u3002");
8599
9004
  } catch (err) {
8600
9005
  setStatusTip(`\u6821\u51C6\u5C3A\u751F\u6210\u5931\u8D25: ${err?.message || String(err)}`);
@@ -8608,7 +9013,9 @@ var PdfPreviewModal = () => {
8608
9013
  unitId: unit.getUnitId(),
8609
9014
  snapshot: unit.save()
8610
9015
  });
8611
- setStatusTip(ok ? `\u5DF2\u901A\u8FC7 IO \u94A9\u5B50 (${ioAdapter.name || "custom"}) \u4FDD\u5B58\u81F3\u5BBF\u4E3B\u540E\u7AEF\uFF01` : "\u5F53\u524D\u672A\u914D\u7F6E onSave \u540E\u7AEF\u4FDD\u5B58\u94A9\u5B50");
9016
+ setStatusTip(
9017
+ ok ? `\u5DF2\u901A\u8FC7 IO \u94A9\u5B50 (${ioAdapter.name || "custom"}) \u4FDD\u5B58\u81F3\u5BBF\u4E3B\u540E\u7AEF\uFF01` : "\u5F53\u524D\u672A\u914D\u7F6E onSave \u540E\u7AEF\u4FDD\u5B58\u94A9\u5B50"
9018
+ );
8612
9019
  } catch (err) {
8613
9020
  setStatusTip(`\u5BBF\u4E3B\u4FDD\u5B58\u5931\u8D25: ${err?.message || String(err)}`);
8614
9021
  }
@@ -8631,764 +9038,745 @@ var PdfPreviewModal = () => {
8631
9038
  const ioCaps = ioService.getIoCapabilities();
8632
9039
  const pdfCapReport = (0, import_univer_pdfs7.inspectPdfExportCapabilities)(unit.save());
8633
9040
  const snapSizeKb = (pdfCapReport.snapshotByteSize / 1024).toFixed(1);
8634
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-backdrop", onClick: () => selectionService.setPreviewOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-card", onClick: (e) => e.stopPropagation(), children: [
8635
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-header", children: [
8636
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-tabs", children: [
8637
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8638
- "button",
8639
- {
8640
- type: "button",
8641
- className: `univer-pdf-modal-tab ${modalTab === "preview" ? "is-active" : ""}`,
8642
- style: { display: "inline-flex", alignItems: "center", gap: 5 },
8643
- onClick: () => featureService.setModalTab("preview"),
8644
- children: [
8645
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiFilePdfIcon, {}),
8646
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "PDF \u52A8\u6001\u6E32\u67D3\u9884\u89C8 & \u4E0B\u8F7D" })
8647
- ]
8648
- }
8649
- ),
8650
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8651
- "button",
8652
- {
8653
- type: "button",
8654
- className: `univer-pdf-modal-tab ${modalTab === "json" ? "is-active" : ""}`,
8655
- onClick: () => featureService.setModalTab("json"),
8656
- children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
8657
- }
8658
- )
8659
- ] }),
8660
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
8661
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8662
- "span",
8663
- {
8664
- style: {
8665
- fontSize: 11,
8666
- padding: "3px 8px",
8667
- borderRadius: 999,
8668
- background: isCustomBackendAdapter ? "#F3F5FF" : "#EEEFF1",
8669
- color: isCustomBackendAdapter ? "#2C53F1" : "#4E5565",
8670
- border: `1px solid ${isCustomBackendAdapter ? "#D2DAFA" : "#E3E5EA"}`,
8671
- fontWeight: 500
8672
- },
8673
- children: [
8674
- "IO \u7BA1\u9053: ",
8675
- ioAdapter.name || "frontend-default"
8676
- ]
8677
- }
8678
- ),
8679
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8680
- "button",
8681
- {
8682
- type: "button",
8683
- className: "univer-pdf-modal-close",
8684
- onClick: () => selectionService.setPreviewOpen(false),
8685
- children: "\xD7"
8686
- }
8687
- )
8688
- ] })
8689
- ] }),
8690
- modalTab === "preview" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-body-split", children: [
8691
- features.datasetBinding ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-side", children: [
8692
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-label", children: "\u6D4B\u8BD5\u6570\u636E\u96C6 JSON\uFF08\u5B9E\u65F6\u586B\u5145\u52A8\u6001\u6587\u672C\u3001\u8868\u683C\u3001\u4E8C\u7EF4\u7801\uFF09" }),
8693
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8694
- "textarea",
8695
- {
8696
- className: "univer-pdf-code-editor",
8697
- value: sampleJsonText,
8698
- onChange: (e) => setSampleJsonText(e.target.value)
8699
- }
8700
- ),
8701
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8702
- "input",
8703
- {
8704
- type: "text",
8705
- placeholder: "\u9632\u4F2A\u659C\u5411\u6C34\u5370\u6587\u5B57\uFF08\u5982\uFF1A\u828B\u9053\u7968\u636E \xB7 \u590D\u5370\u65E0\u6548\uFF09",
8706
- value: watermarkText,
8707
- onChange: (e) => setWatermarkText(e.target.value),
8708
- style: {
8709
- border: "1px solid #D5D8DF",
8710
- borderRadius: 6,
8711
- padding: "5px 8px",
8712
- fontSize: 11.5,
8713
- color: "#1B1C1F",
8714
- background: "#FFFFFF"
8715
- }
8716
- }
8717
- ),
8718
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8719
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8720
- "input",
8721
- {
8722
- type: "checkbox",
8723
- checked: excludeBasePdf,
8724
- onChange: (e) => {
8725
- setExcludeBasePdf(e.target.checked);
8726
- generatePreview(sampleJsonText, watermarkText, e.target.checked);
9041
+ const isUnifiedIoTab = modalTab === "preview" || modalTab === "import";
9042
+ const browserAvailable = modalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.browser) : Boolean(ioCaps.formats.export.pdf?.browser);
9043
+ const serverAvailable = modalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.server) : Boolean(ioCaps.formats.export.pdf?.server);
9044
+ const unifiedIoSection = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9045
+ PdfUnifiedIoSection,
9046
+ {
9047
+ ioTarget,
9048
+ browserAvailable,
9049
+ serverAvailable,
9050
+ snapSizeKb,
9051
+ editorEnabled,
9052
+ importing,
9053
+ rendering,
9054
+ selectedFileName: selectedImportFile?.name,
9055
+ pendingImport,
9056
+ ioError,
9057
+ fileInputRef,
9058
+ onSelectTarget: handleSelectTarget,
9059
+ onFileInputChange: handleImportFileChange,
9060
+ onPickFileClick: () => fileInputRef.current?.click(),
9061
+ onConfirmImport: handleConfirmStagedImport,
9062
+ onCancelImport: handleCancelStagedImport,
9063
+ onSwitchAndRetry: () => void handleSwitchAndRetry()
9064
+ }
9065
+ );
9066
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-backdrop", onClick: () => selectionService.setPreviewOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9067
+ "div",
9068
+ {
9069
+ className: "univer-pdf-modal-card",
9070
+ "data-testid": "yudao-io-modal",
9071
+ role: "dialog",
9072
+ "aria-modal": "true",
9073
+ onClick: (e) => e.stopPropagation(),
9074
+ children: [
9075
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-header", children: [
9076
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-tabs", children: [
9077
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9078
+ "button",
9079
+ {
9080
+ type: "button",
9081
+ className: `univer-pdf-modal-tab ${isUnifiedIoTab ? "is-active" : ""}`,
9082
+ style: { display: "inline-flex", alignItems: "center", gap: 5 },
9083
+ onClick: () => featureService.setModalTab("preview"),
9084
+ children: [
9085
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiFilePdfIcon, {}),
9086
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "PDF \u5BFC\u5165 / \u9884\u89C8\u4E0E\u5BFC\u51FA" })
9087
+ ]
8727
9088
  }
8728
- }
8729
- ),
8730
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9488\u5F0F\u5957\u6253\u6A21\u5F0F\uFF1A\u5BFC\u51FA/\u6253\u5370\u81EA\u52A8\u5265\u79BB\u5E95\u56FE PDF" })
8731
- ] }),
8732
- features.acroForm && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8733
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8734
- "input",
8735
- {
8736
- type: "checkbox",
8737
- checked: interactiveForm,
8738
- onChange: (e) => {
8739
- const checked = e.target.checked;
8740
- setInteractiveForm(checked);
8741
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8742
- interactiveForm: checked
8743
- });
9089
+ ),
9090
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9091
+ "button",
9092
+ {
9093
+ type: "button",
9094
+ className: `univer-pdf-modal-tab ${modalTab === "json" ? "is-active" : ""}`,
9095
+ onClick: () => featureService.setModalTab("json"),
9096
+ children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
8744
9097
  }
8745
- }
8746
- ),
8747
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4EA4\u4E92\u5F0F AcroForm \u8868\u5355\u57DF\u5BFC\u51FA (\u652F\u6301 PDF \u9605\u8BFB\u5668\u586B\u8868)" })
8748
- ] }),
8749
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8750
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8751
- "input",
8752
- {
8753
- type: "checkbox",
8754
- checked: pdfACompliant,
8755
- onChange: (e) => {
8756
- const checked = e.target.checked;
8757
- setPdfACompliant(checked);
8758
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8759
- pdfACompliant: checked
8760
- });
9098
+ )
9099
+ ] }),
9100
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
9101
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9102
+ "span",
9103
+ {
9104
+ style: {
9105
+ fontSize: 11,
9106
+ padding: "3px 8px",
9107
+ borderRadius: 999,
9108
+ background: isCustomBackendAdapter ? "#F3F5FF" : "#EEEFF1",
9109
+ color: isCustomBackendAdapter ? "#2C53F1" : "#4E5565",
9110
+ border: `1px solid ${isCustomBackendAdapter ? "#D2DAFA" : "#E3E5EA"}`,
9111
+ fontWeight: 500
9112
+ },
9113
+ children: [
9114
+ "IO \u7BA1\u9053: ",
9115
+ ioAdapter.name || "frontend-default"
9116
+ ]
8761
9117
  }
8762
- }
8763
- ),
8764
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "PDF/A-1b \u957F\u671F\u5F52\u6863\u5408\u89C4 (/Metadata XMP + /OutputIntents)" })
8765
- ] }),
8766
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8767
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8768
- "input",
8769
- {
8770
- type: "checkbox",
8771
- checked: accessibilityTagged,
8772
- onChange: (e) => {
8773
- const checked = e.target.checked;
8774
- setAccessibilityTagged(checked);
8775
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8776
- accessibilityTagged: checked
8777
- });
9118
+ ),
9119
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9120
+ "button",
9121
+ {
9122
+ type: "button",
9123
+ className: "univer-pdf-modal-close",
9124
+ onClick: () => selectionService.setPreviewOpen(false),
9125
+ children: "\xD7"
8778
9126
  }
8779
- }
8780
- ),
8781
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "PDF/UA \u65E0\u969C\u788D\u6807\u7B7E\u7ED3\u6784 (/StructTreeRoot + Alt-Text)" })
8782
- ] }),
8783
- (features.acroForm || features.sanitize && editorEnabled) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
8784
- features.acroForm && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8785
- "button",
8786
- {
8787
- type: "button",
8788
- className: "univer-pdf-mini-btn",
8789
- style: { flex: 1 },
8790
- onClick: () => {
8791
- const xml = (0, import_univer_pdfs7.exportFormDataToXfdf)(unit.save());
8792
- const blob = new Blob([xml], { type: "application/vnd.adobe.xfdf" });
8793
- const url = URL.createObjectURL(blob);
8794
- const a = document.createElement("a");
8795
- a.href = url;
8796
- a.download = `${unit.getName() || "form-data"}.xfdf`;
8797
- a.click();
8798
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
8799
- setStatusTip("\u5DF2\u5BFC\u51FA Adobe \u6807\u51C6 XFDF \u8868\u5355\u6570\u636E\u6587\u4EF6");
8800
- },
8801
- children: "\u5BFC\u51FA XFDF"
8802
- }
8803
- ),
8804
- features.acroForm && editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8805
- "button",
8806
- {
8807
- type: "button",
8808
- className: "univer-pdf-mini-btn",
8809
- style: { flex: 1 },
8810
- onClick: () => {
8811
- const input = document.createElement("input");
8812
- input.type = "file";
8813
- input.accept = ".xfdf,.xml";
8814
- input.onchange = async () => {
8815
- const file = input.files?.[0];
8816
- if (!file) return;
8817
- const xml = await file.text();
8818
- const next = (0, import_univer_pdfs7.importFormDataFromXfdf)(unit.save(), xml);
8819
- commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
8820
- unitId: unit.getUnitId(),
8821
- snapshot: next
8822
- });
8823
- generatePreview();
8824
- setStatusTip("\u5DF2\u5BFC\u5165 XFDF \u6570\u636E\u5E76\u5237\u65B0 PDF \u9884\u89C8");
8825
- };
8826
- input.click();
8827
- },
8828
- children: "\u5BFC\u5165 XFDF"
8829
- }
8830
- ),
8831
- features.sanitize && editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8832
- "button",
8833
- {
8834
- type: "button",
8835
- className: "univer-pdf-mini-btn",
8836
- onClick: () => {
8837
- const cleaned = (0, import_univer_pdfs7.sanitizePdfUnit)(unit.save());
8838
- commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
8839
- unitId: unit.getUnitId(),
8840
- snapshot: cleaned
8841
- });
8842
- generatePreview();
8843
- setStatusTip("\u5DF2\u5B8C\u6210\u5143\u6570\u636E\u4E0E\u6279\u6CE8\u6E05\u7406 (Sanitize)");
8844
- },
8845
- children: "\u8131\u654F\u6E05\u7406"
8846
- }
8847
- )
9127
+ )
9128
+ ] })
8848
9129
  ] }),
8849
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
8850
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8851
- "input",
8852
- {
8853
- type: "checkbox",
8854
- checked: enableAuditSeal,
8855
- onChange: (e) => {
8856
- const checked = e.target.checked;
8857
- setEnableAuditSeal(checked);
8858
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9130
+ isUnifiedIoTab ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-body-split", children: [
9131
+ features.datasetBinding ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-side", children: [
9132
+ unifiedIoSection,
9133
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-label", children: "\u6D4B\u8BD5\u6570\u636E\u96C6 JSON\uFF08\u5B9E\u65F6\u586B\u5145\u52A8\u6001\u6587\u672C\u3001\u8868\u683C\u3001\u4E8C\u7EF4\u7801\uFF09" }),
9134
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9135
+ "textarea",
9136
+ {
9137
+ className: "univer-pdf-code-editor",
9138
+ style: { minHeight: 96 },
9139
+ value: sampleJsonText,
9140
+ onChange: (e) => setSampleJsonText(e.target.value)
8859
9141
  }
8860
- }
8861
- ),
8862
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiShieldSealIcon, { style: { color: "#4E5565" } }),
8863
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
8864
- ] }),
8865
- enableAuditSeal && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8866
- "input",
8867
- {
8868
- type: "text",
8869
- placeholder: "\u7B7E\u7AE0\u8D23\u4EFB\u4EBA / \u673A\u6784\u540D\u79F0",
8870
- value: auditSigner,
8871
- onChange: (e) => setAuditSigner(e.target.value),
8872
- style: {
8873
- border: "1px solid #D5D8DF",
8874
- borderRadius: 6,
8875
- padding: "4px 8px",
8876
- fontSize: 11,
8877
- color: "#1B1C1F",
8878
- background: "#FFFFFF"
8879
- }
8880
- }
8881
- ),
8882
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8883
- "div",
8884
- {
8885
- style: {
8886
- padding: "6px 8px",
8887
- background: "#F9FAFB",
8888
- border: "1px solid #E3E5EA",
8889
- borderRadius: 6,
8890
- display: "flex",
8891
- flexDirection: "column",
8892
- gap: 5
8893
- },
8894
- children: [
8895
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
8896
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
8897
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
8898
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "X:" }),
8899
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8900
- "input",
8901
- {
8902
- type: "number",
8903
- step: "0.5",
8904
- value: printerOffsetXMm,
8905
- onChange: (e) => {
8906
- const nextX = Number(e.target.value) || 0;
8907
- setPrinterOffsetXMm(nextX);
8908
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8909
- printerOffsetXMm: nextX
8910
- });
8911
- },
8912
- style: {
8913
- width: "100%",
8914
- border: "1px solid #D5D8DF",
8915
- borderRadius: 4,
8916
- padding: "2px 5px",
8917
- fontSize: 11,
8918
- color: "#1B1C1F",
8919
- background: "#FFFFFF"
8920
- }
8921
- }
8922
- )
8923
- ] }),
8924
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
8925
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Y:" }),
8926
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
8927
- "input",
9142
+ ),
9143
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9144
+ "input",
9145
+ {
9146
+ type: "text",
9147
+ placeholder: "\u9632\u4F2A\u659C\u5411\u6C34\u5370\u6587\u5B57\uFF08\u5982\uFF1A\u5185\u90E8\u5355\u636E \xB7 \u590D\u5370\u65E0\u6548\uFF09",
9148
+ value: watermarkText,
9149
+ onChange: (e) => setWatermarkText(e.target.value),
9150
+ style: {
9151
+ border: "1px solid #D5D8DF",
9152
+ borderRadius: 6,
9153
+ padding: "5px 8px",
9154
+ fontSize: 11.5,
9155
+ color: "#1B1C1F",
9156
+ background: "#FFFFFF"
9157
+ }
9158
+ }
9159
+ ),
9160
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9161
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9162
+ "input",
9163
+ {
9164
+ type: "checkbox",
9165
+ checked: excludeBasePdf,
9166
+ onChange: (e) => {
9167
+ setExcludeBasePdf(e.target.checked);
9168
+ void generatePreview(sampleJsonText, watermarkText, e.target.checked);
9169
+ }
9170
+ }
9171
+ ),
9172
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9488\u5F0F\u5957\u6253\u6A21\u5F0F\uFF1A\u5BFC\u51FA/\u6253\u5370\u81EA\u52A8\u5265\u79BB\u5E95\u56FE PDF" })
9173
+ ] }),
9174
+ features.acroForm && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9175
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9176
+ "input",
9177
+ {
9178
+ type: "checkbox",
9179
+ checked: interactiveForm,
9180
+ onChange: (e) => {
9181
+ const checked = e.target.checked;
9182
+ setInteractiveForm(checked);
9183
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9184
+ interactiveForm: checked
9185
+ });
9186
+ }
9187
+ }
9188
+ ),
9189
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4EA4\u4E92\u5F0F AcroForm \u8868\u5355\u57DF\u5BFC\u51FA (\u652F\u6301 PDF \u9605\u8BFB\u5668\u586B\u8868)" })
9190
+ ] }),
9191
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9192
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9193
+ "input",
9194
+ {
9195
+ type: "checkbox",
9196
+ checked: pdfACompliant,
9197
+ onChange: (e) => {
9198
+ const checked = e.target.checked;
9199
+ setPdfACompliant(checked);
9200
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9201
+ pdfACompliant: checked
9202
+ });
9203
+ }
9204
+ }
9205
+ ),
9206
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "PDF/A-1b \u957F\u671F\u5F52\u6863\u5408\u89C4 (/Metadata XMP + /OutputIntents)" })
9207
+ ] }),
9208
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9209
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9210
+ "input",
9211
+ {
9212
+ type: "checkbox",
9213
+ checked: accessibilityTagged,
9214
+ onChange: (e) => {
9215
+ const checked = e.target.checked;
9216
+ setAccessibilityTagged(checked);
9217
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9218
+ accessibilityTagged: checked
9219
+ });
9220
+ }
9221
+ }
9222
+ ),
9223
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "PDF/UA \u65E0\u969C\u788D\u6807\u7B7E\u7ED3\u6784 (/StructTreeRoot + Alt-Text)" })
9224
+ ] }),
9225
+ (features.acroForm || features.sanitize && editorEnabled) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
9226
+ features.acroForm && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9227
+ "button",
9228
+ {
9229
+ type: "button",
9230
+ className: "univer-pdf-mini-btn",
9231
+ style: { flex: 1 },
9232
+ onClick: () => {
9233
+ const xml = (0, import_univer_pdfs7.exportFormDataToXfdf)(unit.save());
9234
+ const blob = new Blob([xml], { type: "application/vnd.adobe.xfdf" });
9235
+ const url = URL.createObjectURL(blob);
9236
+ const a = document.createElement("a");
9237
+ a.href = url;
9238
+ a.download = `${unit.getName() || "form-data"}.xfdf`;
9239
+ a.click();
9240
+ setTimeout(() => URL.revokeObjectURL(url), 1e3);
9241
+ setStatusTip("\u5DF2\u5BFC\u51FA Adobe \u6807\u51C6 XFDF \u8868\u5355\u6570\u636E\u6587\u4EF6");
9242
+ },
9243
+ children: "\u5BFC\u51FA XFDF"
9244
+ }
9245
+ ),
9246
+ features.acroForm && editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9247
+ "button",
9248
+ {
9249
+ type: "button",
9250
+ className: "univer-pdf-mini-btn",
9251
+ style: { flex: 1 },
9252
+ onClick: () => {
9253
+ const input = document.createElement("input");
9254
+ input.type = "file";
9255
+ input.accept = ".xfdf,.xml";
9256
+ input.onchange = async () => {
9257
+ const file = input.files?.[0];
9258
+ if (!file) return;
9259
+ const xml = await file.text();
9260
+ const next = (0, import_univer_pdfs7.importFormDataFromXfdf)(unit.save(), xml);
9261
+ commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
9262
+ unitId: unit.getUnitId(),
9263
+ snapshot: next
9264
+ });
9265
+ void generatePreview();
9266
+ setStatusTip("\u5DF2\u5BFC\u5165 XFDF \u6570\u636E\u5E76\u5237\u65B0 PDF \u9884\u89C8");
9267
+ };
9268
+ input.click();
9269
+ },
9270
+ children: "\u5BFC\u5165 XFDF"
9271
+ }
9272
+ ),
9273
+ features.sanitize && editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9274
+ "button",
9275
+ {
9276
+ type: "button",
9277
+ className: "univer-pdf-mini-btn",
9278
+ onClick: () => {
9279
+ const cleaned = (0, import_univer_pdfs7.sanitizePdfUnit)(unit.save());
9280
+ commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
9281
+ unitId: unit.getUnitId(),
9282
+ snapshot: cleaned
9283
+ });
9284
+ void generatePreview();
9285
+ setStatusTip("\u5DF2\u5B8C\u6210\u5143\u6570\u636E\u4E0E\u6279\u6CE8\u6E05\u7406 (Sanitize)");
9286
+ },
9287
+ children: "\u8131\u654F\u6E05\u7406"
9288
+ }
9289
+ )
9290
+ ] }),
9291
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9292
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9293
+ "input",
9294
+ {
9295
+ type: "checkbox",
9296
+ checked: enableAuditSeal,
9297
+ onChange: (e) => {
9298
+ const checked = e.target.checked;
9299
+ setEnableAuditSeal(checked);
9300
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9301
+ }
9302
+ }
9303
+ ),
9304
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9305
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9306
+ ] }),
9307
+ enableAuditSeal && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9308
+ "input",
9309
+ {
9310
+ type: "text",
9311
+ placeholder: "\u7B7E\u7AE0\u8D23\u4EFB\u4EBA / \u673A\u6784\u540D\u79F0",
9312
+ value: auditSigner,
9313
+ onChange: (e) => setAuditSigner(e.target.value),
9314
+ style: {
9315
+ border: "1px solid #D5D8DF",
9316
+ borderRadius: 6,
9317
+ padding: "4px 8px",
9318
+ fontSize: 11,
9319
+ color: "#1B1C1F",
9320
+ background: "#FFFFFF"
9321
+ }
9322
+ }
9323
+ ),
9324
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9325
+ "div",
9326
+ {
9327
+ style: {
9328
+ padding: "6px 8px",
9329
+ background: "#F9FAFB",
9330
+ border: "1px solid #E3E5EA",
9331
+ borderRadius: 6,
9332
+ display: "flex",
9333
+ flexDirection: "column",
9334
+ gap: 5
9335
+ },
9336
+ children: [
9337
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9338
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
9339
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
9340
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "X:" }),
9341
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9342
+ "input",
9343
+ {
9344
+ type: "number",
9345
+ step: "0.5",
9346
+ value: printerOffsetXMm,
9347
+ onChange: (e) => {
9348
+ const nextX = Number(e.target.value) || 0;
9349
+ setPrinterOffsetXMm(nextX);
9350
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9351
+ printerOffsetXMm: nextX
9352
+ });
9353
+ },
9354
+ style: {
9355
+ width: "100%",
9356
+ border: "1px solid #D5D8DF",
9357
+ borderRadius: 4,
9358
+ padding: "2px 5px",
9359
+ fontSize: 11,
9360
+ color: "#1B1C1F",
9361
+ background: "#FFFFFF"
9362
+ }
9363
+ }
9364
+ )
9365
+ ] }),
9366
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#4E5565" }, children: [
9367
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Y:" }),
9368
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9369
+ "input",
9370
+ {
9371
+ type: "number",
9372
+ step: "0.5",
9373
+ value: printerOffsetYMm,
9374
+ onChange: (e) => {
9375
+ const nextY = Number(e.target.value) || 0;
9376
+ setPrinterOffsetYMm(nextY);
9377
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9378
+ printerOffsetYMm: nextY
9379
+ });
9380
+ },
9381
+ style: {
9382
+ width: "100%",
9383
+ border: "1px solid #D5D8DF",
9384
+ borderRadius: 4,
9385
+ padding: "2px 5px",
9386
+ fontSize: 11,
9387
+ color: "#1B1C1F",
9388
+ background: "#FFFFFF"
9389
+ }
9390
+ }
9391
+ )
9392
+ ] })
9393
+ ] }),
9394
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9395
+ "button",
8928
9396
  {
8929
- type: "number",
8930
- step: "0.5",
8931
- value: printerOffsetYMm,
8932
- onChange: (e) => {
8933
- const nextY = Number(e.target.value) || 0;
8934
- setPrinterOffsetYMm(nextY);
8935
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8936
- printerOffsetYMm: nextY
8937
- });
8938
- },
8939
- style: {
8940
- width: "100%",
8941
- border: "1px solid #D5D8DF",
8942
- borderRadius: 4,
8943
- padding: "2px 5px",
8944
- fontSize: 11,
8945
- color: "#1B1C1F",
8946
- background: "#FFFFFF"
8947
- }
9397
+ type: "button",
9398
+ className: "univer-pdf-mini-btn",
9399
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9400
+ disabled: rendering,
9401
+ onClick: handleDownloadCalibrationGrid,
9402
+ children: [
9403
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiRulerGridIcon, {}),
9404
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9405
+ ]
8948
9406
  }
8949
9407
  )
8950
- ] })
9408
+ ]
9409
+ }
9410
+ ),
9411
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9412
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11.5, color: "#31363F" }, children: [
9413
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F" }),
9414
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9415
+ "select",
9416
+ {
9417
+ value: cjkTextMode,
9418
+ onChange: (e) => {
9419
+ const mode = e.target.value;
9420
+ setCjkTextMode(mode);
9421
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9422
+ cjkTextMode: mode
9423
+ });
9424
+ },
9425
+ style: {
9426
+ border: "1px solid #D5D8DF",
9427
+ borderRadius: 4,
9428
+ padding: "2px 5px",
9429
+ fontSize: 11,
9430
+ color: "#1B1C1F",
9431
+ background: "#FFFFFF"
9432
+ },
9433
+ children: [
9434
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "raster-hd", children: "\u9AD8\u6E05\u6805\u683C\u6A21\u5F0F (3x DPI PNG)" }),
9435
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "cid-vector", children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F (cid-vector 0KB)" }),
9436
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "subset-ttf", children: "TTF \u5B57\u4F53\u5B50\u96C6\u77E2\u91CF\u5185\u5D4C (subset-ttf)" })
9437
+ ]
9438
+ }
9439
+ )
8951
9440
  ] }),
9441
+ cjkTextMode === "subset-ttf" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9442
+ "button",
9443
+ {
9444
+ type: "button",
9445
+ className: "univer-pdf-mini-btn",
9446
+ onClick: () => {
9447
+ const input = document.createElement("input");
9448
+ input.type = "file";
9449
+ input.accept = ".ttf";
9450
+ input.onchange = async () => {
9451
+ const file = input.files?.[0];
9452
+ if (!file) return;
9453
+ const bytes = new Uint8Array(await file.arrayBuffer());
9454
+ setCustomFontBytes(bytes);
9455
+ setCustomFontName(file.name);
9456
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9457
+ cjkTextMode: "subset-ttf",
9458
+ customFontBytes: bytes
9459
+ });
9460
+ };
9461
+ input.click();
9462
+ },
9463
+ children: customFontName ? `\u5DF2\u8F7D\u5165\u5B57\u4F53: ${customFontName}` : "\u4E0A\u4F20 .ttf \u5B57\u4F53\u542F\u7528\u5B50\u96C6\u5316\u5185\u5D4C"
9464
+ }
9465
+ )
9466
+ ] }),
9467
+ splitMergeQuickBox,
9468
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
9469
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9470
+ "button",
9471
+ {
9472
+ type: "button",
9473
+ className: "univer-pdf-mini-btn is-primary",
9474
+ disabled: rendering,
9475
+ onClick: () => void generatePreview(),
9476
+ children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
9477
+ }
9478
+ ),
9479
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9480
+ "button",
9481
+ {
9482
+ type: "button",
9483
+ className: "univer-pdf-mini-btn",
9484
+ disabled: rendering,
9485
+ onClick: () => {
9486
+ const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
9487
+ const batchArr = [1, 2, 3].map((n) => ({
9488
+ ...baseObj,
9489
+ orderNo: `BATCH-2026-00${n}`,
9490
+ batchSeq: n
9491
+ }));
9492
+ const txt = JSON.stringify(batchArr, null, 2);
9493
+ setSampleJsonText(txt);
9494
+ void generatePreview(txt);
9495
+ },
9496
+ children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
9497
+ }
9498
+ ),
8952
9499
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9500
+ "button",
9501
+ {
9502
+ type: "button",
9503
+ "data-testid": "yudao-io-export-download",
9504
+ className: "univer-pdf-mini-btn",
9505
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9506
+ disabled: rendering,
9507
+ onClick: () => void handleExportAndDownload(),
9508
+ children: [
9509
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
9510
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
9511
+ ]
9512
+ }
9513
+ ),
9514
+ features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8953
9515
  "button",
8954
9516
  {
8955
9517
  type: "button",
8956
9518
  className: "univer-pdf-mini-btn",
8957
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9519
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
8958
9520
  disabled: rendering,
8959
- onClick: handleDownloadCalibrationGrid,
9521
+ onClick: handleBrowserPrint,
9522
+ children: [
9523
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9524
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9525
+ ]
9526
+ }
9527
+ ),
9528
+ features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9529
+ "button",
9530
+ {
9531
+ type: "button",
9532
+ className: "univer-pdf-mini-btn",
9533
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9534
+ disabled: rendering,
9535
+ onClick: handleSilentPrint,
9536
+ children: [
9537
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9538
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9539
+ ]
9540
+ }
9541
+ ),
9542
+ ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9543
+ "button",
9544
+ {
9545
+ type: "button",
9546
+ className: "univer-pdf-mini-btn",
9547
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9548
+ onClick: handleSaveToHost,
8960
9549
  children: [
8961
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiRulerGridIcon, {}),
8962
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9550
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiSaveIcon, {}),
9551
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF" })
8963
9552
  ]
8964
9553
  }
8965
9554
  )
8966
- ]
8967
- }
8968
- ),
8969
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
8970
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11.5, color: "#31363F" }, children: [
8971
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F" }),
9555
+ ] }),
9556
+ statusTip && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-status-banner", children: statusTip })
9557
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-side", style: { width: 320 }, children: [
9558
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-label", children: "\u901A\u7528 PDF \u5BFC\u5165\u4E0E\u5BFC\u51FA\u5DE5\u4F5C\u53F0" }),
9559
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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" }),
9560
+ unifiedIoSection,
8972
9561
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
8973
- "select",
9562
+ "button",
8974
9563
  {
8975
- value: cjkTextMode,
8976
- onChange: (e) => {
8977
- const mode = e.target.value;
8978
- setCjkTextMode(mode);
8979
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
8980
- cjkTextMode: mode
8981
- });
8982
- },
8983
- style: {
8984
- border: "1px solid #D5D8DF",
8985
- borderRadius: 4,
8986
- padding: "2px 5px",
8987
- fontSize: 11,
8988
- color: "#1B1C1F",
8989
- background: "#FFFFFF"
8990
- },
9564
+ type: "button",
9565
+ "data-testid": "yudao-io-export-download",
9566
+ className: "univer-pdf-mini-btn is-primary",
9567
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9568
+ disabled: rendering,
9569
+ onClick: () => void handleExportAndDownload(),
8991
9570
  children: [
8992
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "raster-hd", children: "\u9AD8\u6E05\u6805\u683C\u6A21\u5F0F (3x DPI PNG)" }),
8993
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "cid-vector", children: "\u4E2D\u6587\u77E2\u91CF\u53EF\u68C0\u7D22\u6A21\u5F0F (cid-vector 0KB)" }),
8994
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "subset-ttf", children: "TTF \u5B57\u4F53\u5B50\u96C6\u77E2\u91CF\u5185\u5D4C (subset-ttf)" })
9571
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
9572
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
8995
9573
  ]
8996
9574
  }
8997
- )
8998
- ] }),
8999
- cjkTextMode === "subset-ttf" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9000
- "button",
9001
- {
9002
- type: "button",
9003
- className: "univer-pdf-mini-btn",
9004
- onClick: () => {
9005
- const input = document.createElement("input");
9006
- input.type = "file";
9007
- input.accept = ".ttf";
9008
- input.onchange = async () => {
9009
- const file = input.files?.[0];
9010
- if (!file) return;
9011
- const bytes = new Uint8Array(await file.arrayBuffer());
9012
- setCustomFontBytes(bytes);
9013
- setCustomFontName(file.name);
9014
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9015
- cjkTextMode: "subset-ttf",
9016
- customFontBytes: bytes
9017
- });
9018
- };
9019
- input.click();
9020
- },
9021
- children: customFontName ? `\u5DF2\u8F7D\u5165\u5B57\u4F53: ${customFontName}` : "\u4E0A\u4F20 .ttf \u5B57\u4F53\u542F\u7528\u5B50\u96C6\u5316\u5185\u5D4C"
9022
- }
9023
- )
9024
- ] }),
9025
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9026
- "div",
9027
- {
9028
- style: {
9029
- padding: "7px 9px",
9030
- background: "#FFFFFF",
9031
- border: "1px solid #E3E5EA",
9032
- borderRadius: 6,
9033
- display: "flex",
9034
- flexDirection: "column",
9035
- gap: 6
9036
- },
9037
- children: [
9038
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 11 }, children: [
9039
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontWeight: 600, color: "#1B1C1F" }, children: "\u7F16\u8BD1\u5BFC\u51FA\u65B9\u5F0F\uFF08\u6309\u6B21\u9009\u62E9\uFF09" }),
9040
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { style: { color: "#7D8698" }, children: [
9041
- "\u5FEB\u7167 ",
9042
- snapSizeKb,
9043
- " KB"
9044
- ] })
9045
- ] }),
9046
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-segmented", children: [
9047
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9048
- "button",
9575
+ ),
9576
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9577
+ "button",
9578
+ {
9579
+ type: "button",
9580
+ className: "univer-pdf-mini-btn",
9581
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9582
+ disabled: rendering,
9583
+ onClick: handleDownloadCalibrationGrid,
9584
+ children: [
9585
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiRulerGridIcon, {}),
9586
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9587
+ ]
9588
+ }
9589
+ ),
9590
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9591
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9592
+ "input",
9593
+ {
9594
+ type: "checkbox",
9595
+ checked: enableAuditSeal,
9596
+ onChange: (e) => {
9597
+ const checked = e.target.checked;
9598
+ setEnableAuditSeal(checked);
9599
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9600
+ }
9601
+ }
9602
+ ),
9603
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9604
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9605
+ ] }),
9606
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9607
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9608
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
9609
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9610
+ "input",
9049
9611
  {
9050
- type: "button",
9051
- className: `univer-pdf-segmented-item ${ioTarget === "browser" ? "is-active" : ""}`,
9052
- onClick: () => {
9053
- setIoTarget("browser");
9054
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, "browser");
9612
+ type: "number",
9613
+ step: "0.5",
9614
+ title: "\u6C34\u5E73\u504F\u79FB X (mm)",
9615
+ value: printerOffsetXMm,
9616
+ onChange: (e) => {
9617
+ const nextX = Number(e.target.value) || 0;
9618
+ setPrinterOffsetXMm(nextX);
9619
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9620
+ printerOffsetXMm: nextX
9621
+ });
9055
9622
  },
9056
- children: [
9057
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiBrowserIcon, {}),
9058
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6D4F\u89C8\u5668\u5904\u7406" })
9059
- ]
9623
+ style: {
9624
+ width: "100%",
9625
+ boxSizing: "border-box",
9626
+ border: "1px solid #D5D8DF",
9627
+ borderRadius: 4,
9628
+ padding: "2px 4px",
9629
+ fontSize: 11,
9630
+ color: "#1B1C1F",
9631
+ background: "#FFFFFF"
9632
+ }
9060
9633
  }
9061
9634
  ),
9062
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9063
- "button",
9635
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9636
+ "input",
9064
9637
  {
9065
- type: "button",
9066
- className: `univer-pdf-segmented-item ${ioTarget === "server" ? "is-active" : ""}`,
9067
- onClick: () => {
9068
- setIoTarget("server");
9069
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, "server");
9638
+ type: "number",
9639
+ step: "0.5",
9640
+ title: "\u5782\u76F4\u504F\u79FB Y (mm)",
9641
+ value: printerOffsetYMm,
9642
+ onChange: (e) => {
9643
+ const nextY = Number(e.target.value) || 0;
9644
+ setPrinterOffsetYMm(nextY);
9645
+ void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9646
+ printerOffsetYMm: nextY
9647
+ });
9070
9648
  },
9071
- children: [
9072
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiServerIcon, {}),
9073
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
9074
- "\u670D\u52A1\u7AEF",
9075
- ioCaps.server.exportPdf ? "" : " (\u672A\u63A5\u5165)"
9076
- ] })
9077
- ]
9649
+ style: {
9650
+ width: "100%",
9651
+ boxSizing: "border-box",
9652
+ border: "1px solid #D5D8DF",
9653
+ borderRadius: 4,
9654
+ padding: "2px 4px",
9655
+ fontSize: 11,
9656
+ color: "#1B1C1F",
9657
+ background: "#FFFFFF"
9658
+ }
9078
9659
  }
9079
9660
  )
9080
9661
  ] })
9081
- ]
9082
- }
9083
- ),
9084
- splitMergeQuickBox,
9085
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
9086
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9087
- "button",
9088
- {
9089
- type: "button",
9090
- className: "univer-pdf-mini-btn is-primary",
9091
- disabled: rendering,
9092
- onClick: () => generatePreview(),
9093
- children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
9094
- }
9095
- ),
9096
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9097
- "button",
9098
- {
9099
- type: "button",
9100
- className: "univer-pdf-mini-btn",
9101
- disabled: rendering,
9102
- onClick: () => {
9103
- const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
9104
- const batchArr = [1, 2, 3].map((n) => ({
9105
- ...baseObj,
9106
- orderNo: `BATCH-2026-00${n}`,
9107
- batchSeq: n
9108
- }));
9109
- const txt = JSON.stringify(batchArr, null, 2);
9110
- setSampleJsonText(txt);
9111
- generatePreview(txt);
9112
- },
9113
- children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
9114
- }
9115
- ),
9116
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9117
- "button",
9118
- {
9119
- type: "button",
9120
- className: "univer-pdf-mini-btn",
9121
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9122
- disabled: !pdfBytesState,
9123
- onClick: handleDownloadPdf,
9124
- children: [
9125
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
9126
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
9127
- ]
9128
- }
9129
- ),
9130
- features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9131
- "button",
9132
- {
9133
- type: "button",
9134
- className: "univer-pdf-mini-btn",
9135
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9136
- disabled: rendering,
9137
- onClick: handleBrowserPrint,
9138
- children: [
9139
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9140
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9141
- ]
9142
- }
9143
- ),
9144
- features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9145
- "button",
9146
- {
9147
- type: "button",
9148
- className: "univer-pdf-mini-btn",
9149
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9150
- disabled: rendering,
9151
- onClick: handleSilentPrint,
9152
- children: [
9153
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9154
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9155
- ]
9156
- }
9157
- ),
9158
- ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9159
- "button",
9160
- {
9161
- type: "button",
9162
- className: "univer-pdf-mini-btn",
9163
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9164
- onClick: handleSaveToHost,
9165
- children: [
9166
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiSaveIcon, {}),
9167
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF" })
9168
- ]
9169
- }
9170
- )
9171
- ] }),
9172
- statusTip && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-status-banner", children: statusTip })
9173
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-side", style: { width: 220 }, children: [
9174
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-label", children: "\u901A\u7528 PDF \u5BFC\u51FA\u9884\u89C8" }),
9175
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { fontSize: 12, color: "#4E5565", lineHeight: 1.6 }, children: "\u5F53\u524D\u5904\u4E8E\u7EAF\u51C0 PDF \u6587\u6863/\u6279\u6CE8\u6A21\u5F0F\uFF08\u672A\u5F00\u542F\u6570\u636E\u96C6\u7ED1\u5B9A\uFF09\u3002\u53F3\u4FA7\u4E3A\u901A\u8FC7\u5F53\u524D IO \u7BA1\u9053\u7F16\u8BD1\u7684\u6807\u51C6 PDF \u9875\u9762\u3002" }),
9176
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9177
- "button",
9178
- {
9179
- type: "button",
9180
- className: "univer-pdf-mini-btn is-primary",
9181
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9182
- disabled: !pdfBytesState,
9183
- onClick: handleDownloadPdf,
9184
- children: [
9185
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
9186
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
9187
- ]
9188
- }
9189
- ),
9190
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9191
- "button",
9192
- {
9193
- type: "button",
9194
- className: "univer-pdf-mini-btn",
9195
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9196
- disabled: rendering,
9197
- onClick: handleDownloadCalibrationGrid,
9198
- children: [
9199
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiRulerGridIcon, {}),
9200
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
9201
- ]
9202
- }
9203
- ),
9204
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
9205
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9206
- "input",
9207
- {
9208
- type: "checkbox",
9209
- checked: enableAuditSeal,
9210
- onChange: (e) => {
9211
- const checked = e.target.checked;
9212
- setEnableAuditSeal(checked);
9213
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, void 0, checked);
9662
+ ] }),
9663
+ splitMergeQuickBox,
9664
+ features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9665
+ "button",
9666
+ {
9667
+ type: "button",
9668
+ className: "univer-pdf-mini-btn",
9669
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9670
+ disabled: rendering,
9671
+ onClick: handleBrowserPrint,
9672
+ children: [
9673
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9674
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9675
+ ]
9214
9676
  }
9215
- }
9216
- ),
9217
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiShieldSealIcon, { style: { color: "#4E5565" } }),
9218
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
9219
- ] }),
9220
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
9221
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { fontSize: 11, fontWeight: 600, color: "#1B1C1F" }, children: "\u9488\u5F0F\u786C\u4EF6\u504F\u79FB\u8865\u507F X/Y (mm)" }),
9222
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
9223
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9224
- "input",
9677
+ ),
9678
+ features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9679
+ "button",
9225
9680
  {
9226
- type: "number",
9227
- step: "0.5",
9228
- title: "\u6C34\u5E73\u504F\u79FB X (mm)",
9229
- value: printerOffsetXMm,
9230
- onChange: (e) => {
9231
- const nextX = Number(e.target.value) || 0;
9232
- setPrinterOffsetXMm(nextX);
9233
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9234
- printerOffsetXMm: nextX
9235
- });
9236
- },
9237
- style: {
9238
- width: "100%",
9239
- boxSizing: "border-box",
9240
- border: "1px solid #D5D8DF",
9241
- borderRadius: 4,
9242
- padding: "2px 4px",
9243
- fontSize: 11,
9244
- color: "#1B1C1F",
9245
- background: "#FFFFFF"
9246
- }
9681
+ type: "button",
9682
+ className: "univer-pdf-mini-btn",
9683
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9684
+ disabled: rendering,
9685
+ onClick: handleSilentPrint,
9686
+ children: [
9687
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9688
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9689
+ ]
9247
9690
  }
9248
9691
  ),
9249
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9250
- "input",
9692
+ ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9693
+ "button",
9251
9694
  {
9252
- type: "number",
9253
- step: "0.5",
9254
- title: "\u5782\u76F4\u504F\u79FB Y (mm)",
9255
- value: printerOffsetYMm,
9256
- onChange: (e) => {
9257
- const nextY = Number(e.target.value) || 0;
9258
- setPrinterOffsetYMm(nextY);
9259
- generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
9260
- printerOffsetYMm: nextY
9261
- });
9262
- },
9263
- style: {
9264
- width: "100%",
9265
- boxSizing: "border-box",
9266
- border: "1px solid #D5D8DF",
9267
- borderRadius: 4,
9268
- padding: "2px 4px",
9269
- fontSize: 11,
9270
- color: "#1B1C1F",
9271
- background: "#FFFFFF"
9272
- }
9695
+ type: "button",
9696
+ className: "univer-pdf-mini-btn",
9697
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9698
+ onClick: handleSaveToHost,
9699
+ children: [
9700
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiSaveIcon, {}),
9701
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4FDD\u5B58\u6A21\u677F\u81F3\u5BBF\u4E3B\u540E\u7AEF" })
9702
+ ]
9273
9703
  }
9274
- )
9275
- ] })
9276
- ] }),
9277
- splitMergeQuickBox,
9278
- features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9279
- "button",
9280
- {
9281
- type: "button",
9282
- className: "univer-pdf-mini-btn",
9283
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9284
- disabled: rendering,
9285
- onClick: handleBrowserPrint,
9286
- children: [
9287
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9288
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u6D4F\u89C8\u5668\u6253\u5370" })
9289
- ]
9290
- }
9291
- ),
9292
- features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9293
- "button",
9294
- {
9295
- type: "button",
9296
- className: "univer-pdf-mini-btn",
9297
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9298
- disabled: rendering,
9299
- onClick: handleSilentPrint,
9300
- children: [
9301
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiPrinterIcon, {}),
9302
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9759\u9ED8\u76F4\u6253 (Lodop/\u672C\u5730\u6253\u5370\u52A9\u624B)" })
9303
- ]
9304
- }
9305
- ),
9306
- ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9307
- "button",
9308
- {
9309
- type: "button",
9310
- className: "univer-pdf-mini-btn",
9311
- style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9312
- onClick: handleSaveToHost,
9313
- children: [
9314
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiSaveIcon, {}),
9315
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4FDD\u5B58\u6A21\u677F\u81F3\u5BBF\u4E3B\u540E\u7AEF" })
9316
- ]
9317
- }
9318
- ),
9319
- statusTip && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-status-banner", children: statusTip })
9320
- ] }),
9321
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-viewer", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PdfRenderedPagesViewer, { pdfBytes: pdfBytesState }) })
9322
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-body-json", children: [
9323
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-json-toolbar", children: [
9324
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-segmented is-inline", children: [
9325
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9326
- "button",
9327
- {
9328
- type: "button",
9329
- className: `univer-pdf-segmented-item ${jsonFormat === "univer" ? "is-active" : ""}`,
9330
- onClick: () => setJsonFormat("univer"),
9331
- children: "Univer IPdfUnitData \u6807\u51C6\u5951\u7EA6"
9332
- }
9333
- ),
9334
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9335
- "button",
9336
- {
9337
- type: "button",
9338
- className: `univer-pdf-segmented-item ${jsonFormat === "pdfme" ? "is-active" : ""}`,
9339
- onClick: () => setJsonFormat("pdfme"),
9340
- children: "pdfme Template \u517C\u5BB9\u683C\u5F0F (mm)"
9341
- }
9342
- )
9343
- ] }),
9344
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
9704
+ ),
9705
+ statusTip && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-status-banner", children: statusTip })
9706
+ ] }),
9707
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-viewer", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PdfRenderedPagesViewer, { pdfBytes: pdfBytesState, hasError: Boolean(ioError) }) })
9708
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-body-json", children: [
9709
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-json-toolbar", children: [
9710
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-segmented is-inline", children: [
9711
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9712
+ "button",
9713
+ {
9714
+ type: "button",
9715
+ className: `univer-pdf-segmented-item ${jsonFormat === "univer" ? "is-active" : ""}`,
9716
+ onClick: () => setJsonFormat("univer"),
9717
+ children: "Univer IPdfUnitData \u6807\u51C6\u5951\u7EA6"
9718
+ }
9719
+ ),
9720
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9721
+ "button",
9722
+ {
9723
+ type: "button",
9724
+ className: `univer-pdf-segmented-item ${jsonFormat === "pdfme" ? "is-active" : ""}`,
9725
+ onClick: () => setJsonFormat("pdfme"),
9726
+ children: "pdfme Template \u517C\u5BB9\u683C\u5F0F (mm)"
9727
+ }
9728
+ )
9729
+ ] }),
9730
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
9731
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9732
+ "button",
9733
+ {
9734
+ type: "button",
9735
+ className: "univer-pdf-mini-btn",
9736
+ onClick: () => {
9737
+ navigator.clipboard?.writeText(jsonEditorValue);
9738
+ setStatusTip("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\uFF01");
9739
+ },
9740
+ children: "\u590D\u5236 JSON"
9741
+ }
9742
+ ),
9743
+ ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9744
+ "button",
9745
+ {
9746
+ type: "button",
9747
+ className: "univer-pdf-mini-btn",
9748
+ style: { display: "inline-flex", alignItems: "center", gap: 4 },
9749
+ onClick: handleSaveToHost,
9750
+ children: [
9751
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiSaveIcon, {}),
9752
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF\u5BBF\u4E3B" })
9753
+ ]
9754
+ }
9755
+ ),
9756
+ editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9757
+ "button",
9758
+ {
9759
+ type: "button",
9760
+ className: "univer-pdf-mini-btn is-primary",
9761
+ onClick: handleApplyImportedJson,
9762
+ children: "\u5BFC\u5165\u5E76\u5E94\u7528\u7F16\u8F91\u5668\u4E2D\u7684 JSON"
9763
+ }
9764
+ )
9765
+ ] })
9766
+ ] }),
9767
+ statusTip && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-status-banner", children: statusTip }),
9345
9768
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9346
- "button",
9347
- {
9348
- type: "button",
9349
- className: "univer-pdf-mini-btn",
9350
- onClick: () => {
9351
- navigator.clipboard?.writeText(jsonEditorValue);
9352
- setStatusTip("\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F\uFF01");
9353
- },
9354
- children: "\u590D\u5236 JSON"
9355
- }
9356
- ),
9357
- ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
9358
- "button",
9359
- {
9360
- type: "button",
9361
- className: "univer-pdf-mini-btn",
9362
- style: { display: "inline-flex", alignItems: "center", gap: 4 },
9363
- onClick: handleSaveToHost,
9364
- children: [
9365
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiSaveIcon, {}),
9366
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4FDD\u5B58\u81F3\u540E\u7AEF\u5BBF\u4E3B" })
9367
- ]
9368
- }
9369
- ),
9370
- editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9371
- "button",
9769
+ "textarea",
9372
9770
  {
9373
- type: "button",
9374
- className: "univer-pdf-mini-btn is-primary",
9375
- onClick: handleApplyImportedJson,
9376
- children: "\u5BFC\u5165\u5E76\u5E94\u7528\u7F16\u8F91\u5668\u4E2D\u7684 JSON"
9771
+ className: "univer-pdf-code-editor",
9772
+ value: jsonEditorValue,
9773
+ onChange: (e) => setJsonEditorValue(e.target.value)
9377
9774
  }
9378
9775
  )
9379
9776
  ] })
9380
- ] }),
9381
- statusTip && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-status-banner", children: statusTip }),
9382
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
9383
- "textarea",
9384
- {
9385
- className: "univer-pdf-code-editor",
9386
- value: jsonEditorValue,
9387
- onChange: (e) => setJsonEditorValue(e.target.value)
9388
- }
9389
- )
9390
- ] })
9391
- ] }) });
9777
+ ]
9778
+ }
9779
+ ) });
9392
9780
  };
9393
9781
 
9394
9782
  // src/controllers/menu.schema.ts
@@ -10220,6 +10608,7 @@ UniverPdfsUIPlugin = __decorateClass([
10220
10608
  PdfLeftSidebar,
10221
10609
  PdfPreviewModal,
10222
10610
  PdfStatusBar,
10611
+ PdfUnifiedIoSection,
10223
10612
  PdfsUIController,
10224
10613
  PdfsUIEnUS,
10225
10614
  PdfsUIFeatureService,
@@ -10250,6 +10639,7 @@ UniverPdfsUIPlugin = __decorateClass([
10250
10639
  openPdfInspectorSidebar,
10251
10640
  readBrowserFileAsOverlayOutcome,
10252
10641
  renderSourcePdfPageToCanvas,
10642
+ resolveInitialModalIoTarget,
10253
10643
  resolvePdfsUIFeatures
10254
10644
  });
10255
10645
  //# sourceMappingURL=index.js.map