Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration guide from v11.2.0 to v12.0.0 #1582

Closed
Reinmar opened this issue Feb 27, 2019 · 0 comments
Closed

Migration guide from v11.2.0 to v12.0.0 #1582

Reinmar opened this issue Feb 27, 2019 · 0 comments
Assignees
Labels
type:docs This issue reports a task related to documentation (e.g. an idea for a guide).
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Feb 27, 2019

Migration guide for CKEditor 5 v12.0.0.

The following are the most important changes and ways to update your code. The list has been split into a section for developers integrating the editor into their systems and a section for plugin authors. However, depending on the CKEditor 5 Framework features that you used you may need to check both sections.

Integration developers

editor.getData() returns an empty string

The editor.getData() method returns an empty string if the editor is empty. If you preferred the old behaviour, then you can use it like this:

editor.getData( { trim: 'none' } ); // -> '<p>&nbsp;</p>'

Modifying editable element attributes

Prior to v12.0.0 the editable attributes could have been changed in various ways. For instance directly via:

editor.ui.view.editable.editableElement.setAttribute( 'spellcheck', 'false' ); // INCORRECT!

Since v12.0.0 the only correct and reliable way to manage editable elements attributes is via the editing view, so, through the engine:

editor.editing.view.change( writer => {
    writer.setAttribute( 'spellcheck', 'false', editor.editing.view.document.getRoot() );
} );

Accessing the editable element

Prior to v12.0.0 you could access the editable element via editor.ui.view.editable.editableElement. The assumption was, therefore, that there's only a single editable element in the entire editor.

Since v12.0.0 the editor UI assumes the existance of multiple editable roots. Therefore, the correct way to access the editable DOM element is via:

editor.ui.getEditableElement( 'editableName' ); // -> Element

However, since all official editors contain just one editable (which is called main like the engine's root), you can access it like this:

editor.ui.getEditableElement(); // -> Element

Main editor UI element

Prior to v12.0.0 you could access the editor's main UI element (its UI container) via editor.element.

Since v12.0.0 that property has been moved to:

editor.ui.element; // -> Element

Image upload adapters

The FileLoader#file property now returns a promise instead of a File object directly. See an example how to modify your upload adapter in: https://github.com/ckeditor/ckeditor5-image/pull/282/files.

Plugin developers

Conversion helpers

The conversion helpers which were available in the @ckeditor/ckeditor5-engine/src/conversion/upcast-converters and @ckeditor/ckeditor5-engine/src/conversion/downcast-converters modules and required importing are now available directly on the for() function.

For instance, prior to v12.0.0:

import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';

// ...

editor.conversion.for( 'upcast' ).add( upcastElementToElement( { view: 'p', model: 'paragraph' } ) );

Since v12.0.0:

editor.conversion.for( 'upcast' ).elementToElement( { view: 'p', model: 'paragraph' } );

You can still use editor.conversion.for( ... ).add() method to define totally custom converters, but the conversion helpers are now available only on the for() object.

Mark your widget as isObject in the schema

All model elements which are represented as widgets in the view should be marked with isObject (and isBlock or isInline) in the schema.

If you see that editor.getData() returns an empty string when your widget is the only content of the editor, then there's a high chance that you forgot to use isObject in its schema definition.

Other changes

@Reinmar Reinmar added status:confirmed type:docs This issue reports a task related to documentation (e.g. an idea for a guide). labels Feb 27, 2019
@Reinmar Reinmar added this to the iteration 22 milestone Feb 27, 2019
@Reinmar Reinmar self-assigned this Feb 27, 2019
@Reinmar Reinmar closed this as completed Mar 5, 2019
skurfuerst added a commit to neos/neos-ui that referenced this issue Jun 15, 2019
If you did use the following statement in your custom UI plugin, this
change is breaking, as UpcastConverters and DowncastConverters is not exported anymore:

`import {UpcastConverters, DowncastConverters} from 'ckeditor5-exports'`

*Background:* CKEditor5 12.x removed this API as explained in their
            [Upgrade Guide in section "Conversion helpers"](ckeditor/ckeditor5#1582)

*How to fix:* Use the new API as described in the upgrade guide of CKEditor5.

*Severity*: Running a search for this on GitHub just shows very few public
            packages affected - so this should be safe for most users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs This issue reports a task related to documentation (e.g. an idea for a guide).
Projects
None yet
Development

No branches or pull requests

1 participant