@portabletext/editor 2.19.0 → 2.19.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.js +67 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/behaviors/behavior.abstract.keyboard.ts +15 -0
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +42 -0
- package/src/operations/behavior.operation.delete.ts +18 -0
- package/src/test/gherkin-parameter-types.ts +5 -0
- package/src/test/vitest/step-definitions.tsx +17 -0
package/lib/index.js
CHANGED
|
@@ -4674,6 +4674,19 @@ const addAnnotationOperationImplementation = ({
|
|
|
4674
4674
|
}
|
|
4675
4675
|
}
|
|
4676
4676
|
}
|
|
4677
|
+
if (operation.unit === "word") {
|
|
4678
|
+
const range = at ?? operation.editor.selection ?? void 0;
|
|
4679
|
+
if (!range)
|
|
4680
|
+
throw new Error("Unable to delete word without a selection");
|
|
4681
|
+
if (Range.isCollapsed(range)) {
|
|
4682
|
+
deleteText(operation.editor, {
|
|
4683
|
+
at: range,
|
|
4684
|
+
unit: "word",
|
|
4685
|
+
reverse: operation.direction === "backward"
|
|
4686
|
+
});
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4677
4690
|
const hanging = reverse ? endPoint ? isTextBlock(context, endBlock) ? endPoint.offset === 0 : !0 : !1 : startPoint ? isTextBlock(context, startBlock) ? startPoint.offset === 0 : !0 : !1;
|
|
4678
4691
|
at ? deleteText(operation.editor, {
|
|
4679
4692
|
at,
|
|
@@ -7047,6 +7060,40 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
7047
7060
|
shift: !1
|
|
7048
7061
|
}]
|
|
7049
7062
|
}),
|
|
7063
|
+
deleteWord: {
|
|
7064
|
+
backward: createKeyboardShortcut({
|
|
7065
|
+
default: [{
|
|
7066
|
+
key: "Backspace",
|
|
7067
|
+
alt: !1,
|
|
7068
|
+
ctrl: !0,
|
|
7069
|
+
meta: !1
|
|
7070
|
+
// shift is optional
|
|
7071
|
+
}],
|
|
7072
|
+
apple: [{
|
|
7073
|
+
key: "Backspace",
|
|
7074
|
+
alt: !0,
|
|
7075
|
+
ctrl: !1,
|
|
7076
|
+
meta: !1
|
|
7077
|
+
// shift is optional
|
|
7078
|
+
}]
|
|
7079
|
+
}),
|
|
7080
|
+
forward: createKeyboardShortcut({
|
|
7081
|
+
default: [{
|
|
7082
|
+
key: "Delete",
|
|
7083
|
+
alt: !1,
|
|
7084
|
+
ctrl: !0,
|
|
7085
|
+
meta: !1
|
|
7086
|
+
// shift is optional
|
|
7087
|
+
}],
|
|
7088
|
+
apple: [{
|
|
7089
|
+
key: "Delete",
|
|
7090
|
+
alt: !0,
|
|
7091
|
+
ctrl: !1,
|
|
7092
|
+
meta: !1
|
|
7093
|
+
// shift is optional
|
|
7094
|
+
}]
|
|
7095
|
+
})
|
|
7096
|
+
},
|
|
7050
7097
|
history: {
|
|
7051
7098
|
undo,
|
|
7052
7099
|
redo
|
|
@@ -9179,6 +9226,26 @@ const abstractAnnotationBehaviors = [defineBehavior({
|
|
|
9179
9226
|
unit: "character"
|
|
9180
9227
|
})]]
|
|
9181
9228
|
}),
|
|
9229
|
+
defineBehavior({
|
|
9230
|
+
on: "keyboard.keydown",
|
|
9231
|
+
guard: ({
|
|
9232
|
+
event
|
|
9233
|
+
}) => defaultKeyboardShortcuts.deleteWord.backward.guard(event.originEvent),
|
|
9234
|
+
actions: [() => [raise({
|
|
9235
|
+
type: "delete.backward",
|
|
9236
|
+
unit: "word"
|
|
9237
|
+
})]]
|
|
9238
|
+
}),
|
|
9239
|
+
defineBehavior({
|
|
9240
|
+
on: "keyboard.keydown",
|
|
9241
|
+
guard: ({
|
|
9242
|
+
event
|
|
9243
|
+
}) => defaultKeyboardShortcuts.deleteWord.forward.guard(event.originEvent),
|
|
9244
|
+
actions: [() => [raise({
|
|
9245
|
+
type: "delete.forward",
|
|
9246
|
+
unit: "word"
|
|
9247
|
+
})]]
|
|
9248
|
+
}),
|
|
9182
9249
|
/**
|
|
9183
9250
|
* Allow raising an `insert.break` event when pressing Enter on an inline
|
|
9184
9251
|
* object.
|