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?