diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx index 04b2e984..6118d767 100644 --- a/src/components/Editor/Editor.tsx +++ b/src/components/Editor/Editor.tsx @@ -46,6 +46,8 @@ import { Figcaption } from './extensions/Figcaption' import { Figure } from './extensions/Figure' import { Footnote } from './extensions/Footnote' import { Iframe } from './extensions/Iframe' +import { Span } from './extensions/Span' +import { ToggleTextWrap } from './extensions/ToggleTextWrap' import { TrailingNode } from './extensions/TrailingNode' import { TextBubbleMenu } from './TextBubbleMenu' @@ -201,6 +203,8 @@ export const Editor = (props: Props) => { CustomBlockquote, Bold, Italic, + Span, + ToggleTextWrap, Strike, HorizontalRule.configure({ HTMLAttributes: { @@ -208,7 +212,10 @@ export const Editor = (props: Props) => { }, }), Underline, - Link.configure({ + Link.extend({ + inclusive: false, + }).configure({ + autolink: true, openOnClick: false, }), Heading.configure({ @@ -244,6 +251,7 @@ export const Editor = (props: Props) => { Figure, Figcaption, Footnote, + ToggleTextWrap, CharacterCount.configure(), // https://github.com/ueberdosis/tiptap/issues/2589#issuecomment-1093084689 BubbleMenu.configure({ pluginKey: 'textBubbleMenu', @@ -252,6 +260,9 @@ export const Editor = (props: Props) => { const { doc, selection } = state const { empty } = selection const isEmptyTextBlock = doc.textBetween(from, to).length === 0 && isTextSelection(selection) + if (isEmptyTextBlock) { + e.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run() + } setIsCommonMarkup(e.isActive('figcaption')) const result = (view.hasFocus() && diff --git a/src/components/Editor/Prosemirror.scss b/src/components/Editor/Prosemirror.scss index d84e01da..ca78c9f1 100644 --- a/src/components/Editor/Prosemirror.scss +++ b/src/components/Editor/Prosemirror.scss @@ -311,3 +311,10 @@ footnote { background-color: unset; } } + +.highlight-fake-selection { + background: var(--selection-background); + color: var(--selection-color); + border: solid var(--selection-background); + border-width: 5px 0; +} diff --git a/src/components/Editor/SimplifiedEditor.tsx b/src/components/Editor/SimplifiedEditor.tsx index a4aa4d7b..a549781e 100644 --- a/src/components/Editor/SimplifiedEditor.tsx +++ b/src/components/Editor/SimplifiedEditor.tsx @@ -117,7 +117,10 @@ const SimplifiedEditor = (props: Props) => { Paragraph, Bold, Italic, - Link.configure({ + Link.extend({ + inclusive: false, + }).configure({ + autolink: true, openOnClick: false, }), CharacterCount.configure({ diff --git a/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx b/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx index c7bb2d32..7457b009 100644 --- a/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx +++ b/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx @@ -129,11 +129,21 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => { }) }) + const handleOpenLinkForm = () => { + props.editor.chain().focus().addTextWrap({ class: 'highlight-fake-selection' }).run() + setLinkEditorOpen(true) + } + + const handleCloseLinkForm = () => { + setLinkEditorOpen(false) + props.editor.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run() + } + return (