add `Decoration` object instead of re-using `Range`
See original GitHub issueRight now for value.decorations
we’re re-using the Range
objects, because they refer to two points with marks. But I think there is more we’ll want to do with decorations, and as currently architected any new properties that decorations support have to be added to Range
which is awkward.
Instead, I think we should separate out decorations into their own Decoration
model:
new Decoration({
anchorKey,
anchorOffset,
focusKey,
focusOffset,
marks,
})
This would allow us to add a data
property holding arbitrary end-user data. And a key
property holding a unique identifier to identify the decorations across renders/updates.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Reusing instances of objects vs creating new ones with every ...
Explanations: "reusing": overwriting the values of an old instance with new values, effectively changing the state of the instance. "new ones/ ...
Read more >Primer on Python Decorators
They can be reused. They can decorate functions with arguments and return values. They can use @functools.wraps to look more like the decorated...
Read more >Example: Decorations - CodeMirror
The range method on these objects gives you an actual decorated range, which holds both the type and a pair of from /...
Read more >Create components to reuse in designs - Figma Help Center
You can create components from any layers or objects you've designed. These could be a whole range of things like buttons, icons, layouts,...
Read more >Before You Recycle, Choose to Reuse
This publication for individuals and groups describes how to reduce waste by reusing materials, including clothing and household items.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@zhujinxuan yup, we would introduce a
renderDecoration
prop for rendering them. The difference is that they are applied to ranges of the document without affecting the document’s data directly, versus marks which are applied to the text itself.These are issues I’ve had to work around recently (basically: updating a large set of decorations essentially requires dropping / rebuilding them since no consistent id exists; and we attach data to them but it ends up looking like
decoration.marks[0].data
everywhere, which isn’t pretty). So I think a new type of Object to handle these in a more focused way than Range+Mark sounds great.