Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example in documentation section does not work #47

Open
sudarsangp opened this issue Nov 25, 2015 · 2 comments
Open

example in documentation section does not work #47

sudarsangp opened this issue Nov 25, 2015 · 2 comments

Comments

@sudarsangp
Copy link

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

Angular medium editor version - 1.1.0

Plunker Example Demo

@shanecp
Copy link

shanecp commented Dec 20, 2015

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()
        }
    };

@simison
Copy link
Collaborator

simison commented Mar 4, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants