-
-
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
Table properties crashes in some pasting scenarios #6177
Comments
I can reproduce it. |
Is it a regression? Is it reproducible on a normal table demo (without table styles)? |
@Reinmar it's not reproducible when table properties plugin is not enabled.
|
The problem comes down to nested tables. The minimal HTML to paste is: <table style="border: 3px solid green;">
<tbody>
<tr>
<td>parent:00</td>
<td>
<table style="border: 3px solid red;">
<tbody>
<tr>
<td>child:00</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table> The converter for table border style fails because when I see 2 solutions since we don't support nested tables:
diff --git a/src/converters/tableproperties.js b/src/converters/tableproperties.js
index 34a9719..ab2b6c3 100644
--- a/src/converters/tableproperties.js
+++ b/src/converters/tableproperties.js
@@ -60,6 +60,10 @@ export function upcastBorderStyles( conversion, viewElementName ) {
return;
}
+ if ( !data.modelRange ) {
+ data = Object.assign( data, conversionApi.convertChildren( data.viewItem, data.modelCursor ) );
+ }
+
const modelElement = [ ...data.modelRange.getItems( { shallow: true } ) ].pop();
conversionApi.consumable.consume( data.viewItem, matcherPattern ); I'd rather go with the later. Do you have any idea what's the right solution, @Reinmar? |
I can never remember why modelRange can be null. It's not the first time we have this issue and not the first time we have to copy that fragment of code. But it seems to work in other cases so if it solves this one, then let's do this. As for whether we support nested tables – not officially :D But we know that it worked so far if someone was enabling nested tables in the schema. |
I created a PR. Let's find out how it performs. |
Fix: Table border styles conversion handler should not throw when it approaches a nested table. Closes ckeditor/ckeditor5#6177.
📝 Provide detailed reproduction steps (if any)
✔️ Expected result
Content is pasted.
❌ Actual result
Exception is being thrown (Chrome):
Exception for Firefox:
📃 Other details
It works fine with the table plugin alone, when no table properties are enabled.
master
If you'd like to see this fixed sooner, add a 👍 reaction to this post.
The text was updated successfully, but these errors were encountered: