@@ -273,6 +273,30 @@ export const schema = new Schema({
273
273
} ,
274
274
} as MarkSpec ,
275
275
276
+ underline : {
277
+ parseDOM : [
278
+ { tag : 'u' } ,
279
+ { style : 'text-decoration=underline' } ,
280
+ { style : 'text-decoration-line=underline' } ,
281
+ ] ,
282
+ toDOM ( ) {
283
+ return [ 'u' , 0 ] ;
284
+ } ,
285
+ } ,
286
+
287
+ strike : {
288
+ parseDOM : [
289
+ { tag : 's' } ,
290
+ { tag : 'strike' } ,
291
+ { tag : 'del' } ,
292
+ { style : 'text-decoration=line-through' } ,
293
+ { style : 'text-decoration-line=line-through' } ,
294
+ ] ,
295
+ toDOM ( ) {
296
+ return [ 's' , 0 ] ;
297
+ } ,
298
+ } ,
299
+
276
300
link : {
277
301
attrs : {
278
302
href : { } ,
@@ -301,5 +325,81 @@ export const schema = new Schema({
301
325
return [ 'code' ] ;
302
326
} ,
303
327
} ,
328
+
329
+ highlight : {
330
+ attrs : {
331
+ color : { default : null } ,
332
+ } ,
333
+ parseDOM : [
334
+ {
335
+ tag : 'mark' ,
336
+ getAttrs : ( node ) => {
337
+ const dom = node as HTMLElement ;
338
+ return {
339
+ color : dom . getAttribute ( 'data-color' ) || dom . style . backgroundColor ,
340
+ } ;
341
+ } ,
342
+ } ,
343
+ ] ,
344
+ toDOM ( node ) {
345
+ const attrs : Record < string , string > = { } ;
346
+ if ( node . attrs . color ) {
347
+ attrs [ 'data-color' ] = node . attrs . color ;
348
+ attrs . style = `background-color: ${ node . attrs . color } ; color: inherit` ;
349
+ }
350
+ return [ 'mark' , attrs , 0 ] ;
351
+ } ,
352
+ } ,
353
+
354
+ textStyle : {
355
+ attrs : {
356
+ color : { default : null } ,
357
+ backgroundColor : { default : null } ,
358
+ fontSize : { default : null } ,
359
+ fontFamily : { default : null } ,
360
+ fontWeight : { default : null } ,
361
+ textDecoration : { default : null } ,
362
+ } ,
363
+ parseDOM : [
364
+ {
365
+ tag : 'span[style]' ,
366
+ getAttrs : ( node ) => {
367
+ const dom = node as HTMLElement ;
368
+ return {
369
+ color : dom . style . color ,
370
+ backgroundColor : dom . style . backgroundColor ,
371
+ fontSize : dom . style . fontSize ,
372
+ fontFamily : dom . style . fontFamily ,
373
+ fontWeight : dom . style . fontWeight ,
374
+ textDecoration : dom . style . textDecoration ,
375
+ } ;
376
+ } ,
377
+ } ,
378
+ ] ,
379
+ toDOM ( node ) {
380
+ const attrs : Record < string , string > = { style : '' } ;
381
+
382
+ if ( node . attrs . color ) {
383
+ attrs . style += `color: ${ node . attrs . color } ;` ;
384
+ }
385
+ if ( node . attrs . backgroundColor ) {
386
+ attrs . style += `background-color: ${ node . attrs . backgroundColor } ; color: inherit;` ;
387
+ }
388
+ if ( node . attrs . fontSize ) {
389
+ attrs . style += `font-size: ${ node . attrs . fontSize } ;` ;
390
+ }
391
+ if ( node . attrs . fontFamily ) {
392
+ attrs . style += `font-family: ${ node . attrs . fontFamily } ;` ;
393
+ }
394
+ if ( node . attrs . fontWeight ) {
395
+ attrs . style += `font-weight: ${ node . attrs . fontWeight } ;` ;
396
+ }
397
+ if ( node . attrs . textDecoration ) {
398
+ attrs . style += `text-decoration: ${ node . attrs . textDecoration } ;` ;
399
+ }
400
+
401
+ return [ 'span' , attrs , 0 ] ;
402
+ } ,
403
+ } ,
304
404
} ,
305
405
} ) ;
0 commit comments