@etrepum/lexical-builder 0.0.25-nightly.20240624.0 → 0.0.26-nightly.20240625.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ import { LexicalEditor, EditorSetOptions } from 'lexical';
2
+
3
+ type EditorUpdateOptions = NonNullable<Parameters<LexicalEditor["update"]>[1]>;
4
+ export interface InitialStateConfig {
5
+ updateOptions: EditorUpdateOptions;
6
+ setOptions: EditorSetOptions;
7
+ }
8
+ 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
+ //# sourceMappingURL=InitialStatePlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitialStatePlan.d.ts","sourceRoot":"","sources":["../src/InitialStatePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAQL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAGtB,MAAM,SAAS,CAAC;AAGjB,KAAK,mBAAmB,GAAG,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAU/E,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,2LAoC3B,CAAC"}
@@ -1,7 +1,9 @@
1
- import { AnyLexicalPlan, AnyLexicalPlanArgument, EditorHandle, InitialEditorConfig } from '@etrepum/lexical-builder-core';
1
+ import { AnyLexicalPlan, AnyLexicalPlanArgument, LexicalEditorWithDispose, InitialEditorConfig } from '@etrepum/lexical-builder-core';
2
2
  import { LexicalEditor } from 'lexical';
3
3
  import { PlanRep } from './PlanRep';
4
4
 
5
+ /** @internal Use a well-known symbol for dev tools purposes */
6
+ export declare const builderSymbol: unique symbol;
5
7
  /**
6
8
  * Build a LexicalEditor by combining together one or more plans, optionally
7
9
  * overriding some of their configuration.
@@ -12,7 +14,7 @@ import { PlanRep } from './PlanRep';
12
14
  *
13
15
  * @example A single root plan with multiple dependencies
14
16
  * ```ts
15
- * const editorHandle = buildEditorFromPlans(
17
+ * const editor = buildEditorFromPlans(
16
18
  * definePlan({
17
19
  * name: "[root]",
18
20
  * dependencies: [
@@ -28,13 +30,13 @@ import { PlanRep } from './PlanRep';
28
30
  * ```
29
31
  * @example A very similar minimal configuration without the register hook
30
32
  * ```ts
31
- * const editorHandle = buildEditorFromPlans(
33
+ * const editor = buildEditorFromPlans(
32
34
  * RichTextPlan,
33
35
  * configPlan(EmojiPlan, { emojiBaseUrl: "/assets/emoji" }),
34
36
  * );
35
37
  * ```
36
38
  */
37
- export declare function buildEditorFromPlans(plan: AnyLexicalPlanArgument, ...plans: AnyLexicalPlanArgument[]): EditorHandle;
39
+ export declare function buildEditorFromPlans(plan: AnyLexicalPlanArgument, ...plans: AnyLexicalPlanArgument[]): LexicalEditorWithDispose;
38
40
  /** @internal */
