1- import { Link } from '@tiptap/extension-link' ;
2- import { Placeholder } from '@tiptap/extension-placeholder' ;
1+ import { Placeholder } from '@tiptap/extensions' ;
32import { EditorContent , useEditor } from '@tiptap/react' ;
43import { StarterKit } from '@tiptap/starter-kit' ;
54import classNames from 'classnames' ;
@@ -69,13 +68,8 @@ export const TextAreaRichText: React.FC<ITextAreaRichTextProps> = (props) => {
6968 const randomId = useRandomId ( id ) ;
7069
7170 const extensions = [
72- StarterKit ,
73- Placeholder . configure ( {
74- placeholder,
75- emptyNodeClass : placeholderClasses ,
76- showOnlyWhenEditable : false ,
77- } ) ,
78- Link ,
71+ StarterKit . configure ( { trailingNode : false } ) ,
72+ Placeholder . configure ( { placeholder, emptyNodeClass : placeholderClasses , showOnlyWhenEditable : false } ) ,
7973 Markdown . configure ( { transformPastedText : true } ) ,
8074 ] ;
8175
@@ -86,7 +80,7 @@ export const TextAreaRichText: React.FC<ITextAreaRichTextProps> = (props) => {
8680 immediatelyRender,
8781 editorProps : {
8882 attributes : {
89- class : 'outline-hidden p-4 [overflow-wrap:anywhere]! prose prose-neutral min-h-40 h-full max-w-none leading-normal' ,
83+ class : 'relative outline-hidden p-4 [overflow-wrap:anywhere]! prose prose-neutral min-h-40 h-full max-w-none leading-normal' ,
9084 role : 'textbox' ,
9185 'aria-labelledby' : randomId ,
9286 } ,
@@ -101,13 +95,11 @@ export const TextAreaRichText: React.FC<ITextAreaRichTextProps> = (props) => {
10195 html : ( ) => editor . getHTML ( ) ,
10296 text : ( ) => editor . getText ( ) ,
10397 markdown : ( ) => {
104- const markdownStorage = editor . storage . markdown as MarkdownStorage | undefined ;
98+ const { storage } = editor ;
99+ const markdownStorage = 'markdown' in storage ? ( storage . markdown as MarkdownStorage ) : undefined ;
105100
106- if ( markdownStorage ) {
107- return markdownStorage . getMarkdown ( ) ;
108- }
109-
110- return editor . getHTML ( ) ;
101+ // Replace soft break syntax emitted by tiptap-markdown (backslash + newline) with standard two-space newline
102+ return markdownStorage ?. getMarkdown ( ) . replace ( / \\ \n / g, ' \n' ) ;
111103 } ,
112104 } ;
113105
@@ -131,7 +123,7 @@ export const TextAreaRichText: React.FC<ITextAreaRichTextProps> = (props) => {
131123
132124 // Update editable setting on Tiptap editor on disabled property change
133125 useEffect ( ( ) => {
134- editor ? .setEditable ( ! disabled ) ;
126+ editor . setEditable ( ! disabled ) ;
135127 } , [ editor , disabled ] ) ;
136128
137129 // Add keydown listener to reset expanded state on ESC key down
0 commit comments