@embedpdf/plugin-commands 3.1.0 → 3.2.0

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 (2) hide show
  1. package/README.md +51 -0
  2. package/package.json +11 -11
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ <!-- Generated from docs/content/headless/ui/commands.mdx by docs/content/scripts/readmes.mjs. Edit there, then run `pnpm readme:sync`. -->
2
+
3
+ # @embedpdf/plugin-commands
4
+
5
+ Commands for EmbedPDF: named actions with a label, an icon, a state and a shortcut, for toolbars, menus and the keyboard.
6
+
7
+ This plugin comes with each EmbedPDF framework package. Import it from the one you use:
8
+
9
+ | Framework | Import from | Docs |
10
+ | :-------- | :---------- | :--- |
11
+ | React | `@embedpdf/react/commands` | [Commands & shortcuts](https://www.embedpdf.com/docs/headless/react/ui/commands) |
12
+ | Vue | `@embedpdf/vue/commands` | [Commands & shortcuts](https://www.embedpdf.com/docs/headless/vue/ui/commands) |
13
+ | Svelte | `@embedpdf/svelte/commands` | [Commands & shortcuts](https://www.embedpdf.com/docs/headless/svelte/ui/commands) |
14
+ | Angular | `@embedpdf/angular/commands` | [Commands & shortcuts](https://www.embedpdf.com/docs/headless/angular/ui/commands) |
15
+
16
+ ## In React
17
+
18
+ A **command** is one action of your viewer, like "zoom in" or "download", defined once: its label, its
19
+ icon, when it's enabled or active, what it does, and its keyboard shortcut. Toolbars, menus, a command
20
+ palette and the keyboard all run the same command, so they always agree. Register the plugin with the
21
+ commands you need:
22
+
23
+ **`commands-plugin.tsx`**
24
+
25
+ ```tsx
26
+ import { AnnotationToken } from '@embedpdf/react/annotation';
27
+ import { commandsPlugin, standardCommands } from '@embedpdf/react/commands';
28
+ import { DocumentsToken } from '@embedpdf/react/runtime';
29
+ import { approveDocument } from './review';
30
+
31
+ export const plugins = [
32
+ /* … */
33
+ commandsPlugin({
34
+ commands: [
35
+ ...standardCommands,
36
+ {
37
+ id: 'review:approve',
38
+ label: 'Approve',
39
+ icon: 'check',
40
+ shortcut: 'Mod+Enter',
41
+ enabled: ({ get }) => get(AnnotationToken).canCreate(),
42
+ run: ({ get }) => approveDocument(get(DocumentsToken)),
43
+ },
44
+ ],
45
+ }),
46
+ ];
47
+ ```
48
+
49
+ ## License
50
+
51
+ Apache-2.0
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-commands",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
- "description": "The commands: one name per action of the viewer, with its label, icon, state and shortcut, which toolbars, menus, a command palette and the keyboard all show and run. A command's state is read from live state, so every reader follows the kernel's one change stream. `/standard` has the commands every viewer has.",
5
+ "description": "Commands for EmbedPDF: named actions with a label, an icon, a state and a shortcut, for toolbars, menus and the keyboard.",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.js",
@@ -30,15 +30,15 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@embedpdf/core-ui": "3.1.0",
34
- "@embedpdf/core": "3.1.0",
35
- "@embedpdf/plugin-annotation": "3.1.0",
36
- "@embedpdf/plugin-i18n": "3.1.0",
37
- "@embedpdf/plugin-interaction": "3.1.0",
38
- "@embedpdf/plugin-render": "3.1.0",
39
- "@embedpdf/plugin-selection": "3.1.0",
40
- "@embedpdf/plugin-shell": "3.1.0",
41
- "@embedpdf/plugin-stage": "3.1.0"
33
+ "@embedpdf/core": "3.2.0",
34
+ "@embedpdf/core-ui": "3.2.0",
35
+ "@embedpdf/plugin-annotation": "3.2.0",
36
+ "@embedpdf/plugin-i18n": "3.2.0",
37
+ "@embedpdf/plugin-selection": "3.2.0",
38
+ "@embedpdf/plugin-interaction": "3.2.0",
39
+ "@embedpdf/plugin-render": "3.2.0",
40
+ "@embedpdf/plugin-stage": "3.2.0",
41
+ "@embedpdf/plugin-shell": "3.2.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "typescript": "^5.0.0",