superside-oss / sanity-copy-paste

MIT License
8 stars 1 forks source link

Cannot read properties of undefined (reading '_type') #3

Open andreagiachettobold opened 1 year ago

andreagiachettobold commented 1 year ago

Hello!

Thank you for your time and work into this plugin. I tried that, but I cannot make it work.

I added the code as you displayed on the readme file, but I get this message:

CopyPasteInput.tsx:75 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_type') at onPaste (CopyPasteInput.tsx:75:62) at onClick (CopyPasteInput.tsx:309:30)

Those are my dependencies on the package.json file

"dependencies": { "@sanity/document-internationalization": "^1.1.1", "@sanity/ui": "^1.3.3", "@sanity/vision": "^3.10.1", "@superside-oss/sanity-plugin-copy-paste": "^1.0.2", "get-video-id": "^3.6.5", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.8.0", "react-is": "^18.2.0", "sanity": "^3.10.1", "sanity-plugin-media": "^2.0.5", "styled-components": "^5.3.10" }, "devDependencies": { "@sanity/eslint-config-studio": "^2.0.1", "eslint": "^8.40.0", "prettier": "^2.8.8", "typescript": "^5.0.4" },

dnzg commented 1 year ago

@andreagiachettobold could you share the schema where you inserted defineField(copyPaste)?

andreagiachettobold commented 1 year ago

Sure! I followed the readme file, here's my snippet:

`import {copyPaste} from '@superside-oss/sanity-plugin-copy-paste'

export const page = defineType({ name: 'page', title: 'Page', type: 'document', icon, i18n: true, groups: [ {title: 'Content', name: 'content', default: true}, {title: 'Page Settings', name: 'pageSettings'}, {title: 'SEO', name: 'seo'}, ], fields: [ defineField(copyPaste), defineField({ title: 'Page Title', name: 'title', type: 'string', group: 'content', validation: (Rule) => Rule.required(), }), ...`