TJSProseMirror for arrays?

Question about the TJSProseMirror component. I am trying to pass a fieldname belonging to an object in an array like so: fieldName={system.rulesElement[${idx}].message} However, what this ends up doing is creating a new key in my document "rulesElement[0]": How would I pass it a fieldname with an array index?
2 Replies
TyphonJS (Michael)
I'm not sure exactly.. It doesn't look like that is possible. foundry.utils.getProperty is utilized to read the property from the document, so whatever is allowed there. A quick look at it and it doesn't seem to support array indexing; just indexing a nested object. Saving data is accomplished with: $doc.update({ [options.fieldName]: data }). If you need array indexing you might need to handle serializing the data externally in a custom wrapper component.
Solidor
Solidor2y ago
No worries. I ended up wrapping it like so.
<div class="editor">
<TJSProseMirror
bind:content={value}
on:editor:save={() => {
$document.update({
system: $document.system,
flags: $document.flags,
});
}}
/>
</div>
<div class="editor">
<TJSProseMirror
bind:content={value}
on:editor:save={() => {
$document.update({
system: $document.system,
flags: $document.flags,
});
}}
/>
</div>
Want results from more Discord servers?
Add your server