sanity: [v3] Pasting external text no longer works in portable text editor
In Sanity Studio v3 you are unable to past test from external sources into the rich text editor. However, you can cut and paste text from within the editor itself as expected. Attempting to paste outside text results in the following error message:
Layout.js:50 TypeError: undefined is not a function
at Array.find (<anonymous>)
at blockContentFeatures (schema.ts:31:35)
at createRuleOptions (usePortableTextEditorValue.ts:25:20)
at new HtmlDeserializer (withoutPatching.ts:50:57)
at htmlToBlocks (array.ts:21:24)
at editor2.insertTextOrHTMLData (ActivateOnFocus.js:190:26)
at editor2.insertData (ActivateOnFocus.js:228:16)
at MemberFieldError.js:289:19
at isEventHandled (index.ts:1585:37)
at index.ts:1446:18
To Reproduce
Steps to reproduce the behavior:
- Create any field that is a block element
{
name: "content",
title: "Content",
type: "array",
of: [{ type: "block" }],
},
- Open a new document of the type in Sanity Studio and activate the rich text editor.
- Attempt to past in text from any source (e.g. copy a URL from your browser)
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
Which versions of Sanity are you using?
Run sanity versions in the terminal and copy-paste the result here.
What operating system are you using?
Which versions of Node.js / npm are you running?
@sanity/cli (global) 3.0.0-dev-preview.15 (latest: 2.30.6)
@sanity/image-url 1.0.1 (up to date)
@sanity/webhook 2.0.0 (up to date)
sanity 3.0.0-dev-preview.15 (latest: 2.29.3)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 17 (4 by maintainers)
This is now fixed with release of v3.8.0
Thank your for reporting this issue. Sorry for the inconvenience, we have now added a test to avoid this particular problem happening again.
I came here while researching my issue. I can’t paste text into a portable text editor either – and I am also using pnpm.
I see this error:
I am using
"sanity": "3.7.1".Is there a way to make it work besides switching to npm/yarn?
EDIT: Reverting back to
"sanity": "3.6.0"solved the issue for me.Is there any intention to have this working with pnpm for the 2.x branch, or is
yarnstill the “official” tool to use?Faced the same issue when pasting text with line breaks to fields of type
Portable Text. Downgrading to sanity3.7.0from3.7.1fixed it for meI just created a new project, following https://www.sanity.io/docs/create-a-sanity-project with these properties:
node version:
18.2.1andnpm ls @sanity/block-tools && npm ls sanityand afther
npm run devI get this error when I try to paste any text in a block elementtoast error
console error
Same issue here on
2.35.2usingpnpm