angular-medium-editor icon indicating copy to clipboard operation
angular-medium-editor copied to clipboard

example in documentation section does not work

Open sudarsangp opened this issue 9 years ago • 2 comments

first example mentioned here doesn't work in the latest version.

Angular medium editor version - 1.1.0

Plunker Example Demo

sudarsangp avatar Nov 25 '15 08:11 sudarsangp

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 avatar Dec 20 '15 10:12 shanecp

@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.

simison avatar Mar 04 '16 16:03 simison