@mdxeditor/editor 0.13.0 → 0.14.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/gurx/react.d.ts
CHANGED
|
@@ -113,8 +113,11 @@ export interface RealmPluginParams<Spec extends AnySystemSpec, Params extends ob
|
|
|
113
113
|
applyParamsToSystem?: (realm: TypedRealm<SystemAndDependencies<Spec>>, props: Params) => void;
|
|
114
114
|
/**
|
|
115
115
|
* Executed when the component mounts. Use this to register import/export visitors, add lexical nodes to the editor, etc.
|
|
116
|
+
* @param realm - the realm instance
|
|
117
|
+
* @param params - the parameters passed to the plugin in the component declaration
|
|
118
|
+
* @param pluginIds - the ids of all the plugins that are present in the component declaration
|
|
116
119
|
*/
|
|
117
|
-
init?: (realm: TypedRealm<SystemAndDependencies<Spec>>,
|
|
120
|
+
init?: (realm: TypedRealm<SystemAndDependencies<Spec>>, params: Params, pluginIds: string[]) => void;
|
|
118
121
|
}
|
|
119
122
|
/** @internal */
|
|
120
123
|
export interface PluginConstructor<Spec extends AnySystemSpec, Params extends object> {
|
package/dist/gurx/react.js
CHANGED
|
@@ -160,10 +160,11 @@ const RealmPluginInitializer = function({
|
|
|
160
160
|
}, []);
|
|
161
161
|
const realm = React__default.useMemo(() => {
|
|
162
162
|
const specs = validPlugins.map((plugin) => plugin.systemSpec);
|
|
163
|
+
const pluginIds = validPlugins.map((plugin) => plugin.id);
|
|
163
164
|
const realm2 = realmFactory(...specs);
|
|
164
165
|
validPlugins.forEach((plugin) => {
|
|
165
166
|
var _a, _b;
|
|
166
|
-
(_a = plugin.init) == null ? void 0 : _a.call(plugin, realm2, plugin.pluginParams);
|
|
167
|
+
(_a = plugin.init) == null ? void 0 : _a.call(plugin, realm2, plugin.pluginParams, pluginIds);
|
|
167
168
|
(_b = plugin.applyParamsToSystem) == null ? void 0 : _b.call(plugin, realm2, plugin.pluginParams);
|
|
168
169
|
});
|
|
169
170
|
return realm2;
|
|
@@ -7,6 +7,7 @@ import styles from "../../styles/ui.module.css.js";
|
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import { $isImageNode } from "./ImageNode.js";
|
|
9
9
|
import ImageResizer from "./ImageResizer.js";
|
|
10
|
+
import { imagePluginHooks } from "./index.js";
|
|
10
11
|
const imageCache = /* @__PURE__ */ new Set();
|
|
11
12
|
function useSuspenseImage(src) {
|
|
12
13
|
if (!imageCache.has(src)) {
|
|
@@ -39,6 +40,7 @@ function ImageEditor({ src, title, nodeKey, width, height }) {
|
|
|
39
40
|
const [selection, setSelection] = React__default.useState(null);
|
|
40
41
|
const activeEditorRef = React__default.useRef(null);
|
|
41
42
|
const [isResizing, setIsResizing] = React__default.useState(false);
|
|
43
|
+
const [disableImageResize] = imagePluginHooks.useEmitterValues("disableImageResize");
|
|
42
44
|
const onDelete = React__default.useCallback(
|
|
43
45
|
(payload) => {
|
|
44
46
|
if (isSelected && $isNodeSelection($getSelection())) {
|
|
@@ -170,7 +172,7 @@ function ImageEditor({ src, title, nodeKey, width, height }) {
|
|
|
170
172
|
title: title || "",
|
|
171
173
|
imageRef
|
|
172
174
|
}
|
|
173
|
-
)), draggable && isFocused && /* @__PURE__ */ React__default.createElement(ImageResizer, { editor, imageRef, onResizeStart, onResizeEnd })));
|
|
175
|
+
)), draggable && isFocused && !disableImageResize && /* @__PURE__ */ React__default.createElement(ImageResizer, { editor, imageRef, onResizeStart, onResizeEnd })));
|
|
174
176
|
}
|
|
175
177
|
export {
|
|
176
178
|
ImageEditor
|
|
@@ -13,6 +13,7 @@ import type { SystemSpec, Realm, RealmNode, PluginConstructor, TypedRealm, Value
|
|
|
13
13
|
import type { RangeSelection, Klass, LexicalNode, TextFormatType, ElementNode, DecoratorNode, LexicalCommand, LexicalEditor } from 'lexical';
|
|
14
14
|
import { CreateImageNodeOptions } from './ImageNode';
|
|
15
15
|
export * from './ImageNode';
|
|
16
|
+
export type ImageUploadHandler = ((image: File) => Promise<string>) | null;
|
|
16
17
|
/** @internal */
|
|
17
18
|
export declare const imageSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
18
19
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -115,13 +116,15 @@ export declare const imageSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
115
116
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
116
117
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
117
118
|
}]) => {
|
|
118
|
-
imageUploadHandler: RealmNode<
|
|
119
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
119
120
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
121
|
+
disableImageResize: RealmNode<boolean>;
|
|
120
122
|
insertImage: RealmNode<string>;
|
|
121
123
|
}>;
|
|
122
124
|
interface ImagePluginParams {
|
|
123
|
-
imageUploadHandler
|
|
125
|
+
imageUploadHandler?: ImageUploadHandler;
|
|
124
126
|
imageAutocompleteSuggestions?: string[];
|
|
127
|
+
disableImageResize?: boolean;
|
|
125
128
|
}
|
|
126
129
|
export declare const
|
|
127
130
|
/** @internal */
|
|
@@ -226,15 +229,17 @@ imagePlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
226
229
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
227
230
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
228
231
|
}]) => {
|
|
229
|
-
imageUploadHandler: RealmNode<
|
|
232
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
230
233
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
234
|
+
disableImageResize: RealmNode<boolean>;
|
|
231
235
|
insertImage: RealmNode<string>;
|
|
232
236
|
}>, ImagePluginParams>,
|
|
233
237
|
/** @internal */
|
|
234
238
|
imagePluginHooks: {
|
|
235
239
|
useRealmContext: () => TypedRealm<{
|
|
236
|
-
imageUploadHandler: RealmNode<
|
|
240
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
237
241
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
242
|
+
disableImageResize: RealmNode<boolean>;
|
|
238
243
|
insertImage: RealmNode<string>;
|
|
239
244
|
} & {
|
|
240
245
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -287,9 +292,10 @@ imagePluginHooks: {
|
|
|
287
292
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
288
293
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
289
294
|
}>;
|
|
290
|
-
useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "imageUploadHandler" | "imageAutocompleteSuggestions" | "insertImage">(key: K, callback: (value: ValueForKey<{
|
|
291
|
-
imageUploadHandler: RealmNode<
|
|
295
|
+
useEmitter: <K extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "imageUploadHandler" | "imageAutocompleteSuggestions" | "disableImageResize" | "insertImage">(key: K, callback: (value: ValueForKey<{
|
|
296
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
292
297
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
298
|
+
disableImageResize: RealmNode<boolean>;
|
|
293
299
|
insertImage: RealmNode<string>;
|
|
294
300
|
} & {
|
|
295
301
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -343,8 +349,9 @@ imagePluginHooks: {
|
|
|
343
349
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
344
350
|
}, K>) => void) => void;
|
|
345
351
|
useEmitterValues: <K_1 extends SystemKeys<{
|
|
346
|
-
imageUploadHandler: RealmNode<
|
|
352
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
347
353
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
354
|
+
disableImageResize: RealmNode<boolean>;
|
|
348
355
|
insertImage: RealmNode<string>;
|
|
349
356
|
} & {
|
|
350
357
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -397,8 +404,9 @@ imagePluginHooks: {
|
|
|
397
404
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
398
405
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
399
406
|
}>>(...keys: K_1) => ValuesForKeys<{
|
|
400
|
-
imageUploadHandler: RealmNode<
|
|
407
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
401
408
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
409
|
+
disableImageResize: RealmNode<boolean>;
|
|
402
410
|
insertImage: RealmNode<string>;
|
|
403
411
|
} & {
|
|
404
412
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -452,8 +460,9 @@ imagePluginHooks: {
|
|
|
452
460
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
453
461
|
}, K_1>;
|
|
454
462
|
usePubKeys: () => (values: SystemDict<{
|
|
455
|
-
imageUploadHandler: RealmNode<
|
|
463
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
456
464
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
465
|
+
disableImageResize: RealmNode<boolean>;
|
|
457
466
|
insertImage: RealmNode<string>;
|
|
458
467
|
} & {
|
|
459
468
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -506,9 +515,10 @@ imagePluginHooks: {
|
|
|
506
515
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
507
516
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
508
517
|
}>) => void;
|
|
509
|
-
usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "imageUploadHandler" | "imageAutocompleteSuggestions" | "insertImage">(key: K_2) => (value: ValueForKey<{
|
|
510
|
-
imageUploadHandler: RealmNode<
|
|
518
|
+
usePublisher: <K_2 extends "jsxComponentDescriptors" | "jsxIsAvailable" | "toMarkdownOptions" | "toMarkdownExtensions" | "mdastExtensions" | "syntaxExtensions" | "markdown" | "activeEditor" | "inFocus" | "historyState" | "currentSelection" | "initialRootEditorState" | "rootEditor" | "createRootEditorSubscription" | "createActiveEditorSubscription" | "importVisitors" | "usedLexicalNodes" | "addImportVisitor" | "addLexicalNode" | "addSyntaxExtension" | "addMdastExtension" | "addToMarkdownExtension" | "addExportVisitor" | "exportVisitors" | "initialMarkdown" | "setMarkdown" | "editorRootElementRef" | "contentEditableClassName" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "imageUploadHandler" | "imageAutocompleteSuggestions" | "disableImageResize" | "insertImage">(key: K_2) => (value: ValueForKey<{
|
|
519
|
+
imageUploadHandler: RealmNode<ImageUploadHandler>;
|
|
511
520
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
521
|
+
disableImageResize: RealmNode<boolean>;
|
|
512
522
|
insertImage: RealmNode<string>;
|
|
513
523
|
} & {
|
|
514
524
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -11,9 +11,8 @@ const imageSystem = system(
|
|
|
11
11
|
(r, [{ rootEditor }]) => {
|
|
12
12
|
const insertImage = r.node();
|
|
13
13
|
const imageAutocompleteSuggestions = r.node([]);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
});
|
|
14
|
+
const disableImageResize = r.node(false);
|
|
15
|
+
const imageUploadHandler = r.node(null);
|
|
17
16
|
r.sub(r.pipe(insertImage, r.o.withLatestFrom(rootEditor)), ([src, theEditor]) => {
|
|
18
17
|
theEditor == null ? void 0 : theEditor.update(() => {
|
|
19
18
|
const imageNode = $createImageNode({ altText: "", src, title: "" });
|
|
@@ -36,6 +35,7 @@ const imageSystem = system(
|
|
|
36
35
|
},
|
|
37
36
|
COMMAND_PRIORITY_EDITOR
|
|
38
37
|
);
|
|
38
|
+
const theUploadHandler = r.getValue(imageUploadHandler);
|
|
39
39
|
editor == null ? void 0 : editor.registerCommand(
|
|
40
40
|
DRAGSTART_COMMAND,
|
|
41
41
|
(event) => {
|
|
@@ -57,6 +57,9 @@ const imageSystem = system(
|
|
|
57
57
|
},
|
|
58
58
|
COMMAND_PRIORITY_HIGH
|
|
59
59
|
);
|
|
60
|
+
if (theUploadHandler === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
60
63
|
editor == null ? void 0 : editor.registerCommand(
|
|
61
64
|
PASTE_COMMAND,
|
|
62
65
|
(event) => {
|
|
@@ -82,16 +85,12 @@ const imageSystem = system(
|
|
|
82
85
|
return {
|
|
83
86
|
imageUploadHandler,
|
|
84
87
|
imageAutocompleteSuggestions,
|
|
88
|
+
disableImageResize,
|
|
85
89
|
insertImage
|
|
86
90
|
};
|
|
87
91
|
},
|
|
88
92
|
[coreSystem]
|
|
89
93
|
);
|
|
90
|
-
const defaultParams = {
|
|
91
|
-
imageUploadHandler: () => {
|
|
92
|
-
throw new Error("Image upload handling is not implemented");
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
94
|
const [
|
|
96
95
|
/** @internal */
|
|
97
96
|
imagePlugin,
|
|
@@ -100,9 +99,10 @@ const [
|
|
|
100
99
|
] = realmPlugin({
|
|
101
100
|
id: "image",
|
|
102
101
|
systemSpec: imageSystem,
|
|
103
|
-
applyParamsToSystem: (realm, params
|
|
104
|
-
realm.pubKey("imageUploadHandler", params.imageUploadHandler);
|
|
105
|
-
realm.pubKey("imageAutocompleteSuggestions", params.imageAutocompleteSuggestions || []);
|
|
102
|
+
applyParamsToSystem: (realm, params) => {
|
|
103
|
+
realm.pubKey("imageUploadHandler", (params == null ? void 0 : params.imageUploadHandler) || null);
|
|
104
|
+
realm.pubKey("imageAutocompleteSuggestions", (params == null ? void 0 : params.imageAutocompleteSuggestions) || []);
|
|
105
|
+
realm.pubKey("disableImageResize", Boolean(params == null ? void 0 : params.disableImageResize));
|
|
106
106
|
},
|
|
107
107
|
init: (realm) => {
|
|
108
108
|
realm.pubKey("addImportVisitor", MdastImageVisitor);
|
|
@@ -164,18 +164,20 @@ function onDrop(event, editor, imageUploadHandler) {
|
|
|
164
164
|
let cbPayload = Array.from(((_a = event.dataTransfer) == null ? void 0 : _a.items) || []);
|
|
165
165
|
cbPayload = cbPayload.filter((i) => /image/.test(i.type));
|
|
166
166
|
if (cbPayload.length > 0) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
if (imageUploadHandler !== null) {
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
Promise.all(cbPayload.map((image) => imageUploadHandler(image.getAsFile()))).then((urls) => {
|
|
170
|
+
urls.forEach((url) => {
|
|
171
|
+
editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
|
|
172
|
+
src: url,
|
|
173
|
+
altText: ""
|
|
174
|
+
});
|
|
173
175
|
});
|
|
176
|
+
}).catch((e) => {
|
|
177
|
+
throw e;
|
|
174
178
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
178
|
-
return true;
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
179
181
|
}
|
|
180
182
|
const node = getImageNodeInSelection();
|
|
181
183
|
if (!node) {
|
|
@@ -1,34 +1,58 @@
|
|
|
1
|
-
import { CODE,
|
|
1
|
+
import { HEADING, QUOTE, LINK, ORDERED_LIST, UNORDERED_LIST, CODE, BOLD_ITALIC_STAR, BOLD_ITALIC_UNDERSCORE, BOLD_STAR, BOLD_UNDERSCORE, INLINE_CODE, ITALIC_STAR, ITALIC_UNDERSCORE } from "@lexical/markdown";
|
|
2
2
|
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin.js";
|
|
3
3
|
import React__default from "react";
|
|
4
4
|
import { CodeBlockNode, $createCodeBlockNode } from "../codeblock/CodeBlockNode.js";
|
|
5
5
|
import { coreSystem } from "../core/index.js";
|
|
6
6
|
import { realmPlugin } from "../../gurx/react.js";
|
|
7
7
|
import { system } from "../../gurx/realmFactory.js";
|
|
8
|
-
function patchMarkdownTransformers(transformers) {
|
|
9
|
-
const transformersCopy = [...transformers];
|
|
10
|
-
const codeTransformer = transformersCopy.find((t) => t === CODE);
|
|
11
|
-
const codeTransformerCopy = {
|
|
12
|
-
...codeTransformer,
|
|
13
|
-
dependencies: [CodeBlockNode],
|
|
14
|
-
replace: (parentNode, _children, match) => {
|
|
15
|
-
const codeBlockNode = $createCodeBlockNode({ code: "", language: match ? match[1] : "", meta: "" });
|
|
16
|
-
parentNode.replace(codeBlockNode);
|
|
17
|
-
setTimeout(() => codeBlockNode.select(), 80);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
transformersCopy.splice(transformersCopy.indexOf(codeTransformer), 1, codeTransformerCopy);
|
|
21
|
-
return transformersCopy;
|
|
22
|
-
}
|
|
23
8
|
const [markdownShortcutPlugin] = realmPlugin({
|
|
24
9
|
id: "markdown-shortcut",
|
|
25
|
-
dependencies: [
|
|
10
|
+
dependencies: [],
|
|
26
11
|
systemSpec: system((_) => ({}), [coreSystem]),
|
|
27
|
-
init: (realm) => {
|
|
28
|
-
|
|
29
|
-
realm.pubKey("
|
|
12
|
+
init: (realm, _, pluginIds) => {
|
|
13
|
+
const transformers = pickTransformersForActivePlugins(pluginIds);
|
|
14
|
+
realm.pubKey("addComposerChild", () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }));
|
|
15
|
+
realm.pubKey("addNestedEditorChild", () => /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers }));
|
|
30
16
|
}
|
|
31
17
|
});
|
|
18
|
+
function pickTransformersForActivePlugins(pluginIds) {
|
|
19
|
+
const transformers = [
|
|
20
|
+
BOLD_ITALIC_STAR,
|
|
21
|
+
BOLD_ITALIC_UNDERSCORE,
|
|
22
|
+
BOLD_STAR,
|
|
23
|
+
BOLD_UNDERSCORE,
|
|
24
|
+
INLINE_CODE,
|
|
25
|
+
ITALIC_STAR,
|
|
26
|
+
ITALIC_UNDERSCORE
|
|
27
|
+
// HIGHLIGHT,
|
|
28
|
+
// STRIKETHROUGH
|
|
29
|
+
];
|
|
30
|
+
if (pluginIds.includes("headings")) {
|
|
31
|
+
transformers.push(HEADING);
|
|
32
|
+
}
|
|
33
|
+
if (pluginIds.includes("quote")) {
|
|
34
|
+
transformers.push(QUOTE);
|
|
35
|
+
}
|
|
36
|
+
if (pluginIds.includes("link")) {
|
|
37
|
+
transformers.push(LINK);
|
|
38
|
+
}
|
|
39
|
+
if (pluginIds.includes("lists")) {
|
|
40
|
+
transformers.push(ORDERED_LIST, UNORDERED_LIST);
|
|
41
|
+
}
|
|
42
|
+
if (pluginIds.includes("codeblock")) {
|
|
43
|
+
const codeTransformerCopy = {
|
|
44
|
+
...CODE,
|
|
45
|
+
dependencies: [CodeBlockNode],
|
|
46
|
+
replace: (parentNode, _children, match) => {
|
|
47
|
+
const codeBlockNode = $createCodeBlockNode({ code: "", language: match ? match[1] : "", meta: "" });
|
|
48
|
+
parentNode.replace(codeBlockNode);
|
|
49
|
+
setTimeout(() => codeBlockNode.select(), 80);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
transformers.push(codeTransformerCopy);
|
|
53
|
+
}
|
|
54
|
+
return transformers;
|
|
55
|
+
}
|
|
32
56
|
export {
|
|
33
57
|
markdownShortcutPlugin
|
|
34
58
|
};
|