@portabletext/editor 4.1.1 → 4.1.2

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
@@ -1,9 +1,9 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { useSelector, useActorRef } from "@xstate/react";
4
- import { createContext, useRef, useContext, useState, useEffect, forwardRef, Component, startTransition } from "react";
4
+ import { createContext, useContext, useRef, useState, useEffect, forwardRef, Component, startTransition } from "react";
5
5
  import { Element as Element$1, Text, Range, Editor, Node, Point, Path, Transforms, createEditor, deleteText, Operation } from "slate";
6
- import { useSelected, useSlateSelector, useSlateStatic, ReactEditor, useSlate, Editable, withReact, Slate } from "slate-react";
6
+ import { useSlateStatic, ReactEditor, useSlate, Editable, withReact, Slate } from "slate-react";
7
7
  import debug$e from "debug";
8
8
  import { DOMEditor, isDOMNode, EDITOR_TO_PENDING_SELECTION, IS_FOCUSED, IS_READ_ONLY } from "slate-dom";
9
9
  import { getBlockEndPoint, getBlockStartPoint, getBlockKeyFromSelectionPoint, isSelectionCollapsed, isKeyedSegment, isEqualSelectionPoints, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, defaultKeyGenerator, parseBlocks, parseBlock, isListBlock, isTypedObject, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint as getSelectionEndPoint$1, parseAnnotation, parseMarkDefs, parseSpan, parseInlineObject } from "./_chunks-es/util.slice-blocks.js";
@@ -11,7 +11,7 @@ import { isTextBlock, isSpan, compileSchema } from "@portabletext/schema";
11
11
  import { defineSchema } from "@portabletext/schema";
12
12
  import { isEmptyTextBlock, sliceTextBlock, getTextBlockText } from "./_chunks-es/util.slice-text-block.js";
13
13
  import { setup, fromCallback, assign, and, enqueueActions, emit, assertEvent, raise as raise$1, not, createActor } from "xstate";
14
- import { isSelectionCollapsed as isSelectionCollapsed$1, getFocusSpan as getFocusSpan$1, isOverlappingSelection, getFocusInlineObject, getFocusTextBlock, getSelectedBlocks, isSelectionExpanded, getSelectionStartBlock, getSelectionEndBlock, getFocusBlock as getFocusBlock$1, isSelectingEntireBlocks, getSelectedValue, isActiveAnnotation, getActiveAnnotationsMarks, getActiveDecorators, getSelectionStartChild, getSelectionEndChild, getSelectionStartPoint, getSelectionEndPoint, getPreviousSpan, getNextSpan, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, getMarkState, isAtTheEndOfBlock, isAtTheStartOfBlock, getFocusListBlock, isActiveDecorator, getFocusChild as getFocusChild$1, getActiveAnnotations, getLastBlock as getLastBlock$1, getSelectedTextBlocks, isActiveListItem, isActiveStyle } from "./_chunks-es/selector.is-at-the-start-of-block.js";
14
+ import { isSelectionCollapsed as isSelectionCollapsed$1, getFocusSpan as getFocusSpan$1, getSelectedChildren, getSelectionStartPoint, getSelectionEndPoint, getFocusInlineObject, getFocusTextBlock, getSelectedBlocks, isSelectionExpanded, getSelectionStartBlock, getSelectionEndBlock, isOverlappingSelection, getFocusBlock as getFocusBlock$1, isSelectingEntireBlocks, getSelectedValue, isActiveAnnotation, getActiveAnnotationsMarks, getActiveDecorators, getSelectionStartChild, getSelectionEndChild, getPreviousSpan, getNextSpan, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, getMarkState, isAtTheEndOfBlock, isAtTheStartOfBlock, getFocusListBlock, isActiveDecorator, getFocusChild as getFocusChild$1, getActiveAnnotations, getLastBlock as getLastBlock$1, getSelectedTextBlocks, isActiveListItem, isActiveStyle } from "./_chunks-es/selector.is-at-the-start-of-block.js";
15
15
  import { defineBehavior, forward, raise, effect } from "./behaviors/index.js";
16
16
  import { compileSchemaDefinitionToPortableTextMemberSchemaTypes, createPortableTextMemberSchemaTypes, portableTextMemberSchemaTypesToSchema } from "@portabletext/sanity-bridge";
17
17
  import { htmlToBlocks } from "@portabletext/block-tools";
@@ -1156,43 +1156,155 @@ function DropIndicator() {
1156
1156
  zIndex: 5
1157
1157
  }, children: /* @__PURE__ */ jsx("span", {}) }), $[0] = t0) : t0 = $[0], t0;
1158
1158
  }
