@etrepum/lexical-react-extension 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/DefaultEditorChildrenComponent.d.ts +14 -0
- package/dist/DefaultEditorChildrenComponent.d.ts.map +1 -0
- package/dist/LexicalExtensionComposer.d.ts +59 -0
- package/dist/LexicalExtensionComposer.d.ts.map +1 -0
- package/dist/ReactExtension.d.ts +17 -0
- package/dist/ReactExtension.d.ts.map +1 -0
- package/dist/ReactPluginHostExtension.d.ts +46 -0
- package/dist/ReactPluginHostExtension.d.ts.map +1 -0
- package/dist/ReactProviderExtension.d.ts +10 -0
- package/dist/ReactProviderExtension.d.ts.map +1 -0
- package/dist/TreeViewExtension.d.ts +7 -0
- package/dist/TreeViewExtension.d.ts.map +1 -0
- package/dist/buildEditorComponent.d.ts +5 -0
- package/dist/buildEditorComponent.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +308 -0
- package/dist/registerSubscription.d.ts +10 -0
- package/dist/registerSubscription.d.ts.map +1 -0
- package/dist/shared/invariant.d.ts +9 -0
- package/dist/shared/invariant.d.ts.map +1 -0
- package/dist/shared/scheduleMicroTask.d.ts +2 -0
- package/dist/shared/scheduleMicroTask.d.ts.map +1 -0
- package/dist/shared/useLayoutEffect.d.ts +4 -0
- package/dist/shared/useLayoutEffect.d.ts.map +1 -0
- package/dist/types.d.ts +82 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useExtensionComponent.d.ts +43 -0
- package/dist/useExtensionComponent.d.ts.map +1 -0
- package/dist/useReactDecorators.d.ts +4 -0
- package/dist/useReactDecorators.d.ts.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EditorChildrenComponentProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @example The default EditorChildrenComponent implementation
|
|
4
|
+
* ```jsx
|
|
5
|
+
* return (
|
|
6
|
+
* <>
|
|
7
|
+
* {contentEditable}
|
|
8
|
+
* {children}
|
|
9
|
+
* </>
|
|
10
|
+
* );
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function DefaultEditorChildrenComponent({ contentEditable, children, }: EditorChildrenComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=DefaultEditorChildrenComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultEditorChildrenComponent.d.ts","sourceRoot":"","sources":["../src/DefaultEditorChildrenComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,eAAe,EACf,QAAQ,GACT,EAAE,4BAA4B,2CAO9B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AnyLexicalExtensionArgument } from '@etrepum/lexical-builder';
|
|
2
|
+
export interface LexicalExtensionComposerProps {
|
|
3
|
+
/**
|
|
4
|
+
* Your root extension, typically defined with {@link defineExtension}
|
|
5
|
+
*/
|
|
6
|
+
extension: AnyLexicalExtensionArgument;
|
|
7
|
+
/**
|
|
8
|
+
* Any children will have access to useLexicalComposerContext (e.g. for React plug-ins or UX)
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The equivalent of LexicalComposer for an extension. Make sure that your extension
|
|
14
|
+
* argument is stable (e.g. using module scope or useMemo) so
|
|
15
|
+
* that you are not re-creating the editor on every render!
|
|
16
|
+
*
|
|
17
|
+
* @example Module scoped extension
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const extension = defineExtension({
|
|
20
|
+
* name: "[root]",
|
|
21
|
+
* dependencies: [RichTextExtension, HistoryExtension, EmojiExtension]
|
|
22
|
+
* });
|
|
23
|
+
* function MyEditor({ children }) {
|
|
24
|
+
* return (<LexicalExtensionComposer extension={extension}>{children}</LexicalExtensionComposer>);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example useMemo extension
|
|
29
|
+
* ```tsx
|
|
30
|
+
* function MyEditor({ emojiBaseUrl, children }) {
|
|
31
|
+
* const extension = useMemo(() => {
|
|
32
|
+
* return defineExtension({
|
|
33
|
+
* name: "[root]",
|
|
34
|
+
* dependencies: [
|
|
35
|
+
* RichTextExtension,
|
|
36
|
+
* HistoryExtension,
|
|
37
|
+
* configExtension(EmojiExtension, { emojiBaseUrl }),
|
|
38
|
+
* ],
|
|
39
|
+
* });
|
|
40
|
+
* }, [emojiBaseUrl]);
|
|
41
|
+
* return (<LexicalExtensionComposer extension={extension}>{children}</LexicalExtensionComposer>);
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example Incorrect usage with unstable extension
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function MyBrokenEditor({ emojiBaseUrl }) {
|
|
48
|
+
* // This argument is not stable, the editor is re-created every render and
|
|
49
|
+
* // all state is lost!
|
|
50
|
+
* const extension = defineExtension({
|
|
51
|
+
* name: "[root]",
|
|
52
|
+
* dependencies: [RichTextExtension, HistoryExtension, EmojiExtension]
|
|
53
|
+
* });
|
|
54
|
+
* return (<LexicalExtensionComposer extension={extension}>{children}</LexicalExtensionComposer>);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function LexicalExtensionComposer({ extension, children, }: LexicalExtensionComposerProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
//# sourceMappingURL=LexicalExtensionComposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LexicalExtensionComposer.d.ts","sourceRoot":"","sources":["../src/LexicalExtensionComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,SAAS,EAAE,2BAA2B,CAAC;IACvC;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,QAAQ,GACT,EAAE,6BAA6B,2CAoB/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactConfig, ReactOutputs } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* An extension to use or configure React for use with Lexical. In an editor, you
|
|
4
|
+
* would typically use {@link LexicalExtensionComposer} (for React projects) or
|
|
5
|
+
* {@link ReactPluginHostExtension} (to use React Extensions and plug-ins in a non-React
|
|
6
|
+
* project).
|
|
7
|
+
*
|
|
8
|
+
* See {@link ReactConfig} for more detailed exextensionations of how to use
|
|
9
|
+
* the config for this Extension.
|
|
10
|
+
*
|
|
11
|
+
* For an Extension developer, you can defineConfig() override the extension with
|
|
12
|
+
* decorators to add JSX inside the editor context that is not
|
|
13
|
+
* location-dependent (e.g. floating UI that does not need to be mounted in
|
|
14
|
+
* some specific location, or effects that return null).
|
|
15
|
+
*/
|
|
16
|
+
export declare const ReactExtension: import('@etrepum/lexical-builder').LexicalExtension<ReactConfig, "@etrepum/lexical-builder/React", ReactOutputs, unknown>;
|
|
17
|
+
//# sourceMappingURL=ReactExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactExtension.d.ts","sourceRoot":"","sources":["../src/ReactExtension.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAY9D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,2HAuCzB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
import { Root, Container } from 'react-dom/client';
|
|
3
|
+
import { AnyLexicalExtension, LexicalExtensionOutput } from '@etrepum/lexical-builder';
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
export interface HostMountCommandArg {
|
|
6
|
+
root: Root;
|
|
7
|
+
}
|
|
8
|
+
export interface MountPluginCommandArg {
|
|
9
|
+
key: string;
|
|
10
|
+
element: JSX.Element | null;
|
|
11
|
+
domNode?: Container | null;
|
|
12
|
+
}
|
|
13
|
+
export declare function mountReactExtensionComponent<Extension extends AnyLexicalExtension>(editor: LexicalEditor, opts: {
|
|
14
|
+
extension: Extension;
|
|
15
|
+
props: [LexicalExtensionOutput<Extension>] extends [
|
|
16
|
+
{
|
|
17
|
+
Component: infer OutputComponentType extends React.ComponentType;
|
|
18
|
+
}
|
|
19
|
+
] ? /** The Props from the Extension output Component */ React.ComponentProps<OutputComponentType> | null : never;
|
|
20
|
+
} & Omit<MountPluginCommandArg, "element">): void;
|
|
21
|
+
export declare function mountReactPluginComponent<P extends Record<never, never> = Record<never, never>>(editor: LexicalEditor, opts: {
|
|
22
|
+
Component: React.ComponentType<P>;
|
|
23
|
+
props: (P & React.Attributes) | null;
|
|
24
|
+
} & Omit<MountPluginCommandArg, "element">): void;
|
|
25
|
+
export declare function mountReactPluginElement(editor: LexicalEditor, opts: MountPluginCommandArg): void;
|
|
26
|
+
export declare function mountReactPluginHost(editor: LexicalEditor, container: Container): void;
|
|
27
|
+
export declare const REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND: import('lexical').LexicalCommand<HostMountCommandArg>;
|
|
28
|
+
export declare const REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND: import('lexical').LexicalCommand<MountPluginCommandArg>;
|
|
29
|
+
/**
|
|
30
|
+
* This extension provides a React host for editors that are not built
|
|
31
|
+
* with LexicalExtensionComposer (e.g. you are using Vanilla JS or some
|
|
32
|
+
* other framework).
|
|
33
|
+
*
|
|
34
|
+
* You must use {@link mountReactPluginHost} for any React content to work.
|
|
35
|
+
* Afterwards, you may use {@link mountReactExtensionComponent} to
|
|
36
|
+
* render UI for a specific React Extension.
|
|
37
|
+
* {@link mountReactPluginComponent} and
|
|
38
|
+
* {@link mountReactPluginElement} can be used to render
|
|
39
|
+
* legacy React plug-ins (or any React content).
|
|
40
|
+
*/
|
|
41
|
+
export declare const ReactPluginHostExtension: import('@etrepum/lexical-builder').LexicalExtension<import('@etrepum/lexical-builder').ExtensionConfigBase, "@etrepum/lexical-builder/ReactPluginHost", {
|
|
42
|
+
renderMountedPlugins: () => import("react/jsx-runtime").JSX.Element | null;
|
|
43
|
+
mountReactPluginHost: (container: Container) => boolean;
|
|
44
|
+
mountReactPlugin: (arg: MountPluginCommandArg) => boolean;
|
|
45
|
+
}, unknown>;
|
|
46
|
+
//# sourceMappingURL=ReactPluginHostExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactPluginHostExtension.d.ts","sourceRoot":"","sources":["../src/ReactPluginHostExtension.tsx"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,KAAK,mBAAmB,EAIxB,KAAK,sBAAsB,EAE5B,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,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,4BAA4B,CAAC,SAAS,SAAS,mBAAmB,EAChF,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE;IACJ,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,SAAS;QACjD;YACE,SAAS,EAAE,MAAM,mBAAmB,SAAS,KAAK,CAAC,aAAa,CAAC;SAClE;KACF,GACwD,AAArD,oDAAoD,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,GAAG,IAAI,GACrG,KAAK,CAAC;CACX,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,QAS3C;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,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAClC,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,QAM5B;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,QAMrB;AAED,eAAO,MAAM,oCAAoC,uDAC2B,CAAC;AAC7E,eAAO,MAAM,sCAAsC,yDAGhD,CAAC;AAuBJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB;;sCAsCK,SAAS;4BAInB,qBAAqB;WAmCnD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An extension used to declare that there is a LexicalExtensionComposer or
|
|
3
|
+
* ReactPluginHostExtension available so that we can issue runtime warnings
|
|
4
|
+
* when plugins that depend on React are hosted in an environment
|
|
5
|
+
* where it is not ever going to be rendered.
|
|
6
|
+
*
|
|
7
|
+
* It is a separate extension so it can be used as a peer dependency.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ReactProviderExtension: import('@etrepum/lexical-builder').LexicalExtension<import('@etrepum/lexical-builder').ExtensionConfigBase, "@etrepum/lexical-builder/ReactProvider", unknown, unknown>;
|
|
10
|
+
//# sourceMappingURL=ReactProviderExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactProviderExtension.d.ts","sourceRoot":"","sources":["../src/ReactProviderExtension.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,yKAEjC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TreeView } from '@lexical/react/LexicalTreeView';
|
|
2
|
+
export type TreeViewConfig = Omit<Parameters<typeof TreeView>[0], "editor">;
|
|
3
|
+
export declare function TreeViewExtensionComponent(props: Partial<TreeViewConfig>): JSX.Element;
|
|
4
|
+
export declare const TreeViewExtension: import('@etrepum/lexical-builder').LexicalExtension<TreeViewConfig, "@etrepum/lexical-builder/TreeView", {
|
|
5
|
+
Component: typeof TreeViewExtensionComponent;
|
|
6
|
+
}, unknown>;
|
|
7
|
+
//# sourceMappingURL=TreeViewExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewExtension.d.ts","sourceRoot":"","sources":["../src/TreeViewExtension.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAK1D,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAC7B,GAAG,CAAC,OAAO,CASb;AAWD,eAAO,MAAM,iBAAiB;;WAK5B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LexicalComposerContextWithEditor } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { ReactConfig, EditorComponentProps } from './types';
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare function buildEditorComponent(config: ReactConfig, context: LexicalComposerContextWithEditor): (props: Partial<EditorComponentProps>) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=buildEditorComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildEditorComponent.d.ts","sourceRoot":"","sources":["../src/buildEditorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEtE,gBAAgB;AAChB,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,gCAAgC,WAOF,OAAO,CAAC,oBAAoB,CAAC,6CAoCrE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare const PACKAGE_VERSION: string;
|
|
9
|
+
export { type DecoratorComponentProps, type DecoratorComponentType, type EditorChildrenComponentProps, type EditorChildrenComponentType, type EditorComponentProps, type EditorComponentType, type ReactConfig, type ErrorBoundaryType, type ErrorBoundaryProps, type ReactOutputs, } from './types';
|
|
10
|
+
export { ReactExtension } from './ReactExtension';
|
|
11
|
+
export { type LexicalExtensionComposerProps, LexicalExtensionComposer, } from './LexicalExtensionComposer';
|
|
12
|
+
export { type HostMountCommandArg, type MountPluginCommandArg, mountReactPluginComponent, mountReactPluginElement, mountReactPluginHost, mountReactExtensionComponent, REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND, REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND, ReactPluginHostExtension, } from './ReactPluginHostExtension';
|
|
13
|
+
export { DefaultEditorChildrenComponent } from './DefaultEditorChildrenComponent';
|
|
14
|
+
export { useExtensionDependency, useExtensionComponent, UseExtensionComponent, type UseExtensionComponentProps, } from './useExtensionComponent';
|
|
15
|
+
export { type TreeViewConfig, TreeViewExtensionComponent, TreeViewExtension, } from './TreeViewExtension';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,KAAK,6BAA6B,EAClC,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,4BAA4B,EAC5B,oCAAoC,EACpC,sCAAsC,EACtC,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,cAAc,EACnB,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { jsx as i, jsxs as b, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import { defineExtension as R, shallowMergeConfig as U, declarePeerDependency as k, provideOutput as _, buildEditorFromExtensions as B, getExtensionDependencyFromEditor as m, configExtension as G } from "@etrepum/lexical-builder";
|
|
3
|
+
import { ContentEditable as K } from "@lexical/react/LexicalContentEditable";
|
|
4
|
+
import { LexicalErrorBoundary as V } from "@lexical/react/LexicalErrorBoundary";
|
|
5
|
+
import { LexicalComposerContext as j, useLexicalComposerContext as y } from "@lexical/react/LexicalComposerContext";
|
|
6
|
+
import { useLayoutEffect as F, useEffect as x, useState as I, useMemo as T, Suspense as D } from "react";
|
|
7
|
+
import { flushSync as Y, createPortal as L } from "react-dom";
|
|
8
|
+
import { CAN_USE_DOM as q, mergeRegister as z } from "@lexical/utils";
|
|
9
|
+
import { createCommand as A, COMMAND_PRIORITY_CRITICAL as J, COMMAND_PRIORITY_EDITOR as w } from "lexical";
|
|
10
|
+
import { createRoot as Q } from "react-dom/client";
|
|
11
|
+
import { TreeView as W } from "@lexical/react/LexicalTreeView";
|
|
12
|
+
const X = q ? F : x;
|
|
13
|
+
function N(e, t, ...n) {
|
|
14
|
+
if (!e)
|
|
15
|
+
throw new Error(
|
|
16
|
+
n.reduce((r, o) => r.replace("%s", String(o)), t || "")
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function Z(e, t) {
|
|
20
|
+
const [n, r] = I(
|
|
21
|
+
() => e.getDecorators()
|
|
22
|
+
);
|
|
23
|
+
return X(() => e.registerDecoratorListener((o) => {
|
|
24
|
+
Y(() => {
|
|
25
|
+
r(o);
|
|
26
|
+
});
|
|
27
|
+
}), [e]), x(() => {
|
|
28
|
+
r(e.getDecorators());
|
|
29
|
+
}, [e]), T(() => {
|
|
30
|
+
const o = [], c = Object.keys(n);
|
|
31
|
+
for (let u = 0; u < c.length; u++) {
|
|
32
|
+
const a = c[u];
|
|
33
|
+
N(
|
|
34
|
+
a !== void 0,
|
|
35
|
+
"useReactDecorators: decoratorKeys[%s] must be defined",
|
|
36
|
+
String(u)
|
|
37
|
+
);
|
|
38
|
+
const l = e.getElementByKey(a);
|
|
39
|
+
if (l !== null) {
|
|
40
|
+
const d = /* @__PURE__ */ i(
|
|
41
|
+
t,
|
|
42
|
+
{
|
|
43
|
+
onError: (s) => {
|
|
44
|
+
e._onError(s);
|
|
45
|
+
},
|
|
46
|
+
children: /* @__PURE__ */ i(D, { fallback: null, children: n[a] })
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
o.push(L(d, l, a));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return o;
|
|
53
|
+
}, [t, n, e]);
|
|
54
|
+
}
|
|
55
|
+
function $(e, t) {
|
|
56
|
+
const [n] = t, r = e.decorators.map(
|
|
57
|
+
(o) => (
|
|
58
|
+
// eslint-disable-next-line react/jsx-key -- wrapped later
|
|
59
|
+
typeof o == "function" ? /* @__PURE__ */ i(o, { context: t }) : o
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
return function(c) {
|
|
63
|
+
const {
|
|
64
|
+
EditorChildrenComponent: u = e.EditorChildrenComponent,
|
|
65
|
+
ErrorBoundary: a = e.ErrorBoundary,
|
|
66
|
+
contentEditable: l = e.contentEditable,
|
|
67
|
+
children: d
|
|
68
|
+
} = c, s = Z(n, a), f = T(
|
|
69
|
+
() => r.map((C, g) => /* @__PURE__ */ i(
|
|
70
|
+
a,
|
|
71
|
+
{
|
|
72
|
+
onError: (E) => {
|
|
73
|
+
n._onError(E);
|
|
74
|
+
},
|
|
75
|
+
children: /* @__PURE__ */ i(D, { fallback: null, children: C })
|
|
76
|
+
},
|
|
77
|
+
g
|
|
78
|
+
)),
|
|
79
|
+
[a]
|
|
80
|
+
);
|
|
81
|
+
return /* @__PURE__ */ i(j.Provider, { value: t, children: /* @__PURE__ */ b(
|
|
82
|
+
u,
|
|
83
|
+
{
|
|
84
|
+
context: t,
|
|
85
|
+
contentEditable: l,
|
|
86
|
+
children: [
|
|
87
|
+
d,
|
|
88
|
+
f,
|
|
89
|
+
s
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
) });
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function ee({
|
|
96
|
+
contentEditable: e,
|
|
97
|
+
children: t
|
|
98
|
+
}) {
|
|
99
|
+
return /* @__PURE__ */ b(v, { children: [
|
|
100
|
+
e,
|
|
101
|
+
t
|
|
102
|
+
] });
|
|
103
|
+
}
|
|
104
|
+
const P = R({
|
|
105
|
+
name: "@etrepum/lexical-builder/ReactProvider"
|
|
106
|
+
}), te = {
|
|
107
|
+
EditorChildrenComponent: ee,
|
|
108
|
+
ErrorBoundary: V,
|
|
109
|
+
contentEditable: /* @__PURE__ */ i(K, {}),
|
|
110
|
+
decorators: []
|
|
111
|
+
}, p = R({
|
|
112
|
+
config: te,
|
|
113
|
+
mergeConfig(e, t) {
|
|
114
|
+
const n = U(e, t);
|
|
115
|
+
return t.decorators && (n.decorators = t.decorators.length > 0 ? [...e.decorators, ...t.decorators] : e.decorators), n;
|
|
116
|
+
},
|
|
117
|
+
name: "@etrepum/lexical-builder/React",
|
|
118
|
+
peerDependencies: [
|
|
119
|
+
// We are not trying to avoid the import, just the direct dependency,
|
|
120
|
+
// so using the extension directly is fine.
|
|
121
|
+
k(P.name)
|
|
122
|
+
],
|
|
123
|
+
register(e, t, n) {
|
|
124
|
+
n.getPeer(
|
|
125
|
+
P.name
|
|
126
|
+
) || N(
|
|
127
|
+
!1,
|
|
128
|
+
"No ReactProviderExtension detected. You must use ReactPluginHostExtension or LexicalExtensionComposer to host React extensions. The following extensions depend on ReactExtension: %s",
|
|
129
|
+
[...n.getDirectDependentNames()].join(" ")
|
|
130
|
+
);
|
|
131
|
+
const o = [
|
|
132
|
+
e,
|
|
133
|
+
{ getTheme: () => e._config.theme }
|
|
134
|
+
], c = $(t, o);
|
|
135
|
+
return _({
|
|
136
|
+
context: o,
|
|
137
|
+
Component: c
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}), ne = "queueMicrotask" in globalThis ? queueMicrotask : (e) => Promise.resolve().then(e);
|
|
141
|
+
function Re({
|
|
142
|
+
extension: e,
|
|
143
|
+
children: t
|
|
144
|
+
}) {
|
|
145
|
+
const n = T(
|
|
146
|
+
() => B(P, p, e),
|
|
147
|
+
[e]
|
|
148
|
+
);
|
|
149
|
+
x(() => {
|
|
150
|
+
let o = !1;
|
|
151
|
+
return ne(() => {
|
|
152
|
+
o = !0;
|
|
153
|
+
}), () => {
|
|
154
|
+
o && n.dispose();
|
|
155
|
+
};
|
|
156
|
+
}, [n]);
|
|
157
|
+
const { Component: r } = m(n, p).output;
|
|
158
|
+
return /* @__PURE__ */ i(r, { children: t });
|
|
159
|
+
}
|
|
160
|
+
function xe(e, t) {
|
|
161
|
+
const { props: n, extension: r, ...o } = t, { Component: c } = m(e, r).output, u = n ? /* @__PURE__ */ i(c, { ...n }) : null;
|
|
162
|
+
H(e, {
|
|
163
|
+
...o,
|
|
164
|
+
element: u
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function he(e, t) {
|
|
168
|
+
const { Component: n, props: r, ...o } = t;
|
|
169
|
+
H(e, {
|
|
170
|
+
...o,
|
|
171
|
+
element: r ? /* @__PURE__ */ i(n, { ...r }) : null
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function H(e, t) {
|
|
175
|
+
m(
|
|
176
|
+
e,
|
|
177
|
+
M
|
|
178
|
+
).output.mountReactPlugin(t);
|
|
179
|
+
}
|
|
180
|
+
function _e(e, t) {
|
|
181
|
+
m(
|
|
182
|
+
e,
|
|
183
|
+
M
|
|
184
|
+
).output.mountReactPluginHost(t);
|
|
185
|
+
}
|
|
186
|
+
const O = A("REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND"), h = A(
|
|
187
|
+
"REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND"
|
|
188
|
+
);
|
|
189
|
+
function oe({
|
|
190
|
+
context: [e]
|
|
191
|
+
}) {
|
|
192
|
+
const {
|
|
193
|
+
output: { renderMountedPlugins: t }
|
|
194
|
+
} = m(e, M), [n, r] = I(t);
|
|
195
|
+
return x(() => e.registerCommand(
|
|
196
|
+
h,
|
|
197
|
+
() => (r(t), !0),
|
|
198
|
+
w
|
|
199
|
+
), [e, t]), n;
|
|
200
|
+
}
|
|
201
|
+
const M = R({
|
|
202
|
+
dependencies: [
|
|
203
|
+
P,
|
|
204
|
+
G(p, { decorators: [oe] })
|
|
205
|
+
],
|
|
206
|
+
name: "@etrepum/lexical-builder/ReactPluginHost",
|
|
207
|
+
register(e, t, n) {
|
|
208
|
+
let r;
|
|
209
|
+
const o = /* @__PURE__ */ new Map(), c = n.getDependency(p), {
|
|
210
|
+
config: { ErrorBoundary: u },
|
|
211
|
+
output: { Component: a }
|
|
212
|
+
} = c, l = e._onError.bind(e);
|
|
213
|
+
function d() {
|
|
214
|
+
const s = [];
|
|
215
|
+
for (const { key: f, element: C, domNode: g } of o.values()) {
|
|
216
|
+
if (!C)
|
|
217
|
+
continue;
|
|
218
|
+
const E = /* @__PURE__ */ i(u, { onError: l, children: /* @__PURE__ */ i(D, { fallback: null, children: C }) }, f);
|
|
219
|
+
s.push(g ? L(E, g, f) : E);
|
|
220
|
+
}
|
|
221
|
+
return s.length > 0 ? /* @__PURE__ */ i(v, { children: s }) : null;
|
|
222
|
+
}
|
|
223
|
+
return _(
|
|
224
|
+
{
|
|
225
|
+
renderMountedPlugins: d,
|
|
226
|
+
// Using outputs to wrap commands will give us better error messages
|
|
227
|
+
// if the mount functions are called on an editor without this extension
|
|
228
|
+
mountReactPluginHost: (s) => e.dispatchCommand(O, {
|
|
229
|
+
root: Q(s)
|
|
230
|
+
}),
|
|
231
|
+
mountReactPlugin: (s) => e.dispatchCommand(h, s)
|
|
232
|
+
},
|
|
233
|
+
z(
|
|
234
|
+
() => {
|
|
235
|
+
r && r.unmount(), o.clear();
|
|
236
|
+
},
|
|
237
|
+
e.registerCommand(
|
|
238
|
+
h,
|
|
239
|
+
(s) => (o.set(s.key, s), !1),
|
|
240
|
+
J
|
|
241
|
+
),
|
|
242
|
+
e.registerCommand(
|
|
243
|
+
O,
|
|
244
|
+
(s) => (N(
|
|
245
|
+
r === void 0,
|
|
246
|
+
"ReactPluginHostExtension: Root is already mounted"
|
|
247
|
+
), r = s.root, r.render(/* @__PURE__ */ i(a, { contentEditable: null })), !0),
|
|
248
|
+
w
|
|
249
|
+
)
|
|
250
|
+
)
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
function S(e) {
|
|
255
|
+
return m(y()[0], e);
|
|
256
|
+
}
|
|
257
|
+
function re(e) {
|
|
258
|
+
return S(e).output.Component;
|
|
259
|
+
}
|
|
260
|
+
function Te({
|
|
261
|
+
"lexical:extension": e,
|
|
262
|
+
...t
|
|
263
|
+
}) {
|
|
264
|
+
const n = re(e);
|
|
265
|
+
return /* @__PURE__ */ i(n, { ...t });
|
|
266
|
+
}
|
|
267
|
+
function se(e) {
|
|
268
|
+
const [t] = y();
|
|
269
|
+
return /* @__PURE__ */ i(
|
|
270
|
+
W,
|
|
271
|
+
{
|
|
272
|
+
editor: t,
|
|
273
|
+
...S(ce).config,
|
|
274
|
+
...e
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
const ie = {
|
|
279
|
+
viewClassName: "tree-view-output",
|
|
280
|
+
treeTypeButtonClassName: "debug-treetype-button",
|
|
281
|
+
timeTravelPanelClassName: "debug-timetravel-panel",
|
|
282
|
+
timeTravelButtonClassName: "debug-timetravel-button",
|
|
283
|
+
timeTravelPanelSliderClassName: "debug-timetravel-panel-slider",
|
|
284
|
+
timeTravelPanelButtonClassName: "debug-timetravel-panel-button"
|
|
285
|
+
}, ce = R({
|
|
286
|
+
name: "@etrepum/lexical-builder/TreeView",
|
|
287
|
+
dependencies: [p],
|
|
288
|
+
config: ie,
|
|
289
|
+
register: () => _({ Component: se })
|
|
290
|
+
}), De = "0.0.36";
|
|
291
|
+
export {
|
|
292
|
+
ee as DefaultEditorChildrenComponent,
|
|
293
|
+
Re as LexicalExtensionComposer,
|
|
294
|
+
De as PACKAGE_VERSION,
|
|
295
|
+
h as REACT_PLUGIN_HOST_MOUNT_PLUGIN_COMMAND,
|
|
296
|
+
O as REACT_PLUGIN_HOST_MOUNT_ROOT_COMMAND,
|
|
297
|
+
p as ReactExtension,
|
|
298
|
+
M as ReactPluginHostExtension,
|
|
299
|
+
ce as TreeViewExtension,
|
|
300
|
+
se as TreeViewExtensionComponent,
|
|
301
|
+
Te as UseExtensionComponent,
|
|
302
|
+
xe as mountReactExtensionComponent,
|
|
303
|
+
he as mountReactPluginComponent,
|
|
304
|
+
H as mountReactPluginElement,
|
|
305
|
+
_e as mountReactPluginHost,
|
|
306
|
+
re as useExtensionComponent,
|
|
307
|
+
S as useExtensionDependency
|
|
308
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
export interface RegisterLexicalSubscription<T> {
|
|
3
|
+
initialValueFn: (editor: LexicalEditor) => T;
|
|
4
|
+
subscribe: (editor: LexicalEditor, onChange: (value: T) => void) => () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Shortcut to Lexical subscriptions when values are used for render.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerLexicalSubscription<T>(editor: LexicalEditor, subscription: RegisterLexicalSubscription<T>, onChange: (value: T) => void): () => void;
|
|
10
|
+
//# sourceMappingURL=registerSubscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAWZ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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 default function invariant(cond?: boolean, message?: string, ...args: string[]): asserts cond;
|
|
9
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/shared/invariant.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAQd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduleMicroTask.d.ts","sourceRoot":"","sources":["../../src/shared/scheduleMicroTask.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,uBAGsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LexicalComposerContextWithEditor } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
export interface EditorChildrenComponentProps {
|
|
3
|
+
context: LexicalComposerContextWithEditor;
|
|
4
|
+
contentEditable: null | JSX.Element;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export type EditorChildrenComponentType = (props: EditorChildrenComponentProps) => JSX.Element | null;
|
|
8
|
+
export interface DecoratorComponentProps {
|
|
9
|
+
context: LexicalComposerContextWithEditor;
|
|
10
|
+
}
|
|
11
|
+
export type DecoratorComponentType = JSX.Element | ((props: DecoratorComponentProps) => JSX.Element | null);
|
|
12
|
+
export interface EditorComponentProps {
|
|
13
|
+
/**
|
|
14
|
+
* The EditorChildrenComponent from the config
|
|
15
|
+
*/
|
|
16
|
+
EditorChildrenComponent: EditorChildrenComponentType;
|
|
17
|
+
/**
|
|
18
|
+
* The children to pass to EditorChildrenComponent
|
|
19
|
+
*/
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* contentEditable from the config
|
|
23
|
+
*/
|
|
24
|
+
contentEditable: JSX.Element | null;
|
|
25
|
+
/**
|
|
26
|
+
* ErrorBoundary from the config
|
|
27
|
+
*/
|
|
28
|
+
ErrorBoundary: ErrorBoundaryType;
|
|
29
|
+
}
|
|
30
|
+
export type EditorComponentType = (
|
|
31
|
+
/** Optional overrides to any of the props, typically only children is used */
|
|
32
|
+
props: Partial<EditorComponentProps>) => JSX.Element;
|
|
33
|
+
export interface ReactConfig {
|
|
34
|
+
/**
|
|
35
|
+
* The default root element of the editor as JSX. Uses `<ContentEditable />`
|
|
36
|
+
* from \@lexical/react/ContentEditable by default,
|
|
37
|
+
* but may be null or another component.
|
|
38
|
+
*
|
|
39
|
+
* This component is responsible for calling `editor.setRootElement(elem)`.
|
|
40
|
+
*/
|
|
41
|
+
contentEditable: JSX.Element | null;
|
|
42
|
+
/**
|
|
43
|
+
* The ErrorBoundary used for rendering decorators in the editor. By default
|
|
44
|
+
* it is `ErrorBoundary` from \@lexical/react/ErrorBoundary.
|
|
45
|
+
*/
|
|
46
|
+
ErrorBoundary: ErrorBoundaryType;
|
|
47
|
+
/**
|
|
48
|
+
* The component that renders the children of the editor context, by default
|
|
49
|
+
* it is {@link DefaultEditorChildrenComponent} which takes the given props
|
|
50
|
+
* and renders them in this order:
|
|
51
|
+
*
|
|
52
|
+
* - contentEditable
|
|
53
|
+
* - children
|
|
54
|
+
*/
|
|
55
|
+
EditorChildrenComponent: EditorChildrenComponentType;
|
|
56
|
+
/**
|
|
57
|
+
* An array of JSX or components that return JSX that should be rendered
|
|
58
|
+
* as children of Component. These will be merged by array concatenation.
|
|
59
|
+
*/
|
|
60
|
+
decorators: readonly DecoratorComponentType[];
|
|
61
|
+
}
|
|
62
|
+
export interface ReactOutputs {
|
|
63
|
+
/**
|
|
64
|
+
* The editor component, this can be used by Extensions that depend on this to
|
|
65
|
+
* render the editor such as {@link ReactPluginHostExtension} or internally by
|
|
66
|
+
* {@link LexicalExtensionComposer}.
|
|
67
|
+
*
|
|
68
|
+
* All props have defaults based on the config and editor state, but may be
|
|
69
|
+
* overridden.
|
|
70
|
+
*/
|
|
71
|
+
Component: EditorComponentType;
|
|
72
|
+
/**
|
|
73
|
+
* This is equivalent to useLexicalComposerContext() from \@lexical/react/LexicalComposerContext.
|
|
74
|
+
*/
|
|
75
|
+
context: LexicalComposerContextWithEditor;
|
|
76
|
+
}
|
|
77
|
+
export interface ErrorBoundaryProps {
|
|
78
|
+
children: JSX.Element;
|
|
79
|
+
onError: (error: Error) => void;
|
|
80
|
+
}
|
|
81
|
+
export type ErrorBoundaryType = React.ComponentClass<ErrorBoundaryProps> | React.FC<ErrorBoundaryProps>;
|
|
82
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAE9F,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,gCAAgC,CAAC;IAC1C,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;;OAEG;IACH,uBAAuB,EAAE,2BAA2B,CAAC;IACrD;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG;AAChC,8EAA8E;AAC9E,KAAK,EAAE,OAAO,CAAC,oBAAoB,CAAC,KACjC,GAAG,CAAC,OAAO,CAAC;AAEjB,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,eAAe,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,aAAa,EAAE,iBAAiB,CAAC;IACjC;;;;;;;OAOG;IACH,uBAAuB,EAAE,2BAA2B,CAAC;IAErD;;;OAGG;IACH,UAAU,EAAE,SAAS,sBAAsB,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC3B;;;;;;;OAOG;IACH,SAAS,EAAE,mBAAmB,CAAC;IAC/B;;OAEG;IACH,OAAO,EAAE,gCAAgC,CAAC;CAC3C;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED,MAAM,MAAM,iBAAiB,GACzB,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,GACxC,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LexicalExtensionOutput, OutputComponentExtension, AnyLexicalExtension, LexicalExtensionDependency } from '@etrepum/lexical-builder';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
export declare function useExtensionDependency<Extension extends AnyLexicalExtension>(extension: Extension): LexicalExtensionDependency<Extension>;
|
|
4
|
+
/**
|
|
5
|
+
* Use a Component from the given Extension that uses the ReactExtension convention
|
|
6
|
+
* of exposing a Component property in its output.
|
|
7
|
+
*
|
|
8
|
+
* @param extension - An extension with a Component property in the output
|
|
9
|
+
* @returns `getExtensionConfigFromEditor(useLexicalComposerContext()[0], extension).Component`
|
|
10
|
+
*/
|
|
11
|
+
export declare function useExtensionComponent<Props extends Record<never, never>, OutputComponent extends React.ComponentType<Props>, Extension extends OutputComponentExtension<OutputComponent>>(extension: Extension): OutputComponent;
|
|
12
|
+
/**
|
|
13
|
+
* The lexical:extension prop combined with the props of the given Extension's
|
|
14
|
+
* output Component.
|
|
15
|
+
*/
|
|
16
|
+
export type UseExtensionComponentProps<Extension extends AnyLexicalExtension> = {
|
|
17
|
+
/** The Extension */ "lexical:extension": Extension;
|
|
18
|
+
} & ([LexicalExtensionOutput<Extension>] extends [
|
|
19
|
+
{
|
|
20
|
+
Component: infer OutputComponentType extends React.ComponentType;
|
|
21
|
+
}
|
|
22
|
+
] ? Omit<ComponentProps<OutputComponentType>, "lexical:extension"> : never);
|
|
23
|
+
/**
|
|
24
|
+
* A convenient way to get an Extension's output Component with {@link useExtensionComponent}
|
|
25
|
+
* and construct it in one step.
|
|
26
|
+
*
|
|
27
|
+
* @example Usage
|
|
28
|
+
* ```tsx
|
|
29
|
+
* return (
|
|
30
|
+
* <UseExtensionComponent
|
|
31
|
+
* lexical:extension={TreeViewExtension}
|
|
32
|
+
* viewClassName="tree-view-output" />
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Alternative without UseExtensionComponent
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const TreeViewComponent = useExtensionComponent(TreeViewExtension);
|
|
39
|
+
* return (<TreeViewComponent viewClassName="tree-view-output" />);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function UseExtensionComponent<Extension extends AnyLexicalExtension>({ "lexical:extension": extension, ...props }: UseExtensionComponentProps<Extension>): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
//# sourceMappingURL=useExtensionComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExtensionComponent.d.ts","sourceRoot":"","sources":["../src/useExtensionComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAE7B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAChC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,wBAAgB,sBAAsB,CAAC,SAAS,SAAS,mBAAmB,EAC1E,SAAS,EAAE,SAAS,GACnB,0BAA0B,CAAC,SAAS,CAAC,CAEvC;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,SAAS,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAClC,eAAe,SAAS,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,EAClD,SAAS,SAAS,wBAAwB,CAAC,eAAe,CAAC,EAC3D,SAAS,EAAE,SAAS,GAAG,eAAe,CAEvC;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,CAAC,SAAS,SAAS,mBAAmB,IAAI;IAC9E,oBAAoB,CAAC,mBAAmB,EAAE,SAAS,CAAC;CACrD,GAAG,CAAC,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,SAAS;IAC/C;QACE,SAAS,EAAE,MAAM,mBAAmB,SAAS,KAAK,CAAC,aAAa,CAAC;KAClE;CACF,GACwD,IAAI,CACvD,cAAc,CAAC,mBAAmB,CAAC,EACnC,mBAAmB,CACpB,GACD,KAAK,CAAC,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,mBAAmB,EAAE,EAC3E,mBAAmB,EAAE,SAAS,EAC9B,GAAG,KAAK,EACT,EAAE,0BAA0B,CAAC,SAAS,CAAC,2CAGvC"}
|
|
@@ -0,0 +1 @@
|
|
|
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;AAKtD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,iBAAiB,GAC/B,GAAG,CAAC,OAAO,EAAE,CAmDf"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@etrepum/lexical-react-extension",
|
|
3
|
+
"description": "[EXPERIMENTAL] Lexical Builder React extension",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lexical",
|
|
7
|
+
"lexical-builder",
|
|
8
|
+
"react",
|
|
9
|
+
"plug-in",
|
|
10
|
+
"extension"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc --noEmit && vite build",
|
|
14
|
+
"dev": "vite",
|
|
15
|
+
"lint": "eslint",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest"
|
|
18
|
+
},
|
|
19
|
+
"version": "0.0.36",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/etrepum/lexical-builder.git",
|
|
24
|
+
"directory": "packages/lexical-react-extension"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/etrepum/lexical-builder/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/etrepum/lexical-builder",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@etrepum/lexical-builder": "*"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@lexical/react": ">=0.33.1 || >=0.33.2-nightly.0",
|
|
35
|
+
"@lexical/text": ">=0.33.1 || >=0.33.2-nightly.0",
|
|
36
|
+
"@lexical/utils": ">=0.33.1 || >=0.33.2-nightly.0",
|
|
37
|
+
"lexical": ">=0.33.1 || >=0.33.2-nightly.0",
|
|
38
|
+
"react": ">=18"
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@repo/eslint-config": "*",
|
|
43
|
+
"@testing-library/dom": "^10.1.0",
|
|
44
|
+
"@testing-library/jest-dom": "^6.4.5",
|
|
45
|
+
"@testing-library/react": "^16.0.0",
|
|
46
|
+
"@testing-library/user-event": "^14.5.2",
|
|
47
|
+
"@types/react-dom": "^18.3.0",
|
|
48
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
49
|
+
"eslint": "^8.57.0",
|
|
50
|
+
"jsdom": "^24.1.0",
|
|
51
|
+
"tslib": "^2.6.2",
|
|
52
|
+
"typescript": "^5.5.2",
|
|
53
|
+
"vite": "^5.4.0",
|
|
54
|
+
"vite-plugin-dts": "^4.0.2",
|
|
55
|
+
"vite-plugin-package-version": "^1.1.0",
|
|
56
|
+
"vitest": "^2.0.5"
|
|
57
|
+
},
|
|
58
|
+
"exports": {
|
|
59
|
+
".": {
|
|
60
|
+
"types": "./dist/index.d.ts",
|
|
61
|
+
"default": "./dist/index.js"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"files": [
|
|
65
|
+
"dist"
|
|
66
|
+
]
|
|
67
|
+
}
|