@etrepum/lexical-builder-core 0.0.36-nightly.20250714.0 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,5 +3,5 @@
3
3
  **EXPERIMENTAL** Lexical Builder Core
4
4
 
5
5
  This is the lightweight part of Lexical Builder that should be adopted
6
- into the lexical package to make it possible to define plans without
6
+ into the lexical package to make it possible to define extensions without
7
7
  any overhead of including the builder runtime.
@@ -0,0 +1,130 @@
1
+ import { AnyLexicalExtension, LexicalExtension, LexicalExtensionConfig, NormalizedLexicalExtensionArgument, NormalizedPeerDependency, ExtensionConfigBase, RegisterCleanup } from './types';
2
+ /**
3
+ * Define a LexicalExtension from the given object literal. TypeScript will
4
+ * infer Config and Name in most cases, but you may want to use
5
+ * {@link safeCast} for config if there are default fields or varying types.
6
+ *
7
+ * @param extension - The LexicalExtension
8
+ * @returns The unmodified extension argument (this is only an inference helper)
9
+ *
10
+ * @example Basic example
11
+ * ```ts
12
+ * export const MyExtension = defineExtension({
13
+ * // Extension names must be unique in an editor
14
+ * name: "my",
15
+ * nodes: [MyNode],
16
+ * });
17
+ * ```
18
+ *
19
+ * @example Extension with optional configuration
20
+ * ```ts
21
+ * export interface ConfigurableConfig {
22
+ * optional?: string;
23
+ * required: number;
24
+ * }
25
+ * export const ConfigurableExtension = defineExtension({
26
+ * name: "configurable",
27
+ * // The Extension's config must satisfy the full config type,
28
+ * // but using the Extension as a dependency never requires
29
+ * // configuration and any partial of the config can be specified
30
+ * config: safeCast<ConfigurableConfig>({ required: 1 }),
31
+ * });
32
+ * ```
33
+ */
34
+ export declare function defineExtension<Config extends ExtensionConfigBase, Name extends string, Output, Init>(extension: LexicalExtension<Config, Name, Output, Init>): LexicalExtension<Config, Name, Output, Init>;
35
+ /**
36
+ * Override a partial of the configuration of an Extension, to be used
37
+ * in the dependencies array of another extension, or as
38
+ * an argument to {@link buildEditorFromExtensions}.
39
+ *
40
+ * Before building the editor, configurations will be merged using
41
+ * extension.mergeConfig(extension, config) or {@link shallowMergeConfig} if
42
+ * this is not directly implemented by the Extension.
43
+ *
44
+ * @param args - An extension followed by one or more config partials for that extension
45
+ * @returns [extension, config, ...configs]
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * export const ReactDecoratorExtension = defineExtension({
50
+ * name: "react-decorator",
51
+ * dependencies: [
52
+ * configExtension(ReactExtension, {
53
+ * decorators: [<ReactDecorator />]
54
+ * }),
55
+ * ],
56
+ * });
57
+ * ```
58
+ */
59
+ export declare function configExtension<Config extends ExtensionConfigBase, Name extends string, Output, Init>(...args: NormalizedLexicalExtensionArgument<Config, Name, Output, Init>): NormalizedLexicalExtensionArgument<Config, Name, Output, Init>;
60
+ /**
61
+ * Provide output from the register function of an Extension
62
+ *
63
+ * @returns A cleanup function
64
+ *
65
+ * @example Provide output with no other cleanup
66
+ * ```ts
67
+ * // This is entirely optional and would be inferred correctly, but
68
+ * // it can be useful for documentation!
69
+ * export interface RegisteredAtOutput {
70
+ * registered_at: number;
71
+ * }
72
+ * export const RegisteredAtExtension = defineExtension({
73
+ * name: "RegisteredAt",
74
+ * register(editor) {
75
+ * return provideOutput<RegisteredAtOutput>({ registered_at: Date.now() });
76
+ * },
77
+ * });
78
+ * ```
79
+ *
80
+ * @example Provide output with other cleanup
81
+ * ```ts
82
+ * export interface UniqueCommandOutput {
83
+ * command: LexicalCommand<unknown>;
84
+ * }
85
+ * export const UniqueCommandExtension = defineExtension({
86
+ * name: 'UniqueCommand',
87
+ * register(editor) {
88
+ * const output: UniqueCommnadOutput = {command: createCommand('UNIQUE_COMMAND')};
89
+ * const cleanup = registerCommand(
90
+ * command,
91
+ * (_payload) => {
92
+ * console.log('Unique command received!');
93
+ * return true;
94
+ * }
95
+ * COMMAND_PRIORITY_EDITOR
96
+ * );
97
+ * return provideOutput(output, cleanup);
98
+ * },
99
+ * });
100
+ * ```
101
+ *
102
+ */
103
+ export declare function provideOutput<Output>(output: Output, cleanup?: () => void): RegisterCleanup<Output>;
104
+ /** @internal */
105
+ export declare const PeerDependencyBrand: unique symbol;
106
+ export declare const ConfigTypeId: unique symbol;
107
+ export declare const OutputTypeId: unique symbol;
108
+ /**
109
+ * Used to declare a peer dependency of an extension in a type-safe way,
110
+ * requires the type parameter. The most common use case for peer dependencies
111
+ * is to avoid a direct import dependency, so you would want to use a
112
+ * type import or the import type (shown in below examples).
113
+ *
114
+ * @param name - The extension's name
115
+ * @param config - An optional config override
116
+ * @returns NormalizedPeerDependency
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * export const PeerExtension = defineExtension({
121
+ * name: 'PeerExtension',
122
+ * peerDependencies: [
123
+ * declarePeerDependency<typeof import("foo").FooExtension>("foo"),
124
+ * declarePeerDependency<typeof import("bar").BarExtension>("bar", {config: "bar"}),
125
+ * ],
126
+ * });
127
+ * ```
128
+ */
129
+ export declare function declarePeerDependency<Extension extends AnyLexicalExtension = never>(name: Extension["name"], config?: Partial<LexicalExtensionConfig<Extension>>): NormalizedPeerDependency<Extension>;
130
+ //# sourceMappingURL=defineExtension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineExtension.d.ts","sourceRoot":"","sources":["../src/defineExtension.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAC7B,MAAM,SAAS,mBAAmB,EAClC,IAAI,SAAS,MAAM,EACnB,MAAM,EACN,IAAI,EAEJ,SAAS,EAAE,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,GACtD,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAE9C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,SAAS,mBAAmB,EAClC,IAAI,SAAS,MAAM,EACnB,MAAM,EACN,IAAI,EAEJ,GAAG,IAAI,EAAE,kCAAkC,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,GACtE,kCAAkC,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAEhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAClC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,eAAe,CAAC,MAAM,CAAC,CAOzB;AAED,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAExC,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,OAAO,MAEjC,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,OAAO,MAEjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,mBAAmB,GAAG,KAAK,EACjF,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EACvB,MAAM,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,GAClD,wBAAwB,CAAC,SAAS,CAAC,CAErC"}
package/dist/index.d.ts CHANGED
@@ -6,9 +6,9 @@
6
6
  *
