@embedpdf/angular 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.
- package/README.md +309 -0
- package/dist/README.md +309 -0
- package/dist/actions/index.d.ts +34 -16
- package/dist/anchored/index.d.ts +67 -0
- package/dist/annotation/index.d.ts +602 -0
- package/dist/attachment/index.d.ts +29 -0
- package/dist/commands/index.d.ts +109 -0
- package/dist/fesm2022/embedpdf-angular-actions.mjs +117 -36
- package/dist/fesm2022/embedpdf-angular-actions.mjs.map +1 -1
- package/dist/fesm2022/embedpdf-angular-anchored.mjs +148 -0
- package/dist/fesm2022/embedpdf-angular-anchored.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-annotation.mjs +1933 -0
- package/dist/fesm2022/embedpdf-angular-annotation.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-attachment.mjs +67 -0
- package/dist/fesm2022/embedpdf-angular-attachment.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-commands.mjs +235 -0
- package/dist/fesm2022/embedpdf-angular-commands.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-form.mjs +1074 -0
- package/dist/fesm2022/embedpdf-angular-form.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-history.mjs +54 -0
- package/dist/fesm2022/embedpdf-angular-history.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-i18n.mjs +100 -0
- package/dist/fesm2022/embedpdf-angular-i18n.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-interaction.mjs +157 -0
- package/dist/fesm2022/embedpdf-angular-interaction.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-link.mjs +306 -0
- package/dist/fesm2022/embedpdf-angular-link.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-measurement.mjs +106 -0
- package/dist/fesm2022/embedpdf-angular-measurement.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-metadata.mjs +77 -0
- package/dist/fesm2022/embedpdf-angular-metadata.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-outline.mjs +76 -0
- package/dist/fesm2022/embedpdf-angular-outline.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-page-edit.mjs +68 -0
- package/dist/fesm2022/embedpdf-angular-page-edit.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-page-view.mjs +297 -0
- package/dist/fesm2022/embedpdf-angular-page-view.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-redaction.mjs +93 -0
- package/dist/fesm2022/embedpdf-angular-redaction.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-render.mjs +331 -69
- package/dist/fesm2022/embedpdf-angular-render.mjs.map +1 -1
- package/dist/fesm2022/embedpdf-angular-runtime.mjs +1151 -390
- package/dist/fesm2022/embedpdf-angular-runtime.mjs.map +1 -1
- package/dist/fesm2022/embedpdf-angular-search.mjs +251 -0
- package/dist/fesm2022/embedpdf-angular-search.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-selection.mjs +477 -0
- package/dist/fesm2022/embedpdf-angular-selection.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-shell.mjs +177 -0
- package/dist/fesm2022/embedpdf-angular-shell.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-signature.mjs +120 -0
- package/dist/fesm2022/embedpdf-angular-signature.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-stage.mjs +688 -288
- package/dist/fesm2022/embedpdf-angular-stage.mjs.map +1 -1
- package/dist/fesm2022/embedpdf-angular-stamp.mjs +169 -0
- package/dist/fesm2022/embedpdf-angular-stamp.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-testing.mjs +89 -0
- package/dist/fesm2022/embedpdf-angular-testing.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-toolbar.mjs +1123 -0
- package/dist/fesm2022/embedpdf-angular-toolbar.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular-view-manager.mjs +69 -0
- package/dist/fesm2022/embedpdf-angular-view-manager.mjs.map +1 -0
- package/dist/fesm2022/embedpdf-angular.mjs +25 -3
- package/dist/fesm2022/embedpdf-angular.mjs.map +1 -1
- package/dist/form/index.d.ts +79 -0
- package/dist/history/index.d.ts +28 -0
- package/dist/i18n/index.d.ts +52 -0
- package/dist/index.d.ts +22 -0
- package/dist/interaction/index.d.ts +58 -0
- package/dist/link/index.d.ts +77 -0
- package/dist/measurement/index.d.ts +46 -0
- package/dist/metadata/index.d.ts +51 -0
- package/dist/outline/index.d.ts +32 -0
- package/dist/page-edit/index.d.ts +27 -0
- package/dist/page-view/index.d.ts +94 -0
- package/dist/redaction/index.d.ts +38 -0
- package/dist/render/index.d.ts +45 -6
- package/dist/runtime/index.d.ts +579 -199
- package/dist/search/index.d.ts +71 -0
- package/dist/selection/index.d.ts +141 -0
- package/dist/shell/index.d.ts +88 -0
- package/dist/signature/index.d.ts +45 -0
- package/dist/stage/index.d.ts +242 -141
- package/dist/stamp/index.d.ts +58 -0
- package/dist/testing/index.d.ts +53 -0
- package/dist/toolbar/index.d.ts +257 -0
- package/dist/view-manager/index.d.ts +23 -0
- package/package.json +145 -14
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { CommandsToken, resolvedCommandsEqual, unknownCommandWarning, boundCommandOf, unregisteredCommand, commandsPlugin } from '@embedpdf/plugin-commands';
|
|
2
|
+
export * from '@embedpdf/plugin-commands';
|
|
3
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { computed, Injectable, inject, effect, output, ElementRef, PLATFORM_ID, Directive, input, untracked } from '@angular/core';
|
|
6
|
+
import { pluginService, devWarn, CapabilityBinding, EpdfKernelHost, injectKernelHost } from '@embedpdf/angular/runtime';
|
|
7
|
+
import { formatShortcut as formatShortcut$1 } from '@embedpdf/core-ui';
|
|
8
|
+
import { CommandsToken as CommandsToken$1 } from '@embedpdf/plugin-commands/contract/host';
|
|
9
|
+
import { createStandardCommands } from '@embedpdf/plugin-commands/standard';
|
|
10
|
+
import { standardCommandsBrowser, isMacPlatform, bindCommandShortcuts } from '@embedpdf/web';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The commands plugin's service, features and directives: every action of the viewer, with its
|
|
14
|
+
* label, icon, state and shortcut, run from buttons, menus and keys.
|
|
15
|
+
*
|
|
16
|
+
* withCommands({ commands }) the plugin, for provideEmbedPdf()
|
|
17
|
+
* withCommandShortcuts() every command's shortcut as a working key
|
|
18
|
+
* inject(EpdfCommands) `execute()`, `searchCommands()`, `executed$`, the settings
|
|
19
|
+
* <button [epdfCommand]="'zoom:in'"> a button of yours that runs and shows a command
|
|
20
|
+
* <div epdfCommandShortcuts> the keys, only while focus is inside that element
|
|
21
|
+
*
|
|
22
|
+
* A command's state is read from live state, so what shows a command follows the viewer's one
|
|
23
|
+
* change stream and changes only when what the command shows did.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* The commands every viewer has: zoom, pages, view rotation, `tool:<id>` for every tool, copy,
|
|
27
|
+
* delete, download and print, with shortcuts and labels in EmbedPDF's eight languages. Spread
|
|
28
|
+
* them into `withCommands({ commands })`.
|
|
29
|
+
*/
|
|
30
|
+
const standardCommands = /* @__PURE__ */ createStandardCommands(standardCommandsBrowser);
|
|
31
|
+
/** A shortcut as a tooltip shows it, for this platform: `'⌘K'` on a Mac, `'Ctrl+K'` elsewhere. */
|
|
32
|
+
function formatShortcut(shortcut, options = {}) {
|
|
33
|
+
return formatShortcut$1(shortcut, { isMac: options.isMac ?? isMacPlatform() });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The commands: `execute()`, `canExecute()`, `resolveCommand()`, `searchCommands()`,
|
|
37
|
+
* `listShortcuts()`, `registerCommand()`, the categories, `executed$` and
|
|
38
|
+
* `executionFailed$`, and the settings. A call that leaves out the document is for this part
|
|
39
|
+
* of the template's document: the one `[epdfDocumentScope]` names, else the active one.
|
|
40
|
+
*/
|
|
41
|
+
class EpdfCommands extends pluginService({
|
|
42
|
+
name: 'EpdfCommands',
|
|
43
|
+
feature: 'withCommands()',
|
|
44
|
+
token: CommandsToken,
|
|
45
|
+
methods: [
|
|
46
|
+
'execute',
|
|
47
|
+
'canExecute',
|
|
48
|
+
'resolveCommand',
|
|
49
|
+
'listCommands',
|
|
50
|
+
'searchCommands',
|
|
51
|
+
'listShortcuts',
|
|
52
|
+
'registerCommand',
|
|
53
|
+
'registerCommands',
|
|
54
|
+
'getCommand',
|
|
55
|
+
'hasCommand',
|
|
56
|
+
'listCommandIds',
|
|
57
|
+
'getDisabledCategories',
|
|
58
|
+
'isCategoryDisabled',
|
|
59
|
+
'disableCategory',
|
|
60
|
+
'enableCategory',
|
|
61
|
+
'setDisabledCategories',
|
|
62
|
+
],
|
|
63
|
+
events: ['onExecuted', 'onExecutionFailed'],
|
|
64
|
+
}) {
|
|
65
|
+
/**
|
|
66
|
+
* One command as a signal, for what shows a command and isn't a button (a row of a shortcut
|
|
67
|
+
* sheet): its label, icon and state, `run()` and `shortcut`. Changes only when what the
|
|
68
|
+
* command shows does. Pass a function for an id that changes. A button uses the `epdfCommand`
|
|
69
|
+
* directive instead. Always a command: an id no plugin registered (or one asked for before
|
|
70
|
+
* the commands plugin is there) is labelled with its id, neither visible nor enabled, and an
|
|
71
|
+
* unknown one warns once in development.
|
|
72
|
+
*/
|
|
73
|
+
commandOf(id) {
|
|
74
|
+
const idOf = typeof id === 'function' ? id : () => id;
|
|
75
|
+
const resolved = this.binding.select((commands) => commands.resolveCommand(idOf()), null, resolvedCommandsEqual);
|
|
76
|
+
const execute = this.binding.method('execute');
|
|
77
|
+
return computed(() => {
|
|
78
|
+
const command = resolved();
|
|
79
|
+
const requested = idOf();
|
|
80
|
+
const commands = this.binding.capability();
|
|
81
|
+
if (command === null && commands !== null) {
|
|
82
|
+
devWarn(`commandOf:${requested}`, `commandOf(): ${unknownCommandWarning(requested, commands.listCommandIds())}`);
|
|
83
|
+
}
|
|
84
|
+
return boundCommandOf(command ?? unregisteredCommand(requested), execute, {
|
|
85
|
+
isMac: isMacPlatform(),
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommands, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
90
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommands, providedIn: 'root' });
|
|
91
|
+
}
|
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommands, decorators: [{
|
|
93
|
+
type: Injectable,
|
|
94
|
+
args: [{ providedIn: 'root' }]
|
|
95
|
+
}] });
|
|
96
|
+
/** The commands plugin, with its settings: `withCommands({ commands: standardCommands })`. */
|
|
97
|
+
function withCommands(options) {
|
|
98
|
+
return { plugins: [commandsPlugin(options)], services: [EpdfCommands] };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The commands for keyboard shortcuts: the host lens of the same plugin, which matches a
|
|
102
|
+
* keystroke to a command. For the workspace, so the keys run for the active document.
|
|
103
|
+
*/
|
|
104
|
+
function shortcutCommands(host) {
|
|
105
|
+
return new CapabilityBinding(host, () => CommandsToken$1, () => null).capability;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Every command's shortcut as a working key, anywhere on the page, for the active document.
|
|
109
|
+
* Keys typed into text fields are left alone, and so is a key whose command can't run right
|
|
110
|
+
* now. A command that's turned off or not allowed still takes its key, and `onRefused` says
|
|
111
|
+
* why. Add it next to `withCommands()`; for a page with more than one viewer, put
|
|
112
|
+
* `epdfCommandShortcuts` on the element around each one instead.
|
|
113
|
+
*/
|
|
114
|
+
function withCommandShortcuts(options) {
|
|
115
|
+
return {
|
|
116
|
+
plugins: [],
|
|
117
|
+
setup: () => {
|
|
118
|
+
const commands = shortcutCommands(inject(EpdfKernelHost));
|
|
119
|
+
// The commands exist once the viewer's engine is there; the keys go with the viewer.
|
|
120
|
+
effect((onCleanup) => {
|
|
121
|
+
const current = commands();
|
|
122
|
+
if (current) {
|
|
123
|
+
onCleanup(bindCommandShortcuts(current, {
|
|
124
|
+
isMac: options?.isMac,
|
|
125
|
+
onRefused: options?.onRefused,
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Every command's shortcut as a working key, while focus is inside this element: for a page
|
|
134
|
+
* with more than one viewer, or keys that should leave the rest of the page alone. Give the
|
|
135
|
+
* element a `tabindex` so a click on it gives it focus. A key whose command is turned off or
|
|
136
|
+
* not allowed fires `(refused)`.
|
|
137
|
+
*
|
|
138
|
+
* <div class="viewer" tabindex="0" epdfCommandShortcuts (refused)="say($event.refusal.message)">
|
|
139
|
+
*/
|
|
140
|
+
class EpdfCommandShortcuts {
|
|
141
|
+
/** A key whose command is turned off or not allowed: say why. */
|
|
142
|
+
refused = output();
|
|
143
|
+
constructor() {
|
|
144
|
+
const element = inject(ElementRef).nativeElement;
|
|
145
|
+
const commands = shortcutCommands(injectKernelHost('epdfCommandShortcuts'));
|
|
146
|
+
if (!isPlatformBrowser(inject(PLATFORM_ID)))
|
|
147
|
+
return;
|
|
148
|
+
effect((onCleanup) => {
|
|
149
|
+
const current = commands();
|
|
150
|
+
if (!current)
|
|
151
|
+
return;
|
|
152
|
+
onCleanup(bindCommandShortcuts(current, {
|
|
153
|
+
target: element,
|
|
154
|
+
onRefused: (commandId, refusal) => this.refused.emit({ commandId, refusal }),
|
|
155
|
+
}));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommandShortcuts, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
159
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.2.4", type: EpdfCommandShortcuts, isStandalone: true, selector: "[epdfCommandShortcuts]", outputs: { refused: "refused" }, ngImport: i0 });
|
|
160
|
+
}
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommandShortcuts, decorators: [{
|
|
162
|
+
type: Directive,
|
|
163
|
+
args: [{ selector: '[epdfCommandShortcuts]' }]
|
|
164
|
+
}], ctorParameters: () => [] });
|
|
165
|
+
/**
|
|
166
|
+
* A button of yours that runs a command and shows its state: a click runs it, and the button's
|
|
167
|
+
* `disabled`, `aria-pressed`, `title` and `hidden` follow the command. The template reference
|
|
168
|
+
* gives the rest as signals:
|
|
169
|
+
*
|
|
170
|
+
* <button [epdfCommand]="'zoom:in'" #zoomIn="epdfCommand">
|
|
171
|
+
* {{ zoomIn.label() }} <kbd>{{ zoomIn.shortcut() }}</kbd>
|
|
172
|
+
* </button>
|
|
173
|
+
*
|
|
174
|
+
* It runs and reads the command for this part of the template's document. An unknown id
|
|
175
|
+
* hides the button.
|
|
176
|
+
*/
|
|
177
|
+
class EpdfCommand {
|
|
178
|
+
/** The command's id: `'zoom:in'`. */
|
|
179
|
+
id = input.required(...(ngDevMode ? [{ debugName: "id", alias: 'epdfCommand' }] : [{ alias: 'epdfCommand' }]));
|
|
180
|
+
/** The command; an unknown id is neither visible nor enabled, so its button is hidden. */
|
|
181
|
+
command = inject(EpdfCommands).commandOf(() => this.id());
|
|
182
|
+
/** What the user sees. */
|
|
183
|
+
label = computed(() => this.command().label, ...(ngDevMode ? [{ debugName: "label" }] : []));
|
|
184
|
+
/** Your icon's name for it, when the command has one. */
|
|
185
|
+
icon = computed(() => this.command().icon, ...(ngDevMode ? [{ debugName: "icon" }] : []));
|
|
186
|
+
/** Its first shortcut, formatted for the platform (`'⌘K'`), or `null`. */
|
|
187
|
+
shortcut = computed(() => this.command().shortcut, ...(ngDevMode ? [{ debugName: "shortcut" }] : []));
|
|
188
|
+
/** Whether it can run now. */
|
|
189
|
+
enabled = computed(() => this.command().enabled, ...(ngDevMode ? [{ debugName: "enabled" }] : []));
|
|
190
|
+
/** Whether it shows as pressed, such as the current tool. */
|
|
191
|
+
active = computed(() => this.command().active, ...(ngDevMode ? [{ debugName: "active" }] : []));
|
|
192
|
+
/** Whether it shows at all. */
|
|
193
|
+
visible = computed(() => this.command().visible, ...(ngDevMode ? [{ debugName: "visible" }] : []));
|
|
194
|
+
/** Run the command for this part of the template's document. Resolves `{ status }`, like `execute()`. */
|
|
195
|
+
run() {
|
|
196
|
+
return untracked(this.command).run();
|
|
197
|
+
}
|
|
198
|
+
onClick() {
|
|
199
|
+
// A command whose `run` throws reports it through `executionFailed$`.
|
|
200
|
+
this.run().catch(() => { });
|
|
201
|
+
}
|
|
202
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommand, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
203
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.4", type: EpdfCommand, isStandalone: true, selector: "[epdfCommand]", inputs: { id: { classPropertyName: "id", publicName: "epdfCommand", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "onClick()" }, properties: { "attr.disabled": "enabled() ? null : \"\"", "attr.aria-pressed": "active() ? \"true\" : null", "attr.title": "label() || null", "hidden": "!visible()" } }, exportAs: ["epdfCommand"], ngImport: i0 });
|
|
204
|
+
}
|
|
205
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.4", ngImport: i0, type: EpdfCommand, decorators: [{
|
|
206
|
+
type: Directive,
|
|
207
|
+
args: [{
|
|
208
|
+
selector: '[epdfCommand]',
|
|
209
|
+
exportAs: 'epdfCommand',
|
|
210
|
+
host: {
|
|
211
|
+
'(click)': 'onClick()',
|
|
212
|
+
'[attr.disabled]': 'enabled() ? null : ""',
|
|
213
|
+
'[attr.aria-pressed]': 'active() ? "true" : null',
|
|
214
|
+
'[attr.title]': 'label() || null',
|
|
215
|
+
'[hidden]': '!visible()',
|
|
216
|
+
},
|
|
217
|
+
}]
|
|
218
|
+
}] });
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @embedpdf/angular/commands: every action of the viewer, run from buttons, menus and keys.
|
|
222
|
+
*
|
|
223
|
+
* withCommands({ commands }), withCommandShortcuts() for provideEmbedPdf()
|
|
224
|
+
* standardCommands the commands every viewer has
|
|
225
|
+
* inject(EpdfCommands) run, find and register commands
|
|
226
|
+
* [epdfCommand], [epdfCommandShortcuts] a command button; the keys in one element
|
|
227
|
+
*/
|
|
228
|
+
// The plugin's types and helpers, so app code has one import for the feature.
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Generated bundle index. Do not edit.
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
export { EpdfCommand, EpdfCommandShortcuts, EpdfCommands, formatShortcut, standardCommands, withCommandShortcuts, withCommands };
|
|
235
|
+
//# sourceMappingURL=embedpdf-angular-commands.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedpdf-angular-commands.mjs","sources":["../../commands/src/commands.ts","../../commands/src/public_api.ts","../../commands/src/embedpdf-angular-commands.ts"],"sourcesContent":["/**\n * The commands plugin's service, features and directives: every action of the viewer, with its\n * label, icon, state and shortcut, run from buttons, menus and keys.\n *\n * withCommands({ commands }) the plugin, for provideEmbedPdf()\n * withCommandShortcuts() every command's shortcut as a working key\n * inject(EpdfCommands) `execute()`, `searchCommands()`, `executed$`, the settings\n * <button [epdfCommand]=\"'zoom:in'\"> a button of yours that runs and shows a command\n * <div epdfCommandShortcuts> the keys, only while focus is inside that element\n *\n * A command's state is read from live state, so what shows a command follows the viewer's one\n * change stream and changes only when what the command shows did.\n */\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n computed,\n Directive,\n effect,\n ElementRef,\n inject,\n Injectable,\n input,\n output,\n PLATFORM_ID,\n untracked,\n type Signal,\n} from '@angular/core';\nimport {\n CapabilityBinding,\n devWarn,\n EpdfKernelHost,\n injectKernelHost,\n pluginService,\n type EmbedPdfFeature,\n} from '@embedpdf/angular/runtime';\nimport { formatShortcut as formatKeys } from '@embedpdf/core-ui';\nimport {\n boundCommandOf,\n commandsPlugin,\n CommandsToken,\n resolvedCommandsEqual,\n unknownCommandWarning,\n unregisteredCommand,\n} from '@embedpdf/plugin-commands';\nimport type {\n BoundCommand,\n CommandId,\n CommandRefusal,\n CommandsConfig,\n ExecuteResult,\n} from '@embedpdf/plugin-commands';\nimport { CommandsToken as CommandsHostToken } from '@embedpdf/plugin-commands/contract/host';\nimport type { CommandsHostCapability } from '@embedpdf/plugin-commands/contract/host';\nimport { createStandardCommands } from '@embedpdf/plugin-commands/standard';\nimport { bindCommandShortcuts, isMacPlatform, standardCommandsBrowser } from '@embedpdf/web';\n\n/**\n * The commands every viewer has: zoom, pages, view rotation, `tool:<id>` for every tool, copy,\n * delete, download and print, with shortcuts and labels in EmbedPDF's eight languages. Spread\n * them into `withCommands({ commands })`.\n */\nexport const standardCommands = /* @__PURE__ */ createStandardCommands(standardCommandsBrowser);\n\n/** A shortcut as a tooltip shows it, for this platform: `'⌘K'` on a Mac, `'Ctrl+K'` elsewhere. */\nexport function formatShortcut(shortcut: string, options: { isMac?: boolean } = {}): string {\n return formatKeys(shortcut, { isMac: options.isMac ?? isMacPlatform() });\n}\n\n/**\n * The commands: `execute()`, `canExecute()`, `resolveCommand()`, `searchCommands()`,\n * `listShortcuts()`, `registerCommand()`, the categories, `executed$` and\n * `executionFailed$`, and the settings. A call that leaves out the document is for this part\n * of the template's document: the one `[epdfDocumentScope]` names, else the active one.\n */\n@Injectable({ providedIn: 'root' })\nexport class EpdfCommands extends pluginService({\n name: 'EpdfCommands',\n feature: 'withCommands()',\n token: CommandsToken,\n methods: [\n 'execute',\n 'canExecute',\n 'resolveCommand',\n 'listCommands',\n 'searchCommands',\n 'listShortcuts',\n 'registerCommand',\n 'registerCommands',\n 'getCommand',\n 'hasCommand',\n 'listCommandIds',\n 'getDisabledCategories',\n 'isCategoryDisabled',\n 'disableCategory',\n 'enableCategory',\n 'setDisabledCategories',\n ],\n events: ['onExecuted', 'onExecutionFailed'],\n}) {\n /**\n * One command as a signal, for what shows a command and isn't a button (a row of a shortcut\n * sheet): its label, icon and state, `run()` and `shortcut`. Changes only when what the\n * command shows does. Pass a function for an id that changes. A button uses the `epdfCommand`\n * directive instead. Always a command: an id no plugin registered (or one asked for before\n * the commands plugin is there) is labelled with its id, neither visible nor enabled, and an\n * unknown one warns once in development.\n */\n commandOf(id: string | (() => string)): Signal<BoundCommand> {\n const idOf = typeof id === 'function' ? id : () => id;\n const resolved = this.binding.select(\n (commands) => commands.resolveCommand(idOf()),\n null,\n resolvedCommandsEqual,\n );\n const execute = this.binding.method('execute');\n return computed(() => {\n const command = resolved();\n const requested = idOf();\n const commands = this.binding.capability();\n if (command === null && commands !== null) {\n devWarn(\n `commandOf:${requested}`,\n `commandOf(): ${unknownCommandWarning(requested, commands.listCommandIds())}`,\n );\n }\n return boundCommandOf(command ?? unregisteredCommand(requested), execute, {\n isMac: isMacPlatform(),\n });\n });\n }\n}\n\n/** The commands plugin, with its settings: `withCommands({ commands: standardCommands })`. */\nexport function withCommands(options?: CommandsConfig): EmbedPdfFeature {\n return { plugins: [commandsPlugin(options)], services: [EpdfCommands] };\n}\n\n/**\n * The commands for keyboard shortcuts: the host lens of the same plugin, which matches a\n * keystroke to a command. For the workspace, so the keys run for the active document.\n */\nfunction shortcutCommands(host: EpdfKernelHost): Signal<CommandsHostCapability | null> {\n return new CapabilityBinding(\n host,\n () => CommandsHostToken,\n () => null,\n ).capability;\n}\n\n/** A key whose command is turned off or not allowed, and why: what `(refused)` carries. */\nexport interface RefusedShortcut {\n readonly commandId: CommandId;\n readonly refusal: CommandRefusal;\n}\n\n/**\n * Every command's shortcut as a working key, anywhere on the page, for the active document.\n * Keys typed into text fields are left alone, and so is a key whose command can't run right\n * now. A command that's turned off or not allowed still takes its key, and `onRefused` says\n * why. Add it next to `withCommands()`; for a page with more than one viewer, put\n * `epdfCommandShortcuts` on the element around each one instead.\n */\nexport function withCommandShortcuts(options?: {\n isMac?: boolean;\n onRefused?: (commandId: CommandId, refusal: CommandRefusal) => void;\n}): EmbedPdfFeature {\n return {\n plugins: [],\n setup: () => {\n const commands = shortcutCommands(inject(EpdfKernelHost));\n // The commands exist once the viewer's engine is there; the keys go with the viewer.\n effect((onCleanup) => {\n const current = commands();\n if (current) {\n onCleanup(\n bindCommandShortcuts(current, {\n isMac: options?.isMac,\n onRefused: options?.onRefused,\n }),\n );\n }\n });\n },\n };\n}\n\n/**\n * Every command's shortcut as a working key, while focus is inside this element: for a page\n * with more than one viewer, or keys that should leave the rest of the page alone. Give the\n * element a `tabindex` so a click on it gives it focus. A key whose command is turned off or\n * not allowed fires `(refused)`.\n *\n * <div class=\"viewer\" tabindex=\"0\" epdfCommandShortcuts (refused)=\"say($event.refusal.message)\">\n */\n@Directive({ selector: '[epdfCommandShortcuts]' })\nexport class EpdfCommandShortcuts {\n /** A key whose command is turned off or not allowed: say why. */\n readonly refused = output<RefusedShortcut>();\n\n constructor() {\n const element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n const commands = shortcutCommands(injectKernelHost('epdfCommandShortcuts'));\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return;\n effect((onCleanup) => {\n const current = commands();\n if (!current) return;\n onCleanup(\n bindCommandShortcuts(current, {\n target: element,\n onRefused: (commandId, refusal) => this.refused.emit({ commandId, refusal }),\n }),\n );\n });\n }\n}\n\n/**\n * A button of yours that runs a command and shows its state: a click runs it, and the button's\n * `disabled`, `aria-pressed`, `title` and `hidden` follow the command. The template reference\n * gives the rest as signals:\n *\n * <button [epdfCommand]=\"'zoom:in'\" #zoomIn=\"epdfCommand\">\n * {{ zoomIn.label() }} <kbd>{{ zoomIn.shortcut() }}</kbd>\n * </button>\n *\n * It runs and reads the command for this part of the template's document. An unknown id\n * hides the button.\n */\n@Directive({\n selector: '[epdfCommand]',\n exportAs: 'epdfCommand',\n host: {\n '(click)': 'onClick()',\n '[attr.disabled]': 'enabled() ? null : \"\"',\n '[attr.aria-pressed]': 'active() ? \"true\" : null',\n '[attr.title]': 'label() || null',\n '[hidden]': '!visible()',\n },\n})\nexport class EpdfCommand {\n /** The command's id: `'zoom:in'`. */\n readonly id = input.required<string>({ alias: 'epdfCommand' });\n\n /** The command; an unknown id is neither visible nor enabled, so its button is hidden. */\n readonly command: Signal<BoundCommand> = inject(EpdfCommands).commandOf(() => this.id());\n /** What the user sees. */\n readonly label: Signal<string> = computed(() => this.command().label);\n /** Your icon's name for it, when the command has one. */\n readonly icon: Signal<string | undefined> = computed(() => this.command().icon);\n /** Its first shortcut, formatted for the platform (`'⌘K'`), or `null`. */\n readonly shortcut: Signal<string | null> = computed(() => this.command().shortcut);\n /** Whether it can run now. */\n readonly enabled: Signal<boolean> = computed(() => this.command().enabled);\n /** Whether it shows as pressed, such as the current tool. */\n readonly active: Signal<boolean> = computed(() => this.command().active);\n /** Whether it shows at all. */\n readonly visible: Signal<boolean> = computed(() => this.command().visible);\n\n /** Run the command for this part of the template's document. Resolves `{ status }`, like `execute()`. */\n run(): Promise<ExecuteResult> {\n return untracked(this.command).run();\n }\n\n protected onClick(): void {\n // A command whose `run` throws reports it through `executionFailed$`.\n this.run().catch(() => {});\n }\n}\n","/**\n * @embedpdf/angular/commands: every action of the viewer, run from buttons, menus and keys.\n *\n * withCommands({ commands }), withCommandShortcuts() for provideEmbedPdf()\n * standardCommands the commands every viewer has\n * inject(EpdfCommands) run, find and register commands\n * [epdfCommand], [epdfCommandShortcuts] a command button; the keys in one element\n */\n\n// The plugin's types and helpers, so app code has one import for the feature.\nexport * from '@embedpdf/plugin-commands';\nexport * from './commands';\n","/**\n * Generated bundle index. Do not edit.\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