@etrepum/lexical-builder-core 0.0.24-nightly.20240617.0 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/definePlan.d.ts +5 -28
- package/dist/definePlan.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -20
- package/dist/internal.d.ts +26 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/types.d.ts +102 -68
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/definePlan.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AnyLexicalPlan, LexicalPlan, LexicalPlanConfig, NormalizedLexicalPlanArgument, NormalizedPeerDependency, PlanConfigBase, RegisterCleanup
|
1
|
+
import { AnyLexicalPlan, LexicalPlan, LexicalPlanConfig, NormalizedLexicalPlanArgument, NormalizedPeerDependency, PlanConfigBase, RegisterCleanup } from './types';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Define a LexicalPlan from the given object literal. TypeScript will
|
@@ -13,8 +13,6 @@ import { AnyLexicalPlan, LexicalPlan, LexicalPlanConfig, NormalizedLexicalPlanAr
|
|
13
13
|
* export const MyPlan = definePlan({
|
14
14
|
* // Plan names must be unique in an editor
|
15
15
|
* name: "my",
|
16
|
-
* // Config must be an object, but an empty object is fine
|
17
|
-
* config: {},
|
18
16
|
* nodes: [MyNode],
|
19
17
|
* });
|
20
18
|
* ```
|
@@ -34,27 +32,7 @@ import { AnyLexicalPlan, LexicalPlan, LexicalPlanConfig, NormalizedLexicalPlanAr
|
|
34
32
|
* });
|
35
33
|
* ```
|
36
34
|
*/
|
37
|
-
export declare function definePlan<Config extends PlanConfigBase, Name extends string, Output>(plan: LexicalPlan<Config, Name, Output>): LexicalPlan<Config, Name, Output>;
|
38
|
-
/**
|
39
|
-
* Define a LexicalPlan from the given object literal, assigning an
|
40
|
-
* empty config and the name "[root]". This plan must only be used
|
41
|
-
* at most once per editor, usually as the first argument to
|
42
|
-
* {@link buildEditorFromPlans} or the plan argument to
|
43
|
-
* {@link LexicalPlanComposer}.
|
44
|
-
*
|
45
|
-
* @param rootPlan A plan without the config or name properties
|
46
|
-
* @returns The given plan argument, after in-place assignment of config and name
|
47
|
-
*
|
48
|
-
* @example
|
49
|
-
* ```ts
|
50
|
-
* const editorHandle = buildEditorFromPlans(
|
51
|
-
* defineRootPlan({
|
52
|
-
* dependencies: [DragonPlan, RichTextPlan, HistoryPlan],
|
53
|
-
* }),
|
54
|
-
* );
|
55
|
-
* ```
|
56
|
-
*/
|
57
|
-
export declare function defineRootPlan<Output>(rootPlan: RootPlanArgument<Output>): RootPlan<Output>;
|
35
|
+
export declare function definePlan<Config extends PlanConfigBase, Name extends string, Output, Init>(plan: LexicalPlan<Config, Name, Output, Init>): LexicalPlan<Config, Name, Output, Init>;
|
58
36
|
/**
|
59
37
|
* Override a partial of the configuration of a Plan, to be used
|
60
38
|
* in the dependencies array of another plan, or as
|
@@ -79,7 +57,7 @@ export declare function defineRootPlan<Output>(rootPlan: RootPlanArgument<Output
|
|
79
57
|
* });
|
80
58
|
* ```
|
81
59
|
*/
|
82
|
-
export declare function configPlan<Config extends PlanConfigBase, Name extends string, Output>(...args: NormalizedLexicalPlanArgument<Config, Name, Output>): NormalizedLexicalPlanArgument<Config, Name, Output>;
|
60
|
+
export declare function configPlan<Config extends PlanConfigBase, Name extends string, Output, Init>(...args: NormalizedLexicalPlanArgument<Config, Name, Output, Init>): NormalizedLexicalPlanArgument<Config, Name, Output, Init>;
|
83
61
|
/**
|
84
62
|
* Provide output from the register function of a Plan
|
85
63
|
*
|
@@ -94,7 +72,6 @@ export declare function configPlan<Config extends PlanConfigBase, Name extends s
|
|
94
72
|
* }
|
95
73
|
* export const RegisteredAtPlan = definePlan({
|
96
74
|
* name: "RegisteredAt",
|
97
|
-
* config: {},
|
98
75
|
* register(editor) {
|
99
76
|
* return provideOutput<RegisteredAtOutput>({ registered_at: Date.now() });
|
100
77
|
* },
|
@@ -108,7 +85,6 @@ export declare function configPlan<Config extends PlanConfigBase, Name extends s
|
|
108
85
|
* }
|
109
86
|
* export const UniqueCommandPlan = definePlan({
|
110
87
|
* name: 'UniqueCommand',
|
111
|
-
* config: {},
|
112
88
|
* register(editor) {
|
113
89
|
* const output: UniqueCommnadOutput = {command: createCommand('UNIQUE_COMMAND')};
|
114
90
|
* const cleanup = registerCommand(
|
@@ -128,6 +104,8 @@ export declare function configPlan<Config extends PlanConfigBase, Name extends s
|
|
128
104
|
export declare function provideOutput<Output>(output: Output, cleanup?: () => void): RegisterCleanup<Output>;
|
129
105
|
/** @internal */
|
130
106
|
export declare const PeerDependencyBrand: unique symbol;
|
107
|
+
export declare const ConfigTypeId: unique symbol;
|
108
|
+
export declare const OutputTypeId: unique symbol;
|
131
109
|
/**
|
132
110
|
* Used to declare a peer dependency of a plan in a type-safe way,
|
133
111
|
* requires the type parameter. The most common use case for peer dependencies
|
@@ -142,7 +120,6 @@ export declare const PeerDependencyBrand: unique symbol;
|
|
142
120
|
* ```ts
|
143
121
|
* export const PeerPlan = definePlan({
|
144
122
|
* name: 'PeerPlan',
|
145
|
-
* config: {},
|
146
123
|
* peerDependencies: [
|
147
124
|
* declarePeerDependency<typeof import("foo").FooPlan>("foo"),
|
148
125
|
* declarePeerDependency<typeof import("bar").BarPlan>("bar", {config: "bar"}),
|
package/dist/definePlan.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"definePlan.d.ts","sourceRoot":"","sources":["../src/definePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,wBAAwB,EACxB,cAAc,EACd,eAAe,
|
1
|
+
{"version":3,"file":"definePlan.d.ts","sourceRoot":"","sources":["../src/definePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,w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hC"}
|
package/dist/index.d.ts
CHANGED
@@ -6,8 +6,9 @@
|
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
export declare const PACKAGE_VERSION: string;
|
9
|
-
export { configPlan, definePlan,
|
10
|
-
export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type EditorHandle, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type
|
9
|
+
export { configPlan, definePlan, provideOutput, declarePeerDependency, } from './definePlan';
|
10
|
+
export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type EditorHandle, type InitialEditorConfig, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanInit, type LexicalPlanName, type LexicalPlanOutput, type OutputComponentPlan, type LexicalPlanDependency, type NormalizedLexicalPlanArgument, type PlanConfigBase, type RegisterState, type RegisterCleanup, type NormalizedPeerDependency, } from './types';
|
11
|
+
export { type LexicalPlanInternal, type initTypeSymbol, type configTypeSymbol, type outputTypeSymbol, } from './internal';
|
11
12
|
export { safeCast } from './safeCast';
|
12
13
|
export { shallowMergeConfig } from './shallowMergeConfig';
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,OAAO,EACL,UAAU,EACV,UAAU,EACV,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,wBAAwB,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
@@ -1,37 +1,33 @@
|
|
1
|
-
function
|
1
|
+
function e(n) {
|
2
2
|
return n;
|
3
3
|
}
|
4
|
-
function
|
5
|
-
return Object.assign(n, { name: "[root]", config: {} });
|
6
|
-
}
|
7
|
-
function f(...n) {
|
4
|
+
function r(...n) {
|
8
5
|
return n;
|
9
6
|
}
|
10
|
-
function
|
7
|
+
function f(n, t) {
|
11
8
|
return Object.assign(() => t && t(), { output: n });
|
12
9
|
}
|
13
|
-
function
|
10
|
+
function c(n, t) {
|
14
11
|
return [n, t];
|
15
12
|
}
|
16
|
-
function
|
13
|
+
function a(n) {
|
17
14
|
return n;
|
18
15
|
}
|
19
|
-
function
|
16
|
+
function i(n, t) {
|
20
17
|
if (!t || n === t)
|
21
18
|
return n;
|
22
|
-
for (const
|
23
|
-
if (n[
|
19
|
+
for (const u in t)
|
20
|
+
if (n[u] !== t[u])
|
24
21
|
return { ...n, ...t };
|
25
22
|
return n;
|
26
23
|
}
|
27
|
-
const
|
24
|
+
const o = "0.0.24";
|
28
25
|
export {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
a as shallowMergeConfig
|
26
|
+
o as PACKAGE_VERSION,
|
27
|
+
r as configPlan,
|
28
|
+
c as declarePeerDependency,
|
29
|
+
e as definePlan,
|
30
|
+
f as provideOutput,
|
31
|
+
a as safeCast,
|
32
|
+
i as shallowMergeConfig
|
37
33
|
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/** @internal */
|
2
|
+
export declare const peerDependencySymbol: unique symbol;
|
3
|
+
/** @internal */
|
4
|
+
export type peerDependencySymbol = typeof peerDependencySymbol;
|
5
|
+
/** @internal */
|
6
|
+
export declare const configTypeSymbol: unique symbol;
|
7
|
+
/** @internal */
|
8
|
+
export type configTypeSymbol = typeof configTypeSymbol;
|
9
|
+
/** @internal */
|
10
|
+
export declare const outputTypeSymbol: unique symbol;
|
11
|
+
/** @internal */
|
12
|
+
export type outputTypeSymbol = typeof outputTypeSymbol;
|
13
|
+
/** @internal */
|
14
|
+
export declare const initTypeSymbol: unique symbol;
|
15
|
+
/** @internal */
|
16
|
+
export type initTypeSymbol = typeof initTypeSymbol;
|
17
|
+
/** @internal */
|
18
|
+
export interface LexicalPlanInternal<out Config, out Output, out Init> {
|
19
|
+
/** @internal */
|
20
|
+
readonly [configTypeSymbol]?: Config;
|
21
|
+
/** @internal */
|
22
|
+
readonly [outputTypeSymbol]?: Output;
|
23
|
+
/** @internal */
|
24
|
+
readonly [initTypeSymbol]?: Init;
|
25
|
+
}
|
26
|
+
//# sourceMappingURL=internal.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,oBAAoB,EAAE,OAAO,MAAM,CAAC;AACzD,gBAAgB;AAChB,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC;AAC/D,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,MAAM,CAAC;AACrD,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC;AACvD,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,MAAM,CAAC;AACrD,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC;AACvD,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AACnD,gBAAgB;AAChB,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AAEnD,gBAAgB;AAChB,MAAM,WAAW,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACnE,gBAAgB;IAChB,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACrC,gBAAgB;IAChB,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACrC,gBAAgB;IAChB,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC;CAClC"}
|
package/dist/types.d.ts
CHANGED
@@ -1,42 +1,44 @@
|
|
1
1
|
import { CreateEditorArgs, EditorState, LexicalEditor } from 'lexical';
|
2
|
-
import {
|
2
|
+
import { LexicalPlanInternal, peerDependencySymbol, configTypeSymbol, outputTypeSymbol, initTypeSymbol } from './internal';
|
3
3
|
|
4
4
|
/**
|
5
5
|
* Any concrete {@link LexicalPlan}
|
6
6
|
*/
|
7
|
-
export type AnyLexicalPlan = LexicalPlan<any, string, any>;
|
7
|
+
export type AnyLexicalPlan = LexicalPlan<any, string, any, any>;
|
8
8
|
/**
|
9
9
|
* Any {@link LexicalPlan} or {@link NormalizedLexicalPlanArgument}
|
10
10
|
*/
|
11
|
-
export type AnyLexicalPlanArgument = LexicalPlanArgument<any, string, any>;
|
11
|
+
export type AnyLexicalPlanArgument = LexicalPlanArgument<any, string, any, any>;
|
12
12
|
/**
|
13
13
|
* The default plan configuration of an empty object
|
14
14
|
*/
|
15
15
|
export type PlanConfigBase = Record<never, never>;
|
16
|
-
export type RootPlan<Output> = LexicalPlan<PlanConfigBase, "[root]", Output>;
|
17
|
-
export type RootPlanArgument<Output = any> = Omit<RootPlan<Output>, "config" | "name">;
|
18
16
|
export type NormalizedPeerDependency<Plan extends AnyLexicalPlan> = [
|
19
17
|
Plan["name"],
|
20
18
|
Partial<LexicalPlanConfig<Plan>> | undefined
|
21
19
|
] & {
|
22
|
-
[
|
20
|
+
readonly [peerDependencySymbol]: Plan;
|
23
21
|
};
|
24
22
|
/**
|
25
23
|
* A tuple of [plan, configOverride, ...configOverrides]
|
26
24
|
*/
|
27
|
-
export type NormalizedLexicalPlanArgument<Config extends PlanConfigBase, Name extends string, Output extends unknown
|
25
|
+
export type NormalizedLexicalPlanArgument<in out Config extends PlanConfigBase, out Name extends string, in out Output extends unknown, in out Init extends unknown> = [
|
26
|
+
LexicalPlan<Config, Name, Output, Init>,
|
27
|
+
Partial<Config>,
|
28
|
+
...Partial<Config>[]
|
29
|
+
];
|
28
30
|
/**
|
29
31
|
* An object that the register method can use to detect unmount and access the
|
30
32
|
* configuration for plan dependencies
|
31
33
|
*/
|
32
|
-
export interface RegisterState {
|
34
|
+
export interface RegisterState<Init> {
|
33
35
|
/** An AbortSignal that is aborted when the EditorHandle is disposed */
|
34
36
|
signal: AbortSignal;
|
35
37
|
/**
|
36
38
|
* Get the result of a peerDependency by name, if it exists
|
37
39
|
* (must be a peerDependency of this plan)
|
38
40
|
*/
|
39
|
-
getPeer<
|
41
|
+
getPeer<Dependency extends AnyLexicalPlan = never>(name: Dependency["name"]): undefined | LexicalPlanDependency<Dependency>;
|
40
42
|
/**
|
41
43
|
* Get the configuration of a dependency by plan
|
42
44
|
* (must be a direct dependency of this plan)
|
@@ -53,15 +55,24 @@ export interface RegisterState {
|
|
53
55
|
* typically only used for devtools.
|
54
56
|
*/
|
55
57
|
getPeerNameSet(): Set<string>;
|
58
|
+
/**
|
59
|
+
* The result of the init function
|
60
|
+
*/
|
61
|
+
getInitResult(): Init;
|
56
62
|
}
|
57
63
|
/**
|
58
64
|
* A {@link LexicalPlan} or {@link NormalizedLexicalPlanArgument} (plan with config overrides)
|
59
65
|
*/
|
60
|
-
export type LexicalPlanArgument<Config extends PlanConfigBase, Name extends string, Output extends unknown> = LexicalPlan<Config, Name, Output> | NormalizedLexicalPlanArgument<Config, Name, Output>;
|
61
|
-
export interface LexicalPlanDependency<Dependency extends AnyLexicalPlan> {
|
66
|
+
export type LexicalPlanArgument<Config extends PlanConfigBase, Name extends string, Output extends unknown, Init extends unknown> = LexicalPlan<Config, Name, Output, Init> | NormalizedLexicalPlanArgument<Config, Name, Output, Init>;
|
67
|
+
export interface LexicalPlanDependency<out Dependency extends AnyLexicalPlan> {
|
62
68
|
config: LexicalPlanConfig<Dependency>;
|
63
69
|
output: LexicalPlanOutput<Dependency>;
|
64
70
|
}
|
71
|
+
export type RegisterCleanup<Output> = (() => void) & (unknown extends Output ? {
|
72
|
+
output?: Output;
|
73
|
+
} : {
|
74
|
+
output: Output;
|
75
|
+
});
|
65
76
|
/**
|
66
77
|
* A Plan is a composable unit of LexicalEditor configuration
|
67
78
|
* (nodes, theme, etc) used to create an editor, plus runtime behavior
|
@@ -70,9 +81,9 @@ export interface LexicalPlanDependency<Dependency extends AnyLexicalPlan> {
|
|
70
81
|
* A Plan may depend on other Plans, and provide functionality to other
|
71
82
|
* plans through its config.
|
72
83
|
*/
|
73
|
-
export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Name extends string = string, Output extends unknown = unknown> {
|
84
|
+
export interface LexicalPlan<in out Config extends PlanConfigBase = PlanConfigBase, out Name extends string = string, in out Output extends unknown = unknown, in out Init extends unknown = unknown> extends InitialEditorConfig, LexicalPlanInternal<Config, Output, Init> {
|
74
85
|
/** The name of the Plan, must be unique */
|
75
|
-
name: Name;
|
86
|
+
readonly name: Name;
|
76
87
|
/** Plan names that must not be loaded with this Plan */
|
77
88
|
conflictsWith?: string[];
|
78
89
|
/** Other Plans that this Plan depends on, can also be used to configure them */
|
@@ -82,52 +93,6 @@ export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Nam
|
|
82
93
|
* configure, if they are directly depended on by another Plan
|
83
94
|
*/
|
84
95
|
peerDependencies?: NormalizedPeerDependency<AnyLexicalPlan>[];
|
85
|
-
/**
|
86
|
-
* @internal Disable root element events (for internal Meta use)
|
87
|
-
*/
|
88
|
-
disableEvents?: CreateEditorArgs["disableEvents"];
|
89
|
-
/**
|
90
|
-
* Used when this editor is nested inside of another editor
|
91
|
-
*/
|
92
|
-
parentEditor?: CreateEditorArgs["parentEditor"];
|
93
|
-
/**
|
94
|
-
* The namespace of this Editor. If two editors share the same
|
95
|
-
* namespace, JSON will be the clipboard interchange format.
|
96
|
-
* Otherwise HTML will be used.
|
97
|
-
*/
|
98
|
-
namespace?: CreateEditorArgs["namespace"];
|
99
|
-
/**
|
100
|
-
* The nodes that this Plan adds to the Editor configuration, will be merged with other Plans
|
101
|
-
*/
|
102
|
-
nodes?: CreateEditorArgs["nodes"];
|
103
|
-
/**
|
104
|
-
* EditorThemeClasses that will be deep merged with other Plans
|
105
|
-
*/
|
106
|
-
theme?: CreateEditorArgs["theme"];
|
107
|
-
/**
|
108
|
-
* Overrides for HTML serialization (exportDOM) and
|
109
|
-
* deserialization (importDOM) that does not require subclassing and node
|
110
|
-
* replacement
|
111
|
-
*/
|
112
|
-
html?: CreateEditorArgs["html"];
|
113
|
-
/**
|
114
|
-
* Whether the initial state of the editor is editable or not
|
115
|
-
*/
|
116
|
-
editable?: CreateEditorArgs["editable"];
|
117
|
-
/**
|
118
|
-
* The editor will catch errors that happen during updates and
|
119
|
-
* reconciliation and call this. It defaults to
|
120
|
-
* `(error) => { throw error }`.
|
121
|
-
*
|
122
|
-
* @param error The Error object
|
123
|
-
* @param editor The editor that this error came from
|
124
|
-
*/
|
125
|
-
onError?: (error: Error, editor: LexicalEditor) => void;
|
126
|
-
/**
|
127
|
-
* The initial EditorState as a JSON string, an EditorState, or a function
|
128
|
-
* to update the editor (once).
|
129
|
-
*/
|
130
|
-
$initialEditorState?: InitialEditorStateType;
|
131
96
|
/**
|
132
97
|
* The default configuration specific to this Plan. This Config may be
|
133
98
|
* seen by this Plan, or any Plan that uses it as a dependency.
|
@@ -135,7 +100,7 @@ export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Nam
|
|
135
100
|
* The config may be mutated on register, this is particularly useful
|
136
101
|
* for vending functionality to other Plans that depend on this Plan.
|
137
102
|
*/
|
138
|
-
config
|
103
|
+
config?: Config;
|
139
104
|
/**
|
140
105
|
* By default, Config is shallow merged `{...a, ...b}` with
|
141
106
|
* {@link shallowMergeConfig}, if your Plan requires other strategies
|
@@ -160,6 +125,19 @@ export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Nam
|
|
160
125
|
* @returns The merged configuration
|
161
126
|
*/
|
162
127
|
mergeConfig?: (config: Config, overrides: Partial<Config>) => Config;
|
128
|
+
/**
|
129
|
+
* Perform any necessary initialization before the editor is created,
|
130
|
+
* this runs after all configuration overrides for both the editor this
|
131
|
+
* this plan have been merged. May be used validate the editor
|
132
|
+
* configuration.
|
133
|
+
*
|
134
|
+
* @param editorConfig The in-progress editor configuration (mutable)
|
135
|
+
* @param config The merged configuration specific to this plan (mutable)
|
136
|
+
* @param state An object containing an AbortSignal that can be
|
137
|
+
* used, and methods for accessing the merged configuration of
|
138
|
+
* dependencies and peerDependencies
|
139
|
+
*/
|
140
|
+
init?: (editorConfig: InitialEditorConfig, config: Config, state: RegisterState<Init>) => Init;
|
163
141
|
/**
|
164
142
|
* Add behavior to the editor (register transforms, listeners, etc.) after
|
165
143
|
* the Editor is created. The register function may also mutate the config
|
@@ -172,22 +150,30 @@ export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Nam
|
|
172
150
|
* dependencies and peerDependencies
|
173
151
|
* @returns A clean-up function
|
174
152
|
*/
|
175
|
-
register?: (editor: LexicalEditor, config: Config, state: RegisterState) => RegisterCleanup<Output>;
|
153
|
+
register?: (editor: LexicalEditor, config: Config, state: RegisterState<Init>) => RegisterCleanup<Output>;
|
176
154
|
}
|
177
|
-
export type RegisterCleanup<Output> = (() => void) & (unknown extends Output ? {
|
178
|
-
output?: Output;
|
179
|
-
} : {
|
180
|
-
output: Output;
|
181
|
-
});
|
182
155
|
/**
|
183
156
|
* Extract the Config type from a Plan
|
184
157
|
*/
|
185
|
-
export type LexicalPlanConfig<Plan extends AnyLexicalPlan> = Plan[
|
158
|
+
export type LexicalPlanConfig<Plan extends AnyLexicalPlan> = NonNullable<Plan[configTypeSymbol]>;
|
186
159
|
/**
|
187
160
|
* Extract the Name type from a Plan
|
188
161
|
*/
|
189
162
|
export type LexicalPlanName<Plan extends AnyLexicalPlan> = Plan["name"];
|
190
|
-
|
163
|
+
/**
|
164
|
+
* Extract the Output type from a Plan
|
165
|
+
*/
|
166
|
+
export type LexicalPlanOutput<Plan extends AnyLexicalPlan> = NonNullable<Plan[outputTypeSymbol]>;
|
167
|
+
/**
|
168
|
+
* Extract the Init type from a Plan
|
169
|
+
*/
|
170
|
+
export type LexicalPlanInit<Plan extends AnyLexicalPlan> = NonNullable<Plan[initTypeSymbol]>;
|
171
|
+
/**
|
172
|
+
* A Plan that has an OutputComponent of the given type (e.g. React.ComponentType)
|
173
|
+
*/
|
174
|
+
export type OutputComponentPlan<ComponentType> = LexicalPlan<any, any, {
|
175
|
+
Component: ComponentType;
|
176
|
+
}, any>;
|
191
177
|
/**
|
192
178
|
* A handle to the editor and its dispose function
|
193
179
|
*/
|
@@ -208,4 +194,52 @@ export interface EditorHandle extends Disposable {
|
|
208
194
|
* - `((editor: LexicalEditor) => void)` A function that is called with the editor for you to mutate it
|
209
195
|
*/
|
210
196
|
export type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
|
197
|
+
export interface InitialEditorConfig {
|
198
|
+
/**
|
199
|
+
* @internal Disable root element events (for internal Meta use)
|
200
|
+
*/
|
201
|
+
disableEvents?: CreateEditorArgs["disableEvents"];
|
202
|
+
/**
|
203
|
+
* Used when this editor is nested inside of another editor
|
204
|
+
*/
|
205
|
+
parentEditor?: CreateEditorArgs["parentEditor"];
|
206
|
+
/**
|
207
|
+
* The namespace of this Editor. If two editors share the same
|
208
|
+
* namespace, JSON will be the clipboard interchange format.
|
209
|
+
* Otherwise HTML will be used.
|
210
|
+
*/
|
211
|
+
namespace?: CreateEditorArgs["namespace"];
|
212
|
+
/**
|
213
|
+
* The nodes that this Plan adds to the Editor configuration, will be merged with other Plans
|
214
|
+
*/
|
215
|
+
nodes?: CreateEditorArgs["nodes"];
|
216
|
+
/**
|
217
|
+
* EditorThemeClasses that will be deep merged with other Plans
|
218
|
+
*/
|
219
|
+
theme?: CreateEditorArgs["theme"];
|
220
|
+
/**
|
221
|
+
* Overrides for HTML serialization (exportDOM) and
|
222
|
+
* deserialization (importDOM) that does not require subclassing and node
|
223
|
+
* replacement
|
224
|
+
*/
|
225
|
+
html?: CreateEditorArgs["html"];
|
226
|
+
/**
|
227
|
+
* Whether the initial state of the editor is editable or not
|
228
|
+
*/
|
229
|
+
editable?: CreateEditorArgs["editable"];
|
230
|
+
/**
|
231
|
+
* The editor will catch errors that happen during updates and
|
232
|
+
* reconciliation and call this. It defaults to
|
233
|
+
* `(error) => { throw error }`.
|
234
|
+
*
|
235
|
+
* @param error The Error object
|
236
|
+
* @param editor The editor that this error came from
|
237
|
+
*/
|
238
|
+
onError?: (error: Error, editor: LexicalEditor) => void;
|
239
|
+
/**
|
240
|
+
* The initial EditorState as a JSON string, an EditorState, or a function
|
241
|
+
* to update the editor (once).
|
242
|
+
*/
|
243
|
+
$initialEditorState?: InitialEditorStateType;
|
244
|
+
}
|
211
245
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AAEH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChE;;GAEG;AAEH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAElD,MAAM,MAAM,wBAAwB,CAAC,IAAI,SAAS,cAAc,IAAI;IAClE,IAAI,CAAC,MAAM,CAAC;IACZ,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS;CAC7C,GAAG;IAAE,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,6BAA6B,CACvC,EAAE,CAAC,GAAG,CAAC,MAAM,SAAS,cAAc,EACpC,GAAG,CAAC,IAAI,SAAS,MAAM,EACvB,EAAE,CAAC,GAAG,CAAC,MAAM,SAAS,OAAO,EAC7B,EAAE,CAAC,GAAG,C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