@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.js
CHANGED
|
@@ -5926,8 +5926,6 @@ const insertBlockObjectActionImplementation = ({
|
|
|
5926
5926
|
}) => {
|
|
5927
5927
|
ReactEditor.focus(action.editor);
|
|
5928
5928
|
},
|
|
5929
|
-
copy: () => {
|
|
5930
|
-
},
|
|
5931
5929
|
"delete.backward": ({
|
|
5932
5930
|
action
|
|
5933
5931
|
}) => {
|
|
@@ -6028,10 +6026,6 @@ const insertBlockObjectActionImplementation = ({
|
|
|
6028
6026
|
}) => {
|
|
6029
6027
|
action.effect();
|
|
6030
6028
|
},
|
|
6031
|
-
"key.down": () => {
|
|
6032
|
-
},
|
|
6033
|
-
"key.up": () => {
|
|
6034
|
-
},
|
|
6035
6029
|
"list item.add": addListItemActionImplementation,
|
|
6036
6030
|
"list item.remove": removeListItemActionImplementation,
|
|
6037
6031
|
"list item.toggle": toggleListItemActionImplementation,
|
|
@@ -6070,8 +6064,6 @@ const insertBlockObjectActionImplementation = ({
|
|
|
6070
6064
|
},
|
|
6071
6065
|
noop: () => {
|
|
6072
6066
|
},
|
|
6073
|
-
paste: () => {
|
|
6074
|
-
},
|
|
6075
6067
|
select: ({
|
|
6076
6068
|
action
|
|
6077
6069
|
}) => {
|
|
@@ -6292,8 +6284,6 @@ function performDefaultAction({
|
|
|
6292
6284
|
});
|
|
6293
6285
|
break;
|
|
6294
6286
|
}
|
|
6295
|
-
case "copy":
|
|
6296
|
-
break;
|
|
6297
6287
|
case "decorator.add": {
|
|
6298
6288
|
behaviorActionImplementations["decorator.add"]({
|
|
6299
6289
|
context,
|
|
@@ -6371,10 +6361,6 @@ function performDefaultAction({
|
|
|
6371
6361
|
});
|
|
6372
6362
|
break;
|
|
6373
6363
|
}
|
|
6374
|
-
case "key.down":
|
|
6375
|
-
break;
|
|
6376
|
-
case "key.up":
|
|
6377
|
-
break;
|
|
6378
6364
|
case "list item.toggle": {
|
|
6379
6365
|
behaviorActionImplementations["list item.toggle"]({
|
|
6380
6366
|
context,
|
|
@@ -6382,8 +6368,6 @@ function performDefaultAction({
|
|
|
6382
6368
|
});
|
|
6383
6369
|
break;
|
|
6384
6370
|
}
|
|
6385
|
-
case "paste":
|
|
6386
|
-
break;
|
|
6387
6371
|
default:
|
|
6388
6372
|
behaviorActionImplementations["style.toggle"]({
|
|
6389
6373
|
context,
|
|
@@ -6437,11 +6421,13 @@ const editorMachine = setup({
|
|
|
6437
6421
|
enqueue
|
|
6438
6422
|
}) => {
|
|
6439
6423
|
assertEvent(event, ["behavior event"]), debug$l("Behavior event", event);
|
|
6440
|
-
const defaultAction = {
|
|
6424
|
+
const defaultAction = event.behaviorEvent.type === "copy" || event.behaviorEvent.type === "key.down" || event.behaviorEvent.type === "key.up" || event.behaviorEvent.type === "paste" ? void 0 : {
|
|
6441
6425
|
...event.behaviorEvent,
|
|
6442
6426
|
editor: event.editor
|
|
6443
6427
|
}, eventBehaviors = context.behaviors.filter((behavior) => behavior.on === event.behaviorEvent.type);
|
|
6444
6428
|
if (eventBehaviors.length === 0) {
|
|
6429
|
+
if (!defaultAction)
|
|
6430
|
+
return;
|
|
6445
6431
|
enqueue.raise({
|
|
6446
6432
|
type: "behavior action intends",
|
|
6447
6433
|
editor: event.editor,
|
|
@@ -6451,7 +6437,9 @@ const editorMachine = setup({
|
|
|
6451
6437
|
}
|
|
6452
6438
|
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);
|
|
6453
6439
|
if (!selection) {
|
|
6454
|
-
console.warn(`Unable to handle event ${event.type} due to missing selection`),
|
|
6440
|
+
if (console.warn(`Unable to handle event ${event.type} due to missing selection`), !defaultAction)
|
|
6441
|
+
return;
|
|
6442
|
+
enqueue.raise({
|
|
6455
6443
|
type: "behavior action intends",
|
|
6456
6444
|
editor: event.editor,
|
|
6457
6445
|
actionIntends: [defaultAction]
|
|
@@ -6484,11 +6472,15 @@ const editorMachine = setup({
|
|
|
6484
6472
|
break;
|
|
6485
6473
|
}
|
|
6486
6474
|
}
|
|
6487
|
-
behaviorOverwritten
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6475
|
+
if (!behaviorOverwritten) {
|
|
6476
|
+
if (!defaultAction)
|
|
6477
|
+
return;
|
|
6478
|
+
enqueue.raise({
|
|
6479
|
+
type: "behavior action intends",
|
|
6480
|
+
editor: event.editor,
|
|
6481
|
+
actionIntends: [defaultAction]
|
|
6482
|
+
});
|
|
6483
|
+
}
|
|
6492
6484
|
})
|
|
6493
6485
|
}
|
|
6494
6486
|
}).createMachine({
|