NYTimes/ice — Issue #11: initializeEditor doesn't recognize custom changeTypes
Author: primatology
Created: 2012-03-05 03:14:40+00:00
State: open

Relevant code in the `initializeEditor` attached below. When a custom changeType is added via `addChangeType`, those elements are not automatically parsed. Seems relatively easy to recognize any element in the `changeTypes` array (rather than hardcoding ins/del), unless this is something intentionally left to each plugin?

var ins = this._getIceNodeClass('insertType'), del = this._getIceNodeClass('deleteType');
ice.dom.each(ice.dom.find(this.element, '.'+ins+','+'.'+del), function(i, el) {
var styleIndex = 0;
var ctnType = '';
var classList = el.className.split(' ');
for(var i = 0; i < classList.length; i++) {
var styleReg = new RegExp(self.stylePrefix + '-(\\d+)').exec(classList[i]);
if(styleReg) styleIndex = styleReg[1];
var ctnReg = new RegExp('('+ins+'|'+del+')').exec(classList[i]);
if(ctnReg) ctnType = self._getChangeTypeFromAlias(ctnReg[1]);
}
var userid = ice.dom.attr(el, self.userIdAttribute);
self.setUserStyle(userid, Number(styleIndex));
var changeid = ice.dom.attr(el, self.changeIdAttribute);
self._changes[changeid] = {
type: ctnType,
userid: userid,
username: ice.dom.attr(el, self.userNameAttribute),
time: ice.dom.attr(el, self.timeAttribute)
};
});