First, whenever a form would have multiple markdown preview widgets, the widget's JavaScript would be loaded & initialized multiple times, thereby causing "redeclaration of MarkdownPreview class" errors. This is fixed by attaching the JavaScript separately as part of the widget's Media subclass. (same for the css)
Whenever you would click "new exp/block translated content", a new form would be added dynamically by Djano. However, the newly added MarkdownPreview widget would not be "initialized" or "hydrated" as this process already happened on page load. This meant that the user could not preview the rendered markdown in newly added markdown preview widgets. The script is now extended by observing newly added form inputs and re-initializing all markdown preview widgets whenever that happens.
This PR fixes the following issues:
MarkdownPreview
class" errors. This is fixed by attaching the JavaScript separately as part of the widget'sMedia
subclass. (same for the css)MarkdownPreview
widget would not be "initialized" or "hydrated" as this process already happened on page load. This meant that the user could not preview the rendered markdown in newly added markdown preview widgets. The script is now extended by observing newly added form inputs and re-initializing all markdown preview widgets whenever that happens.