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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -307,6 +307,53 @@ The v1 part vocabulary — public API, grown by demand, never speculatively:
307
307
  `toolbar`, `toolbar-button(-active)`, `mode-tab(-active)`, `tab(-active)`,
308
308
  `menu`, `menu-item(-active)`.
309
309
 
310
+ ### Signatures — sign with a mark, through a key you bring
311
+
312
+ The Insert tab's signature button opens the **people** panel: one row per
313
+ person (a stamp library of kind `signatures`) holding a drawn, typed, or
314
+ uploaded signature and, optionally, initials. Pick a mark, click a signature
315
+ field to sign it — or click anywhere else to drop it as a stamp, as Preview
316
+ does. A "sign here" click on an unsigned field targets it; the next mark
317
+ picked goes in. The Form tab authors signature fields.
318
+
319
+ What placing a mark on a field does is the `signatures` config:
320
+
321
+ ```tsx
322
+ import { FullViewer, personalSigner, indexedDbKeyStore } from '@embedpdf/viewer-chrome';
323
+
324
+ <FullViewer
325
+ engine={engine}
326
+ signatures={{
327
+ // The key holder: your own key (`webCryptoSigner`), a signing service
328
+ // (`remoteSigner`), or one self-signed identity per person kept in the
329
+ // browser (`personalSigner`). Without a signer the mark is only DRAWN
330
+ // into the field — nothing is sealed.
331
+ signer: () => personalSigner({ subject: 'Ada Lovelace', store: indexedDbKeyStore('acme-keys') }),
332
+ // Anchors a reader trusts; none → "valid, signer not trusted" at best.
333
+ trust: { anchors: async () => [rootCertificateDer] },
334
+ // 'sign' (default with a signer) | 'visual' (default without) | 'ask' (a dialog first)
335
+ mode: 'ask',
336
+ allowCertify: true, // offer a certification (first signature) in the dialog
337
+ kinds: ['signature'], // no initials
338
+ fonts: [{ key: 'great-vibes', url: '/fonts/GreatVibes.ttf', label: 'Great Vibes' }], // typed marks
339
+ }}
340
+ stamps={{
341
+ sidebar: ['stamps'], // library kinds the stamps sidebar lists
342
+ toolbar: ['embedpdf-standard:Check', 'embedpdf-standard:Cross'], // quick marks in the Insert bar
343
+ }}
344
+ />;
345
+ ```
346
+
347
+ A signed field shows its verdict on click — document intact, signature
348
+ verified, signer trusted, changes since — and offers the signed revision as
349
+ a download. The panel judges what a save _would_ produce: an unsaved
350
+ annotation after a plain approval signature reads "valid, unsaved changes
351
+ will invalidate it" and a one-line notice says which signature, the way
352
+ Acrobat warns. With `allowCertify` on, the first signature opens the sign
353
+ dialog with the choice Acrobat's certify dialog gives: a plain approval,
354
+ or a certification that allows comments, form filling only, or no changes.
355
+ `viewer.get(SignatureToken)` drives all of it from code.
356
+
310
357
  ## What's deliberately NOT here (yet)
311
358
 
312
359
  - **The element registry** (`elements: { button: 'tag' }` + exported base
package/dist/chrome.cjs CHANGED
@@ -53,6 +53,10 @@ const mainBar = {
53
53
  (0, _embedpdf_react_toolbar.item)("mode:redact", {
54
54
  variants: ["label"],
55
55
  importance: 1
56
+ }),
57
+ (0, _embedpdf_react_toolbar.item)("mode:measure", {
58
+ variants: ["label"],
59
+ importance: 1
56
60
  })
57
61
  ]
58
62
  })],
