@embedpdf/viewer-chrome 3.0.0-next.13 → 3.0.0-next.15

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.
Files changed (157) hide show
  1. package/README.md +175 -132
  2. package/dist/annotation-fonts-BqoLZ4Mp.js +80 -0
  3. package/dist/annotation-fonts-BqoLZ4Mp.js.map +1 -0
  4. package/dist/annotation-fonts-Dt0IQXhz.cjs +91 -0
  5. package/dist/annotation-fonts-Dt0IQXhz.cjs.map +1 -0
  6. package/dist/annotation-style--rPIZsuP.js +879 -0
  7. package/dist/annotation-style--rPIZsuP.js.map +1 -0
  8. package/dist/annotation-style-Bzvvp8-N.cjs +879 -0
  9. package/dist/annotation-style-Bzvvp8-N.cjs.map +1 -0
  10. package/dist/ar-D9XKAmDx.js +567 -0
  11. package/dist/ar-D9XKAmDx.js.map +1 -0
  12. package/dist/ar-DnEj5vbP.cjs +567 -0
  13. package/dist/ar-DnEj5vbP.cjs.map +1 -0
  14. package/dist/chrome.cjs +378 -221
  15. package/dist/chrome.cjs.map +1 -1
  16. package/dist/chrome.d.cts +5 -34
  17. package/dist/chrome.d.ts +5 -34
  18. package/dist/chrome.js +377 -218
  19. package/dist/chrome.js.map +1 -1
  20. package/dist/commands-BmgxhJ8B.js +953 -0
  21. package/dist/commands-BmgxhJ8B.js.map +1 -0
  22. package/dist/commands-CYt4SFUX.cjs +1060 -0
  23. package/dist/commands-CYt4SFUX.cjs.map +1 -0
  24. package/dist/commands.cjs +12 -595
  25. package/dist/commands.d.cts +29 -4
  26. package/dist/commands.d.ts +29 -4
  27. package/dist/commands.js +2 -593
  28. package/dist/comments-panel-MUVgLCBI.js +514 -0
  29. package/dist/comments-panel-MUVgLCBI.js.map +1 -0
  30. package/dist/comments-panel-pEcQg4Vs.cjs +514 -0
  31. package/dist/comments-panel-pEcQg4Vs.cjs.map +1 -0
  32. package/dist/de-Bdr4aWzm.js +566 -0
  33. package/dist/de-Bdr4aWzm.js.map +1 -0
  34. package/dist/de-Dv6zvbnd.cjs +566 -0
  35. package/dist/de-Dv6zvbnd.cjs.map +1 -0
  36. package/dist/dialog-B5GBisKv.js +55 -0
  37. package/dist/dialog-B5GBisKv.js.map +1 -0
  38. package/dist/dialog-t8F13BL_.cjs +60 -0
  39. package/dist/dialog-t8F13BL_.cjs.map +1 -0
  40. package/dist/es-BP09DR9w.cjs +566 -0
  41. package/dist/es-BP09DR9w.cjs.map +1 -0
  42. package/dist/es-BSXz5tBv.js +566 -0
  43. package/dist/es-BSXz5tBv.js.map +1 -0
  44. package/dist/form-design-panel-B5MXTZ96.cjs +418 -0
  45. package/dist/form-design-panel-B5MXTZ96.cjs.map +1 -0
  46. package/dist/form-design-panel-vWWU9uB-.js +418 -0
  47. package/dist/form-design-panel-vWWU9uB-.js.map +1 -0
  48. package/dist/fr-BBQQn7tJ.cjs +566 -0
  49. package/dist/fr-BBQQn7tJ.cjs.map +1 -0
  50. package/dist/fr-Ckn3K9v1.js +566 -0
  51. package/dist/fr-Ckn3K9v1.js.map +1 -0
  52. package/dist/he-DRsG7bH7.cjs +567 -0
  53. package/dist/he-DRsG7bH7.cjs.map +1 -0
  54. package/dist/he-wdGU5PkU.js +567 -0
  55. package/dist/he-wdGU5PkU.js.map +1 -0
  56. package/dist/icons-BrK5iVL8.js +856 -0
  57. package/dist/icons-BrK5iVL8.js.map +1 -0
  58. package/dist/icons-x0Tc05bs.cjs +1010 -0
  59. package/dist/icons-x0Tc05bs.cjs.map +1 -0
  60. package/dist/index.cjs +3162 -5106
  61. package/dist/index.cjs.map +1 -1
  62. package/dist/index.d.cts +636 -143
  63. package/dist/index.d.ts +636 -143
  64. package/dist/index.js +3083 -4975
  65. package/dist/index.js.map +1 -1
  66. package/dist/it-BuP4o0xQ.cjs +566 -0
  67. package/dist/it-BuP4o0xQ.cjs.map +1 -0
  68. package/dist/it-Us-VmvIu.js +566 -0
  69. package/dist/it-Us-VmvIu.js.map +1 -0
  70. package/dist/ja-Cizj0-5O.js +566 -0
  71. package/dist/ja-Cizj0-5O.js.map +1 -0
  72. package/dist/ja-DovEd6ts.cjs +566 -0
  73. package/dist/ja-DovEd6ts.cjs.map +1 -0
  74. package/dist/ko-B-qJEol2.cjs +566 -0
  75. package/dist/ko-B-qJEol2.cjs.map +1 -0
  76. package/dist/ko-DlrXliE1.js +566 -0
  77. package/dist/ko-DlrXliE1.js.map +1 -0
  78. package/dist/labels-BiM9wp9K.cjs +21 -0
  79. package/dist/labels-BiM9wp9K.cjs.map +1 -0
  80. package/dist/labels-C6_i87Oj.js +16 -0
  81. package/dist/labels-C6_i87Oj.js.map +1 -0
  82. package/dist/link-editor-CSjqPnj1.cjs +125 -0
  83. package/dist/link-editor-CSjqPnj1.cjs.map +1 -0
  84. package/dist/link-editor-SxM1nnJU.js +125 -0
  85. package/dist/link-editor-SxM1nnJU.js.map +1 -0
  86. package/dist/measurement-Bs61XWbJ.js +325 -0
  87. package/dist/measurement-Bs61XWbJ.js.map +1 -0
  88. package/dist/measurement-CcCsHPOX.cjs +326 -0
  89. package/dist/measurement-CcCsHPOX.cjs.map +1 -0
  90. package/dist/nl-0aF7M_0h.js +566 -0
  91. package/dist/nl-0aF7M_0h.js.map +1 -0
  92. package/dist/nl-D3KZDDiJ.cjs +566 -0
  93. package/dist/nl-D3KZDDiJ.cjs.map +1 -0
  94. package/dist/pl-BW--AaCI.js +566 -0
  95. package/dist/pl-BW--AaCI.js.map +1 -0
  96. package/dist/pl-DSFhAUqx.cjs +566 -0
  97. package/dist/pl-DSFhAUqx.cjs.map +1 -0
  98. package/dist/pt-C5S-8MC5.cjs +566 -0
  99. package/dist/pt-C5S-8MC5.cjs.map +1 -0
  100. package/dist/pt-DIhpU5pT.js +566 -0
  101. package/dist/pt-DIhpU5pT.js.map +1 -0
  102. package/dist/redact-confirm-B6j36TPw.js +83 -0
  103. package/dist/redact-confirm-B6j36TPw.js.map +1 -0
  104. package/dist/redact-confirm-CX_SY2ZN.cjs +83 -0
  105. package/dist/redact-confirm-CX_SY2ZN.cjs.map +1 -0
  106. package/dist/redaction-panel-BmoIl-Ll.cjs +96 -0
  107. package/dist/redaction-panel-BmoIl-Ll.cjs.map +1 -0
  108. package/dist/redaction-panel-IJDshSJI.js +96 -0
  109. package/dist/redaction-panel-IJDshSJI.js.map +1 -0
  110. package/dist/search-panel-HfIhJm1M.js +249 -0
  111. package/dist/search-panel-HfIhJm1M.js.map +1 -0
  112. package/dist/search-panel-s9IoiOtv.cjs +249 -0
  113. package/dist/search-panel-s9IoiOtv.cjs.map +1 -0
  114. package/dist/sheet-BDsa_Sup.cjs +442 -0
  115. package/dist/sheet-BDsa_Sup.cjs.map +1 -0
  116. package/dist/sheet-R6XDgyEf.js +365 -0
  117. package/dist/sheet-R6XDgyEf.js.map +1 -0
  118. package/dist/sign-dialog-CgnR7akj.cjs +155 -0
  119. package/dist/sign-dialog-CgnR7akj.cjs.map +1 -0
  120. package/dist/sign-dialog-GDqCoQhA.js +155 -0
  121. package/dist/sign-dialog-GDqCoQhA.js.map +1 -0
  122. package/dist/signature-inspector-DyO313Qf.cjs +166 -0
  123. package/dist/signature-inspector-DyO313Qf.cjs.map +1 -0
  124. package/dist/signature-inspector-okFz8do6.js +166 -0
  125. package/dist/signature-inspector-okFz8do6.js.map +1 -0
  126. package/dist/signature-maker-BhCmYyHD.js +393 -0
  127. package/dist/signature-maker-BhCmYyHD.js.map +1 -0
  128. package/dist/signature-maker-BoYa8vgA.cjs +393 -0
  129. package/dist/signature-maker-BoYa8vgA.cjs.map +1 -0
  130. package/dist/signatures-panel-B56PC6d9.cjs +300 -0
  131. package/dist/signatures-panel-B56PC6d9.cjs.map +1 -0
  132. package/dist/signatures-panel-CgnFfhFm.js +300 -0
  133. package/dist/signatures-panel-CgnFfhFm.js.map +1 -0
  134. package/dist/stamp-store-BHvRs-Do.cjs +147 -0
  135. package/dist/stamp-store-BHvRs-Do.cjs.map +1 -0
  136. package/dist/stamp-store-WuF-L3Jj.js +112 -0
  137. package/dist/stamp-store-WuF-L3Jj.js.map +1 -0
  138. package/dist/stamps-panel-B9NYGayn.cjs +231 -0
  139. package/dist/stamps-panel-B9NYGayn.cjs.map +1 -0
  140. package/dist/stamps-panel-CDO0FPyK.js +231 -0
  141. package/dist/stamps-panel-CDO0FPyK.js.map +1 -0
  142. package/dist/toolbar-CJu2wKTU.cjs +1659 -0
  143. package/dist/toolbar-CJu2wKTU.cjs.map +1 -0
  144. package/dist/toolbar-z9od3tKl.js +1564 -0
  145. package/dist/toolbar-z9od3tKl.js.map +1 -0
  146. package/dist/zh-cn-3tmMeHqv.cjs +566 -0
  147. package/dist/zh-cn-3tmMeHqv.cjs.map +1 -0
  148. package/dist/zh-cn-CxkUUBct.js +566 -0
  149. package/dist/zh-cn-CxkUUBct.js.map +1 -0
  150. package/package.json +6 -4
  151. package/src/styles.css +153 -89
  152. package/dist/commands.cjs.map +0 -1
  153. package/dist/commands.js.map +0 -1
  154. package/dist/es-DYwzfxyt.cjs +0 -293
  155. package/dist/es-DYwzfxyt.cjs.map +0 -1
  156. package/dist/es-sN6uqBgD.js +0 -293
  157. package/dist/es-sN6uqBgD.js.map +0 -1
