-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Custom inline element disappear after setData() if it is the only or first element in tableCell #6698
Comments
Hi! There are a couple of things that I spotted that can cause issues:
IDK if any of these is the reason of your problems, but you could try resolving them and see. |
I also encountered a similar problem. I made a placeholder example on the documentation: Insert a placeholder in the table: Then I saved the data and reload it into the editor: If insert a space before the placeholder, everything will be OK: |
Fix (engine): Upcast conversion will now try to wrap text and inline elements in paragraph if such content is converted in a place where is not allowed but a paragraph is allowed. Closes #7753. Closes #6698. Internal (paragraph): Auto-paragraphing content conversion moved to the engine package. Tests (table): Added tests for upcasting inline elements inside a table cell.
We fixed the problem and the patch will be included in the next release (planned around the end of August). Thanks! |
@Reinmar great news, thank you for the work put into this ! Looking forward to this. |
I happen to be working with the older Ckeditor version 16 (this bug was fixed with 22) and i cant upgrade. just add this as a fix and i think youre good to go ;) /**
* "Decorates" splitToAllowedParent() to extend it with auto-paragraphing
*
* CkEditor before v22 has this bug: https://github.com/ckeditor/ckeditor5/issues/6698, https://github.com/ckeditor/ckeditor5/issues/7753
*
* to fix it we use the second proposal of https://github.com/ckeditor/ckeditor5/issues/7753
* which was implemented as WIP here https://github.com/ckeditor/ckeditor5/pull/7787/commits/56ff10c5e9cc24f3c3397a97f7927c1708e00581#diff-fa5058ba57a9a2b39fb0d473a22492bff2b09abe2b2bb63c15629e75fb05215fR73-R95
*/
_fixUpcastConversionAndAutoParagraphing() {
// https://github.com/ckeditor/ckeditor5/blob/56ff10c5e9cc24f3c3397a97f7927c1708e00581/packages/ckeditor5-paragraph/src/paragraph.js#L210
const isParagraphable = ( node, position, schema ) => {
const context = schema.createContext( position );
// When paragraph is allowed in this context...
if ( !schema.checkChild( context, 'paragraph' ) ) {
return false;
}
// And a node would be allowed in this paragraph...
if ( !schema.checkChild( context.push( 'paragraph' ), node ) ) {
return false;
}
return true;
}
const conversionApi = this.editor.data.upcastDispatcher.conversionApi;
const originalSplitToAllowedParent = conversionApi.splitToAllowedParent;
conversionApi.splitToAllowedParent = ( node, modelCursor ) => {
const result = originalSplitToAllowedParent( node, modelCursor );
if ( result ) {
return result;
}
if ( !isParagraphable( node, modelCursor, conversionApi.schema ) ) {
return null;
}
const paragraph = conversionApi.writer.createElement( 'paragraph' );
conversionApi.writer.insert( paragraph, modelCursor );
return {
position: conversionApi.writer.createPositionAt( paragraph, 0 )
};
};
} Edit: i just run the ckeditor test suite with this fix in version 21 and it works perfectly |
I target to create a plugin to insert FontAwesome icon to the editor.
(I understand this is not a bug, but my lack of knowledge on the editor, anyhow when creating the ticket "bug" was the closest option from the list.)
Code
I took reference from the horizontal rule plugin, everything worked fine until I saved the data and reloaded it into the editor.
The icon was not showing up.
upcast() was called, model element returned, but the element did not appear.
I looked into table cell, and realized that table cell accept only block element.
I cannot find any example of putting inline element inside table cell.
However, if I pad an empty space before the icon, it can display properly, with the padded space of course.
✔️ Expected result
The inline icon appears in the table cell after setData()
❌ Actual result
Nothing shows up in the table cell
📃 Other details
The text was updated successfully, but these errors were encountered: