psergus / ngWYSIWYG

true angular WYSIWYG
MIT License
63 stars 42 forks source link

extend ngWYSIWYG #54

Closed Nathalielim closed 8 years ago

Nathalielim commented 8 years ago

how can i extend the directive so that the editor can show different buttons for different html views?

brunokrebs commented 8 years ago

It is easy, it is just a matter of creating a literal object to be passed as the config parameter of wysiwygEdit directive. This is explained here.

As an example, to choose what buttons to show in page 1, you create an object:

angular.module('whatever').controller('page1Controller', ['$scope', function($scope) {
    $scope.configPage1 = {
        toolbar: [
            { name: 'basicStyling', items: ['bold', 'italic'] }
        ]
    };
});

And then pass it to the directive at page1.html:

    <wysiwyg-edit content="your_variable" config="configPage1"></wysiwyg-edit>

To use other buttons in other page, you just replicate it, choosing whatever buttons you want:

angular.module('whatever').controller('page2Controller', ['$scope', function($scope) {
    $scope.configPage2 = {
        toolbar: [
            { name: 'basicStyling', items: ['orderedList', 'unorderedList'] }
        ]
    };
});

And then pass it to the directive at page2.html:

    <wysiwyg-edit content="your_variable" config="configPage2"></wysiwyg-edit>