@@ -1,13 +1,32 @@
1
+ import { AnnotationToolInput } from "@embedpdf/react/annotation";
1
2
  import { CommandDef } from "@embedpdf/react/commands";
2
3
  //#region src/config/commands.d.ts
4
+ type Ctx = Parameters<NonNullable<CommandDef['run']>>[0];
5
+ /** The dialog the Go to Page command opens without a page to go to (ui/go-to-page.tsx). */
6
+ declare const GO_TO_PAGE_DIALOG = "go-to-page";
7
+ /** The keyboard shortcuts sheet, which `?` opens (ui/shortcuts-sheet.tsx). */
8
+ declare const SHORTCUTS_DIALOG = "shortcuts";
9
+ /** The confirmation before marked areas are removed for good (ui/redact-confirm.tsx). */
10
+ declare const REDACT_CONFIRM_DIALOG = "redact-confirm";
11
+ /** The form designer's sidebar (ui/form-design-panel.tsx), which `form:design` opens. */
12
+ declare const FORM_DESIGN_PANEL = "form-design";
13
+ /** Form design's resting tool, the form plugin's: widgets select, move and resize there. */
14
+ declare const FORM_DESIGN_TOOL = "form-edit";
15
+ /**
16
+ * Whether a tool designs a form: design's resting tool, or a field tool. Neither fills, so the
17
+ * form lends its widgets to be selected, moved and resized.
18
+ */
19
+ declare const isFormDesignTool: (tool: string | null | undefined) => boolean;
20
+ /** Whether a form is being designed: the active tool designs it. */
21
+ declare const isDesigningForm: (commandContext: Pick<Ctx, "tryGet">) => boolean;
3
22
  type ColorKey = 'color' | 'interiorColor' | 'fontColor';
