@mdxeditor/editor 0.11.1 → 0.13.0

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.
Files changed (47) hide show
  1. package/dist/MDXEditor.d.ts +8 -0
  2. package/dist/MDXEditor.js +13 -10
  3. package/dist/exportMarkdownFromLexical.d.ts +19 -0
  4. package/dist/gurx/react.d.ts +34 -6
  5. package/dist/gurx/realm.d.ts +18 -2
  6. package/dist/gurx/realmFactory.d.ts +23 -2
  7. package/dist/icons/rich_text.svg.js +2 -2
  8. package/dist/importMarkdownToLexical.d.ts +7 -0
  9. package/dist/plugins/codeblock/index.d.ts +23 -3
  10. package/dist/plugins/codemirror/index.d.ts +31 -3
  11. package/dist/plugins/core/NestedLexicalEditor.d.ts +1 -1
  12. package/dist/plugins/core/NestedLexicalEditor.js +4 -4
  13. package/dist/plugins/core/SharedHistoryPlugin.js +1 -1
  14. package/dist/plugins/core/index.d.ts +31 -3
  15. package/dist/plugins/core/index.js +11 -1
  16. package/dist/plugins/diff-source/index.d.ts +23 -3
  17. package/dist/plugins/directives/index.d.ts +23 -3
  18. package/dist/plugins/frontmatter/FrontmatterEditor.js +1 -2
  19. package/dist/plugins/frontmatter/index.d.ts +23 -3
  20. package/dist/plugins/headings/index.d.ts +5 -1
  21. package/dist/plugins/image/ImageEditor.js +2 -2
  22. package/dist/plugins/image/index.d.ts +23 -3
  23. package/dist/plugins/jsx/index.d.ts +22 -2
  24. package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
  25. package/dist/plugins/link/AutoLinkPlugin.js +18 -0
  26. package/dist/plugins/link/index.d.ts +22 -4
  27. package/dist/plugins/link/index.js +16 -5
  28. package/dist/plugins/link-dialog/index.d.ts +19 -3
  29. package/dist/plugins/link-dialog/index.js +1 -0
  30. package/dist/plugins/lists/index.d.ts +23 -3
  31. package/dist/plugins/lists/index.js +2 -2
  32. package/dist/plugins/markdown-shortcut/index.d.ts +2 -0
  33. package/dist/plugins/markdown-shortcut/index.js +1 -1
  34. package/dist/plugins/quote/index.d.ts +17 -3
  35. package/dist/plugins/sandpack/index.d.ts +30 -2
  36. package/dist/plugins/table/TableEditor.js +5 -5
  37. package/dist/plugins/table/index.d.ts +23 -3
  38. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +1 -1
  39. package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +1 -1
  40. package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +1 -1
  41. package/dist/plugins/thematic-break/index.d.ts +23 -3
  42. package/dist/plugins/thematic-break/index.js +2 -2
  43. package/dist/plugins/toolbar/index.d.ts +18 -2
  44. package/dist/plugins/toolbar/primitives/select.js +1 -1
  45. package/dist/style.css +186 -164
  46. package/dist/styles/ui.module.css.js +90 -84
  47. package/package.json +1 -1
@@ -34,6 +34,14 @@ export interface MDXEditorProps {
34
34
  * For a content-specific styling, Use `contentEditableClassName` property.
35
35
  */
36
36
  className?: string;
37
+ /**
38
+ * pass if you would like to have the editor automatically focused when mounted.
39
+ */
40
+ autoFocus?: boolean;
41
+ /**
42
+ * The placeholder contents, displayed when the editor is empty.
43
+ */
44
+ placeholder?: React.ReactNode;
37
45
  }
38
46
  /**
39
47
  * The interface for the {@link MDXEditor} object reference.
package/dist/MDXEditor.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import React__default from "react";
2
2
  import { corePlugin, corePluginHooks } from "./plugins/core/index.js";
3
3
  import { lexicalTheme } from "./styles/lexicalTheme.js";
4
- import { LexicalComposer } from "@lexical/react/LexicalComposer";
4
+ import { LexicalComposer } from "@lexical/react/LexicalComposer.js";
5
5
  import styles from "./styles/ui.module.css.js";
6
- import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
7
- import { ContentEditable } from "@lexical/react/LexicalContentEditable";
8
- import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
6
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin.js";
7
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable.js";
8
+ import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary.js";
9
9
  import classNames from "classnames";
10
10
  import { noop } from "./utils/fp.js";
11
11
  import { RealmPluginInitializer } from "./gurx/react.js";
@@ -28,20 +28,21 @@ const LexicalProvider = ({ children }) => {
28
28
  );
29
29
  };
30
30
  const RichTextEditor = () => {
31
- const [contentEditableClassName, composerChildren, topAreaChildren, editorWrappers] = corePluginHooks.useEmitterValues(
31
+ const [contentEditableClassName, composerChildren, topAreaChildren, editorWrappers, placeholder] = corePluginHooks.useEmitterValues(
32
32
  "contentEditableClassName",
33
33
  "composerChildren",
34
34
  "topAreaChildren",
35
- "editorWrappers"
35
+ "editorWrappers",
36
+ "placeholder"
36
37
  );
37
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, topAreaChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(RenderRecurisveWrappers, { wrappers: editorWrappers }, /* @__PURE__ */ React__default.createElement(
38
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, topAreaChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })), /* @__PURE__ */ React__default.createElement(RenderRecurisveWrappers, { wrappers: editorWrappers }, /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.rootContentEditableWrapper) }, /* @__PURE__ */ React__default.createElement(
38
39
  RichTextPlugin,
39
40
  {
40
41
  contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { className: classNames(styles.contentEditable, contentEditableClassName) }),
41
- placeholder: /* @__PURE__ */ React__default.createElement("div", null),
42
+ placeholder: /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.contentEditable, styles.placeholder) }, /* @__PURE__ */ React__default.createElement("p", null, placeholder)),
42
43
  ErrorBoundary: LexicalErrorBoundary
43
44
  }
44
- )), composerChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
45
+ ))), composerChildren.map((Child, index) => /* @__PURE__ */ React__default.createElement(Child, { key: index })));
45
46
  };
46
47
  const DEFAULT_MARKDOWN_OPTIONS = {
47
48
  listItemIndent: "one"
@@ -91,7 +92,9 @@ const MDXEditor = React__default.forwardRef((props, ref) => {
91
92
  contentEditableClassName: props.contentEditableClassName ?? "",
92
93
  initialMarkdown: props.markdown,
93
94
  onChange: props.onChange ?? noop,
94
- toMarkdownOptions: props.toMarkdownOptions ?? DEFAULT_MARKDOWN_OPTIONS
95
+ toMarkdownOptions: props.toMarkdownOptions ?? DEFAULT_MARKDOWN_OPTIONS,
96
+ autoFocus: props.autoFocus ?? false,
97
+ placeholder: props.placeholder ?? ""
95
98
  }),
96
99
  ...props.plugins || []
97
100
  ]
@@ -74,15 +74,31 @@ export interface LexicalExportVisitor<LN extends LexicalNode, UN extends Mdast.C
74
74
  */
75
75
  join?<T extends Mdast.Content>(prevNode: T, currentNode: T): T;
76
76
  }
77
+ /**
78
+ * The "any" type for LexicalExportVisitor.
79
+ * @internal
80
+ */
77
81
  export type LexicalVisitor = LexicalExportVisitor<LexicalNode, Mdast.Content>;
82
+ /**
83
+ * @internal
84
+ */
78
85
  export interface ExportLexicalTreeOptions {
79
86
  root: LexicalRootNode;
80
87
  visitors: LexicalVisitor[];
81
88
  jsxComponentDescriptors: JsxComponentDescriptor[];
82
89
  jsxIsAvailable: boolean;
83
90
  }
91
+ /**
92
+ * @internal
93
+ */
84
94
  export declare function exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors, jsxIsAvailable }: ExportLexicalTreeOptions): Mdast.Root;
95
+ /**
96
+ * @internal
97
+ */
85
98
  export type ToMarkdownExtension = NonNullable<ToMarkdownOptions['extensions']>[number];
99
+ /**
100
+ * @internal
101
+ */
86
102
  export interface ExportMarkdownFromLexicalOptions extends ExportLexicalTreeOptions {
87
103
  visitors: LexicalVisitor[];
88
104
  /**
@@ -111,4 +127,7 @@ export interface LexicalConvertOptions {
111
127
  */
112
128
  toMarkdownOptions?: ToMarkdownOptions;
113
129
  }
130
+ /**
131
+ * @internal
132
+ */
114
133
  export declare function exportMarkdownFromLexical({ root, toMarkdownOptions, toMarkdownExtensions, visitors, jsxComponentDescriptors, jsxIsAvailable }: ExportMarkdownFromLexicalOptions): string;
