@mdxeditor/editor 0.12.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/MDXEditor.d.ts +4 -0
- package/dist/MDXEditor.js +11 -10
- package/dist/gurx/react.d.ts +4 -1
- package/dist/gurx/react.js +2 -1
- package/dist/plugins/codeblock/index.d.ts +13 -3
- package/dist/plugins/codemirror/index.d.ts +17 -3
- package/dist/plugins/core/NestedLexicalEditor.d.ts +1 -1
- package/dist/plugins/core/NestedLexicalEditor.js +4 -4
- package/dist/plugins/core/SharedHistoryPlugin.js +1 -1
- package/dist/plugins/core/index.d.ts +12 -3
- package/dist/plugins/core/index.js +4 -1
- package/dist/plugins/diff-source/index.d.ts +13 -3
- package/dist/plugins/directives/index.d.ts +13 -3
- package/dist/plugins/frontmatter/index.d.ts +13 -3
- package/dist/plugins/headings/index.d.ts +3 -1
- package/dist/plugins/image/ImageEditor.js +5 -3
- package/dist/plugins/image/index.d.ts +32 -12
- package/dist/plugins/image/index.js +23 -21
- package/dist/plugins/jsx/index.d.ts +12 -2
- package/dist/plugins/link/AutoLinkPlugin.d.ts +9 -0
- package/dist/plugins/link/AutoLinkPlugin.js +18 -0
- package/dist/plugins/link/index.d.ts +21 -4
- package/dist/plugins/link/index.js +16 -5
- package/dist/plugins/link-dialog/index.d.ts +11 -3
- package/dist/plugins/link-dialog/index.js +1 -0
- package/dist/plugins/lists/index.d.ts +13 -3
- package/dist/plugins/lists/index.js +2 -2
- package/dist/plugins/markdown-shortcut/index.d.ts +1 -0
- package/dist/plugins/markdown-shortcut/index.js +45 -21
- package/dist/plugins/quote/index.d.ts +10 -3
- package/dist/plugins/sandpack/index.d.ts +16 -2
- package/dist/plugins/table/TableEditor.js +5 -5
- package/dist/plugins/table/index.d.ts +13 -3
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.d.ts +1 -1
- package/dist/plugins/thematic-break/LexicalThematicBreakVisitor.js +1 -1
- package/dist/plugins/thematic-break/MdastThematicBreakVisitor.js +1 -1
- package/dist/plugins/thematic-break/index.d.ts +13 -3
- package/dist/plugins/thematic-break/index.js +2 -2
- package/dist/plugins/toolbar/index.d.ts +10 -2
- package/dist/style.css +184 -165
- package/dist/styles/ui.module.css.js +90 -84
- package/package.json +1 -1
|
@@ -107,6 +107,7 @@ export declare const jsxSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
107
107
|
markdown: RealmNode<string>;
|
|
108
108
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
109
109
|
contentEditableClassName: RealmNode<string>;
|
|
110
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
110
111
|
autoFocus: RealmNode<boolean>;
|
|
111
112
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
112
113
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -156,6 +157,7 @@ export declare const jsxSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
156
157
|
markdown: RealmNode<string>;
|
|
157
158
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
158
159
|
contentEditableClassName: RealmNode<string>;
|
|
160
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
159
161
|
autoFocus: RealmNode<boolean>;
|
|
160
162
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
161
163
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -219,6 +221,7 @@ jsxPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
219
221
|
markdown: RealmNode<string>;
|
|
220
222
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
221
223
|
contentEditableClassName: RealmNode<string>;
|
|
224
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
222
225
|
autoFocus: RealmNode<boolean>;
|
|
223
226
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
224
227
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -268,6 +271,7 @@ jsxPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
268
271
|
markdown: RealmNode<string>;
|
|
269
272
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
270
273
|
contentEditableClassName: RealmNode<string>;
|
|
274
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
271
275
|
autoFocus: RealmNode<boolean>;
|
|
272
276
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
273
277
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -324,6 +328,7 @@ jsxPluginHooks: {
|
|
|
324
328
|
markdown: RealmNode<string>;
|
|
325
329
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
326
330
|
contentEditableClassName: RealmNode<string>;
|
|
331
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
327
332
|
autoFocus: RealmNode<boolean>;
|
|
328
333
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
329
334
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -345,7 +350,7 @@ jsxPluginHooks: {
|
|
|
345
350
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
346
351
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
347
352
|
}>;
|
|
348
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "insertJsx">(key: K, callback: (value: ValueForKey<{
|
|
353
|
+
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" | "insertJsx">(key: K, callback: (value: ValueForKey<{
|
|
349
354
|
insertJsx: RealmNode<InsertJsxPayload>;
|
|
350
355
|
} & {
|
|
351
356
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -376,6 +381,7 @@ jsxPluginHooks: {
|
|
|
376
381
|
markdown: RealmNode<string>;
|
|
377
382
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
378
383
|
contentEditableClassName: RealmNode<string>;
|
|
384
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
379
385
|
autoFocus: RealmNode<boolean>;
|
|
380
386
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
381
387
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -428,6 +434,7 @@ jsxPluginHooks: {
|
|
|
428
434
|
markdown: RealmNode<string>;
|
|
429
435
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
430
436
|
contentEditableClassName: RealmNode<string>;
|
|
437
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
431
438
|
autoFocus: RealmNode<boolean>;
|
|
432
439
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
433
440
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -479,6 +486,7 @@ jsxPluginHooks: {
|
|
|
479
486
|
markdown: RealmNode<string>;
|
|
480
487
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
481
488
|
contentEditableClassName: RealmNode<string>;
|
|
489
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
482
490
|
autoFocus: RealmNode<boolean>;
|
|
483
491
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
484
492
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -531,6 +539,7 @@ jsxPluginHooks: {
|
|
|
531
539
|
markdown: RealmNode<string>;
|
|
532
540
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
533
541
|
contentEditableClassName: RealmNode<string>;
|
|
542
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
534
543
|
autoFocus: RealmNode<boolean>;
|
|
535
544
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
536
545
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -552,7 +561,7 @@ jsxPluginHooks: {
|
|
|
552
561
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
553
562
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
554
563
|
}>) => void;
|
|
555
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "insertJsx">(key: K_2) => (value: ValueForKey<{
|
|
564
|
+
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" | "insertJsx">(key: K_2) => (value: ValueForKey<{
|
|
556
565
|
insertJsx: RealmNode<InsertJsxPayload>;
|
|
557
566
|
} & {
|
|
558
567
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -583,6 +592,7 @@ jsxPluginHooks: {
|
|
|
583
592
|
markdown: RealmNode<string>;
|
|
584
593
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
585
594
|
contentEditableClassName: RealmNode<string>;
|
|
595
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
586
596
|
autoFocus: RealmNode<boolean>;
|
|
587
597
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
588
598
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { FC } from 'react';
|
|
9
|
+
export declare const LexicalAutoLinkPlugin: FC;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createLinkMatcherWithRegExp, AutoLinkPlugin } from "@lexical/react/LexicalAutoLinkPlugin.js";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
|
|
4
|
+
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
5
|
+
const MATCHERS = [
|
|
6
|
+
createLinkMatcherWithRegExp(URL_REGEX, (text) => {
|
|
7
|
+
return text.startsWith("http") ? text : `https://${text}`;
|
|
8
|
+
}),
|
|
9
|
+
createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {
|
|
10
|
+
return `mailto:${text}`;
|
|
11
|
+
})
|
|
12
|
+
];
|
|
13
|
+
const LexicalAutoLinkPlugin = () => {
|
|
14
|
+
return /* @__PURE__ */ React__default.createElement(AutoLinkPlugin, { matchers: MATCHERS });
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
LexicalAutoLinkPlugin
|
|
18
|
+
};
|
|
@@ -10,7 +10,22 @@ import type { HistoryState } from '@lexical/history';
|
|
|
10
10
|
import type { LexicalEditor, RangeSelection, Klass, LexicalNode, TextFormatType, ElementNode, DecoratorNode } from 'lexical';
|
|
11
11
|
import type { PluginConstructor, SystemSpec, Realm, RealmNode } from '../../gurx';
|
|
12
12
|
import React from 'react';
|
|
13
|
-
import { LinkPlugin as LexicalLinkPlugin } from '@lexical/react/LexicalLinkPlugin';
|
|
13
|
+
import { LinkPlugin as LexicalLinkPlugin } from '@lexical/react/LexicalLinkPlugin.js';
|
|
14
|
+
/**
|
|
15
|
+
* The parameters used to configure the link plugin
|
|
16
|
+
*/
|
|
17
|
+
interface LinkPluginParams {
|
|
18
|
+
/**
|
|
19
|
+
* An optional function to validate the URL of a link.
|
|
20
|
+
* By default, no validation is performed.
|
|
21
|
+
*/
|
|
22
|
+
validateUrl?: React.ComponentProps<typeof LexicalLinkPlugin>['validateUrl'];
|
|
23
|
+
/**
|
|
24
|
+
* Whether to disable the auto-linking of URLs and email addresses.
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
disableAutoLink?: boolean;
|
|
28
|
+
}
|
|
14
29
|
/**
|
|
15
30
|
* @internal
|
|
16
31
|
*/
|
|
@@ -43,6 +58,7 @@ export declare const linkPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r
|
|
|
43
58
|
markdown: RealmNode<string>;
|
|
44
59
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
45
60
|
contentEditableClassName: RealmNode<string>;
|
|
61
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
46
62
|
autoFocus: RealmNode<boolean>;
|
|
47
63
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
48
64
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -63,6 +79,7 @@ export declare const linkPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r
|
|
|
63
79
|
applyBlockType: RealmNode<BlockType>;
|
|
64
80
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
65
81
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
66
|
-
}>], (
|
|
67
|
-
|
|
68
|
-
}>;
|
|
82
|
+
}>], (r: Realm) => {
|
|
83
|
+
disableAutoLink: RealmNode<boolean>;
|
|
84
|
+
}>, LinkPluginParams>;
|
|
85
|
+
export {};
|
|
@@ -2,19 +2,30 @@ import React__default from "react";
|
|
|
2
2
|
import { coreSystem } from "../core/index.js";
|
|
3
3
|
import { MdastLinkVisitor } from "./MdastLinkVisitor.js";
|
|
4
4
|
import { LexicalLinkVisitor } from "./LexicalLinkVisitor.js";
|
|
5
|
-
import { LinkNode } from "@lexical/link";
|
|
6
|
-
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
7
|
-
import {
|
|
5
|
+
import { LinkNode, AutoLinkNode } from "@lexical/link";
|
|
6
|
+
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin.js";
|
|
7
|
+
import { LexicalAutoLinkPlugin } from "./AutoLinkPlugin.js";
|
|
8
8
|
import { system } from "../../gurx/realmFactory.js";
|
|
9
|
+
import { realmPlugin } from "../../gurx/react.js";
|
|
10
|
+
const linkSystem = system(
|
|
11
|
+
(r) => {
|
|
12
|
+
const disableAutoLink = r.node(false);
|
|
13
|
+
return { disableAutoLink };
|
|
14
|
+
},
|
|
15
|
+
[coreSystem]
|
|
16
|
+
);
|
|
9
17
|
const [linkPlugin] = realmPlugin({
|
|
10
18
|
id: "link",
|
|
11
|
-
systemSpec:
|
|
19
|
+
systemSpec: linkSystem,
|
|
12
20
|
init: (realm, params) => {
|
|
21
|
+
const disableAutoLink = Boolean(params == null ? void 0 : params.disableAutoLink);
|
|
13
22
|
realm.pubKey("addImportVisitor", MdastLinkVisitor);
|
|
14
23
|
realm.pubKey("addLexicalNode", LinkNode);
|
|
24
|
+
realm.pubKey("addLexicalNode", AutoLinkNode);
|
|
15
25
|
realm.pubKey("addExportVisitor", LexicalLinkVisitor);
|
|
26
|
+
realm.pubKey("disableAutoLink", disableAutoLink);
|
|
16
27
|
const linkPluginProps = (params == null ? void 0 : params.validateUrl) ? { validateUrl: params.validateUrl } : {};
|
|
17
|
-
realm.pubKey("addComposerChild", () => /* @__PURE__ */ React__default.createElement(LinkPlugin, { ...linkPluginProps }));
|
|
28
|
+
realm.pubKey("addComposerChild", () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(LinkPlugin, { ...linkPluginProps }), disableAutoLink ? null : /* @__PURE__ */ React__default.createElement(LexicalAutoLinkPlugin, null)));
|
|
18
29
|
}
|
|
19
30
|
});
|
|
20
31
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RefObject,
|
|
1
|
+
import type { RefObject, ReactNode, ComponentType } from 'react';
|
|
2
2
|
import type { Options } from 'mdast-util-to-markdown';
|
|
3
3
|
import type { Config } from 'mdast-util-from-markdown/lib';
|
|
4
4
|
import type { Extension } from 'micromark-util-types';
|
|
@@ -61,6 +61,7 @@ linkDialogPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
61
61
|
markdown: RealmNode<string>;
|
|
62
62
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
63
63
|
contentEditableClassName: RealmNode<string>;
|
|
64
|
+
placeholder: RealmNode<ReactNode>;
|
|
64
65
|
autoFocus: RealmNode<boolean>;
|
|
65
66
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
66
67
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -110,6 +111,7 @@ linkDialogPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
110
111
|
markdown: RealmNode<string>;
|
|
111
112
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
112
113
|
contentEditableClassName: RealmNode<string>;
|
|
114
|
+
placeholder: RealmNode<ReactNode>;
|
|
113
115
|
autoFocus: RealmNode<boolean>;
|
|
114
116
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
115
117
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -186,6 +188,7 @@ linkDialogPluginHooks: {
|
|
|
186
188
|
markdown: RealmNode<string>;
|
|
187
189
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
188
190
|
contentEditableClassName: RealmNode<string>;
|
|
191
|
+
placeholder: RealmNode<ReactNode>;
|
|
189
192
|
autoFocus: RealmNode<boolean>;
|
|
190
193
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
191
194
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -207,7 +210,7 @@ linkDialogPluginHooks: {
|
|
|
207
210
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
208
211
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
209
212
|
}>;
|
|
210
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "dialogState" | "onWindowChange" | "linkDialogState" | "updateLinkUrl" | "switchFromPreviewToLinkEdit" | "cancelLinkEdit" | "removeLink" | "openLinkEditDialog" | "applyLinkChanges" | "linkAutocompleteSuggestions">(key: K, callback: (value: ValueForKey<{
|
|
213
|
+
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" | "dialogState" | "onWindowChange" | "linkDialogState" | "updateLinkUrl" | "switchFromPreviewToLinkEdit" | "cancelLinkEdit" | "removeLink" | "openLinkEditDialog" | "applyLinkChanges" | "linkAutocompleteSuggestions">(key: K, callback: (value: ValueForKey<{
|
|
211
214
|
dialogState: RealmNode<boolean>;
|
|
212
215
|
onWindowChange: RealmNode<true>;
|
|
213
216
|
linkDialogState: RealmNode<InactiveLinkDialog | PreviewLinkDialog | EditLinkDialog>;
|
|
@@ -247,6 +250,7 @@ linkDialogPluginHooks: {
|
|
|
247
250
|
markdown: RealmNode<string>;
|
|
248
251
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
249
252
|
contentEditableClassName: RealmNode<string>;
|
|
253
|
+
placeholder: RealmNode<ReactNode>;
|
|
250
254
|
autoFocus: RealmNode<boolean>;
|
|
251
255
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
252
256
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -308,6 +312,7 @@ linkDialogPluginHooks: {
|
|
|
308
312
|
markdown: RealmNode<string>;
|
|
309
313
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
310
314
|
contentEditableClassName: RealmNode<string>;
|
|
315
|
+
placeholder: RealmNode<ReactNode>;
|
|
311
316
|
autoFocus: RealmNode<boolean>;
|
|
312
317
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
313
318
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -368,6 +373,7 @@ linkDialogPluginHooks: {
|
|
|
368
373
|
markdown: RealmNode<string>;
|
|
369
374
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
370
375
|
contentEditableClassName: RealmNode<string>;
|
|
376
|
+
placeholder: RealmNode<ReactNode>;
|
|
371
377
|
autoFocus: RealmNode<boolean>;
|
|
372
378
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
373
379
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -429,6 +435,7 @@ linkDialogPluginHooks: {
|
|
|
429
435
|
markdown: RealmNode<string>;
|
|
430
436
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
431
437
|
contentEditableClassName: RealmNode<string>;
|
|
438
|
+
placeholder: RealmNode<ReactNode>;
|
|
432
439
|
autoFocus: RealmNode<boolean>;
|
|
433
440
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
434
441
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -450,7 +457,7 @@ linkDialogPluginHooks: {
|
|
|
450
457
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
451
458
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
452
459
|
}>) => void;
|
|
453
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "dialogState" | "onWindowChange" | "linkDialogState" | "updateLinkUrl" | "switchFromPreviewToLinkEdit" | "cancelLinkEdit" | "removeLink" | "openLinkEditDialog" | "applyLinkChanges" | "linkAutocompleteSuggestions">(key: K_2) => (value: ValueForKey<{
|
|
460
|
+
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" | "dialogState" | "onWindowChange" | "linkDialogState" | "updateLinkUrl" | "switchFromPreviewToLinkEdit" | "cancelLinkEdit" | "removeLink" | "openLinkEditDialog" | "applyLinkChanges" | "linkAutocompleteSuggestions">(key: K_2) => (value: ValueForKey<{
|
|
454
461
|
dialogState: RealmNode<boolean>;
|
|
455
462
|
onWindowChange: RealmNode<true>;
|
|
456
463
|
linkDialogState: RealmNode<InactiveLinkDialog | PreviewLinkDialog | EditLinkDialog>;
|
|
@@ -490,6 +497,7 @@ linkDialogPluginHooks: {
|
|
|
490
497
|
markdown: RealmNode<string>;
|
|
491
498
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
492
499
|
contentEditableClassName: RealmNode<string>;
|
|
500
|
+
placeholder: RealmNode<ReactNode>;
|
|
493
501
|
autoFocus: RealmNode<boolean>;
|
|
494
502
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
495
503
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RefObject,
|
|
1
|
+
import type { RefObject, ReactNode, ComponentType } from 'react';
|
|
2
2
|
import type { Options } from 'mdast-util-to-markdown';
|
|
3
3
|
import type { Config } from 'mdast-util-from-markdown/lib';
|
|
4
4
|
import type { Extension } from 'micromark-util-types';
|
|
@@ -43,6 +43,7 @@ export declare const listsSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
43
43
|
markdown: RealmNode<string>;
|
|
44
44
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
45
45
|
contentEditableClassName: RealmNode<string>;
|
|
46
|
+
placeholder: RealmNode<ReactNode>;
|
|
46
47
|
autoFocus: RealmNode<boolean>;
|
|
47
48
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
48
49
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -92,6 +93,7 @@ export declare const listsSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
92
93
|
markdown: RealmNode<string>;
|
|
93
94
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
94
95
|
contentEditableClassName: RealmNode<string>;
|
|
96
|
+
placeholder: RealmNode<ReactNode>;
|
|
95
97
|
autoFocus: RealmNode<boolean>;
|
|
96
98
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
97
99
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -147,6 +149,7 @@ listsPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
147
149
|
markdown: RealmNode<string>;
|
|
148
150
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
149
151
|
contentEditableClassName: RealmNode<string>;
|
|
152
|
+
placeholder: RealmNode<ReactNode>;
|
|
150
153
|
autoFocus: RealmNode<boolean>;
|
|
151
154
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
152
155
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -196,6 +199,7 @@ listsPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
196
199
|
markdown: RealmNode<string>;
|
|
197
200
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
198
201
|
contentEditableClassName: RealmNode<string>;
|
|
202
|
+
placeholder: RealmNode<ReactNode>;
|
|
199
203
|
autoFocus: RealmNode<boolean>;
|
|
200
204
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
201
205
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -254,6 +258,7 @@ listsPluginHooks: {
|
|
|
254
258
|
markdown: RealmNode<string>;
|
|
255
259
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
256
260
|
contentEditableClassName: RealmNode<string>;
|
|
261
|
+
placeholder: RealmNode<ReactNode>;
|
|
257
262
|
autoFocus: RealmNode<boolean>;
|
|
258
263
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
259
264
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -275,7 +280,7 @@ listsPluginHooks: {
|
|
|
275
280
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
276
281
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
277
282
|
}>;
|
|
278
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "currentListType" | "applyListType">(key: K, callback: (value: ValueForKey<{
|
|
283
|
+
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" | "currentListType" | "applyListType">(key: K, callback: (value: ValueForKey<{
|
|
279
284
|
currentListType: RealmNode<"" | ListType>;
|
|
280
285
|
applyListType: RealmNode<"" | ListType>;
|
|
281
286
|
} & {
|
|
@@ -307,6 +312,7 @@ listsPluginHooks: {
|
|
|
307
312
|
markdown: RealmNode<string>;
|
|
308
313
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
309
314
|
contentEditableClassName: RealmNode<string>;
|
|
315
|
+
placeholder: RealmNode<ReactNode>;
|
|
310
316
|
autoFocus: RealmNode<boolean>;
|
|
311
317
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
312
318
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -360,6 +366,7 @@ listsPluginHooks: {
|
|
|
360
366
|
markdown: RealmNode<string>;
|
|
361
367
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
362
368
|
contentEditableClassName: RealmNode<string>;
|
|
369
|
+
placeholder: RealmNode<ReactNode>;
|
|
363
370
|
autoFocus: RealmNode<boolean>;
|
|
364
371
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
365
372
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -412,6 +419,7 @@ listsPluginHooks: {
|
|
|
412
419
|
markdown: RealmNode<string>;
|
|
413
420
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
414
421
|
contentEditableClassName: RealmNode<string>;
|
|
422
|
+
placeholder: RealmNode<ReactNode>;
|
|
415
423
|
autoFocus: RealmNode<boolean>;
|
|
416
424
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
417
425
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -465,6 +473,7 @@ listsPluginHooks: {
|
|
|
465
473
|
markdown: RealmNode<string>;
|
|
466
474
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
467
475
|
contentEditableClassName: RealmNode<string>;
|
|
476
|
+
placeholder: RealmNode<ReactNode>;
|
|
468
477
|
autoFocus: RealmNode<boolean>;
|
|
469
478
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
470
479
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -486,7 +495,7 @@ listsPluginHooks: {
|
|
|
486
495
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
487
496
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
488
497
|
}>) => void;
|
|
489
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "currentListType" | "applyListType">(key: K_2) => (value: ValueForKey<{
|
|
498
|
+
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" | "currentListType" | "applyListType">(key: K_2) => (value: ValueForKey<{
|
|
490
499
|
currentListType: RealmNode<"" | ListType>;
|
|
491
500
|
applyListType: RealmNode<"" | ListType>;
|
|
492
501
|
} & {
|
|
@@ -518,6 +527,7 @@ listsPluginHooks: {
|
|
|
518
527
|
markdown: RealmNode<string>;
|
|
519
528
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
520
529
|
contentEditableClassName: RealmNode<string>;
|
|
530
|
+
placeholder: RealmNode<ReactNode>;
|
|
521
531
|
autoFocus: RealmNode<boolean>;
|
|
522
532
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
523
533
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -5,8 +5,8 @@ import { LexicalListVisitor } from "./LexicalListVisitor.js";
|
|
|
5
5
|
import { LexicalListItemVisitor } from "./LexicalListItemVisitor.js";
|
|
6
6
|
import { $isListNode, ListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, ListItemNode, $getListDepth, $isListItemNode } from "@lexical/list";
|
|
7
7
|
import { $isRootOrShadowRoot, INDENT_CONTENT_COMMAND, COMMAND_PRIORITY_CRITICAL, $getSelection, $isRangeSelection, $isElementNode } from "lexical";
|
|
8
|
-
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
9
|
-
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
8
|
+
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin.js";
|
|
9
|
+
import { ListPlugin } from "@lexical/react/LexicalListPlugin.js";
|
|
10
10
|
import { $findMatchingParent, $getNearestNodeOfType } from "@lexical/utils";
|
|
11
11
|
import { system } from "../../gurx/realmFactory.js";
|
|
12
12
|
import { realmPlugin } from "../../gurx/react.js";
|
|
@@ -40,6 +40,7 @@ export declare const markdownShortcutPlugin: PluginConstructor<SystemSpec<[Syste
|
|
|
40
40
|
markdown: RealmNode<string>;
|
|
41
41
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
42
42
|
contentEditableClassName: RealmNode<string>;
|
|
43
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
43
44
|
autoFocus: RealmNode<boolean>;
|
|
44
45
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
45
46
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
@@ -1,34 +1,58 @@
|
|
|
1
|
-
import { CODE,
|
|
2
|
-
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
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
|
+
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
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RefObject,
|
|
1
|
+
import type { RefObject, ReactNode, ComponentType } from 'react';
|
|
2
2
|
import type { Options } from 'mdast-util-to-markdown';
|
|
3
3
|
import type { Config } from 'mdast-util-from-markdown/lib';
|
|
4
4
|
import type { Extension } from 'micromark-util-types';
|
|
@@ -42,6 +42,7 @@ quotePlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
42
42
|
markdown: RealmNode<string>;
|
|
43
43
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
44
44
|
contentEditableClassName: RealmNode<string>;
|
|
45
|
+
placeholder: RealmNode<ReactNode>;
|
|
45
46
|
autoFocus: RealmNode<boolean>;
|
|
46
47
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
47
48
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -94,6 +95,7 @@ quotePluginHooks: {
|
|
|
94
95
|
markdown: RealmNode<string>;
|
|
95
96
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
96
97
|
contentEditableClassName: RealmNode<string>;
|
|
98
|
+
placeholder: RealmNode<ReactNode>;
|
|
97
99
|
autoFocus: RealmNode<boolean>;
|
|
98
100
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
99
101
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -115,7 +117,7 @@ quotePluginHooks: {
|
|
|
115
117
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
116
118
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
117
119
|
}>;
|
|
118
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode">(key: K, callback: (value: ValueForKey<{
|
|
120
|
+
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">(key: K, callback: (value: ValueForKey<{
|
|
119
121
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
120
122
|
inFocus: RealmNode<boolean>;
|
|
121
123
|
historyState: RealmNode<HistoryState>;
|
|
@@ -144,6 +146,7 @@ quotePluginHooks: {
|
|
|
144
146
|
markdown: RealmNode<string>;
|
|
145
147
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
146
148
|
contentEditableClassName: RealmNode<string>;
|
|
149
|
+
placeholder: RealmNode<ReactNode>;
|
|
147
150
|
autoFocus: RealmNode<boolean>;
|
|
148
151
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
149
152
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -194,6 +197,7 @@ quotePluginHooks: {
|
|
|
194
197
|
markdown: RealmNode<string>;
|
|
195
198
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
196
199
|
contentEditableClassName: RealmNode<string>;
|
|
200
|
+
placeholder: RealmNode<ReactNode>;
|
|
197
201
|
autoFocus: RealmNode<boolean>;
|
|
198
202
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
199
203
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -243,6 +247,7 @@ quotePluginHooks: {
|
|
|
243
247
|
markdown: RealmNode<string>;
|
|
244
248
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
245
249
|
contentEditableClassName: RealmNode<string>;
|
|
250
|
+
placeholder: RealmNode<ReactNode>;
|
|
246
251
|
autoFocus: RealmNode<boolean>;
|
|
247
252
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
248
253
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -293,6 +298,7 @@ quotePluginHooks: {
|
|
|
293
298
|
markdown: RealmNode<string>;
|
|
294
299
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
295
300
|
contentEditableClassName: RealmNode<string>;
|
|
301
|
+
placeholder: RealmNode<ReactNode>;
|
|
296
302
|
autoFocus: RealmNode<boolean>;
|
|
297
303
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
298
304
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
@@ -314,7 +320,7 @@ quotePluginHooks: {
|
|
|
314
320
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
315
321
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
316
322
|
}>) => void;
|
|
317
|
-
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" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode">(key: K_2) => (value: ValueForKey<{
|
|
323
|
+
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">(key: K_2) => (value: ValueForKey<{
|
|
318
324
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
319
325
|
inFocus: RealmNode<boolean>;
|
|
320
326
|
historyState: RealmNode<HistoryState>;
|
|
@@ -343,6 +349,7 @@ quotePluginHooks: {
|
|
|
343
349
|
markdown: RealmNode<string>;
|
|
344
350
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
345
351
|
contentEditableClassName: RealmNode<string>;
|
|
352
|
+
placeholder: RealmNode<ReactNode>;
|
|
346
353
|
autoFocus: RealmNode<boolean>;
|
|
347
354
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
348
355
|
addComposerChild: RealmNode<ComponentType<{}>>;
|