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 28
Allow to pass initial data to the editor constructor #38
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0607fcd
Data instead of element in constructor.
szymonkups a28e1f1
Changed manual test text.
szymonkups 5067e6a
Using global import instead of directly accessing document.
szymonkups 21f0c27
Added tests to editor initialized by data.
szymonkups cf3e0c1
Added api docs.
szymonkups a425afb
Removed unused CSS class.
szymonkups 007c87a
Appending editor to the container in data initialization manual test.
szymonkups 3c44112
Fixed typo.
szymonkups faf83c8
Added more docs.
szymonkups cbb9c5e
Minor improvements for the manual test.
1303600
Merge branch 'master' into t/37
Reinmar 6a001e7
Renamed editor.element to editor.sourceElement. Implemented EditorWit…
0be5f78
Merge branch 'master' into t/37
7fd172f
Merge branch 'master' into t/37
fd4ba2d
Editor#sourceElement should be null when an editor was initialized wi…
7c46819
Improved a test description.
3135a7c
Used better variable name.
33d5b26
More API docs polish.
Reinmar 3f27c04
Minor API docs improvement.
Reinmar 6e17bbf
Editor#destroy() will not blow up when editor was initialized with th…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,43 @@ | ||
/** | ||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals console:false, document, window */ | ||
|
||
import InlineEditor from '../../src/inlineeditor'; | ||
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset'; | ||
|
||
window.editors = []; | ||
const container = document.querySelector( '.container' ); | ||
let counter = 1; | ||
|
||
function initEditor() { | ||
InlineEditor | ||
.create( `<h2>Editor ${ counter }</h2><p>This is an editor instance.</p>`, { | ||
plugins: [ ArticlePluginSet ], | ||
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', '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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there's no source element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throws an ugly error. I'm on it.