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

Suggestion: move everything related to indent and format to plugins or packages #4528

Open
GermanJablo opened this issue May 22, 2023 · 0 comments
Labels
enhancement Improvement over existing feature

Comments

@GermanJablo
Copy link
Contributor

  1. The indent and format properties should not be unique to all ElementNodes. Nodes like RootNode, LinkNode, or MarkNode unnecessarily expose those properties, methods, and serialized properties.

  2. The format and especially the indentations are subject to many opinions. Some examples:

    • Should there be a maximum level of indentation?
    • If in the selection there are some nodes with the minimum or maximum level of indentation, should the others be able to be indented/outdented?
    • Which nodes should be indented or formatted and which should not? For example, what should happen to Code, Table, or DecoratorNodes? Should the alignment be applied on the ListNode or on its ListItems?
    • Should backspace at the beginning of a listItem do outdent? Or 'enter' on an empty listItem?

    If the logic about format and indents are in the same place, it is much easier for each user to customize the behavior to their liking.

  3. The reconciler doesn't seem like the right place to modify the DOM element for these two properties. It could be achieved with createDOM, simplifying the reconciler and using the API it was designed for.

  4. The code would be cleaner. There are many edge cases to consider and having things related to indent and format scattered throughout the packages makes it more difficult to modify and debug the code.

  5. It would be a good learning resource. There is currently no example in the playground of how to add properties and methods to many nodes at once. It is very plausible that users want to do this with properties like collapse, color, etc. They do not have the ability to extend ElementNode or modify the reconcile.


I could help with this. I've been experimenting with ways to extend many nodes with the same properties (1) using the mixin pattern or (2) by modifying the node prototype. One of the things I still have to work on though is getting good type-safety, but this change would be very challenging so I'd like to hear your thoughts on it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement over existing feature
Projects
None yet
Development

No branches or pull requests

1 participant