@mdxeditor/editor 1.11.0 → 1.11.2
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 +8 -0
- package/dist/index.js +32 -1
- package/dist/plugins/core/index.js +21 -3
- package/dist/utils/fp.js +31 -1
- package/dist/utils/lexicalHelpers.js +20 -2
- package/dist/utils/makeHslTransparent.d.ts +1 -0
- package/dist/utils/makeHslTransparent.js +6 -0
- package/dist/utils/whitespaceConversion.d.ts +2 -0
- package/dist/utils/whitespaceConversion.js +9 -0
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -51,4 +51,12 @@ export * from './plugins/toolbar/primitives/TooltipWrap';
|
|
|
51
51
|
export * from './plugins/toolbar/primitives/select';
|
|
52
52
|
export * from './plugins/core/NestedLexicalEditor';
|
|
53
53
|
export * from './plugins/core/PropertyPopover';
|
|
54
|
+
export * from './utils/detectMac';
|
|
55
|
+
export * from './utils/fp';
|
|
56
|
+
export * from './utils/isPartOftheEditorUI';
|
|
57
|
+
export * from './utils/lexicalHelpers';
|
|
58
|
+
export * from './utils/makeHslTransparent';
|
|
59
|
+
export * from './utils/uuid4';
|
|
60
|
+
export * from './utils/voidEmitter';
|
|
61
|
+
export * from './utils/whitespaceConversion';
|
|
54
62
|
export * from './gurx';
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,14 @@ import { TooltipWrap } from "./plugins/toolbar/primitives/TooltipWrap.js";
|
|
|
48
48
|
import { Select, SelectButtonTrigger, SelectContent, SelectItem, SelectTrigger } from "./plugins/toolbar/primitives/select.js";
|
|
49
49
|
import { NestedEditorsContext, NestedLexicalEditor, useLexicalNodeRemove, useMdastNodeUpdater, useNestedEditorContext } from "./plugins/core/NestedLexicalEditor.js";
|
|
50
50
|
import { PropertyPopover } from "./plugins/core/PropertyPopover.js";
|
|
51
|
+
import { CAN_USE_DOM, IS_APPLE, controlOrMeta } from "./utils/detectMac.js";
|
|
52
|
+
import { always, call, compose, curry1to0, curry2to1, joinProc, noop, prop, tap, thrush } from "./utils/fp.js";
|
|
53
|
+
import { isPartOftheEditorUI } from "./utils/isPartOftheEditorUI.js";
|
|
54
|
+
import { fromWithinEditorRead, getSelectedNode, getSelectionRectangle, getStateAsMarkdown } from "./utils/lexicalHelpers.js";
|
|
55
|
+
import { makeHslTransparent } from "./utils/makeHslTransparent.js";
|
|
56
|
+
import { uuidv4 } from "./utils/uuid4.js";
|
|
57
|
+
import { voidEmitter } from "./utils/voidEmitter.js";
|
|
58
|
+
import { WHITESPACE_MARKER, replaceWhitespace } from "./utils/whitespaceConversion.js";
|
|
51
59
|
import { $createGenericHTMLNode, $isGenericHTMLNode, GenericHTMLNode } from "./plugins/core/GenericHTMLNode.js";
|
|
52
60
|
import { $createImageNode, $isImageNode, ImageNode } from "./plugins/image/ImageNode.js";
|
|
53
61
|
import { useCodeBlockEditorContext } from "./plugins/codeblock/CodeBlockNode.js";
|
|
@@ -66,6 +74,7 @@ export {
|
|
|
66
74
|
Button,
|
|
67
75
|
ButtonOrDropdownButton,
|
|
68
76
|
ButtonWithTooltip,
|
|
77
|
+
CAN_USE_DOM,
|
|
69
78
|
ChangeAdmonitionType,
|
|
70
79
|
ChangeCodeMirrorLanguage,
|
|
71
80
|
CodeMirrorEditor,
|
|
@@ -78,6 +87,7 @@ export {
|
|
|
78
87
|
GenericHTMLNode,
|
|
79
88
|
GenericJsxEditor,
|
|
80
89
|
INSERT_IMAGE_COMMAND,
|
|
90
|
+
IS_APPLE,
|
|
81
91
|
ImageNode,
|
|
82
92
|
InsertAdmonition,
|
|
83
93
|
InsertCodeBlock,
|
|
@@ -111,15 +121,22 @@ export {
|
|
|
111
121
|
ToolbarToggleItem,
|
|
112
122
|
TooltipWrap,
|
|
113
123
|
UndoRedo,
|
|
124
|
+
WHITESPACE_MARKER,
|
|
125
|
+
always,
|
|
126
|
+
call,
|
|
114
127
|
codeBlockPlugin,
|
|
115
128
|
codeBlockPluginHooks,
|
|
116
129
|
codeBlockSystem,
|
|
117
130
|
codeMirrorHooks,
|
|
118
131
|
codeMirrorPlugin,
|
|
119
132
|
codeMirrorSystem,
|
|
133
|
+
compose,
|
|
134
|
+
controlOrMeta,
|
|
120
135
|
corePlugin,
|
|
121
136
|
corePluginHooks,
|
|
122
137
|
coreSystem,
|
|
138
|
+
curry1to0,
|
|
139
|
+
curry2to1,
|
|
123
140
|
defaultComparator,
|
|
124
141
|
diffSourcePlugin,
|
|
125
142
|
diffSourcePluginHooks,
|
|
@@ -129,10 +146,14 @@ export {
|
|
|
129
146
|
directivesSystem,
|
|
130
147
|
exportLexicalTreeToMdast,
|
|
131
148
|
exportMarkdownFromLexical,
|
|
149
|
+
fromWithinEditorRead,
|
|
132
150
|
frontmatterPlugin,
|
|
133
151
|
frontmatterPluginHooks,
|
|
134
152
|
frontmatterSystem,
|
|
135
153
|
getRealmFactory,
|
|
154
|
+
getSelectedNode,
|
|
155
|
+
getSelectionRectangle,
|
|
156
|
+
getStateAsMarkdown,
|
|
136
157
|
headingsPlugin,
|
|
137
158
|
headingsPluginHooks,
|
|
138
159
|
headingsSystem,
|
|
@@ -141,6 +162,8 @@ export {
|
|
|
141
162
|
imageSystem,
|
|
142
163
|
importMarkdownToLexical,
|
|
143
164
|
importMdastTreeToLexical,
|
|
165
|
+
isPartOftheEditorUI,
|
|
166
|
+
joinProc,
|
|
144
167
|
jsxPlugin,
|
|
145
168
|
jsxPluginHooks,
|
|
146
169
|
jsxSystem,
|
|
@@ -150,13 +173,17 @@ export {
|
|
|
150
173
|
listsPlugin,
|
|
151
174
|
listsPluginHooks,
|
|
152
175
|
listsSystem,
|
|
176
|
+
makeHslTransparent,
|
|
153
177
|
markdownShortcutPlugin,
|
|
178
|
+
noop,
|
|
179
|
+
prop,
|
|
154
180
|
quotePlugin,
|
|
155
181
|
quotePluginHooks,
|
|
156
182
|
realm,
|
|
157
183
|
realmFactory,
|
|
158
184
|
realmFactoryToComponent,
|
|
159
185
|
realmPlugin,
|
|
186
|
+
replaceWhitespace,
|
|
160
187
|
sandpackPlugin,
|
|
161
188
|
sandpackPluginHooks,
|
|
162
189
|
sandpackSystem,
|
|
@@ -165,9 +192,11 @@ export {
|
|
|
165
192
|
tablePlugin,
|
|
166
193
|
tablePluginHooks,
|
|
167
194
|
tableSystem,
|
|
195
|
+
tap,
|
|
168
196
|
thematicBreakPlugin,
|
|
169
197
|
thematicBreakPluginHooks,
|
|
170
198
|
thematicBreakSystem,
|
|
199
|
+
thrush,
|
|
171
200
|
toolbarPlugin,
|
|
172
201
|
toolbarPluginHooks,
|
|
173
202
|
toolbarSystem,
|
|
@@ -175,5 +204,7 @@ export {
|
|
|
175
204
|
useHasPlugin,
|
|
176
205
|
useLexicalNodeRemove,
|
|
177
206
|
useMdastNodeUpdater,
|
|
178
|
-
useNestedEditorContext
|
|
207
|
+
useNestedEditorContext,
|
|
208
|
+
uuidv4,
|
|
209
|
+
voidEmitter
|
|
179
210
|
};
|
|
@@ -2,7 +2,7 @@ import { createEmptyHistoryState } from "@lexical/react/LexicalHistoryPlugin.js"
|
|
|
2
2
|
import { $isHeadingNode } from "@lexical/rich-text";
|
|
3
3
|
import { $setBlocksType } from "@lexical/selection";
|
|
4
4
|
import { $findMatchingParent, $wrapNodeInElement, $insertNodeToNearestRoot } from "@lexical/utils";
|
|
5
|
-
import { createCommand, SELECTION_CHANGE_COMMAND, $getRoot, COMMAND_PRIORITY_CRITICAL, $setSelection, BLUR_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getSelection, $isRangeSelection, $insertNodes, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
|
|
5
|
+
import { createCommand, SELECTION_CHANGE_COMMAND, $getRoot, COMMAND_PRIORITY_CRITICAL, $setSelection, BLUR_COMMAND, FOCUS_COMMAND, KEY_DOWN_COMMAND, $isDecoratorNode, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, $getSelection, $isRangeSelection, $insertNodes, $createParagraphNode, ParagraphNode, TextNode } from "lexical";
|
|
6
6
|
import { exportMarkdownFromLexical } from "../../exportMarkdownFromLexical.js";
|
|
7
7
|
import { importMarkdownToLexical } from "../../importMarkdownToLexical.js";
|
|
8
8
|
import { LexicalLinebreakVisitor } from "./LexicalLinebreakVisitor.js";
|
|
@@ -148,8 +148,14 @@ const coreSystem = system((r) => {
|
|
|
148
148
|
const addToMarkdownExtension = createAppendNodeFor(toMarkdownExtensions);
|
|
149
149
|
const setMarkdown = r.node();
|
|
150
150
|
r.sub(
|
|
151
|
-
r.pipe(
|
|
152
|
-
|
|
151
|
+
r.pipe(
|
|
152
|
+
setMarkdown,
|
|
153
|
+
r.o.withLatestFrom(markdown, rootEditor, importVisitors, mdastExtensions, syntaxExtensions, inFocus),
|
|
154
|
+
r.o.filter(([newMarkdown, oldMarkdown]) => {
|
|
155
|
+
return newMarkdown.trim() !== oldMarkdown.trim();
|
|
156
|
+
})
|
|
157
|
+
),
|
|
158
|
+
([theNewMarkdownValue, , editor, importVisitors2, mdastExtensions2, syntaxExtensions2, inFocus2]) => {
|
|
153
159
|
editor == null ? void 0 : editor.update(() => {
|
|
154
160
|
$getRoot().clear();
|
|
155
161
|
importMarkdownToLexical({
|
|
@@ -161,6 +167,8 @@ const coreSystem = system((r) => {
|
|
|
161
167
|
});
|
|
162
168
|
if (!inFocus2) {
|
|
163
169
|
$setSelection(null);
|
|
170
|
+
} else {
|
|
171
|
+
editor.focus();
|
|
164
172
|
}
|
|
165
173
|
});
|
|
166
174
|
}
|
|
@@ -215,6 +223,16 @@ const coreSystem = system((r) => {
|
|
|
215
223
|
COMMAND_PRIORITY_CRITICAL
|
|
216
224
|
);
|
|
217
225
|
});
|
|
226
|
+
r.pub(createRootEditorSubscription, (theEditor) => {
|
|
227
|
+
return theEditor.registerCommand(
|
|
228
|
+
FOCUS_COMMAND,
|
|
229
|
+
() => {
|
|
230
|
+
r.pub(inFocus, true);
|
|
231
|
+
return false;
|
|
232
|
+
},
|
|
233
|
+
COMMAND_PRIORITY_CRITICAL
|
|
234
|
+
);
|
|
235
|
+
});
|
|
218
236
|
r.pub(createRootEditorSubscription, (theRootEditor) => {
|
|
219
237
|
return theRootEditor.registerCommand(
|
|
220
238
|
KEY_DOWN_COMMAND,
|
package/dist/utils/fp.js
CHANGED
|
@@ -1,14 +1,44 @@
|
|
|
1
|
+
function compose(a, b) {
|
|
2
|
+
return (arg) => a(b(arg));
|
|
3
|
+
}
|
|
4
|
+
function thrush(arg, proc) {
|
|
5
|
+
return proc(arg);
|
|
6
|
+
}
|
|
7
|
+
function curry2to1(proc, arg1) {
|
|
8
|
+
return (arg2) => proc(arg1, arg2);
|
|
9
|
+
}
|
|
10
|
+
function curry1to0(proc, arg) {
|
|
11
|
+
return () => proc(arg);
|
|
12
|
+
}
|
|
13
|
+
function prop(property) {
|
|
14
|
+
return (object) => object[property];
|
|
15
|
+
}
|
|
1
16
|
function tap(arg, proc) {
|
|
2
17
|
proc(arg);
|
|
3
18
|
return arg;
|
|
4
19
|
}
|
|
20
|
+
function call(proc) {
|
|
21
|
+
proc();
|
|
22
|
+
}
|
|
5
23
|
function always(value) {
|
|
6
24
|
return () => value;
|
|
7
25
|
}
|
|
26
|
+
function joinProc(...procs) {
|
|
27
|
+
return () => {
|
|
28
|
+
procs.map(call);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
8
31
|
function noop() {
|
|
9
32
|
}
|
|
10
33
|
export {
|
|
11
34
|
always,
|
|
35
|
+
call,
|
|
36
|
+
compose,
|
|
37
|
+
curry1to0,
|
|
38
|
+
curry2to1,
|
|
39
|
+
joinProc,
|
|
12
40
|
noop,
|
|
13
|
-
|
|
41
|
+
prop,
|
|
42
|
+
tap,
|
|
43
|
+
thrush
|
|
14
44
|
};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { $getSelection } from "lexical";
|
|
1
|
+
import { $getSelection, $getRoot } from "lexical";
|
|
2
2
|
import { $isAtNodeEnd } from "@lexical/selection";
|
|
3
|
+
import { tap } from "./fp.js";
|
|
4
|
+
import { exportMarkdownFromLexical } from "../exportMarkdownFromLexical.js";
|
|
5
|
+
function fromWithinEditorRead(editor, fn) {
|
|
6
|
+
let result = null;
|
|
7
|
+
editor.getEditorState().read(() => {
|
|
8
|
+
result = fn();
|
|
9
|
+
});
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
3
12
|
function getSelectedNode(selection) {
|
|
4
13
|
try {
|
|
5
14
|
const anchor = selection.anchor;
|
|
@@ -56,7 +65,16 @@ function getSelectionRectangle(editor) {
|
|
|
56
65
|
}
|
|
57
66
|
return null;
|
|
58
67
|
}
|
|
68
|
+
function getStateAsMarkdown(editor, exportParams) {
|
|
69
|
+
return tap({ markdown: "" }, (result) => {
|
|
70
|
+
editor.getEditorState().read(() => {
|
|
71
|
+
result.markdown = exportMarkdownFromLexical({ root: $getRoot(), ...exportParams });
|
|
72
|
+
});
|
|
73
|
+
}).markdown;
|
|
74
|
+
}
|
|
59
75
|
export {
|
|
76
|
+
fromWithinEditorRead,
|
|
60
77
|
getSelectedNode,
|
|
61
|
-
getSelectionRectangle
|
|
78
|
+
getSelectionRectangle,
|
|
79
|
+
getStateAsMarkdown
|
|
62
80
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeHslTransparent(hsl: string, alpha: number): string;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"private": false,
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"type": "module",
|
|
12
|
-
"version": "1.11.
|
|
12
|
+
"version": "1.11.2",
|
|
13
13
|
"description": "React component for rich text markdown editing",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "vite build",
|
|
@@ -232,6 +232,11 @@
|
|
|
232
232
|
"import": "./dist/plugins/core/NestedLexicalEditor.js",
|
|
233
233
|
"default": "./dist/plugins/core/NestedLexicalEditor.js"
|
|
234
234
|
},
|
|
235
|
+
"./utils": {
|
|
236
|
+
"types": "./dist/utils.d.ts",
|
|
237
|
+
"import": "./dist/utils.js",
|
|
238
|
+
"default": "./dist/utils.js"
|
|
239
|
+
},
|
|
235
240
|
"./plugins/codeblock": {
|
|
236
241
|
"types": "./dist/plugins/codeblock/index.d.ts",
|
|
237
242
|
"import": "./dist/plugins/codeblock/index.js",
|