sanity-io / sanity-plugin-internationalized-array

A plugin to register array fields with a custom input component to store field values in multiple languages, queryable by using the language ID as an array `_key`.
MIT License
45 stars 11 forks source link

Slate editor error from fields with array of type "block" #39

Closed philiphand closed 1 year ago

philiphand commented 1 year ago

Error when using portable text (array of type block) fields

I am experiencing an error when editing formattable text within internationalized arrays. The studio runs and the fields appear without issues, but when editing the text I get the following error when attempting to edit the field:

Uncaught error: Cannot resolve a Slate point from DOM point: [object Text]

This is how the field is set up:

export const internationalizedArrayConfig = {
    languages,
    fieldTypes: [
        'string',
        defineField({
            name: 'formattedText',
            type: 'array',
            of: [{type: 'block'}]
        })
    ],
}

const plugins = [
  internationalizedArray(internationalizedArrayConfig),
]

// Inside the schema
        defineField({
            name: "formattedTextField",
            title: "Weight example",
            type: "internationalizedArrayFormattedText",
        }),

I do not get any issues with string fields of the type internationalizedArrayString, so the problem seems related to the default portable text editor. Is portable text currently incompatible with this plugin?

image image

philiphand commented 1 year ago

Solved by updating to the newest version of the plugin.

chiholiu10 commented 10 months ago

Do you have entire file of how this part of the code is implemented, still missing the entire context.