1 | import type { Dispose, EditorView } from '@remirror/core-types';
|
2 | import { AnyExtension, GetExtensions } from '../extension';
|
3 | import type { GetConstructor, StateUpdateLifecycleProps } from '../types';
|
4 | /**
|
5 | * Transforms the unsorted array of presets and extension into presets and
|
6 | * sorted extensions. Handles uniqueness of extensions and automatically throws
|
7 | * an error when required extensions are missing.
|
8 | *
|
9 | * @internalremarks Currently matching by constructor - what if different
|
10 | * versions exist in the same app
|
11 | *
|
12 | * @param initialExtensions - the extensions to be transformed. This includes
|
13 | * the extension that are parents to other extensions.
|
14 | *
|
15 | * @returns the list of extension instances sorted by priority
|
16 | */
|
17 | export declare function transformExtensions<RawExtensions extends AnyExtension>(initialExtensions: readonly RawExtensions[], settings: Remirror.ManagerSettings): ExtensionTransformation<RawExtensions>;
|
18 | /**
|
19 | * This is the object shape that is returned from the combined transformation.
|
20 | */
|
21 | export interface ExtensionTransformation<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> {
|
22 | /**
|
23 | * The list of extensions sorted by priority and original extension. Every
|
24 | * extension passed in and those contained by presets are placed here.
|
25 | */
|
26 | extensions: Expanded[];
|
27 | /**
|
28 | * A map where the key is the [[`ExtensionConstructor`]] and the value is the
|
29 | * [[`Extension`]] instance. This is used to lookup extensions contained
|
30 | * within a manager. It is a weak map so that values can be garbage collected
|
31 | * when references to the constructor are lost.
|
32 | */
|
33 | extensionMap: WeakMap<GetConstructor<Expanded>, Expanded>;
|
34 | }
|
35 | export interface ManagerLifecycleHandlers {
|
36 | /**
|
37 | * Contains the methods run when the manager is first created.
|
38 | */
|
39 | create: Array<() => Dispose | void>;
|
40 | /**
|
41 | * Holds the methods to run once the Editor has received the view from the
|
42 | * attached.
|
43 | */
|
44 | view: Array<(view: EditorView) => Dispose | void>;
|
45 | /**
|
46 | * The update method is called every time the state updates. This allows
|
47 | * extensions to listen to updates.
|
48 | */
|
49 | update: Array<(props: StateUpdateLifecycleProps) => void>;
|
50 | /**
|
51 | * Called when the manager is being destroyed.
|
52 | */
|
53 | destroy: Array<() => void>;
|
54 | }
|
55 | interface SetupExtensionProps {
|
56 | extension: AnyExtension;
|
57 | nodeNames: string[];
|
58 | markNames: string[];
|
59 | plainNames: string[];
|
60 | store: Remirror.ExtensionStore;
|
61 | handlers: ManagerLifecycleHandlers;
|
62 | }
|
63 | /**
|
64 | * This helper function extracts all the lifecycle methods from the provided
|
65 | * extension and adds them to the provided `handler` container.
|
66 | */
|
67 | export declare function extractLifecycleMethods(props: SetupExtensionProps): void;
|
68 | export {};
|