Skip to content

Commit ab7253d

Browse files
committed
Add plugin-commands package with multi-framework support
Introduces the @embedpdf/plugin-commands package, providing a cross-framework (React, Preact, Vue, Svelte) commands plugin for the EmbedPDF platform. Includes core plugin logic, state management, keyboard shortcut handling, framework adapters, shared hooks/utilities, and configuration files for building and type safety.
1 parent 0455681 commit ab7253d

37 files changed

Lines changed: 1118 additions & 0 deletions
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"name": "@embedpdf/plugin-commands",
3+
"version": "1.0.0",
4+
"type": "module",
5+
"license": "MIT",
6+
"main": "./dist/index.cjs",
7+
"module": "./dist/index.js",
8+
"types": "./dist/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/index.d.ts",
12+
"import": "./dist/index.js",
13+
"require": "./dist/index.cjs"
14+
},
15+
"./preact": {
16+
"types": "./dist/preact/index.d.ts",
17+
"import": "./dist/preact/index.js",
18+
"require": "./dist/preact/index.cjs"
19+
},
20+
"./react": {
21+
"types": "./dist/react/index.d.ts",
22+
"import": "./dist/react/index.js",
23+
"require": "./dist/react/index.cjs"
24+
},
25+
"./vue": {
26+
"types": "./dist/vue/index.d.ts",
27+
"import": "./dist/vue/index.js",
28+
"require": "./dist/vue/index.cjs"
29+
},
30+
"./svelte": {
31+
"types": "./dist/svelte/index.d.ts",
32+
"svelte": "./dist/svelte/index.js",
33+
"import": "./dist/svelte/index.js",
34+
"require": "./dist/svelte/index.cjs"
35+
}
36+
},
37+
"scripts": {
38+
"build:base": "vite build --mode base",
39+
"build:react": "vite build --mode react",
40+
"build:preact": "vite build --mode preact",
41+
"build:vue": "vite build --mode vue",
42+
"build:svelte": "vite build --mode svelte",
43+
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
44+
"clean": "rimraf dist",
45+
"lint": "eslint src --color",
46+
"lint:fix": "eslint src --color --fix"
47+
},
48+
"dependencies": {
49+
"@embedpdf/models": "workspace:*"
50+
},
51+
"devDependencies": {
52+
"@embedpdf/build": "workspace:*",
53+
"@embedpdf/core": "workspace:*",
54+
"@embedpdf/plugin-i18n": "workspace:*",
55+
"@types/react": "^18.2.0",
56+
"typescript": "^5.0.0"
57+
},
58+
"peerDependencies": {
59+
"@embedpdf/core": "workspace:*",
60+
"react": ">=16.8.0",
61+
"react-dom": ">=16.8.0",
62+
"preact": "^10.26.4",
63+
"vue": ">=3.2.0",
64+
"svelte": ">=5 <6"
65+
},
66+
"files": [
67+
"dist",
68+
"README.md"
69+
],
70+
"repository": {
71+
"type": "git",
72+
"url": "https://github.com/embedpdf/embed-pdf-viewer",
73+
"directory": "packages/plugin-commands"
74+
},
75+
"homepage": "https://www.embedpdf.com/docs",
76+
"bugs": {
77+
"url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
78+
},
79+
"publishConfig": {
80+
"access": "public"
81+
}
82+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib';
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Action } from '@embedpdf/core';
2+
3+
export const REGISTER_COMMAND = 'COMMANDS/REGISTER';
4+
export const UNREGISTER_COMMAND = 'COMMANDS/UNREGISTER';
5+
export const MARK_COMMANDS_CHANGED = 'COMMANDS/MARK_CHANGED';
6+
export const CLEAR_CHANGED_COMMANDS = 'COMMANDS/CLEAR_CHANGED';
7+
8+
export interface RegisterCommandAction extends Action {
9+
type: typeof REGISTER_COMMAND;
10+
payload: string; // commandId
11+
}
12+
13+
export interface UnregisterCommandAction extends Action {
14+
type: typeof UNREGISTER_COMMAND;
15+
payload: string; // commandId
16+
}
17+
18+
export interface MarkCommandsChangedAction extends Action {
19+
type: typeof MARK_COMMANDS_CHANGED;
20+
payload: string[]; // commandIds
21+
}
22+
23+
export interface ClearChangedCommandsAction extends Action {
24+
type: typeof CLEAR_CHANGED_COMMANDS;
25+
}
26+
27+
export type CommandsAction =
28+
| RegisterCommandAction
29+
| UnregisterCommandAction
30+
| MarkCommandsChangedAction
31+
| ClearChangedCommandsAction;
32+
33+
export const registerCommand = (commandId: string): RegisterCommandAction => ({
34+
type: REGISTER_COMMAND,
35+
payload: commandId,
36+
});
37+
38+
export const unregisterCommand = (commandId: string): UnregisterCommandAction => ({
39+
type: UNREGISTER_COMMAND,
40+
payload: commandId,
41+
});
42+
43+
export const markCommandsChanged = (commandIds: string[]): MarkCommandsChangedAction => ({
44+
type: MARK_COMMANDS_CHANGED,
45+
payload: commandIds,
46+
});
47+
48+
export const clearChangedCommands = (): ClearChangedCommandsAction => ({
49+
type: CLEAR_CHANGED_COMMANDS,
50+
});

0 commit comments

Comments
 (0)