kfahy / slack-disable-wysiwyg-bookmarklet

Disables the WYSIWYG editor in Slack.
MIT License
823 stars 23 forks source link

Doesn't work for some markdown elements #6

Open shmerl opened 4 years ago

shmerl commented 4 years ago

For example:

* test

Will turn into

And when editing, it won't revert to raw markdown.

shmerl commented 4 years ago

Actually, it's a bit worse. After activating the fix, bullet syntax stops working altogether on second try.

kfahy commented 4 years ago

Oof, good find, @shmerl! I hadn't noticed this bullet behavior before, but I also reproduced in a workspace that hasn't yet been migrated to WYSIWYG, so perhaps this rollout was independent.

Don't have time to dig into this now, but from a quick glance of the Slack JS it looks like the bullet conversion might be happening in the following block:

return t[0].elements.forEach(e=>{
    if (e && e.type)
        if (e.type === p.a.LIST) {
            let t = 1;
            e.elements.forEach(n=>{
                const a = r(n);
                "ordered" === e.style ? (i.push(`${t}. ${a}`),
                t += 1) : i.push(`\u2022 ${a}`)
            }
            )
        } else
            i.push(r(e))
}