@portabletext/editor 1.57.2 → 1.57.3
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 +50 -189
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +46 -184
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
- package/src/internal-utils/is-hotkey.ts +1 -1
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +63 -188
- package/src/keyboard-shortcuts/is-keyboard-shortcut.test.ts +0 -93
- package/src/keyboard-shortcuts/is-keyboard-shortcut.ts +0 -28
- package/src/keyboard-shortcuts/keyboard-shortcuts.ts +0 -120
package/lib/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$f = require("debug"), slateDom = require("slate-dom"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), selector_getFocusSpan = require("./_chunks-cjs/selector.get-focus-span.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), types = require("@sanity/types"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
|
|
3
|
+
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$f = require("debug"), slateDom = require("slate-dom"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), selector_getFocusSpan = require("./_chunks-cjs/selector.get-focus-span.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), keyboardShortcuts = require("@portabletext/keyboard-shortcuts"), types = require("@sanity/types"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -5347,203 +5347,64 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
|
|
|
5347
5347
|
})]]
|
|
5348
5348
|
}), coreAnnotationBehaviors = {
|
|
5349
5349
|
addAnnotationOnCollapsedSelection
|
|
5350
|
-
}
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
arrowDown: createKeyboardShortcut({
|
|
5360
|
-
default: {
|
|
5361
|
-
guard: (event) => isKeyboardShortcut(event, "ArrowDown", {
|
|
5362
|
-
ctrlKey: !1,
|
|
5363
|
-
metaKey: !1,
|
|
5364
|
-
shiftKey: !1,
|
|
5365
|
-
altKey: !1
|
|
5366
|
-
}),
|
|
5367
|
-
keys: ["ArrowDown"]
|
|
5368
|
-
}
|
|
5350
|
+
}, defaultKeyboardShortcuts = {
|
|
5351
|
+
arrowDown: keyboardShortcuts.createKeyboardShortcut({
|
|
5352
|
+
default: [{
|
|
5353
|
+
key: "ArrowDown",
|
|
5354
|
+
alt: !1,
|
|
5355
|
+
ctrl: !1,
|
|
5356
|
+
meta: !1,
|
|
5357
|
+
shift: !1
|
|
5358
|
+
}]
|
|
5369
5359
|
}),
|
|
5370
|
-
arrowUp: createKeyboardShortcut({
|
|
5371
|
-
default: {
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
keys: ["ArrowUp"]
|
|
5379
|
-
}
|
|
5360
|
+
arrowUp: keyboardShortcuts.createKeyboardShortcut({
|
|
5361
|
+
default: [{
|
|
5362
|
+
key: "ArrowUp",
|
|
5363
|
+
alt: !1,
|
|
5364
|
+
ctrl: !1,
|
|
5365
|
+
meta: !1,
|
|
5366
|
+
shift: !1
|
|
5367
|
+
}]
|
|
5380
5368
|
}),
|
|
5381
|
-
break: createKeyboardShortcut({
|
|
5382
|
-
default: {
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
keys: ["Enter"]
|
|
5387
|
-
}
|
|
5369
|
+
break: keyboardShortcuts.createKeyboardShortcut({
|
|
5370
|
+
default: [{
|
|
5371
|
+
key: "Enter",
|
|
5372
|
+
shift: !1
|
|
5373
|
+
}]
|
|
5388
5374
|
}),
|
|
5389
|
-
lineBreak: createKeyboardShortcut({
|
|
5390
|
-
default: {
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
keys: ["Shift", "Enter"]
|
|
5395
|
-
}
|
|
5375
|
+
lineBreak: keyboardShortcuts.createKeyboardShortcut({
|
|
5376
|
+
default: [{
|
|
5377
|
+
key: "Enter",
|
|
5378
|
+
shift: !0
|
|
5379
|
+
}]
|
|
5396
5380
|
}),
|
|
5397
5381
|
decorators: {
|
|
5398
|
-
strong:
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
ctrlKey: !0,
|
|
5403
|
-
metaKey: !1,
|
|
5404
|
-
shiftKey: !1
|
|
5405
|
-
}),
|
|
5406
|
-
keys: ["Ctrl", "B"]
|
|
5407
|
-
},
|
|
5408
|
-
apple: {
|
|
5409
|
-
guard: (event) => isKeyboardShortcut(event, "b", {
|
|
5410
|
-
altKey: !1,
|
|
5411
|
-
ctrlKey: !1,
|
|
5412
|
-
metaKey: !0,
|
|
5413
|
-
shiftKey: !1
|
|
5414
|
-
}),
|
|
5415
|
-
keys: ["\u2318", "B"]
|
|
5416
|
-
}
|
|
5417
|
-
}),
|
|
5418
|
-
em: createKeyboardShortcut({
|
|
5419
|
-
default: {
|
|
5420
|
-
guard: (event) => isKeyboardShortcut(event, "i", {
|
|
5421
|
-
altKey: !1,
|
|
5422
|
-
ctrlKey: !0,
|
|
5423
|
-
metaKey: !1,
|
|
5424
|
-
shiftKey: !1
|
|
5425
|
-
}),
|
|
5426
|
-
keys: ["Ctrl", "I"]
|
|
5427
|
-
},
|
|
5428
|
-
apple: {
|
|
5429
|
-
guard: (event) => isKeyboardShortcut(event, "i", {
|
|
5430
|
-
altKey: !1,
|
|
5431
|
-
ctrlKey: !1,
|
|
5432
|
-
metaKey: !0,
|
|
5433
|
-
shiftKey: !1
|
|
5434
|
-
}),
|
|
5435
|
-
keys: ["\u2318", "I"]
|
|
5436
|
-
}
|
|
5437
|
-
}),
|
|
5438
|
-
underline: createKeyboardShortcut({
|
|
5439
|
-
default: {
|
|
5440
|
-
guard: (event) => isKeyboardShortcut(event, "u", {
|
|
5441
|
-
altKey: !1,
|
|
5442
|
-
ctrlKey: !0,
|
|
5443
|
-
metaKey: !1,
|
|
5444
|
-
shiftKey: !1
|
|
5445
|
-
}),
|
|
5446
|
-
keys: ["Ctrl", "U"]
|
|
5447
|
-
},
|
|
5448
|
-
apple: {
|
|
5449
|
-
guard: (event) => isKeyboardShortcut(event, "u", {
|
|
5450
|
-
altKey: !1,
|
|
5451
|
-
ctrlKey: !1,
|
|
5452
|
-
metaKey: !0,
|
|
5453
|
-
shiftKey: !1
|
|
5454
|
-
}),
|
|
5455
|
-
keys: ["\u2318", "U"]
|
|
5456
|
-
}
|
|
5457
|
-
}),
|
|
5458
|
-
code: createKeyboardShortcut({
|
|
5459
|
-
default: {
|
|
5460
|
-
guard: (event) => isKeyboardShortcut(event, "'", {
|
|
5461
|
-
altKey: !1,
|
|
5462
|
-
ctrlKey: !0,
|
|
5463
|
-
metaKey: !1,
|
|
5464
|
-
shiftKey: !1
|
|
5465
|
-
}),
|
|
5466
|
-
keys: ["Ctrl", "'"]
|
|
5467
|
-
},
|
|
5468
|
-
apple: {
|
|
5469
|
-
guard: (event) => isKeyboardShortcut(event, "'", {
|
|
5470
|
-
altKey: !1,
|
|
5471
|
-
ctrlKey: !1,
|
|
5472
|
-
metaKey: !0,
|
|
5473
|
-
shiftKey: !1
|
|
5474
|
-
}),
|
|
5475
|
-
keys: ["\u2318", "'"]
|
|
5476
|
-
}
|
|
5477
|
-
})
|
|
5382
|
+
strong: keyboardShortcuts.bold,
|
|
5383
|
+
em: keyboardShortcuts.italic,
|
|
5384
|
+
underline: keyboardShortcuts.underline,
|
|
5385
|
+
code: keyboardShortcuts.code
|
|
5478
5386
|
},
|
|
5479
5387
|
history: {
|
|
5480
|
-
undo:
|
|
5481
|
-
|
|
5482
|
-
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5483
|
-
altKey: !1,
|
|
5484
|
-
ctrlKey: !0,
|
|
5485
|
-
metaKey: !1,
|
|
5486
|
-
shiftKey: !1
|
|
5487
|
-
}),
|
|
5488
|
-
keys: ["Ctrl", "Z"]
|
|
5489
|
-
},
|
|
5490
|
-
apple: {
|
|
5491
|
-
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5492
|
-
altKey: !1,
|
|
5493
|
-
ctrlKey: !1,
|
|
5494
|
-
metaKey: !0,
|
|
5495
|
-
shiftKey: !1
|
|
5496
|
-
}),
|
|
5497
|
-
keys: ["\u2318", "Z"]
|
|
5498
|
-
}
|
|
5499
|
-
}),
|
|
5500
|
-
redo: createKeyboardShortcut({
|
|
5501
|
-
default: {
|
|
5502
|
-
guard: (event) => isKeyboardShortcut(event, "y", {
|
|
5503
|
-
ctrlKey: !0,
|
|
5504
|
-
metaKey: !1,
|
|
5505
|
-
shiftKey: !1,
|
|
5506
|
-
altKey: !1
|
|
5507
|
-
}) || isKeyboardShortcut(event, "z", {
|
|
5508
|
-
ctrlKey: !0,
|
|
5509
|
-
metaKey: !1,
|
|
5510
|
-
shiftKey: !0,
|
|
5511
|
-
altKey: !1
|
|
5512
|
-
}),
|
|
5513
|
-
keys: ["Ctrl", "Y"]
|
|
5514
|
-
},
|
|
5515
|
-
apple: {
|
|
5516
|
-
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5517
|
-
ctrlKey: !1,
|
|
5518
|
-
metaKey: !0,
|
|
5519
|
-
shiftKey: !0,
|
|
5520
|
-
altKey: !1
|
|
5521
|
-
}),
|
|
5522
|
-
keys: ["\u2318", "Shift", "Z"]
|
|
5523
|
-
}
|
|
5524
|
-
})
|
|
5388
|
+
undo: keyboardShortcuts.undo,
|
|
5389
|
+
redo: keyboardShortcuts.redo
|
|
5525
5390
|
},
|
|
5526
|
-
tab: createKeyboardShortcut({
|
|
5527
|
-
default: {
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
keys: ["Tab"]
|
|
5535
|
-
}
|
|
5391
|
+
tab: keyboardShortcuts.createKeyboardShortcut({
|
|
5392
|
+
default: [{
|
|
5393
|
+
key: "Tab",
|
|
5394
|
+
alt: !1,
|
|
5395
|
+
ctrl: !1,
|
|
5396
|
+
meta: !1,
|
|
5397
|
+
shift: !1
|
|
5398
|
+
}]
|
|
5536
5399
|
}),
|
|
5537
|
-
shiftTab: createKeyboardShortcut({
|
|
5538
|
-
default: {
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
keys: ["Shift", "Tab"]
|
|
5546
|
-
}
|
|
5400
|
+
shiftTab: keyboardShortcuts.createKeyboardShortcut({
|
|
5401
|
+
default: [{
|
|
5402
|
+
key: "Tab",
|
|
5403
|
+
alt: !1,
|
|
5404
|
+
ctrl: !1,
|
|
5405
|
+
meta: !1,
|
|
5406
|
+
shift: !0
|
|
5407
|
+
}]
|
|
5547
5408
|
})
|
|
5548
5409
|
}, arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
5549
5410
|
on: "keyboard.keydown",
|