@portabletext/editor 1.49.0 → 1.49.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.
package/lib/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), editorProvider = require("./_chunks-cjs/editor-provider.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), selector_getFocusInlineObject = require("./_chunks-cjs/selector.get-focus-inline-object.cjs"), slateDom = require("slate-dom"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), util_selectionPointToBlockOffset = require("./_chunks-cjs/util.selection-point-to-block-offset.cjs"), uniq = require("lodash/uniq.js"), behaviors_index = require("./behaviors/index.cjs"), xstate = require("xstate");
3
+ var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), editorProvider = require("./_chunks-cjs/editor-provider.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), selector_getFocusInlineObject = require("./_chunks-cjs/selector.get-focus-inline-object.cjs"), slateDom = require("slate-dom"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), util_selectionPointToBlockOffset = require("./_chunks-cjs/util.selection-point-to-block-offset.cjs"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), xstate = require("xstate");
4
4
  function _interopDefaultCompat(e) {
5
5
  return e && typeof e == "object" && "default" in e ? e : { default: e };
6
6
  }
@@ -330,130 +330,6 @@ function getSelectionDomNodes({
330
330
  childNodes: childEntries.map(([childNode]) => slateDom.DOMEditor.toDOMNode(slateEditor, childNode))
331
331
  };
332
332
  }
333
- const debug$2 = editorProvider.debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (props) => {
334
- const {
335
- editorActor,
336
- attributes,
337
- children,
338
- leaf,
339
- schemaTypes,
340
- renderChild,
341
- renderDecorator,
342
- renderAnnotation
343
- } = props, spanRef = React.useRef(null), portableTextEditor = editorProvider.usePortableTextEditor(), blockSelected = slateReact.useSelected(), [focused, setFocused] = React.useState(!1), [selected, setSelected] = React.useState(!1), block = children.props.parent, path = React.useMemo(() => block ? [{
344
- _key: block?._key
345
- }, "children", {
346
- _key: leaf._key
347
- }] : [], [block, leaf._key]), decoratorValues = React.useMemo(() => schemaTypes.decorators.map((dec) => dec.value), [schemaTypes.decorators]), marks = React.useMemo(() => uniq__default.default((leaf.marks || EMPTY_MARKS).filter((mark) => decoratorValues.includes(mark))), [decoratorValues, leaf.marks]), annotationMarks = Array.isArray(leaf.marks) ? leaf.marks : EMPTY_MARKS, annotations = React.useMemo(() => annotationMarks.map((mark_0) => !decoratorValues.includes(mark_0) && block?.markDefs?.find((def) => def._key === mark_0)).filter(Boolean), [annotationMarks, block, decoratorValues]), shouldTrackSelectionAndFocus = annotations.length > 0 && blockSelected;
348
- React.useEffect(() => {
349
- if (!shouldTrackSelectionAndFocus) {
350
- setFocused(!1);
351
- return;
352
- }
353
- const sel = editorProvider.PortableTextEditor.getSelection(portableTextEditor);
354
- sel && isEqual__default.default(sel.focus.path, path) && editorProvider.PortableTextEditor.isCollapsedSelection(portableTextEditor) && React.startTransition(() => {
355
- setFocused(!0);
356
- });
357
- }, [shouldTrackSelectionAndFocus, path, portableTextEditor]);
358
- const setSelectedFromRange = React.useCallback(() => {
359
- if (!shouldTrackSelectionAndFocus)
360
- return;
361
- debug$2("Setting selection and focus from range");
362
- const winSelection = window.getSelection();
363
- if (!winSelection) {
364
- setSelected(!1);
365
- return;
366
- }
367
- if (winSelection && winSelection.rangeCount > 0) {
368
- const range = winSelection.getRangeAt(0);
369
- spanRef.current && range.intersectsNode(spanRef.current) ? setSelected(!0) : setSelected(!1);
370
- } else
371
- setSelected(!1);
372
- }, [shouldTrackSelectionAndFocus]);
373
- React.useEffect(() => {
374
- if (!shouldTrackSelectionAndFocus)
375
- return;
376
- const onBlur = editorActor.on("blurred", () => {
377
- setFocused(!1), setSelected(!1);
378
- }), onFocus = editorActor.on("focused", () => {
379
- const sel_0 = editorProvider.PortableTextEditor.getSelection(portableTextEditor);
380
- sel_0 && isEqual__default.default(sel_0.focus.path, path) && editorProvider.PortableTextEditor.isCollapsedSelection(portableTextEditor) && setFocused(!0), setSelectedFromRange();
381
- }), onSelection = editorActor.on("selection", (event) => {
382
- event.selection && isEqual__default.default(event.selection.focus.path, path) && editorProvider.PortableTextEditor.isCollapsedSelection(portableTextEditor) ? setFocused(!0) : setFocused(!1), setSelectedFromRange();
383
- });
384
- return () => {
385
- onBlur.unsubscribe(), onFocus.unsubscribe(), onSelection.unsubscribe();
386
- };
387
- }, [editorActor, path, portableTextEditor, setSelectedFromRange, shouldTrackSelectionAndFocus]), React.useEffect(() => setSelectedFromRange(), [setSelectedFromRange]);
388
- const content = React.useMemo(() => {
389
- let returnedChildren = children;
390
- if (slate.Text.isText(leaf) && leaf._type === schemaTypes.span.name && (marks.forEach((mark_1) => {
391
- const schemaType = schemaTypes.decorators.find((dec_0) => dec_0.value === mark_1);
392
- if (schemaType && renderDecorator) {
393
- const _props = Object.defineProperty({
394
- children: returnedChildren,
395
- editorElementRef: spanRef,
396
- focused,
397
- path,
398
- selected,
399
- schemaType,
400
- value: mark_1
401
- }, "type", {
402
- enumerable: !1,
403
- get() {
404
- return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaType;
405
- }
406
- });
407
- returnedChildren = renderDecorator(_props);
408
- }
409
- }), block && annotations.length > 0 && annotations.forEach((annotation) => {
410
- const schemaType_0 = schemaTypes.annotations.find((t) => t.name === annotation._type);
411
- if (schemaType_0)
412
- if (renderAnnotation) {
413
- const _props_0 = Object.defineProperty({
414
- block,
415
- children: returnedChildren,
416
- editorElementRef: spanRef,
417
- focused,
418
- path,
419
- selected,
420
- schemaType: schemaType_0,
421
- value: annotation
422
- }, "type", {
423
- enumerable: !1,
424
- get() {
425
- return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaType_0;
426
- }
427
- });
428
- returnedChildren = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children: renderAnnotation(_props_0) });
429
- } else
430
- returnedChildren = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children: returnedChildren });
431
- }), block && renderChild)) {
432
- const child = block.children.find((_child) => _child._key === leaf._key);
433
- if (child) {
434
- const _props_1 = Object.defineProperty({
435
- annotations,
436
- children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: returnedChildren }),
437
- editorElementRef: spanRef,
438
- focused,
439
- path,
440
- schemaType: schemaTypes.span,
441
- selected,
442
- value: child
443
- }, "type", {
444
- enumerable: !1,
445
- get() {
446
- return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaTypes.span;
447
- }
448
- });
449
- returnedChildren = renderChild(_props_1);
450
- }
451
- }
452
- return returnedChildren;
453
- }, [annotations, block, children, focused, leaf, marks, path, renderAnnotation, renderChild, renderDecorator, schemaTypes.annotations, schemaTypes.decorators, schemaTypes.span, selected]);
454
- return React.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("span", { ...attributes, ref: spanRef, "data-child-key": leaf._key, "data-child-name": leaf._type, "data-child-type": "span", children: content }, leaf._key), [leaf, attributes, content]);
455
- };
456
- Leaf.displayName = "Leaf";
457
333
  function DropIndicator() {
458
334
  const $ = reactCompilerRuntime.c(1);
459
335
  let t0;
@@ -615,7 +491,7 @@ function RenderBlockObject(props) {
615
491
  value: props.blockObject
616
492
  }) : /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultBlockObject, { blockObject: props.blockObject }) }),
