@portabletext/editor 1.48.15 → 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/_chunks-cjs/editor-provider.cjs +32 -17
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -0
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +32 -17
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +2 -0
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.cjs +360 -294
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +367 -301
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/behaviors/behavior.core.block-element.ts +108 -0
- package/src/converters/converter.portable-text.ts +4 -1
- package/src/converters/converter.text-html.ts +4 -1
- package/src/converters/converter.text-plain.ts +4 -1
- package/src/editor/Editable.tsx +21 -52
- package/src/editor/__tests__/PortableTextEditor.test.tsx +6 -0
- package/src/editor/__tests__/RangeDecorations.test.tsx +2 -2
- package/src/editor/components/render-block-object.tsx +89 -0
- package/src/editor/components/render-default-object.tsx +21 -0
- package/src/editor/components/render-element.tsx +140 -0
- package/src/editor/components/render-inline-object.tsx +90 -0
- package/src/editor/components/render-leaf.tsx +64 -0
- package/src/editor/components/render-span.tsx +260 -0
- package/src/editor/components/render-text-block.tsx +147 -0
- package/src/editor/components/render-text.tsx +18 -0
- package/src/editor/components/use-core-block-element-behaviors.ts +39 -0
- package/src/internal-utils/parse-blocks.ts +2 -2
- package/src/internal-utils/slate-utils.ts +1 -1
- package/src/editor/components/DefaultObject.tsx +0 -21
- package/src/editor/components/Element.tsx +0 -461
- package/src/editor/components/Leaf.tsx +0 -329
package/lib/index.cjs
CHANGED
|
@@ -330,65 +330,53 @@ function getSelectionDomNodes({
|
|
|
330
330
|
childNodes: childEntries.map(([childNode]) => slateDom.DOMEditor.toDOMNode(slateEditor, childNode))
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
|
-
function
|
|
333
|
+
function DropIndicator() {
|
|
334
|
+
const $ = reactCompilerRuntime.c(1);
|
|
335
|
+
let t0;
|
|
336
|
+
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("div", { contentEditable: !1, className: "pt-drop-indicator", style: {
|
|
337
|
+
position: "absolute",
|
|
338
|
+
width: "100%",
|
|
339
|
+
height: 1,
|
|
340
|
+
borderBottom: "1px solid currentColor",
|
|
341
|
+
zIndex: 5
|
|
342
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", {}) }), $[0] = t0) : t0 = $[0], t0;
|
|
343
|
+
}
|
|
344
|
+
function RenderDefaultBlockObject(props) {
|
|
334
345
|
const $ = reactCompilerRuntime.c(4);
|
|
335
346
|
let t0;
|
|
336
347
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
337
348
|
userSelect: "none"
|
|
338
349
|
}, $[0] = t0) : t0 = $[0];
|
|
339
350
|
let t1;
|
|
340
|
-
return $[1] !== props.
|
|
351
|
+
return $[1] !== props.blockObject._key || $[2] !== props.blockObject._type ? (t1 = /* @__PURE__ */ jsxRuntime.jsxs("div", { style: t0, children: [
|
|
341
352
|
"[",
|
|
342
|
-
props.
|
|
353
|
+
props.blockObject._type,
|
|
343
354
|
": ",
|
|
344
|
-
props.
|
|
355
|
+
props.blockObject._key,
|
|
345
356
|
"]"
|
|
346
|
-
] }), $[1] = props.
|
|
357
|
+
] }), $[1] = props.blockObject._key, $[2] = props.blockObject._type, $[3] = t1) : t1 = $[3], t1;
|
|
347
358
|
}
|
|
348
|
-
function
|
|
359
|
+
function RenderDefaultInlineObject(props) {
|
|
349
360
|
const $ = reactCompilerRuntime.c(4);
|
|
350
361
|
let t0;
|
|
351
362
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
352
363
|
userSelect: "none"
|
|
353
364
|
}, $[0] = t0) : t0 = $[0];
|
|
354
365
|
let t1;
|
|
355
|
-
return $[1] !== props.
|
|
366
|
+
return $[1] !== props.inlineObject._key || $[2] !== props.inlineObject._type ? (t1 = /* @__PURE__ */ jsxRuntime.jsxs("span", { style: t0, children: [
|
|
356
367
|
"[",
|
|
357
|
-
props.
|
|
368
|
+
props.inlineObject._type,
|
|
358
369
|
": ",
|
|
359
|
-
props.
|
|
370
|
+
props.inlineObject._key,
|
|
360
371
|
"]"
|
|
361
|
-
] }), $[1] = props.
|
|
372
|
+
] }), $[1] = props.inlineObject._key, $[2] = props.inlineObject._type, $[3] = t1) : t1 = $[3], t1;
|
|
362
373
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
height: 1,
|
|
370
|
-
borderBottom: "1px solid currentColor",
|
|
371
|
-
zIndex: 5
|
|
372
|
-
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", {}) }), $[0] = t0) : t0 = $[0], t0;
|
|
373
|
-
}
|
|
374
|
-
editorProvider.debugWithName("components:Element");
|
|
375
|
-
const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
|
|
376
|
-
display: "inline-block"
|
|
377
|
-
}, Element$1 = ({
|
|
378
|
-
attributes,
|
|
379
|
-
children,
|
|
380
|
-
element,
|
|
381
|
-
schemaTypes,
|
|
382
|
-
readOnly,
|
|
383
|
-
renderBlock,
|
|
384
|
-
renderChild,
|
|
385
|
-
renderListItem,
|
|
386
|
-
renderStyle,
|
|
387
|
-
spellCheck
|
|
388
|
-
}) => {
|
|
389
|
-
const editorActor = React.useContext(editorProvider.EditorActorContext), slateEditor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), blockRef = React.useRef(null), inlineBlockObjectRef = React.useRef(null), focused = selected && slateEditor.selection && slate.Range.isCollapsed(slateEditor.selection) || !1, [dragPositionBlock, setDragPositionBlock] = React.useState();
|
|
390
|
-
React.useEffect(() => {
|
|
391
|
-
const behavior = behaviors_index.defineBehavior({
|
|
374
|
+
function createCoreBlockElementBehaviorsConfig({
|
|
375
|
+
key,
|
|
376
|
+
onSetDragPositionBlock
|
|
377
|
+
}) {
|
|
378
|
+
return [{
|
|
379
|
+
behavior: behaviors_index.defineBehavior({
|
|
392
380
|
on: "drag.dragover",
|
|
393
381
|
guard: ({
|
|
394
382
|
snapshot,
|
|
@@ -400,7 +388,7 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
|
|
|
400
388
|
selection: event.position.selection
|
|
401
389
|
}
|
|
402
390
|
});
|
|
403
|
-
if (!dropFocusBlock || dropFocusBlock.node._key !==
|
|
391
|
+
if (!dropFocusBlock || dropFocusBlock.node._key !== key)
|
|
404
392
|
return !1;
|
|
405
393
|
const dragOrigin = snapshot.beta.internalDrag?.origin;
|
|
406
394
|
return !dragOrigin || selector_isSelectingEntireBlocks.getSelectedBlocks({
|
|
@@ -408,7 +396,7 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
|
|
|
408
396
|
...snapshot.context,
|
|
409
397
|
selection: dragOrigin.selection
|
|
410
398
|
}
|
|
411
|
-
}).some((draggedBlock) => draggedBlock.node._key ===
|
|
399
|
+
}).some((draggedBlock) => draggedBlock.node._key === key) ? !1 : selector_isSelectingEntireBlocks.isSelectingEntireBlocks({
|
|
412
400
|
context: {
|
|
413
401
|
...snapshot.context,
|
|
414
402
|
selection: dragOrigin.selection
|
|
@@ -416,205 +404,286 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
|
|
|
416
404
|
});
|
|
417
405
|
},
|
|
418
406
|
actions: [({
|
|
419
|
-
event
|
|
407
|
+
event
|
|
420
408
|
}) => [{
|
|
421
409
|
type: "effect",
|
|
422
410
|
effect: () => {
|
|
423
|
-
|
|
411
|
+
onSetDragPositionBlock(event.position.block);
|
|
424
412
|
}
|
|
425
413
|
}]]
|
|
426
|
-
}),
|
|
414
|
+
}),
|
|
415
|
+
priority: editorProvider.createEditorPriority({
|
|
427
416
|
reference: {
|
|
428
417
|
priority: editorProvider.corePriority,
|
|
429
418
|
importance: "lower"
|
|
430
419
|
}
|
|
431
|
-
})
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
};
|
|
435
|
-
return editorActor.send({
|
|
436
|
-
type: "add behavior",
|
|
437
|
-
behaviorConfig
|
|
438
|
-
}), () => {
|
|
439
|
-
editorActor.send({
|
|
440
|
-
type: "remove behavior",
|
|
441
|
-
behaviorConfig
|
|
442
|
-
});
|
|
443
|
-
};
|
|
444
|
-
}, [editorActor, element._key]), React.useEffect(() => {
|
|
445
|
-
const behavior_0 = behaviors_index.defineBehavior({
|
|
420
|
+
})
|
|
421
|
+
}, {
|
|
422
|
+
behavior: behaviors_index.defineBehavior({
|
|
446
423
|
on: "drag.*",
|
|
447
424
|
guard: ({
|
|
448
|
-
event
|
|
449
|
-
}) =>
|
|
425
|
+
event
|
|
426
|
+
}) => event.type !== "drag.dragover",
|
|
450
427
|
actions: [({
|
|
451
|
-
event
|
|
428
|
+
event
|
|
452
429
|
}) => [{
|
|
453
430
|
type: "effect",
|
|
454
431
|
effect: () => {
|
|
455
|
-
|
|
432
|
+
onSetDragPositionBlock(void 0);
|
|
456
433
|
}
|
|
457
|
-
}, behaviors_index.forward(
|
|
458
|
-
}),
|
|
434
|
+
}, behaviors_index.forward(event)]]
|
|
435
|
+
}),
|
|
436
|
+
priority: editorProvider.createEditorPriority({
|
|
459
437
|
reference: {
|
|
460
438
|
priority: editorProvider.corePriority,
|
|
461
439
|
importance: "lower"
|
|
462
440
|
}
|
|
463
|
-
})
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
441
|
+
})
|
|
442
|
+
}];
|
|
443
|
+
}
|
|
444
|
+
function useCoreBlockElementBehaviors(t0) {
|
|
445
|
+
const $ = reactCompilerRuntime.c(5), {
|
|
446
|
+
key,
|
|
447
|
+
onSetDragPositionBlock
|
|
448
|
+
} = t0, editorActor = React.useContext(editorProvider.EditorActorContext);
|
|
449
|
+
let t1, t2;
|
|
450
|
+
$[0] !== editorActor || $[1] !== key || $[2] !== onSetDragPositionBlock ? (t1 = () => {
|
|
451
|
+
const behaviorConfigs = createCoreBlockElementBehaviorsConfig({
|
|
452
|
+
key,
|
|
453
|
+
onSetDragPositionBlock
|
|
454
|
+
});
|
|
455
|
+
for (const behaviorConfig of behaviorConfigs)
|
|
471
456
|
editorActor.send({
|
|
472
|
-
type: "
|
|
473
|
-
behaviorConfig
|
|
457
|
+
type: "add behavior",
|
|
458
|
+
behaviorConfig
|
|
474
459
|
});
|
|
460
|
+
return () => {
|
|
461
|
+
for (const behaviorConfig_0 of behaviorConfigs)
|
|
462
|
+
editorActor.send({
|
|
463
|
+
type: "remove behavior",
|
|
464
|
+
behaviorConfig: behaviorConfig_0
|
|
465
|
+
});
|
|
475
466
|
};
|
|
476
|
-
}, [editorActor]);
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
const elmPath = [{
|
|
494
|
-
_key: block._key
|
|
495
|
-
}, "children", {
|
|
496
|
-
_key: element._key
|
|
497
|
-
}];
|
|
498
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { ...attributes, children: [
|
|
499
|
-
children,
|
|
500
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { draggable: !readOnly, className: "pt-inline-object", "data-testid": "pt-inline-object", ref: inlineBlockObjectRef, style: inlineBlockStyle, contentEditable: !1, children: [
|
|
501
|
-
renderChild && renderChild({
|
|
502
|
-
annotations: EMPTY_ANNOTATIONS,
|
|
503
|
-
// These inline objects currently doesn't support annotations. This is a limitation of the current PT spec/model.
|
|
504
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DefaultInlineObject, { value }),
|
|
505
|
-
editorElementRef: inlineBlockObjectRef,
|
|
506
|
-
focused,
|
|
507
|
-
path: elmPath,
|
|
508
|
-
schemaType,
|
|
509
|
-
selected,
|
|
510
|
-
type: schemaType,
|
|
511
|
-
value
|
|
512
|
-
}),
|
|
513
|
-
!renderChild && /* @__PURE__ */ jsxRuntime.jsx(DefaultInlineObject, { value })
|
|
514
|
-
] }, element._key)
|
|
515
|
-
] });
|
|
516
|
-
}
|
|
517
|
-
throw new Error("Block not found!");
|
|
518
|
-
}
|
|
519
|
-
if (element._type === schemaTypes.block.name) {
|
|
520
|
-
className = "pt-block pt-text-block";
|
|
521
|
-
const isListItem = "listItem" in element, style = "style" in element && element.style || "normal";
|
|
522
|
-
className = `pt-block pt-text-block pt-text-block-style-${style}`;
|
|
523
|
-
const blockStyleType = schemaTypes.styles.find((item) => item.value === style);
|
|
524
|
-
renderStyle && blockStyleType && (renderedBlock = renderStyle({
|
|
525
|
-
block: element,
|
|
526
|
-
children,
|
|
467
|
+
}, t2 = [editorActor, key, onSetDragPositionBlock], $[0] = editorActor, $[1] = key, $[2] = onSetDragPositionBlock, $[3] = t1, $[4] = t2) : (t1 = $[3], t2 = $[4]), React.useEffect(t1, t2);
|
|
468
|
+
}
|
|
469
|
+
function RenderBlockObject(props) {
|
|
470
|
+
const [dragPositionBlock, setDragPositionBlock] = React.useState(), blockObjectRef = React.useRef(null), slateEditor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), editorActor = React.useContext(editorProvider.EditorActorContext);
|
|
471
|
+
useCoreBlockElementBehaviors({
|
|
472
|
+
key: props.element._key,
|
|
473
|
+
onSetDragPositionBlock: setDragPositionBlock
|
|
474
|
+
});
|
|
475
|
+
const legacySchemaType = react.useSelector(editorActor, (s) => s.context.getLegacySchema().blockObjects.find((blockObject) => blockObject.name === props.element._type));
|
|
476
|
+
legacySchemaType || console.error(`Block object type ${props.element._type} not found in Schema`);
|
|
477
|
+
const focused = selected && slateEditor.selection !== null && slate.Range.isCollapsed(slateEditor.selection);
|
|
478
|
+
return /* @__PURE__ */ jsxRuntime.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: [
|
|
479
|
+
dragPositionBlock === "start" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null,
|
|
480
|
+
props.children,
|
|
481
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockObjectRef, contentEditable: !1, draggable: !props.readOnly, children: props.renderBlock && legacySchemaType ? props.renderBlock({
|
|
482
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultBlockObject, { blockObject: props.blockObject }),
|
|
483
|
+
editorElementRef: blockObjectRef,
|
|
527
484
|
focused,
|
|
485
|
+
path: [{
|
|
486
|
+
_key: props.element._key
|
|
487
|
+
}],
|
|
488
|
+
schemaType: legacySchemaType,
|
|
528
489
|
selected,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
path: blockPath,
|
|
544
|
-
schemaType: listType,
|
|
545
|
-
level: value.level || 1,
|
|
546
|
-
editorElementRef: blockRef
|
|
547
|
-
}));
|
|
490
|
+
type: legacySchemaType,
|
|
491
|
+
value: props.blockObject
|
|
492
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultBlockObject, { blockObject: props.blockObject }) }),
|
|
493
|
+
dragPositionBlock === "end" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
|
|
494
|
+
] });
|
|
495
|
+
}
|
|
496
|
+
function RenderInlineObject(props) {
|
|
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));
|
|
498
|
+
legacySchemaType || console.error(`Inline object type ${props.element._type} not found in Schema`);
|
|
499
|
+
const focused = selected && slateEditor.selection !== null && slate.Range.isCollapsed(slateEditor.selection), path = slateDom.DOMEditor.findPath(slateEditor, props.element), [block] = editorProvider.getPointBlock({
|
|
500
|
+
editor: slateEditor,
|
|
501
|
+
point: {
|
|
502
|
+
path,
|
|
503
|
+
offset: 0
|
|
548
504
|
}
|
|
549
|
-
|
|
550
|
-
|
|
505
|
+
});
|
|
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: [
|
|
507
|
+
props.children,
|
|
508
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { ref: inlineObjectRef, style: {
|
|
509
|
+
display: "inline-block"
|
|
510
|
+
}, children: props.renderChild && block && legacySchemaType ? props.renderChild({
|
|
511
|
+
annotations: [],
|
|
512
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultInlineObject, { inlineObject: props.inlineObject }),
|
|
513
|
+
editorElementRef: inlineObjectRef,
|
|
514
|
+
selected,
|
|
515
|
+
focused,
|
|
516
|
+
path: [{
|
|
517
|
+
_key: block._key
|
|
518
|
+
}, "children", {
|
|
519
|
+
_key: props.element._key
|
|
520
|
+
}],
|
|
521
|
+
schemaType: legacySchemaType,
|
|
522
|
+
value: props.inlineObject,
|
|
523
|
+
type: legacySchemaType
|
|
524
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultInlineObject, { inlineObject: props.inlineObject }) })
|
|
525
|
+
] });
|
|
526
|
+
}
|
|
527
|
+
function RenderTextBlock(props) {
|
|
528
|
+
const [dragPositionBlock, setDragPositionBlock] = React.useState(), blockRef = React.useRef(null), slateEditor = slateReact.useSlateStatic(), selected = slateReact.useSelected(), editorActor = React.useContext(editorProvider.EditorActorContext);
|
|
529
|
+
useCoreBlockElementBehaviors({
|
|
530
|
+
key: props.element._key,
|
|
531
|
+
onSetDragPositionBlock: setDragPositionBlock
|
|
532
|
+
});
|
|
533
|
+
const legacySchema = react.useSelector(editorActor, (s) => s.context.getLegacySchema()), focused = selected && slateEditor.selection !== null && slate.Range.isCollapsed(slateEditor.selection);
|
|
534
|
+
let children = props.children;
|
|
535
|
+
const legacyBlockSchemaType = legacySchema.block;
|
|
536
|
+
if (props.renderStyle && props.textBlock.style) {
|
|
537
|
+
const legacyStyleSchemaType = props.textBlock.style !== void 0 ? legacySchema.styles.find((style) => style.value === props.textBlock.style) : void 0;
|
|
538
|
+
legacyStyleSchemaType ? children = props.renderStyle({
|
|
539
|
+
block: props.textBlock,
|
|
540
|
+
children,
|
|
551
541
|
editorElementRef: blockRef,
|
|
552
542
|
focused,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
543
|
+
path: [{
|
|
544
|
+
_key: props.textBlock._key
|
|
545
|
+
}],
|
|
546
|
+
schemaType: legacyStyleSchemaType,
|
|
556
547
|
selected,
|
|
557
|
-
style
|
|
558
|
-
|
|
559
|
-
value
|
|
560
|
-
}, "type", {
|
|
561
|
-
enumerable: !1,
|
|
562
|
-
get() {
|
|
563
|
-
return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaTypes.block;
|
|
564
|
-
}
|
|
565
|
-
}), propsOrDefaultRendered = renderBlock ? renderBlock(renderProps) : children;
|
|
566
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, spellCheck, children: [
|
|
567
|
-
dragPositionBlock === "start" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null,
|
|
568
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: propsOrDefaultRendered }),
|
|
569
|
-
dragPositionBlock === "end" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
|
|
570
|
-
] }, element._key);
|
|
548
|
+
value: props.textBlock.style
|
|
549
|
+
}) : console.error(`Unable to find Schema type for text block style ${props.textBlock.style}`);
|
|
571
550
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
let renderedBlockFromProps;
|
|
578
|
-
if (renderBlock) {
|
|
579
|
-
const _props = Object.defineProperty({
|
|
580
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DefaultBlockObject, { value }),
|
|
551
|
+
if (props.renderListItem && props.textBlock.listItem) {
|
|
552
|
+
const legacyListItemSchemaType = legacySchema.lists.find((list) => list.value === props.textBlock.listItem);
|
|
553
|
+
legacyListItemSchemaType ? children = props.renderListItem({
|
|
554
|
+
block: props.textBlock,
|
|
555
|
+
children,
|
|
581
556
|
editorElementRef: blockRef,
|
|
582
557
|
focused,
|
|
583
|
-
|
|
584
|
-
|
|
558
|
+
level: props.textBlock.level ?? 1,
|
|
559
|
+
path: [{
|
|
560
|
+
_key: props.textBlock._key
|
|
561
|
+
}],
|
|
585
562
|
selected,
|
|
586
|
-
value:
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
get() {
|
|
590
|
-
return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaType_0;
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
renderedBlockFromProps = renderBlock(_props);
|
|
563
|
+
value: props.textBlock.listItem,
|
|
564
|
+
schemaType: legacyListItemSchemaType
|
|
565
|
+
}) : console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
|
|
594
566
|
}
|
|
595
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...attributes, className, children: [
|
|
567
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...props.attributes, className: ["pt-block", "pt-text-block", ...props.textBlock.style ? [`pt-text-block-style-${props.textBlock.style}`] : [], ...props.textBlock.listItem ? ["pt-list-item", `pt-list-item-${props.textBlock.listItem}`, `pt-list-item-level-${props.textBlock.level ?? 1}`] : []].join(" "), spellCheck: props.spellCheck, "data-block-key": props.textBlock._key, "data-block-name": props.textBlock._type, "data-block-type": "text", children: [
|
|
596
568
|
dragPositionBlock === "start" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null,
|
|
597
|
-
children
|
|
598
|
-
|
|
569
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: blockRef, children: props.renderBlock ? props.renderBlock({
|
|
570
|
+
children,
|
|
571
|
+
editorElementRef: blockRef,
|
|
572
|
+
focused,
|
|
573
|
+
level: props.textBlock.level,
|
|
574
|
+
listItem: props.textBlock.listItem,
|
|
575
|
+
path: [{
|
|
576
|
+
_key: props.textBlock._key
|
|
577
|
+
}],
|
|
578
|
+
selected,
|
|
579
|
+
schemaType: legacyBlockSchemaType,
|
|
580
|
+
style: props.textBlock.style,
|
|
581
|
+
type: legacyBlockSchemaType,
|
|
582
|
+
value: props.textBlock
|
|
583
|
+
}) : props.children }),
|
|
599
584
|
dragPositionBlock === "end" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null
|
|
600
|
-
] }
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
585
|
+
] });
|
|
586
|
+
}
|
|
587
|
+
function RenderElement(props) {
|
|
588
|
+
const $ = reactCompilerRuntime.c(45), editorActor = React.useContext(editorProvider.EditorActorContext), schema = react.useSelector(editorActor, _temp$1);
|
|
589
|
+
if ("__inline" in props.element && props.element.__inline === !0) {
|
|
590
|
+
let t02;
|
|
591
|
+
if ($[0] !== props.element || $[1] !== schema) {
|
|
592
|
+
let t13;
|
|
593
|
+
$[3] !== props.element ? (t13 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[3] = props.element, $[4] = t13) : t13 = $[4], t02 = util_sliceBlocks.parseInlineObject({
|
|
594
|
+
context: {
|
|
595
|
+
keyGenerator: _temp2,
|
|
596
|
+
schema
|
|
597
|
+
},
|
|
598
|
+
options: {
|
|
599
|
+
refreshKeys: !1
|
|
600
|
+
},
|
|
601
|
+
inlineObject: {
|
|
602
|
+
_key: props.element._key,
|
|
603
|
+
_type: props.element._type,
|
|
604
|
+
...t13
|
|
605
|
+
}
|
|
606
|
+
}), $[0] = props.element, $[1] = schema, $[2] = t02;
|
|
607
|
+
} else
|
|
608
|
+
t02 = $[2];
|
|
609
|
+
const inlineObject = t02;
|
|
610
|
+
inlineObject || console.error(`Unable to find Inline Object "${props.element._type}" in Schema`);
|
|
611
|
+
let t12;
|
|
612
|
+
$[5] !== inlineObject || $[6] !== props.element._key || $[7] !== props.element._type ? (t12 = inlineObject ?? {
|
|
613
|
+
_key: props.element._key,
|
|
614
|
+
_type: props.element._type
|
|
615
|
+
}, $[5] = inlineObject, $[6] = props.element._key, $[7] = props.element._type, $[8] = t12) : t12 = $[8];
|
|
616
|
+
let t22;
|
|
617
|
+
return $[9] !== props.attributes || $[10] !== props.children || $[11] !== props.element || $[12] !== props.readOnly || $[13] !== props.renderChild || $[14] !== t12 ? (t22 = /* @__PURE__ */ jsxRuntime.jsx(RenderInlineObject, { attributes: props.attributes, element: props.element, inlineObject: t12, readOnly: props.readOnly, renderChild: props.renderChild, children: props.children }), $[9] = props.attributes, $[10] = props.children, $[11] = props.element, $[12] = props.readOnly, $[13] = props.renderChild, $[14] = t12, $[15] = t22) : t22 = $[15], t22;
|
|
618
|
+
}
|
|
619
|
+
let t0;
|
|
620
|
+
$[16] !== props.element || $[17] !== schema ? (t0 = util_sliceBlocks.parseTextBlock({
|
|
621
|
+
context: {
|
|
622
|
+
keyGenerator: _temp3,
|
|
623
|
+
schema
|
|
624
|
+
},
|
|
625
|
+
options: {
|
|
626
|
+
refreshKeys: !1
|
|
627
|
+
},
|
|
628
|
+
block: props.element
|
|
629
|
+
}), $[16] = props.element, $[17] = schema, $[18] = t0) : t0 = $[18];
|
|
630
|
+
const textBlock = t0;
|
|
631
|
+
if (textBlock) {
|
|
632
|
+
let t12;
|
|
633
|
+
return $[19] !== props.attributes || $[20] !== props.children || $[21] !== props.element || $[22] !== props.readOnly || $[23] !== props.renderBlock || $[24] !== props.renderListItem || $[25] !== props.renderStyle || $[26] !== props.spellCheck || $[27] !== textBlock ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(RenderTextBlock, { attributes: props.attributes, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, renderListItem: props.renderListItem, renderStyle: props.renderStyle, spellCheck: props.spellCheck, textBlock, children: props.children }), $[19] = props.attributes, $[20] = props.children, $[21] = props.element, $[22] = props.readOnly, $[23] = props.renderBlock, $[24] = props.renderListItem, $[25] = props.renderStyle, $[26] = props.spellCheck, $[27] = textBlock, $[28] = t12) : t12 = $[28], t12;
|
|
634
|
+
}
|
|
635
|
+
let t1;
|
|
636
|
+
if ($[29] !== props.element || $[30] !== schema) {
|
|
637
|
+
let t22;
|
|
638
|
+
$[32] !== props.element ? (t22 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[32] = props.element, $[33] = t22) : t22 = $[33], t1 = util_sliceBlocks.parseBlockObject({
|
|
639
|
+
context: {
|
|
640
|
+
keyGenerator: _temp4,
|
|
641
|
+
schema
|
|
642
|
+
},
|
|
643
|
+
options: {
|
|
644
|
+
refreshKeys: !1
|
|
645
|
+
},
|
|
646
|
+
blockObject: {
|
|
647
|
+
_key: props.element._key,
|
|
648
|
+
_type: props.element._type,
|
|
649
|
+
...t22
|
|
650
|
+
}
|
|
651
|
+
}), $[29] = props.element, $[30] = schema, $[31] = t1;
|
|
652
|
+
} else
|
|
653
|
+
t1 = $[31];
|
|
654
|
+
const blockObject = t1;
|
|
655
|
+
blockObject || console.error(`Unable to find Block Object "${props.element._type}" in Schema`);
|
|
656
|
+
let t2;
|
|
657
|
+
$[34] !== blockObject || $[35] !== props.element._key || $[36] !== props.element._type ? (t2 = blockObject ?? {
|
|
658
|
+
_key: props.element._key,
|
|
659
|
+
_type: props.element._type
|
|
660
|
+
}, $[34] = blockObject, $[35] = props.element._key, $[36] = props.element._type, $[37] = t2) : t2 = $[37];
|
|
661
|
+
let t3;
|
|
662
|
+
return $[38] !== props.attributes || $[39] !== props.children || $[40] !== props.element || $[41] !== props.readOnly || $[42] !== props.renderBlock || $[43] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(RenderBlockObject, { attributes: props.attributes, blockObject: t2, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, children: props.children }), $[38] = props.attributes, $[39] = props.children, $[40] = props.element, $[41] = props.readOnly, $[42] = props.renderBlock, $[43] = t2, $[44] = t3) : t3 = $[44], t3;
|
|
663
|
+
}
|
|
664
|
+
function _temp4() {
|
|
665
|
+
return "";
|
|
666
|
+
}
|
|
667
|
+
function _temp3() {
|
|
668
|
+
return "";
|
|
669
|
+
}
|
|
670
|
+
function _temp2() {
|
|
671
|
+
return "";
|
|
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
|
|
615
679
|
}, "children", {
|
|
616
|
-
_key: leaf._key
|
|
617
|
-
}] :
|
|
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;
|
|
618
687
|
React.useEffect(() => {
|
|
619
688
|
if (!shouldTrackSelectionAndFocus) {
|
|
620
689
|
setFocused(!1);
|
|
@@ -628,7 +697,6 @@ const debug$2 = editorProvider.debugWithName("components:Leaf"), EMPTY_MARKS = [
|
|
|
628
697
|
const setSelectedFromRange = React.useCallback(() => {
|
|
629
698
|
if (!shouldTrackSelectionAndFocus)
|
|
630
699
|
return;
|
|
631
|
-
debug$2("Setting selection and focus from range");
|
|
632
700
|
const winSelection = window.getSelection();
|
|
633
701
|
if (!winSelection) {
|
|
634
702
|
setSelected(!1);
|
|
@@ -655,75 +723,92 @@ const debug$2 = editorProvider.debugWithName("components:Leaf"), EMPTY_MARKS = [
|
|
|
655
723
|
onBlur.unsubscribe(), onFocus.unsubscribe(), onSelection.unsubscribe();
|
|
656
724
|
};
|
|
657
725
|
}, [editorActor, path, portableTextEditor, setSelectedFromRange, shouldTrackSelectionAndFocus]), React.useEffect(() => setSelectedFromRange(), [setSelectedFromRange]);
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
focused,
|
|
709
|
-
path,
|
|
710
|
-
schemaType: schemaTypes.span,
|
|
711
|
-
selected,
|
|
712
|
-
value: child
|
|
713
|
-
}, "type", {
|
|
714
|
-
enumerable: !1,
|
|
715
|
-
get() {
|
|
716
|
-
return console.warn("Property 'type' is deprecated, use 'schemaType' instead."), schemaTypes.span;
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
returnedChildren = renderChild(_props_1);
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
return returnedChildren;
|
|
723
|
-
}, [annotations, block, children, focused, leaf, marks, path, renderAnnotation, renderChild, renderDecorator, schemaTypes.annotations, schemaTypes.decorators, schemaTypes.span, selected]);
|
|
724
|
-
return React.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx("span", { ...attributes, ref: spanRef, children: content }, leaf._key), [leaf, attributes, content]);
|
|
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
|
|
725
776
|
};
|
|
726
|
-
|
|
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
|
+
}
|
|
804
|
+
function _temp(s) {
|
|
805
|
+
return s.context.schema;
|
|
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
|
+
}
|
|
727
812
|
const debug$1 = editorProvider.debugWithName("plugin:withHotKeys");
|
|
728
813
|
function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions) {
|
|
729
814
|
const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions ?? {};
|
|
@@ -1040,13 +1125,7 @@ function createDecorate(rangeDecorationActor) {
|
|
|
1040
1125
|
}) || slate.Range.includes(decoratedRange, path));
|
|
1041
1126
|
};
|
|
1042
1127
|
}
|
|
1043
|
-
const debug = editorProvider.debugWithName("component:Editable"),
|
|
1044
|
-
position: "absolute",
|
|
1045
|
-
userSelect: "none",
|
|
1046
|
-
pointerEvents: "none",
|
|
1047
|
-
left: 0,
|
|
1048
|
-
right: 0
|
|
1049
|
-
}, PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
|
|
1128
|
+
const debug = editorProvider.debugWithName("component:Editable"), PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
|
|
1050
1129
|
const {
|
|
1051
1130
|
hotkeys,
|
|
1052
1131
|
onBlur,
|
|
@@ -1108,21 +1187,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
|
|
|
1108
1187
|
const withHotKeys = createWithHotkeys(editorActor, portableTextEditor, hotkeys);
|
|
1109
1188
|
return debug("Editable is in edit mode"), withHotKeys(slateEditor);
|
|
1110
1189
|
}, [editorActor, hotkeys, portableTextEditor, readOnly, slateEditor]);
|
|
1111
|
-
const renderElement = React.useCallback((eProps) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1112
|
-
if (lProps.leaf._type === "span") {
|
|
1113
|
-
let rendered = /* @__PURE__ */ jsxRuntime.jsx(Leaf, { ...lProps, editorActor, schemaTypes: portableTextEditor.schemaTypes, renderAnnotation, renderChild, renderDecorator, readOnly });
|
|
1114
|
-
if (renderPlaceholder && lProps.leaf.placeholder && lProps.text.text === "")
|
|
1115
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1116
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: PLACEHOLDER_STYLE, contentEditable: !1, children: renderPlaceholder() }),
|
|
1117
|
-
rendered
|
|
1118
|
-
] });
|
|
1119
|
-
const decoration = lProps.leaf.rangeDecoration;
|
|
1120
|
-
return decoration && (rendered = decoration.component({
|
|
1121
|
-
children: rendered
|
|
1122
|
-
})), rendered;
|
|
1123
|
-
}
|
|
1124
|
-
return lProps.children;
|
|
1125
|
-
}, [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(() => {
|
|
1126
1191
|
if (propsSelection) {
|
|
1127
1192
|
debug(`Selection from props ${JSON.stringify(propsSelection)}`);
|
|
1128
1193
|
const normalizedSelection = normalizeSelection(propsSelection, editorProvider.fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name));
|
|
@@ -1633,6 +1698,7 @@ const debug = editorProvider.debugWithName("component:Editable"), PLACEHOLDER_ST
|
|
|
1633
1698
|
renderPlaceholder: void 0,
|
|
1634
1699
|
renderElement,
|
|
1635
1700
|
renderLeaf,
|
|
1701
|
+
renderText,
|
|
1636
1702
|
scrollSelectionIntoView: scrollSelectionIntoViewToSlate
|
|
1637
1703
|
}
|
|
1638
1704
|
) : null;
|