@yudaocode/univer-pdfs-ui 1.6.218 → 1.6.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  zh_CN_default
3
- } from "./chunk-BGVYO6EP.js";
3
+ } from "./chunk-FVF66I7J.js";
4
4
  import {
5
5
  en_US_default
6
- } from "./chunk-TLZPB72N.js";
6
+ } from "./chunk-QLNL6XVB.js";
7
7
  import {
8
8
  __decorateClass,
9
9
  __decorateParam
10
10
  } from "./chunk-BRKEJJFQ.js";
11
11
 
12
12
  // src/controllers/pdfs-ui.controller.ts
13
- import { Disposable as Disposable2, ICommandService as ICommandService8, Inject, toDisposable } from "@univerjs/core";
13
+ import { Disposable as Disposable2, ICommandService as ICommandService9, Inject, toDisposable } from "@univerjs/core";
14
14
  import {
15
15
  BuiltInUIPart,
16
16
  ComponentManager,
@@ -197,6 +197,19 @@ var PdfFindReplaceIcon = createSvgIcon(
197
197
  /* @__PURE__ */ jsx("path", { d: "M10.2 10.2L13.8 13.8", strokeWidth: "1.45", strokeLinecap: "round" })
198
198
  ] })
199
199
  );
200
+ var PdfSplitExtractIcon = createSvgIcon(
201
+ /* @__PURE__ */ jsxs(Fragment, { children: [
202
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "2.6", width: "4.8", height: "10.8", rx: "0.9", strokeWidth: "1.35" }),
203
+ /* @__PURE__ */ jsx("rect", { x: "9.2", y: "2.6", width: "4.8", height: "10.8", rx: "0.9", strokeWidth: "1.35" }),
204
+ /* @__PURE__ */ jsx("path", { d: "M6.8 8H9.2", strokeWidth: "1.35", strokeLinecap: "round" })
205
+ ] })
206
+ );
207
+ var PdfCropPageIcon = createSvgIcon(
208
+ /* @__PURE__ */ jsxs(Fragment, { children: [
209
+ /* @__PURE__ */ jsx("path", { d: "M4.5 2V11.5H14", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
210
+ /* @__PURE__ */ jsx("path", { d: "M2 4.5H11.5V14", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" })
211
+ ] })
212
+ );
200
213
  function createInlineIcon(children, size = 14) {
201
214
  return ({ style }) => /* @__PURE__ */ jsx(
202
215
  "svg",
@@ -453,6 +466,27 @@ var UiShieldLockIcon = createInlineIcon(
453
466
  ] }),
454
467
  14
455
468
  );
469
+ var UiStampSealIcon = createInlineIcon(
470
+ /* @__PURE__ */ jsxs(Fragment, { children: [
471
+ /* @__PURE__ */ jsx("rect", { x: "2.2", y: "3.4", width: "11.6", height: "9.2", rx: "2" }),
472
+ /* @__PURE__ */ jsx("path", { d: "M5.2 8.2L7 10L10.8 6.2" })
473
+ ] }),
474
+ 14
475
+ );
476
+ var UiMessageReplyIcon = createInlineIcon(
477
+ /* @__PURE__ */ jsxs(Fragment, { children: [
478
+ /* @__PURE__ */ jsx("path", { d: "M2.5 3.2H13.5V10.8H6.5L3.2 13.5V10.8H2.5V3.2Z" }),
479
+ /* @__PURE__ */ jsx("path", { d: "M5.2 6.2H10.8M5.2 8.4H8.8" })
480
+ ] }),
481
+ 14
482
+ );
483
+ var UiPptxSlideIcon = createInlineIcon(
484
+ /* @__PURE__ */ jsxs(Fragment, { children: [
485
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "2.8", width: "12", height: "8.6", rx: "1.2" }),
486
+ /* @__PURE__ */ jsx("path", { d: "M8 11.4V13.8M5.2 13.8H10.8M5.2 5.8H8.2M5.2 8.2H10.8" })
487
+ ] }),
488
+ 14
489
+ );
456
490
  var PDF_ICON_MAP = {
457
491
  PdfSelectCursorIcon,
458
492
  PdfHandPanIcon,
@@ -485,7 +519,9 @@ var PDF_ICON_MAP = {
485
519
  PdfRulerIcon,
486
520
  PdfGridIcon,
487
521
  PdfMarginIcon,
488
- PdfFindReplaceIcon
522
+ PdfFindReplaceIcon,
523
+ PdfSplitExtractIcon,
524
+ PdfCropPageIcon
489
525
  };
490
526
 
491
527
  // src/operations/pdf-ui.operation.ts
@@ -702,6 +738,18 @@ var TogglePdfInspectorOperation = {
702
738
  return true;
703
739
  }
704
740
  };
741
+ var OpenPdfSplitModalOperation = {
742
+ id: "pdfs-ui.operation.open-split-modal",
743
+ type: CommandType.OPERATION,
744
+ handler: (accessor, params) => {
745
+ const selectionService = accessor.get(IPdfSelectionService);
746
+ selectionService.commitActiveEditing();
747
+ selectionService.setEditingElement(null);
748
+ const nextOpen = typeof params?.open === "boolean" ? params.open : true;
749
+ selectionService.setSplitModalOpen(nextOpen);
750
+ return true;
751
+ }
752
+ };
705
753
  var OpenPdfPreviewOperation = {
706
754
  id: "pdfs-ui.operation.open-preview",
707
755
  type: CommandType.OPERATION,
@@ -869,7 +917,10 @@ var SetPdfInteractionModeOperation = {
869
917
  const featureService = accessor.get(IPdfsUIFeatureService);
870
918
  const sel = accessor.get(IPdfSelectionService);
871
919
  const targetMode = params?.mode ?? "select";
872
- if (!featureService.isEditorEnabled() && targetMode === "ink") {
920
+ if (!featureService.isEditorEnabled() && (targetMode === "ink" || targetMode === "crop")) {
921
+ return false;
922
+ }
923
+ if (targetMode === "crop" && !featureService.getFeatures().cropBox) {
873
924
  return false;
874
925
  }
875
926
  sel.setInteractionMode(
@@ -1097,7 +1148,9 @@ import {
1097
1148
  renderBarcodeDataUrl,
1098
1149
  renderQrCodeDataUrl,
1099
1150
  resolveMultiVariableText,
1151
+ resolvePdfCropBoxPt,
1100
1152
  resolvePolygonNormalizedPoints,
1153
+ SetPdfPageCropBoxCommand,
1101
1154
  smoothSignatureStrokeQuadratic,
1102
1155
  toggleCircleMarkState,
1103
1156
  toHtmlDateTimeInputValue,
@@ -1933,6 +1986,112 @@ var PdfCanvasView = () => {
1933
1986
  const [liveInkPoints, setLiveInkPoints] = useState2(null);
1934
1987
  const [isPanning, setIsPanning] = useState2(false);
1935
1988
  const [signaturePadElementId, setSignaturePadElementId] = useState2(null);
1989
+ const [cropDraft, setCropDraft] = useState2(null);
1990
+ const resolvedActiveCrop = useMemo2(
1991
+ () => resolvePdfCropBoxPt(activePage?.cropBox),
1992
+ [activePage?.cropBox]
1993
+ );
1994
+ const defaultCropRect = useMemo2(
1995
+ () => ({
1996
+ left: Math.round(pageSize.width * 0.06),
1997
+ top: Math.round(pageSize.height * 0.06),
1998
+ width: Math.max(24, Math.round(pageSize.width * 0.88)),
1999
+ height: Math.max(24, Math.round(pageSize.height * 0.88))
2000
+ }),
2001
+ [pageSize.width, pageSize.height]
2002
+ );
2003
+ useEffect2(() => {
2004
+ setCropDraft(null);
2005
+ }, [activePageId, interactionMode]);
2006
+ const effectiveCropRect = cropDraft ?? resolvedActiveCrop ?? defaultCropRect;
2007
+ const commitActiveCropBox = useCallback2(() => {
2008
+ if (!activePageId) return;
2009
+ commandService.syncExecuteCommand(SetPdfPageCropBoxCommand.id, {
2010
+ pageId: activePageId,
2011
+ cropBox: {
2012
+ left: effectiveCropRect.left,
2013
+ top: effectiveCropRect.top,
2014
+ width: effectiveCropRect.width,
2015
+ height: effectiveCropRect.height,
2016
+ leftPt: effectiveCropRect.left,
2017
+ topPt: effectiveCropRect.top,
2018
+ widthPt: effectiveCropRect.width,
2019
+ heightPt: effectiveCropRect.height
2020
+ }
2021
+ });
2022
+ setCropDraft(null);
2023
+ void commandService.executeCommand(SetPdfInteractionModeOperation.id, { mode: "select" });
2024
+ }, [activePageId, commandService, effectiveCropRect]);
2025
+ const resetActiveCropBox = useCallback2(() => {
2026
+ if (!activePageId) return;
2027
+ commandService.syncExecuteCommand(SetPdfPageCropBoxCommand.id, {
2028
+ pageId: activePageId,
2029
+ cropBox: void 0
2030
+ });
2031
+ setCropDraft(null);
2032
+ void commandService.executeCommand(SetPdfInteractionModeOperation.id, { mode: "select" });
2033
+ }, [activePageId, commandService]);
2034
+ const startPanCropRect = (e) => {
2035
+ e.stopPropagation();
2036
+ e.preventDefault();
2037
+ const orig = { ...effectiveCropRect };
2038
+ const startX = e.clientX;
2039
+ const startY = e.clientY;
2040
+ const onMove = (ev) => {
2041
+ const dx = (ev.clientX - startX) / zoom;
2042
+ const dy = (ev.clientY - startY) / zoom;
2043
+ const nextLeft = Math.round(Math.max(0, Math.min(pageSize.width - orig.width, orig.left + dx)) * 100) / 100;
2044
+ const nextTop = Math.round(Math.max(0, Math.min(pageSize.height - orig.height, orig.top + dy)) * 100) / 100;
2045
+ setCropDraft({ ...orig, left: nextLeft, top: nextTop });
2046
+ };
2047
+ const onUp = () => {
2048
+ window.removeEventListener("pointermove", onMove);
2049
+ window.removeEventListener("pointerup", onUp);
2050
+ };
2051
+ window.addEventListener("pointermove", onMove);
2052
+ window.addEventListener("pointerup", onUp);
2053
+ };
2054
+ const startResizeCropRect = (e, dir) => {
2055
+ e.stopPropagation();
2056
+ e.preventDefault();
2057
+ const orig = { ...effectiveCropRect };
2058
+ const startX = e.clientX;
2059
+ const startY = e.clientY;
2060
+ const minDim = 24;
2061
+ const onMove = (ev) => {
2062
+ const dx = (ev.clientX - startX) / zoom;
2063
+ const dy = (ev.clientY - startY) / zoom;
2064
+ let { left, top, width, height } = orig;
2065
+ if (dir.includes("e")) {
2066
+ width = Math.max(minDim, Math.min(pageSize.width - orig.left, orig.width + dx));
2067
+ }
2068
+ if (dir.includes("s")) {
2069
+ height = Math.max(minDim, Math.min(pageSize.height - orig.top, orig.height + dy));
2070
+ }
2071
+ if (dir.includes("w")) {
2072
+ const clampedLeft = Math.max(0, Math.min(orig.left + orig.width - minDim, orig.left + dx));
2073
+ width = orig.left + orig.width - clampedLeft;
2074
+ left = clampedLeft;
2075
+ }
2076
+ if (dir.includes("n")) {
2077
+ const clampedTop = Math.max(0, Math.min(orig.top + orig.height - minDim, orig.top + dy));
2078
+ height = orig.top + orig.height - clampedTop;
2079
+ top = clampedTop;
2080
+ }
2081
+ setCropDraft({
2082
+ left: Math.round(left * 100) / 100,
2083
+ top: Math.round(top * 100) / 100,
2084
+ width: Math.round(width * 100) / 100,
2085
+ height: Math.round(height * 100) / 100
2086
+ });
2087
+ };
2088
+ const onUp = () => {
2089
+ window.removeEventListener("pointermove", onMove);
2090
+ window.removeEventListener("pointerup", onUp);
2091
+ };
2092
+ window.addEventListener("pointermove", onMove);
2093
+ window.addEventListener("pointerup", onUp);
2094
+ };
1936
2095
  const triggerDirectImageUpload = useCallback2(
1937
2096
  (elementId) => {
1938
2097
  if (typeof document === "undefined") return;
@@ -2247,7 +2406,7 @@ var PdfCanvasView = () => {
2247
2406
  }
2248
2407
  };
2249
2408
  const startMoveElements = (e, clickedEl) => {
2250
- if (interactionMode === "pan" || interactionMode === "ink") return;
2409
+ if (interactionMode === "pan" || interactionMode === "ink" || interactionMode === "crop") return;
2251
2410
  if (interactionMode === "form") {
2252
2411
  e.stopPropagation();
2253
2412
  if (isLockedByLayer(clickedEl)) return;
@@ -2558,6 +2717,28 @@ var PdfCanvasView = () => {
2558
2717
  }
2559
2718
  )
2560
2719
  ] }),
2720
+ interactionMode === "crop" && editorEnabled && features.cropBox && /* @__PURE__ */ jsxs3(
2721
+ "div",
2722
+ {
2723
+ className: "univer-pdf-floating-mode-bar",
2724
+ "data-testid": "pdf-crop-mode-banner",
2725
+ onPointerDown: (e) => e.stopPropagation(),
2726
+ children: [
2727
+ /* @__PURE__ */ jsx3(UiCropIcon, {}),
2728
+ /* @__PURE__ */ jsx3("span", { children: "\u9875\u9762\u88C1\u5207\u6A21\u5F0F\uFF1A\u62D6\u52A8\u56DB\u89D2\u6216\u56DB\u8FB9\u63A7\u5236\u70B9\u8C03\u6574\u88C1\u5207\u533A\u57DF" }),
2729
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: commitActiveCropBox, children: "\u5E94\u7528\u88C1\u5207" }),
2730
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: resetActiveCropBox, children: "\u91CD\u7F6E\u88C1\u5207" }),
2731
+ /* @__PURE__ */ jsx3(
2732
+ "button",
2733
+ {
2734
+ type: "button",
2735
+ onClick: () => void commandService.executeCommand(SetPdfInteractionModeOperation.id, { mode: "select" }),
2736
+ children: "\u53D6\u6D88 (Esc)"
2737
+ }
2738
+ )
2739
+ ]
2740
+ }
2741
+ ),
2561
2742
  /* @__PURE__ */ jsx3("div", { ref: scrollRef, className: "univer-pdf-stage-scroll", onScroll: syncViewportRatio, children: /* @__PURE__ */ jsx3(
2562
2743
  "div",
2563
2744
  {
@@ -2643,15 +2824,16 @@ var PdfCanvasView = () => {
2643
2824
  }
2644
2825
  ),
2645
2826
  showCalibrationGrid && /* @__PURE__ */ jsx3(CalibrationGridOverlay, { widthPt: pageSize.width, heightPt: pageSize.height, zoom }),
2646
- activePage?.cropBox && /* @__PURE__ */ jsx3(
2827
+ interactionMode !== "crop" && resolvedActiveCrop && /* @__PURE__ */ jsx3(
2647
2828
  "div",
2648
2829
  {
2830
+ "data-testid": "pdf-passive-crop-guide",
2649
2831
  style: {
2650
2832
  position: "absolute",
2651
- left: activePage.cropBox.left * zoom,
2652
- top: activePage.cropBox.top * zoom,
2653
- width: activePage.cropBox.width * zoom,
2654
- height: activePage.cropBox.height * zoom,
2833
+ left: resolvedActiveCrop.left * zoom,
2834
+ top: resolvedActiveCrop.top * zoom,
2835
+ width: resolvedActiveCrop.width * zoom,
2836
+ height: resolvedActiveCrop.height * zoom,
2655
2837
  border: "1.5px dashed #2C53F1",
2656
2838
  boxShadow: "0 0 0 9999px rgba(27, 28, 31, 0.08)",
2657
2839
  pointerEvents: "none",
@@ -2659,6 +2841,160 @@ var PdfCanvasView = () => {
2659
2841
  }
2660
2842
  }
2661
2843
  ),
2844
+ interactionMode === "crop" && editorEnabled && features.cropBox && /* @__PURE__ */ jsxs3(
2845
+ "div",
2846
+ {
2847
+ "data-testid": "pdf-canvas-crop-overlay",
2848
+ onPointerDown: (e) => e.stopPropagation(),
2849
+ style: {
2850
+ position: "absolute",
2851
+ inset: 0,
2852
+ zIndex: 60
2853
+ },
2854
+ children: [
2855
+ /* @__PURE__ */ jsx3(
2856
+ "div",
2857
+ {
2858
+ style: {
2859
+ position: "absolute",
2860
+ left: 0,
2861
+ top: 0,
2862
+ width: pageWidthPx,
2863
+ height: effectiveCropRect.top * zoom,
2864
+ background: "rgba(27, 28, 31, 0.38)",
2865
+ pointerEvents: "none"
2866
+ }
2867
+ }
2868
+ ),
2869
+ /* @__PURE__ */ jsx3(
2870
+ "div",
2871
+ {
2872
+ style: {
2873
+ position: "absolute",
2874
+ left: 0,
2875
+ top: (effectiveCropRect.top + effectiveCropRect.height) * zoom,
2876
+ width: pageWidthPx,
2877
+ height: Math.max(0, pageHeightPx - (effectiveCropRect.top + effectiveCropRect.height) * zoom),
2878
+ background: "rgba(27, 28, 31, 0.38)",
2879
+ pointerEvents: "none"
2880
+ }
2881
+ }
2882
+ ),
2883
+ /* @__PURE__ */ jsx3(
2884
+ "div",
2885
+ {
2886
+ style: {
2887
+ position: "absolute",
2888
+ left: 0,
2889
+ top: effectiveCropRect.top * zoom,
2890
+ width: effectiveCropRect.left * zoom,
2891
+ height: effectiveCropRect.height * zoom,
2892
+ background: "rgba(27, 28, 31, 0.38)",
2893
+ pointerEvents: "none"
2894
+ }
2895
+ }
2896
+ ),
2897
+ /* @__PURE__ */ jsx3(
2898
+ "div",
2899
+ {
2900
+ style: {
2901
+ position: "absolute",
2902
+ left: (effectiveCropRect.left + effectiveCropRect.width) * zoom,
2903
+ top: effectiveCropRect.top * zoom,
2904
+ width: Math.max(0, pageWidthPx - (effectiveCropRect.left + effectiveCropRect.width) * zoom),
2905
+ height: effectiveCropRect.height * zoom,
2906
+ background: "rgba(27, 28, 31, 0.38)",
2907
+ pointerEvents: "none"
2908
+ }
2909
+ }
2910
+ ),
2911
+ /* @__PURE__ */ jsxs3(
2912
+ "div",
2913
+ {
2914
+ "data-testid": "pdf-crop-box-rect",
2915
+ onPointerDown: startPanCropRect,
2916
+ style: {
2917
+ position: "absolute",
2918
+ left: effectiveCropRect.left * zoom,
2919
+ top: effectiveCropRect.top * zoom,
2920
+ width: effectiveCropRect.width * zoom,
2921
+ height: effectiveCropRect.height * zoom,
2922
+ border: "2px dashed #2C53F1",
2923
+ boxSizing: "border-box",
2924
+ cursor: "move"
2925
+ },
2926
+ children: [
2927
+ HANDLE_LIST.map((h) => /* @__PURE__ */ jsx3(
2928
+ "div",
2929
+ {
2930
+ "data-testid": `pdf-crop-handle-${h.dir}`,
2931
+ className: "univer-pdf-resize-handle",
2932
+ style: {
2933
+ ...h.style,
2934
+ width: 9,
2935
+ height: 9,
2936
+ background: "#2C53F1",
2937
+ border: "1.5px solid #FFFFFF",
2938
+ borderRadius: 2,
2939
+ cursor: h.cursor
2940
+ },
2941
+ onPointerDown: (ev) => startResizeCropRect(ev, h.dir)
2942
+ },
2943
+ `crop-${h.dir}`
2944
+ )),
2945
+ /* @__PURE__ */ jsxs3(
2946
+ "div",
2947
+ {
2948
+ "data-testid": "pdf-crop-action-pill",
2949
+ onPointerDown: (ev) => ev.stopPropagation(),
2950
+ style: {
2951
+ position: "absolute",
2952
+ bottom: -36,
2953
+ right: 0,
2954
+ display: "inline-flex",
2955
+ alignItems: "center",
2956
+ gap: 6,
2957
+ padding: "4px 8px",
2958
+ background: "#FFFFFF",
2959
+ border: "1px solid #D2DAFA",
2960
+ borderRadius: 999,
2961
+ boxShadow: "0 4px 14px rgba(27, 28, 31, 0.16)",
2962
+ whiteSpace: "nowrap",
2963
+ zIndex: 65
2964
+ },
2965
+ children: [
2966
+ /* @__PURE__ */ jsx3("span", { style: { fontSize: 10.5, color: "#4E5565", fontFamily: "monospace" }, children: displayUnit === "mm" ? `${ptToMm(effectiveCropRect.width)}\xD7${ptToMm(effectiveCropRect.height)} mm` : `${Math.round(effectiveCropRect.width)}\xD7${Math.round(effectiveCropRect.height)} pt` }),
2967
+ /* @__PURE__ */ jsx3(
2968
+ "button",
2969
+ {
2970
+ type: "button",
2971
+ "data-testid": "pdf-crop-apply-btn",
2972
+ className: "univer-pdf-mini-btn is-soft-primary",
2973
+ style: { padding: "2px 8px", fontSize: 11 },
2974
+ onClick: commitActiveCropBox,
2975
+ children: "\u5E94\u7528\u88C1\u5207"
2976
+ }
2977
+ ),
2978
+ /* @__PURE__ */ jsx3(
2979
+ "button",
2980
+ {
2981
+ type: "button",
2982
+ "data-testid": "pdf-crop-reset-btn",
2983
+ className: "univer-pdf-mini-btn is-danger",
2984
+ style: { padding: "2px 8px", fontSize: 11 },
2985
+ onClick: resetActiveCropBox,
2986
+ children: "\u91CD\u7F6E\u88C1\u5207"
2987
+ }
2988
+ )
2989
+ ]
2990
+ }
2991
+ )
2992
+ ]
2993
+ }
2994
+ )
2995
+ ]
2996
+ }
2997
+ ),
2662
2998
  elements.map((el) => {
2663
2999
  if (isHiddenByLayer(el)) return null;
2664
3000
  const elLocked = isLockedByLayer(el);
@@ -3358,8 +3694,24 @@ var ListElementView = ({ element, zoom, isEditing, onCommit }) => {
3358
3694
  );
3359
3695
  };
3360
3696
  var StampElementView = ({ element, zoom }) => {
3697
+ if (element.svgContent) {
3698
+ const dataUrl = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(element.svgContent)}`;
3699
+ return /* @__PURE__ */ jsx3(
3700
+ "img",
3701
+ {
3702
+ src: dataUrl,
3703
+ alt: element.name || element.primaryText || "Stamp",
3704
+ draggable: false,
3705
+ style: { width: "100%", height: "100%", objectFit: "contain" }
3706
+ }
3707
+ );
3708
+ }
3361
3709
  const color = element.color || "#dc2626";
3362
3710
  const isRect = element.stampShape === "rect";
3711
+ const isPill = element.stampShape === "pill";
3712
+ const outerRadius = isPill ? 999 : isRect ? 4 * zoom : "50%";
3713
+ const innerRadius = isPill ? 999 : isRect ? 2 * zoom : "50%";
3714
+ const metaLine = [element.signer, element.dateText].filter(Boolean).join(" \xB7 ");
3363
3715
  return /* @__PURE__ */ jsx3(
3364
3716
  "div",
3365
3717
  {
@@ -3368,7 +3720,7 @@ var StampElementView = ({ element, zoom }) => {
3368
3720
  height: "100%",
3369
3721
  boxSizing: "border-box",
3370
3722
  border: `${2.2 * zoom}px solid ${color}`,
3371
- borderRadius: isRect ? 4 * zoom : "50%",
3723
+ borderRadius: outerRadius,
3372
3724
  padding: 3 * zoom,
3373
3725
  display: "flex",
3374
3726
  alignItems: "center",
@@ -3382,7 +3734,7 @@ var StampElementView = ({ element, zoom }) => {
3382
3734
  width: "100%",
3383
3735
  height: "100%",
3384
3736
  border: `${0.9 * zoom}px solid ${color}`,
3385
- borderRadius: isRect ? 2 * zoom : "50%",
3737
+ borderRadius: innerRadius,
3386
3738
  display: "flex",
3387
3739
  flexDirection: "column",
3388
3740
  alignItems: "center",
@@ -3394,7 +3746,8 @@ var StampElementView = ({ element, zoom }) => {
3394
3746
  children: [
3395
3747
  /* @__PURE__ */ jsx3("div", { style: { fontSize: 10.5 * zoom, fontWeight: 700, letterSpacing: 0.5 }, children: element.primaryText }),
3396
3748
  /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 16 16", width: 12 * zoom, height: 12 * zoom, fill: color, style: { margin: "1px 0" }, children: /* @__PURE__ */ jsx3("polygon", { points: "8,1.5 9.9,5.8 14.5,6.2 11,9.3 12.1,13.8 8,11.4 3.9,13.8 5,9.3 1.5,6.2 6.1,5.8" }) }),
3397
- element.secondaryText && /* @__PURE__ */ jsx3("div", { style: { fontSize: 8 * zoom, fontWeight: 600 }, children: element.secondaryText })
3749
+ element.secondaryText && /* @__PURE__ */ jsx3("div", { style: { fontSize: 8 * zoom, fontWeight: 600 }, children: element.secondaryText }),
3750
+ metaLine && /* @__PURE__ */ jsx3("div", { style: { fontSize: 7.5 * zoom, marginTop: 1 }, children: metaLine })
3398
3751
  ]
3399
3752
  }
3400
3753
  )
@@ -4159,11 +4512,18 @@ var AnnotationElementView = ({ element, zoom, isSelected }) => {
4159
4512
  fontSize: 9.5,
4160
4513
  padding: "1px 5px",
4161
4514
  borderRadius: 999,
4162
- background: element.status === "resolved" || element.status === "accepted" ? "#F3F5FF" : "#EEEFF1",
4163
- color: element.status === "resolved" || element.status === "accepted" ? "#2C53F1" : "#4E5565",
4164
- border: `1px solid ${element.status === "resolved" || element.status === "accepted" ? "#D2DAFA" : "#E3E5EA"}`
4515
+ background: (element.reviewStatus ?? element.status) === "accepted" || (element.reviewStatus ?? element.status) === "completed" || element.status === "resolved" ? "#F3F5FF" : (element.reviewStatus ?? element.status) === "rejected" ? "#FEF2F2" : "#EEEFF1",
4516
+ color: (element.reviewStatus ?? element.status) === "accepted" || (element.reviewStatus ?? element.status) === "completed" || element.status === "resolved" ? "#2C53F1" : (element.reviewStatus ?? element.status) === "rejected" ? "#DC2626" : "#4E5565",
4517
+ border: `1px solid ${(element.reviewStatus ?? element.status) === "accepted" || (element.reviewStatus ?? element.status) === "completed" || element.status === "resolved" ? "#D2DAFA" : (element.reviewStatus ?? element.status) === "rejected" ? "#FECACA" : "#E3E5EA"}`
4165
4518
  },
4166
- children: element.status || "open"
4519
+ children: (() => {
4520
+ const st = element.reviewStatus ?? element.status ?? "open";
4521
+ if (st === "accepted") return "\u5DF2\u63A5\u53D7";
4522
+ if (st === "rejected") return "\u5DF2\u9A73\u56DE";
4523
+ if (st === "completed" || st === "resolved") return "\u5DF2\u5B8C\u6210";
4524
+ if (st === "cancelled") return "\u5DF2\u53D6\u6D88";
4525
+ return "\u5F85\u5904\u7406";
4526
+ })()
4167
4527
  }
4168
4528
  )
4169
4529
  ] }),
@@ -4927,9 +5287,15 @@ var PdfStatusBar = () => {
4927
5287
  import { generateRandomId as generateRandomId2, ICommandService as ICommandService5, IUniverInstanceService as IUniverInstanceService5, UniverInstanceType as UniverInstanceType5 } from "@univerjs/core";
4928
5288
  import { useDependency as useDependency4, useObservable as useObservable4 } from "@univerjs/ui";
4929
5289
  import {
5290
+ AddPdfAnnotationReplyCommand,
5291
+ AddPdfElementCommand as AddPdfElementCommand3,
4930
5292
  AlignSelectedPdfElementsCommand,
4931
5293
  AssignPdfElementLayerCommand,
4932
5294
  autoDetectFormFieldsOnPage,
5295
+ buildPdfApprovalStampSvg,
5296
+ convertPdfUnitToPptxBytes,
5297
+ createPdfApprovalStampElement,
5298
+ DeletePdfAnnotationReplyCommand,
4933
5299
  DeleteSelectedPdfElementsCommand as DeleteSelectedPdfElementsCommand2,
4934
5300
  detectFormFieldsFromPageSpans,
4935
5301
  DistributeSelectedPdfElementsCommand,
@@ -4941,6 +5307,7 @@ import {
4941
5307
  formatBatesNumber,
4942
5308
  formatPdfDateTimeValue as formatPdfDateTimeValue2,
4943
5309
  getDefaultDateTimeFormat,
5310
+ getPdfStandardStampPreset,
4944
5311
  importFormDataFromXfdf,
4945
5312
  IPdfIoService as IPdfIoService2,
4946
5313
  IPdfSelectionService as IPdfSelectionService5,
@@ -4948,6 +5315,7 @@ import {
4948
5315
  mmToPt as mmToPt2,
4949
5316
  normalizeImageCrop as normalizeImageCrop2,
4950
5317
  PDF_PAGE_PRESETS,
5318
+ PDF_STANDARD_STAMP_PRESETS,
4951
5319
  PdfElementType as PdfElementType4,
4952
5320
  ptToMm as ptToMm2,
4953
5321
  recalculatePdfFormFields,
@@ -4958,11 +5326,12 @@ import {
4958
5326
  RotatePdfPageCommand,
4959
5327
  sanitizePdfUnit,
4960
5328
  SavePdfVersionCommand,
5329
+ SetPdfAnnotationReviewStatusCommand,
4961
5330
  SetPdfBatesConfigCommand,
4962
5331
  SetPdfBookmarksCommand,
4963
5332
  SetPdfHeaderFooterConfigCommand,
4964
5333
  SetPdfNativeTextSpansCommand,
4965
- SetPdfPageCropBoxCommand,
5334
+ SetPdfPageCropBoxCommand as SetPdfPageCropBoxCommand2,
4966
5335
  SetPdfPageSizeCommand,
4967
5336
  SetPdfSecurityConfigCommand,
4968
5337
  UpdatePdfElementsCommand as UpdatePdfElementsCommand3,
@@ -5010,6 +5379,10 @@ var PdfInspectorPanel = () => {
5010
5379
  const [replaceNotice, setReplaceNotice] = useState4("");
5011
5380
  const [replyAuthorInput, setReplyAuthorInput] = useState4("Reviewer");
5012
5381
  const [replyContentInput, setReplyContentInput] = useState4("");
5382
+ const [stampPresetId, setStampPresetId] = useState4("approved");
5383
+ const [stampSignerInput, setStampSignerInput] = useState4("\u5BA1\u9605\u7EC4");
5384
+ const [stampDateInput, setStampDateInput] = useState4(() => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
5385
+ const [stampShapeInput, setStampShapeInput] = useState4("rect");
5013
5386
  const currentSnapshot = snapshot ?? unit?.getSnapshot() ?? null;
5014
5387
  if (!currentSnapshot || !unit) return null;
5015
5388
  void versionsTick;
@@ -5466,38 +5839,248 @@ var PdfInspectorPanel = () => {
5466
5839
  }
5467
5840
  )
5468
5841
  ] }),
5469
- features.cropBox && /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-checkbox-row", children: [
5470
- /* @__PURE__ */ jsx5(
5471
- "input",
5472
- {
5473
- type: "checkbox",
5474
- checked: Boolean(activePage.cropBox),
5475
- onChange: (e) => {
5476
- if (e.target.checked) {
5477
- const pSz = activePage.pageSize ?? pageSize;
5478
- commandService.syncExecuteCommand(SetPdfPageCropBoxCommand.id, {
5479
- pageId: activePage.id,
5480
- cropBox: {
5481
- left: Math.round(pSz.width * 0.05),
5482
- top: Math.round(pSz.height * 0.05),
5483
- width: Math.round(pSz.width * 0.9),
5484
- height: Math.round(pSz.height * 0.9)
5485
- }
5486
- });
5487
- } else {
5488
- commandService.syncExecuteCommand(SetPdfPageCropBoxCommand.id, {
5489
- pageId: activePage.id,
5490
- cropBox: void 0
5491
- });
5842
+ features.cropBox && /* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", gap: 5 }, children: [
5843
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-checkbox-row", children: [
5844
+ /* @__PURE__ */ jsx5(
5845
+ "input",
5846
+ {
5847
+ type: "checkbox",
5848
+ checked: Boolean(activePage.cropBox),
5849
+ onChange: (e) => {
5850
+ if (e.target.checked) {
5851
+ const pSz = activePage.pageSize ?? pageSize;
5852
+ commandService.syncExecuteCommand(SetPdfPageCropBoxCommand2.id, {
5853
+ pageId: activePage.id,
5854
+ cropBox: {
5855
+ left: Math.round(pSz.width * 0.05),
5856
+ top: Math.round(pSz.height * 0.05),
5857
+ width: Math.round(pSz.width * 0.9),
5858
+ height: Math.round(pSz.height * 0.9)
5859
+ }
5860
+ });
5861
+ } else {
5862
+ commandService.syncExecuteCommand(SetPdfPageCropBoxCommand2.id, {
5863
+ pageId: activePage.id,
5864
+ cropBox: void 0
5865
+ });
5866
+ }
5492
5867
  }
5493
5868
  }
5494
- }
5495
- ),
5496
- /* @__PURE__ */ jsx5(UiCropIcon, {}),
5497
- /* @__PURE__ */ jsx5("span", { children: "\u542F\u7528\u5F53\u524D\u9875\u88C1\u5207\u6846 (CropBox)" })
5498
- ] })
5869
+ ),
5870
+ /* @__PURE__ */ jsx5(UiCropIcon, {}),
5871
+ /* @__PURE__ */ jsx5("span", { children: "\u542F\u7528\u5F53\u524D\u9875\u88C1\u5207\u6846 (CropBox)" })
5872
+ ] }),
5873
+ /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-btn-row", children: [
5874
+ /* @__PURE__ */ jsxs5(
5875
+ "button",
5876
+ {
5877
+ type: "button",
5878
+ "data-testid": "pdf-inspector-enter-crop-btn",
5879
+ className: "univer-pdf-mini-btn",
5880
+ style: { flex: 1, display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
5881
+ onClick: () => void commandService.executeCommand(SetPdfInteractionModeOperation.id, { mode: "crop" }),
5882
+ children: [
5883
+ /* @__PURE__ */ jsx5(UiCropIcon, {}),
5884
+ /* @__PURE__ */ jsx5("span", { children: "\u753B\u5E03\u62D6\u62FD\u88C1\u5207" })
5885
+ ]
5886
+ }
5887
+ ),
5888
+ /* @__PURE__ */ jsxs5(
5889
+ "button",
5890
+ {
5891
+ type: "button",
5892
+ "data-testid": "pdf-inspector-open-split-btn",
5893
+ className: "univer-pdf-mini-btn",
5894
+ style: { flex: 1, display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
5895
+ onClick: () => void commandService.executeCommand(OpenPdfSplitModalOperation.id, { open: true }),
5896
+ children: [
5897
+ /* @__PURE__ */ jsx5(UiSplitMergeIcon, {}),
5898
+ /* @__PURE__ */ jsx5("span", { children: "\u62C6\u5206\u63D0\u53D6" })
5899
+ ]
5900
+ }
5901
+ )
5902
+ ] })
5903
+ ] }),
5904
+ /* @__PURE__ */ jsxs5(
5905
+ "button",
5906
+ {
5907
+ type: "button",
5908
+ "data-testid": "pdf-inspector-export-pptx-btn",
5909
+ className: "univer-pdf-mini-btn",
5910
+ style: { width: "100%", marginTop: 4, display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 5 },
5911
+ onClick: () => {
5912
+ const pptxBytes = convertPdfUnitToPptxBytes(currentSnapshot);
5913
+ if (typeof document !== "undefined" && typeof URL !== "undefined" && typeof URL.createObjectURL === "function") {
5914
+ const blob = new Blob([pptxBytes.slice().buffer], {
5915
+ type: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
5916
+ });
5917
+ const url = URL.createObjectURL(blob);
5918
+ const a = document.createElement("a");
5919
+ a.href = url;
5920
+ a.download = `${(currentSnapshot.name || "presentation").replace(/[\\/:*?"<>|]+/g, "_")}.pptx`;
5921
+ document.body.appendChild(a);
5922
+ a.click();
5923
+ a.remove();
5924
+ setTimeout(() => URL.revokeObjectURL(url), 1e4);
5925
+ }
5926
+ },
5927
+ children: [
5928
+ /* @__PURE__ */ jsx5(UiPptxSlideIcon, { style: { color: "#2C53F1" } }),
5929
+ /* @__PURE__ */ jsx5("span", { children: "\u5BFC\u51FA\u53EF\u7F16\u8F91 PPTX \u6F14\u793A\u6587\u7A3F (.pptx)" })
5930
+ ]
5931
+ }
5932
+ )
5499
5933
  ] })
5500
5934
  ] }),
5935
+ (isPdfElementTypeAllowed(PdfElementType4.STAMP, features) || isPdfElementTypeAllowed(PdfElementType4.SVG, features)) && (() => {
5936
+ const activeStampPreset = getPdfStandardStampPreset(stampPresetId) ?? PDF_STANDARD_STAMP_PRESETS[0];
5937
+ const previewSvg = buildPdfApprovalStampSvg({
5938
+ preset: activeStampPreset.id,
5939
+ title: activeStampPreset.title,
5940
+ subtitle: activeStampPreset.subtitle,
5941
+ signer: stampSignerInput,
5942
+ dateText: stampDateInput,
5943
+ color: activeStampPreset.color,
5944
+ shape: stampShapeInput
5945
+ });
5946
+ const previewDataUri = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(previewSvg)}`;
5947
+ return /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-section", "data-testid": "pdf-inspector-stamp-library", children: [
5948
+ /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-heading", style: { justifyContent: "flex-start", gap: 5 }, children: [
5949
+ /* @__PURE__ */ jsx5(UiStampSealIcon, { style: { color: "#4E5565" } }),
5950
+ /* @__PURE__ */ jsx5("span", { children: "\u6807\u51C6\u5BA1\u9605\u56FE\u7AE0\u5E93\u4E0E\u52A8\u6001\u7B7E\u7AE0" })
5951
+ ] }),
5952
+ /* @__PURE__ */ jsx5("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 4 }, children: PDF_STANDARD_STAMP_PRESETS.map((preset) => {
5953
+ const selected = preset.id === activeStampPreset.id;
5954
+ return /* @__PURE__ */ jsx5(
5955
+ "button",
5956
+ {
5957
+ type: "button",
5958
+ "data-testid": `pdf-stamp-preset-${preset.id}`,
5959
+ onClick: () => {
5960
+ setStampPresetId(preset.id);
5961
+ setStampShapeInput(preset.shape);
5962
+ },
5963
+ style: {
5964
+ padding: "4px 3px",
5965
+ fontSize: 10.5,
5966
+ fontWeight: selected ? 600 : 500,
5967
+ borderRadius: 4,
5968
+ border: selected ? `1.5px solid ${preset.color}` : "1px solid #E3E5EA",
5969
+ background: selected ? "#F9FAFB" : "#FFFFFF",
5970
+ color: preset.color,
5971
+ cursor: "pointer",
5972
+ overflow: "hidden",
5973
+ textOverflow: "ellipsis",
5974
+ whiteSpace: "nowrap"
5975
+ },
5976
+ title: `${preset.title} (${preset.subtitle})`,
5977
+ children: preset.title
5978
+ },
5979
+ preset.id
5980
+ );
5981
+ }) }),
5982
+ /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-grid-2", children: [
5983
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
5984
+ /* @__PURE__ */ jsx5("span", { children: "\u7B7E\u7F72\u4EBA / \u90E8\u95E8" }),
5985
+ /* @__PURE__ */ jsx5(
5986
+ "input",
5987
+ {
5988
+ type: "text",
5989
+ "data-testid": "pdf-stamp-signer-input",
5990
+ value: stampSignerInput,
5991
+ placeholder: "\u5982\uFF1A\u6CD5\u52A1\u90E8 \xB7 \u738B\u5DE5",
5992
+ onChange: (e) => setStampSignerInput(e.target.value)
5993
+ }
5994
+ )
5995
+ ] }),
5996
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
5997
+ /* @__PURE__ */ jsx5("span", { children: "\u7B7E\u7AE0\u65E5\u671F" }),
5998
+ /* @__PURE__ */ jsx5(
5999
+ "input",
6000
+ {
6001
+ type: "text",
6002
+ "data-testid": "pdf-stamp-date-input",
6003
+ value: stampDateInput,
6004
+ placeholder: "YYYY-MM-DD",
6005
+ onChange: (e) => setStampDateInput(e.target.value)
6006
+ }
6007
+ )
6008
+ ] })
6009
+ ] }),
6010
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-row", children: [
6011
+ /* @__PURE__ */ jsx5("span", { children: "\u56FE\u7AE0\u5916\u6846\u7248\u5F0F" }),
6012
+ /* @__PURE__ */ jsxs5(
6013
+ "select",
6014
+ {
6015
+ "data-testid": "pdf-stamp-shape-select",
6016
+ value: stampShapeInput,
6017
+ onChange: (e) => setStampShapeInput(e.target.value),
6018
+ children: [
6019
+ /* @__PURE__ */ jsx5("option", { value: "rect", children: "\u6807\u51C6\u65B9\u7AE0 (rect)" }),
6020
+ /* @__PURE__ */ jsx5("option", { value: "pill", children: "\u5706\u89D2\u80F6\u56CA\u7AE0 (pill)" }),
6021
+ /* @__PURE__ */ jsx5("option", { value: "circle", children: "\u53CC\u73AF\u516C\u7AE0\u5706\u7AE0 (circle)" })
6022
+ ]
6023
+ }
6024
+ )
6025
+ ] }),
6026
+ /* @__PURE__ */ jsx5(
6027
+ "div",
6028
+ {
6029
+ style: {
6030
+ padding: "6px 8px",
6031
+ background: "#F9FAFB",
6032
+ border: "1px dashed #D5D8DF",
6033
+ borderRadius: 5,
6034
+ display: "flex",
6035
+ alignItems: "center",
6036
+ justifyContent: "center",
6037
+ minHeight: 54
6038
+ },
6039
+ children: /* @__PURE__ */ jsx5(
6040
+ "img",
6041
+ {
6042
+ src: previewDataUri,
6043
+ alt: activeStampPreset.title,
6044
+ style: { maxHeight: 58, maxWidth: "100%", objectFit: "contain" }
6045
+ }
6046
+ )
6047
+ }
6048
+ ),
6049
+ /* @__PURE__ */ jsx5(
6050
+ "button",
6051
+ {
6052
+ type: "button",
6053
+ "data-testid": "pdf-stamp-insert-btn",
6054
+ className: "univer-pdf-mini-btn is-soft-primary",
6055
+ style: { width: "100%" },
6056
+ onClick: () => {
6057
+ const useStampType = isPdfElementTypeAllowed(PdfElementType4.STAMP, features);
6058
+ const built = createPdfApprovalStampElement({
6059
+ preset: activeStampPreset.id,
6060
+ title: activeStampPreset.title,
6061
+ subtitle: activeStampPreset.subtitle,
6062
+ signer: stampSignerInput,
6063
+ dateText: stampDateInput,
6064
+ color: activeStampPreset.color,
6065
+ shape: stampShapeInput
6066
+ });
6067
+ commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
6068
+ pageId: activePageId,
6069
+ elementType: useStampType ? PdfElementType4.STAMP : PdfElementType4.SVG,
6070
+ element: useStampType ? built : {
6071
+ type: PdfElementType4.SVG,
6072
+ name: built.name,
6073
+ svgContent: previewSvg,
6074
+ opacity: 0.92,
6075
+ transform: built.transform
6076
+ }
6077
+ });
6078
+ },
6079
+ children: "\u4E00\u952E\u52A0\u76D6\u52A8\u6001\u56FE\u7AE0\u81F3\u5F53\u524D\u9875"
6080
+ }
6081
+ )
6082
+ ] });
6083
+ })(),
5501
6084
  features.findReplace && /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-section", children: [
5502
6085
  /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-heading", style: { justifyContent: "space-between" }, children: [
5503
6086
  /* @__PURE__ */ jsxs5("span", { style: { display: "inline-flex", alignItems: "center", gap: 5 }, children: [
@@ -6517,165 +7100,245 @@ var PdfInspectorPanel = () => {
6517
7100
  )
6518
7101
  ] })
6519
7102
  ] }),
6520
- isPdfElementTypeAllowed(PdfElementType4.ANNOTATION, features) && element.type === PdfElementType4.ANNOTATION && /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-section", children: [
6521
- /* @__PURE__ */ jsx5("div", { className: "univer-pdf-inspector-heading", children: "\u5BA1\u9605\u6279\u6CE8\u4E0E\u8BA8\u8BBA\u4E32" }),
6522
- /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-grid-2", children: [
6523
- /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
6524
- /* @__PURE__ */ jsx5("span", { children: "\u6279\u6CE8\u7C7B\u578B" }),
6525
- /* @__PURE__ */ jsxs5(
6526
- "select",
6527
- {
6528
- value: element.annotationType,
6529
- onChange: (e) => updateElement({ annotationType: e.target.value }),
6530
- children: [
6531
- /* @__PURE__ */ jsx5("option", { value: "highlight", children: "\u8367\u5149\u9AD8\u4EAE (Highlight)" }),
6532
- /* @__PURE__ */ jsx5("option", { value: "underline", children: "\u4E0B\u5212\u7EBF (Underline)" }),
6533
- /* @__PURE__ */ jsx5("option", { value: "strikeout", children: "\u5220\u9664\u7EBF (Strikeout)" }),
6534
- /* @__PURE__ */ jsx5("option", { value: "squiggly", children: "\u6CE2\u6D6A\u7EBF (Squiggly)" }),
6535
- /* @__PURE__ */ jsx5("option", { value: "stickyNote", children: "\u5BA1\u9605\u4FBF\u7B7E (Sticky Note)" })
6536
- ]
6537
- }
6538
- )
6539
- ] }),
6540
- /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
6541
- /* @__PURE__ */ jsx5("span", { children: "\u5BA1\u9605\u72B6\u6001" }),
6542
- /* @__PURE__ */ jsxs5(
6543
- "select",
6544
- {
6545
- value: element.status ?? "open",
6546
- onChange: (e) => updateElement({ status: e.target.value }),
6547
- children: [
6548
- /* @__PURE__ */ jsx5("option", { value: "open", children: "\u5F85\u5904\u7406 (open)" }),
6549
- /* @__PURE__ */ jsx5("option", { value: "accepted", children: "\u5DF2\u91C7\u7EB3 (accepted)" }),
6550
- /* @__PURE__ */ jsx5("option", { value: "rejected", children: "\u5DF2\u9A73\u56DE (rejected)" }),
6551
- /* @__PURE__ */ jsx5("option", { value: "resolved", children: "\u5DF2\u89E3\u51B3 (resolved)" })
6552
- ]
6553
- }
6554
- )
6555
- ] }),
6556
- /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
6557
- /* @__PURE__ */ jsx5("span", { children: "\u5BA1\u9605\u4EBA" }),
7103
+ isPdfElementTypeAllowed(PdfElementType4.ANNOTATION, features) && element.type === PdfElementType4.ANNOTATION && (() => {
7104
+ const rawStatus = element.reviewStatus ?? element.status ?? "open";
7105
+ const effectiveReviewStatus = rawStatus === "accepted" || rawStatus === "rejected" || rawStatus === "completed" || rawStatus === "cancelled" ? rawStatus : rawStatus === "resolved" ? "completed" : "open";
7106
+ const statusMetaMap = {
7107
+ open: { label: "\u5F85\u5904\u7406", color: "#4E5565", bg: "#F9FAFB", border: "#D5D8DF" },
7108
+ accepted: { label: "\u5DF2\u63A5\u53D7", color: "#16A34A", bg: "#F0FDF4", border: "#BBF7D0" },
7109
+ rejected: { label: "\u5DF2\u62D2\u7EDD", color: "#DC2626", bg: "#FEF2F2", border: "#FECACA" },
7110
+ completed: { label: "\u5DF2\u5B8C\u6210", color: "#2C53F1", bg: "#F3F5FF", border: "#D2DAFA" },
7111
+ cancelled: { label: "\u5DF2\u53D6\u6D88", color: "#64748B", bg: "#F1F5F9", border: "#CBD5E1" }
7112
+ };
7113
+ const curBadge = statusMetaMap[effectiveReviewStatus];
7114
+ return /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-section", "data-testid": "pdf-inspector-annotation-thread", children: [
7115
+ /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-heading", style: { justifyContent: "space-between" }, children: [
7116
+ /* @__PURE__ */ jsxs5("span", { style: { display: "inline-flex", alignItems: "center", gap: 5 }, children: [
7117
+ /* @__PURE__ */ jsx5(UiMessageReplyIcon, { style: { color: "#4E5565" } }),
7118
+ /* @__PURE__ */ jsx5("span", { children: "\u6279\u6CE8\u56DE\u590D\u7EBF\u7A0B\u4E0E\u5BA1\u9605\u72B6\u6001\u6D41\u8F6C" })
7119
+ ] }),
6558
7120
  /* @__PURE__ */ jsx5(
6559
- "input",
7121
+ "span",
6560
7122
  {
6561
- type: "text",
6562
- value: element.author ?? "Reviewer",
6563
- onChange: (e) => updateElement({ author: e.target.value })
7123
+ "data-testid": "pdf-annot-review-status-badge",
7124
+ style: {
7125
+ fontSize: 10.5,
7126
+ fontWeight: 600,
7127
+ padding: "1px 7px",
7128
+ borderRadius: 999,
7129
+ color: curBadge.color,
7130
+ background: curBadge.bg,
7131
+ border: `1px solid ${curBadge.border}`
7132
+ },
7133
+ children: curBadge.label
6564
7134
  }
6565
7135
  )
6566
7136
  ] }),
6567
- /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
6568
- /* @__PURE__ */ jsx5("span", { children: "\u6807\u8BB0\u989C\u8272" }),
6569
- /* @__PURE__ */ jsx5(
6570
- "input",
7137
+ /* @__PURE__ */ jsx5("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: ["open", "accepted", "rejected", "completed", "cancelled"].map((st) => {
7138
+ const m = statusMetaMap[st];
7139
+ const isCur = effectiveReviewStatus === st;
7140
+ return /* @__PURE__ */ jsx5(
7141
+ "button",
6571
7142
  {
6572
- type: "color",
6573
- value: element.color || "#2C53F1",
6574
- onChange: (e) => updateElement({ color: e.target.value })
6575
- }
6576
- )
6577
- ] })
6578
- ] }),
6579
- /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
6580
- /* @__PURE__ */ jsx5("span", { children: "\u6279\u6CE8\u6B63\u6587" }),
6581
- /* @__PURE__ */ jsx5(
6582
- "textarea",
6583
- {
6584
- rows: 2,
6585
- value: element.comment ?? "",
6586
- placeholder: "\u8F93\u5165\u5BA1\u9605\u610F\u89C1...",
6587
- onChange: (e) => updateElement({ comment: e.target.value })
6588
- }
6589
- )
6590
- ] }),
6591
- /* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
6592
- /* @__PURE__ */ jsxs5("span", { style: { fontSize: 11, fontWeight: 600, color: "#31363F" }, children: [
6593
- "\u56DE\u590D\u4E32 (",
6594
- (element.replies ?? []).length,
6595
- ")"
6596
- ] }),
6597
- (element.replies ?? []).map((rep) => /* @__PURE__ */ jsxs5(
6598
- "div",
6599
- {
6600
- style: {
6601
- padding: "5px 7px",
6602
- background: "#F9FAFB",
6603
- border: "1px solid #E3E5EA",
6604
- borderRadius: 4,
6605
- fontSize: 11,
6606
- display: "flex",
6607
- justifyContent: "space-between",
6608
- alignItems: "flex-start",
6609
- gap: 6
7143
+ type: "button",
7144
+ "data-testid": `pdf-annot-status-btn-${st}`,
7145
+ onClick: () => commandService.syncExecuteCommand(SetPdfAnnotationReviewStatusCommand.id, {
7146
+ unitId: unit.getUnitId(),
7147
+ pageId: activePageId,
7148
+ elementId: element.id,
7149
+ reviewStatus: st
7150
+ }),
7151
+ style: {
7152
+ padding: "2px 7px",
7153
+ fontSize: 10.5,
7154
+ fontWeight: isCur ? 600 : 500,
7155
+ borderRadius: 4,
7156
+ border: isCur ? `1.5px solid ${m.color}` : "1px solid #E3E5EA",
7157
+ background: isCur ? m.bg : "#FFFFFF",
7158
+ color: isCur ? m.color : "#4E5565",
7159
+ cursor: "pointer"
7160
+ },
7161
+ children: m.label
6610
7162
  },
6611
- children: [
6612
- /* @__PURE__ */ jsxs5("div", { children: [
6613
- /* @__PURE__ */ jsxs5("strong", { style: { color: "#1B1C1F" }, children: [
6614
- rep.author,
6615
- ": "
6616
- ] }),
6617
- /* @__PURE__ */ jsx5("span", { style: { color: "#31363F" }, children: rep.content })
6618
- ] }),
6619
- /* @__PURE__ */ jsx5(
6620
- "button",
6621
- {
6622
- type: "button",
6623
- className: "univer-pdf-mini-btn is-danger",
6624
- onClick: () => updateElement({
6625
- replies: (element.replies ?? []).filter((r) => r.id !== rep.id)
6626
- }),
6627
- children: "\xD7"
6628
- }
6629
- )
6630
- ]
6631
- },
6632
- rep.id
6633
- )),
6634
- /* @__PURE__ */ jsxs5("div", { style: { display: "flex", gap: 4 }, children: [
6635
- /* @__PURE__ */ jsx5(
6636
- "input",
6637
- {
6638
- type: "text",
6639
- placeholder: "\u5BA1\u9605\u4EBA",
6640
- value: replyAuthorInput,
6641
- onChange: (e) => setReplyAuthorInput(e.target.value),
6642
- style: { width: 68, fontSize: 11, padding: "3px 5px", border: "1px solid #E3E5EA", borderRadius: 4 }
6643
- }
6644
- ),
7163
+ st
7164
+ );
7165
+ }) }),
7166
+ /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-grid-2", children: [
7167
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7168
+ /* @__PURE__ */ jsx5("span", { children: "\u6279\u6CE8\u7C7B\u578B" }),
7169
+ /* @__PURE__ */ jsxs5(
7170
+ "select",
7171
+ {
7172
+ value: element.annotationType,
7173
+ onChange: (e) => updateElement({ annotationType: e.target.value }),
7174
+ children: [
7175
+ /* @__PURE__ */ jsx5("option", { value: "highlight", children: "\u8367\u5149\u9AD8\u4EAE (Highlight)" }),
7176
+ /* @__PURE__ */ jsx5("option", { value: "underline", children: "\u4E0B\u5212\u7EBF (Underline)" }),
7177
+ /* @__PURE__ */ jsx5("option", { value: "strikeout", children: "\u5220\u9664\u7EBF (Strikeout)" }),
7178
+ /* @__PURE__ */ jsx5("option", { value: "squiggly", children: "\u6CE2\u6D6A\u7EBF (Squiggly)" }),
7179
+ /* @__PURE__ */ jsx5("option", { value: "stickyNote", children: "\u5BA1\u9605\u4FBF\u7B7E (Sticky Note)" })
7180
+ ]
7181
+ }
7182
+ )
7183
+ ] }),
7184
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7185
+ /* @__PURE__ */ jsx5("span", { children: "\u5BA1\u9605\u72B6\u6001" }),
7186
+ /* @__PURE__ */ jsxs5(
7187
+ "select",
7188
+ {
7189
+ "data-testid": "pdf-annot-review-status-select",
7190
+ value: effectiveReviewStatus,
7191
+ onChange: (e) => commandService.syncExecuteCommand(SetPdfAnnotationReviewStatusCommand.id, {
7192
+ unitId: unit.getUnitId(),
7193
+ pageId: activePageId,
7194
+ elementId: element.id,
7195
+ reviewStatus: e.target.value
7196
+ }),
7197
+ children: [
7198
+ /* @__PURE__ */ jsx5("option", { value: "open", children: "\u5F85\u5904\u7406 (open)" }),
7199
+ /* @__PURE__ */ jsx5("option", { value: "accepted", children: "\u5DF2\u63A5\u53D7 (accepted)" }),
7200
+ /* @__PURE__ */ jsx5("option", { value: "rejected", children: "\u5DF2\u62D2\u7EDD (rejected)" }),
7201
+ /* @__PURE__ */ jsx5("option", { value: "completed", children: "\u5DF2\u5B8C\u6210 (completed)" }),
7202
+ /* @__PURE__ */ jsx5("option", { value: "cancelled", children: "\u5DF2\u53D6\u6D88 (cancelled)" })
7203
+ ]
7204
+ }
7205
+ )
7206
+ ] }),
7207
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7208
+ /* @__PURE__ */ jsx5("span", { children: "\u5BA1\u9605\u4EBA" }),
7209
+ /* @__PURE__ */ jsx5(
7210
+ "input",
7211
+ {
7212
+ type: "text",
7213
+ value: element.author ?? "Reviewer",
7214
+ onChange: (e) => updateElement({ author: e.target.value })
7215
+ }
7216
+ )
7217
+ ] }),
7218
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7219
+ /* @__PURE__ */ jsx5("span", { children: "\u6807\u8BB0\u989C\u8272" }),
7220
+ /* @__PURE__ */ jsx5(
7221
+ "input",
7222
+ {
7223
+ type: "color",
7224
+ value: element.color || "#2C53F1",
7225
+ onChange: (e) => updateElement({ color: e.target.value })
7226
+ }
7227
+ )
7228
+ ] })
7229
+ ] }),
7230
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7231
+ /* @__PURE__ */ jsx5("span", { children: "\u6279\u6CE8\u6B63\u6587" }),
6645
7232
  /* @__PURE__ */ jsx5(
6646
- "input",
7233
+ "textarea",
6647
7234
  {
6648
- type: "text",
6649
- placeholder: "\u6DFB\u52A0\u56DE\u590D\u610F\u89C1...",
6650
- value: replyContentInput,
6651
- onChange: (e) => setReplyContentInput(e.target.value),
6652
- style: { flex: 1, fontSize: 11, padding: "3px 5px", border: "1px solid #E3E5EA", borderRadius: 4 }
7235
+ rows: 2,
7236
+ value: element.comment ?? "",
7237
+ placeholder: "\u8F93\u5165\u5BA1\u9605\u610F\u89C1...",
7238
+ onChange: (e) => updateElement({ comment: e.target.value })
6653
7239
  }
6654
- ),
6655
- /* @__PURE__ */ jsx5(
6656
- "button",
7240
+ )
7241
+ ] }),
7242
+ /* @__PURE__ */ jsxs5("div", { "data-testid": "pdf-annot-reply-list", style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
7243
+ /* @__PURE__ */ jsxs5("span", { style: { fontSize: 11, fontWeight: 600, color: "#31363F" }, children: [
7244
+ "\u56DE\u590D\u4E32 (",
7245
+ (element.replies ?? []).length,
7246
+ ")"
7247
+ ] }),
7248
+ (element.replies ?? []).map((rep) => /* @__PURE__ */ jsxs5(
7249
+ "div",
6657
7250
  {
6658
- type: "button",
6659
- className: "univer-pdf-mini-btn is-soft-primary",
6660
- disabled: !replyContentInput.trim(),
6661
- onClick: () => {
6662
- const newReply = {
6663
- id: `reply-${generateRandomId2(5)}`,
6664
- author: replyAuthorInput.trim() || "Reviewer",
6665
- content: replyContentInput.trim(),
6666
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
6667
- };
6668
- updateElement({
6669
- replies: [...element.replies ?? [], newReply]
6670
- });
6671
- setReplyContentInput("");
7251
+ "data-testid": `pdf-annot-reply-item-${rep.id}`,
7252
+ style: {
7253
+ padding: "5px 7px",
7254
+ background: "#F9FAFB",
7255
+ border: "1px solid #E3E5EA",
7256
+ borderRadius: 4,
7257
+ fontSize: 11,
7258
+ display: "flex",
7259
+ justifyContent: "space-between",
7260
+ alignItems: "flex-start",
7261
+ gap: 6
6672
7262
  },
6673
- children: "\u56DE\u590D"
6674
- }
6675
- )
7263
+ children: [
7264
+ /* @__PURE__ */ jsxs5("div", { children: [
7265
+ /* @__PURE__ */ jsxs5("div", { children: [
7266
+ /* @__PURE__ */ jsxs5("strong", { style: { color: "#1B1C1F" }, children: [
7267
+ rep.author,
7268
+ ": "
7269
+ ] }),
7270
+ /* @__PURE__ */ jsx5("span", { style: { color: "#31363F" }, children: rep.content })
7271
+ ] }),
7272
+ rep.createdAt && /* @__PURE__ */ jsx5("div", { style: { fontSize: 9.5, color: "#7D8698", marginTop: 1 }, children: rep.createdAt.slice(0, 16).replace("T", " ") })
7273
+ ] }),
7274
+ /* @__PURE__ */ jsx5(
7275
+ "button",
7276
+ {
7277
+ type: "button",
7278
+ "data-testid": `pdf-annot-delete-reply-${rep.id}`,
7279
+ className: "univer-pdf-mini-btn is-danger",
7280
+ onClick: () => commandService.syncExecuteCommand(DeletePdfAnnotationReplyCommand.id, {
7281
+ unitId: unit.getUnitId(),
7282
+ pageId: activePageId,
7283
+ elementId: element.id,
7284
+ replyId: rep.id
7285
+ }),
7286
+ children: "\xD7"
7287
+ }
7288
+ )
7289
+ ]
7290
+ },
7291
+ rep.id
7292
+ )),
7293
+ /* @__PURE__ */ jsxs5("div", { style: { display: "flex", gap: 4 }, children: [
7294
+ /* @__PURE__ */ jsx5(
7295
+ "input",
7296
+ {
7297
+ type: "text",
7298
+ placeholder: "\u56DE\u590D\u4EBA",
7299
+ value: replyAuthorInput,
7300
+ onChange: (e) => setReplyAuthorInput(e.target.value),
7301
+ style: { width: 68, fontSize: 11, padding: "3px 5px", border: "1px solid #E3E5EA", borderRadius: 4 }
7302
+ }
7303
+ ),
7304
+ /* @__PURE__ */ jsx5(
7305
+ "input",
7306
+ {
7307
+ type: "text",
7308
+ "data-testid": "pdf-annot-reply-input",
7309
+ placeholder: "\u8F93\u5165\u6279\u6CE8\u56DE\u590D\u5185\u5BB9...",
7310
+ value: replyContentInput,
7311
+ onChange: (e) => setReplyContentInput(e.target.value),
7312
+ style: { flex: 1, fontSize: 11, padding: "3px 5px", border: "1px solid #E3E5EA", borderRadius: 4 }
7313
+ }
7314
+ ),
7315
+ /* @__PURE__ */ jsx5(
7316
+ "button",
7317
+ {
7318
+ type: "button",
7319
+ "data-testid": "pdf-annot-add-reply-btn",
7320
+ className: "univer-pdf-mini-btn is-soft-primary",
7321
+ disabled: !replyContentInput.trim(),
7322
+ onClick: () => {
7323
+ commandService.syncExecuteCommand(AddPdfAnnotationReplyCommand.id, {
7324
+ unitId: unit.getUnitId(),
7325
+ pageId: activePageId,
7326
+ elementId: element.id,
7327
+ reply: {
7328
+ author: replyAuthorInput.trim() || "Reviewer",
7329
+ content: replyContentInput.trim(),
7330
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
7331
+ }
7332
+ });
7333
+ setReplyContentInput("");
7334
+ },
7335
+ children: "+ \u6DFB\u52A0\u56DE\u590D"
7336
+ }
7337
+ )
7338
+ ] })
6676
7339
  ] })
6677
- ] })
6678
- ] }),
7340
+ ] });
7341
+ })(),
6679
7342
  isPdfElementTypeAllowed(PdfElementType4.REDACTION, features) && element.type === PdfElementType4.REDACTION && /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-section", children: [
6680
7343
  /* @__PURE__ */ jsx5("div", { className: "univer-pdf-inspector-heading", children: "\u6C38\u4E45\u8131\u654F\u6D82\u9ED1 (\u5BFC\u51FA\u81EA\u52A8\u5265\u79BB\u5E95\u5C42\u6587\u672C)" }),
6681
7344
  /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-row", children: [
@@ -7167,17 +7830,64 @@ var PdfInspectorPanel = () => {
7167
7830
  ] })
7168
7831
  ] }),
7169
7832
  element.type === PdfElementType4.STAMP && /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-inspector-section", children: [
7170
- /* @__PURE__ */ jsx5("div", { className: "univer-pdf-inspector-heading", children: "\u7535\u5B50\u7B7E\u7AE0\u914D\u7F6E" }),
7833
+ /* @__PURE__ */ jsx5("div", { className: "univer-pdf-inspector-heading", children: "\u7535\u5B50\u7B7E\u7AE0\u4E0E\u6807\u51C6\u5BA1\u9605\u7AE0\u914D\u7F6E" }),
7834
+ /* @__PURE__ */ jsx5("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 4 }, children: PDF_STANDARD_STAMP_PRESETS.map((preset) => /* @__PURE__ */ jsx5(
7835
+ "button",
7836
+ {
7837
+ type: "button",
7838
+ className: "univer-pdf-mini-btn",
7839
+ style: { fontSize: 10, padding: "3px 2px", color: preset.color, borderColor: element.preset === preset.id ? preset.color : void 0 },
7840
+ onClick: () => {
7841
+ const nextShape = preset.shape;
7842
+ const nextSvg = buildPdfApprovalStampSvg({
7843
+ preset: preset.id,
7844
+ title: preset.title,
7845
+ subtitle: preset.subtitle,
7846
+ signer: element.signer,
7847
+ dateText: element.dateText,
7848
+ color: preset.color,
7849
+ shape: nextShape
7850
+ });
7851
+ updateElement({
7852
+ preset: preset.id,
7853
+ stampShape: nextShape,
7854
+ primaryText: preset.title,
7855
+ secondaryText: preset.subtitle,
7856
+ color: preset.color,
7857
+ svgContent: nextSvg
7858
+ });
7859
+ },
7860
+ children: preset.title
7861
+ },
7862
+ preset.id
7863
+ )) }),
7171
7864
  /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-row", children: [
7172
7865
  /* @__PURE__ */ jsx5("span", { children: "\u5370\u7AE0\u5916\u6846" }),
7173
7866
  /* @__PURE__ */ jsxs5(
7174
7867
  "select",
7175
7868
  {
7176
7869
  value: element.stampShape || "oval",
7177
- onChange: (e) => updateElement({ stampShape: e.target.value }),
7870
+ onChange: (e) => {
7871
+ const nextShape = e.target.value;
7872
+ const rebuildSvg = element.svgContent && nextShape !== "oval" ? buildPdfApprovalStampSvg({
7873
+ preset: element.preset,
7874
+ title: element.primaryText,
7875
+ subtitle: element.secondaryText,
7876
+ signer: element.signer,
7877
+ dateText: element.dateText,
7878
+ color: element.color,
7879
+ shape: nextShape
7880
+ }) : void 0;
7881
+ updateElement({
7882
+ stampShape: nextShape,
7883
+ ...rebuildSvg !== void 0 ? { svgContent: rebuildSvg } : {}
7884
+ });
7885
+ },
7178
7886
  children: [
7179
7887
  /* @__PURE__ */ jsx5("option", { value: "oval", children: "\u692D\u5706\u516C\u7AE0 / \u4E13\u7528\u7AE0" }),
7180
- /* @__PURE__ */ jsx5("option", { value: "rect", children: "\u65B9\u578B\u8D22\u52A1\u6838\u9A8C\u7AE0" })
7888
+ /* @__PURE__ */ jsx5("option", { value: "circle", children: "\u6B63\u5706\u6807\u51C6\u516C\u7AE0 (circle)" }),
7889
+ /* @__PURE__ */ jsx5("option", { value: "rect", children: "\u65B9\u578B\u8D22\u52A1/\u5BA1\u9605\u7AE0 (rect)" }),
7890
+ /* @__PURE__ */ jsx5("option", { value: "pill", children: "\u80F6\u56CA\u5BA1\u9605\u72B6\u6001\u7AE0 (pill)" })
7181
7891
  ]
7182
7892
  }
7183
7893
  )
@@ -7189,7 +7899,22 @@ var PdfInspectorPanel = () => {
7189
7899
  {
7190
7900
  type: "text",
7191
7901
  value: element.primaryText,
7192
- onChange: (e) => updateElement({ primaryText: e.target.value })
7902
+ onChange: (e) => {
7903
+ const nextTitle = e.target.value;
7904
+ const nextSvg = element.svgContent ? buildPdfApprovalStampSvg({
7905
+ preset: element.preset,
7906
+ title: nextTitle,
7907
+ subtitle: element.secondaryText,
7908
+ signer: element.signer,
7909
+ dateText: element.dateText,
7910
+ color: element.color,
7911
+ shape: element.stampShape === "circle" || element.stampShape === "pill" ? element.stampShape : "rect"
7912
+ }) : void 0;
7913
+ updateElement({
7914
+ primaryText: nextTitle,
7915
+ ...nextSvg ? { svgContent: nextSvg } : {}
7916
+ });
7917
+ }
7193
7918
  }
7194
7919
  )
7195
7920
  ] }),
@@ -7200,10 +7925,81 @@ var PdfInspectorPanel = () => {
7200
7925
  {
7201
7926
  type: "text",
7202
7927
  value: element.secondaryText || "",
7203
- onChange: (e) => updateElement({ secondaryText: e.target.value })
7928
+ onChange: (e) => {
7929
+ const nextSub = e.target.value;
7930
+ const nextSvg = element.svgContent ? buildPdfApprovalStampSvg({
7931
+ preset: element.preset,
7932
+ title: element.primaryText,
7933
+ subtitle: nextSub,
7934
+ signer: element.signer,
7935
+ dateText: element.dateText,
7936
+ color: element.color,
7937
+ shape: element.stampShape === "circle" || element.stampShape === "pill" ? element.stampShape : "rect"
7938
+ }) : void 0;
7939
+ updateElement({
7940
+ secondaryText: nextSub,
7941
+ ...nextSvg ? { svgContent: nextSvg } : {}
7942
+ });
7943
+ }
7204
7944
  }
7205
7945
  )
7206
7946
  ] }),
7947
+ /* @__PURE__ */ jsxs5("div", { className: "univer-pdf-grid-2", children: [
7948
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7949
+ /* @__PURE__ */ jsx5("span", { children: "\u7B7E\u7F72\u4EBA" }),
7950
+ /* @__PURE__ */ jsx5(
7951
+ "input",
7952
+ {
7953
+ type: "text",
7954
+ placeholder: "\u5982\uFF1A\u5F20\u5DE5",
7955
+ value: element.signer || "",
7956
+ onChange: (e) => {
7957
+ const nextSigner = e.target.value;
7958
+ const nextSvg = element.svgContent ? buildPdfApprovalStampSvg({
7959
+ preset: element.preset,
7960
+ title: element.primaryText,
7961
+ subtitle: element.secondaryText,
7962
+ signer: nextSigner,
7963
+ dateText: element.dateText,
7964
+ color: element.color,
7965
+ shape: element.stampShape === "circle" || element.stampShape === "pill" ? element.stampShape : "rect"
7966
+ }) : void 0;
7967
+ updateElement({
7968
+ signer: nextSigner || void 0,
7969
+ ...nextSvg ? { svgContent: nextSvg } : {}
7970
+ });
7971
+ }
7972
+ }
7973
+ )
7974
+ ] }),
7975
+ /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-col", children: [
7976
+ /* @__PURE__ */ jsx5("span", { children: "\u65E5\u671F" }),
7977
+ /* @__PURE__ */ jsx5(
7978
+ "input",
7979
+ {
7980
+ type: "text",
7981
+ placeholder: "YYYY-MM-DD",
7982
+ value: element.dateText || "",
7983
+ onChange: (e) => {
7984
+ const nextDate = e.target.value;
7985
+ const nextSvg = element.svgContent ? buildPdfApprovalStampSvg({
7986
+ preset: element.preset,
7987
+ title: element.primaryText,
7988
+ subtitle: element.secondaryText,
7989
+ signer: element.signer,
7990
+ dateText: nextDate,
7991
+ color: element.color,
7992
+ shape: element.stampShape === "circle" || element.stampShape === "pill" ? element.stampShape : "rect"
7993
+ }) : void 0;
7994
+ updateElement({
7995
+ dateText: nextDate || void 0,
7996
+ ...nextSvg ? { svgContent: nextSvg } : {}
7997
+ });
7998
+ }
7999
+ }
8000
+ )
8001
+ ] })
8002
+ ] }),
7207
8003
  /* @__PURE__ */ jsxs5("label", { className: "univer-pdf-form-row", children: [
7208
8004
  /* @__PURE__ */ jsx5("span", { children: "\u5370\u6CE5\u989C\u8272" }),
7209
8005
  /* @__PURE__ */ jsx5(
@@ -7211,7 +8007,22 @@ var PdfInspectorPanel = () => {
7211
8007
  {
7212
8008
  type: "color",
7213
8009
  value: element.color || "#dc2626",
7214
- onChange: (e) => updateElement({ color: e.target.value })
8010
+ onChange: (e) => {
8011
+ const nextColor = e.target.value;
8012
+ const nextSvg = element.svgContent ? buildPdfApprovalStampSvg({
8013
+ preset: element.preset,
8014
+ title: element.primaryText,
8015
+ subtitle: element.secondaryText,
8016
+ signer: element.signer,
8017
+ dateText: element.dateText,
8018
+ color: nextColor,
8019
+ shape: element.stampShape === "circle" || element.stampShape === "pill" ? element.stampShape : "rect"
8020
+ }) : void 0;
8021
+ updateElement({
8022
+ color: nextColor,
8023
+ ...nextSvg ? { svgContent: nextSvg } : {}
8024
+ });
8025
+ }
7215
8026
  }
7216
8027
  )
7217
8028
  ] })
@@ -8296,7 +9107,7 @@ import {
8296
9107
  } from "@univerjs/core";
8297
9108
  import { useDependency as useDependency5, useObservable as useObservable5 } from "@univerjs/ui";
8298
9109
  import {
8299
- AddPdfElementCommand as AddPdfElementCommand3,
9110
+ AddPdfElementCommand as AddPdfElementCommand4,
8300
9111
  AddPdfLayerCommand,
8301
9112
  AddPdfPageCommand,
8302
9113
  AssignPdfElementLayerCommand as AssignPdfElementLayerCommand2,
@@ -8485,7 +9296,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8485
9296
  const selectedIds = selState.selectedElementIds;
8486
9297
  const handleInsertField = (field) => {
8487
9298
  if (field.type === "table") {
8488
- commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9299
+ commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8489
9300
  elementType: PdfElementType5.TABLE,
8490
9301
  element: {
8491
9302
  name: field.label,
@@ -8500,7 +9311,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8500
9311
  }
8501
9312
  });
8502
9313
  } else if (field.type === "qrcode") {
8503
- commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9314
+ commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8504
9315
  elementType: PdfElementType5.QRCODE,
8505
9316
  element: {
8506
9317
  name: field.label,
@@ -8509,7 +9320,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8509
9320
  }
8510
9321
  });
8511
9322
  } else if (field.type === "barcode") {
8512
- commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9323
+ commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8513
9324
  elementType: PdfElementType5.BARCODE,
8514
9325
  element: {
8515
9326
  name: field.label,
@@ -8518,7 +9329,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8518
9329
  }
8519
9330
  });
8520
9331
  } else {
8521
- commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9332
+ commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8522
9333
  elementType: PdfElementType5.TEXT,
8523
9334
  element: {
8524
9335
  name: field.label,
@@ -8756,6 +9567,36 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8756
9567
  item.key
8757
9568
  )) }),
8758
9569
  effectiveTab === "pages" && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-thumb-list", children: [
9570
+ /* @__PURE__ */ jsxs6("div", { style: { display: "grid", gridTemplateColumns: editorEnabled && features.cropBox ? "1fr 1fr" : "1fr", gap: 4 }, children: [
9571
+ /* @__PURE__ */ jsxs6(
9572
+ "button",
9573
+ {
9574
+ type: "button",
9575
+ "data-testid": "pdf-sidebar-split-extract-btn",
9576
+ className: "univer-pdf-mini-btn",
9577
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9578
+ onClick: () => void commandService.executeCommand(OpenPdfSplitModalOperation.id, { open: true }),
9579
+ children: [
9580
+ /* @__PURE__ */ jsx6(UiSplitMergeIcon, {}),
9581
+ /* @__PURE__ */ jsx6("span", { children: "\u62C6\u5206\u63D0\u53D6" })
9582
+ ]
9583
+ }
9584
+ ),
9585
+ editorEnabled && features.cropBox && /* @__PURE__ */ jsxs6(
9586
+ "button",
9587
+ {
9588
+ type: "button",
9589
+ "data-testid": "pdf-sidebar-crop-mode-btn",
9590
+ className: "univer-pdf-mini-btn",
9591
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
9592
+ onClick: () => void commandService.executeCommand(SetPdfInteractionModeOperation.id, { mode: "crop" }),
9593
+ children: [
9594
+ /* @__PURE__ */ jsx6(UiCropIcon, {}),
9595
+ /* @__PURE__ */ jsx6("span", { children: "\u9875\u9762\u88C1\u5207" })
9596
+ ]
9597
+ }
9598
+ )
9599
+ ] }),
8759
9600
  editorEnabled && /* @__PURE__ */ jsxs6("div", { className: "univer-pdf-thumb-toolbar", style: { display: "flex", flexDirection: "column", gap: 5 }, children: [
8760
9601
  /* @__PURE__ */ jsxs6(
8761
9602
  "button",
@@ -8777,7 +9618,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8777
9618
  type: "button",
8778
9619
  className: "univer-pdf-mini-btn",
8779
9620
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8780
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9621
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8781
9622
  elementType: PdfElementType5.ELLIPSE
8782
9623
  }),
8783
9624
  children: [
@@ -8792,7 +9633,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8792
9633
  type: "button",
8793
9634
  className: "univer-pdf-mini-btn",
8794
9635
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8795
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9636
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8796
9637
  elementType: PdfElementType5.POLYGON
8797
9638
  }),
8798
9639
  children: [
@@ -8807,7 +9648,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8807
9648
  type: "button",
8808
9649
  className: "univer-pdf-mini-btn",
8809
9650
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8810
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9651
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8811
9652
  elementType: PdfElementType5.LINE
8812
9653
  }),
8813
9654
  children: [
@@ -8821,7 +9662,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8821
9662
  {
8822
9663
  type: "button",
8823
9664
  className: "univer-pdf-mini-btn",
8824
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9665
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8825
9666
  elementType: PdfElementType5.SVG
8826
9667
  }),
8827
9668
  children: "+ SVG \u77E2\u91CF"
@@ -8832,7 +9673,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8832
9673
  {
8833
9674
  type: "button",
8834
9675
  className: "univer-pdf-mini-btn",
8835
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9676
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8836
9677
  elementType: PdfElementType5.CHECKBOX
8837
9678
  }),
8838
9679
  children: "+ \u590D\u9009\u6846"
@@ -8843,7 +9684,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8843
9684
  {
8844
9685
  type: "button",
8845
9686
  className: "univer-pdf-mini-btn",
8846
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9687
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8847
9688
  elementType: PdfElementType5.RADIO_GROUP
8848
9689
  }),
8849
9690
  children: "+ \u5355\u9009\u7EC4"
@@ -8854,7 +9695,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8854
9695
  {
8855
9696
  type: "button",
8856
9697
  className: "univer-pdf-mini-btn",
8857
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9698
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8858
9699
  elementType: PdfElementType5.SELECT
8859
9700
  }),
8860
9701
  children: "+ \u4E0B\u62C9\u6846"
@@ -8866,7 +9707,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8866
9707
  type: "button",
8867
9708
  className: "univer-pdf-mini-btn",
8868
9709
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8869
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9710
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8870
9711
  elementType: PdfElementType5.CIRCLE_MARK
8871
9712
  }),
8872
9713
  children: [
@@ -8881,7 +9722,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8881
9722
  type: "button",
8882
9723
  className: "univer-pdf-mini-btn",
8883
9724
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8884
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9725
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8885
9726
  elementType: PdfElementType5.DATE_TIME
8886
9727
  }),
8887
9728
  children: [
@@ -8896,7 +9737,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8896
9737
  type: "button",
8897
9738
  className: "univer-pdf-mini-btn",
8898
9739
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8899
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9740
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8900
9741
  elementType: PdfElementType5.SIGNATURE
8901
9742
  }),
8902
9743
  children: [
@@ -8911,7 +9752,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8911
9752
  type: "button",
8912
9753
  className: "univer-pdf-mini-btn",
8913
9754
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4, gridColumn: "span 2" },
8914
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9755
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8915
9756
  elementType: PdfElementType5.ANNOTATION,
8916
9757
  element: {
8917
9758
  name: "\u9AD8\u4EAE/\u4E0B\u5212\u7EBF\u6279\u6CE8",
@@ -8933,7 +9774,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8933
9774
  type: "button",
8934
9775
  className: "univer-pdf-mini-btn",
8935
9776
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8936
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9777
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8937
9778
  elementType: PdfElementType5.ANNOTATION,
8938
9779
  element: {
8939
9780
  name: "\u5BA1\u9605\u4FBF\u7B7E",
@@ -8955,7 +9796,7 @@ var PdfLeftSidebar = ({ initialTab = "pages" }) => {
8955
9796
  type: "button",
8956
9797
  className: "univer-pdf-mini-btn",
8957
9798
  style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap: 4 },
8958
- onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand3.id, {
9799
+ onClick: () => commandService.syncExecuteCommand(AddPdfElementCommand4.id, {
8959
9800
  elementType: PdfElementType5.REDACTION,
8960
9801
  element: {
8961
9802
  name: "\u8131\u654F\u6D82\u9ED1",
@@ -11346,6 +12187,480 @@ var PdfPreviewModal = () => {
11346
12187
  ) });
11347
12188
  };
11348
12189
 
12190
+ // src/views/preview/PdfSplitExtractModal.tsx
12191
+ import { ICommandService as ICommandService8, IUniverInstanceService as IUniverInstanceService8, UniverInstanceType as UniverInstanceType8 } from "@univerjs/core";
12192
+ import { useDependency as useDependency7, useObservable as useObservable7 } from "@univerjs/ui";
12193
+ import {
12194
+ formatPdfPageIndicesLabel,
12195
+ IPdfIoService as IPdfIoService5,
12196
+ IPdfSelectionService as IPdfSelectionService8,
12197
+ parsePdfPageRangeSpec,
12198
+ ReplacePdfSnapshotCommand as ReplacePdfSnapshotCommand5,
12199
+ splitPdfBytesByRanges,
12200
+ splitPdfUnitByRanges
12201
+ } from "@yudaocode/univer-pdfs";
12202
+ import { useMemo as useMemo3, useState as useState7 } from "react";
12203
+ import { of as of6 } from "rxjs";
12204
+ import { Fragment as Fragment6, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
12205
+ function computePdfSplitPlanPreview(mode, rangeSpec, everyNPages, totalPages) {
12206
+ if (totalPages <= 0) {
12207
+ return { valid: false, error: "\u5F53\u524D\u6587\u6863\u6682\u65E0\u53EF\u62C6\u5206\u9875\u9762", fileCount: 0, items: [] };
12208
+ }
12209
+ try {
12210
+ const groups = mode === "everyN" ? parsePdfPageRangeSpec("", totalPages, {
12211
+ everyNPages: Math.max(1, Math.floor(Number(everyNPages) || 1))
12212
+ }) : parsePdfPageRangeSpec(rangeSpec, totalPages);
12213
+ if (groups.length === 0) {
12214
+ return { valid: false, error: "\u672A\u5339\u914D\u5230\u6709\u6548\u9875\u7801\u8303\u56F4", fileCount: 0, items: [] };
12215
+ }
12216
+ const items = groups.map((pageIndices, idx) => ({
12217
+ index: idx + 1,
12218
+ label: formatPdfPageIndicesLabel(pageIndices),
12219
+ pageCount: pageIndices.length,
12220
+ pageIndices
12221
+ }));
12222
+ return {
12223
+ valid: true,
12224
+ fileCount: items.length,
12225
+ items
12226
+ };
12227
+ } catch (err) {
12228
+ return {
12229
+ valid: false,
12230
+ error: err instanceof Error ? err.message : "\u9875\u7801\u533A\u95F4\u683C\u5F0F\u6709\u8BEF",
12231
+ fileCount: 0,
12232
+ items: []
12233
+ };
12234
+ }
12235
+ }
12236
+ function triggerBrowserFileDownload(bytes, fileName) {
12237
+ if (typeof document === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function") {
12238
+ return;
12239
+ }
12240
+ const blob = new Blob([bytes.slice().buffer], { type: "application/pdf" });
12241
+ const blobUrl = URL.createObjectURL(blob);
12242
+ const anchor = document.createElement("a");
12243
+ anchor.href = blobUrl;
12244
+ anchor.download = fileName;
12245
+ anchor.style.display = "none";
12246
+ document.body.appendChild(anchor);
12247
+ anchor.click();
12248
+ anchor.remove();
12249
+ setTimeout(() => URL.revokeObjectURL(blobUrl), 1e4);
12250
+ }
12251
+ var PdfSplitExtractModal = ({
12252
+ forceOpen,
12253
+ onClose
12254
+ }) => {
12255
+ const instanceService = useDependency7(IUniverInstanceService8);
12256
+ const commandService = useDependency7(ICommandService8);
12257
+ const selectionService = useDependency7(IPdfSelectionService8);
12258
+ const ioService = useDependency7(IPdfIoService5);
12259
+ const featureService = useDependency7(IPdfsUIFeatureService);
12260
+ const splitModalOpen = useObservable7(
12261
+ selectionService.splitModalOpen$,
12262
+ selectionService.getSplitModalOpen()
12263
+ );
12264
+ const editorEnabled = useObservable7(
12265
+ featureService.editorEnabled$,
12266
+ featureService.isEditorEnabled()
12267
+ );
12268
+ const unit = useObservable7(
12269
+ () => instanceService.getCurrentTypeOfUnit$(UniverInstanceType8.UNIVER_PDF),
12270
+ instanceService.getCurrentUnitOfType(UniverInstanceType8.UNIVER_PDF),
12271
+ false,
12272
+ [instanceService]
12273
+ );
12274
+ const snapshot = useObservable7(
12275
+ () => unit ? unit.snapshotChanged$ : of6(null),
12276
+ unit ? unit.getSnapshot() : null,
12277
+ false,
12278
+ [unit]
12279
+ );
12280
+ const [mode, setMode] = useState7("range");
12281
+ const [rangeSpec, setRangeSpec] = useState7("");
12282
+ const [everyN, setEveryN] = useState7(2);
12283
+ const [busy, setBusy] = useState7(false);
12284
+ const [statusMessage, setStatusMessage] = useState7("");
12285
+ const isOpen = forceOpen ?? splitModalOpen;
12286
+ const currentSnapshot = snapshot ?? unit?.getSnapshot() ?? null;
12287
+ const totalPages = currentSnapshot?.document.pageOrder.length ?? 0;
12288
+ const effectiveRangeSpec = rangeSpec || (totalPages >= 4 ? `1-2, 3-${totalPages}` : totalPages >= 2 ? `1, 2-${totalPages}` : "1");
12289
+ const preview = useMemo3(
12290
+ () => computePdfSplitPlanPreview(mode, effectiveRangeSpec, everyN, totalPages),
12291
+ [mode, effectiveRangeSpec, everyN, totalPages]
12292
+ );
12293
+ if (!isOpen || !currentSnapshot || !unit) {
12294
+ return null;
12295
+ }
12296
+ const handleClose = () => {
12297
+ setStatusMessage("");
12298
+ selectionService.setSplitModalOpen(false);
12299
+ onClose?.();
12300
+ };
12301
+ const handleExtractIntoWorkspace = () => {
12302
+ if (!preview.valid || preview.items.length === 0 || !editorEnabled) return;
12303
+ const mergedOneBased = preview.items.map((item) => item.label).join("+");
12304
+ const parts = splitPdfUnitByRanges(currentSnapshot, [mergedOneBased]);
12305
+ if (parts.length === 0) return;
12306
+ const extracted = {
12307
+ ...parts[0].unit,
12308
+ id: unit.getUnitId()
12309
+ };
12310
+ commandService.syncExecuteCommand(ReplacePdfSnapshotCommand5.id, {
12311
+ unitId: unit.getUnitId(),
12312
+ snapshot: extracted
12313
+ });
12314
+ handleClose();
12315
+ };
12316
+ const handleDownloadSplitFiles = async () => {
12317
+ if (!preview.valid || preview.items.length === 0) return;
12318
+ setBusy(true);
12319
+ setStatusMessage("");
12320
+ try {
12321
+ const fullPdfBytes = await ioService.exportPdf({
12322
+ unitId: unit.getUnitId(),
12323
+ snapshot: currentSnapshot,
12324
+ data: currentSnapshot.metadata?.sampleData
12325
+ });
12326
+ const splitParts = mode === "everyN" ? await splitPdfBytesByRanges(fullPdfBytes, [], {
12327
+ everyNPages: Math.max(1, Math.floor(Number(everyN) || 1))
12328
+ }) : await splitPdfBytesByRanges(fullPdfBytes, [effectiveRangeSpec]);
12329
+ const safeBaseName = (currentSnapshot.name || "document").replace(/[\\/:*?"<>|]+/g, "_").trim() || "document";
12330
+ for (const part of splitParts) {
12331
+ triggerBrowserFileDownload(part.bytes, `${safeBaseName}-P${part.label}.pdf`);
12332
+ }
12333
+ setStatusMessage(`\u5DF2\u751F\u6210\u5E76\u5BFC\u51FA ${splitParts.length} \u4E2A\u72EC\u7ACB PDF \u6587\u4EF6`);
12334
+ } catch (err) {
12335
+ setStatusMessage(err instanceof Error ? err.message : "\u62C6\u5206\u5BFC\u51FA PDF \u5931\u8D25");
12336
+ } finally {
12337
+ setBusy(false);
12338
+ }
12339
+ };
12340
+ return /* @__PURE__ */ jsx8(
12341
+ "div",
12342
+ {
12343
+ role: "dialog",
12344
+ "aria-modal": "true",
12345
+ "aria-label": "PDF \u9875\u9762\u62C6\u5206\u4E0E\u63D0\u53D6",
12346
+ "data-testid": "pdf-split-extract-modal",
12347
+ onPointerDown: (e) => {
12348
+ if (e.target === e.currentTarget) handleClose();
12349
+ },
12350
+ style: {
12351
+ position: "fixed",
12352
+ inset: 0,
12353
+ background: "rgba(27, 28, 31, 0.44)",
12354
+ display: "flex",
12355
+ alignItems: "center",
12356
+ justifyContent: "center",
12357
+ zIndex: 1250
12358
+ },
12359
+ children: /* @__PURE__ */ jsxs8(
12360
+ "div",
12361
+ {
12362
+ onPointerDown: (e) => e.stopPropagation(),
12363
+ style: {
12364
+ width: 520,
12365
+ maxWidth: "calc(100vw - 32px)",
12366
+ background: "#FFFFFF",
12367
+ border: "1px solid #E3E5EA",
12368
+ borderRadius: 8,
12369
+ boxShadow: "0 14px 36px rgba(27, 28, 31, 0.2)",
12370
+ padding: "16px 20px",
12371
+ display: "flex",
12372
+ flexDirection: "column",
12373
+ gap: 12,
12374
+ color: "#1B1C1F"
12375
+ },
12376
+ children: [
12377
+ /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
12378
+ /* @__PURE__ */ jsxs8("div", { style: { display: "inline-flex", alignItems: "center", gap: 7, fontSize: 14, fontWeight: 600 }, children: [
12379
+ /* @__PURE__ */ jsx8(UiSplitMergeIcon, { style: { color: "#2C53F1" } }),
12380
+ /* @__PURE__ */ jsxs8("span", { children: [
12381
+ "\u9875\u9762\u62C6\u5206\u4E0E\u63D0\u53D6 (",
12382
+ currentSnapshot.name,
12383
+ " \xB7 \u5171 ",
12384
+ totalPages,
12385
+ " \u9875)"
12386
+ ] })
12387
+ ] }),
12388
+ /* @__PURE__ */ jsx8(
12389
+ "button",
12390
+ {
12391
+ type: "button",
12392
+ className: "univer-pdf-mini-btn",
12393
+ onClick: handleClose,
12394
+ "aria-label": "\u5173\u95ED\u62C6\u5206\u7A97\u53E3",
12395
+ children: "\xD7"
12396
+ }
12397
+ )
12398
+ ] }),
12399
+ /* @__PURE__ */ jsxs8("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 8 }, children: [
12400
+ /* @__PURE__ */ jsx8(
12401
+ "button",
12402
+ {
12403
+ type: "button",
12404
+ "data-testid": "pdf-split-mode-range",
12405
+ onClick: () => setMode("range"),
12406
+ style: {
12407
+ padding: "8px 10px",
12408
+ borderRadius: 6,
12409
+ border: mode === "range" ? "1.5px solid #2C53F1" : "1px solid #E3E5EA",
12410
+ background: mode === "range" ? "#F3F5FF" : "#F9FAFB",
12411
+ color: mode === "range" ? "#2C53F1" : "#31363F",
12412
+ fontSize: 12,
12413
+ fontWeight: mode === "range" ? 600 : 500,
12414
+ cursor: "pointer",
12415
+ textAlign: "left"
12416
+ },
12417
+ children: "\u6309\u9875\u7801\u533A\u95F4\u62C6\u5206 (\u5982 1-2, 3-5)"
12418
+ }
12419
+ ),
12420
+ /* @__PURE__ */ jsx8(
12421
+ "button",
12422
+ {
12423
+ type: "button",
12424
+ "data-testid": "pdf-split-mode-everyn",
12425
+ onClick: () => setMode("everyN"),
12426
+ style: {
12427
+ padding: "8px 10px",
12428
+ borderRadius: 6,
12429
+ border: mode === "everyN" ? "1.5px solid #2C53F1" : "1px solid #E3E5EA",
12430
+ background: mode === "everyN" ? "#F3F5FF" : "#F9FAFB",
12431
+ color: mode === "everyN" ? "#2C53F1" : "#31363F",
12432
+ fontSize: 12,
12433
+ fontWeight: mode === "everyN" ? 600 : 500,
12434
+ cursor: "pointer",
12435
+ textAlign: "left"
12436
+ },
12437
+ children: "\u6BCF N \u9875\u62C6\u5206\u4E3A\u72EC\u7ACB\u6587\u4EF6"
12438
+ }
12439
+ )
12440
+ ] }),
12441
+ mode === "range" ? /* @__PURE__ */ jsxs8("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: [
12442
+ /* @__PURE__ */ jsxs8("label", { style: { fontSize: 11.5, color: "#4E5565", fontWeight: 500 }, children: [
12443
+ "\u8F93\u5165\u9875\u7801\u533A\u95F4\uFF08\u9017\u53F7\u5206\u9694\u591A\u4E2A\u72EC\u7ACB\u6587\u4EF6\uFF0C\u52A0\u53F7\u5408\u5E76\u975E\u8FDE\u7EED\u9875\uFF0C\u5982 ",
12444
+ /* @__PURE__ */ jsx8("code", { children: "1-2, 3-5" }),
12445
+ " \u6216 ",
12446
+ /* @__PURE__ */ jsx8("code", { children: "1+3, 2+4" }),
12447
+ "\uFF09"
12448
+ ] }),
12449
+ /* @__PURE__ */ jsx8(
12450
+ "input",
12451
+ {
12452
+ type: "text",
12453
+ "data-testid": "pdf-split-range-input",
12454
+ value: effectiveRangeSpec,
12455
+ placeholder: "\u4F8B\u5982 1-2, 3-5 \u6216 odd / even",
12456
+ onChange: (e) => setRangeSpec(e.target.value),
12457
+ style: {
12458
+ height: 32,
12459
+ padding: "0 10px",
12460
+ fontSize: 12.5,
12461
+ border: "1px solid #D5D8DF",
12462
+ borderRadius: 5,
12463
+ color: "#1B1C1F",
12464
+ background: "#FFFFFF"
12465
+ }
12466
+ }
12467
+ ),
12468
+ /* @__PURE__ */ jsxs8("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: [
12469
+ /* @__PURE__ */ jsx8(
12470
+ "button",
12471
+ {
12472
+ type: "button",
12473
+ className: "univer-pdf-mini-btn",
12474
+ onClick: () => setRangeSpec("single"),
12475
+ children: "\u9010\u9875\u5355\u4EFD\u62C6\u5206"
12476
+ }
12477
+ ),
12478
+ /* @__PURE__ */ jsx8(
12479
+ "button",
12480
+ {
12481
+ type: "button",
12482
+ className: "univer-pdf-mini-btn",
12483
+ onClick: () => setRangeSpec("odd"),
12484
+ children: "\u4EC5\u63D0\u53D6\u5947\u6570\u9875 (odd)"
12485
+ }
12486
+ ),
12487
+ /* @__PURE__ */ jsx8(
12488
+ "button",
12489
+ {
12490
+ type: "button",
12491
+ className: "univer-pdf-mini-btn",
12492
+ onClick: () => setRangeSpec("even"),
12493
+ children: "\u4EC5\u63D0\u53D6\u5076\u6570\u9875 (even)"
12494
+ }
12495
+ ),
12496
+ /* @__PURE__ */ jsx8(
12497
+ "button",
12498
+ {
12499
+ type: "button",
12500
+ className: "univer-pdf-mini-btn",
12501
+ onClick: () => setRangeSpec("all"),
12502
+ children: "\u5168\u90E8\u9875\u9762"
12503
+ }
12504
+ )
12505
+ ] })
12506
+ ] }) : /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
12507
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: 12, color: "#31363F" }, children: "\u6BCF" }),
12508
+ /* @__PURE__ */ jsx8(
12509
+ "input",
12510
+ {
12511
+ type: "number",
12512
+ "data-testid": "pdf-split-every-n-input",
12513
+ min: 1,
12514
+ max: Math.max(1, totalPages),
12515
+ value: everyN,
12516
+ onChange: (e) => setEveryN(Math.max(1, Number(e.target.value) || 1)),
12517
+ style: {
12518
+ width: 76,
12519
+ height: 30,
12520
+ padding: "0 8px",
12521
+ fontSize: 12.5,
12522
+ border: "1px solid #D5D8DF",
12523
+ borderRadius: 5,
12524
+ color: "#1B1C1F",
12525
+ background: "#FFFFFF"
12526
+ }
12527
+ }
12528
+ ),
12529
+ /* @__PURE__ */ jsx8("span", { style: { fontSize: 12, color: "#31363F" }, children: "\u9875\u81EA\u52A8\u62C6\u5206\u4E3A\u4E00\u4E2A\u72EC\u7ACB PDF \u6587\u4EF6" })
12530
+ ] }),
12531
+ /* @__PURE__ */ jsx8(
12532
+ "div",
12533
+ {
12534
+ "data-testid": "pdf-split-preview-summary",
12535
+ style: {
12536
+ padding: "10px 12px",
12537
+ background: "#F9FAFB",
12538
+ border: "1px solid #E3E5EA",
12539
+ borderRadius: 6,
12540
+ display: "flex",
12541
+ flexDirection: "column",
12542
+ gap: 6,
12543
+ maxHeight: 156,
12544
+ overflowY: "auto"
12545
+ },
12546
+ children: preview.valid ? /* @__PURE__ */ jsxs8(Fragment6, { children: [
12547
+ /* @__PURE__ */ jsxs8("div", { style: { fontSize: 12, fontWeight: 600, color: "#1B1C1F" }, children: [
12548
+ "\u9884\u8BA1\u751F\u6210 ",
12549
+ /* @__PURE__ */ jsx8("span", { style: { color: "#2C53F1" }, children: preview.fileCount }),
12550
+ " \u4E2A\u72EC\u7ACB PDF \u6587\u4EF6"
12551
+ ] }),
12552
+ /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 }, children: preview.items.map((item) => /* @__PURE__ */ jsxs8(
12553
+ "span",
12554
+ {
12555
+ style: {
12556
+ display: "inline-flex",
12557
+ alignItems: "center",
12558
+ gap: 4,
12559
+ padding: "3px 8px",
12560
+ borderRadius: 4,
12561
+ background: "#FFFFFF",
12562
+ border: "1px solid #D2DAFA",
12563
+ fontSize: 11,
12564
+ color: "#31363F"
12565
+ },
12566
+ children: [
12567
+ /* @__PURE__ */ jsx8(UiFilePdfIcon, { style: { width: 12, height: 12, color: "#2C53F1" } }),
12568
+ /* @__PURE__ */ jsxs8("span", { children: [
12569
+ "\u7B2C ",
12570
+ item.index,
12571
+ " \u4EFD \xB7 P",
12572
+ item.label,
12573
+ " (",
12574
+ item.pageCount,
12575
+ " \u9875)"
12576
+ ] })
12577
+ ]
12578
+ },
12579
+ item.index
12580
+ )) })
12581
+ ] }) : /* @__PURE__ */ jsx8("div", { style: { fontSize: 11.5, color: "#DC2626" }, children: preview.error })
12582
+ }
12583
+ ),
12584
+ statusMessage && /* @__PURE__ */ jsx8(
12585
+ "div",
12586
+ {
12587
+ style: {
12588
+ fontSize: 11.5,
12589
+ color: "#2C53F1",
12590
+ background: "#F3F5FF",
12591
+ padding: "5px 8px",
12592
+ borderRadius: 4
12593
+ },
12594
+ children: statusMessage
12595
+ }
12596
+ ),
12597
+ /* @__PURE__ */ jsxs8("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 }, children: [
12598
+ /* @__PURE__ */ jsx8(
12599
+ "button",
12600
+ {
12601
+ type: "button",
12602
+ className: "univer-pdf-mini-btn",
12603
+ style: { height: 32, padding: "0 14px", fontSize: 12 },
12604
+ onClick: handleClose,
12605
+ children: "\u53D6\u6D88"
12606
+ }
12607
+ ),
12608
+ /* @__PURE__ */ jsxs8("div", { style: { display: "inline-flex", alignItems: "center", gap: 8 }, children: [
12609
+ editorEnabled && /* @__PURE__ */ jsx8(
12610
+ "button",
12611
+ {
12612
+ type: "button",
12613
+ "data-testid": "pdf-split-extract-workspace-btn",
12614
+ className: "univer-pdf-mini-btn",
12615
+ disabled: !preview.valid || busy,
12616
+ onClick: handleExtractIntoWorkspace,
12617
+ style: {
12618
+ height: 32,
12619
+ padding: "0 12px",
12620
+ fontSize: 12,
12621
+ borderColor: "#2C53F1",
12622
+ color: "#2C53F1",
12623
+ background: "#F3F5FF"
12624
+ },
12625
+ children: "\u63D0\u53D6\u81F3\u5F53\u524D\u5DE5\u4F5C\u533A"
12626
+ }
12627
+ ),
12628
+ /* @__PURE__ */ jsxs8(
12629
+ "button",
12630
+ {
12631
+ type: "button",
12632
+ "data-testid": "pdf-split-download-btn",
12633
+ disabled: !preview.valid || busy,
12634
+ onClick: handleDownloadSplitFiles,
12635
+ style: {
12636
+ height: 32,
12637
+ padding: "0 14px",
12638
+ fontSize: 12,
12639
+ fontWeight: 600,
12640
+ color: "#FFFFFF",
12641
+ background: preview.valid && !busy ? "#2C53F1" : "#7D8698",
12642
+ border: "none",
12643
+ borderRadius: 5,
12644
+ cursor: preview.valid && !busy ? "pointer" : "not-allowed",
12645
+ display: "inline-flex",
12646
+ alignItems: "center",
12647
+ gap: 5
12648
+ },
12649
+ children: [
12650
+ /* @__PURE__ */ jsx8(UiDownloadIcon, { style: { width: 13, height: 13, color: "#FFFFFF" } }),
12651
+ /* @__PURE__ */ jsx8("span", { children: busy ? "\u6B63\u5728\u62C6\u5206\u5BFC\u51FA..." : "\u4E0B\u8F7D\u62C6\u5206 PDF \u6587\u4EF6" })
12652
+ ]
12653
+ }
12654
+ )
12655
+ ] })
12656
+ ] })
12657
+ ]
12658
+ }
12659
+ )
12660
+ }
12661
+ );
12662
+ };
12663
+
11349
12664
  // src/controllers/menu.schema.ts
11350
12665
  import {
11351
12666
  MenuItemType,
@@ -11355,13 +12670,13 @@ import {
11355
12670
  RibbonViewGroup
11356
12671
  } from "@univerjs/ui";
11357
12672
  import {
11358
- AddPdfElementCommand as AddPdfElementCommand4,
12673
+ AddPdfElementCommand as AddPdfElementCommand5,
11359
12674
  AddPdfPageCommand as AddPdfPageCommand2,
11360
12675
  AlignSelectedPdfElementsCommand as AlignSelectedPdfElementsCommand2,
11361
12676
  DeleteSelectedPdfElementsCommand as DeleteSelectedPdfElementsCommand3,
11362
12677
  DistributeSelectedPdfElementsCommand as DistributeSelectedPdfElementsCommand2,
11363
12678
  DuplicateSelectedPdfElementsCommand as DuplicateSelectedPdfElementsCommand3,
11364
- IPdfSelectionService as IPdfSelectionService8,
12679
+ IPdfSelectionService as IPdfSelectionService9,
11365
12680
  PdfElementType as PdfElementType6
11366
12681
  } from "@yudaocode/univer-pdfs";
11367
12682
  import { combineLatest, map } from "rxjs";
@@ -11410,7 +12725,7 @@ function createBtn(config) {
11410
12725
  };
11411
12726
  }
11412
12727
  var SelectModeMenuFactory = (accessor) => {
11413
- const sel = accessor.get(IPdfSelectionService8);
12728
+ const sel = accessor.get(IPdfSelectionService9);
11414
12729
  return {
11415
12730
  id: "pdfs-ui.menu.mode-select",
11416
12731
  commandId: SetPdfInteractionModeOperation.id,
@@ -11423,7 +12738,7 @@ var SelectModeMenuFactory = (accessor) => {
11423
12738
  };
11424
12739
  };
11425
12740
  var PanModeMenuFactory = (accessor) => {
11426
- const sel = accessor.get(IPdfSelectionService8);
12741
+ const sel = accessor.get(IPdfSelectionService9);
11427
12742
  return {
11428
12743
  id: "pdfs-ui.menu.mode-pan",
11429
12744
  commandId: SetPdfInteractionModeOperation.id,
@@ -11436,7 +12751,7 @@ var PanModeMenuFactory = (accessor) => {
11436
12751
  };
11437
12752
  };
11438
12753
  var InkModeMenuFactory = (accessor) => {
11439
- const sel = accessor.get(IPdfSelectionService8);
12754
+ const sel = accessor.get(IPdfSelectionService9);
11440
12755
  const featService = accessor.get(IPdfsUIFeatureService);
11441
12756
  return {
11442
12757
  id: "pdfs-ui.menu.mode-ink",
@@ -11455,7 +12770,7 @@ var InkModeMenuFactory = (accessor) => {
11455
12770
  };
11456
12771
  var InsertPdfTextMenuFactory = createBtn({
11457
12772
  id: "pdfs-ui.menu.insert-text",
11458
- commandId: AddPdfElementCommand4.id,
12773
+ commandId: AddPdfElementCommand5.id,
11459
12774
  title: "pdfs.ribbon.insertText",
11460
12775
  label: "pdfs.ribbon.insertText",
11461
12776
  icon: "PdfTextIcon",
@@ -11465,7 +12780,7 @@ var InsertPdfTextMenuFactory = createBtn({
11465
12780
  });
11466
12781
  var InsertPdfTextCompactMenuFactory = createBtn({
11467
12782
  id: "pdfs-ui.menu.start-insert-text",
11468
- commandId: AddPdfElementCommand4.id,
12783
+ commandId: AddPdfElementCommand5.id,
11469
12784
  title: "pdfs.ribbon.insertText",
11470
12785
  icon: "PdfTextIcon",
11471
12786
  params: { elementType: PdfElementType6.TEXT },
@@ -11484,7 +12799,7 @@ var InsertPdfParagraphMenuFactory = createBtn({
11484
12799
  });
11485
12800
  var InsertPdfListMenuFactory = createBtn({
11486
12801
  id: "pdfs-ui.menu.insert-list",
11487
- commandId: AddPdfElementCommand4.id,
12802
+ commandId: AddPdfElementCommand5.id,
11488
12803
  title: "pdfs.ribbon.insertList",
11489
12804
  label: "pdfs.ribbon.insertList",
11490
12805
  icon: "PdfListIcon",
@@ -11504,7 +12819,7 @@ var InsertPdfDividerMenuFactory = createBtn({
11504
12819
  });
11505
12820
  var InsertPdfImageMenuFactory = createBtn({
11506
12821
  id: "pdfs-ui.menu.insert-image",
11507
- commandId: AddPdfElementCommand4.id,
12822
+ commandId: AddPdfElementCommand5.id,
11508
12823
  title: "pdfs.ribbon.insertImage",
11509
12824
  icon: "PdfImageIcon",
11510
12825
  params: { elementType: PdfElementType6.IMAGE },
@@ -11513,7 +12828,7 @@ var InsertPdfImageMenuFactory = createBtn({
11513
12828
  });
11514
12829
  var InsertPdfTableMenuFactory = createBtn({
11515
12830
  id: "pdfs-ui.menu.insert-table",
11516
- commandId: AddPdfElementCommand4.id,
12831
+ commandId: AddPdfElementCommand5.id,
11517
12832
  title: "pdfs.ribbon.insertTable",
11518
12833
  icon: "PdfTableIcon",
11519
12834
  params: { elementType: PdfElementType6.TABLE },
@@ -11523,7 +12838,7 @@ var InsertPdfTableMenuFactory = createBtn({
11523
12838
  });
11524
12839
  var InsertPdfQrCodeMenuFactory = createBtn({
11525
12840
  id: "pdfs-ui.menu.insert-qrcode",
11526
- commandId: AddPdfElementCommand4.id,
12841
+ commandId: AddPdfElementCommand5.id,
11527
12842
  title: "pdfs.ribbon.insertQrCode",
11528
12843
  icon: "PdfQrCodeIcon",
11529
12844
  params: { elementType: PdfElementType6.QRCODE },
@@ -11533,7 +12848,7 @@ var InsertPdfQrCodeMenuFactory = createBtn({
11533
12848
  });
11534
12849
  var InsertPdfBarcodeMenuFactory = createBtn({
11535
12850
  id: "pdfs-ui.menu.insert-barcode",
11536
- commandId: AddPdfElementCommand4.id,
12851
+ commandId: AddPdfElementCommand5.id,
11537
12852
  title: "pdfs.ribbon.insertBarcode",
11538
12853
  icon: "PdfBarcodeIcon",
11539
12854
  params: { elementType: PdfElementType6.BARCODE },
@@ -11543,7 +12858,7 @@ var InsertPdfBarcodeMenuFactory = createBtn({
11543
12858
  });
11544
12859
  var InsertPdfShapeMenuFactory = createBtn({
11545
12860
  id: "pdfs-ui.menu.insert-shape",
11546
- commandId: AddPdfElementCommand4.id,
12861
+ commandId: AddPdfElementCommand5.id,
11547
12862
  title: "pdfs.ribbon.insertShape",
11548
12863
  icon: "PdfShapeIcon",
11549
12864
  params: { elementType: PdfElementType6.SHAPE },
@@ -11552,7 +12867,7 @@ var InsertPdfShapeMenuFactory = createBtn({
11552
12867
  });
11553
12868
  var InsertPdfStampMenuFactory = createBtn({
11554
12869
  id: "pdfs-ui.menu.insert-stamp",
11555
- commandId: AddPdfElementCommand4.id,
12870
+ commandId: AddPdfElementCommand5.id,
11556
12871
  title: "pdfs.ribbon.insertStamp",
11557
12872
  icon: "PdfStampIcon",
11558
12873
  params: { elementType: PdfElementType6.STAMP },
@@ -11599,7 +12914,7 @@ var InsertStrikeMarkMenuFactory = createBtn({
11599
12914
  });
11600
12915
  var InsertAnnotateStampMenuFactory = createBtn({
11601
12916
  id: "pdfs-ui.menu.annotate-stamp",
11602
- commandId: AddPdfElementCommand4.id,
12917
+ commandId: AddPdfElementCommand5.id,
11603
12918
  title: "pdfs.ribbon.insertStamp",
11604
12919
  label: "pdfs.ribbon.insertStamp",
11605
12920
  icon: "PdfStampIcon",
@@ -11648,7 +12963,7 @@ var DistributeHMenuFactory = createBtn({
11648
12963
  requiresEditor: true
11649
12964
  });
11650
12965
  var DuplicateElementMenuFactory = (accessor) => {
11651
- const sel = accessor.get(IPdfSelectionService8);
12966
+ const sel = accessor.get(IPdfSelectionService9);
11652
12967
  const featService = accessor.get(IPdfsUIFeatureService);
11653
12968
  return {
11654
12969
  id: DuplicateSelectedPdfElementsCommand3.id,
@@ -11661,7 +12976,7 @@ var DuplicateElementMenuFactory = (accessor) => {
11661
12976
  };
11662
12977
  };
11663
12978
  var DeleteElementMenuFactory = (accessor) => {
11664
- const sel = accessor.get(IPdfSelectionService8);
12979
+ const sel = accessor.get(IPdfSelectionService9);
11665
12980
  const featService = accessor.get(IPdfsUIFeatureService);
11666
12981
  return {
11667
12982
  id: DeleteSelectedPdfElementsCommand3.id,
@@ -11699,7 +13014,7 @@ var ToggleInspectorMenuFactory = createBtn({
11699
13014
  requiresEditor: true
11700
13015
  });
11701
13016
  var ToggleFindReplaceMenuFactory = (accessor) => {
11702
- const sel = accessor.get(IPdfSelectionService8);
13017
+ const sel = accessor.get(IPdfSelectionService9);
11703
13018
  const featService = accessor.get(IPdfsUIFeatureService);
11704
13019
  return {
11705
13020
  id: TogglePdfFindReplaceOperation.id,
@@ -11712,6 +13027,30 @@ var ToggleFindReplaceMenuFactory = (accessor) => {
11712
13027
  hidden$: featService.features$.pipe(map((f) => !f.findReplace))
11713
13028
  };
11714
13029
  };
13030
+ var OpenPdfSplitModalMenuFactory = createBtn({
13031
+ id: OpenPdfSplitModalOperation.id,
13032
+ title: "pdfs.ribbon.splitExtract",
13033
+ label: "pdfs.ribbon.splitExtract",
13034
+ icon: "PdfSplitExtractIcon"
13035
+ });
13036
+ var CropModeMenuFactory = (accessor) => {
13037
+ const sel = accessor.get(IPdfSelectionService9);
13038
+ const featService = accessor.get(IPdfsUIFeatureService);
13039
+ return {
13040
+ id: "pdfs-ui.menu.mode-crop",
13041
+ commandId: SetPdfInteractionModeOperation.id,
13042
+ type: MenuItemType.BUTTON,
13043
+ title: "pdfs.ribbon.cropPage",
13044
+ label: "pdfs.ribbon.cropPage",
13045
+ tooltip: "pdfs.ribbon.cropPage",
13046
+ icon: "PdfCropPageIcon",
13047
+ params: { mode: "crop" },
13048
+ activated$: sel.interactionMode$.pipe(map((m) => m === "crop")),
13049
+ hidden$: combineLatest([featService.features$, featService.editorEnabled$]).pipe(
13050
+ map(([f, editorEnabled]) => !editorEnabled || !f.cropBox)
13051
+ )
13052
+ };
13053
+ };
11715
13054
  var OpenPdfPreviewMenuFactory = createBtn({
11716
13055
  id: OpenPdfPreviewOperation.id,
11717
13056
  title: "pdfs.ribbon.previewPdf",
@@ -11725,7 +13064,7 @@ var PrintPdfMenuFactory = createBtn({
11725
13064
  hiddenWhen: (f) => !f.print
11726
13065
  });
11727
13066
  var ToggleRulerMenuFactory = (accessor) => {
11728
- const sel = accessor.get(IPdfSelectionService8);
13067
+ const sel = accessor.get(IPdfSelectionService9);
11729
13068
  return {
11730
13069
  id: TogglePdfRulerOperation.id,
11731
13070
  type: MenuItemType.BUTTON,
@@ -11736,7 +13075,7 @@ var ToggleRulerMenuFactory = (accessor) => {
11736
13075
  };
11737
13076
  };
11738
13077
  var ToggleGridMenuFactory = (accessor) => {
11739
- const sel = accessor.get(IPdfSelectionService8);
13078
+ const sel = accessor.get(IPdfSelectionService9);
11740
13079
  return {
11741
13080
  id: TogglePdfGridOperation.id,
11742
13081
  type: MenuItemType.BUTTON,
@@ -11747,7 +13086,7 @@ var ToggleGridMenuFactory = (accessor) => {
11747
13086
  };
11748
13087
  };
11749
13088
  var ToggleMarginsMenuFactory = (accessor) => {
11750
- const sel = accessor.get(IPdfSelectionService8);
13089
+ const sel = accessor.get(IPdfSelectionService9);
11751
13090
  return {
11752
13091
  id: TogglePdfMarginsOperation.id,
11753
13092
  type: MenuItemType.BUTTON,
@@ -11758,7 +13097,7 @@ var ToggleMarginsMenuFactory = (accessor) => {
11758
13097
  };
11759
13098
  };
11760
13099
  var ToggleSnapMenuFactory = (accessor) => {
11761
- const sel = accessor.get(IPdfSelectionService8);
13100
+ const sel = accessor.get(IPdfSelectionService9);
11762
13101
  return {
11763
13102
  id: TogglePdfSnapOperation.id,
11764
13103
  type: MenuItemType.BUTTON,
@@ -11805,6 +13144,7 @@ var pdfsMenuSchema = {
11805
13144
  ["pdfs-ui.menu.open-json"]: { order: 2, menuItemFactory: OpenJsonExchangeMenuFactory },
11806
13145
  [TogglePdfInspectorOperation.id]: { order: 3, menuItemFactory: ToggleInspectorMenuFactory },
11807
13146
  [TogglePdfFindReplaceOperation.id]: { order: 3.5, menuItemFactory: ToggleFindReplaceMenuFactory },
13147
+ [OpenPdfSplitModalOperation.id]: { order: 3.8, menuItemFactory: OpenPdfSplitModalMenuFactory },
11808
13148
  [OpenPdfPreviewOperation.id]: { order: 4, menuItemFactory: OpenPdfPreviewMenuFactory },
11809
13149
  [PrintPdfOperation.id]: { order: 5, menuItemFactory: PrintPdfMenuFactory }
11810
13150
  },
@@ -11820,7 +13160,7 @@ var pdfsMenuSchema = {
11820
13160
  order: 1,
11821
13161
  menuItemFactory: createBtn({
11822
13162
  id: "pdfs-ui.menu.insert-image-2",
11823
- commandId: AddPdfElementCommand4.id,
13163
+ commandId: AddPdfElementCommand5.id,
11824
13164
  title: "pdfs.ribbon.insertImage",
11825
13165
  icon: "PdfImageIcon",
11826
13166
  params: { elementType: PdfElementType6.IMAGE },
@@ -11832,7 +13172,7 @@ var pdfsMenuSchema = {
11832
13172
  order: 1.5,
11833
13173
  menuItemFactory: createBtn({
11834
13174
  id: "pdfs-ui.menu.insert-static-table",
11835
- commandId: AddPdfElementCommand4.id,
13175
+ commandId: AddPdfElementCommand5.id,
11836
13176
  title: "pdfs.ribbon.insertStaticTable",
11837
13177
  icon: "PdfTableIcon",
11838
13178
  params: {
@@ -11848,7 +13188,7 @@ var pdfsMenuSchema = {
11848
13188
  order: 2,
11849
13189
  menuItemFactory: createBtn({
11850
13190
  id: "pdfs-ui.menu.insert-table-2",
11851
- commandId: AddPdfElementCommand4.id,
13191
+ commandId: AddPdfElementCommand5.id,
11852
13192
  title: "pdfs.ribbon.insertTable",
11853
13193
  icon: "PdfTableIcon",
11854
13194
  params: { elementType: PdfElementType6.TABLE },
@@ -11861,7 +13201,7 @@ var pdfsMenuSchema = {
11861
13201
  order: 3,
11862
13202
  menuItemFactory: createBtn({
11863
13203
  id: "pdfs-ui.menu.insert-qrcode-2",
11864
- commandId: AddPdfElementCommand4.id,
13204
+ commandId: AddPdfElementCommand5.id,
11865
13205
  title: "pdfs.ribbon.insertQrCode",
11866
13206
  icon: "PdfQrCodeIcon",
11867
13207
  params: { elementType: PdfElementType6.QRCODE },
@@ -11874,7 +13214,7 @@ var pdfsMenuSchema = {
11874
13214
  order: 4,
11875
13215
  menuItemFactory: createBtn({
11876
13216
  id: "pdfs-ui.menu.insert-barcode-2",
11877
- commandId: AddPdfElementCommand4.id,
13217
+ commandId: AddPdfElementCommand5.id,
11878
13218
  title: "pdfs.ribbon.insertBarcode",
11879
13219
  icon: "PdfBarcodeIcon",
11880
13220
  params: { elementType: PdfElementType6.BARCODE },
@@ -11888,7 +13228,7 @@ var pdfsMenuSchema = {
11888
13228
  order: 6,
11889
13229
  menuItemFactory: createBtn({
11890
13230
  id: "pdfs-ui.menu.insert-stamp-2",
11891
- commandId: AddPdfElementCommand4.id,
13231
+ commandId: AddPdfElementCommand5.id,
11892
13232
  title: "pdfs.ribbon.insertStamp",
11893
13233
  icon: "PdfStampIcon",
11894
13234
  params: { elementType: PdfElementType6.STAMP },
@@ -11909,6 +13249,7 @@ var pdfsMenuSchema = {
11909
13249
  [TogglePdfGridOperation.id]: { order: 2, menuItemFactory: ToggleGridMenuFactory },
11910
13250
  [TogglePdfMarginsOperation.id]: { order: 3, menuItemFactory: ToggleMarginsMenuFactory },
11911
13251
  [TogglePdfSnapOperation.id]: { order: 4, menuItemFactory: ToggleSnapMenuFactory },
13252
+ ["pdfs-ui.menu.mode-crop"]: { order: 4.5, menuItemFactory: CropModeMenuFactory },
11912
13253
  [SwitchPdfDisplayUnitOperation.id]: { order: 5, menuItemFactory: SwitchUnitMenuFactory },
11913
13254
  ["pdfs-ui.menu.zoom-reset"]: { order: 6, menuItemFactory: ZoomResetMenuFactory }
11914
13255
  }
@@ -11962,6 +13303,7 @@ var PdfsUIController = class extends Disposable2 {
11962
13303
  TogglePdfInspectorOperation,
11963
13304
  TogglePdfFindReplaceOperation,
11964
13305
  OpenPdfPreviewOperation,
13306
+ OpenPdfSplitModalOperation,
11965
13307
  UploadBasePdfOperation,
11966
13308
  SavePdfToHostOperation,
11967
13309
  PrintPdfOperation,
@@ -11999,10 +13341,13 @@ var PdfsUIController = class extends Disposable2 {
11999
13341
  this.disposeWithMe(
12000
13342
  this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => PdfPreviewModal)
12001
13343
  );
13344
+ this.disposeWithMe(
13345
+ this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => PdfSplitExtractModal)
13346
+ );
12002
13347
  }
12003
13348
  };
12004
13349
  PdfsUIController = __decorateClass([
12005
- __decorateParam(1, ICommandService8),
13350
+ __decorateParam(1, ICommandService9),
12006
13351
  __decorateParam(2, IMenuManagerService),
12007
13352
  __decorateParam(3, IUIPartsService),
12008
13353
  __decorateParam(4, ISidebarService3),
@@ -12011,9 +13356,9 @@ PdfsUIController = __decorateClass([
12011
13356
  ], PdfsUIController);
12012
13357
 
12013
13358
  // src/plugin.ts
12014
- import { DependentOn, Inject as Inject2, Injector, LocaleService as LocaleService3, LocaleType, Plugin, UniverInstanceType as UniverInstanceType8 } from "@univerjs/core";
13359
+ import { DependentOn, Inject as Inject2, Injector, LocaleService as LocaleService3, LocaleType, Plugin, UniverInstanceType as UniverInstanceType9 } from "@univerjs/core";
12015
13360
  import { UniverRenderEnginePlugin } from "@univerjs/engine-render";
12016
- import { IPdfIoService as IPdfIoService5, UniverPdfsPlugin } from "@yudaocode/univer-pdfs";
13361
+ import { IPdfIoService as IPdfIoService6, UniverPdfsPlugin } from "@yudaocode/univer-pdfs";
12017
13362
  var UNIVER_PDFS_UI_PLUGIN_NAME = "UNIVER_PDFS_UI_PLUGIN";
12018
13363
  var UniverPdfsUIPlugin = class extends Plugin {
12019
13364
  constructor(_config = {}, _injector) {
@@ -12028,7 +13373,7 @@ var UniverPdfsUIPlugin = class extends Plugin {
12028
13373
  [LocaleType.EN_US]: en_US_default
12029
13374
  });
12030
13375
  }
12031
- const coreAssets = this._injector.has(IPdfIoService5) ? this._injector.get(IPdfIoService5).getPdfjsAssets() : void 0;
13376
+ const coreAssets = this._injector.has(IPdfIoService6) ? this._injector.get(IPdfIoService6).getPdfjsAssets() : void 0;
12032
13377
  const mergedAssets = this._config.pdfjsAssets ?? coreAssets;
12033
13378
  if (mergedAssets) {
12034
13379
  configurePdfjsAssets(mergedAssets);
@@ -12051,7 +13396,7 @@ var UniverPdfsUIPlugin = class extends Plugin {
12051
13396
  };
12052
13397
  UniverPdfsUIPlugin.pluginName = UNIVER_PDFS_UI_PLUGIN_NAME;
12053
13398
  UniverPdfsUIPlugin.packageName = "@yudaocode/univer-pdfs-ui";
12054
- UniverPdfsUIPlugin.type = UniverInstanceType8.UNIVER_PDF;
13399
+ UniverPdfsUIPlugin.type = UniverInstanceType9.UNIVER_PDF;
12055
13400
  UniverPdfsUIPlugin = __decorateClass([
12056
13401
  DependentOn(UniverRenderEnginePlugin, UniverPdfsPlugin),
12057
13402
  __decorateParam(1, Inject2(Injector))
@@ -12062,6 +13407,7 @@ export {
12062
13407
  IPdfsUIFeatureService,
12063
13408
  InsertPdfPresetElementOperation,
12064
13409
  OpenPdfPreviewOperation,
13410
+ OpenPdfSplitModalOperation,
12065
13411
  PDF_INSPECTOR_COMPONENT_KEY,
12066
13412
  PDF_INSPECTOR_SIDEBAR_ID,
12067
13413
  PdfCanvasView,
@@ -12070,6 +13416,7 @@ export {
12070
13416
  PdfInspectorPanel as PdfInspectorSidebar,
12071
13417
  PdfLeftSidebar,
12072
13418
  PdfPreviewModal,
13419
+ PdfSplitExtractModal,
12073
13420
  PdfStatusBar,
12074
13421
  PdfUnifiedIoSection,
12075
13422
  PdfsUIController,
@@ -12099,6 +13446,7 @@ export {
12099
13446
  clearPdfDocumentCache,
12100
13447
  collectPdfFindMatches,
12101
13448
  computePdfDocumentCacheKey,
13449
+ computePdfSplitPlanPreview,
12102
13450
  configurePdfjsAssets,
12103
13451
  countBookmarkTreeItems,
12104
13452
  deleteBookmarkFromTree,