webvs
webvs copied to clipboard
Add Comment component
See previous discussion on #41. (Branch typo fixed, hence new PR)
I agree with your arguments. I'm not suggesting that we don't support comment component at all. I think we might want to handle unsupported components similarly ie. have them in the component tree but be inert in the rendering. So that you can still use (from the editor for e.g.) the component tree manipulation methods addComponent
detachComponent
etc. to move these inert components around in the tree, but still have no effect in the rendering.
So what i suggest is this:
- create a new
Inert
component class that doesn't do anything. Very similar to the Comment class you have right now, but with no concrete options interface. -
Here in Container.ts when a component class is not found, in addition to the warning we'll create an
Inert
component with given options and insert into tree as usual. - create a new
Comment
component class that inherits fromInert
and has the Comment options interface. -
Here in Effectlist.ts add an extra check for
!(component instanceof Inert)
to skip drawing for inert components as well.
That makes perfect sense.This way seems the best. Should I do it, or will you? I'm not 100% sure how to do the Inert
subclass, but could figure it out for sure.
If you're up for it. You can just continue adding to this PR, you already have most of it. Happy to help if you have any questions.
I tried to write a unit test for either Inert
or Comment
but couldn't quickly figure out how to check that draw()
would not be called, since the test already fails (rightly so) on the call to init()
.
Ah I screwed up again. I'll just not have init()
throw an error, but just be empty.