@portabletext/editor 1.0.7 → 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/lib/index.d.mts CHANGED
@@ -341,7 +341,12 @@ export declare type OnCopyFn = (
341
341
  event: ClipboardEvent_2<HTMLDivElement | HTMLSpanElement>,
342
342
  ) => undefined | unknown
343
343
 
344
- /** @beta */
344
+ /**
345
+ * @beta
346
+ * It is encouraged not to return `Promise<undefined>` from the `OnPasteFn` as
347
+ * a mechanism to fall back to the native paste behaviour. This doesn't work in
348
+ * all cases. Always return plain `undefined` if possible.
349
+ **/
345
350
  export declare type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise
346
351
 
347
352
  /** @beta */
package/lib/index.d.ts CHANGED
@@ -341,7 +341,12 @@ export declare type OnCopyFn = (
341
341
  event: ClipboardEvent_2<HTMLDivElement | HTMLSpanElement>,
342
342
  ) => undefined | unknown
343
343
 
344
- /** @beta */
344
+ /**
345
+ * @beta
346
+ * It is encouraged not to return `Promise<undefined>` from the `OnPasteFn` as
347
+ * a mechanism to fall back to the native paste behaviour. This doesn't work in
348
+ * all cases. Always return plain `undefined` if possible.
349
+ **/
345
350
  export declare type OnPasteFn = (data: PasteData) => OnPasteResultOrPromise
346
351
 
347
352
  /** @beta */
package/lib/index.esm.js CHANGED
@@ -4442,7 +4442,7 @@ const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (prop
4442
4442
  }
4443
4443
  const value = PortableTextEditor.getValue(portableTextEditor), ptRange = toPortableTextRange(value, slateEditor.selection, schemaTypes), path = (ptRange == null ? void 0 : ptRange.focus.path) || [], onPasteResult = onPaste({ event, value, path, schemaTypes });
4444
4444
  onPasteResult === void 0 ? (debug("No result from custom paste handler, pasting normally"), slateEditor.insertData(event.clipboardData)) : (change$.next({ type: "loading", isLoading: !0 }), Promise.resolve(onPasteResult).then((result) => {
4445
- debug("Custom paste function from client resolved", result), result && result.insert ? slateEditor.insertFragment(
4445
+ debug("Custom paste function from client resolved", result), !result || !result.insert ? (debug("No result from custom paste handler, pasting normally"), slateEditor.insertData(event.clipboardData)) : result.insert ? slateEditor.insertFragment(
4446
4446
  toSlateValue(result.insert, { schemaTypes })
4447
4447
  ) : console.warn("Your onPaste function returned something unexpected:", result);
4448
4448
  }).catch((error) => (console.error(error), error)).finally(() => {