@portabletext/editor 2.13.0 → 2.13.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-dts/behavior.types.action.d.cts +73 -73
- package/lib/_chunks-dts/behavior.types.action.d.ts +9 -9
- package/lib/index.cjs +198 -8
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +198 -8
- 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 +3 -3
- 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.js
CHANGED
|
@@ -907,7 +907,7 @@ function RenderBlockObject(props) {
|
|
|
907
907
|
$[13] !== dragPositionBlock ? (t4 = dragPositionBlock === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[13] = dragPositionBlock, $[14] = t4) : t4 = $[14];
|
|
908
908
|
const t5 = !props.readOnly;
|
|
909
909
|
let t6;
|
|
910
|
-
$[15] !== blockObject || $[16] !== focused || $[17] !== legacySchemaType || $[18] !== props.element._key || $[19] !== props.renderBlock || $[20] !== selected ? (t6 = props.renderBlock && legacySchemaType ? /* @__PURE__ */ jsx(props.renderBlock,
|
|
910
|
+
$[15] !== blockObject || $[16] !== focused || $[17] !== legacySchemaType || $[18] !== props.element._key || $[19] !== props.renderBlock || $[20] !== selected ? (t6 = props.renderBlock && legacySchemaType ? /* @__PURE__ */ jsx(RenderBlock$1, { renderBlock: props.renderBlock, editorElementRef: blockObjectRef, focused, path: [{
|
|
911
911
|
_key: props.element._key
|
|
912
912
|
}], schemaType: legacySchemaType, selected, type: legacySchemaType, value: blockObject, children: /* @__PURE__ */ jsx(RenderDefaultBlockObject, { blockObject }) }) : /* @__PURE__ */ jsx(RenderDefaultBlockObject, { blockObject }), $[15] = blockObject, $[16] = focused, $[17] = legacySchemaType, $[18] = props.element._key, $[19] = props.renderBlock, $[20] = selected, $[21] = t6) : t6 = $[21];
|
|
913
913
|
let t7;
|
|
@@ -922,6 +922,28 @@ function RenderBlockObject(props) {
|
|
|
922
922
|
t8
|
|
923
923
|
] }), $[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;
|
|
924
924
|
}
|
|
925
|
+
function RenderBlock$1({
|
|
926
|
+
renderBlock,
|
|
927
|
+
children,
|
|
928
|
+
editorElementRef,
|
|
929
|
+
focused,
|
|
930
|
+
path,
|
|
931
|
+
schemaType,
|
|
932
|
+
selected,
|
|
933
|
+
type,
|
|
934
|
+
value
|
|
935
|
+
}) {
|
|
936
|
+
return renderBlock({
|
|
937
|
+
children,
|
|
938
|
+
editorElementRef,
|
|
939
|
+
focused,
|
|
940
|
+
path,
|
|
941
|
+
schemaType,
|
|
942
|
+
selected,
|
|
943
|
+
type,
|
|
944
|
+
value
|
|
945
|
+
});
|
|
946
|
+
}
|
|
925
947
|
function RenderInlineObject(props) {
|
|
926
948
|
const $ = c(32), inlineObjectRef = useRef(null), slateEditor = useSlateStatic(), selected = useSelected();
|
|
927
949
|
let t0;
|
|
@@ -963,7 +985,7 @@ function RenderInlineObject(props) {
|
|
|
963
985
|
display: "inline-block"
|
|
964
986
|
}, $[16] = t6) : t6 = $[16];
|
|
965
987
|
let t7;
|
|
966
|
-
$[17] !== block || $[18] !== focused || $[19] !== inlineObject_0 || $[20] !== legacySchemaType || $[21] !== props.element._key || $[22] !== props.renderChild || $[23] !== selected ? (t7 = /* @__PURE__ */ jsx("span", { ref: inlineObjectRef, style: t6, children: props.renderChild && block && legacySchemaType ? /* @__PURE__ */ jsx(props.renderChild,
|
|
988
|
+
$[17] !== block || $[18] !== focused || $[19] !== inlineObject_0 || $[20] !== legacySchemaType || $[21] !== props.element._key || $[22] !== props.renderChild || $[23] !== selected ? (t7 = /* @__PURE__ */ jsx("span", { ref: inlineObjectRef, style: t6, children: props.renderChild && block && legacySchemaType ? /* @__PURE__ */ jsx(RenderChild$1, { renderChild: props.renderChild, annotations: [], editorElementRef: inlineObjectRef, selected, focused, path: [{
|
|
967
989
|
_key: block._key
|
|
968
990
|
}, "children", {
|
|
969
991
|
_key: props.element._key
|
|
@@ -974,6 +996,30 @@ function RenderInlineObject(props) {
|
|
|
974
996
|
t7
|
|
975
997
|
] }), $[25] = inlineObject_0._key, $[26] = inlineObject_0._type, $[27] = props.attributes, $[28] = props.children, $[29] = t5, $[30] = t7, $[31] = t8) : t8 = $[31], t8;
|
|
976
998
|
}
|
|
999
|
+
function RenderChild$1({
|
|
1000
|
+
renderChild,
|
|
1001
|
+
annotations,
|
|
1002
|
+
children,
|
|
1003
|
+
editorElementRef,
|
|
1004
|
+
focused,
|
|
1005
|
+
path,
|
|
1006
|
+
schemaType,
|
|
1007
|
+
selected,
|
|
1008
|
+
value,
|
|
1009
|
+
type
|
|
1010
|
+
}) {
|
|
1011
|
+
return renderChild({
|
|
1012
|
+
annotations,
|
|
1013
|
+
children,
|
|
1014
|
+
editorElementRef,
|
|
1015
|
+
focused,
|
|
1016
|
+
path,
|
|
1017
|
+
schemaType,
|
|
1018
|
+
selected,
|
|
1019
|
+
value,
|
|
1020
|
+
type
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
977
1023
|
function RenderTextBlock(props) {
|
|
978
1024
|
const $ = c(77), [dragPositionBlock, setDragPositionBlock] = useState(), blockRef = useRef(null), selected = useSelected();
|
|
979
1025
|
let t0;
|
|
@@ -998,7 +1044,7 @@ function RenderTextBlock(props) {
|
|
|
998
1044
|
_key: props.textBlock._key
|
|
999
1045
|
}], $[9] = props.textBlock._key, $[10] = t42) : t42 = $[10];
|
|
1000
1046
|
let t52;
|
|
1001
|
-
$[11] !== children || $[12] !== focused || $[13] !== legacyStyleSchemaType || $[14] !== props.renderStyle || $[15] !== props.textBlock || $[16] !== selected || $[17] !== t42 ? (t52 = /* @__PURE__ */ jsx(props.renderStyle,
|
|
1047
|
+
$[11] !== children || $[12] !== focused || $[13] !== legacyStyleSchemaType || $[14] !== props.renderStyle || $[15] !== props.textBlock || $[16] !== selected || $[17] !== t42 ? (t52 = /* @__PURE__ */ 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;
|
|
1002
1048
|
} else
|
|
1003
1049
|
console.error(`Unable to find Schema type for text block style ${props.textBlock.style}`);
|
|
1004
1050
|
}
|
|
@@ -1017,7 +1063,7 @@ function RenderTextBlock(props) {
|
|
|
1017
1063
|
_key: props.textBlock._key
|
|
1018
1064
|
}], $[24] = props.textBlock._key, $[25] = t52) : t52 = $[25];
|
|
1019
1065
|
let t62;
|
|
1020
|
-
$[26] !== children || $[27] !== focused || $[28] !== legacyListItemSchemaType || $[29] !== props.renderListItem || $[30] !== props.textBlock || $[31] !== selected || $[32] !== t42 || $[33] !== t52 ? (t62 = /* @__PURE__ */ jsx(props.renderListItem,
|
|
1066
|
+
$[26] !== children || $[27] !== focused || $[28] !== legacyListItemSchemaType || $[29] !== props.renderListItem || $[30] !== props.textBlock || $[31] !== selected || $[32] !== t42 || $[33] !== t52 ? (t62 = /* @__PURE__ */ 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;
|
|
1021
1067
|
} else
|
|
1022
1068
|
console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
|
|
1023
1069
|
}
|
|
@@ -1048,7 +1094,7 @@ function RenderTextBlock(props) {
|
|
|
1048
1094
|
let t12;
|
|
1049
1095
|
$[51] !== dragPositionBlock ? (t12 = dragPositionBlock === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[51] = dragPositionBlock, $[52] = t12) : t12 = $[52];
|
|
1050
1096
|
let t13;
|
|
1051
|
-
$[53] !== children || $[54] !== focused || $[55] !== props.legacySchema || $[56] !== props.renderBlock || $[57] !== props.textBlock || $[58] !== selected ? (t13 = props.renderBlock ? /* @__PURE__ */ jsx(props.renderBlock,
|
|
1097
|
+
$[53] !== children || $[54] !== focused || $[55] !== props.legacySchema || $[56] !== props.renderBlock || $[57] !== props.textBlock || $[58] !== selected ? (t13 = props.renderBlock ? /* @__PURE__ */ jsx(RenderBlock, { renderBlock: props.renderBlock, editorElementRef: blockRef, focused, level: props.textBlock.level, listItem: props.textBlock.listItem, path: [{
|
|
1052
1098
|
_key: props.textBlock._key
|
|
1053
1099
|
}], 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];
|
|
1054
1100
|
let t14;
|
|
@@ -1062,6 +1108,80 @@ function RenderTextBlock(props) {
|
|
|
1062
1108
|
t15
|
|
1063
1109
|
] }), $[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;
|
|
1064
1110
|
}
|
|
1111
|
+
function RenderBlock({
|
|
1112
|
+
renderBlock,
|
|
1113
|
+
children,
|
|
1114
|
+
editorElementRef,
|
|
1115
|
+
focused,
|
|
1116
|
+
level,
|
|
1117
|
+
listItem,
|
|
1118
|
+
path,
|
|
1119
|
+
selected,
|
|
1120
|
+
style,
|
|
1121
|
+
schemaType,
|
|
1122
|
+
type,
|
|
1123
|
+
value
|
|
1124
|
+
}) {
|
|
1125
|
+
return renderBlock({
|
|
1126
|
+
children,
|
|
1127
|
+
editorElementRef,
|
|
1128
|
+
focused,
|
|
1129
|
+
level,
|
|
1130
|
+
listItem,
|
|
1131
|
+
path,
|
|
1132
|
+
selected,
|
|
1133
|
+
style,
|
|
1134
|
+
schemaType,
|
|
1135
|
+
type,
|
|
1136
|
+
value
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
function RenderListItem({
|
|
1140
|
+
renderListItem,
|
|
1141
|
+
block,
|
|
1142
|
+
children,
|
|
1143
|
+
editorElementRef,
|
|
1144
|
+
focused,
|
|
1145
|
+
level,
|
|
1146
|
+
path,
|
|
1147
|
+
schemaType,
|
|
1148
|
+
selected,
|
|
1149
|
+
value
|
|
1150
|
+
}) {
|
|
1151
|
+
return renderListItem({
|
|
1152
|
+
block,
|
|
1153
|
+
children,
|
|
1154
|
+
editorElementRef,
|
|
1155
|
+
focused,
|
|
1156
|
+
level,
|
|
1157
|
+
path,
|
|
1158
|
+
schemaType,
|
|
1159
|
+
selected,
|
|
1160
|
+
value
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
function RenderStyle({
|
|
1164
|
+
renderStyle,
|
|
1165
|
+
block,
|
|
1166
|
+
children,
|
|
1167
|
+
editorElementRef,
|
|
1168
|
+
focused,
|
|
1169
|
+
path,
|
|
1170
|
+
schemaType,
|
|
1171
|
+
selected,
|
|
1172
|
+
value
|
|
1173
|
+
}) {
|
|
1174
|
+
return renderStyle({
|
|
1175
|
+
block,
|
|
1176
|
+
children,
|
|
1177
|
+
editorElementRef,
|
|
1178
|
+
focused,
|
|
1179
|
+
path,
|
|
1180
|
+
schemaType,
|
|
1181
|
+
selected,
|
|
1182
|
+
value
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1065
1185
|
function RenderElement(props) {
|
|
1066
1186
|
const $ = c(34), editorActor = useContext(EditorActorContext), schema = useSelector(editorActor, _temp$3), legacySchema = useSelector(editorActor, _temp2$2), slateStatic = useSlateStatic();
|
|
1067
1187
|
if ("__inline" in props.element && props.element.__inline === !0) {
|
|
@@ -1188,11 +1308,11 @@ function RenderSpan(props) {
|
|
|
1188
1308
|
}), children = props.children;
|
|
1189
1309
|
for (const mark_1 of decorators) {
|
|
1190
1310
|
const legacyDecoratorSchemaType = legacySchema.decorators.find((dec) => dec.value === mark_1);
|
|
1191
|
-
path && legacyDecoratorSchemaType && props.renderDecorator && (children = /* @__PURE__ */ jsx(props.renderDecorator,
|
|
1311
|
+
path && legacyDecoratorSchemaType && props.renderDecorator && (children = /* @__PURE__ */ jsx(RenderDecorator, { renderDecorator: props.renderDecorator, editorElementRef: spanRef, focused, path, selected, schemaType: legacyDecoratorSchemaType, value: mark_1, type: legacyDecoratorSchemaType, children }));
|
|
1192
1312
|
}
|
|
1193
1313
|
for (const annotationMarkDef of annotationMarkDefs) {
|
|
1194
1314
|
const legacyAnnotationSchemaType = legacySchema.annotations.find((t) => t.name === annotationMarkDef._type);
|
|
1195
|
-
legacyAnnotationSchemaType && (block_0 && path && props.renderAnnotation ? children = /* @__PURE__ */ jsx("span", { ref: spanRef, children: /* @__PURE__ */ jsx(props.renderAnnotation,
|
|
1315
|
+
legacyAnnotationSchemaType && (block_0 && path && props.renderAnnotation ? children = /* @__PURE__ */ jsx("span", { ref: spanRef, children: /* @__PURE__ */ jsx(RenderAnnotation, { renderAnnotation: props.renderAnnotation, block: block_0, editorElementRef: spanRef, focused, path, selected, schemaType: legacyAnnotationSchemaType, value: annotationMarkDef, type: legacyAnnotationSchemaType, children }) }) : children = /* @__PURE__ */ jsx("span", { ref: spanRef, children }));
|
|
1196
1316
|
}
|
|
1197
1317
|
$[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;
|
|
1198
1318
|
} else
|
|
@@ -1207,7 +1327,7 @@ function RenderSpan(props) {
|
|
|
1207
1327
|
const child = t32;
|
|
1208
1328
|
if (child) {
|
|
1209
1329
|
let t4;
|
|
1210
|
-
$[28] !== annotationMarkDefs || $[29] !== child || $[30] !== children || $[31] !== focused || $[32] !== legacySchema.span || $[33] !== path || $[34] !== props.renderChild || $[35] !== selected ? (t4 = /* @__PURE__ */ jsx(props.renderChild,
|
|
1330
|
+
$[28] !== annotationMarkDefs || $[29] !== child || $[30] !== children || $[31] !== focused || $[32] !== legacySchema.span || $[33] !== path || $[34] !== props.renderChild || $[35] !== selected ? (t4 = /* @__PURE__ */ jsx(RenderChild, { renderChild: props.renderChild, annotations: annotationMarkDefs, editorElementRef: spanRef, focused, path, schemaType: legacySchema.span, selected, value: child, type: legacySchema.span, children }), $[28] = annotationMarkDefs, $[29] = child, $[30] = children, $[31] = focused, $[32] = legacySchema.span, $[33] = path, $[34] = props.renderChild, $[35] = selected, $[36] = t4) : t4 = $[36], children = t4;
|
|
1211
1331
|
}
|
|
1212
1332
|
}
|
|
1213
1333
|
let t3;
|
|
@@ -1219,6 +1339,76 @@ function _temp2$1(decorator) {
|
|
|
1219
1339
|
function _temp$2(s) {
|
|
1220
1340
|
return s.context.getLegacySchema();
|
|
1221
1341
|
}
|
|
1342
|
+
function RenderAnnotation({
|
|
1343
|
+
renderAnnotation,
|
|
1344
|
+
block,
|
|
1345
|
+
children,
|
|
1346
|
+
editorElementRef,
|
|
1347
|
+
focused,
|
|
1348
|
+
path,
|
|
1349
|
+
schemaType,
|
|
1350
|
+
selected,
|
|
1351
|
+
value,
|
|
1352
|
+
type
|
|
1353
|
+
}) {
|
|
1354
|
+
return renderAnnotation({
|
|
1355
|
+
block,
|
|
1356
|
+
children,
|
|
1357
|
+
editorElementRef,
|
|
1358
|
+
focused,
|
|
1359
|
+
path,
|
|
1360
|
+
schemaType,
|
|
1361
|
+
selected,
|
|
1362
|
+
value,
|
|
1363
|
+
type
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
function RenderDecorator({
|
|
1367
|
+
renderDecorator,
|
|
1368
|
+
children,
|
|
1369
|
+
editorElementRef,
|
|
1370
|
+
focused,
|
|
1371
|
+
path,
|
|
1372
|
+
schemaType,
|
|
1373
|
+
selected,
|
|
1374
|
+
value,
|
|
1375
|
+
type
|
|
1376
|
+
}) {
|
|
1377
|
+
return renderDecorator({
|
|
1378
|
+
children,
|
|
1379
|
+
editorElementRef,
|
|
1380
|
+
focused,
|
|
1381
|
+
path,
|
|
1382
|
+
schemaType,
|
|
1383
|
+
selected,
|
|
1384
|
+
value,
|
|
1385
|
+
type
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
function RenderChild({
|
|
1389
|
+
renderChild,
|
|
1390
|
+
annotations,
|
|
1391
|
+
children,
|
|
1392
|
+
editorElementRef,
|
|
1393
|
+
focused,
|
|
1394
|
+
path,
|
|
1395
|
+
schemaType,
|
|
1396
|
+
selected,
|
|
1397
|
+
value,
|
|
1398
|
+
type
|
|
1399
|
+
}) {
|
|
1400
|
+
return renderChild({
|
|
1401
|
+
annotations,
|
|
1402
|
+
children,
|
|
1403
|
+
editorElementRef,
|
|
1404
|
+
focused,
|
|
1405
|
+
path,
|
|
1406
|
+
schemaType,
|
|
1407
|
+
selected,
|
|
1408
|
+
value,
|
|
1409
|
+
type
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1222
1412
|
const PLACEHOLDER_STYLE = {
|
|
1223
1413
|
position: "absolute",
|
|
1224
1414
|
userSelect: "none",
|