-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Allow defining target in attributeToAttrbibute conversion helpers #2061
Comments
BTW, another addition to the conversion API that people are missing is #1589. |
I wonder how this API could look like and if we should somehow restrict it. Let's assume someone would go crazy and convert this Now if we assume that the intended way of using this API is to point to a know inner child we might simplify it by:
The idea behind 1/2 is such: editor.conversion.for( 'downcast' ).attributeToAttribute( {
model: 'id',
view: 'id',
// 1.
viewTarget: 'img'
// or 1.
viewTarget: {
name: 'img',
classes: 'foo bar' // or whatever the API is...
}
// or 2.
viewTarget: viewChild => viewChild.is( 'img' )
} ); I think that such API might be a bit simpler and in line with other options that conversion API provides for defining view elements. Internally this could be a treewalker that iterates over the viewElement children (whole tree) (the mapped view element from the model element that holds this attribute). The only problem I see in the above is how to restrict the depth of a search? Immediate children solves only Bottom line it looks like simple addition and I don't see potential risks but @scofalik may have additonal points to make here. |
This issue affects #6325. |
Callback which gets the parent element and lets you return whatever you want. No more magic and no more options. All other options, such as flat or deep search with mapper or a callback should be available in the view element API. This way these methods will be reusable in other places. |
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may be relevant, so if you're interested in the solution, leave a comment or reaction under this issue. |
We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it). |
Typical problem – model and view structures don't match one another. Example:
If you want to write a converter for let's say an
id
attribute that should be added on<img>
a simple use ofattributeToAttribute()
will not work as expected, because the attribute will end up in the<figure>
. That's because<image>
is mapped to<figure>
.It's possible to work around this by using lower-level, event-based mechanism. You can find the solution here: https://github.com/ckeditor/ckeditor5-core/compare/poc/customfigureattributes
However, I think we can easily resolve this by adding
viewTarget
property:I'm not sure if upcast conversion requires a similar mechanism, but it's worth checking.
The text was updated successfully, but these errors were encountered: