Skip to content

Fix ckeditor 4 url #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions ckeditor/ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,50 @@ webix.protoUI({
this.$view.className += " webix_selectable";
this._waitEditor = webix.promise.defer();

var tid = config.textAreaID = "t"+webix.uid();
this.$view.innerHTML = "<textarea id='"+tid+"'>"+config.value+"</textarea>";
const tid = config.textAreaID = "t"+webix.uid();
this.$view.innerHTML = `<textarea id=${tid}>${config.value || ""}</textarea>`;

this.$ready.push(this._init_ckeditor_once);
},
defaults:{
language:"en",
language: "en",
barHeight: 70,
toolbar: [
[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],
[ 'FontSize', 'TextColor', 'BGColor' ]
],
editorConfig: {}
},
_init_ckeditor_once:function(){
_init_ckeditor_once:function(){
if (this.config.cdn === false){
webix.delay( webix.bind( this._render_ckeditor, this) );
return;
};

var cdn = this.config.cdn || "//cdn.ckeditor.com/4.13.0/standard/";
window.CKEDITOR_BASEPATH = cdn;
webix.require([cdn+"/ckeditor.js"])
const cdn = this.config.cdn || "//cdn.ckeditor.com/4.22.1/standard/";

window.CKEDITOR_BASEPATH = cdn;
webix.require([cdn+"ckeditor.js"])
.then( webix.bind(this._render_ckeditor, this) )
.catch(function(e){
console.log(e);
});
});
},
_render_ckeditor:function(){
var initMethod = "replace";
let initMethod = "replace";
if(this.config.editorType === "inline") {
CKEDITOR.disableAutoInline = true;
initMethod = "inline";
this.$view.style["overflow-y"] = "auto";
};

var barHeight = 70; // toolbar + bottombar, as initial sizes are set to the editable area
var config = webix.extend({
const barHeight = this.config.barHeight; // toolbar + bottombar, as initial sizes are set to the editable area
const config = webix.extend({
toolbar: this.config.toolbar,
language: this.config.language,
width:this.$width,
height:this.$height-barHeight,
resize_enabled:false
width: this.$width,
height: this.$height - barHeight,
resize_enabled: false,
}, this.config.editorConfig);

this._editor = CKEDITOR[initMethod](this.config.textAreaID, config);
Expand All @@ -68,17 +69,17 @@ webix.protoUI({
this._editor.setData(value);
else webix.delay(function(){
this.setValue(value);
},this,[],100);
}, this, [], 100);
},
getValue:function(){
return this._editor?this._editor.getData():this.config.value;
return this._editor ? this._editor.getData() : this.config.value;
},
focus:function(){
this._focus_await = true;
if (this._editor)
this._editor.focus();
},
getEditor:function(waitEditor){
return waitEditor?this._waitEditor:this._editor;
return waitEditor ? this._waitEditor : this._editor;
}
}, webix.ui.view);
2 changes: 1 addition & 1 deletion ckeditor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wbx/view-ckeditor",
"version": "4.13.0",
"version": "4.22.1",
"description": "CKEditor as Webix view",
"main": "ckeditor.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions ckeditor/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<script src="//cdn.webix.com/edge/webix.js" type="text/javascript" charset="utf-8"></script>

<!-- `cdn:false` assumes that required files are included manually -->
<!--
<script src="//cdn.ckeditor.com/4.13.0/standard/ckeditor.js"></script>
<!--
<script src="//cdn.ckeditor.com/4.22.1/standard/ckeditor.js"></script>
<script>
window.CKEDITOR_BASEPATH = "//cdn.ckeditor.com/4.13.0/standard/";
</script>
window.CKEDITOR_BASEPATH = "//cdn.ckeditor.com/4.22.1/standard/";
</script>
-->

<script type="text/javascript" src="./ckeditor.js"></script>
Expand Down