@portabletext/editor 1.55.6 → 1.55.7
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.get-text-before.cjs +3 -3
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +37 -37
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +9 -9
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +10 -10
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs +5 -5
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/{selection-point.cjs → util.slice-blocks.cjs} +14 -14
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -0
- package/lib/_chunks-cjs/util.slice-text-block.cjs +11 -11
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
- package/lib/_chunks-es/util.is-equal-selection-points.js +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/{selection-point.js → util.slice-blocks.js} +14 -14
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -0
- package/lib/_chunks-es/util.slice-text-block.js +1 -1
- package/lib/index.cjs +417 -194
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +6 -6
- package/lib/index.d.ts +6 -6
- package/lib/index.js +350 -127
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +11 -11
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2 -2
- package/lib/plugins/index.d.ts +2 -2
- package/lib/plugins/index.js +2 -2
- package/lib/selectors/index.cjs +7 -7
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +1 -1
- package/lib/utils/index.cjs +11 -11
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -2
- package/package.json +13 -13
- package/src/behaviors/behavior.abstract.keyboard.ts +28 -3
- package/src/behaviors/behavior.core.block-objects.ts +5 -3
- package/src/behaviors/behavior.core.decorators.ts +5 -5
- package/src/behaviors/behavior.core.lists.ts +5 -3
- package/src/editor/relay-machine.ts +2 -2
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +207 -0
- package/src/keyboard-shortcuts/is-keyboard-shortcut.test.ts +93 -0
- package/src/keyboard-shortcuts/is-keyboard-shortcut.ts +28 -0
- package/src/keyboard-shortcuts/keyboard-shortcuts.ts +120 -0
- package/src/selection/selection-point.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.ts +3 -3
- package/src/types/editor.ts +1 -1
- package/src/utils/util.slice-blocks.ts +2 -1
- package/lib/_chunks-cjs/selection-point.cjs.map +0 -1
- package/lib/_chunks-es/selection-point.js.map +0 -1
- package/src/behaviors/behavior.emoji-picker.ts +0 -402
- package/src/internal-utils/key-is.ts +0 -11
package/lib/index.d.cts
CHANGED
|
@@ -960,7 +960,7 @@ export declare type EditorEmittedEvent =
|
|
|
960
960
|
}
|
|
961
961
|
| {
|
|
962
962
|
/**
|
|
963
|
-
* @deprecated
|
|
963
|
+
* @deprecated Will be removed in the next major version
|
|
964
964
|
*/
|
|
965
965
|
type: 'done loading'
|
|
966
966
|
}
|
|
@@ -979,7 +979,7 @@ export declare type EditorEmittedEvent =
|
|
|
979
979
|
}
|
|
980
980
|
| {
|
|
981
981
|
/**
|
|
982
|
-
* @deprecated
|
|
982
|
+
* @deprecated Will be removed in the next major version
|
|
983
983
|
*/
|
|
984
984
|
type: 'loading'
|
|
985
985
|
}
|
|
@@ -3417,7 +3417,7 @@ export declare type ListSchemaType = BaseDefinition & {
|
|
|
3417
3417
|
* The editor is currently loading something
|
|
3418
3418
|
* Could be used to show a spinner etc.
|
|
3419
3419
|
* @beta
|
|
3420
|
-
* @deprecated
|
|
3420
|
+
* @deprecated Will be removed in the next major version
|
|
3421
3421
|
*/
|
|
3422
3422
|
export declare type LoadingChange = {
|
|
3423
3423
|
type: 'loading'
|
|
@@ -3620,7 +3620,7 @@ export {PortableTextChild}
|
|
|
3620
3620
|
*/
|
|
3621
3621
|
export declare const PortableTextEditable: ForwardRefExoticComponent<
|
|
3622
3622
|
Omit<PortableTextEditableProps, 'ref'> &
|
|
3623
|
-
RefAttributes<Omit<HTMLDivElement, '
|
|
3623
|
+
RefAttributes<Omit<HTMLDivElement, 'as' | 'onPaste' | 'onBeforeInput'>>
|
|
3624
3624
|
>
|
|
3625
3625
|
|
|
3626
3626
|
/**
|
|
@@ -3756,9 +3756,9 @@ export declare class PortableTextEditor extends Component<
|
|
|
3756
3756
|
path: Path,
|
|
3757
3757
|
) => [
|
|
3758
3758
|
(
|
|
3759
|
-
| PortableTextSpan
|
|
3760
3759
|
| PortableTextObject
|
|
3761
|
-
|
|
|
3760
|
+
| PortableTextSpan
|
|
3761
|
+
| PortableTextTextBlock<PortableTextObject | PortableTextSpan>
|
|
3762
3762
|
| undefined
|
|
3763
3763
|
),
|
|
3764
3764
|
Path | undefined,
|
package/lib/index.d.ts
CHANGED
|
@@ -960,7 +960,7 @@ export declare type EditorEmittedEvent =
|
|
|
960
960
|
}
|
|
961
961
|
| {
|
|
962
962
|
/**
|
|
963
|
-
* @deprecated
|
|
963
|
+
* @deprecated Will be removed in the next major version
|
|
964
964
|
*/
|
|
965
965
|
type: 'done loading'
|
|
966
966
|
}
|
|
@@ -979,7 +979,7 @@ export declare type EditorEmittedEvent =
|
|
|
979
979
|
}
|
|
980
980
|
| {
|
|
981
981
|
/**
|
|
982
|
-
* @deprecated
|
|
982
|
+
* @deprecated Will be removed in the next major version
|
|
983
983
|
*/
|
|
984
984
|
type: 'loading'
|
|
985
985
|
}
|
|
@@ -3417,7 +3417,7 @@ export declare type ListSchemaType = BaseDefinition & {
|
|
|
3417
3417
|
* The editor is currently loading something
|
|
3418
3418
|
* Could be used to show a spinner etc.
|
|
3419
3419
|
* @beta
|
|
3420
|
-
* @deprecated
|
|
3420
|
+
* @deprecated Will be removed in the next major version
|
|
3421
3421
|
*/
|
|
3422
3422
|
export declare type LoadingChange = {
|
|
3423
3423
|
type: 'loading'
|
|
@@ -3620,7 +3620,7 @@ export {PortableTextChild}
|
|
|
3620
3620
|
*/
|
|
3621
3621
|
export declare const PortableTextEditable: ForwardRefExoticComponent<
|
|
3622
3622
|
Omit<PortableTextEditableProps, 'ref'> &
|
|
3623
|
-
RefAttributes<Omit<HTMLDivElement, '
|
|
3623
|
+
RefAttributes<Omit<HTMLDivElement, 'as' | 'onPaste' | 'onBeforeInput'>>
|
|
3624
3624
|
>
|
|
3625
3625
|
|
|
3626
3626
|
/**
|
|
@@ -3756,9 +3756,9 @@ export declare class PortableTextEditor extends Component<
|
|
|
3756
3756
|
path: Path,
|
|
3757
3757
|
) => [
|
|
3758
3758
|
(
|
|
3759
|
-
| PortableTextSpan
|
|
3760
3759
|
| PortableTextObject
|
|
3761
|
-
|
|
|
3760
|
+
| PortableTextSpan
|
|
3761
|
+
| PortableTextTextBlock<PortableTextObject | PortableTextSpan>
|
|
3762
3762
|
| undefined
|
|
3763
3763
|
),
|
|
3764
3764
|
Path | undefined,
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Element as Element$1, Text, Range, Editor, Node, Point, Transforms, Pat
|
|
|
9
9
|
import { useSelected, useSlateSelector, useSlateStatic, withReact, ReactEditor, Slate, useSlate, Editable } from "slate-react";
|
|
10
10
|
import debug$f from "debug";
|
|
11
11
|
import { DOMEditor, isDOMNode } from "slate-dom";
|
|
12
|
-
import { getBlockStartPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isTextBlock, parseBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, parseInlineObject, isKeyedSegment, isSpan$1 as isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/
|
|
12
|
+
import { getBlockStartPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isTextBlock, parseBlock, parseAnnotation, blockOffsetToSpanSelectionPoint, parseInlineObject, isKeyedSegment, isSpan$1 as isSpan, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint, getTextBlockText, parseBlocks } from "./_chunks-es/util.slice-blocks.js";
|
|
13
13
|
import { getBlockEndPoint, isEmptyTextBlock, isEqualSelectionPoints } from "./_chunks-es/util.is-equal-selection-points.js";
|
|
14
14
|
import { isSelectionCollapsed, selectionPointToBlockOffset, sliceTextBlock } from "./_chunks-es/util.slice-text-block.js";
|
|
15
15
|
import isEqual from "lodash/isEqual.js";
|
|
@@ -5380,125 +5380,211 @@ const addAnnotationOnCollapsedSelection = defineBehavior({
|
|
|
5380
5380
|
})]]
|
|
5381
5381
|
}), coreAnnotationBehaviors = {
|
|
5382
5382
|
addAnnotationOnCollapsedSelection
|
|
5383
|
-
}, IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
|
|
5384
|
-
alt: "altKey",
|
|
5385
|
-
control: "ctrlKey",
|
|
5386
|
-
meta: "metaKey",
|
|
5387
|
-
shift: "shiftKey"
|
|
5388
|
-
}, aliases = {
|
|
5389
|
-
add: "+",
|
|
5390
|
-
break: "pause",
|
|
5391
|
-
cmd: "meta",
|
|
5392
|
-
command: "meta",
|
|
5393
|
-
ctl: "control",
|
|
5394
|
-
ctrl: "control",
|
|
5395
|
-
del: "delete",
|
|
5396
|
-
down: "arrowdown",
|
|
5397
|
-
esc: "escape",
|
|
5398
|
-
ins: "insert",
|
|
5399
|
-
left: "arrowleft",
|
|
5400
|
-
mod: IS_MAC ? "meta" : "control",
|
|
5401
|
-
opt: "alt",
|
|
5402
|
-
option: "alt",
|
|
5403
|
-
return: "enter",
|
|
5404
|
-
right: "arrowright",
|
|
5405
|
-
space: " ",
|
|
5406
|
-
spacebar: " ",
|
|
5407
|
-
up: "arrowup",
|
|
5408
|
-
win: "meta",
|
|
5409
|
-
windows: "meta"
|
|
5410
|
-
}, keyCodes = {
|
|
5411
|
-
backspace: 8,
|
|
5412
|
-
tab: 9,
|
|
5413
|
-
enter: 13,
|
|
5414
|
-
shift: 16,
|
|
5415
|
-
control: 17,
|
|
5416
|
-
alt: 18,
|
|
5417
|
-
pause: 19,
|
|
5418
|
-
capslock: 20,
|
|
5419
|
-
escape: 27,
|
|
5420
|
-
" ": 32,
|
|
5421
|
-
pageup: 33,
|
|
5422
|
-
pagedown: 34,
|
|
5423
|
-
end: 35,
|
|
5424
|
-
home: 36,
|
|
5425
|
-
arrowleft: 37,
|
|
5426
|
-
arrowup: 38,
|
|
5427
|
-
arrowright: 39,
|
|
5428
|
-
arrowdown: 40,
|
|
5429
|
-
insert: 45,
|
|
5430
|
-
delete: 46,
|
|
5431
|
-
meta: 91,
|
|
5432
|
-
numlock: 144,
|
|
5433
|
-
scrolllock: 145,
|
|
5434
|
-
";": 186,
|
|
5435
|
-
"=": 187,
|
|
5436
|
-
",": 188,
|
|
5437
|
-
"-": 189,
|
|
5438
|
-
".": 190,
|
|
5439
|
-
"/": 191,
|
|
5440
|
-
"`": 192,
|
|
5441
|
-
"[": 219,
|
|
5442
|
-
"\\": 220,
|
|
5443
|
-
"]": 221,
|
|
5444
|
-
"'": 222,
|
|
5445
|
-
f1: 112,
|
|
5446
|
-
f2: 113,
|
|
5447
|
-
f3: 114,
|
|
5448
|
-
f4: 115,
|
|
5449
|
-
f5: 116,
|
|
5450
|
-
f6: 117,
|
|
5451
|
-
f7: 118,
|
|
5452
|
-
f8: 119,
|
|
5453
|
-
f9: 120,
|
|
5454
|
-
f10: 121,
|
|
5455
|
-
f11: 122,
|
|
5456
|
-
f12: 123,
|
|
5457
|
-
f13: 124,
|
|
5458
|
-
f14: 125,
|
|
5459
|
-
f15: 126,
|
|
5460
|
-
f16: 127,
|
|
5461
|
-
f17: 128,
|
|
5462
|
-
f18: 129,
|
|
5463
|
-
f19: 130,
|
|
5464
|
-
f20: 131
|
|
5465
5383
|
};
|
|
5466
|
-
function
|
|
5467
|
-
return
|
|
5468
|
-
}
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
}
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
}
|
|
5495
|
-
|
|
5384
|
+
function isKeyboardShortcut(event, key, allowedModifiers = {}) {
|
|
5385
|
+
return event.key.toLowerCase() === key.toLowerCase() && (allowedModifiers.ctrlKey === event.ctrlKey || allowedModifiers.ctrlKey === void 0) && (allowedModifiers.metaKey === event.metaKey || allowedModifiers.metaKey === void 0) && (allowedModifiers.shiftKey === event.shiftKey || allowedModifiers.shiftKey === void 0) && (allowedModifiers.altKey === event.altKey || allowedModifiers.altKey === void 0);
|
|
5386
|
+
}
|
|
5387
|
+
const IS_APPLE = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent);
|
|
5388
|
+
function createKeyboardShortcut(definition) {
|
|
5389
|
+
return IS_APPLE ? definition.apple ?? definition.default : definition.default;
|
|
5390
|
+
}
|
|
5391
|
+
const defaultKeyboardShortcuts = {
|
|
5392
|
+
arrowDown: createKeyboardShortcut({
|
|
5393
|
+
default: {
|
|
5394
|
+
guard: (event) => isKeyboardShortcut(event, "ArrowDown", {
|
|
5395
|
+
ctrlKey: !1,
|
|
5396
|
+
metaKey: !1,
|
|
5397
|
+
shiftKey: !1,
|
|
5398
|
+
altKey: !1
|
|
5399
|
+
}),
|
|
5400
|
+
keys: ["ArrowDown"]
|
|
5401
|
+
}
|
|
5402
|
+
}),
|
|
5403
|
+
arrowUp: createKeyboardShortcut({
|
|
5404
|
+
default: {
|
|
5405
|
+
guard: (event) => isKeyboardShortcut(event, "ArrowUp", {
|
|
5406
|
+
ctrlKey: !1,
|
|
5407
|
+
metaKey: !1,
|
|
5408
|
+
shiftKey: !1,
|
|
5409
|
+
altKey: !1
|
|
5410
|
+
}),
|
|
5411
|
+
keys: ["ArrowUp"]
|
|
5412
|
+
}
|
|
5413
|
+
}),
|
|
5414
|
+
break: createKeyboardShortcut({
|
|
5415
|
+
default: {
|
|
5416
|
+
guard: (event) => isKeyboardShortcut(event, "Enter", {
|
|
5417
|
+
shiftKey: !1
|
|
5418
|
+
}),
|
|
5419
|
+
keys: ["Enter"]
|
|
5420
|
+
}
|
|
5421
|
+
}),
|
|
5422
|
+
lineBreak: createKeyboardShortcut({
|
|
5423
|
+
default: {
|
|
5424
|
+
guard: (event) => isKeyboardShortcut(event, "Enter", {
|
|
5425
|
+
shiftKey: !0
|
|
5426
|
+
}),
|
|
5427
|
+
keys: ["Shift", "Enter"]
|
|
5428
|
+
}
|
|
5429
|
+
}),
|
|
5430
|
+
decorators: {
|
|
5431
|
+
strong: createKeyboardShortcut({
|
|
5432
|
+
default: {
|
|
5433
|
+
guard: (event) => isKeyboardShortcut(event, "b", {
|
|
5434
|
+
altKey: !1,
|
|
5435
|
+
ctrlKey: !0,
|
|
5436
|
+
metaKey: !1,
|
|
5437
|
+
shiftKey: !1
|
|
5438
|
+
}),
|
|
5439
|
+
keys: ["Ctrl", "B"]
|
|
5440
|
+
},
|
|
5441
|
+
apple: {
|
|
5442
|
+
guard: (event) => isKeyboardShortcut(event, "b", {
|
|
5443
|
+
altKey: !1,
|
|
5444
|
+
ctrlKey: !1,
|
|
5445
|
+
metaKey: !0,
|
|
5446
|
+
shiftKey: !1
|
|
5447
|
+
}),
|
|
5448
|
+
keys: ["\u2318", "B"]
|
|
5449
|
+
}
|
|
5450
|
+
}),
|
|
5451
|
+
em: createKeyboardShortcut({
|
|
5452
|
+
default: {
|
|
5453
|
+
guard: (event) => isKeyboardShortcut(event, "i", {
|
|
5454
|
+
altKey: !1,
|
|
5455
|
+
ctrlKey: !0,
|
|
5456
|
+
metaKey: !1,
|
|
5457
|
+
shiftKey: !1
|
|
5458
|
+
}),
|
|
5459
|
+
keys: ["Ctrl", "I"]
|
|
5460
|
+
},
|
|
5461
|
+
apple: {
|
|
5462
|
+
guard: (event) => isKeyboardShortcut(event, "i", {
|
|
5463
|
+
altKey: !1,
|
|
5464
|
+
ctrlKey: !1,
|
|
5465
|
+
metaKey: !0,
|
|
5466
|
+
shiftKey: !1
|
|
5467
|
+
}),
|
|
5468
|
+
keys: ["\u2318", "I"]
|
|
5469
|
+
}
|
|
5470
|
+
}),
|
|
5471
|
+
underline: createKeyboardShortcut({
|
|
5472
|
+
default: {
|
|
5473
|
+
guard: (event) => isKeyboardShortcut(event, "u", {
|
|
5474
|
+
altKey: !1,
|
|
5475
|
+
ctrlKey: !0,
|
|
5476
|
+
metaKey: !1,
|
|
5477
|
+
shiftKey: !1
|
|
5478
|
+
}),
|
|
5479
|
+
keys: ["Ctrl", "U"]
|
|
5480
|
+
},
|
|
5481
|
+
apple: {
|
|
5482
|
+
guard: (event) => isKeyboardShortcut(event, "u", {
|
|
5483
|
+
altKey: !1,
|
|
5484
|
+
ctrlKey: !1,
|
|
5485
|
+
metaKey: !0,
|
|
5486
|
+
shiftKey: !1
|
|
5487
|
+
}),
|
|
5488
|
+
keys: ["\u2318", "U"]
|
|
5489
|
+
}
|
|
5490
|
+
}),
|
|
5491
|
+
code: createKeyboardShortcut({
|
|
5492
|
+
default: {
|
|
5493
|
+
guard: (event) => isKeyboardShortcut(event, "'", {
|
|
5494
|
+
altKey: !1,
|
|
5495
|
+
ctrlKey: !0,
|
|
5496
|
+
metaKey: !1,
|
|
5497
|
+
shiftKey: !1
|
|
5498
|
+
}),
|
|
5499
|
+
keys: ["Ctrl", "'"]
|
|
5500
|
+
},
|
|
5501
|
+
apple: {
|
|
5502
|
+
guard: (event) => isKeyboardShortcut(event, "'", {
|
|
5503
|
+
altKey: !1,
|
|
5504
|
+
ctrlKey: !1,
|
|
5505
|
+
metaKey: !0,
|
|
5506
|
+
shiftKey: !1
|
|
5507
|
+
}),
|
|
5508
|
+
keys: ["\u2318", "'"]
|
|
5509
|
+
}
|
|
5510
|
+
})
|
|
5511
|
+
},
|
|
5512
|
+
history: {
|
|
5513
|
+
undo: createKeyboardShortcut({
|
|
5514
|
+
default: {
|
|
5515
|
+
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5516
|
+
altKey: !1,
|
|
5517
|
+
ctrlKey: !0,
|
|
5518
|
+
metaKey: !1,
|
|
5519
|
+
shiftKey: !1
|
|
5520
|
+
}),
|
|
5521
|
+
keys: ["Ctrl", "Z"]
|
|
5522
|
+
},
|
|
5523
|
+
apple: {
|
|
5524
|
+
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5525
|
+
altKey: !1,
|
|
5526
|
+
ctrlKey: !1,
|
|
5527
|
+
metaKey: !0,
|
|
5528
|
+
shiftKey: !1
|
|
5529
|
+
}),
|
|
5530
|
+
keys: ["\u2318", "Z"]
|
|
5531
|
+
}
|
|
5532
|
+
}),
|
|
5533
|
+
redo: createKeyboardShortcut({
|
|
5534
|
+
default: {
|
|
5535
|
+
guard: (event) => isKeyboardShortcut(event, "y", {
|
|
5536
|
+
ctrlKey: !0,
|
|
5537
|
+
metaKey: !1,
|
|
5538
|
+
shiftKey: !1,
|
|
5539
|
+
altKey: !1
|
|
5540
|
+
}) || isKeyboardShortcut(event, "z", {
|
|
5541
|
+
ctrlKey: !0,
|
|
5542
|
+
metaKey: !1,
|
|
5543
|
+
shiftKey: !0,
|
|
5544
|
+
altKey: !1
|
|
5545
|
+
}),
|
|
5546
|
+
keys: ["Ctrl", "Y"]
|
|
5547
|
+
},
|
|
5548
|
+
apple: {
|
|
5549
|
+
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5550
|
+
ctrlKey: !1,
|
|
5551
|
+
metaKey: !0,
|
|
5552
|
+
shiftKey: !0,
|
|
5553
|
+
altKey: !1
|
|
5554
|
+
}),
|
|
5555
|
+
keys: ["\u2318", "Shift", "Z"]
|
|
5556
|
+
}
|
|
5557
|
+
})
|
|
5558
|
+
},
|
|
5559
|
+
tab: createKeyboardShortcut({
|
|
5560
|
+
default: {
|
|
5561
|
+
guard: (event) => isKeyboardShortcut(event, "Tab", {
|
|
5562
|
+
ctrlKey: !1,
|
|
5563
|
+
metaKey: !1,
|
|
5564
|
+
shiftKey: !1,
|
|
5565
|
+
altKey: !1
|
|
5566
|
+
}),
|
|
5567
|
+
keys: ["Tab"]
|
|
5568
|
+
}
|
|
5569
|
+
}),
|
|
5570
|
+
shiftTab: createKeyboardShortcut({
|
|
5571
|
+
default: {
|
|
5572
|
+
guard: (event) => isKeyboardShortcut(event, "Tab", {
|
|
5573
|
+
ctrlKey: !1,
|
|
5574
|
+
metaKey: !1,
|
|
5575
|
+
shiftKey: !0,
|
|
5576
|
+
altKey: !1
|
|
5577
|
+
}),
|
|
5578
|
+
keys: ["Shift", "Tab"]
|
|
5579
|
+
}
|
|
5580
|
+
})
|
|
5581
|
+
}, arrowDownOnLonelyBlockObject = defineBehavior({
|
|
5496
5582
|
on: "keyboard.keydown",
|
|
5497
5583
|
guard: ({
|
|
5498
5584
|
snapshot,
|
|
5499
5585
|
event
|
|
5500
5586
|
}) => {
|
|
5501
|
-
if (!
|
|
5587
|
+
if (!defaultKeyboardShortcuts.arrowDown.guard(event.originEvent) || !isSelectionCollapsed$1(snapshot))
|
|
5502
5588
|
return !1;
|
|
5503
5589
|
const focusBlockObject = getFocusBlockObject(snapshot), nextBlock = getNextBlock(snapshot);
|
|
5504
5590
|
return focusBlockObject && !nextBlock;
|
|
@@ -5518,7 +5604,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
|
|
|
5518
5604
|
snapshot,
|
|
5519
5605
|
event
|
|
5520
5606
|
}) => {
|
|
5521
|
-
if (!
|
|
5607
|
+
if (!defaultKeyboardShortcuts.arrowUp.guard(event.originEvent) || !isSelectionCollapsed$1(snapshot))
|
|
5522
5608
|
return !1;
|
|
5523
5609
|
const focusBlockObject = getFocusBlockObject(snapshot), previousBlock = getPreviousBlock(snapshot);
|
|
5524
5610
|
return focusBlockObject && !previousBlock;
|
|
@@ -5697,7 +5783,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
|
|
|
5697
5783
|
guard: ({
|
|
5698
5784
|
snapshot,
|
|
5699
5785
|
event
|
|
5700
|
-
}) =>
|
|
5786
|
+
}) => defaultKeyboardShortcuts.decorators.strong.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "strong"),
|
|
5701
5787
|
actions: [() => [raise({
|
|
5702
5788
|
type: "decorator.toggle",
|
|
5703
5789
|
decorator: "strong"
|
|
@@ -5708,7 +5794,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
|
|
|
5708
5794
|
guard: ({
|
|
5709
5795
|
snapshot,
|
|
5710
5796
|
event
|
|
5711
|
-
}) =>
|
|
5797
|
+
}) => defaultKeyboardShortcuts.decorators.em.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "em"),
|
|
5712
5798
|
actions: [() => [raise({
|
|
5713
5799
|
type: "decorator.toggle",
|
|
5714
5800
|
decorator: "em"
|
|
@@ -5719,7 +5805,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
|
|
|
5719
5805
|
guard: ({
|
|
5720
5806
|
snapshot,
|
|
5721
5807
|
event
|
|
5722
|
-
}) =>
|
|
5808
|
+
}) => defaultKeyboardShortcuts.decorators.underline.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "underline"),
|
|
5723
5809
|
actions: [() => [raise({
|
|
5724
5810
|
type: "decorator.toggle",
|
|
5725
5811
|
decorator: "underline"
|
|
@@ -5730,7 +5816,7 @@ const arrowDownOnLonelyBlockObject = defineBehavior({
|
|
|
5730
5816
|
guard: ({
|
|
5731
5817
|
snapshot,
|
|
5732
5818
|
event
|
|
5733
|
-
}) =>
|
|
5819
|
+
}) => defaultKeyboardShortcuts.decorators.code.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "code"),
|
|
5734
5820
|
actions: [() => [raise({
|
|
5735
5821
|
type: "decorator.toggle",
|
|
5736
5822
|
decorator: "code"
|
|
@@ -6223,7 +6309,7 @@ const coreDndBehaviors = [
|
|
|
6223
6309
|
snapshot,
|
|
6224
6310
|
event
|
|
6225
6311
|
}) => {
|
|
6226
|
-
if (!
|
|
6312
|
+
if (!defaultKeyboardShortcuts.tab.guard(event.originEvent))
|
|
6227
6313
|
return !1;
|
|
6228
6314
|
const selectedBlocks = getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => isListBlock(snapshot.context, block.node) ? [{
|
|
6229
6315
|
node: block.node,
|
|
@@ -6248,7 +6334,7 @@ const coreDndBehaviors = [
|
|
|
6248
6334
|
snapshot,
|
|
6249
6335
|
event
|
|
6250
6336
|
}) => {
|
|
6251
|
-
if (!
|
|
6337
|
+
if (!defaultKeyboardShortcuts.shiftTab.guard(event.originEvent))
|
|
6252
6338
|
return !1;
|
|
6253
6339
|
const selectedBlocks = getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => isListBlock(snapshot.context, block.node) ? [{
|
|
6254
6340
|
node: block.node,
|
|
@@ -6621,16 +6707,17 @@ const coreDndBehaviors = [
|
|
|
6621
6707
|
text: `
|
|
6622
6708
|
`
|
|
6623
6709
|
})]]
|
|
6624
|
-
})],
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6710
|
+
})], abstractKeyboardBehaviors = [
|
|
6711
|
+
/**
|
|
6712
|
+
* Allow raising an `insert.break` event when pressing Enter on an inline
|
|
6713
|
+
* object.
|
|
6714
|
+
*/
|
|
6628
6715
|
defineBehavior({
|
|
6629
6716
|
on: "keyboard.keydown",
|
|
6630
6717
|
guard: ({
|
|
6631
6718
|
snapshot,
|
|
6632
6719
|
event
|
|
6633
|
-
}) =>
|
|
6720
|
+
}) => defaultKeyboardShortcuts.break.guard(event.originEvent) && isSelectionCollapsed$1(snapshot) && getFocusInlineObject(snapshot),
|
|
6634
6721
|
actions: [() => [raise({
|
|
6635
6722
|
type: "insert.break"
|
|
6636
6723
|
})]]
|
|
@@ -6644,10 +6731,34 @@ const coreDndBehaviors = [
|
|
|
6644
6731
|
on: "keyboard.keydown",
|
|
6645
6732
|
guard: ({
|
|
6646
6733
|
event
|
|
6647
|
-
}) =>
|
|
6734
|
+
}) => defaultKeyboardShortcuts.lineBreak.guard(event.originEvent),
|
|
6648
6735
|
actions: [() => [raise({
|
|
6649
6736
|
type: "insert.soft break"
|
|
6650
6737
|
})]]
|
|
6738
|
+
}),
|
|
6739
|
+
/**
|
|
6740
|
+
* Manual handling of undo shortcuts.
|
|
6741
|
+
*/
|
|
6742
|
+
defineBehavior({
|
|
6743
|
+
on: "keyboard.keydown",
|
|
6744
|
+
guard: ({
|
|
6745
|
+
event
|
|
6746
|
+
}) => defaultKeyboardShortcuts.history.undo.guard(event.originEvent),
|
|
6747
|
+
actions: [() => [raise({
|
|
6748
|
+
type: "history.undo"
|
|
6749
|
+
})]]
|
|
6750
|
+
}),
|
|
6751
|
+
/**
|
|
6752
|
+
* Manual handling of redo shortcuts.
|
|
6753
|
+
*/
|
|
6754
|
+
defineBehavior({
|
|
6755
|
+
on: "keyboard.keydown",
|
|
6756
|
+
guard: ({
|
|
6757
|
+
event
|
|
6758
|
+
}) => defaultKeyboardShortcuts.history.redo.guard(event.originEvent),
|
|
6759
|
+
actions: [() => [raise({
|
|
6760
|
+
type: "history.redo"
|
|
6761
|
+
})]]
|
|
6651
6762
|
})
|
|
6652
6763
|
], abstractListItemBehaviors = [defineBehavior({
|
|
6653
6764
|
on: "list item.add",
|
|
@@ -10576,6 +10687,118 @@ function RenderText(props) {
|
|
|
10576
10687
|
let t0;
|
|
10577
10688
|
return $[0] !== props.attributes || $[1] !== props.children || $[2] !== props.text._key || $[3] !== props.text._type ? (t0 = /* @__PURE__ */ jsx("span", { ...props.attributes, "data-child-key": props.text._key, "data-child-name": props.text._type, "data-child-type": "span", children: props.children }), $[0] = props.attributes, $[1] = props.children, $[2] = props.text._key, $[3] = props.text._type, $[4] = t0) : t0 = $[4], t0;
|
|
10578
10689
|
}
|
|
10690
|
+
const IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
|
|
10691
|
+
alt: "altKey",
|
|
10692
|
+
control: "ctrlKey",
|
|
10693
|
+
meta: "metaKey",
|
|
10694
|
+
shift: "shiftKey"
|
|
10695
|
+
}, aliases = {
|
|
10696
|
+
add: "+",
|
|
10697
|
+
break: "pause",
|
|
10698
|
+
cmd: "meta",
|
|
10699
|
+
command: "meta",
|
|
10700
|
+
ctl: "control",
|
|
10701
|
+
ctrl: "control",
|
|
10702
|
+
del: "delete",
|
|
10703
|
+
down: "arrowdown",
|
|
10704
|
+
esc: "escape",
|
|
10705
|
+
ins: "insert",
|
|
10706
|
+
left: "arrowleft",
|
|
10707
|
+
mod: IS_MAC ? "meta" : "control",
|
|
10708
|
+
opt: "alt",
|
|
10709
|
+
option: "alt",
|
|
10710
|
+
return: "enter",
|
|
10711
|
+
right: "arrowright",
|
|
10712
|
+
space: " ",
|
|
10713
|
+
spacebar: " ",
|
|
10714
|
+
up: "arrowup",
|
|
10715
|
+
win: "meta",
|
|
10716
|
+
windows: "meta"
|
|
10717
|
+
}, keyCodes = {
|
|
10718
|
+
backspace: 8,
|
|
10719
|
+
tab: 9,
|
|
10720
|
+
enter: 13,
|
|
10721
|
+
shift: 16,
|
|
10722
|
+
control: 17,
|
|
10723
|
+
alt: 18,
|
|
10724
|
+
pause: 19,
|
|
10725
|
+
capslock: 20,
|
|
10726
|
+
escape: 27,
|
|
10727
|
+
" ": 32,
|
|
10728
|
+
pageup: 33,
|
|
10729
|
+
pagedown: 34,
|
|
10730
|
+
end: 35,
|
|
10731
|
+
home: 36,
|
|
10732
|
+
arrowleft: 37,
|
|
10733
|
+
arrowup: 38,
|
|
10734
|
+
arrowright: 39,
|
|
10735
|
+
arrowdown: 40,
|
|
10736
|
+
insert: 45,
|
|
10737
|
+
delete: 46,
|
|
10738
|
+
meta: 91,
|
|
10739
|
+
numlock: 144,
|
|
10740
|
+
scrolllock: 145,
|
|
10741
|
+
";": 186,
|
|
10742
|
+
"=": 187,
|
|
10743
|
+
",": 188,
|
|
10744
|
+
"-": 189,
|
|
10745
|
+
".": 190,
|
|
10746
|
+
"/": 191,
|
|
10747
|
+
"`": 192,
|
|
10748
|
+
"[": 219,
|
|
10749
|
+
"\\": 220,
|
|
10750
|
+
"]": 221,
|
|
10751
|
+
"'": 222,
|
|
10752
|
+
f1: 112,
|
|
10753
|
+
f2: 113,
|
|
10754
|
+
f3: 114,
|
|
10755
|
+
f4: 115,
|
|
10756
|
+
f5: 116,
|
|
10757
|
+
f6: 117,
|
|
10758
|
+
f7: 118,
|
|
10759
|
+
f8: 119,
|
|
10760
|
+
f9: 120,
|
|
10761
|
+
f10: 121,
|
|
10762
|
+
f11: 122,
|
|
10763
|
+
f12: 123,
|
|
10764
|
+
f13: 124,
|
|
10765
|
+
f14: 125,
|
|
10766
|
+
f15: 126,
|
|
10767
|
+
f16: 127,
|
|
10768
|
+
f17: 128,
|
|
10769
|
+
f18: 129,
|
|
10770
|
+
f19: 130,
|
|
10771
|
+
f20: 131
|
|
10772
|
+
};
|
|
10773
|
+
function isHotkey(hotkey, event) {
|
|
10774
|
+
return compareHotkey(parseHotkey(hotkey), event);
|
|
10775
|
+
}
|
|
10776
|
+
function parseHotkey(hotkey) {
|
|
10777
|
+
const parsedHotkey = {
|
|
10778
|
+
altKey: !1,
|
|
10779
|
+
ctrlKey: !1,
|
|
10780
|
+
metaKey: !1,
|
|
10781
|
+
shiftKey: !1
|
|
10782
|
+
}, hotkeySegments = hotkey.replace("++", "+add").split("+");
|
|
10783
|
+
for (const rawHotkeySegment of hotkeySegments) {
|
|
10784
|
+
const optional = rawHotkeySegment.endsWith("?") && rawHotkeySegment.length > 1, hotkeySegment = optional ? rawHotkeySegment.slice(0, -1) : rawHotkeySegment, keyName = toKeyName(hotkeySegment), modifier = modifiers[keyName], alias = aliases[hotkeySegment], code = keyCodes[keyName];
|
|
10785
|
+
if (hotkeySegment.length > 1 && modifier === void 0 && alias === void 0 && code === void 0)
|
|
10786
|
+
throw new TypeError(`Unknown modifier: "${hotkeySegment}"`);
|
|
10787
|
+
(hotkeySegments.length === 1 || modifier === void 0) && (parsedHotkey.key = keyName, parsedHotkey.keyCode = toKeyCode(hotkeySegment)), modifier !== void 0 && (parsedHotkey[modifier] = optional ? null : !0);
|
|
10788
|
+
}
|
|
10789
|
+
return parsedHotkey;
|
|
10790
|
+
}
|
|
10791
|
+
function compareHotkey(parsedHotkey, event) {
|
|
10792
|
+
return (parsedHotkey.altKey == null || parsedHotkey.altKey === event.altKey) && (parsedHotkey.ctrlKey == null || parsedHotkey.ctrlKey === event.ctrlKey) && (parsedHotkey.metaKey == null || parsedHotkey.metaKey === event.metaKey) && (parsedHotkey.shiftKey == null || parsedHotkey.shiftKey === event.shiftKey) ? parsedHotkey.keyCode !== void 0 && event.keyCode !== void 0 ? parsedHotkey.keyCode === 91 && event.keyCode === 93 ? !0 : parsedHotkey.keyCode === event.keyCode : parsedHotkey.keyCode === event.keyCode || parsedHotkey.key === event.key.toLowerCase() : !1;
|
|
10793
|
+
}
|
|
10794
|
+
function toKeyCode(name) {
|
|
10795
|
+
const keyName = toKeyName(name);
|
|
10796
|
+
return keyCodes[keyName] ?? keyName.toUpperCase().charCodeAt(0);
|
|
10797
|
+
}
|
|
10798
|
+
function toKeyName(name) {
|
|
10799
|
+
const keyName = name.toLowerCase();
|
|
10800
|
+
return aliases[keyName] ?? keyName;
|
|
10801
|
+
}
|
|
10579
10802
|
const debug$1 = debugWithName("plugin:withHotKeys");
|
|
10580
10803
|
function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions) {
|
|
10581
10804
|
const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions ?? {};
|