7
7
  */
8
8
  export declare const PACKAGE_VERSION: string;
9
- export { configPlan, definePlan, provideOutput, declarePeerDependency, } from './definePlan';
10
- export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type AnyNormalizedLexicalPlanArgument, type LexicalEditorWithDispose, type InitialEditorConfig, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanInit, type LexicalPlanName, type LexicalPlanOutput, type OutputComponentPlan, type LexicalPlanDependency, type NormalizedLexicalPlanArgument, type PlanConfigBase, type PlanInitState, type PlanRegisterState, type RegisterCleanup, type NormalizedPeerDependency, } from './types';
11
- export { type LexicalPlanInternal, type initTypeSymbol, type configTypeSymbol, type outputTypeSymbol, } from './internal';
9
+ export { configExtension, defineExtension, provideOutput, declarePeerDependency, } from './defineExtension';
10
+ export { type AnyLexicalExtension, type AnyLexicalExtensionArgument, type AnyNormalizedLexicalExtensionArgument, type LexicalEditorWithDispose, type InitialEditorConfig, type InitialEditorStateType, type LexicalExtension, type LexicalExtensionArgument, type LexicalExtensionConfig, type LexicalExtensionInit, type LexicalExtensionName, type LexicalExtensionOutput, type OutputComponentExtension, type LexicalExtensionDependency, type NormalizedLexicalExtensionArgument, type ExtensionConfigBase, type ExtensionInitState, type ExtensionRegisterState, type RegisterCleanup, type NormalizedPeerDependency, } from './types';
11
+ export { type LexicalExtensionInternal, type initTypeSymbol, type configTypeSymbol, type outputTypeSymbol, } from './internal';
12
12
  export { safeCast } from './safeCast';