4
23
  interface ToolAccentDefinition {
5
24
  primary: ColorKey;
6
25
  secondary?: ColorKey;
7
26
  }
8
27
  /**
9
- * toolId → the SAME icon + accent definition its toolbar button uses, recorded
10
- * as a side effect of the `tool()` command definitions below — ONE source of
28
+ * toolId → the same icon + accent definition its toolbar button uses, recorded
29
+ * as a side effect of the `tool()` command definitions below — one source of
11
30
  * truth, so the tool cursor (ui/tool-cursor.tsx) and the button can never
12
31
  * drift apart.
13
32
  */
@@ -16,7 +35,13 @@ declare const TOOL_ICONS: Record<string, {
16
35
  accent?: ToolAccentDefinition;
17
36
  }>;
18
37
  declare const defaultCommands: CommandDef[];
19
- declare const MODE_SURFACES: readonly ["mode:annotate", "mode:shapes", "mode:insert", "mode:form", "mode:redact"];
38
+ declare const MODE_SURFACES: readonly ["mode:annotate", "mode:shapes", "mode:insert", "mode:form", "mode:redact", "mode:measure"];
39
+ /**
40
+ * A `tool:<id>` command for each tool of yours (`plugins.annotation.tools`) that no command has
41
+ * (`isTaken` says which ids do): labelled by its `meta.label`, else its id; drawn with its
42
+ * `meta.icon`, else the icon of the tool it extends; in that tool's feature, else `annotations`.
43
+ */
44
+ declare function toolCommandsFor(tools: readonly AnnotationToolInput[], isTaken: (id: string) => boolean): CommandDef[];
20
45
  //#endregion
21
- export { MODE_SURFACES, TOOL_ICONS, ToolAccentDefinition, defaultCommands };
46
+ export { FORM_DESIGN_PANEL, FORM_DESIGN_TOOL, GO_TO_PAGE_DIALOG, MODE_SURFACES, REDACT_CONFIRM_DIALOG, SHORTCUTS_DIALOG, TOOL_ICONS, ToolAccentDefinition, defaultCommands, isDesigningForm, isFormDesignTool, toolCommandsFor };
22
47
  //# sourceMappingURL=commands.d.ts.map
