@yudaocode/univer-pdfs-ui 1.6.214 → 1.6.216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +481 -199
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/index.js +476 -199
- 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
|
};
|
|
@@ -1082,19 +1179,53 @@ function loadPdfDocument(dataUri, overrideAssets) {
|
|
|
1082
1179
|
const effectiveAssets = overrideAssets ?? configuredAssets ?? resolveGlobalPdfjsAssets();
|
|
1083
1180
|
ensurePdfjsWorker(effectiveAssets);
|
|
1084
1181
|
const bytes = dataUriToUint8Array(dataUri);
|
|
1085
|
-
const cacheKey = (0, import_univer_pdfs2.computePdfPayloadDigest)(bytes)
|
|
1182
|
+
const cacheKey = `${(0, import_univer_pdfs2.computePdfPayloadDigest)(bytes)}|${effectiveAssets?.cMapUrl ?? ""}`;
|
|
1086
1183
|
const existing = docCache.get(cacheKey);
|
|
1087
|
-
if (existing) {
|
|
1184
|
+
if (existing && existing.cMapFailures.length === 0) {
|
|
1088
1185
|
touchCacheEntry(cacheKey, existing);
|
|
1089
|
-
return existing.promise;
|
|
1186
|
+
return { promise: existing.promise, entry: existing, cacheKey };
|
|
1090
1187
|
}
|
|
1188
|
+
const cMapFailures = [];
|
|
1091
1189
|
const docInitParams = {
|
|
1092
1190
|
data: bytes.slice(),
|
|
1093
1191
|
isEvalSupported: false
|
|
1094
1192
|
};
|
|
1095
1193
|
if (effectiveAssets?.cMapUrl) {
|
|
1096
|
-
|
|
1097
|
-
|
|
1194
|
+
const cMapUrl = effectiveAssets.cMapUrl;
|
|
1195
|
+
const cMapPacked = effectiveAssets.cMapPacked ?? true;
|
|
1196
|
+
const normalizedBase = cMapUrl.endsWith("/") ? cMapUrl : `${cMapUrl}/`;
|
|
1197
|
+
docInitParams.cMapUrl = normalizedBase;
|
|
1198
|
+
docInitParams.cMapPacked = cMapPacked;
|
|
1199
|
+
docInitParams.CMapReaderFactory = class BgTrackedCMapReaderFactory {
|
|
1200
|
+
constructor(params) {
|
|
1201
|
+
this.baseUrl = params?.baseUrl ?? normalizedBase;
|
|
1202
|
+
this.isCompressed = params?.isCompressed ?? cMapPacked;
|
|
1203
|
+
}
|
|
1204
|
+
async fetch({ name }) {
|
|
1205
|
+
const base = this.baseUrl.endsWith("/") ? this.baseUrl : `${this.baseUrl}/`;
|
|
1206
|
+
const url = `${base}${name}${this.isCompressed ? ".bcmap" : ""}`;
|
|
1207
|
+
let resp;
|
|
1208
|
+
try {
|
|
1209
|
+
resp = await fetch(url);
|
|
1210
|
+
} catch (err) {
|
|
1211
|
+
const reason = err?.message || String(err);
|
|
1212
|
+
cMapFailures.push({ name, url, reason });
|
|
1213
|
+
throw new Error(`Unable to load CMap at ${url}: ${reason}`);
|
|
1214
|
+
}
|
|
1215
|
+
if (!resp.ok) {
|
|
1216
|
+
const reason = `HTTP ${resp.status}`;
|
|
1217
|
+
cMapFailures.push({ name, url, reason });
|
|
1218
|
+
throw new Error(`Unable to load CMap at ${url}: ${reason}`);
|
|
1219
|
+
}
|
|
1220
|
+
const buf = new Uint8Array(await resp.arrayBuffer());
|
|
1221
|
+
if (buf.byteLength === 0) {
|
|
1222
|
+
const reason = "Empty CMap payload";
|
|
1223
|
+
cMapFailures.push({ name, url, reason });
|
|
1224
|
+
throw new Error(`Unable to load CMap at ${url}: ${reason}`);
|
|
1225
|
+
}
|
|
1226
|
+
return { cMapData: buf, isCompressed: this.isCompressed };
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1098
1229
|
}
|
|
1099
1230
|
if (effectiveAssets?.standardFontDataUrl) {
|
|
1100
1231
|
docInitParams.standardFontDataUrl = effectiveAssets.standardFontDataUrl;
|
|
@@ -1104,6 +1235,7 @@ function loadPdfDocument(dataUri, overrideAssets) {
|
|
|
1104
1235
|
}
|
|
1105
1236
|
const loadingTask = pdfjsLib.getDocument(docInitParams);
|
|
1106
1237
|
const entry = {
|
|
1238
|
+
cMapFailures,
|
|
1107
1239
|
promise: loadingTask.promise.then((doc) => {
|
|
1108
1240
|
entry.resolvedDoc = doc;
|
|
1109
1241
|
return doc;
|
|
@@ -1116,10 +1248,11 @@ function loadPdfDocument(dataUri, overrideAssets) {
|
|
|
1116
1248
|
};
|
|
1117
1249
|
docCache.set(cacheKey, entry);
|
|
1118
1250
|
evictOverflowCacheEntries();
|
|
1119
|
-
return entry.promise;
|
|
1251
|
+
return { promise: entry.promise, entry, cacheKey };
|
|
1120
1252
|
}
|
|
1121
1253
|
async function inspectSourcePdfPages(dataUri, assets) {
|
|
1122
|
-
const
|
|
1254
|
+
const { promise: docPromise } = loadPdfDocument(dataUri, assets);
|
|
1255
|
+
const doc = await docPromise;
|
|
1123
1256
|
const sizes = [];
|
|
1124
1257
|
for (let i = 1; i <= doc.numPages; i++) {
|
|
1125
1258
|
const page = await doc.getPage(i);
|
|
@@ -1151,7 +1284,8 @@ async function renderSourcePdfPageToCanvas(canvas, dataUri, pageNumber, targetWi
|
|
|
1151
1284
|
} catch {
|
|
1152
1285
|
}
|
|
1153
1286
|
}
|
|
1154
|
-
const
|
|
1287
|
+
const { promise: docPromise, entry: docEntry, cacheKey } = loadPdfDocument(dataUri, assets);
|
|
1288
|
+
const doc = await docPromise;
|
|
1155
1289
|
if (activeCanvasRenderTasks.has(canvas)) {
|
|
1156
1290
|
return;
|
|
1157
1291
|
}
|
|
@@ -1172,6 +1306,17 @@ async function renderSourcePdfPageToCanvas(canvas, dataUri, pageNumber, targetWi
|
|
|
1172
1306
|
activeCanvasRenderTasks.set(canvas, renderTask);
|
|
1173
1307
|
try {
|
|
1174
1308
|
await renderTask.promise;
|
|
1309
|
+
if (docEntry.cMapFailures.length > 0) {
|
|
1310
|
+
const f = docEntry.cMapFailures[0];
|
|
1311
|
+
if (docCache.get(cacheKey) === docEntry) {
|
|
1312
|
+
docCache.delete(cacheKey);
|
|
1313
|
+
}
|
|
1314
|
+
const err = new Error(
|
|
1315
|
+
`PDF \u4E2D\u6587\u5B57\u4F53 CMap \u8D44\u6E90\u52A0\u8F7D\u5931\u8D25\uFF08${f.name}\uFF1A${f.url}\uFF0C${f.reason}\uFF09`
|
|
1316
|
+
);
|
|
1317
|
+
err.code = "CMAP_LOAD_FAILED";
|
|
1318
|
+
throw err;
|
|
1319
|
+
}
|
|
1175
1320
|
} catch (err) {
|
|
1176
1321
|
if (isRenderingCancelledError(err)) {
|
|
1177
1322
|
return;
|
|
@@ -8219,6 +8364,69 @@ function resolveFallbackTarget(err, attemptedTarget) {
|
|
|
8219
8364
|
}
|
|
8220
8365
|
return attemptedTarget === "server" ? "browser" : "server";
|
|
8221
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
|
+
}
|
|
8222
8430
|
function uint8ToDataUri(bytes) {
|
|
8223
8431
|
let binary = "";
|
|
8224
8432
|
const chunkSize = 32768;
|
|
@@ -8313,6 +8521,7 @@ var PdfUnifiedIoSection = ({
|
|
|
8313
8521
|
serverAvailable,
|
|
8314
8522
|
snapSizeKb,
|
|
8315
8523
|
editorEnabled,
|
|
8524
|
+
showImportSection = true,
|
|
8316
8525
|
importing,
|
|
8317
8526
|
rendering,
|
|
8318
8527
|
selectedFileName,
|
|
@@ -8384,7 +8593,7 @@ var PdfUnifiedIoSection = ({
|
|
|
8384
8593
|
]
|
|
8385
8594
|
}
|
|
8386
8595
|
),
|
|
8387
|
-
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: [
|
|
8388
8597
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }, children: [
|
|
8389
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" }),
|
|
8390
8599
|
selectedFileName && !pendingImport && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -8514,6 +8723,7 @@ var PdfPreviewModal = () => {
|
|
|
8514
8723
|
const featureService = (0, import_ui6.useDependency)(IPdfsUIFeatureService);
|
|
8515
8724
|
const features = (0, import_ui6.useObservable)(featureService.features$, featureService.getFeatures());
|
|
8516
8725
|
const editorEnabled = (0, import_ui6.useObservable)(featureService.editorEnabled$, featureService.isEditorEnabled());
|
|
8726
|
+
const ioModal = (0, import_ui6.useObservable)(featureService.ioModal$, featureService.getIoModalConfig());
|
|
8517
8727
|
const ioAdapter = (0, import_ui6.useObservable)(ioService.adapter$, ioService.getAdapter());
|
|
8518
8728
|
const open = (0, import_ui6.useObservable)(selectionService.previewOpen$, false);
|
|
8519
8729
|
const modalTab = (0, import_ui6.useObservable)(featureService.modalTab$, featureService.getModalTab());
|
|
@@ -8524,6 +8734,8 @@ var PdfPreviewModal = () => {
|
|
|
8524
8734
|
[instanceService]
|
|
8525
8735
|
);
|
|
8526
8736
|
const fileInputRef = (0, import_react5.useRef)(null);
|
|
8737
|
+
const importReqSeqRef = (0, import_react5.useRef)(0);
|
|
8738
|
+
const importAbortRef = (0, import_react5.useRef)(null);
|
|
8527
8739
|
const [sampleJsonText, setSampleJsonText] = (0, import_react5.useState)("{}");
|
|
8528
8740
|
const [pdfBytesState, setPdfBytesState] = (0, import_react5.useState)(null);
|
|
8529
8741
|
const [rendering, setRendering] = (0, import_react5.useState)(false);
|
|
@@ -8681,29 +8893,30 @@ var PdfPreviewModal = () => {
|
|
|
8681
8893
|
const runStagedImport = async (file, overrideTarget) => {
|
|
8682
8894
|
if (!unit) return;
|
|
8683
8895
|
const effectiveTarget = overrideTarget ?? ioTarget;
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
}
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
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
|
+
});
|
|
8707
8920
|
};
|
|
8708
8921
|
const handleImportFileChange = (e) => {
|
|
8709
8922
|
const file = e.target.files?.[0];
|
|
@@ -8715,17 +8928,11 @@ var PdfPreviewModal = () => {
|
|
|
8715
8928
|
const handleConfirmStagedImport = () => {
|
|
8716
8929
|
if (!unit || !pendingImport) return;
|
|
8717
8930
|
const staged = pendingImport;
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
});
|
|
8724
|
-
} else {
|
|
8725
|
-
commandService.syncExecuteCommand(import_univer_pdfs7.ReplacePdfSnapshotCommand.id, {
|
|
8726
|
-
unitId: unit.getUnitId(),
|
|
8727
|
-
snapshot: staged.snapshot
|
|
8728
|
-
});
|
|
8931
|
+
const outcomeResult = applyStagedPdfImportToUnit(commandService, unit.getUnitId(), staged);
|
|
8932
|
+
if (!outcomeResult.applied) {
|
|
8933
|
+
setIoError(outcomeResult.error ?? null);
|
|
8934
|
+
setStatusTip("");
|
|
8935
|
+
return;
|
|
8729
8936
|
}
|
|
8730
8937
|
setPendingImport(null);
|
|
8731
8938
|
setIoError(null);
|
|
@@ -8750,6 +8957,10 @@ var PdfPreviewModal = () => {
|
|
|
8750
8957
|
);
|
|
8751
8958
|
};
|
|
8752
8959
|
const handleCancelStagedImport = () => {
|
|
8960
|
+
importReqSeqRef.current += 1;
|
|
8961
|
+
importAbortRef.current?.abort();
|
|
8962
|
+
importAbortRef.current = null;
|
|
8963
|
+
setImporting(false);
|
|
8753
8964
|
setPendingImport(null);
|
|
8754
8965
|
setIoError(null);
|
|
8755
8966
|
setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u5185\u5BB9\u672A\u53D8\u66F4");
|
|
@@ -8758,7 +8969,7 @@ var PdfPreviewModal = () => {
|
|
|
8758
8969
|
setIoTarget(nextTarget);
|
|
8759
8970
|
setIoError(null);
|
|
8760
8971
|
setPdfBytesState(null);
|
|
8761
|
-
if (modalTab === "preview") {
|
|
8972
|
+
if (modalTab === "preview" || modalTab === "export") {
|
|
8762
8973
|
void generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
|
|
8763
8974
|
} else if (modalTab === "import") {
|
|
8764
8975
|
const caps = ioService.getIoCapabilities();
|
|
@@ -8781,8 +8992,19 @@ var PdfPreviewModal = () => {
|
|
|
8781
8992
|
await generatePreview(sampleJsonText, watermarkText, excludeBasePdf, nextTarget);
|
|
8782
8993
|
}
|
|
8783
8994
|
};
|
|
8995
|
+
(0, import_react5.useEffect)(() => {
|
|
8996
|
+
return () => {
|
|
8997
|
+
importReqSeqRef.current += 1;
|
|
8998
|
+
importAbortRef.current?.abort();
|
|
8999
|
+
importAbortRef.current = null;
|
|
9000
|
+
};
|
|
9001
|
+
}, []);
|
|
8784
9002
|
(0, import_react5.useEffect)(() => {
|
|
8785
9003
|
if (!open) {
|
|
9004
|
+
importReqSeqRef.current += 1;
|
|
9005
|
+
importAbortRef.current?.abort();
|
|
9006
|
+
importAbortRef.current = null;
|
|
9007
|
+
setImporting(false);
|
|
8786
9008
|
setPendingImport(null);
|
|
8787
9009
|
setSelectedImportFile(null);
|
|
8788
9010
|
setIoError(null);
|
|
@@ -8796,7 +9018,8 @@ var PdfPreviewModal = () => {
|
|
|
8796
9018
|
const initialPdfA = Boolean(snap.pdfACompliant ?? snap.metadata?.pdfACompliant);
|
|
8797
9019
|
const initialPdfUa = Boolean(snap.accessibilityTagged ?? snap.metadata?.accessibilityTagged);
|
|
8798
9020
|
const caps = ioService.getIoCapabilities();
|
|
8799
|
-
const
|
|
9021
|
+
const activeTab = clampPdfModalTab(featureService.getModalTab(), ioModal);
|
|
9022
|
+
const initialTarget = resolveInitialModalIoTarget(caps, activeTab);
|
|
8800
9023
|
setSampleJsonText(initialSampleText);
|
|
8801
9024
|
setWatermarkText(initialWm);
|
|
8802
9025
|
setExcludeBasePdf(initialStripBg);
|
|
@@ -8805,8 +9028,7 @@ var PdfPreviewModal = () => {
|
|
|
8805
9028
|
setIoTarget(initialTarget);
|
|
8806
9029
|
setIoError(null);
|
|
8807
9030
|
setStatusTip("");
|
|
8808
|
-
|
|
8809
|
-
if (activeTab === "preview") {
|
|
9031
|
+
if (activeTab === "preview" || activeTab === "export") {
|
|
8810
9032
|
void generatePreview(initialSampleText, initialWm, initialStripBg, initialTarget, {
|
|
8811
9033
|
pdfACompliant: initialPdfA,
|
|
8812
9034
|
accessibilityTagged: initialPdfUa
|
|
@@ -9028,7 +9250,14 @@ var PdfPreviewModal = () => {
|
|
|
9028
9250
|
setStatusTip("\u672A\u8BC6\u522B\u7684 JSON \u683C\u5F0F\uFF1A\u8BF7\u63D0\u4F9B Univer IPdfUnitData \u6216 pdfme Template JSON");
|
|
9029
9251
|
return;
|
|
9030
9252
|
}
|
|
9031
|
-
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
|
+
}
|
|
9032
9261
|
setStatusTip("\u5DF2\u6210\u529F\u5E94\u7528\u6A21\u677F JSON\uFF08\u652F\u6301 Ctrl+Z \u64A4\u9500\uFF09\uFF01");
|
|
9033
9262
|
} catch (err) {
|
|
9034
9263
|
setStatusTip(`JSON \u89E3\u6790\u9519\u8BEF: ${err?.message || String(err)}`);
|
|
@@ -9038,9 +9267,24 @@ var PdfPreviewModal = () => {
|
|
|
9038
9267
|
const ioCaps = ioService.getIoCapabilities();
|
|
9039
9268
|
const pdfCapReport = (0, import_univer_pdfs7.inspectPdfExportCapabilities)(unit.save());
|
|
9040
9269
|
const snapSizeKb = (pdfCapReport.snapshotByteSize / 1024).toFixed(1);
|
|
9041
|
-
const
|
|
9042
|
-
const
|
|
9043
|
-
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
|
+
};
|
|
9044
9288
|
const unifiedIoSection = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9045
9289
|
PdfUnifiedIoSection,
|
|
9046
9290
|
{
|
|
@@ -9049,6 +9293,7 @@ var PdfPreviewModal = () => {
|
|
|
9049
9293
|
serverAvailable,
|
|
9050
9294
|
snapSizeKb,
|
|
9051
9295
|
editorEnabled,
|
|
9296
|
+
showImportSection: showImportControls,
|
|
9052
9297
|
importing,
|
|
9053
9298
|
rendering,
|
|
9054
9299
|
selectedFileName: selectedImportFile?.name,
|
|
@@ -9073,11 +9318,12 @@ var PdfPreviewModal = () => {
|
|
|
9073
9318
|
onClick: (e) => e.stopPropagation(),
|
|
9074
9319
|
children: [
|
|
9075
9320
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-modal-header", children: [
|
|
9076
|
-
/* @__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: [
|
|
9077
9322
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9078
9323
|
"button",
|
|
9079
9324
|
{
|
|
9080
9325
|
type: "button",
|
|
9326
|
+
"data-testid": "yudao-io-tab-preview",
|
|
9081
9327
|
className: `univer-pdf-modal-tab ${isUnifiedIoTab ? "is-active" : ""}`,
|
|
9082
9328
|
style: { display: "inline-flex", alignItems: "center", gap: 5 },
|
|
9083
9329
|
onClick: () => featureService.setModalTab("preview"),
|
|
@@ -9087,20 +9333,36 @@ var PdfPreviewModal = () => {
|
|
|
9087
9333
|
]
|
|
9088
9334
|
}
|
|
9089
9335
|
),
|
|
9090
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9336
|
+
ioModal.tabs.includes("json") && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9091
9337
|
"button",
|
|
9092
9338
|
{
|
|
9093
9339
|
type: "button",
|
|
9094
|
-
|
|
9340
|
+
"data-testid": "yudao-io-tab-json",
|
|
9341
|
+
className: `univer-pdf-modal-tab ${effectiveModalTab === "json" ? "is-active" : ""}`,
|
|
9095
9342
|
onClick: () => featureService.setModalTab("json"),
|
|
9096
9343
|
children: `{ } JSON \u5951\u7EA6 (IPdfUnitData / pdfme \u4E92\u8F6C)`
|
|
9097
9344
|
}
|
|
9098
9345
|
)
|
|
9099
|
-
] }),
|
|
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
|
+
)) }),
|
|
9100
9361
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
|
|
9101
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9362
|
+
ioModal.showPipelineBadge && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9102
9363
|
"span",
|
|
9103
9364
|
{
|
|
9365
|
+
"data-testid": "yudao-io-pipeline-badge",
|
|
9104
9366
|
style: {
|
|
9105
9367
|
fontSize: 11,
|
|
9106
9368
|
padding: "3px 8px",
|
|
@@ -9464,7 +9726,7 @@ var PdfPreviewModal = () => {
|
|
|
9464
9726
|
}
|
|
9465
9727
|
)
|
|
9466
9728
|
] }),
|
|
9467
|
-
splitMergeQuickBox,
|
|
9729
|
+
showExportControls && splitMergeQuickBox,
|
|
9468
9730
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "univer-pdf-btn-row", children: [
|
|
9469
9731
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9470
9732
|
"button",
|
|
@@ -9476,41 +9738,43 @@ var PdfPreviewModal = () => {
|
|
|
9476
9738
|
children: rendering ? "\u6E32\u67D3\u4E2D..." : "\u91CD\u65B0\u751F\u6210 PDF"
|
|
9477
9739
|
}
|
|
9478
9740
|
),
|
|
9479
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
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
|
+
] }),
|
|
9514
9778
|
features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9515
9779
|
"button",
|
|
9516
9780
|
{
|
|
@@ -9558,109 +9822,118 @@ var PdfPreviewModal = () => {
|
|
|
9558
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" }),
|
|
9559
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" }),
|
|
9560
9824
|
unifiedIoSection,
|
|
9561
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9562
|
-
|
|
9563
|
-
|
|
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(),
|
|
9570
|
-
children: [
|
|
9571
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(UiDownloadIcon, {}),
|
|
9572
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "\u4E0B\u8F7D\u6807\u51C6 PDF \u6587\u4EF6" })
|
|
9573
|
-
]
|
|
9574
|
-
}
|
|
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",
|
|
9825
|
+
showExportControls && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
9826
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9827
|
+
"button",
|
|
9593
9828
|
{
|
|
9594
|
-
type: "
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
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
|
+
]
|
|
9601
9839
|
}
|
|
9602
9840
|
),
|
|
9603
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
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: [
|
|
9609
9856
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9610
9857
|
"input",
|
|
9611
9858
|
{
|
|
9612
|
-
type: "
|
|
9613
|
-
|
|
9614
|
-
title: "\u6C34\u5E73\u504F\u79FB X (mm)",
|
|
9615
|
-
value: printerOffsetXMm,
|
|
9859
|
+
type: "checkbox",
|
|
9860
|
+
checked: enableAuditSeal,
|
|
9616
9861
|
onChange: (e) => {
|
|
9617
|
-
const
|
|
9618
|
-
|
|
9619
|
-
void generatePreview(
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
borderRadius: 4,
|
|
9628
|
-
padding: "2px 4px",
|
|
9629
|
-
fontSize: 11,
|
|
9630
|
-
color: "#1B1C1F",
|
|
9631
|
-
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
|
+
);
|
|
9632
9872
|
}
|
|
9633
9873
|
}
|
|
9634
9874
|
),
|
|
9635
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
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
|
+
}
|
|
9658
9905
|
}
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
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
|
|
9662
9936
|
] }),
|
|
9663
|
-
splitMergeQuickBox,
|
|
9664
9937
|
features.print && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
9665
9938
|
"button",
|
|
9666
9939
|
{
|
|
@@ -9811,13 +10084,17 @@ function createBtn(config) {
|
|
|
9811
10084
|
tooltip: config.tooltip ?? config.title,
|
|
9812
10085
|
icon: config.icon,
|
|
9813
10086
|
params: config.params,
|
|
9814
|
-
hidden$: needsHiddenObs ? (0, import_rxjs6.combineLatest)([
|
|
9815
|
-
|
|
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]) => {
|
|
9816
10093
|
if (requiresEditor && !editorEnabled) return true;
|
|
9817
10094
|
if (config.elementTypeGate && !isPdfElementTypeAllowed(config.elementTypeGate, f)) {
|
|
9818
10095
|
return true;
|
|
9819
10096
|
}
|
|
9820
|
-
return config.hiddenWhen ? config.hiddenWhen(f, editorEnabled) : false;
|
|
10097
|
+
return config.hiddenWhen ? config.hiddenWhen(f, editorEnabled, ioModal) : false;
|
|
9821
10098
|
})
|
|
9822
10099
|
) : void 0
|
|
9823
10100
|
};
|
|
@@ -10093,7 +10370,7 @@ var UploadBasePdfMenuFactory = createBtn({
|
|
|
10093
10370
|
label: "pdfs.ribbon.importPdf",
|
|
10094
10371
|
icon: "PdfUploadIcon",
|
|
10095
10372
|
requiresEditor: true,
|
|
10096
|
-
hiddenWhen: (f) => !f.basePdfOverlay
|
|
10373
|
+
hiddenWhen: (f, _editor, ioModal) => !f.basePdfOverlay || !ioModal.tabs.includes("import")
|
|
10097
10374
|
});
|
|
10098
10375
|
var OpenJsonExchangeMenuFactory = createBtn({
|
|
10099
10376
|
id: "pdfs-ui.menu.open-json",
|
|
@@ -10102,7 +10379,8 @@ var OpenJsonExchangeMenuFactory = createBtn({
|
|
|
10102
10379
|
label: "pdfs.ribbon.jsonExchange",
|
|
10103
10380
|
icon: "PdfJsonIcon",
|
|
10104
10381
|
params: { tab: "json" },
|
|
10105
|
-
requiresEditor: true
|
|
10382
|
+
requiresEditor: true,
|
|
10383
|
+
hiddenWhen: (_f, _editor, ioModal) => !ioModal.tabs.includes("json")
|
|
10106
10384
|
});
|
|
10107
10385
|
var ToggleInspectorMenuFactory = createBtn({
|
|
10108
10386
|
id: TogglePdfInspectorOperation.id,
|
|
@@ -10115,8 +10393,7 @@ var OpenPdfPreviewMenuFactory = createBtn({
|
|
|
10115
10393
|
id: OpenPdfPreviewOperation.id,
|
|
10116
10394
|
title: "pdfs.ribbon.previewPdf",
|
|
10117
10395
|
label: "pdfs.ribbon.previewPdf",
|
|
10118
|
-
icon: "PdfPreviewIcon"
|
|
10119
|
-
params: { tab: "preview" }
|
|
10396
|
+
icon: "PdfPreviewIcon"
|
|
10120
10397
|
});
|
|
10121
10398
|
var PrintPdfMenuFactory = createBtn({
|
|
10122
10399
|
id: PrintPdfOperation.id,
|
|
@@ -10575,7 +10852,7 @@ var UniverPdfsUIPlugin = class extends import_core9.Plugin {
|
|
|
10575
10852
|
this._injector.add([
|
|
10576
10853
|
IPdfsUIFeatureService,
|
|
10577
10854
|
{
|
|
10578
|
-
useFactory: () => new PdfsUIFeatureService(this._config.features, editorEnabled)
|
|
10855
|
+
useFactory: () => new PdfsUIFeatureService(this._config.features, editorEnabled, this._config.ioModal)
|
|
10579
10856
|
}
|
|
10580
10857
|
]);
|
|
10581
10858
|
this._injector.add([
|
|
@@ -10596,6 +10873,7 @@ UniverPdfsUIPlugin = __decorateClass([
|
|
|
10596
10873
|
], UniverPdfsUIPlugin);
|
|
10597
10874
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10598
10875
|
0 && (module.exports = {
|
|
10876
|
+
ALL_PDF_IO_MODAL_TABS,
|
|
10599
10877
|
AdjustPdfZoomOperation,
|
|
10600
10878
|
IPdfsUIFeatureService,
|
|
10601
10879
|
InsertPdfPresetElementOperation,
|
|
@@ -10629,9 +10907,12 @@ UniverPdfsUIPlugin = __decorateClass([
|
|
|
10629
10907
|
UniverPdfsUIPlugin,
|
|
10630
10908
|
UpdatePdfUIFeaturesOperation,
|
|
10631
10909
|
UploadBasePdfOperation,
|
|
10910
|
+
applyStagedPdfImportToUnit,
|
|
10911
|
+
clampPdfModalTab,
|
|
10632
10912
|
clearPdfDocumentCache,
|
|
10633
10913
|
computePdfDocumentCacheKey,
|
|
10634
10914
|
configurePdfjsAssets,
|
|
10915
|
+
executeGuardedStagedImport,
|
|
10635
10916
|
getPdfjsAssetsConfig,
|
|
10636
10917
|
inspectSourcePdfPages,
|
|
10637
10918
|
isPdfElementTypeAllowed,
|
|
@@ -10640,6 +10921,7 @@ UniverPdfsUIPlugin = __decorateClass([
|
|
|
10640
10921
|
readBrowserFileAsOverlayOutcome,
|
|
10641
10922
|
renderSourcePdfPageToCanvas,
|
|
10642
10923
|
resolveInitialModalIoTarget,
|
|
10924
|
+
resolvePdfIoModalConfig,
|
|
10643
10925
|
resolvePdfsUIFeatures
|
|
10644
10926
|
});
|
|
10645
10927
|
//# sourceMappingURL=index.js.map
|