Rich text editor breaks Text Replacement feature on Apple platforms

The forums I moderate recently switched to using the new rich text editor, and I immediately noticed that it seems to (somewhat) break OS text replacement features, such as General > Keyboards > Text Replacement on iOS. This is unfortunate because I have several replacements that I use a lot in Discourse. For example, one of my most common moderation tasks is to redirect users to other forums, and so I have e.g. a text replacement that replaces adf with a link to the Apple developer forums. (I prefer not to use canned replies for this because most of the rest of the post is often less boilerplate, but they always contain that link. Besides, I have several other replacements that don’t fit that model.)

Interestingly, some of my replacements do continue to work; e.g. \tau seems to turn reliably into τ. And my adf replacement seems to almost work if I type it between backticks: I’m writing this post on macOS Safari, and [backtick] adf [backtick] [space] briefly results in [Apple Developer Forums](https://forums.developer.apple.com/), although that disappears and turns back into adf if I interact with the editor in any way afterwards.

I assume the leading backslash must have something to do with why this is working for my other replacements, so I can probably work around this bug by changing my adf replacement to \adf. But I shouldn’t really have to.

This is a pretty serious problem for me because it’s interfering with my ability to do this kind of moderation efficiently from the Discourse iOS app. (This is also why I don’t want to have to add a leading backslash: it’s annoying to type a backslash on a phone keyboard.)

1 Like

Maybe this is a feature request, but I think you’ll just need to click the imageto switch back to the Markdown editor if you want to use such customizations.

Sure, just using the markdown editor is an acceptable workaround. Consider this a feature request to have the feature work consistently in all editing modes, then. Again, the rich text editor doesn’t always ignore these substitutions — I imagine they’re initiated by the OS in some way — it just tends to handle them badly.

2 Likes

I suspect this is the class of problem where we are pre-processing clipboard for safety.

Pasting in [test] into rich text composer leads to \[test\] in raw

Similarly pasting:

<a href="apple.com">apple</a>

leads to apple in RTE (not a link)

but leads to apple if you paste it into raw


Feels highly related @renato ?

2 Likes

This feels like a bug to me, probably in our logic of creating a link when pasting on top of a selection. I’ll take a look.

iOS text replacements may be similar to Android’s IME, bypassing the usual expected text insertion events. I’m not sure, but it seems to be a different problem.

It’s not impossible that these inconsistent occurrences are being caused by a runtime error. I’ll try to reproduce it this week.

3 Likes