@portabletext/editor 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
7
- "cms",
8
- "headless",
9
7
  "realtime",
10
8
  "content",
11
9
  "portable-text-editor",
12
10
  "structure",
13
- "api",
14
11
  "collaborative",
15
12
  "editor",
16
13
  "text",
@@ -46,7 +43,7 @@
46
43
  ],
47
44
  "dependencies": {
48
45
  "@portabletext/patches": "1.0.2",
49
- "debug": "^3.2.7",
46
+ "debug": "^4.3.4",
50
47
  "is-hotkey-esm": "^1.0.0",
51
48
  "lodash": "^4.17.21",
52
49
  "slate": "0.100.0",
@@ -404,7 +404,10 @@ export const PortableTextEditable = forwardRef(function PortableTextEditable(
404
404
  Promise.resolve(onPasteResult)
405
405
  .then((result) => {
406
406
  debug('Custom paste function from client resolved', result)
407
- if (result && result.insert) {
407
+ if (!result || !result.insert) {
408
+ debug('No result from custom paste handler, pasting normally')
409
+ slateEditor.insertData(event.clipboardData)
410
+ } else if (result.insert) {
408
411
  slateEditor.insertFragment(
409
412
  toSlateValue(result.insert as PortableTextBlock[], {schemaTypes}),
410
413
  )
@@ -394,7 +394,12 @@ export interface PasteData {
394
394
  value: PortableTextBlock[] | undefined
395
395
  }
396
396
 
397
- /** @beta */
397
+ /**
398
+ * @beta
399
+ * It is encouraged not to return `Promise<undefined>` from the `OnPasteFn` as
400
+ * a mechanism to fall back to the native paste behaviour. This doesn't work in
401
+ * all cases. Always return plain `undefined` if possible.
402
+ **/
398
403
  export type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise
399
404
 
400
405
  /** @beta */