1159
+ function defaultCompare(a, b) {
1160
+ return a === b;
1161
+ }
1162
+ function useEditorSelector(editor, selector, t0) {
1163
+ const $ = c(3), compare = t0 === void 0 ? defaultCompare : t0;
1164
+ let t1;
1165
+ return $[0] !== editor || $[1] !== selector ? (t1 = (editorActorSnapshot) => {
1166
+ const snapshot = getEditorSnapshot({
1167
+ editorActorSnapshot,
1168
+ slateEditorInstance: editor._internal.slateEditor.instance
1169
+ });
1170
+ return selector(snapshot);
1171
+ }, $[0] = editor, $[1] = selector, $[2] = t1) : t1 = $[2], useSelector(editor._internal.editorActor, t1, compare);
1172
+ }
1173
+ function getEditorSnapshot({
1174
+ editorActorSnapshot,
1175
+ slateEditorInstance
1176
+ }) {
1177
+ const selection = slateEditorInstance.selection ? slateRangeToSelection({
1178
+ schema: editorActorSnapshot.context.schema,
1179
+ editor: slateEditorInstance,
1180
+ range: slateEditorInstance.selection
1181
+ }) : null;
1182
+ return {
1183
+ blockIndexMap: slateEditorInstance.blockIndexMap,
1184
+ context: {
1185
+ converters: [...editorActorSnapshot.context.converters],
1186
+ keyGenerator: editorActorSnapshot.context.keyGenerator,
1187
+ readOnly: editorActorSnapshot.matches({
1188
+ "edit mode": "read only"
1189
+ }),
1190
+ schema: editorActorSnapshot.context.schema,
1191
+ selection,
1192
+ value: slateEditorInstance.value
1193
+ },
1194
+ decoratorState: slateEditorInstance.decoratorState
1195
+ };
1196
+ }
1197
+ const emptySet = /* @__PURE__ */ new Set(), defaultSelectionState = {
1198
+ focusedChildKey: void 0,
1199
+ selectedChildKeys: emptySet,
1200
+ focusedBlockKey: void 0,
1201
+ selectedBlockKeys: emptySet
1202
+ }, SelectionStateContext = createContext(defaultSelectionState);
1203
+ function SelectionStateProvider(t0) {
1204
+ const $ = c(5), {
1205
+ children
1206
+ } = t0, editorActor = useContext(EditorActorContext), slateEditor = useSlateStatic();
1207
+ let t1;
1208
+ $[0] !== slateEditor ? (t1 = (editorActorSnapshot) => {
1209
+ const snapshot = getEditorSnapshot({
1210
+ editorActorSnapshot,
1211
+ slateEditorInstance: slateEditor
1212
+ });
1213
+ if (!snapshot.context.selection)
1214
+ return defaultSelectionState;
1215
+ const isCollapsed = isSelectionCollapsed$1(snapshot);
1216
+ let focusedChildKey;
1217
+ isCollapsed && (focusedChildKey = getFocusSpan$1(snapshot)?.node._key);
1218
+ const selectedChildren = getSelectedChildren()(snapshot);
1219
+ let selectedChildKeys = selectedChildren.length > 0 ? new Set(selectedChildren.map(_temp$4)) : emptySet;
1220
+ isCollapsed && focusedChildKey && !selectedChildKeys.has(focusedChildKey) && (selectedChildKeys = new Set(selectedChildKeys), selectedChildKeys.add(focusedChildKey));
1221
+ const startPoint = getSelectionStartPoint(snapshot), endPoint = getSelectionEndPoint(snapshot), startBlockKey = startPoint ? getBlockKeyFromSelectionPoint(startPoint) : void 0, endBlockKey = endPoint ? getBlockKeyFromSelectionPoint(endPoint) : void 0;
1222
+ let selectedBlockKeys = emptySet;
1223
+ if (startBlockKey && endBlockKey) {
1224
+ const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey), endBlockIndex = snapshot.blockIndexMap.get(endBlockKey);
1225
+ if (startBlockIndex !== void 0 && endBlockIndex !== void 0) {
1226
+ const minIndex = Math.min(startBlockIndex, endBlockIndex), maxIndex = Math.max(startBlockIndex, endBlockIndex);
1227
+ selectedBlockKeys = /* @__PURE__ */ new Set();
1228
+ for (const [key, index] of snapshot.blockIndexMap)
1229
+ index >= minIndex && index <= maxIndex && selectedBlockKeys.add(key);
1230
+ }
1231
+ }
1232
+ const focusedBlockKey = isCollapsed ? startBlockKey : void 0;
1233
+ return {
1234
+ focusedChildKey,
1235
+ selectedChildKeys: selectedChildKeys.size > 0 ? selectedChildKeys : emptySet,
1236
+ focusedBlockKey,
1237
+ selectedBlockKeys: selectedBlockKeys.size > 0 ? selectedBlockKeys : emptySet
1238
+ };
1239
+ }, $[0] = slateEditor, $[1] = t1) : t1 = $[1];
1240
+ const selectionState = useSelector(editorActor, t1, _temp2$3);
1241
+ let t2;
1242
+ return $[2] !== children || $[3] !== selectionState ? (t2 = /* @__PURE__ */ jsx(SelectionStateContext.Provider, { value: selectionState, children }), $[2] = children, $[3] = selectionState, $[4] = t2) : t2 = $[4], t2;
1243
+ }
1244
+ function _temp2$3(prev, next) {
1245
+ if (prev.focusedChildKey !== next.focusedChildKey)
1246
+ return !1;
1247
+ if (prev.selectedChildKeys !== next.selectedChildKeys) {
1248
+ if (prev.selectedChildKeys.size !== next.selectedChildKeys.size)
1249
+ return !1;
1250
+ for (const key_0 of prev.selectedChildKeys)
1251
+ if (!next.selectedChildKeys.has(key_0))
1252
+ return !1;
1253
+ }
1254
+ if (prev.focusedBlockKey !== next.focusedBlockKey)
1255
+ return !1;
1256
+ if (prev.selectedBlockKeys !== next.selectedBlockKeys) {
1257
+ if (prev.selectedBlockKeys.size !== next.selectedBlockKeys.size)
1258
+ return !1;
1259
+ for (const key_1 of prev.selectedBlockKeys)
1260
+ if (!next.selectedBlockKeys.has(key_1))
1261
+ return !1;
1262
+ }
1263
+ return !0;
1264
+ }
1265
+ function _temp$4(child) {
1266
+ return child.node._key;
1267
+ }
1159
1268
  function RenderBlockObject(props) {
1160
- const $ = c(33), blockObjectRef = useRef(null), selected = useSelected();
1269
+ const $ = c(34), blockObjectRef = useRef(null), {
1270
+ selectedBlockKeys,
1271
+ focusedBlockKey
1272
+ } = useContext(SelectionStateContext);
1161
1273
  let t0;
1162
- $[0] !== selected ? (t0 = (editor) => selected && editor.selection !== null && Range.isCollapsed(editor.selection), $[0] = selected, $[1] = t0) : t0 = $[1];
1163
- const focused = useSlateSelector(t0);
1274
+ $[0] !== props.element._key || $[1] !== selectedBlockKeys ? (t0 = selectedBlockKeys.has(props.element._key), $[0] = props.element._key, $[1] = selectedBlockKeys, $[2] = t0) : t0 = $[2];
1275
+ const selected = t0, focused = focusedBlockKey === props.element._key;
1164
1276
  let t1;
1165
- if ($[2] !== props.element._type || $[3] !== props.legacySchema.blockObjects) {
1277
+ if ($[3] !== props.element._type || $[4] !== props.legacySchema.blockObjects) {
1166
1278
  let t22;
1167
- $[5] !== props.element._type ? (t22 = (schemaType) => schemaType.name === props.element._type, $[5] = props.element._type, $[6] = t22) : t22 = $[6], t1 = props.legacySchema.blockObjects.find(t22), $[2] = props.element._type, $[3] = props.legacySchema.blockObjects, $[4] = t1;
1279
+ $[6] !== props.element._type ? (t22 = (schemaType) => schemaType.name === props.element._type, $[6] = props.element._type, $[7] = t22) : t22 = $[7], t1 = props.legacySchema.blockObjects.find(t22), $[3] = props.element._type, $[4] = props.legacySchema.blockObjects, $[5] = t1;
1168
1280
  } else
1169
- t1 = $[4];
1281
+ t1 = $[5];
1170
1282
  const legacySchemaType = t1;
1171
1283
  legacySchemaType || console.error(`Unable to find Block Object "${props.element._type}" in Schema`);
1172
1284
  let t2;
1173
- $[7] !== props.blockObject || $[8] !== props.element._key || $[9] !== props.element._type ? (t2 = props.blockObject ?? {
1285
+ $[8] !== props.blockObject || $[9] !== props.element._key || $[10] !== props.element._type ? (t2 = props.blockObject ?? {
1174
1286
  _key: props.element._key,
1175
1287
  _type: props.element._type
1176
- }, $[7] = props.blockObject, $[8] = props.element._key, $[9] = props.element._type, $[10] = t2) : t2 = $[10];
1288
+ }, $[8] = props.blockObject, $[9] = props.element._key, $[10] = props.element._type, $[11] = t2) : t2 = $[11];
1177
1289
  const blockObject = t2;
1178
1290
  let t3;
1179
- $[11] !== props.dropPosition ? (t3 = props.dropPosition === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[11] = props.dropPosition, $[12] = t3) : t3 = $[12];
1291
+ $[12] !== props.dropPosition ? (t3 = props.dropPosition === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[12] = props.dropPosition, $[13] = t3) : t3 = $[13];
1180
1292
  const t4 = !props.readOnly;
1181
1293
  let t5;
1182
- $[13] !== blockObject || $[14] !== focused || $[15] !== legacySchemaType || $[16] !== props.element._key || $[17] !== props.renderBlock || $[18] !== selected ? (t5 = props.renderBlock && legacySchemaType ? /* @__PURE__ */ jsx(RenderBlock$1, { renderBlock: props.renderBlock, editorElementRef: blockObjectRef, focused, path: [{
1294
+ $[14] !== blockObject || $[15] !== focused || $[16] !== legacySchemaType || $[17] !== props.element._key || $[18] !== props.renderBlock || $[19] !== selected ? (t5 = props.renderBlock && legacySchemaType ? /* @__PURE__ */ jsx(RenderBlock$1, { renderBlock: props.renderBlock, editorElementRef: blockObjectRef, focused, path: [{
1183
1295
  _key: props.element._key
1184
- }], schemaType: legacySchemaType, selected, type: legacySchemaType, value: blockObject, children: /* @__PURE__ */ jsx(RenderDefaultBlockObject, { blockObject }) }) : /* @__PURE__ */ jsx(RenderDefaultBlockObject, { blockObject }), $[13] = blockObject, $[14] = focused, $[15] = legacySchemaType, $[16] = props.element._key, $[17] = props.renderBlock, $[18] = selected, $[19] = t5) : t5 = $[19];
1296
+ }], schemaType: legacySchemaType, selected, type: legacySchemaType, value: blockObject, children: /* @__PURE__ */ jsx(RenderDefaultBlockObject, { blockObject }) }) : /* @__PURE__ */ jsx(RenderDefaultBlockObject, { blockObject }), $[14] = blockObject, $[15] = focused, $[16] = legacySchemaType, $[17] = props.element._key, $[18] = props.renderBlock, $[19] = selected, $[20] = t5) : t5 = $[20];
1185
1297
  let t6;
1186
- $[20] !== t4 || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsx("div", { ref: blockObjectRef, contentEditable: !1, draggable: t4, children: t5 }), $[20] = t4, $[21] = t5, $[22] = t6) : t6 = $[22];
1298
+ $[21] !== t4 || $[22] !== t5 ? (t6 = /* @__PURE__ */ jsx("div", { ref: blockObjectRef, contentEditable: !1, draggable: t4, children: t5 }), $[21] = t4, $[22] = t5, $[23] = t6) : t6 = $[23];
1187
1299
  let t7;
1188
- $[23] !== props.dropPosition ? (t7 = props.dropPosition === "end" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[23] = props.dropPosition, $[24] = t7) : t7 = $[24];
1300
+ $[24] !== props.dropPosition ? (t7 = props.dropPosition === "end" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[24] = props.dropPosition, $[25] = t7) : t7 = $[25];
1189
1301
  let t8;
1190
- return $[25] !== props.attributes || $[26] !== props.children || $[27] !== props.element._key || $[28] !== props.element._type || $[29] !== t3 || $[30] !== t6 || $[31] !== t7 ? (t8 = /* @__PURE__ */ jsxs("div", { ...props.attributes, className: "pt-block pt-object-block", "data-block-key": props.element._key, "data-block-name": props.element._type, "data-block-type": "object", children: [
1302
+ return $[26] !== props.attributes || $[27] !== props.children || $[28] !== props.element._key || $[29] !== props.element._type || $[30] !== t3 || $[31] !== t6 || $[32] !== t7 ? (t8 = /* @__PURE__ */ jsxs("div", { ...props.attributes, className: "pt-block pt-object-block", "data-block-key": props.element._key, "data-block-name": props.element._type, "data-block-type": "object", children: [
1191
1303
  t3,
1192
1304
  props.children,
1193
1305
  t6,
1194
1306
  t7
1195
- ] }), $[25] = props.attributes, $[26] = props.children, $[27] = props.element._key, $[28] = props.element._type, $[29] = t3, $[30] = t6, $[31] = t7, $[32] = t8) : t8 = $[32], t8;
1307
+ ] }), $[26] = props.attributes, $[27] = props.children, $[28] = props.element._key, $[29] = props.element._type, $[30] = t3, $[31] = t6, $[32] = t7, $[33] = t8) : t8 = $[33], t8;
1196
1308
  }
