ep_clear_formatting
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "ep_clear_formatting", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"keywords": ["clear", "formatting"], | ||
@@ -5,0 +5,0 @@ "description": "Clear formatting on a selection, this plugin requires the file menu", |
exports.postAceInit = function(hook, context){ | ||
$('#clearFormatting').click(function(){ | ||
context.ace.callWithAce(function(ace){ | ||
var rep = ace.ace_getRep(); | ||
var rep = ace.ace_getRep(); // get the current user selection | ||
var isSelection = (rep.selStart[0] !== rep.selEnd[0] || rep.selStart[1] !== rep.selEnd[1]); | ||
if(!isSelection) return false; // No point proceeding if no selection.. | ||
// note this is just bodged together, we need to query the documentattributemanager probably to find out | ||
// which attributes exist... | ||
ace.ace_setAttributeOnSelection("bold", false); | ||
ace.ace_setAttributeOnSelection("italic", false); | ||
ace.ace_setAttributeOnSelection("underline", false); | ||
ace.ace_setAttributeOnSelection("strikethrough", false); | ||
ace.ace_setAttributeOnSelection("fontcolor", false); | ||
ace.ace_setAttributeOnSelection("color", false); | ||
ace.ace_setAttributeOnSelection("subscript", false); | ||
ace.ace_setAttributeOnSelection("superscript", false); | ||
var attrs = rep.apool.attribToNum; // get the attributes on this document | ||
$.each(attrs, function(k, v){ // for each attribute | ||
var attr = k.split(",")[0]; // get the name of the attribute | ||
if(attr !== "author"){ // if its not an author attribute | ||
ace.ace_setAttributeOnSelection(attr, false); // set the attribute to false | ||
} | ||
}); | ||
},'clearFormatting' , true); | ||
}); | ||
} |
2222
36