1 | import type { Static, Transaction } from '@remirror/core-types';
|
2 | import { AnyExtension, PlainExtension } from '../extension';
|
3 | import type { CreateExtensionPlugin } from '../types';
|
4 | export interface MetaOptions {
|
5 | /**
|
6 | * Set to true to capture meta data on commands and keybindings. This creates
|
7 | * a wrapper around every command and keybinding and as a result it may lead
|
8 | * to a performance penalty.
|
9 | */
|
10 | capture?: Static<boolean>;
|
11 | }
|
12 | /**
|
13 | * Support meta data for commands and key bindings.
|
14 | *
|
15 | * Metadata is dded to all commands and keybindings and that information is
|
16 | * provided to the `onChange` handle whenever the state is updated.
|
17 | *
|
18 | * @internalremarks
|
19 | *
|
20 | * TODO capture keybindings as well. This will be more difficult since
|
21 | * keybindings can dynamically be added to the editor.
|
22 | */
|
23 | export declare class MetaExtension extends PlainExtension<MetaOptions> {
|
24 | get name(): "meta";
|
25 | onCreate(): void;
|
26 | /**
|
27 | * This is here to provide a
|
28 | */
|
29 | createPlugin(): CreateExtensionPlugin;
|
30 | /**
|
31 | * Intercept command names and attributes.
|
32 | */
|
33 | private captureCommands;
|
34 | /**
|
35 | * Intercept command name and attributes.
|
36 | */
|
37 | private captureKeybindings;
|
38 | /**
|
39 | * Get the command metadata.
|
40 | */
|
41 | private getCommandMeta;
|
42 | private setCommandMeta;
|
43 | }
|
44 | interface CommandMetadata {
|
45 | type: 'command';
|
46 | /**
|
47 | * Was this called as part of a chain?
|
48 | */
|
49 | chain: boolean;
|
50 | /**
|
51 | * Is this a decorated command?
|
52 | */
|
53 | decorated: boolean;
|
54 | /**
|
55 | * The name of the extension.
|
56 | */
|
57 | extension: string;
|
58 | /**
|
59 | * The name of the command that was called.
|
60 | */
|
61 | name: string;
|
62 | }
|
63 | interface KeyBindingMetadata {
|
64 | type: 'keyBinding';
|
65 | /**
|
66 | * The name of the extension used.
|
67 | */
|
68 | extension: string;
|
69 | /**
|
70 | * The shortcut used to invoke this keybinding.
|
71 | */
|
72 | shortcut: string;
|
73 | }
|
74 | export type Metadata = CommandMetadata | KeyBindingMetadata;
|
75 | declare global {
|
76 | namespace Remirror {
|
77 | interface ManagerStore<Extension extends AnyExtension> {
|
78 | /**
|
79 | * Get the command metadata for the transaction.
|
80 | * @internal
|
81 | */
|
82 | getCommandMeta(tr: Transaction): Metadata[];
|
83 | }
|
84 | interface AllExtensions {
|
85 | meta: MetaExtension;
|
86 | }
|
87 | }
|
88 | }
|
89 | export {};
|