Created
March 4, 2019 11:21
Revisions
-
Basster created this gist
Mar 4, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ export default class Emptyness { constructor(editor) { this.editor = editor; } init() { const doc = this.editor.model.document; const view = this.editor.ui.view.editable; if (!view) { return; } view.set( 'isEmpty', !documentHasContent(doc) ); view.listenTo(doc, 'change:data', () => { view.set( 'isEmpty', !documentHasContent(doc) ); } ); if (view.isRendered === true) { return; } const bind = view.bindTemplate; view.extendTemplate( { attributes: { class: [ bind.if( 'isEmpty', 'ck-editor__is-empty' ) ] } } ); } } function documentHasContent(doc) { return doc.model.hasContent(doc.getRoot()); }