@mdxeditor/editor 0.10.0-alpha.2 → 0.10.0-alpha.3
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/MDXEditor.d.ts +29 -0
- package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +13 -0
- package/dist/directive-editors/GenericDirectiveEditor.d.ts +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -1
- package/dist/jsx-editors/GenericJsxEditor.d.ts +5 -0
- package/dist/plugins/core/NestedLexicalEditor.d.ts +9 -2
- package/dist/plugins/core/PropertyPopover.d.ts +17 -2
- package/dist/plugins/diff-source/index.d.ts +1 -0
- package/dist/plugins/image/index.d.ts +4 -0
- package/dist/plugins/jsx/index.d.ts +9 -0
- package/dist/plugins/lists/LexicalListVisitor.js +0 -1
- package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +4 -0
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +3 -0
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +4 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +5 -0
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +2 -2
- package/dist/plugins/toolbar/components/CodeToggle.d.ts +4 -0
- package/dist/plugins/toolbar/components/CreateLink.d.ts +4 -0
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +5 -0
- package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +4 -0
- package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +5 -0
- package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +4 -0
- package/dist/plugins/toolbar/components/InsertImage.d.ts +4 -0
- package/dist/plugins/toolbar/components/InsertSandpack.d.ts +4 -0
- package/dist/plugins/toolbar/components/InsertTable.d.ts +4 -0
- package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +4 -0
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +5 -0
- package/dist/plugins/toolbar/components/ListsToggle.d.ts +5 -0
- package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +5 -0
- package/dist/plugins/toolbar/components/UndoRedo.d.ts +3 -0
- package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +3 -0
- package/dist/plugins/toolbar/primitives/select.d.ts +19 -0
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +80 -5
- package/package.json +11 -1
package/dist/MDXEditor.d.ts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RealmPluginInitializer } from './gurx';
|
|
3
3
|
import { ToMarkdownOptions } from './exportMarkdownFromLexical';
|
|
4
|
+
/**
|
|
5
|
+
* The properties of the {@link MDXEditor} React component.
|
|
6
|
+
*/
|
|
4
7
|
export interface MDXEditorProps {
|
|
8
|
+
/**
|
|
9
|
+
* the CSS class to apply to the content editable element of the editor.
|
|
10
|
+
* Use this to style the various content elements like lists and blockquotes.
|
|
11
|
+
*/
|
|
5
12
|
contentEditableClassName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The markdown to edit. Notice that this is read only when the component is mounted.
|
|
15
|
+
* To change the component content dynamically, use the `MDXEditorMethods.setMarkdown` method.
|
|
16
|
+
*/
|
|
6
17
|
markdown: string;
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when the editor value changes. The callback is not throttled, you can use any throttling mechanism
|
|
20
|
+
* if you intend to do auto-saving.
|
|
21
|
+
*/
|
|
7
22
|
onChange?: (markdown: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* The markdown options used to generate the resulting markdown.
|
|
25
|
+
* See {@link https://github.com/syntax-tree/mdast-util-to-markdown#options | the mdast-util-to-markdown docs} for the full list of options.
|
|
26
|
+
*/
|
|
8
27
|
toMarkdownOptions?: ToMarkdownOptions;
|
|
28
|
+
/**
|
|
29
|
+
* The plugins to use in the editor.
|
|
30
|
+
*/
|
|
9
31
|
plugins?: React.ComponentProps<typeof RealmPluginInitializer>['plugins'];
|
|
32
|
+
/**
|
|
33
|
+
* The class name to apply to the root component element. Use this if you want to change the editor dimensions, maximum height, etc.
|
|
34
|
+
* For a content-specific styling, Use `contentEditableClassName` property.
|
|
35
|
+
*/
|
|
10
36
|
className?: string;
|
|
11
37
|
}
|
|
12
38
|
/**
|
|
@@ -28,4 +54,7 @@ export interface MDXEditorMethods {
|
|
|
28
54
|
*/
|
|
29
55
|
setMarkdown: (value: string) => void;
|
|
30
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The MDXEditor React component. See {@link MDXEditorProps} for the list of properties supported and the {@link MDXEditorMethods} for the methods accessible through the ref.
|
|
59
|
+
*/
|
|
31
60
|
export declare const MDXEditor: React.ForwardRefExoticComponent<MDXEditorProps & React.RefAttributes<MDXEditorMethods>>;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { DirectiveDescriptor } from '../plugins/directives';
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare const ADMONITION_TYPES: readonly ["note", "tip", "danger", "info", "caution"];
|
|
4
|
+
/** @internal */
|
|
3
5
|
export type AdmonitionKind = (typeof ADMONITION_TYPES)[number];
|
|
6
|
+
/**
|
|
7
|
+
* Pass this descriptor to the `directivesPlugin` `directiveDescriptors` parameter to enable {@link https://docusaurus.io/docs/markdown-features/admonitions | markdown admonitions}.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <MDXEditor
|
|
12
|
+
* plugins={[
|
|
13
|
+
* directivesPlugin({ directiveDescriptors: [ AdmonitionDirectiveDescriptor] }),
|
|
14
|
+
* ]} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
4
17
|
export declare const AdmonitionDirectiveDescriptor: DirectiveDescriptor;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DirectiveEditorProps } from '../plugins/directives';
|
|
3
|
+
/**
|
|
4
|
+
* A generic editor that can be used as an universal UI for any directive.
|
|
5
|
+
* Allows editing of the directive content and properties.
|
|
6
|
+
* Use this editor for the {@link DirectiveDescriptor} Editor option.
|
|
7
|
+
*/
|
|
3
8
|
export declare const GenericDirectiveEditor: React.FC<DirectiveEditorProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -47,3 +47,5 @@ export * from './plugins/toolbar/primitives/toolbar';
|
|
|
47
47
|
export * from './plugins/toolbar/primitives/DialogButton';
|
|
48
48
|
export * from './plugins/toolbar/primitives/TooltipWrap';
|
|
49
49
|
export * from './plugins/toolbar/primitives/select';
|
|
50
|
+
export * from './plugins/core/NestedLexicalEditor';
|
|
51
|
+
export * from './plugins/core/PropertyPopover';
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,8 @@ import { Button, ButtonOrDropdownButton, ButtonWithTooltip, ConditionalContents,
|
|
|
42
42
|
import { DialogButton } from "./plugins/toolbar/primitives/DialogButton.js";
|
|
43
43
|
import { TooltipWrap } from "./plugins/toolbar/primitives/TooltipWrap.js";
|
|
44
44
|
import { Select, SelectButtonTrigger, SelectContent, SelectItem, SelectTrigger } from "./plugins/toolbar/primitives/select.js";
|
|
45
|
+
import { NestedEditorsContext, NestedLexicalEditor, useLexicalNodeRemove, useMdastNodeUpdater, useNestedEditorContext } from "./plugins/core/NestedLexicalEditor.js";
|
|
46
|
+
import { PropertyPopover } from "./plugins/core/PropertyPopover.js";
|
|
45
47
|
import { useCodeBlockEditorContext } from "./plugins/codeblock/CodeBlockNode.js";
|
|
46
48
|
export {
|
|
47
49
|
ADMONITION_TYPES,
|
|
@@ -72,6 +74,9 @@ export {
|
|
|
72
74
|
ListsToggle,
|
|
73
75
|
MDXEditor,
|
|
74
76
|
MultipleChoiceToggleGroup,
|
|
77
|
+
NestedEditorsContext,
|
|
78
|
+
NestedLexicalEditor,
|
|
79
|
+
PropertyPopover,
|
|
75
80
|
Root,
|
|
76
81
|
Select,
|
|
77
82
|
SelectButtonTrigger,
|
|
@@ -131,5 +136,8 @@ export {
|
|
|
131
136
|
toolbarPlugin,
|
|
132
137
|
toolbarPluginHooks,
|
|
133
138
|
toolbarSystem,
|
|
134
|
-
useCodeBlockEditorContext
|
|
139
|
+
useCodeBlockEditorContext,
|
|
140
|
+
useLexicalNodeRemove,
|
|
141
|
+
useMdastNodeUpdater,
|
|
142
|
+
useNestedEditorContext
|
|
135
143
|
};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { JsxEditorProps } from '../plugins/jsx';
|
|
3
|
+
/**
|
|
4
|
+
* A generic editor that can be used as an universal UI for any JSX element.
|
|
5
|
+
* Allows editing of the element content and properties.
|
|
6
|
+
* Use this editor for the {@link JsxComponentDescriptor} Editor option.
|
|
7
|
+
*/
|
|
3
8
|
export declare const GenericJsxEditor: React.FC<JsxEditorProps>;
|
|
@@ -13,7 +13,14 @@ interface NestedEditorsContextValue<T extends Node> {
|
|
|
13
13
|
};
|
|
14
14
|
focusEmitter: VoidEmitter;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Use this context to provide the necessary values to the {@link NestedLexicalEditor} React component.
|
|
18
|
+
* Place it as a wrapper in your custom lexical node decorators.
|
|
19
|
+
*/
|
|
16
20
|
export declare const NestedEditorsContext: React.Context<NestedEditorsContextValue<Node<import("unist").Data>> | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* A hook to get the current {@link NestedEditorsContext} value. Use this in your custom editor components.
|
|
23
|
+
*/
|
|
17
24
|
export declare const useNestedEditorContext: <T extends Mdast.Content>() => NestedEditorsContextValue<T>;
|
|
18
25
|
/**
|
|
19
26
|
* A hook that returns a function that can be used to update the mdast node. Use this in your custom editor components.
|
|
@@ -24,7 +31,7 @@ export declare function useMdastNodeUpdater<T extends Mdast.Content>(): (node: P
|
|
|
24
31
|
*/
|
|
25
32
|
export declare function useLexicalNodeRemove(): () => void;
|
|
26
33
|
/**
|
|
27
|
-
* The properties of the {@link
|
|
34
|
+
* The properties of the {@link NestedLexicalEditor} React component.
|
|
28
35
|
* @typeParam T - The type of the mdast node of the editor.
|
|
29
36
|
*/
|
|
30
37
|
export interface NestedEditorProps<T extends Mdast.Content> {
|
|
@@ -62,7 +69,7 @@ export interface NestedEditorProps<T extends Mdast.Content> {
|
|
|
62
69
|
* children: Mdast.PhrasingContent[]
|
|
63
70
|
* }
|
|
64
71
|
*
|
|
65
|
-
* return <
|
|
72
|
+
* return <NestedLexicalEditor<CalloutDirectiveNode> getContent={node => node.children} getUpdatedMdastNode={(node, children) => ({ ...node, children })} />
|
|
66
73
|
* ```
|
|
67
74
|
*/
|
|
68
75
|
export declare const NestedLexicalEditor: <T extends Mdast.Content>(props: NestedEditorProps<T>) => React.JSX.Element;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The properties of the {@link PropertyPopover} React component.
|
|
4
|
+
*/
|
|
5
|
+
export interface PropertyPopoverProps {
|
|
6
|
+
/**
|
|
7
|
+
* The properties to edit. The key is the name of the property, and the value is the initial value.
|
|
8
|
+
*/
|
|
3
9
|
properties: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Triggered when the user edits the property values.
|
|
12
|
+
*/
|
|
4
13
|
onChange: (values: Record<string, string>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* The title to display in the popover.
|
|
16
|
+
*/
|
|
5
17
|
title: string;
|
|
6
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* A React component that can be used in custom editors to edit the properties of the node.
|
|
21
|
+
* Displays a simple, static key/value editing UI in a popover.
|
|
22
|
+
*/
|
|
7
23
|
export declare const PropertyPopover: React.FC<PropertyPopoverProps>;
|
|
8
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
/** @internal */
|
|
2
3
|
export type ViewMode = 'rich-text' | 'source' | 'diff';
|
|
3
4
|
/** @internal */
|
|
4
5
|
export declare const diffSourceSystem: import("../../gurx").SystemSpec<[import("../../gurx").SystemSpec<[], (r: import("../../gurx").Realm) => {
|
|
@@ -530,7 +530,11 @@ imagePluginHooks: {
|
|
|
530
530
|
insertDecoratorNode: import("../../gurx").RealmNode<() => import("lexical").DecoratorNode<unknown>>;
|
|
531
531
|
}, K_2>) => void;
|
|
532
532
|
};
|
|
533
|
+
/** @internal */
|
|
533
534
|
export type InsertImagePayload = Readonly<CreateImageNodeOptions>;
|
|
535
|
+
/**
|
|
536
|
+
* @internal
|
|
537
|
+
*/
|
|
534
538
|
export declare const INSERT_IMAGE_COMMAND: LexicalCommand<InsertImagePayload>;
|
|
535
539
|
declare global {
|
|
536
540
|
interface DragEvent {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
3
6
|
export type MdastJsx = MdxJsxTextElement | MdxJsxFlowElement;
|
|
4
7
|
/**
|
|
5
8
|
* Defines the structure of a JSX component property.
|
|
@@ -109,7 +112,13 @@ export declare const jsxSystem: import("../../gurx").SystemSpec<[import("../../g
|
|
|
109
112
|
convertSelectionToNode: import("../../gurx").RealmNode<() => import("lexical").ElementNode>;
|
|
110
113
|
insertDecoratorNode: import("../../gurx").RealmNode<() => import("lexical").DecoratorNode<unknown>>;
|
|
111
114
|
}>], (_: import("../../gurx").Realm) => {}>;
|
|
115
|
+
/**
|
|
116
|
+
* The parameters of the `jsxPlugin`.
|
|
117
|
+
*/
|
|
112
118
|
export interface JsxPluginParams {
|
|
119
|
+
/**
|
|
120
|
+
* A set of descriptors that document the JSX elements used in the document.
|
|
121
|
+
*/
|
|
113
122
|
jsxComponentDescriptors: JsxComponentDescriptor[];
|
|
114
123
|
}
|
|
115
124
|
export declare const
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that allows the user to change the admonition type of the current selection.
|
|
4
|
+
* For this component to work, you must pass the {@link AdmonitionDirectiveDescriptor} to the `directivesPlugin` `directiveDescriptors` parameter.
|
|
5
|
+
*/
|
|
2
6
|
export declare const ChangeAdmonitionType: () => React.JSX.Element;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that allows the user to change the code block language of the current selection.
|
|
4
|
+
* For this component to work, you must enable the `codeMirrorPlugin` for the editor.
|
|
5
|
+
* See {@link ConditionalContents} for an example on how to display the dropdown only when a code block is in focus.
|
|
6
|
+
*/
|
|
2
7
|
export declare const ChangeCodeMirrorLanguage: () => React.JSX.Element;
|
|
@@ -21,8 +21,8 @@ const ChangeCodeMirrorLanguage = () => {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
},
|
|
24
|
-
triggerTitle: "Select
|
|
25
|
-
placeholder: "
|
|
24
|
+
triggerTitle: "Select code block language",
|
|
25
|
+
placeholder: "Code block language",
|
|
26
26
|
items: Object.entries(codeBlockLanguages).map(([value, label]) => ({ value, label }))
|
|
27
27
|
}
|
|
28
28
|
));
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A wrapper element for the toolbar contents that lets the user toggle between rich text, diff and source mode.
|
|
4
|
+
* Put the rich text toolbar contents as children of this component.
|
|
5
|
+
* For this component to work, you must include the `diffSourcePlugin`.
|
|
6
|
+
*/
|
|
2
7
|
export declare const DiffSourceToggleWrapper: React.FC<{
|
|
3
8
|
children: React.ReactNode;
|
|
4
9
|
}>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar dropdown button that allows the user to insert admonitions.
|
|
4
|
+
* For this to work, you need to have the `directives` plugin enabled with the {@link AdmonitionDirectiveDescriptor} configured.
|
|
5
|
+
*/
|
|
2
6
|
export declare const InsertAdmonition: () => React.JSX.Element;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert a fenced code block.
|
|
4
|
+
* Once the code block is focused, you can construct a special code block toolbar for it, using the {@link ConditionalContents} primitive.
|
|
5
|
+
* See the {@link ConditionalContents} documentation for an example.
|
|
6
|
+
*/
|
|
2
7
|
export declare const InsertCodeBlock: React.FC;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert a {@link https://jekyllrb.com/docs/front-matter/ | front-matter} editor (if one is not already present).
|
|
4
|
+
* For this to work, you need to have the `frontmatterPlugin` plugin enabled.
|
|
5
|
+
*/
|
|
2
6
|
export declare const InsertFrontmatter: React.FC;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert an image from an URL.
|
|
4
|
+
* For the button to work, you need to have the `imagePlugin` plugin enabled.
|
|
5
|
+
*/
|
|
2
6
|
export declare const InsertImage: React.ForwardRefExoticComponent<Omit<Record<string, never>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A dropdown button that allows the user to insert a live code block into the editor. The dropdown offers a list of presets that are defined in the sandpack plugin config.
|
|
4
|
+
* For this to work, you need to have the `sandpackPlugin` installed.
|
|
5
|
+
*/
|
|
2
6
|
export declare const InsertSandpack: () => React.JSX.Element;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar button that allows the user to insert a thematic break (rendered as an HR HTML element).
|
|
4
|
+
* For this button to work, you need to have the `thematicBreakPlugin` plugin enabled.
|
|
5
|
+
*/
|
|
2
6
|
export declare const InsertThematicBreak: React.FC;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar component that includes all toolbar components.
|
|
4
|
+
* Notice that some of the buttons will work only if you have the corresponding plugin enabled, so you should use it only for testing purposes.
|
|
5
|
+
* You'll probably want to create your own toolbar component that includes only the buttons that you need.
|
|
6
|
+
*/
|
|
2
7
|
export declare const KitchenSinkToolbar: React.FC;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A toolbar toggle that allows the user to toggle between bulleted and numbered lists.
|
|
4
|
+
* Pressing the selected button will convert the current list to the other type. Pressing it again will remove the list.
|
|
5
|
+
* For this button to work, you need to have the `listsPlugin` plugin enabled.
|
|
6
|
+
*/
|
|
2
7
|
export declare const ListsToggle: React.FC;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A component that displays the focused live code block's name.
|
|
4
|
+
* For this component to work, you must enable the `sandpackPlugin` for the editor.
|
|
5
|
+
* See {@link ConditionalContents} for an example on how to display the dropdown only when a sandpack editor is in focus.
|
|
6
|
+
*/
|
|
2
7
|
export declare const ShowSandpackInfo: () => React.JSX.Element;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A small styled wrapper around the radix-ui tooltip, that lets you display an instan tooltip on hover.
|
|
4
|
+
*/
|
|
2
5
|
export declare const TooltipWrap: React.ForwardRefExoticComponent<{
|
|
3
6
|
title: string;
|
|
4
7
|
children: ReactNode;
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
2
5
|
export declare const SelectItem: React.ForwardRefExoticComponent<{
|
|
3
6
|
className?: string | undefined;
|
|
4
7
|
children: React.ReactNode;
|
|
5
8
|
value: string;
|
|
6
9
|
} & React.RefAttributes<HTMLDivElement | null>>;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
7
13
|
export declare const SelectTrigger: React.FC<{
|
|
8
14
|
title: string;
|
|
9
15
|
placeholder: string;
|
|
10
16
|
className?: string;
|
|
11
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
12
21
|
export declare const SelectContent: React.FC<{
|
|
13
22
|
children: React.ReactNode;
|
|
14
23
|
className?: string;
|
|
15
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
16
28
|
export declare const SelectButtonTrigger: React.FC<{
|
|
17
29
|
children: React.ReactNode;
|
|
18
30
|
title: string;
|
|
19
31
|
className?: string;
|
|
20
32
|
}>;
|
|
33
|
+
/**
|
|
34
|
+
* The properties of the {@link Select} React component.
|
|
35
|
+
*/
|
|
21
36
|
export interface SelectProps<T extends string> {
|
|
22
37
|
value: T;
|
|
23
38
|
onChange: (value: T) => void;
|
|
@@ -28,4 +43,8 @@ export interface SelectProps<T extends string> {
|
|
|
28
43
|
value: T;
|
|
29
44
|
} | 'separator')[];
|
|
30
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* A toolbar primitive you can use to build dropdowns, such as the block type select.
|
|
48
|
+
* See {@link SelectProps} for more details.
|
|
49
|
+
*/
|
|
31
50
|
export declare const Select: <T extends string>(props: SelectProps<T>) => React.JSX.Element;
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
import * as RadixToolbar from '@radix-ui/react-toolbar';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { EditorInFocus } from '../../core';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
export declare const Root: (props: RadixToolbar.ToolbarProps & React.RefAttributes<HTMLDivElement>) => React.JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* A toolbar button primitive.
|
|
10
|
+
*/
|
|
5
11
|
export declare const Button: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object>>;
|
|
12
|
+
/**
|
|
13
|
+
* A toolbar button with a custom toolbar primitive.
|
|
14
|
+
*/
|
|
6
15
|
export declare const ButtonWithTooltip: ({ title, children, ...props }: Omit<RadixToolbar.ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object> & {
|
|
7
16
|
title: string;
|
|
8
17
|
}) => React.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
9
21
|
export declare const ToolbarToggleItem: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<object>>;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
10
25
|
export declare const SingleToggleGroup: React.ForwardRefExoticComponent<(Omit<RadixToolbar.ToolbarToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<RadixToolbar.ToolbarToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & React.RefAttributes<object>>;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
11
29
|
export declare const ToggleSingleGroupWithItem: React.ForwardRefExoticComponent<Omit<RadixToolbar.ToolbarToggleGroupSingleProps, "type"> & {
|
|
12
30
|
on: boolean;
|
|
13
31
|
title: string;
|
|
14
32
|
disabled?: boolean | undefined;
|
|
15
33
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
+
/**
|
|
35
|
+
* A toolbar primitive that allows you to build an UI with multiple non-exclusive toggle groups, like the bold/italic/underline toggle.
|
|
36
|
+
*/
|
|
16
37
|
export declare const MultipleChoiceToggleGroup: React.FC<{
|
|
17
38
|
items: {
|
|
18
39
|
title: string;
|
|
@@ -22,7 +43,10 @@ export declare const MultipleChoiceToggleGroup: React.FC<{
|
|
|
22
43
|
disabled?: boolean;
|
|
23
44
|
}[];
|
|
24
45
|
}>;
|
|
25
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The properties of the {@link SingleChoiceToggleGroup} React component.
|
|
48
|
+
*/
|
|
49
|
+
export interface SingleChoiceToggleGroupProps<T extends string> {
|
|
26
50
|
items: {
|
|
27
51
|
title: string;
|
|
28
52
|
value: T;
|
|
@@ -32,6 +56,9 @@ interface SingleChoiceToggleGroupProps<T extends string> {
|
|
|
32
56
|
value: T;
|
|
33
57
|
className?: string;
|
|
34
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* A toolbar primitive that allows you to build an UI with multiple exclusive toggle groups, like the list type toggle.
|
|
61
|
+
*/
|
|
35
62
|
export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChange, className, items }: SingleChoiceToggleGroupProps<T>) => React.JSX.Element;
|
|
36
63
|
/**
|
|
37
64
|
* The properties of the {@link ButtonOrDropdownButton} React component.
|
|
@@ -70,16 +97,64 @@ export interface ButtonOrDropdownButtonProps<T extends string> {
|
|
|
70
97
|
* @see {@link ButtonOrDropdownButtonProps} for the properties of the React component.
|
|
71
98
|
*/
|
|
72
99
|
export declare const ButtonOrDropdownButton: <T extends string>(props: ButtonOrDropdownButtonProps<T>) => React.JSX.Element;
|
|
73
|
-
|
|
100
|
+
/**
|
|
101
|
+
* An object that describes a possible option to be displayed in the {@link ConditionalContents} component.
|
|
102
|
+
*/
|
|
103
|
+
export type ConditionalContentsOption = {
|
|
104
|
+
/**
|
|
105
|
+
* A function that returns `true` if the option should be displayed for the current editor in focus.
|
|
106
|
+
*/
|
|
74
107
|
when: (rootNode: EditorInFocus | null) => boolean;
|
|
108
|
+
/**
|
|
109
|
+
* The contents to display if the `when` function returns `true`.
|
|
110
|
+
*/
|
|
75
111
|
contents: () => React.ReactNode;
|
|
76
112
|
};
|
|
77
|
-
|
|
113
|
+
/**
|
|
114
|
+
* A default option to be displayed in the {@link ConditionalContents} component if none of the other options match.
|
|
115
|
+
*/
|
|
116
|
+
export type FallBackOption = {
|
|
117
|
+
/**
|
|
118
|
+
* The contents to display
|
|
119
|
+
*/
|
|
78
120
|
fallback: () => React.ReactNode;
|
|
79
121
|
};
|
|
80
|
-
|
|
122
|
+
/**
|
|
123
|
+
* The properties of the {@link ConditionalContents} React component.
|
|
124
|
+
*/
|
|
125
|
+
export interface ConditionalContentsProps {
|
|
126
|
+
/**
|
|
127
|
+
* A set of options that define the contents to show based on the editor that is in focus.
|
|
128
|
+
* Can be either a {@link ConditionalContentsOption} or a {@link FallBackOption}.
|
|
129
|
+
* See the {@link ConditionalContents} documentation for an example.
|
|
130
|
+
*/
|
|
81
131
|
options: (ConditionalContentsOption | FallBackOption)[];
|
|
82
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* A toolbar primitive that allows you to show different contents based on the editor that is in focus.
|
|
135
|
+
* Useful for code editors that have different features and don't support rich text formatting.
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* <ConditionalContents
|
|
139
|
+
* options={[
|
|
140
|
+
* { when: (editor) => editor?.editorType === 'codeblock', contents: () => <ChangeCodeMirrorLanguage /> },
|
|
141
|
+
* { when: (editor) => editor?.editorType === 'sandpack', contents: () => <ShowSandpackInfo /> },
|
|
142
|
+
* {
|
|
143
|
+
* fallback: () => (
|
|
144
|
+
* <>
|
|
145
|
+
* <UndoRedo />
|
|
146
|
+
* <BoldItalicUnderlineToggles />
|
|
147
|
+
* <InsertCodeBlock />
|
|
148
|
+
* </>
|
|
149
|
+
* )
|
|
150
|
+
* }
|
|
151
|
+
* ]}
|
|
152
|
+
* />
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
83
155
|
export declare const ConditionalContents: React.FC<ConditionalContentsProps>;
|
|
156
|
+
/**
|
|
157
|
+
* A toolbar primitive that allows you to show a separator between toolbar items.
|
|
158
|
+
* By default, the separator is styled as vertical line.
|
|
159
|
+
*/
|
|
84
160
|
export declare const Separator: React.ForwardRefExoticComponent<RadixToolbar.ToolbarSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
85
|
-
export {};
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"private": false,
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"type": "module",
|
|
12
|
-
"version": "0.10.0-alpha.
|
|
12
|
+
"version": "0.10.0-alpha.3",
|
|
13
13
|
"description": "React component for rich text markdown editing",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "vite build",
|
|
@@ -171,6 +171,8 @@
|
|
|
171
171
|
}
|
|
172
172
|
]
|
|
173
173
|
},
|
|
174
|
+
"module": "dist/index.js",
|
|
175
|
+
"types": "dist/index.d.ts",
|
|
174
176
|
"exports": {
|
|
175
177
|
"./package.json": "./package.json",
|
|
176
178
|
"./style.css": "./dist/style.css",
|
|
@@ -190,6 +192,14 @@
|
|
|
190
192
|
"import": "./dist/jsx-editors/GenericJsxEditor.js",
|
|
191
193
|
"types": "./dist/jsx-editors/GenericJsxEditor.d.ts"
|
|
192
194
|
},
|
|
195
|
+
"./plugins/core/PropertyPopover": {
|
|
196
|
+
"import": "./dist/plugins/core/PropertyPopover.js",
|
|
197
|
+
"types": "./dist/plugins/core/PropertyPopover.d.ts"
|
|
198
|
+
},
|
|
199
|
+
"./plugins/core/NestedLexicalEditor": {
|
|
200
|
+
"import": "./dist/plugins/core/NestedLexicalEditor.js",
|
|
201
|
+
"types": "./dist/plugins/core/NestedLexicalEditor.d.ts"
|
|
202
|
+
},
|
|
193
203
|
"./plugins/codeblock": {
|
|
194
204
|
"types": "./dist/plugins/codeblock/index.d.ts",
|
|
195
205
|
"import": "./dist/plugins/codeblock/index.js"
|