From ae017b50bcb88d52cb151b797c05cea38e7892f7 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 6 Aug 2015 16:04:39 -0400 Subject: [PATCH] (js) Improve ckEditor directive The directive will now consider the following attributes: - ck-options: a JSON object of options - ck-locale: the locale code to be used as the language and the speller language --- .../js/vendor/ckeditor/ck.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/UI/WebServerResources/js/vendor/ckeditor/ck.js b/UI/WebServerResources/js/vendor/ckeditor/ck.js index f9859344c..f31508887 100644 --- a/UI/WebServerResources/js/vendor/ckeditor/ck.js +++ b/UI/WebServerResources/js/vendor/ckeditor/ck.js @@ -4,7 +4,8 @@ (function() { 'use strict'; - angular.module('ck', []).directive('ckEditor', function() { + ckEditor.$inject = ['$parse']; + function ckEditor($parse) { var calledEarly, loaded; loaded = false; calledEarly = false; @@ -39,7 +40,7 @@ }, link: function($scope, elm, attr, ngModel) { - var ck; + var ck, options = {}, locale; if (!ngModel) { return; } @@ -49,7 +50,16 @@ } loaded = false; - ck = CKEDITOR.replace(elm[0]); + if (attr.ckOptions) + options = angular.fromJson(attr.ckOptions.replace(/'/g, "\"")); + + if (attr.ckLocale) { + locale = $parse(attr.ckLocale)($scope); + options.language = locale; + options.scayt_sLang = locale; + } + + ck = CKEDITOR.replace(elm[0], options); ck.on('pasteState', function() { $scope.$apply(function() { ngModel.$setViewValue(ck.getData()); @@ -61,6 +71,9 @@ }; } }; - }); - + } + + angular + .module('ck', []) + .directive('ckEditor', ckEditor); })();