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=&quot;app&quot;&gt;
    	&lt;ckeditor value=&quot;&lt;p&gt;This is a CKEditor 4 WYSIWYG editor instance created with &#xfe0f;Vue.&lt;/p&gt;&quot;&gt;&lt;/ckeditor&gt;
    &lt;/div&gt;
    
    &lt;script&gt;
    	Vue.use( CKEditor );
    
    	new Vue( {
    		el: &apos;#app&apos;
    	} );
    &lt;/script&gt;
  • Inline editor
    &lt;div id=&quot;app&quot;&gt;
    	&lt;ckeditor type=&quot;inline&quot; value=&quot;&lt;p&gt;This is a CKEditor 4 WYSIWYG editor instance created with &#xfe0f;Vue.&lt;/p&gt;&quot;&gt;&lt;/ckeditor&gt;
    &lt;/div&gt;
    
    &lt;script&gt;
    	Vue.use( CKEditor );
    
    	new Vue( {
    		el: &apos;#app&apos;
    	} );
    &lt;/script&gt;
  • Editor with custom event handlers and configuration
    &lt;div id=&quot;app&quot;&gt;
    	&lt;ckeditor
    		@ready=&quot;logEvent(&apos;ready&apos;, &#x24;event)&quot;
    		@focus=&quot;logEvent(&apos;focus&apos;, &#x24;event)&quot;
    		@blur=&quot;logEvent(&apos;blur&apos;, &#x24;event)&quot;
    		@input=&quot;logEvent(&apos;input&apos;, &#x24;event)&quot;
    
    		:config=&quot;editorConfig&quot;
    		:value=&quot;editorData&quot;
    	&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=&quot;event-log&quot;&gt;
    			&lt;ul&gt;
    				&lt;li v-for=&quot;event of events&quot;&gt;
    					{{ event.timestamp }} - {{ event.name }}
    				&lt;/li&gt;
    			&lt;/ul&gt;
    		&lt;/div&gt;
    		&lt;button v-on:click=&quot;clearEventsLog()&quot;&gt;Clear events log&lt;/button&gt;
    	&lt;/section&gt;
    &lt;/div&gt;
    &lt;script&gt;
    	Vue.use( CKEditor );
    
    	new Vue( {
    		el: &apos;#app&apos;,
    		data: function() {
    			return {
    				events: [],
    				editorData: &apos;This is a CKEditor 4 WYSIWYG editor instance created with Vue.&apos;,
    				editorConfig: {
    					toolbar: [
    						[ &apos;Source&apos; ],
    						[ &apos;Styles&apos;, &apos;Format&apos;, &apos;Font&apos;, &apos;FontSize&apos; ],
    						[ &apos;Bold&apos;, &apos;Italic&apos; ],
    						[ &apos;Undo&apos;, &apos;Redo&apos; ],
    						[ &apos;About&apos; ]
    					]
    				}
    			};
    		},
    		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( &apos;en&apos;, {
    					hour12: false,
    					hour: &apos;2-digit&apos;,
    					minute: &apos;2-digit&apos;,
    					second: &apos;2-digit&apos;
    				} ).format( new Date() );
    			},
    
    			clearEventsLog: function() {
    				this.events = [];
    			}
    		}
    	} );
    &lt;/script&gt;
  • Two-way data binding
    &lt;div id=&quot;app&quot;&gt;
    	&lt;p&gt;
    		&lt;textarea id=&quot;editor-editor&quot; class=&quot;source-editor&quot; v-model.lazy=&quot;editorData&quot;&gt;