13
13
  export { shallowMergeConfig } from './shallowMergeConfig';
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EACl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CHANGED
@@ -1,4 +1,4 @@
1
- function e(n) {
1
+ function u(n) {
2
2
  return n;
3
3
  }
4
4
  function r(...n) {
@@ -12,27 +12,27 @@ function f(n, t) {
12
12
  { output: n }
13
13
  );
14
14
  }
15
- function c(n, t) {
15
+ function i(n, t) {
16
16
  return [n, t];
17
17
  }
18
- function i(n) {
18
+ function o(n) {
19
19
  return n;
20
20
  }
21
- function a(n, t) {
21
+ function c(n, t) {
22
22
  if (!t || n === t)
23
23
  return n;
24
- for (const u in t)
25
- if (n[u] !== t[u])
24
+ for (const e in t)
25
+ if (n[e] !== t[e])
26
26
  return { ...n, ...t };
27
27
  return n;
28
28
  }
29
- const o = "0.0.36-nightly.20250714.0";
29
+ const s = "0.0.36";
30
30
  export {
31
- o as PACKAGE_VERSION,
32
- r as configPlan,
33
- c as declarePeerDependency,
34
- e as definePlan,
31
+ s as PACKAGE_VERSION,
32
+ r as configExtension,
33
+ i as declarePeerDependency,
34
+ u as defineExtension,
35
35
  f as provideOutput,
36
- i as safeCast,
37
- a as shallowMergeConfig
36
+ o as safeCast,
37
+ c as shallowMergeConfig
38
38
  };
@@ -15,7 +15,7 @@ export declare const initTypeSymbol: unique symbol;
15
15
  /** @internal */
16
16
  export type initTypeSymbol = typeof initTypeSymbol;
17
17
  /** @internal */
18
- export interface LexicalPlanInternal<out Config, out Output, out Init> {
18
+ export interface LexicalExtensionInternal<out Config, out Output, out Init> {
19
19
  /** @internal */
20
20
  readonly [configTypeSymbol]?: Config;
21
21
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AACA,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,oBAAoB,EAAE,OAAO,MAAM,CAAC;AACzD,gBAAgB;AAChB,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC;AAC/D,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,gBAAgB,EAAE,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OAAO,gBAAgB,CAAC;AACvD,gBAAgB;AAChB,MAAM,CAAC,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AACnD,gBAAgB;AAChB,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AAEnD,gBAAgB;AAChB,MAAM,WAAW,wBAAwB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACxE,gBAAgB;IAChB,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACrC,gBAAgB;IAChB,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAC;IACrC,gBAAgB;IAChB,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC;CAClC"}
@@ -8,7 +8,7 @@
8
8
  /**
9
9
  * Explicitly and safely cast a value to a specific type when inference or
10
10
  * satisfies isn't going to work as expected (often useful for the config
11
- * property with definePlan)
11
+ * property with defineExtension)
12
12
  */
13
13
  export declare function safeCast<T>(value: T): T;
14
14
  //# sourceMappingURL=safeCast.d.ts.map
@@ -1,10 +1,10 @@
1
- import { PlanConfigBase } from './types';
1
+ import { ExtensionConfigBase } from './types';
2
2
  /**
3
- * The default merge strategy for plan configuration is a shallow merge.
3
+ * The default merge strategy for extension configuration is a shallow merge.
4
4
  *
5
5
  * @param config - A full config
6
6
  * @param overrides - A partial config of overrides
7
7
  * @returns config if there are no overrides, otherwise `{...config, ...overrides}`
8
8
  */
9
- export declare function shallowMergeConfig<T extends PlanConfigBase>(config: T, overrides?: Partial<T>): T;
9
+ export declare function shallowMergeConfig<T extends ExtensionConfigBase>(config: T, overrides?: Partial<T>): T;
10
10
  //# sourceMappingURL=shallowMergeConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shallowMergeConfig.d.ts","sourceRoot":"","sources":["../src/shallowMergeConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,cAAc,EACzD,MAAM,EAAE,CAAC,EACT,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACrB,CAAC,CAUH"}
1
+ {"version":3,"file":"shallowMergeConfig.d.ts","sourceRoot":"","sources":["../src/shallowMergeConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,mBAAmB,EAC9D,MAAM,EAAE,CAAC,EACT,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GACrB,CAAC,CAUH"}
package/dist/types.d.ts CHANGED
@@ -1,87 +1,87 @@
1
1
  import { CreateEditorArgs, EditorState, LexicalEditor } from 'lexical';
2
- import { LexicalPlanInternal, peerDependencySymbol, configTypeSymbol, outputTypeSymbol, initTypeSymbol } from './internal';
2
+ import { LexicalExtensionInternal, peerDependencySymbol, configTypeSymbol, outputTypeSymbol, initTypeSymbol } from './internal';
3
3
  /**
4
- * Any concrete {@link LexicalPlan}
4
+ * Any concrete {@link LexicalExtension}
5
5
  */
6
- export type AnyLexicalPlan = LexicalPlan<any, string, any, any>;
6
+ export type AnyLexicalExtension = LexicalExtension<any, string, any, any>;
7
7
  /**
8
- * Any {@link LexicalPlan} or {@link NormalizedLexicalPlanArgument}
8
+ * Any {@link LexicalExtension} or {@link NormalizedLexicalExtensionArgument}
9
9
  */
10
- export type AnyLexicalPlanArgument = AnyLexicalPlan | AnyNormalizedLexicalPlanArgument;
10
+ export type AnyLexicalExtensionArgument = AnyLexicalExtension | AnyNormalizedLexicalExtensionArgument;
11
11
  /**
12
- * The default plan configuration of an empty object
12
+ * The default extension configuration of an empty object
13
13
  */
14
- export type PlanConfigBase = Record<never, never>;
15
- export type NormalizedPeerDependency<Plan extends AnyLexicalPlan> = [
16
- Plan["name"],
17
- Partial<LexicalPlanConfig<Plan>> | undefined
14
+ export type ExtensionConfigBase = Record<never, never>;
15
+ export type NormalizedPeerDependency<Extension extends AnyLexicalExtension> = [
16
+ Extension["name"],
17
+ Partial<LexicalExtensionConfig<Extension>> | undefined
18
18
  ] & {
19
- readonly [peerDependencySymbol]: Plan;
19
+ readonly [peerDependencySymbol]: Extension;
20
20
  };
21
21
  /**
22
- * Any {@link NormalizedLexicalPlanArgument}
22
+ * Any {@link NormalizedLexicalExtensionArgument}
23
23
  */
24
- export type NormalizedLexicalPlanArgument<in out Config extends PlanConfigBase, out Name extends string, in out Output, in out Init> = [LexicalPlan<Config, Name, Output, Init>, ...Partial<Config>[]];
24
+ export type NormalizedLexicalExtensionArgument<in out Config extends ExtensionConfigBase, out Name extends string, in out Output, in out Init> = [LexicalExtension<Config, Name, Output, Init>, ...Partial<Config>[]];
25
25
  /**
26
- * A tuple of [plan, ...configOverrides]
26
+ * A tuple of [extension, ...configOverrides]
27
27
  */
28
- export type AnyNormalizedLexicalPlanArgument = NormalizedLexicalPlanArgument<any, string, any, any>;
28
+ export type AnyNormalizedLexicalExtensionArgument = NormalizedLexicalExtensionArgument<any, string, any, any>;
29
29
  /**
30
30
  * An object that the register method can use to detect unmount and access the
31
- * configuration for plan dependencies
31
+ * configuration for extension dependencies
32
32
  */
33
- export interface PlanInitState {
33
+ export interface ExtensionInitState {
34
34
  /** An AbortSignal that is aborted when the LexicalEditor is disposed */
35
35
  signal: AbortSignal;
36
36
  /**
37
37
  * Get the result of a peerDependency by name, if it exists
38
- * (must be a peerDependency of this plan)
38
+ * (must be a peerDependency of this extension)
39
39
  */
40
- getPeer: <Dependency extends AnyLexicalPlan = never>(name: Dependency["name"]) => undefined | Omit<LexicalPlanDependency<Dependency>, "output">;
40
+ getPeer: <Dependency extends AnyLexicalExtension = never>(name: Dependency["name"]) => undefined | Omit<LexicalExtensionDependency<Dependency>, "output">;
41
41
  /**
42
- * Get the configuration of a dependency by plan
43
- * (must be a direct dependency of this plan)
42
+ * Get the configuration of a dependency by extension
43
+ * (must be a direct dependency of this extension)
44
44
  */
45
- getDependency: <Dependency extends AnyLexicalPlan>(dep: Dependency) => Omit<LexicalPlanDependency<Dependency>, "output">;
45
+ getDependency: <Dependency extends AnyLexicalExtension>(dep: Dependency) => Omit<LexicalExtensionDependency<Dependency>, "output">;
46
46
  /**
47
47
  * Get the names of any direct dependents of this
48
- * Plan, typically only used for error messages.
48
+ * Extension, typically only used for error messages.
49
49
  */
50
50
  getDirectDependentNames: () => ReadonlySet<string>;
51
51
  /**
52
52
  * Get the names of all peer dependencies of this
53
- * Plan, even if they do not exist in the builder,
53
+ * Extension, even if they do not exist in the builder,
54
54
  * typically only used for devtools.
55
55
  */
56
56
  getPeerNameSet: () => ReadonlySet<string>;
57
57
  }
58
58
  /**
59
59
  * An object that the register method can use to detect unmount and access the
60
- * configuration for plan dependencies
60
+ * configuration for extension dependencies
61
61
  */
62
- export interface PlanRegisterState<Init> extends Omit<PlanInitState, "getPeer" | "getDependency"> {
62
+ export interface ExtensionRegisterState<Init> extends Omit<ExtensionInitState, "getPeer" | "getDependency"> {
63
63
  /**
64
64
  * Get the result of a peerDependency by name, if it exists
65
- * (must be a peerDependency of this plan)
65
+ * (must be a peerDependency of this extension)
66
66
  */
67
- getPeer: <Dependency extends AnyLexicalPlan = never>(name: Dependency["name"]) => undefined | LexicalPlanDependency<Dependency>;
67
+ getPeer: <Dependency extends AnyLexicalExtension = never>(name: Dependency["name"]) => undefined | LexicalExtensionDependency<Dependency>;
68
68
  /**
69
- * Get the configuration of a dependency by plan
70
- * (must be a direct dependency of this plan)
69
+ * Get the configuration of a dependency by extension
70
+ * (must be a direct dependency of this extension)
71
71
  */
72
- getDependency: <Dependency extends AnyLexicalPlan>(dep: Dependency) => LexicalPlanDependency<Dependency>;
72
+ getDependency: <Dependency extends AnyLexicalExtension>(dep: Dependency) => LexicalExtensionDependency<Dependency>;
73
73
  /**
74
74
  * The result of the init function
75
75
  */
76
76
  getInitResult: () => Init;
77
77
  }
78
78
  /**
79
- * A {@link LexicalPlan} or {@link NormalizedLexicalPlanArgument} (plan with config overrides)
79
+ * A {@link LexicalExtension} or {@link NormalizedLexicalExtensionArgument} (extension with config overrides)
80
80
  */
81
- export type LexicalPlanArgument<Config extends PlanConfigBase, Name extends string, Output, Init> = LexicalPlan<Config, Name, Output, Init> | NormalizedLexicalPlanArgument<Config, Name, Output, Init>;
82
- export interface LexicalPlanDependency<out Dependency extends AnyLexicalPlan> {
83
- config: LexicalPlanConfig<Dependency>;
84
- output: LexicalPlanOutput<Dependency>;
81
+ export type LexicalExtensionArgument<Config extends ExtensionConfigBase, Name extends string, Output, Init> = LexicalExtension<Config, Name, Output, Init> | NormalizedLexicalExtensionArgument<Config, Name, Output, Init>;
82
+ export interface LexicalExtensionDependency<out Dependency extends AnyLexicalExtension> {
83
+ config: LexicalExtensionConfig<Dependency>;
84
+ output: LexicalExtensionOutput<Dependency>;
85
85
  }
86
86
  export type RegisterCleanup<Output> = (() => void) & (unknown extends Output ? {
87
87
  output?: Output;
@@ -89,41 +89,41 @@ export type RegisterCleanup<Output> = (() => void) & (unknown extends Output ? {
89
89
  output: Output;
90
90
  });
91
91
  /**
92
- * A Plan is a composable unit of LexicalEditor configuration
92
+ * An Extension is a composable unit of LexicalEditor configuration
93
93
  * (nodes, theme, etc) used to create an editor, plus runtime behavior
94
94
  * that is registered after the editor is created.
95
95
  *
96
- * A Plan may depend on other Plans, and provide functionality to other
97
- * plans through its config.
96
+ * An Extension may depend on other Extensions, and provide functionality to other
97
+ * extensions through its config.
98
98
  */
99
- export interface LexicalPlan<in out Config extends PlanConfigBase, out Name extends string, in out Output, in out Init> extends InitialEditorConfig, LexicalPlanInternal<Config, Output, Init> {
100
- /** The name of the Plan, must be unique */
99
+ export interface LexicalExtension<in out Config extends ExtensionConfigBase, out Name extends string, in out Output, in out Init> extends InitialEditorConfig, LexicalExtensionInternal<Config, Output, Init> {
100
+ /** The name of the Extension, must be unique */
101
101
  readonly name: Name;
102
- /** Plan names that must not be loaded with this Plan */
102
+ /** Extension names that must not be loaded with this Extension */
103
103
  conflictsWith?: string[];
104
- /** Other Plans that this Plan depends on, can also be used to configure them */
105
- dependencies?: AnyLexicalPlanArgument[];
104
+ /** Other Extensions that this Extension depends on, can also be used to configure them */
105
+ dependencies?: AnyLexicalExtensionArgument[];
106
106
  /**
107
- * Other Plans, by name, that this Plan can optionally depend on or
108
- * configure, if they are directly depended on by another Plan
107
+ * Other Extensions, by name, that this Extension can optionally depend on or
108
+ * configure, if they are directly depended on by another Extension
109
109
  */
110
- peerDependencies?: NormalizedPeerDependency<AnyLexicalPlan>[];
110
+ peerDependencies?: NormalizedPeerDependency<AnyLexicalExtension>[];
111
111
  /**
112
- * The default configuration specific to this Plan. This Config may be
113
- * seen by this Plan, or any Plan that uses it as a dependency.
112
+ * The default configuration specific to this Extension. This Config may be
113
+ * seen by this Extension, or any Extension that uses it as a dependency.
114
114
  *
115
115
  * The config may be mutated on register, this is particularly useful
116
- * for vending functionality to other Plans that depend on this Plan.
116
+ * for vending functionality to other Extensions that depend on this Extension.
117
117
  */
118
118
  config?: Config;
119
119
  /**
120
120
  * By default, Config is shallow merged `{...a, ...b}` with
121
- * {@link shallowMergeConfig}, if your Plan requires other strategies
121
+ * {@link shallowMergeConfig}, if your Extension requires other strategies
122
122
  * (such as concatenating an Array) you can implement it here.
123
123
  *
124
124
  * @example Merging an array
125
125
  * ```js
126
- * const plan = definePlan({
126
+ * const extension = defineExtension({
127
127
  * // ...
128
128
  * mergeConfig(config, overrides) {
129
129
  * const merged = shallowMergeConfig(config, overrides);
@@ -143,63 +143,63 @@ export interface LexicalPlan<in out Config extends PlanConfigBase, out Name exte
143
143
  /**
144
144
  * Perform any necessary initialization before the editor is created,
145
145
  * this runs after all configuration overrides for both the editor this
146
- * this plan have been merged. May be used validate the editor
146
+ * this extension have been merged. May be used validate the editor
147
147
  * configuration.
148
148
  *
149
149
  * @param editorConfig - The in-progress editor configuration (mutable)
150
- * @param config - The merged configuration specific to this plan (mutable)
150
+ * @param config - The merged configuration specific to this extension (mutable)
151
151
  * @param state - An object containing an AbortSignal that can be
152
152
  * used, and methods for accessing the merged configuration of
153
153
  * dependencies and peerDependencies
154
154
  */
155
- init?: (editorConfig: InitialEditorConfig, config: Config, state: PlanInitState) => Init;
155
+ init?: (editorConfig: InitialEditorConfig, config: Config, state: ExtensionInitState) => Init;
156
156
  /**
157
157
  * Add behavior to the editor (register transforms, listeners, etc.) after
158
158
  * the Editor is created, but before its initial state is set.
159
159
  * The register function may also mutate the config
160
- * in-place to expose data to other plans that use it as a dependency.
160
+ * in-place to expose data to other extensions that use it as a dependency.
161
161
  *
162
- * @param editor - The editor this Plan is being registered with
163
- * @param config - The merged configuration specific to this Plan
162
+ * @param editor - The editor this Extension is being registered with
163
+ * @param config - The merged configuration specific to this Extension
164
164
  * @param state - An object containing an AbortSignal that can be
165
165
  * used, and methods for accessing the merged configuration of
166
166
  * dependencies and peerDependencies
167
167
  * @returns A clean-up function
168
168
  */
169
- register?: (editor: LexicalEditor, config: Config, state: PlanRegisterState<Init>) => RegisterCleanup<Output>;
169
+ register?: (editor: LexicalEditor, config: Config, state: ExtensionRegisterState<Init>) => RegisterCleanup<Output>;
170
170
  /**
171
171
  * Run any code that must happen after initialization of the
172
172
  * editor state (which happens after all register calls).
173
173
  *
174
- * @param editor - The editor this Plan is being registered with
175
- * @param config - The merged configuration specific to this Plan
174
+ * @param editor - The editor this Extension is being registered with
175
+ * @param config - The merged configuration specific to this Extension
176
176
  * @param state - An object containing an AbortSignal that can be
177
177
  * used, and methods for accessing the merged configuration of
178
178
  * dependencies and peerDependencies
179
179
  * @returns A clean-up function
180
180
  */
181
- afterInitialization?: (editor: LexicalEditor, config: Config, state: PlanRegisterState<Init>) => () => void;
181
+ afterInitialization?: (editor: LexicalEditor, config: Config, state: ExtensionRegisterState<Init>) => () => void;
182
182
  }
183
183
  /**
184
- * Extract the Config type from a Plan
184
+ * Extract the Config type from an Extension
185
185
  */
186
- export type LexicalPlanConfig<Plan extends AnyLexicalPlan> = NonNullable<Plan[configTypeSymbol]>;
186
+ export type LexicalExtensionConfig<Extension extends AnyLexicalExtension> = NonNullable<Extension[configTypeSymbol]>;
187
187
  /**
188
- * Extract the Name type from a Plan
188
+ * Extract the Name type from an Extension
189
189
  */
190
- export type LexicalPlanName<Plan extends AnyLexicalPlan> = Plan["name"];
190
+ export type LexicalExtensionName<Extension extends AnyLexicalExtension> = Extension["name"];
191
191
  /**
192
- * Extract the Output type from a Plan
192
+ * Extract the Output type from an Extension
193
193
  */
194
- export type LexicalPlanOutput<Plan extends AnyLexicalPlan> = NonNullable<Plan[outputTypeSymbol]>;
194
+ export type LexicalExtensionOutput<Extension extends AnyLexicalExtension> = NonNullable<Extension[outputTypeSymbol]>;
195
195
  /**
196
- * Extract the Init type from a Plan
196
+ * Extract the Init type from an Extension
197
197
  */
198
- export type LexicalPlanInit<Plan extends AnyLexicalPlan> = NonNullable<Plan[initTypeSymbol]>;
198
+ export type LexicalExtensionInit<Extension extends AnyLexicalExtension> = NonNullable<Extension[initTypeSymbol]>;
199
199
  /**
200
- * A Plan that has an OutputComponent of the given type (e.g. React.ComponentType)
200
+ * An Extension that has an OutputComponent of the given type (e.g. React.ComponentType)
201
201
  */
202
- export type OutputComponentPlan<ComponentType> = LexicalPlan<any, any, {
202
+ export type OutputComponentExtension<ComponentType> = LexicalExtension<any, any, {
203
203
  Component: ComponentType;
204
204
  }, any>;
205
205
  /**
@@ -236,11 +236,11 @@ export interface InitialEditorConfig {
236
236
  */
237
237
  namespace?: CreateEditorArgs["namespace"];
238
238
  /**
239
- * The nodes that this Plan adds to the Editor configuration, will be merged with other Plans
239
+ * The nodes that this Extension adds to the Editor configuration, will be merged with other Extensions
240
240
  */
241
241
  nodes?: CreateEditorArgs["nodes"];
242
242
  /**
243
- * EditorThemeClasses that will be deep merged with other Plans
243
+ * EditorThemeClasses that will be deep merged with other Extensions
244
244
  */
245
245
  theme?: CreateEditorArgs["theme"];
246
246
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AAEH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC9B,cAAc,GACd,gCAAgC,CAAC;AACrC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAElD,MAAM,MAAM,wBAAwB,CAAC,IAAI,SAAS,cAAc,IAAI;IAClE,IAAI,CAAC,MAAM,CAAC;IACZ,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS;CAC7C,GAAG;IAAE,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,6BAA6B,CACvC,EAAE,CAAC,GAAG,CAAC,MAAM,SAAS,cAAc,EACpC,GAAG,CAAC,IAAI,SAAS,MAAM,EACvB,EAAE,CAAC,GAAG,CAAC,MAAM,EACb,EAAE,CAAC,GAAG,CAAC,IAAI,IACT,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,gCAAg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;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IACxD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;CAC9C"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "lexical",
7
7
  "lexical-builder",
8
8
  "plug-in",
9
- "plan"
9
+ "extension"
10
10
  ],
11
11
  "scripts": {
12
12
  "build": "tsc --noEmit && vite build",
@@ -15,7 +15,7 @@
15
15
  "test": "vitest run --typecheck",
16
16
  "test:watch": "vitest"
17
17
  },
18
- "version": "0.0.36-nightly.20250714.0",
18
+ "version": "0.0.36",
19
19
  "license": "MIT",
20
20
  "repository": {
21
21
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/etrepum/lexical-builder",
29
29
  "peerDependencies": {
30
- "lexical": ">=0.31.0 || >=0.31.1-nightly.0"
30
+ "lexical": ">=0.33.1 || >=0.33.2-nightly.0"
31
31
  },
32
32
  "sideEffects": false,
33
33
  "devDependencies": {
@@ -1,130 +0,0 @@
1
- import { AnyLexicalPlan, LexicalPlan, LexicalPlanConfig, NormalizedLexicalPlanArgument, NormalizedPeerDependency, PlanConfigBase, RegisterCleanup } from './types';
2
- /**
3
- * Define a LexicalPlan from the given object literal. TypeScript will
4
- * infer Config and Name in most cases, but you may want to use
5
- * {@link safeCast} for config if there are default fields or varying types.
6
- *
7
- * @param plan - The LexicalPlan
8
- * @returns The unmodified plan argument (this is only an inference helper)
9
- *
10
- * @example Basic example
11
- * ```ts
12
- * export const MyPlan = definePlan({
13
- * // Plan names must be unique in an editor
14
- * name: "my",
15
- * nodes: [MyNode],
16
- * });
17
- * ```
18
- *
19
- * @example Plan with optional configuration
20
- * ```ts
21
- * export interface ConfigurableConfig {
22
- * optional?: string;
23
- * required: number;
24
- * }
25
- * export const ConfigurablePlan = definePlan({
26
- * name: "configurable",
27
- * // The Plan's config must satisfy the full config type,
28
- * // but using the Plan as a dependency never requires
29
- * // configuration and any partial of the config can be specified
30
- * config: safeCast<ConfigurableConfig>({ required: 1 }),
31
- * });
32
- * ```
33
- */
34
- export declare function definePlan<Config extends PlanConfigBase, Name extends string, Output, Init>(plan: LexicalPlan<Config, Name, Output, Init>): LexicalPlan<Config, Name, Output, Init>;
35
- /**
36
- * Override a partial of the configuration of a Plan, to be used
37
- * in the dependencies array of another plan, or as
38
- * an argument to {@link buildEditorFromPlans}.
39
- *
40
- * Before building the editor, configurations will be merged using
41
- * plan.mergeConfig(plan, config) or {@link shallowMergeConfig} if
42
- * this is not directly implemented by the Plan.
43
- *
44
- * @param args - A plan followed by one or more config partials for that plan
45
- * @returns [plan, config, ...configs]
46
- *
47
- * @example
48
- * ```ts
49
- * export const ReactDecoratorPlan = definePlan({
50
- * name: "react-decorator",
51
- * dependencies: [
52
- * configPlan(ReactPlan, {
53
- * decorators: [<ReactDecorator />]
54
- * }),
55
- * ],
56
- * });
57
- * ```
58
- */
59
- export declare function configPlan<Config extends PlanConfigBase, Name extends string, Output, Init>(...args: NormalizedLexicalPlanArgument<Config, Name, Output, Init>): NormalizedLexicalPlanArgument<Config, Name, Output, Init>;
60
- /**
61
- * Provide output from the register function of a Plan
62
- *
63
- * @returns A cleanup function
64
- *
65
- * @example Provide output with no other cleanup
66
- * ```ts
67
- * // This is entirely optional and would be inferred correctly, but
68
- * // it can be useful for documentation!
69
- * export interface RegisteredAtOutput {
70
- * registered_at: number;
71
- * }
72
- * export const RegisteredAtPlan = definePlan({
73
- * name: "RegisteredAt",
74
- * register(editor) {
75
- * return provideOutput<RegisteredAtOutput>({ registered_at: Date.now() });
76
- * },
77
- * });
78
- * ```
79
- *
80
- * @example Provide output with other cleanup
81
- * ```ts
82
- * export interface UniqueCommandOutput {
83
- * command: LexicalCommand<unknown>;
84
- * }
85
- * export const UniqueCommandPlan = definePlan({
86
- * name: 'UniqueCommand',
87
- * register(editor) {
88
- * const output: UniqueCommnadOutput = {command: createCommand('UNIQUE_COMMAND')};
89
- * const cleanup = registerCommand(
90
- * command,
91
- * (_payload) => {
92
- * console.log('Unique command received!');
93
- * return true;
94
- * }
95
- * COMMAND_PRIORITY_EDITOR
96
- * );
97
- * return provideOutput(output, cleanup);
98
- * },
99
- * });
100
- * ```
101
- *
102
- */
103
- export declare function provideOutput<Output>(output: Output, cleanup?: () => void): RegisterCleanup<Output>;
104
- /** @internal */
105
- export declare const PeerDependencyBrand: unique symbol;
106
- export declare const ConfigTypeId: unique symbol;
107
- export declare const OutputTypeId: unique symbol;
108
- /**
109
- * Used to declare a peer dependency of a plan in a type-safe way,
110
- * requires the type parameter. The most common use case for peer dependencies
111
- * is to avoid a direct import dependency, so you would want to use a
112
- * type import or the import type (shown in below examples).
113
- *
114
- * @param name - The plan's name
115
- * @param config - An optional config override
116
- * @returns NormalizedPeerDependency
117
- *
118
- * @example
119
- * ```ts
120
- * export const PeerPlan = definePlan({
121
- * name: 'PeerPlan',
122
- * peerDependencies: [
123
- * declarePeerDependency<typeof import("foo").FooPlan>("foo"),
124
- * declarePeerDependency<typeof import("bar").BarPlan>("bar", {config: "bar"}),
125
- * ],
126
- * });
127
- * ```
128
- */
129
- export declare function declarePeerDependency<Plan extends AnyLexicalPlan = never>(name: Plan["name"], config?: Partial<LexicalPlanConfig<Plan>>): NormalizedPeerDependency<Plan>;
130
- //# sourceMappingURL=definePlan.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definePlan.d.ts","sourceRoot":"","sources":["../src/definePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,wBAAwB,EACxB,cAAc,EACd,eAAe,EAChB,MAAM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