@portabletext/editor 1.52.0 → 1.52.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.js CHANGED
@@ -9,7 +9,7 @@ import { Element as Element$1, Text, Range, Editor, Node, Point, Transforms, Pat
9
9
  import { useSlateStatic, useSelected, withReact, ReactEditor, Slate, useSlate, Editable } from "slate-react";
10
10
  import debug$h from "debug";
11
11
  import { DOMEditor, isDOMNode } from "slate-dom";
12
- import { getBlockStartPoint, getBlockKeyFromSelectionPoint, parseInlineObject, parseTextBlock, parseBlockObject, parseBlock, sliceBlocks, isTextBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, isKeyedSegment, isSpan$1 as isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/selection-point.js";
12
+ import { getBlockStartPoint, getBlockKeyFromSelectionPoint, isTextBlock, parseBlock, sliceBlocks, parseAnnotation, blockOffsetToSpanSelectionPoint, parseInlineObject, isKeyedSegment, isSpan$1 as isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/selection-point.js";
13
13
  import { getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./_chunks-es/util.is-equal-selection-points.js";
14
14
  import { isSelectionCollapsed, selectionPointToBlockOffset } from "./_chunks-es/util.selection-point-to-block-offset.js";
15
15
  import isEqual from "lodash/isEqual.js";
@@ -1013,93 +1013,49 @@ function RenderTextBlock(props) {
1013
1013
  ] });
1014
1014
  }
1015
1015
  function RenderElement(props) {
1016
- const $ = c(45), editorActor = useContext(EditorActorContext), schema = useSelector(editorActor, _temp$1);
1016
+ const $ = c(43), editorActor = useContext(EditorActorContext), schema = useSelector(editorActor, _temp$1);
1017
1017
  if ("__inline" in props.element && props.element.__inline === !0) {
1018
1018
  let t02;
1019
- if ($[0] !== props.element || $[1] !== schema) {
1020
- let t13;
1021
- $[3] !== props.element ? (t13 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[3] = props.element, $[4] = t13) : t13 = $[4], t02 = parseInlineObject({
1022
- context: {
1023
- keyGenerator: _temp2,
1024
- schema
1025
- },
1026
- options: {
1027
- refreshKeys: !1,
1028
- validateFields: !1
1029
- },
1030
- inlineObject: {
1031
- _key: props.element._key,
1032
- _type: props.element._type,
1033
- ...t13
1034
- }
1035
- }), $[0] = props.element, $[1] = schema, $[2] = t02;
1036
- } else
1037
- t02 = $[2];
1038
- const inlineObject = t02;
1039
- inlineObject || console.error(`Unable to find Inline Object "${props.element._type}" in Schema`);
1019
+ $[0] !== props.element ? (t02 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[0] = props.element, $[1] = t02) : t02 = $[1];
1040
1020
  let t12;
1041
- $[5] !== inlineObject || $[6] !== props.element._key || $[7] !== props.element._type ? (t12 = inlineObject ?? {
1021
+ $[2] !== props.element._key || $[3] !== props.element._type || $[4] !== t02 ? (t12 = {
1042
1022
  _key: props.element._key,
1043
- _type: props.element._type
1044
- }, $[5] = inlineObject, $[6] = props.element._key, $[7] = props.element._type, $[8] = t12) : t12 = $[8];
1023
+ _type: props.element._type,
1024
+ ...t02
1025
+ }, $[2] = props.element._key, $[3] = props.element._type, $[4] = t02, $[5] = t12) : t12 = $[5];
1026
+ const inlineObject = t12;
1027
+ schema.inlineObjects.find((inlineObject_0) => inlineObject_0.name === props.element._type) || console.error(`Unable to find Inline Object "${props.element._type}" in Schema`);
1045
1028
  let t22;
1046
- return $[9] !== props.attributes || $[10] !== props.children || $[11] !== props.element || $[12] !== props.readOnly || $[13] !== props.renderChild || $[14] !== t12 ? (t22 = /* @__PURE__ */ 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;
1029
+ $[6] !== inlineObject || $[7] !== props.element._key || $[8] !== props.element._type ? (t22 = inlineObject ?? {
1030
+ _key: props.element._key,
1031
+ _type: props.element._type
1032
+ }, $[6] = inlineObject, $[7] = props.element._key, $[8] = props.element._type, $[9] = t22) : t22 = $[9];
1033
+ let t32;
1034
+ return $[10] !== props.attributes || $[11] !== props.children || $[12] !== props.element || $[13] !== props.readOnly || $[14] !== props.renderChild || $[15] !== t22 ? (t32 = /* @__PURE__ */ jsx(RenderInlineObject, { attributes: props.attributes, element: props.element, inlineObject: t22, readOnly: props.readOnly, renderChild: props.renderChild, children: props.children }), $[10] = props.attributes, $[11] = props.children, $[12] = props.element, $[13] = props.readOnly, $[14] = props.renderChild, $[15] = t22, $[16] = t32) : t32 = $[16], t32;
1047
1035
  }
1048
- let t0;
1049
- $[16] !== props.element || $[17] !== schema ? (t0 = parseTextBlock({
1050
- context: {
1051
- keyGenerator: _temp3,
1052
- schema
1053
- },
1054
- options: {
1055
- refreshKeys: !1,
1056
- validateFields: !1
1057
- },
1058
- block: props.element
1059
- }), $[16] = props.element, $[17] = schema, $[18] = t0) : t0 = $[18];
1060
- const textBlock = t0;
1061
- if (textBlock) {
1062
- let t12;
1063
- 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__ */ 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;
1036
+ if (isTextBlock({
1037
+ schema
1038
+ }, props.element)) {
1039
+ let t02;
1040
+ return $[17] !== props.attributes || $[18] !== props.children || $[19] !== props.element || $[20] !== props.readOnly || $[21] !== props.renderBlock || $[22] !== props.renderListItem || $[23] !== props.renderStyle || $[24] !== props.spellCheck ? (t02 = /* @__PURE__ */ jsx(RenderTextBlock, { attributes: props.attributes, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, renderListItem: props.renderListItem, renderStyle: props.renderStyle, spellCheck: props.spellCheck, textBlock: props.element, children: props.children }), $[17] = props.attributes, $[18] = props.children, $[19] = props.element, $[20] = props.readOnly, $[21] = props.renderBlock, $[22] = props.renderListItem, $[23] = props.renderStyle, $[24] = props.spellCheck, $[25] = t02) : t02 = $[25], t02;
1064
1041
  }
1042
+ let t0;
1043
+ $[26] !== props.element ? (t0 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[26] = props.element, $[27] = t0) : t0 = $[27];
1065
1044
  let t1;
1066
- if ($[29] !== props.element || $[30] !== schema) {
1067
- let t22;
1068
- $[32] !== props.element ? (t22 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[32] = props.element, $[33] = t22) : t22 = $[33], t1 = parseBlockObject({
1069
- context: {
1070
- keyGenerator: _temp4,
1071
- schema
1072
- },
1073
- options: {
1074
- refreshKeys: !1,
1075
- validateFields: !1
1076
- },
1077
- blockObject: {
1078
- _key: props.element._key,
1079
- _type: props.element._type,
1080
- ...t22
1081
- }
1082
- }), $[29] = props.element, $[30] = schema, $[31] = t1;
1083
- } else
1084
- t1 = $[31];
1045
+ $[28] !== props.element._key || $[29] !== props.element._type || $[30] !== t0 ? (t1 = {
1046
+ _key: props.element._key,
1047
+ _type: props.element._type,
1048
+ ...t0
1049
+ }, $[28] = props.element._key, $[29] = props.element._type, $[30] = t0, $[31] = t1) : t1 = $[31];
1085
1050
  const blockObject = t1;
1086
- blockObject || console.error(`Unable to find Block Object "${props.element._type}" in Schema`);
1051
+ schema.blockObjects.find((blockObject_0) => blockObject_0.name === props.element._type) || console.error(`Unable to find Block Object "${props.element._type}" in Schema`);
1087
1052
  let t2;
1088
- $[34] !== blockObject || $[35] !== props.element._key || $[36] !== props.element._type ? (t2 = blockObject ?? {
1053
+ $[32] !== blockObject || $[33] !== props.element._key || $[34] !== props.element._type ? (t2 = blockObject ?? {
1089
1054
  _key: props.element._key,
1090
1055
  _type: props.element._type
1091
- }, $[34] = blockObject, $[35] = props.element._key, $[36] = props.element._type, $[37] = t2) : t2 = $[37];
1056
+ }, $[32] = blockObject, $[33] = props.element._key, $[34] = props.element._type, $[35] = t2) : t2 = $[35];
1092
1057
  let t3;
1093
- return $[38] !== props.attributes || $[39] !== props.children || $[40] !== props.element || $[41] !== props.readOnly || $[42] !== props.renderBlock || $[43] !== t2 ? (t3 = /* @__PURE__ */ 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;
1094
- }
1095
- function _temp4() {
1096
- return "";
1097
- }
1098
- function _temp3() {
1099
- return "";
1100
- }
1101
- function _temp2() {
1102
- return "";
1058
+ return $[36] !== props.attributes || $[37] !== props.children || $[38] !== props.element || $[39] !== props.readOnly || $[40] !== props.renderBlock || $[41] !== t2 ? (t3 = /* @__PURE__ */ jsx(RenderBlockObject, { attributes: props.attributes, blockObject: t2, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, children: props.children }), $[36] = props.attributes, $[37] = props.children, $[38] = props.element, $[39] = props.readOnly, $[40] = props.renderBlock, $[41] = t2, $[42] = t3) : t3 = $[42], t3;
1103
1059
  }
1104
1060
  function _temp$1(s) {
1105
1061
  return s.context.schema;
@@ -4683,7 +4639,7 @@ function createWithSchemaTypes({
4683
4639
  editorActor
4684
4640
  }) {
4685
4641
  return function(editor) {
4686
- editor.isTextBlock = (value) => isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
4642
+ editor.isTextBlock = (value) => Editor.isEditor(value) ? !1 : isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => Editor.isEditor(value) ? !1 : isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => Editor.isEditor(value) ? !1 : isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
4687
4643
  const {
4688
4644
  normalizeNode
4689
4645
  } = editor;