Generic [wrap]/Markdown-it Custom Token Types causing errors in RTE

Priority/Severity: Low?

Platform: Devices using new RTE.

Description: Creating custom token types, which previously worked fine with just the markdown-it engine, causes errors with ProseMirror. As without a ProseMirror schema to handle the parsed to DOM, any custom token types create an error. Similarly there are behavior issues when toggling between RTE and Markdown with BBCode.

Reproducible steps:

RTE First:

  1. Open Editor
  2. Set mode to RTE
  3. Insert custom BBCode.
    a. For example with Discourse Meta: [wrap=test2 user-id=1]Content[/wrap]
  4. Dismiss error and toggle between RTE and md mode.
    a. BBCode is escaped

Markdown First:

  1. Open Editor
  2. Set mode to Markdown
  3. Insert custom BBCode.
  4. Toggle between md mode and RTE.
    a. BBCode is not visible
  5. Toggle back to see raw.

Current workaround:
Use Markdown mode only instead.


Getting the error itself isn’t that big of a deal, the bigger issue is with the weird behavior when toggling or when inserting the code.

The ideal solution would be for every markdown plugin to create a proper wizard/ProseMirror schema to handle it.

With regards to the generic [wrap] bbcode, perhaps just letting it stay in plain text is best, since multiple components could be using the generic bbcode in the same Discourse instance. The ideal solution is probably to let devs create a custom wizard and match the output to their own implementations, and let it fallback to plain text if no matches are found.

More generally, with any existing plugins that haven’t been updated to use ProseMirror, letting it default to plain text (that isn’t escaped/hidden) would be a nice interim fallback.

2 Likes

Thanks for reporting, @renato is keeping an eye out for edge cases like this, wrap has been our go-to for certain theme components, we will get it working.

2 Likes