package/dist/commands.js CHANGED
@@ -1,593 +1,2 @@
1
- import { DocumentsToken } from "@embedpdf/react/runtime";
2
- import { StageToken, ZoomMode } from "@embedpdf/react/stage";
3
- import { InteractionToken } from "@embedpdf/react/interaction";
4
- import { SelectionToken, copySelection } from "@embedpdf/react/selection";
5
- import { AnnotationToken } from "@embedpdf/react/annotation";
6
- import { StampToken } from "@embedpdf/react/stamp";
7
- import { RedactionToken } from "@embedpdf/react/redaction";
8
- import { ActionsToken } from "@embedpdf/react/actions";
9
- import { FormToken, fieldKeyOf } from "@embedpdf/react/form";
10
- import { SignatureToken } from "@embedpdf/react/signature";
11
- import { LinkToken, openLinkTarget } from "@embedpdf/react/link";
12
- import { SearchToken } from "@embedpdf/react/search";
13
- import { I18nToken } from "@embedpdf/react/i18n";
14
- import { ShellToken } from "@embedpdf/react/shell";
15
- //#region src/config/commands.ts
16
- /** Where selection-made stamps go: the user's own library, persisted. */
17
- const CUSTOM_LIBRARY_ID = "embedpdf-custom";
18
- const stage = (c) => c.tryGet(StageToken);
19
- const interaction = (c) => c.tryGet(InteractionToken);
20
- const anno = (c) => c.tryGet(AnnotationToken);
21
- const textSelection = (c) => c.tryGet(SelectionToken);
22
- const sameTextRange = (a, b) => a === b || !!a && !!b && a.start.pon === b.start.pon && a.start.index === b.start.index && a.end.pon === b.end.pon && a.end.index === b.end.index;
23
- const hasAnnotationSelection = (c) => (anno(c)?.selection().length ?? 0) > 0;
24
- /** v2 gated strip items per subtype (comment hidden on links/widgets) — here
25
- * it's one derivation over the selected DTOs instead of per-command lookups. */
26
- const selectionSubtypes = (c) => new Set((anno(c)?.getSelected() ?? []).map((a) => a.subtype));
27
- /**
28
- * The selection's `link` value: a target, `null` (linkable but none set), or
29
- * `undefined` when the selection cannot carry a link at all (widgets, mixed
30
- * link states) — the schema decides, never a subtype blocklist.
31
- */
32
- const selectionLink = (c) => {
33
- const p = anno(c)?.getSelectionProps();
34
- if (!p || !p.specs.some((s) => s.key === "link") || p.mixed.includes("link")) return void 0;
35
- return p.values.link ?? null;
36
- };
37
- /**
38
- * toolId → the SAME icon + accent definition its toolbar button uses, recorded
39
- * as a side effect of the `tool()` command definitions below — ONE source of
40
- * truth, so the tool cursor (ui/tool-cursor.tsx) and the button can never
41
- * drift apart.
42
- */
43
- const TOOL_ICONS = {};
44
- TOOL_ICONS["stamp"] = { icon: "rubberStamp" };
45
- const toolAccent = (c, toolId, accent) => {
46
- if (!accent) return null;
47
- const anno = c.tryGet(AnnotationToken);
48
- if (!anno) return null;
49
- const d = anno.currentDefaults(toolId);
50
- return {
51
- primary: d[accent.primary] ?? void 0,
52
- secondary: accent.secondary ? d[accent.secondary] ?? void 0 : void 0
53
- };
54
- };
55
- /** A tool command: activates a real interaction tool; active = it's the tool.
56
- * The icon previews the tool's current defaults — keyed by the SAME toolId
57
- * as run/active, so the accent can't drift to another tool's colors. */
58
- const tool = (id, toolId, labelKey, icon, accent) => {
59
- TOOL_ICONS[toolId] = {
60
- icon,
61
- ...accent ? { accent } : {}
62
- };
63
- const authority = id.startsWith("annotation:add") || id.startsWith("insert:add") ? (c) => anno(c)?.canCreate() ?? true : id.startsWith("form:add") ? (c) => c.tryGet(FormToken)?.canDesign() ?? true : id === "redaction:redact" ? (c) => c.tryGet(RedactionToken)?.canMark() ?? true : null;
64
- return {
65
- id,
66
- labelKey,
67
- icon,
68
- categories: ["tool"],
69
- run: (c) => interaction(c)?.activateTool(toolId),
70
- active: (c) => interaction(c)?.activeToolId() === toolId,
71
- enabled: (c) => interaction(c) != null && (authority?.(c) ?? true),
72
- iconAccent: (c) => toolAccent(c, toolId, accent)
73
- };
74
- };
75
- /** A fixed zoom level (fraction), e.g. 1 = 100%. */
76
- const zoomLevel = (id, level, label) => ({
77
- id,
78
- labelKey: label,
79
- categories: ["zoom", "zoom-level"],
80
- run: (c) => stage(c)?.zoomTo({ level }),
81
- enabled: (c) => stage(c) != null
82
- });
83
- const spread = (id, mode, labelKey, icon) => ({
84
- id,
85
- labelKey,
86
- icon,
87
- categories: ["page", "spread"],
88
- run: (c) => stage(c)?.setSpread(mode),
89
- active: (c) => stage(c)?.spread() === mode,
90
- enabled: (c) => stage(c) != null
91
- });
92
- const defaultCommands = [
93
- {
94
- id: "zoom:in",
95
- labelKey: "commands.zoom.in",
96
- icon: "zoomIn",
97
- shortcut: ["Mod+=", "Mod+NumpadAdd"],
98
- categories: ["zoom"],
99
- run: (c) => stage(c)?.zoomIn(),
100
- enabled: (c) => stage(c) != null
101
- },
102
- {
103
- id: "zoom:out",
104
- labelKey: "commands.zoom.out",
105
- icon: "zoomOut",
106
- shortcut: ["Mod+-", "Mod+NumpadSubtract"],
107
- categories: ["zoom"],
108
- run: (c) => stage(c)?.zoomOut(),
109
- enabled: (c) => stage(c) != null
110
- },
111
- {
112
- id: "zoom:fit-page",
113
- labelKey: "commands.zoom.fitPage",
114
- icon: "fitToPage",
115
- shortcut: "Mod+0",
116
- categories: ["zoom"],
117
- run: (c) => stage(c)?.fitPage(),
118
- active: (c) => stage(c)?.zoomMode() === ZoomMode.FitPage,
119
- enabled: (c) => stage(c) != null
120
- },
121
- {
122
- id: "zoom:fit-width",
123
- labelKey: "commands.zoom.fitWidth",
124
- icon: "fitToWidth",
125
- shortcut: "Mod+1",
126
- categories: ["zoom"],
127
- run: (c) => stage(c)?.fitWidth(),
128
- active: (c) => stage(c)?.zoomMode() === ZoomMode.FitWidth,
129
- enabled: (c) => stage(c) != null
130
- },
131
- {
132
- id: "zoom:automatic",
133
- labelKey: "commands.zoom.automatic",
134
- categories: ["zoom"],
135
- run: (c) => stage(c)?.automatic(),
136
- active: (c) => stage(c)?.zoomMode() === ZoomMode.Automatic,
137
- enabled: (c) => stage(c) != null
138
- },
139
- zoomLevel("zoom:50", .5, "commands.zoom.p50"),
140
- zoomLevel("zoom:100", 1, "commands.zoom.p100"),
141
- zoomLevel("zoom:150", 1.5, "commands.zoom.p150"),
142
- zoomLevel("zoom:200", 2, "commands.zoom.p200"),
143
- zoomLevel("zoom:400", 4, "commands.zoom.p400"),
144
- {
145
- id: "zoom:menu",
146
- labelKey: "commands.zoom.menu",
147
- icon: "zoomIn",
148
- categories: ["zoom"],
149
- menu: "zoom"
150
- },
151
- {
152
- id: "pan:toggle",
153
- labelKey: "commands.pan",
154
- icon: "hand",
155
- categories: ["tools"],
156
- run: (c) => interaction(c)?.activateTool("pan"),
157
- active: (c) => interaction(c)?.activeToolId() === "pan",
158
- enabled: (c) => interaction(c) != null
159
- },
160
- {
161
- id: "pointer:toggle",
162
- labelKey: "commands.pointer",
163
- icon: "pointer",
164
- categories: ["tools"],
165
- run: (c) => interaction(c)?.activateTool("pointer"),
166
- active: (c) => interaction(c)?.activeToolId() === "pointer",
167
- enabled: (c) => interaction(c) != null
168
- },
169
- {
170
- id: "panel:sidebar",
171
- labelKey: "commands.sidebar",
172
- icon: "sidebar",
173
- categories: ["panel"],
174
- panel: {
175
- id: "sidebar",
176
- exclusive: "left"
177
- }
178
- },
179
- {
180
- id: "panel:search",
181
- labelKey: "commands.search",
182
- icon: "search",
183
- visible: (c) => c.tryGet(SearchToken)?.canSearch() ?? true,
184
- categories: ["panel"],
185
- panel: {
186
- id: "search",
187
- exclusive: "right"
188
- }
189
- },
190
- {
191
- id: "panel:comment",
192
- labelKey: "commands.comment",
193
- icon: "comment",
194
- visible: (c) => anno(c)?.canRead() ?? true,
195
- categories: ["panel"],
196
- panel: {
197
- id: "comment",
198
- exclusive: "right"
199
- }
200
- },
201
- {
202
- id: "panel:annotation-style",
203
- labelKey: "commands.style",
204
- icon: "palette",
205
- categories: ["panel"],
206
- panel: {
207
- id: "annotation-style",
208
- exclusive: "right"
209
- }
210
- },
211
- {
212
- id: "document:menu",
213
- labelKey: "commands.menu",
214
- icon: "menu",
215
- categories: ["document"],
216
- menu: "document"
217
- },
218
- {
219
- id: "page:settings",
220
- labelKey: "commands.viewControls",
221
- icon: "viewSettings",
222
- categories: ["page"],
223
- menu: "page-settings"
224
- },
225
- {
226
- id: "document:download",
227
- labelKey: "commands.download",
228
- icon: "download",
229
- categories: ["document"],
230
- run: (c) => {
231
- const id = c.documentId ?? void 0;
232
- const documents = c.tryGet(DocumentsToken);
233
- if (!documents) return;
234
- const pull = () => documents.download(id);
235
- const actions = c.tryGet(ActionsToken);
236
- (actions ? actions.runDocumentVerb("save", pull) : pull()).then((bytes) => {
237
- const blob = new Blob([bytes], { type: "application/pdf" });
238
- const url = URL.createObjectURL(blob);
239
- const a = document.createElement("a");
240
- a.href = url;
241
- a.download = "document.pdf";
242
- a.click();
243
- URL.revokeObjectURL(url);
244
- }).catch((e) => console.warn("[snippet-react] download failed", e));
245
- },
246
- enabled: (c) => c.documentId != null && (c.tryGet(DocumentsToken)?.allows("doc.download") ?? false)
247
- },
248
- {
249
- id: "document:print",
250
- labelKey: "commands.print",
251
- icon: "print",
252
- shortcut: "Mod+p",
253
- categories: ["document"],
254
- run: (c) => {
255
- const actions = c.documentId != null ? c.tryGet(ActionsToken) : null;
256
- if (actions) actions.runDocumentVerb("print", () => window.print());
257
- else window.print();
258
- },
259
- enabled: (c) => c.documentId == null || (c.tryGet(DocumentsToken)?.allows("doc.print") ?? true)
260
- },
261
- {
262
- id: "document:fullscreen",
263
- labelKey: "commands.fullscreen",
264
- icon: "externalLink",
265
- categories: ["document"],
266
- run: () => {
267
- if (document.fullscreenElement) document.exitFullscreen();
268
- else document.documentElement.requestFullscreen().catch(() => {});
269
- },
270
- active: () => Boolean(document.fullscreenElement)
271
- },
272
- spread("spread:none", "none", "commands.spread.none", "singlePage"),
273
- spread("spread:odd", "odd", "commands.spread.odd", "doublePage"),
274
- spread("spread:even", "even", "commands.spread.even", "book2"),
275
- {
276
- id: "scroll:vertical",
277
- labelKey: "commands.scroll.vertical",
278
- icon: "vertical",
279
- categories: ["page", "scroll"],
280
- run: (c) => stage(c)?.setLayout("vertical"),
281
- active: (c) => stage(c)?.layout() === "vertical",
282
- enabled: (c) => stage(c) != null
283
- },
284
- {
285
- id: "scroll:horizontal",
286
- labelKey: "commands.scroll.horizontal",
287
- icon: "horizontal",
288
- categories: ["page", "scroll"],
289
- run: (c) => stage(c)?.setLayout("horizontal"),
290
- active: (c) => stage(c)?.layout() === "horizontal",
291
- enabled: (c) => stage(c) != null
292
- },
293
- {
294
- id: "rotate:clockwise",
295
- labelKey: "commands.rotate.clockwise",
296
- icon: "rotateClockwise",
297
- categories: ["page", "rotate"],
298
- run: (c) => stage(c)?.rotateView(90),
299
- enabled: (c) => stage(c) != null
300
- },
301
- {
302
- id: "rotate:counter-clockwise",
303
- labelKey: "commands.rotate.counterclockwise",
304
- icon: "rotateCounterClockwise",
305
- categories: ["page", "rotate"],
306
- run: (c) => stage(c)?.rotateView(-90),
307
- enabled: (c) => stage(c) != null
308
- },
309
- {
310
- id: "mode:view",
311
- labelKey: "commands.mode.view",
312
- categories: ["mode"],
313
- run: (c) => {
314
- const shell = c.tryGet(ShellToken);
315
- for (const m of MODE_SURFACES) shell?.close(m);
316
- interaction(c)?.activateTool("pointer");
317
- },
318
- active: (c) => {
319
- const shell = c.tryGet(ShellToken);
320
- return shell ? MODE_SURFACES.every((m) => !shell.isOpen(m)) : true;
321
- }
322
- },
323
- modeCommand("mode:annotate", "commands.mode.annotate"),
324
- modeCommand("mode:shapes", "commands.mode.shapes"),
325
- modeCommand("mode:insert", "commands.mode.insert"),
326
- modeCommand("mode:form", "commands.mode.form", "form-edit"),
327
- modeCommand("mode:redact", "commands.mode.redact"),
328
- tool("annotation:add-highlight", "highlight", "commands.annotate.highlight", "highlight", { primary: "color" }),
329
- tool("annotation:add-strikeout", "strikeout", "commands.annotate.strikeout", "strikethrough", { primary: "color" }),
330
- tool("annotation:add-underline", "underline", "commands.annotate.underline", "underline", { primary: "color" }),
331
- tool("annotation:add-squiggly", "squiggly", "commands.annotate.squiggly", "squiggly", { primary: "color" }),
332
- tool("annotation:add-ink", "ink", "commands.annotate.ink", "pencilMarker", { primary: "color" }),
333
- tool("annotation:add-ink-highlight", "ink-highlight", "commands.annotate.inkHighlight", "inkHighlighter", { primary: "color" }),
334
- tool("annotation:add-text", "free-text", "commands.annotate.text", "freeText", { primary: "fontColor" }),
335
- tool("annotation:add-insert-text", "insert-text", "commands.annotate.insertText", "insertText", { primary: "color" }),
336
- tool("annotation:add-replace-text", "replace-text", "commands.annotate.replaceText", "replaceText", { primary: "color" }),
337
- tool("annotation:add-callout", "free-text-callout", "commands.annotate.callout", "callout", {
338
- primary: "color",
339
- secondary: "interiorColor"
340
- }),
341
- tool("annotation:add-note", "note", "commands.annotate.note", "message"),
342
- tool("annotation:add-link", "link", "commands.annotate.link", "link"),
343
- tool("annotation:add-rectangle", "square", "commands.shapes.rectangle", "square", {
344
- primary: "color",
345
- secondary: "interiorColor"
346
- }),
347
- tool("annotation:add-circle", "circle", "commands.shapes.circle", "circle", {
348
- primary: "color",
349
- secondary: "interiorColor"
350
- }),
351
- tool("annotation:add-line", "line", "commands.shapes.line", "line", { primary: "color" }),
352
- tool("annotation:add-arrow", "arrow", "commands.shapes.arrow", "lineArrow", { primary: "color" }),
353
- tool("annotation:add-polygon", "polygon", "commands.shapes.polygon", "polygon", {
354
- primary: "color",
355
- secondary: "interiorColor"
356
- }),
357
- tool("annotation:add-polyline", "polyline", "commands.shapes.polyline", "zigzag", { primary: "color" }),
358
- {
359
- id: "insert:add-stamp",
360
- labelKey: "commands.insert.stamp",
361
- icon: "rubberStamp",
362
- visible: (c) => c.tryGet(StampToken) != null,
363
- enabled: (c) => anno(c)?.canCreate() ?? true,
364
- categories: ["panel"],
365
- panel: {
366
- id: "stamps",
367
- exclusive: "right"
368
- }
369
- },
370
- tool("insert:add-attachment", "attachment", "commands.insert.attachment", "paperclip"),
371
- {
372
- id: "insert:add-signature",
373
- labelKey: "commands.insert.signature",
374
- icon: "signature",
375
- visible: (c) => c.tryGet(StampToken) != null && c.tryGet(SignatureToken) != null,
376
- enabled: (c) => anno(c)?.canCreate() ?? true,
377
- categories: ["panel"],
378
- panel: {
379
- id: "signatures",
380
- exclusive: "right"
381
- }
382
- },
383
- tool("insert:add-image", "image", "commands.insert.image", "photo"),
384
- tool("form:add-textfield", "form-text", "commands.form.textfield", "formTextfield"),
385
- tool("form:add-checkbox", "form-checkbox", "commands.form.checkbox", "formCheckbox"),
386
- tool("form:add-radio", "form-radio", "commands.form.radio", "formRadio"),
387
- tool("form:add-select", "form-combobox", "commands.form.select", "formSelect"),
388
- tool("form:add-listbox", "form-listbox", "commands.form.listbox", "formListbox"),
389
- tool("form:add-signature", "form-signature", "commands.form.signature", "signature"),
390
- tool("redaction:redact", "redact", "commands.redact.mark", "redactArea"),
391
- {
392
- id: "panel:redaction",
393
- labelKey: "commands.redact.panel",
394
- icon: "redactionSidebar",
395
- visible: (c) => {
396
- const r = c.tryGet(RedactionToken);
397
- return r ? r.canMark() || r.canApply() : true;
398
- },
399
- categories: ["panel"],
400
- panel: {
401
- id: "redaction",
402
- exclusive: "right"
403
- }
404
- },
405
- {
406
- id: "annotation:delete",
407
- labelKey: "commands.annotate.delete",
408
- icon: "trash",
409
- categories: ["annotation"],
410
- run: (c) => {
411
- const a = anno(c);
412
- if (!a) return;
413
- const form = c.tryGet(FormToken);
414
- const dtos = a.getSelected();
415
- const widgets = form ? dtos.filter((d) => d.subtype === "widget") : [];
416
- if (widgets.length === 0) {
417
- a.deleteSelection();
418
- return;
419
- }
420
- const keys = /* @__PURE__ */ new Set();
421
- for (const w of widgets) {
422
- const objnum = w.ref.kind === "objectNumber" ? w.ref.annotObjectNumber : 0;
423
- const field = objnum > 0 ? form.fieldForWidget(objnum) : null;
424
- if (field) keys.add(fieldKeyOf(field));
425
- }
426
- for (const key of keys) form.deleteField(key);
427
- for (const d of dtos) if (d.subtype !== "widget") a.delete(d.ref);
428
- a.deselect();
429
- },
430
- visible: hasAnnotationSelection,
431
- enabled: (c) => {
432
- const a = anno(c);
433
- const refs = a?.getSelection() ?? [];
434
- return refs.length > 0 && refs.every((r) => a.canDelete(r));
435
- }
436
- },
437
- {
438
- id: "annotation:comment",
439
- labelKey: "commands.comment",
440
- icon: "comment",
441
- categories: ["annotation"],
442
- panel: {
443
- id: "comment",
444
- exclusive: "right"
445
- },
446
- visible: (c) => hasAnnotationSelection(c) && !selectionSubtypes(c).has("widget")
447
- },
448
- {
449
- id: "annotation:style",
450
- labelKey: "commands.style",
451
- icon: "palette",
452
- categories: ["annotation"],
453
- panel: {
454
- id: "annotation-style",
455
- exclusive: "right"
456
- },
457
- visible: (c) => (anno(c)?.getSelectionProps().specs.length ?? 0) > 0
458
- },
459
- {
460
- id: "annotation:stamp-from-selection",
461
- labelKey: "commands.annotate.stampFromSelection",
462
- icon: "rubberStampPlus",
463
- categories: ["annotation"],
464
- run: (c) => {
465
- const a = anno(c);
466
- const stamp = c.tryGet(StampToken);
467
- const documentId = c.documentId;
468
- if (!a || !stamp || documentId == null) return;
469
- const dtos = a.getSelected();
470
- const pon = dtos[0]?.ref.pageObjectNumber;
471
- if (pon === void 0) return;
472
- const i18n = c.tryGet(I18nToken);
473
- const label = i18n?.t("demo.stampsCustomLabel") ?? "Custom stamp";
474
- const libraryName = i18n?.t("demo.stampsCustomLibrary") ?? "My stamps";
475
- const libraryId = CUSTOM_LIBRARY_ID;
476
- (stamp.library(libraryId) ? Promise.resolve(libraryId) : stamp.createLibrary(libraryName, {
477
- id: libraryId,
478
- categories: ["custom"]
479
- })).then((id) => stamp.addAssetFromAnnotations(documentId, pon, dtos.map((d) => d.ref), {
480
- libraryId: id,
481
- label: `${label} ${stamp.assets(id).length + 1}`
482
- })).then(() => c.tryGet(ShellToken)?.open("stamps", {
483
- exclusive: "right",
484
- props: { libraryId }
485
- })).catch((e) => console.warn("[embedpdf] stamp from selection failed", e));
486
- },
487
- visible: (c) => c.tryGet(StampToken) != null && hasAnnotationSelection(c) && !selectionSubtypes(c).has("widget") && !selectionSubtypes(c).has("redact") && new Set((anno(c)?.getSelected() ?? []).map((d) => d.ref.pageObjectNumber)).size === 1,
488
- enabled: (c) => c.tryGet(DocumentsToken)?.allows("doc.download") ?? true
489
- },
490
- {
491
- id: "annotation:group",
492
- labelKey: "commands.annotate.group",
493
- icon: "group",
494
- categories: ["annotation"],
495
- run: (c) => void anno(c)?.group(),
496
- visible: (c) => anno(c)?.canGroup() ?? false
497
- },
498
- {
499
- id: "annotation:ungroup",
500
- labelKey: "commands.annotate.ungroup",
501
- icon: "ungroup",
502
- categories: ["annotation"],
503
- run: (c) => void anno(c)?.ungroup(),
504
- visible: (c) => anno(c)?.canUngroup() ?? false
505
- },
506
- {
507
- id: "selection:copy",
508
- labelKey: "commands.selection.copy",
509
- icon: "copy",
510
- categories: ["selection"],
511
- visible: (c) => {
512
- const s = textSelection(c);
513
- return !!s && s.hasSelection() && s.canCopy();
514
- },
515
- run: (c) => {
516
- const s = textSelection(c);
517
- if (!s) return;
518
- const copiedRange = s.snapshot().range;
519
- copySelection(s).then((text) => {
520
- if (text !== "" && sameTextRange(s.snapshot().range, copiedRange)) s.clear();
521
- }, () => {});
522
- }
523
- },
524
- {
525
- id: "annotation:link",
526
- labelKey: "commands.annotate.link",
527
- icon: "link",
528
- categories: ["annotation"],
529
- run: (c) => c.tryGet(ShellToken)?.toggle("link-editor"),
530
- active: (c) => c.tryGet(ShellToken)?.isOpen("link-editor") ?? false,
531
- visible: (c) => selectionLink(c) === null
532
- },
533
- {
534
- id: "annotation:goto-link",
535
- labelKey: "commands.annotate.gotoLink",
536
- icon: "externalLink",
537
- categories: ["annotation"],
538
- run: (c) => {
539
- const target = selectionLink(c);
540
- const link = c.tryGet(LinkToken);
541
- if (target && link) openLinkTarget(link, target);
542
- },
543
- visible: (c) => selectionLink(c) != null
544
- },
545
- {
546
- id: "annotation:remove-link",
547
- labelKey: "commands.annotate.removeLink",
548
- icon: "linkOff",
549
- categories: ["annotation"],
550
- run: (c) => anno(c)?.updateSelection({ link: null }),
551
- visible: (c) => selectionLink(c) != null
552
- },
553
- {
554
- id: "history:undo",
555
- labelKey: "commands.undo",
556
- icon: "arrowBackUp",
557
- categories: ["history"],
558
- run: () => {},
559
- enabled: () => false
560
- },
561
- {
562
- id: "history:redo",
563
- labelKey: "commands.redo",
564
- icon: "arrowForwardUp",
565
- categories: ["history"],
566
- run: () => {},
567
- enabled: () => false
568
- }
569
- ];
570
- const MODE_SURFACES = [
571
- "mode:annotate",
572
- "mode:shapes",
573
- "mode:insert",
574
- "mode:form",
575
- "mode:redact"
576
- ];
577
- function modeCommand(id, labelKey, toolId = "pointer") {
578
- return {
579
- id,
580
- labelKey,
581
- categories: ["mode"],
582
- run: (c) => {
583
- const shell = c.tryGet(ShellToken);
584
- shell?.toggle(id, { exclusive: "mode" });
585
- interaction(c)?.activateTool(shell?.isOpen(id) ? toolId : "pointer");
586
- },
587
- active: (c) => c.tryGet(ShellToken)?.isOpen(id) ?? false
588
- };
589
- }
590
- //#endregion
591
- export { MODE_SURFACES, TOOL_ICONS, defaultCommands };
592
-
593
- //# sourceMappingURL=commands.js.map
1
+ import { a as REDACT_CONFIRM_DIALOG, c as defaultCommands, d as toolCommandsFor, i as MODE_SURFACES, l as isDesigningForm, n as FORM_DESIGN_TOOL, o as SHORTCUTS_DIALOG, r as GO_TO_PAGE_DIALOG, s as TOOL_ICONS, t as FORM_DESIGN_PANEL, u as isFormDesignTool } from "./commands-BmgxhJ8B.js";
2
+ export { FORM_DESIGN_PANEL, FORM_DESIGN_TOOL, GO_TO_PAGE_DIALOG, MODE_SURFACES, REDACT_CONFIRM_DIALOG, SHORTCUTS_DIALOG, TOOL_ICONS, defaultCommands, isDesigningForm, isFormDesignTool, toolCommandsFor };