|
|
@@ -12,37 +12,38 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
|
|
|
|
|
|
-ClassicEditor.create( document.querySelector( '#editor' ), {
|
|
|
- plugins: [ Enter, Typing, Paragraph ],
|
|
|
- toolbar: []
|
|
|
-} )
|
|
|
-.then( editor => {
|
|
|
- window.editor = editor;
|
|
|
-
|
|
|
- editor.document.schema.allow( { name: '$text', inside: '$root' } );
|
|
|
-
|
|
|
- const editable = editor.ui.view.editableElement;
|
|
|
-
|
|
|
- document.querySelector( '#nbsp' ).addEventListener( 'click', () => {
|
|
|
- editor.document.enqueueChanges( () => {
|
|
|
- editor.document.selection.collapseToStart();
|
|
|
- editor.document.batch().weakInsert( editor.document.selection.getFirstPosition(), '\u00A0' );
|
|
|
+ClassicEditor
|
|
|
+ .create( document.querySelector( '#editor' ), {
|
|
|
+ plugins: [ Enter, Typing, Paragraph ],
|
|
|
+ toolbar: []
|
|
|
+ } )
|
|
|
+ .then( editor => {
|
|
|
+ window.editor = editor;
|
|
|
+
|
|
|
+ editor.document.schema.allow( { name: '$text', inside: '$root' } );
|
|
|
+
|
|
|
+ const editable = editor.ui.view.editableElement;
|
|
|
+
|
|
|
+ document.querySelector( '#nbsp' ).addEventListener( 'click', () => {
|
|
|
+ editor.document.enqueueChanges( () => {
|
|
|
+ editor.document.selection.collapseToStart();
|
|
|
+ editor.document.batch().weakInsert( editor.document.selection.getFirstPosition(), '\u00A0' );
|
|
|
+ } );
|
|
|
} );
|
|
|
- } );
|
|
|
|
|
|
- editor.document.on( 'changesDone', () => {
|
|
|
- console.clear();
|
|
|
+ editor.document.on( 'changesDone', () => {
|
|
|
+ console.clear();
|
|
|
|
|
|
- const modelData = getModelData( editor.document, { withoutSelection: true } );
|
|
|
- console.log( 'model:', modelData.replace( /\u00A0/g, ' ' ) );
|
|
|
+ const modelData = getModelData( editor.document, { withoutSelection: true } );
|
|
|
+ console.log( 'model:', modelData.replace( /\u00A0/g, ' ' ) );
|
|
|
|
|
|
- const viewData = getViewData( editor.editing.view, { withoutSelection: true } );
|
|
|
- console.log( 'view:', viewData.replace( /\u00A0/g, ' ' ) );
|
|
|
+ const viewData = getViewData( editor.editing.view, { withoutSelection: true } );
|
|
|
+ console.log( 'view:', viewData.replace( /\u00A0/g, ' ' ) );
|
|
|
|
|
|
- console.log( 'dom:', editable.innerHTML );
|
|
|
- console.log( 'editor.getData', editor.getData() );
|
|
|
- }, { priority: 'lowest' } );
|
|
|
-} )
|
|
|
-.catch( err => {
|
|
|
- console.error( err.stack );
|
|
|
-} );
|
|
|
+ console.log( 'dom:', editable.innerHTML );
|
|
|
+ console.log( 'editor.getData', editor.getData() );
|
|
|
+ }, { priority: 'lowest' } );
|
|
|
+ } )
|
|
|
+ .catch( err => {
|
|
|
+ console.error( err.stack );
|
|
|
+ } );
|