1197
1309
  function RenderBlock$1({
1198
1310
  renderBlock,
@@ -1217,20 +1329,23 @@ function RenderBlock$1({
1217
1329
  });
1218
1330
  }
1219
1331
  function RenderInlineObject(props) {
1220
- const $ = c(32), inlineObjectRef = useRef(null), slateEditor = useSlateStatic(), selected = useSelected();
1332
+ const $ = c(33), inlineObjectRef = useRef(null), slateEditor = useSlateStatic(), {
1333
+ selectedChildKeys,
1334
+ focusedChildKey
1335
+ } = useContext(SelectionStateContext);
1221
1336
  let t0;
1222
- $[0] !== selected ? (t0 = (editor) => selected && editor.selection !== null && Range.isCollapsed(editor.selection), $[0] = selected, $[1] = t0) : t0 = $[1];
1223
- const focused = useSlateSelector(t0);
1337
+ $[0] !== props.element._key || $[1] !== selectedChildKeys ? (t0 = selectedChildKeys.has(props.element._key), $[0] = props.element._key, $[1] = selectedChildKeys, $[2] = t0) : t0 = $[2];
1338
+ const selected = t0, focused = focusedChildKey === props.element._key;
1224
1339
  let t1;
1225
- if ($[2] !== props.element._type || $[3] !== props.legacySchema.inlineObjects) {
1340
+ if ($[3] !== props.element._type || $[4] !== props.legacySchema.inlineObjects) {
1226
1341
  let t22;
1227
- $[5] !== props.element._type ? (t22 = (inlineObject) => inlineObject.name === props.element._type, $[5] = props.element._type, $[6] = t22) : t22 = $[6], t1 = props.legacySchema.inlineObjects.find(t22), $[2] = props.element._type, $[3] = props.legacySchema.inlineObjects, $[4] = t1;
1342
+ $[6] !== props.element._type ? (t22 = (inlineObject) => inlineObject.name === props.element._type, $[6] = props.element._type, $[7] = t22) : t22 = $[7], t1 = props.legacySchema.inlineObjects.find(t22), $[3] = props.element._type, $[4] = props.legacySchema.inlineObjects, $[5] = t1;
1228
1343
  } else
1229
- t1 = $[4];
1344
+ t1 = $[5];
1230
1345
  const legacySchemaType = t1;
1231
1346
  legacySchemaType || console.error(`Unable to find Inline Object "${props.element._type}" in Schema`);
1232
1347
  let t2;
1233
- if ($[7] !== props.element || $[8] !== slateEditor) {
1348
+ if ($[8] !== props.element || $[9] !== slateEditor) {
1234
1349
  const path = DOMEditor.findPath(slateEditor, props.element);
1235
1350
  t2 = getPointBlock({
1236
1351
  editor: slateEditor,
@@ -1238,35 +1353,35 @@ function RenderInlineObject(props) {
1238
1353
  path,
1239
1354
  offset: 0
1240
1355
  }
1241
- }), $[7] = props.element, $[8] = slateEditor, $[9] = t2;
1356
+ }), $[8] = props.element, $[9] = slateEditor, $[10] = t2;
1242
1357
  } else
1243
- t2 = $[9];
1358
+ t2 = $[10];
1244
1359
  const [block] = t2;
1245
1360
  block || console.error(`Unable to find parent block of inline object ${props.element._key}`);
1246
1361
  let t3;
1247
- $[10] !== props.element ? (t3 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[10] = props.element, $[11] = t3) : t3 = $[11];
1362
+ $[11] !== props.element ? (t3 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[11] = props.element, $[12] = t3) : t3 = $[12];
1248
1363
  let t4;
1249
- $[12] !== props.element._key || $[13] !== props.element._type || $[14] !== t3 ? (t4 = {
1364
+ $[13] !== props.element._key || $[14] !== props.element._type || $[15] !== t3 ? (t4 = {
1250
1365
  _key: props.element._key,
1251
1366
  _type: props.element._type,
1252
1367
  ...t3
1253
- }, $[12] = props.element._key, $[13] = props.element._type, $[14] = t3, $[15] = t4) : t4 = $[15];
1368
+ }, $[13] = props.element._key, $[14] = props.element._type, $[15] = t3, $[16] = t4) : t4 = $[16];
1254
1369
  const inlineObject_0 = t4, t5 = !props.readOnly;
1255
1370
  let t6;
1256
- $[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = {
1371
+ $[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = {
1257
1372
  display: "inline-block"
1258
- }, $[16] = t6) : t6 = $[16];
1373
+ }, $[17] = t6) : t6 = $[17];
1259
1374
  let t7;
1260
- $[17] !== block || $[18] !== focused || $[19] !== inlineObject_0 || $[20] !== legacySchemaType || $[21] !== props.element._key || $[22] !== props.renderChild || $[23] !== selected ? (t7 = /* @__PURE__ */ jsx("span", { ref: inlineObjectRef, style: t6, children: props.renderChild && block && legacySchemaType ? /* @__PURE__ */ jsx(RenderChild$1, { renderChild: props.renderChild, annotations: [], editorElementRef: inlineObjectRef, selected, focused, path: [{
1375
+ $[18] !== block || $[19] !== focused || $[20] !== inlineObject_0 || $[21] !== legacySchemaType || $[22] !== props.element._key || $[23] !== props.renderChild || $[24] !== selected ? (t7 = /* @__PURE__ */ jsx("span", { ref: inlineObjectRef, style: t6, children: props.renderChild && block && legacySchemaType ? /* @__PURE__ */ jsx(RenderChild$1, { renderChild: props.renderChild, annotations: [], editorElementRef: inlineObjectRef, selected, focused, path: [{
1261
1376
  _key: block._key
1262
1377
  }, "children", {
1263
1378
  _key: props.element._key
1264
- }], schemaType: legacySchemaType, value: inlineObject_0, type: legacySchemaType, children: /* @__PURE__ */ jsx(RenderDefaultInlineObject, { inlineObject: inlineObject_0 }) }) : /* @__PURE__ */ jsx(RenderDefaultInlineObject, { inlineObject: inlineObject_0 }) }), $[17] = block, $[18] = focused, $[19] = inlineObject_0, $[20] = legacySchemaType, $[21] = props.element._key, $[22] = props.renderChild, $[23] = selected, $[24] = t7) : t7 = $[24];
1379
+ }], schemaType: legacySchemaType, value: inlineObject_0, type: legacySchemaType, children: /* @__PURE__ */ jsx(RenderDefaultInlineObject, { inlineObject: inlineObject_0 }) }) : /* @__PURE__ */ jsx(RenderDefaultInlineObject, { inlineObject: inlineObject_0 }) }), $[18] = block, $[19] = focused, $[20] = inlineObject_0, $[21] = legacySchemaType, $[22] = props.element._key, $[23] = props.renderChild, $[24] = selected, $[25] = t7) : t7 = $[25];
1265
1380
  let t8;
1266
- return $[25] !== inlineObject_0._key || $[26] !== inlineObject_0._type || $[27] !== props.attributes || $[28] !== props.children || $[29] !== t5 || $[30] !== t7 ? (t8 = /* @__PURE__ */ jsxs("span", { ...props.attributes, draggable: t5, className: "pt-inline-object", "data-child-key": inlineObject_0._key, "data-child-name": inlineObject_0._type, "data-child-type": "object", children: [
1381
+ return $[26] !== inlineObject_0._key || $[27] !== inlineObject_0._type || $[28] !== props.attributes || $[29] !== props.children || $[30] !== t5 || $[31] !== t7 ? (t8 = /* @__PURE__ */ jsxs("span", { ...props.attributes, draggable: t5, className: "pt-inline-object", "data-child-key": inlineObject_0._key, "data-child-name": inlineObject_0._type, "data-child-type": "object", children: [
1267
1382
  props.children,
1268
1383
  t7
1269
- ] }), $[25] = inlineObject_0._key, $[26] = inlineObject_0._type, $[27] = props.attributes, $[28] = props.children, $[29] = t5, $[30] = t7, $[31] = t8) : t8 = $[31], t8;
1384
+ ] }), $[26] = inlineObject_0._key, $[27] = inlineObject_0._type, $[28] = props.attributes, $[29] = props.children, $[30] = t5, $[31] = t7, $[32] = t8) : t8 = $[32], t8;
1270
1385
  }
1271
1386
  function RenderChild$1({
1272
1387
  renderChild,
@@ -1293,87 +1408,90 @@ function RenderChild$1({
1293
1408
  });
1294
1409
  }
1295
1410
  function RenderTextBlock(props) {
1296
- const $ = c(75), blockRef = useRef(null), selected = useSelected();
1411
+ const $ = c(77), blockRef = useRef(null), {
1412
+ selectedBlockKeys,
1413
+ focusedBlockKey
1414
+ } = useContext(SelectionStateContext);
1297
1415
  let t0;
1298
- $[0] !== selected ? (t0 = (editor) => selected && editor.selection !== null && Range.isCollapsed(editor.selection), $[0] = selected, $[1] = t0) : t0 = $[1];
1299
- const focused = useSlateSelector(t0);
1416
+ $[0] !== props.textBlock._key || $[1] !== selectedBlockKeys ? (t0 = selectedBlockKeys.has(props.textBlock._key), $[0] = props.textBlock._key, $[1] = selectedBlockKeys, $[2] = t0) : t0 = $[2];
1417
+ const selected = t0, focused = focusedBlockKey === props.textBlock._key, slateEditor = useSlateStatic();
1300
1418
  let t1;
1301
- $[2] !== props.textBlock._key ? (t1 = (editor_0) => editor_0.listIndexMap.get(props.textBlock._key), $[2] = props.textBlock._key, $[3] = t1) : t1 = $[3];
1302
- const listIndex = useSlateSelector(t1);
1419
+ $[3] !== props.textBlock._key || $[4] !== slateEditor.listIndexMap ? (t1 = slateEditor.listIndexMap.get(props.textBlock._key), $[3] = props.textBlock._key, $[4] = slateEditor.listIndexMap, $[5] = t1) : t1 = $[5];
1420
+ const listIndex = t1;
1303
1421
  let children = props.children;
1304
1422
  if (props.renderStyle && props.textBlock.style) {
1305
1423
  let t22;
1306
- $[4] !== props.legacySchema || $[5] !== props.textBlock.style ? (t22 = props.textBlock.style !== void 0 ? props.legacySchema.styles.find((style) => style.value === props.textBlock.style) : void 0, $[4] = props.legacySchema, $[5] = props.textBlock.style, $[6] = t22) : t22 = $[6];
1424
+ $[6] !== props.legacySchema || $[7] !== props.textBlock.style ? (t22 = props.textBlock.style !== void 0 ? props.legacySchema.styles.find((style) => style.value === props.textBlock.style) : void 0, $[6] = props.legacySchema, $[7] = props.textBlock.style, $[8] = t22) : t22 = $[8];
1307
1425
  const legacyStyleSchemaType = t22;
1308
1426
  if (legacyStyleSchemaType) {
1309
1427
  let t32;
1310
- $[7] !== props.textBlock._key ? (t32 = [{
1428
+ $[9] !== props.textBlock._key ? (t32 = [{
1311
1429
  _key: props.textBlock._key
1312
- }], $[7] = props.textBlock._key, $[8] = t32) : t32 = $[8];
1430
+ }], $[9] = props.textBlock._key, $[10] = t32) : t32 = $[10];
1313
1431
  let t42;
1314
- $[9] !== children || $[10] !== focused || $[11] !== legacyStyleSchemaType || $[12] !== props.renderStyle || $[13] !== props.textBlock || $[14] !== selected || $[15] !== t32 ? (t42 = /* @__PURE__ */ jsx(RenderStyle, { renderStyle: props.renderStyle, block: props.textBlock, editorElementRef: blockRef, focused, path: t32, schemaType: legacyStyleSchemaType, selected, value: props.textBlock.style, children }), $[9] = children, $[10] = focused, $[11] = legacyStyleSchemaType, $[12] = props.renderStyle, $[13] = props.textBlock, $[14] = selected, $[15] = t32, $[16] = t42) : t42 = $[16], children = t42;
1432
+ $[11] !== children || $[12] !== focused || $[13] !== legacyStyleSchemaType || $[14] !== props.renderStyle || $[15] !== props.textBlock || $[16] !== selected || $[17] !== t32 ? (t42 = /* @__PURE__ */ jsx(RenderStyle, { renderStyle: props.renderStyle, block: props.textBlock, editorElementRef: blockRef, focused, path: t32, schemaType: legacyStyleSchemaType, selected, value: props.textBlock.style, children }), $[11] = children, $[12] = focused, $[13] = legacyStyleSchemaType, $[14] = props.renderStyle, $[15] = props.textBlock, $[16] = selected, $[17] = t32, $[18] = t42) : t42 = $[18], children = t42;
1315
1433
  } else
1316
1434
  console.error(`Unable to find Schema type for text block style ${props.textBlock.style}`);
1317
1435
  }
1318
1436
  if (props.renderListItem && props.textBlock.listItem) {
1319
1437
  let t22;
1320
- if ($[17] !== props.legacySchema.lists || $[18] !== props.textBlock.listItem) {
1438
+ if ($[19] !== props.legacySchema.lists || $[20] !== props.textBlock.listItem) {
1321
1439
  let t32;
1322
- $[20] !== props.textBlock.listItem ? (t32 = (list) => list.value === props.textBlock.listItem, $[20] = props.textBlock.listItem, $[21] = t32) : t32 = $[21], t22 = props.legacySchema.lists.find(t32), $[17] = props.legacySchema.lists, $[18] = props.textBlock.listItem, $[19] = t22;
1440
+ $[22] !== props.textBlock.listItem ? (t32 = (list) => list.value === props.textBlock.listItem, $[22] = props.textBlock.listItem, $[23] = t32) : t32 = $[23], t22 = props.legacySchema.lists.find(t32), $[19] = props.legacySchema.lists, $[20] = props.textBlock.listItem, $[21] = t22;
1323
1441
  } else
1324
- t22 = $[19];
1442
+ t22 = $[21];
1325
1443
  const legacyListItemSchemaType = t22;
1326
1444
  if (legacyListItemSchemaType) {
1327
1445
  const t32 = props.textBlock.level ?? 1;
1328
1446
  let t42;
1329
- $[22] !== props.textBlock._key ? (t42 = [{
1447
+ $[24] !== props.textBlock._key ? (t42 = [{
1330
1448
  _key: props.textBlock._key
1331
- }], $[22] = props.textBlock._key, $[23] = t42) : t42 = $[23];
1449
+ }], $[24] = props.textBlock._key, $[25] = t42) : t42 = $[25];
1332
1450
  let t52;
1333
- $[24] !== children || $[25] !== focused || $[26] !== legacyListItemSchemaType || $[27] !== props.renderListItem || $[28] !== props.textBlock || $[29] !== selected || $[30] !== t32 || $[31] !== t42 ? (t52 = /* @__PURE__ */ jsx(RenderListItem, { renderListItem: props.renderListItem, block: props.textBlock, editorElementRef: blockRef, focused, level: t32, path: t42, selected, value: props.textBlock.listItem, schemaType: legacyListItemSchemaType, children }), $[24] = children, $[25] = focused, $[26] = legacyListItemSchemaType, $[27] = props.renderListItem, $[28] = props.textBlock, $[29] = selected, $[30] = t32, $[31] = t42, $[32] = t52) : t52 = $[32], children = t52;
1451
+ $[26] !== children || $[27] !== focused || $[28] !== legacyListItemSchemaType || $[29] !== props.renderListItem || $[30] !== props.textBlock || $[31] !== selected || $[32] !== t32 || $[33] !== t42 ? (t52 = /* @__PURE__ */ jsx(RenderListItem, { renderListItem: props.renderListItem, block: props.textBlock, editorElementRef: blockRef, focused, level: t32, path: t42, selected, value: props.textBlock.listItem, schemaType: legacyListItemSchemaType, children }), $[26] = children, $[27] = focused, $[28] = legacyListItemSchemaType, $[29] = props.renderListItem, $[30] = props.textBlock, $[31] = selected, $[32] = t32, $[33] = t42, $[34] = t52) : t52 = $[34], children = t52;
1334
1452
  } else
1335
1453
  console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
1336
1454
  }
1337
1455
  const t2 = props.attributes;
1338
1456
  let t3;
1339
- $[33] !== props.textBlock.style ? (t3 = props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], $[33] = props.textBlock.style, $[34] = t3) : t3 = $[34];
1457
+ $[35] !== props.textBlock.style ? (t3 = props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], $[35] = props.textBlock.style, $[36] = t3) : t3 = $[36];
1340
1458
  let t4;
1341
- $[35] !== props.textBlock.level || $[36] !== props.textBlock.listItem ? (t4 = props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : [], $[35] = props.textBlock.level, $[36] = props.textBlock.listItem, $[37] = t4) : t4 = $[37];
1459
+ $[37] !== props.textBlock.level || $[38] !== props.textBlock.listItem ? (t4 = props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : [], $[37] = props.textBlock.level, $[38] = props.textBlock.listItem, $[39] = t4) : t4 = $[39];
1342
1460
  let t5;
1343
- $[38] !== t3 || $[39] !== t4 ? (t5 = ["pt-block", "pt-text-block", ...t3, ...t4], $[38] = t3, $[39] = t4, $[40] = t5) : t5 = $[40];
1461
+ $[40] !== t3 || $[41] !== t4 ? (t5 = ["pt-block", "pt-text-block", ...t3, ...t4], $[40] = t3, $[41] = t4, $[42] = t5) : t5 = $[42];
1344
1462
  const t6 = t5.join(" ");
1345
1463
  let t7;
1346
- $[41] !== props.textBlock.listItem ? (t7 = props.textBlock.listItem !== void 0 ? {
1464
+ $[43] !== props.textBlock.listItem ? (t7 = props.textBlock.listItem !== void 0 ? {
1347
1465
  "data-list-item": props.textBlock.listItem
1348
- } : {}, $[41] = props.textBlock.listItem, $[42] = t7) : t7 = $[42];
1466
+ } : {}, $[43] = props.textBlock.listItem, $[44] = t7) : t7 = $[44];
1349
1467
  let t8;
1350
- $[43] !== props.textBlock.level ? (t8 = props.textBlock.level !== void 0 ? {
1468
+ $[45] !== props.textBlock.level ? (t8 = props.textBlock.level !== void 0 ? {
1351
1469
  "data-level": props.textBlock.level
1352
- } : {}, $[43] = props.textBlock.level, $[44] = t8) : t8 = $[44];
1470
+ } : {}, $[45] = props.textBlock.level, $[46] = t8) : t8 = $[46];
1353
1471
  let t9;
1354
- $[45] !== props.textBlock.style ? (t9 = props.textBlock.style !== void 0 ? {
1472
+ $[47] !== props.textBlock.style ? (t9 = props.textBlock.style !== void 0 ? {
1355
1473
  "data-style": props.textBlock.style
1356
- } : {}, $[45] = props.textBlock.style, $[46] = t9) : t9 = $[46];
1474
+ } : {}, $[47] = props.textBlock.style, $[48] = t9) : t9 = $[48];
1357
1475
  let t10;
1358
- $[47] !== listIndex ? (t10 = listIndex !== void 0 ? {
1476
+ $[49] !== listIndex ? (t10 = listIndex !== void 0 ? {
1359
1477
  "data-list-index": listIndex
1360
- } : {}, $[47] = listIndex, $[48] = t10) : t10 = $[48];
1478
+ } : {}, $[49] = listIndex, $[50] = t10) : t10 = $[50];
1361
1479
  let t11;
1362
- $[49] !== props.dropPosition ? (t11 = props.dropPosition === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[49] = props.dropPosition, $[50] = t11) : t11 = $[50];
1480
+ $[51] !== props.dropPosition ? (t11 = props.dropPosition === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[51] = props.dropPosition, $[52] = t11) : t11 = $[52];
1363
1481
  let t12;
1364
- $[51] !== children || $[52] !== focused || $[53] !== props.legacySchema || $[54] !== props.renderBlock || $[55] !== props.textBlock || $[56] !== selected ? (t12 = props.renderBlock ? /* @__PURE__ */ jsx(RenderBlock, { renderBlock: props.renderBlock, editorElementRef: blockRef, focused, level: props.textBlock.level, listItem: props.textBlock.listItem, path: [{
1482
+ $[53] !== children || $[54] !== focused || $[55] !== props.legacySchema || $[56] !== props.renderBlock || $[57] !== props.textBlock || $[58] !== selected ? (t12 = props.renderBlock ? /* @__PURE__ */ jsx(RenderBlock, { renderBlock: props.renderBlock, editorElementRef: blockRef, focused, level: props.textBlock.level, listItem: props.textBlock.listItem, path: [{
1365
1483
  _key: props.textBlock._key
1366
- }], selected, schemaType: props.legacySchema.block, style: props.textBlock.style, type: props.legacySchema.block, value: props.textBlock, children }) : children, $[51] = children, $[52] = focused, $[53] = props.legacySchema, $[54] = props.renderBlock, $[55] = props.textBlock, $[56] = selected, $[57] = t12) : t12 = $[57];
1484
+ }], selected, schemaType: props.legacySchema.block, style: props.textBlock.style, type: props.legacySchema.block, value: props.textBlock, children }) : children, $[53] = children, $[54] = focused, $[55] = props.legacySchema, $[56] = props.renderBlock, $[57] = props.textBlock, $[58] = selected, $[59] = t12) : t12 = $[59];
1367
1485
  let t13;
1368
- $[58] !== t12 ? (t13 = /* @__PURE__ */ jsx("div", { ref: blockRef, children: t12 }), $[58] = t12, $[59] = t13) : t13 = $[59];
1486
+ $[60] !== t12 ? (t13 = /* @__PURE__ */ jsx("div", { ref: blockRef, children: t12 }), $[60] = t12, $[61] = t13) : t13 = $[61];
1369
1487
  let t14;
1370
- $[60] !== props.dropPosition ? (t14 = props.dropPosition === "end" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[60] = props.dropPosition, $[61] = t14) : t14 = $[61];
1488
+ $[62] !== props.dropPosition ? (t14 = props.dropPosition === "end" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[62] = props.dropPosition, $[63] = t14) : t14 = $[63];
1371
1489
  let t15;
1372
- return $[62] !== props.attributes || $[63] !== props.spellCheck || $[64] !== props.textBlock._key || $[65] !== props.textBlock._type || $[66] !== t10 || $[67] !== t11 || $[68] !== t13 || $[69] !== t14 || $[70] !== t6 || $[71] !== t7 || $[72] !== t8 || $[73] !== t9 ? (t15 = /* @__PURE__ */ jsxs("div", { ...t2, className: t6, spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text", ...t7, ...t8, ...t9, ...t10, children: [
1490
+ return $[64] !== props.attributes || $[65] !== props.spellCheck || $[66] !== props.textBlock._key || $[67] !== props.textBlock._type || $[68] !== t10 || $[69] !== t11 || $[70] !== t13 || $[71] !== t14 || $[72] !== t6 || $[73] !== t7 || $[74] !== t8 || $[75] !== t9 ? (t15 = /* @__PURE__ */ jsxs("div", { ...t2, className: t6, spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text", ...t7, ...t8, ...t9, ...t10, children: [
1373
1491
  t11,
1374
1492
  t13,
1375
1493
  t14
1376
- ] }), $[62] = props.attributes, $[63] = props.spellCheck, $[64] = props.textBlock._key, $[65] = props.textBlock._type, $[66] = t10, $[67] = t11, $[68] = t13, $[69] = t14, $[70] = t6, $[71] = t7, $[72] = t8, $[73] = t9, $[74] = t15) : t15 = $[74], t15;
1494
+ ] }), $[64] = props.attributes, $[65] = props.spellCheck, $[66] = props.textBlock._key, $[67] = props.textBlock._type, $[68] = t10, $[69] = t11, $[70] = t13, $[71] = t14, $[72] = t6, $[73] = t7, $[74] = t8, $[75] = t9, $[76] = t15) : t15 = $[76], t15;
1377
1495
  }
