Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/* global console */
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
import Typing from '@ckeditor/ckeditor5-typing/src/typing';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Undo from '@ckeditor/ckeditor5-undo/src/undo';
import Heading from '@ckeditor/ckeditor5-heading/src/heading';
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
import { enablePlaceholder } from '../../src/view/placeholder';
ClassicEditor
.create( global.document.querySelector( '#editor' ), {
plugins: [ Enter, Typing, Paragraph, Undo, Heading ],
toolbar: [ 'heading', '|', 'undo', 'redo' ]
} )
.then( editor => {
const view = editor.editing.view;
const viewDoc = view.document;
const header = viewDoc.getRoot().getChild( 0 );
const paragraph = viewDoc.getRoot().getChild( 1 );
enablePlaceholder( {
view,
element: header,
text: 'Type some header text...'
} );
enablePlaceholder( {
.then( editor => {
newEditor = editor;
balloon = newEditor.plugins.get( 'ContextualBalloon' );
balloonToolbar = newEditor.plugins.get( 'BalloonToolbar' );
const button = new View();
button.element = global.document.createElement( 'div' );
// There must be at least one toolbar items which is not disabled to show it.
// https://github.com/ckeditor/ckeditor5-ui/issues/269
balloonToolbar.toolbarView.items.add( button );
newEditor.editing.view.isFocused = true;
newEditor.editing.view.getDomRoot().focus();
} );
} );
beforeEach( () => {
// Most tests assume non-edge environment but we do not set `contenteditable=false` on Edge so stub `env.isEdge`.
testUtils.sinon.stub( env, 'isEdge' ).get( () => false );
editorElement = global.document.createElement( 'div' );
global.document.body.appendChild( editorElement );
return ClassicTestEditor
.create( editorElement, {
plugins: [ Image ]
} )
.then( newEditor => {
editor = newEditor;
model = editor.model;
document = model.document;
view = editor.editing.view;
viewDocument = editor.editing.view.document;
} );
} );
beforeEach( () => {
editorElement = global.document.createElement( 'div' );
global.document.body.appendChild( editorElement );
return ClassicEditor.create( editorElement, {
plugins: [ Image, ImageBalloon, Paragraph ],
} )
.then( newEditor => {
editor = newEditor;
doc = editor.document;
editingView = editor.editing.view;
plugin = editor.plugins.get( ImageBalloon );
view = new View();
view.template = new Template( { tag: 'div' } );
view.init();
} );
} );
beforeEach( () => {
editorElement = global.document.createElement( 'div' );
global.document.body.appendChild( editorElement );
return ClassicEditor.create( editorElement, {
plugins: [ Image, ImageBalloon, Paragraph ],
} )
.then( newEditor => {
editor = newEditor;
doc = editor.document;
editingView = editor.editing.view;
plugin = editor.plugins.get( ImageBalloon );
view = new View();
view.template = new Template( { tag: 'div' } );
view.init();
} );
} );
return toWidget( viewWriter.createContainerElement( 'table' ), viewWriter );
}
} );
editor.conversion.for( 'downcast' ).elementToElement( { model: 'tableRow', view: 'tr' } );
editor.conversion.for( 'downcast' ).elementToElement( {
model: 'tableCell',
view: ( modelItem, viewWriter ) => {
return toWidgetEditable( viewWriter.createEditableElement( 'td' ), viewWriter );
}
} );
}
}
ClassicEditor
.create( global.document.querySelector( '#editor' ), {
plugins: [ Enter, Typing, Paragraph, SelectionTest, Undo, Widget ],
toolbar: [ 'undo', 'redo' ]
} )
.then( editor => {
editor.model.document.on( 'change', () => {
printModelContents( editor );
} );
printModelContents( editor );
} )
.catch( err => {
console.error( err.stack );
} );
const modelDiv = global.document.querySelector( '#model' );
beforeEach( () => {
editorElement = global.document.createElement( 'div' );
global.document.body.appendChild( editorElement );
return ClassicTestEditor
.create( editorElement, {
plugins: [ Image, ImageStyle ]
} )
.then( newEditor => {
editor = newEditor;
} );
} );
beforeEach( () => {
dropdown = editor.ui.componentFactory.create( 'testColor' );
dropdown.render();
documentColorsModel = dropdown.colorTableView.documentColors;
global.document.body.appendChild( dropdown.element );
} );
afterEach( () => {
beforeEach( () => {
editorElement = global.document.createElement( 'div' );
global.document.body.appendChild( editorElement );
return ClassicTestEditor
.create( editorElement, {
plugins: [ ImageTextAlternativeEditing, ImageTextAlternativeUI, Image, Paragraph ]
} )
.then( newEditor => {
editor = newEditor;
model = editor.model;
doc = model.document;
newEditor.editing.view.attachDomRoot( editorElement );
plugin = editor.plugins.get( ImageTextAlternativeUI );
command = editor.commands.get( 'imageTextAlternative' );
form = plugin._form;
balloon = editor.plugins.get( 'ContextualBalloon' );
button = editor.ui.componentFactory.create( 'imageTextAlternative' );
beforeEach( () => {
editorElement = global.document.createElement( 'div' );
global.document.body.appendChild( editorElement );
return ClassicTestEditor
.create( editorElement, {
plugins: [ MediaEmbed, AutoMediaEmbed, Link, List, Bold, Typing, Image, ImageCaption ]
} )
.then( newEditor => {
editor = newEditor;
} );
} );