Skip to content

Commit

Permalink
T/51: Used config.initialData instead of innerHTML to set the ini…
Browse files Browse the repository at this point in the history
…tial state of the editor (#52)

Internal: Used `config.initialData` instead of `innerHTML` to set the initial state of the editor. Closes #51.
  • Loading branch information
ma2ciek authored Jun 14, 2019
2 parents 79d5e32 + 7a22e24 commit 950b49a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/ckeditor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ckeditor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.3.1",
"@ckeditor/ckeditor5-build-classic": "^11.0.1",
"@ckeditor/ckeditor5-build-classic": "^12.1.0",
"@ckeditor/ckeditor5-dev-env": "^13.0.2",
"@ckeditor/ckeditor5-dev-utils": "^11.0.1",
"@vue/test-utils": "^1.0.0-beta.29",
Expand Down
12 changes: 7 additions & 5 deletions src/ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export default {
name: 'ckeditor',

render( createElement ) {
return createElement( this.tagName, {
domProps: {
innerHTML: this.value || ''
}
} );
return createElement( this.tagName );
},

props: {
Expand Down Expand Up @@ -57,6 +53,12 @@ export default {
},

mounted() {
if ( this.value ) {
Object.assign( this.config, {
initialData: this.value
} );
}

this.editor.create( this.$el, this.config )
.then( editor => {
// Save the reference to the instance for further use.
Expand Down
2 changes: 1 addition & 1 deletion tests/ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe( 'CKEditor Component', () => {
} );

Vue.nextTick( () => {
expect( vm.$el.innerHTML ).to.equal( 'foo' );
expect( vm.instance.config.initialData ).to.equal( 'foo' );
expect( vm.instance.setDataCounter ).to.equal( 0 );

wrapper.destroy();
Expand Down
2 changes: 2 additions & 0 deletions tests/plugin/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Vue.use( CKEditor );
describe( 'CKEditor plugin', () => {
describe( 'Vue.use()', () => {
it( 'works with an actual editor build', done => {
Vue.config.errorHandler = done;

const wrapper = mount( {
template: '<ckeditor :editor="editor" @ready="onReady()" v-model="editorData"></ckeditor>',
methods: {
Expand Down

0 comments on commit 950b49a

Please sign in to comment.