@portabletext/editor 2.13.0 → 2.13.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/_chunks-dts/behavior.types.action.d.cts +73 -73
- package/lib/_chunks-dts/behavior.types.action.d.ts +1 -1
- package/lib/index.cjs +237 -13
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +237 -13
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.cts +2 -2
- package/lib/utils/index.d.ts +2 -2
- package/package.json +5 -5
- package/src/editor/Editable.tsx +90 -1
- package/src/editor/components/render-block-object.tsx +29 -2
- package/src/editor/components/render-inline-object.tsx +31 -2
- package/src/editor/components/render-span.tsx +91 -6
- package/src/editor/components/render-text-block.tsx +95 -6
package/lib/index.cjs
CHANGED
|
@@ -878,7 +878,7 @@ function RenderBlockObject(props) {
|
|
|
878
878
|
$[13] !== dragPositionBlock ? (t4 = dragPositionBlock === "start" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null, $[13] = dragPositionBlock, $[14] = t4) : t4 = $[14];
|
|
879
879
|
const t5 = !props.readOnly;
|
|
880
880
|
let t6;
|
|
881
|
-
$[15] !== blockObject || $[16] !== focused || $[17] !== legacySchemaType || $[18] !== props.element._key || $[19] !== props.renderBlock || $[20] !== selected ? (t6 = props.renderBlock && legacySchemaType ? /* @__PURE__ */ jsxRuntime.jsx(props.renderBlock,
|
|
881
|
+
$[15] !== blockObject || $[16] !== focused || $[17] !== legacySchemaType || $[18] !== props.element._key || $[19] !== props.renderBlock || $[20] !== selected ? (t6 = props.renderBlock && legacySchemaType ? /* @__PURE__ */ jsxRuntime.jsx(RenderBlock$1, { renderBlock: props.renderBlock, editorElementRef: blockObjectRef, focused, path: [{
|
|
882
882
|
_key: props.element._key
|
|
883
883
|
}], schemaType: legacySchemaType, selected, type: legacySchemaType, value: blockObject, children: /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultBlockObject, { blockObject }) }) : /* @__PURE__ */ jsxRuntime.jsx(RenderDefaultBlockObject, { blockObject }), $[15] = blockObject, $[16] = focused, $[17] = legacySchemaType, $[18] = props.element._key, $[19] = props.renderBlock, $[20] = selected, $[21] = t6) : t6 = $[21];
|
|
884
884
|
let t7;
|
|
@@ -893,6 +893,28 @@ function RenderBlockObject(props) {
|
|
|
893
893
|
t8
|
|
894
894
|
] }), $[27] = props.attributes, $[28] = props.children, $[29] = props.element._key, $[30] = props.element._type, $[31] = t4, $[32] = t7, $[33] = t8, $[34] = t9) : t9 = $[34], t9;
|
|
895
895
|
}
|
|
896
|
+
function RenderBlock$1({
|
|
897
|
+
renderBlock,
|
|
898
|
+
children,
|
|
899
|
+
editorElementRef,
|
|
900
|
+
focused,
|
|
901
|
+
path,
|
|
902
|
+
schemaType,
|
|
903
|
+
selected,
|
|
904
|
+
type,
|
|
905
|
+
value
|
|
906
|
+
}) {
|
|
907
|
+
return renderBlock({
|
|
908
|
+
children,
|
|
909
|
+
editorElementRef,
|
|
910
|
+
focused,
|
|
911
|
+
path,
|
|
912
|
+
schemaType,
|
|
913
|
+
selected,
|
|
914
|
+
type,
|
|
915
|
+
value
|
|
916
|
+
});
|
|
917
|
+
}
|
|
896
918
|
function RenderInlineObject(props) {
|
|
897
919
|
const $ = reactCompilerRuntime.c(32), inlineObjectRef = React.useRef(null), slateEditor = slateReact.useSlateStatic(), selected = slateReact.useSelected();
|
|
898
920
|
let t0;
|
|
@@ -934,7 +956,7 @@ function RenderInlineObject(props) {
|
|
|
934
956
|
display: "inline-block"
|
|
935
957
|
}, $[16] = t6) : t6 = $[16];
|
|
936
958
|
let t7;
|
|
937
|
-
$[17] !== block || $[18] !== focused || $[19] !== inlineObject_0 || $[20] !== legacySchemaType || $[21] !== props.element._key || $[22] !== props.renderChild || $[23] !== selected ? (t7 = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: inlineObjectRef, style: t6, children: props.renderChild && block && legacySchemaType ? /* @__PURE__ */ jsxRuntime.jsx(props.renderChild,
|
|
959
|
+
$[17] !== block || $[18] !== focused || $[19] !== inlineObject_0 || $[20] !== legacySchemaType || $[21] !== props.element._key || $[22] !== props.renderChild || $[23] !== selected ? (t7 = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: inlineObjectRef, style: t6, children: props.renderChild && block && legacySchemaType ? /* @__PURE__ */ jsxRuntime.jsx(RenderChild$1, { renderChild: props.renderChild, annotations: [], editorElementRef: inlineObjectRef, selected, focused, path: [{
|
|
938
960
|
_key: block._key
|
|
939
961
|
}, "children", {
|
|
940
962
|
_key: props.element._key
|
|
@@ -945,6 +967,30 @@ function RenderInlineObject(props) {
|
|
|
945
967
|
t7
|
|
946
968
|
] }), $[25] = inlineObject_0._key, $[26] = inlineObject_0._type, $[27] = props.attributes, $[28] = props.children, $[29] = t5, $[30] = t7, $[31] = t8) : t8 = $[31], t8;
|
|
947
969
|
}
|
|
970
|
+
function RenderChild$1({
|
|
971
|
+
renderChild,
|
|
972
|
+
annotations,
|
|
973
|
+
children,
|
|
974
|
+
editorElementRef,
|
|
975
|
+
focused,
|
|
976
|
+
path,
|
|
977
|
+
schemaType,
|
|
978
|
+
selected,
|
|
979
|
+
value,
|
|
980
|
+
type
|
|
981
|
+
}) {
|
|
982
|
+
return renderChild({
|
|
983
|
+
annotations,
|
|
984
|
+
children,
|
|
985
|
+
editorElementRef,
|
|
986
|
+
focused,
|
|
987
|
+
path,
|
|
988
|
+
schemaType,
|
|
989
|
+
selected,
|
|
990
|
+
value,
|
|
991
|
+
type
|
|
992
|
+
});
|
|
993
|
+
}
|
|
948
994
|
function RenderTextBlock(props) {
|
|
949
995
|
const $ = reactCompilerRuntime.c(77), [dragPositionBlock, setDragPositionBlock] = React.useState(), blockRef = React.useRef(null), selected = slateReact.useSelected();
|
|
950
996
|
let t0;
|
|
@@ -969,7 +1015,7 @@ function RenderTextBlock(props) {
|
|
|
969
1015
|
_key: props.textBlock._key
|
|
970
1016
|
}], $[9] = props.textBlock._key, $[10] = t42) : t42 = $[10];
|
|
971
1017
|
let t52;
|
|
972
|
-
$[11] !== children || $[12] !== focused || $[13] !== legacyStyleSchemaType || $[14] !== props.renderStyle || $[15] !== props.textBlock || $[16] !== selected || $[17] !== t42 ? (t52 = /* @__PURE__ */ jsxRuntime.jsx(props.renderStyle,
|
|
1018
|
+
$[11] !== children || $[12] !== focused || $[13] !== legacyStyleSchemaType || $[14] !== props.renderStyle || $[15] !== props.textBlock || $[16] !== selected || $[17] !== t42 ? (t52 = /* @__PURE__ */ jsxRuntime.jsx(RenderStyle, { renderStyle: props.renderStyle, block: props.textBlock, editorElementRef: blockRef, focused, path: t42, schemaType: legacyStyleSchemaType, selected, value: props.textBlock.style, children }), $[11] = children, $[12] = focused, $[13] = legacyStyleSchemaType, $[14] = props.renderStyle, $[15] = props.textBlock, $[16] = selected, $[17] = t42, $[18] = t52) : t52 = $[18], children = t52;
|
|
973
1019
|
} else
|
|
974
1020
|
console.error(`Unable to find Schema type for text block style ${props.textBlock.style}`);
|
|
975
1021
|
}
|
|
@@ -988,7 +1034,7 @@ function RenderTextBlock(props) {
|
|
|
988
1034
|
_key: props.textBlock._key
|
|
989
1035
|
}], $[24] = props.textBlock._key, $[25] = t52) : t52 = $[25];
|
|
990
1036
|
let t62;
|
|
991
|
-
$[26] !== children || $[27] !== focused || $[28] !== legacyListItemSchemaType || $[29] !== props.renderListItem || $[30] !== props.textBlock || $[31] !== selected || $[32] !== t42 || $[33] !== t52 ? (t62 = /* @__PURE__ */ jsxRuntime.jsx(props.renderListItem,
|
|
1037
|
+
$[26] !== children || $[27] !== focused || $[28] !== legacyListItemSchemaType || $[29] !== props.renderListItem || $[30] !== props.textBlock || $[31] !== selected || $[32] !== t42 || $[33] !== t52 ? (t62 = /* @__PURE__ */ jsxRuntime.jsx(RenderListItem, { renderListItem: props.renderListItem, block: props.textBlock, editorElementRef: blockRef, focused, level: t42, path: t52, selected, value: props.textBlock.listItem, schemaType: legacyListItemSchemaType, children }), $[26] = children, $[27] = focused, $[28] = legacyListItemSchemaType, $[29] = props.renderListItem, $[30] = props.textBlock, $[31] = selected, $[32] = t42, $[33] = t52, $[34] = t62) : t62 = $[34], children = t62;
|
|
992
1038
|
} else
|
|
993
1039
|
console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
|
|
994
1040
|
}
|
|
@@ -1019,7 +1065,7 @@ function RenderTextBlock(props) {
|
|
|
1019
1065
|
let t12;
|
|
1020
1066
|
$[51] !== dragPositionBlock ? (t12 = dragPositionBlock === "start" ? /* @__PURE__ */ jsxRuntime.jsx(DropIndicator, {}) : null, $[51] = dragPositionBlock, $[52] = t12) : t12 = $[52];
|
|
1021
1067
|
let t13;
|
|
1022
|
-
$[53] !== children || $[54] !== focused || $[55] !== props.legacySchema || $[56] !== props.renderBlock || $[57] !== props.textBlock || $[58] !== selected ? (t13 = props.renderBlock ? /* @__PURE__ */ jsxRuntime.jsx(props.renderBlock,
|
|
1068
|
+
$[53] !== children || $[54] !== focused || $[55] !== props.legacySchema || $[56] !== props.renderBlock || $[57] !== props.textBlock || $[58] !== selected ? (t13 = props.renderBlock ? /* @__PURE__ */ jsxRuntime.jsx(RenderBlock, { renderBlock: props.renderBlock, editorElementRef: blockRef, focused, level: props.textBlock.level, listItem: props.textBlock.listItem, path: [{
|
|
1023
1069
|
_key: props.textBlock._key
|
|
1024
1070
|
}], 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] = t13) : t13 = $[59];
|
|
1025
1071
|
let t14;
|
|
@@ -1033,6 +1079,80 @@ function RenderTextBlock(props) {
|
|
|
1033
1079
|
t15
|
|
1034
1080
|
] }), $[64] = props.attributes, $[65] = props.spellCheck, $[66] = props.textBlock._key, $[67] = props.textBlock._type, $[68] = t10, $[69] = t11, $[70] = t12, $[71] = t14, $[72] = t15, $[73] = t7, $[74] = t8, $[75] = t9, $[76] = t16) : t16 = $[76], t16;
|
|
1035
1081
|
}
|
|
1082
|
+
function RenderBlock({
|
|
1083
|
+
renderBlock,
|
|
1084
|
+
children,
|
|
1085
|
+
editorElementRef,
|
|
1086
|
+
focused,
|
|
1087
|
+
level,
|
|
1088
|
+
listItem,
|
|
1089
|
+
path,
|
|
1090
|
+
selected,
|
|
1091
|
+
style,
|
|
1092
|
+
schemaType,
|
|
1093
|
+
type,
|
|
1094
|
+
value
|
|
1095
|
+
}) {
|
|
1096
|
+
return renderBlock({
|
|
1097
|
+
children,
|
|
1098
|
+
editorElementRef,
|
|
1099
|
+
focused,
|
|
1100
|
+
level,
|
|
1101
|
+
listItem,
|
|
1102
|
+
path,
|
|
1103
|
+
selected,
|
|
1104
|
+
style,
|
|
1105
|
+
schemaType,
|
|
1106
|
+
type,
|
|
1107
|
+
value
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
function RenderListItem({
|
|
1111
|
+
renderListItem,
|
|
1112
|
+
block,
|
|
1113
|
+
children,
|
|
1114
|
+
editorElementRef,
|
|
1115
|
+
focused,
|
|
1116
|
+
level,
|
|
1117
|
+
path,
|
|
1118
|
+
schemaType,
|
|
1119
|
+
selected,
|
|
1120
|
+
value
|
|
1121
|
+
}) {
|
|
1122
|
+
return renderListItem({
|
|
1123
|
+
block,
|
|
1124
|
+
children,
|
|
1125
|
+
editorElementRef,
|
|
1126
|
+
focused,
|
|
1127
|
+
level,
|
|
1128
|
+
path,
|
|
1129
|
+
schemaType,
|
|
1130
|
+
selected,
|
|
1131
|
+
value
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
function RenderStyle({
|
|
1135
|
+
renderStyle,
|
|
1136
|
+
block,
|
|
1137
|
+
children,
|
|
1138
|
+
editorElementRef,
|
|
1139
|
+
focused,
|
|
1140
|
+
path,
|
|
1141
|
+
schemaType,
|
|
1142
|
+
selected,
|
|
1143
|
+
value
|
|
1144
|
+
}) {
|
|
1145
|
+
return renderStyle({
|
|
1146
|
+
block,
|
|
1147
|
+
children,
|
|
1148
|
+
editorElementRef,
|
|
1149
|
+
focused,
|
|
1150
|
+
path,
|
|
1151
|
+
schemaType,
|
|
1152
|
+
selected,
|
|
1153
|
+
value
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1036
1156
|
function RenderElement(props) {
|
|
1037
1157
|
const $ = reactCompilerRuntime.c(34), editorActor = React.useContext(EditorActorContext), schema$12 = react.useSelector(editorActor, _temp$3), legacySchema = react.useSelector(editorActor, _temp2$2), slateStatic = slateReact.useSlateStatic();
|
|
1038
1158
|
if ("__inline" in props.element && props.element.__inline === !0) {
|
|
@@ -1159,11 +1279,11 @@ function RenderSpan(props) {
|
|
|
1159
1279
|
}), children = props.children;
|
|
1160
1280
|
for (const mark_1 of decorators) {
|
|
1161
1281
|
const legacyDecoratorSchemaType = legacySchema.decorators.find((dec) => dec.value === mark_1);
|
|
1162
|
-
path && legacyDecoratorSchemaType && props.renderDecorator && (children = /* @__PURE__ */ jsxRuntime.jsx(props.renderDecorator,
|
|
1282
|
+
path && legacyDecoratorSchemaType && props.renderDecorator && (children = /* @__PURE__ */ jsxRuntime.jsx(RenderDecorator, { renderDecorator: props.renderDecorator, editorElementRef: spanRef, focused, path, selected, schemaType: legacyDecoratorSchemaType, value: mark_1, type: legacyDecoratorSchemaType, children }));
|
|
1163
1283
|
}
|
|
1164
1284
|
for (const annotationMarkDef of annotationMarkDefs) {
|
|
1165
1285
|
const legacyAnnotationSchemaType = legacySchema.annotations.find((t) => t.name === annotationMarkDef._type);
|
|
1166
|
-
legacyAnnotationSchemaType && (block_0 && path && props.renderAnnotation ? children = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children: /* @__PURE__ */ jsxRuntime.jsx(props.renderAnnotation,
|
|
1286
|
+
legacyAnnotationSchemaType && (block_0 && path && props.renderAnnotation ? children = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children: /* @__PURE__ */ jsxRuntime.jsx(RenderAnnotation, { renderAnnotation: props.renderAnnotation, block: block_0, editorElementRef: spanRef, focused, path, selected, schemaType: legacyAnnotationSchemaType, value: annotationMarkDef, type: legacyAnnotationSchemaType, children }) }) : children = /* @__PURE__ */ jsxRuntime.jsx("span", { ref: spanRef, children }));
|
|
1167
1287
|
}
|
|
1168
1288
|
$[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;
|
|
1169
1289
|
} else
|
|
@@ -1178,7 +1298,7 @@ function RenderSpan(props) {
|
|
|
1178
1298
|
const child = t32;
|
|
1179
1299
|
if (child) {
|
|
1180
1300
|
let t4;
|
|
1181
|
-
$[28] !== annotationMarkDefs || $[29] !== child || $[30] !== children || $[31] !== focused || $[32] !== legacySchema.span || $[33] !== path || $[34] !== props.renderChild || $[35] !== selected ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(props.renderChild,
|
|
1301
|
+
$[28] !== annotationMarkDefs || $[29] !== child || $[30] !== children || $[31] !== focused || $[32] !== legacySchema.span || $[33] !== path || $[34] !== props.renderChild || $[35] !== selected ? (t4 = /* @__PURE__ */ jsxRuntime.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;
|
|
1182
1302
|
}
|
|
1183
1303
|
}
|
|
1184
1304
|
let t3;
|
|
@@ -1190,6 +1310,76 @@ function _temp2$1(decorator) {
|
|
|
1190
1310
|
function _temp$2(s) {
|
|
1191
1311
|
return s.context.getLegacySchema();
|
|
1192
1312
|
}
|
|
1313
|
+
function RenderAnnotation({
|
|
1314
|
+
renderAnnotation,
|
|
1315
|
+
block,
|
|
1316
|
+
children,
|
|
1317
|
+
editorElementRef,
|
|
1318
|
+
focused,
|
|
1319
|
+
path,
|
|
1320
|
+
schemaType,
|
|
1321
|
+
selected,
|
|
1322
|
+
value,
|
|
1323
|
+
type
|
|
1324
|
+
}) {
|
|
1325
|
+
return renderAnnotation({
|
|
1326
|
+
block,
|
|
1327
|
+
children,
|
|
1328
|
+
editorElementRef,
|
|
1329
|
+
focused,
|
|
1330
|
+
path,
|
|
1331
|
+
schemaType,
|
|
1332
|
+
selected,
|
|
1333
|
+
value,
|
|
1334
|
+
type
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
function RenderDecorator({
|
|
1338
|
+
renderDecorator,
|
|
1339
|
+
children,
|
|
1340
|
+
editorElementRef,
|
|
1341
|
+
focused,
|
|
1342
|
+
path,
|
|
1343
|
+
schemaType,
|
|
1344
|
+
selected,
|
|
1345
|
+
value,
|
|
1346
|
+
type
|
|
1347
|
+
}) {
|
|
1348
|
+
return renderDecorator({
|
|
1349
|
+
children,
|
|
1350
|
+
editorElementRef,
|
|
1351
|
+
focused,
|
|
1352
|
+
path,
|
|
1353
|
+
schemaType,
|
|
1354
|
+
selected,
|
|
1355
|
+
value,
|
|
1356
|
+
type
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
function RenderChild({
|
|
1360
|
+
renderChild,
|
|
1361
|
+
annotations,
|
|
1362
|
+
children,
|
|
1363
|
+
editorElementRef,
|
|
1364
|
+
focused,
|
|
1365
|
+
path,
|
|
1366
|
+
schemaType,
|
|
1367
|
+
selected,
|
|
1368
|
+
value,
|
|
1369
|
+
type
|
|
1370
|
+
}) {
|
|
1371
|
+
return renderChild({
|
|
1372
|
+
annotations,
|
|
1373
|
+
children,
|
|
1374
|
+
editorElementRef,
|
|
1375
|
+
focused,
|
|
1376
|
+
path,
|
|
1377
|
+
schemaType,
|
|
1378
|
+
selected,
|
|
1379
|
+
value,
|
|
1380
|
+
type
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1193
1383
|
const PLACEHOLDER_STYLE = {
|
|
1194
1384
|
position: "absolute",
|
|
1195
1385
|
userSelect: "none",
|
|
@@ -1694,7 +1884,7 @@ function createDecorate(schema2, slateEditor) {
|
|
|
1694
1884
|
};
|
|
1695
1885
|
}
|
|
1696
1886
|
const RelayActorContext = React.createContext({}), debug$d = debugWithName("component:Editable"), PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
|
|
1697
|
-
const $ = reactCompilerRuntime.c(
|
|
1887
|
+
const $ = reactCompilerRuntime.c(172);
|
|
1698
1888
|
let hotkeys, onBeforeInput, onBlur, onClick, onCopy, onCut, onDrag, onDragEnd, onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop, onFocus, onPaste, propsSelection, rangeDecorations, renderAnnotation, renderBlock, renderChild, renderDecorator, renderListItem, renderPlaceholder, renderStyle, restProps, scrollSelectionIntoView, spellCheck;
|
|
1699
1889
|
$[0] !== props ? ({
|
|
1700
1890
|
hotkeys,
|
|
@@ -2231,16 +2421,50 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2231
2421
|
}, $[140] = editorActor, $[141] = onDragLeave, $[142] = slateEditor, $[143] = t34) : t34 = $[143];
|
|
2232
2422
|
const handleDragLeave = t34;
|
|
2233
2423
|
let t35;
|
|
2234
|
-
$[144] !== forwardedRef ? (t35 = (node) => {
|
|
2235
|
-
typeof forwardedRef == "function" ? forwardedRef(node) : forwardedRef && (forwardedRef.current = node)
|
|
2236
|
-
|
|
2424
|
+
$[144] !== forwardedRef || $[145] !== slateEditor ? (t35 = (node) => {
|
|
2425
|
+
if (typeof forwardedRef == "function" ? forwardedRef(node) : forwardedRef && (forwardedRef.current = node), node) {
|
|
2426
|
+
const mutationObserver = new MutationObserver(() => {
|
|
2427
|
+
validateSelection(slateEditor, node);
|
|
2428
|
+
});
|
|
2429
|
+
return mutationObserver.observe(node, {
|
|
2430
|
+
attributeOldValue: !1,
|
|
2431
|
+
attributes: !1,
|
|
2432
|
+
characterData: !1,
|
|
2433
|
+
childList: !0,
|
|
2434
|
+
subtree: !0
|
|
2435
|
+
}), () => {
|
|
2436
|
+
mutationObserver.disconnect();
|
|
2437
|
+
};
|
|
2438
|
+
}
|
|
2439
|
+
}, $[144] = forwardedRef, $[145] = slateEditor, $[146] = t35) : t35 = $[146];
|
|
2237
2440
|
const callbackRef = t35;
|
|
2238
2441
|
if (!portableTextEditor)
|
|
2239
2442
|
return null;
|
|
2240
2443
|
let t36;
|
|
2241
|
-
return $[
|
|
2444
|
+
return $[147] !== callbackRef || $[148] !== decorate || $[149] !== handleClick || $[150] !== handleCopy || $[151] !== handleCut || $[152] !== handleDrag || $[153] !== handleDragEnd || $[154] !== handleDragEnter || $[155] !== handleDragLeave || $[156] !== handleDragOver || $[157] !== handleDragStart || $[158] !== handleDrop || $[159] !== handleKeyDown || $[160] !== handleKeyUp || $[161] !== handleOnBeforeInput || $[162] !== handleOnBlur || $[163] !== handleOnFocus || $[164] !== handlePaste || $[165] !== hasInvalidValue || $[166] !== readOnly || $[167] !== renderElement || $[168] !== renderLeaf || $[169] !== restProps || $[170] !== scrollSelectionIntoViewToSlate ? (t36 = hasInvalidValue ? null : /* @__PURE__ */ jsxRuntime.jsx(slateReact.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 }), $[147] = callbackRef, $[148] = decorate, $[149] = handleClick, $[150] = handleCopy, $[151] = handleCut, $[152] = handleDrag, $[153] = handleDragEnd, $[154] = handleDragEnter, $[155] = handleDragLeave, $[156] = handleDragOver, $[157] = handleDragStart, $[158] = handleDrop, $[159] = handleKeyDown, $[160] = handleKeyUp, $[161] = handleOnBeforeInput, $[162] = handleOnBlur, $[163] = handleOnFocus, $[164] = handlePaste, $[165] = hasInvalidValue, $[166] = readOnly, $[167] = renderElement, $[168] = renderLeaf, $[169] = restProps, $[170] = scrollSelectionIntoViewToSlate, $[171] = t36) : t36 = $[171], t36;
|
|
2242
2445
|
});
|
|
2243
2446
|
PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
|
|
2447
|
+
function validateSelection(slateEditor, activeElement) {
|
|
2448
|
+
if (!slateEditor.selection)
|
|
2449
|
+
return;
|
|
2450
|
+
let root;
|
|
2451
|
+
try {
|
|
2452
|
+
root = slateReact.ReactEditor.findDocumentOrShadowRoot(slateEditor);
|
|
2453
|
+
} catch {
|
|
2454
|
+
}
|
|
2455
|
+
if (!root || activeElement !== root.activeElement)
|
|
2456
|
+
return;
|
|
2457
|
+
const domSelection = slateReact.ReactEditor.getWindow(slateEditor).getSelection();
|
|
2458
|
+
if (!domSelection || domSelection.rangeCount === 0)
|
|
2459
|
+
return;
|
|
2460
|
+
const existingDOMRange = domSelection.getRangeAt(0);
|
|
2461
|
+
try {
|
|
2462
|
+
const newDOMRange = slateReact.ReactEditor.toDOMRange(slateEditor, slateEditor.selection);
|
|
2463
|
+
(newDOMRange.startOffset !== existingDOMRange.startOffset || newDOMRange.endOffset !== existingDOMRange.endOffset) && (debug$d("DOM range out of sync, validating selection"), domSelection?.removeAllRanges(), domSelection.addRange(newDOMRange));
|
|
2464
|
+
} catch {
|
|
2465
|
+
debug$d("Could not resolve selection, selecting top document"), slate.Transforms.deselect(slateEditor), slateEditor.children.length > 0 && slate.Transforms.select(slateEditor, [0, 0]), slateEditor.onChange();
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2244
2468
|
function _temp(s) {
|
|
2245
2469
|
return s.matches({
|
|
2246
2470
|
"edit mode": "read only"
|