@@ -6,7 +6,7 @@ import Image from './../../nodes/Image.js'
66import ImageInline from './../../nodes/ImageInline.js'
77import TaskList from './../../nodes/TaskList.js'
88import TaskItem from './../../nodes/TaskItem.js'
9- import Underline from './../../marks/Underline .js'
9+ import { Italic , Strong , Underline , Link } from './../../marks/index .js'
1010import TiptapImage from '@tiptap/extension-image'
1111import { getExtensionField } from '@tiptap/core'
1212import { __serializeForClipboard as serializeForClipboard } from '@tiptap/pm/view'
@@ -85,9 +85,7 @@ describe('Markdown extension integrated in the editor', () => {
8585 content : '<p><ul class="contains-task-list"><li><input type="checkbox">Hello</li></ul></p>' ,
8686 extensions : [ Markdown , TaskList , TaskItem ] ,
8787 } )
88- editor . commands . selectAll ( )
89- const slice = editor . state . selection . content ( )
90- const { text } = serializeForClipboard ( editor . view , slice )
88+ const text = copyEditorContent ( editor )
9189 expect ( text ) . toBe ( '\n- [ ] Hello' )
9290 } )
9391
@@ -96,9 +94,7 @@ describe('Markdown extension integrated in the editor', () => {
9694 content : '<pre><code>Hello</code></pre>' ,
9795 extensions : [ Markdown , CodeBlock ] ,
9896 } )
99- editor . commands . selectAll ( )
100- const slice = editor . state . selection . content ( )
101- const { text } = serializeForClipboard ( editor . view , slice )
97+ const text = copyEditorContent ( editor )
10298 expect ( text ) . toBe ( 'Hello' )
10399 } )
104100
@@ -107,10 +103,51 @@ describe('Markdown extension integrated in the editor', () => {
107103 content : '<blockquote><p><ul class="contains-task-list"><li><input type="checkbox">Hello</li></ul></blockquote>' ,
108104 extensions : [ Markdown , Blockquote , TaskList , TaskItem ] ,
109105 } )
110- editor . commands . selectAll ( )
111- const slice = editor . state . selection . content ( )
112- const { text } = serializeForClipboard ( editor . view , slice )
106+ const text = copyEditorContent ( editor )
113107 expect ( text ) . toBe ( '\n- [ ] Hello' )
114108 } )
115109
110+ it ( 'copies address from blockquote to markdown' , ( ) => {
111+ const editor = createCustomEditor ( {
112+ content : '<blockquote><p>Hermannsreute 44A</p></blockquote>' ,
113+ extensions : [ Markdown , Blockquote ] ,
114+ } )
115+ const text = copyEditorContent ( editor )
116+ expect ( text ) . toBe ( 'Hermannsreute 44A' )
117+ } )
118+
119+ it ( 'copy version number without escape character' , ( ) => {
120+ const editor = createCustomEditor ( {
121+ content : '<p>Hello</p><p>28.0.4</p>' ,
122+ extensions : [ Markdown ] ,
123+ } )
124+ const text = copyEditorContent ( editor )
125+ expect ( text ) . toBe ( 'Hello\n\n28.0.4' )
126+ } )
127+
128+ it ( 'strips bold, italic, and other marks from paragraph' , ( ) => {
129+ const editor = createCustomEditor ( {
130+ content : '<p><strong>Hello</strong></p><p><span style="text-decoration: underline;">lonely </span><em>world</em></p>' ,
131+ extensions : [ Markdown , Italic , Strong , Underline ] ,
132+ } )
133+ const text = copyEditorContent ( editor )
134+ expect ( text ) . toBe ( 'Hello\n\nlonely world' )
135+ } )
136+
137+ it ( 'strips href and link formatting from email address' , ( ) => {
138+ const editor = createCustomEditor ( {
139+ content :
'<p>Hello</p><p><a href="mailto:[email protected] ">[email protected] </a></p>' , 140+ extensions : [ Markdown , Link ] ,
141+ } )
142+ const text = copyEditorContent ( editor )
143+ expect ( text ) . toBe ( 'Hello\n\[email protected] ' ) 144+ } )
145+
116146} )
147+
148+ function copyEditorContent ( editor ) {
149+ editor . commands . selectAll ( )
150+ const slice = editor . state . selection . content ( )
151+ const { text } = serializeForClipboard ( editor . view , slice )
152+ return text
153+ }
0 commit comments