I am using CKEditor with angularJS. I have two editor windows as below:
{{ modal.data.text }}
<textarea
id="Textarea1"
data-ck-editor
data-ng-disabled="modal.action=='delete'"
data-ng-model="modal.data.text"></textarea>
{{ modal.data.notes }}
<textarea
id="Textarea2"
data-ck-editor
data-ng-disabled="modal.action=='delete'"
data-ng-model="modal.data.notes"></textarea>
的应用允许用户在网格选择行,然后执行下列中的模态对象来填充新数据。注意,编辑器实例在启动和不选择一个新的行中的每个时创建。
The application allows a user to select rows in a grid and then the following is executed to populate new data in the modal object. Note that the editor instances are created on start up and not each time a new row is selected.
$scope.modal.data = row;
我用下面的指令:
I am using the following directive:
app.directive('ckEditor',
[ function() {
return {
require : '?ngModel',
link : function($scope, elm, attr, ngModel) {
var ck = CKEDITOR.replace(elm[0]);
ck.on('instanceReady', function() {
ck.setData(ngModel.$viewValue);
});
ck.on('pasteState', function() {
$scope.$apply(function() {
ngModel.$setViewValue(ck.getData());
});
});
ngModel.$render = function(value) {
ck.setData(ngModel.$modelValue);
};
}
};
} ])
当用户选择一个行,然后一个标签的数据有时出现,通常没有。
When the user selects a row and then a tab the data "sometimes" appears and usually does not.
在测试这一点,我注意到,注释掉功能:ck.on('pasteState',函数()似乎帮助,但后来我也有更多的问题,因为它似乎当我输入数据到CDEditor模型{{} }不显示的数据进行更新。
While testing this I noticed that commenting out the function: ck.on('pasteState', function() seems to help but then I also have more problems as it seems when I enter data into the CDEditor the model {{ }} don't show that data being updated.
有人能给予我什么我可以做一些咨询帮助。该{{modal.data.text}}和在{{modal.data.notes}}得到渲染,但在CKEditor的窗户通常与他们没有数据显示。还什么是pasteState'和功能如何,当我在CKEditor的窗口做击键AngularJS模型得到更新?最后的问题。这是否会甚至与多个编辑器窗口工作。会不会有编辑器的两个实例产生的?
Can someone help by giving me some advice on what I can do. The {{ modal.data.text }} and the {{ modal.data.notes }} get rendered but the CKEditor windows usually appear with no data in them. Also what's the function of 'pasteState' and how does the AngularJS model get updated when I do keystrokes in the CKEditor window? Final question. Will this even work with multiple editor windows. Will there be two instances of the editor created?
推荐答案
动态创建多个编辑: http://jsfiddle.net / TheSharpieOne / cPTr7 /
与多个编辑启动和动态变化值: http://jsfiddle.net/TheSharpieOne/tBrKQ/1/
Starting with multiple editors and changing values on the fly: http://jsfiddle.net/TheSharpieOne/tBrKQ/1/
更新击键: http://jsfiddle.net/TheSharpieOne/fMC2p/ (注:纯内编辑时textarea的,CKEDITOR将分析文本和更新一次,在HTML包装吧)
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)
所有具有相同的指令:
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);
};
}
};
}])
相关推荐
最新文章