@portabletext/editor 1.14.0 → 1.14.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/index.cjs +15 -23
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +219 -215
- package/lib/index.d.ts +219 -215
- package/lib/index.js +15 -23
- package/lib/index.js.map +1 -1
- package/package.json +13 -13
- package/src/editor/behavior/behavior.actions.ts +2 -34
- package/src/editor/behavior/behavior.types.ts +31 -27
- package/src/editor/editor-machine.ts +29 -9
- package/src/index.ts +4 -2
package/lib/index.cjs
CHANGED
|
@@ -5905,8 +5905,6 @@ const insertBlockObjectActionImplementation = ({
|
|
|
5905
5905
|
}) => {
|
|
5906
5906
|
slateReact.ReactEditor.focus(action.editor);
|
|
5907
5907
|
},
|
|
5908
|
-
copy: () => {
|
|
5909
|
-
},
|
|
5910
5908
|
"delete.backward": ({
|
|
5911
5909
|
action
|
|
5912
5910
|
}) => {
|
|
@@ -6007,10 +6005,6 @@ const insertBlockObjectActionImplementation = ({
|
|
|
6007
6005
|
}) => {
|
|
6008
6006
|
action.effect();
|
|
6009
6007
|
},
|
|
6010
|
-
"key.down": () => {
|
|
6011
|
-
},
|
|
6012
|
-
"key.up": () => {
|
|
6013
|
-
},
|
|
6014
6008
|
"list item.add": addListItemActionImplementation,
|
|
6015
6009
|
"list item.remove": removeListItemActionImplementation,
|
|
6016
6010
|
"list item.toggle": toggleListItemActionImplementation,
|
|
@@ -6049,8 +6043,6 @@ const insertBlockObjectActionImplementation = ({
|
|
|
6049
6043
|
},
|
|
6050
6044
|
noop: () => {
|
|
6051
6045
|
},
|
|
6052
|
-
paste: () => {
|
|
6053
|
-
},
|
|
6054
6046
|
select: ({
|
|
6055
6047
|
action
|
|
6056
6048
|
}) => {
|
|
@@ -6271,8 +6263,6 @@ function performDefaultAction({
|
|
|
6271
6263
|
});
|
|
6272
6264
|
break;
|
|
6273
6265
|
}
|
|
6274
|
-
case "copy":
|
|
6275
|
-
break;
|
|
6276
6266
|
case "decorator.add": {
|
|
6277
6267
|
behaviorActionImplementations["decorator.add"]({
|
|
6278
6268
|
context,
|
|
@@ -6350,10 +6340,6 @@ function performDefaultAction({
|
|
|
6350
6340
|
});
|
|
6351
6341
|
break;
|
|
6352
6342
|
}
|
|
6353
|
-
case "key.down":
|
|
6354
|
-
break;
|
|
6355
|
-
case "key.up":
|
|
6356
|
-
break;
|
|
6357
6343
|
case "list item.toggle": {
|
|
6358
6344
|
behaviorActionImplementations["list item.toggle"]({
|
|
6359
6345
|
context,
|
|
@@ -6361,8 +6347,6 @@ function performDefaultAction({
|
|
|
6361
6347
|
});
|
|
6362
6348
|
break;
|
|
6363
6349
|
}
|
|
6364
|
-
case "paste":
|
|
6365
|
-
break;
|
|
6366
6350
|
default:
|
|
6367
6351
|
behaviorActionImplementations["style.toggle"]({
|
|
6368
6352
|
context,
|
|
@@ -6416,11 +6400,13 @@ const editorMachine = xstate.setup({
|
|
|
6416
6400
|
enqueue
|
|
6417
6401
|
}) => {
|
|
6418
6402
|
xstate.assertEvent(event, ["behavior event"]), debug$l("Behavior event", event);
|
|
6419
|
-
const defaultAction = {
|
|
6403
|
+
const defaultAction = event.behaviorEvent.type === "copy" || event.behaviorEvent.type === "key.down" || event.behaviorEvent.type === "key.up" || event.behaviorEvent.type === "paste" ? void 0 : {
|
|
6420
6404
|
...event.behaviorEvent,
|
|
6421
6405
|
editor: event.editor
|
|
6422
6406
|
}, eventBehaviors = context.behaviors.filter((behavior) => behavior.on === event.behaviorEvent.type);
|
|
6423
6407
|
if (eventBehaviors.length === 0) {
|
|
6408
|
+
if (!defaultAction)
|
|
6409
|
+
return;
|
|
6424
6410
|
enqueue.raise({
|
|
6425
6411
|
type: "behavior action intends",
|
|
6426
6412
|
editor: event.editor,
|
|
@@ -6430,7 +6416,9 @@ const editorMachine = xstate.setup({
|
|
|
6430
6416
|
}
|
|
6431
6417
|
const value = fromSlateValue(event.editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(event.editor)), selection = toPortableTextRange(value, event.editor.selection, context.schema);
|
|
6432
6418
|
if (!selection) {
|
|
6433
|
-
console.warn(`Unable to handle event ${event.type} due to missing selection`),
|
|
6419
|
+
if (console.warn(`Unable to handle event ${event.type} due to missing selection`), !defaultAction)
|
|
6420
|
+
return;
|
|
6421
|
+
enqueue.raise({
|
|
6434
6422
|
type: "behavior action intends",
|
|
6435
6423
|
editor: event.editor,
|
|
6436
6424
|
actionIntends: [defaultAction]
|
|
@@ -6463,11 +6451,15 @@ const editorMachine = xstate.setup({
|
|
|
6463
6451
|
break;
|
|
6464
6452
|
}
|
|
6465
6453
|
}
|
|
6466
|
-
behaviorOverwritten
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6454
|
+
if (!behaviorOverwritten) {
|
|
6455
|
+
if (!defaultAction)
|
|
6456
|
+
return;
|
|
6457
|
+
enqueue.raise({
|
|
6458
|
+
type: "behavior action intends",
|
|
6459
|
+
editor: event.editor,
|
|
6460
|
+
actionIntends: [defaultAction]
|
|
6461
|
+
});
|
|
6462
|
+
}
|
|
6471
6463
|
})
|
|
6472
6464
|
}
|
|
6473
6465
|
}).createMachine({
|