How do I get the elementRoot of a ChatMessage?
SvelteApplication provides
elementRoot
prop to components that implement it, which is very useful. I'm looking to get something similar for my Svelte chat message templates.
I'm using this in index.js
SurgeRoll.svelte does this:
The svelte:component is the component in which I want to get hold of that root element. Specifically I want to be able to do something like:
... which I'm currently using successfully in my SvelteApplication ActorSheet component.4 Replies
elementRoot
is a prop of the component ApplicationShell
, so you are in full control with your own components for chat messages.Ok I don't understand what
ApplicationShell
has to do with the above? (Nor where to find it)It doesn't and you are not using it in this case. If you are not using it there is no
elementRoot
to bind.
I suggest though that you check out the applyStyles
action from @typhonjs-fvtt/runtime/svelte/action
This import will change in the coming release.
Unfortunately I don't have time right now to have a lengthy discussion. I need to finish this release up absolutely by tomorrow.Thanks I managed to get it working using style-props for the Chat Message: https://svelte.dev/docs/component-directives#style-props
However, I've been looking at
applyStyles
within the context of Application Shell
and haven't quite figured out how to get it to apply the styles.
I tried:
and then
And I can see that the value is reaching ApplicationShell's props but it's not populating to the rendered style property for the app.
Maybe it's the wrong type. Should be an object I guess.
Yup! That did it 🙂