@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.
- package/README.md +51 -0
- 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.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
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
|
|
34
|
-
"@embedpdf/core": "3.
|
|
35
|
-
"@embedpdf/plugin-annotation": "3.
|
|
36
|
-
"@embedpdf/plugin-i18n": "3.
|
|
37
|
-
"@embedpdf/plugin-
|
|
38
|
-
"@embedpdf/plugin-
|
|
39
|
-
"@embedpdf/plugin-
|
|
40
|
-
"@embedpdf/plugin-
|
|
41
|
-
"@embedpdf/plugin-
|
|
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",
|