Firepad.prototype.selectionHasAttributes = function() {
var startPos = this.codeMirror_.getCursor('start'), endPos = this.codeMirror_.getCursor('end');
var startIndex = this.codeMirror_.indexFromPos(startPos), endIndex = this.codeMirror_.indexFromPos(endPos);
return this.rangeHasAttributes(startIndex, endIndex);
};
Firepad.prototype.rangeHasAttributes = function(start, end) {
this.assertReady_('rangeHasAttributes');
var doc = (start != null && end != null) ?
this.getOperationForSpan(start, end) :
this.getOperationForSpan(0, this.codeMirror_.getValue().length);
var i = 0, op = doc.ops[i];
while(op) {
var attrs=op.attributes;
if (!attrs) continue;
if (ATTR.LINE_INDENT in attrs || ATTR.LIST_TYPE in attrs || ATTR.LINE_ALIGN in attrs) return true; // found a line attribute
if (ATTR.BOLD in attrs || ATTR.ITALIC in attrs || ATTR.UNDERLINE in attrs || ATTR.STRIKE in attrs || ATTR.FONT in attrs ||
ATTR.FONT_SIZE in attrs || ATTR.COLOR in attrs || ATTR.BACKGROUND_COLOR in attrs) return true; // found an entity attribute
op = doc.ops[++i];
}
// this.entityManager_ ???
return false;
};
- should I worry about something in this.entityManager_ ? I see entityManager has it's own element.hasAttribute(attr) ?