@portabletext/editor 1.40.0 → 1.40.1

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.
@@ -2443,7 +2443,12 @@ const converterJson = {
2443
2443
  blocks: snapshot.context.value,
2444
2444
  selection
2445
2445
  });
2446
- return {
2446
+ return blocks.length === 0 ? {
2447
+ type: "serialization.failure",
2448
+ mimeType: "application/x-portable-text",
2449
+ reason: "No blocks serialized",
2450
+ originEvent: event.originEvent
2451
+ } : {
2447
2452
  type: "serialization.success",
2448
2453
  data: JSON.stringify(blocks),
2449
2454
  mimeType: "application/x-portable-text",
@@ -2552,7 +2557,7 @@ const converterJson = {
2552
2557
  data: sliceBlocks({
2553
2558
  blocks: snapshot.context.value,
2554
2559
  selection
2555
- }).map((block) => isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]`).join("") : `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]`).join(`
2560
+ }).map((block) => isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : "").join("") : "").filter((block) => block !== "").join(`
2556
2561
 
2557
2562
  `),
2558
2563
  mimeType: "text/plain",
@@ -5291,12 +5296,9 @@ function createWithEventListeners(editorActor, subscriptions) {
5291
5296
  editorActor.send({
5292
5297
  type: "behavior event",
5293
5298
  behaviorEvent: {
5294
- type: "deserialize",
5299
+ type: "input.*",
5295
5300
  originEvent: {
5296
- type: "input.*",
5297
- originEvent: {
5298
- dataTransfer
5299
- }
5301
+ dataTransfer
5300
5302
  }
5301
5303
  },
5302
5304
  editor