Multiple 4.2 CKEditor instances on one page with AngularJS

家住魔仙堡 提交于 2019-12-04 16:41:18

Creating multiple editors on the fly: http://jsfiddle.net/TheSharpieOne/cPTr7/

Starting with multiple editors and changing values on the fly: http://jsfiddle.net/TheSharpieOne/tBrKQ/1/

Updating on keystroke: http://jsfiddle.net/TheSharpieOne/fMC2p/ (Note: when editing within the plain textarea, ckEditor will parse the text and update it again, wrapping it in HTML)

All have the same directive:

app.directive('ckEditor', [function () {
    return {
        require: '?ngModel',
        link: function ($scope, elm, attr, ngModel) {

            var ck = CKEDITOR.replace(elm[0]);

            ck.on('pasteState', function () {
                $scope.$apply(function () {
                    ngModel.$setViewValue(ck.getData());
                });
            });

            ngModel.$render = function (value) {
                ck.setData(ngModel.$modelValue);
            };
        }
    };
}])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!