617
493
  dragPositionBlock === "end" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
618
- ] }, props.element._key);
494
+ ] });
619
495
  }
620
496
  function RenderInlineObject(props) {
621
497
  const inlineObjectRef = React.useRef(null), slateEditor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), editorActor = React.useContext(editorProvider.EditorActorContext), legacySchemaType = react.useSelector(editorActor, (s) => s.context.getLegacySchema().inlineObjects.find((inlineObject) => inlineObject.name === props.element._type));
@@ -627,11 +503,11 @@ function RenderInlineObject(props) {
627
503
  offset: 0
628
504
  }
629
505
  });
630
- return block || console.error(`Unable to find parent block of inline object ${props.element._key}`), /* @__PURE__ */ jsxRuntime.jsxs("span", { ...props.attributes, children: [
506
+ return block || console.error(`Unable to find parent block of inline object ${props.element._key}`), /* @__PURE__ */ jsxRuntime.jsxs("span", { ...props.attributes, draggable: !props.readOnly, className: "pt-inline-object", "data-child-key": props.inlineObject._key, "data-child-name": props.inlineObject._type, "data-child-type": "object", children: [
631
507
  props.children,
632
- /* @__PURE__ */ jsxRuntime.jsx("span", { draggable: !props.readOnly, className: "pt-inline-object", "data-testid": "pt-inline-object", ref: inlineObjectRef, style: {
508
+ /* @__PURE__ */ jsxRuntime.jsx("span", { ref: inlineObjectRef, style: {
633
509
  display: "inline-block"
634
- }, "data-child-key": props.inlineObject._key, "data-child-name": props.inlineObject._type, "data-child-type": "object", children: props.renderChild && block && legacySchemaType ? props.renderChild({
510
+ }, children: props.renderChild && block && legacySchemaType ? props.renderChild({
635
511
  annotations: [],
636
512
  children: /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultInlineObject, { inlineObject: props.inlineObject }),
637
513
  editorElementRef: inlineObjectRef,
@@ -645,7 +521,7 @@ function RenderInlineObject(props) {
645
521
  schemaType: legacySchemaType,
646
522
  value: props.inlineObject,
647
523
  type: legacySchemaType
648
- }) : /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultInlineObject, { inlineObject: props.inlineObject }) }, props.element._key)
524
+ }) : /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultInlineObject, { inlineObject: props.inlineObject }) })
649
525
  ] });
650
526
  }
