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

downcastAttributeToElement does not support downcasting from specified model element #4321

Closed
scofalik opened this issue Mar 19, 2018 · 3 comments · Fixed by ckeditor/ckeditor5-engine#1373
Assignees
Labels
package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Milestone

Comments

@scofalik
Copy link
Contributor

downcastAttributeToAttribute converter lets us specify from which model element the attribute is converted. This is an example configuration:

downcastAttributeToAttribute( {
	model: {
		name: 'image',
		key: 'source'
	},
	view: 'src'
} );

In this case, source attribute is converted only from images.

The same is not possible with downcastAttributeToElement. There are two things we can do now:

  1. Assume that this kind of conversion always happens for $text. This is quite a rational assumption given that the converter uses wrap converter which is meant to wrap parts of view in AttributeElement. I don't know if there's any other real case. Maybe if we will add inline elements or something.

  2. Provide support for name in config.

@scofalik scofalik self-assigned this Mar 19, 2018
@pjasiun
Copy link

pjasiun commented Mar 20, 2018

2

@Reinmar
Copy link
Member

Reinmar commented Mar 20, 2018

What will this converter do? What kind of element will it create and what's the use case in general?

@scofalik
Copy link
Contributor Author

scofalik commented Mar 20, 2018

It doesn't matter what kind of element will it create because we are talking here about model part of config, so about the part that is converted (and consumed).

In short, we are deciding whether we should give control over the event name to which the converter will be added. It could be attribute:attrName or attribute:attrName:elementName. In the second case, only attrName set on elementName will be converted.

We could also hardcode $text in the place of elementName, but then the inline features (like for example smileys) would not be wrapped (so a smiley might break a link, for example). So we should definitely go with solution 2. as it is future-proof.

We'd like following to work (suppose thereotical smiley plugin):

<$text linkHref="foo.html>foo</$text>
<smiley name="smile" linkHref="foo.html"></smiley>
<$text linkHref="bar.html">bar</$text>

🔽

<a href="foo.html>foo<img src="smile.jpg"></img>bar</a>

So we cannot hardcode that attributeToElement conversion is only for $text.

jodator referenced this issue in ckeditor/ckeditor5-engine Mar 21, 2018
Fixed: conversion.downcast-converters.downcastAttributeToElement should let specify from what element the model attribute will be converted. Closes #1370.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-engine Oct 9, 2019
@mlewand mlewand added this to the iteration 15 milestone Oct 9, 2019
@mlewand mlewand added module:conversion type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:engine labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
4 participants