@ckeditor/ckeditor5-editor-inline
Advanced tools
Comparing version 12.0.0 to 12.1.0
Changelog | ||
========= | ||
## [12.1.0](https://github.com/ckeditor/ckeditor5-editor-inline/compare/v12.0.0...v12.1.0) (2019-04-10) | ||
### Features | ||
* Introduced `EditorConfig#initialData`. ([59e97b5](https://github.com/ckeditor/ckeditor5-editor-inline/commit/59e97b5)) | ||
## [12.0.0](https://github.com/ckeditor/ckeditor5-editor-inline/compare/v11.0.2...v12.0.0) (2019-02-28) | ||
@@ -5,0 +12,0 @@ |
{ | ||
"name": "@ckeditor/ckeditor5-editor-inline", | ||
"version": "12.0.0", | ||
"version": "12.1.0", | ||
"description": "Inline editor implementation for CKEditor 5.", | ||
@@ -12,16 +12,15 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^12.0.0", | ||
"@ckeditor/ckeditor5-engine": "^13.0.0", | ||
"@ckeditor/ckeditor5-theme-lark": "^13.0.0", | ||
"@ckeditor/ckeditor5-ui": "^12.0.0", | ||
"@ckeditor/ckeditor5-utils": "^12.0.0", | ||
"@ckeditor/ckeditor5-core": "^12.1.0", | ||
"@ckeditor/ckeditor5-engine": "^13.1.0", | ||
"@ckeditor/ckeditor5-ui": "^12.1.0", | ||
"@ckeditor/ckeditor5-utils": "^12.1.0", | ||
"lodash-es": "^4.17.10" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^11.0.0", | ||
"@ckeditor/ckeditor5-enter": "^11.0.0", | ||
"@ckeditor/ckeditor5-heading": "^11.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^11.0.0", | ||
"@ckeditor/ckeditor5-typing": "^12.0.0", | ||
"@ckeditor/ckeditor5-undo": "^11.0.0", | ||
"@ckeditor/ckeditor5-basic-styles": "^11.1.0", | ||
"@ckeditor/ckeditor5-enter": "^11.0.1", | ||
"@ckeditor/ckeditor5-heading": "^11.0.1", | ||
"@ckeditor/ckeditor5-paragraph": "^11.0.1", | ||
"@ckeditor/ckeditor5-typing": "^12.0.1", | ||
"@ckeditor/ckeditor5-undo": "^11.0.1", | ||
"eslint": "^5.5.0", | ||
@@ -28,0 +27,0 @@ "eslint-config-ckeditor5": "^1.0.11", |
@@ -21,2 +21,3 @@ /** | ||
import { isElement } from 'lodash-es'; | ||
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror'; | ||
@@ -103,6 +104,10 @@ /** | ||
/** | ||
* Creates an inline editor instance. | ||
* Creates a new inline editor instance. | ||
* | ||
* Creating an instance when using a {@glink builds/index CKEditor build}: | ||
* There are three general ways how the editor can be initialized. | ||
* | ||
* # Using an existing DOM element (and loading data from it) | ||
* | ||
* You can initialize the editor using an existing DOM element: | ||
* | ||
* InlineEditor | ||
@@ -117,17 +122,16 @@ * .create( document.querySelector( '#editor' ) ) | ||
* | ||
* Creating an instance when using CKEditor from source (make sure to specify the list of plugins to load and the toolbar): | ||
* The element's content will be used as the editor data and the element will become the editable element. | ||
* | ||
* import InlineEditor from '@ckeditor/ckeditor5-editor-inline/src/inlineeditor'; | ||
* import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; | ||
* import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; | ||
* import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; | ||
* import ... | ||
* # Creating a detached editor | ||
* | ||
* Alternatively, you can initialize the editor by passing the initial data directly as a `String`. | ||
* In this case, the editor will render an element that must be inserted into the DOM for the editor to work properly: | ||
* | ||
* InlineEditor | ||
* .create( document.querySelector( '#editor' ), { | ||
* plugins: [ Essentials, Bold, Italic, ... ], | ||
* toolbar: [ 'bold', 'italic', ... ] | ||
* } ) | ||
* .create( '<p>Hello world!</p>' ) | ||
* .then( editor => { | ||
* console.log( 'Editor was initialized', editor ); | ||
* | ||
* // Initial data was provided so the editor UI element needs to be added manually to the DOM. | ||
* document.body.appendChild( editor.ui.element ); | ||
* } ) | ||
@@ -138,17 +142,15 @@ * .catch( err => { | ||
* | ||
* Creating an instance when using the initial data instead of a DOM element: | ||
* This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your | ||
* web page content is generated on the client-side and the DOM structure is not ready at the moment when you initialize the editor. | ||
* | ||
* import InlineEditor from '@ckeditor/ckeditor5-editor-inline/src/inlineeditor'; | ||
* import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; | ||
* import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; | ||
* import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; | ||
* import ... | ||
* # Using an existing DOM element (and data provided in `config.initialData`) | ||
* | ||
* You can also mix those two ways by providing a DOM element to be used and passing the initial data through the config: | ||
* | ||
* InlineEditor | ||
* .create( '<p>Hello world!</p>' ) | ||
* .create( document.querySelector( '#editor' ), { | ||
* initialData: '<h2>Initial data</h2><p>Foo bar.</p>' | ||
* } ) | ||
* .then( editor => { | ||
* console.log( 'Editor was initialized', editor ); | ||
* | ||
* // Initial data was provided so `editor.element` needs to be added manually to the DOM. | ||
* document.body.appendChild( editor.element ); | ||
* } ) | ||
@@ -159,16 +161,36 @@ * .catch( err => { | ||
* | ||
* This method can be used to initialize the editor on an existing element with specified content in case if your integration | ||
* makes it difficult to set the content of the source element. | ||
* | ||
* Note that an error will be thrown if you pass initial data both as the first parameter and also in the config. | ||
* | ||
* # Configuring the editor | ||
* | ||
* See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about | ||
* customizing plugins, toolbar and other. | ||
* | ||
* # Using the editor from source | ||
* | ||
* The code samples listed in the previous sections of this documentation assume that you are using an | ||
* {@glink builds/guides/overview editor build} (for example – `@ckeditor/ckeditor5-build-inline`). | ||
* | ||
* If you want to use the inline editor from source (`@ckeditor/ckeditor5-editor-inline/src/inlineeditor`), | ||
* then you need to define the list of | ||
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and | ||
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from | ||
* source in the {@glink builds/guides/integration/advanced-setup "Advanced setup" guide}. | ||
* | ||
* @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor | ||
* (on which the editor will be initialized) or the initial data for the editor. | ||
* or the editor's initial data. | ||
* | ||
* If a source element is passed, then its contents will be automatically | ||
* {@link module:editor-inline/inlineeditor~InlineEditor#setData loaded} to the editor on startup and the element | ||
* itself will be used as the editor's editable element. | ||
* If a DOM element is passed, its content will be automatically loaded to the editor upon initialization. | ||
* Moreover, the editor data will be set back to the original element once the editor is destroyed. | ||
* | ||
* If data is provided, then `editor.element` will be created automatically and needs to be added | ||
* to the DOM manually. | ||
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration. | ||
* @returns {Promise} A promise resolved once the editor is ready. | ||
* The promise returns the created {@link module:editor-inline/inlineeditor~InlineEditor} instance. | ||
* If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually. | ||
* It is available under {@link module:editor-inline/inlineeditorui~InlineEditorUI#element `editor.ui.element`} property. | ||
* | ||
* @param {module:core/editor/editorconfig~EditorConfig} [config] The editor configuration. | ||
* @returns {Promise} A promise resolved once the editor is ready. The promise resolves with the created editor instance. | ||
*/ | ||
static create( sourceElementOrData, config ) { | ||
static create( sourceElementOrData, config = {} ) { | ||
return new Promise( resolve => { | ||
@@ -183,6 +205,12 @@ const editor = new this( sourceElementOrData, config ); | ||
.then( () => { | ||
const initialData = isElement( sourceElementOrData ) ? | ||
getDataFromElement( sourceElementOrData ) : | ||
sourceElementOrData; | ||
if ( !isElement( sourceElementOrData ) && config.initialData ) { | ||
// Documented in core/editor/editorconfig.jdoc. | ||
throw new CKEditorError( | ||
'editor-create-initial-data: ' + | ||
'The config.initialData option cannot be used together with initial data passed in Editor.create().' | ||
); | ||
} | ||
const initialData = config.initialData || getInitialData( sourceElementOrData ); | ||
return editor.data.init( initialData ); | ||
@@ -199,1 +227,5 @@ } ) | ||
mix( InlineEditor, ElementApiMixin ); | ||
function getInitialData( sourceElementOrData ) { | ||
return isElement( sourceElementOrData ) ? getDataFromElement( sourceElementOrData ) : sourceElementOrData; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32863
5
533
- Removed@ckeditor/ckeditor5-theme-lark@13.0.1(transitive)