D2 uses VueJS. You should read up on how to pass variables to HTML attributes in the Vue docs. The D2 docs probably also have enough info for this as well.
Yeah, here you are defining a newmsg variable in your data(), whoch overrides the one we build by default.
The best way to set defaults is to inject a message with the values. If you want those defaults everytime you view the page, you have two options:
Wire a ui-event node, which emits an event on every page view. And pass the defaults as a message to this node.
Use Vue's computed variables where you could have a variable color that returns msg.color || 'black'. So, uses the injected color if its defined, otherwise, falls back to the default
Thank you for teaching me this, It was needed. It had not occurred to me to set the defaults like that with a ui-event nodes. Way better for stuff with many variables like the main passion project I've been working on.
Perhaps offtopic, but still relevant i think, could the default template code be modified, so that it includes more examples with the mounted and methods that show how to listen for incoming payload, because grabbing documentation each time is not ideal.
Here i refer to the this.$socket.on('msg-input:...' functions.