@mdxeditor/editor 1.5.0 → 1.6.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/README.md
CHANGED
|
@@ -9,7 +9,7 @@ MDXEditor is an open-source React component that allows users to author markdown
|
|
|
9
9
|
The component supports the core markdown syntax and certain extensions, including tables, images, code blocks, etc. It also allows users to edit JSX components with a built-in JSX editor or a custom one.
|
|
10
10
|
|
|
11
11
|
```jsx
|
|
12
|
-
import {MDXEditor, headingsPlugin
|
|
12
|
+
import {MDXEditor, headingsPlugin} from '@mdxeditor/editor';
|
|
13
13
|
|
|
14
14
|
export default function App() {
|
|
15
15
|
return <MDXEditor markdown={'# Hello World'} plugins={[headingsPlugin()]} />;
|
package/dist/gurx/realm.d.ts
CHANGED
|
@@ -81,7 +81,6 @@ export declare function realm(): {
|
|
|
81
81
|
<T1_14, T2_13, T3_12, T4_11, T5_10, T6_9, T7_8, T8_7, T9_6, T10_5, T11_4, T12_3, T13_3, T14_2, T15_1, T16>(nodes_0: RN<T1_14>, nodes_1: RN<T2_13>, nodes_2: RN<T3_12>, nodes_3: RN<T4_11>, nodes_4: RN<T5_10>, nodes_5: RN<T6_9>, nodes_6: RN<T7_8>, nodes_7: RN<T8_7>, nodes_8: RN<T9_6>, nodes_9: RN<T10_5>, nodes_10: RN<T11_4>, nodes_11: RN<T12_3>, nodes_12: RN<T13_3>, nodes_13: RN<T14_2>, nodes_14: RN<T15_1>, nodes_15: RN<T16>): RN<[T1_14, T2_13, T3_12, T4_11, T5_10, T6_9, T7_8, T8_7, T9_6, T10_5, T11_4, T12_3, T13_3, T14_2, T15_1, T16]>;
|
|
82
82
|
};
|
|
83
83
|
connect: <T extends unknown[] = unknown[]>({ sources, pulls, map, sink: { key: sink } }: RealmProjectionSpec<T>) => void;
|
|
84
|
-
debug: () => void;
|
|
85
84
|
derive: <T_1>(source: RealmNode<T_1>, initial: T_1) => RealmNode<T_1>;
|
|
86
85
|
getKeyValue: (key: string) => unknown;
|
|
87
86
|
getValue: <T_2>(node: RN<T_2>) => T_2;
|
package/dist/gurx/realm.js
CHANGED
|
@@ -218,11 +218,6 @@ function realm() {
|
|
|
218
218
|
});
|
|
219
219
|
executionMaps.clear();
|
|
220
220
|
}
|
|
221
|
-
function debug() {
|
|
222
|
-
Object.entries(labels).forEach(([name, value]) => {
|
|
223
|
-
state.get(value.key);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
221
|
function pub(...args) {
|
|
227
222
|
const map2 = {};
|
|
228
223
|
for (let index = 0; index < args.length; index += 2) {
|
|
@@ -452,7 +447,6 @@ function realm() {
|
|
|
452
447
|
return {
|
|
453
448
|
combine,
|
|
454
449
|
connect,
|
|
455
|
-
debug,
|
|
456
450
|
derive,
|
|
457
451
|
getKeyValue,
|
|
458
452
|
getValue,
|
|
@@ -13,7 +13,7 @@ const CodeMirrorEditor = ({ language, nodeKey, code, focusEmitter }) => {
|
|
|
13
13
|
(_b = (_a = codeMirrorRef.current) == null ? void 0 : _a.getCodemirror()) == null ? void 0 : _b.dom.addEventListener("paste", (e) => {
|
|
14
14
|
e.stopPropagation();
|
|
15
15
|
});
|
|
16
|
-
}, [codeMirrorRef]);
|
|
16
|
+
}, [codeMirrorRef, language]);
|
|
17
17
|
return /* @__PURE__ */ React__default.createElement(
|
|
18
18
|
"div",
|
|
19
19
|
{
|
|
@@ -73,11 +73,19 @@ export interface JsxEditorProps {
|
|
|
73
73
|
mdastNode: MdastJsx;
|
|
74
74
|
descriptor: JsxComponentDescriptor;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
type JsxTextPayload = {
|
|
77
|
+
kind: 'text';
|
|
77
78
|
name: string;
|
|
78
|
-
kind: 'flow' | 'text';
|
|
79
79
|
props: Record<string, string>;
|
|
80
|
-
|
|
80
|
+
children?: MdxJsxTextElement['children'];
|
|
81
|
+
};
|
|
82
|
+
type JsxFlowPayload = {
|
|
83
|
+
kind: 'flow';
|
|
84
|
+
name: string;
|
|
85
|
+
props: Record<string, string>;
|
|
86
|
+
children?: MdxJsxFlowElement['children'];
|
|
87
|
+
};
|
|
88
|
+
type InsertJsxPayload = JsxTextPayload | JsxFlowPayload;
|
|
81
89
|
/** @internal */
|
|
82
90
|
export declare const jsxSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
83
91
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -7,19 +7,38 @@ import { MdastMdxJsEsmVisitor } from "./MdastMdxJsEsmVisitor.js";
|
|
|
7
7
|
import { MdastMdxJsxElementVisitor } from "./MdastMdxJsxElementVisitor.js";
|
|
8
8
|
import { system } from "../../gurx/realmFactory.js";
|
|
9
9
|
import { realmPlugin } from "../../gurx/react.js";
|
|
10
|
+
function toMdastJsxAttributes(attributes) {
|
|
11
|
+
return Object.entries(attributes).map(([name, value]) => ({
|
|
12
|
+
type: "mdxJsxAttribute",
|
|
13
|
+
name,
|
|
14
|
+
value
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
10
17
|
const jsxSystem = system(
|
|
11
18
|
(r, [{ insertDecoratorNode }]) => {
|
|
12
19
|
const insertJsx = r.node();
|
|
13
20
|
r.link(
|
|
14
21
|
r.pipe(
|
|
15
22
|
insertJsx,
|
|
16
|
-
r.o.map(({ name,
|
|
17
|
-
return () =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
r.o.map(({ kind, name, children, props }) => {
|
|
24
|
+
return () => {
|
|
25
|
+
const attributes = toMdastJsxAttributes(props);
|
|
26
|
+
if (kind === "flow") {
|
|
27
|
+
return $createLexicalJsxNode({
|
|
28
|
+
type: "mdxJsxFlowElement",
|
|
29
|
+
name,
|
|
30
|
+
children: children ?? [],
|
|
31
|
+
attributes
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
return $createLexicalJsxNode({
|
|
35
|
+
type: "mdxJsxTextElement",
|
|
36
|
+
name,
|
|
37
|
+
children: children ?? [],
|
|
38
|
+
attributes
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
23
42
|
})
|
|
24
43
|
),
|
|
25
44
|
insertDecoratorNode
|