@@ -4,7 +4,7 @@ import type { ValuesForKeys, TypedRealm, System, RealmFactory, ValueForKey,
4
4
  /**
5
5
  * Describes the mapping between the system streams and the component properties.
6
6
  * Each property uses the keys as the names of the properties and the values as the corresponding stream names.
7
- * @typeParam SS the type of the system.
7
+ * @typeParam SS - the type of the system.
8
8
  */
9
9
  export interface SystemPropsMap<Sys extends System, K = keyof Sys, D = {
10
10
  [name: string]: K;
@@ -42,8 +42,10 @@ export type MethodsFromPropMap<Sys extends System, Map extends SystemPropsMap<Sy
42
42
  [K in StringKeys<Map['methods']>]: Map['methods'][K] extends string ? Sys[Map['methods'][K]] extends RealmNode<infer R> ? (value: R) => void : never : never;
43
43
  };
44
44
  /**
45
- * Used to correctly specify type refs for system components
45
+ * @internal
46
+ * Used to correctly specify type refs for system components.
46
47
  *
48
+ * @example
47
49
  * ```tsx
48
50
  * const s = system(() => { return { a: statefulStream(0) } })
49
51
  * const { Component } = systemToComponent(s)
@@ -54,15 +56,15 @@ export type MethodsFromPropMap<Sys extends System, Map extends SystemPropsMap<Sy
54
56
  * }
55
57
  * ```
56
58
  *
57
- * @typeParam T the type of the component
59
+ * @typeParam T - the type of the component
58
60
  */
59
61
  export type RefHandle<T> = T extends React.ForwardRefExoticComponent<React.RefAttributes<infer Handle>> ? Handle : never;
60
62
  /**
61
63
  * Converts a system spec to React component by mapping the system streams to component properties, events and methods. Returns hooks for querying and modifying
62
64
  * the system streams from the component's child components.
63
- * @param realmFactory The return value from a [[system]] call.
64
- * @param map The streams to props / events / methods mapping Check [[SystemPropsMap]] for more details.
65
- * @param Root The optional React component to render. By default, the resulting component renders nothing, acting as a logical wrapper for its children.
65
+ * @param realmFactory - The return value from a [[system]] call.
66
+ * @param map - The streams to props / events / methods mapping Check [[SystemPropsMap]] for more details.
67
+ * @param Root - The optional React component to render. By default, the resulting component renders nothing, acting as a logical wrapper for its children.
66
68
  * @returns an object containing the following:
67
69
  * - `Component`: the React component.
68
70
  * - `useEmitterValue`: a hook that lets child components use values emitted from the specified output stream.
@@ -80,6 +82,7 @@ export declare function realmFactoryToComponent<RootComp, RF extends RealmFactor
80
82
  children?: React.ReactNode;
81
83
  })> & React.RefAttributes<MethodsFromPropMap<Sys, M>>>;
82
84
  };
85
+ /** @internal */
83
86
  export declare function sysHooks<Sys extends System>(): {
84
87
  useRealmContext: () => TypedRealm<Sys>;
85
88
  useEmitter: <K extends Extract<keyof Sys, string>>(key: K, callback: (value: ValueForKey<Sys, K>) => void) => void;
@@ -88,18 +91,40 @@ export declare function sysHooks<Sys extends System>(): {
88
91
  usePublisher: <K_2 extends keyof Sys>(key: K_2) => (value: ValueForKey<Sys, K_2>) => void;
89
92
  };
90
93
  type SystemAndDependencies<Spec extends AnySystemSpec> = SystemOfSpecs<[Spec]> & SystemOfSpecs<Spec['dependencies']>;
94
+ /**
95
+ * The parameters of a plugin declaration. THe best way to understand what each one does is to examine the source code of the existing plugins.
96
+ */
91
97
  export interface RealmPluginParams<Spec extends AnySystemSpec, Params extends object> {
98
+ /**
99
+ * The id of the plugin. Used to declare conditional features that are activated only if the plugin is present.
100
+ */
92
101
  id: string;
102
+ /**
103
+ * The ids of the plugins that this plugin depends on. The plugin will not be activated if any of the dependencies is not present.
104
+ */
93
105
  dependencies?: string[];
106
+ /**
107
+ * The system spec of the plugin. Construct one using {@link system}.
108
+ */
94
109
  systemSpec: Spec;
110
+ /**
111
+ * The callback is executed every time the react component is re-rendered.
112
+ */
95
113
  applyParamsToSystem?: (realm: TypedRealm<SystemAndDependencies<Spec>>, props: Params) => void;
114
+ /**
115
+ * Executed when the component mounts. Use this to register import/export visitors, add lexical nodes to the editor, etc.
116
+ */
96
117
  init?: (realm: TypedRealm<SystemAndDependencies<Spec>>, props: Params) => void;
97
118
  }
119
+ /** @internal */
98
120
  export interface PluginConstructor<Spec extends AnySystemSpec, Params extends object> {
99
121
  (params?: Params): {
100
122
  pluginParams?: Params;
101
123
  } & RealmPluginParams<Spec, Params>;
102
124
  }
125
+ /**
126
+ * Declares a new MDXEditor plugin.
127
+ */
103
128
  export declare function realmPlugin<Spec extends AnySystemSpec, Params extends object>(params: RealmPluginParams<Spec, Params>): readonly [PluginConstructor<Spec, Params>, {
104
129
  useRealmContext: () => TypedRealm<SystemAndDependencies<Spec>>;
105
130
  useEmitter: <K extends Extract<keyof (Spec extends AnySystemSpec ? {} & ReturnType<Spec["constructor"]> : never), string> | Extract<keyof SystemOfSpecs<Spec["dependencies"]>, string>>(key: K, callback: (value: ValueForKey<SystemAndDependencies<Spec>, K>) => void) => void;
@@ -107,13 +132,16 @@ export declare function realmPlugin<Spec extends AnySystemSpec, Params extends o
107
132
  usePubKeys: () => (values: SystemDict<SystemAndDependencies<Spec>>) => void;
108
133
  usePublisher: <K_2 extends keyof (Spec extends AnySystemSpec ? {} & ReturnType<Spec["constructor"]> : never) | keyof SystemOfSpecs<Spec["dependencies"]>>(key: K_2) => (value: ValueForKey<SystemAndDependencies<Spec>, K_2>) => void;
109
134
  }];
135
+ /** @internal */
110
136
  export declare const RealmPluginInitializer: <P extends ({
111
137
  pluginParams?: any;
112
138
  } & RealmPluginParams<AnySystemSpec, any>)[]>({ plugins, children }: {
113
139
  plugins: P;
114
140
  children?: React.ReactNode;
115
141
  }) => React.FunctionComponentElement<React.ProviderProps<TypedRealm<any>>>;
142
+ /** @internal */
116
143
  export declare function useHasPlugin(id: string): boolean;
144
+ /** @internal */
117
145
  export declare const RequirePlugin: React.FC<{
118
146
  id: string;
119
147
  children: React.ReactNode;
@@ -1,20 +1,26 @@
1
1
  import { LongTuple } from './realmFactory';
2
+ /** @internal */
2
3
  export type NodeKey = string;
3
- export interface RealmNode<T = unknown> {
4
+ /** @internal */
5
+ export interface RealmNode<_T = unknown> {
4
6
  key: NodeKey;
5
7
  toString(): string;
6
8
  }
7
9
  /** @internal */
8
10
  type RN<T = unknown> = RealmNode<T>;
11
+ /** @internal **/
9
12
  export type Subscription<T = any> = (value: T) => unknown;
13
+ /** @internal */
10
14
  export type UnsubscribeHandle = () => void;
11
15
  type ProjectionFunc<T extends unknown[] = unknown[]> = (done: (...values: unknown[]) => void) => (...args: T) => void;
16
+ /** @internal */
12
17
  export interface RealmProjection<T extends unknown[] = unknown[]> {
13
18
  sources: Set<NodeKey>;
14
19
  pulls: Set<NodeKey>;
15
20
  sink: NodeKey;
16
21
  map: ProjectionFunc<T>;
17
22
  }
23
+ /** @internal */
18
24
  export interface RealmProjectionSpec<T extends unknown[] = unknown[]> {
19
25
  sources: RealmNode[];
20
26
  pulls?: RealmNode[];
@@ -23,14 +29,18 @@ export interface RealmProjectionSpec<T extends unknown[] = unknown[]> {
23
29
  }
24
30
  /**
25
31
  * A function which determines if two values are equal.
26
- * Implement custom comparators when [[distinctUntilChanged]] needs to work on non-primitive objects.
32
+ * Implement custom comparators when the distinctUntilChanged operator needs to work on non-primitive objects.
27
33
  * @returns true if values should be considered equal.
28
34
  */
29
35
  export interface Comparator<T = any> {
30
36
  (current: T, next: T): boolean;
31
37
  }
32
38
  type NodesFromValuesRec<T extends unknown[], Acc extends unknown[]> = T extends [infer Head, ...infer Tail] ? NodesFromValuesRec<Tail, [...Acc, Head extends unknown ? RealmNode<Head> : never]> : Acc;
39
+ /** @internal */
33
40
  export type NodesFromValues<T extends unknown[]> = T extends unknown[] ? NodesFromValuesRec<T, []> : never;
41
+ /**
42
+ * A comparator function to determine if two values are equal. Used by distinctUntilChanged operator.
43
+ */
34
44
  export declare function defaultComparator<T>(current: T, next: T): boolean;
35
45
  declare class SetMap<T> {
36
46
  map: Map<string, Set<T>>;
@@ -39,6 +49,9 @@ declare class SetMap<T> {
39
49
  use(key: NodeKey, cb: (value: Set<T>) => unknown): void;
40
50
  delete(key: NodeKey): boolean;
41
51
  }
52
+ /**
53
+ * @internal
54
+ */
42
55
  export declare class RefCount {
43
56
  map: Map<NodeKey, number>;
44
57
  constructor(map?: Map<string, number>);
@@ -46,7 +59,9 @@ export declare class RefCount {
46
59
  increment(key: NodeKey): void;
47
60
  decrement(key: NodeKey, ifZero: () => void): void;
48
61
  }
62
+ /** @internal */
49
63
  export type RealmGraph = SetMap<RealmProjection>;
64
+ /** @internal */
50
65
  export declare function realm(): {
51
66
  combine: {
52
67
  <T1>(nodes_0: RN<T1>): RN<T1>;
@@ -128,6 +143,7 @@ export declare function realm(): {
128
143
  subKey: (key: string, subscription: Subscription<unknown>) => UnsubscribeHandle;
129
144
  subKeys: (keys: string[], subscription: Subscription<unknown>) => UnsubscribeHandle;
130
145
  };
146
+ /** @internal */
131
147
  export interface Realm extends ReturnType<typeof realm> {
132
148
  }
133
149
  export {};
@@ -1,4 +1,7 @@
1
1
  import { Realm, RealmNode, Subscription, UnsubscribeHandle } from './realm';
2
+ /**
3
+ * The system interface is the runtime representation of a state management module, a a record of nodes.
4
+ */
2
5
  export interface System {
3
6
  [key: string]: RealmNode<any>;
4
7
  }
@@ -12,11 +15,13 @@ export interface SystemSpec<Dependencies extends AnySystemSpecs, /** @internal *
12
15
  constructor: Constructor;
13
16
  dependencies: Dependencies;
14
17
  }
18
+ /** @internal **/
15
19
  export interface AnySystemSpec extends SystemSpec<AnySystemSpecs, any> {
16
20
  id: string;
17
21
  }
18
- export interface AnySystemSpecs extends Array<AnySystemSpec> {
19
- }
22
+ /** @internal **/
23
+ export type AnySystemSpecs = Array<AnySystemSpec>;
24
+ /** @internal **/
20
25
  export type SystemOfSpec<Spec extends AnySystemSpec> = ReturnType<Spec['constructor']>;
21
26
  /** @internal **/
22
27
  export type SSR<Spec extends AnySystemSpec> = SystemOfSpec<Spec>;
@@ -30,19 +35,32 @@ type SystemsFromSpecsRec<ST extends unknown[], Acc extends unknown[]> = ST exten
30
35
  export interface SystemConstructor<D extends AnySystemSpecs> {
31
36
  (r: Realm, dependencies: SystemsFromSpecs<D>): System;
32
37
  }
38
+ /**
39
+ * Declare a new state management module (system). The constructor receives the realm and the dependencies as arguments.
40
+ * @param constructor - The system constructor.
41
+ * @param dependencies - The dependencies of the system - other systems.
42
+ */
33
43
  export declare function system<Dependencies extends LongTuple<AnySystemSpec>, Constructor extends SystemConstructor<Dependencies>>(constructor: Constructor, dependencies?: Dependencies): SystemSpec<Dependencies, Constructor>;
34
44
  type SystemKey<S extends System> = Extract<keyof S, string>;
45
+ /** @internal */
35
46
  export type ValuesForKeys<S extends System, K extends SystemKey<S>[]> = K extends unknown[] ? ValuesForKeysRec<S, K, []> : never;
36
47
  type ValuesForKeysRec<S extends Record<any, RealmNode>, K extends unknown[], Acc extends unknown[]> = K extends [infer Head, ...infer Tail] ? ValuesForKeysRec<S, Tail, [...Acc, S[Head] extends RealmNode<infer R> ? R : never]> : Acc;
48
+ /** @internal **/
37
49
  export type SystemOfSpecs<Specs extends AnySystemSpec[]> = Specs extends unknown[] ? SystemOfSpecsRec<Specs, {}> : Specs;
38
50
  type SystemOfSpecsRec<Specs extends unknown[], Acc extends {}> = Specs extends [infer Head, ...infer Tail] ? SystemOfSpecsRec<Tail, Head extends AnySystemSpec ? Acc & SystemOfSpec<Head> : never> : Acc;
51
+ /** @internal */
39
52
  export type LongTuple<K> = [] | [K] | [K, K] | [K, K, K] | [K, K, K, K] | [K, K, K, K, K] | [K, K, K, K, K, K] | [K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K] | [K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K, K];
53
+ /** @internal */
40
54
  export type SystemKeys<S extends System, K extends Extract<keyof S, string> = Extract<keyof S, string>> = LongTuple<K>;
55
+ /** @internal */
41
56
  export type ValueForKey<S extends System, K extends keyof S> = S[K] extends RealmNode<infer V> ? V : never;
57
+ /** @internal */
42
58
  export type SystemDict<S extends System> = {
43
59
  [K in keyof S]?: ValueForKey<S, K>;
44
60
  };
61
+ /** @internal */
45
62
  export type SystemKeysArray<S extends System> = Array<keyof S>;
63
+ /** @internal */
46
64
  export interface TypedRealm<S extends System> extends Pick<Realm, 'sub' | 'pub' | 'spread' | 'derive' | 'singletonSubKey' | 'resetSingletonSubs'> {
47
65
  getKeyValues<K extends SystemKeys<S>>(keys: K): ValuesForKeys<S, K>;
48
66
  getKeyValue<K extends keyof S>(key: K): ValueForKey<S, K>;
@@ -52,7 +70,10 @@ export interface TypedRealm<S extends System> extends Pick<Realm, 'sub' | 'pub'
52
70
  subKey<K extends keyof S>(key: K, subscription: Subscription<ValueForKey<S, K>>): UnsubscribeHandle;
53
71
  subKeys<K extends SystemKeys<S>>(keys: K, subscription: Subscription<ValuesForKeys<S, K>>): UnsubscribeHandle;
54
72
  }
73
+ /** @internal */
55
74
  export declare function realmFactory<Specs extends LongTuple<AnySystemSpec>>(...specs: Specs): TypedRealm<SystemOfSpecs<Specs>>;
75
+ /** @internal */
56
76
  export type RealmFactory<Sys extends System> = () => TypedRealm<Sys>;
77
+ /** @internal */
57
78
  export declare function getRealmFactory<Specs extends LongTuple<AnySystemSpec>>(...specs: Specs): () => TypedRealm<SystemOfSpecs<[...Specs]>>;
58
79
  export {};
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
- const SvgRichText = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "mask0_318_249", style: {
2
+ const SvgRichText = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "mask0_447_68", style: {
3
3
  maskType: "alpha"
4
- }, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 24, height: 24 }, /* @__PURE__ */ React.createElement("rect", { width: 24, height: 24, fill: "#D9D9D9" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#mask0_318_249)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 22V20H19V22H5Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M6.80005 18V4H12.325C13.4084 4 14.4084 4.33333 15.325 5C16.2417 5.66667 16.7001 6.59167 16.7001 7.775C16.7001 8.625 16.5084 9.279 16.125 9.737C15.7417 10.1957 15.3834 10.525 15.05 10.725C15.4667 10.9083 15.9294 11.25 16.438 11.75C16.946 12.25 17.2001 13 17.2001 14C17.2001 15.4833 16.6584 16.521 15.575 17.113C14.4917 17.7043 13.475 18 12.525 18H6.80005ZM9.82505 15.2H12.425C13.225 15.2 13.7124 14.9957 13.887 14.587C14.0624 14.179 14.15 13.8833 14.15 13.7C14.15 13.5167 14.0624 13.2207 13.887 12.812C13.7124 12.404 13.2 12.2 12.35 12.2H9.82505V15.2ZM9.82505 9.5H12.15C12.7 9.5 13.1 9.35833 13.35 9.075C13.6 8.79167 13.725 8.475 13.725 8.125C13.725 7.725 13.5834 7.4 13.3 7.15C13.0167 6.9 12.65 6.775 12.2 6.775H9.82505V9.5Z", fill: "currentColor" })));
4
+ }, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 24, height: 24 }, /* @__PURE__ */ React.createElement("rect", { width: 24, height: 24, fill: "#D9D9D9" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#mask0_447_68)" }, /* @__PURE__ */ React.createElement("path", { d: "M6 17H18L14.25 12L11.25 16L9 13L6 17ZM3 21V3H21V21H3ZM5 19H19V5H5V19Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M6 12V6H11V12H9.5V10.5H7.5V12H6ZM7.5 9H9.5V7.5H7.5V9Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M12 6H18V7.5H12V6Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M12 9H18V10.5H12V9Z", fill: "currentColor" })));
5
5
  const RichTextIcon = SvgRichText;
6
6
  export {
7
7
  RichTextIcon as default
@@ -3,6 +3,7 @@ import * as Mdast from 'mdast';
3
3
  import { fromMarkdown } from 'mdast-util-from-markdown';
4
4
  import { ParseOptions } from 'micromark-util-types';
5
5
  import { IS_BOLD, IS_ITALIC, IS_UNDERLINE } from './FormatConstants';
6
+ /** @internal */
6
7
  export type MdastExtensions = NonNullable<Parameters<typeof fromMarkdown>[1]>['mdastExtensions'];
7
8
  /**
8
9
  * A set of actions that can be used to modify the lexical tree while visiting the mdast tree.
@@ -61,12 +62,14 @@ export interface MdastImportVisitor<UN extends Mdast.Content> {
61
62
  }
62
63
  /**
63
64
  * The options of the tree import utility. Not meant to be used directly.
65
+ * @internal
64
66
  */
65
67
  export interface MdastTreeImportOptions {
66
68
  root: LexicalRootNode;
67
69
  visitors: MdastImportVisitor<Mdast.Content>[];
68
70
  mdastRoot: Mdast.Root;
69
71
  }
72
+ /** @internal */
70
73
  export interface MarkdownParseOptions extends Omit<MdastTreeImportOptions, 'mdastRoot'> {
71
74
  markdown: string;
72
75
  syntaxExtensions: NonNullable<ParseOptions['extensions']>;
@@ -74,11 +77,15 @@ export interface MarkdownParseOptions extends Omit<MdastTreeImportOptions, 'mdas
74
77
  }
75
78
  /**
76
79
  * An extension for the `fromMarkdown` utility tree construction.
80
+ * @internal
77
81
  */
78
82
  export type MdastExtension = NonNullable<MdastExtensions>[number];
79
83
  /**
80
84
  * An extension for the `fromMarkdown` utility markdown parse.
85
+ * @internal
81
86
  */
82
87
  export type SyntaxExtension = MarkdownParseOptions['syntaxExtensions'][number];
88
+ /** @internal */
83
89
  export declare function importMarkdownToLexical({ root, markdown, visitors, syntaxExtensions, mdastExtensions }: MarkdownParseOptions): void;
90
+ /** @internal */
84
91
  export declare function importMdastTreeToLexical({ root, mdastRoot, visitors }: MdastTreeImportOptions): void;
@@ -1,4 +1,4 @@
1
- import type { RefObject, ComponentType, ReactNode } from 'react';
1
+ import type { RefObject, ReactNode, ComponentType } from 'react';
2
2
  import type { Options } from 'mdast-util-to-markdown';
3
3
  import type { Config } from 'mdast-util-from-markdown/lib';
4
4
  import type { Extension } from 'micromark-util-types';
@@ -94,6 +94,8 @@ export declare const codeBlockSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
94
94
  markdown: RealmNode<string>;
95
95
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
96
96
  contentEditableClassName: RealmNode<string>;
97
+ placeholder: RealmNode<ReactNode>;
98
+ autoFocus: RealmNode<boolean>;
97
99
  composerChildren: RealmNode<ComponentType<{}>[]>;
98
100
  addComposerChild: RealmNode<ComponentType<{}>>;
99
101
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -142,6 +144,8 @@ export declare const codeBlockSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
142
144
  markdown: RealmNode<string>;
143
145
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
144
146
  contentEditableClassName: RealmNode<string>;
147
+ placeholder: RealmNode<ReactNode>;
148
+ autoFocus: RealmNode<boolean>;
145
149
  composerChildren: RealmNode<ComponentType<{}>[]>;
146
150
  addComposerChild: RealmNode<ComponentType<{}>>;
147
151
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -213,6 +217,8 @@ codeBlockPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
213
217
  markdown: RealmNode<string>;
214
218
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
215
219
  contentEditableClassName: RealmNode<string>;
220
+ placeholder: RealmNode<ReactNode>;
221
+ autoFocus: RealmNode<boolean>;
216
222
  composerChildren: RealmNode<ComponentType<{}>[]>;
217
223
  addComposerChild: RealmNode<ComponentType<{}>>;
218
224
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -261,6 +267,8 @@ codeBlockPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
261
267
  markdown: RealmNode<string>;
262
268
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
263
269
  contentEditableClassName: RealmNode<string>;
270
+ placeholder: RealmNode<ReactNode>;
271
+ autoFocus: RealmNode<boolean>;
264
272
  composerChildren: RealmNode<ComponentType<{}>[]>;
265
273
  addComposerChild: RealmNode<ComponentType<{}>>;
266
274
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -324,6 +332,8 @@ codeBlockPluginHooks: {
324
332
  markdown: RealmNode<string>;
325
333
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
326
334
  contentEditableClassName: RealmNode<string>;
335
+ placeholder: RealmNode<ReactNode>;
336
+ autoFocus: RealmNode<boolean>;
327
337
  composerChildren: RealmNode<ComponentType<{}>[]>;
328
338
  addComposerChild: RealmNode<ComponentType<{}>>;
329
339
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -344,7 +354,7 @@ codeBlockPluginHooks: {
344
354
  convertSelectionToNode: RealmNode<() => ElementNode>;
345
355
  insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
346
356
  }>;
347
- useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "codeBlockEditorDescriptors" | "defaultCodeBlockLanguage" | "appendCodeBlockEditorDescriptor" | "insertCodeBlock">(key: K, callback: (value: ValueForKey<{
357
+ useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "codeBlockEditorDescriptors" | "defaultCodeBlockLanguage" | "appendCodeBlockEditorDescriptor" | "insertCodeBlock">(key: K, callback: (value: ValueForKey<{
348
358
  codeBlockEditorDescriptors: RealmNode<CodeBlockEditorDescriptor[]>;
349
359
  defaultCodeBlockLanguage: RealmNode<string>;
350
360
  appendCodeBlockEditorDescriptor: RealmNode<CodeBlockEditorDescriptor>;
@@ -378,6 +388,8 @@ codeBlockPluginHooks: {
378
388
  markdown: RealmNode<string>;
379
389
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
380
390
  contentEditableClassName: RealmNode<string>;
391
+ placeholder: RealmNode<ReactNode>;
392
+ autoFocus: RealmNode<boolean>;
381
393
  composerChildren: RealmNode<ComponentType<{}>[]>;
382
394
  addComposerChild: RealmNode<ComponentType<{}>>;
383
395
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -432,6 +444,8 @@ codeBlockPluginHooks: {
432
444
  markdown: RealmNode<string>;
433
445
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
434
446
  contentEditableClassName: RealmNode<string>;
447
+ placeholder: RealmNode<ReactNode>;
448
+ autoFocus: RealmNode<boolean>;
435
449
  composerChildren: RealmNode<ComponentType<{}>[]>;
436
450
  addComposerChild: RealmNode<ComponentType<{}>>;
437
451
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -485,6 +499,8 @@ codeBlockPluginHooks: {
485
499
  markdown: RealmNode<string>;
486
500
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
487
501
  contentEditableClassName: RealmNode<string>;
502
+ placeholder: RealmNode<ReactNode>;
503
+ autoFocus: RealmNode<boolean>;
488
504
  composerChildren: RealmNode<ComponentType<{}>[]>;
489
505
  addComposerChild: RealmNode<ComponentType<{}>>;
490
506
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -539,6 +555,8 @@ codeBlockPluginHooks: {
539
555
  markdown: RealmNode<string>;
540
556
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
541
557
  contentEditableClassName: RealmNode<string>;
558
+ placeholder: RealmNode<ReactNode>;
559
+ autoFocus: RealmNode<boolean>;
542
560
  composerChildren: RealmNode<ComponentType<{}>[]>;
543
561
  addComposerChild: RealmNode<ComponentType<{}>>;
544
562
  topAreaChildren: RealmNode<ComponentType<{}>[]>;
@@ -559,7 +577,7 @@ codeBlockPluginHooks: {
559
577
  convertSelectionToNode: RealmNode<() => ElementNode>;
560
578
  insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
561
579
  }>) => void;
562
- usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "codeBlockEditorDescriptors" | "defaultCodeBlockLanguage" | "appendCodeBlockEditorDescriptor" | "insertCodeBlock">(key: K_2) => (value: ValueForKey<{
580
+ usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "codeBlockEditorDescriptors" | "defaultCodeBlockLanguage" | "appendCodeBlockEditorDescriptor" | "insertCodeBlock">(key: K_2) => (value: ValueForKey<{
563
581
  codeBlockEditorDescriptors: RealmNode<CodeBlockEditorDescriptor[]>;
564
582
  defaultCodeBlockLanguage: RealmNode<string>;
565
583
  appendCodeBlockEditorDescriptor: RealmNode<CodeBlockEditorDescriptor>;
@@ -593,6 +611,8 @@ codeBlockPluginHooks: {
593
611
  markdown: RealmNode<string>;
594
612
  editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
595
613
  contentEditableClassName: RealmNode<string>;
614
+ placeholder: RealmNode<ReactNode>;
615
+ autoFocus: RealmNode<boolean>;
596
616
  composerChildren: RealmNode<ComponentType<{}>[]>;
597
617
  addComposerChild: RealmNode<ComponentType<{}>>;
598
618
  topAreaChildren: RealmNode<ComponentType<{}>[]>;