Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your directive is working well.</p> <p>There is a plugin called <strong>sourcearea</strong> that controls the CKEditor behavior while on <em>source mode</em>. I couldn't see any event being fire inside the code of that plugin for handling input. There are though two events that we can use to catch when the CKEditor goes back to <em>GUI mode</em>. The events are <strong>ariaWidget</strong> and <strong>dataReady</strong>.</p> <p>I've updated your example to use the <strong>dataReady</strong> event, so it updates the textarea when switching back. I also changed the <strong>pasteState</strong> event to <strong>change</strong>, as <a href="https://stackoverflow.com/questions/11997246/bind-ckeditor-value-to-model-text-in-angularjs-and-rails#comment27180866_12021632">Dan Caragea said</a> it was introduced in version 4.2. <a href="http://jsfiddle.net/fdD63/3/" rel="nofollow noreferrer">Updated fiddle can be found here</a></p> <p>One almost-there-solution I found is to listen to the <strong>key</strong> event and update the model. It is almost there, because it seems the event is only fired for the old key pressed. So the last key is always missing.</p> <pre><code>var cmsPlus = angular.module('cmsPlus', []); cmsPlus.directive('ckEditor', function() { return { require: '?ngModel', link: function(scope, elm, attr, ngModel) { var ck = CKEDITOR.replace(elm[0]); if (!ngModel) return; ck.on('instanceReady', function() { ck.setData(ngModel.$viewValue); }); function updateModel() { scope.$apply(function() { ngModel.$setViewValue(ck.getData()); }); } ck.on('change', updateModel); ck.on('key', updateModel); ck.on('dataReady', updateModel); ngModel.$render = function(value) { ck.setData(ngModel.$viewValue); }; } }; }); </code></pre> <p>Anyway, maybe you can figure out from this how to fix the last key problem. It is almost there!</p> <p>EDIT: updated fiddle link to correct version</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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