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

Add a feature to Tree that allows the removal of attributes from elements #626

Closed
hackerwins opened this issue Aug 23, 2023 · 1 comment
Closed
Labels
enhancement 🌟 New feature or request good first issue 🐤 Good for newcomers sdk ⚒️

Comments

@hackerwins
Copy link
Member

hackerwins commented Aug 23, 2023

What would you like to be added:

Add a feature to Tree that allows the removal of attributes from elements

Our objective in developing Tree is to create a data structure capable of representing tree-based models for WYSIWYG Editors.

root.tree = new Tree({
  type: 'doc',
  children: [{
    type: 'p',
    attributes: { bold: true },
    children: [{ type: 'text', value: 'hello' }],
  }],
});
assert.equal(root.tree.toXML(), `<doc><p bold="true">hello</p></doc>`);

Currently, users can modify attributes of elements using Tree.style:

root.t.style(0, 1, { italic: true });
assert.equal(root.tree.toXML(), `<doc><p bold="true" italic="true">hello</p></doc>`);

However, the current interface lacks a method for removing attributes from elements. As a workaround, users resort to setting attributes to false values like null or undefined. This approach can lead to confusion, especially in projects where multiple versions are maintained using Yorkie.

To address this issue, we could introduce a dedicated interface for removing attributes. This would enhance clarity and user experience across different implementations.

root.t.removeStyle(0, 1, 'italic');

Why is this needed:

@hackerwins
Copy link
Member Author

This issue has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request good first issue 🐤 Good for newcomers sdk ⚒️
Projects
Status: Done
Development

No branches or pull requests

2 participants