@portabletext/editor 2.12.3 → 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-cjs/selector.is-selecting-entire-blocks.cjs +64 -5
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +1 -0
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +9 -17
- package/lib/_chunks-dts/behavior.types.action.d.ts +9 -17
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +65 -6
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +1 -0
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.cjs +262 -29
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +262 -29
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/index.js +1 -1
- package/lib/selectors/index.cjs +1 -0
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +15 -1
- package/lib/selectors/index.d.ts +15 -1
- package/lib/selectors/index.js +2 -1
- package/lib/utils/index.d.cts +2 -2
- package/package.json +13 -13
- package/src/behaviors/behavior.abstract.delete.ts +1 -0
- package/src/behaviors/behavior.abstract.keyboard.ts +27 -0
- 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/src/internal-utils/asserters.ts +1 -1
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +22 -0
- package/src/operations/behavior.operation.delete.ts +6 -24
- package/src/selectors/index.ts +1 -0
- package/src/selectors/selector.get-mark-state.ts +75 -6
- package/src/types/paths.ts +18 -0
package/lib/index.js
CHANGED
|
@@ -157,17 +157,6 @@ function fromSlateValue(value, textBlockType, keyMap = {}) {
|
|
|
157
157
|
function isEqualToEmptyEditor(children, schemaTypes) {
|
|
158
158
|
return children === void 0 || children && Array.isArray(children) && children.length === 0 || children && Array.isArray(children) && children.length === 1 && Element$1.isElement(children[0]) && children[0]._type === schemaTypes.block.name && "style" in children[0] && children[0].style === schemaTypes.styles[0].name && !("listItem" in children[0]) && Array.isArray(children[0].children) && children[0].children.length === 1 && Text.isText(children[0].children[0]) && children[0].children[0]._type === "span" && !children[0].children[0].marks?.join("") && children[0].children[0].text === "";
|
|
159
159
|
}
|
|
160
|
-
function getBlockPath({
|
|
161
|
-
editor,
|
|
162
|
-
_key
|
|
163
|
-
}) {
|
|
164
|
-
const [, blockPath] = Array.from(Editor.nodes(editor, {
|
|
165
|
-
at: [],
|
|
166
|
-
match: (n) => n._key === _key
|
|
167
|
-
})).at(0) ?? [void 0, void 0], blockIndex = blockPath?.at(0);
|
|
168
|
-
if (blockIndex !== void 0)
|
|
169
|
-
return [blockIndex];
|
|
170
|
-
}
|
|
171
160
|
function getFocusBlock({
|
|
172
161
|
editor
|
|
173
162
|
}) {
|
|
@@ -918,7 +907,7 @@ function RenderBlockObject(props) {
|
|
|
918
907
|
$[13] !== dragPositionBlock ? (t4 = dragPositionBlock === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[13] = dragPositionBlock, $[14] = t4) : t4 = $[14];
|
|
919
908
|
const t5 = !props.readOnly;
|
|
920
909
|
let t6;
|
|
921
|
-
$[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: [{
|
|
922
911
|
_key: props.element._key
|
|
923
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];
|
|
924
913
|
let t7;
|
|
@@ -933,6 +922,28 @@ function RenderBlockObject(props) {
|
|
|
933
922
|
t8
|
|
934
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;
|
|
935
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
|
+
}
|
|
936
947
|
function RenderInlineObject(props) {
|
|
937
948
|
const $ = c(32), inlineObjectRef = useRef(null), slateEditor = useSlateStatic(), selected = useSelected();
|
|
938
949
|
let t0;
|
|
@@ -974,7 +985,7 @@ function RenderInlineObject(props) {
|
|
|
974
985
|
display: "inline-block"
|
|
975
986
|
}, $[16] = t6) : t6 = $[16];
|
|
976
987
|
let t7;
|
|
977
|
-
$[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: [{
|
|
978
989
|
_key: block._key
|
|
979
990
|
}, "children", {
|
|
980
991
|
_key: props.element._key
|
|
@@ -985,6 +996,30 @@ function RenderInlineObject(props) {
|
|
|
985
996
|
t7
|
|
986
997
|
] }), $[25] = inlineObject_0._key, $[26] = inlineObject_0._type, $[27] = props.attributes, $[28] = props.children, $[29] = t5, $[30] = t7, $[31] = t8) : t8 = $[31], t8;
|
|
987
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
|
+
}
|
|
988
1023
|
function RenderTextBlock(props) {
|
|
989
1024
|
const $ = c(77), [dragPositionBlock, setDragPositionBlock] = useState(), blockRef = useRef(null), selected = useSelected();
|
|
990
1025
|
let t0;
|
|
@@ -1009,7 +1044,7 @@ function RenderTextBlock(props) {
|
|
|
1009
1044
|
_key: props.textBlock._key
|
|
1010
1045
|
}], $[9] = props.textBlock._key, $[10] = t42) : t42 = $[10];
|
|
1011
1046
|
let t52;
|
|
1012
|
-
$[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;
|
|
1013
1048
|
} else
|
|
1014
1049
|
console.error(`Unable to find Schema type for text block style ${props.textBlock.style}`);
|
|
1015
1050
|
}
|
|
@@ -1028,7 +1063,7 @@ function RenderTextBlock(props) {
|
|
|
1028
1063
|
_key: props.textBlock._key
|
|
1029
1064
|
}], $[24] = props.textBlock._key, $[25] = t52) : t52 = $[25];
|
|
1030
1065
|
let t62;
|
|
1031
|
-
$[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;
|
|
1032
1067
|
} else
|
|
1033
1068
|
console.error(`Unable to find Schema type for text block list item ${props.textBlock.listItem}`);
|
|
1034
1069
|
}
|
|
@@ -1059,7 +1094,7 @@ function RenderTextBlock(props) {
|
|
|
1059
1094
|
let t12;
|
|
1060
1095
|
$[51] !== dragPositionBlock ? (t12 = dragPositionBlock === "start" ? /* @__PURE__ */ jsx(DropIndicator, {}) : null, $[51] = dragPositionBlock, $[52] = t12) : t12 = $[52];
|
|
1061
1096
|
let t13;
|
|
1062
|
-
$[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: [{
|
|
1063
1098
|
_key: props.textBlock._key
|
|
1064
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];
|
|
1065
1100
|
let t14;
|
|
@@ -1073,6 +1108,80 @@ function RenderTextBlock(props) {
|
|
|
1073
1108
|
t15
|
|
1074
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;
|
|
1075
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
|
+
}
|
|
1076
1185
|
function RenderElement(props) {
|
|
1077
1186
|
const $ = c(34), editorActor = useContext(EditorActorContext), schema = useSelector(editorActor, _temp$3), legacySchema = useSelector(editorActor, _temp2$2), slateStatic = useSlateStatic();
|
|
1078
1187
|
if ("__inline" in props.element && props.element.__inline === !0) {
|
|
@@ -1199,11 +1308,11 @@ function RenderSpan(props) {
|
|
|
1199
1308
|
}), children = props.children;
|
|
1200
1309
|
for (const mark_1 of decorators) {
|
|
1201
1310
|
const legacyDecoratorSchemaType = legacySchema.decorators.find((dec) => dec.value === mark_1);
|
|
1202
|
-
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 }));
|
|
1203
1312
|
}
|
|
1204
1313
|
for (const annotationMarkDef of annotationMarkDefs) {
|
|
1205
1314
|
const legacyAnnotationSchemaType = legacySchema.annotations.find((t) => t.name === annotationMarkDef._type);
|
|
1206
|
-
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 }));
|
|
1207
1316
|
}
|
|
1208
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;
|
|
1209
1318
|
} else
|
|
@@ -1218,7 +1327,7 @@ function RenderSpan(props) {
|
|
|
1218
1327
|
const child = t32;
|
|
1219
1328
|
if (child) {
|
|
1220
1329
|
let t4;
|
|
1221
|
-
$[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;
|
|
1222
1331
|
}
|
|
1223
1332
|
}
|
|
1224
1333
|
let t3;
|
|
@@ -1230,6 +1339,76 @@ function _temp2$1(decorator) {
|
|
|
1230
1339
|
function _temp$2(s) {
|
|
1231
1340
|
return s.context.getLegacySchema();
|
|
1232
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
|
+
}
|
|
1233
1412
|
const PLACEHOLDER_STYLE = {
|
|
1234
1413
|
position: "absolute",
|
|
1235
1414
|
userSelect: "none",
|
|
@@ -4433,16 +4612,19 @@ const addAnnotationOperationImplementation = ({
|
|
|
4433
4612
|
const endBlock = operation.editor.value.at(endBlockIndex);
|
|
4434
4613
|
if (!endBlock)
|
|
4435
4614
|
throw new Error("Failed to get end block");
|
|
4436
|
-
|
|
4437
|
-
editor: operation.editor,
|
|
4438
|
-
_key: anchorBlockKey
|
|
4439
|
-
}) : void 0, focusBlockPath = focusBlockKey !== void 0 ? getBlockPath({
|
|
4440
|
-
editor: operation.editor,
|
|
4441
|
-
_key: focusBlockKey
|
|
4442
|
-
}) : void 0;
|
|
4443
|
-
if (operation.at.anchor.path.length === 1 && operation.at.focus.path.length === 1 && anchorBlockPath && focusBlockPath && anchorBlockPath[0] === focusBlockPath[0]) {
|
|
4615
|
+
if (operation.unit === "block") {
|
|
4444
4616
|
Transforms.removeNodes(operation.editor, {
|
|
4445
|
-
at:
|
|
4617
|
+
at: {
|
|
4618
|
+
anchor: {
|
|
4619
|
+
path: [startBlockIndex],
|
|
4620
|
+
offset: 0
|
|
4621
|
+
},
|
|
4622
|
+
focus: {
|
|
4623
|
+
path: [endBlockIndex],
|
|
4624
|
+
offset: 0
|
|
4625
|
+
}
|
|
4626
|
+
},
|
|
4627
|
+
mode: "highest"
|
|
4446
4628
|
}), operation.editor.children.length === 0 && Transforms.insertNodes(operation.editor, createPlaceholderBlock(context));
|
|
4447
4629
|
return;
|
|
4448
4630
|
}
|
|
@@ -6630,6 +6812,15 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
6630
6812
|
shift: !1
|
|
6631
6813
|
}]
|
|
6632
6814
|
}),
|
|
6815
|
+
backspace: createKeyboardShortcut({
|
|
6816
|
+
default: [{
|
|
6817
|
+
key: "Backspace",
|
|
6818
|
+
alt: !1,
|
|
6819
|
+
ctrl: !1,
|
|
6820
|
+
meta: !1,
|
|
6821
|
+
shift: !1
|
|
6822
|
+
}]
|
|
6823
|
+
}),
|
|
6633
6824
|
break: createKeyboardShortcut({
|
|
6634
6825
|
default: [{
|
|
6635
6826
|
key: "Enter",
|
|
@@ -6648,6 +6839,15 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
6648
6839
|
underline,
|
|
6649
6840
|
code
|
|
6650
6841
|
},
|
|
6842
|
+
delete: createKeyboardShortcut({
|
|
6843
|
+
default: [{
|
|
6844
|
+
key: "Delete",
|
|
6845
|
+
alt: !1,
|
|
6846
|
+
ctrl: !1,
|
|
6847
|
+
meta: !1,
|
|
6848
|
+
shift: !1
|
|
6849
|
+
}]
|
|
6850
|
+
}),
|
|
6651
6851
|
history: {
|
|
6652
6852
|
undo,
|
|
6653
6853
|
redo
|
|
@@ -8043,7 +8243,8 @@ const abstractAnnotationBehaviors = [defineBehavior({
|
|
|
8043
8243
|
path: event.at,
|
|
8044
8244
|
offset: 0
|
|
8045
8245
|
}
|
|
8046
|
-
}
|
|
8246
|
+
},
|
|
8247
|
+
unit: "block"
|
|
8047
8248
|
})]]
|
|
8048
8249
|
}), defineBehavior({
|
|
8049
8250
|
on: "delete.child",
|
|
@@ -8691,6 +8892,38 @@ const abstractAnnotationBehaviors = [defineBehavior({
|
|
|
8691
8892
|
alt: !1
|
|
8692
8893
|
}]
|
|
8693
8894
|
}), abstractKeyboardBehaviors = [
|
|
8895
|
+
/**
|
|
8896
|
+
* When Backspace is pressed on an inline object, Slate will raise a
|
|
8897
|
+
* `delete.backward` event with `unit: 'block'`. This is wrong and this
|
|
8898
|
+
* Behavior adjusts that.
|
|
8899
|
+
*/
|
|
8900
|
+
defineBehavior({
|
|
8901
|
+
on: "keyboard.keydown",
|
|
8902
|
+
guard: ({
|
|
8903
|
+
snapshot,
|
|
8904
|
+
event
|
|
8905
|
+
}) => defaultKeyboardShortcuts.backspace.guard(event.originEvent) && isSelectionCollapsed$1(snapshot) && getFocusInlineObject(snapshot),
|
|
8906
|
+
actions: [() => [raise({
|
|
8907
|
+
type: "delete.backward",
|
|
8908
|
+
unit: "character"
|
|
8909
|
+
})]]
|
|
8910
|
+
}),
|
|
8911
|
+
/**
|
|
8912
|
+
* When Delete is pressed on an inline object, Slate will raise a
|
|
8913
|
+
* `delete.forward` event with `unit: 'block'`. This is wrong and this
|
|
8914
|
+
* Behavior adjusts that.
|
|
8915
|
+
*/
|
|
8916
|
+
defineBehavior({
|
|
8917
|
+
on: "keyboard.keydown",
|
|
8918
|
+
guard: ({
|
|
8919
|
+
snapshot,
|
|
8920
|
+
event
|
|
8921
|
+
}) => defaultKeyboardShortcuts.delete.guard(event.originEvent) && isSelectionCollapsed$1(snapshot) && getFocusInlineObject(snapshot),
|
|
8922
|
+
actions: [() => [raise({
|
|
8923
|
+
type: "delete.forward",
|
|
8924
|
+
unit: "character"
|
|
8925
|
+
})]]
|
|
8926
|
+
}),
|
|
8694
8927
|
/**
|
|
8695
8928
|
* Allow raising an `insert.break` event when pressing Enter on an inline
|
|
8696
8929
|
* object.
|