Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js |
— | — | @@ -31,6 +31,26 @@ |
32 | 32 | handler: this._convertHTMLLeaf, |
33 | 33 | type: 'paragraph' |
34 | 34 | }; |
| 35 | + case 'h1': |
| 36 | + case 'h2': |
| 37 | + case 'h3': |
| 38 | + case 'h4': |
| 39 | + case 'h5': |
| 40 | + case 'h6': |
| 41 | + var res = { |
| 42 | + handler: this._convertHTMLLeaf, |
| 43 | + type: 'heading', |
| 44 | + attribs: { } |
| 45 | + }; |
| 46 | + switch ( nodeName.toLowerCase() ) { |
| 47 | + case 'h1': res.attribs.level = 1; break; |
| 48 | + case 'h2': res.attribs.level = 2; break; |
| 49 | + case 'h3': res.attribs.level = 3; break; |
| 50 | + case 'h4': res.attribs.level = 4; break; |
| 51 | + case 'h5': res.attribs.level = 5; break; |
| 52 | + case 'h6': res.attribs.level = 6; break; |
| 53 | + } |
| 54 | + return res; |
35 | 55 | case 'li': |
36 | 56 | case 'dl': |
37 | 57 | case 'dd': |
— | — | @@ -99,6 +119,9 @@ |
100 | 120 | // Call a handler for the particular node type |
101 | 121 | var hi = this.getHTMLHandlerInfo( cnode.nodeName ); |
102 | 122 | var res = hi.handler.call(this, cnode, 0, hi.type ); |
| 123 | + if ( hi.attribs ) { |
| 124 | + $.extend( res.node.attributes, hi.attribs ); |
| 125 | + } |
103 | 126 | out.children.push( res.node ); |
104 | 127 | break; |
105 | 128 | case Node.TEXT_NODE: |
— | — | @@ -170,6 +193,9 @@ |
171 | 194 | // Call a handler for the particular node type |
172 | 195 | var hi = this.getHTMLHandlerInfo( cnode.nodeName ); |
173 | 196 | var res = hi.handler.call(this, cnode, offset + 1, hi.type ); |
| 197 | + if ( hi.attribs ) { |
| 198 | + $.extend( res.node.attributes, hi.attribs ); |
| 199 | + } |
174 | 200 | wnode.children.push( res.node ); |
175 | 201 | offset = res.offset; |
176 | 202 | break; |