1 2ko.bindingHandlers.ckeditor = { 3 init: function (element, valueAccessor, allBindings, viewModel, bindingContext) { 4 5 var modelValue = valueAccessor(); 6 var ignoreChanges = false; 7 var ignoreChangesTimout = 0; 8 9 var options = ko.utils.extend({ 10 removePlugins: 'elementspath', 11 customConfig: modelValue['customConfig'] ? modelValue['customConfig'] : 'config.js', 12 filebrowserBrowseUrl: '/filemanager.aspx', 13 filebrowserUploadUrl: '/uploader/upload.php' 14 }, allBindings.get('ckeditorOptions') || { 15 }); 16 17 var editor = CKEDITOR.replace(element, options); 18 19 editor.on('change', function () { 20 clearTimeout(ignoreChangesTimout); 21 ignoreChanges = true; 22 modelValue['data'](editor.getData()); 23 ignoreChangesTimout = setTimeout(function () { 24 ignoreChanges = false; 25 }, 100) 26 }); 27 28 modelValue['data'].subscribe(function (newValue) { 29 var editor = new CKEDITOR.dom.element(element).getEditor(); 30 if (editor && !(ignoreChanges)) 31 editor.setData(newValue); 32 }); 33 34 //handle disposal (if KO removes by the template binding) 35 ko.utils.domNodeDisposal.addDisposeCallback(element, function () { 36 if (editor) { 37 CKEDITOR.remove(editor); 38 }; 39 }); 40 }, 41 update: function (element, valueAccessor, allBindings, viewModel, bindingContext) { 42 var editor = new CKEDITOR.dom.element(element).getEditor(); 43 editor.setData(ko.unwrap(valueAccessor()['data']), null, true); 44 } 45};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.