Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
12 | | - * Convert a HTML DOM to WikiDom |
| 12 | + * Convert HTML DOM to WikiDom |
13 | 13 | * |
14 | 14 | * @method |
15 | 15 | * @param {Object} root of HTML DOM (usually the body element) |
— | — | @@ -355,6 +355,13 @@ |
356 | 356 | break; |
357 | 357 | } |
358 | 358 | } |
| 359 | + // Insert one char if no text was returned to satisfy WikiDom's |
| 360 | + // 1-char-minimum width for annotations. Feels a bit icky, but likely |
| 361 | + // simplifies editor internals. |
| 362 | + if ( text === '' ) { |
| 363 | + text = ' '; |
| 364 | + offset++; |
| 365 | + } |
359 | 366 | annotations[0].range.end = offset; |
360 | 367 | return { |
361 | 368 | text: text, |
— | — | @@ -369,10 +376,10 @@ |
370 | 377 | var attrib = attribs.item(i), |
371 | 378 | key = attrib.name; |
372 | 379 | if ( key.match( /^data-json-/ ) ) { |
373 | | - // strip data- prefix from data-* |
| 380 | + // strip data- prefix and decode |
374 | 381 | out[key.replace( /^data-json-/, '' )] = JSON.parse(attrib.value); |
375 | 382 | } else if ( key.match( /^data-/ ) ) { |
376 | | - // strip data- prefix from data-* |
| 383 | + // strip data- prefix |
377 | 384 | out[key.replace( /^data-/, '' )] = attrib.value; |
378 | 385 | } else { |
379 | 386 | // prefix html properties with html/ |
— | — | @@ -389,10 +396,10 @@ |
390 | 397 | var attrib = attribs.item(i), |
391 | 398 | key = attrib.name; |
392 | 399 | if ( key.match( /^data-json-/ ) ) { |
393 | | - // strip data- prefix from data-* |
| 400 | + // strip data-json- prefix and decode |
394 | 401 | out[key.replace( /^data-json-/, '' )] = JSON.parse(attrib.value); |
395 | 402 | } else if ( key.match( /^data-/ ) ) { |
396 | | - // strip data- prefix from data-* |
| 403 | + // strip data- prefix |
397 | 404 | out[key.replace( /^data-/, '' )] = attrib.value; |
398 | 405 | } else { |
399 | 406 | // pass through a few whitelisted keys |
— | — | @@ -408,7 +415,7 @@ |
409 | 416 | return out; |
410 | 417 | }; |
411 | 418 | |
412 | | -// Quick HACK: define Node constants |
| 419 | +// Quick HACK: define Node constants locally |
413 | 420 | // https://developer.mozilla.org/en/nodeType |
414 | 421 | var Node = { |
415 | 422 | ELEMENT_NODE: 1, |