jkomoros / card-web

The web app behind thecompendium.cards
Apache License 2.0
56 stars 8 forks source link

Refactor contenteditable/selection #91

Open jkomoros opened 5 years ago

jkomoros commented 5 years ago

Related to #55

jkomoros commented 5 years ago

selection states can only be listened for changes at the document level, but the selection within a shadow root is hidden from outside.

In addition, the card-editor is in a different shadow root from where the content-editable portions might be, like the body section of content-card.

The current solution is that things like content-card calle reportSelection when the selection changes and there's a selection in themselves.

Ideally that reportSelection behavior would be a mixin that any elements can do.

Also ideally card-editor woudl have a direct link back to the content-editable regions that are affiliated with it, so it can for example check before doing exec commands that a selection is inside that element before doing esxec command, and then the card-editor can be fully presonisible for issuing all execCommands--and issuing them from any other location doesn't have to be done.