@mdxeditor/editor 0.15.2 → 0.16.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.
- package/dist/MDXEditor.d.ts +5 -0
- package/dist/MDXEditor.js +8 -2
- package/dist/gurx/react.js +1 -1
- package/dist/plugins/codeblock/index.d.ts +12 -2
- package/dist/plugins/codemirror/CodeMirrorEditor.js +6 -3
- package/dist/plugins/codemirror/index.d.ts +16 -2
- package/dist/plugins/core/index.d.ts +11 -2
- package/dist/plugins/core/index.js +12 -4
- package/dist/plugins/diff-source/SourceEditor.js +2 -1
- package/dist/plugins/diff-source/index.d.ts +12 -2
- package/dist/plugins/directives/index.d.ts +12 -2
- package/dist/plugins/frontmatter/FrontmatterEditor.js +4 -1
- package/dist/plugins/frontmatter/index.d.ts +12 -2
- package/dist/plugins/headings/index.d.ts +4 -0
- package/dist/plugins/image/index.d.ts +12 -2
- package/dist/plugins/jsx/index.d.ts +12 -2
- package/dist/plugins/link/index.d.ts +1 -0
- package/dist/plugins/link-dialog/index.d.ts +10 -2
- package/dist/plugins/lists/index.d.ts +12 -2
- package/dist/plugins/markdown-shortcut/index.d.ts +1 -0
- package/dist/plugins/quote/index.d.ts +9 -2
- package/dist/plugins/sandpack/SandpackEditor.js +3 -1
- package/dist/plugins/sandpack/index.d.ts +16 -2
- package/dist/plugins/table/index.d.ts +12 -2
- package/dist/plugins/thematic-break/index.d.ts +12 -2
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +1 -1
- package/dist/plugins/toolbar/index.d.ts +10 -2
- package/dist/plugins/toolbar/index.js +3 -2
- package/dist/plugins/toolbar/primitives/DialogButton.js +2 -2
- package/dist/plugins/toolbar/primitives/select.js +14 -2
- package/dist/plugins/toolbar/primitives/toolbar.d.ts +4 -1
- package/dist/plugins/toolbar/primitives/toolbar.js +12 -8
- package/dist/style.css +211 -169
- package/dist/styles/ui.module.css.js +88 -85
- package/package.json +1 -1
|
@@ -42,6 +42,7 @@ export declare const toolbarSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
42
42
|
contentEditableClassName: RealmNode<string>;
|
|
43
43
|
placeholder: RealmNode<React.ReactNode>;
|
|
44
44
|
autoFocus: RealmNode<boolean>;
|
|
45
|
+
readOnly: RealmNode<boolean>;
|
|
45
46
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
46
47
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
47
48
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -97,6 +98,7 @@ toolbarPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
97
98
|
contentEditableClassName: RealmNode<string>;
|
|
98
99
|
placeholder: RealmNode<React.ReactNode>;
|
|
99
100
|
autoFocus: RealmNode<boolean>;
|
|
101
|
+
readOnly: RealmNode<boolean>;
|
|
100
102
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
101
103
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
102
104
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -156,6 +158,7 @@ toolbarPluginHooks: {
|
|
|
156
158
|
contentEditableClassName: RealmNode<string>;
|
|
157
159
|
placeholder: RealmNode<React.ReactNode>;
|
|
158
160
|
autoFocus: RealmNode<boolean>;
|
|
161
|
+
readOnly: RealmNode<boolean>;
|
|
159
162
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
160
163
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
161
164
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -176,7 +179,7 @@ toolbarPluginHooks: {
|
|
|
176
179
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
177
180
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
178
181
|
}>;
|
|
179
|
-
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" | "toolbarContents">(key: K, callback: (value: ValueForKey<{
|
|
182
|
+
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" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "toolbarContents">(key: K, callback: (value: ValueForKey<{
|
|
180
183
|
toolbarContents: RealmNode<() => React.ReactNode>;
|
|
181
184
|
} & {
|
|
182
185
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -209,6 +212,7 @@ toolbarPluginHooks: {
|
|
|
209
212
|
contentEditableClassName: RealmNode<string>;
|
|
210
213
|
placeholder: RealmNode<React.ReactNode>;
|
|
211
214
|
autoFocus: RealmNode<boolean>;
|
|
215
|
+
readOnly: RealmNode<boolean>;
|
|
212
216
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
213
217
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
214
218
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -262,6 +266,7 @@ toolbarPluginHooks: {
|
|
|
262
266
|
contentEditableClassName: RealmNode<string>;
|
|
263
267
|
placeholder: RealmNode<React.ReactNode>;
|
|
264
268
|
autoFocus: RealmNode<boolean>;
|
|
269
|
+
readOnly: RealmNode<boolean>;
|
|
265
270
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
266
271
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
267
272
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -314,6 +319,7 @@ toolbarPluginHooks: {
|
|
|
314
319
|
contentEditableClassName: RealmNode<string>;
|
|
315
320
|
placeholder: RealmNode<React.ReactNode>;
|
|
316
321
|
autoFocus: RealmNode<boolean>;
|
|
322
|
+
readOnly: RealmNode<boolean>;
|
|
317
323
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
318
324
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
319
325
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -367,6 +373,7 @@ toolbarPluginHooks: {
|
|
|
367
373
|
contentEditableClassName: RealmNode<string>;
|
|
368
374
|
placeholder: RealmNode<React.ReactNode>;
|
|
369
375
|
autoFocus: RealmNode<boolean>;
|
|
376
|
+
readOnly: RealmNode<boolean>;
|
|
370
377
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
371
378
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
372
379
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -387,7 +394,7 @@ toolbarPluginHooks: {
|
|
|
387
394
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
388
395
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
389
396
|
}>) => void;
|
|
390
|
-
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" | "toolbarContents">(key: K_2) => (value: ValueForKey<{
|
|
397
|
+
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" | "readOnly" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "toolbarContents">(key: K_2) => (value: ValueForKey<{
|
|
391
398
|
toolbarContents: RealmNode<() => React.ReactNode>;
|
|
392
399
|
} & {
|
|
393
400
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -420,6 +427,7 @@ toolbarPluginHooks: {
|
|
|
420
427
|
contentEditableClassName: RealmNode<string>;
|
|
421
428
|
placeholder: RealmNode<React.ReactNode>;
|
|
422
429
|
autoFocus: RealmNode<boolean>;
|
|
430
|
+
readOnly: RealmNode<boolean>;
|
|
423
431
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
424
432
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
425
433
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { coreSystem } from "../core/index.js";
|
|
2
|
+
import { coreSystem, corePluginHooks } from "../core/index.js";
|
|
3
3
|
import { Root } from "./primitives/toolbar.js";
|
|
4
4
|
import { system } from "../../gurx/realmFactory.js";
|
|
5
5
|
import { realmPlugin } from "../../gurx/react.js";
|
|
@@ -30,7 +30,8 @@ const [
|
|
|
30
30
|
});
|
|
31
31
|
const ToolbarWrapper = () => {
|
|
32
32
|
const [toolbarContents] = toolbarPluginHooks.useEmitterValues("toolbarContents");
|
|
33
|
-
|
|
33
|
+
const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
|
|
34
|
+
return /* @__PURE__ */ React__default.createElement(Root, { readOnly }, toolbarContents());
|
|
34
35
|
};
|
|
35
36
|
export {
|
|
36
37
|
toolbarPlugin,
|
|
@@ -12,7 +12,7 @@ import { TooltipWrap } from "./TooltipWrap.js";
|
|
|
12
12
|
const MAX_SUGGESTIONS = 20;
|
|
13
13
|
const DialogButton = React__default.forwardRef(
|
|
14
14
|
({ autocompleteSuggestions = [], submitButtonTitle, dialogInputPlaceholder, onSubmit, tooltipTitle, buttonContent }, forwardedRef) => {
|
|
15
|
-
const [editorRootElementRef] = corePluginHooks.useEmitterValues("editorRootElementRef");
|
|
15
|
+
const [editorRootElementRef, readOnly] = corePluginHooks.useEmitterValues("editorRootElementRef", "readOnly");
|
|
16
16
|
const [open, setOpen] = React__default.useState(false);
|
|
17
17
|
const onSubmitCallback = React__default.useCallback(
|
|
18
18
|
(value) => {
|
|
@@ -21,7 +21,7 @@ const DialogButton = React__default.forwardRef(
|
|
|
21
21
|
},
|
|
22
22
|
[onSubmit]
|
|
23
23
|
);
|
|
24
|
-
return /* @__PURE__ */ React__default.createElement(Dialog.Root, { open, onOpenChange: setOpen }, /* @__PURE__ */ React__default.createElement(Dialog.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: tooltipTitle }, buttonContent))), /* @__PURE__ */ React__default.createElement(Dialog.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Dialog.Overlay, { className: styles.dialogOverlay }), /* @__PURE__ */ React__default.createElement(Dialog.Content, { className: styles.dialogContent }, /* @__PURE__ */ React__default.createElement(
|
|
24
|
+
return /* @__PURE__ */ React__default.createElement(Dialog.Root, { open, onOpenChange: setOpen }, /* @__PURE__ */ React__default.createElement(Dialog.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ref: forwardedRef, disabled: readOnly }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title: tooltipTitle }, buttonContent))), /* @__PURE__ */ React__default.createElement(Dialog.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Dialog.Overlay, { className: styles.dialogOverlay }), /* @__PURE__ */ React__default.createElement(Dialog.Content, { className: styles.dialogContent }, /* @__PURE__ */ React__default.createElement(
|
|
25
25
|
DialogForm,
|
|
26
26
|
{
|
|
27
27
|
submitButtonTitle,
|
|
@@ -11,7 +11,18 @@ const SelectItem = React__default.forwardRef(
|
|
|
11
11
|
}
|
|
12
12
|
);
|
|
13
13
|
const SelectTrigger = ({ title, placeholder, className }) => {
|
|
14
|
-
|
|
14
|
+
const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
|
|
15
|
+
return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(
|
|
16
|
+
RadixSelect.Trigger,
|
|
17
|
+
{
|
|
18
|
+
"aria-label": placeholder,
|
|
19
|
+
className: classNames(styles.selectTrigger, className),
|
|
20
|
+
"data-toolbar-item": true,
|
|
21
|
+
disabled: readOnly
|
|
22
|
+
},
|
|
23
|
+
/* @__PURE__ */ React__default.createElement(RadixSelect.Value, { placeholder }),
|
|
24
|
+
/* @__PURE__ */ React__default.createElement(RadixSelect.Icon, { className: styles.selectDropdownArrow }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))
|
|
25
|
+
));
|
|
15
26
|
};
|
|
16
27
|
const SelectContent = ({
|
|
17
28
|
children,
|
|
@@ -25,7 +36,8 @@ const SelectButtonTrigger = ({
|
|
|
25
36
|
title,
|
|
26
37
|
className
|
|
27
38
|
}) => {
|
|
28
|
-
|
|
39
|
+
const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
|
|
40
|
+
return /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, /* @__PURE__ */ React__default.createElement(RadixSelect.Trigger, { className: classNames(styles.toolbarButtonSelectTrigger, className), disabled: readOnly }, children, /* @__PURE__ */ React__default.createElement(RadixSelect.Icon, { className: styles.selectDropdownArrow }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))));
|
|
29
41
|
};
|
|
30
42
|
const Select = (props) => {
|
|
31
43
|
return /* @__PURE__ */ React__default.createElement(RadixSelect.Root, { value: props.value || void 0, onValueChange: props.onChange }, /* @__PURE__ */ React__default.createElement(SelectTrigger, { title: props.triggerTitle, placeholder: props.placeholder }), /* @__PURE__ */ React__default.createElement(SelectContent, null, props.items.map((item, index) => {
|
|
@@ -4,7 +4,10 @@ import { EditorInFocus } from '../../core';
|
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export declare const Root:
|
|
7
|
+
export declare const Root: React.FC<{
|
|
8
|
+
readOnly: boolean;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}>;
|
|
8
11
|
/**
|
|
9
12
|
* A toolbar button primitive.
|
|
10
13
|
*/
|
|
@@ -6,12 +6,6 @@ import styles from "../../../styles/ui.module.css.js";
|
|
|
6
6
|
import { TooltipWrap } from "./TooltipWrap.js";
|
|
7
7
|
import { SelectButtonTrigger, SelectContent, SelectItem } from "./select.js";
|
|
8
8
|
import { corePluginHooks } from "../../core/index.js";
|
|
9
|
-
function decorate(Component, decoratedProps) {
|
|
10
|
-
return (props) => {
|
|
11
|
-
const className = classNames(decoratedProps.className, props.className);
|
|
12
|
-
return /* @__PURE__ */ React__default.createElement(Component, { ...decoratedProps, ...props, className });
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
9
|
function decorateWithRef(Component, decoratedProps) {
|
|
16
10
|
return React__default.forwardRef((props, ref) => {
|
|
17
11
|
const className = classNames(decoratedProps.className, props.className);
|
|
@@ -23,7 +17,16 @@ function addTooltipToChildren(Component) {
|
|
|
23
17
|
return /* @__PURE__ */ React__default.createElement(Component, { ...props }, /* @__PURE__ */ React__default.createElement(TooltipWrap, { title }, children));
|
|
24
18
|
};
|
|
25
19
|
}
|
|
26
|
-
const Root =
|
|
20
|
+
const Root = ({ readOnly, children }) => {
|
|
21
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
22
|
+
RadixToolbar.Root,
|
|
23
|
+
{
|
|
24
|
+
className: classNames(styles.toolbarRoot, { [styles.readOnlyToolbarRoot]: readOnly }),
|
|
25
|
+
...readOnly ? { tabIndex: -1 } : {}
|
|
26
|
+
},
|
|
27
|
+
children
|
|
28
|
+
);
|
|
29
|
+
};
|
|
27
30
|
const Button = decorateWithRef(RadixToolbar.Button, { className: styles.toolbarButton, "data-toolbar-item": true });
|
|
28
31
|
const ButtonWithTooltip = addTooltipToChildren(Button);
|
|
29
32
|
const ToolbarToggleItem = decorateWithRef(RadixToolbar.ToggleItem, {
|
|
@@ -74,7 +77,8 @@ const SingleChoiceToggleGroup = ({ value, onChange, className, items }) => {
|
|
|
74
77
|
));
|
|
75
78
|
};
|
|
76
79
|
const ButtonOrDropdownButton = (props) => {
|
|
77
|
-
|
|
80
|
+
const [readOnly] = corePluginHooks.useEmitterValues("readOnly");
|
|
81
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, props.items.length === 1 ? /* @__PURE__ */ React__default.createElement(ButtonWithTooltip, { title: props.title, onClick: () => props.onChoose(""), disabled: readOnly }, props.children) : /* @__PURE__ */ React__default.createElement(RadixSelect.Root, { value: "", onValueChange: props.onChoose }, /* @__PURE__ */ React__default.createElement(SelectButtonTrigger, { title: props.title }, props.children), /* @__PURE__ */ React__default.createElement(SelectContent, { className: styles.toolbarButtonDropdownContainer }, props.items.map((item, index) => /* @__PURE__ */ React__default.createElement(SelectItem, { key: index, value: item.value }, item.label)))));
|
|
78
82
|
};
|
|
79
83
|
function isConditionalContentsOption(option) {
|
|
80
84
|
return Object.hasOwn(option, "when");
|