This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from ckeditor/t/72
Feature: Editor can now be created with initial data passed to the `create()` method. Closes #72. BREAKING CHANGE: The `ClassicEditor#element` property was renamed to `ClassicEditor#sourceElement`. See ckeditor/ckeditor5-core#64.
- Loading branch information
Showing
6 changed files
with
207 additions
and
20 deletions.
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 characters
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 characters
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<p> | ||
<button id="destroyEditors">Destroy editors</button> | ||
<button id="initEditor">Init editor</button> | ||
</p> | ||
|
||
<div class="container"></div> | ||
|
||
<style> | ||
body { | ||
width: 10000px; | ||
height: 10000px; | ||
} | ||
|
||
.container { | ||
padding: 20px; | ||
width: 500px; | ||
} | ||
</style> |
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals console:false, document, window */ | ||
|
||
import ClassicEditor from '../../src/classiceditor'; | ||
import Enter from '@ckeditor/ckeditor5-enter/src/enter'; | ||
import Typing from '@ckeditor/ckeditor5-typing/src/typing'; | ||
import Heading from '@ckeditor/ckeditor5-heading/src/heading'; | ||
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; | ||
import Undo from '@ckeditor/ckeditor5-undo/src/undo'; | ||
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; | ||
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; | ||
|
||
window.editors = []; | ||
let counter = 1; | ||
|
||
const container = document.querySelector( '.container' ); | ||
|
||
function initEditor() { | ||
ClassicEditor | ||
.create( `<h2>Hello world! #${ counter }</h2><p>This is an editor instance.</p>`, { | ||
plugins: [ Enter, Typing, Paragraph, Undo, Heading, Bold, Italic ], | ||
toolbar: [ 'heading', '|', 'bold', 'italic', 'undo', 'redo' ] | ||
} ) | ||
.then( editor => { | ||
counter += 1; | ||
window.editors.push( editor ); | ||
container.appendChild( editor.element ); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
} | ||
|
||
function destroyEditors() { | ||
window.editors.forEach( editor => { | ||
editor.destroy() | ||
.then( () => { | ||
editor.element.remove(); | ||
} ); | ||
} ); | ||
window.editors = []; | ||
counter = 1; | ||
} | ||
|
||
document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor ); | ||
document.getElementById( 'destroyEditors' ).addEventListener( 'click', destroyEditors ); |
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1. Click "Init editor". | ||
2. New editor instance should be appended to the document with initial data in it. You can create more than one editor. | ||
3. After clicking "Destroy editor" all editors should be removed from the document. |
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 characters