@mdxeditor/editor 3.36.0 → 3.38.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/index.d.ts +27 -0
- package/dist/index.js +4 -0
- package/dist/plugins/remote/index.js +51 -0
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { Options } from 'mdast-util-from-markdown';
|
|
|
36
36
|
import { Options as Options_2 } from 'mdast-util-to-markdown/lib/types';
|
|
37
37
|
import { Options as Options_3 } from 'mdast-util-gfm-table';
|
|
38
38
|
import { ParseOptions } from 'micromark-util-types';
|
|
39
|
+
import { PropsWithChildren } from 'react';
|
|
39
40
|
import * as RadixToolbar from '@radix-ui/react-toolbar';
|
|
40
41
|
import { RangeSelection } from 'lexical';
|
|
41
42
|
import { ReactNode } from 'react';
|
|
@@ -2519,6 +2520,25 @@ export declare function realmPlugin<Params>(plugin: {
|
|
|
2519
2520
|
*/
|
|
2520
2521
|
export declare type RectData = Pick<DOMRect, 'height' | 'width' | 'top' | 'left'>;
|
|
2521
2522
|
|
|
2523
|
+
/**
|
|
2524
|
+
* A context provider that allows you to register and access realms of remote MDX editors.
|
|
2525
|
+
* @group Utils
|
|
2526
|
+
*/
|
|
2527
|
+
export declare const RemoteMDXEditorRealmProvider: FC<PropsWithChildren>;
|
|
2528
|
+
|
|
2529
|
+
/**
|
|
2530
|
+
* A plugin that allows you to access the editor's realm outside of the editor's component tree.
|
|
2531
|
+
* Requires wrapping your application in the `RemoteMDXEditorRealmProvider` component.
|
|
2532
|
+
* @see {@link useRemoteMDXEditorRealm}.
|
|
2533
|
+
* @group Utils
|
|
2534
|
+
*/
|
|
2535
|
+
export declare const remoteRealmPlugin: (params?: {
|
|
2536
|
+
/**
|
|
2537
|
+
* The id to access the realm with. See {@link useRemoteMDXEditorRealm}.
|
|
2538
|
+
*/
|
|
2539
|
+
editorId: string;
|
|
2540
|
+
} | undefined) => RealmPlugin;
|
|
2541
|
+
|
|
2522
2542
|
/**
|
|
2523
2543
|
* Removes the frontmatter node from the markdown document.
|
|
2524
2544
|
* @group Frontmatter
|
|
@@ -2979,6 +2999,13 @@ export declare function useMdastNodeUpdater<T extends Mdast.RootContent>(): (nod
|
|
|
2979
2999
|
*/
|
|
2980
3000
|
export declare function useNestedEditorContext<T extends Mdast.RootContent>(): NestedEditorsContextValue<T>;
|
|
2981
3001
|
|
|
3002
|
+
/**
|
|
3003
|
+
* A hook to access the realm of a remote MDX editor by its ID. You need to wrap your tree in the `RemoteMDXEditorRealmProvider` and add the {@link remoteRealmPlugin} to the editor's instance.
|
|
3004
|
+
* @param editorId - The id passed to the {@link remoteRealmPlugin} of the MDX editor instance.
|
|
3005
|
+
* @group Utils
|
|
3006
|
+
*/
|
|
3007
|
+
export declare function useRemoteMDXEditorRealm(editorId: string): Realm | undefined;
|
|
3008
|
+
|
|
2982
3009
|
export declare function useTranslation(): Translation;
|
|
2983
3010
|
|
|
2984
3011
|
/* Excluded from this release type: uuidv4 */
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ import { TooltipWrap } from "./plugins/toolbar/primitives/TooltipWrap.js";
|
|
|
52
52
|
import { Select, SelectButtonTrigger, SelectContent, SelectItem, SelectTrigger } from "./plugins/toolbar/primitives/select.js";
|
|
53
53
|
import { NestedEditorsContext, NestedLexicalEditor, useLexicalNodeRemove, useMdastNodeUpdater, useNestedEditorContext } from "./plugins/core/NestedLexicalEditor.js";
|
|
54
54
|
import { PropertyPopover } from "./plugins/core/PropertyPopover.js";
|
|
55
|
+
import { RemoteMDXEditorRealmProvider, remoteRealmPlugin, useRemoteMDXEditorRealm } from "./plugins/remote/index.js";
|
|
55
56
|
import { CAN_USE_DOM, IS_APPLE, controlOrMeta } from "./utils/detectMac.js";
|
|
56
57
|
import { always, call, compose, curry1to0, curry2to1, joinProc, noop, prop, tap, thrush } from "./utils/fp.js";
|
|
57
58
|
import { isPartOftheEditorUI } from "./utils/isPartOftheEditorUI.js";
|
|
@@ -139,6 +140,7 @@ export {
|
|
|
139
140
|
NestedLexicalEditor,
|
|
140
141
|
PropertyPopover,
|
|
141
142
|
RealmWithPlugins,
|
|
143
|
+
RemoteMDXEditorRealmProvider,
|
|
142
144
|
Root,
|
|
143
145
|
SandpackEditor,
|
|
144
146
|
Select,
|
|
@@ -297,6 +299,7 @@ export {
|
|
|
297
299
|
readOnly$,
|
|
298
300
|
readOnlyDiff$,
|
|
299
301
|
realmPlugin,
|
|
302
|
+
remoteRealmPlugin,
|
|
300
303
|
removeFrontmatter$,
|
|
301
304
|
removeLink$,
|
|
302
305
|
rootEditor$,
|
|
@@ -324,6 +327,7 @@ export {
|
|
|
324
327
|
useLexicalNodeRemove,
|
|
325
328
|
useMdastNodeUpdater,
|
|
326
329
|
useNestedEditorContext,
|
|
330
|
+
useRemoteMDXEditorRealm,
|
|
327
331
|
useTranslation,
|
|
328
332
|
usedLexicalNodes$,
|
|
329
333
|
uuidv4,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React__default, { useEffect, useCallback, useMemo, createContext } from "react";
|
|
2
|
+
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
3
|
+
import { addComposerChild$ } from "../core/index.js";
|
|
4
|
+
const RemoteMDXEditorRealmContextValueStub = {
|
|
5
|
+
editorMap: /* @__PURE__ */ new Map(),
|
|
6
|
+
registerEditor: (_id, _realm) => void 0
|
|
7
|
+
};
|
|
8
|
+
const RemoteMDXEditorRealmContext = createContext(RemoteMDXEditorRealmContextValueStub);
|
|
9
|
+
const RemoteMDXEditorRealmProvider = ({ children }) => {
|
|
10
|
+
const [editorMap, setEditorMap] = React__default.useState(/* @__PURE__ */ new Map());
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
return () => {
|
|
13
|
+
setEditorMap(/* @__PURE__ */ new Map());
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
const registerEditor = useCallback((id, realm) => {
|
|
17
|
+
setEditorMap((prev) => {
|
|
18
|
+
return new Map(prev).set(id, realm);
|
|
19
|
+
});
|
|
20
|
+
}, []);
|
|
21
|
+
const contextValue = useMemo(
|
|
22
|
+
() => ({
|
|
23
|
+
editorMap,
|
|
24
|
+
registerEditor
|
|
25
|
+
}),
|
|
26
|
+
[editorMap, registerEditor]
|
|
27
|
+
);
|
|
28
|
+
return /* @__PURE__ */ React__default.createElement(RemoteMDXEditorRealmContext.Provider, { value: contextValue }, children);
|
|
29
|
+
};
|
|
30
|
+
const RemotePluginRegister = ({ realm, editorId }) => {
|
|
31
|
+
const { registerEditor } = React__default.useContext(RemoteMDXEditorRealmContext);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
registerEditor(editorId, realm);
|
|
34
|
+
}, [realm, editorId, registerEditor]);
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
const remoteRealmPlugin = realmPlugin({
|
|
38
|
+
init: (realm, params) => {
|
|
39
|
+
if (params == null ? void 0 : params.editorId) {
|
|
40
|
+
realm.pub(addComposerChild$, () => /* @__PURE__ */ React__default.createElement(RemotePluginRegister, { realm, editorId: params.editorId }));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
function useRemoteMDXEditorRealm(editorId) {
|
|
45
|
+
return React__default.useContext(RemoteMDXEditorRealmContext).editorMap.get(editorId);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
RemoteMDXEditorRealmProvider,
|
|
49
|
+
remoteRealmPlugin,
|
|
50
|
+
useRemoteMDXEditorRealm
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"*.css"
|
|
12
12
|
],
|
|
13
13
|
"type": "module",
|
|
14
|
-
"version": "3.
|
|
14
|
+
"version": "3.38.0",
|
|
15
15
|
"description": "React component for rich text markdown editing",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "vite build",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"@codemirror/state": "^6.4.0",
|
|
45
45
|
"@codemirror/view": "^6.23.0",
|
|
46
46
|
"@codesandbox/sandpack-react": "^2.20.0",
|
|
47
|
-
"@lexical/clipboard": "^0.
|
|
48
|
-
"@lexical/link": "^0.
|
|
49
|
-
"@lexical/list": "^0.
|
|
50
|
-
"@lexical/markdown": "^0.
|
|
51
|
-
"@lexical/plain-text": "^0.
|
|
52
|
-
"@lexical/react": "^0.
|
|
53
|
-
"@lexical/rich-text": "^0.
|
|
54
|
-
"@lexical/selection": "^0.
|
|
55
|
-
"@lexical/utils": "^0.
|
|
47
|
+
"@lexical/clipboard": "^0.32.1",
|
|
48
|
+
"@lexical/link": "^0.32.1",
|
|
49
|
+
"@lexical/list": "^0.32.1",
|
|
50
|
+
"@lexical/markdown": "^0.32.1",
|
|
51
|
+
"@lexical/plain-text": "^0.32.1",
|
|
52
|
+
"@lexical/react": "^0.32.1",
|
|
53
|
+
"@lexical/rich-text": "^0.32.1",
|
|
54
|
+
"@lexical/selection": "^0.32.1",
|
|
55
|
+
"@lexical/utils": "^0.32.1",
|
|
56
56
|
"@mdxeditor/gurx": "^1.1.4",
|
|
57
57
|
"@radix-ui/colors": "^3.0.0",
|
|
58
58
|
"@radix-ui/react-dialog": "^1.1.11",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"codemirror": "^6.0.1",
|
|
69
69
|
"downshift": "^7.6.0",
|
|
70
70
|
"js-yaml": "4.1.0",
|
|
71
|
-
"lexical": "^0.
|
|
71
|
+
"lexical": "^0.32.1",
|
|
72
72
|
"mdast-util-directive": "^3.0.0",
|
|
73
73
|
"mdast-util-from-markdown": "^2.0.0",
|
|
74
74
|
"mdast-util-frontmatter": "^2.0.1",
|