@@ -99,6 +103,10 @@ const insertBar = {
99
103
  sections: { center: [
100
104
  (0, _embedpdf_react_toolbar.group)("stamps", { importance: 4 }, [
101
105
  "insert:add-stamp",
106
+ (0, _embedpdf_react_toolbar.custom)("quick-stamps", {
107
+ terminal: "insert:add-stamp",
108
+ importance: 3
109
+ }),
102
110
  "insert:add-attachment",
103
111
  "insert:add-signature",
104
112
  "insert:add-image"
@@ -116,9 +124,26 @@ const formBar = {
116
124
  "form:add-radio"
117
125
  ]),
118
126
  (0, _embedpdf_react_toolbar.group)("choice-fields", { importance: 2 }, ["form:add-select", "form:add-listbox"]),
127
+ (0, _embedpdf_react_toolbar.group)("signature-fields", { importance: 2 }, ["form:add-signature"]),
119
128
  history
120
129
  ] }
121
130
  };
131
+ const measureBar = {
132
+ id: "measure",
133
+ sections: { center: [
134
+ (0, _embedpdf_react_toolbar.group)("measure", { importance: 5 }, [
135
+ "measurement:distance",
136
+ "measurement:perimeter",
137
+ "measurement:area",
138
+ "measurement:calibrate"
139
+ ]),
140
+ (0, _embedpdf_react_toolbar.group)("scale", { importance: 4 }, [(0, _embedpdf_react_toolbar.custom)("measurement-scale", {
141
+ variants: ["inline"],
142
+ terminal: "panel:measurement"
143
+ })]),
144
+ style
145
+ ] }
146
+ };
122
147
  const redactBar = {
123
148
  id: "redact",
124
149
  sections: { center: [
@@ -203,7 +228,8 @@ const defaultChrome = (0, _embedpdf_react_toolbar.defineChrome)({
203
228
  "mode:shapes": shapesBar,
204
229
  "mode:insert": insertBar,
205
230
  "mode:form": formBar,
206
- "mode:redact": redactBar
231
+ "mode:redact": redactBar,
232
+ "mode:measure": measureBar
207
233
  },
208
234
  menus: {
209
235
  document: documentMenu,
@@ -1 +1 @@
1
- {"version":3,"file":"chrome.cjs","names":[],"sources":["../src/config/chrome.ts"],"sourcesContent":["/**\n * The chrome — structure only. No breakpoints, no show/hide lists, no locale\n * overrides, no dividers/spacers, no hand-written overflow menus. What fits is\n * measured and solved at runtime (@embedpdf/core-ui); the overflow menu is\n * derived. Compare to the v2 snippet's 1,950-line ui-schema.ts.\n *\n * `importance` (1 sheds first … 5 pinned) is the only responsive knob.\n */\nimport {\n defineChrome,\n group,\n item,\n custom,\n type BarSchema,\n type ChromeSchema,\n type MenuSchema,\n} from '@embedpdf/react/toolbar';\n\n// Reused across every mode band — plain values, so composition is just a const.\nconst style = group('style', { importance: 4 }, [item('panel:annotation-style')]);\nconst history = group('history', { importance: 3 }, ['history:undo', 'history:redo']);\n\n// ── main toolbar ─────────────────────────────────────────────────────────────\nconst mainBar: BarSchema = {\n id: 'main',\n sections: {\n // v2 layout: everything before the first spacer sits LEFT-aligned —\n // document menu, workspace, zoom strip, pan/pointer. Only the mode tabs\n // are truly centered.\n start: [\n group('document', { importance: 5 }, [item('document:menu')]),\n group('workspace', { importance: 4 }, [\n item('panel:sidebar', { importance: 5 }),\n item('page:settings'),\n ]),\n // The inline zoom strip; when it can't fit it renders its 'button'\n // variant, and in the overflow menu it projects through zoom:menu.\n group('zoom', { importance: 4 }, [\n custom('zoom-controls', { variants: ['inline', 'button'], terminal: 'zoom:menu' }),\n ]),\n group('tools', { importance: 2 }, ['pan:toggle', 'pointer:toggle']),\n ],\n center: [\n group('modes', {\n role: 'tabs',\n // The group ladder: full strip → trailing tabs shed behind a derived\n // in-strip chevron (v2's overflow-tabs-button) → select (v2's\n // mode-select-button) → global overflow. Tab items at importance 1 so\n // the strip is the FIRST thing to compact; the group at 4 so its\n // compact forms survive long.\n shed: true,\n collapse: 'select',\n importance: 4,\n labelKey: 'commands.mode.group',\n items: [\n item('mode:view', { variants: ['label'], importance: 1 }),\n item('mode:annotate', { variants: ['label'], importance: 1 }),\n item('mode:shapes', { variants: ['label'], importance: 1 }),\n item('mode:insert', { variants: ['label'], importance: 1 }),\n item('mode:form', { variants: ['label'], importance: 1 }),\n item('mode:redact', { variants: ['label'], importance: 1 }),\n ],\n }),\n ],\n end: [group('panels', { importance: 5 }, ['panel:search', 'panel:comment'])],\n },\n};\n\n// ── secondary bands (one per mode; which shows is derived from shell) ────────\nconst annotateBar: BarSchema = {\n id: 'annotate',\n sections: {\n center: [\n group('comment', { importance: 4 }, ['annotation:add-note', 'annotation:add-link']),\n group('markup', { importance: 4 }, [\n 'annotation:add-highlight',\n 'annotation:add-strikeout',\n 'annotation:add-underline',\n 'annotation:add-squiggly',\n ]),\n group('draw', { importance: 3 }, ['annotation:add-ink', 'annotation:add-ink-highlight']),\n group('text', { importance: 2 }, [\n 'annotation:add-text',\n 'annotation:add-insert-text',\n 'annotation:add-replace-text',\n 'annotation:add-callout',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst shapesBar: BarSchema = {\n id: 'shapes',\n sections: {\n center: [\n group('shapes', { importance: 4 }, [\n 'annotation:add-rectangle',\n 'annotation:add-circle',\n 'annotation:add-line',\n 'annotation:add-arrow',\n ]),\n group('polygons', { importance: 2 }, ['annotation:add-polygon', 'annotation:add-polyline']),\n style,\n history,\n ],\n },\n};\n\nconst insertBar: BarSchema = {\n id: 'insert',\n sections: {\n center: [\n group('stamps', { importance: 4 }, [\n 'insert:add-stamp',\n 'insert:add-attachment',\n 'insert:add-signature',\n 'insert:add-image',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst formBar: BarSchema = {\n id: 'form',\n sections: {\n center: [\n group('fields', { importance: 4 }, [\n 'form:add-textfield',\n 'form:add-checkbox',\n 'form:add-radio',\n ]),\n group('choice-fields', { importance: 2 }, ['form:add-select', 'form:add-listbox']),\n history,\n ],\n },\n};\n\nconst redactBar: BarSchema = {\n id: 'redact',\n sections: {\n center: [\n group('redact', { importance: 4 }, ['redaction:redact', 'panel:redaction']),\n style,\n history,\n ],\n },\n};\n\n// ── menus (command trees; separators derive between sections) ────────────────\nconst documentMenu: MenuSchema = {\n id: 'document',\n sections: [\n { items: ['document:download', 'document:print'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\nconst zoomMenu: MenuSchema = {\n id: 'zoom',\n sections: [\n {\n labelKey: 'commands.zoom.level',\n items: ['zoom:50', 'zoom:100', 'zoom:150', 'zoom:200', 'zoom:400'],\n },\n { items: ['zoom:in', 'zoom:out'] },\n { items: ['zoom:fit-page', 'zoom:fit-width', 'zoom:automatic'] },\n ],\n};\n\nconst pageSettingsMenu: MenuSchema = {\n id: 'page-settings',\n sections: [\n { labelKey: 'commands.spread.group', items: ['spread:none', 'spread:odd', 'spread:even'] },\n { labelKey: 'commands.scroll.group', items: ['scroll:vertical', 'scroll:horizontal'] },\n { labelKey: 'commands.rotate.group', items: ['rotate:clockwise', 'rotate:counter-clockwise'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\n// ── contextual strips (anchored to selections; same BarSchema vocabulary) ────\n// WHICH commands actually show is each command's `visible` derivation (group\n// only when groupable, style only when the kind declares editable props…), so\n// one strip serves single AND multi selection — v2 needed two schemas for that.\nconst annotationStrip: BarSchema = {\n id: 'annotation-strip',\n sections: {\n center: [\n group('annotation-actions', { importance: 4 }, [\n 'annotation:comment',\n 'annotation:style',\n 'annotation:stamp-from-selection',\n 'annotation:link',\n 'annotation:goto-link',\n 'annotation:remove-link',\n 'annotation:group',\n 'annotation:ungroup',\n ]),\n // Its own group → a derived separator; delete stands apart.\n group('annotation-danger', { importance: 5 }, ['annotation:delete']),\n ],\n },\n};\n\n// The text-selection strip: appears when a text selection SETTLES (the menu\n// component gates on `isSelecting()`). One command today; \"Highlight\" et al.\n// are one more id here + one command — no component changes.\nconst selectionStrip: BarSchema = {\n id: 'selection-strip',\n sections: {\n center: [group('selection-actions', { importance: 4 }, ['selection:copy'])],\n },\n};\n\n/**\n * The DEFAULT chrome — exported as a VALUE, which is the whole customization\n * model: consumers pass nothing and track this, transform it, or write their\n * own. It is never merged with anything.\n */\nexport const defaultChrome = defineChrome({\n bars: { main: mainBar },\n modeBars: {\n 'mode:annotate': annotateBar,\n 'mode:shapes': shapesBar,\n 'mode:insert': insertBar,\n 'mode:form': formBar,\n 'mode:redact': redactBar,\n },\n menus: { document: documentMenu, zoom: zoomMenu, 'page-settings': pageSettingsMenu },\n strips: { annotation: annotationStrip, selection: selectionStrip },\n});\n\n// Lookups take the RESOLVED schema (the host may have replaced the default) —\n// the typed literal widens to arbitrary string keys here, once.\n\n/** Menu lookup by id (arbitrary string). */\nexport function getMenu(schema: ChromeSchema, id: string): MenuSchema | undefined {\n return (schema.menus as Record<string, MenuSchema> | undefined)?.[id];\n}\n\n/** Secondary band lookup by mode-surface id. */\nexport function getModeBar(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.modeBars as Record<string, BarSchema> | undefined)?.[id];\n}\n\n/** Contextual strip lookup by context id ('annotation', …). */\nexport function getStrip(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.strips as Record<string, BarSchema> | undefined)?.[id];\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,SAAA,GAAA,wBAAA,MAAA,CAAc,SAAS,EAAE,YAAY,EAAE,GAAG,EAAA,GAAA,wBAAA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B,CAAC,CACrE,EACF;AACF;AAKA,MAAM,iBAA4B;CAChC,IAAI;CACJ,UAAU,EACR,QAAQ,EAAA,GAAA,wBAAA,MAAA,CAAO,qBAAqB,EAAE,YAAY,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAC5E;AACF;;;;;;AAOA,MAAa,iBAAA,GAAA,wBAAA,aAAA,CAA6B;CACxC,MAAM,EAAE,MAAM,QAAQ;CACtB,UAAU;EACR,iBAAiB;EACjB,eAAe;EACf,eAAe;EACf,aAAa;EACb,eAAe;CACjB;CACA,OAAO;EAAE,UAAU;EAAc,MAAM;EAAU,iBAAiB;CAAiB;CACnF,QAAQ;EAAE,YAAY;EAAiB,WAAW;CAAe;AACnE,CAAC;;AAMD,SAAgB,QAAQ,QAAsB,IAAoC;CAChF,OAAQ,OAAO,QAAmD;AACpE;;AAGA,SAAgB,WAAW,QAAsB,IAAmC;CAClF,OAAQ,OAAO,WAAqD;AACtE;;AAGA,SAAgB,SAAS,QAAsB,IAAmC;CAChF,OAAQ,OAAO,SAAmD;AACpE"}
1
+ {"version":3,"file":"chrome.cjs","names":[],"sources":["../src/config/chrome.ts"],"sourcesContent":["/**\n * The chrome — structure only. No breakpoints, no show/hide lists, no locale\n * overrides, no dividers/spacers, no hand-written overflow menus. What fits is\n * measured and solved at runtime (@embedpdf/core-ui); the overflow menu is\n * derived. Compare to the v2 snippet's 1,950-line ui-schema.ts.\n *\n * `importance` (1 sheds first … 5 pinned) is the only responsive knob.\n */\nimport {\n defineChrome,\n group,\n item,\n custom,\n type BarSchema,\n type ChromeSchema,\n type MenuSchema,\n} from '@embedpdf/react/toolbar';\n\n// Reused across every mode band — plain values, so composition is just a const.\nconst style = group('style', { importance: 4 }, [item('panel:annotation-style')]);\nconst history = group('history', { importance: 3 }, ['history:undo', 'history:redo']);\n\n// ── main toolbar ─────────────────────────────────────────────────────────────\nconst mainBar: BarSchema = {\n id: 'main',\n sections: {\n // v2 layout: everything before the first spacer sits LEFT-aligned —\n // document menu, workspace, zoom strip, pan/pointer. Only the mode tabs\n // are truly centered.\n start: [\n group('document', { importance: 5 }, [item('document:menu')]),\n group('workspace', { importance: 4 }, [\n item('panel:sidebar', { importance: 5 }),\n item('page:settings'),\n ]),\n // The inline zoom strip; when it can't fit it renders its 'button'\n // variant, and in the overflow menu it projects through zoom:menu.\n group('zoom', { importance: 4 }, [\n custom('zoom-controls', { variants: ['inline', 'button'], terminal: 'zoom:menu' }),\n ]),\n group('tools', { importance: 2 }, ['pan:toggle', 'pointer:toggle']),\n ],\n center: [\n group('modes', {\n role: 'tabs',\n // The group ladder: full strip → trailing tabs shed behind a derived\n // in-strip chevron (v2's overflow-tabs-button) → select (v2's\n // mode-select-button) → global overflow. Tab items at importance 1 so\n // the strip is the FIRST thing to compact; the group at 4 so its\n // compact forms survive long.\n shed: true,\n collapse: 'select',\n importance: 4,\n labelKey: 'commands.mode.group',\n items: [\n item('mode:view', { variants: ['label'], importance: 1 }),\n item('mode:annotate', { variants: ['label'], importance: 1 }),\n item('mode:shapes', { variants: ['label'], importance: 1 }),\n item('mode:insert', { variants: ['label'], importance: 1 }),\n item('mode:form', { variants: ['label'], importance: 1 }),\n item('mode:redact', { variants: ['label'], importance: 1 }),\n item('mode:measure', { variants: ['label'], importance: 1 }),\n ],\n }),\n ],\n end: [group('panels', { importance: 5 }, ['panel:search', 'panel:comment'])],\n },\n};\n\n// ── secondary bands (one per mode; which shows is derived from shell) ────────\nconst annotateBar: BarSchema = {\n id: 'annotate',\n sections: {\n center: [\n group('comment', { importance: 4 }, ['annotation:add-note', 'annotation:add-link']),\n group('markup', { importance: 4 }, [\n 'annotation:add-highlight',\n 'annotation:add-strikeout',\n 'annotation:add-underline',\n 'annotation:add-squiggly',\n ]),\n group('draw', { importance: 3 }, ['annotation:add-ink', 'annotation:add-ink-highlight']),\n group('text', { importance: 2 }, [\n 'annotation:add-text',\n 'annotation:add-insert-text',\n 'annotation:add-replace-text',\n 'annotation:add-callout',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst shapesBar: BarSchema = {\n id: 'shapes',\n sections: {\n center: [\n group('shapes', { importance: 4 }, [\n 'annotation:add-rectangle',\n 'annotation:add-circle',\n 'annotation:add-line',\n 'annotation:add-arrow',\n ]),\n group('polygons', { importance: 2 }, ['annotation:add-polygon', 'annotation:add-polyline']),\n style,\n history,\n ],\n },\n};\n\nconst insertBar: BarSchema = {\n id: 'insert',\n sections: {\n center: [\n group('stamps', { importance: 4 }, [\n 'insert:add-stamp',\n // Quick marks (`stamps.toolbar`): thumbnails that arm on click; in a\n // menu the stamps panel stands in for them.\n custom('quick-stamps', { terminal: 'insert:add-stamp', importance: 3 }),\n 'insert:add-attachment',\n 'insert:add-signature',\n 'insert:add-image',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst formBar: BarSchema = {\n id: 'form',\n sections: {\n center: [\n group('fields', { importance: 4 }, [\n 'form:add-textfield',\n 'form:add-checkbox',\n 'form:add-radio',\n ]),\n group('choice-fields', { importance: 2 }, ['form:add-select', 'form:add-listbox']),\n group('signature-fields', { importance: 2 }, ['form:add-signature']),\n history,\n ],\n },\n};\n\nconst measureBar: BarSchema = {\n id: 'measure',\n sections: {\n center: [\n group('measure', { importance: 5 }, [\n 'measurement:distance',\n 'measurement:perimeter',\n 'measurement:area',\n 'measurement:calibrate',\n ]),\n group('scale', { importance: 4 }, [\n custom('measurement-scale', { variants: ['inline'], terminal: 'panel:measurement' }),\n ]),\n style,\n ],\n },\n};\n\nconst redactBar: BarSchema = {\n id: 'redact',\n sections: {\n center: [\n group('redact', { importance: 4 }, ['redaction:redact', 'panel:redaction']),\n style,\n history,\n ],\n },\n};\n\n// ── menus (command trees; separators derive between sections) ────────────────\nconst documentMenu: MenuSchema = {\n id: 'document',\n sections: [\n { items: ['document:download', 'document:print'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\nconst zoomMenu: MenuSchema = {\n id: 'zoom',\n sections: [\n {\n labelKey: 'commands.zoom.level',\n items: ['zoom:50', 'zoom:100', 'zoom:150', 'zoom:200', 'zoom:400'],\n },\n { items: ['zoom:in', 'zoom:out'] },\n { items: ['zoom:fit-page', 'zoom:fit-width', 'zoom:automatic'] },\n ],\n};\n\nconst pageSettingsMenu: MenuSchema = {\n id: 'page-settings',\n sections: [\n { labelKey: 'commands.spread.group', items: ['spread:none', 'spread:odd', 'spread:even'] },\n { labelKey: 'commands.scroll.group', items: ['scroll:vertical', 'scroll:horizontal'] },\n { labelKey: 'commands.rotate.group', items: ['rotate:clockwise', 'rotate:counter-clockwise'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\n// ── contextual strips (anchored to selections; same BarSchema vocabulary) ────\n// WHICH commands actually show is each command's `visible` derivation (group\n// only when groupable, style only when the kind declares editable props…), so\n// one strip serves single AND multi selection — v2 needed two schemas for that.\nconst annotationStrip: BarSchema = {\n id: 'annotation-strip',\n sections: {\n center: [\n group('annotation-actions', { importance: 4 }, [\n 'annotation:comment',\n 'annotation:style',\n 'annotation:stamp-from-selection',\n 'annotation:link',\n 'annotation:goto-link',\n 'annotation:remove-link',\n 'annotation:group',\n 'annotation:ungroup',\n ]),\n // Its own group → a derived separator; delete stands apart.\n group('annotation-danger', { importance: 5 }, ['annotation:delete']),\n ],\n },\n};\n\n// The text-selection strip: appears when a text selection SETTLES (the menu\n// component gates on `isSelecting()`). One command today; \"Highlight\" et al.\n// are one more id here + one command — no component changes.\nconst selectionStrip: BarSchema = {\n id: 'selection-strip',\n sections: {\n center: [group('selection-actions', { importance: 4 }, ['selection:copy'])],\n },\n};\n\n/**\n * The DEFAULT chrome — exported as a VALUE, which is the whole customization\n * model: consumers pass nothing and track this, transform it, or write their\n * own. It is never merged with anything.\n */\nexport const defaultChrome = defineChrome({\n bars: { main: mainBar },\n modeBars: {\n 'mode:annotate': annotateBar,\n 'mode:shapes': shapesBar,\n 'mode:insert': insertBar,\n 'mode:form': formBar,\n 'mode:redact': redactBar,\n 'mode:measure': measureBar,\n },\n menus: { document: documentMenu, zoom: zoomMenu, 'page-settings': pageSettingsMenu },\n strips: { annotation: annotationStrip, selection: selectionStrip },\n});\n\n// Lookups take the RESOLVED schema (the host may have replaced the default) —\n// the typed literal widens to arbitrary string keys here, once.\n\n/** Menu lookup by id (arbitrary string). */\nexport function getMenu(schema: ChromeSchema, id: string): MenuSchema | undefined {\n return (schema.menus as Record<string, MenuSchema> | undefined)?.[id];\n}\n\n/** Secondary band lookup by mode-surface id. */\nexport function getModeBar(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.modeBars as Record<string, BarSchema> | undefined)?.[id];\n}\n\n/** Contextual strip lookup by context id ('annotation', …). */\nexport function getStrip(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.strips as Record<string, BarSchema> | undefined)?.[id];\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,SAAA,GAAA,wBAAA,MAAA,CAAc,SAAS,EAAE,YAAY,EAAE,GAAG,EAAA,GAAA,wBAAA,KAAA,CAAM,wBAAwB,CAAC,CAAC;AAChF,MAAM,WAAA,GAAA,wBAAA,MAAA,CAAgB,WAAW,EAAE,YAAY,EAAE,GAAG,CAAC,gBAAgB,cAAc,CAAC;AAGpF,MAAM,UAAqB;CACzB,IAAI;CACJ,UAAU;EAIR,OAAO;IACC,GAAA,wBAAA,MAAA,CAAA,YAAY,EAAE,YAAY,EAAE,GAAG,EAAA,GAAA,wBAAA,KAAA,CAAM,eAAe,CAAC,CAAC;IACtD,GAAA,wBAAA,MAAA,CAAA,aAAa,EAAE,YAAY,EAAE,GAAG,EAAA,GAAA,wBAAA,KAAA,CAC/B,iBAAiB,EAAE,YAAY,EAAE,CAAC,IAAA,GAAA,wBAAA,KAAA,CAClC,eAAe,CACtB,CAAC;IAGK,GAAA,wBAAA,MAAA,CAAA,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAA,GAAA,wBAAA,OAAA,CACxB,iBAAiB;IAAE,UAAU,CAAC,UAAU,QAAQ;IAAG,UAAU;GAAY,CAAC,CACnF,CAAC;IACK,G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R,QAAQ,EAAA,GAAA,wBAAA,MAAA,CAAO,qBAAqB,EAAE,YAAY,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAC5E;AACF;;;;;;AAOA,MAAa,iBAAA,GAAA,wBAAA,aAAA,CAA6B;CACxC,MAAM,EAAE,MAAM,QAAQ;CACtB,UAAU;EACR,iBAAiB;EACjB,eAAe;EACf,eAAe;EACf,aAAa;EACb,eAAe;EACf,gBAAgB;CAClB;CACA,OAAO;EAAE,UAAU;EAAc,MAAM;EAAU,iBAAiB;CAAiB;CACnF,QAAQ;EAAE,YAAY;EAAiB,WAAW;CAAe;AACnE,CAAC;;AAMD,SAAgB,QAAQ,QAAsB,IAAoC;CAChF,OAAQ,OAAO,QAAmD;AACpE;;AAGA,SAAgB,WAAW,QAAsB,IAAmC;CAClF,OAAQ,OAAO,WAAqD;AACtE;;AAGA,SAAgB,SAAS,QAAsB,IAAmC;CAChF,OAAQ,OAAO,SAAmD;AACpE"}
package/dist/chrome.d.cts CHANGED
@@ -15,6 +15,7 @@ declare const defaultChrome: {
15
15
  'mode:insert': BarSchema;
16
16
  'mode:form': BarSchema;
17
17
  'mode:redact': BarSchema;
18
+ 'mode:measure': BarSchema;
18
19
  };
19
20
  menus: {
20
21
  document: MenuSchema;
package/dist/chrome.d.ts CHANGED
@@ -15,6 +15,7 @@ declare const defaultChrome: {
15
15
  'mode:insert': BarSchema;
16
16
  'mode:form': BarSchema;
17
17
  'mode:redact': BarSchema;
18
+ 'mode:measure': BarSchema;
18
19
  };
19
20
  menus: {
20
21
  document: MenuSchema;
package/dist/chrome.js CHANGED
@@ -52,6 +52,10 @@ const mainBar = {
52
52
  item("mode:redact", {
53
53
  variants: ["label"],
54
54
  importance: 1
55
+ }),
56
+ item("mode:measure", {
57
+ variants: ["label"],
58
+ importance: 1
55
59
  })
56
60
  ]
57
61
  })],
@@ -98,6 +102,10 @@ const insertBar = {
98
102
  sections: { center: [
99
103
  group("stamps", { importance: 4 }, [
100
104
  "insert:add-stamp",
105
+ custom("quick-stamps", {
106
+ terminal: "insert:add-stamp",
107
+ importance: 3
108
+ }),
101
109
  "insert:add-attachment",
102
110
  "insert:add-signature",
103
111
  "insert:add-image"
@@ -115,9 +123,26 @@ const formBar = {
115
123
  "form:add-radio"
116
124
  ]),
117
125
  group("choice-fields", { importance: 2 }, ["form:add-select", "form:add-listbox"]),
126
+ group("signature-fields", { importance: 2 }, ["form:add-signature"]),
118
127
  history
119
128
  ] }
120
129
  };
130
+ const measureBar = {
131
+ id: "measure",
132
+ sections: { center: [
133
+ group("measure", { importance: 5 }, [
134
+ "measurement:distance",
135
+ "measurement:perimeter",
136
+ "measurement:area",
137
+ "measurement:calibrate"
138
+ ]),
139
+ group("scale", { importance: 4 }, [custom("measurement-scale", {
140
+ variants: ["inline"],
141
+ terminal: "panel:measurement"
142
+ })]),
143
+ style
144
+ ] }
145
+ };
121
146
  const redactBar = {
122
147
  id: "redact",
123
148
  sections: { center: [
@@ -202,7 +227,8 @@ const defaultChrome = defineChrome({
202
227
  "mode:shapes": shapesBar,
203
228
  "mode:insert": insertBar,
204
229
  "mode:form": formBar,
205
- "mode:redact": redactBar
230
+ "mode:redact": redactBar,
231
+ "mode:measure": measureBar
206
232
  },
207
233
  menus: {
208
234
  document: documentMenu,
@@ -1 +1 @@
1
- {"version":3,"file":"chrome.js","names":[],"sources":["../src/config/chrome.ts"],"sourcesContent":["/**\n * The chrome — structure only. No breakpoints, no show/hide lists, no locale\n * overrides, no dividers/spacers, no hand-written overflow menus. What fits is\n * measured and solved at runtime (@embedpdf/core-ui); the overflow menu is\n * derived. Compare to the v2 snippet's 1,950-line ui-schema.ts.\n *\n * `importance` (1 sheds first … 5 pinned) is the only responsive knob.\n */\nimport {\n defineChrome,\n group,\n item,\n custom,\n type BarSchema,\n type ChromeSchema,\n type MenuSchema,\n} from '@embedpdf/react/toolbar';\n\n// Reused across every mode band — plain values, so composition is just a const.\nconst style = group('style', { importance: 4 }, [item('panel:annotation-style')]);\nconst history = group('history', { importance: 3 }, ['history:undo', 'history:redo']);\n\n// ── main toolbar ─────────────────────────────────────────────────────────────\nconst mainBar: BarSchema = {\n id: 'main',\n sections: {\n // v2 layout: everything before the first spacer sits LEFT-aligned —\n // document menu, workspace, zoom strip, pan/pointer. Only the mode tabs\n // are truly centered.\n start: [\n group('document', { importance: 5 }, [item('document:menu')]),\n group('workspace', { importance: 4 }, [\n item('panel:sidebar', { importance: 5 }),\n item('page:settings'),\n ]),\n // The inline zoom strip; when it can't fit it renders its 'button'\n // variant, and in the overflow menu it projects through zoom:menu.\n group('zoom', { importance: 4 }, [\n custom('zoom-controls', { variants: ['inline', 'button'], terminal: 'zoom:menu' }),\n ]),\n group('tools', { importance: 2 }, ['pan:toggle', 'pointer:toggle']),\n ],\n center: [\n group('modes', {\n role: 'tabs',\n // The group ladder: full strip → trailing tabs shed behind a derived\n // in-strip chevron (v2's overflow-tabs-button) → select (v2's\n // mode-select-button) → global overflow. Tab items at importance 1 so\n // the strip is the FIRST thing to compact; the group at 4 so its\n // compact forms survive long.\n shed: true,\n collapse: 'select',\n importance: 4,\n labelKey: 'commands.mode.group',\n items: [\n item('mode:view', { variants: ['label'], importance: 1 }),\n item('mode:annotate', { variants: ['label'], importance: 1 }),\n item('mode:shapes', { variants: ['label'], importance: 1 }),\n item('mode:insert', { variants: ['label'], importance: 1 }),\n item('mode:form', { variants: ['label'], importance: 1 }),\n item('mode:redact', { variants: ['label'], importance: 1 }),\n ],\n }),\n ],\n end: [group('panels', { importance: 5 }, ['panel:search', 'panel:comment'])],\n },\n};\n\n// ── secondary bands (one per mode; which shows is derived from shell) ────────\nconst annotateBar: BarSchema = {\n id: 'annotate',\n sections: {\n center: [\n group('comment', { importance: 4 }, ['annotation:add-note', 'annotation:add-link']),\n group('markup', { importance: 4 }, [\n 'annotation:add-highlight',\n 'annotation:add-strikeout',\n 'annotation:add-underline',\n 'annotation:add-squiggly',\n ]),\n group('draw', { importance: 3 }, ['annotation:add-ink', 'annotation:add-ink-highlight']),\n group('text', { importance: 2 }, [\n 'annotation:add-text',\n 'annotation:add-insert-text',\n 'annotation:add-replace-text',\n 'annotation:add-callout',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst shapesBar: BarSchema = {\n id: 'shapes',\n sections: {\n center: [\n group('shapes', { importance: 4 }, [\n 'annotation:add-rectangle',\n 'annotation:add-circle',\n 'annotation:add-line',\n 'annotation:add-arrow',\n ]),\n group('polygons', { importance: 2 }, ['annotation:add-polygon', 'annotation:add-polyline']),\n style,\n history,\n ],\n },\n};\n\nconst insertBar: BarSchema = {\n id: 'insert',\n sections: {\n center: [\n group('stamps', { importance: 4 }, [\n 'insert:add-stamp',\n 'insert:add-attachment',\n 'insert:add-signature',\n 'insert:add-image',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst formBar: BarSchema = {\n id: 'form',\n sections: {\n center: [\n group('fields', { importance: 4 }, [\n 'form:add-textfield',\n 'form:add-checkbox',\n 'form:add-radio',\n ]),\n group('choice-fields', { importance: 2 }, ['form:add-select', 'form:add-listbox']),\n history,\n ],\n },\n};\n\nconst redactBar: BarSchema = {\n id: 'redact',\n sections: {\n center: [\n group('redact', { importance: 4 }, ['redaction:redact', 'panel:redaction']),\n style,\n history,\n ],\n },\n};\n\n// ── menus (command trees; separators derive between sections) ────────────────\nconst documentMenu: MenuSchema = {\n id: 'document',\n sections: [\n { items: ['document:download', 'document:print'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\nconst zoomMenu: MenuSchema = {\n id: 'zoom',\n sections: [\n {\n labelKey: 'commands.zoom.level',\n items: ['zoom:50', 'zoom:100', 'zoom:150', 'zoom:200', 'zoom:400'],\n },\n { items: ['zoom:in', 'zoom:out'] },\n { items: ['zoom:fit-page', 'zoom:fit-width', 'zoom:automatic'] },\n ],\n};\n\nconst pageSettingsMenu: MenuSchema = {\n id: 'page-settings',\n sections: [\n { labelKey: 'commands.spread.group', items: ['spread:none', 'spread:odd', 'spread:even'] },\n { labelKey: 'commands.scroll.group', items: ['scroll:vertical', 'scroll:horizontal'] },\n { labelKey: 'commands.rotate.group', items: ['rotate:clockwise', 'rotate:counter-clockwise'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\n// ── contextual strips (anchored to selections; same BarSchema vocabulary) ────\n// WHICH commands actually show is each command's `visible` derivation (group\n// only when groupable, style only when the kind declares editable props…), so\n// one strip serves single AND multi selection — v2 needed two schemas for that.\nconst annotationStrip: BarSchema = {\n id: 'annotation-strip',\n sections: {\n center: [\n group('annotation-actions', { importance: 4 }, [\n 'annotation:comment',\n 'annotation:style',\n 'annotation:stamp-from-selection',\n 'annotation:link',\n 'annotation:goto-link',\n 'annotation:remove-link',\n 'annotation:group',\n 'annotation:ungroup',\n ]),\n // Its own group → a derived separator; delete stands apart.\n group('annotation-danger', { importance: 5 }, ['annotation:delete']),\n ],\n },\n};\n\n// The text-selection strip: appears when a text selection SETTLES (the menu\n// component gates on `isSelecting()`). One command today; \"Highlight\" et al.\n// are one more id here + one command — no component changes.\nconst selectionStrip: BarSchema = {\n id: 'selection-strip',\n sections: {\n center: [group('selection-actions', { importance: 4 }, ['selection:copy'])],\n },\n};\n\n/**\n * The DEFAULT chrome — exported as a VALUE, which is the whole customization\n * model: consumers pass nothing and track this, transform it, or write their\n * own. It is never merged with anything.\n */\nexport const defaultChrome = defineChrome({\n bars: { main: mainBar },\n modeBars: {\n 'mode:annotate': annotateBar,\n 'mode:shapes': shapesBar,\n 'mode:insert': insertBar,\n 'mode:form': formBar,\n 'mode:redact': redactBar,\n },\n menus: { document: documentMenu, zoom: zoomMenu, 'page-settings': pageSettingsMenu },\n strips: { annotation: annotationStrip, selection: selectionStrip },\n});\n\n// Lookups take the RESOLVED schema (the host may have replaced the default) —\n// the typed literal widens to arbitrary string keys here, once.\n\n/** Menu lookup by id (arbitrary string). */\nexport function getMenu(schema: ChromeSchema, id: string): MenuSchema | undefined {\n return (schema.menus as Record<string, MenuSchema> | undefined)?.[id];\n}\n\n/** Secondary band lookup by mode-surface id. */\nexport function getModeBar(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.modeBars as Record<string, BarSchema> | undefined)?.[id];\n}\n\n/** Contextual strip lookup by context id ('annotation', …). */\nexport function getStrip(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.strips as Record<string, BarSchema> | undefined)?.[id];\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,QAAQ,MAAM,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC,KAAK,wBAAwB,CAAC,CAAC;AAChF,MAAM,UAAU,MAAM,WAAW,EAAE,YAAY,EAAE,GAAG,CAAC,gBAAgB,cAAc,CAAC;AAGpF,MAAM,UAAqB;CACzB,IAAI;CACJ,UAAU;EAIR,OAAO;GACL,MAAM,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,KAAK,eAAe,CAAC,CAAC;GAC5D,MAAM,aAAa,EAAE,YAAY,EAAE,GAAG,CACpC,KAAK,iBAAiB,EAAE,YAAY,EAAE,CAAC,GACvC,KAAK,eAAe,CACtB,CAAC;GAGD,MAAM,QAAQ,EAAE,YAAY,EAAE,GAAG,CAC/B,OAAO,iBAAiB;IAAE,UAAU,CAAC,UAAU,QAAQ;IAAG,UAAU;GAAY,CAAC,CACnF,CAAC;GACD,MAAM,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC,cAAc,gBAAgB,CAAC;EACpE;EACA,QAAQ,CACN,MAAM,SAAS;GACb,MAAM;GAMN,MAAM;GACN,UAAU;GACV,YAAY;GACZ,UAAU;GACV,OAAO;IACL,KAAK,aAAa;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IACxD,KAAK,iBAAiB;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IAC5D,KAAK,eAAe;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IAC1D,KAAK,eAAe;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IAC1D,KAAK,aAAa;KAAE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,aAAa;EACb,eAAe;CACjB;CACA,OAAO;EAAE,UAAU;EAAc,MAAM;EAAU,iBAAiB;CAAiB;CACnF,QAAQ;EAAE,YAAY;EAAiB,WAAW;CAAe;AACnE,CAAC;;AAMD,SAAgB,QAAQ,QAAsB,IAAoC;CAChF,OAAQ,OAAO,QAAmD;AACpE;;AAGA,SAAgB,WAAW,QAAsB,IAAmC;CAClF,OAAQ,OAAO,WAAqD;AACtE;;AAGA,SAAgB,SAAS,QAAsB,IAAmC;CAChF,OAAQ,OAAO,SAAmD;AACpE"}
1
+ {"version":3,"file":"chrome.js","names":[],"sources":["../src/config/chrome.ts"],"sourcesContent":["/**\n * The chrome — structure only. No breakpoints, no show/hide lists, no locale\n * overrides, no dividers/spacers, no hand-written overflow menus. What fits is\n * measured and solved at runtime (@embedpdf/core-ui); the overflow menu is\n * derived. Compare to the v2 snippet's 1,950-line ui-schema.ts.\n *\n * `importance` (1 sheds first … 5 pinned) is the only responsive knob.\n */\nimport {\n defineChrome,\n group,\n item,\n custom,\n type BarSchema,\n type ChromeSchema,\n type MenuSchema,\n} from '@embedpdf/react/toolbar';\n\n// Reused across every mode band — plain values, so composition is just a const.\nconst style = group('style', { importance: 4 }, [item('panel:annotation-style')]);\nconst history = group('history', { importance: 3 }, ['history:undo', 'history:redo']);\n\n// ── main toolbar ─────────────────────────────────────────────────────────────\nconst mainBar: BarSchema = {\n id: 'main',\n sections: {\n // v2 layout: everything before the first spacer sits LEFT-aligned —\n // document menu, workspace, zoom strip, pan/pointer. Only the mode tabs\n // are truly centered.\n start: [\n group('document', { importance: 5 }, [item('document:menu')]),\n group('workspace', { importance: 4 }, [\n item('panel:sidebar', { importance: 5 }),\n item('page:settings'),\n ]),\n // The inline zoom strip; when it can't fit it renders its 'button'\n // variant, and in the overflow menu it projects through zoom:menu.\n group('zoom', { importance: 4 }, [\n custom('zoom-controls', { variants: ['inline', 'button'], terminal: 'zoom:menu' }),\n ]),\n group('tools', { importance: 2 }, ['pan:toggle', 'pointer:toggle']),\n ],\n center: [\n group('modes', {\n role: 'tabs',\n // The group ladder: full strip → trailing tabs shed behind a derived\n // in-strip chevron (v2's overflow-tabs-button) → select (v2's\n // mode-select-button) → global overflow. Tab items at importance 1 so\n // the strip is the FIRST thing to compact; the group at 4 so its\n // compact forms survive long.\n shed: true,\n collapse: 'select',\n importance: 4,\n labelKey: 'commands.mode.group',\n items: [\n item('mode:view', { variants: ['label'], importance: 1 }),\n item('mode:annotate', { variants: ['label'], importance: 1 }),\n item('mode:shapes', { variants: ['label'], importance: 1 }),\n item('mode:insert', { variants: ['label'], importance: 1 }),\n item('mode:form', { variants: ['label'], importance: 1 }),\n item('mode:redact', { variants: ['label'], importance: 1 }),\n item('mode:measure', { variants: ['label'], importance: 1 }),\n ],\n }),\n ],\n end: [group('panels', { importance: 5 }, ['panel:search', 'panel:comment'])],\n },\n};\n\n// ── secondary bands (one per mode; which shows is derived from shell) ────────\nconst annotateBar: BarSchema = {\n id: 'annotate',\n sections: {\n center: [\n group('comment', { importance: 4 }, ['annotation:add-note', 'annotation:add-link']),\n group('markup', { importance: 4 }, [\n 'annotation:add-highlight',\n 'annotation:add-strikeout',\n 'annotation:add-underline',\n 'annotation:add-squiggly',\n ]),\n group('draw', { importance: 3 }, ['annotation:add-ink', 'annotation:add-ink-highlight']),\n group('text', { importance: 2 }, [\n 'annotation:add-text',\n 'annotation:add-insert-text',\n 'annotation:add-replace-text',\n 'annotation:add-callout',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst shapesBar: BarSchema = {\n id: 'shapes',\n sections: {\n center: [\n group('shapes', { importance: 4 }, [\n 'annotation:add-rectangle',\n 'annotation:add-circle',\n 'annotation:add-line',\n 'annotation:add-arrow',\n ]),\n group('polygons', { importance: 2 }, ['annotation:add-polygon', 'annotation:add-polyline']),\n style,\n history,\n ],\n },\n};\n\nconst insertBar: BarSchema = {\n id: 'insert',\n sections: {\n center: [\n group('stamps', { importance: 4 }, [\n 'insert:add-stamp',\n // Quick marks (`stamps.toolbar`): thumbnails that arm on click; in a\n // menu the stamps panel stands in for them.\n custom('quick-stamps', { terminal: 'insert:add-stamp', importance: 3 }),\n 'insert:add-attachment',\n 'insert:add-signature',\n 'insert:add-image',\n ]),\n style,\n history,\n ],\n },\n};\n\nconst formBar: BarSchema = {\n id: 'form',\n sections: {\n center: [\n group('fields', { importance: 4 }, [\n 'form:add-textfield',\n 'form:add-checkbox',\n 'form:add-radio',\n ]),\n group('choice-fields', { importance: 2 }, ['form:add-select', 'form:add-listbox']),\n group('signature-fields', { importance: 2 }, ['form:add-signature']),\n history,\n ],\n },\n};\n\nconst measureBar: BarSchema = {\n id: 'measure',\n sections: {\n center: [\n group('measure', { importance: 5 }, [\n 'measurement:distance',\n 'measurement:perimeter',\n 'measurement:area',\n 'measurement:calibrate',\n ]),\n group('scale', { importance: 4 }, [\n custom('measurement-scale', { variants: ['inline'], terminal: 'panel:measurement' }),\n ]),\n style,\n ],\n },\n};\n\nconst redactBar: BarSchema = {\n id: 'redact',\n sections: {\n center: [\n group('redact', { importance: 4 }, ['redaction:redact', 'panel:redaction']),\n style,\n history,\n ],\n },\n};\n\n// ── menus (command trees; separators derive between sections) ────────────────\nconst documentMenu: MenuSchema = {\n id: 'document',\n sections: [\n { items: ['document:download', 'document:print'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\nconst zoomMenu: MenuSchema = {\n id: 'zoom',\n sections: [\n {\n labelKey: 'commands.zoom.level',\n items: ['zoom:50', 'zoom:100', 'zoom:150', 'zoom:200', 'zoom:400'],\n },\n { items: ['zoom:in', 'zoom:out'] },\n { items: ['zoom:fit-page', 'zoom:fit-width', 'zoom:automatic'] },\n ],\n};\n\nconst pageSettingsMenu: MenuSchema = {\n id: 'page-settings',\n sections: [\n { labelKey: 'commands.spread.group', items: ['spread:none', 'spread:odd', 'spread:even'] },\n { labelKey: 'commands.scroll.group', items: ['scroll:vertical', 'scroll:horizontal'] },\n { labelKey: 'commands.rotate.group', items: ['rotate:clockwise', 'rotate:counter-clockwise'] },\n { items: ['document:fullscreen'] },\n ],\n};\n\n// ── contextual strips (anchored to selections; same BarSchema vocabulary) ────\n// WHICH commands actually show is each command's `visible` derivation (group\n// only when groupable, style only when the kind declares editable props…), so\n// one strip serves single AND multi selection — v2 needed two schemas for that.\nconst annotationStrip: BarSchema = {\n id: 'annotation-strip',\n sections: {\n center: [\n group('annotation-actions', { importance: 4 }, [\n 'annotation:comment',\n 'annotation:style',\n 'annotation:stamp-from-selection',\n 'annotation:link',\n 'annotation:goto-link',\n 'annotation:remove-link',\n 'annotation:group',\n 'annotation:ungroup',\n ]),\n // Its own group → a derived separator; delete stands apart.\n group('annotation-danger', { importance: 5 }, ['annotation:delete']),\n ],\n },\n};\n\n// The text-selection strip: appears when a text selection SETTLES (the menu\n// component gates on `isSelecting()`). One command today; \"Highlight\" et al.\n// are one more id here + one command — no component changes.\nconst selectionStrip: BarSchema = {\n id: 'selection-strip',\n sections: {\n center: [group('selection-actions', { importance: 4 }, ['selection:copy'])],\n },\n};\n\n/**\n * The DEFAULT chrome — exported as a VALUE, which is the whole customization\n * model: consumers pass nothing and track this, transform it, or write their\n * own. It is never merged with anything.\n */\nexport const defaultChrome = defineChrome({\n bars: { main: mainBar },\n modeBars: {\n 'mode:annotate': annotateBar,\n 'mode:shapes': shapesBar,\n 'mode:insert': insertBar,\n 'mode:form': formBar,\n 'mode:redact': redactBar,\n 'mode:measure': measureBar,\n },\n menus: { document: documentMenu, zoom: zoomMenu, 'page-settings': pageSettingsMenu },\n strips: { annotation: annotationStrip, selection: selectionStrip },\n});\n\n// Lookups take the RESOLVED schema (the host may have replaced the default) —\n// the typed literal widens to arbitrary string keys here, once.\n\n/** Menu lookup by id (arbitrary string). */\nexport function getMenu(schema: ChromeSchema, id: string): MenuSchema | undefined {\n return (schema.menus as Record<string, MenuSchema> | undefined)?.[id];\n}\n\n/** Secondary band lookup by mode-surface id. */\nexport function getModeBar(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.modeBars as Record<string, BarSchema> | undefined)?.[id];\n}\n\n/** Contextual strip lookup by context id ('annotation', …). */\nexport function getStrip(schema: ChromeSchema, id: string): BarSchema | undefined {\n return (schema.strips as Record<string, BarSchema> | undefined)?.[id];\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,QAAQ,MAAM,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC,KAAK,wBAAwB,CAAC,CAAC;AAChF,MAAM,UAAU,MAAM,WAAW,EAAE,YAAY,EAAE,GAAG,CAAC,gBAAgB,cAAc,CAAC;AAGpF,MAAM,UAAqB;CACzB,IAAI;CACJ,UAAU;EAIR,OAAO;GACL,MAAM,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,KAAK,eAAe,CAAC,CAAC;GAC5D,MAAM,aAAa,EAAE,YAAY,EAAE,GAAG,CACpC,KAAK,iBAAiB,EAAE,YAAY,EAAE,CAAC,GACvC,KAAK,eAAe,CACtB,CAAC;GAGD,MAAM,QAAQ,EAAE,YAAY,EAAE,GAAG,CAC/B,OAAO,iBAAiB;IAAE,UAAU,CAAC,UAAU,QAAQ;IAAG,UAAU;GAAY,CAAC,CACnF,CAAC;GACD,MAAM,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC,cAAc,gBAAgB,CAAC;EACpE;EACA,QAAQ,CACN,MAAM,SAAS;GACb,MAAM;GAMN,MAAM;GACN,UAAU;GACV,YAAY;GACZ,UAAU;GACV,OAAO;IACL,KAAK,aAAa;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IACxD,KAAK,iBAAiB;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IAC5D,KAAK,eAAe;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IAC1D,KAAK,eAAe;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IAC1D,KAAK,aAAa;KAAE,UAAU,CAAC,OAAO;KAAG,YAAY;IAAE,CAAC;IACxD,KAAK,e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AAE,YAAY,EAAE,GAAG;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GAED,MAAM,qBAAqB,EAAE,YAAY,EAAE,GAAG,CAAC,mBAAmB,CAAC,CACrE,EACF;AACF;AAKA,MAAM,iBAA4B;CAChC,IAAI;CACJ,UAAU,EACR,QAAQ,CAAC,MAAM,qBAAqB,EAAE,YAAY,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAC5E;AACF;;;;;;AAOA,MAAa,gBAAgB,aAAa;CACxC,MAAM,EAAE,MAAM,QAAQ;CACtB,UAAU;EACR,iBAAiB;EACjB,eAAe;EACf,eAAe;EACf,aAAa;EACb,eAAe;EACf,gBAAgB;CAClB;CACA,OAAO;EAAE,UAAU;EAAc,MAAM;EAAU,iBAAiB;CAAiB;CACnF,QAAQ;EAAE,YAAY;EAAiB,WAAW;CAAe;AACnE,CAAC;;AAMD,SAAgB,QAAQ,QAAsB,IAAoC;CAChF,OAAQ,OAAO,QAAmD;AACpE;;AAGA,SAAgB,WAAW,QAAsB,IAAmC;CAClF,OAAQ,OAAO,WAAqD;AACtE;;AAGA,SAAgB,SAAS,QAAsB,IAAmC;CAChF,OAAQ,OAAO,SAAmD;AACpE"}
package/dist/commands.cjs CHANGED
@@ -5,9 +5,11 @@ let _embedpdf_react_interaction = require("@embedpdf/react/interaction");
5
5
  let _embedpdf_react_selection = require("@embedpdf/react/selection");
6
6
  let _embedpdf_react_annotation = require("@embedpdf/react/annotation");
7
7
  let _embedpdf_react_stamp = require("@embedpdf/react/stamp");
8
+ let _embedpdf_react_measurement = require("@embedpdf/react/measurement");
8
9
  let _embedpdf_react_redaction = require("@embedpdf/react/redaction");
9
10
  let _embedpdf_react_actions = require("@embedpdf/react/actions");
10
11
  let _embedpdf_react_form = require("@embedpdf/react/form");
12
+ let _embedpdf_react_signature = require("@embedpdf/react/signature");
11
13
  let _embedpdf_react_link = require("@embedpdf/react/link");
12
14
  let _embedpdf_react_search = require("@embedpdf/react/search");
13
15
  let _embedpdf_react_i18n = require("@embedpdf/react/i18n");
@@ -325,6 +327,7 @@ const defaultCommands = [
325
327
  modeCommand("mode:insert", "commands.mode.insert"),
326
328
  modeCommand("mode:form", "commands.mode.form", "form-edit"),
327
329
  modeCommand("mode:redact", "commands.mode.redact"),
330
+ modeCommand("mode:measure", "commands.mode.measure"),
328
331
  tool("annotation:add-highlight", "highlight", "commands.annotate.highlight", "highlight", { primary: "color" }),
329
332
  tool("annotation:add-strikeout", "strikeout", "commands.annotate.strikeout", "strikethrough", { primary: "color" }),
330
333
  tool("annotation:add-underline", "underline", "commands.annotate.underline", "underline", { primary: "color" }),
@@ -368,13 +371,25 @@ const defaultCommands = [
368
371
  }
369
372
  },
370
373
  tool("insert:add-attachment", "attachment", "commands.insert.attachment", "paperclip"),
371
- tool("insert:add-signature", "signature", "commands.insert.signature", "signature"),
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
+ },
372
386
  tool("insert:add-image", "image", "commands.insert.image", "photo"),
373
387
  tool("form:add-textfield", "form-text", "commands.form.textfield", "formTextfield"),
374
388
  tool("form:add-checkbox", "form-checkbox", "commands.form.checkbox", "formCheckbox"),
375
389
  tool("form:add-radio", "form-radio", "commands.form.radio", "formRadio"),
376
390
  tool("form:add-select", "form-combobox", "commands.form.select", "formSelect"),
377
391
  tool("form:add-listbox", "form-listbox", "commands.form.listbox", "formListbox"),
392
+ tool("form:add-signature", "form-signature", "commands.form.signature", "signature"),
378
393
  tool("redaction:redact", "redact", "commands.redact.mark", "redactArea"),
379
394
  {
380
395
  id: "panel:redaction",
@@ -390,6 +405,57 @@ const defaultCommands = [
390
405
  exclusive: "right"
391
406
  }
392
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
+ },
393
459
  {
394
460
  id: "annotation:delete",
395
461
  labelKey: "commands.annotate.delete",
@@ -560,7 +626,8 @@ const MODE_SURFACES = [
560
626
  "mode:shapes",
561
627
  "mode:insert",
562
628
  "mode:form",
563
- "mode:redact"
629
+ "mode:redact",
630
+ "mode:measure"
564
631
  ];
565
632
  function modeCommand(id, labelKey, toolId = "pointer") {
566
633
  return {