39
41
  export declare class LexicalBuilder {
40
42
  phases: Map<AnyLexicalPlan, PlanRep<AnyLexicalPlan>>[];
@@ -43,10 +45,11 @@ export declare class LexicalBuilder {
43
45
  reverseEdges: Map<AnyLexicalPlan, Set<AnyLexicalPlan>>;
44
46
  addStack: Set<AnyLexicalPlan>;
45
47
  conflicts: Map<string, string>;
48
+ PACKAGE_VERSION: string;
46
49
  constructor();
47
- /** Look up the editor that was created by this LexicalBuilder or undefined */
48
- static fromEditor(editor: LexicalEditor): LexicalBuilder | undefined;
49
- buildEditor(): EditorHandle;
50
+ /** Look up the editor that was created by this LexicalBuilder or throw */
51
+ static fromEditor(editor: LexicalEditor): LexicalBuilder;
52
+ buildEditor(): LexicalEditorWithDispose;
50
53
  getPlanRep<Plan extends AnyLexicalPlan>(plan: Plan): PlanRep<Plan> | undefined;
51
54
  addPlan(arg: AnyLexicalPlanArgument, parent?: AnyLexicalPlan): number;
52
55
  sortedPlanReps(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;IAaxB,0EAA0E;IAC1E,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc;IAoBxD,WAAW,IAAI,wBAAwB;IA6BvC,UAAU,CAAC,IAAI,SAAS,cAAc,EACpC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS;IAQ5B,OAAO,CAAC,GAAG,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM;IAmGpE,cAAc;IAMf,cAAc,CACZ,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,eAAe,GAC1B,MAAM,IAAI;IAiCb,qBAAqB,CAAC,MAAM,EAAE,WAAW;CAqF1C"}
package/dist/PlanRep.d.ts CHANGED
@@ -16,7 +16,8 @@ export declare class PlanRep<Plan extends AnyLexicalPlan> {
16
16
  _initResult?: LexicalPlanInit<Plan>;
17
17
  plan: Plan;
18
18
  constructor(builder: LexicalBuilder, plan: Plan);
19
- register(editor: LexicalEditor, signal: AbortSignal): () => void;
19
+ afterInitialization(editor: LexicalEditor, signal: AbortSignal): undefined | (() => void);
20
+ register(editor: LexicalEditor, signal: AbortSignal): undefined | (() => void);
20
21
  init(editorConfig: InitialEditorConfig, signal: AbortSignal): void;
21
22
  getInitResult(): LexicalPlanInit<Plan>;
22
23
  getRegisterState(signal: AbortSignal): RegisterState<LexicalPlanInit<Plan>>;
@@ -1 +1 @@
1
- {"version":3,"file":"PlanRep.d.ts","sourceRoot":"","sources":["../src/PlanRep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACd,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C;;GAEG;AACH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I,eAAe,CAAC,IAAI,CAAC;IAQtC,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAa3E,OAAO,CAAC,QAAQ,SAAS,cAAc,GAAG,KAAK,EAC7C,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GACrB,SAAS,GAAG,qBAAqB,CAAC,QAAQ,CAAC;IAM9C,aAAa,CAAC,UAAU,SAAS,cAAc,EAC7C,GAAG,EAAE,UAAU,GACd,qBAAqB,CAAC,UAAU,CAAC;IAWpC,uBAAuB;IAOvB,cAAc;IASd,iBAAiB,IAAI,qBAAqB,CAAC,IAAI,CAAC;IAchD,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC;CAcrC"}
@@ -0,0 +1,12 @@
1
+ import { InitialEditorConfig } from '@etrepum/lexical-builder-core';
2
+ import { KlassConstructor, LexicalNode } from 'lexical';
3
+
4
+ export interface KnownTypesAndNodes {
5
+ types: Set<string>;
6
+ nodes: Set<KlassConstructor<typeof LexicalNode>>;
7
+ }
8
+ export declare function getKnownTypesAndNodes(config: InitialEditorConfig): {
9
+ types: Set<string>;
10
+ nodes: Set<KlassConstructor<typeof LexicalNode>>;
11
+ };
12
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExD,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"}
@@ -22,24 +22,4 @@ import { AnyLexicalPlan, LexicalPlanDependency } from '@etrepum/lexical-builder-
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;
25
- /**
26
- * Get the finalized config and output of a Plan that was used to build the
27
- * editor by name.
28
- *
29
- * Both the explicit Plan type and the name are required.
30
- *
31
- * This can be used from the implementation of a LexicalNode or in other
32
- * situation where you have an editor reference but it's not easy to pass the
33
- * config around. Use this version if you do not have a concrete reference to
34
- * the Plan for some reason (e.g. it is an optional peer dependency).
35
- *
36
- * @example
37
- * ```tsx
38
- * $getPeerDependency<typeof import("@some/plan").SomePlan>("@some/plan")
39
- * ```
40
- *
41
- * @param planName The name of the Plan
42
- * @returns The config and output of the Plan or undefined
43
- */
44
- export declare function $getPeerDependency<Plan extends AnyLexicalPlan = never>(planName: Plan["name"]): LexicalPlanDependency<Plan> | undefined;
45
25
  //# sourceMappingURL=getPeerDependencyFromEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPeerDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPeerDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAKvC;;;;;;;;;;;;;;;;;;;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,CAWzC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,cAAc,GAAG,KAAK,EACpE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GACrB,qBAAqB,CAAC,IAAI,CAAC,GAAG,SAAS,CAEzC"}
1
+ {"version":3,"file":"getPeerDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPeerDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EACL,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"}
@@ -15,17 +15,4 @@ import { AnyLexicalPlan, LexicalPlanDependency } from '@etrepum/lexical-builder-
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>;
18
- /**
19
- * Get the finalized config and output of a Plan that was used to build the editor.
20
- *
21
- * This is useful in the implementation of a LexicalNode or in other
22
- * situations where you have an editor reference but it's not easy to
23
- * pass the config or {@link RegisterState} around.
24
- *
25
- * It will throw if the Editor was not built using this Plan.
26
- *
27
- * @param plan The concrete reference to a Plan used to build this editor
28
- * @returns The config and outputs for that Plan
29
- */
30
- export declare function $getPlanDependency<Plan extends AnyLexicalPlan>(plan: Plan): LexicalPlanDependency<Plan>;
31
18
  //# sourceMappingURL=getPlanDependencyFromEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPlanDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPlanDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAKvC;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,SAAS,cAAc,EACrE,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,IAAI,GACT,qBAAqB,CAAC,IAAI,CAAC,CAc7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,cAAc,EAC5D,IAAI,EAAE,IAAI,GACT,qBAAqB,CAAC,IAAI,CAAC,CAE7B"}
1
+ {"version":3,"file":"getPlanDependencyFromEditor.d.ts","sourceRoot":"","sources":["../src/getPlanDependencyFromEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EACL,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,11 +8,13 @@
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 EditorHandle, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanName, type LexicalPlanOutput, type LexicalPlanInit, type OutputComponentPlan, type LexicalPlanDependency, type NormalizedLexicalPlanArgument, type PlanConfigBase, type RegisterState, type NormalizedPeerDependency, } from '@etrepum/lexical-builder-core';
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 RegisterState, 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
- export { $getPlanDependency, getPlanDependencyFromEditor, } from './getPlanDependencyFromEditor';
15
- export { $getPeerDependency, getPeerDependencyFromEditor, } from './getPeerDependencyFromEditor';
14
+ export { getPlanDependencyFromEditor } from './getPlanDependencyFromEditor';
15
+ export { getPeerDependencyFromEditor } from './getPeerDependencyFromEditor';
16
+ export { getKnownTypesAndNodes, type KnownTypesAndNodes } from './config';
17
+ export { InitialStatePlan, type InitialStateConfig } from './InitialStatePlan';
16
18
  export { type AutoFocusConfig, AutoFocusPlan } from './AutoFocusPlan';
17
19
  export { DragonPlan } from './DragonPlan';
18
20
  export { type HistoryConfig, HistoryPlan } from './HistoryPlan';
@@ -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,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,wBAAwB,GAC9B,MAAM,+BAA+B,CA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O,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,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,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,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"}
package/dist/index.js CHANGED
@@ -4,15 +4,15 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { shallowMergeConfig, configPlan, definePlan, safeCast } from "@etrepum/lexical-builder-core";
7
+ import { shallowMergeConfig, definePlan, safeCast, configPlan } from "@etrepum/lexical-builder-core";
8
8
  import { configPlan as configPlan2, declarePeerDependency, definePlan as definePlan2, provideOutput, safeCast as safeCast2, shallowMergeConfig as shallowMergeConfig2 } from "@etrepum/lexical-builder-core";
9
- import { $getRoot, $createParagraphNode, createEditor, $getEditor } from "lexical";
9
+ import { RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode, $getRoot, $createParagraphNode, createEditor } from "lexical";
10
10
  import { mergeRegister } from "@lexical/utils";
11
11
  import { registerDragonSupport } from "@lexical/dragon";
12
12
  import { createEmptyHistoryState, registerHistory } from "@lexical/history";
13
13
  import { registerPlainText } from "@lexical/plain-text";
14
14
  import { HeadingNode, QuoteNode, registerRichText } from "@lexical/rich-text";
15
- const PACKAGE_VERSION = "0.0.25-nightly.20240624.0";
15
+ const PACKAGE_VERSION = "0.0.26-nightly.20240625.0";
16
16
  function invariant(cond, message, ...args) {
17
17
  if (cond) {
18
18
  return;
@@ -32,34 +32,6 @@ function deepThemeMergeInPlace(a, b) {
32
32
  }
33
33
  return b;
34
34
  }
35
- const HISTORY_MERGE_OPTIONS = { tag: "history-merge" };
36
- function $defaultInitializer() {
37
- const root = $getRoot();
38
- if (root.isEmpty()) {
39
- root.append($createParagraphNode());
40
- }
41
- }
42
- function initializeEditor(editor, $initialEditorState = $defaultInitializer) {
43
- switch (typeof $initialEditorState) {
44
- case "function": {
45
- editor.update(() => $initialEditorState(editor), HISTORY_MERGE_OPTIONS);
46
- break;
47
- }
48
- case "string": {
49
- const parsedEditorState = editor.parseEditorState($initialEditorState);
50
- editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);
51
- break;
52
- }
53
- case "object": {
54
- if ($initialEditorState) {
55
- editor.setEditorState($initialEditorState, HISTORY_MERGE_OPTIONS);
56
- }
57
- break;
58
- }
59
- }
60
- }
61
- const noop$1 = () => {
62
- };
63
35
  class PlanRep {
64
36
  constructor(builder, plan) {
65
37
  __publicField(this, "builder");
@@ -75,10 +47,20 @@ class PlanRep {
75
47
  this.plan = plan;
76
48
  this.configs = /* @__PURE__ */ new Set();
77
49
  }
50
+ afterInitialization(editor, signal) {
51
+ if (!this.plan.afterInitialization) {
52
+ return void 0;
53
+ }
54
+ return this.plan.afterInitialization(
55
+ editor,
56
+ this.getConfig(),
57
+ this.getRegisterState(signal)
58
+ );
59
+ }
78
60
  register(editor, signal) {
79
61
  if (!this.plan.register) {
80
62
  this._output = void 0;
81
- return noop$1;
63
+ return void 0;
82
64
  }
83
65
  invariant(
84
66
  this._registerState !== void 0,
@@ -96,7 +78,11 @@ class PlanRep {
96
78
  const config = this.getConfig();
97
79
  const registerState = this.getRegisterState(signal);
98
80
  if (this.plan.init) {
99
- this._initResult = this.plan.init(editorConfig, config, registerState);
81
+ this._initResult = this.plan.init(
82
+ editorConfig,
83
+ config,
84
+ registerState
85
+ );
100
86
  }
101
87
  }
102
88
  getInitResult() {
@@ -175,9 +161,55 @@ class PlanRep {
175
161
  return this._config;
176
162
  }
177
163
  }
178
- const buildersForEditors = /* @__PURE__ */ new WeakMap();
164
+ const HISTORY_MERGE_OPTIONS = { tag: "history-merge" };
165
+ function $defaultInitializer() {
166
+ const root = $getRoot();
167
+ if (root.isEmpty()) {
168
+ root.append($createParagraphNode());
169
+ }
170
+ }
171
+ const InitialStatePlan = definePlan({
172
+ name: "@etrepum/lexical-builder/InitialState",
173
+ // These are automatically added by createEditor, we add them here so they are
174
+ // visible during planRep.init so plans can see all known types before the
175
+ // editor is created.
176
+ // (excluding ArtificialNode__DO_NOT_USE because it isn't really public API
177
+ // and shouldn't change anything)
178
+ nodes: [RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode],
179
+ config: safeCast({
180
+ updateOptions: HISTORY_MERGE_OPTIONS,
181
+ setOptions: HISTORY_MERGE_OPTIONS
182
+ }),
183
+ init({ $initialEditorState = $defaultInitializer }) {
184
+ return $initialEditorState;
185
+ },
186
+ afterInitialization(editor, { updateOptions, setOptions }, state) {
187
+ const $initialEditorState = state.getInitResult();
188
+ switch (typeof $initialEditorState) {
189
+ case "function": {
190
+ editor.update(() => $initialEditorState(editor), updateOptions);
191
+ break;
192
+ }
193
+ case "string": {
194
+ const parsedEditorState = editor.parseEditorState($initialEditorState);
195
+ editor.setEditorState(parsedEditorState, setOptions);
196
+ break;
197
+ }
198
+ case "object": {
199
+ if ($initialEditorState) {
200
+ editor.setEditorState($initialEditorState, setOptions);
201
+ }
202
+ break;
203
+ }
204
+ }
205
+ return () => {
206
+ };
207
+ }
208
+ });
209
+ const builderSymbol = Symbol.for("@etrepum/lexical-builder");
179
210
  function buildEditorFromPlans(plan, ...plans) {
180
211
  const builder = new LexicalBuilder();
212
+ builder.addPlan(InitialStatePlan);
181
213
  builder.addPlan(plan);
182
214
  for (const otherPlan of plans) {
183
215
  builder.addPlan(otherPlan);
@@ -186,28 +218,12 @@ function buildEditorFromPlans(plan, ...plans) {
186
218
  }
187
219
  function noop() {
188
220
  }
189
- class DisposableEditorHandle {
190
- constructor(editor, dispose) {
191
- __publicField(this, "editor");
192
- __publicField(this, "dispose");
193
- this.editor = editor;
194
- this.dispose = () => {
195
- try {
196
- dispose();
197
- } finally {
198
- this.dispose = noop;
199
- }
200
- };
201
- }
202
- // This should be safe even if the runtime doesn't have Symbol.dispose
203
- // because it will just be `handle[undefined] = dispose;`
204
- [Symbol.dispose]() {
205
- this.dispose();
206
- }
207
- }
208
221
  function defaultOnError(err) {
209
222
  throw err;
210
223
  }
224
+ function maybeWithBuilder(editor) {
225
+ return editor;
226
+ }
211
227
  class LexicalBuilder {
212
228
  constructor() {
213
229
  __publicField(this, "phases");
@@ -216,34 +232,60 @@ class LexicalBuilder {
216
232
  __publicField(this, "reverseEdges");
217
233
  __publicField(this, "addStack");
218
234
  __publicField(this, "conflicts");
235
+ __publicField(this, "PACKAGE_VERSION");
219
236
  this.phases = [/* @__PURE__ */ new Map()];
220
237
  this.planMap = /* @__PURE__ */ new Map();
221
238
  this.planNameMap = /* @__PURE__ */ new Map();
222
239
  this.conflicts = /* @__PURE__ */ new Map();
223
240
  this.reverseEdges = /* @__PURE__ */ new Map();
224
241
  this.addStack = /* @__PURE__ */ new Set();
242
+ this.PACKAGE_VERSION = PACKAGE_VERSION;
225
243
  }
226
- /** Look up the editor that was created by this LexicalBuilder or undefined */
244
+ /** Look up the editor that was created by this LexicalBuilder or throw */
227
245
  static fromEditor(editor) {
228
- return buildersForEditors.get(editor);
246
+ const builder = maybeWithBuilder(editor)[builderSymbol];
247
+ invariant(
248
+ builder && typeof builder === "object",
249
+ "LexicalBuilder.fromEditor: The given editor was not created with LexicalBuilder, or has been disposed"
250
+ );
251
+ invariant(
252
+ builder.PACKAGE_VERSION === PACKAGE_VERSION,
253
+ "LexicalBuilder.fromEditor: The given editor was created with LexicalBuilder %s but this version is %s. A project should have exactly one copy of LexicalBuilder",
254
+ builder.PACKAGE_VERSION,
255
+ PACKAGE_VERSION
256
+ );
257
+ invariant(
258
+ builder instanceof LexicalBuilder,
259
+ "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."
260
+ );
261
+ return builder;
229
262
  }
230
263
  buildEditor() {
231
264
  const controller = new AbortController();
232
265
  const { $initialEditorState, onError, ...editorConfig } = this.buildCreateEditorArgs(controller.signal);
233
- const editor = createEditor({
234
- ...editorConfig,
235
- ...onError ? { onError: (err) => onError(err, editor) } : {}
236
- });
237
- initializeEditor(editor, $initialEditorState);
238
- buildersForEditors.set(editor, this);
239
- return new DisposableEditorHandle(
240
- editor,
241
- mergeRegister(
242
- () => buildersForEditors.delete(editor),
243
- () => editor.setRootElement(null),
244
- this.registerEditor(editor, controller)
245
- )
266
+ let disposeOnce = noop;
267
+ function dispose() {
268
+ try {
269
+ disposeOnce();
270
+ } finally {
271
+ disposeOnce = noop;
272
+ }
273
+ }
274
+ const editor = Object.assign(
275
+ createEditor({
276
+ ...editorConfig,
277
+ ...onError ? { onError: (err) => onError(err, editor) } : {}
278
+ }),
279
+ { [builderSymbol]: this, dispose, [Symbol.dispose]: dispose }
280
+ );
281
+ disposeOnce = mergeRegister(
282
+ () => {
283
+ delete maybeWithBuilder(editor)[builderSymbol];
284
+ },
285
+ () => editor.setRootElement(null),
286
+ this.registerEditor(editor, controller)
246
287
  );
288
+ return editor;
247
289
  }
248
290
  getPlanRep(plan) {
249
291
  const pair = this.planMap.get(plan);
@@ -356,9 +398,21 @@ class LexicalBuilder {
356
398
  registerEditor(editor, controller) {
357
399
  const cleanups = [];
358
400
  const signal = controller.signal;
401
+ const planReps = [];
359
402
  for (const planRep of this.sortedPlanReps()) {
360
- cleanups.push(planRep.register(editor, signal));
403
+ const cleanup = planRep.register(editor, signal);
404
+ if (cleanup) {
405
+ cleanups.push(cleanup);
406
+ }
407
+ planReps.push(planRep);
361
408
  }
409
+ for (const planRep of planReps) {
410
+ const cleanup = planRep.afterInitialization(editor, signal);
411
+ if (cleanup) {
412
+ cleanups.push(cleanup);
413
+ }
414
+ }
415
+ planReps.length = 0;
362
416
  return () => {
363
417
  for (let i = cleanups.length - 1; i >= 0; i--) {
364
418
  const cleanupFun = cleanups[i];
@@ -458,11 +512,6 @@ class LexicalBuilder {
458
512
  }
459
513
  function getPlanDependencyFromEditor(editor, plan) {
460
514
  const builder = LexicalBuilder.fromEditor(editor);
461
- invariant(
462
- builder !== void 0,
463
- "getPlanFromEditor: editor was not created with this build of Lexical Builder %s",
464
- PACKAGE_VERSION
465
- );
466
515
  const rep = builder.getPlanRep(plan);
467
516
  invariant(
468
517
  rep !== void 0,
@@ -471,21 +520,20 @@ function getPlanDependencyFromEditor(editor, plan) {
471
520
  );
472
521
  return rep.getPlanDependency();
473
522
  }
474
- function $getPlanDependency(plan) {
475
- return getPlanDependencyFromEditor($getEditor(), plan);
476
- }
477
523
  function getPeerDependencyFromEditor(editor, planName) {
478
524
  const builder = LexicalBuilder.fromEditor(editor);
479
- invariant(
480
- builder !== void 0,
481
- "getPeerConfigFromEditor: editor was not created with this build of Lexical Builder %s",
482
- PACKAGE_VERSION
483
- );
484
525
  const peer = builder.planNameMap.get(planName);
485
526
  return peer ? peer.getPlanDependency() : void 0;
486
527
  }
487
- function $getPeerDependency(planName) {
488
- return getPeerDependencyFromEditor($getEditor(), planName);
528
+ function getKnownTypesAndNodes(config) {
529
+ const types = /* @__PURE__ */ new Set();
530
+ const nodes = /* @__PURE__ */ new Set();
531
+ for (const klassOrReplacement of config.nodes ?? []) {
532
+ const klass = typeof klassOrReplacement === "function" ? klassOrReplacement : klassOrReplacement.replace;
533
+ types.add(klass.getType());
534
+ nodes.add(klass);
535
+ }
536
+ return { types, nodes };
489
537
  }
490
538
  const AutoFocusPlan = definePlan({
491
539
  config: safeCast({}),
@@ -530,11 +578,10 @@ const RichTextPlan = definePlan({
530
578
  register: registerRichText
531
579
  });
532
580
  export {
533
- $getPeerDependency,
534
- $getPlanDependency,
535
581
  AutoFocusPlan,
536
582
  DragonPlan,
537
583
  HistoryPlan,
584
+ InitialStatePlan,
538
585
  LexicalBuilder,
539
586
  PACKAGE_VERSION,
540
587
  PlainTextPlan,
@@ -543,6 +590,7 @@ export {
543
590
  configPlan2 as configPlan,
544
591
  declarePeerDependency,
545
592
  definePlan2 as definePlan,
593
+ getKnownTypesAndNodes,
546
594
  getPeerDependencyFromEditor,
547
595
  getPlanDependencyFromEditor,
548
596
  provideOutput,
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/initializeEditor.ts","../src/PlanRep.ts","../src/LexicalBuilder.ts","../src/getPlanDependencyFromEditor.ts","../src/getPeerDependencyFromEditor.ts","../src/AutoFocusPlan.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 { InitialEditorStateType } from \"@etrepum/lexical-builder-core\";\n\nimport { $createParagraphNode, $getRoot, type LexicalEditor } 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 function initializeEditor(\n editor: LexicalEditor,\n $initialEditorState: InitialEditorStateType = $defaultInitializer,\n): void {\n switch (typeof $initialEditorState) {\n case \"function\": {\n editor.update(() => $initialEditorState(editor), HISTORY_MERGE_OPTIONS);\n break;\n }\n case \"string\": {\n const parsedEditorState = editor.parseEditorState($initialEditorState);\n editor.setEditorState(parsedEditorState, HISTORY_MERGE_OPTIONS);\n break;\n }\n case \"object\": {\n if ($initialEditorState) {\n editor.setEditorState($initialEditorState, HISTORY_MERGE_OPTIONS);\n }\n break;\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 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 register(editor: LexicalEditor, signal: AbortSignal): () => void {\n if (!this.plan.register) {\n this._output = undefined;\n return noop;\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(editorConfig, config, registerState);\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 */\nimport type {\n AnyLexicalPlan,\n AnyLexicalPlanArgument,\n EditorHandle,\n InitialEditorConfig,\n LexicalPlanConfig,\n} from \"@etrepum/lexical-builder-core\";\n\nimport {\n LexicalEditor,\n createEditor,\n type CreateEditorArgs,\n type EditorThemeClasses,\n type HTMLConfig,\n type KlassConstructor,\n type LexicalNode,\n} from \"lexical\";\nimport invariant from \"./shared/invariant\";\n\nimport { deepThemeMergeInPlace } from \"./deepThemeMergeInPlace\";\nimport { initializeEditor } from \"./initializeEditor\";\nimport { PlanRep } from \"./PlanRep\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { configPlan, definePlan } from \"@etrepum/lexical-builder-core\";\n\nconst buildersForEditors = new WeakMap<LexicalEditor, LexicalBuilder>();\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 editorHandle = 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 editorHandle = buildEditorFromPlans(\n * RichTextPlan,\n * configPlan(EmojiPlan, { emojiBaseUrl: \"/assets/emoji\" }),\n * );\n * ```\n */\nexport function buildEditorFromPlans(\n plan: AnyLexicalPlanArgument,\n ...plans: AnyLexicalPlanArgument[]\n): EditorHandle {\n const builder = new LexicalBuilder();\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/** @internal */\nclass DisposableEditorHandle implements EditorHandle {\n editor: LexicalEditor;\n dispose: () => void;\n constructor(editor: LexicalEditor, dispose: () => void) {\n this.editor = editor;\n this.dispose = () => {\n try {\n dispose();\n } finally {\n this.dispose = noop;\n }\n };\n }\n // This should be safe even if the runtime doesn't have Symbol.dispose\n // because it will just be `handle[undefined] = dispose;`\n [Symbol.dispose]() {\n this.dispose();\n }\n}\n\n/** Throw the given Error */\nfunction defaultOnError(err: Error) {\n throw err;\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\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 }\n\n /** Look up the editor that was created by this LexicalBuilder or undefined */\n static fromEditor(editor: LexicalEditor): LexicalBuilder | undefined {\n return buildersForEditors.get(editor);\n }\n\n buildEditor(): EditorHandle {\n const controller = new AbortController();\n const { $initialEditorState, onError, ...editorConfig } =\n this.buildCreateEditorArgs(controller.signal);\n const editor = createEditor({\n ...editorConfig,\n ...(onError ? { onError: (err) => onError(err, editor) } : {}),\n });\n initializeEditor(editor, $initialEditorState);\n buildersForEditors.set(editor, this);\n return new DisposableEditorHandle(\n editor,\n mergeRegister(\n () => buildersForEditors.delete(editor),\n () => editor.setRootElement(null),\n this.registerEditor(editor, controller),\n ),\n );\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 for (const planRep of this.sortedPlanReps()) {\n cleanups.push(planRep.register(editor, signal));\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 { $getEditor, LexicalEditor } from \"lexical\";\nimport {\n AnyLexicalPlan,\n LexicalPlanDependency,\n} from \"@etrepum/lexical-builder-core\";\nimport { LexicalBuilder } from \"./LexicalBuilder\";\nimport invariant from \"./shared/invariant\";\nimport { PACKAGE_VERSION } from \"./PACKAGE_VERSION\";\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 invariant(\n builder !== undefined,\n \"getPlanFromEditor: editor was not created with this build of Lexical Builder %s\",\n PACKAGE_VERSION,\n );\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\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 plan The concrete reference to a Plan used to build this editor\n * @returns The config and outputs for that Plan\n */\nexport function $getPlanDependency<Plan extends AnyLexicalPlan>(\n plan: Plan,\n): LexicalPlanDependency<Plan> {\n return getPlanDependencyFromEditor($getEditor(), plan);\n}\n","import { $getEditor, LexicalEditor } from \"lexical\";\nimport {\n AnyLexicalPlan,\n LexicalPlanDependency,\n} from \"@etrepum/lexical-builder-core\";\nimport { LexicalBuilder } from \"./LexicalBuilder\";\nimport invariant from \"./shared/invariant\";\nimport { PACKAGE_VERSION } from \"./PACKAGE_VERSION\";\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 invariant(\n builder !== undefined,\n \"getPeerConfigFromEditor: editor was not created with this build of Lexical Builder %s\",\n PACKAGE_VERSION,\n );\n const peer = builder.planNameMap.get(planName);\n return peer\n ? (peer.getPlanDependency() as LexicalPlanDependency<Plan>)\n : undefined;\n}\n\n/**\n * Get the finalized config and output of a Plan that was used to build the\n * editor by name.\n *\n * Both the explicit Plan type and the name are required.\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 * @example\n * ```tsx\n * $getPeerDependency<typeof import(\"@some/plan\").SomePlan>(\"@some/plan\")\n * ```\n *\n * @param planName The name of the Plan\n * @returns The config and output of the Plan or undefined\n */\nexport function $getPeerDependency<Plan extends AnyLexicalPlan = never>(\n planName: Plan[\"name\"],\n): LexicalPlanDependency<Plan> | undefined {\n return getPeerDependencyFromEditor($getEditor(), planName);\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","/**\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\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\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 register: registerDragonSupport,\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\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\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 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\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\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 register: registerRichText,\n});\n"],"names":["noop"],"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,WAAW,EAAE;AAAA,EAAA;AAE3E;ACCgB,SAAA,sBAAsB,GAAY,GAAY;AAC5D,MACE,KACA,KACA,CAAC,MAAM,QAAQ,CAAC,KAChB,OAAO,MAAM,YACb,OAAO,MAAM,UACb;AACA,UAAM,OAAO;AACb,UAAM,OAAO;AACb,eAAW,KAAK,MAAM;AACf,WAAA,CAAC,IAAI,sBAAsB,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AAAA,IAClD;AACO,WAAA;AAAA,EACT;AACO,SAAA;AACT;AC5BA,MAAM,wBAAwB,EAAE,KAAK;AAErC,SAAS,sBAAsB;AAC7B,QAAM,OAAO;AACT,MAAA,KAAK,WAAW;AACb,SAAA,OAAO,sBAAsB;AAAA,EACpC;AACF;AAEgB,SAAA,iBACd,QACA,sBAA8C,qBACxC;AACN,UAAQ,OAAO,qBAAqB;AAAA,IAClC,KAAK,YAAY;AACf,aAAO,OAAO,MAAM,oBAAoB,MAAM,GAAG,qBAAqB;AACtE;AAAA,IACF;AAAA,IACA,KAAK,UAAU;AACP,YAAA,oBAAoB,OAAO,iBAAiB,mBAAmB;AAC9D,aAAA,eAAe,m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gB,QAAQ,0BAA0B,GAAG,KAAK;AAAA,EACnE;AACF,CAAC;AC3BM,MAAM,gBAAgB,WAAW;AAAA,EACtC,eAAe,CAAC,oBAAoB;AAAA,EACpC,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACFM,MAAM,eAAe,WAAW;AAAA,EACrC,eAAe,CAAC,qBAAqB;AAAA,EACrC,MAAM;AAAA,EACN,OAAO,CAAC,aAAa,SAAS;AAAA,EAC9B,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/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\";\n\nimport {\n LexicalEditor,\n createEditor,\n type CreateEditorArgs,\n type EditorThemeClasses,\n type HTMLConfig,\n type KlassConstructor,\n type LexicalNode,\n} from \"lexical\";\nimport invariant from \"./shared/invariant\";\n\nimport { deepThemeMergeInPlace } from \"./deepThemeMergeInPlace\";\nimport { PlanRep } from \"./PlanRep\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { configPlan } from \"@etrepum/lexical-builder-core\";\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","/**\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\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\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 register: registerDragonSupport,\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\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\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 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\";\n\nimport { definePlan } from \"@etrepum/lexical-builder-core\";\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 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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C,gBAAgB;AAC3C,aAAA;AAAA,QACL,MAAM;AAKJ,gBAAM,gBAAgB,SAAS;AAE7B,cAAA,gBAAgB,SACf,kBAAkB,QAAQ,CAAC,YAAY,SAAS,aAAa,IAC9D;AAEA,wBAAY,MAAM,EAAE,eAAe,KAAM,CAAA;AAAA,UAC3C;AAAA,QACF;AAAA,QACA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IACrB,CACD;AAAA,EACH;AACF,CAAC;AC9BM,MAAM,aAAa,WAAW;AAAA,EACnC,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACaM,MAAM,cAAc,WAAW;AAAA,EACpC,QAAQ,SAAwB;AAAA,IAC9B,2BAA2B;AAAA,IAC3B,OAAO;AAAA,EAAA,CACR;AAAA,EACD,MAAM;AAAA,EACN,SAAS,QAAQ,EAAE,OAAO,6BAA6B;AACrD,WAAO,gBAAgB,QAAQ,0BAA0B,GAAG,KAAK;AAAA,EACnE;AACF,CAAC;AC3BM,MAAM,gBAAgB,WAAW;AAAA,EACtC,eAAe,CAAC,oBAAoB;AAAA,EACpC,MAAM;AAAA,EACN,UAAU;AACZ,CAAC;ACFM,MAAM,eAAe,WAAW;AAAA,EACrC,eAAe,CAAC,qBAAqB;AAAA,EACrC,MAAM;AAAA,EACN,OAAO,CAAC,aAAa,SAAS;AAAA,EAC9B,UAAU;AACZ,CAAC;"}
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "test": "vitest run",
18
18
  "test:watch": "vitest"
19
19
  },
20
- "version": "0.0.25-nightly.20240624.0",
20
+ "version": "0.0.26-nightly.20240625.0",
21
21
  "license": "MIT",
22
22
  "repository": {
23
23
  "type": "git",
@@ -1,5 +0,0 @@
1
- import { InitialEditorStateType } from '@etrepum/lexical-builder-core';
2
- import { LexicalEditor } from 'lexical';
3
-
4
- export declare function initializeEditor(editor: LexicalEditor, $initialEditorState?: InitialEditorStateType): void;
5
- //# sourceMappingURL=initializeEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initializeEditor.d.ts","sourceRoot":"","sources":["../src/initializeEditor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7E,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,mBAAmB,GAAE,sBAA4C,GAChE,IAAI,CAkBN"}