@embedpdf/viewer-chrome 3.0.0-next.14 → 3.0.0-next.16

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 (177) hide show
  1. package/README.md +175 -132
  2. package/dist/annotation-fonts-DWjVOTP0.js +80 -0
  3. package/dist/annotation-fonts-DWjVOTP0.js.map +1 -0
  4. package/dist/annotation-fonts-dpfVkhnq.cjs +91 -0
  5. package/dist/annotation-fonts-dpfVkhnq.cjs.map +1 -0
  6. package/dist/annotation-style-B3XKAyZ-.cjs +879 -0
  7. package/dist/annotation-style-B3XKAyZ-.cjs.map +1 -0
  8. package/dist/annotation-style-CXF3X47Z.js +879 -0
  9. package/dist/annotation-style-CXF3X47Z.js.map +1 -0
  10. package/dist/ar-B132r9bo.cjs +659 -0
  11. package/dist/ar-B132r9bo.cjs.map +1 -0
  12. package/dist/ar-BLWFJoA_.js +659 -0
  13. package/dist/ar-BLWFJoA_.js.map +1 -0
  14. package/dist/attachments-panel-Cxln8xos.cjs +217 -0
  15. package/dist/attachments-panel-Cxln8xos.cjs.map +1 -0
  16. package/dist/attachments-panel-H1ucRbwo.js +217 -0
  17. package/dist/attachments-panel-H1ucRbwo.js.map +1 -0
  18. package/dist/chrome.cjs +399 -242
  19. package/dist/chrome.cjs.map +1 -1
  20. package/dist/chrome.d.cts +5 -35
  21. package/dist/chrome.d.ts +5 -35
  22. package/dist/chrome.js +398 -239
  23. package/dist/chrome.js.map +1 -1
  24. package/dist/commands-BkgLP3Om.js +1348 -0
  25. package/dist/commands-BkgLP3Om.js.map +1 -0
  26. package/dist/commands-DL1gjZt7.cjs +1473 -0
  27. package/dist/commands-DL1gjZt7.cjs.map +1 -0
  28. package/dist/commands.cjs +13 -649
  29. package/dist/commands.d.cts +30 -3
  30. package/dist/commands.d.ts +30 -3
  31. package/dist/commands.js +2 -647
  32. package/dist/comments-panel-BsnWedTh.cjs +514 -0
  33. package/dist/comments-panel-BsnWedTh.cjs.map +1 -0
  34. package/dist/comments-panel-D7Eadws9.js +514 -0
  35. package/dist/comments-panel-D7Eadws9.js.map +1 -0
  36. package/dist/de-7_MvFWzN.cjs +658 -0
  37. package/dist/de-7_MvFWzN.cjs.map +1 -0
  38. package/dist/de-BUhwc9-x.js +658 -0
  39. package/dist/de-BUhwc9-x.js.map +1 -0
  40. package/dist/dialog-BIb373cg.js +55 -0
  41. package/dist/dialog-BIb373cg.js.map +1 -0
  42. package/dist/dialog-CngKTnAM.cjs +60 -0
  43. package/dist/dialog-CngKTnAM.cjs.map +1 -0
  44. package/dist/es-DgYj-1L3.cjs +658 -0
  45. package/dist/es-DgYj-1L3.cjs.map +1 -0
  46. package/dist/es-DoXTqFoO.js +658 -0
  47. package/dist/es-DoXTqFoO.js.map +1 -0
  48. package/dist/form-design-panel-CgV_5YWC.js +418 -0
  49. package/dist/form-design-panel-CgV_5YWC.js.map +1 -0
  50. package/dist/form-design-panel-D0FdmWXW.cjs +418 -0
  51. package/dist/form-design-panel-D0FdmWXW.cjs.map +1 -0
  52. package/dist/fr-B-8NDhBA.js +658 -0
  53. package/dist/fr-B-8NDhBA.js.map +1 -0
  54. package/dist/fr-C856dmQJ.cjs +658 -0
  55. package/dist/fr-C856dmQJ.cjs.map +1 -0
  56. package/dist/he-BFTeNc4t.cjs +659 -0
  57. package/dist/he-BFTeNc4t.cjs.map +1 -0
  58. package/dist/he-Dlh0fNXM.js +659 -0
  59. package/dist/he-Dlh0fNXM.js.map +1 -0
  60. package/dist/icons-1UfLUZ_y.cjs +1029 -0
  61. package/dist/icons-1UfLUZ_y.cjs.map +1 -0
  62. package/dist/icons-7dB0Y1ct.js +875 -0
  63. package/dist/icons-7dB0Y1ct.js.map +1 -0
  64. package/dist/index.cjs +3651 -5447
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +646 -144
  67. package/dist/index.d.ts +646 -144
  68. package/dist/index.js +3618 -5368
  69. package/dist/index.js.map +1 -1
  70. package/dist/it-Bef-2Yxq.cjs +658 -0
  71. package/dist/it-Bef-2Yxq.cjs.map +1 -0
  72. package/dist/it-BkirG7ol.js +658 -0
  73. package/dist/it-BkirG7ol.js.map +1 -0
  74. package/dist/ja-CGEjCE-s.js +658 -0
  75. package/dist/ja-CGEjCE-s.js.map +1 -0
  76. package/dist/ja-DNw2zqSD.cjs +658 -0
  77. package/dist/ja-DNw2zqSD.cjs.map +1 -0
  78. package/dist/ko-CTkl5vMh.js +658 -0
  79. package/dist/ko-CTkl5vMh.js.map +1 -0
  80. package/dist/ko-YHzeBqP6.cjs +658 -0
  81. package/dist/ko-YHzeBqP6.cjs.map +1 -0
  82. package/dist/labels-BiM9wp9K.cjs +21 -0
  83. package/dist/labels-BiM9wp9K.cjs.map +1 -0
  84. package/dist/labels-C6_i87Oj.js +16 -0
  85. package/dist/labels-C6_i87Oj.js.map +1 -0
  86. package/dist/link-editor-CAS7MZM2.cjs +125 -0
  87. package/dist/link-editor-CAS7MZM2.cjs.map +1 -0
  88. package/dist/link-editor-CkwtqRvb.js +125 -0
  89. package/dist/link-editor-CkwtqRvb.js.map +1 -0
  90. package/dist/measurement-CQdbnIrn.js +325 -0
  91. package/dist/measurement-CQdbnIrn.js.map +1 -0
  92. package/dist/measurement-Cxv1Ahxx.cjs +326 -0
  93. package/dist/measurement-Cxv1Ahxx.cjs.map +1 -0
  94. package/dist/nl-BjkbaLq3.cjs +658 -0
  95. package/dist/nl-BjkbaLq3.cjs.map +1 -0
  96. package/dist/nl-Dya4sR8_.js +658 -0
  97. package/dist/nl-Dya4sR8_.js.map +1 -0
  98. package/dist/outline-panel-BpGtBdj0.cjs +707 -0
  99. package/dist/outline-panel-BpGtBdj0.cjs.map +1 -0
  100. package/dist/outline-panel-DO5_REYw.js +707 -0
  101. package/dist/outline-panel-DO5_REYw.js.map +1 -0
  102. package/dist/outline-properties-BCa2cc0t.js +330 -0
  103. package/dist/outline-properties-BCa2cc0t.js.map +1 -0
  104. package/dist/outline-properties-DT3FIxCw.cjs +330 -0
  105. package/dist/outline-properties-DT3FIxCw.cjs.map +1 -0
  106. package/dist/pl-CKKdVnpZ.cjs +658 -0
  107. package/dist/pl-CKKdVnpZ.cjs.map +1 -0
  108. package/dist/pl-DA9b5NVg.js +658 -0
  109. package/dist/pl-DA9b5NVg.js.map +1 -0
  110. package/dist/print-dialog-BqIrHCBh.cjs +276 -0
  111. package/dist/print-dialog-BqIrHCBh.cjs.map +1 -0
  112. package/dist/print-dialog-DvcI2m2_.js +276 -0
  113. package/dist/print-dialog-DvcI2m2_.js.map +1 -0
  114. package/dist/pt-DLcszlzi.cjs +658 -0
  115. package/dist/pt-DLcszlzi.cjs.map +1 -0
  116. package/dist/pt-Nm8yyjbX.js +658 -0
  117. package/dist/pt-Nm8yyjbX.js.map +1 -0
  118. package/dist/redact-confirm-C6EiK8yN.cjs +83 -0
  119. package/dist/redact-confirm-C6EiK8yN.cjs.map +1 -0
  120. package/dist/redact-confirm-CKuv9iN_.js +83 -0
  121. package/dist/redact-confirm-CKuv9iN_.js.map +1 -0
  122. package/dist/redaction-panel-CgNZ-pQk.js +96 -0
  123. package/dist/redaction-panel-CgNZ-pQk.js.map +1 -0
  124. package/dist/redaction-panel-ZhX0dlMi.cjs +96 -0
  125. package/dist/redaction-panel-ZhX0dlMi.cjs.map +1 -0
  126. package/dist/search-panel-BE4xzWlm.js +249 -0
  127. package/dist/search-panel-BE4xzWlm.js.map +1 -0
  128. package/dist/search-panel-wcbTNG1z.cjs +249 -0
  129. package/dist/search-panel-wcbTNG1z.cjs.map +1 -0
  130. package/dist/sheet-DTBFiwde.cjs +461 -0
  131. package/dist/sheet-DTBFiwde.cjs.map +1 -0
  132. package/dist/sheet-DyjKfAq0.js +378 -0
  133. package/dist/sheet-DyjKfAq0.js.map +1 -0
  134. package/dist/sign-dialog-D5WGx-Yn.cjs +155 -0
  135. package/dist/sign-dialog-D5WGx-Yn.cjs.map +1 -0
  136. package/dist/sign-dialog-DerNe8qT.js +155 -0
  137. package/dist/sign-dialog-DerNe8qT.js.map +1 -0
  138. package/dist/signature-inspector-Bz6TAfZM.cjs +160 -0
  139. package/dist/signature-inspector-Bz6TAfZM.cjs.map +1 -0
  140. package/dist/signature-inspector-CsGr9EBk.js +160 -0
  141. package/dist/signature-inspector-CsGr9EBk.js.map +1 -0
  142. package/dist/signature-maker-D_YfBXLn.cjs +393 -0
  143. package/dist/signature-maker-D_YfBXLn.cjs.map +1 -0
  144. package/dist/signature-maker-Dnth4rV4.js +393 -0
  145. package/dist/signature-maker-Dnth4rV4.js.map +1 -0
  146. package/dist/signatures-panel-Ci_LaI1C.cjs +294 -0
  147. package/dist/signatures-panel-Ci_LaI1C.cjs.map +1 -0
  148. package/dist/signatures-panel-DZ9ywrjz.js +294 -0
  149. package/dist/signatures-panel-DZ9ywrjz.js.map +1 -0
  150. package/dist/stamp-store-BHvRs-Do.cjs +147 -0
  151. package/dist/stamp-store-BHvRs-Do.cjs.map +1 -0
  152. package/dist/stamp-store-WuF-L3Jj.js +112 -0
  153. package/dist/stamp-store-WuF-L3Jj.js.map +1 -0
  154. package/dist/stamps-panel-BrczStaz.js +225 -0
  155. package/dist/stamps-panel-BrczStaz.js.map +1 -0
  156. package/dist/stamps-panel-Cv9nJBwx.cjs +225 -0
  157. package/dist/stamps-panel-Cv9nJBwx.cjs.map +1 -0
  158. package/dist/theme-Be0OZokZ.js +97 -0
  159. package/dist/theme-Be0OZokZ.js.map +1 -0
  160. package/dist/theme-FR26JI3r.cjs +126 -0
  161. package/dist/theme-FR26JI3r.cjs.map +1 -0
  162. package/dist/toolbar-DF361xWY.js +1565 -0
  163. package/dist/toolbar-DF361xWY.js.map +1 -0
  164. package/dist/toolbar-ddvpsvTb.cjs +1660 -0
  165. package/dist/toolbar-ddvpsvTb.cjs.map +1 -0
  166. package/dist/zh-cn-BMPPkLpL.js +658 -0
  167. package/dist/zh-cn-BMPPkLpL.js.map +1 -0
  168. package/dist/zh-cn-CZOO3p4H.cjs +658 -0
  169. package/dist/zh-cn-CZOO3p4H.cjs.map +1 -0
  170. package/package.json +6 -4
  171. package/src/styles.css +161 -89
  172. package/dist/commands.cjs.map +0 -1
  173. package/dist/commands.js.map +0 -1
  174. package/dist/es-BXLlBo2b.cjs +0 -321
  175. package/dist/es-BXLlBo2b.cjs.map +0 -1
  176. package/dist/es-CLgTsFDS.js +0 -321
  177. package/dist/es-CLgTsFDS.js.map +0 -1
