No, I found it in the code of the Rich Text Plugin by Bubble. (see image on first post).
I hear my inner-@keith gesturing snarky obscenities and pointing at the color variables thread. “Not even the ‘safe’ stuff is safe to use.”
Since I’ve got 2 experts here, let me ask you a question: how do you handle the saving of an output? @Thimo , I’ve been studying your Rich Text Editor (ModernJS) plugin’s code, but I haven’t been able to test it. What would happen if I have a page with:
- your rich text editor which gets its initial content from the parent group
- a dropdown that allows me to change the data of that parent group
- a workflow that fires when the editor’s content has changed
- that then makes a change to the parent’s group thing and saves the output to it.
My plugin gets all loopy. It will allow me to type, but if I hit space it resets the content, and a bunch of other unreliable stuff.
Diving into Thimo’s code, I’m wondering if this is your work-around to avoid that. But I need a couple of days of reading and re-reading this to completely grok it (my fault, not yours. I’m slow.)
if (instance.data.initial_data != properties.initial_data && instance.data.initial_data !== null && properties.initial_data !== null && instance.data.editor.blocks !== undefined) {
var blockCount = JSON.parse(properties.initial_data).blocks.length
instance.publishState('total_block_count', blockCount);
if (properties.initial_data !== null && blockCount > 0) {
instance.publishState('saved_data',properties.initial_data)
instance.data.editor.blocks.render(JSON.parse(properties.initial_data))
instance.publishState('saved_data_html', instance.data.edjsParser.parse(JSON.parse(properties.initial_data)).join(' '));
setTimeout(() => {
instance.publishState('saved_data',properties.initial_data)
}, 100)
}
}
instance.data.initial_data = properties.initial_data