@mdxeditor/editor 3.50.0 → 3.52.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.js +3 -3
- package/dist/index.d.ts +66 -65
- package/dist/plugins/link-dialog/LinkDialog.js +10 -3
- package/dist/plugins/link-dialog/index.js +46 -40
- package/package.json +8 -7
package/dist/MDXEditor.js
CHANGED
|
@@ -25,7 +25,7 @@ const RichTextEditor = () => {
|
|
|
25
25
|
const setEditorRootWrapperElement = usePublisher(contentEditableWrapperElement$);
|
|
26
26
|
const onRef = (el) => {
|
|
27
27
|
setEditorRootWrapperElement(el);
|
|
28
|
-
setContentEditableRef({ current: el });
|
|
28
|
+
setContentEditableRef(el ? { current: el } : null);
|
|
29
29
|
};
|
|
30
30
|
const [contentEditableClassName, spellCheck, composerChildren, topAreaChildren, editorWrappers, placeholder, bottomAreaChildren] = useCellValues(
|
|
31
31
|
contentEditableClassName$,
|
|
@@ -120,8 +120,8 @@ const Methods = ({ mdxRef }) => {
|
|
|
120
120
|
(_a = realm.getValue(rootEditor$)) == null ? void 0 : _a.focus(callbackFn, opts);
|
|
121
121
|
},
|
|
122
122
|
getContentEditableHTML: () => {
|
|
123
|
-
var _a
|
|
124
|
-
return ((
|
|
123
|
+
var _a;
|
|
124
|
+
return ((_a = realm.getValue(contentEditableRef$)) == null ? void 0 : _a.current.innerHTML) ?? "";
|
|
125
125
|
},
|
|
126
126
|
getSelectionMarkdown: () => {
|
|
127
127
|
const viewMode = realm.getValue(viewMode$);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
1
|
import { Config } from 'mdast-util-from-markdown/lib';
|
|
4
2
|
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
5
3
|
import { DecoratorNode } from 'lexical';
|
|
@@ -17,6 +15,8 @@ import { Extension as Extension_2 } from '@codemirror/state';
|
|
|
17
15
|
import { FC } from 'react';
|
|
18
16
|
import { HeadingTagType } from '@lexical/rich-text';
|
|
19
17
|
import { HistoryState } from '@lexical/history';
|
|
18
|
+
import { JSX } from 'react';
|
|
19
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
20
20
|
import { KlassConstructor } from 'lexical';
|
|
21
21
|
import * as lexical from 'lexical';
|
|
22
22
|
import { LexicalCommand } from 'lexical';
|
|
@@ -336,7 +336,7 @@ export declare type BlockType = 'paragraph' | 'quote' | HeadingTagType | '';
|
|
|
336
336
|
* Supports paragraphs, headings and block quotes.
|
|
337
337
|
* @group Toolbar Components
|
|
338
338
|
*/
|
|
339
|
-
export declare const BlockTypeSelect: () =>
|
|
339
|
+
export declare const BlockTypeSelect: () => JSX_2.Element | null;
|
|
340
340
|
|
|
341
341
|
/**
|
|
342
342
|
* A toolbar component that lets the user toggle bold, italic and underline formatting.
|
|
@@ -354,7 +354,7 @@ export declare interface BoldItalicUnderlineTogglesProps {
|
|
|
354
354
|
* A toolbar button primitive.
|
|
355
355
|
* @group Toolbar Primitives
|
|
356
356
|
*/
|
|
357
|
-
export declare const Button: default_2.ForwardRefExoticComponent<
|
|
357
|
+
export declare const Button: default_2.ForwardRefExoticComponent<RadixToolbar.ToolbarButtonProps & default_2.RefAttributes<HTMLButtonElement>>;
|
|
358
358
|
|
|
359
359
|
/**
|
|
360
360
|
* Use this primitive to create a toolbar button that can be either a button or a dropdown, depending on the number of items passed.
|
|
@@ -387,15 +387,15 @@ export declare const ButtonOrDropdownButton: <T extends string>(props: {
|
|
|
387
387
|
*/
|
|
388
388
|
label: string | JSX.Element;
|
|
389
389
|
}[];
|
|
390
|
-
}) =>
|
|
390
|
+
}) => JSX_2.Element;
|
|
391
391
|
|
|
392
392
|
/**
|
|
393
393
|
* A toolbar button with tooltip primitive.
|
|
394
394
|
* @group Toolbar Primitives
|
|
395
395
|
*/
|
|
396
|
-
export declare const ButtonWithTooltip: ({ title, children, ...props }:
|
|
396
|
+
export declare const ButtonWithTooltip: ({ title, children, ...props }: RadixToolbar.ToolbarButtonProps & default_2.RefAttributes<HTMLButtonElement> & {
|
|
397
397
|
title: string;
|
|
398
|
-
}) =>
|
|
398
|
+
}) => JSX_2.Element;
|
|
399
399
|
|
|
400
400
|
/**
|
|
401
401
|
* Calls the passed function.
|
|
@@ -416,7 +416,7 @@ export declare const cancelLinkEdit$: NodeRef<void>;
|
|
|
416
416
|
* For this component to work, you must pass the {@link AdmonitionDirectiveDescriptor} to the `directivesPlugin` `directiveDescriptors` parameter.
|
|
417
417
|
* @group Toolbar Components
|
|
418
418
|
*/
|
|
419
|
-
export declare const ChangeAdmonitionType: () =>
|
|
419
|
+
export declare const ChangeAdmonitionType: () => JSX_2.Element;
|
|
420
420
|
|
|
421
421
|
/**
|
|
422
422
|
* A component that allows the user to change the code block language of the current selection.
|
|
@@ -424,7 +424,7 @@ export declare const ChangeAdmonitionType: () => default_2.JSX.Element;
|
|
|
424
424
|
* See {@link ConditionalContents} for an example on how to display the dropdown only when a code block is in focus.
|
|
425
425
|
* @group Toolbar Components
|
|
426
426
|
*/
|
|
427
|
-
export declare const ChangeCodeMirrorLanguage: () =>
|
|
427
|
+
export declare const ChangeCodeMirrorLanguage: () => JSX_2.Element;
|
|
428
428
|
|
|
429
429
|
export declare type ClickLinkCallback = (url: string) => void;
|
|
430
430
|
|
|
@@ -587,7 +587,7 @@ export declare const codeBlockPlugin: (params?: {
|
|
|
587
587
|
*/
|
|
588
588
|
export declare const codeMirrorAutoLoadLanguageSupport$: NodeRef<boolean>;
|
|
589
589
|
|
|
590
|
-
export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter }: CodeBlockEditorProps) =>
|
|
590
|
+
export declare const CodeMirrorEditor: ({ language, nodeKey, code, focusEmitter }: CodeBlockEditorProps) => JSX_2.Element;
|
|
591
591
|
|
|
592
592
|
/**
|
|
593
593
|
* The code mirror extensions for the coemirror code block editor.
|
|
@@ -760,7 +760,7 @@ export declare interface CreateImageNodeParameters {
|
|
|
760
760
|
* For this component to work, you must include the `linkDialogPlugin`.
|
|
761
761
|
* @group Toolbar Components
|
|
762
762
|
*/
|
|
763
|
-
export declare const CreateLink: () =>
|
|
763
|
+
export declare const CreateLink: () => JSX_2.Element;
|
|
764
764
|
|
|
765
765
|
/**
|
|
766
766
|
* An input signal that lets you register a new {@link EditorSubscription} for the root editor.
|
|
@@ -823,51 +823,51 @@ export declare const DEFAULT_FORMAT: 0;
|
|
|
823
823
|
export declare const defaultCodeBlockLanguage$: NodeRef<string>;
|
|
824
824
|
|
|
825
825
|
export declare const defaultSvgIcons: {
|
|
826
|
-
undo:
|
|
827
|
-
redo:
|
|
828
|
-
format_bold:
|
|
829
|
-
format_italic:
|
|
830
|
-
format_underlined:
|
|
831
|
-
format_highlight:
|
|
832
|
-
code:
|
|
833
|
-
strikeThrough:
|
|
834
|
-
superscript:
|
|
835
|
-
subscript:
|
|
836
|
-
format_list_bulleted:
|
|
837
|
-
format_list_numbered:
|
|
838
|
-
format_list_checked:
|
|
839
|
-
link:
|
|
840
|
-
add_photo:
|
|
841
|
-
table:
|
|
842
|
-
horizontal_rule:
|
|
843
|
-
frontmatter:
|
|
844
|
-
frame_source:
|
|
845
|
-
arrow_drop_down:
|
|
846
|
-
admonition:
|
|
847
|
-
sandpack:
|
|
848
|
-
rich_text:
|
|
849
|
-
difference:
|
|
850
|
-
markdown:
|
|
851
|
-
open_in_new:
|
|
852
|
-
link_off:
|
|
853
|
-
edit:
|
|
854
|
-
content_copy:
|
|
855
|
-
more_horiz:
|
|
856
|
-
more_vert:
|
|
857
|
-
close:
|
|
858
|
-
settings:
|
|
859
|
-
delete_big:
|
|
860
|
-
delete_small:
|
|
861
|
-
format_align_center:
|
|
862
|
-
format_align_left:
|
|
863
|
-
format_align_right:
|
|
864
|
-
add_row:
|
|
865
|
-
add_column:
|
|
866
|
-
insert_col_left:
|
|
867
|
-
insert_row_above:
|
|
868
|
-
insert_row_below:
|
|
869
|
-
insert_col_right:
|
|
870
|
-
check:
|
|
826
|
+
undo: JSX_2.Element;
|
|
827
|
+
redo: JSX_2.Element;
|
|
828
|
+
format_bold: JSX_2.Element;
|
|
829
|
+
format_italic: JSX_2.Element;
|
|
830
|
+
format_underlined: JSX_2.Element;
|
|
831
|
+
format_highlight: JSX_2.Element;
|
|
832
|
+
code: JSX_2.Element;
|
|
833
|
+
strikeThrough: JSX_2.Element;
|
|
834
|
+
superscript: JSX_2.Element;
|
|
835
|
+
subscript: JSX_2.Element;
|
|
836
|
+
format_list_bulleted: JSX_2.Element;
|
|
837
|
+
format_list_numbered: JSX_2.Element;
|
|
838
|
+
format_list_checked: JSX_2.Element;
|
|
839
|
+
link: JSX_2.Element;
|
|
840
|
+
add_photo: JSX_2.Element;
|
|
841
|
+
table: JSX_2.Element;
|
|
842
|
+
horizontal_rule: JSX_2.Element;
|
|
843
|
+
frontmatter: JSX_2.Element;
|
|
844
|
+
frame_source: JSX_2.Element;
|
|
845
|
+
arrow_drop_down: JSX_2.Element;
|
|
846
|
+
admonition: JSX_2.Element;
|
|
847
|
+
sandpack: JSX_2.Element;
|
|
848
|
+
rich_text: JSX_2.Element;
|
|
849
|
+
difference: JSX_2.Element;
|
|
850
|
+
markdown: JSX_2.Element;
|
|
851
|
+
open_in_new: JSX_2.Element;
|
|
852
|
+
link_off: JSX_2.Element;
|
|
853
|
+
edit: JSX_2.Element;
|
|
854
|
+
content_copy: JSX_2.Element;
|
|
855
|
+
more_horiz: JSX_2.Element;
|
|
856
|
+
more_vert: JSX_2.Element;
|
|
857
|
+
close: JSX_2.Element;
|
|
858
|
+
settings: JSX_2.Element;
|
|
859
|
+
delete_big: JSX_2.Element;
|
|
860
|
+
delete_small: JSX_2.Element;
|
|
861
|
+
format_align_center: JSX_2.Element;
|
|
862
|
+
format_align_left: JSX_2.Element;
|
|
863
|
+
format_align_right: JSX_2.Element;
|
|
864
|
+
add_row: JSX_2.Element;
|
|
865
|
+
add_column: JSX_2.Element;
|
|
866
|
+
insert_col_left: JSX_2.Element;
|
|
867
|
+
insert_row_above: JSX_2.Element;
|
|
868
|
+
insert_row_below: JSX_2.Element;
|
|
869
|
+
insert_col_right: JSX_2.Element;
|
|
870
|
+
check: JSX_2.Element;
|
|
871
871
|
};
|
|
872
872
|
|
|
873
873
|
/**
|
|
@@ -1122,9 +1122,10 @@ export declare interface EditingImageDialogState {
|
|
|
1122
1122
|
export declare interface EditLinkDialog {
|
|
1123
1123
|
type: 'edit';
|
|
1124
1124
|
initialUrl: string;
|
|
1125
|
-
hasInitialText: boolean;
|
|
1126
1125
|
url: string;
|
|
1127
1126
|
title: string;
|
|
1127
|
+
text: string;
|
|
1128
|
+
withAnchorText: boolean;
|
|
1128
1129
|
linkNodeKey: string;
|
|
1129
1130
|
rectangle: RectData;
|
|
1130
1131
|
}
|
|
@@ -1539,7 +1540,7 @@ export declare const initialMarkdownNormalize$: NodeRef<boolean>;
|
|
|
1539
1540
|
*
|
|
1540
1541
|
* @group Toolbar Components
|
|
1541
1542
|
*/
|
|
1542
|
-
export declare const InsertAdmonition: () =>
|
|
1543
|
+
export declare const InsertAdmonition: () => JSX_2.Element;
|
|
1543
1544
|
|
|
1544
1545
|
/**
|
|
1545
1546
|
* A signal that inserts a new code block into the editor with the published options.
|
|
@@ -1648,7 +1649,7 @@ export declare const insertSandpack$: NodeRef<string>;
|
|
|
1648
1649
|
* For this to work, you need to have the `sandpackPlugin` installed.
|
|
1649
1650
|
* @group Toolbar Components
|
|
1650
1651
|
*/
|
|
1651
|
-
export declare const InsertSandpack: () =>
|
|
1652
|
+
export declare const InsertSandpack: () => JSX_2.Element;
|
|
1652
1653
|
|
|
1653
1654
|
/**
|
|
1654
1655
|
* A signal that will insert a table with the published amount of rows and columns into the active editor.
|
|
@@ -2470,7 +2471,7 @@ export declare const NestedLexicalEditor: <T extends Mdast.RootContent>(props: {
|
|
|
2470
2471
|
* Whether or not the editor edits blocks (multiple paragraphs)
|
|
2471
2472
|
*/
|
|
2472
2473
|
block?: boolean;
|
|
2473
|
-
}) =>
|
|
2474
|
+
}) => JSX_2.Element;
|
|
2474
2475
|
|
|
2475
2476
|
/**
|
|
2476
2477
|
* The state of the image dialog when it is in new mode.
|
|
@@ -2685,7 +2686,7 @@ export declare interface SandpackConfig {
|
|
|
2685
2686
|
presets: SandpackPreset[];
|
|
2686
2687
|
}
|
|
2687
2688
|
|
|
2688
|
-
export declare const SandpackEditor: ({ nodeKey, code, focusEmitter, preset }: SandpackEditorProps) =>
|
|
2689
|
+
export declare const SandpackEditor: ({ nodeKey, code, focusEmitter, preset }: SandpackEditorProps) => JSX_2.Element;
|
|
2689
2690
|
|
|
2690
2691
|
export declare interface SandpackEditorProps extends CodeBlockEditorProps {
|
|
2691
2692
|
preset: SandpackPreset;
|
|
@@ -2781,7 +2782,7 @@ export declare const Select: <T extends string>(props: {
|
|
|
2781
2782
|
label: string | JSX.Element;
|
|
2782
2783
|
value: T;
|
|
2783
2784
|
} | 'separator')[];
|
|
2784
|
-
}) =>
|
|
2785
|
+
}) => JSX_2.Element;
|
|
2785
2786
|
|
|
2786
2787
|
/* Excluded from this release type: SelectButtonTrigger */
|
|
2787
2788
|
|
|
@@ -2866,7 +2867,7 @@ export declare type SerializedTableNode = Spread<{
|
|
|
2866
2867
|
*/
|
|
2867
2868
|
export declare const setMarkdown$: NodeRef<string>;
|
|
2868
2869
|
|
|
2869
|
-
|
|
2870
|
+
export declare const showLinkTitleField$: NodeRef<boolean>;
|
|
2870
2871
|
|
|
2871
2872
|
/**
|
|
2872
2873
|
* A component that displays the focused live code block's name.
|
|
@@ -2874,7 +2875,7 @@ export declare const setMarkdown$: NodeRef<string>;
|
|
|
2874
2875
|
* See {@link ConditionalContents} for an example on how to display the dropdown only when a sandpack editor is in focus.
|
|
2875
2876
|
* @group Toolbar Components
|
|
2876
2877
|
*/
|
|
2877
|
-
export declare const ShowSandpackInfo: () =>
|
|
2878
|
+
export declare const ShowSandpackInfo: () => JSX_2.Element;
|
|
2878
2879
|
|
|
2879
2880
|
/**
|
|
2880
2881
|
* A toolbar primitive that allows you to build an UI with multiple exclusive toggle groups, like the list type toggle.
|
|
@@ -2890,7 +2891,7 @@ export declare const SingleChoiceToggleGroup: <T extends string>({ value, onChan
|
|
|
2890
2891
|
value: T | '';
|
|
2891
2892
|
ggClassName?: string;
|
|
2892
2893
|
className?: string;
|
|
2893
|
-
}) =>
|
|
2894
|
+
}) => JSX_2.Element;
|
|
2894
2895
|
|
|
2895
2896
|
/* Excluded from this release type: SingleToggleGroup */
|
|
2896
2897
|
|
|
@@ -13,6 +13,7 @@ createCommand();
|
|
|
13
13
|
function LinkEditForm({
|
|
14
14
|
url,
|
|
15
15
|
title,
|
|
16
|
+
text,
|
|
16
17
|
onSubmit,
|
|
17
18
|
onCancel,
|
|
18
19
|
linkAutocompleteSuggestions,
|
|
@@ -29,8 +30,7 @@ function LinkEditForm({
|
|
|
29
30
|
values: {
|
|
30
31
|
url,
|
|
31
32
|
title,
|
|
32
|
-
text
|
|
33
|
-
// text is only for freshly created links with no content, it always starts empty
|
|
33
|
+
text
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
const t = useTranslation();
|
|
@@ -46,6 +46,12 @@ function LinkEditForm({
|
|
|
46
46
|
e.stopPropagation();
|
|
47
47
|
onCancel();
|
|
48
48
|
},
|
|
49
|
+
onKeyDown: (e) => {
|
|
50
|
+
if (e.key === "Escape") {
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
onCancel();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
49
55
|
className: classNames(styles.multiFieldForm, styles.linkDialogEditForm)
|
|
50
56
|
},
|
|
51
57
|
/* @__PURE__ */ React__default.createElement("div", { className: styles.formField }, /* @__PURE__ */ React__default.createElement("label", { htmlFor: "link-url" }, t("createLink.url", "URL")), /* @__PURE__ */ React__default.createElement(
|
|
@@ -153,11 +159,12 @@ const LinkDialog = () => {
|
|
|
153
159
|
{
|
|
154
160
|
url: linkDialogState.url,
|
|
155
161
|
title: linkDialogState.title,
|
|
162
|
+
text: linkDialogState.text,
|
|
156
163
|
onSubmit: updateLink,
|
|
157
164
|
onCancel: cancelLinkEdit.bind(null),
|
|
158
165
|
linkAutocompleteSuggestions,
|
|
159
166
|
showLinkTitleField,
|
|
160
|
-
showAnchorTextField:
|
|
167
|
+
showAnchorTextField: linkDialogState.withAnchorText
|
|
161
168
|
}
|
|
162
169
|
),
|
|
163
170
|
linkDialogState.type === "preview" && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $createLinkNode, TOGGLE_LINK_COMMAND,
|
|
1
|
+
import { $isLinkNode, $createLinkNode, TOGGLE_LINK_COMMAND, LinkNode } from "@lexical/link";
|
|
2
2
|
import { Signal, Cell, Action, withLatestFrom, map, filter } from "@mdxeditor/gurx";
|
|
3
|
-
import { KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_LOW, KEY_MODIFIER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, $createTextNode, $insertNodes, $getNearestNodeFromDOMNode } from "lexical";
|
|
3
|
+
import { KEY_ESCAPE_COMMAND, COMMAND_PRIORITY_LOW, KEY_MODIFIER_COMMAND, $getSelection, $isRangeSelection, COMMAND_PRIORITY_HIGH, $getNodeByKey, $createTextNode, $insertNodes, $isTextNode, $getNearestNodeFromDOMNode } from "lexical";
|
|
4
4
|
import { realmPlugin } from "../../RealmWithPlugins.js";
|
|
5
5
|
import { IS_APPLE } from "../../utils/detectMac.js";
|
|
6
6
|
import { getSelectionRectangle, getSelectedNode } from "../../utils/lexicalHelpers.js";
|
|
@@ -64,28 +64,29 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
|
|
|
64
64
|
COMMAND_PRIORITY_HIGH
|
|
65
65
|
);
|
|
66
66
|
});
|
|
67
|
-
r.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
r.sub(r.pipe(switchFromPreviewToLinkEdit$, withLatestFrom(linkDialogState$, activeEditor$)), ([, state, editor]) => {
|
|
68
|
+
if (state.type === "preview") {
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
editor == null ? void 0 : editor.getEditorState().read(() => {
|
|
71
|
+
const node = $getNodeByKey(state.linkNodeKey);
|
|
72
|
+
const withAnchorText = $isLinkNode(node) ? node.getTextContent().length > 0 && node.getChildrenSize() <= 1 : false;
|
|
73
|
+
const text = withAnchorText && node ? node.getTextContent() : "";
|
|
74
|
+
r.pub(linkDialogState$, {
|
|
74
75
|
type: "edit",
|
|
75
76
|
initialUrl: state.url,
|
|
76
|
-
hasInitialText: true,
|
|
77
77
|
url: state.url,
|
|
78
78
|
title: state.title,
|
|
79
|
+
text,
|
|
80
|
+
withAnchorText,
|
|
79
81
|
linkNodeKey: state.linkNodeKey,
|
|
80
82
|
rectangle: state.rectangle
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
} else {
|
|
87
|
+
throw new Error("Cannot switch to edit mode when not in preview mode");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
89
90
|
r.sub(r.pipe(updateLink$, withLatestFrom(activeEditor$, linkDialogState$, currentSelection$)), ([payload, editor, state, selection]) => {
|
|
90
91
|
var _a, _b, _c;
|
|
91
92
|
const text = ((_a = payload.text) == null ? void 0 : _a.trim()) ?? "";
|
|
@@ -105,11 +106,15 @@ const linkDialogState$ = Cell({ type: "inactive" }, (r) => {
|
|
|
105
106
|
} else {
|
|
106
107
|
linkNode.setURL(url);
|
|
107
108
|
linkNode.setTitle(title);
|
|
109
|
+
updateLinkText(linkNode.getFirstChild(), text);
|
|
108
110
|
}
|
|
109
111
|
},
|
|
110
112
|
{ discrete: true }
|
|
111
113
|
);
|
|
112
114
|
} else {
|
|
115
|
+
editor == null ? void 0 : editor.update(() => {
|
|
116
|
+
updateLinkText(selection == null ? void 0 : selection.anchor.getNode(), text);
|
|
117
|
+
});
|
|
113
118
|
editor == null ? void 0 : editor.dispatchCommand(TOGGLE_LINK_COMMAND, { url, title });
|
|
114
119
|
}
|
|
115
120
|
r.pub(linkDialogState$, {
|
|
@@ -204,29 +209,24 @@ const openLinkEditDialog$ = Action((r) => {
|
|
|
204
209
|
editor == null ? void 0 : editor.focus(() => {
|
|
205
210
|
setTimeout(() => {
|
|
206
211
|
editor.getEditorState().read(() => {
|
|
207
|
-
const
|
|
212
|
+
const linkNode = getLinkNodeInSelection(selection);
|
|
208
213
|
const rectangle = getSelectionRectangle(editor);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
url: "",
|
|
226
|
-
linkNodeKey: "",
|
|
227
|
-
rectangle
|
|
228
|
-
});
|
|
229
|
-
}
|
|
214
|
+
const initialUrl = (linkNode == null ? void 0 : linkNode.getURL()) ?? "";
|
|
215
|
+
const url = (linkNode == null ? void 0 : linkNode.getURL()) ?? "";
|
|
216
|
+
const title = (linkNode == null ? void 0 : linkNode.getTitle()) ?? "";
|
|
217
|
+
const linkNodeKey = (linkNode == null ? void 0 : linkNode.getKey()) ?? "";
|
|
218
|
+
const withAnchorText = linkNode ? linkNode.getTextContent().length > 0 && linkNode.getChildrenSize() <= 1 : Boolean(selection == null ? void 0 : selection.isCollapsed());
|
|
219
|
+
const text = withAnchorText && linkNode ? linkNode.getTextContent() : "";
|
|
220
|
+
r.pub(linkDialogState$, {
|
|
221
|
+
type: "edit",
|
|
222
|
+
initialUrl,
|
|
223
|
+
url,
|
|
224
|
+
title,
|
|
225
|
+
text,
|
|
226
|
+
withAnchorText,
|
|
227
|
+
linkNodeKey,
|
|
228
|
+
rectangle
|
|
229
|
+
});
|
|
230
230
|
});
|
|
231
231
|
});
|
|
232
232
|
});
|
|
@@ -262,6 +262,12 @@ const onReadOnlyClickLinkCallback$ = Cell(null, (r) => {
|
|
|
262
262
|
});
|
|
263
263
|
});
|
|
264
264
|
});
|
|
265
|
+
function updateLinkText(node, text) {
|
|
266
|
+
if ($isTextNode(node) && text) {
|
|
267
|
+
node.setTextContent(text);
|
|
268
|
+
node.selectStart();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
265
271
|
const showLinkTitleField$ = Cell(true);
|
|
266
272
|
const linkDialogPlugin = realmPlugin({
|
|
267
273
|
init(r, params) {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"*.css"
|
|
12
12
|
],
|
|
13
13
|
"type": "module",
|
|
14
|
-
"version": "3.
|
|
14
|
+
"version": "3.52.0",
|
|
15
15
|
"description": "React component for rich text markdown editing",
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "vite build",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"@types/mdast": "^4.0.3",
|
|
115
115
|
"@types/multer": "^1.4.7",
|
|
116
116
|
"@types/node": "^20.2.5",
|
|
117
|
-
"@types/react": "^
|
|
118
|
-
"@types/react-dom": "^
|
|
117
|
+
"@types/react": "^19.2.7",
|
|
118
|
+
"@types/react-dom": "^19.2.3",
|
|
119
119
|
"@types/unist": "^3.0.2",
|
|
120
120
|
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
121
121
|
"@typescript-eslint/parser": "^7.9.0",
|
|
@@ -144,9 +144,9 @@
|
|
|
144
144
|
"postcss-mixins": "^9.0.4",
|
|
145
145
|
"postcss-nesting": "^11.2.2",
|
|
146
146
|
"prettier": "^3.1.1",
|
|
147
|
-
"react": "^19.1
|
|
148
|
-
"react-dom": "^19.1
|
|
149
|
-
"semantic-release": "^
|
|
147
|
+
"react": "^19.2.1",
|
|
148
|
+
"react-dom": "^19.2.1",
|
|
149
|
+
"semantic-release": "^25.0.2",
|
|
150
150
|
"svgo": "^3.3.2",
|
|
151
151
|
"terser": "^5.26.0",
|
|
152
152
|
"typedoc": "^0.25.13",
|
|
@@ -162,7 +162,8 @@
|
|
|
162
162
|
"vitest": "^1.1.1"
|
|
163
163
|
},
|
|
164
164
|
"publishConfig": {
|
|
165
|
-
"access": "public"
|
|
165
|
+
"access": "public",
|
|
166
|
+
"provenance": true
|
|
166
167
|
},
|
|
167
168
|
"engines": {
|
|
168
169
|
"node": ">=16"
|