angular-medium-editor
angular-medium-editor copied to clipboard
example in documentation section does not work
first example mentioned here doesn't work in the latest version.
Angular medium editor version - 1.1.0
The following should work (for a custom extension).
var HighlighterButton = MediumEditor.extensions.button.extend({
name: 'highlighter',
tagNames: ['mark'], // nodeName which indicates the button should be 'active' when isAlreadyApplied() is called
contentDefault: '<b>H</b>', // default innerHTML of the button
contentFA: '<i class="fa fa-paint-brush"></i>', // innerHTML of button when 'fontawesome' is being used
aria: 'Hightlight', // used as both aria-label and title attributes
action: 'highlight', // used as the data-action attribute of the button
init: function () {
//console.log('HIGHLIGHT BUTTON....');
MediumEditor.extensions.button.prototype.init.call(this);
this.classApplier = rangy.createClassApplier('highlight', {
elementTagName: 'mark',
normalize: true
});
},
handleClick: function (event) {
this.classApplier.toggleSelection();
}
});
And in your options for the directive, use
$scope.customBindOptions2 = {
toolbar: {
buttons: [
"bold", "italic", "underline", "anchor", "h1",
"highlighter",
"quote", "orderedlist", "unorderedlist"]
},
extensions: {
'highlight': new HighlighterButton()
}
};
@shanecp wanna PR this against the README.md? :-)
I updated Readme earlier for the new version, but didn't have time to test+update extensions handling.