UNPKG

2.95 kBTypeScriptView Raw
1import type { ClassName } from '@linaria/core/types/cx';
2import type { ProsemirrorAttributes } from '@remirror/core-types';
3import { AnyExtension, PlainExtension } from '../extension';
4/**
5 * This extension allows others extension to add the `createAttributes` method
6 * for adding attributes to the prosemirror dom element.
7 *
8 * @remarks
9 *
10 * Use this to include all the dynamically generated attributes provided by each
11 * extension. High priority extensions have preference over the lower priority
12 * extensions.
13 *
14 * @category Builtin Extension
15 */
16export declare class AttributesExtension extends PlainExtension {
17 get name(): "attributes";
18 private attributeList;
19 private attributeObject;
20 /**
21 * Create the attributes object on initialization.
22 *
23 * @internal
24 */
25 onCreate(): void;
26 private readonly updateAttributes;
27 private transformAttributes;
28}
29declare global {
30 namespace Remirror {
31 interface ManagerStore<Extension extends AnyExtension> {
32 /**
33 * The attributes to be added to the prosemirror editor.
34 */
35 attributes: ProsemirrorAttributes;
36 }
37 interface ExtensionStore {
38 /**
39 * Triggers a recalculation of the `view.dom` attributes for each
40 * extension and notifies the parent UI once done.
41 *
42 * This will also dispatch an update to the state automatically. However
43 * you can disable this by setting `triggerUpdate` to `false`.
44 *
45 * By not triggering an update the new value may not be capture by the view layer, e.g. `React`.
46 *
47 * @param triggerUpdate - defaults to true
48 */
49 updateAttributes: (triggerUpdate?: boolean) => void;
50 }
51 interface ExcludeOptions {
52 /**
53 * Whether to use the attributes provided by this extension
54 *
55 * @defaultValue undefined
56 */
57 attributes?: boolean;
58 }
59 interface BaseExtension {
60 /**
61 * A list of class names to add to the main editor element.
62 */
63 classNames?: ClassName[];
64 /**
65 * Allows the extension to modify the attributes for the Prosemirror editor
66 * dom element.
67 *
68 * @remarks
69 *
70 * Sometimes an extension will need to make a change to the attributes of the
71 * editor itself. For example a placeholder may need to do some work to make
72 * the editor more accessible by setting the `aria-placeholder` value to match
73 * the value of the placeholder.
74 *
75 * @alpha
76 */
77 createAttributes?(): ProsemirrorAttributes;
78 }
79 interface AllExtensions {
80 attributes: AttributesExtension;
81 }
82 }
83}