651
527
  function RenderTextBlock(props) {
@@ -706,10 +582,10 @@ function RenderTextBlock(props) {
706
582
  value: props.textBlock
707
583
  }) : props.children }),
708
584
  dragPositionBlock === "end" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
709
- ] }, props.element._key);
585
+ ] });
710
586
  }
711
587
  function RenderElement(props) {
712
- const $ = reactCompilerRuntime.c(45), editorActor = React.useContext(editorProvider.EditorActorContext), schema = react.useSelector(editorActor, _temp);
588
+ const $ = reactCompilerRuntime.c(45), editorActor = React.useContext(editorProvider.EditorActorContext), schema = react.useSelector(editorActor, _temp$1);
713
589
  if ("__inline" in props.element && props.element.__inline === !0) {
714
590
  let t02;
715
591
  if ($[0] !== props.element || $[1] !== schema) {
@@ -794,9 +670,145 @@ function _temp3() {
794
670
  function _temp2() {
795
671
  return "";
796
672
  }
673
+ function _temp$1(s) {
674
+ return s.context.schema;
675
+ }
676
+ function RenderSpan(props) {
677
+ const slateEditor = slateReact.useSlateStatic(), editorActor = React.useContext(editorProvider.EditorActorContext), legacySchema = react.useSelector(editorActor, (s) => s.context.getLegacySchema()), spanRef = React.useRef(null), portableTextEditor = editorProvider.usePortableTextEditor(), blockSelected = slateReact.useSelected(), [focused, setFocused] = React.useState(!1), [selected, setSelected] = React.useState(!1), parent = props.children.props.parent, block = parent && slateEditor.isTextBlock(parent) ? parent : void 0, path = React.useMemo(() => block ? [{
678
+ _key: block._key
679
+ }, "children", {
680
+ _key: props.leaf._key
681
+ }] : void 0, [block, props.leaf._key]), decoratorSchemaTypes = editorActor.getSnapshot().context.schema.decorators.map((decorator) => decorator.name), decorators = uniq__default.default((props.leaf.marks ?? []).filter((mark) => decoratorSchemaTypes.includes(mark))), annotationMarkDefs = (props.leaf.marks ?? []).flatMap((mark_0) => {
682
+ if (decoratorSchemaTypes.includes(mark_0))
683
+ return [];
684
+ const markDef_0 = block?.markDefs?.find((markDef) => markDef._key === mark_0);
685
+ return markDef_0 ? [markDef_0] : [];
686
+ }), shouldTrackSelectionAndFocus = annotationMarkDefs.length > 0 && blockSelected;
687
+ React.useEffect(() => {
688
+ if (!shouldTrackSelectionAndFocus) {
689
+ setFocused(!1);
690
+ return;
691
+ }
692
+ const sel = editorProvider.PortableTextEditor.getSelection(portableTextEditor);
693
+ sel && isEqual__default.default(sel.focus.path, path) && editorProvider.PortableTextEditor.isCollapsedSelection(portableTextEditor) && React.startTransition(() => {
694
+ setFocused(!0);
695
+ });
696
+ }, [shouldTrackSelectionAndFocus, path, portableTextEditor]);
697
+ const setSelectedFromRange = React.useCallback(() => {
698
+ if (!shouldTrackSelectionAndFocus)
699
+ return;
700
+ const winSelection = window.getSelection();
701
+ if (!winSelection) {
702
+ setSelected(!1);
703
+ return;
704
+ }
705
+ if (winSelection && winSelection.rangeCount > 0) {
706
+ const range = winSelection.getRangeAt(0);
707
+ spanRef.current && range.intersectsNode(spanRef.current) ? setSelected(!0) : setSelected(!1);
708
+ } else
709
+ setSelected(!1);
710
+ }, [shouldTrackSelectionAndFocus]);
711
+ React.useEffect(() => {
712
+ if (!shouldTrackSelectionAndFocus)
713
+ return;
714
+ const onBlur = editorActor.on("blurred", () => {
715
+ setFocused(!1), setSelected(!1);
716
+ }), onFocus = editorActor.on("focused", () => {
717
+ const sel_0 = editorProvider.PortableTextEditor.getSelection(portableTextEditor);
718
+ sel_0 && isEqual__default.default(sel_0.focus.path, path) && editorProvider.PortableTextEditor.isCollapsedSelection(portableTextEditor) && setFocused(!0), setSelectedFromRange();
719
+ }), onSelection = editorActor.on("selection", (event) => {
720
+ event.selection && isEqual__default.default(event.selection.focus.path, path) && editorProvider.PortableTextEditor.isCollapsedSelection(portableTextEditor) ? setFocused(!0) : setFocused(!1), setSelectedFromRange();
721
+ });
722
+ return () => {
723
+ onBlur.unsubscribe(), onFocus.unsubscribe(), onSelection.unsubscribe();
724
+ };
725
+ }, [editorActor, path, portableTextEditor, setSelectedFromRange, shouldTrackSelectionAndFocus]), React.useEffect(() => setSelectedFromRange(), [setSelectedFromRange]);
726
+ let children = props.children;
727
+ for (const mark_1 of decorators) {
728
+ const legacyDecoratorSchemaType = legacySchema.decorators.find((dec) => dec.value === mark_1);
729
+ path && legacyDecoratorSchemaType && props.renderDecorator && (children = props.renderDecorator({
730
+ children,
731
+ editorElementRef: spanRef,
732
+ focused,
733
+ path,
734
+ selected,
735
+ schemaType: legacyDecoratorSchemaType,
736
+ value: mark_1,
737
+ type: legacyDecoratorSchemaType
738
+ }));
739
+ }
740
+ for (const annotationMarkDef of annotationMarkDefs) {
741
+ const legacyAnnotationSchemaType = legacySchema.annotations.find((t) => t.name === annotationMarkDef._type);
742
+ legacyAnnotationSchemaType && (block && path && props.renderAnnotation ? children = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children: props.renderAnnotation({
743
+ block,
744
+ children,
745
+ editorElementRef: spanRef,
746
+ focused,
747
+ path,
748
+ selected,
749
+ schemaType: legacyAnnotationSchemaType,
750
+ value: annotationMarkDef,
751
+ type: legacyAnnotationSchemaType
752
+ }) }) : children = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children }));
753
+ }
754
+ if (block && path && props.renderChild) {
755
+ const child = block.children.find((_child) => _child._key === props.leaf._key);
756
+ child && (children = props.renderChild({
757
+ annotations: annotationMarkDefs,
758
+ children,
759
+ editorElementRef: spanRef,
760
+ focused,
761
+ path,
762
+ schemaType: legacySchema.span,
763
+ selected,
764
+ value: child,
765
+ type: legacySchema.span
766
+ }));
767
+ }
768
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, ref: spanRef, children });
769
+ }
770
+ const PLACEHOLDER_STYLE = {
771
+ position: "absolute",
772
+ userSelect: "none",
773
+ pointerEvents: "none",
774
+ left: 0,
775
+ right: 0
776
+ };
777
+ function RenderLeaf(props) {
778
+ const $ = reactCompilerRuntime.c(12), editorActor = React.useContext(editorProvider.EditorActorContext), schema = react.useSelector(editorActor, _temp);
779
+ if (props.leaf._type !== schema.span.name)
780
+ return props.children;
781
+ let t0;
782
+ $[0] !== props ? (t0 = /* @__PURE__ */ jsxRuntime.jsx(RenderSpan, { ...props }), $[0] = props, $[1] = t0) : t0 = $[1];
783
+ let renderedSpan = t0;
784
+ if (props.renderPlaceholder && props.leaf.placeholder && props.text.text === "") {
785
+ let t1;
786
+ $[2] !== props.renderPlaceholder ? (t1 = props.renderPlaceholder(), $[2] = props.renderPlaceholder, $[3] = t1) : t1 = $[3];
787
+ let t2;
788
+ $[4] !== t1 ? (t2 = /* @__PURE__ */ jsxRuntime.jsx("span", { style: PLACEHOLDER_STYLE, contentEditable: !1, children: t1 }), $[4] = t1, $[5] = t2) : t2 = $[5];
789
+ let t3;
790
+ return $[6] !== renderedSpan || $[7] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
791
+ t2,
792
+ renderedSpan
793
+ ] }), $[6] = renderedSpan, $[7] = t2, $[8] = t3) : t3 = $[8], t3;
794
+ }
795
+ const rangeDecoration = props.leaf.rangeDecoration;
796
+ if (rangeDecoration) {
797
+ let t1;
798
+ $[9] !== rangeDecoration || $[10] !== renderedSpan ? (t1 = rangeDecoration.component({
799
+ children: renderedSpan
800
+ }), $[9] = rangeDecoration, $[10] = renderedSpan, $[11] = t1) : t1 = $[11], renderedSpan = t1;
801
+ }
802
+ return renderedSpan;
803
+ }
797
804
  function _temp(s) {
798
805
  return s.context.schema;
799
806
  }
807
+ function RenderText(props) {
808
+ const $ = reactCompilerRuntime.c(5);
809
+ let t0;
810
+ return $[0] !== props.attributes || $[1] !== props.children || $[2] !== props.text._key || $[3] !== props.text._type ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, "data-child-key": props.text._key, "data-child-name": props.text._type, "data-child-type": "span", children: props.children }), $[0] = props.attributes, $[1] = props.children, $[2] = props.text._key, $[3] = props.text._type, $[4] = t0) : t0 = $[4], t0;
811
+ }
800
812
  const debug$1 = editorProvider.debugWithName("plugin:withHotKeys");
801
813
  function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions) {
802
814
  const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions ?? {};
@@ -1113,13 +1125,7 @@ function createDecorate(rangeDecorationActor) {
1113
1125
  }) || slate.Range.includes(decoratedRange, path));
1114
1126
  };
1115
1127
  }
1116
- const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_STYLE = {
1117
- position: "absolute",
1118
- userSelect: "none",
1119
- pointerEvents: "none",
1120
- left: 0,
1121
- right: 0
1122
- }, PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
1128
+ const debug = editorProvider.debugWithName("component:Editable"), PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
1123
1129
  const {
1124
1130
  hotkeys,
1125
1131
  onBlur,
@@ -1181,21 +1187,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1181
1187
  const withHotKeys = createWithHotkeys(editorActor, portableTextEditor, hotkeys);
1182
1188
  return debug("Editable is in edit mode"), withHotKeys(slateEditor);
1183
1189
  }, [editorActor, hotkeys, portableTextEditor, readOnly, slateEditor]);
1184
- const renderElement = React.useCallback((eProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderElement, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, spellCheck }), [spellCheck, readOnly, renderBlock, renderChild, renderListItem, renderStyle]), renderLeaf = React.useCallback((lProps) => {
1185
- if (lProps.leaf._type === "span") {
1186
- let rendered = /* @__PURE__ */ jsxRuntime.jsx(Leaf, { ...lProps, editorActor, schemaTypes: portableTextEditor.schemaTypes, renderAnnotation, renderChild, renderDecorator, readOnly });
1187
- if (renderPlaceholder && lProps.leaf.placeholder && lProps.text.text === "")
1188
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1189
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: PLACEHOLDER_STYLE, contentEditable: !1, children: renderPlaceholder() }),
1190
- rendered
1191
- ] });
1192
- const decoration = lProps.leaf.rangeDecoration;
1193
- return decoration && (rendered = decoration.component({
1194
- children: rendered
1195
- })), rendered;
1196
- }
1197
- return lProps.children;
1198
- }, [editorActor, portableTextEditor, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder]), restoreSelectionFromProps = React.useCallback(() => {
1190
+ const renderElement = React.useCallback((eProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderElement, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, spellCheck }), [spellCheck, readOnly, renderBlock, renderChild, renderListItem, renderStyle]), renderLeaf = React.useCallback((leafProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderLeaf, { ...leafProps, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder }), [readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder]), renderText = React.useCallback((props_0) => /* @__PURE__ */ jsxRuntime.jsx(RenderText, { ...props_0 }), []), restoreSelectionFromProps = React.useCallback(() => {
1199
1191
  if (propsSelection) {
1200
1192
  debug(`Selection from props ${JSON.stringify(propsSelection)}`);
1201
1193
  const normalizedSelection = normalizeSelection(propsSelection, editorProvider.fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name));
@@ -1706,6 +1698,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
1706
1698
  renderPlaceholder: void 0,
1707
1699
  renderElement,
1708
1700
  renderLeaf,
1701
+ renderText,
1709
1702
  scrollSelectionIntoView: scrollSelectionIntoViewToSlate
1710
1703
  }
1711
1704
  ) : null;