Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks to Vojta for the excellent directive. Sometimes it doesn't load. Here is a modified version to fix that issue.</p> <pre><code>angular.module('ck', []).directive('ckEditor', function() { var calledEarly, loaded; loaded = false; calledEarly = false; return { require: '?ngModel', compile: function(element, attributes, transclude) { var loadIt, local; local = this; loadIt = function() { return calledEarly = true; }; element.ready(function() { return loadIt(); }); return { post: function($scope, element, attributes, controller) { if (calledEarly) { return local.link($scope, element, attributes, controller); } loadIt = (function($scope, element, attributes, controller) { return function() { local.link($scope, element, attributes, controller); }; })($scope, element, attributes, controller); } }; }, link: function($scope, elm, attr, ngModel) { var ck; if (!ngModel) { return; } if (calledEarly &amp;&amp; !loaded) { return loaded = true; } loaded = false; ck = CKEDITOR.replace(elm[0]); ck.on('pasteState', function() { $scope.$apply(function() { ngModel.$setViewValue(ck.getData()); }); }); ngModel.$render = function(value) { ck.setData(ngModel.$viewValue); }; } }; }); </code></pre> <p>or if you need it in coffeescript</p> <pre><code>angular.module('ck', []).directive('ckEditor', -&gt; loaded = false calledEarly = false { require: '?ngModel', compile: (element, attributes, transclude) -&gt; local = @ loadIt = -&gt; calledEarly = true element.ready -&gt; loadIt() post: ($scope, element, attributes, controller) -&gt; return local.link $scope, element, attributes, controller if calledEarly loadIt = (($scope, element, attributes, controller) -&gt; return -&gt; local.link $scope, element, attributes, controller )($scope, element, attributes, controller) link: ($scope, elm, attr, ngModel) -&gt; return unless ngModel if (calledEarly and not loaded) return loaded = true loaded = false ck = CKEDITOR.replace(elm[0]) ck.on('pasteState', -&gt; $scope.$apply( -&gt; ngModel.$setViewValue(ck.getData()) ) ) ngModel.$render = (value) -&gt; ck.setData(ngModel.$viewValue) } ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload