@mdxeditor/editor 0.11.1 → 0.13.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 +8 -0
- package/dist/MDXEditor.js +13 -10
- package/dist/exportMarkdownFromLexical.d.ts +19 -0
- package/dist/gurx/react.d.ts +34 -6
- package/dist/gurx/realm.d.ts +18 -2
- package/dist/gurx/realmFactory.d.ts +23 -2
- package/dist/icons/rich_text.svg.js +2 -2
- package/dist/importMarkdownToLexical.d.ts +7 -0
- package/dist/plugins/codeblock/index.d.ts +23 -3
- package/dist/plugins/codemirror/index.d.ts +31 -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 +31 -3
- package/dist/plugins/core/index.js +11 -1
- package/dist/plugins/diff-source/index.d.ts +23 -3
- package/dist/plugins/directives/index.d.ts +23 -3
- package/dist/plugins/frontmatter/FrontmatterEditor.js +1 -2
- package/dist/plugins/frontmatter/index.d.ts +23 -3
- package/dist/plugins/headings/index.d.ts +5 -1
- package/dist/plugins/image/ImageEditor.js +2 -2
- package/dist/plugins/image/index.d.ts +23 -3
- package/dist/plugins/jsx/index.d.ts +22 -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 +22 -4
- package/dist/plugins/link/index.js +16 -5
- package/dist/plugins/link-dialog/index.d.ts +19 -3
- package/dist/plugins/link-dialog/index.js +1 -0
- package/dist/plugins/lists/index.d.ts +23 -3
- package/dist/plugins/lists/index.js +2 -2
- package/dist/plugins/markdown-shortcut/index.d.ts +2 -0
- package/dist/plugins/markdown-shortcut/index.js +1 -1
- package/dist/plugins/quote/index.d.ts +17 -3
- package/dist/plugins/sandpack/index.d.ts +30 -2
- package/dist/plugins/table/TableEditor.js +5 -5
- package/dist/plugins/table/index.d.ts +23 -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 +23 -3
- package/dist/plugins/thematic-break/index.js +2 -2
- package/dist/plugins/toolbar/index.d.ts +18 -2
- package/dist/plugins/toolbar/primitives/select.js +1 -1
- package/dist/style.css +186 -164
- package/dist/styles/ui.module.css.js +90 -84
- package/package.json +1 -1
|
@@ -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';
|
|
@@ -41,6 +41,8 @@ export declare const frontmatterSystem: SystemSpec<[SystemSpec<[], (r: Realm) =>
|
|
|
41
41
|
markdown: RealmNode<string>;
|
|
42
42
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
43
43
|
contentEditableClassName: RealmNode<string>;
|
|
44
|
+
placeholder: RealmNode<ReactNode>;
|
|
45
|
+
autoFocus: RealmNode<boolean>;
|
|
44
46
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
45
47
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
46
48
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -89,6 +91,8 @@ export declare const frontmatterSystem: SystemSpec<[SystemSpec<[], (r: Realm) =>
|
|
|
89
91
|
markdown: RealmNode<string>;
|
|
90
92
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
91
93
|
contentEditableClassName: RealmNode<string>;
|
|
94
|
+
placeholder: RealmNode<ReactNode>;
|
|
95
|
+
autoFocus: RealmNode<boolean>;
|
|
92
96
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
93
97
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
94
98
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -142,6 +146,8 @@ frontmatterPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
142
146
|
markdown: RealmNode<string>;
|
|
143
147
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
144
148
|
contentEditableClassName: RealmNode<string>;
|
|
149
|
+
placeholder: RealmNode<ReactNode>;
|
|
150
|
+
autoFocus: RealmNode<boolean>;
|
|
145
151
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
146
152
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
147
153
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -190,6 +196,8 @@ frontmatterPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
190
196
|
markdown: RealmNode<string>;
|
|
191
197
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
192
198
|
contentEditableClassName: RealmNode<string>;
|
|
199
|
+
placeholder: RealmNode<ReactNode>;
|
|
200
|
+
autoFocus: RealmNode<boolean>;
|
|
193
201
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
194
202
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
195
203
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -245,6 +253,8 @@ frontmatterPluginHooks: {
|
|
|
245
253
|
markdown: RealmNode<string>;
|
|
246
254
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
247
255
|
contentEditableClassName: RealmNode<string>;
|
|
256
|
+
placeholder: RealmNode<ReactNode>;
|
|
257
|
+
autoFocus: RealmNode<boolean>;
|
|
248
258
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
249
259
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
250
260
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -265,7 +275,7 @@ frontmatterPluginHooks: {
|
|
|
265
275
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
266
276
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
267
277
|
}>;
|
|
268
|
-
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" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "insertFrontmatter">(key: K, callback: (value: ValueForKey<{
|
|
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" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "insertFrontmatter">(key: K, callback: (value: ValueForKey<{
|
|
269
279
|
insertFrontmatter: RealmNode<true>;
|
|
270
280
|
} & {
|
|
271
281
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -296,6 +306,8 @@ frontmatterPluginHooks: {
|
|
|
296
306
|
markdown: RealmNode<string>;
|
|
297
307
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
298
308
|
contentEditableClassName: RealmNode<string>;
|
|
309
|
+
placeholder: RealmNode<ReactNode>;
|
|
310
|
+
autoFocus: RealmNode<boolean>;
|
|
299
311
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
300
312
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
301
313
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -347,6 +359,8 @@ frontmatterPluginHooks: {
|
|
|
347
359
|
markdown: RealmNode<string>;
|
|
348
360
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
349
361
|
contentEditableClassName: RealmNode<string>;
|
|
362
|
+
placeholder: RealmNode<ReactNode>;
|
|
363
|
+
autoFocus: RealmNode<boolean>;
|
|
350
364
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
351
365
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
352
366
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -397,6 +411,8 @@ frontmatterPluginHooks: {
|
|
|
397
411
|
markdown: RealmNode<string>;
|
|
398
412
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
399
413
|
contentEditableClassName: RealmNode<string>;
|
|
414
|
+
placeholder: RealmNode<ReactNode>;
|
|
415
|
+
autoFocus: RealmNode<boolean>;
|
|
400
416
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
401
417
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
402
418
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -448,6 +464,8 @@ frontmatterPluginHooks: {
|
|
|
448
464
|
markdown: RealmNode<string>;
|
|
449
465
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
450
466
|
contentEditableClassName: RealmNode<string>;
|
|
467
|
+
placeholder: RealmNode<ReactNode>;
|
|
468
|
+
autoFocus: RealmNode<boolean>;
|
|
451
469
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
452
470
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
453
471
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -468,7 +486,7 @@ frontmatterPluginHooks: {
|
|
|
468
486
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
469
487
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
470
488
|
}>) => void;
|
|
471
|
-
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" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "insertFrontmatter">(key: K_2) => (value: ValueForKey<{
|
|
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" | "placeholder" | "autoFocus" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "insertFrontmatter">(key: K_2) => (value: ValueForKey<{
|
|
472
490
|
insertFrontmatter: RealmNode<true>;
|
|
473
491
|
} & {
|
|
474
492
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -499,6 +517,8 @@ frontmatterPluginHooks: {
|
|
|
499
517
|
markdown: RealmNode<string>;
|
|
500
518
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
501
519
|
contentEditableClassName: RealmNode<string>;
|
|
520
|
+
placeholder: RealmNode<ReactNode>;
|
|
521
|
+
autoFocus: RealmNode<boolean>;
|
|
502
522
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
503
523
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
504
524
|
topAreaChildren: 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,8 @@ export declare const headingsSystem: 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>;
|
|
47
|
+
autoFocus: RealmNode<boolean>;
|
|
46
48
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
47
49
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
48
50
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -95,6 +97,8 @@ export declare const headingsPlugin: PluginConstructor<SystemSpec<[SystemSpec<[]
|
|
|
95
97
|
markdown: RealmNode<string>;
|
|
96
98
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
97
99
|
contentEditableClassName: RealmNode<string>;
|
|
100
|
+
placeholder: RealmNode<ReactNode>;
|
|
101
|
+
autoFocus: RealmNode<boolean>;
|
|
98
102
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
99
103
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
100
104
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
3
|
-
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
2
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext.js";
|
|
3
|
+
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection.js";
|
|
4
4
|
import { mergeRegister } from "@lexical/utils";
|
|
5
5
|
import { $isNodeSelection, $getSelection, $getNodeByKey, $setSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND } from "lexical";
|
|
6
6
|
import styles from "../../styles/ui.module.css.js";
|
|
@@ -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,8 @@ export declare const imageSystem: 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>;
|
|
47
|
+
autoFocus: RealmNode<boolean>;
|
|
46
48
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
47
49
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
48
50
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -91,6 +93,8 @@ export declare const imageSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
91
93
|
markdown: RealmNode<string>;
|
|
92
94
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
93
95
|
contentEditableClassName: RealmNode<string>;
|
|
96
|
+
placeholder: RealmNode<ReactNode>;
|
|
97
|
+
autoFocus: RealmNode<boolean>;
|
|
94
98
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
95
99
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
96
100
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -150,6 +154,8 @@ imagePlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
150
154
|
markdown: RealmNode<string>;
|
|
151
155
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
152
156
|
contentEditableClassName: RealmNode<string>;
|
|
157
|
+
placeholder: RealmNode<ReactNode>;
|
|
158
|
+
autoFocus: RealmNode<boolean>;
|
|
153
159
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
154
160
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
155
161
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -198,6 +204,8 @@ imagePlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
198
204
|
markdown: RealmNode<string>;
|
|
199
205
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
200
206
|
contentEditableClassName: RealmNode<string>;
|
|
207
|
+
placeholder: RealmNode<ReactNode>;
|
|
208
|
+
autoFocus: RealmNode<boolean>;
|
|
201
209
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
202
210
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
203
211
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -257,6 +265,8 @@ imagePluginHooks: {
|
|
|
257
265
|
markdown: RealmNode<string>;
|
|
258
266
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
259
267
|
contentEditableClassName: RealmNode<string>;
|
|
268
|
+
placeholder: RealmNode<ReactNode>;
|
|
269
|
+
autoFocus: RealmNode<boolean>;
|
|
260
270
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
261
271
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
262
272
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -277,7 +287,7 @@ imagePluginHooks: {
|
|
|
277
287
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
278
288
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
279
289
|
}>;
|
|
280
|
-
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" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "imageUploadHandler" | "imageAutocompleteSuggestions" | "insertImage">(key: K, callback: (value: ValueForKey<{
|
|
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<{
|
|
281
291
|
imageUploadHandler: RealmNode<(image: File) => Promise<string>>;
|
|
282
292
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
283
293
|
insertImage: RealmNode<string>;
|
|
@@ -310,6 +320,8 @@ imagePluginHooks: {
|
|
|
310
320
|
markdown: RealmNode<string>;
|
|
311
321
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
312
322
|
contentEditableClassName: RealmNode<string>;
|
|
323
|
+
placeholder: RealmNode<ReactNode>;
|
|
324
|
+
autoFocus: RealmNode<boolean>;
|
|
313
325
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
314
326
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
315
327
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -363,6 +375,8 @@ imagePluginHooks: {
|
|
|
363
375
|
markdown: RealmNode<string>;
|
|
364
376
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
365
377
|
contentEditableClassName: RealmNode<string>;
|
|
378
|
+
placeholder: RealmNode<ReactNode>;
|
|
379
|
+
autoFocus: RealmNode<boolean>;
|
|
366
380
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
367
381
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
368
382
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -415,6 +429,8 @@ imagePluginHooks: {
|
|
|
415
429
|
markdown: RealmNode<string>;
|
|
416
430
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
417
431
|
contentEditableClassName: RealmNode<string>;
|
|
432
|
+
placeholder: RealmNode<ReactNode>;
|
|
433
|
+
autoFocus: RealmNode<boolean>;
|
|
418
434
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
419
435
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
420
436
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -468,6 +484,8 @@ imagePluginHooks: {
|
|
|
468
484
|
markdown: RealmNode<string>;
|
|
469
485
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
470
486
|
contentEditableClassName: RealmNode<string>;
|
|
487
|
+
placeholder: RealmNode<ReactNode>;
|
|
488
|
+
autoFocus: RealmNode<boolean>;
|
|
471
489
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
472
490
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
473
491
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -488,7 +506,7 @@ imagePluginHooks: {
|
|
|
488
506
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
489
507
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
490
508
|
}>) => void;
|
|
491
|
-
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" | "composerChildren" | "addComposerChild" | "topAreaChildren" | "addTopAreaChild" | "nestedEditorChildren" | "addNestedEditorChild" | "editorWrappers" | "addEditorWrapper" | "currentFormat" | "editorInFocus" | "applyFormat" | "currentBlockType" | "applyBlockType" | "convertSelectionToNode" | "insertDecoratorNode" | "imageUploadHandler" | "imageAutocompleteSuggestions" | "insertImage">(key: K_2) => (value: ValueForKey<{
|
|
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<{
|
|
492
510
|
imageUploadHandler: RealmNode<(image: File) => Promise<string>>;
|
|
493
511
|
imageAutocompleteSuggestions: RealmNode<string[]>;
|
|
494
512
|
insertImage: RealmNode<string>;
|
|
@@ -521,6 +539,8 @@ imagePluginHooks: {
|
|
|
521
539
|
markdown: RealmNode<string>;
|
|
522
540
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
523
541
|
contentEditableClassName: RealmNode<string>;
|
|
542
|
+
placeholder: RealmNode<ReactNode>;
|
|
543
|
+
autoFocus: RealmNode<boolean>;
|
|
524
544
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
525
545
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
526
546
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -107,6 +107,8 @@ 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>;
|
|
111
|
+
autoFocus: RealmNode<boolean>;
|
|
110
112
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
111
113
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
112
114
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -155,6 +157,8 @@ export declare const jsxSystem: SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
155
157
|
markdown: RealmNode<string>;
|
|
156
158
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
157
159
|
contentEditableClassName: RealmNode<string>;
|
|
160
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
161
|
+
autoFocus: RealmNode<boolean>;
|
|
158
162
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
159
163
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
160
164
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -217,6 +221,8 @@ jsxPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
217
221
|
markdown: RealmNode<string>;
|
|
218
222
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
219
223
|
contentEditableClassName: RealmNode<string>;
|
|
224
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
225
|
+
autoFocus: RealmNode<boolean>;
|
|
220
226
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
221
227
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
222
228
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -265,6 +271,8 @@ jsxPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
265
271
|
markdown: RealmNode<string>;
|
|
266
272
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
267
273
|
contentEditableClassName: RealmNode<string>;
|
|
274
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
275
|
+
autoFocus: RealmNode<boolean>;
|
|
268
276
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
269
277
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
270
278
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -320,6 +328,8 @@ jsxPluginHooks: {
|
|
|
320
328
|
markdown: RealmNode<string>;
|
|
321
329
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
322
330
|
contentEditableClassName: RealmNode<string>;
|
|
331
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
332
|
+
autoFocus: RealmNode<boolean>;
|
|
323
333
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
324
334
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
325
335
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -340,7 +350,7 @@ jsxPluginHooks: {
|
|
|
340
350
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
341
351
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
342
352
|
}>;
|
|
343
|
-
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" | "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<{
|
|
344
354
|
insertJsx: RealmNode<InsertJsxPayload>;
|
|
345
355
|
} & {
|
|
346
356
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -371,6 +381,8 @@ jsxPluginHooks: {
|
|
|
371
381
|
markdown: RealmNode<string>;
|
|
372
382
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
373
383
|
contentEditableClassName: RealmNode<string>;
|
|
384
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
385
|
+
autoFocus: RealmNode<boolean>;
|
|
374
386
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
375
387
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
376
388
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -422,6 +434,8 @@ jsxPluginHooks: {
|
|
|
422
434
|
markdown: RealmNode<string>;
|
|
423
435
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
424
436
|
contentEditableClassName: RealmNode<string>;
|
|
437
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
438
|
+
autoFocus: RealmNode<boolean>;
|
|
425
439
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
426
440
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
427
441
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -472,6 +486,8 @@ jsxPluginHooks: {
|
|
|
472
486
|
markdown: RealmNode<string>;
|
|
473
487
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
474
488
|
contentEditableClassName: RealmNode<string>;
|
|
489
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
490
|
+
autoFocus: RealmNode<boolean>;
|
|
475
491
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
476
492
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
477
493
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -523,6 +539,8 @@ jsxPluginHooks: {
|
|
|
523
539
|
markdown: RealmNode<string>;
|
|
524
540
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
525
541
|
contentEditableClassName: RealmNode<string>;
|
|
542
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
543
|
+
autoFocus: RealmNode<boolean>;
|
|
526
544
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
527
545
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
528
546
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -543,7 +561,7 @@ jsxPluginHooks: {
|
|
|
543
561
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
544
562
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
545
563
|
}>) => void;
|
|
546
|
-
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" | "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<{
|
|
547
565
|
insertJsx: RealmNode<InsertJsxPayload>;
|
|
548
566
|
} & {
|
|
549
567
|
activeEditor: RealmNode<LexicalEditor | null>;
|
|
@@ -574,6 +592,8 @@ jsxPluginHooks: {
|
|
|
574
592
|
markdown: RealmNode<string>;
|
|
575
593
|
editorRootElementRef: RealmNode<React.RefObject<HTMLDivElement> | null>;
|
|
576
594
|
contentEditableClassName: RealmNode<string>;
|
|
595
|
+
placeholder: RealmNode<React.ReactNode>;
|
|
596
|
+
autoFocus: RealmNode<boolean>;
|
|
577
597
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
578
598
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
579
599
|
topAreaChildren: 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,8 @@ 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>;
|
|
62
|
+
autoFocus: RealmNode<boolean>;
|
|
46
63
|
composerChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
47
64
|
addComposerChild: RealmNode<React.ComponentType<{}>>;
|
|
48
65
|
topAreaChildren: RealmNode<React.ComponentType<{}>[]>;
|
|
@@ -62,6 +79,7 @@ export declare const linkPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r
|
|
|
62
79
|
applyBlockType: RealmNode<BlockType>;
|
|
63
80
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
64
81
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
65
|
-
}>], (
|
|
66
|
-
|
|
67
|
-
}>;
|
|
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,8 @@ 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>;
|
|
65
|
+
autoFocus: RealmNode<boolean>;
|
|
64
66
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
65
67
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
66
68
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -109,6 +111,8 @@ linkDialogPlugin: PluginConstructor<SystemSpec<[SystemSpec<[], (r: Realm) => {
|
|
|
109
111
|
markdown: RealmNode<string>;
|
|
110
112
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
111
113
|
contentEditableClassName: RealmNode<string>;
|
|
114
|
+
placeholder: RealmNode<ReactNode>;
|
|
115
|
+
autoFocus: RealmNode<boolean>;
|
|
112
116
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
113
117
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
114
118
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -184,6 +188,8 @@ linkDialogPluginHooks: {
|
|
|
184
188
|
markdown: RealmNode<string>;
|
|
185
189
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
186
190
|
contentEditableClassName: RealmNode<string>;
|
|
191
|
+
placeholder: RealmNode<ReactNode>;
|
|
192
|
+
autoFocus: RealmNode<boolean>;
|
|
187
193
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
188
194
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
189
195
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -204,7 +210,7 @@ linkDialogPluginHooks: {
|
|
|
204
210
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
205
211
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
206
212
|
}>;
|
|
207
|
-
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" | "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<{
|
|
208
214
|
dialogState: RealmNode<boolean>;
|
|
209
215
|
onWindowChange: RealmNode<true>;
|
|
210
216
|
linkDialogState: RealmNode<InactiveLinkDialog | PreviewLinkDialog | EditLinkDialog>;
|
|
@@ -244,6 +250,8 @@ linkDialogPluginHooks: {
|
|
|
244
250
|
markdown: RealmNode<string>;
|
|
245
251
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
246
252
|
contentEditableClassName: RealmNode<string>;
|
|
253
|
+
placeholder: RealmNode<ReactNode>;
|
|
254
|
+
autoFocus: RealmNode<boolean>;
|
|
247
255
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
248
256
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
249
257
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -304,6 +312,8 @@ linkDialogPluginHooks: {
|
|
|
304
312
|
markdown: RealmNode<string>;
|
|
305
313
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
306
314
|
contentEditableClassName: RealmNode<string>;
|
|
315
|
+
placeholder: RealmNode<ReactNode>;
|
|
316
|
+
autoFocus: RealmNode<boolean>;
|
|
307
317
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
308
318
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
309
319
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -363,6 +373,8 @@ linkDialogPluginHooks: {
|
|
|
363
373
|
markdown: RealmNode<string>;
|
|
364
374
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
365
375
|
contentEditableClassName: RealmNode<string>;
|
|
376
|
+
placeholder: RealmNode<ReactNode>;
|
|
377
|
+
autoFocus: RealmNode<boolean>;
|
|
366
378
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
367
379
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
368
380
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -423,6 +435,8 @@ linkDialogPluginHooks: {
|
|
|
423
435
|
markdown: RealmNode<string>;
|
|
424
436
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
425
437
|
contentEditableClassName: RealmNode<string>;
|
|
438
|
+
placeholder: RealmNode<ReactNode>;
|
|
439
|
+
autoFocus: RealmNode<boolean>;
|
|
426
440
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
427
441
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
428
442
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|
|
@@ -443,7 +457,7 @@ linkDialogPluginHooks: {
|
|
|
443
457
|
convertSelectionToNode: RealmNode<() => ElementNode>;
|
|
444
458
|
insertDecoratorNode: RealmNode<() => DecoratorNode<unknown>>;
|
|
445
459
|
}>) => void;
|
|
446
|
-
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" | "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<{
|
|
447
461
|
dialogState: RealmNode<boolean>;
|
|
448
462
|
onWindowChange: RealmNode<true>;
|
|
449
463
|
linkDialogState: RealmNode<InactiveLinkDialog | PreviewLinkDialog | EditLinkDialog>;
|
|
@@ -483,6 +497,8 @@ linkDialogPluginHooks: {
|
|
|
483
497
|
markdown: RealmNode<string>;
|
|
484
498
|
editorRootElementRef: RealmNode<RefObject<HTMLDivElement> | null>;
|
|
485
499
|
contentEditableClassName: RealmNode<string>;
|
|
500
|
+
placeholder: RealmNode<ReactNode>;
|
|
501
|
+
autoFocus: RealmNode<boolean>;
|
|
486
502
|
composerChildren: RealmNode<ComponentType<{}>[]>;
|
|
487
503
|
addComposerChild: RealmNode<ComponentType<{}>>;
|
|
488
504
|
topAreaChildren: RealmNode<ComponentType<{}>[]>;
|