@etrepum/lexical-builder-core 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # `@etrepum/lexical-builder-core`
2
+
3
+ **EXPERIMENTAL** Lexical Builder Core
4
+
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
7
+ any overhead of including the builder runtime.
@@ -0,0 +1,153 @@
1
+ import { AnyLexicalPlan, LexicalPlan, LexicalPlanConfig, NormalizedLexicalPlanArgument, NormalizedPeerDependency, PlanConfigBase, RegisterCleanup, RootPlan, RootPlanArgument } from './types';
2
+
3
+ /**
4
+ * Define a LexicalPlan from the given object literal. TypeScript will
5
+ * infer Config and Name in most cases, but you may want to use
6
+ * {@link safeCast} for config if there are default fields or varying types.
7
+ *
8
+ * @param plan The LexicalPlan
9
+ * @returns The unmodified plan argument (this is only an inference helper)
10
+ *
11
+ * @example Basic example
12
+ * ```ts
13
+ * export const MyPlan = definePlan({
14
+ * // Plan names must be unique in an editor
15
+ * name: "my",
16
+ * // Config must be an object, but an empty object is fine
17
+ * config: {},
18
+ * nodes: [MyNode],
19
+ * });
20
+ * ```
21
+ *
22
+ * @example Plan with optional configuration
23
+ * ```ts
24
+ * export interface ConfigurableConfig {
25
+ * optional?: string;
26
+ * required: number;
27
+ * }
28
+ * export const ConfigurablePlan = definePlan({
29
+ * name: "configurable",
30
+ * // The Plan's config must satisfy the full config type,
31
+ * // but using the Plan as a dependency never requires
32
+ * // configuration and any partial of the config can be specified
33
+ * config: safeCast<ConfigurableConfig>({ required: 1 }),
34
+ * });
35
+ * ```
36
+ */
37
+ export declare function definePlan<Config extends PlanConfigBase, Name extends string, Output>(plan: LexicalPlan<Config, Name, Output>): LexicalPlan<Config, Name, Output>;
38
+ /**
39
+ * Define a LexicalPlan from the given object literal, assigning an
40
+ * empty config and the name "[root]". This plan must only be used
41
+ * at most once per editor, usually as the first argument to
42
+ * {@link buildEditorFromPlans} or the plan argument to
43
+ * {@link LexicalPlanComposer}.
44
+ *
45
+ * @param rootPlan A plan without the config or name properties
46
+ * @returns The given plan argument, after in-place assignment of config and name
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const editorHandle = buildEditorFromPlans(
51
+ * defineRootPlan({
52
+ * dependencies: [DragonPlan, RichTextPlan, HistoryPlan],
53
+ * }),
54
+ * );
55
+ * ```
56
+ */
57
+ export declare function defineRootPlan<Output>(rootPlan: RootPlanArgument<Output>): RootPlan<Output>;
58
+ /**
59
+ * Override a partial of the configuration of a Plan, to be used
60
+ * in the dependencies array of another plan, or as
61
+ * an argument to {@link buildEditorFromPlans}.
62
+ *
63
+ * Before building the editor, configurations will be merged using
64
+ * plan.mergeConfig(plan, config) or {@link shallowMergeConfig} if
65
+ * this is not directly implemented by the Plan.
66
+ *
67
+ * @param args A plan followed by one or more config partials for that plan
68
+ * @returns [plan, config, ...configs]
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * export const ReactDecoratorPlan = definePlan({
73
+ * name: "react-decorator",
74
+ * dependencies: [
75
+ * configPlan(ReactPlan, {
76
+ * decorators: [<ReactDecorator />]
77
+ * }),
78
+ * ],
79
+ * });
80
+ * ```
81
+ */
82
+ export declare function configPlan<Config extends PlanConfigBase, Name extends string, Output>(...args: NormalizedLexicalPlanArgument<Config, Name, Output>): NormalizedLexicalPlanArgument<Config, Name, Output>;
83
+ /**
84
+ * Provide output from the register function of a Plan
85
+ *
86
+ * @returns A cleanup function
87
+ *
88
+ * @example Provide output with no other cleanup
89
+ * ```ts
90
+ * // This is entirely optional and would be inferred correctly, but
91
+ * // it can be useful for documentation!
92
+ * export interface RegisteredAtOutput {
93
+ * registered_at: number;
94
+ * }
95
+ * export const RegisteredAtPlan = definePlan({
96
+ * name: "RegisteredAt",
97
+ * config: {},
98
+ * register(editor) {
99
+ * return provideOutput<RegisteredAtOutput>({ registered_at: Date.now() });
100
+ * },
101
+ * });
102
+ * ```
103
+ *
104
+ * @example Provide output with other cleanup
105
+ * ```ts
106
+ * export interface UniqueCommandOutput {
107
+ * command: LexicalCommand<unknown>;
108
+ * }
109
+ * export const UniqueCommandPlan = definePlan({
110
+ * name: 'UniqueCommand',
111
+ * config: {},
112
+ * register(editor) {
113
+ * const output: UniqueCommnadOutput = {command: createCommand('UNIQUE_COMMAND')};
114
+ * const cleanup = registerCommand(
115
+ * command,
116
+ * (_payload) => {
117
+ * console.log('Unique command received!');
118
+ * return true;
119
+ * }
120
+ * COMMAND_PRIORITY_EDITOR
121
+ * );
122
+ * return provideOutput(output, cleanup);
123
+ * },
124
+ * });
125
+ * ```
126
+ *
127
+ */
128
+ export declare function provideOutput<Output>(output: Output, cleanup?: () => void): RegisterCleanup<Output>;
129
+ /** @internal */
130
+ export declare const PeerDependencyBrand: unique symbol;
131
+ /**
132
+ * Used to declare a peer dependency of a plan in a type-safe way,
133
+ * requires the type parameter. The most common use case for peer dependencies
134
+ * is to avoid a direct import dependency, so you would want to use a
135
+ * type import or the import type (shown in below examples).
136
+ *
137
+ * @param name The plan's name
138
+ * @param config An optional config override
139
+ * @returns NormalizedPeerDependency
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * export const PeerPlan = definePlan({
144
+ * name: 'PeerPlan',
145
+ * config: {},
146
+ * peerDependencies: [
147
+ * declarePeerDependency<typeof import("foo").FooPlan>("foo"),
148
+ * declarePeerDependency<typeof import("bar").BarPlan>("bar", {config: "bar"}),
149
+ * ],
150
+ * });
151
+ */
152
+ export declare function declarePeerDependency<Plan extends AnyLexicalPlan = never>(name: Plan["name"], config?: Partial<LexicalPlanConfig<Plan>>): NormalizedPeerDependency<Plan>;
153
+ //# sourceMappingURL=definePlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definePlan.d.ts","sourceRoot":"","sources":["../src/definePlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,wBAAwB,EACxB,cAAc,EACd,eAAe,EAC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1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare const PACKAGE_VERSION: string;
9
+ export { configPlan, definePlan, defineRootPlan, provideOutput, declarePeerDependency, } from './definePlan';
10
+ export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type EditorHandle, type InitialEditorStateType, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanName, type LexicalPlanOutput, type LexicalPlanDependency, type RootPlan, type RootPlanArgument, type NormalizedLexicalPlanArgument, type PlanConfigBase, type RegisterState, type RegisterCleanup, type NormalizedPeerDependency, } from './types';
11
+ export { safeCast } from './safeCast';
12
+ export { shallowMergeConfig } from './shallowMergeConfig';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,cAAc,EACd,aAAa,EACb,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,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,qBAAqB,EAC1B,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,wBAAwB,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ function r(n) {
2
+ return n;
3
+ }
4
+ function u(n) {
5
+ return Object.assign(n, { name: "[root]", config: {} });
6
+ }
7
+ function f(...n) {
8
+ return n;
9
+ }
10
+ function o(n, t) {
11
+ return Object.assign(() => t && t(), { output: n });
12
+ }
13
+ function c(n, t) {
14
+ return [n, t];
15
+ }
16
+ function i(n) {
17
+ return n;
18
+ }
19
+ function a(n, t) {
20
+ if (!t || n === t)
21
+ return n;
22
+ for (const e in t)
23
+ if (n[e] !== t[e])
24
+ return { ...n, ...t };
25
+ return n;
26
+ }
27
+ const l = "0.0.23";
28
+ export {
29
+ l as PACKAGE_VERSION,
30
+ f as configPlan,
31
+ c as declarePeerDependency,
32
+ r as definePlan,
33
+ u as defineRootPlan,
34
+ o as provideOutput,
35
+ i as safeCast,
36
+ a as shallowMergeConfig
37
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /**
9
+ * Explicitly and safely cast a value to a specific type when inference or
10
+ * satisfies isn't going to work as expected (often useful for the config
11
+ * property with definePlan)
12
+ */
13
+ export declare function safeCast<T>(value: T): T;
14
+ //# sourceMappingURL=safeCast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeCast.d.ts","sourceRoot":"","sources":["../src/safeCast.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC"}
@@ -0,0 +1,11 @@
1
+ import { PlanConfigBase } from './types';
2
+
3
+ /**
4
+ * The default merge strategy for plan configuration is a shallow merge.
5
+ *
6
+ * @param config A full config
7
+ * @param overrides A partial config of overrides
8
+ * @returns config if there are no overrides, otherwise `{...config, ...overrides}`
9
+ */
10
+ export declare function shallowMergeConfig<T extends PlanConfigBase>(config: T, overrides?: Partial<T>): T;
11
+ //# sourceMappingURL=shallowMergeConfig.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,211 @@
1
+ import { CreateEditorArgs, EditorState, LexicalEditor } from 'lexical';
2
+ import { PeerDependencyBrand } from './definePlan';
3
+
4
+ /**
5
+ * Any concrete {@link LexicalPlan}
6
+ */
7
+ export type AnyLexicalPlan = LexicalPlan<any, string, any>;
8
+ /**
9
+ * Any {@link LexicalPlan} or {@link NormalizedLexicalPlanArgument}
10
+ */
11
+ export type AnyLexicalPlanArgument = LexicalPlanArgument<any, string, any>;
12
+ /**
13
+ * The default plan configuration of an empty object
14
+ */
15
+ export type PlanConfigBase = Record<never, never>;
16
+ export type RootPlan<Output> = LexicalPlan<PlanConfigBase, "[root]", Output>;
17
+ export type RootPlanArgument<Output = any> = Omit<RootPlan<Output>, "config" | "name">;
18
+ export type NormalizedPeerDependency<Plan extends AnyLexicalPlan> = [
19
+ Plan["name"],
20
+ Partial<LexicalPlanConfig<Plan>> | undefined
21
+ ] & {
22
+ [PeerDependencyBrand]: Plan;
23
+ };
24
+ /**
25
+ * A tuple of [plan, configOverride, ...configOverrides]
26
+ */
27
+ export type NormalizedLexicalPlanArgument<Config extends PlanConfigBase, Name extends string, Output extends unknown> = [LexicalPlan<Config, Name, Output>, Partial<Config>, ...Partial<Config>[]];
28
+ /**
29
+ * An object that the register method can use to detect unmount and access the
30
+ * configuration for plan dependencies
31
+ */
32
+ export interface RegisterState {
33
+ /** An AbortSignal that is aborted when the EditorHandle is disposed */
34
+ signal: AbortSignal;
35
+ /**
36
+ * Get the result of a peerDependency by name, if it exists
37
+ * (must be a peerDependency of this plan)
38
+ */
39
+ getPeer<Plan extends AnyLexicalPlan = never>(name: Plan["name"]): undefined | LexicalPlanDependency<Plan>;
40
+ /**
41
+ * Get the configuration of a dependency by plan
42
+ * (must be a direct dependency of this plan)
43
+ */
44
+ getDependency<Dependency extends AnyLexicalPlan>(dep: Dependency): LexicalPlanDependency<Dependency>;
45
+ /**
46
+ * Get the names of any direct dependents of this
47
+ * Plan, typically only used for error messages.
48
+ */
49
+ getDirectDependentNames(): string[];
50
+ /**
51
+ * Get the names of all peer dependencies of this
52
+ * Plan, even if they do not exist in the builder,
53
+ * typically only used for devtools.
54
+ */
55
+ getPeerNameSet(): Set<string>;
56
+ }
57
+ /**
58
+ * A {@link LexicalPlan} or {@link NormalizedLexicalPlanArgument} (plan with config overrides)
59
+ */
60
+ export type LexicalPlanArgument<Config extends PlanConfigBase, Name extends string, Output extends unknown> = LexicalPlan<Config, Name, Output> | NormalizedLexicalPlanArgument<Config, Name, Output>;
61
+ export interface LexicalPlanDependency<Dependency extends AnyLexicalPlan> {
62
+ config: LexicalPlanConfig<Dependency>;
63
+ output: LexicalPlanOutput<Dependency>;
64
+ }
65
+ /**
66
+ * A Plan is a composable unit of LexicalEditor configuration
67
+ * (nodes, theme, etc) used to create an editor, plus runtime behavior
68
+ * that is registered after the editor is created.
69
+ *
70
+ * A Plan may depend on other Plans, and provide functionality to other
71
+ * plans through its config.
72
+ */
73
+ export interface LexicalPlan<Config extends PlanConfigBase = PlanConfigBase, Name extends string = string, Output extends unknown = unknown> {
74
+ /** The name of the Plan, must be unique */
75
+ name: Name;
76
+ /** Plan names that must not be loaded with this Plan */
77
+ conflictsWith?: string[];
78
+ /** Other Plans that this Plan depends on, can also be used to configure them */
79
+ dependencies?: AnyLexicalPlanArgument[];
80
+ /**
81
+ * Other Plans, by name, that this Plan can optionally depend on or
82
+ * configure, if they are directly depended on by another Plan
83
+ */
84
+ peerDependencies?: NormalizedPeerDependency<AnyLexicalPlan>[];
85
+ /**
86
+ * @internal Disable root element events (for internal Meta use)
87
+ */
88
+ disableEvents?: CreateEditorArgs["disableEvents"];
89
+ /**
90
+ * Used when this editor is nested inside of another editor
91
+ */
92
+ parentEditor?: CreateEditorArgs["parentEditor"];
93
+ /**
94
+ * The namespace of this Editor. If two editors share the same
95
+ * namespace, JSON will be the clipboard interchange format.
96
+ * Otherwise HTML will be used.
97
+ */
98
+ namespace?: CreateEditorArgs["namespace"];
99
+ /**
100
+ * The nodes that this Plan adds to the Editor configuration, will be merged with other Plans
101
+ */
102
+ nodes?: CreateEditorArgs["nodes"];
103
+ /**
104
+ * EditorThemeClasses that will be deep merged with other Plans
105
+ */
106
+ theme?: CreateEditorArgs["theme"];
107
+ /**
108
+ * Overrides for HTML serialization (exportDOM) and
109
+ * deserialization (importDOM) that does not require subclassing and node
110
+ * replacement
111
+ */
112
+ html?: CreateEditorArgs["html"];
113
+ /**
114
+ * Whether the initial state of the editor is editable or not
115
+ */
116
+ editable?: CreateEditorArgs["editable"];
117
+ /**
118
+ * The editor will catch errors that happen during updates and
119
+ * reconciliation and call this. It defaults to
120
+ * `(error) => { throw error }`.
121
+ *
122
+ * @param error The Error object
123
+ * @param editor The editor that this error came from
124
+ */
125
+ onError?: (error: Error, editor: LexicalEditor) => void;
126
+ /**
127
+ * The initial EditorState as a JSON string, an EditorState, or a function
128
+ * to update the editor (once).
129
+ */
130
+ $initialEditorState?: InitialEditorStateType;
131
+ /**
132
+ * The default configuration specific to this Plan. This Config may be
133
+ * seen by this Plan, or any Plan that uses it as a dependency.
134
+ *
135
+ * The config may be mutated on register, this is particularly useful
136
+ * for vending functionality to other Plans that depend on this Plan.
137
+ */
138
+ config: Config;
139
+ /**
140
+ * By default, Config is shallow merged `{...a, ...b}` with
141
+ * {@link shallowMergeConfig}, if your Plan requires other strategies
142
+ * (such as concatenating an Array) you can implement it here.
143
+ *
144
+ * @example Merging an array
145
+ * ```js
146
+ * const plan = definePlan({
147
+ * // ...
148
+ * mergeConfig(config, overrides) {
149
+ * const merged = shallowMergeConfig(config, overrides);
150
+ * if (Array.isArray(overrides.decorators)) {
151
+ * merged.decorators = [...config.decorators, ...overrides.decorators];
152
+ * }
153
+ * return merged;
154
+ * }
155
+ * });
156
+ * ```
157
+ *
158
+ * @param config The current configuration
159
+ * @param overrides The partial configuration to merge
160
+ * @returns The merged configuration
161
+ */
162
+ mergeConfig?: (config: Config, overrides: Partial<Config>) => Config;
163
+ /**
164
+ * Add behavior to the editor (register transforms, listeners, etc.) after
165
+ * the Editor is created. The register function may also mutate the config
166
+ * in-place to expose data to other plans that use it as a dependency.
167
+ *
168
+ * @param editor The editor this Plan is being registered with
169
+ * @param config The merged configuration specific to this Plan
170
+ * @param state An object containing an AbortSignal that can be
171
+ * used, and methods for accessing the merged configuration of
172
+ * dependencies and peerDependencies
173
+ * @returns A clean-up function
174
+ */
175
+ register?: (editor: LexicalEditor, config: Config, state: RegisterState) => RegisterCleanup<Output>;
176
+ }
177
+ export type RegisterCleanup<Output> = (() => void) & (unknown extends Output ? {
178
+ output?: Output;
179
+ } : {
180
+ output: Output;
181
+ });
182
+ /**
183
+ * Extract the Config type from a Plan
184
+ */
185
+ export type LexicalPlanConfig<Plan extends AnyLexicalPlan> = Plan["config"];
186
+ /**
187
+ * Extract the Name type from a Plan
188
+ */
189
+ export type LexicalPlanName<Plan extends AnyLexicalPlan> = Plan["name"];
190
+ export type LexicalPlanOutput<Plan> = Plan extends LexicalPlan<infer _Config, infer _Name, infer Output> ? Output : unknown;
191
+ /**
192
+ * A handle to the editor and its dispose function
193
+ */
194
+ export interface EditorHandle extends Disposable {
195
+ /** The created editor */
196
+ editor: LexicalEditor;
197
+ /**
198
+ * Dispose the editor and perform all clean-up
199
+ * (also available as Symbol.dispose via Disposable)
200
+ */
201
+ dispose: () => void;
202
+ }
203
+ /**
204
+ * All of the possible ways to initialize $initialEditorState:
205
+ * - `null` an empty state, the default
206
+ * - `string` an EditorState serialized to JSON
207
+ * - `EditorState` an EditorState that has been deserialized already (not just parsed JSON)
208
+ * - `((editor: LexicalEditor) => void)` A function that is called with the editor for you to mutate it
209
+ */
210
+ export type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void);
211
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD;;GAEG;AAEH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3D;;GAEG;AAEH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAElD,MAAM,MAAM,QAAQ,CAAC,MAAM,IAAI,WAAW,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7E,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,GAAG,IAAI,IAAI,CAC/C,QAAQ,CAAC,MAAM,CAAC,EAChB,QAAQ,GAAG,MAAM,CAClB,CAAC;AAEF,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,CAAC,mBAAmB,CAAC,EAA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AAE,MAAM,EACd,KAAK,EAAE,aAAa,KACjB,eAAe,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,MAAM,eAAe,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,GAChD,CAAC,OAAO,SAAS,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,cAAc,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5E;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,cAAc,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;AAExE,MAAM,MAAM,iBAAiB,CAAC,IAAI,IAChC,IAAI,SAAS,WAAW,CAAC,MAAM,OAAO,EAAE,MAAM,KAAK,EAAE,MAAM,MAAM,CAAC,GAC9D,MAAM,GACN,OAAO,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,yBAAyB;IACzB,MAAM,EAAE,aAAa,CAAC;IACtB;;;OAGG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAC9B,IAAI,GACJ,MAAM,GACN,WAAW,GACX,CAAC,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@etrepum/lexical-builder-core",
3
+ "description": "[EXPERIMENTAL] Lexical Builder @etrepum/lexical-builder-core",
4
+ "type": "module",
5
+ "keywords": [
6
+ "lexical",
7
+ "lexical-builder",
8
+ "plug-in",
9
+ "plan"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc --noEmit && vite build",
13
+ "dev": "vite",
14
+ "test": "vitest run --typecheck",
15
+ "test:watch": "vitest"
16
+ },
17
+ "version": "0.0.23",
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/etrepum/lexical-builder.git",
22
+ "directory": "packages/lexical-builder-core"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/etrepum/lexical-builder/issues"
26
+ },
27
+ "homepage": "https://github.com/etrepum/lexical-builder",
28
+ "dependencies": {},
29
+ "peerDependencies": {
30
+ "lexical": ">=0.16.0-0"
31
+ },
32
+ "sideEffects": false,
33
+ "devDependencies": {
34
+ "@testing-library/dom": "^10.1.0",
35
+ "@testing-library/jest-dom": "^6.4.5",
36
+ "@testing-library/user-event": "^14.5.2",
37
+ "jsdom": "^24.1.0",
38
+ "tslib": "^2.6.2",
39
+ "typescript": "^5.4.5",
40
+ "vite": "^5.2.11",
41
+ "vite-plugin-dts": "^3.9.1",
42
+ "vite-plugin-package-version": "^1.1.0",
43
+ "vitest": "^1.6.0"
44
+ },
45
+ "module": "dist/index.js",
46
+ "types": "dist/index.d.ts",
47
+ "files": [
48
+ "dist"
49
+ ]
50
+ }