@etrepum/lexical-builder 0.0.5 → 0.0.7
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/dist/AutoFocusPlan.d.ts +8 -1
- package/dist/AutoFocusPlan.d.ts.map +1 -1
- package/dist/DragonPlan.d.ts +1 -1
- package/dist/DragonPlan.d.ts.map +1 -1
- package/dist/HistoryPlan.d.ts +8 -1
- package/dist/HistoryPlan.d.ts.map +1 -1
- package/dist/LexicalBuilder.d.ts.map +1 -1
- package/dist/PlainTextPlan.d.ts +1 -1
- package/dist/PlainTextPlan.d.ts.map +1 -1
- package/dist/PlanRep.d.ts +1 -1
- package/dist/PlanRep.d.ts.map +1 -1
- package/dist/RichTextPlan.d.ts +1 -1
- package/dist/RichTextPlan.d.ts.map +1 -1
- package/dist/index.d.ts +21 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -340
- package/dist/index.js.map +1 -1
- package/dist/safeCast.d.ts +5 -0
- package/dist/safeCast.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -4
- package/dist/ReactPlan.d.ts +0 -40
- package/dist/ReactPlan.d.ts.map +0 -1
- package/dist/ReactPluginHostPlan.d.ts +0 -23
- package/dist/ReactPluginHostPlan.d.ts.map +0 -1
- package/dist/__tests__/unit/LexicalBuilder.test.d.ts +0 -9
- package/dist/__tests__/unit/LexicalBuilder.test.d.ts.map +0 -1
- package/dist/registerShowPlaceholder.d.ts +0 -6
- package/dist/registerShowPlaceholder.d.ts.map +0 -1
- package/dist/registerSubscription.d.ts +0 -11
- package/dist/registerSubscription.d.ts.map +0 -1
- package/dist/shared/useLayoutEffect.d.ts +0 -5
- package/dist/shared/useLayoutEffect.d.ts.map +0 -1
- package/dist/useReactDecorators.d.ts +0 -10
- package/dist/useReactDecorators.d.ts.map +0 -1
- package/dist/useRegisterSubscription.d.ts +0 -4
- package/dist/useRegisterSubscription.d.ts.map +0 -1
package/dist/AutoFocusPlan.d.ts
CHANGED
|
@@ -5,8 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
+
declare const NAME = "@etrepum/lexical-builder/AutoFocusPlan";
|
|
9
|
+
declare module "@etrepum/lexical-builder" {
|
|
10
|
+
interface LexicalPlanRegistry {
|
|
11
|
+
[NAME]: typeof AutoFocusPlan;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
8
14
|
export interface AutoFocusConfig {
|
|
9
15
|
defaultSelection?: "rootStart" | "rootEnd";
|
|
10
16
|
}
|
|
11
|
-
export declare const AutoFocusPlan: import('
|
|
17
|
+
export declare const AutoFocusPlan: import('@etrepum/lexical-builder').LexicalPlan<AutoFocusConfig, "@etrepum/lexical-builder/AutoFocusPlan">;
|
|
18
|
+
export {};
|
|
12
19
|
//# sourceMappingURL=AutoFocusPlan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoFocusPlan.d.ts","sourceRoot":"","sources":["../src/AutoFocusPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C;AAED,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"AutoFocusPlan.d.ts","sourceRoot":"","sources":["../src/AutoFocusPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,QAAA,MAAM,IAAI,2CAA2C,CAAC;AACtD,OAAO,QAAQ,0BAA0B,CAAC;IACxC,UAAU,mBAAmB;QAC3B,CAAC,IAAI,CAAC,EAAE,OAAO,aAAa,CAAC;KAC9B;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C;AAED,eAAO,MAAM,aAAa,2GAwBxB,CAAC"}
|
package/dist/DragonPlan.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export declare const DragonPlan: import('
|
|
8
|
+
export declare const DragonPlan: import('@etrepum/lexical-builder').LexicalPlan<{}, "@lexical/dragon">;
|
|
9
9
|
//# sourceMappingURL=DragonPlan.d.ts.map
|
package/dist/DragonPlan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragonPlan.d.ts","sourceRoot":"","sources":["../src/DragonPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"DragonPlan.d.ts","sourceRoot":"","sources":["../src/DragonPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,UAAU,uEAIrB,CAAC"}
|
package/dist/HistoryPlan.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { HistoryState } from '@lexical/history';
|
|
2
2
|
|
|
3
|
+
declare const NAME = "@etrepum/lexical-builder/HistoryPlan";
|
|
4
|
+
declare module "@etrepum/lexical-builder" {
|
|
5
|
+
interface LexicalPlanRegistry {
|
|
6
|
+
[NAME]: typeof HistoryPlan;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
export interface HistoryConfig {
|
|
4
10
|
delay: number;
|
|
5
11
|
createInitialHistoryState: () => HistoryState;
|
|
6
12
|
}
|
|
7
|
-
export declare const HistoryPlan: import('
|
|
13
|
+
export declare const HistoryPlan: import('@etrepum/lexical-builder').LexicalPlan<HistoryConfig, "@etrepum/lexical-builder/HistoryPlan">;
|
|
14
|
+
export {};
|
|
8
15
|
//# sourceMappingURL=HistoryPlan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryPlan.d.ts","sourceRoot":"","sources":["../src/HistoryPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;AAK1B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB,EAAE,MAAM,YAAY,CAAC;CAC/C;AAED,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"HistoryPlan.d.ts","sourceRoot":"","sources":["../src/HistoryPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;AAK1B,QAAA,MAAM,IAAI,yCAAyC,CAAC;AACpD,OAAO,QAAQ,0BAA0B,CAAC;IACxC,UAAU,mBAAmB;QAC3B,CAAC,IAAI,CAAC,EAAE,OAAO,WAAW,CAAC;KAC5B;CACF;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB,EAAE,MAAM,YAAY,CAAC;CAC/C;AAED,eAAO,MAAM,WAAW,uGAStB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalBuilder.d.ts","sourceRoot":"","sources":["../src/LexicalBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EAEb,KAAK,gBAAgB,EAKtB,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,EAC5B,GAAG,KAAK,EAAE,sBAAsB,EAAE,GACjC,YAAY,CAOd;
|
|
1
|
+
{"version":3,"file":"LexicalBuilder.d.ts","sourceRoot":"","sources":["../src/LexicalBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EAEb,KAAK,gBAAgB,EAKtB,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,sBAAsB,EAC5B,GAAG,KAAK,EAAE,sBAAsB,EAAE,GACjC,YAAY,CAOd;AAgBD,gBAAgB;AAChB,qBAAa,cAAc;IACzB,MAAM,EAAE,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,EAAE,GAAG,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAChE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IAClD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;IAU/B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc;IASxD,WAAW,IAAI,YAAY;IAkB3B,OAAO,CAAC,GAAG,EAAE,sBAAsB,GAAG,MAAM;IAsE3C,cAAc;IAMf,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI;IA6BjD,qBAAqB;CAmFtB"}
|
package/dist/PlainTextPlan.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PlainTextPlan: import('
|
|
1
|
+
export declare const PlainTextPlan: import('@etrepum/lexical-builder').LexicalPlan<{}, "@lexical/plain-text">;
|
|
2
2
|
//# sourceMappingURL=PlainTextPlan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainTextPlan.d.ts","sourceRoot":"","sources":["../src/PlainTextPlan.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"PlainTextPlan.d.ts","sourceRoot":"","sources":["../src/PlainTextPlan.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,2EAKxB,CAAC"}
|
package/dist/PlanRep.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LexicalBuilder } from './LexicalBuilder';
|
|
2
2
|
import { AnyLexicalPlan, LexicalPlanConfig } from './types';
|
|
3
|
-
import { LexicalPlanRegistry } from '
|
|
3
|
+
import { LexicalPlanRegistry } from './';
|
|
4
4
|
|
|
5
5
|
export declare class PlanRep<Plan extends AnyLexicalPlan> {
|
|
6
6
|
builder: LexicalBuilder;
|
package/dist/PlanRep.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanRep.d.ts","sourceRoot":"","sources":["../src/PlanRep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,
|
|
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,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAM9C,qBAAa,OAAO,CAAC,IAAI,SAAS,cAAc;IAC9C,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC;gBACC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI;IAK/C,aAAa,CAAC,IAAI,SAAS,MAAM,mBAAmB,EAClD,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAI3D,mBAAmB,CAAC,UAAU,SAAS,cAAc,EACnD,GAAG,EAAE,UAAU,GACd,iBAAiB,CAAC,UAAU,CAAC;IAUhC,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC;CAcrC"}
|
package/dist/RichTextPlan.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export declare const RichTextPlan: import('
|
|
8
|
+
export declare const RichTextPlan: import('@etrepum/lexical-builder').LexicalPlan<{}, "@lexical/rich-text">;
|
|
9
9
|
//# sourceMappingURL=RichTextPlan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextPlan.d.ts","sourceRoot":"","sources":["../src/RichTextPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"RichTextPlan.d.ts","sourceRoot":"","sources":["../src/RichTextPlan.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,eAAO,MAAM,YAAY,0EAMvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,20 +5,33 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* An open interface for Name -> Config mappings. If you are defining a
|
|
10
|
+
* plan with non-empty config and it may be used as a peerDependency then
|
|
11
|
+
* you should extend this as follows:
|
|
12
|
+
*
|
|
13
|
+
* @example Extending LexicalPlanRegistry
|
|
14
|
+
* ```ts
|
|
15
|
+
* const NAME = "@some/plan";
|
|
16
|
+
* export const SomePlan = definePlan({ name: NAME, config: { className: "default" } });
|
|
17
|
+
* declare module '@etrepum/lexical-builder' {
|
|
18
|
+
* interface LexicalPlanRegistry {
|
|
19
|
+
* [NAME]: typeof SomePlan;
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
9
24
|
export interface LexicalPlanRegistry {
|
|
10
25
|
}
|
|
11
26
|
export declare const PACKAGE_VERSION: any;
|
|
12
|
-
export { type AutoFocusConfig, AutoFocusPlan } from './AutoFocusPlan';
|
|
13
27
|
export { configPlan, definePlan, defineRootPlan } from './definePlan';
|
|
28
|
+
export { LexicalBuilder, buildEditorFromPlans } from './LexicalBuilder';
|
|
29
|
+
export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type EditorHandle, type InitialEditorStateType, type LexicalPeerConfig, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanName, type NormalizedLexicalPlanArgument, type PlanConfigBase, type RegisterState, } from './types';
|
|
30
|
+
export { safeCast } from './safeCast';
|
|
31
|
+
export { shallowMergeConfig } from './shallowMergeConfig';
|
|
32
|
+
export { type AutoFocusConfig, AutoFocusPlan } from './AutoFocusPlan';
|
|
14
33
|
export { DragonPlan } from './DragonPlan';
|
|
15
34
|
export { type HistoryConfig, HistoryPlan } from './HistoryPlan';
|
|
16
|
-
export { LexicalBuilder, buildEditorFromPlans } from './LexicalBuilder';
|
|
17
35
|
export { PlainTextPlan } from './PlainTextPlan';
|
|
18
|
-
export { type DecoratorComponentProps, type DecoratorComponentType, type EditorChildrenComponentProps, type EditorChildrenComponentType, type EditorComponentProps, type EditorComponentType, LexicalPlanComposer, type LexicalPlanComposerProps, type ReactConfig, ReactPlan, } from './ReactPlan';
|
|
19
|
-
export { type HostMountCommandArg, type MountPluginCommandArg, type Container, mountReactPluginComponent, mountReactPluginElement, mountReactPluginHost, REACT_MOUNT_PLUGIN_COMMAND, REACT_PLUGIN_HOST_MOUNT_COMMAND, ReactPluginHostPlan, } from './ReactPluginHostPlan';
|
|
20
36
|
export { RichTextPlan } from './RichTextPlan';
|
|
21
|
-
export { type AnyLexicalPlan, type AnyLexicalPlanArgument, type EditorHandle, type InitialEditorStateType, type LexicalPeerConfig, type LexicalPlan, type LexicalPlanArgument, type LexicalPlanConfig, type LexicalPlanName, type NormalizedLexicalPlanArgument, type PlanConfigBase, type RegisterState, } from './types';
|
|
22
|
-
export { type ErrorBoundaryType, type ErrorBoundaryProps, } from './useReactDecorators';
|
|
23
|
-
export { safeCast } from './safeCast';
|
|
24
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,mBAAmB;CAAG;AACvC,eAAO,MAAM,eAAe,KAAkC,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,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,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,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,21 +4,11 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
+
import { $getRoot, $createParagraphNode, createEditor } from "lexical";
|
|
8
|
+
import { mergeRegister } from "@lexical/utils";
|
|
7
9
|
import { registerDragonSupport } from "@lexical/dragon";
|
|
8
10
|
import { createEmptyHistoryState, registerHistory } from "@lexical/history";
|
|
9
|
-
import { $getRoot, $createParagraphNode, createEditor, createCommand, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR } from "lexical";
|
|
10
|
-
import { mergeRegister, CAN_USE_DOM } from "@lexical/utils";
|
|
11
11
|
import { registerPlainText } from "@lexical/plain-text";
|
|
12
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
13
|
-
import { LexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
14
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
15
|
-
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
16
|
-
import useLexicalEditable from "@lexical/react/useLexicalEditable";
|
|
17
|
-
import { useLayoutEffect, useEffect, useState, useMemo, Suspense, useCallback, useRef } from "react";
|
|
18
|
-
import { $canShowPlaceholderCurry } from "@lexical/text";
|
|
19
|
-
import { flushSync, createPortal } from "react-dom";
|
|
20
|
-
import useLexicalSubscription from "@lexical/react/useLexicalSubscription";
|
|
21
|
-
import { createRoot } from "react-dom/client";
|
|
22
12
|
import { HeadingNode, QuoteNode, registerRichText } from "@lexical/rich-text";
|
|
23
13
|
function definePlan(plan) {
|
|
24
14
|
return plan;
|
|
@@ -29,41 +19,6 @@ function defineRootPlan(plan) {
|
|
|
29
19
|
function configPlan(plan, config) {
|
|
30
20
|
return [plan, config];
|
|
31
21
|
}
|
|
32
|
-
function safeCast(value) {
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
const AutoFocusPlan = definePlan({
|
|
36
|
-
config: safeCast({}),
|
|
37
|
-
name: "@etrepum/lexical-builder/AutoFocusPlan",
|
|
38
|
-
register(editor, { defaultSelection }) {
|
|
39
|
-
return editor.registerRootListener((rootElement) => {
|
|
40
|
-
editor.focus(
|
|
41
|
-
() => {
|
|
42
|
-
const activeElement = document.activeElement;
|
|
43
|
-
if (rootElement !== null && (activeElement === null || !rootElement.contains(activeElement))) {
|
|
44
|
-
rootElement.focus({ preventScroll: true });
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
{ defaultSelection }
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const DragonPlan = definePlan({
|
|
53
|
-
config: {},
|
|
54
|
-
name: "@lexical/dragon",
|
|
55
|
-
register: registerDragonSupport
|
|
56
|
-
});
|
|
57
|
-
const HistoryPlan = definePlan({
|
|
58
|
-
config: safeCast({
|
|
59
|
-
createInitialHistoryState: createEmptyHistoryState,
|
|
60
|
-
delay: 300
|
|
61
|
-
}),
|
|
62
|
-
name: "@etrepum/lexical-builder/HistoryPlan",
|
|
63
|
-
register(editor, { delay, createInitialHistoryState }) {
|
|
64
|
-
return registerHistory(editor, createInitialHistoryState(), delay);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
22
|
function invariant(cond, message, ...args) {
|
|
68
23
|
if (cond) {
|
|
69
24
|
return;
|
|
@@ -166,6 +121,19 @@ function buildEditorFromPlans(plan, ...plans) {
|
|
|
166
121
|
}
|
|
167
122
|
return builder.buildEditor();
|
|
168
123
|
}
|
|
124
|
+
class DisposableEditorHandle {
|
|
125
|
+
constructor(editor, dispose) {
|
|
126
|
+
__publicField(this, "editor");
|
|
127
|
+
__publicField(this, "dispose");
|
|
128
|
+
this.editor = editor;
|
|
129
|
+
this.dispose = dispose;
|
|
130
|
+
}
|
|
131
|
+
// This should be safe even if the runtime doesn't have Symbol.dispose
|
|
132
|
+
// because it will just be `handle[undefined] = dispose;`
|
|
133
|
+
[Symbol.dispose]() {
|
|
134
|
+
this.dispose();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
169
137
|
class LexicalBuilder {
|
|
170
138
|
constructor() {
|
|
171
139
|
__publicField(this, "phases");
|
|
@@ -193,11 +161,13 @@ class LexicalBuilder {
|
|
|
193
161
|
});
|
|
194
162
|
initializeEditor(editor, $initialEditorState);
|
|
195
163
|
buildersForEditors.set(editor, this);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
164
|
+
return new DisposableEditorHandle(
|
|
165
|
+
editor,
|
|
166
|
+
mergeRegister(
|
|
167
|
+
() => buildersForEditors.delete(editor),
|
|
168
|
+
this.registerEditor(editor)
|
|
169
|
+
)
|
|
199
170
|
);
|
|
200
|
-
return { dispose, editor };
|
|
201
171
|
}
|
|
202
172
|
addPlan(arg) {
|
|
203
173
|
let plan;
|
|
@@ -376,293 +346,49 @@ class LexicalBuilder {
|
|
|
376
346
|
return config;
|
|
377
347
|
}
|
|
378
348
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
conflictsWith: ["@lexical/rich-text"],
|
|
382
|
-
name: "@lexical/plain-text",
|
|
383
|
-
register: registerPlainText
|
|
384
|
-
});
|
|
385
|
-
function canShowPlaceholderFromCurrentEditorState(editor) {
|
|
386
|
-
const currentCanShowPlaceholder = editor.getEditorState().read($canShowPlaceholderCurry(editor.isComposing()));
|
|
387
|
-
return currentCanShowPlaceholder;
|
|
388
|
-
}
|
|
389
|
-
function subscribe(editor, onChange) {
|
|
390
|
-
const resetCanShowPlaceholder = () => onChange(canShowPlaceholderFromCurrentEditorState(editor));
|
|
391
|
-
return mergeRegister(
|
|
392
|
-
editor.registerUpdateListener(resetCanShowPlaceholder),
|
|
393
|
-
editor.registerEditableListener(resetCanShowPlaceholder)
|
|
394
|
-
);
|
|
349
|
+
function safeCast(value) {
|
|
350
|
+
return value;
|
|
395
351
|
}
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
});
|
|
411
|
-
}, [editor]);
|
|
412
|
-
useEffect(() => {
|
|
413
|
-
setDecorators(editor.getDecorators());
|
|
414
|
-
}, [editor]);
|
|
415
|
-
return useMemo(() => {
|
|
416
|
-
const decoratedPortals = [];
|
|
417
|
-
const decoratorKeys = Object.keys(decorators);
|
|
418
|
-
for (let i = 0; i < decoratorKeys.length; i++) {
|
|
419
|
-
const nodeKey = decoratorKeys[i];
|
|
420
|
-
invariant(
|
|
421
|
-
nodeKey !== void 0,
|
|
422
|
-
"useReactDecorators: decoratorKeys[%s] must be defined",
|
|
423
|
-
String(i)
|
|
352
|
+
const NAME$1 = "@etrepum/lexical-builder/AutoFocusPlan";
|
|
353
|
+
const AutoFocusPlan = definePlan({
|
|
354
|
+
config: safeCast({}),
|
|
355
|
+
name: NAME$1,
|
|
356
|
+
register(editor, { defaultSelection }) {
|
|
357
|
+
return editor.registerRootListener((rootElement) => {
|
|
358
|
+
editor.focus(
|
|
359
|
+
() => {
|
|
360
|
+
const activeElement = document.activeElement;
|
|
361
|
+
if (rootElement !== null && (activeElement === null || !rootElement.contains(activeElement))) {
|
|
362
|
+
rootElement.focus({ preventScroll: true });
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
{ defaultSelection }
|
|
424
366
|
);
|
|
425
|
-
const element = editor.getElementByKey(nodeKey);
|
|
426
|
-
if (element !== null) {
|
|
427
|
-
const reactDecorator = /* @__PURE__ */ jsx(ErrorBoundary, { onError: (e) => editor._onError(e), children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: decorators[nodeKey] }) });
|
|
428
|
-
decoratedPortals.push(createPortal(reactDecorator, element, nodeKey));
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
return decoratedPortals;
|
|
432
|
-
}, [ErrorBoundary, decorators, editor]);
|
|
433
|
-
}
|
|
434
|
-
function useRegisterSubscription(subscription) {
|
|
435
|
-
const sub = useCallback(
|
|
436
|
-
(editor) => {
|
|
437
|
-
return {
|
|
438
|
-
initialValueFn: subscription.initialValueFn.bind(subscription, editor),
|
|
439
|
-
subscribe: subscription.subscribe.bind(subscription, editor)
|
|
440
|
-
};
|
|
441
|
-
},
|
|
442
|
-
[subscription]
|
|
443
|
-
);
|
|
444
|
-
return useLexicalSubscription(sub);
|
|
445
|
-
}
|
|
446
|
-
const scheduleMicrotask = "queueMicrotask" in globalThis ? queueMicrotask : (fn) => Promise.resolve().then(fn);
|
|
447
|
-
function LexicalPlanComposer({
|
|
448
|
-
plan,
|
|
449
|
-
children
|
|
450
|
-
}) {
|
|
451
|
-
const componentRef = useRef(void 0);
|
|
452
|
-
const handle = useMemo(() => {
|
|
453
|
-
return buildEditorFromPlans(
|
|
454
|
-
definePlan({
|
|
455
|
-
name: "@lexical/builder/LexicalPlanComposer",
|
|
456
|
-
config: {},
|
|
457
|
-
dependencies: [ReactPlan],
|
|
458
|
-
register(_editor, _config, state) {
|
|
459
|
-
componentRef.current = state.getDependencyConfig(ReactPlan).Component;
|
|
460
|
-
return () => {
|
|
461
|
-
componentRef.current = void 0;
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
}),
|
|
465
|
-
plan
|
|
466
|
-
);
|
|
467
|
-
}, [plan]);
|
|
468
|
-
useEffect(() => {
|
|
469
|
-
let didMount = false;
|
|
470
|
-
scheduleMicrotask(() => {
|
|
471
|
-
didMount = true;
|
|
472
367
|
});
|
|
473
|
-
return () => {
|
|
474
|
-
if (didMount) {
|
|
475
|
-
handle.dispose();
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
}, [handle]);
|
|
479
|
-
const EditorComponent = componentRef.current;
|
|
480
|
-
return EditorComponent ? /* @__PURE__ */ jsx(EditorComponent, { children }) : null;
|
|
481
|
-
}
|
|
482
|
-
function DefaultEditorChildrenComponent({
|
|
483
|
-
contentEditable,
|
|
484
|
-
placeholder,
|
|
485
|
-
children
|
|
486
|
-
}) {
|
|
487
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
488
|
-
contentEditable,
|
|
489
|
-
placeholder && /* @__PURE__ */ jsx(Placeholder, { content: placeholder }),
|
|
490
|
-
children
|
|
491
|
-
] });
|
|
492
|
-
}
|
|
493
|
-
function buildEditorComponent(config) {
|
|
494
|
-
const context = config.getContext();
|
|
495
|
-
const [editor] = context;
|
|
496
|
-
const rawConfigDecorators = config.decorators.map(
|
|
497
|
-
(El) => typeof El === "function" ? /* @__PURE__ */ jsx(El, { context }) : El
|
|
498
|
-
);
|
|
499
|
-
return function EditorComponent(props) {
|
|
500
|
-
const {
|
|
501
|
-
EditorChildrenComponent = config.EditorChildrenComponent,
|
|
502
|
-
ErrorBoundary = config.ErrorBoundary,
|
|
503
|
-
contentEditable = config.contentEditable,
|
|
504
|
-
placeholder = config.placeholder,
|
|
505
|
-
children
|
|
506
|
-
} = props;
|
|
507
|
-
const decorators = useReactDecorators(editor, ErrorBoundary);
|
|
508
|
-
const configDecorators = useMemo(
|
|
509
|
-
() => rawConfigDecorators.map((decorator, i) => /* @__PURE__ */ jsx(ErrorBoundary, { onError: (e) => editor._onError(e), children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: decorator }) }, i)),
|
|
510
|
-
[ErrorBoundary]
|
|
511
|
-
);
|
|
512
|
-
return /* @__PURE__ */ jsx(LexicalComposerContext.Provider, { value: context, children: /* @__PURE__ */ jsxs(
|
|
513
|
-
EditorChildrenComponent,
|
|
514
|
-
{
|
|
515
|
-
context,
|
|
516
|
-
contentEditable,
|
|
517
|
-
placeholder: placeholder && /* @__PURE__ */ jsx(Placeholder, { content: placeholder }),
|
|
518
|
-
children: [
|
|
519
|
-
children,
|
|
520
|
-
configDecorators,
|
|
521
|
-
decorators
|
|
522
|
-
]
|
|
523
|
-
}
|
|
524
|
-
) });
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
function WithEditable({
|
|
528
|
-
content
|
|
529
|
-
}) {
|
|
530
|
-
return content(useLexicalEditable());
|
|
531
|
-
}
|
|
532
|
-
function Placeholder({
|
|
533
|
-
content
|
|
534
|
-
}) {
|
|
535
|
-
const showPlaceholder = useRegisterSubscription(canShowPlaceholder);
|
|
536
|
-
if (!showPlaceholder) {
|
|
537
|
-
return null;
|
|
538
|
-
} else if (typeof content === "function") {
|
|
539
|
-
return /* @__PURE__ */ jsx(WithEditable, { content });
|
|
540
|
-
} else {
|
|
541
|
-
return content;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
const initialConfig = {
|
|
545
|
-
EditorChildrenComponent: DefaultEditorChildrenComponent,
|
|
546
|
-
ErrorBoundary: LexicalErrorBoundary,
|
|
547
|
-
contentEditable: /* @__PURE__ */ jsx(ContentEditable, {}),
|
|
548
|
-
decorators: [],
|
|
549
|
-
placeholder: null,
|
|
550
|
-
// Initialized on registration
|
|
551
|
-
Component() {
|
|
552
|
-
invariant(false, "ReactPlan used before register");
|
|
553
|
-
},
|
|
554
|
-
// Initialized on registration
|
|
555
|
-
getContext() {
|
|
556
|
-
invariant(false, "ReactPlan used before register");
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
const ReactPlan = definePlan({
|
|
560
|
-
config: initialConfig,
|
|
561
|
-
mergeConfig(a, b) {
|
|
562
|
-
const config = shallowMergeConfig(a, b);
|
|
563
|
-
if (b && b.decorators && b.decorators.length > 0) {
|
|
564
|
-
config.decorators = [...a.decorators, ...b.decorators];
|
|
565
|
-
}
|
|
566
|
-
return config;
|
|
567
|
-
},
|
|
568
|
-
name: "@etrepum/lexical-builder/ReactPlan",
|
|
569
|
-
register(editor, config) {
|
|
570
|
-
const context = [
|
|
571
|
-
editor,
|
|
572
|
-
{ getTheme: () => editor._config.theme }
|
|
573
|
-
];
|
|
574
|
-
config.getContext = () => context;
|
|
575
|
-
config.Component = buildEditorComponent(config);
|
|
576
|
-
return () => {
|
|
577
|
-
config.getContext = initialConfig.getContext;
|
|
578
|
-
config.Component = initialConfig.Component;
|
|
579
|
-
};
|
|
580
368
|
}
|
|
581
369
|
});
|
|
582
|
-
|
|
583
|
-
const { Component, props, ...rest } = opts;
|
|
584
|
-
return mountReactPluginElement(editor, {
|
|
585
|
-
...rest,
|
|
586
|
-
element: Component && props ? /* @__PURE__ */ jsx(Component, { ...props }) : null
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
function mountReactPluginElement(editor, opts) {
|
|
590
|
-
editor.dispatchCommand(REACT_MOUNT_PLUGIN_COMMAND, opts);
|
|
591
|
-
}
|
|
592
|
-
function mountReactPluginHost(editor, container) {
|
|
593
|
-
editor.dispatchCommand(REACT_PLUGIN_HOST_MOUNT_COMMAND, {
|
|
594
|
-
root: createRoot(container)
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
const REACT_PLUGIN_HOST_MOUNT_COMMAND = createCommand("REACT_PLUGIN_HOST_MOUNT_COMMAND");
|
|
598
|
-
const REACT_MOUNT_PLUGIN_COMMAND = createCommand(
|
|
599
|
-
"REACT_MOUNT_PLUGIN_COMMAND"
|
|
600
|
-
);
|
|
601
|
-
const ReactPluginHostPlan = definePlan({
|
|
370
|
+
const DragonPlan = definePlan({
|
|
602
371
|
config: {},
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
for (const { key, element, domNode } of mountedPlugins.values()) {
|
|
616
|
-
if (!element) {
|
|
617
|
-
continue;
|
|
618
|
-
}
|
|
619
|
-
const wrapped = /* @__PURE__ */ jsx(ErrorBoundary, { onError: (e) => editor._onError(e), children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: element }) }, key);
|
|
620
|
-
children.push(domNode ? createPortal(wrapped, domNode, key) : wrapped);
|
|
621
|
-
}
|
|
622
|
-
return children.length > 0 ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
|
|
623
|
-
}
|
|
624
|
-
function PluginHost() {
|
|
625
|
-
const [children, setChildren] = useState(renderMountedPlugins);
|
|
626
|
-
useEffect(() => {
|
|
627
|
-
return editor.registerCommand(
|
|
628
|
-
REACT_MOUNT_PLUGIN_COMMAND,
|
|
629
|
-
() => {
|
|
630
|
-
setChildren(renderMountedPlugins);
|
|
631
|
-
return true;
|
|
632
|
-
},
|
|
633
|
-
COMMAND_PRIORITY_EDITOR
|
|
634
|
-
);
|
|
635
|
-
}, []);
|
|
636
|
-
return children;
|
|
637
|
-
}
|
|
638
|
-
return mergeRegister(
|
|
639
|
-
() => {
|
|
640
|
-
if (root) {
|
|
641
|
-
root.unmount();
|
|
642
|
-
}
|
|
643
|
-
},
|
|
644
|
-
editor.registerCommand(
|
|
645
|
-
REACT_MOUNT_PLUGIN_COMMAND,
|
|
646
|
-
(arg) => {
|
|
647
|
-
mountedPlugins.set(arg.key, arg);
|
|
648
|
-
return false;
|
|
649
|
-
},
|
|
650
|
-
COMMAND_PRIORITY_CRITICAL
|
|
651
|
-
),
|
|
652
|
-
editor.registerCommand(
|
|
653
|
-
REACT_PLUGIN_HOST_MOUNT_COMMAND,
|
|
654
|
-
(arg) => {
|
|
655
|
-
root = arg.root;
|
|
656
|
-
root.render(
|
|
657
|
-
/* @__PURE__ */ jsx(Component, { children: /* @__PURE__ */ jsx(PluginHost, {}) })
|
|
658
|
-
);
|
|
659
|
-
return true;
|
|
660
|
-
},
|
|
661
|
-
COMMAND_PRIORITY_EDITOR
|
|
662
|
-
)
|
|
663
|
-
);
|
|
372
|
+
name: "@lexical/dragon",
|
|
373
|
+
register: registerDragonSupport
|
|
374
|
+
});
|
|
375
|
+
const NAME = "@etrepum/lexical-builder/HistoryPlan";
|
|
376
|
+
const HistoryPlan = definePlan({
|
|
377
|
+
config: safeCast({
|
|
378
|
+
createInitialHistoryState: createEmptyHistoryState,
|
|
379
|
+
delay: 300
|
|
380
|
+
}),
|
|
381
|
+
name: NAME,
|
|
382
|
+
register(editor, { delay, createInitialHistoryState }) {
|
|
383
|
+
return registerHistory(editor, createInitialHistoryState(), delay);
|
|
664
384
|
}
|
|
665
385
|
});
|
|
386
|
+
const PlainTextPlan = definePlan({
|
|
387
|
+
config: {},
|
|
388
|
+
conflictsWith: ["@lexical/rich-text"],
|
|
389
|
+
name: "@lexical/plain-text",
|
|
390
|
+
register: registerPlainText
|
|
391
|
+
});
|
|
666
392
|
const RichTextPlan = definePlan({
|
|
667
393
|
config: {},
|
|
668
394
|
conflictsWith: ["@lexical/plain-text"],
|
|
@@ -670,27 +396,20 @@ const RichTextPlan = definePlan({
|
|
|
670
396
|
nodes: [HeadingNode, QuoteNode],
|
|
671
397
|
register: registerRichText
|
|
672
398
|
});
|
|
673
|
-
const PACKAGE_VERSION = "0.0.
|
|
399
|
+
const PACKAGE_VERSION = "0.0.7";
|
|
674
400
|
export {
|
|
675
401
|
AutoFocusPlan,
|
|
676
402
|
DragonPlan,
|
|
677
403
|
HistoryPlan,
|
|
678
404
|
LexicalBuilder,
|
|
679
|
-
LexicalPlanComposer,
|
|
680
405
|
PACKAGE_VERSION,
|
|
681
406
|
PlainTextPlan,
|
|
682
|
-
REACT_MOUNT_PLUGIN_COMMAND,
|
|
683
|
-
REACT_PLUGIN_HOST_MOUNT_COMMAND,
|
|
684
|
-
ReactPlan,
|
|
685
|
-
ReactPluginHostPlan,
|
|
686
407
|
RichTextPlan,
|
|
687
408
|
buildEditorFromPlans,
|
|
688
409
|
configPlan,
|
|
689
410
|
definePlan,
|
|
690
411
|
defineRootPlan,
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
mountReactPluginHost,
|
|
694
|
-
safeCast
|
|
412
|
+
safeCast,
|
|
413
|
+
shallowMergeConfig
|
|
695
414
|
};
|
|
696
415
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/definePlan.ts","../src/safeCast.ts","../src/AutoFocusPlan.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/initializeEditor.ts","../src/shallowMergeConfig.ts","../src/PlanRep.ts","../src/LexicalBuilder.ts","../src/PlainTextPlan.ts","../src/registerShowPlaceholder.ts","../src/shared/useLayoutEffect.ts","../src/useReactDecorators.tsx","../src/useRegisterSubscription.ts","../src/ReactPlan.tsx","../src/ReactPluginHostPlan.tsx","../src/RichTextPlan.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {\n AnyLexicalPlan,\n LexicalPlan,\n LexicalPlanConfig,\n PlanConfigBase,\n} from \"./types\";\n\nexport function definePlan<Config extends PlanConfigBase, Name extends string>(\n plan: LexicalPlan<Config, Name>,\n): LexicalPlan<Config, Name> {\n return plan;\n}\n\nexport function defineRootPlan(\n plan: Omit<LexicalPlan<PlanConfigBase, string>, \"config\" | \"name\">,\n): LexicalPlan<PlanConfigBase, \"[root]\"> {\n return { ...plan, name: \"[root]\", config: {} };\n}\n\nexport function configPlan<Plan extends AnyLexicalPlan>(\n plan: Plan,\n config: Partial<LexicalPlanConfig<Plan>>,\n): [Plan, Partial<LexicalPlanConfig<Plan>>] {\n return [plan, config];\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// TypeScript 4.9's satisfies operator is not supported by our version of prettier\nexport function safeCast<T>(value: T): T {\n return value;\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 } from \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nexport interface AutoFocusConfig {\n defaultSelection?: \"rootStart\" | \"rootEnd\";\n}\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 \"./definePlan\";\n\nexport const DragonPlan = definePlan({\n config: {},\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 \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nexport interface HistoryConfig {\n delay: number;\n createInitialHistoryState: () => HistoryState;\n}\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 */\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\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 \"./types\";\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 */\nimport type { PlanConfigBase } from \"./types\";\n\nexport function shallowMergeConfig<T extends PlanConfigBase>(\n a: T,\n b?: Partial<T>,\n): T {\n if (!b || a === b) {\n return a;\n }\n for (const k in b) {\n if (b[k] !== a[k]) {\n return { ...a, ...b };\n }\n }\n return a;\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 LexicalPlanConfig,\n} from \"./types\";\nimport type { LexicalPlanRegistry } from \"@etrepum/lexical-builder\";\n\nimport invariant from \"./shared/invariant\";\n\nimport { shallowMergeConfig } from \"./shallowMergeConfig\";\n\nexport class PlanRep<Plan extends AnyLexicalPlan> {\n builder: LexicalBuilder;\n configs: Set<LexicalPlanConfig<Plan>>;\n _config?: LexicalPlanConfig<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 getPeerConfig<Name extends keyof LexicalPlanRegistry>(\n name: string,\n ): undefined | LexicalPlanConfig<LexicalPlanRegistry[Name]> {\n const rep = this.builder.planNameMap.get(name);\n return rep && rep.getConfig();\n }\n getDependencyConfig<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): LexicalPlanConfig<Dependency> {\n const pair = this.builder.planMap.get(dep);\n invariant(\n pair !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return pair[1].getConfig();\n }\n getConfig(): LexicalPlanConfig<Plan> {\n if (this._config) {\n return this._config;\n }\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}\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} from \"./types\";\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\";\n\nconst buildersForEditors = new WeakMap<LexicalEditor, LexicalBuilder>();\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 */\nexport class LexicalBuilder {\n phases: Map<AnyLexicalPlan, PlanRep<AnyLexicalPlan>>[];\n planMap: Map<AnyLexicalPlan, [number, PlanRep<AnyLexicalPlan>]>;\n planNameMap: Map<string, PlanRep<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 }\n\n static fromEditor(editor: LexicalEditor): LexicalBuilder {\n const builder = buildersForEditors.get(editor);\n invariant(\n builder !== undefined,\n \"LexicalBuilder.fromEditor: editor was not created with this version of LexicalBuilder\",\n );\n return builder;\n }\n\n buildEditor(): EditorHandle {\n const { $initialEditorState, onError, ...editorConfig } =\n this.buildCreateEditorArgs();\n const editor = createEditor({\n ...editorConfig,\n ...(onError ? { onError: (err) => onError(err, editor) } : {}),\n });\n initializeEditor(editor, $initialEditorState);\n buildersForEditors.set(editor, this);\n const dispose = mergeRegister(\n () => buildersForEditors.delete(editor),\n this.registerEditor(editor),\n );\n return { dispose, editor };\n }\n\n addPlan(arg: AnyLexicalPlanArgument): 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 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 // TODO detect circular dependencies\n for (const dep of plan.dependencies || []) {\n phase = Math.max(phase, 1 + this.addPlan(dep));\n }\n for (const [depName, cfg] of Object.entries(\n plan.peerDependencies || {},\n )) {\n const dep = this.planNameMap.get(depName);\n if (dep) {\n phase = Math.max(phase, 1 + this.addPlan([dep.plan, cfg]));\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 }\n for (const config of configs) {\n planRep.configs.add(config);\n }\n return phase;\n }\n\n *sortedPlanReps() {\n for (const phase of this.phases) {\n yield* phase.values();\n }\n }\n\n registerEditor(editor: LexicalEditor): () => void {\n const cleanups: (() => void)[] = [];\n const controller = new AbortController();\n for (const planRep of this.sortedPlanReps()) {\n if (planRep.plan.register) {\n cleanups.push(\n planRep.plan.register(editor, planRep.getConfig(), {\n getDependencyConfig: planRep.getDependencyConfig.bind(planRep),\n getPeerConfig: planRep.getPeerConfig.bind(planRep),\n signal: controller.signal,\n }),\n );\n }\n }\n return () => {\n for (let i = cleanups.length - 1; i >= 0; i--) {\n const cleanupFun = cleanups[i];\n invariant(\n cleanupFun !== undefined,\n \"LexicalBuilder: Expecting cleanups[%s] to be defined\",\n String(i),\n );\n cleanupFun();\n }\n cleanups.length = 0;\n controller.abort();\n };\n }\n\n buildCreateEditorArgs() {\n const config: Pick<\n CreateEditorArgs,\n \"nodes\" | \"html\" | \"theme\" | \"disableEvents\" | \"editable\" | \"namespace\"\n > &\n Pick<AnyLexicalPlan, \"$initialEditorState\" | \"onError\"> = {};\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 for (const planRep of this.sortedPlanReps()) {\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { registerPlainText } from \"@lexical/plain-text\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const PlainTextPlan = definePlan({\n config: {},\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 type { LexicalEditor } from \"lexical\";\n\nimport { $canShowPlaceholderCurry } from \"@lexical/text\";\nimport { mergeRegister } from \"@lexical/utils\";\n\nimport {\n RegisterLexicalSubscription,\n registerLexicalSubscription,\n} from \"./registerSubscription\";\n\nfunction canShowPlaceholderFromCurrentEditorState(\n editor: LexicalEditor,\n): boolean {\n const currentCanShowPlaceholder = editor\n .getEditorState()\n .read($canShowPlaceholderCurry(editor.isComposing()));\n\n return currentCanShowPlaceholder;\n}\n\nfunction subscribe(\n editor: LexicalEditor,\n onChange: (canShow: boolean) => void,\n) {\n const resetCanShowPlaceholder = () =>\n onChange(canShowPlaceholderFromCurrentEditorState(editor));\n return mergeRegister(\n editor.registerUpdateListener(resetCanShowPlaceholder),\n editor.registerEditableListener(resetCanShowPlaceholder),\n );\n}\n\nexport const canShowPlaceholder: RegisterLexicalSubscription<boolean> = {\n initialValueFn: canShowPlaceholderFromCurrentEditorState,\n subscribe,\n};\n\nexport function registerCanShowPlaceholder(\n editor: LexicalEditor,\n onChange: (canShow: boolean) => void,\n): () => void {\n return registerLexicalSubscription(editor, canShowPlaceholder, onChange);\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 { useEffect, useLayoutEffect } from \"react\";\nimport { CAN_USE_DOM } from \"@lexical/utils\";\n\nconst useLayoutEffectImpl: typeof useLayoutEffect = CAN_USE_DOM\n ? useLayoutEffect\n : useEffect;\n\nexport default useLayoutEffectImpl;\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 { LexicalEditor, NodeKey } from \"lexical\";\n\nimport { Suspense, useEffect, useMemo, useState } from \"react\";\nimport * as React from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport useLayoutEffect from \"./shared/useLayoutEffect\";\nimport invariant from \"./shared/invariant\";\n\nexport type ErrorBoundaryProps = {\n children: JSX.Element;\n onError: (error: Error) => void;\n};\n\nexport type ErrorBoundaryType =\n | React.ComponentClass<ErrorBoundaryProps>\n | React.FC<ErrorBoundaryProps>;\n\nexport function useReactDecorators(\n editor: LexicalEditor,\n ErrorBoundary: ErrorBoundaryType,\n): Array<JSX.Element> {\n const [decorators, setDecorators] = useState<Record<NodeKey, JSX.Element>>(\n () => editor.getDecorators<JSX.Element>(),\n );\n\n // Subscribe to changes\n useLayoutEffect(() => {\n return editor.registerDecoratorListener<JSX.Element>((nextDecorators) => {\n flushSync(() => {\n setDecorators(nextDecorators);\n });\n });\n }, [editor]);\n\n useEffect(() => {\n // If the content editable mounts before the subscription is added, then\n // nothing will be rendered on initial pass. We can get around that by\n // ensuring that we set the value.\n setDecorators(editor.getDecorators());\n }, [editor]);\n\n // Return decorators defined as React Portals\n return useMemo(() => {\n const decoratedPortals = [];\n const decoratorKeys = Object.keys(decorators);\n\n for (let i = 0; i < decoratorKeys.length; i++) {\n const nodeKey = decoratorKeys[i];\n invariant(\n nodeKey !== undefined,\n \"useReactDecorators: decoratorKeys[%s] must be defined\",\n String(i),\n );\n const element = editor.getElementByKey(nodeKey);\n\n if (element !== null) {\n const reactDecorator = (\n <ErrorBoundary onError={(e) => editor._onError(e)}>\n <Suspense fallback={null}>{decorators[nodeKey]}</Suspense>\n </ErrorBoundary>\n );\n decoratedPortals.push(createPortal(reactDecorator, element, nodeKey));\n }\n }\n\n return decoratedPortals;\n }, [ErrorBoundary, decorators, editor]);\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 { RegisterLexicalSubscription } from \"./registerSubscription\";\n\nimport useLexicalSubscription from \"@lexical/react/useLexicalSubscription\";\nimport { LexicalEditor } from \"lexical\";\nimport { useCallback } from \"react\";\n\nexport function useRegisterSubscription<T>(\n subscription: RegisterLexicalSubscription<T>,\n): T {\n const sub = useCallback(\n (editor: LexicalEditor) => {\n return {\n initialValueFn: subscription.initialValueFn.bind(subscription, editor),\n subscribe: subscription.subscribe.bind(subscription, editor),\n };\n },\n [subscription],\n );\n return useLexicalSubscription(sub);\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 { AnyLexicalPlanArgument } from \"./types\";\n\nimport {\n LexicalComposerContext,\n type LexicalComposerContextWithEditor,\n} from \"@lexical/react/LexicalComposerContext\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport useLexicalEditable from \"@lexical/react/useLexicalEditable\";\nimport * as React from \"react\";\nimport { Suspense, useEffect, useMemo, useRef } from \"react\";\n\nimport { definePlan } from \"./definePlan\";\nimport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nimport { canShowPlaceholder } from \"./registerShowPlaceholder\";\nimport { shallowMergeConfig } from \"./shallowMergeConfig\";\nimport {\n type ErrorBoundaryType,\n useReactDecorators,\n} from \"./useReactDecorators\";\nimport { useRegisterSubscription } from \"./useRegisterSubscription\";\nimport invariant from \"./shared/invariant\";\n\nexport interface EditorChildrenComponentProps {\n context: LexicalComposerContextWithEditor;\n placeholder: null | JSX.Element;\n contentEditable: null | JSX.Element;\n children?: React.ReactNode;\n}\n\nexport type EditorChildrenComponentType = (\n props: EditorChildrenComponentProps,\n) => JSX.Element | null;\n\nexport interface DecoratorComponentProps {\n context: LexicalComposerContextWithEditor;\n}\nexport type DecoratorComponentType =\n | JSX.Element\n | ((props: DecoratorComponentProps) => JSX.Element | null);\n\nexport interface EditorComponentProps {\n EditorChildrenComponent: EditorChildrenComponentType;\n children?: React.ReactNode;\n placeholder:\n | ((isEditable: boolean) => null | JSX.Element)\n | null\n | JSX.Element;\n contentEditable: JSX.Element | null;\n ErrorBoundary: ErrorBoundaryType;\n}\n\nexport type EditorComponentType = (\n props: Partial<EditorComponentProps>,\n) => JSX.Element;\n\nexport interface ReactConfig {\n contentEditable: JSX.Element | null;\n placeholder:\n | ((isEditable: boolean) => null | JSX.Element)\n | null\n | JSX.Element;\n ErrorBoundary: ErrorBoundaryType;\n EditorChildrenComponent: EditorChildrenComponentType;\n Component: EditorComponentType;\n getContext: () => LexicalComposerContextWithEditor;\n decorators: readonly DecoratorComponentType[];\n}\n\nexport interface LexicalPlanComposerProps {\n plan: AnyLexicalPlanArgument;\n children: React.ReactNode;\n}\n\nconst scheduleMicrotask =\n \"queueMicrotask\" in globalThis\n ? queueMicrotask\n : (fn: () => void) => Promise.resolve().then(fn);\n\nexport function LexicalPlanComposer({\n plan,\n children,\n}: LexicalPlanComposerProps) {\n const componentRef = useRef<EditorComponentType | undefined>(undefined);\n const handle = useMemo(() => {\n return buildEditorFromPlans(\n definePlan({\n name: \"@lexical/builder/LexicalPlanComposer\",\n config: {},\n dependencies: [ReactPlan],\n register(_editor, _config, state) {\n componentRef.current = state.getDependencyConfig(ReactPlan).Component;\n return () => {\n componentRef.current = undefined;\n };\n },\n }),\n plan,\n );\n }, [plan]);\n useEffect(() => {\n // This is an awful trick to detect StrictMode\n let didMount = false;\n scheduleMicrotask(() => {\n didMount = true;\n });\n return () => {\n if (didMount) {\n handle.dispose();\n }\n };\n }, [handle]);\n const EditorComponent = componentRef.current;\n return EditorComponent ? <EditorComponent>{children}</EditorComponent> : null;\n}\n\nfunction DefaultEditorChildrenComponent({\n contentEditable,\n placeholder,\n children,\n}: EditorChildrenComponentProps) {\n return (\n <>\n {contentEditable}\n {placeholder && <Placeholder content={placeholder} />}\n {children}\n </>\n );\n}\n\nfunction buildEditorComponent(config: ReactConfig) {\n const context = config.getContext();\n const [editor] = context;\n const rawConfigDecorators = config.decorators.map((El) =>\n typeof El === \"function\" ? <El context={context} /> : El,\n );\n return function EditorComponent(props: Partial<EditorComponentProps>) {\n const {\n EditorChildrenComponent = config.EditorChildrenComponent,\n ErrorBoundary = config.ErrorBoundary,\n contentEditable = config.contentEditable,\n placeholder = config.placeholder,\n children,\n } = props;\n const decorators = useReactDecorators(editor, ErrorBoundary);\n const configDecorators = useMemo(\n () =>\n rawConfigDecorators.map((decorator, i) => (\n <ErrorBoundary onError={(e) => editor._onError(e)} key={i}>\n <Suspense fallback={null}>{decorator}</Suspense>\n </ErrorBoundary>\n )),\n [ErrorBoundary],\n );\n return (\n <LexicalComposerContext.Provider value={context}>\n <EditorChildrenComponent\n context={context}\n contentEditable={contentEditable}\n placeholder={placeholder && <Placeholder content={placeholder} />}\n >\n {children}\n {configDecorators}\n {decorators}\n </EditorChildrenComponent>\n </LexicalComposerContext.Provider>\n );\n };\n}\n\nfunction WithEditable({\n content,\n}: {\n content: (isEditable: boolean) => null | JSX.Element;\n}) {\n return content(useLexicalEditable());\n}\n\nfunction Placeholder({\n content,\n}: {\n content: ((isEditable: boolean) => null | JSX.Element) | JSX.Element;\n}): null | JSX.Element {\n const showPlaceholder = useRegisterSubscription(canShowPlaceholder);\n if (!showPlaceholder) {\n return null;\n } else if (typeof content === \"function\") {\n return <WithEditable content={content} />;\n } else {\n return content;\n }\n}\n\nconst initialConfig: ReactConfig = {\n EditorChildrenComponent: DefaultEditorChildrenComponent,\n ErrorBoundary: LexicalErrorBoundary,\n contentEditable: <ContentEditable />,\n decorators: [],\n placeholder: null,\n // Initialized on registration\n Component(): JSX.Element {\n invariant(false, \"ReactPlan used before register\");\n },\n // Initialized on registration\n getContext() {\n invariant(false, \"ReactPlan used before register\");\n },\n};\n\nexport const ReactPlan = definePlan({\n config: initialConfig,\n mergeConfig(a, b) {\n const config = shallowMergeConfig(a, b);\n if (b && b.decorators && b.decorators.length > 0) {\n config.decorators = [...a.decorators, ...b.decorators];\n }\n return config;\n },\n name: \"@etrepum/lexical-builder/ReactPlan\",\n register(editor, config) {\n const context: LexicalComposerContextWithEditor = [\n editor,\n { getTheme: () => editor._config.theme },\n ];\n config.getContext = () => context;\n config.Component = buildEditorComponent(config);\n return () => {\n config.getContext = initialConfig.getContext;\n config.Component = initialConfig.Component;\n };\n },\n});\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { mergeRegister } from \"@lexical/utils\";\nimport {\n COMMAND_PRIORITY_CRITICAL,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n LexicalEditor,\n} from \"lexical\";\nimport { Suspense, useEffect, useState } from \"react\";\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { createRoot, Root } from \"react-dom/client\";\n\nimport { configPlan, definePlan } from \"./definePlan\";\nimport { ReactPlan } from \"./ReactPlan\";\n\nexport interface HostMountCommandArg {\n root: Root;\n}\n\nexport type Container = Element | DocumentFragment;\n\nexport interface MountPluginCommandArg {\n key: string;\n element: JSX.Element | null;\n domNode?: Container | null;\n}\n\nexport function mountReactPluginComponent<\n P extends Record<never, never> = Record<never, never>,\n>(\n editor: LexicalEditor,\n opts: {\n Component: null | React.ComponentType<P>;\n props: (P & React.Attributes) | null;\n } & Omit<MountPluginCommandArg, \"element\">,\n) {\n const { Component, props, ...rest } = opts;\n return mountReactPluginElement(editor, {\n ...rest,\n element: Component && props ? <Component {...props} /> : null,\n });\n}\n\nexport function mountReactPluginElement(\n editor: LexicalEditor,\n opts: MountPluginCommandArg,\n) {\n editor.dispatchCommand(REACT_MOUNT_PLUGIN_COMMAND, opts);\n}\n\nexport function mountReactPluginHost(\n editor: LexicalEditor,\n container: Container,\n) {\n editor.dispatchCommand(REACT_PLUGIN_HOST_MOUNT_COMMAND, {\n root: createRoot(container),\n });\n}\n\nexport const REACT_PLUGIN_HOST_MOUNT_COMMAND =\n createCommand<HostMountCommandArg>(\"REACT_PLUGIN_HOST_MOUNT_COMMAND\");\nexport const REACT_MOUNT_PLUGIN_COMMAND = createCommand<MountPluginCommandArg>(\n \"REACT_MOUNT_PLUGIN_COMMAND\",\n);\n\nexport const ReactPluginHostPlan = definePlan({\n config: {},\n dependencies: [\n configPlan(ReactPlan, {\n contentEditable: null,\n }),\n ],\n name: \"@etrepum/lexical-builder/ReactPluginHostPlan\",\n register(editor, _config, state) {\n let root: Root | undefined;\n const mountedPlugins = new Map<\n MountPluginCommandArg[\"key\"],\n MountPluginCommandArg\n >();\n const { ErrorBoundary, Component } = state.getDependencyConfig(ReactPlan);\n function renderMountedPlugins() {\n const children: JSX.Element[] = [];\n for (const { key, element, domNode } of mountedPlugins.values()) {\n if (!element) {\n continue;\n }\n const wrapped = (\n <ErrorBoundary onError={(e) => editor._onError(e)} key={key}>\n <Suspense fallback={null}>{element}</Suspense>\n </ErrorBoundary>\n );\n children.push(domNode ? createPortal(wrapped, domNode, key) : wrapped);\n }\n return children.length > 0 ? <>{children}</> : null;\n }\n function PluginHost() {\n const [children, setChildren] = useState(renderMountedPlugins);\n useEffect(() => {\n return editor.registerCommand(\n REACT_MOUNT_PLUGIN_COMMAND,\n () => {\n setChildren(renderMountedPlugins);\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\n );\n }, []);\n return children;\n }\n return mergeRegister(\n () => {\n if (root) {\n root.unmount();\n }\n },\n editor.registerCommand(\n REACT_MOUNT_PLUGIN_COMMAND,\n (arg) => {\n mountedPlugins.set(arg.key, arg);\n return false;\n },\n COMMAND_PRIORITY_CRITICAL,\n ),\n editor.registerCommand(\n REACT_PLUGIN_HOST_MOUNT_COMMAND,\n (arg) => {\n root = arg.root;\n root.render(\n <Component>\n <PluginHost />\n </Component>,\n );\n return true;\n },\n COMMAND_PRIORITY_EDITOR,\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 { HeadingNode, QuoteNode, registerRichText } from \"@lexical/rich-text\";\n\nimport { definePlan } from \"./definePlan\";\n\nexport const RichTextPlan = definePlan({\n config: {},\n conflictsWith: [\"@lexical/plain-text\"],\n name: \"@lexical/rich-text\",\n nodes: [HeadingNode, QuoteNode],\n register: registerRichText,\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/** An open interface for Name -> Config mappings */\nexport interface LexicalPlanRegistry {}\nexport const PACKAGE_VERSION = import.meta.env.PACKAGE_VERSION;\n\nexport { type AutoFocusConfig, AutoFocusPlan } from \"./AutoFocusPlan\";\nexport { configPlan, definePlan, defineRootPlan } from \"./definePlan\";\nexport { DragonPlan } from \"./DragonPlan\";\nexport { type HistoryConfig, HistoryPlan } from \"./HistoryPlan\";\nexport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nexport { PlainTextPlan } from \"./PlainTextPlan\";\nexport {\n type DecoratorComponentProps,\n type DecoratorComponentType,\n type EditorChildrenComponentProps,\n type EditorChildrenComponentType,\n type EditorComponentProps,\n type EditorComponentType,\n LexicalPlanComposer,\n type LexicalPlanComposerProps,\n type ReactConfig,\n ReactPlan,\n} from \"./ReactPlan\";\nexport {\n type HostMountCommandArg,\n type MountPluginCommandArg,\n type Container,\n mountReactPluginComponent,\n mountReactPluginElement,\n mountReactPluginHost,\n REACT_MOUNT_PLUGIN_COMMAND,\n REACT_PLUGIN_HOST_MOUNT_COMMAND,\n ReactPluginHostPlan,\n} from \"./ReactPluginHostPlan\";\nexport { RichTextPlan } from \"./RichTextPlan\";\nexport {\n type AnyLexicalPlan,\n type AnyLexicalPlanArgument,\n type EditorHandle,\n type InitialEditorStateType,\n type LexicalPeerConfig,\n type LexicalPlan,\n type LexicalPlanArgument,\n type LexicalPlanConfig,\n type LexicalPlanName,\n type NormalizedLexicalPlanArgument,\n type PlanConfigBase,\n type RegisterState,\n} from \"./types\";\nexport {\n type ErrorBoundaryType,\n type ErrorBoundaryProps,\n} from \"./useReactDecorators\";\nexport { safeCast } from \"./safeCast\";\n"],"names":["useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,WACd,MAC2B;AACpB,SAAA;AACT;AAEO,SAAS,eACd,MACuC;AACvC,SAAO,EAAE,GAAG,MAAM,MAAM,UAAU,QAAQ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lan.ts","../src/shared/invariant.ts","../src/deepThemeMergeInPlace.ts","../src/initializeEditor.ts","../src/shallowMergeConfig.ts","../src/PlanRep.ts","../src/LexicalBuilder.ts","../src/safeCast.ts","../src/AutoFocusPlan.ts","../src/DragonPlan.ts","../src/HistoryPlan.ts","../src/PlainTextPlan.ts","../src/RichTextPlan.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {\n AnyLexicalPlan,\n LexicalPlan,\n LexicalPlanConfig,\n PlanConfigBase,\n} from \"./types\";\n\nexport function definePlan<Config extends PlanConfigBase, Name extends string>(\n plan: LexicalPlan<Config, Name>,\n): LexicalPlan<Config, Name> {\n return plan;\n}\n\nexport function defineRootPlan(\n plan: Omit<LexicalPlan<PlanConfigBase, string>, \"config\" | \"name\">,\n): LexicalPlan<PlanConfigBase, \"[root]\"> {\n return { ...plan, name: \"[root]\", config: {} };\n}\n\nexport function configPlan<Plan extends AnyLexicalPlan>(\n plan: Plan,\n config: Partial<LexicalPlanConfig<Plan>>,\n): [Plan, Partial<LexicalPlanConfig<Plan>>] {\n return [plan, config];\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// 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\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 \"./types\";\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 */\nimport type { PlanConfigBase } from \"./types\";\n\nexport function shallowMergeConfig<T extends PlanConfigBase>(\n a: T,\n b?: Partial<T>,\n): T {\n if (!b || a === b) {\n return a;\n }\n for (const k in b) {\n if (b[k] !== a[k]) {\n return { ...a, ...b };\n }\n }\n return a;\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 { AnyLexicalPlan, LexicalPlanConfig } from \"./types\";\nimport type { LexicalPlanRegistry } from \"./\";\n\nimport invariant from \"./shared/invariant\";\n\nimport { shallowMergeConfig } from \"./shallowMergeConfig\";\n\nexport class PlanRep<Plan extends AnyLexicalPlan> {\n builder: LexicalBuilder;\n configs: Set<LexicalPlanConfig<Plan>>;\n _config?: LexicalPlanConfig<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 getPeerConfig<Name extends keyof LexicalPlanRegistry>(\n name: string,\n ): undefined | LexicalPlanConfig<LexicalPlanRegistry[Name]> {\n const rep = this.builder.planNameMap.get(name);\n return rep && rep.getConfig();\n }\n getDependencyConfig<Dependency extends AnyLexicalPlan>(\n dep: Dependency,\n ): LexicalPlanConfig<Dependency> {\n const pair = this.builder.planMap.get(dep);\n invariant(\n pair !== undefined,\n \"LexicalPlanBuilder: Plan %s missing dependency plan %s to be in registry\",\n this.plan.name,\n dep.name,\n );\n return pair[1].getConfig();\n }\n getConfig(): LexicalPlanConfig<Plan> {\n if (this._config) {\n return this._config;\n }\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}\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} from \"./types\";\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\";\n\nconst buildersForEditors = new WeakMap<LexicalEditor, LexicalBuilder>();\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\nclass DisposableEditorHandle implements EditorHandle {\n editor: LexicalEditor;\n dispose: () => void;\n constructor(editor: LexicalEditor, dispose: () => void) {\n this.editor = editor;\n this.dispose = dispose;\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/** @internal */\nexport class LexicalBuilder {\n phases: Map<AnyLexicalPlan, PlanRep<AnyLexicalPlan>>[];\n planMap: Map<AnyLexicalPlan, [number, PlanRep<AnyLexicalPlan>]>;\n planNameMap: Map<string, PlanRep<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 }\n\n static fromEditor(editor: LexicalEditor): LexicalBuilder {\n const builder = buildersForEditors.get(editor);\n invariant(\n builder !== undefined,\n \"LexicalBuilder.fromEditor: editor was not created with this version of LexicalBuilder\",\n );\n return builder;\n }\n\n buildEditor(): EditorHandle {\n const { $initialEditorState, onError, ...editorConfig } =\n this.buildCreateEditorArgs();\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 this.registerEditor(editor),\n ),\n );\n }\n\n addPlan(arg: AnyLexicalPlanArgument): 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 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 // TODO detect circular dependencies\n for (const dep of plan.dependencies || []) {\n phase = Math.max(phase, 1 + this.addPlan(dep));\n }\n for (const [depName, cfg] of Object.entries(\n plan.peerDependencies || {},\n )) {\n const dep = this.planNameMap.get(depName);\n if (dep) {\n phase = Math.max(phase, 1 + this.addPlan([dep.plan, cfg]));\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 }\n for (const config of configs) {\n planRep.configs.add(config);\n }\n return phase;\n }\n\n *sortedPlanReps() {\n for (const phase of this.phases) {\n yield* phase.values();\n }\n }\n\n registerEditor(editor: LexicalEditor): () => void {\n const cleanups: (() => void)[] = [];\n const controller = new AbortController();\n for (const planRep of this.sortedPlanReps()) {\n if (planRep.plan.register) {\n cleanups.push(\n planRep.plan.register(editor, planRep.getConfig(), {\n getDependencyConfig: planRep.getDependencyConfig.bind(planRep),\n getPeerConfig: planRep.getPeerConfig.bind(planRep),\n signal: controller.signal,\n }),\n );\n }\n }\n return () => {\n for (let i = cleanups.length - 1; i >= 0; i--) {\n const cleanupFun = cleanups[i];\n invariant(\n cleanupFun !== undefined,\n \"LexicalBuilder: Expecting cleanups[%s] to be defined\",\n String(i),\n );\n cleanupFun();\n }\n cleanups.length = 0;\n controller.abort();\n };\n }\n\n buildCreateEditorArgs() {\n const config: Pick<\n CreateEditorArgs,\n \"nodes\" | \"html\" | \"theme\" | \"disableEvents\" | \"editable\" | \"namespace\"\n > &\n Pick<AnyLexicalPlan, \"$initialEditorState\" | \"onError\"> = {};\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 for (const planRep of this.sortedPlanReps()) {\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 return config;\n }\n}\n","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n/**\n * Explicitly and safely cast a value to a specific type when inference or\n * satisfies isn't going to work as expected (often useful for the config\n * property with definePlan)\n */\nexport function safeCast<T>(value: T): T {\n return value;\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 } from \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nconst NAME = \"@etrepum/lexical-builder/AutoFocusPlan\";\ndeclare module \"@etrepum/lexical-builder\" {\n interface LexicalPlanRegistry {\n [NAME]: typeof AutoFocusPlan;\n }\n}\n\nexport interface AutoFocusConfig {\n defaultSelection?: \"rootStart\" | \"rootEnd\";\n}\n\nexport const AutoFocusPlan = definePlan({\n config: safeCast<AutoFocusConfig>({}),\n name: NAME,\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 \"./definePlan\";\n\nexport const DragonPlan = definePlan({\n config: {},\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 \"./definePlan\";\nimport { safeCast } from \"./safeCast\";\n\nconst NAME = \"@etrepum/lexical-builder/HistoryPlan\";\ndeclare module \"@etrepum/lexical-builder\" {\n interface LexicalPlanRegistry {\n [NAME]: typeof HistoryPlan;\n }\n}\n\nexport interface HistoryConfig {\n delay: number;\n createInitialHistoryState: () => HistoryState;\n}\n\nexport const HistoryPlan = definePlan({\n config: safeCast<HistoryConfig>({\n createInitialHistoryState: createEmptyHistoryState,\n delay: 300,\n }),\n name: NAME,\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 \"./definePlan\";\n\nexport const PlainTextPlan = definePlan({\n config: {},\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 \"./definePlan\";\n\nexport const RichTextPlan = definePlan({\n config: {},\n conflictsWith: [\"@lexical/plain-text\"],\n name: \"@lexical/rich-text\",\n nodes: [HeadingNode, QuoteNode],\n register: registerRichText,\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 * An open interface for Name -> Config mappings. If you are defining a\n * plan with non-empty config and it may be used as a peerDependency then\n * you should extend this as follows:\n *\n * @example Extending LexicalPlanRegistry\n * ```ts\n * const NAME = \"@some/plan\";\n * export const SomePlan = definePlan({ name: NAME, config: { className: \"default\" } });\n * declare module '@etrepum/lexical-builder' {\n * interface LexicalPlanRegistry {\n * [NAME]: typeof SomePlan;\n * }\n * }\n * ```\n */\nexport interface LexicalPlanRegistry {}\nexport const PACKAGE_VERSION = import.meta.env.PACKAGE_VERSION;\n\nexport { configPlan, definePlan, defineRootPlan } from \"./definePlan\";\nexport { LexicalBuilder, buildEditorFromPlans } from \"./LexicalBuilder\";\nexport {\n type AnyLexicalPlan,\n type AnyLexicalPlanArgument,\n type EditorHandle,\n type InitialEditorStateType,\n type LexicalPeerConfig,\n type LexicalPlan,\n type LexicalPlanArgument,\n type LexicalPlanConfig,\n type LexicalPlanName,\n type NormalizedLexicalPlanArgument,\n type PlanConfigBase,\n type RegisterState,\n} from \"./types\";\nexport { safeCast } from \"./safeCast\";\nexport { shallowMergeConfig } from \"./shallowMergeConfig\";\n// These plan definitions should all be colocated with their implementations, only here for convenience\nexport { type AutoFocusConfig, AutoFocusPlan } from \"./AutoFocusPlan\";\nexport { DragonPlan } from \"./DragonPlan\";\nexport { type HistoryConfig, HistoryPlan } from \"./HistoryPlan\";\nexport { PlainTextPlan } from \"./PlainTextPlan\";\nexport { RichTextPlan } from \"./RichTextPlan\";\n"],"names":["NAME"],"mappings":";;;;;;;;;;;;AAeO,SAAS,WACd,MAC2B;AACpB,SAAA;AACT;AAEO,S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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
|
+
*/
|
|
8
13
|
export declare function safeCast<T>(value: T): T;
|
|
9
14
|
//# sourceMappingURL=safeCast.d.ts.map
|
package/dist/safeCast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeCast.d.ts","sourceRoot":"","sources":["../src/safeCast.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreateEditorArgs, EditorState, LexicalEditor } from 'lexical';
|
|
2
|
-
import { LexicalPlanRegistry } from '
|
|
2
|
+
import { LexicalPlanRegistry } from './';
|
|
3
3
|
|
|
4
4
|
export type AnyLexicalPlan = LexicalPlan<any, string>;
|
|
5
5
|
export type AnyLexicalPlanArgument = LexicalPlanArgument<any, string>;
|
|
@@ -103,7 +103,7 @@ export type LexicalPeerConfig<Name extends keyof LexicalPlanRegistry | string> =
|
|
|
103
103
|
] extends [keyof LexicalPlanRegistry] ? LexicalPlanRegistry[Name] : PlanConfigBase;
|
|
104
104
|
export type LexicalPlanConfig<Plan extends AnyLexicalPlan> = Plan["config"];
|
|
105
105
|
export type LexicalPlanName<Plan extends AnyLexicalPlan> = Plan["name"];
|
|
106
|
-
export interface EditorHandle {
|
|
106
|
+
export interface EditorHandle extends Disposable {
|
|
107
107
|
editor: LexicalEditor;
|
|
108
108
|
dispose: () => void;
|
|
109
109
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts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ACd,KAAK,EAAE,aAAa,KACjB,MAAM,IAAI,CAAC;CACjB;AAED,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,MAAM,mBAAmB,GAAG,MAAM,IAC3E;IAAC,IAAI;CAAC,SAAS,CAAC,MAAM,mBAAmB,CAAC,GACtC,mBAAmB,CAAC,IAAI,CAAC,GACzB,cAAc,CAAC;AAErB,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,cAAc,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;AAE5E,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,cAAc,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;AAExE,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAC9B,IAAI,GACJ,MAAM,GACN,WAAW,GACX,CAAC,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC,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.
|
|
20
|
+
"version": "0.0.7",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -32,12 +32,10 @@
|
|
|
32
32
|
"@lexical/dragon": ">=0.15.0",
|
|
33
33
|
"@lexical/history": ">=0.15.0",
|
|
34
34
|
"@lexical/plain-text": ">=0.15.0",
|
|
35
|
-
"@lexical/react": ">=0.15.0",
|
|
36
35
|
"@lexical/rich-text": ">=0.15.0",
|
|
37
36
|
"@lexical/text": ">=0.15.0",
|
|
38
37
|
"@lexical/utils": ">=0.15.0",
|
|
39
|
-
"lexical": ">=0.15.0"
|
|
40
|
-
"react": ">=18"
|
|
38
|
+
"lexical": ">=0.15.0"
|
|
41
39
|
},
|
|
42
40
|
"sideEffects": false,
|
|
43
41
|
"devDependencies": {
|
package/dist/ReactPlan.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { AnyLexicalPlanArgument } from './types';
|
|
2
|
-
import { LexicalComposerContextWithEditor } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
import { ErrorBoundaryType } from './useReactDecorators';
|
|
4
|
-
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
export interface EditorChildrenComponentProps {
|
|
7
|
-
context: LexicalComposerContextWithEditor;
|
|
8
|
-
placeholder: null | JSX.Element;
|
|
9
|
-
contentEditable: null | JSX.Element;
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
}
|
|
12
|
-
export type EditorChildrenComponentType = (props: EditorChildrenComponentProps) => JSX.Element | null;
|
|
13
|
-
export interface DecoratorComponentProps {
|
|
14
|
-
context: LexicalComposerContextWithEditor;
|
|
15
|
-
}
|
|
16
|
-
export type DecoratorComponentType = JSX.Element | ((props: DecoratorComponentProps) => JSX.Element | null);
|
|
17
|
-
export interface EditorComponentProps {
|
|
18
|
-
EditorChildrenComponent: EditorChildrenComponentType;
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
|
|
21
|
-
contentEditable: JSX.Element | null;
|
|
22
|
-
ErrorBoundary: ErrorBoundaryType;
|
|
23
|
-
}
|
|
24
|
-
export type EditorComponentType = (props: Partial<EditorComponentProps>) => JSX.Element;
|
|
25
|
-
export interface ReactConfig {
|
|
26
|
-
contentEditable: JSX.Element | null;
|
|
27
|
-
placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
|
|
28
|
-
ErrorBoundary: ErrorBoundaryType;
|
|
29
|
-
EditorChildrenComponent: EditorChildrenComponentType;
|
|
30
|
-
Component: EditorComponentType;
|
|
31
|
-
getContext: () => LexicalComposerContextWithEditor;
|
|
32
|
-
decorators: readonly DecoratorComponentType[];
|
|
33
|
-
}
|
|
34
|
-
export interface LexicalPlanComposerProps {
|
|
35
|
-
plan: AnyLexicalPlanArgument;
|
|
36
|
-
children: React.ReactNode;
|
|
37
|
-
}
|
|
38
|
-
export declare function LexicalPlanComposer({ plan, children, }: LexicalPlanComposerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
|
-
export declare const ReactPlan: import('./types').LexicalPlan<ReactConfig, "@etrepum/lexical-builder/ReactPlan">;
|
|
40
|
-
//# sourceMappingURL=ReactPlan.d.ts.map
|
package/dist/ReactPlan.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactPlan.d.ts","sourceRoot":"","sources":["../src/ReactPlan.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,uCAAuC,CAAC;AAI/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,gCAAgC,CAAC;IAC1C,WAAW,EAAE,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;IAChC,eAAe,EAAE,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,MAAM,2BAA2B,GAAG,CACxC,KAAK,EAAE,4BAA4B,KAChC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;AAExB,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,gCAAgC,CAAC;CAC3C;AACD,MAAM,MAAM,sBAAsB,GAC9B,GAAG,CAAC,OAAO,GACX,CAAC,CAAC,KAAK,EAAE,uBAAuB,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAE7D,MAAM,WAAW,oBAAoB;IACnC,uBAAuB,EAAE,2BAA2B,CAAC;IACrD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,EACP,CAAC,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAC7C,IAAI,GACJ,GAAG,CAAC,OAAO,CAAC;IAChB,eAAe,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC,aAAa,EAAE,iBAAiB,CAAC;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,KAAK,EAAE,OAAO,CAAC,oBAAoB,CAAC,KACjC,GAAG,CAAC,OAAO,CAAC;AAEjB,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC,WAAW,EACP,CAAC,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAC7C,IAAI,GACJ,GAAG,CAAC,OAAO,CAAC;IAChB,aAAa,EAAE,iBAAiB,CAAC;IACjC,uBAAuB,EAAE,2BAA2B,CAAC;IACrD,SAAS,EAAE,mBAAmB,CAAC;IAC/B,UAAU,EAAE,MAAM,gCAAgC,CAAC;IACnD,UAAU,EAAE,SAAS,sBAAsB,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAOD,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,QAAQ,GACT,EAAE,wBAAwB,kDAgC1B;AA+FD,eAAO,MAAM,SAAS,kFAsBpB,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { LexicalEditor } from 'lexical';
|
|
2
|
-
import { Root } from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
export interface HostMountCommandArg {
|
|
6
|
-
root: Root;
|
|
7
|
-
}
|
|
8
|
-
export type Container = Element | DocumentFragment;
|
|
9
|
-
export interface MountPluginCommandArg {
|
|
10
|
-
key: string;
|
|
11
|
-
element: JSX.Element | null;
|
|
12
|
-
domNode?: Container | null;
|
|
13
|
-
}
|
|
14
|
-
export declare function mountReactPluginComponent<P extends Record<never, never> = Record<never, never>>(editor: LexicalEditor, opts: {
|
|
15
|
-
Component: null | React.ComponentType<P>;
|
|
16
|
-
props: (P & React.Attributes) | null;
|
|
17
|
-
} & Omit<MountPluginCommandArg, "element">): void;
|
|
18
|
-
export declare function mountReactPluginElement(editor: LexicalEditor, opts: MountPluginCommandArg): void;
|
|
19
|
-
export declare function mountReactPluginHost(editor: LexicalEditor, container: Container): void;
|
|
20
|
-
export declare const REACT_PLUGIN_HOST_MOUNT_COMMAND: import('lexical').LexicalCommand<HostMountCommandArg>;
|
|
21
|
-
export declare const REACT_MOUNT_PLUGIN_COMMAND: import('lexical').LexicalCommand<MountPluginCommandArg>;
|
|
22
|
-
export declare const ReactPluginHostPlan: import('./types').LexicalPlan<{}, "@etrepum/lexical-builder/ReactPluginHostPlan">;
|
|
23
|
-
//# sourceMappingURL=ReactPluginHostPlan.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactPluginHostPlan.d.ts","sourceRoot":"","sources":["../src/ReactPluginHostPlan.tsx"],"names":[],"mappings":"AAQA,OAAO,EAIL,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAc,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKpD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC5B;AAED,wBAAgB,yBAAyB,CACvC,CAAC,SAAS,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAErD,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE;IACJ,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CACtC,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,QAO3C;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,qBAAqB,QAG5B;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,QAKrB;AAED,eAAO,MAAM,+BAA+B,uDAC2B,CAAC;AACxE,eAAO,MAAM,0BAA0B,yDAEtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,mFAyE9B,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
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 {};
|
|
9
|
-
//# sourceMappingURL=LexicalBuilder.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalBuilder.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/LexicalBuilder.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LexicalEditor } from 'lexical';
|
|
2
|
-
import { RegisterLexicalSubscription } from './registerSubscription';
|
|
3
|
-
|
|
4
|
-
export declare const canShowPlaceholder: RegisterLexicalSubscription<boolean>;
|
|
5
|
-
export declare function registerCanShowPlaceholder(editor: LexicalEditor, onChange: (canShow: boolean) => void): () => void;
|
|
6
|
-
//# sourceMappingURL=registerShowPlaceholder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerShowPlaceholder.d.ts","sourceRoot":"","sources":["../src/registerShowPlaceholder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C,OAAO,EACL,2BAA2B,EAE5B,MAAM,wBAAwB,CAAC;AAwBhC,eAAO,MAAM,kBAAkB,EAAE,2BAA2B,CAAC,OAAO,CAGnE,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GACnC,MAAM,IAAI,CAEZ"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LexicalEditor } from 'lexical';
|
|
2
|
-
|
|
3
|
-
export interface RegisterLexicalSubscription<T> {
|
|
4
|
-
initialValueFn: (editor: LexicalEditor) => T;
|
|
5
|
-
subscribe: (editor: LexicalEditor, onChange: (value: T) => void) => () => void;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Shortcut to Lexical subscriptions when values are used for render.
|
|
9
|
-
*/
|
|
10
|
-
export declare function registerLexicalSubscription<T>(editor: LexicalEditor, subscription: RegisterLexicalSubscription<T>, onChange: (value: T) => void): () => void;
|
|
11
|
-
//# sourceMappingURL=registerSubscription.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerSubscription.d.ts","sourceRoot":"","sources":["../src/registerSubscription.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC5C,cAAc,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,CAAC,CAAC;IAC7C,SAAS,EAAE,CACT,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KACzB,MAAM,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,2BAA2B,CAAC,CAAC,CAAC,EAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAC3B,MAAM,IAAI,CAUZ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/shared/useLayoutEffect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAC;AAGnD,QAAA,MAAM,mBAAmB,EAAE,OAAO,eAErB,CAAC;AAEd,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LexicalEditor } from 'lexical';
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
export type ErrorBoundaryProps = {
|
|
5
|
-
children: JSX.Element;
|
|
6
|
-
onError: (error: Error) => void;
|
|
7
|
-
};
|
|
8
|
-
export type ErrorBoundaryType = React.ComponentClass<ErrorBoundaryProps> | React.FC<ErrorBoundaryProps>;
|
|
9
|
-
export declare function useReactDecorators(editor: LexicalEditor, ErrorBoundary: ErrorBoundaryType): Array<JSX.Element>;
|
|
10
|
-
//# sourceMappingURL=useReactDecorators.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useReactDecorators.d.ts","sourceRoot":"","sources":["../src/useReactDecorators.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAW,MAAM,SAAS,CAAC;AAGtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,GACxC,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;AAEjC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,iBAAiB,GAC/B,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CA+CpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRegisterSubscription.d.ts","sourceRoot":"","sources":["../src/useRegisterSubscription.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAM1E,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,YAAY,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAC3C,CAAC,CAWH"}
|