StackExchange / Stacks-Editor

Stack Overflow's Combination Rich Text / Markdown Editor
https://editor.stackoverflow.design
MIT License
355 stars 46 forks source link

Offer a callback for Content changes #343

Open PJUllrich opened 2 months ago

PJUllrich commented 2 months ago

Hey there, I'm trying to figure out how I can listen to content changes both in the RichTextView and the MarkdownView so that I can use the rendered HTML and update a form field with it. In other frameworks, you can add a callback when instantiating the editor or you can listen to custom events like data:change. I'm struggling to understand how Stacks-Editor allows users to react to state changes really. Would you mind clarifying this part, please?

giamir commented 2 months ago

Currently we don't support that feature out of the box and we cannot guarantee we will implement it any time soon.

If for your use case you need a callback to be executed all the times something changes in the editor I would recommend you to write a simple plugin like this one and pass it as an option when you instantiate the editor (see here).

I will leave this issue open for now since I can see how a more straightforward mechanism to detect user changes in the editor could be useful in various situations.