@portabletext/editor 1.48.10 → 1.48.12
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/editor-provider.cjs +785 -126
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +464 -19
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +9 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
- package/lib/_chunks-es/editor-provider.js +679 -22
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +448 -3
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +9 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +2 -2
- package/lib/behaviors/index.cjs +27 -377
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +2863 -13243
- package/lib/behaviors/index.d.ts +2863 -13243
- package/lib/behaviors/index.js +22 -377
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +17 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2563 -110
- package/lib/index.d.ts +2563 -110
- package/lib/index.js +4 -5
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +347 -30
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2563 -111
- package/lib/plugins/index.d.ts +2563 -111
- package/lib/plugins/index.js +324 -8
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +29 -29
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2562 -103
- package/lib/selectors/index.d.ts +2562 -103
- package/lib/selectors/index.js +2 -3
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +5 -5
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2563 -105
- package/lib/utils/index.d.ts +2563 -105
- package/lib/utils/index.js +2 -3
- package/lib/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/behaviors/behavior.emoji-picker.ts +0 -6
- package/src/behaviors/behavior.markdown.ts +0 -48
- package/src/behaviors/behavior.perform-event.ts +16 -6
- package/src/behaviors/index.ts +0 -15
- package/src/editor/create-editor.ts +0 -3
- package/src/editor/editor-machine.ts +1 -13
- package/src/internal-utils/__tests__/operationToPatches.test.ts +0 -2
- package/src/internal-utils/__tests__/patchToOperations.test.ts +0 -2
- package/src/plugins/plugin.core.tsx +1 -1
- package/lib/_chunks-cjs/behavior.core.cjs +0 -700
- package/lib/_chunks-cjs/behavior.core.cjs.map +0 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +0 -321
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +0 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +0 -449
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +0 -1
- package/lib/_chunks-cjs/util.get-selection-start-point.cjs +0 -10
- package/lib/_chunks-cjs/util.get-selection-start-point.cjs.map +0 -1
- package/lib/_chunks-es/behavior.core.js +0 -703
- package/lib/_chunks-es/behavior.core.js.map +0 -1
- package/lib/_chunks-es/behavior.markdown.js +0 -325
- package/lib/_chunks-es/behavior.markdown.js.map +0 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +0 -451
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +0 -1
- package/lib/_chunks-es/util.get-selection-start-point.js +0 -11
- package/lib/_chunks-es/util.get-selection-start-point.js.map +0 -1
- package/src/behaviors/behavior.code-editor.ts +0 -77
- package/src/behaviors/behavior.links.ts +0 -84
- package/src/internal-utils/looks-like-url.test.ts +0 -19
- package/src/internal-utils/looks-like-url.ts +0 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), React = require("react"), slateReact = require("slate-react"), reactCompilerRuntime = require("react-compiler-runtime"), debug$f = require("debug"), isEqual = require("lodash/isEqual.js"), slate = require("slate"), xstate = require("xstate"), patches = require("@portabletext/patches"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), uniq = require("lodash/uniq.js"), util_sliceBlocks = require("./util.slice-blocks.cjs"), getRandomValues = require("get-random-values-esm"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), types = require("@sanity/types"), omit = require("lodash/omit.js"), util_selectionPointToBlockOffset = require("./util.selection-point-to-block-offset.cjs"), selector_isSelectingEntireBlocks = require("./selector.is-selecting-entire-blocks.cjs"), slateDom = require("slate-dom"), startCase = require("lodash.startcase"),
|
|
2
|
+
var jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), React = require("react"), slateReact = require("slate-react"), reactCompilerRuntime = require("react-compiler-runtime"), debug$f = require("debug"), isEqual = require("lodash/isEqual.js"), slate = require("slate"), xstate = require("xstate"), patches = require("@portabletext/patches"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), uniq = require("lodash/uniq.js"), util_sliceBlocks = require("./util.slice-blocks.cjs"), getRandomValues = require("get-random-values-esm"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), types = require("@sanity/types"), omit = require("lodash/omit.js"), util_selectionPointToBlockOffset = require("./util.selection-point-to-block-offset.cjs"), selector_isSelectingEntireBlocks = require("./selector.is-selecting-entire-blocks.cjs"), slateDom = require("slate-dom"), startCase = require("lodash.startcase"), behaviors_index = require("../behaviors/index.cjs"), rxjs = require("rxjs"), useEffectEvent = require("use-effect-event");
|
|
3
3
|
function _interopDefaultCompat(e) {
|
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
5
5
|
}
|
|
@@ -4946,7 +4946,7 @@ function createWithSchemaTypes({
|
|
|
4946
4946
|
editorActor
|
|
4947
4947
|
}) {
|
|
4948
4948
|
return function(editor) {
|
|
4949
|
-
editor.isTextBlock = (value) => util_sliceBlocks.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => util_sliceBlocks.isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => 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) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4949
|
+
editor.isTextBlock = (value) => util_sliceBlocks.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => util_sliceBlocks.isSpan$1(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => util_sliceBlocks.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => 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) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4950
4950
|
const {
|
|
4951
4951
|
normalizeNode
|
|
4952
4952
|
} = editor;
|
|
@@ -5697,7 +5697,6 @@ function editorConfigToMachineInput(config) {
|
|
|
5697
5697
|
schema: schema2
|
|
5698
5698
|
} = compileSchemasFromEditorConfig(config);
|
|
5699
5699
|
return {
|
|
5700
|
-
behaviors: config.behaviors,
|
|
5701
5700
|
converters: createCoreConverters(legacySchema),
|
|
5702
5701
|
getLegacySchema: () => legacySchema,
|
|
5703
5702
|
keyGenerator: config.keyGenerator ?? defaultKeyGenerator,
|
|
@@ -5729,7 +5728,6 @@ function createInternalEditor(editorActor) {
|
|
|
5729
5728
|
switch (event.type) {
|
|
5730
5729
|
case "add behavior":
|
|
5731
5730
|
case "remove behavior":
|
|
5732
|
-
case "update behaviors":
|
|
5733
5731
|
case "update key generator":
|
|
5734
5732
|
case "update readOnly":
|
|
5735
5733
|
case "patches":
|
|
@@ -5811,7 +5809,669 @@ function createGloballyScopedContext(key, defaultValue) {
|
|
|
5811
5809
|
const symbol = Symbol.for(key);
|
|
5812
5810
|
return typeof document > "u" ? React.createContext(defaultValue) : (globalScope[symbol] = globalScope[symbol] ?? React.createContext(defaultValue), globalScope[symbol]);
|
|
5813
5811
|
}
|
|
5814
|
-
const EditorContext = createGloballyScopedContext("@portabletext/editor/context/editor", null),
|
|
5812
|
+
const EditorContext = createGloballyScopedContext("@portabletext/editor/context/editor", null), addAnnotationOnCollapsedSelection = behaviors_index.defineBehavior({
|
|
5813
|
+
on: "annotation.add",
|
|
5814
|
+
guard: ({
|
|
5815
|
+
snapshot
|
|
5816
|
+
}) => {
|
|
5817
|
+
if (!selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot))
|
|
5818
|
+
return !1;
|
|
5819
|
+
const caretWordSelection = selector_isSelectingEntireBlocks.getCaretWordSelection(snapshot);
|
|
5820
|
+
return !caretWordSelection || !selector_isSelectingEntireBlocks.isSelectionExpanded({
|
|
5821
|
+
context: {
|
|
5822
|
+
...snapshot.context,
|
|
5823
|
+
selection: caretWordSelection
|
|
5824
|
+
}
|
|
5825
|
+
}) ? !1 : {
|
|
5826
|
+
caretWordSelection
|
|
5827
|
+
};
|
|
5828
|
+
},
|
|
5829
|
+
actions: [({
|
|
5830
|
+
event
|
|
5831
|
+
}, {
|
|
5832
|
+
caretWordSelection
|
|
5833
|
+
}) => [behaviors_index.raise({
|
|
5834
|
+
type: "select",
|
|
5835
|
+
at: caretWordSelection
|
|
5836
|
+
}), behaviors_index.raise({
|
|
5837
|
+
type: "annotation.add",
|
|
5838
|
+
annotation: event.annotation
|
|
5839
|
+
})]]
|
|
5840
|
+
}), coreAnnotationBehaviors = {
|
|
5841
|
+
addAnnotationOnCollapsedSelection
|
|
5842
|
+
}, IS_MAC = typeof window < "u" && /Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent), modifiers = {
|
|
5843
|
+
alt: "altKey",
|
|
5844
|
+
control: "ctrlKey",
|
|
5845
|
+
meta: "metaKey",
|
|
5846
|
+
shift: "shiftKey"
|
|
5847
|
+
}, aliases = {
|
|
5848
|
+
add: "+",
|
|
5849
|
+
break: "pause",
|
|
5850
|
+
cmd: "meta",
|
|
5851
|
+
command: "meta",
|
|
5852
|
+
ctl: "control",
|
|
5853
|
+
ctrl: "control",
|
|
5854
|
+
del: "delete",
|
|
5855
|
+
down: "arrowdown",
|
|
5856
|
+
esc: "escape",
|
|
5857
|
+
ins: "insert",
|
|
5858
|
+
left: "arrowleft",
|
|
5859
|
+
mod: IS_MAC ? "meta" : "control",
|
|
5860
|
+
opt: "alt",
|
|
5861
|
+
option: "alt",
|
|
5862
|
+
return: "enter",
|
|
5863
|
+
right: "arrowright",
|
|
5864
|
+
space: " ",
|
|
5865
|
+
spacebar: " ",
|
|
5866
|
+
up: "arrowup",
|
|
5867
|
+
win: "meta",
|
|
5868
|
+
windows: "meta"
|
|
5869
|
+
}, keyCodes = {
|
|
5870
|
+
backspace: 8,
|
|
5871
|
+
tab: 9,
|
|
5872
|
+
enter: 13,
|
|
5873
|
+
shift: 16,
|
|
5874
|
+
control: 17,
|
|
5875
|
+
alt: 18,
|
|
5876
|
+
pause: 19,
|
|
5877
|
+
capslock: 20,
|
|
5878
|
+
escape: 27,
|
|
5879
|
+
" ": 32,
|
|
5880
|
+
pageup: 33,
|
|
5881
|
+
pagedown: 34,
|
|
5882
|
+
end: 35,
|
|
5883
|
+
home: 36,
|
|
5884
|
+
arrowleft: 37,
|
|
5885
|
+
arrowup: 38,
|
|
5886
|
+
arrowright: 39,
|
|
5887
|
+
arrowdown: 40,
|
|
5888
|
+
insert: 45,
|
|
5889
|
+
delete: 46,
|
|
5890
|
+
meta: 91,
|
|
5891
|
+
numlock: 144,
|
|
5892
|
+
scrolllock: 145,
|
|
5893
|
+
";": 186,
|
|
5894
|
+
"=": 187,
|
|
5895
|
+
",": 188,
|
|
5896
|
+
"-": 189,
|
|
5897
|
+
".": 190,
|
|
5898
|
+
"/": 191,
|
|
5899
|
+
"`": 192,
|
|
5900
|
+
"[": 219,
|
|
5901
|
+
"\\": 220,
|
|
5902
|
+
"]": 221,
|
|
5903
|
+
"'": 222,
|
|
5904
|
+
f1: 112,
|
|
5905
|
+
f2: 113,
|
|
5906
|
+
f3: 114,
|
|
5907
|
+
f4: 115,
|
|
5908
|
+
f5: 116,
|
|
5909
|
+
f6: 117,
|
|
5910
|
+
f7: 118,
|
|
5911
|
+
f8: 119,
|
|
5912
|
+
f9: 120,
|
|
5913
|
+
f10: 121,
|
|
5914
|
+
f11: 122,
|
|
5915
|
+
f12: 123,
|
|
5916
|
+
f13: 124,
|
|
5917
|
+
f14: 125,
|
|
5918
|
+
f15: 126,
|
|
5919
|
+
f16: 127,
|
|
5920
|
+
f17: 128,
|
|
5921
|
+
f18: 129,
|
|
5922
|
+
f19: 130,
|
|
5923
|
+
f20: 131
|
|
5924
|
+
};
|
|
5925
|
+
function isHotkey(hotkey, event) {
|
|
5926
|
+
return compareHotkey(parseHotkey(hotkey), event);
|
|
5927
|
+
}
|
|
5928
|
+
function parseHotkey(hotkey) {
|
|
5929
|
+
const parsedHotkey = {
|
|
5930
|
+
altKey: !1,
|
|
5931
|
+
ctrlKey: !1,
|
|
5932
|
+
metaKey: !1,
|
|
5933
|
+
shiftKey: !1
|
|
5934
|
+
}, hotkeySegments = hotkey.replace("++", "+add").split("+");
|
|
5935
|
+
for (const rawHotkeySegment of hotkeySegments) {
|
|
5936
|
+
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];
|
|
5937
|
+
if (hotkeySegment.length > 1 && modifier === void 0 && alias === void 0 && code === void 0)
|
|
5938
|
+
throw new TypeError(`Unknown modifier: "${hotkeySegment}"`);
|
|
5939
|
+
(hotkeySegments.length === 1 || modifier === void 0) && (parsedHotkey.key = keyName, parsedHotkey.keyCode = toKeyCode(hotkeySegment)), modifier !== void 0 && (parsedHotkey[modifier] = optional ? null : !0);
|
|
5940
|
+
}
|
|
5941
|
+
return parsedHotkey;
|
|
5942
|
+
}
|
|
5943
|
+
function compareHotkey(parsedHotkey, event) {
|
|
5944
|
+
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;
|
|
5945
|
+
}
|
|
5946
|
+
function toKeyCode(name) {
|
|
5947
|
+
const keyName = toKeyName(name);
|
|
5948
|
+
return keyCodes[keyName] ?? keyName.toUpperCase().charCodeAt(0);
|
|
5949
|
+
}
|
|
5950
|
+
function toKeyName(name) {
|
|
5951
|
+
const keyName = name.toLowerCase();
|
|
5952
|
+
return aliases[keyName] ?? keyName;
|
|
5953
|
+
}
|
|
5954
|
+
const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
5955
|
+
on: "keyboard.keydown",
|
|
5956
|
+
guard: ({
|
|
5957
|
+
snapshot,
|
|
5958
|
+
event
|
|
5959
|
+
}) => {
|
|
5960
|
+
if (!isHotkey("ArrowDown", event.originEvent) || !selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot))
|
|
5961
|
+
return !1;
|
|
5962
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
5963
|
+
return focusBlockObject && !nextBlock;
|
|
5964
|
+
},
|
|
5965
|
+
actions: [({
|
|
5966
|
+
snapshot
|
|
5967
|
+
}) => [behaviors_index.raise({
|
|
5968
|
+
type: "insert.block",
|
|
5969
|
+
block: {
|
|
5970
|
+
_type: snapshot.context.schema.block.name
|
|
5971
|
+
},
|
|
5972
|
+
placement: "after"
|
|
5973
|
+
})]]
|
|
5974
|
+
}), arrowUpOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
5975
|
+
on: "keyboard.keydown",
|
|
5976
|
+
guard: ({
|
|
5977
|
+
snapshot,
|
|
5978
|
+
event
|
|
5979
|
+
}) => {
|
|
5980
|
+
if (!isHotkey("ArrowUp", event.originEvent) || !selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot))
|
|
5981
|
+
return !1;
|
|
5982
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
5983
|
+
return focusBlockObject && !previousBlock;
|
|
5984
|
+
},
|
|
5985
|
+
actions: [({
|
|
5986
|
+
snapshot
|
|
5987
|
+
}) => [behaviors_index.raise({
|
|
5988
|
+
type: "insert.block",
|
|
5989
|
+
block: {
|
|
5990
|
+
_type: snapshot.context.schema.block.name
|
|
5991
|
+
},
|
|
5992
|
+
placement: "before"
|
|
5993
|
+
})]]
|
|
5994
|
+
}), breakingBlockObject = behaviors_index.defineBehavior({
|
|
5995
|
+
on: "insert.break",
|
|
5996
|
+
guard: ({
|
|
5997
|
+
snapshot
|
|
5998
|
+
}) => {
|
|
5999
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot);
|
|
6000
|
+
return selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot) && focusBlockObject !== void 0;
|
|
6001
|
+
},
|
|
6002
|
+
actions: [({
|
|
6003
|
+
snapshot
|
|
6004
|
+
}) => [behaviors_index.raise({
|
|
6005
|
+
type: "insert.block",
|
|
6006
|
+
block: {
|
|
6007
|
+
_type: snapshot.context.schema.block.name
|
|
6008
|
+
},
|
|
6009
|
+
placement: "after"
|
|
6010
|
+
})]]
|
|
6011
|
+
}), clickingAboveLonelyBlockObject = behaviors_index.defineBehavior({
|
|
6012
|
+
on: "mouse.click",
|
|
6013
|
+
guard: ({
|
|
6014
|
+
snapshot,
|
|
6015
|
+
event
|
|
6016
|
+
}) => {
|
|
6017
|
+
if (snapshot.context.readOnly || snapshot.context.selection && !selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot))
|
|
6018
|
+
return !1;
|
|
6019
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject({
|
|
6020
|
+
context: {
|
|
6021
|
+
...snapshot.context,
|
|
6022
|
+
selection: event.position.selection
|
|
6023
|
+
}
|
|
6024
|
+
}), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock({
|
|
6025
|
+
context: {
|
|
6026
|
+
...snapshot.context,
|
|
6027
|
+
selection: event.position.selection
|
|
6028
|
+
}
|
|
6029
|
+
});
|
|
6030
|
+
return event.position.isEditor && event.position.block === "start" && focusBlockObject && !previousBlock;
|
|
6031
|
+
},
|
|
6032
|
+
actions: [({
|
|
6033
|
+
snapshot,
|
|
6034
|
+
event
|
|
6035
|
+
}) => [behaviors_index.raise({
|
|
6036
|
+
type: "select",
|
|
6037
|
+
at: event.position.selection
|
|
6038
|
+
}), behaviors_index.raise({
|
|
6039
|
+
type: "insert.block",
|
|
6040
|
+
block: {
|
|
6041
|
+
_type: snapshot.context.schema.block.name
|
|
6042
|
+
},
|
|
6043
|
+
placement: "before",
|
|
6044
|
+
select: "start"
|
|
6045
|
+
})]]
|
|
6046
|
+
}), clickingBelowLonelyBlockObject = behaviors_index.defineBehavior({
|
|
6047
|
+
on: "mouse.click",
|
|
6048
|
+
guard: ({
|
|
6049
|
+
snapshot,
|
|
6050
|
+
event
|
|
6051
|
+
}) => {
|
|
6052
|
+
if (snapshot.context.readOnly || snapshot.context.selection && !selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot))
|
|
6053
|
+
return !1;
|
|
6054
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject({
|
|
6055
|
+
context: {
|
|
6056
|
+
...snapshot.context,
|
|
6057
|
+
selection: event.position.selection
|
|
6058
|
+
}
|
|
6059
|
+
}), nextBlock = selector_isSelectingEntireBlocks.getNextBlock({
|
|
6060
|
+
context: {
|
|
6061
|
+
...snapshot.context,
|
|
6062
|
+
selection: event.position.selection
|
|
6063
|
+
}
|
|
6064
|
+
});
|
|
6065
|
+
return event.position.isEditor && event.position.block === "end" && focusBlockObject && !nextBlock;
|
|
6066
|
+
},
|
|
6067
|
+
actions: [({
|
|
6068
|
+
snapshot,
|
|
6069
|
+
event
|
|
6070
|
+
}) => [behaviors_index.raise({
|
|
6071
|
+
type: "select",
|
|
6072
|
+
at: event.position.selection
|
|
6073
|
+
}), behaviors_index.raise({
|
|
6074
|
+
type: "insert.block",
|
|
6075
|
+
block: {
|
|
6076
|
+
_type: snapshot.context.schema.block.name
|
|
6077
|
+
},
|
|
6078
|
+
placement: "after",
|
|
6079
|
+
select: "start"
|
|
6080
|
+
})]]
|
|
6081
|
+
}), deletingEmptyTextBlockAfterBlockObject = behaviors_index.defineBehavior({
|
|
6082
|
+
on: "delete.backward",
|
|
6083
|
+
guard: ({
|
|
6084
|
+
snapshot
|
|
6085
|
+
}) => {
|
|
6086
|
+
const focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
6087
|
+
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
6088
|
+
focusTextBlock,
|
|
6089
|
+
previousBlock
|
|
6090
|
+
} : !1;
|
|
6091
|
+
},
|
|
6092
|
+
actions: [(_, {
|
|
6093
|
+
focusTextBlock,
|
|
6094
|
+
previousBlock
|
|
6095
|
+
}) => [behaviors_index.raise({
|
|
6096
|
+
type: "delete.block",
|
|
6097
|
+
at: focusTextBlock.path
|
|
6098
|
+
}), behaviors_index.raise({
|
|
6099
|
+
type: "select",
|
|
6100
|
+
at: {
|
|
6101
|
+
anchor: {
|
|
6102
|
+
path: previousBlock.path,
|
|
6103
|
+
offset: 0
|
|
6104
|
+
},
|
|
6105
|
+
focus: {
|
|
6106
|
+
path: previousBlock.path,
|
|
6107
|
+
offset: 0
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
})]]
|
|
6111
|
+
}), deletingEmptyTextBlockBeforeBlockObject = behaviors_index.defineBehavior({
|
|
6112
|
+
on: "delete.forward",
|
|
6113
|
+
guard: ({
|
|
6114
|
+
snapshot
|
|
6115
|
+
}) => {
|
|
6116
|
+
const focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
6117
|
+
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !util_sliceBlocks.isTextBlock(snapshot.context, nextBlock.node) ? {
|
|
6118
|
+
focusTextBlock,
|
|
6119
|
+
nextBlock
|
|
6120
|
+
} : !1;
|
|
6121
|
+
},
|
|
6122
|
+
actions: [(_, {
|
|
6123
|
+
focusTextBlock,
|
|
6124
|
+
nextBlock
|
|
6125
|
+
}) => [behaviors_index.raise({
|
|
6126
|
+
type: "delete.block",
|
|
6127
|
+
at: focusTextBlock.path
|
|
6128
|
+
}), behaviors_index.raise({
|
|
6129
|
+
type: "select",
|
|
6130
|
+
at: {
|
|
6131
|
+
anchor: {
|
|
6132
|
+
path: nextBlock.path,
|
|
6133
|
+
offset: 0
|
|
6134
|
+
},
|
|
6135
|
+
focus: {
|
|
6136
|
+
path: nextBlock.path,
|
|
6137
|
+
offset: 0
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
})]]
|
|
6141
|
+
}), coreBlockObjectBehaviors = {
|
|
6142
|
+
arrowDownOnLonelyBlockObject,
|
|
6143
|
+
arrowUpOnLonelyBlockObject,
|
|
6144
|
+
breakingBlockObject,
|
|
6145
|
+
clickingAboveLonelyBlockObject,
|
|
6146
|
+
clickingBelowLonelyBlockObject,
|
|
6147
|
+
deletingEmptyTextBlockAfterBlockObject,
|
|
6148
|
+
deletingEmptyTextBlockBeforeBlockObject
|
|
6149
|
+
}, coreDecoratorBehaviors = {
|
|
6150
|
+
strongShortcut: behaviors_index.defineBehavior({
|
|
6151
|
+
on: "keyboard.keydown",
|
|
6152
|
+
guard: ({
|
|
6153
|
+
snapshot,
|
|
6154
|
+
event
|
|
6155
|
+
}) => isHotkey("mod+b", event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "strong"),
|
|
6156
|
+
actions: [() => [behaviors_index.raise({
|
|
6157
|
+
type: "decorator.toggle",
|
|
6158
|
+
decorator: "strong"
|
|
6159
|
+
})]]
|
|
6160
|
+
}),
|
|
6161
|
+
emShortcut: behaviors_index.defineBehavior({
|
|
6162
|
+
on: "keyboard.keydown",
|
|
6163
|
+
guard: ({
|
|
6164
|
+
snapshot,
|
|
6165
|
+
event
|
|
6166
|
+
}) => isHotkey("mod+i", event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "em"),
|
|
6167
|
+
actions: [() => [behaviors_index.raise({
|
|
6168
|
+
type: "decorator.toggle",
|
|
6169
|
+
decorator: "em"
|
|
6170
|
+
})]]
|
|
6171
|
+
}),
|
|
6172
|
+
underlineShortcut: behaviors_index.defineBehavior({
|
|
6173
|
+
on: "keyboard.keydown",
|
|
6174
|
+
guard: ({
|
|
6175
|
+
snapshot,
|
|
6176
|
+
event
|
|
6177
|
+
}) => isHotkey("mod+u", event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "underline"),
|
|
6178
|
+
actions: [() => [behaviors_index.raise({
|
|
6179
|
+
type: "decorator.toggle",
|
|
6180
|
+
decorator: "underline"
|
|
6181
|
+
})]]
|
|
6182
|
+
}),
|
|
6183
|
+
codeShortcut: behaviors_index.defineBehavior({
|
|
6184
|
+
on: "keyboard.keydown",
|
|
6185
|
+
guard: ({
|
|
6186
|
+
snapshot,
|
|
6187
|
+
event
|
|
6188
|
+
}) => isHotkey("mod+'", event.originEvent) && snapshot.context.schema.decorators.some((decorator) => decorator.name === "code"),
|
|
6189
|
+
actions: [() => [behaviors_index.raise({
|
|
6190
|
+
type: "decorator.toggle",
|
|
6191
|
+
decorator: "code"
|
|
6192
|
+
})]]
|
|
6193
|
+
})
|
|
6194
|
+
}, coreDndBehaviors = [
|
|
6195
|
+
/**
|
|
6196
|
+
* When dragging over the drag origin, we don't want to show the caret in the
|
|
6197
|
+
* text.
|
|
6198
|
+
*/
|
|
6199
|
+
behaviors_index.defineBehavior({
|
|
6200
|
+
on: "drag.dragover",
|
|
6201
|
+
guard: ({
|
|
6202
|
+
snapshot,
|
|
6203
|
+
event
|
|
6204
|
+
}) => {
|
|
6205
|
+
const dragOrigin = snapshot.beta.internalDrag?.origin;
|
|
6206
|
+
return dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(event.position.selection)({
|
|
6207
|
+
...snapshot,
|
|
6208
|
+
context: {
|
|
6209
|
+
...snapshot.context,
|
|
6210
|
+
selection: dragOrigin.selection
|
|
6211
|
+
}
|
|
6212
|
+
}) : !1;
|
|
6213
|
+
},
|
|
6214
|
+
actions: []
|
|
6215
|
+
})
|
|
6216
|
+
], breakingAtTheEndOfTextBlock = behaviors_index.defineBehavior({
|
|
6217
|
+
on: "insert.break",
|
|
6218
|
+
guard: ({
|
|
6219
|
+
snapshot
|
|
6220
|
+
}) => {
|
|
6221
|
+
const focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot);
|
|
6222
|
+
if (!snapshot.context.selection || !focusTextBlock || !selectionCollapsed)
|
|
6223
|
+
return !1;
|
|
6224
|
+
const atTheEndOfBlock = selector_isSelectingEntireBlocks.isAtTheEndOfBlock(focusTextBlock)(snapshot), focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
|
|
6225
|
+
return atTheEndOfBlock ? {
|
|
6226
|
+
focusListItem,
|
|
6227
|
+
focusLevel
|
|
6228
|
+
} : !1;
|
|
6229
|
+
},
|
|
6230
|
+
actions: [({
|
|
6231
|
+
snapshot
|
|
6232
|
+
}, {
|
|
6233
|
+
focusListItem,
|
|
6234
|
+
focusLevel
|
|
6235
|
+
}) => [behaviors_index.raise({
|
|
6236
|
+
type: "insert.block",
|
|
6237
|
+
block: {
|
|
6238
|
+
_type: snapshot.context.schema.block.name,
|
|
6239
|
+
children: [{
|
|
6240
|
+
_type: snapshot.context.schema.span.name,
|
|
6241
|
+
text: "",
|
|
6242
|
+
marks: []
|
|
6243
|
+
}],
|
|
6244
|
+
markDefs: [],
|
|
6245
|
+
listItem: focusListItem,
|
|
6246
|
+
level: focusLevel,
|
|
6247
|
+
style: snapshot.context.schema.styles[0]?.name
|
|
6248
|
+
},
|
|
6249
|
+
placement: "after"
|
|
6250
|
+
})]]
|
|
6251
|
+
}), breakingAtTheStartOfTextBlock = behaviors_index.defineBehavior({
|
|
6252
|
+
on: "insert.break",
|
|
6253
|
+
guard: ({
|
|
6254
|
+
snapshot
|
|
6255
|
+
}) => {
|
|
6256
|
+
const focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot);
|
|
6257
|
+
if (!snapshot.context.selection || !focusTextBlock || !selectionCollapsed)
|
|
6258
|
+
return !1;
|
|
6259
|
+
const focusSpan = selector_isSelectingEntireBlocks.getFocusSpan(snapshot), focusDecorators = focusSpan?.node.marks?.filter((mark) => snapshot.context.schema.decorators.some((decorator) => decorator.name === mark) ?? []), focusAnnotations = focusSpan?.node.marks?.filter((mark) => !snapshot.context.schema.decorators.some((decorator) => decorator.name === mark)) ?? [], focusListItem = focusTextBlock.node.listItem, focusLevel = focusTextBlock.node.level;
|
|
6260
|
+
return selector_isSelectingEntireBlocks.isAtTheStartOfBlock(focusTextBlock)(snapshot) ? {
|
|
6261
|
+
focusAnnotations,
|
|
6262
|
+
focusDecorators,
|
|
6263
|
+
focusListItem,
|
|
6264
|
+
focusLevel
|
|
6265
|
+
} : !1;
|
|
6266
|
+
},
|
|
6267
|
+
actions: [({
|
|
6268
|
+
snapshot
|
|
6269
|
+
}, {
|
|
6270
|
+
focusAnnotations,
|
|
6271
|
+
focusDecorators,
|
|
6272
|
+
focusListItem,
|
|
6273
|
+
focusLevel
|
|
6274
|
+
}) => [behaviors_index.raise({
|
|
6275
|
+
type: "insert.block",
|
|
6276
|
+
block: {
|
|
6277
|
+
_type: snapshot.context.schema.block.name,
|
|
6278
|
+
children: [{
|
|
6279
|
+
_type: snapshot.context.schema.span.name,
|
|
6280
|
+
marks: focusAnnotations.length === 0 ? focusDecorators : [],
|
|
6281
|
+
text: ""
|
|
6282
|
+
}],
|
|
6283
|
+
listItem: focusListItem,
|
|
6284
|
+
level: focusLevel,
|
|
6285
|
+
style: snapshot.context.schema.styles[0]?.name
|
|
6286
|
+
},
|
|
6287
|
+
placement: "before",
|
|
6288
|
+
select: "none"
|
|
6289
|
+
})]]
|
|
6290
|
+
}), breakingEntireDocument = behaviors_index.defineBehavior({
|
|
6291
|
+
on: "insert.break",
|
|
6292
|
+
guard: ({
|
|
6293
|
+
snapshot
|
|
6294
|
+
}) => {
|
|
6295
|
+
if (!snapshot.context.selection || !selector_isSelectingEntireBlocks.isSelectionExpanded(snapshot))
|
|
6296
|
+
return !1;
|
|
6297
|
+
const firstBlock = selector_isSelectingEntireBlocks.getFirstBlock(snapshot), lastBlock = selector_isSelectingEntireBlocks.getLastBlock(snapshot);
|
|
6298
|
+
if (!firstBlock || !lastBlock)
|
|
6299
|
+
return !1;
|
|
6300
|
+
const firstBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
6301
|
+
context: snapshot.context,
|
|
6302
|
+
block: firstBlock
|
|
6303
|
+
}), selectionStartPoint = util_selectionPointToBlockOffset.getSelectionStartPoint(snapshot.context.selection), lastBlockEndPoint = util_sliceBlocks.getBlockEndPoint({
|
|
6304
|
+
context: snapshot.context,
|
|
6305
|
+
block: lastBlock
|
|
6306
|
+
}), selectionEndPoint = util_selectionPointToBlockOffset.getSelectionEndPoint(snapshot.context.selection);
|
|
6307
|
+
return util_sliceBlocks.isEqualSelectionPoints(firstBlockStartPoint, selectionStartPoint) && util_sliceBlocks.isEqualSelectionPoints(lastBlockEndPoint, selectionEndPoint) ? {
|
|
6308
|
+
selection: snapshot.context.selection
|
|
6309
|
+
} : !1;
|
|
6310
|
+
},
|
|
6311
|
+
actions: [(_, {
|
|
6312
|
+
selection
|
|
6313
|
+
}) => [behaviors_index.raise({
|
|
6314
|
+
type: "delete",
|
|
6315
|
+
at: selection
|
|
6316
|
+
})]]
|
|
6317
|
+
}), breakingEntireBlocks = behaviors_index.defineBehavior({
|
|
6318
|
+
on: "insert.break",
|
|
6319
|
+
guard: ({
|
|
6320
|
+
snapshot
|
|
6321
|
+
}) => {
|
|
6322
|
+
if (!snapshot.context.selection || !selector_isSelectingEntireBlocks.isSelectionExpanded(snapshot))
|
|
6323
|
+
return !1;
|
|
6324
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
6325
|
+
if (!selectionStartBlock || !selectionEndBlock)
|
|
6326
|
+
return !1;
|
|
6327
|
+
const startBlockStartPoint = util_sliceBlocks.getBlockStartPoint({
|
|
6328
|
+
context: snapshot.context,
|
|
6329
|
+
block: selectionStartBlock
|
|
6330
|
+
}), selectionStartPoint = util_selectionPointToBlockOffset.getSelectionStartPoint(snapshot.context.selection), endBlockEndPoint = util_sliceBlocks.getBlockEndPoint({
|
|
6331
|
+
context: snapshot.context,
|
|
6332
|
+
block: selectionEndBlock
|
|
6333
|
+
}), selectionEndPoint = util_selectionPointToBlockOffset.getSelectionEndPoint(snapshot.context.selection);
|
|
6334
|
+
return util_sliceBlocks.isEqualSelectionPoints(selectionStartPoint, startBlockStartPoint) && util_sliceBlocks.isEqualSelectionPoints(selectionEndPoint, endBlockEndPoint) ? {
|
|
6335
|
+
selectedBlocks
|
|
6336
|
+
} : !1;
|
|
6337
|
+
},
|
|
6338
|
+
actions: [({
|
|
6339
|
+
snapshot
|
|
6340
|
+
}, {
|
|
6341
|
+
selectedBlocks
|
|
6342
|
+
}) => [behaviors_index.raise({
|
|
6343
|
+
type: "insert.block",
|
|
6344
|
+
block: {
|
|
6345
|
+
_type: snapshot.context.schema.block.name,
|
|
6346
|
+
children: [{
|
|
6347
|
+
_type: snapshot.context.schema.span.name,
|
|
6348
|
+
text: "",
|
|
6349
|
+
marks: []
|
|
6350
|
+
}]
|
|
6351
|
+
},
|
|
6352
|
+
placement: "before",
|
|
6353
|
+
select: "start"
|
|
6354
|
+
}), ...selectedBlocks.map((block) => behaviors_index.raise({
|
|
6355
|
+
type: "delete.block",
|
|
6356
|
+
at: block.path
|
|
6357
|
+
}))]]
|
|
6358
|
+
}), coreInsertBreakBehaviors = {
|
|
6359
|
+
breakingAtTheEndOfTextBlock,
|
|
6360
|
+
breakingAtTheStartOfTextBlock,
|
|
6361
|
+
breakingEntireDocument,
|
|
6362
|
+
breakingEntireBlocks
|
|
6363
|
+
}, MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior({
|
|
6364
|
+
on: "delete.backward",
|
|
6365
|
+
guard: ({
|
|
6366
|
+
snapshot
|
|
6367
|
+
}) => {
|
|
6368
|
+
const selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot), focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot), focusSpan = selector_isSelectingEntireBlocks.getFocusSpan(snapshot);
|
|
6369
|
+
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
|
|
6370
|
+
focusTextBlock
|
|
6371
|
+
} : !1;
|
|
6372
|
+
},
|
|
6373
|
+
actions: [(_, {
|
|
6374
|
+
focusTextBlock
|
|
6375
|
+
}) => [behaviors_index.raise({
|
|
6376
|
+
type: "block.unset",
|
|
6377
|
+
props: ["listItem", "level"],
|
|
6378
|
+
at: focusTextBlock.path
|
|
6379
|
+
})]]
|
|
6380
|
+
}), unindentListOnBackspace = behaviors_index.defineBehavior({
|
|
6381
|
+
on: "delete.backward",
|
|
6382
|
+
guard: ({
|
|
6383
|
+
snapshot
|
|
6384
|
+
}) => {
|
|
6385
|
+
const selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot), focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot), focusSpan = selector_isSelectingEntireBlocks.getFocusSpan(snapshot);
|
|
6386
|
+
return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0 && focusTextBlock.node.level !== void 0 && focusTextBlock.node.level > 1 ? {
|
|
6387
|
+
focusTextBlock,
|
|
6388
|
+
level: focusTextBlock.node.level - 1
|
|
6389
|
+
} : !1;
|
|
6390
|
+
},
|
|
6391
|
+
actions: [(_, {
|
|
6392
|
+
focusTextBlock,
|
|
6393
|
+
level
|
|
6394
|
+
}) => [behaviors_index.raise({
|
|
6395
|
+
type: "block.set",
|
|
6396
|
+
props: {
|
|
6397
|
+
level
|
|
6398
|
+
},
|
|
6399
|
+
at: focusTextBlock.path
|
|
6400
|
+
})]]
|
|
6401
|
+
}), clearListOnEnter = behaviors_index.defineBehavior({
|
|
6402
|
+
on: "insert.break",
|
|
6403
|
+
guard: ({
|
|
6404
|
+
snapshot
|
|
6405
|
+
}) => {
|
|
6406
|
+
const selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot), focusListBlock = selector_isSelectingEntireBlocks.getFocusListBlock(snapshot);
|
|
6407
|
+
return !selectionCollapsed || !focusListBlock || !util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
|
|
6408
|
+
focusListBlock
|
|
6409
|
+
};
|
|
6410
|
+
},
|
|
6411
|
+
actions: [(_, {
|
|
6412
|
+
focusListBlock
|
|
6413
|
+
}) => [behaviors_index.raise({
|
|
6414
|
+
type: "block.unset",
|
|
6415
|
+
props: ["listItem", "level"],
|
|
6416
|
+
at: focusListBlock.path
|
|
6417
|
+
})]]
|
|
6418
|
+
}), indentListOnTab = behaviors_index.defineBehavior({
|
|
6419
|
+
on: "keyboard.keydown",
|
|
6420
|
+
guard: ({
|
|
6421
|
+
snapshot,
|
|
6422
|
+
event
|
|
6423
|
+
}) => {
|
|
6424
|
+
if (!isHotkey("Tab", event.originEvent))
|
|
6425
|
+
return !1;
|
|
6426
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_sliceBlocks.isListBlock(snapshot.context, block.node) ? [{
|
|
6427
|
+
node: block.node,
|
|
6428
|
+
path: block.path
|
|
6429
|
+
}] : []);
|
|
6430
|
+
return selectedListBlocks.length === selectedBlocks.length ? {
|
|
6431
|
+
selectedListBlocks
|
|
6432
|
+
} : !1;
|
|
6433
|
+
},
|
|
6434
|
+
actions: [(_, {
|
|
6435
|
+
selectedListBlocks
|
|
6436
|
+
}) => selectedListBlocks.map((selectedListBlock) => behaviors_index.raise({
|
|
6437
|
+
type: "block.set",
|
|
6438
|
+
props: {
|
|
6439
|
+
level: Math.min(MAX_LIST_LEVEL, Math.max(1, selectedListBlock.node.level + 1))
|
|
6440
|
+
},
|
|
6441
|
+
at: selectedListBlock.path
|
|
6442
|
+
}))]
|
|
6443
|
+
}), unindentListOnShiftTab = behaviors_index.defineBehavior({
|
|
6444
|
+
on: "keyboard.keydown",
|
|
6445
|
+
guard: ({
|
|
6446
|
+
snapshot,
|
|
6447
|
+
event
|
|
6448
|
+
}) => {
|
|
6449
|
+
if (!isHotkey("Shift+Tab", event.originEvent))
|
|
6450
|
+
return !1;
|
|
6451
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => util_sliceBlocks.isListBlock(snapshot.context, block.node) ? [{
|
|
6452
|
+
node: block.node,
|
|
6453
|
+
path: block.path
|
|
6454
|
+
}] : []);
|
|
6455
|
+
return selectedListBlocks.length === selectedBlocks.length ? {
|
|
6456
|
+
selectedListBlocks
|
|
6457
|
+
} : !1;
|
|
6458
|
+
},
|
|
6459
|
+
actions: [(_, {
|
|
6460
|
+
selectedListBlocks
|
|
6461
|
+
}) => selectedListBlocks.map((selectedListBlock) => behaviors_index.raise({
|
|
6462
|
+
type: "block.set",
|
|
6463
|
+
props: {
|
|
6464
|
+
level: Math.min(MAX_LIST_LEVEL, Math.max(1, selectedListBlock.node.level - 1))
|
|
6465
|
+
},
|
|
6466
|
+
at: selectedListBlock.path
|
|
6467
|
+
}))]
|
|
6468
|
+
}), coreListBehaviors = {
|
|
6469
|
+
clearListOnBackspace,
|
|
6470
|
+
unindentListOnBackspace,
|
|
6471
|
+
clearListOnEnter,
|
|
6472
|
+
indentListOnTab,
|
|
6473
|
+
unindentListOnShiftTab
|
|
6474
|
+
}, coreBehaviors = [coreAnnotationBehaviors.addAnnotationOnCollapsedSelection, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, ...coreDndBehaviors, coreBlockObjectBehaviors.clickingAboveLonelyBlockObject, coreBlockObjectBehaviors.clickingBelowLonelyBlockObject, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab, coreInsertBreakBehaviors.breakingAtTheEndOfTextBlock, coreInsertBreakBehaviors.breakingAtTheStartOfTextBlock, coreInsertBreakBehaviors.breakingEntireDocument, coreInsertBreakBehaviors.breakingEntireBlocks], abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
5815
6475
|
on: "annotation.toggle",
|
|
5816
6476
|
guard: ({
|
|
5817
6477
|
snapshot,
|
|
@@ -5819,11 +6479,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5819
6479
|
}) => selector_isSelectingEntireBlocks.isActiveAnnotation(event.annotation.name)(snapshot),
|
|
5820
6480
|
actions: [({
|
|
5821
6481
|
event
|
|
5822
|
-
}) => [
|
|
6482
|
+
}) => [behaviors_index.raise({
|
|
5823
6483
|
type: "annotation.remove",
|
|
5824
6484
|
annotation: event.annotation
|
|
5825
6485
|
})]]
|
|
5826
|
-
}),
|
|
6486
|
+
}), behaviors_index.defineBehavior({
|
|
5827
6487
|
on: "annotation.toggle",
|
|
5828
6488
|
guard: ({
|
|
5829
6489
|
snapshot,
|
|
@@ -5831,11 +6491,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5831
6491
|
}) => !selector_isSelectingEntireBlocks.isActiveAnnotation(event.annotation.name)(snapshot),
|
|
5832
6492
|
actions: [({
|
|
5833
6493
|
event
|
|
5834
|
-
}) => [
|
|
6494
|
+
}) => [behaviors_index.raise({
|
|
5835
6495
|
type: "annotation.add",
|
|
5836
6496
|
annotation: event.annotation
|
|
5837
6497
|
})]]
|
|
5838
|
-
})], abstractDecoratorBehaviors = [
|
|
6498
|
+
})], abstractDecoratorBehaviors = [behaviors_index.defineBehavior({
|
|
5839
6499
|
on: "decorator.toggle",
|
|
5840
6500
|
guard: ({
|
|
5841
6501
|
snapshot,
|
|
@@ -5843,11 +6503,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5843
6503
|
}) => selector_isSelectingEntireBlocks.isActiveDecorator(event.decorator)(snapshot),
|
|
5844
6504
|
actions: [({
|
|
5845
6505
|
event
|
|
5846
|
-
}) => [
|
|
6506
|
+
}) => [behaviors_index.raise({
|
|
5847
6507
|
type: "decorator.remove",
|
|
5848
6508
|
decorator: event.decorator
|
|
5849
6509
|
})]]
|
|
5850
|
-
}),
|
|
6510
|
+
}), behaviors_index.defineBehavior({
|
|
5851
6511
|
on: "decorator.toggle",
|
|
5852
6512
|
guard: ({
|
|
5853
6513
|
snapshot,
|
|
@@ -5867,11 +6527,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5867
6527
|
},
|
|
5868
6528
|
actions: [({
|
|
5869
6529
|
event
|
|
5870
|
-
}) => [
|
|
6530
|
+
}) => [behaviors_index.raise({
|
|
5871
6531
|
...event,
|
|
5872
6532
|
type: "decorator.add"
|
|
5873
6533
|
})]]
|
|
5874
|
-
})], abstractDeleteBehaviors = [
|
|
6534
|
+
})], abstractDeleteBehaviors = [behaviors_index.defineBehavior({
|
|
5875
6535
|
on: "delete.text",
|
|
5876
6536
|
guard: ({
|
|
5877
6537
|
snapshot,
|
|
@@ -5900,37 +6560,37 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5900
6560
|
},
|
|
5901
6561
|
actions: [(_, {
|
|
5902
6562
|
selection
|
|
5903
|
-
}) => [
|
|
6563
|
+
}) => [behaviors_index.raise({
|
|
5904
6564
|
type: "delete",
|
|
5905
6565
|
at: selection
|
|
5906
6566
|
})]]
|
|
5907
|
-
})], abstractInsertBehaviors = [
|
|
6567
|
+
})], abstractInsertBehaviors = [behaviors_index.defineBehavior({
|
|
5908
6568
|
on: "insert.blocks",
|
|
5909
6569
|
guard: ({
|
|
5910
6570
|
event
|
|
5911
6571
|
}) => event.placement === "before",
|
|
5912
6572
|
actions: [({
|
|
5913
6573
|
event
|
|
5914
|
-
}) => event.blocks.map((block, index) =>
|
|
6574
|
+
}) => event.blocks.map((block, index) => behaviors_index.raise({
|
|
5915
6575
|
type: "insert.block",
|
|
5916
6576
|
block,
|
|
5917
6577
|
placement: index === 0 ? "before" : "after",
|
|
5918
6578
|
select: "end"
|
|
5919
6579
|
}))]
|
|
5920
|
-
}),
|
|
6580
|
+
}), behaviors_index.defineBehavior({
|
|
5921
6581
|
on: "insert.blocks",
|
|
5922
6582
|
guard: ({
|
|
5923
6583
|
event
|
|
5924
6584
|
}) => event.placement === "after",
|
|
5925
6585
|
actions: [({
|
|
5926
6586
|
event
|
|
5927
|
-
}) => event.blocks.map((block) =>
|
|
6587
|
+
}) => event.blocks.map((block) => behaviors_index.raise({
|
|
5928
6588
|
type: "insert.block",
|
|
5929
6589
|
block,
|
|
5930
6590
|
placement: "after",
|
|
5931
6591
|
select: "end"
|
|
5932
6592
|
}))]
|
|
5933
|
-
}),
|
|
6593
|
+
}), behaviors_index.defineBehavior({
|
|
5934
6594
|
on: "insert.blocks",
|
|
5935
6595
|
guard: ({
|
|
5936
6596
|
snapshot,
|
|
@@ -5938,7 +6598,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5938
6598
|
}) => {
|
|
5939
6599
|
if (event.placement !== "auto")
|
|
5940
6600
|
return !1;
|
|
5941
|
-
const focusTextBlock =
|
|
6601
|
+
const focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot);
|
|
5942
6602
|
return focusTextBlock ? {
|
|
5943
6603
|
focusTextBlock
|
|
5944
6604
|
} : !1;
|
|
@@ -5948,66 +6608,66 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5948
6608
|
event
|
|
5949
6609
|
}, {
|
|
5950
6610
|
focusTextBlock
|
|
5951
|
-
}) => event.blocks.length === 1 ? [
|
|
6611
|
+
}) => event.blocks.length === 1 ? [behaviors_index.raise({
|
|
5952
6612
|
type: "insert.block",
|
|
5953
6613
|
block: event.blocks[0],
|
|
5954
6614
|
placement: "auto",
|
|
5955
6615
|
select: "end"
|
|
5956
|
-
})] : util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) =>
|
|
6616
|
+
})] : util_sliceBlocks.isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => behaviors_index.raise({
|
|
5957
6617
|
type: "insert.block",
|
|
5958
6618
|
block,
|
|
5959
6619
|
placement: index === 0 ? "auto" : "after",
|
|
5960
6620
|
select: "end"
|
|
5961
|
-
})) : event.blocks.flatMap((block, index) => index === 0 ? [
|
|
6621
|
+
})) : event.blocks.flatMap((block, index) => index === 0 ? [behaviors_index.raise({
|
|
5962
6622
|
type: "split"
|
|
5963
|
-
}),
|
|
6623
|
+
}), behaviors_index.raise({
|
|
5964
6624
|
type: "select.previous block",
|
|
5965
6625
|
select: "end"
|
|
5966
|
-
}),
|
|
6626
|
+
}), behaviors_index.raise({
|
|
5967
6627
|
type: "insert.block",
|
|
5968
6628
|
block,
|
|
5969
6629
|
placement: "auto",
|
|
5970
6630
|
select: "end"
|
|
5971
|
-
})] : index === event.blocks.length - 1 ? [
|
|
6631
|
+
})] : index === event.blocks.length - 1 ? [behaviors_index.raise({
|
|
5972
6632
|
type: "select.next block",
|
|
5973
6633
|
select: "start"
|
|
5974
|
-
}),
|
|
6634
|
+
}), behaviors_index.raise({
|
|
5975
6635
|
type: "insert.block",
|
|
5976
6636
|
block,
|
|
5977
6637
|
placement: "auto",
|
|
5978
6638
|
select: "end"
|
|
5979
|
-
})] : [
|
|
6639
|
+
})] : [behaviors_index.raise({
|
|
5980
6640
|
type: "insert.block",
|
|
5981
6641
|
block,
|
|
5982
6642
|
placement: "after",
|
|
5983
6643
|
select: "end"
|
|
5984
6644
|
})])]
|
|
5985
|
-
}),
|
|
6645
|
+
}), behaviors_index.defineBehavior({
|
|
5986
6646
|
on: "insert.blocks",
|
|
5987
6647
|
guard: ({
|
|
5988
6648
|
event
|
|
5989
6649
|
}) => event.placement === "auto",
|
|
5990
6650
|
actions: [({
|
|
5991
6651
|
event
|
|
5992
|
-
}) => event.blocks.map((block, index) =>
|
|
6652
|
+
}) => event.blocks.map((block, index) => behaviors_index.raise({
|
|
5993
6653
|
type: "insert.block",
|
|
5994
6654
|
block,
|
|
5995
6655
|
placement: index === 0 ? "auto" : "after",
|
|
5996
6656
|
select: "end"
|
|
5997
6657
|
}))]
|
|
5998
|
-
}),
|
|
6658
|
+
}), behaviors_index.defineBehavior({
|
|
5999
6659
|
on: "insert.break",
|
|
6000
|
-
actions: [() => [
|
|
6660
|
+
actions: [() => [behaviors_index.raise({
|
|
6001
6661
|
type: "split"
|
|
6002
6662
|
})]]
|
|
6003
|
-
}),
|
|
6663
|
+
}), behaviors_index.defineBehavior({
|
|
6004
6664
|
on: "insert.soft break",
|
|
6005
|
-
actions: [() => [
|
|
6665
|
+
actions: [() => [behaviors_index.raise({
|
|
6006
6666
|
type: "insert.text",
|
|
6007
6667
|
text: `
|
|
6008
6668
|
`
|
|
6009
6669
|
})]]
|
|
6010
|
-
})], abstractListItemBehaviors = [
|
|
6670
|
+
})], abstractListItemBehaviors = [behaviors_index.defineBehavior({
|
|
6011
6671
|
on: "list item.add",
|
|
6012
6672
|
guard: ({
|
|
6013
6673
|
snapshot
|
|
@@ -6018,7 +6678,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6018
6678
|
event
|
|
6019
6679
|
}, {
|
|
6020
6680
|
selectedTextBlocks
|
|
6021
|
-
}) => selectedTextBlocks.map((block) =>
|
|
6681
|
+
}) => selectedTextBlocks.map((block) => behaviors_index.raise({
|
|
6022
6682
|
type: "block.set",
|
|
6023
6683
|
at: block.path,
|
|
6024
6684
|
props: {
|
|
@@ -6026,7 +6686,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6026
6686
|
listItem: event.listItem
|
|
6027
6687
|
}
|
|
6028
6688
|
}))]
|
|
6029
|
-
}),
|
|
6689
|
+
}), behaviors_index.defineBehavior({
|
|
6030
6690
|
on: "list item.remove",
|
|
6031
6691
|
guard: ({
|
|
6032
6692
|
snapshot
|
|
@@ -6035,12 +6695,12 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6035
6695
|
}),
|
|
6036
6696
|
actions: [(_, {
|
|
6037
6697
|
selectedTextBlocks
|
|
6038
|
-
}) => selectedTextBlocks.map((block) =>
|
|
6698
|
+
}) => selectedTextBlocks.map((block) => behaviors_index.raise({
|
|
6039
6699
|
type: "block.unset",
|
|
6040
6700
|
at: block.path,
|
|
6041
6701
|
props: ["level", "listItem"]
|
|
6042
6702
|
}))]
|
|
6043
|
-
}),
|
|
6703
|
+
}), behaviors_index.defineBehavior({
|
|
6044
6704
|
on: "list item.toggle",
|
|
6045
6705
|
guard: ({
|
|
6046
6706
|
snapshot,
|
|
@@ -6048,11 +6708,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6048
6708
|
}) => selector_isSelectingEntireBlocks.isActiveListItem(event.listItem)(snapshot),
|
|
6049
6709
|
actions: [({
|
|
6050
6710
|
event
|
|
6051
|
-
}) => [
|
|
6711
|
+
}) => [behaviors_index.raise({
|
|
6052
6712
|
type: "list item.remove",
|
|
6053
6713
|
listItem: event.listItem
|
|
6054
6714
|
})]]
|
|
6055
|
-
}),
|
|
6715
|
+
}), behaviors_index.defineBehavior({
|
|
6056
6716
|
on: "list item.toggle",
|
|
6057
6717
|
guard: ({
|
|
6058
6718
|
snapshot,
|
|
@@ -6060,17 +6720,17 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6060
6720
|
}) => !selector_isSelectingEntireBlocks.isActiveListItem(event.listItem)(snapshot),
|
|
6061
6721
|
actions: [({
|
|
6062
6722
|
event
|
|
6063
|
-
}) => [
|
|
6723
|
+
}) => [behaviors_index.raise({
|
|
6064
6724
|
type: "list item.add",
|
|
6065
6725
|
listItem: event.listItem
|
|
6066
6726
|
})]]
|
|
6067
|
-
})], abstractMoveBehaviors = [
|
|
6727
|
+
})], abstractMoveBehaviors = [behaviors_index.defineBehavior({
|
|
6068
6728
|
on: "move.block up",
|
|
6069
6729
|
guard: ({
|
|
6070
6730
|
snapshot,
|
|
6071
6731
|
event
|
|
6072
6732
|
}) => {
|
|
6073
|
-
const previousBlock =
|
|
6733
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock({
|
|
6074
6734
|
context: {
|
|
6075
6735
|
...snapshot.context,
|
|
6076
6736
|
selection: {
|
|
@@ -6093,18 +6753,18 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6093
6753
|
event
|
|
6094
6754
|
}, {
|
|
6095
6755
|
previousBlock
|
|
6096
|
-
}) => [
|
|
6756
|
+
}) => [behaviors_index.raise({
|
|
6097
6757
|
type: "move.block",
|
|
6098
6758
|
at: event.at,
|
|
6099
6759
|
to: previousBlock.path
|
|
6100
6760
|
})]]
|
|
6101
|
-
}),
|
|
6761
|
+
}), behaviors_index.defineBehavior({
|
|
6102
6762
|
on: "move.block down",
|
|
6103
6763
|
guard: ({
|
|
6104
6764
|
snapshot,
|
|
6105
6765
|
event
|
|
6106
6766
|
}) => {
|
|
6107
|
-
const nextBlock =
|
|
6767
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock({
|
|
6108
6768
|
context: {
|
|
6109
6769
|
...snapshot.context,
|
|
6110
6770
|
selection: {
|
|
@@ -6127,18 +6787,18 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6127
6787
|
event
|
|
6128
6788
|
}, {
|
|
6129
6789
|
nextBlock
|
|
6130
|
-
}) => [
|
|
6790
|
+
}) => [behaviors_index.raise({
|
|
6131
6791
|
type: "move.block",
|
|
6132
6792
|
at: event.at,
|
|
6133
6793
|
to: nextBlock.path
|
|
6134
6794
|
})]]
|
|
6135
|
-
})], abstractSelectBehaviors = [
|
|
6795
|
+
})], abstractSelectBehaviors = [behaviors_index.defineBehavior({
|
|
6136
6796
|
on: "select.previous block",
|
|
6137
6797
|
guard: ({
|
|
6138
6798
|
snapshot,
|
|
6139
6799
|
event
|
|
6140
6800
|
}) => {
|
|
6141
|
-
const previousBlock =
|
|
6801
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
6142
6802
|
if (!previousBlock)
|
|
6143
6803
|
return !1;
|
|
6144
6804
|
const point = event.select === "end" ? util_sliceBlocks.getBlockEndPoint({
|
|
@@ -6157,17 +6817,17 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6157
6817
|
},
|
|
6158
6818
|
actions: [(_, {
|
|
6159
6819
|
selection
|
|
6160
|
-
}) => [
|
|
6820
|
+
}) => [behaviors_index.raise({
|
|
6161
6821
|
type: "select",
|
|
6162
6822
|
at: selection
|
|
6163
6823
|
})]]
|
|
6164
|
-
}),
|
|
6824
|
+
}), behaviors_index.defineBehavior({
|
|
6165
6825
|
on: "select.next block",
|
|
6166
6826
|
guard: ({
|
|
6167
6827
|
snapshot,
|
|
6168
6828
|
event
|
|
6169
6829
|
}) => {
|
|
6170
|
-
const nextBlock =
|
|
6830
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
6171
6831
|
if (!nextBlock)
|
|
6172
6832
|
return !1;
|
|
6173
6833
|
const point = event.select === "end" ? util_sliceBlocks.getBlockEndPoint({
|
|
@@ -6186,18 +6846,18 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6186
6846
|
},
|
|
6187
6847
|
actions: [(_, {
|
|
6188
6848
|
selection
|
|
6189
|
-
}) => [
|
|
6849
|
+
}) => [behaviors_index.raise({
|
|
6190
6850
|
type: "select",
|
|
6191
6851
|
at: selection
|
|
6192
6852
|
})]]
|
|
6193
|
-
})], abstractSplitBehaviors = [
|
|
6853
|
+
})], abstractSplitBehaviors = [behaviors_index.defineBehavior({
|
|
6194
6854
|
on: "split",
|
|
6195
6855
|
guard: ({
|
|
6196
6856
|
snapshot
|
|
6197
6857
|
}) => {
|
|
6198
6858
|
if (!snapshot.context.selection)
|
|
6199
6859
|
return !1;
|
|
6200
|
-
const selectionStartPoint =
|
|
6860
|
+
const selectionStartPoint = util_selectionPointToBlockOffset.getSelectionStartPoint(snapshot.context.selection), selectionEndPoint = util_selectionPointToBlockOffset.getSelectionEndPoint(snapshot.context.selection), focusTextBlock = selector_isSelectingEntireBlocks.getFocusTextBlock({
|
|
6201
6861
|
context: {
|
|
6202
6862
|
...snapshot.context,
|
|
6203
6863
|
selection: {
|
|
@@ -6235,7 +6895,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6235
6895
|
}
|
|
6236
6896
|
};
|
|
6237
6897
|
}
|
|
6238
|
-
if (
|
|
6898
|
+
if (selector_isSelectingEntireBlocks.getFocusBlockObject({
|
|
6239
6899
|
context: {
|
|
6240
6900
|
...snapshot.context,
|
|
6241
6901
|
selection: {
|
|
@@ -6268,16 +6928,16 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6268
6928
|
actions: [(_, {
|
|
6269
6929
|
newTextBlock,
|
|
6270
6930
|
selection
|
|
6271
|
-
}) => [
|
|
6931
|
+
}) => [behaviors_index.raise({
|
|
6272
6932
|
type: "delete",
|
|
6273
6933
|
at: selection
|
|
6274
|
-
}),
|
|
6934
|
+
}), behaviors_index.raise({
|
|
6275
6935
|
type: "insert.block",
|
|
6276
6936
|
block: newTextBlock,
|
|
6277
6937
|
placement: "after",
|
|
6278
6938
|
select: "start"
|
|
6279
6939
|
})]]
|
|
6280
|
-
})], abstractStyleBehaviors = [
|
|
6940
|
+
})], abstractStyleBehaviors = [behaviors_index.defineBehavior({
|
|
6281
6941
|
on: "style.add",
|
|
6282
6942
|
guard: ({
|
|
6283
6943
|
snapshot
|
|
@@ -6288,14 +6948,14 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6288
6948
|
event
|
|
6289
6949
|
}, {
|
|
6290
6950
|
selectedTextBlocks
|
|
6291
|
-
}) => selectedTextBlocks.map((block) =>
|
|
6951
|
+
}) => selectedTextBlocks.map((block) => behaviors_index.raise({
|
|
6292
6952
|
type: "block.set",
|
|
6293
6953
|
at: block.path,
|
|
6294
6954
|
props: {
|
|
6295
6955
|
style: event.style
|
|
6296
6956
|
}
|
|
6297
6957
|
}))]
|
|
6298
|
-
}),
|
|
6958
|
+
}), behaviors_index.defineBehavior({
|
|
6299
6959
|
on: "style.remove",
|
|
6300
6960
|
guard: ({
|
|
6301
6961
|
snapshot
|
|
@@ -6304,12 +6964,12 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6304
6964
|
}),
|
|
6305
6965
|
actions: [(_, {
|
|
6306
6966
|
selectedTextBlocks
|
|
6307
|
-
}) => selectedTextBlocks.map((block) =>
|
|
6967
|
+
}) => selectedTextBlocks.map((block) => behaviors_index.raise({
|
|
6308
6968
|
type: "block.unset",
|
|
6309
6969
|
at: block.path,
|
|
6310
6970
|
props: ["style"]
|
|
6311
6971
|
}))]
|
|
6312
|
-
}),
|
|
6972
|
+
}), behaviors_index.defineBehavior({
|
|
6313
6973
|
on: "style.toggle",
|
|
6314
6974
|
guard: ({
|
|
6315
6975
|
snapshot,
|
|
@@ -6317,11 +6977,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6317
6977
|
}) => selector_isSelectingEntireBlocks.isActiveStyle(event.style)(snapshot),
|
|
6318
6978
|
actions: [({
|
|
6319
6979
|
event
|
|
6320
|
-
}) => [
|
|
6980
|
+
}) => [behaviors_index.raise({
|
|
6321
6981
|
type: "style.remove",
|
|
6322
6982
|
style: event.style
|
|
6323
6983
|
})]]
|
|
6324
|
-
}),
|
|
6984
|
+
}), behaviors_index.defineBehavior({
|
|
6325
6985
|
on: "style.toggle",
|
|
6326
6986
|
guard: ({
|
|
6327
6987
|
snapshot,
|
|
@@ -6329,21 +6989,21 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6329
6989
|
}) => !selector_isSelectingEntireBlocks.isActiveStyle(event.style)(snapshot),
|
|
6330
6990
|
actions: [({
|
|
6331
6991
|
event
|
|
6332
|
-
}) => [
|
|
6992
|
+
}) => [behaviors_index.raise({
|
|
6333
6993
|
type: "style.add",
|
|
6334
6994
|
style: event.style
|
|
6335
6995
|
})]]
|
|
6336
6996
|
})], keyIs = {
|
|
6337
6997
|
lineBreak: (event) => event.key === "Enter" && event.shiftKey
|
|
6338
|
-
}, raiseInsertSoftBreak =
|
|
6998
|
+
}, raiseInsertSoftBreak = behaviors_index.defineBehavior({
|
|
6339
6999
|
on: "keyboard.keydown",
|
|
6340
7000
|
guard: ({
|
|
6341
7001
|
event
|
|
6342
7002
|
}) => keyIs.lineBreak(event.originEvent),
|
|
6343
|
-
actions: [() => [
|
|
7003
|
+
actions: [() => [behaviors_index.raise({
|
|
6344
7004
|
type: "insert.soft break"
|
|
6345
7005
|
})]]
|
|
6346
|
-
}), raiseDeserializationSuccessOrFailure =
|
|
7006
|
+
}), raiseDeserializationSuccessOrFailure = behaviors_index.defineBehavior({
|
|
6347
7007
|
on: "deserialize",
|
|
6348
7008
|
guard: ({
|
|
6349
7009
|
snapshot,
|
|
@@ -6376,11 +7036,11 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6376
7036
|
},
|
|
6377
7037
|
actions: [({
|
|
6378
7038
|
event
|
|
6379
|
-
}, deserializeEvent) => [
|
|
7039
|
+
}, deserializeEvent) => [behaviors_index.raise({
|
|
6380
7040
|
...deserializeEvent,
|
|
6381
7041
|
originEvent: event.originEvent
|
|
6382
7042
|
})]]
|
|
6383
|
-
}), raiseSerializationSuccessOrFailure =
|
|
7043
|
+
}), raiseSerializationSuccessOrFailure = behaviors_index.defineBehavior({
|
|
6384
7044
|
on: "serialize",
|
|
6385
7045
|
guard: ({
|
|
6386
7046
|
snapshot,
|
|
@@ -6399,41 +7059,41 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6399
7059
|
},
|
|
6400
7060
|
actions: [({
|
|
6401
7061
|
event
|
|
6402
|
-
}, serializeEvents) => serializeEvents.map((serializeEvent) =>
|
|
7062
|
+
}, serializeEvents) => serializeEvents.map((serializeEvent) => behaviors_index.raise({
|
|
6403
7063
|
...serializeEvent,
|
|
6404
7064
|
originEvent: event.originEvent
|
|
6405
7065
|
}))]
|
|
6406
7066
|
}), defaultBehaviors = [
|
|
6407
|
-
|
|
7067
|
+
behaviors_index.defineBehavior({
|
|
6408
7068
|
on: "clipboard.copy",
|
|
6409
7069
|
guard: ({
|
|
6410
7070
|
snapshot
|
|
6411
7071
|
}) => {
|
|
6412
|
-
const focusSpan =
|
|
7072
|
+
const focusSpan = selector_isSelectingEntireBlocks.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot);
|
|
6413
7073
|
return focusSpan && selectionCollapsed;
|
|
6414
7074
|
},
|
|
6415
7075
|
actions: []
|
|
6416
7076
|
}),
|
|
6417
|
-
|
|
7077
|
+
behaviors_index.defineBehavior({
|
|
6418
7078
|
on: "clipboard.copy",
|
|
6419
7079
|
actions: [({
|
|
6420
7080
|
event
|
|
6421
|
-
}) => [
|
|
7081
|
+
}) => [behaviors_index.raise({
|
|
6422
7082
|
type: "serialize",
|
|
6423
7083
|
originEvent: event
|
|
6424
7084
|
})]]
|
|
6425
7085
|
}),
|
|
6426
|
-
|
|
7086
|
+
behaviors_index.defineBehavior({
|
|
6427
7087
|
on: "clipboard.cut",
|
|
6428
7088
|
guard: ({
|
|
6429
7089
|
snapshot
|
|
6430
7090
|
}) => {
|
|
6431
|
-
const focusSpan =
|
|
7091
|
+
const focusSpan = selector_isSelectingEntireBlocks.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectingEntireBlocks.isSelectionCollapsed(snapshot);
|
|
6432
7092
|
return focusSpan && selectionCollapsed;
|
|
6433
7093
|
},
|
|
6434
7094
|
actions: []
|
|
6435
7095
|
}),
|
|
6436
|
-
|
|
7096
|
+
behaviors_index.defineBehavior({
|
|
6437
7097
|
on: "clipboard.cut",
|
|
6438
7098
|
guard: ({
|
|
6439
7099
|
snapshot
|
|
@@ -6444,24 +7104,24 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6444
7104
|
event
|
|
6445
7105
|
}, {
|
|
6446
7106
|
selection
|
|
6447
|
-
}) => [
|
|
7107
|
+
}) => [behaviors_index.raise({
|
|
6448
7108
|
type: "serialize",
|
|
6449
7109
|
originEvent: event
|
|
6450
|
-
}),
|
|
7110
|
+
}), behaviors_index.raise({
|
|
6451
7111
|
type: "delete",
|
|
6452
7112
|
at: selection
|
|
6453
7113
|
})]]
|
|
6454
7114
|
}),
|
|
6455
|
-
|
|
7115
|
+
behaviors_index.defineBehavior({
|
|
6456
7116
|
on: "drag.dragstart",
|
|
6457
7117
|
actions: [({
|
|
6458
7118
|
event
|
|
6459
|
-
}) => [
|
|
7119
|
+
}) => [behaviors_index.raise({
|
|
6460
7120
|
type: "serialize",
|
|
6461
7121
|
originEvent: event
|
|
6462
7122
|
})]]
|
|
6463
7123
|
}),
|
|
6464
|
-
|
|
7124
|
+
behaviors_index.defineBehavior({
|
|
6465
7125
|
on: "serialization.success",
|
|
6466
7126
|
actions: [({
|
|
6467
7127
|
event
|
|
@@ -6472,7 +7132,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6472
7132
|
}
|
|
6473
7133
|
}]]
|
|
6474
7134
|
}),
|
|
6475
|
-
|
|
7135
|
+
behaviors_index.defineBehavior({
|
|
6476
7136
|
on: "serialization.failure",
|
|
6477
7137
|
actions: [({
|
|
6478
7138
|
event
|
|
@@ -6483,14 +7143,14 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6483
7143
|
}
|
|
6484
7144
|
}]]
|
|
6485
7145
|
}),
|
|
6486
|
-
|
|
7146
|
+
behaviors_index.defineBehavior({
|
|
6487
7147
|
on: "drag.drop",
|
|
6488
7148
|
guard: ({
|
|
6489
7149
|
snapshot,
|
|
6490
7150
|
event
|
|
6491
7151
|
}) => {
|
|
6492
7152
|
const dragOrigin = snapshot.beta.internalDrag?.origin, dropPosition = event.position.selection;
|
|
6493
|
-
return dragOrigin ?
|
|
7153
|
+
return dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(dropPosition)({
|
|
6494
7154
|
...snapshot,
|
|
6495
7155
|
context: {
|
|
6496
7156
|
...snapshot.context,
|
|
@@ -6500,19 +7160,19 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6500
7160
|
},
|
|
6501
7161
|
actions: []
|
|
6502
7162
|
}),
|
|
6503
|
-
|
|
7163
|
+
behaviors_index.defineBehavior({
|
|
6504
7164
|
on: "drag.drop",
|
|
6505
7165
|
actions: [({
|
|
6506
7166
|
event
|
|
6507
|
-
}) => [
|
|
7167
|
+
}) => [behaviors_index.raise({
|
|
6508
7168
|
type: "select",
|
|
6509
7169
|
at: event.position.selection
|
|
6510
|
-
}),
|
|
7170
|
+
}), behaviors_index.raise({
|
|
6511
7171
|
type: "deserialize",
|
|
6512
7172
|
originEvent: event
|
|
6513
7173
|
})]]
|
|
6514
7174
|
}),
|
|
6515
|
-
|
|
7175
|
+
behaviors_index.defineBehavior({
|
|
6516
7176
|
on: "deserialization.success",
|
|
6517
7177
|
guard: ({
|
|
6518
7178
|
snapshot,
|
|
@@ -6520,7 +7180,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6520
7180
|
}) => {
|
|
6521
7181
|
if (event.originEvent.type !== "drag.drop" || snapshot.beta.internalDrag === void 0)
|
|
6522
7182
|
return !1;
|
|
6523
|
-
const dragOrigin = snapshot.beta.internalDrag.origin, dropPosition = event.originEvent.position.selection, droppingOnDragOrigin = dragOrigin ?
|
|
7183
|
+
const dragOrigin = snapshot.beta.internalDrag.origin, dropPosition = event.originEvent.position.selection, droppingOnDragOrigin = dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(dropPosition)({
|
|
6524
7184
|
...snapshot,
|
|
6525
7185
|
context: {
|
|
6526
7186
|
...snapshot.context,
|
|
@@ -6531,7 +7191,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6531
7191
|
...snapshot.context,
|
|
6532
7192
|
selection: dragOrigin.selection
|
|
6533
7193
|
}
|
|
6534
|
-
}), draggedBlocks =
|
|
7194
|
+
}), draggedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks({
|
|
6535
7195
|
context: {
|
|
6536
7196
|
...snapshot.context,
|
|
6537
7197
|
selection: dragOrigin.selection
|
|
@@ -6551,13 +7211,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6551
7211
|
draggedBlocks,
|
|
6552
7212
|
dragOrigin,
|
|
6553
7213
|
originEvent
|
|
6554
|
-
}) => [...draggingEntireBlocks ? draggedBlocks.map((block) =>
|
|
7214
|
+
}) => [...draggingEntireBlocks ? draggedBlocks.map((block) => behaviors_index.raise({
|
|
6555
7215
|
type: "delete.block",
|
|
6556
7216
|
at: block.path
|
|
6557
|
-
})) : [
|
|
7217
|
+
})) : [behaviors_index.raise({
|
|
6558
7218
|
type: "delete",
|
|
6559
7219
|
at: dragOrigin.selection
|
|
6560
|
-
})],
|
|
7220
|
+
})], behaviors_index.raise({
|
|
6561
7221
|
type: "insert.blocks",
|
|
6562
7222
|
blocks: event.data,
|
|
6563
7223
|
placement: draggingEntireBlocks ? originEvent.position.block === "start" ? "before" : originEvent.position.block === "end" ? "after" : "auto" : "auto"
|
|
@@ -6568,13 +7228,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6568
7228
|
* assume that the intended behavior is that the pasted text inherits
|
|
6569
7229
|
* formatting from the text it's pasted into.
|
|
6570
7230
|
*/
|
|
6571
|
-
|
|
7231
|
+
behaviors_index.defineBehavior({
|
|
6572
7232
|
on: "deserialization.success",
|
|
6573
7233
|
guard: ({
|
|
6574
7234
|
snapshot,
|
|
6575
7235
|
event
|
|
6576
7236
|
}) => {
|
|
6577
|
-
if (
|
|
7237
|
+
if (selector_isSelectingEntireBlocks.getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
|
|
6578
7238
|
const activeDecorators = snapshot.context.activeDecorators;
|
|
6579
7239
|
return {
|
|
6580
7240
|
activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
|
|
@@ -6588,7 +7248,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6588
7248
|
activeAnnotations,
|
|
6589
7249
|
activeDecorators,
|
|
6590
7250
|
textRuns
|
|
6591
|
-
}) => textRuns.flatMap((textRun, index) => index !== textRuns.length - 1 ? [
|
|
7251
|
+
}) => textRuns.flatMap((textRun, index) => index !== textRuns.length - 1 ? [behaviors_index.raise({
|
|
6592
7252
|
type: "insert.span",
|
|
6593
7253
|
text: textRun,
|
|
6594
7254
|
decorators: activeDecorators,
|
|
@@ -6600,9 +7260,9 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6600
7260
|
name: _type,
|
|
6601
7261
|
value
|
|
6602
7262
|
}))
|
|
6603
|
-
}),
|
|
7263
|
+
}), behaviors_index.raise({
|
|
6604
7264
|
type: "insert.break"
|
|
6605
|
-
})] : [
|
|
7265
|
+
})] : [behaviors_index.raise({
|
|
6606
7266
|
type: "insert.span",
|
|
6607
7267
|
text: textRun,
|
|
6608
7268
|
decorators: activeDecorators,
|
|
@@ -6616,17 +7276,17 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6616
7276
|
}))
|
|
6617
7277
|
})])]
|
|
6618
7278
|
}),
|
|
6619
|
-
|
|
7279
|
+
behaviors_index.defineBehavior({
|
|
6620
7280
|
on: "deserialization.success",
|
|
6621
7281
|
actions: [({
|
|
6622
7282
|
event
|
|
6623
|
-
}) => [
|
|
7283
|
+
}) => [behaviors_index.raise({
|
|
6624
7284
|
type: "insert.blocks",
|
|
6625
7285
|
blocks: event.data,
|
|
6626
7286
|
placement: "auto"
|
|
6627
7287
|
})]]
|
|
6628
7288
|
}),
|
|
6629
|
-
|
|
7289
|
+
behaviors_index.defineBehavior({
|
|
6630
7290
|
on: "deserialization.failure",
|
|
6631
7291
|
actions: [({
|
|
6632
7292
|
event
|
|
@@ -6637,39 +7297,39 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6637
7297
|
}
|
|
6638
7298
|
}]]
|
|
6639
7299
|
}),
|
|
6640
|
-
|
|
7300
|
+
behaviors_index.defineBehavior({
|
|
6641
7301
|
on: "clipboard.paste",
|
|
6642
7302
|
guard: ({
|
|
6643
7303
|
snapshot
|
|
6644
|
-
}) => snapshot.context.selection &&
|
|
7304
|
+
}) => snapshot.context.selection && selector_isSelectingEntireBlocks.isSelectionExpanded(snapshot) ? {
|
|
6645
7305
|
selection: snapshot.context.selection
|
|
6646
7306
|
} : !1,
|
|
6647
7307
|
actions: [({
|
|
6648
7308
|
event
|
|
6649
7309
|
}, {
|
|
6650
7310
|
selection
|
|
6651
|
-
}) => [
|
|
7311
|
+
}) => [behaviors_index.raise({
|
|
6652
7312
|
type: "delete",
|
|
6653
7313
|
at: selection
|
|
6654
|
-
}),
|
|
7314
|
+
}), behaviors_index.raise({
|
|
6655
7315
|
type: "deserialize",
|
|
6656
7316
|
originEvent: event
|
|
6657
7317
|
})]]
|
|
6658
7318
|
}),
|
|
6659
|
-
|
|
7319
|
+
behaviors_index.defineBehavior({
|
|
6660
7320
|
on: "clipboard.paste",
|
|
6661
7321
|
actions: [({
|
|
6662
7322
|
event
|
|
6663
|
-
}) => [
|
|
7323
|
+
}) => [behaviors_index.raise({
|
|
6664
7324
|
type: "deserialize",
|
|
6665
7325
|
originEvent: event
|
|
6666
7326
|
})]]
|
|
6667
7327
|
}),
|
|
6668
|
-
|
|
7328
|
+
behaviors_index.defineBehavior({
|
|
6669
7329
|
on: "input.*",
|
|
6670
7330
|
actions: [({
|
|
6671
7331
|
event
|
|
6672
|
-
}) => [
|
|
7332
|
+
}) => [behaviors_index.raise({
|
|
6673
7333
|
type: "deserialize",
|
|
6674
7334
|
originEvent: event
|
|
6675
7335
|
})]]
|
|
@@ -6746,10 +7406,15 @@ function performEvent({
|
|
|
6746
7406
|
let nativeEventPrevented = !1, defaultBehaviorOverwritten = !1, eventBehaviorIndex = -1;
|
|
6747
7407
|
for (const eventBehavior of eventBehaviors) {
|
|
6748
7408
|
eventBehaviorIndex++;
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
7409
|
+
let shouldRun = !1;
|
|
7410
|
+
try {
|
|
7411
|
+
shouldRun = eventBehavior.guard === void 0 || eventBehavior.guard({
|
|
7412
|
+
snapshot: guardSnapshot,
|
|
7413
|
+
event
|
|
7414
|
+
});
|
|
7415
|
+
} catch (error) {
|
|
7416
|
+
console.error(new Error(`Evaluating guard for "${event.type}" failed due to: ${error.message}`));
|
|
7417
|
+
}
|
|
6753
7418
|
if (shouldRun) {
|
|
6754
7419
|
defaultBehaviorOverwritten = !0;
|
|
6755
7420
|
for (const actionSet of eventBehavior.actions) {
|
|
@@ -6939,11 +7604,6 @@ const editorMachine = xstate.setup({
|
|
|
6939
7604
|
event
|
|
6940
7605
|
}) => (xstate.assertEvent(event, "remove behavior"), context.behaviors.delete(event.behavior), /* @__PURE__ */ new Set([...context.behaviors]))
|
|
6941
7606
|
}),
|
|
6942
|
-
"assign behaviors": xstate.assign({
|
|
6943
|
-
behaviors: ({
|
|
6944
|
-
event
|
|
6945
|
-
}) => (xstate.assertEvent(event, "update behaviors"), /* @__PURE__ */ new Set([...event.behaviors]))
|
|
6946
|
-
}),
|
|
6947
7607
|
"assign schema": xstate.assign({
|
|
6948
7608
|
schema: ({
|
|
6949
7609
|
event
|
|
@@ -7067,7 +7727,7 @@ const editorMachine = xstate.setup({
|
|
|
7067
7727
|
context: ({
|
|
7068
7728
|
input
|
|
7069
7729
|
}) => ({
|
|
7070
|
-
behaviors: /* @__PURE__ */ new Set([...
|
|
7730
|
+
behaviors: /* @__PURE__ */ new Set([...coreBehaviors]),
|
|
7071
7731
|
converters: new Set(input.converters ?? []),
|
|
7072
7732
|
getLegacySchema: input.getLegacySchema,
|
|
7073
7733
|
keyGenerator: input.keyGenerator,
|
|
@@ -7156,9 +7816,6 @@ const editorMachine = xstate.setup({
|
|
|
7156
7816
|
"remove behavior": {
|
|
7157
7817
|
actions: "remove behavior from context"
|
|
7158
7818
|
},
|
|
7159
|
-
"update behaviors": {
|
|
7160
|
-
actions: "assign behaviors"
|
|
7161
|
-
},
|
|
7162
7819
|
"update key generator": {
|
|
7163
7820
|
actions: xstate.assign({
|
|
7164
7821
|
keyGenerator: ({
|
|
@@ -7988,6 +8645,7 @@ exports.EditorActorContext = EditorActorContext;
|
|
|
7988
8645
|
exports.EditorProvider = EditorProvider;
|
|
7989
8646
|
exports.KEY_TO_VALUE_ELEMENT = KEY_TO_VALUE_ELEMENT;
|
|
7990
8647
|
exports.PortableTextEditor = PortableTextEditor;
|
|
8648
|
+
exports.coreBehaviors = coreBehaviors;
|
|
7991
8649
|
exports.debugWithName = debugWithName;
|
|
7992
8650
|
exports.defaultKeyGenerator = defaultKeyGenerator;
|
|
7993
8651
|
exports.defineSchema = defineSchema;
|
|
@@ -7997,6 +8655,7 @@ exports.getFirstBlock = getFirstBlock;
|
|
|
7997
8655
|
exports.getLastBlock = getLastBlock;
|
|
7998
8656
|
exports.getNodeBlock = getNodeBlock;
|
|
7999
8657
|
exports.isEqualToEmptyEditor = isEqualToEmptyEditor;
|
|
8658
|
+
exports.isHotkey = isHotkey;
|
|
8000
8659
|
exports.moveRangeByOperation = moveRangeByOperation;
|
|
8001
8660
|
exports.slateRangeToSelection = slateRangeToSelection;
|
|
8002
8661
|
exports.toSlateRange = toSlateRange;
|