package/dist/commands.js CHANGED
@@ -1,647 +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 { MeasurementToken } from "@embedpdf/react/measurement";
8
- import { RedactionToken } from "@embedpdf/react/redaction";
9
- import { ActionsToken } from "@embedpdf/react/actions";
10
- import { FormToken, fieldKeyOf } from "@embedpdf/react/form";
11
- import { SignatureToken } from "@embedpdf/react/signature";
12
- import { LinkToken, openLinkTarget } from "@embedpdf/react/link";
13
- import { SearchToken } from "@embedpdf/react/search";
14
- import { I18nToken } from "@embedpdf/react/i18n";
15
- import { ShellToken } from "@embedpdf/react/shell";
16
- //#region src/config/commands.ts
17
- /** Where selection-made stamps go: the user's own library, persisted. */
18
- const CUSTOM_LIBRARY_ID = "embedpdf-custom";
19
- const stage = (c) => c.tryGet(StageToken);
20
- const interaction = (c) => c.tryGet(InteractionToken);
21
- const anno = (c) => c.tryGet(AnnotationToken);
22
- const textSelection = (c) => c.tryGet(SelectionToken);
23
- 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;
24
- const hasAnnotationSelection = (c) => (anno(c)?.selection().length ?? 0) > 0;
25
- /** v2 gated strip items per subtype (comment hidden on links/widgets) — here
26
- * it's one derivation over the selected DTOs instead of per-command lookups. */
27
- const selectionSubtypes = (c) => new Set((anno(c)?.getSelected() ?? []).map((a) => a.subtype));
28
- /**
29
- * The selection's `link` value: a target, `null` (linkable but none set), or
30
- * `undefined` when the selection cannot carry a link at all (widgets, mixed
31
- * link states) — the schema decides, never a subtype blocklist.
32
- */
33
- const selectionLink = (c) => {
34
- const p = anno(c)?.getSelectionProps();
35
- if (!p || !p.specs.some((s) => s.key === "link") || p.mixed.includes("link")) return void 0;
36
- return p.values.link ?? null;
37
- };
38
- /**
39
- * toolId → the SAME icon + accent definition its toolbar button uses, recorded
40
- * as a side effect of the `tool()` command definitions below — ONE source of
41
- * truth, so the tool cursor (ui/tool-cursor.tsx) and the button can never
42
- * drift apart.
43
- */
44
- const TOOL_ICONS = {};
45
- TOOL_ICONS["stamp"] = { icon: "rubberStamp" };
46
- const toolAccent = (c, toolId, accent) => {
47
- if (!accent) return null;
48
- const anno = c.tryGet(AnnotationToken);
49
- if (!anno) return null;
50
- const d = anno.currentDefaults(toolId);
51
- return {
52
- primary: d[accent.primary] ?? void 0,
53
- secondary: accent.secondary ? d[accent.secondary] ?? void 0 : void 0
54
- };
55
- };
56
- /** A tool command: activates a real interaction tool; active = it's the tool.
57
- * The icon previews the tool's current defaults — keyed by the SAME toolId
58
- * as run/active, so the accent can't drift to another tool's colors. */
59
- const tool = (id, toolId, labelKey, icon, accent) => {
60
- TOOL_ICONS[toolId] = {
61
- icon,
62
- ...accent ? { accent } : {}
63
- };
64
- 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;
65
- return {
66
- id,
67
- labelKey,
68
- icon,
69
- categories: ["tool"],
70
- run: (c) => interaction(c)?.activateTool(toolId),
71
- active: (c) => interaction(c)?.activeToolId() === toolId,
72
- enabled: (c) => interaction(c) != null && (authority?.(c) ?? true),
73
- iconAccent: (c) => toolAccent(c, toolId, accent)
74
- };
75
- };
76
- /** A fixed zoom level (fraction), e.g. 1 = 100%. */
77
- const zoomLevel = (id, level, label) => ({
78
- id,
79
- labelKey: label,
80
- categories: ["zoom", "zoom-level"],
81
- run: (c) => stage(c)?.zoomTo({ level }),
82
- enabled: (c) => stage(c) != null
83
- });
84
- const spread = (id, mode, labelKey, icon) => ({
85
- id,
86
- labelKey,
87
- icon,
88
- categories: ["page", "spread"],
89
- run: (c) => stage(c)?.setSpread(mode),
90
- active: (c) => stage(c)?.spread() === mode,
91
- enabled: (c) => stage(c) != null
92
- });
93
- const defaultCommands = [
94
- {
95
- id: "zoom:in",
96
- labelKey: "commands.zoom.in",
97
- icon: "zoomIn",
98
- shortcut: ["Mod+=", "Mod+NumpadAdd"],
99
- categories: ["zoom"],
100
- run: (c) => stage(c)?.zoomIn(),
101
- enabled: (c) => stage(c) != null
102
- },
103
- {
104
- id: "zoom:out",
105
- labelKey: "commands.zoom.out",
106
- icon: "zoomOut",
107
- shortcut: ["Mod+-", "Mod+NumpadSubtract"],
108
- categories: ["zoom"],
109
- run: (c) => stage(c)?.zoomOut(),
110
- enabled: (c) => stage(c) != null
111
- },
112
- {
113
- id: "zoom:fit-page",
114
- labelKey: "commands.zoom.fitPage",
115
- icon: "fitToPage",
116
- shortcut: "Mod+0",
117
- categories: ["zoom"],
118
- run: (c) => stage(c)?.fitPage(),
119
- active: (c) => stage(c)?.zoomMode() === ZoomMode.FitPage,
120
- enabled: (c) => stage(c) != null
121
- },
122
- {
123
- id: "zoom:fit-width",
124
- labelKey: "commands.zoom.fitWidth",
125
- icon: "fitToWidth",
126
- shortcut: "Mod+1",
127
- categories: ["zoom"],
128
- run: (c) => stage(c)?.fitWidth(),
129
- active: (c) => stage(c)?.zoomMode() === ZoomMode.FitWidth,
130
- enabled: (c) => stage(c) != null
131
- },
132
- {
133
- id: "zoom:automatic",
134
- labelKey: "commands.zoom.automatic",
135
- categories: ["zoom"],
136
- run: (c) => stage(c)?.automatic(),
137
- active: (c) => stage(c)?.zoomMode() === ZoomMode.Automatic,
138
- enabled: (c) => stage(c) != null
139
- },
140
- zoomLevel("zoom:50", .5, "commands.zoom.p50"),
141
- zoomLevel("zoom:100", 1, "commands.zoom.p100"),
142
- zoomLevel("zoom:150", 1.5, "commands.zoom.p150"),
143
- zoomLevel("zoom:200", 2, "commands.zoom.p200"),
144
- zoomLevel("zoom:400", 4, "commands.zoom.p400"),
145
- {
146
- id: "zoom:menu",
147
- labelKey: "commands.zoom.menu",
148
- icon: "zoomIn",
149
- categories: ["zoom"],
150
- menu: "zoom"
151
- },
152
- {
153
- id: "pan:toggle",
154
- labelKey: "commands.pan",
155
- icon: "hand",
156
- categories: ["tools"],
157
- run: (c) => interaction(c)?.activateTool("pan"),
158
- active: (c) => interaction(c)?.activeToolId() === "pan",
159
- enabled: (c) => interaction(c) != null
160
- },
161
- {
162
- id: "pointer:toggle",
163
- labelKey: "commands.pointer",
164
- icon: "pointer",
165
- categories: ["tools"],
166
- run: (c) => interaction(c)?.activateTool("pointer"),
167
- active: (c) => interaction(c)?.activeToolId() === "pointer",
168
- enabled: (c) => interaction(c) != null
169
- },
170
- {
171
- id: "panel:sidebar",
172
- labelKey: "commands.sidebar",
173
- icon: "sidebar",
174
- categories: ["panel"],
175
- panel: {
176
- id: "sidebar",
177
- exclusive: "left"
178
- }
179
- },
180
- {
181
- id: "panel:search",
182
- labelKey: "commands.search",
183
- icon: "search",
184
- visible: (c) => c.tryGet(SearchToken)?.canSearch() ?? true,
185
- categories: ["panel"],
186
- panel: {
187
- id: "search",
188
- exclusive: "right"
189
- }
190
- },
191
- {
192
- id: "panel:comment",
193
- labelKey: "commands.comment",
194
- icon: "comment",
195
- visible: (c) => anno(c)?.canRead() ?? true,
196
- categories: ["panel"],
197
- panel: {
198
- id: "comment",
199
- exclusive: "right"
200
- }
201
- },
202
- {
203
- id: "panel:annotation-style",
204
- labelKey: "commands.style",
205
- icon: "palette",
206
- categories: ["panel"],
207
- panel: {
208
- id: "annotation-style",
209
- exclusive: "right"
210
- }
211
- },
212
- {
213
- id: "document:menu",
214
- labelKey: "commands.menu",
215
- icon: "menu",
216
- categories: ["document"],
217
- menu: "document"
218
- },
219
- {
220
- id: "page:settings",
221
- labelKey: "commands.viewControls",
222
- icon: "viewSettings",
223
- categories: ["page"],
224
- menu: "page-settings"
225
- },
226
- {
227
- id: "document:download",
228
- labelKey: "commands.download",
229
- icon: "download",
230
- categories: ["document"],
231
- run: (c) => {
232
- const id = c.documentId ?? void 0;
233
- const documents = c.tryGet(DocumentsToken);
234
- if (!documents) return;
235
- const pull = () => documents.download(id);
236
- const actions = c.tryGet(ActionsToken);
237
- (actions ? actions.runDocumentVerb("save", pull) : pull()).then((bytes) => {
238
- const blob = new Blob([bytes], { type: "application/pdf" });
239
- const url = URL.createObjectURL(blob);
240
- const a = document.createElement("a");
241
- a.href = url;
242
- a.download = "document.pdf";
243
- a.click();
244
- URL.revokeObjectURL(url);
245
- }).catch((e) => console.warn("[snippet-react] download failed", e));
246
- },
247
- enabled: (c) => c.documentId != null && (c.tryGet(DocumentsToken)?.allows("doc.download") ?? false)
248
- },
249
- {
250
- id: "document:print",
251
- labelKey: "commands.print",
252
- icon: "print",
253
- shortcut: "Mod+p",
254
- categories: ["document"],
255
- run: (c) => {
256
- const actions = c.documentId != null ? c.tryGet(ActionsToken) : null;
257
- if (actions) actions.runDocumentVerb("print", () => window.print());
258
- else window.print();
259
- },
260
- enabled: (c) => c.documentId == null || (c.tryGet(DocumentsToken)?.allows("doc.print") ?? true)
261
- },
262
- {
263
- id: "document:fullscreen",
264
- labelKey: "commands.fullscreen",
265
- icon: "externalLink",
266
- categories: ["document"],
267
- run: () => {
268
- if (document.fullscreenElement) document.exitFullscreen();
269
- else document.documentElement.requestFullscreen().catch(() => {});
270
- },
271
- active: () => Boolean(document.fullscreenElement)
272
- },
273
- spread("spread:none", "none", "commands.spread.none", "singlePage"),
274
- spread("spread:odd", "odd", "commands.spread.odd", "doublePage"),
275
- spread("spread:even", "even", "commands.spread.even", "book2"),
276
- {
277
- id: "scroll:vertical",
278
- labelKey: "commands.scroll.vertical",
279
- icon: "vertical",
280
- categories: ["page", "scroll"],
281
- run: (c) => stage(c)?.setLayout("vertical"),
282
- active: (c) => stage(c)?.layout() === "vertical",
283
- enabled: (c) => stage(c) != null
284
- },
285
- {
286
- id: "scroll:horizontal",
287
- labelKey: "commands.scroll.horizontal",
288
- icon: "horizontal",
289
- categories: ["page", "scroll"],
290
- run: (c) => stage(c)?.setLayout("horizontal"),
291
- active: (c) => stage(c)?.layout() === "horizontal",
292
- enabled: (c) => stage(c) != null
293
- },
294
- {
295
- id: "rotate:clockwise",
296
- labelKey: "commands.rotate.clockwise",
297
- icon: "rotateClockwise",
298
- categories: ["page", "rotate"],
299
- run: (c) => stage(c)?.rotateView(90),
300
- enabled: (c) => stage(c) != null
301
- },
302
- {
303
- id: "rotate:counter-clockwise",
304
- labelKey: "commands.rotate.counterclockwise",
305
- icon: "rotateCounterClockwise",
306
- categories: ["page", "rotate"],
307
- run: (c) => stage(c)?.rotateView(-90),
308
- enabled: (c) => stage(c) != null
309
- },
310
- {
311
- id: "mode:view",
312
- labelKey: "commands.mode.view",
313
- categories: ["mode"],
314
- run: (c) => {
315
- const shell = c.tryGet(ShellToken);
316
- for (const m of MODE_SURFACES) shell?.close(m);
317
- interaction(c)?.activateTool("pointer");
318
- },
319
- active: (c) => {
320
- const shell = c.tryGet(ShellToken);
321
- return shell ? MODE_SURFACES.every((m) => !shell.isOpen(m)) : true;
322
- }
323
- },
324
- modeCommand("mode:annotate", "commands.mode.annotate"),
325
- modeCommand("mode:shapes", "commands.mode.shapes"),
326
- modeCommand("mode:insert", "commands.mode.insert"),
327
- modeCommand("mode:form", "commands.mode.form", "form-edit"),
328
- modeCommand("mode:redact", "commands.mode.redact"),
329
- modeCommand("mode:measure", "commands.mode.measure"),
330
- tool("annotation:add-highlight", "highlight", "commands.annotate.highlight", "highlight", { primary: "color" }),
331
- tool("annotation:add-strikeout", "strikeout", "commands.annotate.strikeout", "strikethrough", { primary: "color" }),
332
- tool("annotation:add-underline", "underline", "commands.annotate.underline", "underline", { primary: "color" }),
333
- tool("annotation:add-squiggly", "squiggly", "commands.annotate.squiggly", "squiggly", { primary: "color" }),
334
- tool("annotation:add-ink", "ink", "commands.annotate.ink", "pencilMarker", { primary: "color" }),
335
- tool("annotation:add-ink-highlight", "ink-highlight", "commands.annotate.inkHighlight", "inkHighlighter", { primary: "color" }),
336
- tool("annotation:add-text", "free-text", "commands.annotate.text", "freeText", { primary: "fontColor" }),
337
- tool("annotation:add-insert-text", "insert-text", "commands.annotate.insertText", "insertText", { primary: "color" }),
338
- tool("annotation:add-replace-text", "replace-text", "commands.annotate.replaceText", "replaceText", { primary: "color" }),
339
- tool("annotation:add-callout", "free-text-callout", "commands.annotate.callout", "callout", {
340
- primary: "color",
341
- secondary: "interiorColor"
342
- }),
343
- tool("annotation:add-note", "note", "commands.annotate.note", "message"),
344
- tool("annotation:add-link", "link", "commands.annotate.link", "link"),
345
- tool("annotation:add-rectangle", "square", "commands.shapes.rectangle", "square", {
346
- primary: "color",
347
- secondary: "interiorColor"
348
- }),
349
- tool("annotation:add-circle", "circle", "commands.shapes.circle", "circle", {
350
- primary: "color",
351
- secondary: "interiorColor"
352
- }),
353
- tool("annotation:add-line", "line", "commands.shapes.line", "line", { primary: "color" }),
354
- tool("annotation:add-arrow", "arrow", "commands.shapes.arrow", "lineArrow", { primary: "color" }),
355
- tool("annotation:add-polygon", "polygon", "commands.shapes.polygon", "polygon", {
356
- primary: "color",
357
- secondary: "interiorColor"
358
- }),
359
- tool("annotation:add-polyline", "polyline", "commands.shapes.polyline", "zigzag", { primary: "color" }),
360
- {
361
- id: "insert:add-stamp",
362
- labelKey: "commands.insert.stamp",
363
- icon: "rubberStamp",
364
- visible: (c) => c.tryGet(StampToken) != null,
365
- enabled: (c) => anno(c)?.canCreate() ?? true,
366
- categories: ["panel"],
367
- panel: {
368
- id: "stamps",
369
- exclusive: "right"
370
- }
371
- },
372
- tool("insert:add-attachment", "attachment", "commands.insert.attachment", "paperclip"),
373
- {
374
- id: "insert:add-signature",
375
- labelKey: "commands.insert.signature",
376
- icon: "signature",
377
- visible: (c) => c.tryGet(StampToken) != null && c.tryGet(SignatureToken) != null,
378
- enabled: (c) => anno(c)?.canCreate() ?? true,
379
- categories: ["panel"],
380
- panel: {
381
- id: "signatures",
382
- exclusive: "right"
383
- }
384
- },
385
- tool("insert:add-image", "image", "commands.insert.image", "photo"),
386
- tool("form:add-textfield", "form-text", "commands.form.textfield", "formTextfield"),
387
- tool("form:add-checkbox", "form-checkbox", "commands.form.checkbox", "formCheckbox"),
388
- tool("form:add-radio", "form-radio", "commands.form.radio", "formRadio"),
389
- tool("form:add-select", "form-combobox", "commands.form.select", "formSelect"),
390
- tool("form:add-listbox", "form-listbox", "commands.form.listbox", "formListbox"),
391
- tool("form:add-signature", "form-signature", "commands.form.signature", "signature"),
392
- tool("redaction:redact", "redact", "commands.redact.mark", "redactArea"),
393
- {
394
- id: "panel:redaction",
395
- labelKey: "commands.redact.panel",
396
- icon: "redactionSidebar",
397
- visible: (c) => {
398
- const r = c.tryGet(RedactionToken);
399
- return r ? r.canMark() || r.canApply() : true;
400
- },
401
- categories: ["panel"],
402
- panel: {
403
- id: "redaction",
404
- exclusive: "right"
405
- }
406
- },
407
- {
408
- ...tool("measurement:distance", "distance", "measurement.distance", "distance", { primary: "color" }),
409
- enabled: (c) => {
410
- const s = stage(c);
411
- const pon = s?.pages()[s.currentPage()]?.pon;
412
- return pon != null && (c.tryGet(MeasurementToken)?.canMeasure(pon) ?? false);
413
- }
414
- },
415
- {
416
- ...tool("measurement:perimeter", "perimeter", "measurement.perimeter", "perimeter", { primary: "color" }),
417
- enabled: (c) => {
418
- const s = stage(c);
419
- const pon = s?.pages()[s.currentPage()]?.pon;
420
- return pon != null && (c.tryGet(MeasurementToken)?.canMeasure(pon) ?? false);
421
- }
422
- },
423
- {
424
- ...tool("measurement:area", "area", "measurement.area", "area", { primary: "color" }),
425
- enabled: (c) => {
426
- const s = stage(c);
427
- const pon = s?.pages()[s.currentPage()]?.pon;
428
- return pon != null && (c.tryGet(MeasurementToken)?.canMeasure(pon) ?? false);
429
- }
430
- },
431
- {
432
- id: "measurement:calibrate",
433
- labelKey: "measurement.calibrate",
434
- icon: "calibrate",
435
- categories: ["tool"],
436
- enabled: (c) => c.tryGet(MeasurementToken)?.canCalibrate() ?? false,
437
- active: (c) => interaction(c)?.activeToolId() === "calibrate",
438
- run: (c) => c.tryGet(MeasurementToken)?.startCalibration()
439
- },
440
- {
441
- id: "panel:measurement",
442
- labelKey: "measurement.title",
443
- icon: "updateScale",
444
- categories: ["panel"],
445
- panel: {
446
- id: "measurement",
447
- exclusive: "right"
448
- }
449
- },
450
- {
451
- id: "annotation:cancel-creation",
452
- labelKey: "commands.annotate.cancelCreation",
453
- categories: ["annotation"],
454
- shortcut: "Escape",
455
- enabled: (c) => anno(c)?.hasCreationDraft() ?? false,
456
- run: (c) => anno(c)?.cancelCreationDraft()
457
- },
458
- {
459
- id: "annotation:delete",
460
- labelKey: "commands.annotate.delete",
461
- icon: "trash",
462
- categories: ["annotation"],
463
- run: (c) => {
464
- const a = anno(c);
465
- if (!a) return;
466
- const form = c.tryGet(FormToken);
467
- const dtos = a.getSelected();
468
- const widgets = form ? dtos.filter((d) => d.subtype === "widget") : [];
469
- if (widgets.length === 0) {
470
- a.deleteSelection();
471
- return;
472
- }
473
- const keys = /* @__PURE__ */ new Set();
474
- for (const w of widgets) {
475
- const objnum = w.ref.kind === "objectNumber" ? w.ref.annotObjectNumber : 0;
476
- const field = objnum > 0 ? form.fieldForWidget(objnum) : null;
477
- if (field) keys.add(fieldKeyOf(field));
478
- }
479
- for (const key of keys) form.deleteField(key);
480
- for (const d of dtos) if (d.subtype !== "widget") a.delete(d.ref);
481
- a.deselect();
482
- },
483
- visible: hasAnnotationSelection,
484
- enabled: (c) => {
485
- const a = anno(c);
486
- const refs = a?.getSelection() ?? [];
487
- return refs.length > 0 && refs.every((r) => a.canDelete(r));
488
- }
489
- },
490
- {
491
- id: "annotation:comment",
492
- labelKey: "commands.comment",
493
- icon: "comment",
494
- categories: ["annotation"],
495
- panel: {
496
- id: "comment",
497
- exclusive: "right"
498
- },
499
- visible: (c) => hasAnnotationSelection(c) && !selectionSubtypes(c).has("widget")
500
- },
501
- {
502
- id: "annotation:style",
503
- labelKey: "commands.style",
504
- icon: "palette",
505
- categories: ["annotation"],
506
- panel: {
507
- id: "annotation-style",
508
- exclusive: "right"
509
- },
510
- visible: (c) => (anno(c)?.getSelectionProps().specs.length ?? 0) > 0
511
- },
512
- {
513
- id: "annotation:stamp-from-selection",
514
- labelKey: "commands.annotate.stampFromSelection",
515
- icon: "rubberStampPlus",
516
- categories: ["annotation"],
517
- run: (c) => {
518
- const a = anno(c);
519
- const stamp = c.tryGet(StampToken);
520
- const documentId = c.documentId;
521
- if (!a || !stamp || documentId == null) return;
522
- const dtos = a.getSelected();
523
- const pon = dtos[0]?.ref.pageObjectNumber;
524
- if (pon === void 0) return;
525
- const i18n = c.tryGet(I18nToken);
526
- const label = i18n?.t("demo.stampsCustomLabel") ?? "Custom stamp";
527
- const libraryName = i18n?.t("demo.stampsCustomLibrary") ?? "My stamps";
528
- const libraryId = CUSTOM_LIBRARY_ID;
529
- (stamp.library(libraryId) ? Promise.resolve(libraryId) : stamp.createLibrary(libraryName, {
530
- id: libraryId,
531
- categories: ["custom"]
532
- })).then((id) => stamp.addAssetFromAnnotations(documentId, pon, dtos.map((d) => d.ref), {
533
- libraryId: id,
534
- label: `${label} ${stamp.assets(id).length + 1}`
535
- })).then(() => c.tryGet(ShellToken)?.open("stamps", {
536
- exclusive: "right",
537
- props: { libraryId }
538
- })).catch((e) => console.warn("[embedpdf] stamp from selection failed", e));
539
- },
540
- 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,
541
- enabled: (c) => c.tryGet(DocumentsToken)?.allows("doc.download") ?? true
542
- },
543
- {
544
- id: "annotation:group",
545
- labelKey: "commands.annotate.group",
546
- icon: "group",
547
- categories: ["annotation"],
548
- run: (c) => void anno(c)?.group(),
549
- visible: (c) => anno(c)?.canGroup() ?? false
550
- },
551
- {
552
- id: "annotation:ungroup",
553
- labelKey: "commands.annotate.ungroup",
554
- icon: "ungroup",
555
- categories: ["annotation"],
556
- run: (c) => void anno(c)?.ungroup(),
557
- visible: (c) => anno(c)?.canUngroup() ?? false
558
- },
559
- {
560
- id: "selection:copy",
561
- labelKey: "commands.selection.copy",
562
- icon: "copy",
563
- categories: ["selection"],
564
- visible: (c) => {
565
- const s = textSelection(c);
566
- return !!s && s.hasSelection() && s.canCopy();
567
- },
568
- run: (c) => {
569
- const s = textSelection(c);
570
- if (!s) return;
571
- const copiedRange = s.snapshot().range;
572
- copySelection(s).then((text) => {
573
- if (text !== "" && sameTextRange(s.snapshot().range, copiedRange)) s.clear();
574
- }, () => {});
575
- }
576
- },
577
- {
578
- id: "annotation:link",
579
- labelKey: "commands.annotate.link",
580
- icon: "link",
581
- categories: ["annotation"],
582
- run: (c) => c.tryGet(ShellToken)?.toggle("link-editor"),
583
- active: (c) => c.tryGet(ShellToken)?.isOpen("link-editor") ?? false,
584
- visible: (c) => selectionLink(c) === null
585
- },
586
- {
587
- id: "annotation:goto-link",
588
- labelKey: "commands.annotate.gotoLink",
589
- icon: "externalLink",
590
- categories: ["annotation"],
591
- run: (c) => {
592
- const target = selectionLink(c);
593
- const link = c.tryGet(LinkToken);
594
- if (target && link) openLinkTarget(link, target);
595
- },
596
- visible: (c) => selectionLink(c) != null
597
- },
598
- {
599
- id: "annotation:remove-link",
600
- labelKey: "commands.annotate.removeLink",
601
- icon: "linkOff",
602
- categories: ["annotation"],
603
- run: (c) => anno(c)?.updateSelection({ link: null }),
604
- visible: (c) => selectionLink(c) != null
605
- },
606
- {
607
- id: "history:undo",
608
- labelKey: "commands.undo",
609
- icon: "arrowBackUp",
610
- categories: ["history"],
611
- run: () => {},
612
- enabled: () => false
613
- },
614
- {
615
- id: "history:redo",
616
- labelKey: "commands.redo",
617
- icon: "arrowForwardUp",
618
- categories: ["history"],
619
- run: () => {},
620
- enabled: () => false
621
- }
622
- ];
623
- const MODE_SURFACES = [
624
- "mode:annotate",
625
- "mode:shapes",
626
- "mode:insert",
627
- "mode:form",
628
- "mode:redact",
629
- "mode:measure"
630
- ];
631
- function modeCommand(id, labelKey, toolId = "pointer") {
632
- return {
633
- id,
634
- labelKey,
635
- categories: ["mode"],
636
- run: (c) => {
637
- const shell = c.tryGet(ShellToken);
638
- shell?.toggle(id, { exclusive: "mode" });
639
- interaction(c)?.activateTool(shell?.isOpen(id) ? toolId : "pointer");
640
- },
641
- active: (c) => c.tryGet(ShellToken)?.isOpen(id) ?? false
642
- };
643
- }
644
- //#endregion
645
- export { MODE_SURFACES, TOOL_ICONS, defaultCommands };
646
-
647
- //# sourceMappingURL=commands.js.map
1
+ import { a as PRINT_DIALOG, c as TOOL_ICONS, d as isFormDesignTool, f as toolCommandsFor, i as MODE_SURFACES, l as defaultCommands, n as FORM_DESIGN_TOOL, o as REDACT_CONFIRM_DIALOG, r as GO_TO_PAGE_DIALOG, s as SHORTCUTS_DIALOG, t as FORM_DESIGN_PANEL, u as isDesigningForm } from "./commands-BkgLP3Om.js";
2
+ export { FORM_DESIGN_PANEL, FORM_DESIGN_TOOL, GO_TO_PAGE_DIALOG, MODE_SURFACES, PRINT_DIALOG, REDACT_CONFIRM_DIALOG, SHORTCUTS_DIALOG, TOOL_ICONS, defaultCommands, isDesigningForm, isFormDesignTool, toolCommandsFor };