How can I change the size of a CKEditor instance when using an AngularJS directive?

812 views
Skip to first unread message

RichardAlan

unread,
Sep 9, 2013, 12:36:30 AM9/9/13
to ang...@googlegroups.com
I am using the following directive:
 
app.directive('ckEditor', function () {
    return {
        restrict: 'A', // only activate on element attribute
        scope: false,
        require: 'ngModel',
        controller: function ($scope, $element, $attrs) { }, //open for now
        link: function ($scope, element, attr, ngModel, ngModelCtrl) {
            if (!ngModel) return; // do nothing if no ng-model you might want to remove this
            element.bind('click', function () {
                for (var name in CKEDITOR.instances)
                    CKEDITOR.instances[name].destroy();
                var ck = CKEDITOR.replace(element[0]);
                ck.on('instanceReady', function () {
                    ck.setData(ngModel.$viewValue);
                });
                ck.on('pasteState', function () {
                    $scope.$apply(function () {
                        ngModel.$setViewValue(ck.getData());
                    });
                });
                ngModel.$render = function (value) {
                    ck.setData(ngModel.$viewValue);
                };
            });
        }
    }
});
 
Sometimes I would like to have a small and other times a large editor window. I created the following that gives me a large window:
 
 
CKEDITOR.editorConfig = function( config ) {
   config.height = 350;
   config.width = '100%';
};
Can anyone tell me how I could modify this directive so I can make it possible to have different sized windows with an attribute/parameter of the directive?
 
 
 
 
 
 
 

Alessandro Ghidini

unread,
Sep 9, 2013, 5:46:13 AM9/9/13
to ang...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.



--
Alessandro Ghidini
Reply all
Reply to author
Forward
0 new messages