1378
1496
  function RenderBlock({
1379
1497
  renderBlock,
@@ -1478,101 +1596,25 @@ function _temp2$2(s_0) {
1478
1596
  function _temp$3(s) {
1479
1597
  return s.context.schema;
1480
1598
  }
1481
- function defaultCompare(a, b) {
1482
- return a === b;
1483
- }
1484
- function useEditorSelector(editor, selector, t0) {
1485
- const $ = c(3), compare = t0 === void 0 ? defaultCompare : t0;
1486
- let t1;
1487
- return $[0] !== editor || $[1] !== selector ? (t1 = (editorActorSnapshot) => {
1488
- const snapshot = getEditorSnapshot({
1489
- editorActorSnapshot,
1490
- slateEditorInstance: editor._internal.slateEditor.instance
1491
- });
1492
- return selector(snapshot);
1493
- }, $[0] = editor, $[1] = selector, $[2] = t1) : t1 = $[2], useSelector(editor._internal.editorActor, t1, compare);
1494
- }
1495
- function getEditorSnapshot({
1496
- editorActorSnapshot,
1497
- slateEditorInstance
1498
- }) {
1499
- const selection = slateEditorInstance.selection ? slateRangeToSelection({
1500
- schema: editorActorSnapshot.context.schema,
1501
- editor: slateEditorInstance,
1502
- range: slateEditorInstance.selection
1503
- }) : null;
1504
- return {
1505
- blockIndexMap: slateEditorInstance.blockIndexMap,
1506
- context: {
1507
- converters: [...editorActorSnapshot.context.converters],
1508
- keyGenerator: editorActorSnapshot.context.keyGenerator,
1509
- readOnly: editorActorSnapshot.matches({
1510
- "edit mode": "read only"
1511
- }),
1512
- schema: editorActorSnapshot.context.schema,
1513
- selection,
1514
- value: slateEditorInstance.value
1515
- },
1516
- decoratorState: slateEditorInstance.decoratorState
1517
- };
1518
- }
1519
1599
  function RenderSpan(props) {
1520
- const $ = c(40), slateEditor = useSlateStatic(), editorActor = useContext(EditorActorContext), legacySchema = useSelector(editorActor, _temp$2), spanRef = useRef(null);
1600
+ const $ = c(35), slateEditor = useSlateStatic(), editorActor = useContext(EditorActorContext), legacySchema = useSelector(editorActor, _temp$2), spanRef = useRef(null), selectionState = useContext(SelectionStateContext), focused = selectionState.focusedChildKey === props.leaf._key;
1521
1601
  let t0;
1522
- $[0] !== props.leaf._key || $[1] !== slateEditor ? (t0 = (editorActorSnapshot) => {
1523
- const snapshot = getEditorSnapshot({
1524
- editorActorSnapshot,
1525
- slateEditorInstance: slateEditor
1526
- });
1527
- if (!snapshot.context.selection || !isSelectionCollapsed$1(snapshot))
1528
- return !1;
1529
- const focusedSpan = getFocusSpan$1(snapshot);
1530
- return focusedSpan ? focusedSpan.node._key === props.leaf._key : !1;
1531
- }, $[0] = props.leaf._key, $[1] = slateEditor, $[2] = t0) : t0 = $[2];
1532
- const focused = useSelector(editorActor, t0);
1602
+ $[0] !== props.leaf._key || $[1] !== selectionState.selectedChildKeys ? (t0 = selectionState.selectedChildKeys.has(props.leaf._key), $[0] = props.leaf._key, $[1] = selectionState.selectedChildKeys, $[2] = t0) : t0 = $[2];
1603
+ const selected = t0, parent = props.children.props.parent, block = parent && slateEditor.isTextBlock(parent) ? parent : void 0;
1533
1604
  let t1;
1534
- $[3] !== props.children.props.parent || $[4] !== props.leaf._key || $[5] !== props.leaf.text || $[6] !== slateEditor ? (t1 = (editorActorSnapshot_0) => {
1535
- const snapshot_0 = getEditorSnapshot({
1536
- editorActorSnapshot: editorActorSnapshot_0,
1537
- slateEditorInstance: slateEditor
1538
- });
1539
- if (!snapshot_0.context.selection)
1540
- return !1;
1541
- const parent = props.children.props.parent, block = parent && isTextBlock(snapshot_0.context, parent) ? parent : void 0, spanSelection = block ? {
1542
- anchor: {
1543
- path: [{
1544
- _key: block._key
1545
- }, "children", {
1546
- _key: props.leaf._key
1547
- }],
1548
- offset: 0
1549
- },
1550
- focus: {
1551
- path: [{
1552
- _key: block._key
1553
- }, "children", {
1554
- _key: props.leaf._key
1555
- }],
1556
- offset: props.leaf.text.length
1557
- }
1558
- } : null;
1559
- return isOverlappingSelection(spanSelection)(snapshot_0);
1560
- }, $[3] = props.children.props.parent, $[4] = props.leaf._key, $[5] = props.leaf.text, $[6] = slateEditor, $[7] = t1) : t1 = $[7];
1561
- const selected = useSelector(editorActor, t1), parent_0 = props.children.props.parent, block_0 = parent_0 && slateEditor.isTextBlock(parent_0) ? parent_0 : void 0;
1562
- let t2;
1563
- $[8] !== block_0 || $[9] !== props.leaf._key ? (t2 = block_0 ? [{
1564
- _key: block_0._key
1605
+ $[3] !== block || $[4] !== props.leaf._key ? (t1 = block ? [{
1606
+ _key: block._key
1565
1607
  }, "children", {
1566
1608
  _key: props.leaf._key
1567
- }] : void 0, $[8] = block_0, $[9] = props.leaf._key, $[10] = t2) : t2 = $[10];
1568
- const path = t2;
1609
+ }] : void 0, $[3] = block, $[4] = props.leaf._key, $[5] = t1) : t1 = $[5];
1610
+ const path = t1;
1569
1611
  let annotationMarkDefs, children;
1570
- if ($[11] !== block_0 || $[12] !== editorActor || $[13] !== focused || $[14] !== legacySchema || $[15] !== path || $[16] !== props.children || $[17] !== props.leaf.marks || $[18] !== props.renderAnnotation || $[19] !== props.renderDecorator || $[20] !== selected) {
1612
+ if ($[6] !== block || $[7] !== editorActor || $[8] !== focused || $[9] !== legacySchema || $[10] !== path || $[11] !== props.children || $[12] !== props.leaf.marks || $[13] !== props.renderAnnotation || $[14] !== props.renderDecorator || $[15] !== selected) {
1571
1613
  const decoratorSchemaTypes = editorActor.getSnapshot().context.schema.decorators.map(_temp2$1), decorators = [...new Set((props.leaf.marks ?? []).filter((mark) => decoratorSchemaTypes.includes(mark)))];
1572
1614
  annotationMarkDefs = (props.leaf.marks ?? []).flatMap((mark_0) => {
1573
1615
  if (decoratorSchemaTypes.includes(mark_0))
1574
1616
  return [];
1575
- const markDef_0 = block_0?.markDefs?.find((markDef) => markDef._key === mark_0);
1617
+ const markDef_0 = block?.markDefs?.find((markDef) => markDef._key === mark_0);
1576
1618
  return markDef_0 ? [markDef_0] : [];
1577
1619
  }), children = props.children;
1578
1620
  for (const mark_1 of decorators) {
@@ -1581,26 +1623,26 @@ function RenderSpan(props) {
1581
1623
  }
1582
1624
  for (const annotationMarkDef of annotationMarkDefs) {
1583
1625
  const legacyAnnotationSchemaType = legacySchema.annotations.find((t) => t.name === annotationMarkDef._type);
1584
- legacyAnnotationSchemaType && (block_0 && path && props.renderAnnotation ? children = /* @__PURE__ */ jsx("span", { ref: spanRef, children: /* @__PURE__ */ jsx(RenderAnnotation, { renderAnnotation: props.renderAnnotation, block: block_0, editorElementRef: spanRef, focused, path, selected, schemaType: legacyAnnotationSchemaType, value: annotationMarkDef, type: legacyAnnotationSchemaType, children }) }) : children = /* @__PURE__ */ jsx("span", { ref: spanRef, children }));
1626
+ legacyAnnotationSchemaType && (block && path && props.renderAnnotation ? children = /* @__PURE__ */ jsx("span", { ref: spanRef, children: /* @__PURE__ */ jsx(RenderAnnotation, { renderAnnotation: props.renderAnnotation, block, editorElementRef: spanRef, focused, path, selected, schemaType: legacyAnnotationSchemaType, value: annotationMarkDef, type: legacyAnnotationSchemaType, children }) }) : children = /* @__PURE__ */ jsx("span", { ref: spanRef, children }));
1585
1627
  }
1586
- $[11] = block_0, $[12] = editorActor, $[13] = focused, $[14] = legacySchema, $[15] = path, $[16] = props.children, $[17] = props.leaf.marks, $[18] = props.renderAnnotation, $[19] = props.renderDecorator, $[20] = selected, $[21] = annotationMarkDefs, $[22] = children;
1628
+ $[6] = block, $[7] = editorActor, $[8] = focused, $[9] = legacySchema, $[10] = path, $[11] = props.children, $[12] = props.leaf.marks, $[13] = props.renderAnnotation, $[14] = props.renderDecorator, $[15] = selected, $[16] = annotationMarkDefs, $[17] = children;
1587
1629
  } else
1588
- annotationMarkDefs = $[21], children = $[22];
1589
- if (block_0 && path && props.renderChild) {
1590
- let t32;
1591
- if ($[23] !== block_0.children || $[24] !== props.leaf) {
1592
- let t4;
1593
- $[26] !== props.leaf ? (t4 = (_child) => _child._key === props.leaf._key, $[26] = props.leaf, $[27] = t4) : t4 = $[27], t32 = block_0.children.find(t4), $[23] = block_0.children, $[24] = props.leaf, $[25] = t32;
1630
+ annotationMarkDefs = $[16], children = $[17];
1631
+ if (block && path && props.renderChild) {
1632
+ let t22;
1633
+ if ($[18] !== block.children || $[19] !== props.leaf) {
1634
+ let t3;
1635
+ $[21] !== props.leaf ? (t3 = (_child) => _child._key === props.leaf._key, $[21] = props.leaf, $[22] = t3) : t3 = $[22], t22 = block.children.find(t3), $[18] = block.children, $[19] = props.leaf, $[20] = t22;
1594
1636
  } else
1595
- t32 = $[25];
1596
- const child = t32;
1637
+ t22 = $[20];
1638
+ const child = t22;
1597
1639
  if (child) {
1598
- let t4;
1599
- $[28] !== annotationMarkDefs || $[29] !== child || $[30] !== children || $[31] !== focused || $[32] !== legacySchema.span || $[33] !== path || $[34] !== props.renderChild || $[35] !== selected ? (t4 = /* @__PURE__ */ jsx(RenderChild, { renderChild: props.renderChild, annotations: annotationMarkDefs, editorElementRef: spanRef, focused, path, schemaType: legacySchema.span, selected, value: child, type: legacySchema.span, children }), $[28] = annotationMarkDefs, $[29] = child, $[30] = children, $[31] = focused, $[32] = legacySchema.span, $[33] = path, $[34] = props.renderChild, $[35] = selected, $[36] = t4) : t4 = $[36], children = t4;
1640
+ let t3;
1641
+ $[23] !== annotationMarkDefs || $[24] !== child || $[25] !== children || $[26] !== focused || $[27] !== legacySchema.span || $[28] !== path || $[29] !== props.renderChild || $[30] !== selected ? (t3 = /* @__PURE__ */ jsx(RenderChild, { renderChild: props.renderChild, annotations: annotationMarkDefs, editorElementRef: spanRef, focused, path, schemaType: legacySchema.span, selected, value: child, type: legacySchema.span, children }), $[23] = annotationMarkDefs, $[24] = child, $[25] = children, $[26] = focused, $[27] = legacySchema.span, $[28] = path, $[29] = props.renderChild, $[30] = selected, $[31] = t3) : t3 = $[31], children = t3;
1600
1642
  }
1601
1643
  }
1602
- let t3;
1603
- return $[37] !== children || $[38] !== props.attributes ? (t3 = /* @__PURE__ */ jsx("span", { ...props.attributes, ref: spanRef, children }), $[37] = children, $[38] = props.attributes, $[39] = t3) : t3 = $[39], t3;
1644
+ let t2;
1645
+ return $[32] !== children || $[33] !== props.attributes ? (t2 = /* @__PURE__ */ jsx("span", { ...props.attributes, ref: spanRef, children }), $[32] = children, $[33] = props.attributes, $[34] = t2) : t2 = $[34], t2;
1604
1646
  }
1605
1647
  function _temp2$1(decorator) {
1606
1648
  return decorator.name;
@@ -2713,7 +2755,7 @@ const debug$b = debugWithName("component:Editable"), PortableTextEditable = forw
2713
2755
  if (!portableTextEditor)
2714
2756
  return null;
2715
2757
  let t39;
2716
- return $[152] !== callbackRef || $[153] !== decorate || $[154] !== handleClick || $[155] !== handleCopy || $[156] !== handleCut || $[157] !== handleDrag || $[158] !== handleDragEnd || $[159] !== handleDragEnter || $[160] !== handleDragLeave || $[161] !== handleDragOver || $[162] !== handleDragStart || $[163] !== handleDrop || $[164] !== handleKeyDown || $[165] !== handleKeyUp || $[166] !== handleOnBeforeInput || $[167] !== handleOnBlur || $[168] !== handleOnFocus || $[169] !== handlePaste || $[170] !== hasInvalidValue || $[171] !== readOnly || $[172] !== renderElement || $[173] !== renderLeaf || $[174] !== restProps || $[175] !== scrollSelectionIntoViewToSlate ? (t39 = hasInvalidValue ? null : /* @__PURE__ */ jsx(Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }), $[152] = callbackRef, $[153] = decorate, $[154] = handleClick, $[155] = handleCopy, $[156] = handleCut, $[157] = handleDrag, $[158] = handleDragEnd, $[159] = handleDragEnter, $[160] = handleDragLeave, $[161] = handleDragOver, $[162] = handleDragStart, $[163] = handleDrop, $[164] = handleKeyDown, $[165] = handleKeyUp, $[166] = handleOnBeforeInput, $[167] = handleOnBlur, $[168] = handleOnFocus, $[169] = handlePaste, $[170] = hasInvalidValue, $[171] = readOnly, $[172] = renderElement, $[173] = renderLeaf, $[174] = restProps, $[175] = scrollSelectionIntoViewToSlate, $[176] = t39) : t39 = $[176], t39;
2758
+ return $[152] !== callbackRef || $[153] !== decorate || $[154] !== handleClick || $[155] !== handleCopy || $[156] !== handleCut || $[157] !== handleDrag || $[158] !== handleDragEnd || $[159] !== handleDragEnter || $[160] !== handleDragLeave || $[161] !== handleDragOver || $[162] !== handleDragStart || $[163] !== handleDrop || $[164] !== handleKeyDown || $[165] !== handleKeyUp || $[166] !== handleOnBeforeInput || $[167] !== handleOnBlur || $[168] !== handleOnFocus || $[169] !== handlePaste || $[170] !== hasInvalidValue || $[171] !== readOnly || $[172] !== renderElement || $[173] !== renderLeaf || $[174] !== restProps || $[175] !== scrollSelectionIntoViewToSlate ? (t39 = hasInvalidValue ? null : /* @__PURE__ */ jsx(SelectionStateProvider, { children: /* @__PURE__ */ jsx(Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }) }), $[152] = callbackRef, $[153] = decorate, $[154] = handleClick, $[155] = handleCopy, $[156] = handleCut, $[157] = handleDrag, $[158] = handleDragEnd, $[159] = handleDragEnter, $[160] = handleDragLeave, $[161] = handleDragOver, $[162] = handleDragStart, $[163] = handleDrop, $[164] = handleKeyDown, $[165] = handleKeyUp, $[166] = handleOnBeforeInput, $[167] = handleOnBlur, $[168] = handleOnFocus, $[169] = handlePaste, $[170] = hasInvalidValue, $[171] = readOnly, $[172] = renderElement, $[173] = renderLeaf, $[174] = restProps, $[175] = scrollSelectionIntoViewToSlate, $[176] = t39) : t39 = $[176], t39;
2717
2759
  });
2718
2760
  PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
2719
2761
  function noop() {