@@ -195,7 +195,7 @@ describe('Markdown', () => {
195
195
expect ( md2 ) . toBe ( 'ab\n\nc__123__\n\n++456++d' ) ;
196
196
} ) ;
197
197
198
- test . skip ( 'can insert Markdown with inline line breaks' , ( ) => {
198
+ test ( 'can insert Markdown with inline line breaks' , ( ) => {
199
199
const { peritext, transfer} = setup ( ) ;
200
200
const md = '1\n2\n3' ;
201
201
peritext . strApi ( ) . ins ( 0 , 'ab' ) ;
@@ -204,9 +204,72 @@ describe('Markdown', () => {
204
204
peritext . refresh ( ) ;
205
205
const all = peritext . rangeAll ( ) ! ;
206
206
const html = transfer . toHtml ( all ) ;
207
- console . log ( html ) ;
208
- expect ( html ) . toBe ( '<p>a123b</p>' ) ;
207
+ expect ( html ) . toBe ( '<p>a1 2 3b</p>' ) ;
209
208
const md2 = transfer . toMarkdown ( all ) ;
210
- expect ( md2 ) . toBe ( 'a123b' ) ;
209
+ expect ( md2 ) . toBe ( 'a1 2 3b' ) ;
210
+ } ) ;
211
+
212
+ test ( 'can insert a blockquote and a paragraph into empty string' , ( ) => {
213
+ const { peritext, transfer} = setup ( ) ;
214
+ const md = '> blockquote' ;
215
+ transfer . fromMarkdown ( 0 , md ) ;
216
+ peritext . refresh ( ) ;
217
+ const all = peritext . rangeAll ( ) ! ;
218
+ const html = transfer . toHtml ( all ) ;
219
+ expect ( html ) . toBe ( '<blockquote><p>blockquote</p></blockquote>' ) ;
220
+ const md2 = transfer . toMarkdown ( all ) ;
221
+ console . log ( md2 ) ;
222
+ expect ( md2 ) . toBe ( '> blockquote' ) ;
223
+ } ) ;
224
+
225
+ test ( 'can insert a blockquote' , ( ) => {
226
+ const { peritext, transfer} = setup ( ) ;
227
+ const md = '> blockquote' ;
228
+ peritext . strApi ( ) . ins ( 0 , 'ab' ) ;
229
+ peritext . refresh ( ) ;
230
+ transfer . fromMarkdown ( 1 , md ) ;
231
+ peritext . refresh ( ) ;
232
+ const all = peritext . rangeAll ( ) ! ;
233
+ const html = transfer . toHtml ( all ) ;
234
+ expect ( html ) . toBe ( '<p>a</p><blockquote><p>blockquoteb</p></blockquote>' ) ;
235
+ const md2 = transfer . toMarkdown ( all ) ;
236
+ expect ( md2 ) . toBe ( 'a\n\n> blockquoteb' ) ;
237
+ } ) ;
238
+
239
+ test ( 'can insert a blockquote and a paragraph' , ( ) => {
240
+ const { peritext, transfer} = setup ( ) ;
241
+ const md = '> blockquote\n\nparagraph' ;
242
+ peritext . strApi ( ) . ins ( 0 , 'ab' ) ;
243
+ peritext . refresh ( ) ;
244
+ transfer . fromMarkdown ( 1 , md ) ;
245
+ peritext . refresh ( ) ;
246
+ const all = peritext . rangeAll ( ) ! ;
247
+ const html = transfer . toHtml ( all ) ;
248
+ expect ( html ) . toBe ( '<p>a</p><blockquote><p>blockquote</p></blockquote><p>paragraphb</p>' ) ;
249
+ const md2 = transfer . toMarkdown ( all ) ;
250
+ expect ( md2 ) . toBe ( 'a\n\n> blockquote\n\nparagraphb' ) ;
251
+ } ) ;
252
+
253
+ test ( 'can insert realistic 3 paragraphs of Markdown' , ( ) => {
254
+ const { peritext, transfer} = setup ( ) ;
255
+ const md =
256
+ 'The German __automotive sector__ is in the process of _cutting ' +
257
+ 'thousands of jobs_ as it grapples with a global shift toward electric vehicles ' +
258
+ '— a transformation Musk himself has been at the forefront of.' +
259
+ '\n\n' +
260
+ '> To be or not to be, that is the question.' +
261
+ '\n\n' +
262
+ 'A `ClipboardEvent` is dispatched for copy, cut, and paste events, and it contains ' +
263
+ 'a `clipboardData` property of type `DataTransfer`. The `DataTransfer` object ' +
264
+ 'is used by the Clipboard Events API to hold multiple representations of data.' ;
265
+ peritext . strApi ( ) . ins ( 0 , 'ab' ) ;
266
+ peritext . refresh ( ) ;
267
+ transfer . fromMarkdown ( 1 , md ) ;
268
+ peritext . refresh ( ) ;
269
+ // console.log(peritext.blocks + '');
270
+ const all = peritext . rangeAll ( ) ! ;
271
+ const md2 = transfer . toMarkdown ( all ) ;
272
+ // console.log(md2);
273
+ expect ( md2 ) . toBe ( 'a' + md + 'b' ) ;
211
274
} ) ;
212
275
} ) ;
0 commit comments