@etrepum/lexical-builder 0.0.28-nightly.20240705.0 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/AutoFocusPlan.d.ts +1 -1
- package/dist/AutoFocusPlan.d.ts.map +1 -1
- package/dist/HistoryPlan.d.ts +2 -2
- package/dist/HistoryPlan.d.ts.map +1 -1
- package/dist/InitialStatePlan.d.ts +1 -3
- package/dist/InitialStatePlan.d.ts.map +1 -1
- package/dist/LexicalBuilder.d.ts +15 -11
- package/dist/LexicalBuilder.d.ts.map +1 -1
- package/dist/PlanRep.d.ts +57 -11
- package/dist/PlanRep.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/getPeerDependencyFromEditor.d.ts +2 -2
- package/dist/getPeerDependencyFromEditor.d.ts.map +1 -1
- package/dist/getPlanDependencyFromEditor.d.ts +3 -3
- package/dist/getPlanDependencyFromEditor.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +336 -164
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/AutoFocusPlan.d.ts
CHANGED
@@ -16,5 +16,5 @@ export interface AutoFocusConfig {
|
|
16
16
|
* A Plan to focus the LexicalEditor when the root element is set
|
17
17
|
* (typically only when the editor is first created).
|
18
18
|
*/
|
19
|
-
export declare const AutoFocusPlan: import('@etrepum/lexical-builder-core').LexicalPlan<AutoFocusConfig, "@etrepum/lexical-builder/
|
19
|
+
export declare const AutoFocusPlan: import('@etrepum/lexical-builder-core').LexicalPlan<AutoFocusConfig, "@etrepum/lexical-builder/AutoFocus", unknown, unknown>;
|
20
20
|
//# sourceMappingURL=AutoFocusPlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AutoFocusPlan.d.ts","sourceRoot":"","sources":["../src/AutoFocusPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,
|
1
|
+
{"version":3,"file":"AutoFocusPlan.d.ts","sourceRoot":"","sources":["../src/AutoFocusPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,8HAwBxB,CAAC"}
|
package/dist/HistoryPlan.d.ts
CHANGED
@@ -13,7 +13,7 @@ export interface HistoryConfig {
|
|
13
13
|
}
|
14
14
|
/**
|
15
15
|
* Registers necessary listeners to manage undo/redo history stack and related
|
16
|
-
* editor commands, via the
|
16
|
+
* editor commands, via the \@lexical/history module.
|
17
17
|
*/
|
18
|
-
export declare const HistoryPlan: import('@etrepum/lexical-builder-core').LexicalPlan<HistoryConfig, "@etrepum/lexical-builder/
|
18
|
+
export declare const HistoryPlan: import('@etrepum/lexical-builder-core').LexicalPlan<HistoryConfig, "@etrepum/lexical-builder/History", unknown, unknown>;
|
19
19
|
//# sourceMappingURL=HistoryPlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"HistoryPlan.d.ts","sourceRoot":"","sources":["../src/HistoryPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"HistoryPlan.d.ts","sourceRoot":"","sources":["../src/HistoryPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,yBAAyB,EAAE,MAAM,YAAY,CAAC;CAC/C;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,0HAStB,CAAC"}
|
@@ -1,10 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { EditorSetOptions, EditorUpdateOptions } from 'lexical';
|
2
2
|
|
3
|
-
type EditorUpdateOptions = NonNullable<Parameters<LexicalEditor["update"]>[1]>;
|
4
3
|
export interface InitialStateConfig {
|
5
4
|
updateOptions: EditorUpdateOptions;
|
6
5
|
setOptions: EditorSetOptions;
|
7
6
|
}
|
8
7
|
export declare const InitialStatePlan: import('@etrepum/lexical-builder-core').LexicalPlan<InitialStateConfig, "@etrepum/lexical-builder/InitialState", unknown, import('@etrepum/lexical-builder-core').InitialEditorStateType>;
|
9
|
-
export {};
|
10
8
|
//# sourceMappingURL=InitialStatePlan.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"InitialStatePlan.d.ts","sourceRoot":"","sources":["../src/InitialStatePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
1
|
+
{"version":3,"file":"InitialStatePlan.d.ts","sourceRoot":"","sources":["../src/InitialStatePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAQL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAWjB,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,2LA2C3B,CAAC"}
|
package/dist/LexicalBuilder.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AnyLexicalPlan, AnyLexicalPlanArgument, LexicalEditorWithDispose, InitialEditorConfig } from '@etrepum/lexical-builder-core';
|
1
|
+
import { AnyLexicalPlan, AnyLexicalPlanArgument, LexicalEditorWithDispose, InitialEditorConfig, LexicalPlanConfig } from '@etrepum/lexical-builder-core';
|
2
2
|
import { LexicalEditor } from 'lexical';
|
3
3
|
import { PlanRep } from './PlanRep';
|
4
4
|
|
@@ -8,8 +8,7 @@ export declare const builderSymbol: unique symbol;
|
|
8
8
|
* Build a LexicalEditor by combining together one or more plans, optionally
|
9
9
|
* overriding some of their configuration.
|
10
10
|
*
|
11
|
-
* @param
|
12
|
-
* @param plans Optional additional plan arguments
|
11
|
+
* @param plans - Plan arguments (plans or plans with config overrides)
|
13
12
|
* @returns An editor handle
|
14
13
|
*
|
15
14
|
* @example A single root plan with multiple dependencies
|
@@ -36,24 +35,29 @@ export declare const builderSymbol: unique symbol;
|
|
36
35
|
* );
|
37
36
|
* ```
|
38
37
|
*/
|
39
|
-
export declare function buildEditorFromPlans(
|
38
|
+
export declare function buildEditorFromPlans(...plans: AnyLexicalPlanArgument[]): LexicalEditorWithDispose;
|
39
|
+
type AnyNormalizedLexicalPlanArgument = ReturnType<typeof normalizePlanArgument>;
|
40
|
+
declare function normalizePlanArgument(arg: AnyLexicalPlanArgument): import('@etrepum/lexical-builder-core/dist/types').NormalizedLexicalPlanArgument<any, string, any, any>;
|
40
41
|
/** @internal */
|
41
42
|
export declare class LexicalBuilder {
|
42
|
-
|
43
|
-
planMap: Map<AnyLexicalPlan, [number, PlanRep<AnyLexicalPlan>]>;
|
43
|
+
roots: readonly AnyNormalizedLexicalPlanArgument[];
|
44
44
|
planNameMap: Map<string, PlanRep<AnyLexicalPlan>>;
|
45
|
-
|
46
|
-
|
45
|
+
outgoingConfigEdges: Map<string, Map<string, LexicalPlanConfig<AnyLexicalPlan>[]>>;
|
46
|
+
incomingEdges: Map<string, Set<string>>;
|
47
47
|
conflicts: Map<string, string>;
|
48
|
+
_sortedPlanReps?: readonly PlanRep<AnyLexicalPlan>[];
|
48
49
|
PACKAGE_VERSION: string;
|
49
|
-
constructor();
|
50
|
+
constructor(roots: AnyNormalizedLexicalPlanArgument[]);
|
51
|
+
static fromPlans(plans: AnyLexicalPlanArgument[]): LexicalBuilder;
|
50
52
|
/** Look up the editor that was created by this LexicalBuilder or throw */
|
51
53
|
static fromEditor(editor: LexicalEditor): LexicalBuilder;
|
52
54
|
buildEditor(): LexicalEditorWithDispose;
|
53
55
|
getPlanRep<Plan extends AnyLexicalPlan>(plan: Plan): PlanRep<Plan> | undefined;
|
54
|
-
|
55
|
-
|
56
|
+
addEdge(fromPlanName: string, toPlanName: string, configs: LexicalPlanConfig<AnyLexicalPlan>[]): void;
|
57
|
+
addPlan(arg: AnyLexicalPlanArgument): void;
|
58
|
+
sortedPlanReps(): readonly PlanRep<AnyLexicalPlan>[];
|
56
59
|
registerEditor(editor: LexicalEditor, controller: AbortController): () => void;
|
57
60
|
buildCreateEditorArgs(signal: AbortSignal): InitialEditorConfig;
|
58
61
|
}
|
62
|
+
export {};
|
59
63
|
//# sourceMappingURL=LexicalBuilder.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LexicalBuilder.d.ts","sourceRoot":"","sources":["../src/LexicalBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,
|
1
|
+
{"version":3,"file":"LexicalBuilder.d.ts","sourceRoot":"","sources":["../src/LexicalBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,aAAa,EAOnB,MAAM,SAAS,CAAC;AAKjB,OAAO,EACL,OAAO,EAKR,MAAM,WAAW,CAAC;AAInB,+DAA+D;AAC/D,eAAO,MAAM,aAAa,eAAyC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,KAAK,EAAE,sBAAsB,EAAE,GACjC,wBAAwB,CAE1B;AAqBD,KAAK,gCAAgC,GAAG,UAAU,CAChD,OAAO,qBAAqB,CAC7B,CAAC;AACF,iBAAS,qBAAqB,CAAC,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1,77 @@
|
|
1
|
-
import {
|
2
|
-
import { AnyLexicalPlan, InitialEditorConfig, LexicalPlanConfig, LexicalPlanDependency, LexicalPlanInit, LexicalPlanOutput, RegisterState } from '@etrepum/lexical-builder-core';
|
1
|
+
import { AnyLexicalPlan, InitialEditorConfig, LexicalPlanConfig, LexicalPlanDependency, LexicalPlanInit, LexicalPlanOutput, RegisterCleanup, PlanInitState, PlanRegisterState } from '@etrepum/lexical-builder-core';
|
3
2
|
import { LexicalEditor } from 'lexical';
|
3
|
+
import { LexicalBuilder } from './LexicalBuilder';
|
4
4
|
|
5
|
+
export declare const PlanRepStateIds: {
|
6
|
+
readonly unmarked: 0;
|
7
|
+
readonly temporary: 1;
|
8
|
+
readonly permanent: 2;
|
9
|
+
readonly configured: 3;
|
10
|
+
readonly initialized: 4;
|
11
|
+
readonly registered: 5;
|
12
|
+
readonly afterInitialization: 6;
|
13
|
+
};
|
14
|
+
interface UnmarkedState {
|
15
|
+
id: (typeof PlanRepStateIds)["unmarked"];
|
16
|
+
}
|
17
|
+
interface TemporaryState extends Omit<UnmarkedState, "id"> {
|
18
|
+
id: (typeof PlanRepStateIds)["temporary"];
|
19
|
+
}
|
20
|
+
interface PermanentState extends Omit<TemporaryState, "id"> {
|
21
|
+
id: (typeof PlanRepStateIds)["permanent"];
|
22
|
+
}
|
23
|
+
interface ConfiguredState<Plan extends AnyLexicalPlan> extends Omit<PermanentState, "id"> {
|
24
|
+
id: (typeof PlanRepStateIds)["configured"];
|
25
|
+
config: LexicalPlanConfig<Plan>;
|
26
|
+
registerState: PlanInitState;
|
27
|
+
}
|
28
|
+
interface InitializedState<Plan extends AnyLexicalPlan> extends Omit<ConfiguredState<Plan>, "id" | "registerState"> {
|
29
|
+
id: (typeof PlanRepStateIds)["initialized"];
|
30
|
+
initResult: LexicalPlanInit<Plan>;
|
31
|
+
registerState: PlanRegisterState<LexicalPlanInit<Plan>>;
|
32
|
+
}
|
33
|
+
interface RegisteredState<Plan extends AnyLexicalPlan> extends Omit<InitializedState<Plan>, "id"> {
|
34
|
+
id: (typeof PlanRepStateIds)["registered"];
|
35
|
+
output: LexicalPlanOutput<Plan>;
|
36
|
+
}
|
37
|
+
interface AfterInitializationState<Plan extends AnyLexicalPlan> extends Omit<RegisteredState<Plan>, "id"> {
|
38
|
+
id: (typeof PlanRepStateIds)["afterInitialization"];
|
39
|
+
}
|
40
|
+
export type PlanRepState<Plan extends AnyLexicalPlan> = UnmarkedState | TemporaryState | PermanentState | ConfiguredState<Plan> | InitializedState<Plan> | RegisteredState<Plan> | AfterInitializationState<Plan>;
|
41
|
+
export declare function isExactlyUnmarkedPlanRepState<Plan extends AnyLexicalPlan>(state: PlanRepState<Plan>): state is UnmarkedState;
|
42
|
+
export declare function isExactlyPermanentPlanRepState<Plan extends AnyLexicalPlan>(state: PlanRepState<Plan>): state is PermanentState;
|
43
|
+
export declare function applyTemporaryMark<Plan extends AnyLexicalPlan>(state: PlanRepState<Plan>): TemporaryState;
|
44
|
+
export declare function applyPermanentMark<Plan extends AnyLexicalPlan>(state: PlanRepState<Plan>): PermanentState;
|
45
|
+
export declare function applyConfiguredState<Plan extends AnyLexicalPlan>(state: PermanentState, config: LexicalPlanConfig<Plan>, registerState: PlanInitState): ConfiguredState<Plan>;
|
46
|
+
export declare function applyInitializedState<Plan extends AnyLexicalPlan>(state: ConfiguredState<Plan>, initResult: LexicalPlanInit<Plan>, registerState: PlanRegisterState<Plan>): InitializedState<Plan>;
|
47
|
+
export declare function applyRegisteredState<Plan extends AnyLexicalPlan>(state: InitializedState<Plan>, cleanup?: RegisterCleanup<LexicalPlanOutput<Plan>> | undefined): never;
|
48
|
+
export declare function applyAfterInitializationState<Plan extends AnyLexicalPlan>(state: RegisteredState<Plan>): AfterInitializationState<Plan>;
|
5
49
|
/**
|
6
50
|
* @internal
|
7
51
|
*/
|
8
52
|
export declare class PlanRep<Plan extends AnyLexicalPlan> {
|
9
53
|
builder: LexicalBuilder;
|
10
54
|
configs: Set<Partial<LexicalPlanConfig<Plan>>>;
|
11
|
-
_config?: LexicalPlanConfig<Plan>;
|
12
55
|
_dependency?: LexicalPlanDependency<Plan>;
|
13
56
|
_output?: LexicalPlanOutput<Plan>;
|
14
57
|
_peerNameSet?: Set<string>;
|
15
|
-
_registerState?: RegisterState<LexicalPlanInit<Plan>>;
|
16
|
-
_initResult?: LexicalPlanInit<Plan>;
|
17
58
|
plan: Plan;
|
59
|
+
state: PlanRepState<Plan>;
|
18
60
|
constructor(builder: LexicalBuilder, plan: Plan);
|
19
|
-
afterInitialization(editor: LexicalEditor
|
20
|
-
register(editor: LexicalEditor
|
61
|
+
afterInitialization(editor: LexicalEditor): undefined | (() => void);
|
62
|
+
register(editor: LexicalEditor): undefined | (() => void);
|
21
63
|
init(editorConfig: InitialEditorConfig, signal: AbortSignal): void;
|
22
64
|
getInitResult(): LexicalPlanInit<Plan>;
|
23
|
-
|
65
|
+
getInitPeer<PeerPlan extends AnyLexicalPlan = never>(name: PeerPlan["name"]): undefined | Omit<LexicalPlanDependency<PeerPlan>, "output">;
|
66
|
+
getPlanInitDependency(): Omit<LexicalPlanDependency<Plan>, "output">;
|
24
67
|
getPeer<PeerPlan extends AnyLexicalPlan = never>(name: PeerPlan["name"]): undefined | LexicalPlanDependency<PeerPlan>;
|
68
|
+
getInitDependency<Dependency extends AnyLexicalPlan>(dep: Dependency): Omit<LexicalPlanDependency<Dependency>, "output">;
|
25
69
|
getDependency<Dependency extends AnyLexicalPlan>(dep: Dependency): LexicalPlanDependency<Dependency>;
|
26
|
-
|
27
|
-
|
70
|
+
getState(): AfterInitializationState<Plan>;
|
71
|
+
getDirectDependentNames(): ReadonlySet<string>;
|
72
|
+
getPeerNameSet(): ReadonlySet<string>;
|
28
73
|
getPlanDependency(): LexicalPlanDependency<Plan>;
|
29
|
-
|
74
|
+
mergeConfigs(): LexicalPlanConfig<Plan>;
|
30
75
|
}
|
76
|
+
export {};
|
31
77
|
//# sourceMappingURL=PlanRep.d.ts.map
|
package/dist/PlanRep.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PlanRep.d.ts","sourceRoot":"","sources":["../src/PlanRep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"PlanRep.d.ts","sourceRoot":"","sources":["../src/PlanRep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,eAAO,MAAM,eAAe;;;;;;;;CAQlB,CAAC;AACX,UAAU,aAAa;IACrB,EAAE,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC;CAC1C;AACD,UAAU,cAAe,SAAQ,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC;IACxD,EAAE,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC,CAAC;CAC3C;AACD,UAAU,cAAe,SAAQ,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC;IACzD,EAAE,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC,CAAC;CAC3C;AACD,UAAU,eAAe,CAAC,IAAI,SAAS,cAAc,CACnD,SAAQ,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC;IAClC,EAAE,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC;IAC3C,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;CAC9B;AACD,UAAU,gBAAgB,CAAC,IAAI,SAAS,cAAc,CACpD,SAAQ,IAAI,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":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,EAAE,GAAG,CAAC,gBAAgB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC;CAClD;AACD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,mBAAmB;;;EAYhE"}
|
@@ -17,8 +17,8 @@ import { AnyLexicalPlan, LexicalPlanDependency } from '@etrepum/lexical-builder-
|
|
17
17
|
* getPeerDependencyFromEditor<typeof import("@some/plan").SomePlan>(editor, "@some/plan");
|
18
18
|
* ```
|
19
19
|
|
20
|
-
* @param editor The editor that may have been built using plan
|
21
|
-
* @param planName The name of the Plan
|
20
|
+
* @param editor - The editor that may have been built using plan
|
21
|
+
* @param planName - The name of the Plan
|
22
22
|
* @returns The config and output of the Plan or undefined
|
23
23
|
*/
|
24
24
|
export declare function getPeerDependencyFromEditor<Plan extends AnyLexicalPlan = never>(editor: LexicalEditor, planName: Plan["name"]): LexicalPlanDependency<Plan> | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getPeerDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPeerDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"getPeerDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPeerDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAGvC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,SAAS,cAAc,GAAG,KAAK,EAEnC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GACrB,qBAAqB,CAAC,IAAI,CAAC,GAAG,SAAS,CAMzC"}
|
@@ -6,12 +6,12 @@ import { AnyLexicalPlan, LexicalPlanDependency } from '@etrepum/lexical-builder-
|
|
6
6
|
*
|
7
7
|
* This is useful in the implementation of a LexicalNode or in other
|
8
8
|
* situations where you have an editor reference but it's not easy to
|
9
|
-
* pass the config or {@link
|
9
|
+
* pass the config or {@link PlanRegisterState} around.
|
10
10
|
*
|
11
11
|
* It will throw if the Editor was not built using this Plan.
|
12
12
|
*
|
13
|
-
* @param editor The editor that was built using plan
|
14
|
-
* @param plan The concrete reference to a Plan used to build this editor
|
13
|
+
* @param editor - The editor that was built using plan
|
14
|
+
* @param plan - The concrete reference to a Plan used to build this editor
|
15
15
|
* @returns The config and output for that Plan
|
16
16
|
*/
|
17
17
|
export declare function getPlanDependencyFromEditor<Plan extends AnyLexicalPlan>(editor: LexicalEditor, plan: Plan): LexicalPlanDependency<Plan>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getPlanDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPlanDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"getPlanDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPlanDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAIvC;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,SAAS,cAAc,EACrE,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,GACT,qBAAqB,CAAC,IAAI,CAAC,CAS7B"}
|
package/dist/index.d.ts
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
export { PACKAGE_VERSION } from './PACKAGE_VERSION';
|
9
9
|
export { configPlan, definePlan, provideOutput, declarePeerDependency, } from '@etrepum/lexical-builder-core';
|
10
10
|
export { LexicalBuilder, buildEditorFromPlans } from './LexicalBuilder';
|
11
|
-
export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type LexicalEditorWithDispose, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanName, type LexicalPlanOutput, type LexicalPlanInit, type OutputComponentPlan, type LexicalPlanDependency, type NormalizedLexicalPlanArgument, type PlanConfigBase, type
|
11
|
+
export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type LexicalEditorWithDispose, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanName, type LexicalPlanOutput, type LexicalPlanInit, type OutputComponentPlan, type LexicalPlanDependency, type NormalizedLexicalPlanArgument, type PlanConfigBase, type PlanRegisterState, type NormalizedPeerDependency, } from '@etrepum/lexical-builder-core';
|
12
12
|
export { safeCast } from '@etrepum/lexical-builder-core';
|
13
13
|
export { shallowMergeConfig } from '@etrepum/lexical-builder-core';
|
14
14
|
export { getPlanDependencyFromEditor } from './getPlanDependencyFromEditor';
|
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,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,qBAAq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E,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,KAAK,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
@@ -9,7 +9,7 @@ import { registerDragonSupport } from "@lexical/dragon";
|
|
9
9
|
import { createEmptyHistoryState, registerHistory } from "@lexical/history";
|
10
10
|
import { registerPlainText } from "@lexical/plain-text";
|
11
11
|
import { HeadingNode, QuoteNode, registerRichText } from "@lexical/rich-text";
|
12
|
-
const PACKAGE_VERSION = "0.0.28
|
12
|
+
const PACKAGE_VERSION = "0.0.28";
|
13
13
|
function invariant(cond, message, ...args) {
|
14
14
|
if (cond) {
|
15
15
|
return;
|
@@ -29,84 +29,205 @@ function deepThemeMergeInPlace(a, b) {
|
|
29
29
|
}
|
30
30
|
return b;
|
31
31
|
}
|
32
|
+
const PlanRepStateIds = {
|
33
|
+
unmarked: 0,
|
34
|
+
temporary: 1,
|
35
|
+
permanent: 2,
|
36
|
+
configured: 3,
|
37
|
+
initialized: 4,
|
38
|
+
registered: 5,
|
39
|
+
afterInitialization: 6
|
40
|
+
};
|
41
|
+
function isExactlyUnmarkedPlanRepState(state) {
|
42
|
+
return state.id === PlanRepStateIds.unmarked;
|
43
|
+
}
|
44
|
+
function isExactlyTemporaryPlanRepState(state) {
|
45
|
+
return state.id === PlanRepStateIds.temporary;
|
46
|
+
}
|
47
|
+
function isExactlyPermanentPlanRepState(state) {
|
48
|
+
return state.id === PlanRepStateIds.permanent;
|
49
|
+
}
|
50
|
+
function isInitializedPlanRepState(state) {
|
51
|
+
return state.id >= PlanRepStateIds.initialized;
|
52
|
+
}
|
53
|
+
function isConfiguredPlanRepState(state) {
|
54
|
+
return state.id >= PlanRepStateIds.configured;
|
55
|
+
}
|
56
|
+
function isRegisteredPlanRepState(state) {
|
57
|
+
return state.id >= PlanRepStateIds.registered;
|
58
|
+
}
|
59
|
+
function isAfterInitializationState(state) {
|
60
|
+
return state.id >= PlanRepStateIds.afterInitialization;
|
61
|
+
}
|
62
|
+
function applyTemporaryMark(state) {
|
63
|
+
invariant(
|
64
|
+
isExactlyUnmarkedPlanRepState(state),
|
65
|
+
"LexicalBuilder: Can not apply a temporary mark to state"
|
66
|
+
);
|
67
|
+
return Object.assign(state, { id: PlanRepStateIds.temporary });
|
68
|
+
}
|
69
|
+
function applyPermanentMark(state) {
|
70
|
+
invariant(
|
71
|
+
isExactlyTemporaryPlanRepState(state),
|
72
|
+
"LexicalBuilder: Can not apply a permanent mark to state"
|
73
|
+
);
|
74
|
+
return Object.assign(state, { id: PlanRepStateIds.permanent });
|
75
|
+
}
|
76
|
+
function applyConfiguredState(state, config, registerState) {
|
77
|
+
return Object.assign(state, {
|
78
|
+
id: PlanRepStateIds.configured,
|
79
|
+
config,
|
80
|
+
registerState
|
81
|
+
});
|
82
|
+
}
|
83
|
+
function applyInitializedState(state, initResult, registerState) {
|
84
|
+
return Object.assign(state, {
|
85
|
+
id: PlanRepStateIds.initialized,
|
86
|
+
initResult,
|
87
|
+
registerState
|
88
|
+
});
|
89
|
+
}
|
90
|
+
function applyRegisteredState(state, cleanup) {
|
91
|
+
return Object.assign(state, {
|
92
|
+
id: PlanRepStateIds.registered,
|
93
|
+
output: cleanup ? cleanup.output : void 0
|
94
|
+
});
|
95
|
+
}
|
96
|
+
function applyAfterInitializationState(state) {
|
97
|
+
return Object.assign(state, { id: PlanRepStateIds.afterInitialization });
|
98
|
+
}
|
99
|
+
const emptySet = /* @__PURE__ */ new Set();
|
32
100
|
class PlanRep {
|
33
101
|
constructor(builder, plan) {
|
34
102
|
__publicField(this, "builder");
|
35
103
|
__publicField(this, "configs");
|
36
|
-
__publicField(this, "_config");
|
37
104
|
__publicField(this, "_dependency");
|
38
105
|
__publicField(this, "_output");
|
39
106
|
__publicField(this, "_peerNameSet");
|
40
|
-
__publicField(this, "_registerState");
|
41
|
-
__publicField(this, "_initResult");
|
42
107
|
__publicField(this, "plan");
|
108
|
+
__publicField(this, "state");
|
43
109
|
this.builder = builder;
|
44
110
|
this.plan = plan;
|
45
111
|
this.configs = /* @__PURE__ */ new Set();
|
112
|
+
this.state = { id: PlanRepStateIds.unmarked };
|
46
113
|
}
|
47
|
-
afterInitialization(editor
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
this.getRegisterState(signal)
|
114
|
+
afterInitialization(editor) {
|
115
|
+
const state = this.state;
|
116
|
+
invariant(
|
117
|
+
state.id === PlanRepStateIds.registered,
|
118
|
+
"PlanRep: afterInitialization called in state id %s (expected %s registered)",
|
119
|
+
String(state.id),
|
120
|
+
String(PlanRepStateIds.registered)
|
55
121
|
);
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
122
|
+
let rval;
|
123
|
+
if (this.plan.afterInitialization) {
|
124
|
+
rval = this.plan.afterInitialization(
|
125
|
+
editor,
|
126
|
+
state.config,
|
127
|
+
state.registerState
|
128
|
+
);
|
61
129
|
}
|
130
|
+
this.state = applyAfterInitializationState(state);
|
131
|
+
return rval;
|
132
|
+
}
|
133
|
+
register(editor) {
|
134
|
+
const state = this.state;
|
62
135
|
invariant(
|
63
|
-
|
64
|
-
"PlanRep: register called
|
136
|
+
state.id === PlanRepStateIds.initialized,
|
137
|
+
"PlanRep: register called in state id %s (expected %s initialized)",
|
138
|
+
String(state.id),
|
139
|
+
String(PlanRepStateIds.initialized)
|
65
140
|
);
|
66
|
-
|
67
|
-
|
68
|
-
this.
|
69
|
-
|
70
|
-
|
71
|
-
|
141
|
+
let cleanup;
|
142
|
+
if (this.plan.register) {
|
143
|
+
cleanup = this.plan.register(
|
144
|
+
editor,
|
145
|
+
state.config,
|
146
|
+
state.registerState
|
147
|
+
);
|
148
|
+
}
|
149
|
+
this.state = applyRegisteredState(state, cleanup);
|
72
150
|
return cleanup;
|
73
151
|
}
|
74
152
|
init(editorConfig, signal) {
|
75
|
-
const
|
76
|
-
|
153
|
+
const initialState = this.state;
|
154
|
+
invariant(
|
155
|
+
isExactlyPermanentPlanRepState(initialState),
|
156
|
+
"LexicalBuilder: Can not configure from state id %s",
|
157
|
+
String(initialState.id)
|
158
|
+
);
|
159
|
+
const initState = {
|
160
|
+
signal,
|
161
|
+
getDirectDependentNames: this.getDirectDependentNames.bind(this),
|
162
|
+
getPeerNameSet: this.getPeerNameSet.bind(this),
|
163
|
+
getPeer: this.getInitPeer.bind(this),
|
164
|
+
getDependency: this.getInitDependency.bind(this)
|
165
|
+
};
|
166
|
+
const registerState = {
|
167
|
+
...initState,
|
168
|
+
getPeer: this.getPeer.bind(this),
|
169
|
+
getDependency: this.getDependency.bind(this),
|
170
|
+
getInitResult: this.getInitResult.bind(this)
|
171
|
+
};
|
172
|
+
const state = applyConfiguredState(
|
173
|
+
initialState,
|
174
|
+
this.mergeConfigs(),
|
175
|
+
initState
|
176
|
+
);
|
177
|
+
this.state = state;
|
178
|
+
let initResult;
|
77
179
|
if (this.plan.init) {
|
78
|
-
|
180
|
+
initResult = this.plan.init(
|
79
181
|
editorConfig,
|
80
|
-
config,
|
81
|
-
|
182
|
+
state.config,
|
183
|
+
initState
|
82
184
|
);
|
83
185
|
}
|
186
|
+
this.state = applyInitializedState(state, initResult, registerState);
|
84
187
|
}
|
85
188
|
getInitResult() {
|
86
189
|
invariant(
|
87
|
-
|
88
|
-
"PlanRep: getInitResult() called for Plan %s
|
190
|
+
this.plan.init !== void 0,
|
191
|
+
"PlanRep: getInitResult() called for Plan %s that does not define init",
|
89
192
|
this.plan.name
|
90
193
|
);
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
194
|
+
const state = this.state;
|
195
|
+
invariant(
|
196
|
+
isInitializedPlanRepState(state),
|
197
|
+
"PlanRep: getInitResult() called for PlanRep in state id %s < %s (initialized)",
|
198
|
+
String(state.id),
|
199
|
+
String(PlanRepStateIds.initialized)
|
200
|
+
);
|
201
|
+
return state.initResult;
|
202
|
+
}
|
203
|
+
getInitPeer(name) {
|
204
|
+
const rep = this.builder.planNameMap.get(name);
|
205
|
+
return rep ? rep.getPlanInitDependency() : void 0;
|
206
|
+
}
|
207
|
+
getPlanInitDependency() {
|
208
|
+
const state = this.state;
|
209
|
+
invariant(
|
210
|
+
isConfiguredPlanRepState(state),
|
211
|
+
"LexicalPlanBuilder: getPlanInitDependency called in state id %s (expected >= %s configured)",
|
212
|
+
String(state.id),
|
213
|
+
String(PlanRepStateIds.configured)
|
214
|
+
);
|
215
|
+
return { config: state.config };
|
105
216
|
}
|
106
217
|
getPeer(name) {
|
107
218
|
const rep = this.builder.planNameMap.get(name);
|
108
219
|
return rep ? rep.getPlanDependency() : void 0;
|
109
220
|
}
|
221
|
+
getInitDependency(dep) {
|
222
|
+
const rep = this.builder.getPlanRep(dep);
|
223
|
+
invariant(
|
224
|
+
rep !== void 0,
|
225
|
+
"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry",
|
226
|
+
this.plan.name,
|
227
|
+
dep.name
|
228
|
+
);
|
229
|
+
return rep.getPlanInitDependency();
|
230
|
+
}
|
110
231
|
getDependency(dep) {
|
111
232
|
const rep = this.builder.getPlanRep(dep);
|
112
233
|
invariant(
|
@@ -117,11 +238,18 @@ class PlanRep {
|
|
117
238
|
);
|
118
239
|
return rep.getPlanDependency();
|
119
240
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
(
|
241
|
+
getState() {
|
242
|
+
const state = this.state;
|
243
|
+
invariant(
|
244
|
+
isAfterInitializationState(state),
|
245
|
+
"PlanRep getState called in state id %s (expected %s afterInitialization)",
|
246
|
+
String(state.id),
|
247
|
+
String(PlanRepStateIds.afterInitialization)
|
124
248
|
);
|
249
|
+
return state;
|
250
|
+
}
|
251
|
+
getDirectDependentNames() {
|
252
|
+
return this.builder.incomingEdges.get(this.plan.name) || emptySet;
|
125
253
|
}
|
126
254
|
getPeerNameSet() {
|
127
255
|
let s = this._peerNameSet;
|
@@ -133,29 +261,26 @@ class PlanRep {
|
|
133
261
|
}
|
134
262
|
getPlanDependency() {
|
135
263
|
if (!this._dependency) {
|
264
|
+
const state = this.state;
|
136
265
|
invariant(
|
137
|
-
|
266
|
+
isRegisteredPlanRepState(state),
|
138
267
|
"Plan %s used as a dependency before registration",
|
139
268
|
this.plan.name
|
140
269
|
);
|
141
270
|
this._dependency = {
|
142
|
-
config:
|
143
|
-
output:
|
271
|
+
config: state.config,
|
272
|
+
output: state.output
|
144
273
|
};
|
145
274
|
}
|
146
275
|
return this._dependency;
|
147
276
|
}
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
config = mergeConfig(config, cfg);
|
154
|
-
}
|
155
|
-
this._config = config;
|
156
|
-
return config;
|
277
|
+
mergeConfigs() {
|
278
|
+
let config = this.plan.config || {};
|
279
|
+
const mergeConfig = this.plan.mergeConfig ? this.plan.mergeConfig.bind(this.plan) : shallowMergeConfig;
|
280
|
+
for (const cfg of this.configs) {
|
281
|
+
config = mergeConfig(config, cfg);
|
157
282
|
}
|
158
|
-
return
|
283
|
+
return config;
|
159
284
|
}
|
160
285
|
}
|
161
286
|
const HISTORY_MERGE_OPTIONS = { tag: "history-merge" };
|
@@ -184,7 +309,9 @@ const InitialStatePlan = definePlan({
|
|
184
309
|
const $initialEditorState = state.getInitResult();
|
185
310
|
switch (typeof $initialEditorState) {
|
186
311
|
case "function": {
|
187
|
-
editor.update(() =>
|
312
|
+
editor.update(() => {
|
313
|
+
$initialEditorState(editor);
|
314
|
+
}, updateOptions);
|
188
315
|
break;
|
189
316
|
}
|
190
317
|
case "string": {
|
@@ -204,14 +331,8 @@ const InitialStatePlan = definePlan({
|
|
204
331
|
}
|
205
332
|
});
|
206
333
|
const builderSymbol = Symbol.for("@etrepum/lexical-builder");
|
207
|
-
function buildEditorFromPlans(
|
208
|
-
|
209
|
-
builder.addPlan(InitialStatePlan);
|
210
|
-
builder.addPlan(plan);
|
211
|
-
for (const otherPlan of plans) {
|
212
|
-
builder.addPlan(otherPlan);
|
213
|
-
}
|
214
|
-
return builder.buildEditor();
|
334
|
+
function buildEditorFromPlans(...plans) {
|
335
|
+
return LexicalBuilder.fromPlans(plans).buildEditor();
|
215
336
|
}
|
216
337
|
function noop() {
|
217
338
|
}
|
@@ -221,22 +342,34 @@ function defaultOnError(err) {
|
|
221
342
|
function maybeWithBuilder(editor) {
|
222
343
|
return editor;
|
223
344
|
}
|
345
|
+
function normalizePlanArgument(arg) {
|
346
|
+
return Array.isArray(arg) ? arg : configPlan(arg);
|
347
|
+
}
|
224
348
|
class LexicalBuilder {
|
225
|
-
constructor() {
|
226
|
-
__publicField(this, "
|
227
|
-
__publicField(this, "planMap");
|
349
|
+
constructor(roots) {
|
350
|
+
__publicField(this, "roots");
|
228
351
|
__publicField(this, "planNameMap");
|
229
|
-
__publicField(this, "
|
230
|
-
__publicField(this, "
|
352
|
+
__publicField(this, "outgoingConfigEdges");
|
353
|
+
__publicField(this, "incomingEdges");
|
231
354
|
__publicField(this, "conflicts");
|
355
|
+
__publicField(this, "_sortedPlanReps");
|
232
356
|
__publicField(this, "PACKAGE_VERSION");
|
233
|
-
this.
|
234
|
-
this.
|
357
|
+
this.outgoingConfigEdges = /* @__PURE__ */ new Map();
|
358
|
+
this.incomingEdges = /* @__PURE__ */ new Map();
|
235
359
|
this.planNameMap = /* @__PURE__ */ new Map();
|
236
360
|
this.conflicts = /* @__PURE__ */ new Map();
|
237
|
-
this.reverseEdges = /* @__PURE__ */ new Map();
|
238
|
-
this.addStack = /* @__PURE__ */ new Set();
|
239
361
|
this.PACKAGE_VERSION = PACKAGE_VERSION;
|
362
|
+
this.roots = roots;
|
363
|
+
for (const plan of roots) {
|
364
|
+
this.addPlan(plan);
|
365
|
+
}
|
366
|
+
}
|
367
|
+
static fromPlans(plans) {
|
368
|
+
const roots = [normalizePlanArgument(InitialStatePlan)];
|
369
|
+
for (const plan of plans) {
|
370
|
+
roots.push(normalizePlanArgument(plan));
|
371
|
+
}
|
372
|
+
return new LexicalBuilder(roots);
|
240
373
|
}
|
241
374
|
/** Look up the editor that was created by this LexicalBuilder or throw */
|
242
375
|
static fromEditor(editor) {
|
@@ -259,7 +392,11 @@ class LexicalBuilder {
|
|
259
392
|
}
|
260
393
|
buildEditor() {
|
261
394
|
const controller = new AbortController();
|
262
|
-
const {
|
395
|
+
const {
|
396
|
+
$initialEditorState: _$initialEditorState,
|
397
|
+
onError,
|
398
|
+
...editorConfig
|
399
|
+
} = this.buildCreateEditorArgs(controller.signal);
|
263
400
|
let disposeOnce = noop;
|
264
401
|
function dispose() {
|
265
402
|
try {
|
@@ -271,15 +408,17 @@ class LexicalBuilder {
|
|
271
408
|
const editor = Object.assign(
|
272
409
|
createEditor({
|
273
410
|
...editorConfig,
|
274
|
-
...onError ? {
|
275
|
-
onError(err
|
276
|
-
|
411
|
+
...onError ? {
|
412
|
+
onError: (err) => {
|
413
|
+
onError(err, editor);
|
414
|
+
}
|
415
|
+
} : {}
|
277
416
|
}),
|
278
417
|
{ [builderSymbol]: this, dispose, [Symbol.dispose]: dispose }
|
279
418
|
);
|
280
419
|
disposeOnce = mergeRegister(
|
281
420
|
() => {
|
282
|
-
|
421
|
+
maybeWithBuilder(editor)[builderSymbol] = void 0;
|
283
422
|
},
|
284
423
|
() => {
|
285
424
|
editor.setRootElement(null);
|
@@ -289,36 +428,54 @@ class LexicalBuilder {
|
|
289
428
|
return editor;
|
290
429
|
}
|
291
430
|
getPlanRep(plan) {
|
292
|
-
const
|
293
|
-
if (
|
294
|
-
|
431
|
+
const rep = this.planNameMap.get(plan.name);
|
432
|
+
if (rep) {
|
433
|
+
invariant(
|
434
|
+
rep.plan === plan,
|
435
|
+
"LexicalBuilder: A registered plan with name %s exists but does not match the given plan",
|
436
|
+
plan.name
|
437
|
+
);
|
295
438
|
return rep;
|
296
439
|
}
|
297
440
|
}
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
441
|
+
addEdge(fromPlanName, toPlanName, configs) {
|
442
|
+
const outgoing = this.outgoingConfigEdges.get(fromPlanName);
|
443
|
+
if (outgoing) {
|
444
|
+
outgoing.set(toPlanName, configs);
|
445
|
+
} else {
|
446
|
+
this.outgoingConfigEdges.set(
|
447
|
+
fromPlanName,
|
448
|
+
/* @__PURE__ */ new Map([[toPlanName, configs]])
|
449
|
+
);
|
450
|
+
}
|
451
|
+
const incoming = this.incomingEdges.get(toPlanName);
|
452
|
+
if (incoming) {
|
453
|
+
incoming.add(fromPlanName);
|
303
454
|
} else {
|
304
|
-
|
305
|
-
configs = [];
|
455
|
+
this.incomingEdges.set(toPlanName, /* @__PURE__ */ new Set([fromPlanName]));
|
306
456
|
}
|
457
|
+
}
|
458
|
+
addPlan(arg) {
|
459
|
+
invariant(
|
460
|
+
this._sortedPlanReps === void 0,
|
461
|
+
"LexicalBuilder: addPlan called after finalization"
|
462
|
+
);
|
463
|
+
const normalized = normalizePlanArgument(arg);
|
464
|
+
const [plan] = normalized;
|
307
465
|
invariant(
|
308
466
|
typeof plan.name === "string",
|
309
467
|
"LexicalBuilder: plan name must be string, not %s",
|
310
468
|
typeof plan.name
|
311
469
|
);
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
edgeSet.add(parent);
|
319
|
-
}
|
320
|
-
let [phase, planRep] = this.planMap.get(plan) || [0, void 0];
|
470
|
+
let planRep = this.planNameMap.get(plan.name);
|
471
|
+
invariant(
|
472
|
+
planRep === void 0 || planRep.plan === plan,
|
473
|
+
"LexicalBuilder: Multiple plans registered with name %s, names must be unique",
|
474
|
+
plan.name
|
475
|
+
);
|
321
476
|
if (!planRep) {
|
477
|
+
planRep = new PlanRep(this, plan);
|
478
|
+
this.planNameMap.set(plan.name, planRep);
|
322
479
|
const hasConflict = this.conflicts.get(plan.name);
|
323
480
|
if (typeof hasConflict === "string") {
|
324
481
|
invariant(
|
@@ -337,83 +494,98 @@ class LexicalBuilder {
|
|
337
494
|
);
|
338
495
|
this.conflicts.set(name, plan.name);
|
339
496
|
}
|
340
|
-
invariant(
|
341
|
-
!this.addStack.has(plan),
|
342
|
-
"LexicalBuilder: Circular dependency detected for Plan %s from %s",
|
343
|
-
plan.name,
|
344
|
-
(parent == null ? void 0 : parent.name) || "[unknown]"
|
345
|
-
);
|
346
|
-
this.addStack.add(plan);
|
347
497
|
for (const dep of plan.dependencies || []) {
|
348
|
-
|
498
|
+
const normDep = normalizePlanArgument(dep);
|
499
|
+
this.addEdge(plan.name, normDep[0].name, normDep.slice(1));
|
500
|
+
this.addPlan(normDep);
|
349
501
|
}
|
350
|
-
for (const [depName,
|
351
|
-
|
352
|
-
if (dep) {
|
353
|
-
phase = Math.max(
|
354
|
-
phase,
|
355
|
-
1 + this.addPlan(
|
356
|
-
configPlan(
|
357
|
-
dep.plan,
|
358
|
-
cfg || {}
|
359
|
-
),
|
360
|
-
plan
|
361
|
-
)
|
362
|
-
);
|
363
|
-
}
|
502
|
+
for (const [depName, config] of plan.peerDependencies || []) {
|
503
|
+
this.addEdge(plan.name, depName, config ? [config] : []);
|
364
504
|
}
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
505
|
+
}
|
506
|
+
}
|
507
|
+
sortedPlanReps() {
|
508
|
+
if (this._sortedPlanReps) {
|
509
|
+
return this._sortedPlanReps;
|
510
|
+
}
|
511
|
+
const sortedPlanReps = [];
|
512
|
+
const visit = (rep, fromPlanName) => {
|
513
|
+
let mark = rep.state;
|
514
|
+
if (isExactlyPermanentPlanRepState(mark)) {
|
515
|
+
return;
|
371
516
|
}
|
372
|
-
|
517
|
+
const planName = rep.plan.name;
|
373
518
|
invariant(
|
374
|
-
|
375
|
-
"LexicalBuilder:
|
376
|
-
|
377
|
-
|
378
|
-
this.planMap.set(plan, [phase, planRep]);
|
379
|
-
this.planNameMap.set(plan.name, planRep);
|
380
|
-
const currentPhaseMap = this.phases[phase];
|
381
|
-
invariant(
|
382
|
-
currentPhaseMap !== void 0,
|
383
|
-
"LexicalBuilder: Expecting phase map for phase %s",
|
384
|
-
String(phase)
|
519
|
+
isExactlyUnmarkedPlanRepState(mark),
|
520
|
+
"LexicalBuilder: Circular dependency detected for Plan %s from %s",
|
521
|
+
planName,
|
522
|
+
fromPlanName || "[unknown]"
|
385
523
|
);
|
386
|
-
|
387
|
-
|
524
|
+
mark = applyTemporaryMark(mark);
|
525
|
+
rep.state = mark;
|
526
|
+
const outgoingConfigEdges = this.outgoingConfigEdges.get(planName);
|
527
|
+
if (outgoingConfigEdges) {
|
528
|
+
for (const toPlanName of outgoingConfigEdges.keys()) {
|
529
|
+
const toRep = this.planNameMap.get(toPlanName);
|
530
|
+
if (toRep) {
|
531
|
+
visit(toRep, planName);
|
532
|
+
}
|
533
|
+
}
|
534
|
+
}
|
535
|
+
mark = applyPermanentMark(mark);
|
536
|
+
rep.state = mark;
|
537
|
+
sortedPlanReps.push(rep);
|
538
|
+
};
|
539
|
+
for (const rep of this.planNameMap.values()) {
|
540
|
+
if (isExactlyUnmarkedPlanRepState(rep.state)) {
|
541
|
+
visit(rep);
|
542
|
+
}
|
388
543
|
}
|
389
|
-
for (const
|
390
|
-
|
544
|
+
for (const rep of sortedPlanReps) {
|
545
|
+
for (const [toPlanName, configs] of this.outgoingConfigEdges.get(
|
546
|
+
rep.plan.name
|
547
|
+
) || []) {
|
548
|
+
if (configs.length > 0) {
|
549
|
+
const toRep = this.planNameMap.get(toPlanName);
|
550
|
+
if (toRep) {
|
551
|
+
for (const config of configs) {
|
552
|
+
toRep.configs.add(config);
|
553
|
+
}
|
554
|
+
}
|
555
|
+
}
|
556
|
+
}
|
391
557
|
}
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
558
|
+
for (const [plan, ...configs] of this.roots) {
|
559
|
+
if (configs.length > 0) {
|
560
|
+
const toRep = this.planNameMap.get(plan.name);
|
561
|
+
invariant(
|
562
|
+
toRep !== void 0,
|
563
|
+
"LexicalBuilder: Expecting existing PlanRep for %s",
|
564
|
+
plan.name
|
565
|
+
);
|
566
|
+
for (const config of configs) {
|
567
|
+
toRep.configs.add(config);
|
568
|
+
}
|
569
|
+
}
|
397
570
|
}
|
571
|
+
this._sortedPlanReps = sortedPlanReps;
|
572
|
+
return this._sortedPlanReps;
|
398
573
|
}
|
399
574
|
registerEditor(editor, controller) {
|
400
575
|
const cleanups = [];
|
401
|
-
const
|
402
|
-
const planReps
|
403
|
-
|
404
|
-
const cleanup = planRep.register(editor, signal);
|
576
|
+
const planReps = this.sortedPlanReps();
|
577
|
+
for (const planRep of planReps) {
|
578
|
+
const cleanup = planRep.register(editor);
|
405
579
|
if (cleanup) {
|
406
580
|
cleanups.push(cleanup);
|
407
581
|
}
|
408
|
-
planReps.push(planRep);
|
409
582
|
}
|
410
583
|
for (const planRep of planReps) {
|
411
|
-
const cleanup = planRep.afterInitialization(editor
|
584
|
+
const cleanup = planRep.afterInitialization(editor);
|
412
585
|
if (cleanup) {
|
413
586
|
cleanups.push(cleanup);
|
414
587
|
}
|
415
588
|
}
|
416
|
-
planReps.length = 0;
|
417
589
|
return () => {
|
418
590
|
for (let i = cleanups.length - 1; i >= 0; i--) {
|
419
591
|
const cleanupFun = cleanups[i];
|
@@ -435,7 +607,7 @@ class LexicalBuilder {
|
|
435
607
|
const htmlExport = /* @__PURE__ */ new Map();
|
436
608
|
const htmlImport = {};
|
437
609
|
const theme = {};
|
438
|
-
const planReps =
|
610
|
+
const planReps = this.sortedPlanReps();
|
439
611
|
for (const planRep of planReps) {
|
440
612
|
const { plan } = planRep;
|
441
613
|
if (plan.onError !== void 0) {
|
@@ -538,7 +710,7 @@ function getKnownTypesAndNodes(config) {
|
|
538
710
|
}
|
539
711
|
const AutoFocusPlan = definePlan({
|
540
712
|
config: safeCast({}),
|
541
|
-
name: "@etrepum/lexical-builder/
|
713
|
+
name: "@etrepum/lexical-builder/AutoFocus",
|
542
714
|
register(editor, { defaultSelection }) {
|
543
715
|
return editor.registerRootListener((rootElement) => {
|
544
716
|
editor.focus(
|
@@ -589,7 +761,7 @@ const HistoryPlan = definePlan({
|
|
589
761
|
createInitialHistoryState: createEmptyHistoryState,
|
590
762
|
delay: 300
|
591
763
|
}),
|
592
|
-
name: "@etrepum/lexical-builder/
|
764
|
+
name: "@etrepum/lexical-builder/History",
|
593
765
|
register(editor, { delay, createInitialHistoryState }) {
|
594
766
|
return registerHistory(editor, createInitialHistoryState(), delay);
|
595
767
|
}
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/PACKAGE_VERSION.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/PlanRep.ts","../src/InitialStatePlan.ts","../src/LexicalBuilder.ts","../src/getPlanDependencyFromEditor.ts","../src/getPeerDependencyFromEditor.ts","../src/config.ts","../src/AutoFocusPlan.ts","../src/disabledToggle.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/PlainTextPlan.ts","../src/RichTextPlan.ts"],"sourcesContent":["/** The build version of this package (e.g. \"0.16.0\") */\nexport const PACKAGE_VERSION: string = import.meta.env.PACKAGE_VERSION;\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// invariant(condition, message) will refine types based on \"condition\", and\n// if \"condition\" is false will throw an error. This function is special-cased\n// in flow itself, so we can't name it anything else.\nexport default function invariant(\n cond?: boolean,\n message?: string,\n ...args: string[]\n): asserts cond {\n if (cond) {\n return;\n }\n\n throw new Error(\n args.reduce((msg, arg) => msg.replace(\"%s\", String(arg)), message || \"\"),\n );\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/**\n * Recursively merge the given theme configuration in-place.\n *\n * @returns If `a` and `b` are both objects (and `b` is not an Array) then\n * all keys in `b` are merged into `a` then `a` is returned.\n * Otherwise `b` is returned.\n *\n * @example\n * ```ts\n * const a = { a: \"a\", nested: { a: 1 } };\n * const b = { b: \"b\", nested: { b: 2 } };\n * const rval = deepThemeMergeInPlace(a, b);\n * expect(a).toBe(rval);\n * expect(a).toEqual({ a: \"a\", b: \"b\", nested: { a: 1, b: 2 } });\n * ```\n */\nexport function deepThemeMergeInPlace(a: unknown, b: unknown) {\n if (\n a &&\n b &&\n !Array.isArray(b) &&\n typeof a === \"object\" &&\n typeof b === \"object\"\n ) {\n const aObj = a as Record<string, unknown>;\n const bObj = b as Record<string, unknown>;\n for (const k in bObj) {\n aObj[k] = deepThemeMergeInPlace(aObj[k], bObj[k]);\n }\n return a;\n }\n return b;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LexicalBuilder } from \"./LexicalBuilder\";\nimport type {\n AnyLexicalPlan,\n InitialEditorConfig,\n LexicalPlanConfig,\n LexicalPlanDependency,\n LexicalPlanInit,\n LexicalPlanOutput,\n RegisterState,\n} from \"@etrepum/lexical-builder-core\";\n\nimport invariant from \"./shared/invariant\";\n\nimport { shallowMergeConfig } from \"@etrepum/lexical-builder-core\";\nimport type { LexicalEditor } from \"lexical\";\n\nconst noop = () => {};\n/**\n * @internal\n */\nexport class PlanRep<Plan extends AnyLexicalPlan> {\n builder: LexicalBuilder;\n configs: Set<Partial<LexicalPlanConfig<Plan>>>;\n _config?: LexicalPlanConfig<Plan>;\n _dependency?: LexicalPlanDependency<Plan>;\n _output?: LexicalPlanOutput<Plan>;\n _peerNameSet?: Set<string>;\n _registerState?: RegisterState<LexicalPlanInit<Plan>>;\n _initResult?: LexicalPlanInit<Plan>;\n plan: Plan;\n constructor(builder: LexicalBuilder, plan: Plan) {\n this.builder = builder;\n this.plan = plan;\n this.configs = new Set();\n }\n afterInitialization(\n editor: LexicalEditor,\n signal: AbortSignal,\n ): undefined | (() => void) {\n if (!this.plan.afterInitialization) {\n return undefined;\n }\n return this.plan.afterInitialization(\n editor,\n this.getConfig(),\n this.getRegisterState(signal),\n );\n }\n register(\n editor: LexicalEditor,\n signal: AbortSignal,\n ): undefined | (() => void) {\n if (!this.plan.register) {\n this._output = undefined;\n return undefined;\n }\n invariant(\n this._registerState !== undefined,\n \"PlanRep: register called before init\",\n );\n const cleanup = this.plan.register(\n editor,\n this.getConfig(),\n this.getRegisterState(signal),\n );\n this._output = cleanup.output as LexicalPlanOutput<Plan>;\n return cleanup;\n }\n init(editorConfig: InitialEditorConfig, signal: AbortSignal) {\n const config = this.getConfig();\n const registerState = this.getRegisterState(signal);\n if (this.plan.init) {\n this._initResult = this.plan.init(\n editorConfig,\n config,\n registerState as RegisterState<never>,\n );\n }\n }\n getInitResult(): LexicalPlanInit<Plan> {\n invariant(\n \"_initResult\" in this,\n \"PlanRep: getInitResult() called for Plan %s but no result was set\",\n this.plan.name,\n );\n return this._initResult!;\n }\n getRegisterState(signal: AbortSignal): RegisterState<LexicalPlanInit<Plan>> {\n if (!this._registerState) {\n this._registerState = {\n getPeer: this.getPeer.bind(this),\n getDependency: this.getDependency.bind(this),\n getDirectDependentNames: this.getDirectDependentNames.bind(this),\n getPeerNameSet: this.getPeerNameSet.bind(this),\n getInitResult: this.getInitResult.bind(this),\n signal,\n };\n }\n return this._registerState;\n }\n getPeer<PeerPlan extends AnyLexicalPlan = never>(\n name: PeerPlan[\"name\"],\n ): undefined | LexicalPlanDependency<PeerPlan> {\n const rep = this.builder.planNameMap.get(name);\n return rep\n ? (rep.getPlanDependency() as LexicalPlanDependency<PeerPlan>)\n : undefined;\n }\n getDependency<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): LexicalPlanDependency<Dependency> {\n const rep = this.builder.getPlanRep(dep);\n invariant(\n rep !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return rep.getPlanDependency();\n }\n\n getDirectDependentNames() {\n return Array.from(\n this.builder.reverseEdges.get(this.plan) || [],\n (plan) => plan.name,\n );\n }\n\n getPeerNameSet() {\n let s = this._peerNameSet;\n if (!s) {\n s = new Set((this.plan.peerDependencies || []).map(([name]) => name));\n this._peerNameSet = s;\n }\n return s;\n }\n\n getPlanDependency(): LexicalPlanDependency<Plan> {\n if (!this._dependency) {\n invariant(\n \"_output\" in this,\n \"Plan %s used as a dependency before registration\",\n this.plan.name,\n );\n this._dependency = {\n config: this.getConfig(),\n output: this._output!,\n };\n }\n return this._dependency;\n }\n getConfig(): LexicalPlanConfig<Plan> {\n if (this._config === undefined) {\n let config = this.plan.config || {};\n const mergeConfig = this.plan.mergeConfig\n ? this.plan.mergeConfig.bind(this.plan)\n : shallowMergeConfig;\n for (const cfg of this.configs) {\n config = mergeConfig(config, cfg);\n }\n this._config = config;\n return config;\n }\n return this._config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { definePlan, safeCast } from \"@etrepum/lexical-builder-core\";\n\nimport {\n $createParagraphNode,\n $getRoot,\n LineBreakNode,\n ParagraphNode,\n RootNode,\n TabNode,\n TextNode,\n type LexicalEditor,\n type EditorSetOptions,\n // TODO https://github.com/facebook/lexical/pull/6332\n // type EditorUpdateOptions\n} from \"lexical\";\n\n// TODO https://github.com/facebook/lexical/pull/6332\ntype EditorUpdateOptions = NonNullable<Parameters<LexicalEditor[\"update\"]>[1]>;\nconst HISTORY_MERGE_OPTIONS = { tag: \"history-merge\" };\n\nfunction $defaultInitializer() {\n const root = $getRoot();\n if (root.isEmpty()) {\n root.append($createParagraphNode());\n }\n}\n\nexport interface InitialStateConfig {\n updateOptions: EditorUpdateOptions;\n setOptions: EditorSetOptions;\n}\n\nexport const InitialStatePlan = definePlan({\n name: \"@etrepum/lexical-builder/InitialState\",\n // These are automatically added by createEditor, we add them here so they are\n // visible during planRep.init so plans can see all known types before the\n // editor is created.\n // (excluding ArtificialNode__DO_NOT_USE because it isn't really public API\n // and shouldn't change anything)\n nodes: [RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode],\n config: safeCast<InitialStateConfig>({\n updateOptions: HISTORY_MERGE_OPTIONS,\n setOptions: HISTORY_MERGE_OPTIONS,\n }),\n init({ $initialEditorState = $defaultInitializer }) {\n return $initialEditorState;\n },\n afterInitialization(editor, { updateOptions, setOptions }, state) {\n const $initialEditorState = state.getInitResult();\n switch (typeof $initialEditorState) {\n case \"function\": {\n editor.update(() => $initialEditorState(editor), updateOptions);\n break;\n }\n case \"string\": {\n const parsedEditorState = editor.parseEditorState($initialEditorState);\n editor.setEditorState(parsedEditorState, setOptions);\n break;\n }\n case \"object\": {\n if ($initialEditorState) {\n editor.setEditorState($initialEditorState, setOptions);\n }\n break;\n }\n }\n return () => {};\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type {\n AnyLexicalPlan,\n AnyLexicalPlanArgument,\n LexicalEditorWithDispose,\n InitialEditorConfig,\n LexicalPlanConfig,\n} from \"@etrepum/lexical-builder-core\";\nimport {\n type LexicalEditor,\n createEditor,\n type CreateEditorArgs,\n type EditorThemeClasses,\n type HTMLConfig,\n type KlassConstructor,\n type LexicalNode,\n} from \"lexical\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { configPlan } from \"@etrepum/lexical-builder-core\";\nimport invariant from \"./shared/invariant\";\nimport { deepThemeMergeInPlace } from \"./deepThemeMergeInPlace\";\nimport { PlanRep } from \"./PlanRep\";\nimport { PACKAGE_VERSION } from \"./PACKAGE_VERSION\";\nimport { InitialStatePlan } from \"./InitialStatePlan\";\n\n/** @internal Use a well-known symbol for dev tools purposes */\nexport const builderSymbol = Symbol.for(\"@etrepum/lexical-builder\");\n\n/**\n * Build a LexicalEditor by combining together one or more plans, optionally\n * overriding some of their configuration.\n *\n * @param plan A plan argument (a plan, or a plan with config overrides)\n * @param plans Optional additional plan arguments\n * @returns An editor handle\n *\n * @example A single root plan with multiple dependencies\n * ```ts\n * const editor = buildEditorFromPlans(\n * definePlan({\n * name: \"[root]\",\n * dependencies: [\n * RichTextPlan,\n * configPlan(EmojiPlan, { emojiBaseUrl: \"/assets/emoji\" }),\n * ],\n * register: (editor: LexicalEditor) => {\n * console.log(\"Editor Created\");\n * return () => console.log(\"Editor Disposed\");\n * },\n * }),\n * );\n * ```\n * @example A very similar minimal configuration without the register hook\n * ```ts\n * const editor = buildEditorFromPlans(\n * RichTextPlan,\n * configPlan(EmojiPlan, { emojiBaseUrl: \"/assets/emoji\" }),\n * );\n * ```\n */\nexport function buildEditorFromPlans(\n plan: AnyLexicalPlanArgument,\n ...plans: AnyLexicalPlanArgument[]\n): LexicalEditorWithDispose {\n const builder = new LexicalBuilder();\n builder.addPlan(InitialStatePlan);\n builder.addPlan(plan);\n for (const otherPlan of plans) {\n builder.addPlan(otherPlan);\n }\n return builder.buildEditor();\n}\n\n/** @internal */\nfunction noop() {}\n\n/** Throw the given Error */\nfunction defaultOnError(err: Error) {\n throw err;\n}\n\ninterface WithBuilder {\n [builderSymbol]?: LexicalBuilder;\n}\n\n/** @internal */\nfunction maybeWithBuilder(editor: LexicalEditor): LexicalEditor & WithBuilder {\n return editor;\n}\n\n/** @internal */\nexport class LexicalBuilder {\n phases: Map<AnyLexicalPlan, PlanRep<AnyLexicalPlan>>[];\n planMap: Map<AnyLexicalPlan, [number, PlanRep<AnyLexicalPlan>]>;\n planNameMap: Map<string, PlanRep<AnyLexicalPlan>>;\n reverseEdges: Map<AnyLexicalPlan, Set<AnyLexicalPlan>>;\n addStack: Set<AnyLexicalPlan>;\n conflicts: Map<string, string>;\n PACKAGE_VERSION: string;\n\n constructor() {\n // closure compiler can't handle class initializers\n this.phases = [new Map()];\n this.planMap = new Map();\n this.planNameMap = new Map();\n this.conflicts = new Map();\n this.reverseEdges = new Map();\n this.addStack = new Set();\n this.PACKAGE_VERSION = PACKAGE_VERSION;\n }\n\n /** Look up the editor that was created by this LexicalBuilder or throw */\n static fromEditor(editor: LexicalEditor): LexicalBuilder {\n const builder = maybeWithBuilder(editor)[builderSymbol];\n invariant(\n builder && typeof builder === \"object\",\n \"LexicalBuilder.fromEditor: The given editor was not created with LexicalBuilder, or has been disposed\",\n );\n // The dev tools variant of this will relax some of these invariants\n invariant(\n builder.PACKAGE_VERSION === PACKAGE_VERSION,\n \"LexicalBuilder.fromEditor: The given editor was created with LexicalBuilder %s but this version is %s. A project should have exactly one copy of LexicalBuilder\",\n builder.PACKAGE_VERSION,\n PACKAGE_VERSION,\n );\n invariant(\n builder instanceof LexicalBuilder,\n \"LexicalBuilder.fromEditor: There are multiple copies of the same version of LexicalBuilder in your project, and this editor was created with another one. Your project, or one of its dependencies, has its package.json and/or bundler configured incorrectly.\",\n );\n return builder;\n }\n\n buildEditor(): LexicalEditorWithDispose {\n const controller = new AbortController();\n const { $initialEditorState, onError, ...editorConfig } =\n this.buildCreateEditorArgs(controller.signal);\n let disposeOnce = noop;\n function dispose() {\n try {\n disposeOnce();\n } finally {\n disposeOnce = noop;\n }\n }\n const editor: LexicalEditorWithDispose & WithBuilder = Object.assign(\n createEditor({\n ...editorConfig,\n ...(onError ? { onError: (err) => { onError(err, editor); } } : {}),\n }),\n { [builderSymbol]: this, dispose, [Symbol.dispose]: dispose },\n );\n disposeOnce = mergeRegister(\n () => {\n delete maybeWithBuilder(editor)[builderSymbol];\n },\n () => { editor.setRootElement(null); },\n this.registerEditor(editor, controller),\n );\n return editor;\n }\n\n getPlanRep<Plan extends AnyLexicalPlan>(\n plan: Plan,\n ): PlanRep<Plan> | undefined {\n const pair = this.planMap.get(plan);\n if (pair) {\n const rep: PlanRep<AnyLexicalPlan> = pair[1];\n return rep as PlanRep<Plan>;\n }\n }\n\n addPlan(arg: AnyLexicalPlanArgument, parent?: AnyLexicalPlan): number {\n let plan: AnyLexicalPlan;\n let configs: unknown[];\n if (Array.isArray(arg)) {\n [plan, ...configs] = arg;\n } else {\n plan = arg;\n configs = [];\n }\n invariant(\n typeof plan.name === \"string\",\n \"LexicalBuilder: plan name must be string, not %s\",\n typeof plan.name,\n );\n // Track incoming dependencies\n if (parent) {\n let edgeSet = this.reverseEdges.get(plan);\n if (!edgeSet) {\n edgeSet = new Set();\n this.reverseEdges.set(plan, edgeSet);\n }\n edgeSet.add(parent);\n }\n let [phase, planRep] = this.planMap.get(plan) || [0, undefined];\n if (!planRep) {\n const hasConflict = this.conflicts.get(plan.name);\n if (typeof hasConflict === \"string\") {\n invariant(\n false,\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n hasConflict,\n );\n }\n for (const name of plan.conflictsWith || []) {\n invariant(\n !this.planNameMap.has(name),\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n name,\n );\n this.conflicts.set(name, plan.name);\n }\n invariant(\n !this.addStack.has(plan),\n \"LexicalBuilder: Circular dependency detected for Plan %s from %s\",\n plan.name,\n parent?.name || \"[unknown]\",\n );\n this.addStack.add(plan);\n for (const dep of plan.dependencies || []) {\n phase = Math.max(phase, 1 + this.addPlan(dep, plan));\n }\n for (const [depName, cfg] of plan.peerDependencies || []) {\n const dep = this.planNameMap.get(depName);\n if (dep) {\n phase = Math.max(\n phase,\n 1 +\n this.addPlan(\n configPlan(\n dep.plan,\n (cfg || {}) as LexicalPlanConfig<typeof dep.plan>,\n ),\n plan,\n ),\n );\n }\n }\n invariant(\n this.phases.length >= phase,\n \"LexicalBuilder: Expected phase to be no greater than phases.length\",\n );\n if (this.phases.length === phase) {\n this.phases.push(new Map());\n }\n planRep = new PlanRep(this, plan);\n invariant(\n !this.planNameMap.has(plan.name),\n \"LexicalBuilder: Multiple plans registered with name %s, names must be unique\",\n plan.name,\n );\n this.planMap.set(plan, [phase, planRep]);\n this.planNameMap.set(plan.name, planRep);\n const currentPhaseMap = this.phases[phase];\n invariant(\n currentPhaseMap !== undefined,\n \"LexicalBuilder: Expecting phase map for phase %s\",\n String(phase),\n );\n currentPhaseMap.set(plan, planRep);\n this.addStack.delete(plan);\n }\n for (const config of configs) {\n planRep.configs.add(config as Partial<LexicalPlanConfig<AnyLexicalPlan>>);\n }\n return phase;\n }\n\n *sortedPlanReps() {\n for (const phase of this.phases) {\n yield* phase.values();\n }\n }\n\n registerEditor(\n editor: LexicalEditor,\n controller: AbortController,\n ): () => void {\n const cleanups: (() => void)[] = [];\n const signal = controller.signal;\n const planReps: PlanRep<AnyLexicalPlan>[] = [];\n for (const planRep of this.sortedPlanReps()) {\n const cleanup = planRep.register(editor, signal);\n if (cleanup) {\n cleanups.push(cleanup);\n }\n planReps.push(planRep);\n }\n for (const planRep of planReps) {\n const cleanup = planRep.afterInitialization(editor, signal);\n if (cleanup) {\n cleanups.push(cleanup);\n }\n }\n planReps.length = 0;\n return () => {\n for (let i = cleanups.length - 1; i >= 0; i--) {\n const cleanupFun = cleanups[i];\n invariant(\n cleanupFun !== undefined,\n \"LexicalBuilder: Expecting cleanups[%s] to be defined\",\n String(i),\n );\n cleanupFun();\n }\n cleanups.length = 0;\n controller.abort();\n };\n }\n\n buildCreateEditorArgs(signal: AbortSignal) {\n const config: InitialEditorConfig = {};\n const nodes = new Set<NonNullable<CreateEditorArgs[\"nodes\"]>[number]>();\n const replacedNodes = new Map<\n KlassConstructor<typeof LexicalNode>,\n PlanRep<AnyLexicalPlan>\n >();\n const htmlExport: NonNullable<HTMLConfig[\"export\"]> = new Map();\n const htmlImport: NonNullable<HTMLConfig[\"import\"]> = {};\n const theme: EditorThemeClasses = {};\n const planReps = [...this.sortedPlanReps()];\n for (const planRep of planReps) {\n const { plan } = planRep;\n if (plan.onError !== undefined) {\n config.onError = plan.onError;\n }\n if (plan.disableEvents !== undefined) {\n config.disableEvents = plan.disableEvents;\n }\n if (plan.editable !== undefined) {\n config.editable = plan.editable;\n }\n if (plan.namespace !== undefined) {\n config.namespace = plan.namespace;\n }\n if (plan.$initialEditorState !== undefined) {\n config.$initialEditorState = plan.$initialEditorState;\n }\n if (plan.nodes) {\n for (const node of plan.nodes) {\n if (typeof node !== \"function\") {\n const conflictPlan = replacedNodes.get(node.replace);\n if (conflictPlan) {\n invariant(\n false,\n \"LexicalBuilder: Plan %s can not register replacement for node %s because %s already did\",\n plan.name,\n node.replace.name,\n conflictPlan.plan.name,\n );\n }\n replacedNodes.set(node.replace, planRep);\n }\n nodes.add(node);\n }\n }\n if (plan.html) {\n if (plan.html.export) {\n for (const [k, v] of plan.html.export.entries()) {\n htmlExport.set(k, v);\n }\n }\n if (plan.html.import) {\n Object.assign(htmlImport, plan.html.import);\n }\n }\n if (plan.theme) {\n deepThemeMergeInPlace(theme, plan.theme);\n }\n }\n if (Object.keys(theme).length > 0) {\n config.theme = theme;\n }\n if (nodes.size) {\n config.nodes = [...nodes];\n }\n const hasImport = Object.keys(htmlImport).length > 0;\n const hasExport = htmlExport.size > 0;\n if (hasImport || hasExport) {\n config.html = {};\n if (hasImport) {\n config.html.import = htmlImport;\n }\n if (hasExport) {\n config.html.export = htmlExport;\n }\n }\n for (const planRep of planReps) {\n planRep.init(config, signal);\n }\n if (!config.onError) {\n config.onError = defaultOnError;\n }\n return config;\n }\n}\n","import { LexicalEditor } from \"lexical\";\nimport {\n AnyLexicalPlan,\n LexicalPlanDependency,\n} from \"@etrepum/lexical-builder-core\";\nimport { LexicalBuilder } from \"./LexicalBuilder\";\nimport invariant from \"./shared/invariant\";\n\n/**\n * Get the finalized config and output of a Plan that was used to build the editor.\n *\n * This is useful in the implementation of a LexicalNode or in other\n * situations where you have an editor reference but it's not easy to\n * pass the config or {@link RegisterState} around.\n *\n * It will throw if the Editor was not built using this Plan.\n *\n * @param editor The editor that was built using plan\n * @param plan The concrete reference to a Plan used to build this editor\n * @returns The config and output for that Plan\n */\nexport function getPlanDependencyFromEditor<Plan extends AnyLexicalPlan>(\n editor: LexicalEditor,\n plan: Plan,\n): LexicalPlanDependency<Plan> {\n const builder = LexicalBuilder.fromEditor(editor);\n const rep = builder.getPlanRep(plan);\n invariant(\n rep !== undefined,\n \"getPlanFromEditor: Plan %s was not built when creating this editor\",\n plan.name,\n );\n return rep.getPlanDependency();\n}\n","import { LexicalEditor } from \"lexical\";\nimport {\n AnyLexicalPlan,\n LexicalPlanDependency,\n} from \"@etrepum/lexical-builder-core\";\nimport { LexicalBuilder } from \"./LexicalBuilder\";\n\n/**\n * Get the finalized config and output of a Plan that was used to build the\n * editor by name.\n *\n * This can be used from the implementation of a LexicalNode or in other\n * situation where you have an editor reference but it's not easy to pass the\n * config around. Use this version if you do not have a concrete reference to\n * the Plan for some reason (e.g. it is an optional peer dependency).\n *\n * Both the explicit Plan type and the name are required.\n *\n * @example\n * ```tsx\n * getPeerDependencyFromEditor<typeof import(\"@some/plan\").SomePlan>(editor, \"@some/plan\");\n * ```\n\n * @param editor The editor that may have been built using plan\n * @param planName The name of the Plan\n * @returns The config and output of the Plan or undefined\n */\nexport function getPeerDependencyFromEditor<\n Plan extends AnyLexicalPlan = never,\n>(\n editor: LexicalEditor,\n planName: Plan[\"name\"],\n): LexicalPlanDependency<Plan> | undefined {\n const builder = LexicalBuilder.fromEditor(editor);\n const peer = builder.planNameMap.get(planName);\n return peer\n ? (peer.getPlanDependency() as LexicalPlanDependency<Plan>)\n : undefined;\n}\n","import { InitialEditorConfig } from \"@etrepum/lexical-builder-core\";\nimport { KlassConstructor, LexicalNode } from \"lexical\";\n\nexport interface KnownTypesAndNodes {\n types: Set<string>;\n nodes: Set<KlassConstructor<typeof LexicalNode>>;\n}\nexport function getKnownTypesAndNodes(config: InitialEditorConfig) {\n const types: KnownTypesAndNodes[\"types\"] = new Set();\n const nodes: KnownTypesAndNodes[\"nodes\"] = new Set();\n for (const klassOrReplacement of config.nodes ?? []) {\n const klass =\n typeof klassOrReplacement === \"function\"\n ? klassOrReplacement\n : klassOrReplacement.replace;\n types.add(klass.getType());\n nodes.add(klass);\n }\n return { types, nodes };\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { definePlan, safeCast } from \"@etrepum/lexical-builder-core\";\n\nexport interface AutoFocusConfig {\n /**\n * Where to move the selection when the editor is focused and there is no\n * existing selection. Can be \"rootStart\" or \"rootEnd\" (the default).\n */\n defaultSelection?: \"rootStart\" | \"rootEnd\";\n}\n\n/**\n * A Plan to focus the LexicalEditor when the root element is set\n * (typically only when the editor is first created).\n */\nexport const AutoFocusPlan = definePlan({\n config: safeCast<AutoFocusConfig>({}),\n name: \"@etrepum/lexical-builder/AutoFocusPlan\",\n register(editor, { defaultSelection }) {\n return editor.registerRootListener((rootElement) => {\n editor.focus(\n () => {\n // If we try and move selection to the same point with setBaseAndExtent, it won't\n // trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.\n // Normally this is fine, Selection API !== Focus API, but fore the intents of the naming\n // of this plugin, which should preserve focus too.\n const activeElement = document.activeElement;\n if (\n rootElement !== null &&\n (activeElement === null || !rootElement.contains(activeElement))\n ) {\n // Note: preventScroll won't work in Webkit.\n rootElement.focus({ preventScroll: true });\n }\n },\n { defaultSelection },\n );\n });\n },\n});\n","export interface DisabledToggleOptions {\n disabled?: boolean;\n register: () => () => void;\n}\nexport interface DisabledToggleOutput {\n isDisabled: () => boolean;\n setDisabled: (disabled: boolean) => void;\n}\nexport function disabledToggle(\n opts: DisabledToggleOptions,\n): [DisabledToggleOutput, () => void] {\n let cleanup: null | (() => void) = null;\n function isDisabled(): boolean {\n return cleanup !== null;\n }\n function setDisabled(disabled: boolean): void {\n if (!disabled && cleanup === null) {\n cleanup = opts.register();\n } else if (disabled && cleanup !== null) {\n cleanup();\n cleanup = null;\n }\n }\n setDisabled(Boolean(opts.disabled));\n return [\n { isDisabled, setDisabled },\n () => {\n setDisabled(false);\n },\n ];\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { registerDragonSupport } from \"@lexical/dragon\";\nimport {\n definePlan,\n provideOutput,\n safeCast,\n} from \"@etrepum/lexical-builder-core\";\nimport { disabledToggle } from \"./disabledToggle\";\n\nexport interface DragonConfig {\n disabled: boolean;\n}\nexport interface DragonOutput {\n isDisabled: () => boolean;\n setDisabled: (disabled: boolean) => void;\n}\n\n/**\n * Add Dragon speech to text input support to the editor, via the\n * \\@lexical/dragon module.\n */\nexport const DragonPlan = definePlan({\n name: \"@lexical/dragon\",\n config: safeCast<DragonConfig>({ disabled: false }),\n register: (editor, config) =>\n provideOutput<DragonOutput>(\n ...disabledToggle({\n disabled: config.disabled,\n register: () => registerDragonSupport(editor),\n }),\n ),\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport {\n createEmptyHistoryState,\n type HistoryState,\n registerHistory,\n} from \"@lexical/history\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\nimport { safeCast } from \"@etrepum/lexical-builder-core\";\n\nexport interface HistoryConfig {\n /**\n * The time (in milliseconds) the editor should delay generating a new history stack,\n * instead of merging the current changes with the current stack. The default is 300ms.\n */\n delay: number;\n /**\n * The initial history state, the default is {@link createEmptyHistoryState}.\n */\n createInitialHistoryState: () => HistoryState;\n}\n\n/**\n * Registers necessary listeners to manage undo/redo history stack and related\n * editor commands, via the @lexical/history module.\n */\nexport const HistoryPlan = definePlan({\n config: safeCast<HistoryConfig>({\n createInitialHistoryState: createEmptyHistoryState,\n delay: 300,\n }),\n name: \"@etrepum/lexical-builder/HistoryPlan\",\n register(editor, { delay, createInitialHistoryState }) {\n return registerHistory(editor, createInitialHistoryState(), delay);\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { registerPlainText } from \"@lexical/plain-text\";\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\nimport { DragonPlan } from \"./DragonPlan\";\n\n/**\n * A plan to register \\@lexical/plain-text behavior\n */\nexport const PlainTextPlan = definePlan({\n conflictsWith: [\"@lexical/rich-text\"],\n name: \"@lexical/plain-text\",\n dependencies: [DragonPlan],\n register: registerPlainText,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { HeadingNode, QuoteNode, registerRichText } from \"@lexical/rich-text\";\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\nimport { DragonPlan } from \"./DragonPlan\";\n\n/**\n * A plan to register \\@lexical/rich-text behavior and nodes\n * ({@link HeadingNode}, {@link QuoteNode})\n */\nexport const RichTextPlan = definePlan({\n conflictsWith: [\"@lexical/plain-text\"],\n name: \"@lexical/rich-text\",\n nodes: [HeadingNode, QuoteNode],\n dependencies: [DragonPlan],\n register: registerRichText,\n});\n"],"names":[],"mappings":";;;;;;;;;;;AACa,MAAA,kBAA0B;ACUf,SAAA,UACtB,MACA,YACG,MACW;AACd,MAAI,MAAM;AACR;AAAA,EACF;AAEA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AAQ,0BAA0B,GAAG,KAAK;AAAA,EACnE;AACF,CAAC;AC3BM,MAAM,gBAAgB,WAAW;AAAA,EACtC,eAAe,CAAC,oBAAoB;AAAA,EACpC,MAAM;AAAA,EACN,cAAc,CAAC,UAAU;AAAA,EACzB,UAAU;AACZ,CAAC;ACHM,MAAM,eAAe,WAAW;AAAA,EACrC,eAAe,CAAC,qBAAqB;AAAA,EACrC,MAAM;AAAA,EACN,OAAO,CAAC,aAAa,SAAS;AAAA,EAC9B,cAAc,CAAC,UAAU;AAAA,EACzB,UAAU;AACZ,CAAC;"}
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/PACKAGE_VERSION.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/PlanRep.ts","../src/InitialStatePlan.ts","../src/LexicalBuilder.ts","../src/getPlanDependencyFromEditor.ts","../src/getPeerDependencyFromEditor.ts","../src/config.ts","../src/AutoFocusPlan.ts","../src/disabledToggle.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/PlainTextPlan.ts","../src/RichTextPlan.ts"],"sourcesContent":["/** The build version of this package (e.g. \"0.16.0\") */\nexport const PACKAGE_VERSION: string = import.meta.env.PACKAGE_VERSION;\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// invariant(condition, message) will refine types based on \"condition\", and\n// if \"condition\" is false will throw an error. This function is special-cased\n// in flow itself, so we can't name it anything else.\nexport default function invariant(\n cond?: boolean,\n message?: string,\n ...args: string[]\n): asserts cond {\n if (cond) {\n return;\n }\n\n throw new Error(\n args.reduce((msg, arg) => msg.replace(\"%s\", String(arg)), message || \"\"),\n );\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/**\n * Recursively merge the given theme configuration in-place.\n *\n * @returns If `a` and `b` are both objects (and `b` is not an Array) then\n * all keys in `b` are merged into `a` then `a` is returned.\n * Otherwise `b` is returned.\n *\n * @example\n * ```ts\n * const a = { a: \"a\", nested: { a: 1 } };\n * const b = { b: \"b\", nested: { b: 2 } };\n * const rval = deepThemeMergeInPlace(a, b);\n * expect(a).toBe(rval);\n * expect(a).toEqual({ a: \"a\", b: \"b\", nested: { a: 1, b: 2 } });\n * ```\n */\nexport function deepThemeMergeInPlace(a: unknown, b: unknown) {\n if (\n a &&\n b &&\n !Array.isArray(b) &&\n typeof a === \"object\" &&\n typeof b === \"object\"\n ) {\n const aObj = a as Record<string, unknown>;\n const bObj = b as Record<string, unknown>;\n for (const k in bObj) {\n aObj[k] = deepThemeMergeInPlace(aObj[k], bObj[k]);\n }\n return a;\n }\n return b;\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {\n AnyLexicalPlan,\n InitialEditorConfig,\n LexicalPlanConfig,\n LexicalPlanDependency,\n LexicalPlanInit,\n LexicalPlanOutput,\n RegisterCleanup,\n PlanInitState,\n PlanRegisterState,\n} from \"@etrepum/lexical-builder-core\";\nimport { shallowMergeConfig } from \"@etrepum/lexical-builder-core\";\nimport type { LexicalEditor } from \"lexical\";\nimport invariant from \"./shared/invariant\";\nimport type { LexicalBuilder } from \"./LexicalBuilder\";\n\nexport const PlanRepStateIds = {\n unmarked: 0,\n temporary: 1,\n permanent: 2,\n configured: 3,\n initialized: 4,\n registered: 5,\n afterInitialization: 6,\n} as const;\ninterface UnmarkedState {\n id: (typeof PlanRepStateIds)[\"unmarked\"];\n}\ninterface TemporaryState extends Omit<UnmarkedState, \"id\"> {\n id: (typeof PlanRepStateIds)[\"temporary\"];\n}\ninterface PermanentState extends Omit<TemporaryState, \"id\"> {\n id: (typeof PlanRepStateIds)[\"permanent\"];\n}\ninterface ConfiguredState<Plan extends AnyLexicalPlan>\n extends Omit<PermanentState, \"id\"> {\n id: (typeof PlanRepStateIds)[\"configured\"];\n config: LexicalPlanConfig<Plan>;\n registerState: PlanInitState;\n}\ninterface InitializedState<Plan extends AnyLexicalPlan>\n extends Omit<ConfiguredState<Plan>, \"id\" | \"registerState\"> {\n id: (typeof PlanRepStateIds)[\"initialized\"];\n initResult: LexicalPlanInit<Plan>;\n registerState: PlanRegisterState<LexicalPlanInit<Plan>>;\n}\ninterface RegisteredState<Plan extends AnyLexicalPlan>\n extends Omit<InitializedState<Plan>, \"id\"> {\n id: (typeof PlanRepStateIds)[\"registered\"];\n output: LexicalPlanOutput<Plan>;\n}\ninterface AfterInitializationState<Plan extends AnyLexicalPlan>\n extends Omit<RegisteredState<Plan>, \"id\"> {\n id: (typeof PlanRepStateIds)[\"afterInitialization\"];\n}\n\nexport type PlanRepState<Plan extends AnyLexicalPlan> =\n | UnmarkedState\n | TemporaryState\n | PermanentState\n | ConfiguredState<Plan>\n | InitializedState<Plan>\n | RegisteredState<Plan>\n | AfterInitializationState<Plan>;\n\nexport function isExactlyUnmarkedPlanRepState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is UnmarkedState {\n return state.id === PlanRepStateIds.unmarked;\n}\nfunction isExactlyTemporaryPlanRepState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is TemporaryState {\n return state.id === PlanRepStateIds.temporary;\n}\nexport function isExactlyPermanentPlanRepState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is PermanentState {\n return state.id === PlanRepStateIds.permanent;\n}\nfunction isInitializedPlanRepState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is\n | InitializedState<Plan>\n | RegisteredState<Plan>\n | AfterInitializationState<Plan> {\n return state.id >= PlanRepStateIds.initialized;\n}\nfunction isConfiguredPlanRepState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is\n | ConfiguredState<Plan>\n | InitializedState<Plan>\n | RegisteredState<Plan>\n | AfterInitializationState<Plan> {\n return state.id >= PlanRepStateIds.configured;\n}\nfunction isRegisteredPlanRepState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is RegisteredState<Plan> | AfterInitializationState<Plan> {\n return state.id >= PlanRepStateIds.registered;\n}\nfunction isAfterInitializationState<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): state is AfterInitializationState<Plan> {\n return state.id >= PlanRepStateIds.afterInitialization;\n}\nexport function applyTemporaryMark<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): TemporaryState {\n invariant(\n isExactlyUnmarkedPlanRepState(state),\n \"LexicalBuilder: Can not apply a temporary mark to state\",\n );\n return Object.assign(state, { id: PlanRepStateIds.temporary });\n}\nexport function applyPermanentMark<Plan extends AnyLexicalPlan>(\n state: PlanRepState<Plan>,\n): PermanentState {\n invariant(\n isExactlyTemporaryPlanRepState(state),\n \"LexicalBuilder: Can not apply a permanent mark to state\",\n );\n return Object.assign(state, { id: PlanRepStateIds.permanent });\n}\nexport function applyConfiguredState<Plan extends AnyLexicalPlan>(\n state: PermanentState,\n config: LexicalPlanConfig<Plan>,\n registerState: PlanInitState,\n): ConfiguredState<Plan> {\n return Object.assign(state, {\n id: PlanRepStateIds.configured,\n config,\n registerState,\n });\n}\nexport function applyInitializedState<Plan extends AnyLexicalPlan>(\n state: ConfiguredState<Plan>,\n initResult: LexicalPlanInit<Plan>,\n registerState: PlanRegisterState<Plan>,\n): InitializedState<Plan> {\n return Object.assign(state, {\n id: PlanRepStateIds.initialized,\n initResult,\n registerState,\n });\n}\nexport function applyRegisteredState<Plan extends AnyLexicalPlan>(\n state: InitializedState<Plan>,\n cleanup?: RegisterCleanup<LexicalPlanOutput<Plan>> | undefined,\n) {\n return Object.assign(state, {\n id: PlanRepStateIds.registered,\n output: cleanup ? cleanup.output : undefined,\n });\n}\nexport function applyAfterInitializationState<Plan extends AnyLexicalPlan>(\n state: RegisteredState<Plan>,\n): AfterInitializationState<Plan> {\n return Object.assign(state, { id: PlanRepStateIds.afterInitialization });\n}\n\nconst emptySet: ReadonlySet<string> = new Set();\n\n/**\n * @internal\n */\nexport class PlanRep<Plan extends AnyLexicalPlan> {\n builder: LexicalBuilder;\n configs: Set<Partial<LexicalPlanConfig<Plan>>>;\n _dependency?: LexicalPlanDependency<Plan>;\n _output?: LexicalPlanOutput<Plan>;\n _peerNameSet?: Set<string>;\n plan: Plan;\n state: PlanRepState<Plan>;\n constructor(builder: LexicalBuilder, plan: Plan) {\n this.builder = builder;\n this.plan = plan;\n this.configs = new Set();\n this.state = { id: PlanRepStateIds.unmarked };\n }\n\n afterInitialization(editor: LexicalEditor): undefined | (() => void) {\n const state = this.state;\n invariant(\n state.id === PlanRepStateIds.registered,\n \"PlanRep: afterInitialization called in state id %s (expected %s registered)\",\n String(state.id),\n String(PlanRepStateIds.registered),\n );\n let rval: undefined | (() => void);\n if (this.plan.afterInitialization) {\n rval = this.plan.afterInitialization(\n editor,\n state.config,\n state.registerState,\n );\n }\n this.state = applyAfterInitializationState(state);\n return rval;\n }\n register(editor: LexicalEditor): undefined | (() => void) {\n const state = this.state;\n invariant(\n state.id === PlanRepStateIds.initialized,\n \"PlanRep: register called in state id %s (expected %s initialized)\",\n String(state.id),\n String(PlanRepStateIds.initialized),\n );\n let cleanup: undefined | RegisterCleanup<LexicalPlanOutput<Plan>>;\n if (this.plan.register) {\n cleanup = this.plan.register(\n editor,\n state.config,\n state.registerState,\n ) as RegisterCleanup<LexicalPlanOutput<Plan>>;\n }\n this.state = applyRegisteredState(state, cleanup);\n return cleanup;\n }\n init(editorConfig: InitialEditorConfig, signal: AbortSignal) {\n const initialState = this.state;\n invariant(\n isExactlyPermanentPlanRepState(initialState),\n \"LexicalBuilder: Can not configure from state id %s\",\n String(initialState.id),\n );\n const initState: PlanInitState = {\n signal,\n getDirectDependentNames: this.getDirectDependentNames.bind(this),\n getPeerNameSet: this.getPeerNameSet.bind(this),\n getPeer: this.getInitPeer.bind(this),\n getDependency: this.getInitDependency.bind(this),\n };\n const registerState: PlanRegisterState<Plan> = {\n ...initState,\n getPeer: this.getPeer.bind(this),\n getDependency: this.getDependency.bind(this),\n getInitResult: this.getInitResult.bind(this),\n };\n const state = applyConfiguredState(\n initialState,\n this.mergeConfigs(),\n initState,\n );\n this.state = state;\n let initResult: LexicalPlanInit<Plan> | undefined;\n if (this.plan.init) {\n initResult = this.plan.init(\n editorConfig,\n state.config,\n initState,\n ) as LexicalPlanInit<Plan>;\n }\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- false positive\n this.state = applyInitializedState(state, initResult!, registerState);\n }\n getInitResult(): LexicalPlanInit<Plan> {\n invariant(\n this.plan.init !== undefined,\n \"PlanRep: getInitResult() called for Plan %s that does not define init\",\n this.plan.name,\n );\n const state = this.state;\n invariant(\n isInitializedPlanRepState(state),\n \"PlanRep: getInitResult() called for PlanRep in state id %s < %s (initialized)\",\n String(state.id),\n String(PlanRepStateIds.initialized),\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- any\n return state.initResult;\n }\n\n getInitPeer<PeerPlan extends AnyLexicalPlan = never>(\n name: PeerPlan[\"name\"],\n ): undefined | Omit<LexicalPlanDependency<PeerPlan>, \"output\"> {\n const rep = this.builder.planNameMap.get(name);\n return rep ? rep.getPlanInitDependency() : undefined;\n }\n\n getPlanInitDependency(): Omit<LexicalPlanDependency<Plan>, \"output\"> {\n const state = this.state;\n invariant(\n isConfiguredPlanRepState(state),\n \"LexicalPlanBuilder: getPlanInitDependency called in state id %s (expected >= %s configured)\",\n String(state.id),\n String(PlanRepStateIds.configured),\n );\n return { config: state.config };\n }\n\n getPeer<PeerPlan extends AnyLexicalPlan = never>(\n name: PeerPlan[\"name\"],\n ): undefined | LexicalPlanDependency<PeerPlan> {\n const rep = this.builder.planNameMap.get(name);\n return rep\n ? (rep.getPlanDependency() as LexicalPlanDependency<PeerPlan>)\n : undefined;\n }\n\n getInitDependency<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): Omit<LexicalPlanDependency<Dependency>, \"output\"> {\n const rep = this.builder.getPlanRep(dep);\n invariant(\n rep !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return rep.getPlanInitDependency();\n }\n\n getDependency<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): LexicalPlanDependency<Dependency> {\n const rep = this.builder.getPlanRep(dep);\n invariant(\n rep !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return rep.getPlanDependency();\n }\n\n getState(): AfterInitializationState<Plan> {\n const state = this.state;\n invariant(\n isAfterInitializationState(state),\n \"PlanRep getState called in state id %s (expected %s afterInitialization)\",\n String(state.id),\n String(PlanRepStateIds.afterInitialization),\n );\n return state;\n }\n\n getDirectDependentNames(): ReadonlySet<string> {\n return this.builder.incomingEdges.get(this.plan.name) || emptySet;\n }\n\n getPeerNameSet(): ReadonlySet<string> {\n let s = this._peerNameSet;\n if (!s) {\n s = new Set((this.plan.peerDependencies || []).map(([name]) => name));\n this._peerNameSet = s;\n }\n return s;\n }\n\n getPlanDependency(): LexicalPlanDependency<Plan> {\n if (!this._dependency) {\n const state = this.state;\n invariant(\n isRegisteredPlanRepState(state),\n \"Plan %s used as a dependency before registration\",\n this.plan.name,\n );\n this._dependency = {\n config: state.config,\n output: state.output,\n };\n }\n return this._dependency;\n }\n mergeConfigs(): LexicalPlanConfig<Plan> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- LexicalPlanConfig<Plan> is any\n let config: LexicalPlanConfig<Plan> = this.plan.config || {};\n const mergeConfig = this.plan.mergeConfig\n ? this.plan.mergeConfig.bind(this.plan)\n : shallowMergeConfig;\n for (const cfg of this.configs) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- LexicalPlanConfig<Plan> is any\n config = mergeConfig(config, cfg);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- any\n return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { definePlan, safeCast } from \"@etrepum/lexical-builder-core\";\nimport {\n $createParagraphNode,\n $getRoot,\n LineBreakNode,\n ParagraphNode,\n RootNode,\n TabNode,\n TextNode,\n type EditorSetOptions,\n type EditorUpdateOptions,\n} from \"lexical\";\n\nconst HISTORY_MERGE_OPTIONS = { tag: \"history-merge\" };\n\nfunction $defaultInitializer() {\n const root = $getRoot();\n if (root.isEmpty()) {\n root.append($createParagraphNode());\n }\n}\n\nexport interface InitialStateConfig {\n updateOptions: EditorUpdateOptions;\n setOptions: EditorSetOptions;\n}\n\nexport const InitialStatePlan = definePlan({\n name: \"@etrepum/lexical-builder/InitialState\",\n // These are automatically added by createEditor, we add them here so they are\n // visible during planRep.init so plans can see all known types before the\n // editor is created.\n // (excluding ArtificialNode__DO_NOT_USE because it isn't really public API\n // and shouldn't change anything)\n nodes: [RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode],\n config: safeCast<InitialStateConfig>({\n updateOptions: HISTORY_MERGE_OPTIONS,\n setOptions: HISTORY_MERGE_OPTIONS,\n }),\n init({ $initialEditorState = $defaultInitializer }) {\n return $initialEditorState;\n },\n afterInitialization(editor, { updateOptions, setOptions }, state) {\n const $initialEditorState = state.getInitResult();\n switch (typeof $initialEditorState) {\n case \"function\": {\n editor.update(() => {\n $initialEditorState(editor);\n }, updateOptions);\n break;\n }\n case \"string\": {\n const parsedEditorState = editor.parseEditorState($initialEditorState);\n editor.setEditorState(parsedEditorState, setOptions);\n break;\n }\n case \"object\": {\n if ($initialEditorState) {\n editor.setEditorState($initialEditorState, setOptions);\n }\n break;\n }\n default: {\n /* noop */\n }\n }\n return () => {\n /* noop */\n };\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type {\n AnyLexicalPlan,\n AnyLexicalPlanArgument,\n LexicalEditorWithDispose,\n InitialEditorConfig,\n LexicalPlanConfig,\n} from \"@etrepum/lexical-builder-core\";\nimport {\n type LexicalEditor,\n createEditor,\n type CreateEditorArgs,\n type EditorThemeClasses,\n type HTMLConfig,\n type KlassConstructor,\n type LexicalNode,\n} from \"lexical\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { configPlan } from \"@etrepum/lexical-builder-core\";\nimport invariant from \"./shared/invariant\";\nimport { deepThemeMergeInPlace } from \"./deepThemeMergeInPlace\";\nimport {\n PlanRep,\n applyPermanentMark,\n applyTemporaryMark,\n isExactlyPermanentPlanRepState,\n isExactlyUnmarkedPlanRepState,\n} from \"./PlanRep\";\nimport { PACKAGE_VERSION } from \"./PACKAGE_VERSION\";\nimport { InitialStatePlan } from \"./InitialStatePlan\";\n\n/** @internal Use a well-known symbol for dev tools purposes */\nexport const builderSymbol = Symbol.for(\"@etrepum/lexical-builder\");\n\n/**\n * Build a LexicalEditor by combining together one or more plans, optionally\n * overriding some of their configuration.\n *\n * @param plans - Plan arguments (plans or plans with config overrides)\n * @returns An editor handle\n *\n * @example A single root plan with multiple dependencies\n * ```ts\n * const editor = buildEditorFromPlans(\n * definePlan({\n * name: \"[root]\",\n * dependencies: [\n * RichTextPlan,\n * configPlan(EmojiPlan, { emojiBaseUrl: \"/assets/emoji\" }),\n * ],\n * register: (editor: LexicalEditor) => {\n * console.log(\"Editor Created\");\n * return () => console.log(\"Editor Disposed\");\n * },\n * }),\n * );\n * ```\n * @example A very similar minimal configuration without the register hook\n * ```ts\n * const editor = buildEditorFromPlans(\n * RichTextPlan,\n * configPlan(EmojiPlan, { emojiBaseUrl: \"/assets/emoji\" }),\n * );\n * ```\n */\nexport function buildEditorFromPlans(\n ...plans: AnyLexicalPlanArgument[]\n): LexicalEditorWithDispose {\n return LexicalBuilder.fromPlans(plans).buildEditor();\n}\n\n/** @internal */\nfunction noop() {\n /*empty*/\n}\n\n/** Throw the given Error */\nfunction defaultOnError(err: Error) {\n throw err;\n}\n\ninterface WithBuilder {\n [builderSymbol]?: LexicalBuilder | undefined;\n}\n\n/** @internal */\nfunction maybeWithBuilder(editor: LexicalEditor): LexicalEditor & WithBuilder {\n return editor;\n}\n\ntype AnyNormalizedLexicalPlanArgument = ReturnType<\n typeof normalizePlanArgument\n>;\nfunction normalizePlanArgument(arg: AnyLexicalPlanArgument) {\n return Array.isArray(arg) ? arg : configPlan(arg);\n}\n\n/** @internal */\nexport class LexicalBuilder {\n roots: readonly AnyNormalizedLexicalPlanArgument[];\n planNameMap: Map<string, PlanRep<AnyLexicalPlan>>;\n outgoingConfigEdges: Map<\n string,\n Map<string, LexicalPlanConfig<AnyLexicalPlan>[]>\n >;\n incomingEdges: Map<string, Set<string>>;\n conflicts: Map<string, string>;\n _sortedPlanReps?: readonly PlanRep<AnyLexicalPlan>[];\n PACKAGE_VERSION: string;\n\n constructor(roots: AnyNormalizedLexicalPlanArgument[]) {\n this.outgoingConfigEdges = new Map();\n this.incomingEdges = new Map();\n this.planNameMap = new Map();\n this.conflicts = new Map();\n this.PACKAGE_VERSION = PACKAGE_VERSION;\n this.roots = roots;\n for (const plan of roots) {\n this.addPlan(plan);\n }\n }\n\n static fromPlans(plans: AnyLexicalPlanArgument[]): LexicalBuilder {\n const roots = [normalizePlanArgument(InitialStatePlan)];\n for (const plan of plans) {\n roots.push(normalizePlanArgument(plan));\n }\n return new LexicalBuilder(roots);\n }\n\n /** Look up the editor that was created by this LexicalBuilder or throw */\n static fromEditor(editor: LexicalEditor): LexicalBuilder {\n const builder = maybeWithBuilder(editor)[builderSymbol];\n invariant(\n builder && typeof builder === \"object\",\n \"LexicalBuilder.fromEditor: The given editor was not created with LexicalBuilder, or has been disposed\",\n );\n // The dev tools variant of this will relax some of these invariants\n invariant(\n builder.PACKAGE_VERSION === PACKAGE_VERSION,\n \"LexicalBuilder.fromEditor: The given editor was created with LexicalBuilder %s but this version is %s. A project should have exactly one copy of LexicalBuilder\",\n builder.PACKAGE_VERSION,\n PACKAGE_VERSION,\n );\n invariant(\n builder instanceof LexicalBuilder,\n \"LexicalBuilder.fromEditor: There are multiple copies of the same version of LexicalBuilder in your project, and this editor was created with another one. Your project, or one of its dependencies, has its package.json and/or bundler configured incorrectly.\",\n );\n return builder;\n }\n\n buildEditor(): LexicalEditorWithDispose {\n const controller = new AbortController();\n const {\n $initialEditorState: _$initialEditorState,\n onError,\n ...editorConfig\n } = this.buildCreateEditorArgs(controller.signal);\n let disposeOnce = noop;\n function dispose() {\n try {\n disposeOnce();\n } finally {\n disposeOnce = noop;\n }\n }\n const editor: LexicalEditorWithDispose & WithBuilder = Object.assign(\n createEditor({\n ...editorConfig,\n ...(onError\n ? {\n onError: (err) => {\n onError(err, editor);\n },\n }\n : {}),\n }),\n { [builderSymbol]: this, dispose, [Symbol.dispose]: dispose },\n );\n disposeOnce = mergeRegister(\n () => {\n maybeWithBuilder(editor)[builderSymbol] = undefined;\n },\n () => {\n editor.setRootElement(null);\n },\n this.registerEditor(editor, controller),\n );\n return editor;\n }\n\n getPlanRep<Plan extends AnyLexicalPlan>(\n plan: Plan,\n ): PlanRep<Plan> | undefined {\n const rep = this.planNameMap.get(plan.name);\n if (rep) {\n invariant(\n rep.plan === plan,\n \"LexicalBuilder: A registered plan with name %s exists but does not match the given plan\",\n plan.name,\n );\n return rep as PlanRep<Plan>;\n }\n }\n\n addEdge(\n fromPlanName: string,\n toPlanName: string,\n configs: LexicalPlanConfig<AnyLexicalPlan>[],\n ) {\n const outgoing = this.outgoingConfigEdges.get(fromPlanName);\n if (outgoing) {\n outgoing.set(toPlanName, configs);\n } else {\n this.outgoingConfigEdges.set(\n fromPlanName,\n new Map([[toPlanName, configs]]),\n );\n }\n const incoming = this.incomingEdges.get(toPlanName);\n if (incoming) {\n incoming.add(fromPlanName);\n } else {\n this.incomingEdges.set(toPlanName, new Set([fromPlanName]));\n }\n }\n\n addPlan(arg: AnyLexicalPlanArgument) {\n invariant(\n this._sortedPlanReps === undefined,\n \"LexicalBuilder: addPlan called after finalization\",\n );\n const normalized = normalizePlanArgument(arg);\n const [plan] = normalized;\n invariant(\n typeof plan.name === \"string\",\n \"LexicalBuilder: plan name must be string, not %s\",\n typeof plan.name,\n );\n let planRep = this.planNameMap.get(plan.name);\n invariant(\n planRep === undefined || planRep.plan === plan,\n \"LexicalBuilder: Multiple plans registered with name %s, names must be unique\",\n plan.name,\n );\n if (!planRep) {\n planRep = new PlanRep(this, plan);\n this.planNameMap.set(plan.name, planRep);\n const hasConflict = this.conflicts.get(plan.name);\n if (typeof hasConflict === \"string\") {\n invariant(\n false,\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n hasConflict,\n );\n }\n for (const name of plan.conflictsWith || []) {\n invariant(\n !this.planNameMap.has(name),\n \"LexicalBuilder: plan %s conflicts with %s\",\n plan.name,\n name,\n );\n this.conflicts.set(name, plan.name);\n }\n for (const dep of plan.dependencies || []) {\n const normDep = normalizePlanArgument(dep);\n this.addEdge(plan.name, normDep[0].name, normDep.slice(1));\n this.addPlan(normDep);\n }\n for (const [depName, config] of plan.peerDependencies || []) {\n this.addEdge(plan.name, depName, config ? [config] : []);\n }\n }\n }\n\n sortedPlanReps(): readonly PlanRep<AnyLexicalPlan>[] {\n if (this._sortedPlanReps) {\n return this._sortedPlanReps;\n }\n // depth-first search based topological DAG sort\n // https://en.wikipedia.org/wiki/Topological_sorting\n const sortedPlanReps: PlanRep<AnyLexicalPlan>[] = [];\n const visit = (rep: PlanRep<AnyLexicalPlan>, fromPlanName?: string) => {\n let mark = rep.state;\n if (isExactlyPermanentPlanRepState(mark)) {\n return;\n }\n const planName = rep.plan.name;\n invariant(\n isExactlyUnmarkedPlanRepState(mark),\n \"LexicalBuilder: Circular dependency detected for Plan %s from %s\",\n planName,\n fromPlanName || \"[unknown]\",\n );\n mark = applyTemporaryMark(mark);\n rep.state = mark;\n const outgoingConfigEdges = this.outgoingConfigEdges.get(planName);\n if (outgoingConfigEdges) {\n for (const toPlanName of outgoingConfigEdges.keys()) {\n const toRep = this.planNameMap.get(toPlanName);\n // may be undefined for an optional peer dependency\n if (toRep) {\n visit(toRep, planName);\n }\n }\n }\n mark = applyPermanentMark(mark);\n rep.state = mark;\n sortedPlanReps.push(rep);\n };\n for (const rep of this.planNameMap.values()) {\n if (isExactlyUnmarkedPlanRepState(rep.state)) {\n visit(rep);\n }\n }\n for (const rep of sortedPlanReps) {\n for (const [toPlanName, configs] of this.outgoingConfigEdges.get(\n rep.plan.name,\n ) || []) {\n if (configs.length > 0) {\n const toRep = this.planNameMap.get(toPlanName);\n if (toRep) {\n for (const config of configs) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- any\n toRep.configs.add(config);\n }\n }\n }\n }\n }\n for (const [plan, ...configs] of this.roots) {\n if (configs.length > 0) {\n const toRep = this.planNameMap.get(plan.name);\n invariant(\n toRep !== undefined,\n \"LexicalBuilder: Expecting existing PlanRep for %s\",\n plan.name,\n );\n for (const config of configs) {\n toRep.configs.add(config);\n }\n }\n }\n this._sortedPlanReps = sortedPlanReps;\n return this._sortedPlanReps;\n }\n\n registerEditor(\n editor: LexicalEditor,\n controller: AbortController,\n ): () => void {\n const cleanups: (() => void)[] = [];\n const planReps = this.sortedPlanReps();\n for (const planRep of planReps) {\n const cleanup = planRep.register(editor);\n if (cleanup) {\n cleanups.push(cleanup);\n }\n }\n for (const planRep of planReps) {\n const cleanup = planRep.afterInitialization(editor);\n if (cleanup) {\n cleanups.push(cleanup);\n }\n }\n return () => {\n for (let i = cleanups.length - 1; i >= 0; i--) {\n const cleanupFun = cleanups[i];\n invariant(\n cleanupFun !== undefined,\n \"LexicalBuilder: Expecting cleanups[%s] to be defined\",\n String(i),\n );\n cleanupFun();\n }\n cleanups.length = 0;\n controller.abort();\n };\n }\n\n buildCreateEditorArgs(signal: AbortSignal) {\n const config: InitialEditorConfig = {};\n const nodes = new Set<NonNullable<CreateEditorArgs[\"nodes\"]>[number]>();\n const replacedNodes = new Map<\n KlassConstructor<typeof LexicalNode>,\n PlanRep<AnyLexicalPlan>\n >();\n const htmlExport: NonNullable<HTMLConfig[\"export\"]> = new Map();\n const htmlImport: NonNullable<HTMLConfig[\"import\"]> = {};\n const theme: EditorThemeClasses = {};\n const planReps = this.sortedPlanReps();\n for (const planRep of planReps) {\n const { plan } = planRep;\n if (plan.onError !== undefined) {\n config.onError = plan.onError;\n }\n if (plan.disableEvents !== undefined) {\n config.disableEvents = plan.disableEvents;\n }\n if (plan.editable !== undefined) {\n config.editable = plan.editable;\n }\n if (plan.namespace !== undefined) {\n config.namespace = plan.namespace;\n }\n if (plan.$initialEditorState !== undefined) {\n config.$initialEditorState = plan.$initialEditorState;\n }\n if (plan.nodes) {\n for (const node of plan.nodes) {\n if (typeof node !== \"function\") {\n const conflictPlan = replacedNodes.get(node.replace);\n if (conflictPlan) {\n invariant(\n false,\n \"LexicalBuilder: Plan %s can not register replacement for node %s because %s already did\",\n plan.name,\n node.replace.name,\n conflictPlan.plan.name,\n );\n }\n replacedNodes.set(node.replace, planRep);\n }\n nodes.add(node);\n }\n }\n if (plan.html) {\n if (plan.html.export) {\n for (const [k, v] of plan.html.export.entries()) {\n htmlExport.set(k, v);\n }\n }\n if (plan.html.import) {\n Object.assign(htmlImport, plan.html.import);\n }\n }\n if (plan.theme) {\n deepThemeMergeInPlace(theme, plan.theme);\n }\n }\n if (Object.keys(theme).length > 0) {\n config.theme = theme;\n }\n if (nodes.size) {\n config.nodes = [...nodes];\n }\n const hasImport = Object.keys(htmlImport).length > 0;\n const hasExport = htmlExport.size > 0;\n if (hasImport || hasExport) {\n config.html = {};\n if (hasImport) {\n config.html.import = htmlImport;\n }\n if (hasExport) {\n config.html.export = htmlExport;\n }\n }\n for (const planRep of planReps) {\n planRep.init(config, signal);\n }\n if (!config.onError) {\n config.onError = defaultOnError;\n }\n return config;\n }\n}\n","import type { LexicalEditor } from \"lexical\";\nimport type {\n AnyLexicalPlan,\n LexicalPlanDependency,\n} from \"@etrepum/lexical-builder-core\";\nimport { LexicalBuilder } from \"./LexicalBuilder\";\nimport invariant from \"./shared/invariant\";\n\n/**\n * Get the finalized config and output of a Plan that was used to build the editor.\n *\n * This is useful in the implementation of a LexicalNode or in other\n * situations where you have an editor reference but it's not easy to\n * pass the config or {@link PlanRegisterState} around.\n *\n * It will throw if the Editor was not built using this Plan.\n *\n * @param editor - The editor that was built using plan\n * @param plan - The concrete reference to a Plan used to build this editor\n * @returns The config and output for that Plan\n */\nexport function getPlanDependencyFromEditor<Plan extends AnyLexicalPlan>(\n editor: LexicalEditor,\n plan: Plan,\n): LexicalPlanDependency<Plan> {\n const builder = LexicalBuilder.fromEditor(editor);\n const rep = builder.getPlanRep(plan);\n invariant(\n rep !== undefined,\n \"getPlanFromEditor: Plan %s was not built when creating this editor\",\n plan.name,\n );\n return rep.getPlanDependency();\n}\n","import type { LexicalEditor } from \"lexical\";\nimport type {\n AnyLexicalPlan,\n LexicalPlanDependency,\n} from \"@etrepum/lexical-builder-core\";\nimport { LexicalBuilder } from \"./LexicalBuilder\";\n\n/**\n * Get the finalized config and output of a Plan that was used to build the\n * editor by name.\n *\n * This can be used from the implementation of a LexicalNode or in other\n * situation where you have an editor reference but it's not easy to pass the\n * config around. Use this version if you do not have a concrete reference to\n * the Plan for some reason (e.g. it is an optional peer dependency).\n *\n * Both the explicit Plan type and the name are required.\n *\n * @example\n * ```tsx\n * getPeerDependencyFromEditor<typeof import(\"@some/plan\").SomePlan>(editor, \"@some/plan\");\n * ```\n\n * @param editor - The editor that may have been built using plan\n * @param planName - The name of the Plan\n * @returns The config and output of the Plan or undefined\n */\nexport function getPeerDependencyFromEditor<\n Plan extends AnyLexicalPlan = never,\n>(\n editor: LexicalEditor,\n planName: Plan[\"name\"],\n): LexicalPlanDependency<Plan> | undefined {\n const builder = LexicalBuilder.fromEditor(editor);\n const peer = builder.planNameMap.get(planName);\n return peer\n ? (peer.getPlanDependency() as LexicalPlanDependency<Plan>)\n : undefined;\n}\n","import type { InitialEditorConfig } from \"@etrepum/lexical-builder-core\";\nimport type { KlassConstructor, LexicalNode } from \"lexical\";\n\nexport interface KnownTypesAndNodes {\n types: Set<string>;\n nodes: Set<KlassConstructor<typeof LexicalNode>>;\n}\nexport function getKnownTypesAndNodes(config: InitialEditorConfig) {\n const types: KnownTypesAndNodes[\"types\"] = new Set();\n const nodes: KnownTypesAndNodes[\"nodes\"] = new Set();\n for (const klassOrReplacement of config.nodes ?? []) {\n const klass =\n typeof klassOrReplacement === \"function\"\n ? klassOrReplacement\n : klassOrReplacement.replace;\n types.add(klass.getType());\n nodes.add(klass);\n }\n return { types, nodes };\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { definePlan, safeCast } from \"@etrepum/lexical-builder-core\";\n\nexport interface AutoFocusConfig {\n /**\n * Where to move the selection when the editor is focused and there is no\n * existing selection. Can be \"rootStart\" or \"rootEnd\" (the default).\n */\n defaultSelection?: \"rootStart\" | \"rootEnd\";\n}\n\n/**\n * A Plan to focus the LexicalEditor when the root element is set\n * (typically only when the editor is first created).\n */\nexport const AutoFocusPlan = definePlan({\n config: safeCast<AutoFocusConfig>({}),\n name: \"@etrepum/lexical-builder/AutoFocus\",\n register(editor, { defaultSelection }) {\n return editor.registerRootListener((rootElement) => {\n editor.focus(\n () => {\n // If we try and move selection to the same point with setBaseAndExtent, it won't\n // trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.\n // Normally this is fine, Selection API !== Focus API, but fore the intents of the naming\n // of this plugin, which should preserve focus too.\n const activeElement = document.activeElement;\n if (\n rootElement !== null &&\n (activeElement === null || !rootElement.contains(activeElement))\n ) {\n // Note: preventScroll won't work in Webkit.\n rootElement.focus({ preventScroll: true });\n }\n },\n { defaultSelection },\n );\n });\n },\n});\n","export interface DisabledToggleOptions {\n disabled?: boolean;\n register: () => () => void;\n}\nexport interface DisabledToggleOutput {\n isDisabled: () => boolean;\n setDisabled: (disabled: boolean) => void;\n}\nexport function disabledToggle(\n opts: DisabledToggleOptions,\n): [DisabledToggleOutput, () => void] {\n let cleanup: null | (() => void) = null;\n function isDisabled(): boolean {\n return cleanup !== null;\n }\n function setDisabled(disabled: boolean): void {\n if (!disabled && cleanup === null) {\n cleanup = opts.register();\n } else if (disabled && cleanup !== null) {\n cleanup();\n cleanup = null;\n }\n }\n setDisabled(Boolean(opts.disabled));\n return [\n { isDisabled, setDisabled },\n () => {\n setDisabled(false);\n },\n ];\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { registerDragonSupport } from \"@lexical/dragon\";\nimport {\n definePlan,\n provideOutput,\n safeCast,\n} from \"@etrepum/lexical-builder-core\";\nimport { disabledToggle } from \"./disabledToggle\";\n\nexport interface DragonConfig {\n disabled: boolean;\n}\nexport interface DragonOutput {\n isDisabled: () => boolean;\n setDisabled: (disabled: boolean) => void;\n}\n\n/**\n * Add Dragon speech to text input support to the editor, via the\n * \\@lexical/dragon module.\n */\nexport const DragonPlan = definePlan({\n name: \"@lexical/dragon\",\n config: safeCast<DragonConfig>({ disabled: false }),\n register: (editor, config) =>\n provideOutput<DragonOutput>(\n ...disabledToggle({\n disabled: config.disabled,\n register: () => registerDragonSupport(editor),\n }),\n ),\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport {\n createEmptyHistoryState,\n type HistoryState,\n registerHistory,\n} from \"@lexical/history\";\nimport { definePlan, safeCast } from \"@etrepum/lexical-builder-core\";\n\nexport interface HistoryConfig {\n /**\n * The time (in milliseconds) the editor should delay generating a new history stack,\n * instead of merging the current changes with the current stack. The default is 300ms.\n */\n delay: number;\n /**\n * The initial history state, the default is {@link createEmptyHistoryState}.\n */\n createInitialHistoryState: () => HistoryState;\n}\n\n/**\n * Registers necessary listeners to manage undo/redo history stack and related\n * editor commands, via the \\@lexical/history module.\n */\nexport const HistoryPlan = definePlan({\n config: safeCast<HistoryConfig>({\n createInitialHistoryState: createEmptyHistoryState,\n delay: 300,\n }),\n name: \"@etrepum/lexical-builder/History\",\n register(editor, { delay, createInitialHistoryState }) {\n return registerHistory(editor, createInitialHistoryState(), delay);\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { registerPlainText } from \"@lexical/plain-text\";\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\nimport { DragonPlan } from \"./DragonPlan\";\n\n/**\n * A plan to register \\@lexical/plain-text behavior\n */\nexport const PlainTextPlan = definePlan({\n conflictsWith: [\"@lexical/rich-text\"],\n name: \"@lexical/plain-text\",\n dependencies: [DragonPlan],\n register: registerPlainText,\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { HeadingNode, QuoteNode, registerRichText } from \"@lexical/rich-text\";\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\nimport { DragonPlan } from \"./DragonPlan\";\n\n/**\n * A plan to register \\@lexical/rich-text behavior and nodes\n * ({@link HeadingNode}, {@link QuoteNode})\n */\nexport const RichTextPlan = definePlan({\n conflictsWith: [\"@lexical/plain-text\"],\n name: \"@lexical/rich-text\",\n nodes: [HeadingNode, QuoteNode],\n dependencies: [DragonPlan],\n register: registerRichText,\n});\n"],"names":[],"mappings":";;;;;;;;;;;AACa,MAAA,kBAA0B;ACUf,SAAA,UACtB,MACA,YACG,MACW;AACd,MAAI,MAAM;AACR;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR,KAAK,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,MAAM,OAAO,GAAG,CAAC,GAAG,WA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AAoB;AAAA,EACpC,MAAM;AAAA,EACN,cAAc,CAAC,UAAU;AAAA,EACzB,UAAU;AACZ,CAAC;ACHM,MAAM,eAAe,WAAW;AAAA,EACrC,eAAe,CAAC,qBAAqB;AAAA,EACrC,MAAM;AAAA,EACN,OAAO,CAAC,aAAa,SAAS;AAAA,EAC9B,cAAc,CAAC,UAAU;AAAA,EACzB,UAAU;AACZ,CAAC;"}
|
package/package.json
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
"test:watch": "vitest",
|
19
19
|
"lint": "eslint"
|
20
20
|
},
|
21
|
-
"version": "0.0.28
|
21
|
+
"version": "0.0.28",
|
22
22
|
"license": "MIT",
|
23
23
|
"repository": {
|
24
24
|
"type": "git",
|
@@ -53,6 +53,7 @@
|
|
53
53
|
"tslib": "^2.6.2",
|
54
54
|
"typescript": "^5.4.5",
|
55
55
|
"vite": "^5.2.11",
|
56
|
+
"vite-plugin-dts": "^3.9.1",
|
56
57
|
"vite-plugin-package-version": "^1.1.0",
|
57
58
|
"vitest": "^1.6.0"
|
58
59
|
},
|