@mdxeditor/editor 3.0.7 → 3.1.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/FormatConstants.js +6 -0
- package/dist/MDXEditor.js +1 -1
- package/dist/directive-editors/GenericDirectiveEditor.js +5 -7
- package/dist/exportMarkdownFromLexical.js +10 -7
- package/dist/icons/strikethrough_s.svg.js +5 -0
- package/dist/icons/subscript.svg.js +5 -0
- package/dist/icons/superscript.svg.js +5 -0
- package/dist/importMarkdownToLexical.js +3 -1
- package/dist/index.d.ts +133 -142
- package/dist/index.js +2 -1
- package/dist/jsx-editors/GenericJsxEditor.js +1 -1
- package/dist/mdastUtilHtmlComment.js +2 -2
- package/dist/node_modules/micromark-extension-gfm-strikethrough/lib/syntax.js +114 -0
- package/dist/node_modules/micromark-util-chunked/index.js +29 -0
- package/dist/node_modules/micromark-util-classify-character/index.js +12 -0
- package/dist/node_modules/micromark-util-resolve-all/index.js +15 -0
- package/dist/plugins/codeblock/index.js +2 -2
- package/dist/plugins/codemirror/index.js +4 -4
- package/dist/plugins/core/Icon.js +6 -0
- package/dist/plugins/core/LexicalTextVisitor.js +56 -10
- package/dist/plugins/core/MdastFormattingVisitor.js +66 -30
- package/dist/plugins/core/MdastHTMLNode.js +1 -2
- package/dist/plugins/core/NestedLexicalEditor.js +1 -1
- package/dist/plugins/core/PropertyPopover.js +28 -18
- package/dist/plugins/core/index.js +36 -39
- package/dist/plugins/core/ui/DownshiftAutoComplete.js +1 -1
- package/dist/plugins/directives/index.js +2 -2
- package/dist/plugins/frontmatter/FrontmatterEditor.js +48 -31
- package/dist/plugins/frontmatter/FrontmatterNode.js +5 -3
- package/dist/plugins/image/ImageDialog.js +1 -1
- package/dist/plugins/image/ImageEditor.js +8 -6
- package/dist/plugins/image/ImageNode.js +2 -2
- package/dist/plugins/image/MdastImageVisitor.js +3 -3
- package/dist/plugins/image/index.js +20 -20
- package/dist/plugins/jsx/index.js +1 -1
- package/dist/plugins/link-dialog/LinkDialog.js +13 -5
- package/dist/plugins/link-dialog/index.js +7 -8
- package/dist/plugins/lists/MdastListVisitor.js +1 -2
- package/dist/plugins/lists/index.js +1 -1
- package/dist/plugins/markdown-shortcut/index.js +4 -2
- package/dist/plugins/sandpack/SandpackEditor.js +1 -1
- package/dist/plugins/sandpack/index.js +2 -2
- package/dist/plugins/sandpack/useCodeMirrorRef.js +8 -8
- package/dist/plugins/table/TableEditor.js +67 -50
- package/dist/plugins/table/TableNode.js +2 -2
- package/dist/plugins/toolbar/components/BlockTypeSelect.js +3 -3
- package/dist/plugins/toolbar/components/BoldItalicUnderlineToggles.js +79 -24
- package/dist/plugins/toolbar/components/ChangeAdmonitionType.js +1 -1
- package/dist/plugins/toolbar/components/ChangeCodeMirrorLanguage.js +1 -1
- package/dist/plugins/toolbar/components/DiffSourceToggleWrapper.js +3 -1
- package/dist/plugins/toolbar/components/InsertFrontmatter.js +3 -1
- package/dist/plugins/toolbar/components/InsertImage.js +12 -1
- package/dist/plugins/toolbar/components/InsertThematicBreak.js +10 -1
- package/dist/plugins/toolbar/components/KitchenSinkToolbar.js +2 -2
- package/dist/plugins/toolbar/primitives/DialogButton.js +1 -1
- package/dist/plugins/toolbar/primitives/select.js +3 -1
- package/dist/plugins/toolbar/primitives/toolbar.js +17 -3
- package/dist/utils/detectMac.js +1 -1
- package/dist/utils/isPartOftheEditorUI.js +1 -1
- package/package.json +9 -8
- package/dist/plugins/core/MdastInlineCodeVisitor.js +0 -27
package/dist/FormatConstants.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
const IS_BOLD = 1;
|
|
2
2
|
const IS_ITALIC = 2;
|
|
3
|
+
const IS_STRIKETHROUGH = 4;
|
|
3
4
|
const IS_UNDERLINE = 8;
|
|
4
5
|
const IS_CODE = 16;
|
|
6
|
+
const IS_SUBSCRIPT = 32;
|
|
7
|
+
const IS_SUPERSCRIPT = 64;
|
|
5
8
|
export {
|
|
6
9
|
IS_BOLD,
|
|
7
10
|
IS_CODE,
|
|
8
11
|
IS_ITALIC,
|
|
12
|
+
IS_STRIKETHROUGH,
|
|
13
|
+
IS_SUBSCRIPT,
|
|
14
|
+
IS_SUPERSCRIPT,
|
|
9
15
|
IS_UNDERLINE
|
|
10
16
|
};
|
package/dist/MDXEditor.js
CHANGED
|
@@ -125,7 +125,7 @@ const MDXEditor = React__default.forwardRef((props, ref) => {
|
|
|
125
125
|
onError: props.onError ?? noop,
|
|
126
126
|
translation: props.translation ?? defaultTranslation
|
|
127
127
|
}),
|
|
128
|
-
...props.plugins
|
|
128
|
+
...props.plugins ?? []
|
|
129
129
|
]
|
|
130
130
|
},
|
|
131
131
|
/* @__PURE__ */ React__default.createElement(EditorRootElement, { className: props.className }, /* @__PURE__ */ React__default.createElement(LexicalProvider, null, /* @__PURE__ */ React__default.createElement(RichTextEditor, null))),
|
|
@@ -5,13 +5,11 @@ import styles from "../styles/ui.module.css.js";
|
|
|
5
5
|
const GenericDirectiveEditor = ({ mdastNode, descriptor }) => {
|
|
6
6
|
const updateMdastNode = useMdastNodeUpdater();
|
|
7
7
|
const properties = React__default.useMemo(() => {
|
|
8
|
-
return descriptor.attributes.reduce(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{}
|
|
14
|
-
);
|
|
8
|
+
return descriptor.attributes.reduce((acc, attributeName) => {
|
|
9
|
+
var _a;
|
|
10
|
+
acc[attributeName] = ((_a = mdastNode.attributes) == null ? void 0 : _a[attributeName]) ?? "";
|
|
11
|
+
return acc;
|
|
12
|
+
}, {});
|
|
15
13
|
}, [mdastNode, descriptor]);
|
|
16
14
|
const onChange = React__default.useCallback(
|
|
17
15
|
(values) => {
|
|
@@ -136,14 +136,13 @@ function exportLexicalTreeToMdast({
|
|
|
136
136
|
return typedRoot;
|
|
137
137
|
}
|
|
138
138
|
function collapseNestedHtmlTags(node) {
|
|
139
|
-
if ("children" in node && node.children) {
|
|
139
|
+
if ("children" in node && node.children.length > 0) {
|
|
140
140
|
if (isMdastHTMLNode(node) && node.children.length === 1) {
|
|
141
141
|
const onlyChild = node.children[0];
|
|
142
142
|
if (onlyChild.type === "mdxJsxTextElement" && onlyChild.name === "span") {
|
|
143
|
-
|
|
144
|
-
var _a;
|
|
143
|
+
onlyChild.attributes.forEach((attribute) => {
|
|
145
144
|
if (attribute.type === "mdxJsxAttribute") {
|
|
146
|
-
const parentAttribute =
|
|
145
|
+
const parentAttribute = node.attributes.find((attr) => attr.type === "mdxJsxAttribute" && attr.name === attribute.name);
|
|
147
146
|
if (parentAttribute) {
|
|
148
147
|
if (attribute.name === "className") {
|
|
149
148
|
const mergedClassesSet = /* @__PURE__ */ new Set([
|
|
@@ -162,7 +161,9 @@ function collapseNestedHtmlTags(node) {
|
|
|
162
161
|
node.children = onlyChild.children;
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
|
-
node.children.forEach((child) =>
|
|
164
|
+
node.children.forEach((child) => {
|
|
165
|
+
collapseNestedHtmlTags(child);
|
|
166
|
+
});
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
function convertUnderlineJsxToHtml(node) {
|
|
@@ -215,9 +216,11 @@ function fixWrappingWhitespace(node, parentChain) {
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
if ("children" in node && node.children) {
|
|
219
|
+
if ("children" in node && node.children.length > 0) {
|
|
219
220
|
const nodeAsParent = node;
|
|
220
|
-
nodeAsParent.children.forEach((child) =>
|
|
221
|
+
nodeAsParent.children.forEach((child) => {
|
|
222
|
+
fixWrappingWhitespace(child, [...parentChain, nodeAsParent]);
|
|
223
|
+
});
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
226
|
function exportMarkdownFromLexical({
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SvgStrikethroughS = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M12.15 20C10.8833 20 9.75833 19.625 8.775 18.875C7.79167 18.125 7.08333 17.1 6.65 15.8L8.85 14.85C9.08333 15.65 9.4875 16.3083 10.0625 16.825C10.6375 17.3416 11.35 17.6 12.2 17.6C12.9 17.6 13.5333 17.4333 14.1 17.1C14.6667 16.7666 14.95 16.2333 14.95 15.5C14.95 15.2 14.8917 14.925 14.775 14.675C14.6583 14.425 14.5 14.2 14.3 14H17.1C17.1833 14.2333 17.2458 14.4708 17.2875 14.7125C17.3292 14.9541 17.35 15.2166 17.35 15.5C17.35 16.9333 16.8375 18.0416 15.8125 18.825C14.7875 19.6083 13.5667 20 12.15 20ZM2 12V9.99998H22V12H2ZM12.05 3.84998C13.15 3.84998 14.1125 4.12081 14.9375 4.66248C15.7625 5.20414 16.4 6.03331 16.85 7.14998L14.65 8.12498C14.5 7.64164 14.2208 7.20831 13.8125 6.82498C13.4042 6.44164 12.8333 6.24998 12.1 6.24998C11.4167 6.24998 10.85 6.40414 10.4 6.71248C9.95 7.02081 9.7 7.44998 9.65 7.99998H7.25C7.28333 6.84998 7.7375 5.87081 8.6125 5.06248C9.4875 4.25414 10.6333 3.84998 12.05 3.84998Z", fill: "currentColor" }));
|
|
3
|
+
export {
|
|
4
|
+
SvgStrikethroughS as default
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SvgSubscript = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M19 21V18H22V17H19V16H23V19H20V20H23V21H19ZM5.875 19L10.5 11.725L6.2 5H8.85L11.95 10H12.05L15.125 5H17.8L13.475 11.725L18.125 19H15.45L12.05 13.575H11.95L8.55 19H5.875Z", fill: "currentColor" }));
|
|
3
|
+
export {
|
|
4
|
+
SvgSubscript as default
|
|
5
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const SvgSuperscript = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M19 8V5H22V4H19V3H23V6H20V7H23V8H19ZM5.875 19L10.5 11.725L6.2 5H8.85L11.95 10H12.05L15.125 5H17.8L13.475 11.725L18.125 19H15.45L12.05 13.575H11.95L8.55 19H5.875Z", fill: "currentColor" }));
|
|
3
|
+
export {
|
|
4
|
+
SvgSuperscript as default
|
|
5
|
+
};
|
|
@@ -53,7 +53,9 @@ function importMdastTreeToLexical({ root, mdastRoot, visitors, ...descriptors })
|
|
|
53
53
|
if (!isParent(mdastNode)) {
|
|
54
54
|
throw new Error("Attempting to visit children of a non-parent");
|
|
55
55
|
}
|
|
56
|
-
mdastNode.children.forEach((child) =>
|
|
56
|
+
mdastNode.children.forEach((child) => {
|
|
57
|
+
visit(child, lexicalParent, mdastNode);
|
|
58
|
+
});
|
|
57
59
|
}
|
|
58
60
|
function visit(mdastNode, lexicalParent, mdastParent) {
|
|
59
61
|
const visitor = visitors.find((visitor2) => {
|