@portabletext/editor 1.21.4 → 1.21.6

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.js CHANGED
@@ -24,7 +24,7 @@ import { createGuards } from "./_chunks-es/selector.is-selection-collapsed.js";
24
24
  import { blockOffsetToSpanSelectionPoint } from "./_chunks-es/util.is-empty-text-block.js";
25
25
  import { coreBehaviors, isCustomBehaviorEvent, isHotkey } from "./_chunks-es/behavior.core.js";
26
26
  import getRandomValues from "get-random-values-esm";
27
- import { htmlToBlocks, normalizeBlock } from "@portabletext/block-tools";
27
+ import { htmlToBlocks } from "@portabletext/block-tools";
28
28
  function createEditorSchema(portableTextType) {
29
29
  if (!portableTextType)
30
30
  throw new Error("Parameter 'portabletextType' missing (required)");
@@ -6618,18 +6618,17 @@ function createWithInsertData(editorActor, schemaTypes) {
6618
6618
  let portableText, fragment, insertedType;
6619
6619
  if (html) {
6620
6620
  if (portableText = htmlToBlocks(html, schemaTypes.portableText, {
6621
- unstable_whitespaceOnPasteMode: whitespaceOnPasteMode
6622
- }).map((block) => normalizeBlock(block, {
6623
- blockTypeName
6624
- })), fragment = toSlateValue(portableText, {
6621
+ unstable_whitespaceOnPasteMode: whitespaceOnPasteMode,
6622
+ keyGenerator: editorActor.getSnapshot().context.keyGenerator
6623
+ }), fragment = toSlateValue(portableText, {
6625
6624
  schemaTypes
6626
6625
  }), insertedType = "HTML", portableText.length === 0)
6627
6626
  return !1;
6628
6627
  } else {
6629
6628
  const textToHtml = `<html><body>${escapeHtml(text).split(/\n{2,}/).map((line) => line ? `<p>${line.replace(/(?:\r\n|\r|\n)/g, "<br/>")}</p>` : "<p></p>").join("")}</body></html>`;
6630
- portableText = htmlToBlocks(textToHtml, schemaTypes.portableText).map((block) => normalizeBlock(block, {
6631
- blockTypeName
6632
- })), fragment = toSlateValue(portableText, {
6629
+ portableText = htmlToBlocks(textToHtml, schemaTypes.portableText, {
6630
+ keyGenerator: editorActor.getSnapshot().context.keyGenerator
6631
+ }), fragment = toSlateValue(portableText, {
6633
6632
  schemaTypes
6634
6633
  }), insertedType = "text";
6635
6634
  }