Backspace doesn't work on TJSProseMirror components if content is blank when edit button is clicked

Think I found a bug with TJSProseMirror. When I click the edit button on an editor component with no text in it, the backspace key is non-functional. Then, if I save it with text and click to edit it again, I can backspace. But if I delete the text and save the editor as empty again, I can't backspace again until I save it with more text.
No description
5 Replies
Solidor
Solidor2y ago
Upon further testing, if I click inside the editor, then I can backspace. It seems like clicking the edit button doesn't focus the editor if the content is empty when I click it
geoidesic
geoidesic2y ago
Yes I was going to post this issue myself. Did you find a way to focus the editor if it's empty?
TyphonJS (Michael)
TJSProseMirror wraps the Foundry implementation. There are many quirks and inaccuracies w/ the Foundry implementation. At least with dnd5e / journals.. You'll notice that when you start the PM editor that the editor view is not focused and you can't type until you click on the editor manually. TJSProseMirror does focus the editor view after creation and has a few custom plugins. One of them is to set the cursor position which defaults to the start of any content. You can also choose end or all to select all content. There likely is some refinement necessary for this plugin and I'll look into it. If I disable the plugin the focusing of the editor view by TJSProseMirror works w/ delete key as well. I also noticed that there are inaccuracies when you have a Foundry PM editor open and TJSProseMirror instance depending on the order of opening. The key mapping is shared and overridden between editors, so functionality that TJSProseMirror sets up like Esc cancelling editing is reset after a Foundry PM editor is open. Super janky and probably nothing I can do about that besides recommending to not use the PM editor. Basically the PM Foundry implementation IMHO is a mess. I firmly believe it is not ready for primetime and not sure why any dev would want to force bad UX on their users. I highly doubt it will be a reliable replacement for TinyMCE now and likely years forward as the core team is not going to spend the time to make it rock solid at least in any reasonable time frame. I only have so much interest, which I suppose is a nice way of saying none at all, in dealing w/ the Foundry PM implementation. PM isn't the problem here either. And I certainly have no interest in writing a 100% controlled PM implementation myself as TinyMCE works just fine. Maybe v11 will be better and have a little more work done on the Foundry PM implementation though I'm not holding my breath.
Solidor
Solidor2y ago
Fair enough. Might go back to TinyMCE for now then. Mainly wanted to use prosemirror because I was afraid of TinyMCE getting deprecated. Luckily I have the editor component wrapped, so I should be able to make the switch in one place and have it be a global change.
TyphonJS (Michael)
OMFG.... After 10 hours of debugging.... So... Here it goes... A big problem of the Foundry PM implementation / prosemirror.js is that it doesn't export all of the PM resources. More and more will likely get incrementally exposed, but even then it's far from what is required if one has full access to all the PM NPM packages. There are many things missing from what Foundry exports into the ProseMirror global variable. I swear this worked when I first created TJSProseMirror... However, it turns out in TRL that when importing PM resources directly from a NPM package that they are potentially incompatible or something is off between the latest version I imported and possibly what the Foundry PM implementation is using or some other non-obvious arcane conflict. To set the initial text selection in TJSProseMirror you need TextSelection. The version Foundry uses is exported to ProseMirror global, but this and several other crucial things like Plugin were not exported until 10.287, so I pulled them in directly from NPM in svelte-standard. When I switched to the Foundry bundled version everything just worked again as it should. However there were absolutely no indications in the PM debugger I have available other than one field updated in the PM transaction was different between the TextSelection instances used; and other applied selection transactions. There is no specific info on this field in PM documentation for transactions, but it's probably a bitfield for applied action. The PM debugger is pretty awesome. It's like the Chrome debugger, but for ProseMirror; see pict... While I can fix this issue... It certainly is absolutely chilling in regard to how much more customization / adding good UX features I'll be doing for TJSProseMirror. The Foundry implementation is so scattershot it is not worth spending developer time on customizing PM editor especially considering that what is required for modding is potentially complete access to the PM API. Now that there are known conflicts when locally importing PM NPM packages to TRL I just have no interest in limiting TRL components to particular minimum versions of Foundry as the PM resources potentially get more exposed every Foundry release. ------ Heh heh... Got a little spicy this morning... I turned off Discord announcement notifications. This woke me up in the middle of the night and I unfortunately took a look and did not get back to sleep / certainly no coffee before my initial post.
No description
Want results from more Discord servers?
Add your server
More Posts