@yudaocode/univer-pdfs-ui 1.6.215 → 1.6.217
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 +425 -191
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +420 -191
- package/lib/es/index.js.map +1 -1
- package/lib/types/index.d.ts +65 -6
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
|
|
|
39
39
|
// src/index.ts
|
|
40
40
|
var src_exports = {};
|
|
41
41
|
__export(src_exports, {
|
|
42
|
+
ALL_PDF_IO_MODAL_TABS: () => ALL_PDF_IO_MODAL_TABS,
|
|
42
43
|
AdjustPdfZoomOperation: () => AdjustPdfZoomOperation,
|
|
43
44
|
IPdfsUIFeatureService: () => IPdfsUIFeatureService,
|
|
44
45
|
InsertPdfPresetElementOperation: () => InsertPdfPresetElementOperation,
|
|
@@ -72,9 +73,12 @@ __export(src_exports, {
|
|
|
72
73
|
UniverPdfsUIPlugin: () => UniverPdfsUIPlugin,
|
|
73
74
|
UpdatePdfUIFeaturesOperation: () => UpdatePdfUIFeaturesOperation,
|
|
74
75
|
UploadBasePdfOperation: () => UploadBasePdfOperation,
|
|
76
|
+
applyStagedPdfImportToUnit: () => applyStagedPdfImportToUnit,
|
|
77
|
+
clampPdfModalTab: () => clampPdfModalTab,
|
|
75
78
|
clearPdfDocumentCache: () => clearPdfDocumentCache,
|
|
76
79
|
computePdfDocumentCacheKey: () => computePdfDocumentCacheKey,
|
|
77
80
|
configurePdfjsAssets: () => configurePdfjsAssets,
|
|
81
|
+
executeGuardedStagedImport: () => executeGuardedStagedImport,
|
|
78
82
|
getPdfjsAssetsConfig: () => getPdfjsAssetsConfig,
|
|
79
83
|
inspectSourcePdfPages: () => inspectSourcePdfPages,
|
|
80
84
|
isPdfElementTypeAllowed: () => isPdfElementTypeAllowed,
|
|
@@ -83,6 +87,7 @@ __export(src_exports, {
|
|
|
83
87
|
readBrowserFileAsOverlayOutcome: () => readBrowserFileAsOverlayOutcome,
|
|
84
88
|
renderSourcePdfPageToCanvas: () => renderSourcePdfPageToCanvas,
|
|
85
89
|
resolveInitialModalIoTarget: () => resolveInitialModalIoTarget,
|
|
90
|
+
resolvePdfIoModalConfig: () => resolvePdfIoModalConfig,
|
|
86
91
|
resolvePdfsUIFeatures: () => resolvePdfsUIFeatures
|
|
87
92
|
});
|
|
88
93
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -524,6 +529,63 @@ var import_univer_pdfs = require("@yudaocode/univer-pdfs");
|
|
|
524
529
|
// src/services/pdfs-ui-feature.service.ts
|
|
525
530
|
var import_core = require("@univerjs/core");
|
|
526
531
|
var import_rxjs = require("rxjs");
|
|
532
|
+
var ALL_PDF_IO_MODAL_TABS = [
|
|
533
|
+
"preview",
|
|
534
|
+
"import",
|
|
535
|
+
"export",
|
|
536
|
+
"json"
|
|
537
|
+
];
|
|
538
|
+
function isValidPdfModalTab(val) {
|
|
539
|
+
return val === "preview" || val === "import" || val === "export" || val === "json";
|
|
540
|
+
}
|
|
541
|
+
function resolvePdfIoModalConfig(raw, base) {
|
|
542
|
+
let tabs;
|
|
543
|
+
let hasExplicitTabs;
|
|
544
|
+
if (Array.isArray(raw?.tabs)) {
|
|
545
|
+
const deduped = [];
|
|
546
|
+
for (const item of raw.tabs) {
|
|
547
|
+
if (isValidPdfModalTab(item) && !deduped.includes(item)) {
|
|
548
|
+
deduped.push(item);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
if (deduped.length > 0) {
|
|
552
|
+
tabs = deduped;
|
|
553
|
+
hasExplicitTabs = true;
|
|
554
|
+
} else {
|
|
555
|
+
tabs = base?.tabs ? [...base.tabs] : [...ALL_PDF_IO_MODAL_TABS];
|
|
556
|
+
hasExplicitTabs = Boolean(base?.hasExplicitTabs);
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
tabs = base?.tabs ? [...base.tabs] : [...ALL_PDF_IO_MODAL_TABS];
|
|
560
|
+
hasExplicitTabs = Boolean(base?.hasExplicitTabs);
|
|
561
|
+
}
|
|
562
|
+
const candidateDefault = raw?.defaultTab ?? base?.defaultTab ?? "preview";
|
|
563
|
+
let defaultTab;
|
|
564
|
+
if (isValidPdfModalTab(candidateDefault) && tabs.includes(candidateDefault)) {
|
|
565
|
+
defaultTab = candidateDefault;
|
|
566
|
+
} else if ((candidateDefault === "import" || candidateDefault === "export") && tabs.includes("preview")) {
|
|
567
|
+
defaultTab = "preview";
|
|
568
|
+
} else {
|
|
569
|
+
defaultTab = tabs[0] ?? "preview";
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
tabs,
|
|
573
|
+
defaultTab,
|
|
574
|
+
showPipelineBadge: raw?.showPipelineBadge ?? base?.showPipelineBadge ?? true,
|
|
575
|
+
hasExplicitTabs
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function clampPdfModalTab(requested, config) {
|
|
579
|
+
if (isValidPdfModalTab(requested)) {
|
|
580
|
+
if (config.tabs.includes(requested)) {
|
|
581
|
+
return requested;
|
|
582
|
+
}
|
|
583
|
+
if ((requested === "import" || requested === "export") && config.tabs.includes("preview")) {
|
|
584
|
+
return "preview";
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return config.defaultTab;
|
|
588
|
+
}
|
|
527
589
|
function resolvePdfsUIFeatures(raw) {
|
|
528
590
|
const rw = raw?.reportWidgets;
|
|
529
591
|
const qrcode = typeof rw === "boolean" ? rw : Boolean(rw?.qrcode);
|
|
@@ -569,20 +631,24 @@ var IPdfsUIFeatureService = (0, import_core.createIdentifier)(
|
|
|
569
631
|
"yudao.univer-pdfs-ui.feature.service"
|
|
570
632
|
);
|
|
571
633
|
var PdfsUIFeatureService = class extends import_core.Disposable {
|
|
572
|
-
constructor(initial, editorEnabled = true) {
|
|
634
|
+
constructor(initial, editorEnabled = true, ioModal) {
|
|
573
635
|
super();
|
|
574
|
-
this.
|
|
575
|
-
this.modalTab$ = this._modalTab$.asObservable();
|
|
636
|
+
this._baseIoModal = resolvePdfIoModalConfig(ioModal);
|
|
576
637
|
this._features$ = new import_rxjs.BehaviorSubject(resolvePdfsUIFeatures(initial));
|
|
638
|
+
this._modalTab$ = new import_rxjs.BehaviorSubject(this._baseIoModal.defaultTab);
|
|
577
639
|
this._editorEnabled$ = new import_rxjs.BehaviorSubject(editorEnabled);
|
|
640
|
+
this._ioModal$ = new import_rxjs.BehaviorSubject(this._baseIoModal);
|
|
578
641
|
this.features$ = this._features$.asObservable();
|
|
642
|
+
this.modalTab$ = this._modalTab$.asObservable();
|
|
579
643
|
this.editorEnabled$ = this._editorEnabled$.asObservable();
|
|
644
|
+
this.ioModal$ = this._ioModal$.asObservable();
|
|
580
645
|
}
|
|
581
646
|
dispose() {
|
|
582
647
|
super.dispose();
|
|
583
648
|
this._features$.complete();
|
|
584
649
|
this._modalTab$.complete();
|
|
585
650
|
this._editorEnabled$.complete();
|
|
651
|
+
this._ioModal$.complete();
|
|
586
652
|
}
|
|
587
653
|
getFeatures() {
|
|
588
654
|
return this._features$.getValue();
|
|
@@ -600,7 +666,27 @@ var PdfsUIFeatureService = class extends import_core.Disposable {
|
|
|
600
666
|
return this._modalTab$.getValue();
|
|
601
667
|
}
|
|
602
668
|
setModalTab(tab) {
|
|
603
|
-
this._modalTab$.next(tab);
|
|
669
|
+
this._modalTab$.next(clampPdfModalTab(tab, this._ioModal$.getValue()));
|
|
670
|
+
}
|
|
671
|
+
getIoModalConfig() {
|
|
672
|
+
const cur = this._ioModal$.getValue();
|
|
673
|
+
return {
|
|
674
|
+
...cur,
|
|
675
|
+
tabs: [...cur.tabs]
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
setIoModalConfig(config) {
|
|
679
|
+
this._baseIoModal = resolvePdfIoModalConfig(config);
|
|
680
|
+
this._ioModal$.next(this._baseIoModal);
|
|
681
|
+
this._modalTab$.next(clampPdfModalTab(this._modalTab$.getValue(), this._baseIoModal));
|
|
682
|
+
}
|
|
683
|
+
applyModalOpenConfig(override) {
|
|
684
|
+
const resolved = override ? resolvePdfIoModalConfig(override, this._baseIoModal) : {
|
|
685
|
+
...this._baseIoModal,
|
|
686
|
+
tabs: [...this._baseIoModal.tabs]
|
|
687
|
+
};
|
|
688
|
+
this._ioModal$.next(resolved);
|
|
689
|
+
return resolved;
|
|
604
690
|
}
|
|
605
691
|
isEditorEnabled() {
|
|
606
692
|
return this._editorEnabled$.getValue();
|
|
@@ -643,7 +729,9 @@ var OpenPdfPreviewOperation = {
|
|
|
643
729
|
const selectionService = accessor.get(import_univer_pdfs.IPdfSelectionService);
|
|
644
730
|
selectionService.commitActiveEditing();
|
|
645
731
|
selectionService.setEditingElement(null);
|
|
646
|
-
accessor.get(IPdfsUIFeatureService)
|
|
732
|
+
const featureService = accessor.get(IPdfsUIFeatureService);
|
|
733
|
+
const effectiveIoModal = featureService.applyModalOpenConfig(params?.ioModal);
|
|
734
|
+
featureService.setModalTab(clampPdfModalTab(params?.tab, effectiveIoModal));
|
|
647
735
|
selectionService.setPreviewOpen(true);
|
|
648
736
|
return true;
|
|
649
737
|
}
|
|
@@ -651,7 +739,8 @@ var OpenPdfPreviewOperation = {
|
|
|
651
739
|
async function readBrowserFileAsOverlayOutcome(file, options) {
|
|
652
740
|
const validated = await (0, import_univer_pdfs.importPdfSource)(file, {
|
|
653
741
|
fileName: file.name,
|
|
654
|
-
password: options?.password
|
|
742
|
+
password: options?.password,
|
|
743
|
+
signal: options?.signal
|
|
655
744
|
});
|
|
656
745
|
return {
|
|
657
746
|
mode: "overlay",
|
|
@@ -670,7 +759,8 @@ var UploadBasePdfOperation = {
|
|
|
670
759
|
selectionService.commitActiveEditing();
|
|
671
760
|
selectionService.setEditingElement(null);
|
|
672
761
|
if (!params?.file) {
|
|
673
|
-
featureService.
|
|
762
|
+
const effectiveIoModal = featureService.applyModalOpenConfig(params?.ioModal);
|
|
763
|
+
featureService.setModalTab(clampPdfModalTab("import", effectiveIoModal));
|
|
674
764
|
selectionService.setPreviewOpen(true);
|
|
675
765
|
return true;
|
|
676
766
|
}
|
|
@@ -683,8 +773,12 @@ var UploadBasePdfOperation = {
|
|
|
683
773
|
unitId: unit.getUnitId(),
|
|
684
774
|
snapshot: unit.save(),
|
|
685
775
|
target: params.target,
|
|
686
|
-
password: params.password
|
|
776
|
+
password: params.password,
|
|
777
|
+
signal: params.signal
|
|
687
778
|
}).then((outcome) => {
|
|
779
|
+
if (params.signal?.aborted) {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
688
782
|
if (outcome.mode === "snapshot") {
|
|
689
783
|
return commandService.syncExecuteCommand(import_univer_pdfs.ReplacePdfSnapshotCommand.id, {
|
|
690
784
|
unitId: unit.getUnitId(),
|
|
@@ -974,6 +1068,9 @@ var UpdatePdfUIFeaturesOperation = {
|
|
|
974
1068
|
if (typeof params?.editorEnabled === "boolean") {
|
|
975
1069
|
featureService.setEditorEnabled(params.editorEnabled);
|
|
976
1070
|
}
|
|
1071
|
+
if (params?.ioModal !== void 0) {
|
|
1072
|
+
featureService.setIoModalConfig(params.ioModal);
|
|
1073
|
+
}
|
|
977
1074
|
return true;
|
|
978
1075
|
}
|
|
979
1076
|
};
|
|
@@ -8267,6 +8364,69 @@ function resolveFallbackTarget(err, attemptedTarget) {
|
|
|
8267
8364
|
}
|
|
8268
8365
|
return attemptedTarget === "server" ? "browser" : "server";
|
|
8269
8366
|
}
|
|
8367
|
+
async function executeGuardedStagedImport(params) {
|
|
8368
|
+
params.importAbortRef?.current?.abort();
|
|
8369
|
+
const reqSeq = ++params.importReqSeqRef.current;
|
|
8370
|
+
const controller = typeof AbortController === "function" ? new AbortController() : null;
|
|
8371
|
+
if (params.importAbortRef) {
|
|
8372
|
+
params.importAbortRef.current = controller;
|
|
8373
|
+
}
|
|
8374
|
+
params.onStart?.();
|
|
8375
|
+
try {
|
|
8376
|
+
const report = await params.ioService.importPdfWithReport(params.file, {
|
|
8377
|
+
unitId: params.unitId,
|
|
8378
|
+
target: params.target,
|
|
8379
|
+
...controller ? { signal: controller.signal } : {}
|
|
8380
|
+
});
|
|
8381
|
+
if (reqSeq !== params.importReqSeqRef.current || controller?.signal.aborted) {
|
|
8382
|
+
return null;
|
|
8383
|
+
}
|
|
8384
|
+
params.onSuccess(report);
|
|
8385
|
+
return report;
|
|
8386
|
+
} catch (err) {
|
|
8387
|
+
if (reqSeq !== params.importReqSeqRef.current || controller?.signal.aborted || err?.name === "AbortError") {
|
|
8388
|
+
return null;
|
|
8389
|
+
}
|
|
8390
|
+
const fallbackTarget = resolveFallbackTarget(err, params.target);
|
|
8391
|
+
const msg = err?.message || String(err);
|
|
8392
|
+
params.onError({
|
|
8393
|
+
operation: "import",
|
|
8394
|
+
message: `PDF \u5BFC\u5165\u89E3\u6790\u5931\u8D25: ${msg}`,
|
|
8395
|
+
failedTarget: params.target,
|
|
8396
|
+
fallbackTarget
|
|
8397
|
+
});
|
|
8398
|
+
return null;
|
|
8399
|
+
} finally {
|
|
8400
|
+
if (reqSeq === params.importReqSeqRef.current) {
|
|
8401
|
+
if (params.importAbortRef && params.importAbortRef.current === controller) {
|
|
8402
|
+
params.importAbortRef.current = null;
|
|
8403
|
+
}
|
|
8404
|
+
params.onSettled?.();
|
|
8405
|
+
}
|
|
8406
|
+
}
|
|
8407
|
+
}
|
|
8408
|
+
function applyStagedPdfImportToUnit(commandService, unitId, staged) {
|
|
8409
|
+
const applied = staged.outcome.mode === "overlay" ? commandService.syncExecuteCommand(import_univer_pdfs7.ImportPdfSourceCommand.id, {
|
|
8410
|
+
unitId,
|
|
8411
|
+
sourceDocumentRef: staged.outcome.sourceDocumentRef,
|
|
8412
|
+
pageSizes: staged.outcome.pageSizes
|
|
8413
|
+
}) : commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
|
|
8414
|
+
unitId,
|
|
8415
|
+
snapshot: staged.snapshot
|
|
8416
|
+
});
|
|
8417
|
+
if (!applied) {
|
|
8418
|
+
return {
|
|
8419
|
+
applied: false,
|
|
8420
|
+
error: {
|
|
8421
|
+
operation: "import",
|
|
8422
|
+
message: "\u5E94\u7528\u5BFC\u5165\u5FEB\u7167\u5230\u8BBE\u8BA1\u5668\u5931\u8D25\uFF1A\u547D\u4EE4\u6267\u884C\u8FD4\u56DE false\uFF0C\u5F53\u524D\u6587\u6863\u672A\u88AB\u4FEE\u6539\u3002",
|
|
8423
|
+
failedTarget: staged.executedBy,
|
|
8424
|
+
fallbackTarget: staged.executedBy === "server" ? "browser" : "server"
|
|
8425
|
+
}
|
|
8426
|
+
};
|
|
8427
|
+
}
|
|
8428
|
+
return { applied: true };
|
|
8429
|
+
}
|
|
8270
8430
|
function uint8ToDataUri(bytes) {
|
|
8271
8431
|
let binary = "";
|
|
8272
8432
|
const chunkSize = 32768;
|
|
@@ -8361,6 +8521,7 @@ var PdfUnifiedIoSection = ({
|
|
|
8361
8521
|
serverAvailable,
|
|
8362
8522
|
snapSizeKb,
|
|
8363
8523
|
editorEnabled,
|
|
8524
|
+
showImportSection = true,
|
|
8364
8525
|
importing,
|
|
8365
8526
|
rendering,
|
|
8366
8527
|
selectedFileName,
|
|
@@ -8432,7 +8593,7 @@ var PdfUnifiedIoSection = ({
|
|
|
8432
8593
|
]
|
|
8433
8594
|
}
|
|
8434
8595
|
),
|
|
8435
|
-
editorEnabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-io-import-box", children: [
|
|
8596
|
+
editorEnabled && showImportSection && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-io-import-box", children: [
|
|
8436
8597
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
|
|
8437
8598
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: 11.5, fontWeight: 600, color: "#1B1C1F" }, children: "PDF / \u6A21\u677F\u5206\u9636\u6BB5\u5BFC\u5165" }),
|
|
8438
8599
|
selectedFileName && !pendingImport && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -8562,6 +8723,7 @@ var PdfPreviewModal = () => {
|
|
|
8562
8723
|
const featureService = (0, import_ui6.useDependency)(IPdfsUIFeatureService);
|
|
8563
8724
|
const features = (0, import_ui6.useObservable)(featureService.features$, featureService.getFeatures());
|
|
8564
8725
|
const editorEnabled = (0, import_ui6.useObservable)(featureService.editorEnabled$, featureService.isEditorEnabled());
|
|
8726
|
+
const ioModal = (0, import_ui6.useObservable)(featureService.ioModal$, featureService.getIoModalConfig());
|
|
8565
8727
|
const ioAdapter = (0, import_ui6.useObservable)(ioService.adapter$, ioService.getAdapter());
|
|
8566
8728
|
const open = (0, import_ui6.useObservable)(selectionService.previewOpen$, false);
|
|
8567
8729
|
const modalTab = (0, import_ui6.useObservable)(featureService.modalTab$, featureService.getModalTab());
|
|
@@ -8572,6 +8734,8 @@ var PdfPreviewModal = () => {
|
|
|
8572
8734
|
[instanceService]
|
|
8573
8735
|
);
|
|
8574
8736
|
const fileInputRef = (0, import_react5.useRef)(null);
|
|
8737
|
+
const importReqSeqRef = (0, import_react5.useRef)(0);
|
|
8738
|
+
const importAbortRef = (0, import_react5.useRef)(null);
|
|
8575
8739
|
const [sampleJsonText, setSampleJsonText] = (0, import_react5.useState)("{}");
|
|
8576
8740
|
const [pdfBytesState, setPdfBytesState] = (0, import_react5.useState)(null);
|
|
8577
8741
|
const [rendering, setRendering] = (0, import_react5.useState)(false);
|
|
@@ -8729,29 +8893,30 @@ var PdfPreviewModal = () => {
|
|
|
8729
8893
|
const runStagedImport = async (file, overrideTarget) => {
|
|
8730
8894
|
if (!unit) return;
|
|
8731
8895
|
const effectiveTarget = overrideTarget ?? ioTarget;
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
}
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8896
|
+
await executeGuardedStagedImport({
|
|
8897
|
+
file,
|
|
8898
|
+
unitId: unit.getUnitId(),
|
|
8899
|
+
target: effectiveTarget,
|
|
8900
|
+
ioService,
|
|
8901
|
+
importReqSeqRef,
|
|
8902
|
+
importAbortRef,
|
|
8903
|
+
onStart: () => {
|
|
8904
|
+
setImporting(true);
|
|
8905
|
+
setIoError(null);
|
|
8906
|
+
setPendingImport(null);
|
|
8907
|
+
setStatusTip("");
|
|
8908
|
+
},
|
|
8909
|
+
onSuccess: (report) => {
|
|
8910
|
+
setPendingImport(report);
|
|
8911
|
+
},
|
|
8912
|
+
onError: (errState) => {
|
|
8913
|
+
setPendingImport(null);
|
|
8914
|
+
setIoError(errState);
|
|
8915
|
+
},
|
|
8916
|
+
onSettled: () => {
|
|
8917
|
+
setImporting(false);
|
|
8918
|
+
}
|
|
8919
|
+
});
|
|
8755
8920
|
};
|
|
8756
8921
|
const handleImportFileChange = (e) => {
|
|
8757
8922
|
const file = e.target.files?.[0];
|
|
@@ -8763,17 +8928,11 @@ var PdfPreviewModal = () => {
|
|
|
8763
8928
|
const handleConfirmStagedImport = () => {
|
|
8764
8929
|
if (!unit || !pendingImport) return;
|
|
8765
8930
|
const staged = pendingImport;
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
});
|
|
8772
|
-
} else {
|
|
8773
|
-
commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
|
|
8774
|
-
unitId: unit.getUnitId(),
|
|
8775
|
-
snapshot: staged.snapshot
|
|
8776
|
-
});
|
|
8931
|
+
const outcomeResult = applyStagedPdfImportToUnit(commandService, unit.getUnitId(), staged);
|
|
8932
|
+
if (!outcomeResult.applied) {
|
|
8933
|
+
setIoError(outcomeResult.error ?? null);
|
|
8934
|
+
setStatusTip("");
|
|
8935
|
+
return;
|
|
8777
8936
|
}
|
|
8778
8937
|
setPendingImport(null);
|
|
8779
8938
|
setIoError(null);
|
|
@@ -8798,6 +8957,10 @@ var PdfPreviewModal = () => {
|
|
|
8798
8957
|
);
|
|
8799
8958
|
};
|
|
8800
8959
|
const handleCancelStagedImport = () => {
|
|
8960
|
+
importReqSeqRef.current += 1;
|
|
8961
|
+
importAbortRef.current?.abort();
|
|
8962
|
+
importAbortRef.current = null;
|
|
8963
|
+
setImporting(false);
|
|
8801
8964
|
setPendingImport(null);
|
|
8802
8965
|
setIoError(null);
|
|
8803
8966
|
setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u5185\u5BB9\u672A\u53D8\u66F4");
|
|
@@ -8806,7 +8969,7 @@ var PdfPreviewModal = () => {
|
|
|
8806
8969
|
setIoTarget(nextTarget);
|
|
8807
8970
|
setIoError(null);
|
|
8808
8971
|
setPdfBytesState(null);
|
|
8809
|
-
if (modalTab === "preview") {
|
|
8972
|
+
if (modalTab === "preview" || modalTab === "export") {
|
|
8810
8973
|
void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
|
|
8811
8974
|
} else if (modalTab === "import") {
|
|
8812
8975
|
const caps = ioService.getIoCapabilities();
|
|
@@ -8829,8 +8992,19 @@ var PdfPreviewModal = () => {
|
|
|
8829
8992
|
await generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
|
|
8830
8993
|
}
|
|
8831
8994
|
};
|
|
8995
|
+
(0, import_react5.useEffect)(() => {
|
|
8996
|
+
return () => {
|
|
8997
|
+
importReqSeqRef.current += 1;
|
|
8998
|
+
importAbortRef.current?.abort();
|
|
8999
|
+
importAbortRef.current = null;
|
|
9000
|
+
};
|
|
9001
|
+
}, []);
|
|
8832
9002
|
(0, import_react5.useEffect)(() => {
|
|
8833
9003
|
if (!open) {
|
|
9004
|
+
importReqSeqRef.current += 1;
|
|
9005
|
+
importAbortRef.current?.abort();
|
|
9006
|
+
importAbortRef.current = null;
|
|
9007
|
+
setImporting(false);
|
|
8834
9008
|
setPendingImport(null);
|
|
8835
9009
|
setSelectedImportFile(null);
|
|
8836
9010
|
setIoError(null);
|
|
@@ -8844,7 +9018,8 @@ var PdfPreviewModal = () => {
|
|
|
8844
9018
|
const initialPdfA = Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant);
|
|
8845
9019
|
const initialPdfUa = Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged);
|
|
8846
9020
|
const caps = ioService.getIoCapabilities();
|
|
8847
|
-
const
|
|
9021
|
+
const activeTab = clampPdfModalTab(featureService.getModalTab(), ioModal);
|
|
9022
|
+
const initialTarget = resolveInitialModalIoTarget(caps, activeTab);
|
|
8848
9023
|
setSampleJsonText(initialSampleText);
|
|
8849
9024
|
setWatermarkText(initialWm);
|
|
8850
9025
|
setExcludeBasePdf(initialStripBg);
|
|
@@ -8853,8 +9028,7 @@ var PdfPreviewModal = () => {
|
|
|
8853
9028
|
setIoTarget(initialTarget);
|
|
8854
9029
|
setIoError(null);
|
|
8855
9030
|
setStatusTip("");
|
|
8856
|
-
|
|
8857
|
-
if (activeTab === "preview") {
|
|
9031
|
+
if (activeTab === "preview" || activeTab === "export") {
|
|
8858
9032
|
void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
|
|
8859
9033
|
pdfACompliant: initialPdfA,
|
|
8860
9034
|
accessibilityTagged: initialPdfUa
|
|
@@ -9076,7 +9250,14 @@ var PdfPreviewModal = () => {
|
|
|
9076
9250
|
setStatusTip("\u672A\u8BC6\u522B\u7684 JSON \u683C\u5F0F\uFF1A\u8BF7\u63D0\u4F9B Univer IPdfUnitData \u6216 pdfme Template JSON");
|
|
9077
9251
|
return;
|
|
9078
9252
|
}
|
|
9079
|
-
commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
|
|
9253
|
+
const applied = commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
|
|
9254
|
+
unitId: unit.getUnitId(),
|
|
9255
|
+
snapshot: nextSnapshot
|
|
9256
|
+
});
|
|
9257
|
+
if (!applied) {
|
|
9258
|
+
setStatusTip("\u5E94\u7528\u6A21\u677F JSON \u5931\u8D25\uFF1AReplacePdfSnapshotCommand \u6267\u884C\u8FD4\u56DE false");
|
|
9259
|
+
return;
|
|
9260
|
+
}
|
|
9080
9261
|
setStatusTip("\u5DF2\u6210\u529F\u5E94\u7528\u6A21\u677F JSON\uFF08\u652F\u6301 Ctrl+Z \u64A4\u9500\uFF09\uFF01");
|
|
9081
9262
|
} catch (err) {
|
|
9082
9263
|
setStatusTip(`JSON \u89E3\u6790\u9519\u8BEF: ${err?.message || String(err)}`);
|
|
@@ -9086,9 +9267,24 @@ var PdfPreviewModal = () => {
|
|
|
9086
9267
|
const ioCaps = ioService.getIoCapabilities();
|
|
9087
9268
|
const pdfCapReport = (0, import_univer_pdfs7.inspectPdfExportCapabilities)(unit.save());
|
|
9088
9269
|
const snapSizeKb = (pdfCapReport.snapshotByteSize / 1024).toFixed(1);
|
|
9089
|
-
const
|
|
9090
|
-
const
|
|
9091
|
-
const
|
|
9270
|
+
const effectiveModalTab = clampPdfModalTab(modalTab, ioModal);
|
|
9271
|
+
const isUnifiedIoTab = !(effectiveModalTab === "json" && ioModal.tabs.includes("json"));
|
|
9272
|
+
const showImportControls = !ioModal.hasExplicitTabs ? ioModal.tabs.includes("import") : effectiveModalTab === "import";
|
|
9273
|
+
const showExportControls = !ioModal.hasExplicitTabs ? ioModal.tabs.includes("export") : effectiveModalTab === "export";
|
|
9274
|
+
const browserAvailable = effectiveModalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.browser) : Boolean(ioCaps.formats.export.pdf?.browser);
|
|
9275
|
+
const serverAvailable = effectiveModalTab === "import" ? Boolean(ioCaps.formats.import.pdf?.server) : Boolean(ioCaps.formats.export.pdf?.server);
|
|
9276
|
+
const tabLabelFor = (tabKey) => {
|
|
9277
|
+
switch (tabKey) {
|
|
9278
|
+
case "preview":
|
|
9279
|
+
return "PDF \u9884\u89C8";
|
|
9280
|
+
case "import":
|
|
9281
|
+
return "PDF \u5BFC\u5165";
|
|
9282
|
+
case "export":
|
|
9283
|
+
return "PDF \u5BFC\u51FA";
|
|
9284
|
+
case "json":
|
|
9285
|
+
return "{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)";
|
|
9286
|
+
}
|
|
9287
|
+
};
|
|
9092
9288
|
const unifiedIoSection = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9093
9289
|
PdfUnifiedIoSection,
|
|
9094
9290
|
{
|
|
@@ -9097,6 +9293,7 @@ var PdfPreviewModal = () => {
|
|
|
9097
9293
|
serverAvailable,
|
|
9098
9294
|
snapSizeKb,
|
|
9099
9295
|
editorEnabled,
|
|
9296
|
+
showImportSection: showImportControls,
|
|
9100
9297
|
importing,
|
|
9101
9298
|
rendering,
|
|
9102
9299
|
selectedFileName: selectedImportFile?.name,
|
|
@@ -9121,11 +9318,12 @@ var PdfPreviewModal = () => {
|
|
|
9121
9318
|
onClick: (e) => e.stopPropagation(),
|
|
9122
9319
|
children: [
|
|
9123
9320
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-header", children: [
|
|
9124
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
9321
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-tabs", children: !ioModal.hasExplicitTabs ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
9125
9322
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9126
9323
|
"button",
|
|
9127
9324
|
{
|
|
9128
9325
|
type: "button",
|
|
9326
|
+
"data-testid": "yudao-io-tab-preview",
|
|
9129
9327
|
className: `univer-pdf-modal-tab ${isUnifiedIoTab ? "is-active" : ""}`,
|
|
9130
9328
|
style: { display: "inline-flex", alignItems: "center", gap: 5 },
|
|
9131
9329
|
onClick: () => featureService.setModalTab("preview"),
|
|
@@ -9135,20 +9333,36 @@ var PdfPreviewModal = () => {
|
|
|
9135
9333
|
]
|
|
9136
9334
|
}
|
|
9137
9335
|
),
|
|
9138
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9336
|
+
ioModal.tabs.includes("json") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9139
9337
|
"button",
|
|
9140
9338
|
{
|
|
9141
9339
|
type: "button",
|
|
9142
|
-
|
|
9340
|
+
"data-testid": "yudao-io-tab-json",
|
|
9341
|
+
className: `univer-pdf-modal-tab ${effectiveModalTab === "json" ? "is-active" : ""}`,
|
|
9143
9342
|
onClick: () => featureService.setModalTab("json"),
|
|
9144
9343
|
children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
|
|
9145
9344
|
}
|
|
9146
9345
|
)
|
|
9147
|
-
] }),
|
|
9346
|
+
] }) : ioModal.tabs.map((tabKey) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9347
|
+
"button",
|
|
9348
|
+
{
|
|
9349
|
+
type: "button",
|
|
9350
|
+
"data-testid": `yudao-io-tab-${tabKey}`,
|
|
9351
|
+
className: `univer-pdf-modal-tab ${effectiveModalTab === tabKey ? "is-active" : ""}`,
|
|
9352
|
+
style: { display: "inline-flex", alignItems: "center", gap: 5 },
|
|
9353
|
+
onClick: () => featureService.setModalTab(tabKey),
|
|
9354
|
+
children: [
|
|
9355
|
+
tabKey !== "json" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiFilePdfIcon, {}),
|
|
9356
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: tabLabelFor(tabKey) })
|
|
9357
|
+
]
|
|
9358
|
+
},
|
|
9359
|
+
tabKey
|
|
9360
|
+
)) }),
|
|
9148
9361
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
|
|
9149
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9362
|
+
ioModal.showPipelineBadge && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9150
9363
|
"span",
|
|
9151
9364
|
{
|
|
9365
|
+
"data-testid": "yudao-io-pipeline-badge",
|
|
9152
9366
|
style: {
|
|
9153
9367
|
fontSize: 11,
|
|
9154
9368
|
padding: "3px 8px",
|
|
@@ -9512,7 +9726,7 @@ var PdfPreviewModal = () => {
|
|
|
9512
9726
|
}
|
|
9513
9727
|
)
|
|
9514
9728
|
] }),
|
|
9515
|
-
splitMergeQuickBox,
|
|
9729
|
+
showExportControls && splitMergeQuickBox,
|
|
9516
9730
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
|
|
9517
9731
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9518
9732
|
"button",
|
|
@@ -9524,41 +9738,43 @@ var PdfPreviewModal = () => {
|
|
|
9524
9738
|
children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
|
|
9525
9739
|
}
|
|
9526
9740
|
),
|
|
9527
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9741
|
+
showExportControls && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
9742
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9743
|
+
"button",
|
|
9744
|
+
{
|
|
9745
|
+
type: "button",
|
|
9746
|
+
className: "univer-pdf-mini-btn",
|
|
9747
|
+
disabled: rendering,
|
|
9748
|
+
onClick: () => {
|
|
9749
|
+
const baseObj = unit.save().metadata?.sampleData ?? { orderNo: "SO-2026-001" };
|
|
9750
|
+
const batchArr = [1, 2, 3].map((n) => ({
|
|
9751
|
+
...baseObj,
|
|
9752
|
+
orderNo: `BATCH-2026-00${n}`,
|
|
9753
|
+
batchSeq: n
|
|
9754
|
+
}));
|
|
9755
|
+
const txt = JSON.stringify(batchArr, null, 2);
|
|
9756
|
+
setSampleJsonText(txt);
|
|
9757
|
+
void generatePreview(txt);
|
|
9758
|
+
},
|
|
9759
|
+
children: "\u6279\u91CF\u5957\u6253 (3\u5355\u5408\u5E76)"
|
|
9760
|
+
}
|
|
9761
|
+
),
|
|
9762
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9763
|
+
"button",
|
|
9764
|
+
{
|
|
9765
|
+
type: "button",
|
|
9766
|
+
"data-testid": "yudao-io-export-download",
|
|
9767
|
+
className: "univer-pdf-mini-btn",
|
|
9768
|
+
style: { display: "inline-flex", alignItems: "center", gap: 4 },
|
|
9769
|
+
disabled: rendering,
|
|
9770
|
+
onClick: () => void handleExportAndDownload(),
|
|
9771
|
+
children: [
|
|
9772
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
|
|
9773
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D PDF \u6587\u4EF6" })
|
|
9774
|
+
]
|
|
9775
|
+
}
|
|
9776
|
+
)
|
|
9777
|
+
] }),
|
|
9562
9778
|
features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9563
9779
|
"button",
|
|
9564
9780
|
{
|
|
@@ -9606,109 +9822,118 @@ var PdfPreviewModal = () => {
|
|
|
9606
9822
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "univer-pdf-modal-label", children: "\u901A\u7528 PDF \u5BFC\u5165\u4E0E\u5BFC\u51FA\u5DE5\u4F5C\u53F0" }),
|
|
9607
9823
|
/* @__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" }),
|
|
9608
9824
|
unifiedIoSection,
|
|
9609
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
type: "button",
|
|
9613
|
-
"data-testid": "yudao-io-export-download",
|
|
9614
|
-
className: "univer-pdf-mini-btn is-primary",
|
|
9615
|
-
style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
|
|
9616
|
-
disabled: rendering,
|
|
9617
|
-
onClick: () => void handleExportAndDownload(),
|
|
9618
|
-
children: [
|
|
9619
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
|
|
9620
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
|
|
9621
|
-
]
|
|
9622
|
-
}
|
|
9623
|
-
),
|
|
9624
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9625
|
-
"button",
|
|
9626
|
-
{
|
|
9627
|
-
type: "button",
|
|
9628
|
-
className: "univer-pdf-mini-btn",
|
|
9629
|
-
style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
|
|
9630
|
-
disabled: rendering,
|
|
9631
|
-
onClick: handleDownloadCalibrationGrid,
|
|
9632
|
-
children: [
|
|
9633
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiRulerGridIcon, {}),
|
|
9634
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
|
|
9635
|
-
]
|
|
9636
|
-
}
|
|
9637
|
-
),
|
|
9638
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
|
|
9639
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9640
|
-
"input",
|
|
9825
|
+
showExportControls && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
9826
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9827
|
+
"button",
|
|
9641
9828
|
{
|
|
9642
|
-
type: "
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9829
|
+
type: "button",
|
|
9830
|
+
"data-testid": "yudao-io-export-download",
|
|
9831
|
+
className: "univer-pdf-mini-btn is-primary",
|
|
9832
|
+
style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
|
|
9833
|
+
disabled: rendering,
|
|
9834
|
+
onClick: () => void handleExportAndDownload(),
|
|
9835
|
+
children: [
|
|
9836
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
|
|
9837
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
|
|
9838
|
+
]
|
|
9649
9839
|
}
|
|
9650
9840
|
),
|
|
9651
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9841
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9842
|
+
"button",
|
|
9843
|
+
{
|
|
9844
|
+
type: "button",
|
|
9845
|
+
className: "univer-pdf-mini-btn",
|
|
9846
|
+
style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
|
|
9847
|
+
disabled: rendering,
|
|
9848
|
+
onClick: handleDownloadCalibrationGrid,
|
|
9849
|
+
children: [
|
|
9850
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiRulerGridIcon, {}),
|
|
9851
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6BEB\u7C73\u6821\u51C6\u6D4B\u8BD5\u5C3A PDF" })
|
|
9852
|
+
]
|
|
9853
|
+
}
|
|
9854
|
+
),
|
|
9855
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "univer-pdf-checkbox-row", style: { fontSize: 11.5 }, children: [
|
|
9657
9856
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9658
9857
|
"input",
|
|
9659
9858
|
{
|
|
9660
|
-
type: "
|
|
9661
|
-
|
|
9662
|
-
title: "\u6C34\u5E73\u504F\u79FB X (mm)",
|
|
9663
|
-
value: printerOffsetXMm,
|
|
9859
|
+
type: "checkbox",
|
|
9860
|
+
checked: enableAuditSeal,
|
|
9664
9861
|
onChange: (e) => {
|
|
9665
|
-
const
|
|
9666
|
-
|
|
9667
|
-
void generatePreview(
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
borderRadius: 4,
|
|
9676
|
-
padding: "2px 4px",
|
|
9677
|
-
fontSize: 11,
|
|
9678
|
-
color: "#1B1C1F",
|
|
9679
|
-
background: "#FFFFFF"
|
|
9862
|
+
const checked = e.target.checked;
|
|
9863
|
+
setEnableAuditSeal(checked);
|
|
9864
|
+
void generatePreview(
|
|
9865
|
+
sampleJsonText,
|
|
9866
|
+
watermarkText,
|
|
9867
|
+
excludeBasePdf,
|
|
9868
|
+
ioTarget,
|
|
9869
|
+
void 0,
|
|
9870
|
+
checked
|
|
9871
|
+
);
|
|
9680
9872
|
}
|
|
9681
9873
|
}
|
|
9682
9874
|
),
|
|
9683
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9875
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiShieldSealIcon, { style: { color: "#4E5565" } }),
|
|
9876
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u9644\u52A0 SHA-256 \u9632\u7BE1\u6539\u7B7E\u7AE0\u6458\u8981" })
|
|
9877
|
+
] }),
|
|
9878
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
|
|
9879
|
+
/* @__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)" }),
|
|
9880
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 4 }, children: [
|
|
9881
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9882
|
+
"input",
|
|
9883
|
+
{
|
|
9884
|
+
type: "number",
|
|
9885
|
+
step: "0.5",
|
|
9886
|
+
title: "\u6C34\u5E73\u504F\u79FB X (mm)",
|
|
9887
|
+
value: printerOffsetXMm,
|
|
9888
|
+
onChange: (e) => {
|
|
9889
|
+
const nextX = Number(e.target.value) || 0;
|
|
9890
|
+
setPrinterOffsetXMm(nextX);
|
|
9891
|
+
void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
|
|
9892
|
+
printerOffsetXMm: nextX
|
|
9893
|
+
});
|
|
9894
|
+
},
|
|
9895
|
+
style: {
|
|
9896
|
+
width: "100%",
|
|
9897
|
+
boxSizing: "border-box",
|
|
9898
|
+
border: "1px solid #D5D8DF",
|
|
9899
|
+
borderRadius: 4,
|
|
9900
|
+
padding: "2px 4px",
|
|
9901
|
+
fontSize: 11,
|
|
9902
|
+
color: "#1B1C1F",
|
|
9903
|
+
background: "#FFFFFF"
|
|
9904
|
+
}
|
|
9706
9905
|
}
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9906
|
+
),
|
|
9907
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9908
|
+
"input",
|
|
9909
|
+
{
|
|
9910
|
+
type: "number",
|
|
9911
|
+
step: "0.5",
|
|
9912
|
+
title: "\u5782\u76F4\u504F\u79FB Y (mm)",
|
|
9913
|
+
value: printerOffsetYMm,
|
|
9914
|
+
onChange: (e) => {
|
|
9915
|
+
const nextY = Number(e.target.value) || 0;
|
|
9916
|
+
setPrinterOffsetYMm(nextY);
|
|
9917
|
+
void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, ioTarget, {
|
|
9918
|
+
printerOffsetYMm: nextY
|
|
9919
|
+
});
|
|
9920
|
+
},
|
|
9921
|
+
style: {
|
|
9922
|
+
width: "100%",
|
|
9923
|
+
boxSizing: "border-box",
|
|
9924
|
+
border: "1px solid #D5D8DF",
|
|
9925
|
+
borderRadius: 4,
|
|
9926
|
+
padding: "2px 4px",
|
|
9927
|
+
fontSize: 11,
|
|
9928
|
+
color: "#1B1C1F",
|
|
9929
|
+
background: "#FFFFFF"
|
|
9930
|
+
}
|
|
9931
|
+
}
|
|
9932
|
+
)
|
|
9933
|
+
] })
|
|
9934
|
+
] }),
|
|
9935
|
+
splitMergeQuickBox
|
|
9710
9936
|
] }),
|
|
9711
|
-
splitMergeQuickBox,
|
|
9712
9937
|
features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9713
9938
|
"button",
|
|
9714
9939
|
{
|
|
@@ -9859,13 +10084,17 @@ function createBtn(config) {
|
|
|
9859
10084
|
tooltip: config.tooltip ?? config.title,
|
|
9860
10085
|
icon: config.icon,
|
|
9861
10086
|
params: config.params,
|
|
9862
|
-
hidden$: needsHiddenObs ? (0, import_rxjs6.combineLatest)([
|
|
9863
|
-
|
|
10087
|
+
hidden$: needsHiddenObs ? (0, import_rxjs6.combineLatest)([
|
|
10088
|
+
featService.features$,
|
|
10089
|
+
featService.editorEnabled$,
|
|
10090
|
+
featService.ioModal$
|
|
10091
|
+
]).pipe(
|
|
10092
|
+
(0, import_rxjs6.map)(([f, editorEnabled, ioModal]) => {
|
|
9864
10093
|
if (requiresEditor && !editorEnabled) return true;
|
|
9865
10094
|
if (config.elementTypeGate && !isPdfElementTypeAllowed(config.elementTypeGate, f)) {
|
|
9866
10095
|
return true;
|
|
9867
10096
|
}
|
|
9868
|
-
return config.hiddenWhen ? config.hiddenWhen(f, editorEnabled) : false;
|
|
10097
|
+
return config.hiddenWhen ? config.hiddenWhen(f, editorEnabled, ioModal) : false;
|
|
9869
10098
|
})
|
|
9870
10099
|
) : void 0
|
|
9871
10100
|
};
|
|
@@ -10141,7 +10370,7 @@ var UploadBasePdfMenuFactory = createBtn({
|
|
|
10141
10370
|
label: "pdfs.ribbon.importPdf",
|
|
10142
10371
|
icon: "PdfUploadIcon",
|
|
10143
10372
|
requiresEditor: true,
|
|
10144
|
-
hiddenWhen: (f) => !f.basePdfOverlay
|
|
10373
|
+
hiddenWhen: (f, _editor, ioModal) => !f.basePdfOverlay || !ioModal.tabs.includes("import")
|
|
10145
10374
|
});
|
|
10146
10375
|
var OpenJsonExchangeMenuFactory = createBtn({
|
|
10147
10376
|
id: "pdfs-ui.menu.open-json",
|
|
@@ -10150,7 +10379,8 @@ var OpenJsonExchangeMenuFactory = createBtn({
|
|
|
10150
10379
|
label: "pdfs.ribbon.jsonExchange",
|
|
10151
10380
|
icon: "PdfJsonIcon",
|
|
10152
10381
|
params: { tab: "json" },
|
|
10153
|
-
requiresEditor: true
|
|
10382
|
+
requiresEditor: true,
|
|
10383
|
+
hiddenWhen: (_f, _editor, ioModal) => !ioModal.tabs.includes("json")
|
|
10154
10384
|
});
|
|
10155
10385
|
var ToggleInspectorMenuFactory = createBtn({
|
|
10156
10386
|
id: TogglePdfInspectorOperation.id,
|
|
@@ -10163,8 +10393,7 @@ var OpenPdfPreviewMenuFactory = createBtn({
|
|
|
10163
10393
|
id: OpenPdfPreviewOperation.id,
|
|
10164
10394
|
title: "pdfs.ribbon.previewPdf",
|
|
10165
10395
|
label: "pdfs.ribbon.previewPdf",
|
|
10166
|
-
icon: "PdfPreviewIcon"
|
|
10167
|
-
params: { tab: "preview" }
|
|
10396
|
+
icon: "PdfPreviewIcon"
|
|
10168
10397
|
});
|
|
10169
10398
|
var PrintPdfMenuFactory = createBtn({
|
|
10170
10399
|
id: PrintPdfOperation.id,
|
|
@@ -10623,7 +10852,7 @@ var UniverPdfsUIPlugin = class extends import_core9.Plugin {
|
|
|
10623
10852
|
this._injector.add([
|
|
10624
10853
|
IPdfsUIFeatureService,
|
|
10625
10854
|
{
|
|
10626
|
-
useFactory: () => new PdfsUIFeatureService(this._config.features, editorEnabled)
|
|
10855
|
+
useFactory: () => new PdfsUIFeatureService(this._config.features, editorEnabled, this._config.ioModal)
|
|
10627
10856
|
}
|
|
10628
10857
|
]);
|
|
10629
10858
|
this._injector.add([
|
|
@@ -10644,6 +10873,7 @@ UniverPdfsUIPlugin = __decorateClass([
|
|
|
10644
10873
|
], UniverPdfsUIPlugin);
|
|
10645
10874
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10646
10875
|
0 && (module.exports = {
|
|
10876
|
+
ALL_PDF_IO_MODAL_TABS,
|
|
10647
10877
|
AdjustPdfZoomOperation,
|
|
10648
10878
|
IPdfsUIFeatureService,
|
|
10649
10879
|
InsertPdfPresetElementOperation,
|
|
@@ -10677,9 +10907,12 @@ UniverPdfsUIPlugin = __decorateClass([
|
|
|
10677
10907
|
UniverPdfsUIPlugin,
|
|
10678
10908
|
UpdatePdfUIFeaturesOperation,
|
|
10679
10909
|
UploadBasePdfOperation,
|
|
10910
|
+
applyStagedPdfImportToUnit,
|
|
10911
|
+
clampPdfModalTab,
|
|
10680
10912
|
clearPdfDocumentCache,
|
|
10681
10913
|
computePdfDocumentCacheKey,
|
|
10682
10914
|
configurePdfjsAssets,
|
|
10915
|
+
executeGuardedStagedImport,
|
|
10683
10916
|
getPdfjsAssetsConfig,
|
|
10684
10917
|
inspectSourcePdfPages,
|
|
10685
10918
|
isPdfElementTypeAllowed,
|
|
@@ -10688,6 +10921,7 @@ UniverPdfsUIPlugin = __decorateClass([
|
|
|
10688
10921
|
readBrowserFileAsOverlayOutcome,
|
|
10689
10922
|
renderSourcePdfPageToCanvas,
|
|
10690
10923
|
resolveInitialModalIoTarget,
|
|
10924
|
+
resolvePdfIoModalConfig,
|
|
10691
10925
|
resolvePdfsUIFeatures
|
|
10692
10926
|
});
|
|
10693
10927
|
//# sourceMappingURL=index.js.map
|