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 method to easily "clone" element with children to model writer. #6819

Closed
jodator opened this issue May 14, 2020 · 3 comments · Fixed by #7373
Closed

Introduce method to easily "clone" element with children to model writer. #6819

jodator opened this issue May 14, 2020 · 3 comments · Fixed by #7373
Assignees
Labels
package:engine type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@jodator
Copy link
Contributor

jodator commented May 14, 2020

📝 Provide a description of the new feature

In some copy/paste scenarios there's a need to copy elements along with its attributes and with children.

I'd propose a new method:

writer.copyElement( element ); // Copies this element with its attributes.
writer.copyElement( element, { deep: true } ); // As above but with children.

That will create a shallow or deep copy of given element. The rationale behind object is that this might be later on enhanced and also simple true/false is hard to remember in code.

ps.: ATM we have private Element._clone() but this is not a good way of doing this.


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

@jodator jodator added type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:engine squad:red labels May 14, 2020
@scofalik
Copy link
Contributor

I think that cloneElement will be a better name - I'd guess people are more used to "cloning".

@Reinmar
Copy link
Member

Reinmar commented May 14, 2020

Agree – cloneElement() sounds more "common".

@Reinmar Reinmar added this to the nice-to-have milestone May 18, 2020
@jodator
Copy link
Contributor Author

jodator commented Jun 3, 2020

AFAIR it should also land on model isntance. Let's follow createElement() pattern here - so only on writer.

@jodator jodator modified the milestones: nice-to-have, iteration 33 Jun 3, 2020
jodator added a commit that referenced this issue Jun 4, 2020
Other (engine): Added Writer#cloneElement(). Closes #6819.

Internal (table): Replaced Element._clone() usages with Writer#cloneElement().
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
Development

Successfully merging a pull request may close this issue.

4 participants