@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.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"),
|
|
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_isEqualSelectionPoints = require("./_chunks-cjs/util.is-equal-selection-points.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), isEqual = require("lodash/isEqual.js"), selector_isSelectionExpanded = require("./_chunks-cjs/selector.is-selection-expanded.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.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"), 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");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -393,7 +393,7 @@ function getEventPosition({
|
|
|
393
393
|
block: eventPositionBlock,
|
|
394
394
|
isEditor: !1,
|
|
395
395
|
selection: {
|
|
396
|
-
anchor:
|
|
396
|
+
anchor: util_sliceBlocks.getBlockStartPoint({
|
|
397
397
|
context: editorActor.getSnapshot().context,
|
|
398
398
|
block: {
|
|
399
399
|
node: eventBlock,
|
|
@@ -415,13 +415,13 @@ function getEventPosition({
|
|
|
415
415
|
};
|
|
416
416
|
if (!eventPositionBlock || !eventSelection)
|
|
417
417
|
return;
|
|
418
|
-
const eventSelectionFocusBlockKey =
|
|
418
|
+
const eventSelectionFocusBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(eventSelection.focus);
|
|
419
419
|
if (eventSelectionFocusBlockKey !== void 0)
|
|
420
420
|
return util_sliceTextBlock.isSelectionCollapsed(eventSelection) && eventBlock && eventSelectionFocusBlockKey !== eventBlock._key ? {
|
|
421
421
|
block: eventPositionBlock,
|
|
422
422
|
isEditor: !1,
|
|
423
423
|
selection: {
|
|
424
|
-
anchor:
|
|
424
|
+
anchor: util_sliceBlocks.getBlockStartPoint({
|
|
425
425
|
context: editorActor.getSnapshot().context,
|
|
426
426
|
block: {
|
|
427
427
|
node: eventBlock,
|
|
@@ -520,7 +520,7 @@ function getSlateRangeFromEvent(editor, event) {
|
|
|
520
520
|
return range;
|
|
521
521
|
}
|
|
522
522
|
function toSlatePath(path, editor) {
|
|
523
|
-
const blockKey =
|
|
523
|
+
const blockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint({
|
|
524
524
|
path
|
|
525
525
|
});
|
|
526
526
|
if (!blockKey)
|
|
@@ -533,7 +533,7 @@ function toSlatePath(path, editor) {
|
|
|
533
533
|
return [];
|
|
534
534
|
if (editor.isVoid(block))
|
|
535
535
|
return [blockIndex, 0];
|
|
536
|
-
const childKey =
|
|
536
|
+
const childKey = util_sliceBlocks.getChildKeyFromSelectionPoint({
|
|
537
537
|
path
|
|
538
538
|
});
|
|
539
539
|
if (!childKey)
|
|
@@ -688,7 +688,7 @@ function getDragSelection({
|
|
|
688
688
|
}
|
|
689
689
|
});
|
|
690
690
|
draggingCollapsedSelection && draggedTextBlock && draggedSpan && (dragSelection = {
|
|
691
|
-
anchor:
|
|
691
|
+
anchor: util_sliceBlocks.getBlockStartPoint({
|
|
692
692
|
context: snapshot.context,
|
|
693
693
|
block: draggedTextBlock
|
|
694
694
|
}),
|
|
@@ -702,7 +702,7 @@ function getDragSelection({
|
|
|
702
702
|
const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
703
703
|
if (!selectionStartBlock || !selectionEndBlock)
|
|
704
704
|
return dragSelection;
|
|
705
|
-
const selectionStartPoint =
|
|
705
|
+
const selectionStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
706
706
|
context: snapshot.context,
|
|
707
707
|
block: selectionStartBlock
|
|
708
708
|
}), selectionEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
@@ -1003,7 +1003,7 @@ function RenderElement(props) {
|
|
|
1003
1003
|
let t32;
|
|
1004
1004
|
return $[10] !== props.attributes || $[11] !== props.children || $[12] !== props.element || $[13] !== props.readOnly || $[14] !== props.renderChild || $[15] !== t22 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(RenderInlineObject, { attributes: props.attributes, element: props.element, inlineObject: t22, readOnly: props.readOnly, renderChild: props.renderChild, children: props.children }), $[10] = props.attributes, $[11] = props.children, $[12] = props.element, $[13] = props.readOnly, $[14] = props.renderChild, $[15] = t22, $[16] = t32) : t32 = $[16], t32;
|
|
1005
1005
|
}
|
|
1006
|
-
if (
|
|
1006
|
+
if (util_sliceBlocks.isTextBlock({
|
|
1007
1007
|
schema: schema2
|
|
1008
1008
|
}, props.element)) {
|
|
1009
1009
|
let t02;
|
|
@@ -1128,7 +1128,7 @@ const converterJson = {
|
|
|
1128
1128
|
reason: "Data is not an array"
|
|
1129
1129
|
};
|
|
1130
1130
|
const parsedBlocks = blocks.flatMap((block) => {
|
|
1131
|
-
const parsedBlock =
|
|
1131
|
+
const parsedBlock = util_sliceBlocks.parseBlock({
|
|
1132
1132
|
context: snapshot.context,
|
|
1133
1133
|
block,
|
|
1134
1134
|
options: {
|
|
@@ -1191,7 +1191,7 @@ function createConverterTextHtml(legacySchema) {
|
|
|
1191
1191
|
keyGenerator: snapshot.context.keyGenerator,
|
|
1192
1192
|
unstable_whitespaceOnPasteMode: legacySchema.block.options.unstable_whitespaceOnPasteMode
|
|
1193
1193
|
}).flatMap((block) => {
|
|
1194
|
-
const parsedBlock =
|
|
1194
|
+
const parsedBlock = util_sliceBlocks.parseBlock({
|
|
1195
1195
|
context: snapshot.context,
|
|
1196
1196
|
block,
|
|
1197
1197
|
options: {
|
|
@@ -1221,7 +1221,7 @@ function createConverterTextPlain(legacySchema) {
|
|
|
1221
1221
|
event
|
|
1222
1222
|
}) => snapshot.context.selection ? {
|
|
1223
1223
|
type: "serialization.success",
|
|
1224
|
-
data: selector_isSelectionExpanded.getSelectedValue(snapshot).map((block) =>
|
|
1224
|
+
data: selector_isSelectionExpanded.getSelectedValue(snapshot).map((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
|
|
1225
1225
|
|
|
1226
1226
|
`),
|
|
1227
1227
|
mimeType: "text/plain",
|
|
@@ -1239,7 +1239,7 @@ function createConverterTextPlain(legacySchema) {
|
|
|
1239
1239
|
const textToHtml = `<html><body>${escapeHtml(event.data).split(/\n{2,}/).map((line) => line ? `<p>${line.replace(/(?:\r\n|\r|\n)/g, "<br/>")}</p>` : "<p></p>").join("")}</body></html>`, parsedBlocks = blockTools.htmlToBlocks(textToHtml, legacySchema.portableText, {
|
|
1240
1240
|
keyGenerator: snapshot.context.keyGenerator
|
|
1241
1241
|
}).flatMap((block) => {
|
|
1242
|
-
const parsedBlock =
|
|
1242
|
+
const parsedBlock = util_sliceBlocks.parseBlock({
|
|
1243
1243
|
context: snapshot.context,
|
|
1244
1244
|
block,
|
|
1245
1245
|
options: {
|
|
@@ -1293,7 +1293,7 @@ function buildIndexMaps(context, {
|
|
|
1293
1293
|
for (let blockIndex = 0; blockIndex < context.value.length; blockIndex++) {
|
|
1294
1294
|
const block = context.value.at(blockIndex);
|
|
1295
1295
|
if (block !== void 0) {
|
|
1296
|
-
if (blockIndexMap.set(block._key, blockIndex), !
|
|
1296
|
+
if (blockIndexMap.set(block._key, blockIndex), !util_sliceBlocks.isTextBlock(context, block)) {
|
|
1297
1297
|
levelIndexMap.clear(), previousListItem = void 0;
|
|
1298
1298
|
continue;
|
|
1299
1299
|
}
|
|
@@ -2767,7 +2767,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
2767
2767
|
context,
|
|
2768
2768
|
operation
|
|
2769
2769
|
}) => {
|
|
2770
|
-
const parsedAnnotation =
|
|
2770
|
+
const parsedAnnotation = util_sliceBlocks.parseAnnotation({
|
|
2771
2771
|
annotation: {
|
|
2772
2772
|
_type: operation.annotation.name,
|
|
2773
2773
|
...operation.annotation.value
|
|
@@ -2923,7 +2923,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
2923
2923
|
const {
|
|
2924
2924
|
_type,
|
|
2925
2925
|
...filteredProps
|
|
2926
|
-
} = operation.props, updatedBlock =
|
|
2926
|
+
} = operation.props, updatedBlock = util_sliceBlocks.parseBlock({
|
|
2927
2927
|
context,
|
|
2928
2928
|
block: {
|
|
2929
2929
|
...parsedBlock,
|
|
@@ -2968,8 +2968,8 @@ const addAnnotationOperationImplementation = ({
|
|
|
2968
2968
|
const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(operation.editor)).at(0);
|
|
2969
2969
|
if (!parsedBlock)
|
|
2970
2970
|
throw new Error(`Unable to parse block at ${JSON.stringify(operation.at)}`);
|
|
2971
|
-
if (
|
|
2972
|
-
const propsToRemove = operation.props.filter((prop) => prop !== "_type"), updatedTextBlock =
|
|
2971
|
+
if (util_sliceBlocks.isTextBlock(context, parsedBlock)) {
|
|
2972
|
+
const propsToRemove = operation.props.filter((prop) => prop !== "_type"), updatedTextBlock = util_sliceBlocks.parseBlock({
|
|
2973
2973
|
context,
|
|
2974
2974
|
block: omit__default.default(parsedBlock, propsToRemove),
|
|
2975
2975
|
options: {
|
|
@@ -2987,7 +2987,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
2987
2987
|
});
|
|
2988
2988
|
return;
|
|
2989
2989
|
}
|
|
2990
|
-
const updatedBlockObject =
|
|
2990
|
+
const updatedBlockObject = util_sliceBlocks.parseBlock({
|
|
2991
2991
|
context,
|
|
2992
2992
|
block: omit__default.default(parsedBlock, operation.props.filter((prop) => prop !== "_type")),
|
|
2993
2993
|
options: {
|
|
@@ -3139,14 +3139,14 @@ const addAnnotationOperationImplementation = ({
|
|
|
3139
3139
|
context,
|
|
3140
3140
|
operation
|
|
3141
3141
|
}) => {
|
|
3142
|
-
const editor = operation.editor, mark = operation.decorator, value = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), manualAnchor = operation.at?.anchor ?
|
|
3142
|
+
const editor = operation.editor, mark = operation.decorator, value = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), manualAnchor = operation.at?.anchor ? util_sliceBlocks.blockOffsetToSpanSelectionPoint({
|
|
3143
3143
|
context: {
|
|
3144
3144
|
...context,
|
|
3145
3145
|
value
|
|
3146
3146
|
},
|
|
3147
3147
|
blockOffset: operation.at.anchor,
|
|
3148
3148
|
direction: "backward"
|
|
3149
|
-
}) : void 0, manualFocus = operation.at?.focus ?
|
|
3149
|
+
}) : void 0, manualFocus = operation.at?.focus ? util_sliceBlocks.blockOffsetToSpanSelectionPoint({
|
|
3150
3150
|
context: {
|
|
3151
3151
|
...context,
|
|
3152
3152
|
value
|
|
@@ -3260,7 +3260,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
3260
3260
|
context,
|
|
3261
3261
|
operation
|
|
3262
3262
|
}) => {
|
|
3263
|
-
const anchorBlockKey =
|
|
3263
|
+
const anchorBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(operation.at.anchor), focusBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(operation.at.focus), anchorBlockPath = anchorBlockKey !== void 0 ? getBlockPath({
|
|
3264
3264
|
editor: operation.editor,
|
|
3265
3265
|
_key: anchorBlockKey
|
|
3266
3266
|
}) : void 0, focusBlockPath = focusBlockKey !== void 0 ? getBlockPath({
|
|
@@ -3285,7 +3285,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
3285
3285
|
context,
|
|
3286
3286
|
operation
|
|
3287
3287
|
}) => {
|
|
3288
|
-
const parsedInlineObject =
|
|
3288
|
+
const parsedInlineObject = util_sliceBlocks.parseInlineObject({
|
|
3289
3289
|
context,
|
|
3290
3290
|
inlineObject: {
|
|
3291
3291
|
_type: operation.inlineObject.name,
|
|
@@ -3355,7 +3355,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
3355
3355
|
context,
|
|
3356
3356
|
operation
|
|
3357
3357
|
}) => {
|
|
3358
|
-
const parsedBlock =
|
|
3358
|
+
const parsedBlock = util_sliceBlocks.parseBlock({
|
|
3359
3359
|
block: operation.block,
|
|
3360
3360
|
context,
|
|
3361
3361
|
options: {
|
|
@@ -4309,7 +4309,7 @@ function unsetPatch(editor, patch) {
|
|
|
4309
4309
|
function findBlock(children, path) {
|
|
4310
4310
|
let blockIndex = -1;
|
|
4311
4311
|
const block = children.find((node, index) => {
|
|
4312
|
-
const isMatch =
|
|
4312
|
+
const isMatch = util_sliceBlocks.isKeyedSegment(path[0]) ? node._key === path[0]._key : index === path[0];
|
|
4313
4313
|
return isMatch && (blockIndex = index), isMatch;
|
|
4314
4314
|
});
|
|
4315
4315
|
if (block)
|
|
@@ -4324,7 +4324,7 @@ function findBlockChild(block, path) {
|
|
|
4324
4324
|
return;
|
|
4325
4325
|
let childIndex = -1;
|
|
4326
4326
|
const child = blockNode.children.find((node, index) => {
|
|
4327
|
-
const isMatch =
|
|
4327
|
+
const isMatch = util_sliceBlocks.isKeyedSegment(path[2]) ? node._key === path[2]._key : index === path[2];
|
|
4328
4328
|
return isMatch && (childIndex = index), isMatch;
|
|
4329
4329
|
});
|
|
4330
4330
|
if (child)
|
|
@@ -4334,14 +4334,14 @@ function findBlockChild(block, path) {
|
|
|
4334
4334
|
};
|
|
4335
4335
|
}
|
|
4336
4336
|
function insertTextPatch(schema2, children, operation, beforeValue) {
|
|
4337
|
-
const block =
|
|
4337
|
+
const block = util_sliceBlocks.isTextBlock({
|
|
4338
4338
|
schema: schema2
|
|
4339
4339
|
}, children[operation.path[0]]) && children[operation.path[0]];
|
|
4340
4340
|
if (!block)
|
|
4341
4341
|
throw new Error("Could not find block");
|
|
4342
|
-
const textChild =
|
|
4342
|
+
const textChild = util_sliceBlocks.isTextBlock({
|
|
4343
4343
|
schema: schema2
|
|
4344
|
-
}, block) &&
|
|
4344
|
+
}, block) && util_sliceBlocks.isSpan$1({
|
|
4345
4345
|
schema: schema2
|
|
4346
4346
|
}, block.children[operation.path[1]]) && block.children[operation.path[1]];
|
|
4347
4347
|
if (!textChild)
|
|
@@ -4350,9 +4350,9 @@ function insertTextPatch(schema2, children, operation, beforeValue) {
|
|
|
4350
4350
|
_key: block._key
|
|
4351
4351
|
}, "children", {
|
|
4352
4352
|
_key: textChild._key
|
|
4353
|
-
}, "text"], prevBlock = beforeValue[operation.path[0]], prevChild =
|
|
4353
|
+
}, "text"], prevBlock = beforeValue[operation.path[0]], prevChild = util_sliceBlocks.isTextBlock({
|
|
4354
4354
|
schema: schema2
|
|
4355
|
-
}, prevBlock) && prevBlock.children[operation.path[1]], prevText =
|
|
4355
|
+
}, prevBlock) && prevBlock.children[operation.path[1]], prevText = util_sliceBlocks.isSpan$1({
|
|
4356
4356
|
schema: schema2
|
|
4357
4357
|
}, prevChild) ? prevChild.text : "", patch = patches.diffMatchPatch(prevText, textChild.text, path);
|
|
4358
4358
|
return patch.value.length ? [patch] : [];
|
|
@@ -4361,9 +4361,9 @@ function removeTextPatch(schema2, children, operation, beforeValue) {
|
|
|
4361
4361
|
const block = children[operation.path[0]];
|
|
4362
4362
|
if (!block)
|
|
4363
4363
|
throw new Error("Could not find block");
|
|
4364
|
-
const child =
|
|
4364
|
+
const child = util_sliceBlocks.isTextBlock({
|
|
4365
4365
|
schema: schema2
|
|
4366
|
-
}, block) && block.children[operation.path[1]] || void 0, textChild =
|
|
4366
|
+
}, block) && block.children[operation.path[1]] || void 0, textChild = util_sliceBlocks.isSpan$1({
|
|
4367
4367
|
schema: schema2
|
|
4368
4368
|
}, child) ? child : void 0;
|
|
4369
4369
|
if (child && !textChild)
|
|
@@ -4374,9 +4374,9 @@ function removeTextPatch(schema2, children, operation, beforeValue) {
|
|
|
4374
4374
|
_key: block._key
|
|
4375
4375
|
}, "children", {
|
|
4376
4376
|
_key: textChild._key
|
|
4377
|
-
}, "text"], beforeBlock = beforeValue[operation.path[0]], prevTextChild =
|
|
4377
|
+
}, "text"], beforeBlock = beforeValue[operation.path[0]], prevTextChild = util_sliceBlocks.isTextBlock({
|
|
4378
4378
|
schema: schema2
|
|
4379
|
-
}, beforeBlock) && beforeBlock.children[operation.path[1]], prevText =
|
|
4379
|
+
}, beforeBlock) && beforeBlock.children[operation.path[1]], prevText = util_sliceBlocks.isSpan$1({
|
|
4380
4380
|
schema: schema2
|
|
4381
4381
|
}, prevTextChild) && prevTextChild.text, patch = patches.diffMatchPatch(prevText || "", textChild.text, path);
|
|
4382
4382
|
return patch.value ? [patch] : [];
|
|
@@ -4395,7 +4395,7 @@ function setNodePatch(schema2, children, operation) {
|
|
|
4395
4395
|
}])];
|
|
4396
4396
|
} else if (operation.path.length === 2) {
|
|
4397
4397
|
const block = children[operation.path[0]];
|
|
4398
|
-
if (
|
|
4398
|
+
if (util_sliceBlocks.isTextBlock({
|
|
4399
4399
|
schema: schema2
|
|
4400
4400
|
}, block)) {
|
|
4401
4401
|
const child = block.children[operation.path[1]];
|
|
@@ -4430,7 +4430,7 @@ function insertNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4430
4430
|
return targetKey ? [patches.insert([fromSlateValue([operation.node], schema2.block.name)[0]], position, [{
|
|
4431
4431
|
_key: targetKey
|
|
4432
4432
|
}])] : [patches.setIfMissing(beforeValue, []), patches.insert([fromSlateValue([operation.node], schema2.block.name)[0]], "before", [operation.path[0]])];
|
|
4433
|
-
} else if (
|
|
4433
|
+
} else if (util_sliceBlocks.isTextBlock({
|
|
4434
4434
|
schema: schema2
|
|
4435
4435
|
}, block) && operation.path.length === 2 && children[operation.path[0]]) {
|
|
4436
4436
|
const position = block.children.length === 0 || !block.children[operation.path[1] - 1] ? "before" : "after", node = {
|
|
@@ -4452,13 +4452,13 @@ function insertNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4452
4452
|
}
|
|
4453
4453
|
function splitNodePatch(schema2, children, operation, beforeValue) {
|
|
4454
4454
|
const patches$1 = [], splitBlock = children[operation.path[0]];
|
|
4455
|
-
if (!
|
|
4455
|
+
if (!util_sliceBlocks.isTextBlock({
|
|
4456
4456
|
schema: schema2
|
|
4457
4457
|
}, splitBlock))
|
|
4458
4458
|
throw new Error(`Block with path ${JSON.stringify(operation.path[0])} is not a text block and can't be split`);
|
|
4459
4459
|
if (operation.path.length === 1) {
|
|
4460
4460
|
const oldBlock = beforeValue[operation.path[0]];
|
|
4461
|
-
if (
|
|
4461
|
+
if (util_sliceBlocks.isTextBlock({
|
|
4462
4462
|
schema: schema2
|
|
4463
4463
|
}, oldBlock)) {
|
|
4464
4464
|
const targetValue = fromSlateValue([children[operation.path[0] + 1]], schema2.block.name)[0];
|
|
@@ -4477,7 +4477,7 @@ function splitNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4477
4477
|
}
|
|
4478
4478
|
if (operation.path.length === 2) {
|
|
4479
4479
|
const splitSpan = splitBlock.children[operation.path[1]];
|
|
4480
|
-
if (
|
|
4480
|
+
if (util_sliceBlocks.isSpan$1({
|
|
4481
4481
|
schema: schema2
|
|
4482
4482
|
}, splitSpan)) {
|
|
4483
4483
|
const targetSpans = fromSlateValue([{
|
|
@@ -4506,7 +4506,7 @@ function removeNodePatch(schema2, beforeValue, operation) {
|
|
|
4506
4506
|
_key: block._key
|
|
4507
4507
|
}])];
|
|
4508
4508
|
throw new Error("Block not found");
|
|
4509
|
-
} else if (
|
|
4509
|
+
} else if (util_sliceBlocks.isTextBlock({
|
|
4510
4510
|
schema: schema2
|
|
4511
4511
|
}, block) && operation.path.length === 2) {
|
|
4512
4512
|
const spanToRemove = block.children[operation.path[1]];
|
|
@@ -4530,14 +4530,14 @@ function mergeNodePatch(schema2, children, operation, beforeValue) {
|
|
|
4530
4530
|
}]));
|
|
4531
4531
|
} else
|
|
4532
4532
|
throw new Error("Target key not found!");
|
|
4533
|
-
else if (
|
|
4533
|
+
else if (util_sliceBlocks.isTextBlock({
|
|
4534
4534
|
schema: schema2
|
|
4535
|
-
}, block) &&
|
|
4535
|
+
}, block) && util_sliceBlocks.isTextBlock({
|
|
4536
4536
|
schema: schema2
|
|
4537
4537
|
}, updatedBlock) && operation.path.length === 2) {
|
|
4538
|
-
const updatedSpan = updatedBlock.children[operation.path[1] - 1] &&
|
|
4538
|
+
const updatedSpan = updatedBlock.children[operation.path[1] - 1] && util_sliceBlocks.isSpan$1({
|
|
4539
4539
|
schema: schema2
|
|
4540
|
-
}, updatedBlock.children[operation.path[1] - 1]) ? updatedBlock.children[operation.path[1] - 1] : void 0, removedSpan = block.children[operation.path[1]] &&
|
|
4540
|
+
}, updatedBlock.children[operation.path[1] - 1]) ? updatedBlock.children[operation.path[1] - 1] : void 0, removedSpan = block.children[operation.path[1]] && util_sliceBlocks.isSpan$1({
|
|
4541
4541
|
schema: schema2
|
|
4542
4542
|
}, block.children[operation.path[1]]) ? block.children[operation.path[1]] : void 0;
|
|
4543
4543
|
updatedSpan && (block.children.filter((span) => span._key === updatedSpan._key).length === 1 ? patches$1.push(patches.set(updatedSpan.text, [{
|
|
@@ -4563,9 +4563,9 @@ function moveNodePatch(schema2, beforeValue, operation) {
|
|
|
4563
4563
|
}])), patches$1.push(patches.insert([fromSlateValue([block], schema2.block.name)[0]], position, [{
|
|
4564
4564
|
_key: targetBlock._key
|
|
4565
4565
|
}]));
|
|
4566
|
-
} else if (operation.path.length === 2 &&
|
|
4566
|
+
} else if (operation.path.length === 2 && util_sliceBlocks.isTextBlock({
|
|
4567
4567
|
schema: schema2
|
|
4568
|
-
}, block) &&
|
|
4568
|
+
}, block) && util_sliceBlocks.isTextBlock({
|
|
4569
4569
|
schema: schema2
|
|
4570
4570
|
}, targetBlock)) {
|
|
4571
4571
|
const child = block.children[operation.path[1]], targetChild = targetBlock.children[operation.newPath[1]], position = operation.newPath[1] === targetBlock.children.length ? "after" : "before", childToInsert = fromSlateValue([block], schema2.block.name)[0].children[operation.path[1]];
|
|
@@ -4725,7 +4725,7 @@ function createWithSchemaTypes({
|
|
|
4725
4725
|
editorActor
|
|
4726
4726
|
}) {
|
|
4727
4727
|
return function(editor) {
|
|
4728
|
-
editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 :
|
|
4728
|
+
editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isSpan$1(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => slate.Editor.isEditor(value) ? !1 : util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4729
4729
|
const {
|
|
4730
4730
|
normalizeNode
|
|
4731
4731
|
} = editor;
|
|
@@ -4938,7 +4938,7 @@ function isEditorNode(node) {
|
|
|
4938
4938
|
return typeof node == "object" && node !== null ? !("_type" in node) && "children" in node && Array.isArray(node.children) : !1;
|
|
4939
4939
|
}
|
|
4940
4940
|
function isTextBlockNode(context, node) {
|
|
4941
|
-
return
|
|
4941
|
+
return util_sliceBlocks.isTypedObject(node) && node._type === context.schema.block.name;
|
|
4942
4942
|
}
|
|
4943
4943
|
function isSpanNode(context, node) {
|
|
4944
4944
|
return typeof node != "object" || node === null || "children" in node ? !1 : "_type" in node ? node._type === context.schema.span.name : "text" in node;
|
|
@@ -5351,125 +5351,211 @@ const addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
|
|
|
5351
5351
|
})]]
|
|
5352
5352
|
}), coreAnnotationBehaviors = {
|
|
5353
5353
|
addAnnotationOnCollapsedSelection
|
|
5354
|
-
}, IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
|
|
5355
|
-
alt: "altKey",
|
|
5356
|
-
control: "ctrlKey",
|
|
5357
|
-
meta: "metaKey",
|
|
5358
|
-
shift: "shiftKey"
|
|
5359
|
-
}, aliases = {
|
|
5360
|
-
add: "+",
|
|
5361
|
-
break: "pause",
|
|
5362
|
-
cmd: "meta",
|
|
5363
|
-
command: "meta",
|
|
5364
|
-
ctl: "control",
|
|
5365
|
-
ctrl: "control",
|
|
5366
|
-
del: "delete",
|
|
5367
|
-
down: "arrowdown",
|
|
5368
|
-
esc: "escape",
|
|
5369
|
-
ins: "insert",
|
|
5370
|
-
left: "arrowleft",
|
|
5371
|
-
mod: IS_MAC ? "meta" : "control",
|
|
5372
|
-
opt: "alt",
|
|
5373
|
-
option: "alt",
|
|
5374
|
-
return: "enter",
|
|
5375
|
-
right: "arrowright",
|
|
5376
|
-
space: " ",
|
|
5377
|
-
spacebar: " ",
|
|
5378
|
-
up: "arrowup",
|
|
5379
|
-
win: "meta",
|
|
5380
|
-
windows: "meta"
|
|
5381
|
-
}, keyCodes = {
|
|
5382
|
-
backspace: 8,
|
|
5383
|
-
tab: 9,
|
|
5384
|
-
enter: 13,
|
|
5385
|
-
shift: 16,
|
|
5386
|
-
control: 17,
|
|
5387
|
-
alt: 18,
|
|
5388
|
-
pause: 19,
|
|
5389
|
-
capslock: 20,
|
|
5390
|
-
escape: 27,
|
|
5391
|
-
" ": 32,
|
|
5392
|
-
pageup: 33,
|
|
5393
|
-
pagedown: 34,
|
|
5394
|
-
end: 35,
|
|
5395
|
-
home: 36,
|
|
5396
|
-
arrowleft: 37,
|
|
5397
|
-
arrowup: 38,
|
|
5398
|
-
arrowright: 39,
|
|
5399
|
-
arrowdown: 40,
|
|
5400
|
-
insert: 45,
|
|
5401
|
-
delete: 46,
|
|
5402
|
-
meta: 91,
|
|
5403
|
-
numlock: 144,
|
|
5404
|
-
scrolllock: 145,
|
|
5405
|
-
";": 186,
|
|
5406
|
-
"=": 187,
|
|
5407
|
-
",": 188,
|
|
5408
|
-
"-": 189,
|
|
5409
|
-
".": 190,
|
|
5410
|
-
"/": 191,
|
|
5411
|
-
"`": 192,
|
|
5412
|
-
"[": 219,
|
|
5413
|
-
"\\": 220,
|
|
5414
|
-
"]": 221,
|
|
5415
|
-
"'": 222,
|
|
5416
|
-
f1: 112,
|
|
5417
|
-
f2: 113,
|
|
5418
|
-
f3: 114,
|
|
5419
|
-
f4: 115,
|
|
5420
|
-
f5: 116,
|
|
5421
|
-
f6: 117,
|
|
5422
|
-
f7: 118,
|
|
5423
|
-
f8: 119,
|
|
5424
|
-
f9: 120,
|
|
5425
|
-
f10: 121,
|
|
5426
|
-
f11: 122,
|
|
5427
|
-
f12: 123,
|
|
5428
|
-
f13: 124,
|
|
5429
|
-
f14: 125,
|
|
5430
|
-
f15: 126,
|
|
5431
|
-
f16: 127,
|
|
5432
|
-
f17: 128,
|
|
5433
|
-
f18: 129,
|
|
5434
|
-
f19: 130,
|
|
5435
|
-
f20: 131
|
|
5436
5354
|
};
|
|
5437
|
-
function
|
|
5438
|
-
return
|
|
5439
|
-
}
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
}
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5355
|
+
function isKeyboardShortcut(event, key, allowedModifiers = {}) {
|
|
5356
|
+
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);
|
|
5357
|
+
}
|
|
5358
|
+
const IS_APPLE = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent);
|
|
5359
|
+
function createKeyboardShortcut(definition) {
|
|
5360
|
+
return IS_APPLE ? definition.apple ?? definition.default : definition.default;
|
|
5361
|
+
}
|
|
5362
|
+
const defaultKeyboardShortcuts = {
|
|
5363
|
+
arrowDown: createKeyboardShortcut({
|
|
5364
|
+
default: {
|
|
5365
|
+
guard: (event) => isKeyboardShortcut(event, "ArrowDown", {
|
|
5366
|
+
ctrlKey: !1,
|
|
5367
|
+
metaKey: !1,
|
|
5368
|
+
shiftKey: !1,
|
|
5369
|
+
altKey: !1
|
|
5370
|
+
}),
|
|
5371
|
+
keys: ["ArrowDown"]
|
|
5372
|
+
}
|
|
5373
|
+
}),
|
|
5374
|
+
arrowUp: createKeyboardShortcut({
|
|
5375
|
+
default: {
|
|
5376
|
+
guard: (event) => isKeyboardShortcut(event, "ArrowUp", {
|
|
5377
|
+
ctrlKey: !1,
|
|
5378
|
+
metaKey: !1,
|
|
5379
|
+
shiftKey: !1,
|
|
5380
|
+
altKey: !1
|
|
5381
|
+
}),
|
|
5382
|
+
keys: ["ArrowUp"]
|
|
5383
|
+
}
|
|
5384
|
+
}),
|
|
5385
|
+
break: createKeyboardShortcut({
|
|
5386
|
+
default: {
|
|
5387
|
+
guard: (event) => isKeyboardShortcut(event, "Enter", {
|
|
5388
|
+
shiftKey: !1
|
|
5389
|
+
}),
|
|
5390
|
+
keys: ["Enter"]
|
|
5391
|
+
}
|
|
5392
|
+
}),
|
|
5393
|
+
lineBreak: createKeyboardShortcut({
|
|
5394
|
+
default: {
|
|
5395
|
+
guard: (event) => isKeyboardShortcut(event, "Enter", {
|
|
5396
|
+
shiftKey: !0
|
|
5397
|
+
}),
|
|
5398
|
+
keys: ["Shift", "Enter"]
|
|
5399
|
+
}
|
|
5400
|
+
}),
|
|
5401
|
+
decorators: {
|
|
5402
|
+
strong: createKeyboardShortcut({
|
|
5403
|
+
default: {
|
|
5404
|
+
guard: (event) => isKeyboardShortcut(event, "b", {
|
|
5405
|
+
altKey: !1,
|
|
5406
|
+
ctrlKey: !0,
|
|
5407
|
+
metaKey: !1,
|
|
5408
|
+
shiftKey: !1
|
|
5409
|
+
}),
|
|
5410
|
+
keys: ["Ctrl", "B"]
|
|
5411
|
+
},
|
|
5412
|
+
apple: {
|
|
5413
|
+
guard: (event) => isKeyboardShortcut(event, "b", {
|
|
5414
|
+
altKey: !1,
|
|
5415
|
+
ctrlKey: !1,
|
|
5416
|
+
metaKey: !0,
|
|
5417
|
+
shiftKey: !1
|
|
5418
|
+
}),
|
|
5419
|
+
keys: ["\u2318", "B"]
|
|
5420
|
+
}
|
|
5421
|
+
}),
|
|
5422
|
+
em: createKeyboardShortcut({
|
|
5423
|
+
default: {
|
|
5424
|
+
guard: (event) => isKeyboardShortcut(event, "i", {
|
|
5425
|
+
altKey: !1,
|
|
5426
|
+
ctrlKey: !0,
|
|
5427
|
+
metaKey: !1,
|
|
5428
|
+
shiftKey: !1
|
|
5429
|
+
}),
|
|
5430
|
+
keys: ["Ctrl", "I"]
|
|
5431
|
+
},
|
|
5432
|
+
apple: {
|
|
5433
|
+
guard: (event) => isKeyboardShortcut(event, "i", {
|
|
5434
|
+
altKey: !1,
|
|
5435
|
+
ctrlKey: !1,
|
|
5436
|
+
metaKey: !0,
|
|
5437
|
+
shiftKey: !1
|
|
5438
|
+
}),
|
|
5439
|
+
keys: ["\u2318", "I"]
|
|
5440
|
+
}
|
|
5441
|
+
}),
|
|
5442
|
+
underline: createKeyboardShortcut({
|
|
5443
|
+
default: {
|
|
5444
|
+
guard: (event) => isKeyboardShortcut(event, "u", {
|
|
5445
|
+
altKey: !1,
|
|
5446
|
+
ctrlKey: !0,
|
|
5447
|
+
metaKey: !1,
|
|
5448
|
+
shiftKey: !1
|
|
5449
|
+
}),
|
|
5450
|
+
keys: ["Ctrl", "U"]
|
|
5451
|
+
},
|
|
5452
|
+
apple: {
|
|
5453
|
+
guard: (event) => isKeyboardShortcut(event, "u", {
|
|
5454
|
+
altKey: !1,
|
|
5455
|
+
ctrlKey: !1,
|
|
5456
|
+
metaKey: !0,
|
|
5457
|
+
shiftKey: !1
|
|
5458
|
+
}),
|
|
5459
|
+
keys: ["\u2318", "U"]
|
|
5460
|
+
}
|
|
5461
|
+
}),
|
|
5462
|
+
code: createKeyboardShortcut({
|
|
5463
|
+
default: {
|
|
5464
|
+
guard: (event) => isKeyboardShortcut(event, "'", {
|
|
5465
|
+
altKey: !1,
|
|
5466
|
+
ctrlKey: !0,
|
|
5467
|
+
metaKey: !1,
|
|
5468
|
+
shiftKey: !1
|
|
5469
|
+
}),
|
|
5470
|
+
keys: ["Ctrl", "'"]
|
|
5471
|
+
},
|
|
5472
|
+
apple: {
|
|
5473
|
+
guard: (event) => isKeyboardShortcut(event, "'", {
|
|
5474
|
+
altKey: !1,
|
|
5475
|
+
ctrlKey: !1,
|
|
5476
|
+
metaKey: !0,
|
|
5477
|
+
shiftKey: !1
|
|
5478
|
+
}),
|
|
5479
|
+
keys: ["\u2318", "'"]
|
|
5480
|
+
}
|
|
5481
|
+
})
|
|
5482
|
+
},
|
|
5483
|
+
history: {
|
|
5484
|
+
undo: createKeyboardShortcut({
|
|
5485
|
+
default: {
|
|
5486
|
+
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5487
|
+
altKey: !1,
|
|
5488
|
+
ctrlKey: !0,
|
|
5489
|
+
metaKey: !1,
|
|
5490
|
+
shiftKey: !1
|
|
5491
|
+
}),
|
|
5492
|
+
keys: ["Ctrl", "Z"]
|
|
5493
|
+
},
|
|
5494
|
+
apple: {
|
|
5495
|
+
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5496
|
+
altKey: !1,
|
|
5497
|
+
ctrlKey: !1,
|
|
5498
|
+
metaKey: !0,
|
|
5499
|
+
shiftKey: !1
|
|
5500
|
+
}),
|
|
5501
|
+
keys: ["\u2318", "Z"]
|
|
5502
|
+
}
|
|
5503
|
+
}),
|
|
5504
|
+
redo: createKeyboardShortcut({
|
|
5505
|
+
default: {
|
|
5506
|
+
guard: (event) => isKeyboardShortcut(event, "y", {
|
|
5507
|
+
ctrlKey: !0,
|
|
5508
|
+
metaKey: !1,
|
|
5509
|
+
shiftKey: !1,
|
|
5510
|
+
altKey: !1
|
|
5511
|
+
}) || isKeyboardShortcut(event, "z", {
|
|
5512
|
+
ctrlKey: !0,
|
|
5513
|
+
metaKey: !1,
|
|
5514
|
+
shiftKey: !0,
|
|
5515
|
+
altKey: !1
|
|
5516
|
+
}),
|
|
5517
|
+
keys: ["Ctrl", "Y"]
|
|
5518
|
+
},
|
|
5519
|
+
apple: {
|
|
5520
|
+
guard: (event) => isKeyboardShortcut(event, "z", {
|
|
5521
|
+
ctrlKey: !1,
|
|
5522
|
+
metaKey: !0,
|
|
5523
|
+
shiftKey: !0,
|
|
5524
|
+
altKey: !1
|
|
5525
|
+
}),
|
|
5526
|
+
keys: ["\u2318", "Shift", "Z"]
|
|
5527
|
+
}
|
|
5528
|
+
})
|
|
5529
|
+
},
|
|
5530
|
+
tab: createKeyboardShortcut({
|
|
5531
|
+
default: {
|
|
5532
|
+
guard: (event) => isKeyboardShortcut(event, "Tab", {
|
|
5533
|
+
ctrlKey: !1,
|
|
5534
|
+
metaKey: !1,
|
|
5535
|
+
shiftKey: !1,
|
|
5536
|
+
altKey: !1
|
|
5537
|
+
}),
|
|
5538
|
+
keys: ["Tab"]
|
|
5539
|
+
}
|
|
5540
|
+
}),
|
|
5541
|
+
shiftTab: createKeyboardShortcut({
|
|
5542
|
+
default: {
|
|
5543
|
+
guard: (event) => isKeyboardShortcut(event, "Tab", {
|
|
5544
|
+
ctrlKey: !1,
|
|
5545
|
+
metaKey: !1,
|
|
5546
|
+
shiftKey: !0,
|
|
5547
|
+
altKey: !1
|
|
5548
|
+
}),
|
|
5549
|
+
keys: ["Shift", "Tab"]
|
|
5550
|
+
}
|
|
5551
|
+
})
|
|
5552
|
+
}, arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
5467
5553
|
on: "keyboard.keydown",
|
|
5468
5554
|
guard: ({
|
|
5469
5555
|
snapshot,
|
|
5470
5556
|
event
|
|
5471
5557
|
}) => {
|
|
5472
|
-
if (!
|
|
5558
|
+
if (!defaultKeyboardShortcuts.arrowDown.guard(event.originEvent) || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
5473
5559
|
return !1;
|
|
5474
5560
|
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
5475
5561
|
return focusBlockObject && !nextBlock;
|
|
@@ -5489,7 +5575,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5489
5575
|
snapshot,
|
|
5490
5576
|
event
|
|
5491
5577
|
}) => {
|
|
5492
|
-
if (!
|
|
5578
|
+
if (!defaultKeyboardShortcuts.arrowUp.guard(event.originEvent) || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
5493
5579
|
return !1;
|
|
5494
5580
|
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
5495
5581
|
return focusBlockObject && !previousBlock;
|
|
@@ -5600,7 +5686,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5600
5686
|
snapshot
|
|
5601
5687
|
}) => {
|
|
5602
5688
|
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
5603
|
-
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !
|
|
5689
|
+
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
5604
5690
|
focusTextBlock,
|
|
5605
5691
|
previousBlock
|
|
5606
5692
|
} : !1;
|
|
@@ -5630,7 +5716,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5630
5716
|
snapshot
|
|
5631
5717
|
}) => {
|
|
5632
5718
|
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
5633
|
-
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !
|
|
5719
|
+
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, nextBlock.node) ? {
|
|
5634
5720
|
focusTextBlock,
|
|
5635
5721
|
nextBlock
|
|
5636
5722
|
} : !1;
|
|
@@ -5668,7 +5754,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5668
5754
|
guard: ({
|
|
5669
5755
|
snapshot,
|
|
5670
5756
|
event
|
|
5671
|
-
}) =>
|
|
5757
|
+
}) => defaultKeyboardShortcuts.decorators.strong.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "strong"),
|
|
5672
5758
|
actions: [() => [behaviors_index.raise({
|
|
5673
5759
|
type: "decorator.toggle",
|
|
5674
5760
|
decorator: "strong"
|
|
@@ -5679,7 +5765,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5679
5765
|
guard: ({
|
|
5680
5766
|
snapshot,
|
|
5681
5767
|
event
|
|
5682
|
-
}) =>
|
|
5768
|
+
}) => defaultKeyboardShortcuts.decorators.em.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "em"),
|
|
5683
5769
|
actions: [() => [behaviors_index.raise({
|
|
5684
5770
|
type: "decorator.toggle",
|
|
5685
5771
|
decorator: "em"
|
|
@@ -5690,7 +5776,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5690
5776
|
guard: ({
|
|
5691
5777
|
snapshot,
|
|
5692
5778
|
event
|
|
5693
|
-
}) =>
|
|
5779
|
+
}) => defaultKeyboardShortcuts.decorators.underline.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "underline"),
|
|
5694
5780
|
actions: [() => [behaviors_index.raise({
|
|
5695
5781
|
type: "decorator.toggle",
|
|
5696
5782
|
decorator: "underline"
|
|
@@ -5701,7 +5787,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5701
5787
|
guard: ({
|
|
5702
5788
|
snapshot,
|
|
5703
5789
|
event
|
|
5704
|
-
}) =>
|
|
5790
|
+
}) => defaultKeyboardShortcuts.decorators.code.guard(event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "code"),
|
|
5705
5791
|
actions: [() => [behaviors_index.raise({
|
|
5706
5792
|
type: "decorator.toggle",
|
|
5707
5793
|
decorator: "code"
|
|
@@ -6055,13 +6141,13 @@ const coreDndBehaviors = [
|
|
|
6055
6141
|
const firstBlock = selector_isSelectingEntireBlocks.getFirstBlock(snapshot), lastBlock = selector_isSelectingEntireBlocks.getLastBlock(snapshot);
|
|
6056
6142
|
if (!firstBlock || !lastBlock)
|
|
6057
6143
|
return !1;
|
|
6058
|
-
const firstBlockStartPoint =
|
|
6144
|
+
const firstBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
6059
6145
|
context: snapshot.context,
|
|
6060
6146
|
block: firstBlock
|
|
6061
|
-
}), selectionStartPoint =
|
|
6147
|
+
}), selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), lastBlockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
6062
6148
|
context: snapshot.context,
|
|
6063
6149
|
block: lastBlock
|
|
6064
|
-
}), selectionEndPoint =
|
|
6150
|
+
}), selectionEndPoint = util_sliceBlocks.getSelectionEndPoint(snapshot.context.selection);
|
|
6065
6151
|
return util_isEqualSelectionPoints.isEqualSelectionPoints(firstBlockStartPoint, selectionStartPoint) && util_isEqualSelectionPoints.isEqualSelectionPoints(lastBlockEndPoint, selectionEndPoint) ? {
|
|
6066
6152
|
selection: snapshot.context.selection
|
|
6067
6153
|
} : !1;
|
|
@@ -6082,13 +6168,13 @@ const coreDndBehaviors = [
|
|
|
6082
6168
|
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
6083
6169
|
if (!selectionStartBlock || !selectionEndBlock)
|
|
6084
6170
|
return !1;
|
|
6085
|
-
const startBlockStartPoint =
|
|
6171
|
+
const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
6086
6172
|
context: snapshot.context,
|
|
6087
6173
|
block: selectionStartBlock
|
|
6088
|
-
}), selectionStartPoint =
|
|
6174
|
+
}), selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), endBlockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
6089
6175
|
context: snapshot.context,
|
|
6090
6176
|
block: selectionEndBlock
|
|
6091
|
-
}), selectionEndPoint =
|
|
6177
|
+
}), selectionEndPoint = util_sliceBlocks.getSelectionEndPoint(snapshot.context.selection);
|
|
6092
6178
|
return util_isEqualSelectionPoints.isEqualSelectionPoints(selectionStartPoint, startBlockStartPoint) && util_isEqualSelectionPoints.isEqualSelectionPoints(selectionEndPoint, endBlockEndPoint) ? {
|
|
6093
6179
|
selectedBlocks
|
|
6094
6180
|
} : !1;
|
|
@@ -6194,9 +6280,9 @@ const coreDndBehaviors = [
|
|
|
6194
6280
|
snapshot,
|
|
6195
6281
|
event
|
|
6196
6282
|
}) => {
|
|
6197
|
-
if (!
|
|
6283
|
+
if (!defaultKeyboardShortcuts.tab.guard(event.originEvent))
|
|
6198
6284
|
return !1;
|
|
6199
|
-
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) =>
|
|
6285
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_sliceBlocks.isListBlock(snapshot.context, block.node) ? [{
|
|
6200
6286
|
node: block.node,
|
|
6201
6287
|
path: block.path
|
|
6202
6288
|
}] : []);
|
|
@@ -6219,9 +6305,9 @@ const coreDndBehaviors = [
|
|
|
6219
6305
|
snapshot,
|
|
6220
6306
|
event
|
|
6221
6307
|
}) => {
|
|
6222
|
-
if (!
|
|
6308
|
+
if (!defaultKeyboardShortcuts.shiftTab.guard(event.originEvent))
|
|
6223
6309
|
return !1;
|
|
6224
|
-
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) =>
|
|
6310
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_sliceBlocks.isListBlock(snapshot.context, block.node) ? [{
|
|
6225
6311
|
node: block.node,
|
|
6226
6312
|
path: block.path
|
|
6227
6313
|
}] : []);
|
|
@@ -6429,7 +6515,7 @@ const coreDndBehaviors = [
|
|
|
6429
6515
|
}
|
|
6430
6516
|
}
|
|
6431
6517
|
});
|
|
6432
|
-
return focusChild ?
|
|
6518
|
+
return focusChild ? util_sliceBlocks.isSpan$1(snapshot.context, focusChild.node) ? {
|
|
6433
6519
|
selection: {
|
|
6434
6520
|
anchor: {
|
|
6435
6521
|
path: event.at,
|
|
@@ -6592,16 +6678,17 @@ const coreDndBehaviors = [
|
|
|
6592
6678
|
text: `
|
|
6593
6679
|
`
|
|
6594
6680
|
})]]
|
|
6595
|
-
})],
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6681
|
+
})], abstractKeyboardBehaviors = [
|
|
6682
|
+
/**
|
|
6683
|
+
* Allow raising an `insert.break` event when pressing Enter on an inline
|
|
6684
|
+
* object.
|
|
6685
|
+
*/
|
|
6599
6686
|
behaviors_index.defineBehavior({
|
|
6600
6687
|
on: "keyboard.keydown",
|
|
6601
6688
|
guard: ({
|
|
6602
6689
|
snapshot,
|
|
6603
6690
|
event
|
|
6604
|
-
}) =>
|
|
6691
|
+
}) => defaultKeyboardShortcuts.break.guard(event.originEvent) && selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
|
|
6605
6692
|
actions: [() => [behaviors_index.raise({
|
|
6606
6693
|
type: "insert.break"
|
|
6607
6694
|
})]]
|
|
@@ -6615,10 +6702,34 @@ const coreDndBehaviors = [
|
|
|
6615
6702
|
on: "keyboard.keydown",
|
|
6616
6703
|
guard: ({
|
|
6617
6704
|
event
|
|
6618
|
-
}) =>
|
|
6705
|
+
}) => defaultKeyboardShortcuts.lineBreak.guard(event.originEvent),
|
|
6619
6706
|
actions: [() => [behaviors_index.raise({
|
|
6620
6707
|
type: "insert.soft break"
|
|
6621
6708
|
})]]
|
|
6709
|
+
}),
|
|
6710
|
+
/**
|
|
6711
|
+
* Manual handling of undo shortcuts.
|
|
6712
|
+
*/
|
|
6713
|
+
behaviors_index.defineBehavior({
|
|
6714
|
+
on: "keyboard.keydown",
|
|
6715
|
+
guard: ({
|
|
6716
|
+
event
|
|
6717
|
+
}) => defaultKeyboardShortcuts.history.undo.guard(event.originEvent),
|
|
6718
|
+
actions: [() => [behaviors_index.raise({
|
|
6719
|
+
type: "history.undo"
|
|
6720
|
+
})]]
|
|
6721
|
+
}),
|
|
6722
|
+
/**
|
|
6723
|
+
* Manual handling of redo shortcuts.
|
|
6724
|
+
*/
|
|
6725
|
+
behaviors_index.defineBehavior({
|
|
6726
|
+
on: "keyboard.keydown",
|
|
6727
|
+
guard: ({
|
|
6728
|
+
event
|
|
6729
|
+
}) => defaultKeyboardShortcuts.history.redo.guard(event.originEvent),
|
|
6730
|
+
actions: [() => [behaviors_index.raise({
|
|
6731
|
+
type: "history.redo"
|
|
6732
|
+
})]]
|
|
6622
6733
|
})
|
|
6623
6734
|
], abstractListItemBehaviors = [behaviors_index.defineBehavior({
|
|
6624
6735
|
on: "list item.add",
|
|
@@ -6759,7 +6870,7 @@ const coreDndBehaviors = [
|
|
|
6759
6870
|
const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
|
|
6760
6871
|
context: snapshot.context,
|
|
6761
6872
|
block: previousBlock
|
|
6762
|
-
}) :
|
|
6873
|
+
}) : util_sliceBlocks.getBlockStartPoint({
|
|
6763
6874
|
context: snapshot.context,
|
|
6764
6875
|
block: previousBlock
|
|
6765
6876
|
});
|
|
@@ -6788,7 +6899,7 @@ const coreDndBehaviors = [
|
|
|
6788
6899
|
const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
|
|
6789
6900
|
context: snapshot.context,
|
|
6790
6901
|
block: nextBlock
|
|
6791
|
-
}) :
|
|
6902
|
+
}) : util_sliceBlocks.getBlockStartPoint({
|
|
6792
6903
|
context: snapshot.context,
|
|
6793
6904
|
block: nextBlock
|
|
6794
6905
|
});
|
|
@@ -6835,7 +6946,7 @@ const coreDndBehaviors = [
|
|
|
6835
6946
|
if (!selection || util_sliceTextBlock.isSelectionCollapsed(selection))
|
|
6836
6947
|
return !1;
|
|
6837
6948
|
const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
6838
|
-
return !selectionStartBlock || !selectionEndBlock ? !1 : !
|
|
6949
|
+
return !selectionStartBlock || !selectionEndBlock ? !1 : !util_sliceBlocks.isTextBlock(snapshot.context, selectionStartBlock.node) && util_sliceBlocks.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
|
|
6839
6950
|
selection
|
|
6840
6951
|
} : !1;
|
|
6841
6952
|
},
|
|
@@ -6873,7 +6984,7 @@ const coreDndBehaviors = [
|
|
|
6873
6984
|
const selection = snapshot.context.selection;
|
|
6874
6985
|
if (!selection || !util_sliceTextBlock.isSelectionCollapsed(selection))
|
|
6875
6986
|
return !1;
|
|
6876
|
-
const selectionStartPoint =
|
|
6987
|
+
const selectionStartPoint = util_sliceBlocks.getSelectionStartPoint(selection), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
6877
6988
|
if (!focusTextBlock)
|
|
6878
6989
|
return !1;
|
|
6879
6990
|
const blockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
@@ -6882,7 +6993,7 @@ const coreDndBehaviors = [
|
|
|
6882
6993
|
}), newTextBlockSelection = {
|
|
6883
6994
|
anchor: selectionStartPoint,
|
|
6884
6995
|
focus: blockEndPoint
|
|
6885
|
-
}, newTextBlock =
|
|
6996
|
+
}, newTextBlock = util_sliceBlocks.parseBlock({
|
|
6886
6997
|
block: util_sliceTextBlock.sliceTextBlock({
|
|
6887
6998
|
context: {
|
|
6888
6999
|
...snapshot.context,
|
|
@@ -7131,7 +7242,7 @@ const coreDndBehaviors = [
|
|
|
7131
7242
|
return {
|
|
7132
7243
|
activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
|
|
7133
7244
|
activeDecorators,
|
|
7134
|
-
textRuns: event.data.flatMap((block) =>
|
|
7245
|
+
textRuns: event.data.flatMap((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? [util_sliceBlocks.getTextBlockText(block)] : [])
|
|
7135
7246
|
};
|
|
7136
7247
|
}
|
|
7137
7248
|
return !1;
|
|
@@ -8901,7 +9012,7 @@ function validateValue(value, types2, keyGenerator) {
|
|
|
8901
9012
|
}
|
|
8902
9013
|
}, !0;
|
|
8903
9014
|
}
|
|
8904
|
-
return !blk._type &&
|
|
9015
|
+
return !blk._type && util_sliceBlocks.isTextBlock({
|
|
8905
9016
|
schema: types2
|
|
8906
9017
|
}, {
|
|
8907
9018
|
...blk,
|
|
@@ -10547,6 +10658,118 @@ function RenderText(props) {
|
|
|
10547
10658
|
let t0;
|
|
10548
10659
|
return $[0] !== props.attributes || $[1] !== props.children || $[2] !== props.text._key || $[3] !== props.text._type ? (t0 = /* @__PURE__ */ jsxRuntime.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;
|
|
10549
10660
|
}
|
|
10661
|
+
const IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
|
|
10662
|
+
alt: "altKey",
|
|
10663
|
+
control: "ctrlKey",
|
|
10664
|
+
meta: "metaKey",
|
|
10665
|
+
shift: "shiftKey"
|
|
10666
|
+
}, aliases = {
|
|
10667
|
+
add: "+",
|
|
10668
|
+
break: "pause",
|
|
10669
|
+
cmd: "meta",
|
|
10670
|
+
command: "meta",
|
|
10671
|
+
ctl: "control",
|
|
10672
|
+
ctrl: "control",
|
|
10673
|
+
del: "delete",
|
|
10674
|
+
down: "arrowdown",
|
|
10675
|
+
esc: "escape",
|
|
10676
|
+
ins: "insert",
|
|
10677
|
+
left: "arrowleft",
|
|
10678
|
+
mod: IS_MAC ? "meta" : "control",
|
|
10679
|
+
opt: "alt",
|
|
10680
|
+
option: "alt",
|
|
10681
|
+
return: "enter",
|
|
10682
|
+
right: "arrowright",
|
|
10683
|
+
space: " ",
|
|
10684
|
+
spacebar: " ",
|
|
10685
|
+
up: "arrowup",
|
|
10686
|
+
win: "meta",
|
|
10687
|
+
windows: "meta"
|
|
10688
|
+
}, keyCodes = {
|
|
10689
|
+
backspace: 8,
|
|
10690
|
+
tab: 9,
|
|
10691
|
+
enter: 13,
|
|
10692
|
+
shift: 16,
|
|
10693
|
+
control: 17,
|
|
10694
|
+
alt: 18,
|
|
10695
|
+
pause: 19,
|
|
10696
|
+
capslock: 20,
|
|
10697
|
+
escape: 27,
|
|
10698
|
+
" ": 32,
|
|
10699
|
+
pageup: 33,
|
|
10700
|
+
pagedown: 34,
|
|
10701
|
+
end: 35,
|
|
10702
|
+
home: 36,
|
|
10703
|
+
arrowleft: 37,
|
|
10704
|
+
arrowup: 38,
|
|
10705
|
+
arrowright: 39,
|
|
10706
|
+
arrowdown: 40,
|
|
10707
|
+
insert: 45,
|
|
10708
|
+
delete: 46,
|
|
10709
|
+
meta: 91,
|
|
10710
|
+
numlock: 144,
|
|
10711
|
+
scrolllock: 145,
|
|
10712
|
+
";": 186,
|
|
10713
|
+
"=": 187,
|
|
10714
|
+
",": 188,
|
|
10715
|
+
"-": 189,
|
|
10716
|
+
".": 190,
|
|
10717
|
+
"/": 191,
|
|
10718
|
+
"`": 192,
|
|
10719
|
+
"[": 219,
|
|
10720
|
+
"\\": 220,
|
|
10721
|
+
"]": 221,
|
|
10722
|
+
"'": 222,
|
|
10723
|
+
f1: 112,
|
|
10724
|
+
f2: 113,
|
|
10725
|
+
f3: 114,
|
|
10726
|
+
f4: 115,
|
|
10727
|
+
f5: 116,
|
|
10728
|
+
f6: 117,
|
|
10729
|
+
f7: 118,
|
|
10730
|
+
f8: 119,
|
|
10731
|
+
f9: 120,
|
|
10732
|
+
f10: 121,
|
|
10733
|
+
f11: 122,
|
|
10734
|
+
f12: 123,
|
|
10735
|
+
f13: 124,
|
|
10736
|
+
f14: 125,
|
|
10737
|
+
f15: 126,
|
|
10738
|
+
f16: 127,
|
|
10739
|
+
f17: 128,
|
|
10740
|
+
f18: 129,
|
|
10741
|
+
f19: 130,
|
|
10742
|
+
f20: 131
|
|
10743
|
+
};
|
|
10744
|
+
function isHotkey(hotkey, event) {
|
|
10745
|
+
return compareHotkey(parseHotkey(hotkey), event);
|
|
10746
|
+
}
|
|
10747
|
+
function parseHotkey(hotkey) {
|
|
10748
|
+
const parsedHotkey = {
|
|
10749
|
+
altKey: !1,
|
|
10750
|
+
ctrlKey: !1,
|
|
10751
|
+
metaKey: !1,
|
|
10752
|
+
shiftKey: !1
|
|
10753
|
+
}, hotkeySegments = hotkey.replace("++", "+add").split("+");
|
|
10754
|
+
for (const rawHotkeySegment of hotkeySegments) {
|
|
10755
|
+
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];
|
|
10756
|
+
if (hotkeySegment.length > 1 && modifier === void 0 && alias === void 0 && code === void 0)
|
|
10757
|
+
throw new TypeError(`Unknown modifier: "${hotkeySegment}"`);
|
|
10758
|
+
(hotkeySegments.length === 1 || modifier === void 0) && (parsedHotkey.key = keyName, parsedHotkey.keyCode = toKeyCode(hotkeySegment)), modifier !== void 0 && (parsedHotkey[modifier] = optional ? null : !0);
|
|
10759
|
+
}
|
|
10760
|
+
return parsedHotkey;
|
|
10761
|
+
}
|
|
10762
|
+
function compareHotkey(parsedHotkey, event) {
|
|
10763
|
+
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;
|
|
10764
|
+
}
|
|
10765
|
+
function toKeyCode(name) {
|
|
10766
|
+
const keyName = toKeyName(name);
|
|
10767
|
+
return keyCodes[keyName] ?? keyName.toUpperCase().charCodeAt(0);
|
|
10768
|
+
}
|
|
10769
|
+
function toKeyName(name) {
|
|
10770
|
+
const keyName = name.toLowerCase();
|
|
10771
|
+
return aliases[keyName] ?? keyName;
|
|
10772
|
+
}
|
|
10550
10773
|
const debug$1 = debugWithName("plugin:withHotKeys");
|
|
10551
10774
|
function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions) {
|
|
10552
10775
|
const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions ?? {};
|
|
@@ -11040,7 +11263,7 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = React.
|
|
|
11040
11263
|
type: "behavior event",
|
|
11041
11264
|
behaviorEvent: {
|
|
11042
11265
|
type: "insert.blocks",
|
|
11043
|
-
blocks:
|
|
11266
|
+
blocks: util_sliceBlocks.parseBlocks({
|
|
11044
11267
|
context: {
|
|
11045
11268
|
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
|
|
11046
11269
|
schema: editorActor.getSnapshot().context.schema
|