froala / angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
MIT License
306 stars 123 forks source link

Problem registering a command #165

Closed mabuonomo closed 6 years ago

mabuonomo commented 6 years ago

Hi, I have some problem with create a dommand

This is my code

<textarea froala froala-init="myControllerFunction(initControls)" class="form-control no-resize auto-growth" name="description" id="description" ng-model="$parent.model.description"></textarea>

$scope.myControllerFunction = function (initControls) {
        initControls.initialize();
        var editor = initControls.getEditor();

        editor.DefineIcon("myDropdown", {
            NAME: "myDropdown"
        });
        editor.RegisterCommand("myDropdown", {
            title: "Example",
            type: "dropdown",
            icon: "dropdownIcon",
            focus: true,
            undo: true,
            refreshAfterCallback: true,
            options: {
                "v1": "Option 1",
                "v2": "Option 2"
            },
            callback: function (cmd, val) {
                console.log(val);
            },
            // Callback on refresh.
            refresh: function ($btn) {
                console.log("do refresh");
            },
            // Callback on dropdown show.
            refreshOnShow: function ($btn, $dropdown) {
                console.log("do refresh when show");
            }
        });
    // });
    }

The error is:

editor.DefineIcon is not a function

editor is not undefined

Thanks

stefanneculai commented 6 years ago

@mabuonomo you should define the new button before initializing the editor just as described in our docs, by using $.FroalaEditor.RegisterCommand.