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

Introduce an elementToStructure and rangeToStructure downcast conversions #9783

Closed
niegowski opened this issue May 28, 2021 · 1 comment
Closed
Assignees
Labels
domain:dx This issue reports a developer experience problem or possible improvement. package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@niegowski
Copy link
Contributor

📝 Provide a description of the new feature

(names of the downcast helpers are yet to be chosen)

Currently, while down-casting model structures to the view structures we rely on the model-view bindings (mappings) so the children of some model element are inserted as children of the bound view element. But sometimes we need to be able to indicate where some model element children should be placed after conversion.

For example for tables:

<table headingRows="1"></table>

This could be handled by the conversion as specifying a template:

<figure class="table">
	<table>
		<thead>
			<$slot for-children={ child.name == 'tableRow' && child.index < getAttribute( 'headingRows' ) }/>
		</thead>
		<tbody>
			<$slot for-children={ child.name == 'tableRow' && child.index >= getAttribute( 'headingRows' ) }/>
		</tbody>
	</table>
</figure>

The tableRows would be converted by dedicated elementToElement converters. 

This way we could use triggerBy API for headingRows attribute to reconvert only the table-thead-tbody structure without reconverting the whole table.

This would be also helpful for document/advanced lists. For example for such model structure:

<paragraph listItem="a" listIndent="0">A</paragraph>
<paragraph listItem="a" listIndent="0">B</paragraph>
<paragraph listItem="b" listIndent="0">C</paragraph>
<paragraph listItem="c" listIndent="1">D</paragraph>
<paragraph listItem="c" listIndent="1">E</paragraph>
<paragraph listItem="d" listIndent="1">F</paragraph>
<paragraph listItem="b" listIndent="0">G</paragraph>

We could generate:

<ul>
	<li>
		<$slot for-element={ paragraph with A }/>
		<$slot for-element={ paragraph with B }/>
	</li>
	<li>
		<$slot for-element={ paragraph with C }/>
		<ul>
			<li>
				<$slot for-element={ paragraph with D }/>
				<$slot for-element={ paragraph with E }/>
			</li>
			<li>
				<$slot for-element={ paragraph with F }/>
			</li>
		</ul>
		<$slot for-element={ paragraph with G }/>
	</li>
</ul>

So for the triggerBy range API we could reconvert only the ul-li structure and reuse the view of the content (paragraphs or other blocks inside those list items)


If you'd like to see this feature implemented, add a 👍 reaction to this post.

@niegowski niegowski added type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:engine domain:dx This issue reports a developer experience problem or possible improvement. squad:dx labels May 28, 2021
@niegowski niegowski added this to the iteration 44 milestone May 28, 2021
@niegowski niegowski self-assigned this May 28, 2021
@Mgsy Mgsy modified the milestones: iteration 44, Iteration 45 Jul 1, 2021
@niegowski
Copy link
Contributor Author

Work on this issue will be handled here: #10054

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

No branches or pull requests

2 participants