Contribute to this guideReport an issue

CKEditor 4 WYSIWYG Editor Vue Integration Documentation

The Vue integration allows you to implement CKEditor 4 as a Vue component, using the <ckeditor /> tag.

The following examples showcase the most important features of the CKEditor 4 WYSIWYG editor Vue integration.

Click the tab below to change an example.

Get Sample Source Code

  • Classic editor
    &lt;div id="app"&gt;
    	&lt;ckeditor value="&lt;p&gt;This is a CKEditor 4 WYSIWYG editor instance created with ️Vue.&lt;/p&gt;"&gt;&lt;/ckeditor&gt;
    &lt;/div&gt;
    
    &lt;script&gt;
    	Vue.use( CKEditor );
    
    	new Vue( {
    		el: '#app'
    	} );
    &lt;/script&gt;
  • Inline editor
    &lt;div id="app"&gt;
    	&lt;ckeditor type="inline" value="&lt;p&gt;This is a CKEditor 4 WYSIWYG editor instance created with ️Vue.&lt;/p&gt;"&gt;&lt;/ckeditor&gt;
    &lt;/div&gt;
    
    &lt;script&gt;
    	Vue.use( CKEditor );
    
    	new Vue( {
    		el: '#app'
    	} );
    &lt;/script&gt;
  • Editor with custom event handlers and configuration
    &lt;div id="app"&gt;
    	&lt;ckeditor
    		@ready="logEvent('ready', $event)"
    		@focus="logEvent('focus', $event)"
    		@blur="logEvent('blur', $event)"
    		@input="logEvent('input', $event)"
    
    		:config="editorConfig"
    		:value="editorData"
    	&gt;&lt;/ckeditor&gt;
    
    	&lt;section&gt;
    		&lt;h3&gt;Events log&lt;/h3&gt;
    		&lt;small&gt;To check additional details about every event, consult the console in the browser developer tools.&lt;/small&gt;
    		&lt;div class="event-log"&gt;
    			&lt;ul&gt;
    				&lt;li v-for="event of events"&gt;
    					{{ event.timestamp }} - {{ event.name }}
    				&lt;/li&gt;
    			&lt;/ul&gt;
    		&lt;/div&gt;
    		&lt;button v-on:click="clearEventsLog()"&gt;Clear events log&lt;/button&gt;
    	&lt;/section&gt;
    &lt;/div&gt;
    &lt;script&gt;
    	Vue.use( CKEditor );
    
    	new Vue( {
    		el: '#app',
    		data: function() {
    			return {
    				events: [],
    				editorData: 'This is a CKEditor 4 WYSIWYG editor instance created with Vue.',
    				editorConfig: {
    					toolbar: [
    						[ 'Source' ],
    						[ 'Styles', 'Format', 'Font', 'FontSize' ],
    						[ 'Bold', 'Italic' ],
    						[ 'Undo', 'Redo' ],
    						[ 'About' ]
    					]
    				}
    			};
    		},
    		methods: {
    			logEvent: function( eventName, event ) {
    				if ( this.events.length &gt; 19 ) {
    					this.events.pop();
    				}
    
    				const eventData = {
    					name: eventName,
    					timestamp: this.getCurrentTimestamp()
    				}
    
    				this.events.unshift( eventData );
    
    				console.log( eventData.timestamp, eventData.name, event );
    			},
    
    			getCurrentTimestamp: function() {
    				return new Intl.DateTimeFormat( 'en', {
    					hour12: false,
    					hour: '2-digit',
    					minute: '2-digit',
    					second: '2-digit'
    				} ).format( new Date() );
    			},
    
    			clearEventsLog: function() {
    				this.events = [];
    			}
    		}
    	} );
    &lt;/script&gt;
  • Two-way data binding
    &lt;div id="app"&gt;
    	&lt;p&gt;
    		&lt;textarea id="editor-editor" class="source-editor" v-model.lazy="editorData"&gt;