File tree 1 file changed +14
-1
lines changed
packages/plugins/preset-commonmark/src/mark
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,22 @@ export const strongSchema = $markSchema('strong', (ctx) => ({
26
26
} ,
27
27
} ,
28
28
parseDOM : [
29
- { tag : 'b' } ,
29
+ // This works around a Google Docs misbehavior where
30
+ // pasted content will be inexplicably wrapped in `<b>`
31
+ // tags with a font-weight normal.
32
+ {
33
+ tag : 'b' ,
34
+ getAttrs : ( node : HTMLElement ) =>
35
+ node . style . fontWeight != 'normal' && null ,
36
+ } ,
30
37
{ tag : 'strong' } ,
31
38
{ style : 'font-style' , getAttrs : ( value ) => ( value === 'bold' ) as false } ,
39
+ { style : 'font-weight=400' , clearMark : ( m ) => m . type . name == 'strong' } ,
40
+ {
41
+ style : 'font-weight' ,
42
+ getAttrs : ( value : string ) =>
43
+ / ^ ( b o l d ( e r ) ? | [ 5 - 9 ] \d { 2 , } ) $ / . test ( value ) && null ,
44
+ } ,
32
45
] ,
33
46
toDOM : ( mark ) => [ 'strong' , ctx . get ( strongAttr . key ) ( mark ) ] ,
34
47
parseMarkdown : {
You canβt perform that action at this time.
0 commit comments