These helpers are there in the main ConverseJS utils but not in
the headless one; unfortunately they are used in some cases
(while parsing inline emoji) so not having them causes an error.
Ideally we'd patch ConverseJS to include this in the headless
version too, but for now as a quick-fix we're just defining
everything directly in our converse.js itself.
This is the mechanism to automatically scroll to the bottom of
the page when a new message comes in. This is now done by
listening for a change on the "mesages" element and acting upon
that. It's still a bit hacky like the earlier one, but at least
the hack is all in one place.
This is instead of using the stanza directly. To get this to work,
we had to import a couple of other util libraries just so that
they assign their respective utils to Converse's `u` object. This
is probably supposed to happen by itself when the respective
plugins are loaded, but for whatever reason it wasn't happening so
here we are.
We already defined window._converse earlier in the file. (In any
case, both these are temporary globals for debugging; once done
we ideally won't have a floating public _converse like that. Come
to think of it, we won't have a floating converse without the
underscore either!)
We forgot to break the switch-case after the middle softkey's
callback, which meant the middle key was calling the right
softkey's action too, causing all sorts of confusion. (Maybe a
sign not to use switch-case? 😛)
They're needed to navigate through the text you're editing, so
having them jump out to the next input field (or whatever it is)
instead is very annoying
The two main stumbling blocks were a tiny line in rollup's config
and the need to import the emoji utils to make the isOnlyEmojis
function available to parseMessage. Both with tiny code changes,
but it took a days' worth of hunting and debugging to get here!
For want of a nail...