-
-
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
#8959 DowncastWriter should handle UIElements consistently while wrapping and inserting #8998
Conversation
Out of curiosity: can we make the bold feature work in this case https://ckeditor.com/docs/ckeditor5/latest/framework/guides/tutorials/implementing-an-inline-widget.html#demo? I'd like it to generate (i.e. the strong is added outside the placeholder): <p>xxx <strong><placeholder>text</placeholder></strong></p> I think it comes from: #1633. |
I updated the PR to properly handle this case. Steps that are required:
const widgetElement = writer.createContainerElement( 'placeholder', null, { isInline: true } );
const attributes = model.document.selection.getAttributes();
const placeholder = writer.createElement( 'placeholder', {
...Object.fromEntries( attributes ),
type: 'placeholder'
} ); Also, I noticed that the only inline element that we currently support ( |
} | ||
// Break attributes on nodes that do exist in the model tree so they can have attributes, other elements | ||
// can't have an attribute in model and won't get wrapped with an AttributeElement while down-casted. | ||
const breakAttributes = !node.is( 'uiElement' ); |
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.
I'm not sure if this should not include rawElement
also.
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.
But OTOH we could use RawElement
(instead of UIElement
) for suggestions in TC.
Notes from a call with @scofalik and @niegowski :
|
If we go with the property – is it automatically copied when you clone an element? And the second thing – what should be the default value of this property for UI/Raw/Empty elements? "allow in attr elements" seem safe and fine in this case. |
I missed that part - I'll add it. Also, I should update
I think that it should trigger the same behavior as the current implementation to replace |
I think that we should use some property to indicate |
After changing the opinion many times already, I'd go with the most specific If we'll ever have to have a more general Also, please make sure to mention that property in Finally, we may consider allowing passing |
Co-authored-by: Piotrek Koszuliński <pkoszulinski@gmail.com>
Ready for another review round. |
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.
I'm missing some tests for the element classes themselves. There are test for create* methods in the DW, but the changes actually affected the element classes and it'd be good to cover that too.
Also, @scofalik could you review changes in the downcast writer? I checked all other files.
I added more tests. |
Suggested merge commit message (convention)
Fix (engine):
DowncastWriter
should handleUIElement
s consistently while wrapping and inserting. Closes #8959.Feature (engine):
ContainerElement
could be marked asisAllowedInsideAttributeElement
and get wrapped with anAttributeElement
. Closes #1633.Additional information
This change introduces a view
Element
propertyisAllowedInsideAttributeElement
(in the same fashion aspriority
onAttributeElement
) to specify the element behavior while being wrapped with anAttributeElement
. Also, it does not break attributes while inserting elements that are not present in the model (UIElement
, probably should handleRawElement
in the same way).