Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>CKEditor does not update textarea while typing, so you need to take care of it.</p> <p><strong>Here's a directive that will make ng-model binding work with CK:</strong></p> <pre class="lang-js prettyprint-override"><code>angular.module('ck', []).directive('ckEditor', function() { return { require: '?ngModel', link: function(scope, elm, attr, ngModel) { var ck = CKEDITOR.replace(elm[0]); if (!ngModel) return; ck.on('pasteState', function() { scope.$apply(function() { ngModel.$setViewValue(ck.getData()); }); }); ngModel.$render = function(value) { ck.setData(ngModel.$viewValue); }; } }; }); </code></pre> <p>In html, just use:</p> <pre class="lang-html prettyprint-override"><code>&lt;textarea ck-editor ng-model="value"&gt;&lt;/textarea&gt; </code></pre> <hr> <p>The previous code will update ng-model on every change.</p> <p><strong>If you only want to update binding on save, override "save" plugin, to not do anything but fire "save" event.</strong></p> <pre class="lang-js prettyprint-override"><code>// modified ckeditor/plugins/save/plugin.js CKEDITOR.plugins.registered['save'] = { init: function(editor) { var command = editor.addCommand('save', { modes: {wysiwyg: 1, source: 1}, readOnly: 1, exec: function(editor) { editor.fire('save'); } }); editor.ui.addButton('Save', { label : editor.lang.save, command : 'save' }); } }; </code></pre> <p>And then, use this event inside the directive:</p> <pre class="lang-js prettyprint-override"><code>angular.module('ck', []).directive('ckEditor', function() { return { require: '?ngModel', link: function(scope, elm, attr, ngModel) { var ck = CKEDITOR.replace(elm[0]); if (!ngModel) return; ck.on('save', function() { scope.$apply(function() { ngModel.$setViewValue(ck.getData()); }); }); } }; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    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