https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106314
Revision: 106314
Author: gwicke
Date: 2011-12-15 11:05:52 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Implement 1-char-minimum width for annotations, and some additonal minor
cleanup.
Modified Paths:
--------------
trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js
Modified: trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js
===================================================================
--- trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js
2011-12-15 10:55:30 UTC (rev 106313)
+++ trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js
2011-12-15 11:05:52 UTC (rev 106314)
@@ -8,7 +8,7 @@
}
/**
- * Convert a HTML DOM to WikiDom
+ * Convert HTML DOM to WikiDom
*
* @method
* @param {Object} root of HTML DOM (usually the body element)
@@ -355,6 +355,13 @@
break;
}
}
+ // Insert one char if no text was returned to satisfy WikiDom's
+ // 1-char-minimum width for annotations. Feels a bit icky, but likely
+ // simplifies editor internals.
+ if ( text === '' ) {
+ text = ' ';
+ offset++;
+ }
annotations[0].range.end = offset;
return {
text: text,
@@ -369,10 +376,10 @@
var attrib = attribs.item(i),
key = attrib.name;
if ( key.match( /^data-json-/ ) ) {
- // strip data- prefix from data-*
+ // strip data- prefix and decode
out[key.replace( /^data-json-/, '' )] =
JSON.parse(attrib.value);
} else if ( key.match( /^data-/ ) ) {
- // strip data- prefix from data-*
+ // strip data- prefix
out[key.replace( /^data-/, '' )] = attrib.value;
} else {
// prefix html properties with html/
@@ -389,10 +396,10 @@
var attrib = attribs.item(i),
key = attrib.name;
if ( key.match( /^data-json-/ ) ) {
- // strip data- prefix from data-*
+ // strip data-json- prefix and decode
out[key.replace( /^data-json-/, '' )] =
JSON.parse(attrib.value);
} else if ( key.match( /^data-/ ) ) {
- // strip data- prefix from data-*
+ // strip data- prefix
out[key.replace( /^data-/, '' )] = attrib.value;
} else {
// pass through a few whitelisted keys
@@ -408,7 +415,7 @@
return out;
};
-// Quick HACK: define Node constants
+// Quick HACK: define Node constants locally
// https://developer.mozilla.org/en/nodeType
var Node = {
ELEMENT_NODE: 1,
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs