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