@mdxeditor/editor 0.10.0-alpha.1 → 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.
Files changed (53) hide show
  1. package/dist/MDXEditor.d.ts +29 -0
  2. package/dist/MDXEditor.js +1 -1
  3. package/dist/directive-editors/AdmonitionDirectiveDescriptor.d.ts +13 -0
  4. package/dist/directive-editors/GenericDirectiveEditor.d.ts +5 -0
  5. package/dist/importMarkdownToLexical.js +1 -1
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +9 -1
  8. package/dist/jsx-editors/GenericJsxEditor.d.ts +5 -0
  9. package/dist/plugins/core/NestedLexicalEditor.d.ts +9 -2
  10. package/dist/plugins/core/PropertyPopover.d.ts +17 -2
  11. package/dist/plugins/diff-source/SourceEditor.js +2 -0
  12. package/dist/plugins/diff-source/index.d.ts +1 -0
  13. package/dist/plugins/image/ImageEditor.d.ts +3 -1
  14. package/dist/plugins/image/ImageEditor.js +29 -6
  15. package/dist/plugins/image/ImageNode.d.ts +11 -1
  16. package/dist/plugins/image/ImageNode.js +37 -9
  17. package/dist/plugins/image/ImageResizer.d.ts +18 -0
  18. package/dist/plugins/image/ImageResizer.js +214 -0
  19. package/dist/plugins/image/LexicalImageVisitor.js +27 -6
  20. package/dist/plugins/image/MdastImageVisitor.d.ts +3 -0
  21. package/dist/plugins/image/MdastImageVisitor.js +72 -1
  22. package/dist/plugins/image/index.d.ts +4 -0
  23. package/dist/plugins/image/index.js +3 -1
  24. package/dist/plugins/jsx/MdastMdxJsxElementVisitor.js +1 -1
  25. package/dist/plugins/jsx/index.d.ts +9 -0
  26. package/dist/plugins/lists/LexicalListVisitor.js +0 -1
  27. package/dist/plugins/table/TableEditor.js +25 -15
  28. package/dist/plugins/toolbar/components/BlockTypeSelect.d.ts +4 -0
  29. package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.d.ts +3 -0
  30. package/dist/plugins/toolbar/components/ChangeAdmonitionType.d.ts +4 -0
  31. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.d.ts +5 -0
  32. package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +2 -2
  33. package/dist/plugins/toolbar/components/CodeToggle.d.ts +4 -0
  34. package/dist/plugins/toolbar/components/CreateLink.d.ts +4 -0
  35. package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.d.ts +5 -0
  36. package/dist/plugins/toolbar/components/InsertAdmonition.d.ts +4 -0
  37. package/dist/plugins/toolbar/components/InsertCodeBlock.d.ts +5 -0
  38. package/dist/plugins/toolbar/components/InsertFrontmatter.d.ts +4 -0
  39. package/dist/plugins/toolbar/components/InsertImage.d.ts +4 -0
  40. package/dist/plugins/toolbar/components/InsertSandpack.d.ts +4 -0
  41. package/dist/plugins/toolbar/components/InsertTable.d.ts +4 -0
  42. package/dist/plugins/toolbar/components/InsertThematicBreak.d.ts +4 -0
  43. package/dist/plugins/toolbar/components/KitchenSinkToolbar.d.ts +5 -0
  44. package/dist/plugins/toolbar/components/ListsToggle.d.ts +5 -0
  45. package/dist/plugins/toolbar/components/ShowSandpackInfo.d.ts +5 -0
  46. package/dist/plugins/toolbar/components/UndoRedo.d.ts +3 -0
  47. package/dist/plugins/toolbar/primitives/TooltipWrap.d.ts +3 -0
  48. package/dist/plugins/toolbar/primitives/select.d.ts +19 -0
  49. package/dist/plugins/toolbar/primitives/toolbar.d.ts +80 -5
  50. package/dist/style.css +232 -158
  51. package/dist/styles/ui.module.css.js +105 -75
  52. package/dist/utils/lexicalHelpers.js +2 -2
  53. package/package.json +12 -1
@@ -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
- interface SingleChoiceToggleGroupProps<T extends string> {
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
- type ConditionalContentsOption = {
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
- type FallBackOption = {
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
- interface ConditionalContentsProps {
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 {};