@mdxeditor/editor 3.49.0 → 3.49.1
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
CHANGED
|
@@ -121,7 +121,7 @@ export declare function $createTableNode(mdastNode: Mdast.Table): TableNode;
|
|
|
121
121
|
export declare function $isCodeBlockNode(node: LexicalNode | null | undefined): node is CodeBlockNode;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
124
|
+
* Returns true if the node is an {@link DirectiveNode}.
|
|
125
125
|
* @group Directive
|
|
126
126
|
*/
|
|
127
127
|
export declare function $isDirectiveNode(node: LexicalNode | null | undefined): node is DirectiveNode;
|
|
@@ -138,13 +138,13 @@ export declare function $isFrontmatterNode(node: LexicalNode | null | undefined)
|
|
|
138
138
|
export declare function $isGenericHTMLNode(node: LexicalNode | null | undefined): node is GenericHTMLNode;
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
|
-
*
|
|
141
|
+
* Returns true if the node is an {@link ImageNode}.
|
|
142
142
|
* @group Image
|
|
143
143
|
*/
|
|
144
144
|
export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
*
|
|
147
|
+
* Returns true if the given node is a {@link TableNode}.
|
|
148
148
|
* @group Table
|
|
149
149
|
*/
|
|
150
150
|
export declare function $isTableNode(node: LexicalNode | null | undefined): node is TableNode;
|
|
@@ -1155,7 +1155,7 @@ export declare const editorSearchCursor$: NodeRef<number>;
|
|
|
1155
1155
|
|
|
1156
1156
|
export declare const editorSearchRanges$: NodeRef<Range[]>;
|
|
1157
1157
|
|
|
1158
|
-
export declare const
|
|
1158
|
+
export declare const editorSearchScrollableContent$: NodeRef<HTMLElement | null>;
|
|
1159
1159
|
|
|
1160
1160
|
export declare const editorSearchTerm$: NodeRef<string>;
|
|
1161
1161
|
|
|
@@ -1182,7 +1182,7 @@ export declare function exportLexicalTreeToMdast({ root, visitors, jsxComponentD
|
|
|
1182
1182
|
/* Excluded from this release type: ExportMarkdownFromLexicalOptions */
|
|
1183
1183
|
|
|
1184
1184
|
/**
|
|
1185
|
-
* Contains the currently registered export
|
|
1185
|
+
* Contains the currently registered export visitors.
|
|
1186
1186
|
* @group Core
|
|
1187
1187
|
*/
|
|
1188
1188
|
export declare const exportVisitors$: NodeRef< LexicalVisitor[]>;
|
|
@@ -1484,7 +1484,7 @@ export declare interface ImportStatement {
|
|
|
1484
1484
|
}
|
|
1485
1485
|
|
|
1486
1486
|
/**
|
|
1487
|
-
* Contains the currently registered import
|
|
1487
|
+
* Contains the currently registered import visitors.
|
|
1488
1488
|
* @group Core
|
|
1489
1489
|
*/
|
|
1490
1490
|
export declare const importVisitors$: NodeRef<MdastImportVisitor<Mdast.Nodes>[]>;
|
|
@@ -1649,11 +1649,11 @@ export declare const InsertSandpack: () => default_2.JSX.Element;
|
|
|
1649
1649
|
*/
|
|
1650
1650
|
export declare const insertTable$: NodeRef<{
|
|
1651
1651
|
/**
|
|
1652
|
-
* The
|
|
1652
|
+
* The number of rows of the table.
|
|
1653
1653
|
*/
|
|
1654
1654
|
rows?: number | undefined;
|
|
1655
1655
|
/**
|
|
1656
|
-
* The
|
|
1656
|
+
* The number of columns of the table.
|
|
1657
1657
|
*/
|
|
1658
1658
|
columns?: number | undefined;
|
|
1659
1659
|
}>;
|
|
@@ -1707,7 +1707,7 @@ export declare const IS_UNDERLINE: 8;
|
|
|
1707
1707
|
export declare function isMdastHTMLNode(node: Mdast.Nodes): node is MdastHTMLNode;
|
|
1708
1708
|
|
|
1709
1709
|
/**
|
|
1710
|
-
* Determines
|
|
1710
|
+
* Determines whether the given node is a JSX node.
|
|
1711
1711
|
* @group JSX
|
|
1712
1712
|
*/
|
|
1713
1713
|
export declare function isMdastJsxNode(node: Mdast.Nodes): node is MdastJsx;
|
|
@@ -1733,7 +1733,7 @@ export declare interface JsxComponentDescriptor {
|
|
|
1733
1733
|
*/
|
|
1734
1734
|
name: string | null;
|
|
1735
1735
|
/**
|
|
1736
|
-
*
|
|
1736
|
+
* Whether the component is a flow or text component (inline or block)
|
|
1737
1737
|
*/
|
|
1738
1738
|
kind: 'flow' | 'text';
|
|
1739
1739
|
/**
|
|
@@ -1742,7 +1742,7 @@ export declare interface JsxComponentDescriptor {
|
|
|
1742
1742
|
*/
|
|
1743
1743
|
source?: string;
|
|
1744
1744
|
/**
|
|
1745
|
-
*
|
|
1745
|
+
* Whether the component is the default export of the module
|
|
1746
1746
|
*/
|
|
1747
1747
|
defaultExport?: boolean;
|
|
1748
1748
|
/**
|
|
@@ -1750,7 +1750,7 @@ export declare interface JsxComponentDescriptor {
|
|
|
1750
1750
|
*/
|
|
1751
1751
|
props: JsxPropertyDescriptor[];
|
|
1752
1752
|
/**
|
|
1753
|
-
*
|
|
1753
|
+
* Whether or not the component has children
|
|
1754
1754
|
*/
|
|
1755
1755
|
hasChildren?: boolean;
|
|
1756
1756
|
/**
|
|
@@ -1797,7 +1797,7 @@ export declare interface JsxPluginParams {
|
|
|
1797
1797
|
*/
|
|
1798
1798
|
jsxComponentDescriptors: JsxComponentDescriptor[];
|
|
1799
1799
|
/**
|
|
1800
|
-
*
|
|
1800
|
+
* Whether or not to allow default React fragments <></> processing in MDX.
|
|
1801
1801
|
*/
|
|
1802
1802
|
allowFragment?: boolean;
|
|
1803
1803
|
}
|
|
@@ -1818,7 +1818,7 @@ export declare interface JsxPropertyDescriptor {
|
|
|
1818
1818
|
*/
|
|
1819
1819
|
type: 'string' | 'number' | 'expression';
|
|
1820
1820
|
/**
|
|
1821
|
-
*
|
|
1821
|
+
* Whether the property is required
|
|
1822
1822
|
*/
|
|
1823
1823
|
required?: boolean;
|
|
1824
1824
|
}
|
|
@@ -2088,7 +2088,7 @@ export declare interface MdastBlockHTMLNode extends MdxJsxFlowElement {
|
|
|
2088
2088
|
export declare type MdastHTMLNode = MdastBlockHTMLNode | MdastInlineHTMLNode;
|
|
2089
2089
|
|
|
2090
2090
|
/**
|
|
2091
|
-
* Implement this interface to convert
|
|
2091
|
+
* Implement this interface to convert certain mdast nodes into lexical nodes.
|
|
2092
2092
|
* @typeParam UN - The type of the mdast node that is being visited.
|
|
2093
2093
|
* @group Markdown Processing
|
|
2094
2094
|
*/
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ import { applyLinkChanges$, cancelLinkEdit$, linkAutocompleteSuggestions$, linkD
|
|
|
28
28
|
import { toolbarClassName$, toolbarContents$, toolbarPlugin } from "./plugins/toolbar/index.js";
|
|
29
29
|
import { cmExtensions$, diffMarkdown$, diffSourcePlugin, readOnlyDiff$ } from "./plugins/diff-source/index.js";
|
|
30
30
|
import { markdownShortcutPlugin } from "./plugins/markdown-shortcut/index.js";
|
|
31
|
-
import { EmptyTextNodeIndex, MDX_FOCUS_SEARCH_NAME, MDX_SEARCH_NAME, debouncedIndexer$, editorSearchCursor$, editorSearchRanges$,
|
|
31
|
+
import { EmptyTextNodeIndex, MDX_FOCUS_SEARCH_NAME, MDX_SEARCH_NAME, debouncedIndexer$, editorSearchCursor$, editorSearchRanges$, editorSearchScrollableContent$, editorSearchTerm$, editorSearchTermDebounced$, editorSearchTextNodeIndex$, rangeSearchScan, searchOpen$, searchPlugin, useEditorSearch } from "./plugins/search/index.js";
|
|
32
32
|
import { BlockTypeSelect } from "./plugins/toolbar/components/BlockTypeSelect.js";
|
|
33
33
|
import { BoldItalicUnderlineToggles, StrikeThroughSupSubToggles } from "./plugins/toolbar/components/BoldItalicUnderlineToggles.js";
|
|
34
34
|
import { ChangeAdmonitionType, admonitionLabelsMap } from "./plugins/toolbar/components/ChangeAdmonitionType.js";
|
|
@@ -233,7 +233,7 @@ export {
|
|
|
233
233
|
editorRootElementRef$,
|
|
234
234
|
editorSearchCursor$,
|
|
235
235
|
editorSearchRanges$,
|
|
236
|
-
|
|
236
|
+
editorSearchScrollableContent$,
|
|
237
237
|
editorSearchTerm$,
|
|
238
238
|
editorSearchTermDebounced$,
|
|
239
239
|
editorSearchTextNodeIndex$,
|
|
@@ -88,9 +88,9 @@ class GenericHTMLNode extends ElementNode {
|
|
|
88
88
|
/*
|
|
89
89
|
// Mutation
|
|
90
90
|
insertNewAfter(selection?: RangeSelection, restoreSelection = true): ParagraphNode | GenericHTMLNode {
|
|
91
|
-
const
|
|
91
|
+
const anchorOffset = selection ? selection.anchor.offset : 0
|
|
92
92
|
const newElement =
|
|
93
|
-
|
|
93
|
+
anchorOffset > 0 && anchorOffset < this.getTextContentSize() ? $createHeadingNode(this.getTag()) : $createParagraphNode()
|
|
94
94
|
const direction = this.getDirection()
|
|
95
95
|
newElement.setDirection(direction)
|
|
96
96
|
this.insertAfter(newElement, restoreSelection)
|
|
@@ -68,9 +68,9 @@ class LexicalMdxExpressionNode extends DecoratorNode {
|
|
|
68
68
|
/*
|
|
69
69
|
// Mutation
|
|
70
70
|
insertNewAfter(selection?: RangeSelection, restoreSelection = true): ParagraphNode | GenericHTMLNode {
|
|
71
|
-
const
|
|
71
|
+
const anchorOffset = selection ? selection.anchor.offset : 0
|
|
72
72
|
const newElement =
|
|
73
|
-
|
|
73
|
+
anchorOffset > 0 && anchorOffset < this.getTextContentSize() ? $createHeadingNode(this.getTag()) : $createParagraphNode()
|
|
74
74
|
const direction = this.getDirection()
|
|
75
75
|
newElement.setDirection(direction)
|
|
76
76
|
this.insertAfter(newElement, restoreSelection)
|
|
@@ -15,11 +15,11 @@ const searchOpen$ = Cell(false);
|
|
|
15
15
|
const editorSearchTermDebounced$ = Cell("", (realm) => {
|
|
16
16
|
realm.link(editorSearchTermDebounced$, realm.pipe(editorSearchTerm$, realm.transformer(debounceTime(250))));
|
|
17
17
|
});
|
|
18
|
-
const
|
|
18
|
+
const editorSearchScrollableContent$ = Cell(
|
|
19
19
|
null,
|
|
20
20
|
(r) => r.sub(contentEditableRef$, (cref) => {
|
|
21
21
|
var _a;
|
|
22
|
-
r.pub(
|
|
22
|
+
r.pub(editorSearchScrollableContent$, ((_a = cref == null ? void 0 : cref.current) == null ? void 0 : _a.parentNode) ?? null);
|
|
23
23
|
})
|
|
24
24
|
);
|
|
25
25
|
const MDX_SEARCH_NAME = "MdxSearch";
|
|
@@ -180,7 +180,7 @@ function useEditorSearch() {
|
|
|
180
180
|
const cursor = useCellValue(editorSearchCursor$);
|
|
181
181
|
const search = useCellValue(editorSearchTerm$);
|
|
182
182
|
const currentRange = ranges[cursor - 1] ?? null;
|
|
183
|
-
const contentEditable = useCellValue(
|
|
183
|
+
const contentEditable = useCellValue(editorSearchScrollableContent$);
|
|
184
184
|
const [isSearchOpen, setIsSearchOpen] = useCell(searchOpen$);
|
|
185
185
|
const openSearch = () => {
|
|
186
186
|
setIsSearchOpen(true);
|
|
@@ -307,7 +307,7 @@ const searchPlugin = realmPlugin({
|
|
|
307
307
|
const scrollRange = ranges[currentCursor - 1];
|
|
308
308
|
if (!scrollRange)
|
|
309
309
|
throw new Error("error updating highlights, scroll range does not exist");
|
|
310
|
-
const contentEditable = realm.getValue(
|
|
310
|
+
const contentEditable = realm.getValue(editorSearchScrollableContent$);
|
|
311
311
|
scrollToRange(scrollRange, contentEditable, {
|
|
312
312
|
ignoreIfInView: true
|
|
313
313
|
});
|
|
@@ -357,7 +357,7 @@ export {
|
|
|
357
357
|
debouncedIndexer$,
|
|
358
358
|
editorSearchCursor$,
|
|
359
359
|
editorSearchRanges$,
|
|
360
|
-
|
|
360
|
+
editorSearchScrollableContent$,
|
|
361
361
|
editorSearchTerm$,
|
|
362
362
|
editorSearchTermDebounced$,
|
|
363
363
|
editorSearchTextNodeIndex$,
|