File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,22 @@ const isVoid = ['img', 'embed']
1515
1616
1717const ELEMENT_TAGS : IHtmlToJsonElementTags = {
18- A : ( el : HTMLElement ) => ( {
19- type : 'a' ,
20- attrs : {
21- url :
22- el . getAttribute ( 'href' ) ? el . getAttribute ( 'href' ) : '#'
18+ A : ( el : HTMLElement ) => {
19+ const attrs : Record < string , string > = { }
20+ const target = el . getAttribute ( 'target' ) ;
21+ const href = el . getAttribute ( 'href' ) ;
22+
23+ attrs . url = href ? href : '#' ;
24+
25+ if ( target && target !== '' ) {
26+ attrs . target = target ;
2327 }
24- } ) ,
28+
29+ return {
30+ type : "a" ,
31+ attrs : attrs ,
32+ } ;
33+ } ,
2534 BLOCKQUOTE : ( ) => ( { type : 'blockquote' , attrs : { } } ) ,
2635 H1 : ( ) => ( { type : 'h1' , attrs : { } } ) ,
2736 H2 : ( ) => ( { type : 'h2' , attrs : { } } ) ,
Original file line number Diff line number Diff line change @@ -632,6 +632,7 @@ export default {
632632 "type" : "a" ,
633633 "attrs" : {
634634 "url" : "link.com" ,
635+ "target" : "_self" ,
635636 "style" : { } ,
636637 "redactor-attributes" : {
637638 "href" : "link.com" ,
@@ -870,6 +871,7 @@ export default {
870871 "type" : "a" ,
871872 "attrs" : {
872873 "url" : "#" ,
874+ "target" : "_blank" ,
873875 "style" : { } ,
874876 "redactor-attributes" : {
875877 "target" : "_blank"
You can’t perform that action at this time.
0 commit comments