ProseMirror UUID discussion

Hi @Jons. I'd be glad to continue the discussion here. I don't see anything immediately that is related to the TJSProseMirror component. The actual editor and such is the Foundry implementation underneath. There are additional plugins and such added, but it's not clear yet if what you are doing in regard to interaction would hit any of the aspects added by TJSProseMirror Can you more specifically outline the problem that you are seeing and perhaps put some console.log statements in foundry-esm.js to verify the UUID being parsed. The drag and drop of documents into the editor when active should be something completely controlled by the underlying Foundry implementation.
8 Replies
Jons
Jons•5mo ago
Sure. When I drop some Item data into ProseMirror editor I got whis Uncaught Error in console:
foundry-esm.js:3571 Uncaught Error: Invalid number of embedded UUID parts
at Object.parseUuid (foundry-esm.js:3571:37)
at fromUuidSync (foundry.js:4915:72)
at #transformUUID (TJSPasteUUID.js:45:40)
at Plugin.transformPastedText (TJSPasteUUID.js:26:53)
at foundry-esm.js:27810:62
at EditorView.someProp (foundry-esm.js:30441:52)
at parseFromClipboard (foundry-esm.js:27810:16)
at editHandlers.drop (foundry-esm.js:28704:19)
at view.dom.addEventListener.view.input.eventHandlers.<computed> (foundry-esm.js:28059:19)
foundry-esm.js:3571 Uncaught Error: Invalid number of embedded UUID parts
at Object.parseUuid (foundry-esm.js:3571:37)
at fromUuidSync (foundry.js:4915:72)
at #transformUUID (TJSPasteUUID.js:45:40)
at Plugin.transformPastedText (TJSPasteUUID.js:26:53)
at foundry-esm.js:27810:62
at EditorView.someProp (foundry-esm.js:30441:52)
at parseFromClipboard (foundry-esm.js:27810:16)
at editHandlers.drop (foundry-esm.js:28704:19)
at view.dom.addEventListener.view.input.eventHandlers.<computed> (foundry-esm.js:28059:19)
The parseUuid function has been called with these params:
{
"uuid": "{\"type\":\"Item\",\"uuid\":\"Compendium.fabulaultima.conditions.Item.6CQ3nO3ZLl148GMQ\"}"
}
{
"uuid": "{\"type\":\"Item\",\"uuid\":\"Compendium.fabulaultima.conditions.Item.6CQ3nO3ZLl148GMQ\"}"
}
Reading the function implementation, it seems that the function expects the string part of uuid as input "Compendium.fabulaultima.conditions.Item.6CQ3nO3ZLl148GMQ", and not a serialized json. That's the problem. So can you confirm that is all happening inside foundry? (sorry, I'm a experienced developer, but I'm still quite new to foundry development and I still have to understand what belongs to core foundry and what to TJS) I noticed that a TJS module is involved in the call stack (TJSPasteUUID.js) wich receive that input and pass it into parseUuid function Some other info: 1. I tried to switch to <TJSTinyMCE> component and it works 2. I'm using foundry v12 The TinyMCE version follows a totally different call stack so I'm a bit confused. I can try to understand if there is something broken in foundry v12
TyphonJS (Michael)
TyphonJS (Michael)OP•5mo ago
See if you get the same error in a core ProseMirror editor (edit any journal / item description, etc.). Just make sure it's not something specific to the compendium formatting of the UUID. Also just try with world items. Drag and drop from the compendium to a world item then drop from there to the editor. I'll certainly put a try / catch around the fromUuidSync call in the paste plugin just for good measure. OK.. I have confirmed this is a problem with v12 works fine on v11. This only seemingly is occurring for compendium dropped items. If you drop the compendium item into a world item then drag the world item to the editor then it works as well. I attached two videos showing dropping from a compendium in v11 / v12.
Jons
Jons•5mo ago
Ok, I want to add some other info: Dropping a compendium item into a journal entry works fine, so I tried to understand what is the difference It seems that the difference is in this function here from foundry-esm
someProp(propName, f) {
let prop = this._props && this._props[propName], value;
if (prop != null && (value = f ? f(prop) : prop))
return value;
for (let i = 0; i < this.directPlugins.length; i++) {
let prop = this.directPlugins[i].props[propName];
if (prop != null && (value = f ? f(prop) : prop))
return value;
}
let plugins = this.state.plugins;
if (plugins)
for (let i = 0; i < plugins.length; i++) {
let prop = plugins[i].props[propName];
if (prop != null && (value = f ? f(prop) : prop))
return value;
}
}
someProp(propName, f) {
let prop = this._props && this._props[propName], value;
if (prop != null && (value = f ? f(prop) : prop))
return value;
for (let i = 0; i < this.directPlugins.length; i++) {
let prop = this.directPlugins[i].props[propName];
if (prop != null && (value = f ? f(prop) : prop))
return value;
}
let plugins = this.state.plugins;
if (plugins)
for (let i = 0; i < plugins.length; i++) {
let prop = plugins[i].props[propName];
if (prop != null && (value = f ? f(prop) : prop))
return value;
}
}
In case of dropping into a journal entry the array of plugins contains 16 elements, in the other case has only 14 plugins I don't know if something important is missing there, I will do more digging later In any case thank you for your response, I will wait for a core update of foundry if that is the problem
TyphonJS (Michael)
TyphonJS (Michael)OP•5mo ago
The intention behind this plugin is that if you paste (not drop in) in Item.ID that it will properly format it as a UUID link. Here is what #transformUUID receives on each version On v11: {"type":"Item","uuid":"Compendium.dnd5e.items.Item.3c7JXOzsv55gqJS5"} On v12: {"type":"Item","uuid":"Compendium.dnd5e.items.Item.3c7JXOzsv55gqJS5"} So something about fromUuidSync and the subsequent core parsing changed. Technically though this plugin is meant to convert Compendium.dnd5e.items.Item.3c7JXOzsv55gqJS5 to a UUID link and not process the strings given above. I need to correct the regex in #transformUUID to better handle this case / add error checking. I have more than enough info to fix this issue. You'll soon find especially over Foundry updates that code that you thought was pretty solid can break because the core Foundry API morphs and changes in unexpected ways.
Jons
Jons•5mo ago
Ok, thank you!
TyphonJS (Michael)
TyphonJS (Michael)OP•5mo ago
I hope your Foundry dev journey is getting off to a good start nonetheless! 😄
Jons
Jons•5mo ago
yeah, sure, my system development is almost ready, I have to do some data entry and maybe some advanced feature to add later, thank you 🙂
TyphonJS (Michael)
TyphonJS (Michael)OP•5mo ago
Right on... Jumping into system development is a more difficult route. If you have any other questions do feel free to post them and drop a note when you release your system. TRL / Svelte library is definitely in a challenging spot. I've been working hard on just hardening the whole framework, but it's gone on a bit longer than expected; quite a bit longer. Normally, things get more complete testing when a new Foundry version comes out, but this time around I only made a small hot patch for the issues reported at the time when v12 dropped. In the future though things will be a bit more streamlined for being able to more immediately respond with a new release when stuff like this pops up. I'm working hard to get the next release out in September.
Want results from more Discord servers?
Add your server