We have an issue with events custom tags and the new WYSIWYG ProseMirror editor: custom fields filled from the event form are not present in the generated string. It still works as before with the markdown editor.
Steps to reproduce:
Enable the Discourse Calendar plugin
Add one custom field in plugin configuration
Open a form for a new Post
Select the ProseMirror editor
Create an event with a value for the custom field (Options > Create Event)
Validate the event
Switch to Markdown editor
What is happening
The custom field is absent from the [event] tag.
What is expected
The custom field should be present in the [event] tag.
Notes
When doing the same but starting with the Markdown editor instead of ProseMirror, the custom field is present in the [event] tag.
I investigated a bit what was happening with the toolbarEvent when validating the new event: addText() method seems to receive in both cases the right markup:
I can’t find another plugin with the same feature, so it’s hard to find what’s wrong.
When validating the form, it calls this.args.model.toolbarEvent.addText() with the right text.
A few console.log™ lead me to : text-manipulation.js#addText() where this.convertFromMarkdown(text) gets called. It seems that the issue comes from here : there is a kind of schema enforced, and it does not contains the custom fields.
The issue comes from the editor extension discourse-calendar/assets/javascripts/discourse/pre-initializers/rich-editor-extension.js : the list of attributes used by convertFromMarkdown() is defined in the EVENT_ATTRIBUTES constant. It works when adding the custom field to the list.
There is nothing about custom fields in this file; I have no idea on how to complete this constant with all the custom fields; the extension seems to get registered early in the process.
Any idea welcome, it makes the plugin unusable with the new editor that can’t be disabled, so we’re stuck with Discourse 3.4.
Custom fields are indeed unsupported on the rich editor for now. We’ll investigate the best path forward.
It can – if you’re an admin, you can set SiteSettings.rich_editor = false via the console, which is still available as a last resort in cases like this.