Skip to content

Commit

Permalink
Merge 00c3faa into 6ba8390
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Nov 5, 2018
2 parents 6ba8390 + 00c3faa commit e642be4
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 149 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.

8 changes: 3 additions & 5 deletions sample/index.html
Expand Up @@ -22,6 +22,7 @@ <h1>CKEditor 5 – Vue.js Component – development sample</h1>
editor="classic"
tag-name="textarea"
v-model="editorData"
:editor="editor"
:config="editorConfig"
:disabled="editorDisabled"
@ready="onEditorReady"
Expand All @@ -40,15 +41,12 @@ <h2>Live editor data</h2>
</div>

<script>
Vue.use( CKEditor, {
editors: {
classic: ClassicEditor
}
} );
Vue.use( CKEditor );

const app = new Vue( {
el: '#app',
data: {
editor: ClassicEditor,
editorData: '<p>Hello world!</p>',
editorConfig: { toolbar: [ 'heading', '|', 'bold', 'italic' ] },
editorDisabled: false
Expand Down
9 changes: 5 additions & 4 deletions src/ckeditor.js
Expand Up @@ -13,7 +13,10 @@ export default {
},

props: {
editor: null,
editor: {
type: Function,
default: null
},
value: {
type: String,
default: ''
Expand Down Expand Up @@ -41,9 +44,7 @@ export default {
},

mounted() {
const creator = typeof this.editor === 'string' ? this.$_ckeditor_types[ this.editor ] : this.editor;

creator.create( this.$el, this.config )
this.editor.create( this.$el, this.config )
.then( editor => {
// Save the reference to the instance for further use.
this.instance = editor;
Expand Down
12 changes: 2 additions & 10 deletions src/plugin.js
Expand Up @@ -10,17 +10,9 @@ const CKEditor = {
* Instals the plugin, registering the `<ckeditor>` component.
*
* @param {Vue} Vue The Vue object.
* @param {Object} [config] Plugin configuration.
* @param {Object.<String,Function>} [config.editors] The configuration of editor constructors and their names.
* @param {String>} [config.componentName] The name of the component used in the template. `'ckeditor'` by default.
*/
install( Vue, config ) {
// https://github.com/gotwarlost/istanbul/issues/665
config = config || {};

Vue.component( config.componentName || 'ckeditor', CKEditorComponent );

Vue.prototype.$_ckeditor_types = config.editors;
install( Vue ) {
Vue.component( 'ckeditor', CKEditorComponent );
},
component: CKEditorComponent
};
Expand Down
4 changes: 1 addition & 3 deletions tests/ckeditor.js
Expand Up @@ -11,8 +11,6 @@ import CKEditorComponent from '../src/ckeditor';
import MockEditor from './_utils/mockeditor';
import { ModelDocument, ViewlDocument } from './_utils/mockeditor';

Vue.prototype.$_ckeditor_types = { classic: MockEditor };

describe( 'CKEditor Component', () => {
let sandbox, wrapper, vm;

Expand Down Expand Up @@ -323,7 +321,7 @@ describe( 'CKEditor Component', () => {
function createComponent( props ) {
const wrapper = mount( CKEditorComponent, {
propsData: Object.assign( {}, {
editor: 'classic'
editor: MockEditor
}, props )
} );

Expand Down
40 changes: 0 additions & 40 deletions tests/plugin/editors.js

This file was deleted.

9 changes: 3 additions & 6 deletions tests/plugin/integration.js
Expand Up @@ -8,17 +8,13 @@ import { mount } from '@vue/test-utils';
import CKEditor from '../../src/plugin';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

Vue.use( CKEditor, {
editors: {
classic: ClassicEditor
}
} );
Vue.use( CKEditor );

describe( 'CKEditor plugin', () => {
describe( 'Vue.use()', () => {
it( 'works with an actual editor build', done => {
const wrapper = mount( {
template: '<ckeditor editor="classic" @ready="onReady()" v-model="editorData"></ckeditor>',
template: '<ckeditor :editor="editor" @ready="onReady()" v-model="editorData"></ckeditor>',
methods: {
onReady: () => {
const instance = wrapper.vm.$children[ 0 ].instance;
Expand All @@ -34,6 +30,7 @@ describe( 'CKEditor plugin', () => {
attachToDocument: true,
data: () => {
return {
editor: ClassicEditor,
editorData: '<p>foo</p>'
};
}
Expand Down
47 changes: 0 additions & 47 deletions tests/plugin/noconfig.js

This file was deleted.

32 changes: 0 additions & 32 deletions tests/plugin/template.js

This file was deleted.

0 comments on commit e642be4

Please sign in to comment.