@portabletext/editor 2.13.2 → 2.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.ts +61 -61
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/index.cjs +206 -140
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +208 -142
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/selectors/index.d.cts +4 -1
- package/lib/selectors/index.d.ts +4 -1
- package/lib/utils/index.d.cts +2 -2
- package/package.json +10 -10
- package/src/editor/Editable.tsx +16 -76
- package/src/editor/validate-selection-machine.test.ts +47 -0
- package/src/editor/validate-selection-machine.ts +149 -0
- package/src/selectors/index.ts +1 -1
- package/src/selectors/selector.get-mark-state.ts +3 -0
- package/src/test/gherkin-parameter-types.ts +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), 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$
|
|
3
|
+
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), 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$g = require("debug"), slateDom = require("slate-dom"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), isEqual = require("lodash/isEqual.js"), schema = require("@portabletext/schema"), selector_isSelectionExpanded = require("./_chunks-cjs/selector.is-selection-expanded.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), xstate = require("xstate"), sanityBridge = require("@portabletext/sanity-bridge"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema$1 = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), patches = require("@portabletext/patches"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), util_sliceTextBlock = require("./_chunks-cjs/util.slice-text-block.cjs"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), keyboardShortcuts = require("@portabletext/keyboard-shortcuts"), isPlainObject = require("lodash/isPlainObject.js"), rxjs = require("rxjs");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
7
|
-
var noop__default = /* @__PURE__ */ _interopDefaultCompat(noop), debug__default = /* @__PURE__ */ _interopDefaultCompat(debug$
|
|
7
|
+
var noop__default = /* @__PURE__ */ _interopDefaultCompat(noop), debug__default = /* @__PURE__ */ _interopDefaultCompat(debug$g), isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual), uniq__default = /* @__PURE__ */ _interopDefaultCompat(uniq), flatten__default = /* @__PURE__ */ _interopDefaultCompat(flatten), omit__default = /* @__PURE__ */ _interopDefaultCompat(omit), get__default = /* @__PURE__ */ _interopDefaultCompat(get), isUndefined__default = /* @__PURE__ */ _interopDefaultCompat(isUndefined), omitBy__default = /* @__PURE__ */ _interopDefaultCompat(omitBy), isPlainObject__default = /* @__PURE__ */ _interopDefaultCompat(isPlainObject);
|
|
8
8
|
function EditorEventListener(props) {
|
|
9
9
|
const $ = reactCompilerRuntime.c(4), editor = useEditor.useEditor();
|
|
10
10
|
let t0, t1;
|
|
@@ -1539,7 +1539,7 @@ function toKeyName(name) {
|
|
|
1539
1539
|
const keyName = name.toLowerCase();
|
|
1540
1540
|
return aliases[keyName] ?? keyName;
|
|
1541
1541
|
}
|
|
1542
|
-
const debug$
|
|
1542
|
+
const debug$f = debugWithName("plugin:withHotKeys");
|
|
1543
1543
|
function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions) {
|
|
1544
1544
|
const reservedHotkeys = ["enter", "tab", "shift", "delete", "end"], activeHotkeys = hotkeysFromOptions ?? {};
|
|
1545
1545
|
return function(editor) {
|
|
@@ -1554,7 +1554,7 @@ function createWithHotkeys(editorActor, portableTextEditor, hotkeysFromOptions)
|
|
|
1554
1554
|
const possibleMark = activeHotkeys[cat];
|
|
1555
1555
|
if (possibleMark) {
|
|
1556
1556
|
const mark = possibleMark[hotkey];
|
|
1557
|
-
debug$
|
|
1557
|
+
debug$f(`HotKey ${hotkey} to toggle ${mark}`), editorActor.send({
|
|
1558
1558
|
type: "behavior event",
|
|
1559
1559
|
behaviorEvent: {
|
|
1560
1560
|
type: "decorator.toggle",
|
|
@@ -1883,8 +1883,85 @@ function createDecorate(schema2, slateEditor) {
|
|
|
1883
1883
|
}) || slate.Range.includes(decoratedRange, path));
|
|
1884
1884
|
};
|
|
1885
1885
|
}
|
|
1886
|
-
const RelayActorContext = React.createContext({}), debug$
|
|
1887
|
-
|
|
1886
|
+
const RelayActorContext = React.createContext({}), debug$e = debugWithName("validate selection machine"), validateSelectionSetup = xstate.setup({
|
|
1887
|
+
types: {
|
|
1888
|
+
context: {},
|
|
1889
|
+
input: {},
|
|
1890
|
+
events: {}
|
|
1891
|
+
},
|
|
1892
|
+
guards: {
|
|
1893
|
+
"pending operations": ({
|
|
1894
|
+
context
|
|
1895
|
+
}) => context.slateEditor.operations.length > 0
|
|
1896
|
+
}
|
|
1897
|
+
}), validateSelectionAction = validateSelectionSetup.createAction(({
|
|
1898
|
+
context,
|
|
1899
|
+
event
|
|
1900
|
+
}) => {
|
|
1901
|
+
validateSelection(context.slateEditor, event.editorElement);
|
|
1902
|
+
}), validateSelectionMachine = validateSelectionSetup.createMachine({
|
|
1903
|
+
id: "validate selection",
|
|
1904
|
+
context: ({
|
|
1905
|
+
input
|
|
1906
|
+
}) => ({
|
|
1907
|
+
slateEditor: input.slateEditor
|
|
1908
|
+
}),
|
|
1909
|
+
initial: "idle",
|
|
1910
|
+
states: {
|
|
1911
|
+
idle: {
|
|
1912
|
+
on: {
|
|
1913
|
+
"validate selection": [{
|
|
1914
|
+
guard: "pending operations",
|
|
1915
|
+
target: "waiting"
|
|
1916
|
+
}, {
|
|
1917
|
+
actions: [validateSelectionAction],
|
|
1918
|
+
target: "idle"
|
|
1919
|
+
}]
|
|
1920
|
+
}
|
|
1921
|
+
},
|
|
1922
|
+
waiting: {
|
|
1923
|
+
after: {
|
|
1924
|
+
0: [{
|
|
1925
|
+
guard: "pending operations",
|
|
1926
|
+
target: ".",
|
|
1927
|
+
reenter: !0
|
|
1928
|
+
}, {
|
|
1929
|
+
target: "idle",
|
|
1930
|
+
actions: [validateSelectionAction]
|
|
1931
|
+
}]
|
|
1932
|
+
},
|
|
1933
|
+
on: {
|
|
1934
|
+
"validate selection": {
|
|
1935
|
+
target: ".",
|
|
1936
|
+
reenter: !0
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
});
|
|
1942
|
+
function validateSelection(slateEditor, editorElement) {
|
|
1943
|
+
if (!slateEditor.selection)
|
|
1944
|
+
return;
|
|
1945
|
+
let root;
|
|
1946
|
+
try {
|
|
1947
|
+
root = slateReact.ReactEditor.findDocumentOrShadowRoot(slateEditor);
|
|
1948
|
+
} catch {
|
|
1949
|
+
}
|
|
1950
|
+
if (!root || editorElement !== root.activeElement)
|
|
1951
|
+
return;
|
|
1952
|
+
const domSelection = slateReact.ReactEditor.getWindow(slateEditor).getSelection();
|
|
1953
|
+
if (!domSelection || domSelection.rangeCount === 0)
|
|
1954
|
+
return;
|
|
1955
|
+
const existingDOMRange = domSelection.getRangeAt(0);
|
|
1956
|
+
try {
|
|
1957
|
+
const newDOMRange = slateReact.ReactEditor.toDOMRange(slateEditor, slateEditor.selection);
|
|
1958
|
+
(newDOMRange.startOffset !== existingDOMRange.startOffset || newDOMRange.endOffset !== existingDOMRange.endOffset) && (debug$e("DOM range out of sync, validating selection"), domSelection?.removeAllRanges(), domSelection.addRange(newDOMRange));
|
|
1959
|
+
} catch {
|
|
1960
|
+
debug$e("Could not resolve selection, selecting top document"), slate.Transforms.deselect(slateEditor), slateEditor.children.length > 0 && slate.Transforms.select(slateEditor, slate.Editor.start(slateEditor, [])), slateEditor.onChange();
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
const debug$d = debugWithName("component:Editable"), PortableTextEditable = React.forwardRef(function(props, forwardedRef) {
|
|
1964
|
+
const $ = reactCompilerRuntime.c(174);
|
|
1888
1965
|
let hotkeys, onBeforeInput, onBlur, onClick, onCopy, onCut, onDrag, onDragEnd, onDragEnter, onDragLeave, onDragOver, onDragStart, onDrop, onFocus, onPaste, propsSelection, rangeDecorations, renderAnnotation, renderBlock, renderChild, renderDecorator, renderListItem, renderPlaceholder, renderStyle, restProps, scrollSelectionIntoView, spellCheck;
|
|
1889
1966
|
$[0] !== props ? ({
|
|
1890
1967
|
hotkeys,
|
|
@@ -1917,50 +1994,57 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
1917
1994
|
} = props, $[0] = props, $[1] = hotkeys, $[2] = onBeforeInput, $[3] = onBlur, $[4] = onClick, $[5] = onCopy, $[6] = onCut, $[7] = onDrag, $[8] = onDragEnd, $[9] = onDragEnter, $[10] = onDragLeave, $[11] = onDragOver, $[12] = onDragStart, $[13] = onDrop, $[14] = onFocus, $[15] = onPaste, $[16] = propsSelection, $[17] = rangeDecorations, $[18] = renderAnnotation, $[19] = renderBlock, $[20] = renderChild, $[21] = renderDecorator, $[22] = renderListItem, $[23] = renderPlaceholder, $[24] = renderStyle, $[25] = restProps, $[26] = scrollSelectionIntoView, $[27] = spellCheck) : (hotkeys = $[1], onBeforeInput = $[2], onBlur = $[3], onClick = $[4], onCopy = $[5], onCut = $[6], onDrag = $[7], onDragEnd = $[8], onDragEnter = $[9], onDragLeave = $[10], onDragOver = $[11], onDragStart = $[12], onDrop = $[13], onFocus = $[14], onPaste = $[15], propsSelection = $[16], rangeDecorations = $[17], renderAnnotation = $[18], renderBlock = $[19], renderChild = $[20], renderDecorator = $[21], renderListItem = $[22], renderPlaceholder = $[23], renderStyle = $[24], restProps = $[25], scrollSelectionIntoView = $[26], spellCheck = $[27]);
|
|
1918
1995
|
const portableTextEditor = usePortableTextEditor(), [hasInvalidValue, setHasInvalidValue] = React.useState(!1), editorActor = React.useContext(EditorActorContext), relayActor = React.useContext(RelayActorContext), readOnly = react.useSelector(editorActor, _temp), slateEditor = slateReact.useSlate();
|
|
1919
1996
|
let t0;
|
|
1920
|
-
$[28] !==
|
|
1997
|
+
$[28] !== slateEditor ? (t0 = {
|
|
1998
|
+
input: {
|
|
1999
|
+
slateEditor
|
|
2000
|
+
}
|
|
2001
|
+
}, $[28] = slateEditor, $[29] = t0) : t0 = $[29];
|
|
2002
|
+
const validateSelectionActor = react.useActorRef(validateSelectionMachine, t0);
|
|
1921
2003
|
let t1;
|
|
1922
|
-
$[30] !==
|
|
1923
|
-
|
|
2004
|
+
$[30] !== rangeDecorations ? (t1 = rangeDecorations ?? [], $[30] = rangeDecorations, $[31] = t1) : t1 = $[31];
|
|
2005
|
+
let t2;
|
|
2006
|
+
$[32] !== editorActor ? (t2 = editorActor.getSnapshot(), $[32] = editorActor, $[33] = t2) : t2 = $[33];
|
|
2007
|
+
const t3 = !editorActor.getSnapshot().matches({
|
|
1924
2008
|
setup: "setting up"
|
|
1925
2009
|
});
|
|
1926
|
-
let
|
|
1927
|
-
$[
|
|
2010
|
+
let t4;
|
|
2011
|
+
$[34] !== readOnly || $[35] !== slateEditor || $[36] !== t1 || $[37] !== t2.context.schema || $[38] !== t3 ? (t4 = {
|
|
1928
2012
|
input: {
|
|
1929
|
-
rangeDecorations:
|
|
2013
|
+
rangeDecorations: t1,
|
|
1930
2014
|
readOnly,
|
|
1931
|
-
schema:
|
|
2015
|
+
schema: t2.context.schema,
|
|
1932
2016
|
slateEditor,
|
|
1933
|
-
skipSetup:
|
|
2017
|
+
skipSetup: t3
|
|
1934
2018
|
}
|
|
1935
|
-
}, $[
|
|
1936
|
-
const rangeDecorationsActor = react.useActorRef(rangeDecorationsMachine,
|
|
1937
|
-
let
|
|
1938
|
-
$[
|
|
2019
|
+
}, $[34] = readOnly, $[35] = slateEditor, $[36] = t1, $[37] = t2.context.schema, $[38] = t3, $[39] = t4) : t4 = $[39];
|
|
2020
|
+
const rangeDecorationsActor = react.useActorRef(rangeDecorationsMachine, t4), decorate = react.useSelector(rangeDecorationsActor, _temp2);
|
|
2021
|
+
let t5, t6;
|
|
2022
|
+
$[40] !== rangeDecorationsActor || $[41] !== readOnly ? (t5 = () => {
|
|
1939
2023
|
rangeDecorationsActor.send({
|
|
1940
2024
|
type: "update read only",
|
|
1941
2025
|
readOnly
|
|
1942
2026
|
});
|
|
1943
|
-
},
|
|
1944
|
-
let
|
|
1945
|
-
$[
|
|
2027
|
+
}, t6 = [rangeDecorationsActor, readOnly], $[40] = rangeDecorationsActor, $[41] = readOnly, $[42] = t5, $[43] = t6) : (t5 = $[42], t6 = $[43]), React.useEffect(t5, t6);
|
|
2028
|
+
let t7, t8;
|
|
2029
|
+
$[44] !== rangeDecorations || $[45] !== rangeDecorationsActor ? (t7 = () => {
|
|
1946
2030
|
rangeDecorationsActor.send({
|
|
1947
2031
|
type: "range decorations updated",
|
|
1948
2032
|
rangeDecorations: rangeDecorations ?? []
|
|
1949
2033
|
});
|
|
1950
|
-
},
|
|
2034
|
+
}, t8 = [rangeDecorationsActor, rangeDecorations], $[44] = rangeDecorations, $[45] = rangeDecorationsActor, $[46] = t7, $[47] = t8) : (t7 = $[46], t8 = $[47]), React.useEffect(t7, t8);
|
|
1951
2035
|
bb0: {
|
|
1952
2036
|
if (readOnly)
|
|
1953
2037
|
break bb0;
|
|
1954
2038
|
createWithHotkeys(editorActor, portableTextEditor, hotkeys)(slateEditor);
|
|
1955
2039
|
}
|
|
1956
|
-
let t9;
|
|
1957
|
-
$[46] !== readOnly || $[47] !== renderBlock || $[48] !== renderChild || $[49] !== renderListItem || $[50] !== renderStyle || $[51] !== spellCheck ? (t9 = (eProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderElement, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, spellCheck }), $[46] = readOnly, $[47] = renderBlock, $[48] = renderChild, $[49] = renderListItem, $[50] = renderStyle, $[51] = spellCheck, $[52] = t9) : t9 = $[52];
|
|
1958
|
-
const renderElement = t9;
|
|
1959
2040
|
let t10;
|
|
1960
|
-
$[
|
|
1961
|
-
const
|
|
2041
|
+
$[48] !== readOnly || $[49] !== renderBlock || $[50] !== renderChild || $[51] !== renderListItem || $[52] !== renderStyle || $[53] !== spellCheck ? (t10 = (eProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderElement, { ...eProps, readOnly, renderBlock, renderChild, renderListItem, renderStyle, spellCheck }), $[48] = readOnly, $[49] = renderBlock, $[50] = renderChild, $[51] = renderListItem, $[52] = renderStyle, $[53] = spellCheck, $[54] = t10) : t10 = $[54];
|
|
2042
|
+
const renderElement = t10;
|
|
1962
2043
|
let t11;
|
|
1963
|
-
$[
|
|
2044
|
+
$[55] !== readOnly || $[56] !== renderAnnotation || $[57] !== renderChild || $[58] !== renderDecorator || $[59] !== renderPlaceholder ? (t11 = (leafProps) => /* @__PURE__ */ jsxRuntime.jsx(RenderLeaf, { ...leafProps, readOnly, renderAnnotation, renderChild, renderDecorator, renderPlaceholder }), $[55] = readOnly, $[56] = renderAnnotation, $[57] = renderChild, $[58] = renderDecorator, $[59] = renderPlaceholder, $[60] = t11) : t11 = $[60];
|
|
2045
|
+
const renderLeaf = t11, renderText = _temp3;
|
|
2046
|
+
let t12;
|
|
2047
|
+
$[61] !== editorActor || $[62] !== propsSelection || $[63] !== slateEditor ? (t12 = () => {
|
|
1964
2048
|
if (propsSelection) {
|
|
1965
2049
|
debug$d(`Selection from props ${JSON.stringify(propsSelection)}`);
|
|
1966
2050
|
const normalizedSelection = normalizeSelection(propsSelection, fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name));
|
|
@@ -1980,10 +2064,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
1980
2064
|
}), slateEditor.onChange());
|
|
1981
2065
|
}
|
|
1982
2066
|
}
|
|
1983
|
-
}, $[
|
|
1984
|
-
const restoreSelectionFromProps =
|
|
1985
|
-
let
|
|
1986
|
-
$[
|
|
2067
|
+
}, $[61] = editorActor, $[62] = propsSelection, $[63] = slateEditor, $[64] = t12) : t12 = $[64];
|
|
2068
|
+
const restoreSelectionFromProps = t12;
|
|
2069
|
+
let t13, t14;
|
|
2070
|
+
$[65] !== editorActor || $[66] !== rangeDecorationsActor || $[67] !== restoreSelectionFromProps ? (t13 = () => {
|
|
1987
2071
|
const onReady = editorActor.on("ready", () => {
|
|
1988
2072
|
rangeDecorationsActor.send({
|
|
1989
2073
|
type: "ready"
|
|
@@ -1996,13 +2080,13 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
1996
2080
|
return () => {
|
|
1997
2081
|
onReady.unsubscribe(), onInvalidValue.unsubscribe(), onValueChanged.unsubscribe();
|
|
1998
2082
|
};
|
|
1999
|
-
},
|
|
2000
|
-
let
|
|
2001
|
-
$[
|
|
2083
|
+
}, t14 = [rangeDecorationsActor, editorActor, restoreSelectionFromProps], $[65] = editorActor, $[66] = rangeDecorationsActor, $[67] = restoreSelectionFromProps, $[68] = t13, $[69] = t14) : (t13 = $[68], t14 = $[69]), React.useEffect(t13, t14);
|
|
2084
|
+
let t15, t16;
|
|
2085
|
+
$[70] !== hasInvalidValue || $[71] !== propsSelection || $[72] !== restoreSelectionFromProps ? (t15 = () => {
|
|
2002
2086
|
propsSelection && !hasInvalidValue && restoreSelectionFromProps();
|
|
2003
|
-
},
|
|
2004
|
-
let
|
|
2005
|
-
$[
|
|
2087
|
+
}, t16 = [hasInvalidValue, propsSelection, restoreSelectionFromProps], $[70] = hasInvalidValue, $[71] = propsSelection, $[72] = restoreSelectionFromProps, $[73] = t15, $[74] = t16) : (t15 = $[73], t16 = $[74]), React.useEffect(t15, t16);
|
|
2088
|
+
let t17;
|
|
2089
|
+
$[75] !== editorActor || $[76] !== onCopy || $[77] !== slateEditor ? (t17 = (event) => {
|
|
2006
2090
|
if (onCopy)
|
|
2007
2091
|
onCopy(event) !== void 0 && event.preventDefault();
|
|
2008
2092
|
else if (event.nativeEvent.clipboardData) {
|
|
@@ -2031,10 +2115,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2031
2115
|
nativeEvent: event
|
|
2032
2116
|
});
|
|
2033
2117
|
}
|
|
2034
|
-
}, $[
|
|
2035
|
-
const handleCopy =
|
|
2036
|
-
let
|
|
2037
|
-
$[
|
|
2118
|
+
}, $[75] = editorActor, $[76] = onCopy, $[77] = slateEditor, $[78] = t17) : t17 = $[78];
|
|
2119
|
+
const handleCopy = t17;
|
|
2120
|
+
let t18;
|
|
2121
|
+
$[79] !== editorActor || $[80] !== onCut || $[81] !== slateEditor ? (t18 = (event_0) => {
|
|
2038
2122
|
if (onCut)
|
|
2039
2123
|
onCut(event_0) !== void 0 && event_0.preventDefault();
|
|
2040
2124
|
else if (event_0.nativeEvent.clipboardData) {
|
|
@@ -2059,10 +2143,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2059
2143
|
nativeEvent: event_0
|
|
2060
2144
|
});
|
|
2061
2145
|
}
|
|
2062
|
-
}, $[
|
|
2063
|
-
const handleCut =
|
|
2064
|
-
let
|
|
2065
|
-
$[
|
|
2146
|
+
}, $[79] = editorActor, $[80] = onCut, $[81] = slateEditor, $[82] = t18) : t18 = $[82];
|
|
2147
|
+
const handleCut = t18;
|
|
2148
|
+
let t19;
|
|
2149
|
+
$[83] !== editorActor || $[84] !== onPaste || $[85] !== portableTextEditor || $[86] !== relayActor || $[87] !== slateEditor ? (t19 = (event_1) => {
|
|
2066
2150
|
const value = fromSlateValue(slateEditor.children, editorActor.getSnapshot().context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(slateEditor)), path = (slateEditor.selection ? slateRangeToSelection({
|
|
2067
2151
|
schema: editorActor.getSnapshot().context.schema,
|
|
2068
2152
|
editor: slateEditor,
|
|
@@ -2146,18 +2230,18 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2146
2230
|
});
|
|
2147
2231
|
}
|
|
2148
2232
|
debug$d("No result from custom paste handler, pasting normally");
|
|
2149
|
-
}, $[
|
|
2150
|
-
const handlePaste =
|
|
2151
|
-
let
|
|
2152
|
-
$[
|
|
2233
|
+
}, $[83] = editorActor, $[84] = onPaste, $[85] = portableTextEditor, $[86] = relayActor, $[87] = slateEditor, $[88] = t19) : t19 = $[88];
|
|
2234
|
+
const handlePaste = t19;
|
|
2235
|
+
let t20;
|
|
2236
|
+
$[89] !== editorActor || $[90] !== onFocus || $[91] !== relayActor || $[92] !== slateEditor ? (t20 = (event_2) => {
|
|
2153
2237
|
onFocus && onFocus(event_2), event_2.isDefaultPrevented() || (relayActor.send({
|
|
2154
2238
|
type: "focused",
|
|
2155
2239
|
event: event_2
|
|
2156
2240
|
}), !slateEditor.selection && isEqualToEmptyEditor(slateEditor.children, editorActor.getSnapshot().context.schema) && (slate.Transforms.select(slateEditor, slate.Editor.start(slateEditor, [])), slateEditor.onChange()));
|
|
2157
|
-
}, $[
|
|
2158
|
-
const handleOnFocus =
|
|
2159
|
-
let
|
|
2160
|
-
$[
|
|
2241
|
+
}, $[89] = editorActor, $[90] = onFocus, $[91] = relayActor, $[92] = slateEditor, $[93] = t20) : t20 = $[93];
|
|
2242
|
+
const handleOnFocus = t20;
|
|
2243
|
+
let t21;
|
|
2244
|
+
$[94] !== editorActor || $[95] !== onClick || $[96] !== slateEditor ? (t21 = (event_3) => {
|
|
2161
2245
|
if (onClick && onClick(event_3), event_3.isDefaultPrevented() || event_3.isPropagationStopped())
|
|
2162
2246
|
return;
|
|
2163
2247
|
const position_3 = getEventPosition({
|
|
@@ -2174,23 +2258,23 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2174
2258
|
editor: slateEditor,
|
|
2175
2259
|
nativeEvent: event_3
|
|
2176
2260
|
});
|
|
2177
|
-
}, $[
|
|
2178
|
-
const handleClick =
|
|
2179
|
-
let
|
|
2180
|
-
$[
|
|
2261
|
+
}, $[94] = editorActor, $[95] = onClick, $[96] = slateEditor, $[97] = t21) : t21 = $[97];
|
|
2262
|
+
const handleClick = t21;
|
|
2263
|
+
let t22;
|
|
2264
|
+
$[98] !== onBlur || $[99] !== relayActor ? (t22 = (event_4) => {
|
|
2181
2265
|
onBlur && onBlur(event_4), event_4.isPropagationStopped() || relayActor.send({
|
|
2182
2266
|
type: "blurred",
|
|
2183
2267
|
event: event_4
|
|
2184
2268
|
});
|
|
2185
|
-
}, $[
|
|
2186
|
-
const handleOnBlur =
|
|
2187
|
-
let t22;
|
|
2188
|
-
$[99] !== onBeforeInput ? (t22 = (event_5) => {
|
|
2189
|
-
onBeforeInput && onBeforeInput(event_5);
|
|
2190
|
-
}, $[99] = onBeforeInput, $[100] = t22) : t22 = $[100];
|
|
2191
|
-
const handleOnBeforeInput = t22;
|
|
2269
|
+
}, $[98] = onBlur, $[99] = relayActor, $[100] = t22) : t22 = $[100];
|
|
2270
|
+
const handleOnBlur = t22;
|
|
2192
2271
|
let t23;
|
|
2193
|
-
$[101] !==
|
|
2272
|
+
$[101] !== onBeforeInput ? (t23 = (event_5) => {
|
|
2273
|
+
onBeforeInput && onBeforeInput(event_5);
|
|
2274
|
+
}, $[101] = onBeforeInput, $[102] = t23) : t23 = $[102];
|
|
2275
|
+
const handleOnBeforeInput = t23;
|
|
2276
|
+
let t24;
|
|
2277
|
+
$[103] !== editorActor || $[104] !== props || $[105] !== slateEditor ? (t24 = (event_6) => {
|
|
2194
2278
|
props.onKeyDown && props.onKeyDown(event_6), event_6.isDefaultPrevented() || slateEditor.pteWithHotKeys(event_6), event_6.isDefaultPrevented() || editorActor.send({
|
|
2195
2279
|
type: "behavior event",
|
|
2196
2280
|
behaviorEvent: {
|
|
@@ -2207,10 +2291,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2207
2291
|
editor: slateEditor,
|
|
2208
2292
|
nativeEvent: event_6
|
|
2209
2293
|
});
|
|
2210
|
-
}, $[
|
|
2211
|
-
const handleKeyDown =
|
|
2212
|
-
let
|
|
2213
|
-
$[
|
|
2294
|
+
}, $[103] = editorActor, $[104] = props, $[105] = slateEditor, $[106] = t24) : t24 = $[106];
|
|
2295
|
+
const handleKeyDown = t24;
|
|
2296
|
+
let t25;
|
|
2297
|
+
$[107] !== editorActor || $[108] !== props || $[109] !== slateEditor ? (t25 = (event_7) => {
|
|
2214
2298
|
props.onKeyUp && props.onKeyUp(event_7), event_7.isDefaultPrevented() || editorActor.send({
|
|
2215
2299
|
type: "behavior event",
|
|
2216
2300
|
behaviorEvent: {
|
|
@@ -2227,26 +2311,26 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2227
2311
|
editor: slateEditor,
|
|
2228
2312
|
nativeEvent: event_7
|
|
2229
2313
|
});
|
|
2230
|
-
}, $[
|
|
2231
|
-
const handleKeyUp =
|
|
2232
|
-
let
|
|
2314
|
+
}, $[107] = editorActor, $[108] = props, $[109] = slateEditor, $[110] = t25) : t25 = $[110];
|
|
2315
|
+
const handleKeyUp = t25;
|
|
2316
|
+
let t26;
|
|
2233
2317
|
bb1: {
|
|
2234
2318
|
if (scrollSelectionIntoView === void 0) {
|
|
2235
|
-
|
|
2319
|
+
t26 = void 0;
|
|
2236
2320
|
break bb1;
|
|
2237
2321
|
}
|
|
2238
2322
|
if (scrollSelectionIntoView === null) {
|
|
2239
|
-
|
|
2323
|
+
t26 = noop__default.default;
|
|
2240
2324
|
break bb1;
|
|
2241
2325
|
}
|
|
2242
|
-
let
|
|
2243
|
-
$[
|
|
2326
|
+
let t272;
|
|
2327
|
+
$[111] !== portableTextEditor || $[112] !== scrollSelectionIntoView ? (t272 = (_editor, domRange) => {
|
|
2244
2328
|
scrollSelectionIntoView(portableTextEditor, domRange);
|
|
2245
|
-
}, $[
|
|
2329
|
+
}, $[111] = portableTextEditor, $[112] = scrollSelectionIntoView, $[113] = t272) : t272 = $[113], t26 = t272;
|
|
2246
2330
|
}
|
|
2247
|
-
const scrollSelectionIntoViewToSlate =
|
|
2248
|
-
let
|
|
2249
|
-
$[
|
|
2331
|
+
const scrollSelectionIntoViewToSlate = t26;
|
|
2332
|
+
let t27, t28;
|
|
2333
|
+
$[114] !== editorActor || $[115] !== slateEditor ? (t27 = () => {
|
|
2250
2334
|
const window2 = slateReact.ReactEditor.getWindow(slateEditor), onDragEnd_0 = () => {
|
|
2251
2335
|
editorActor.send({
|
|
2252
2336
|
type: "dragend"
|
|
@@ -2259,9 +2343,9 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2259
2343
|
return window2.document.addEventListener("dragend", onDragEnd_0), window2.document.addEventListener("drop", onDrop_0), () => {
|
|
2260
2344
|
window2.document.removeEventListener("dragend", onDragEnd_0), window2.document.removeEventListener("drop", onDrop_0);
|
|
2261
2345
|
};
|
|
2262
|
-
},
|
|
2263
|
-
let
|
|
2264
|
-
$[
|
|
2346
|
+
}, t28 = [slateEditor, editorActor], $[114] = editorActor, $[115] = slateEditor, $[116] = t27, $[117] = t28) : (t27 = $[116], t28 = $[117]), React.useEffect(t27, t28);
|
|
2347
|
+
let t29;
|
|
2348
|
+
$[118] !== editorActor || $[119] !== onDragStart || $[120] !== slateEditor ? (t29 = (event_8) => {
|
|
2265
2349
|
if (onDragStart?.(event_8), event_8.isDefaultPrevented() || event_8.isPropagationStopped())
|
|
2266
2350
|
return;
|
|
2267
2351
|
const position_4 = getEventPosition({
|
|
@@ -2289,10 +2373,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2289
2373
|
},
|
|
2290
2374
|
editor: slateEditor
|
|
2291
2375
|
}), !0;
|
|
2292
|
-
}, $[
|
|
2293
|
-
const handleDragStart =
|
|
2294
|
-
let
|
|
2295
|
-
$[
|
|
2376
|
+
}, $[118] = editorActor, $[119] = onDragStart, $[120] = slateEditor, $[121] = t29) : t29 = $[121];
|
|
2377
|
+
const handleDragStart = t29;
|
|
2378
|
+
let t30;
|
|
2379
|
+
$[122] !== editorActor || $[123] !== onDrag || $[124] !== slateEditor ? (t30 = (event_9) => {
|
|
2296
2380
|
if (onDrag?.(event_9), !(event_9.isDefaultPrevented() || event_9.isPropagationStopped() || !getEventPosition({
|
|
2297
2381
|
editorActor,
|
|
2298
2382
|
slateEditor,
|
|
@@ -2308,10 +2392,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2308
2392
|
},
|
|
2309
2393
|
editor: slateEditor
|
|
2310
2394
|
}), !0;
|
|
2311
|
-
}, $[
|
|
2312
|
-
const handleDrag =
|
|
2313
|
-
let
|
|
2314
|
-
$[
|
|
2395
|
+
}, $[122] = editorActor, $[123] = onDrag, $[124] = slateEditor, $[125] = t30) : t30 = $[125];
|
|
2396
|
+
const handleDrag = t30;
|
|
2397
|
+
let t31;
|
|
2398
|
+
$[126] !== editorActor || $[127] !== onDragEnd || $[128] !== slateEditor ? (t31 = (event_10) => {
|
|
2315
2399
|
if (onDragEnd?.(event_10), !(event_10.isDefaultPrevented() || event_10.isPropagationStopped()))
|
|
2316
2400
|
return editorActor.send({
|
|
2317
2401
|
type: "behavior event",
|
|
@@ -2323,10 +2407,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2323
2407
|
},
|
|
2324
2408
|
editor: slateEditor
|
|
2325
2409
|
}), !0;
|
|
2326
|
-
}, $[
|
|
2327
|
-
const handleDragEnd =
|
|
2328
|
-
let
|
|
2329
|
-
$[
|
|
2410
|
+
}, $[126] = editorActor, $[127] = onDragEnd, $[128] = slateEditor, $[129] = t31) : t31 = $[129];
|
|
2411
|
+
const handleDragEnd = t31;
|
|
2412
|
+
let t32;
|
|
2413
|
+
$[130] !== editorActor || $[131] !== onDragEnter || $[132] !== slateEditor ? (t32 = (event_11) => {
|
|
2330
2414
|
if (onDragEnter?.(event_11), event_11.isDefaultPrevented() || event_11.isPropagationStopped())
|
|
2331
2415
|
return;
|
|
2332
2416
|
const position_6 = getEventPosition({
|
|
@@ -2346,10 +2430,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2346
2430
|
},
|
|
2347
2431
|
editor: slateEditor
|
|
2348
2432
|
}), !0;
|
|
2349
|
-
}, $[
|
|
2350
|
-
const handleDragEnter =
|
|
2351
|
-
let
|
|
2352
|
-
$[
|
|
2433
|
+
}, $[130] = editorActor, $[131] = onDragEnter, $[132] = slateEditor, $[133] = t32) : t32 = $[133];
|
|
2434
|
+
const handleDragEnter = t32;
|
|
2435
|
+
let t33;
|
|
2436
|
+
$[134] !== editorActor || $[135] !== onDragOver || $[136] !== slateEditor ? (t33 = (event_12) => {
|
|
2353
2437
|
if (onDragOver?.(event_12), event_12.isDefaultPrevented() || event_12.isPropagationStopped())
|
|
2354
2438
|
return;
|
|
2355
2439
|
const position_7 = getEventPosition({
|
|
@@ -2371,10 +2455,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2371
2455
|
editor: slateEditor,
|
|
2372
2456
|
nativeEvent: event_12
|
|
2373
2457
|
}), !0;
|
|
2374
|
-
}, $[
|
|
2375
|
-
const handleDragOver =
|
|
2376
|
-
let
|
|
2377
|
-
$[
|
|
2458
|
+
}, $[134] = editorActor, $[135] = onDragOver, $[136] = slateEditor, $[137] = t33) : t33 = $[137];
|
|
2459
|
+
const handleDragOver = t33;
|
|
2460
|
+
let t34;
|
|
2461
|
+
$[138] !== editorActor || $[139] !== onDrop || $[140] !== slateEditor ? (t34 = (event_13) => {
|
|
2378
2462
|
if (onDrop?.(event_13), event_13.isDefaultPrevented() || event_13.isPropagationStopped())
|
|
2379
2463
|
return;
|
|
2380
2464
|
const position_8 = getEventPosition({
|
|
@@ -2399,10 +2483,10 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2399
2483
|
editor: slateEditor,
|
|
2400
2484
|
nativeEvent: event_13
|
|
2401
2485
|
}), !0;
|
|
2402
|
-
}, $[
|
|
2403
|
-
const handleDrop =
|
|
2404
|
-
let
|
|
2405
|
-
$[
|
|
2486
|
+
}, $[138] = editorActor, $[139] = onDrop, $[140] = slateEditor, $[141] = t34) : t34 = $[141];
|
|
2487
|
+
const handleDrop = t34;
|
|
2488
|
+
let t35;
|
|
2489
|
+
$[142] !== editorActor || $[143] !== onDragLeave || $[144] !== slateEditor ? (t35 = (event_14) => {
|
|
2406
2490
|
if (onDragLeave?.(event_14), !(event_14.isDefaultPrevented() || event_14.isPropagationStopped() || !getEventPosition({
|
|
2407
2491
|
editorActor,
|
|
2408
2492
|
slateEditor,
|
|
@@ -2418,15 +2502,18 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2418
2502
|
},
|
|
2419
2503
|
editor: slateEditor
|
|
2420
2504
|
}), !0;
|
|
2421
|
-
}, $[
|
|
2422
|
-
const handleDragLeave =
|
|
2423
|
-
let
|
|
2424
|
-
$[
|
|
2425
|
-
if (typeof forwardedRef == "function" ? forwardedRef(
|
|
2505
|
+
}, $[142] = editorActor, $[143] = onDragLeave, $[144] = slateEditor, $[145] = t35) : t35 = $[145];
|
|
2506
|
+
const handleDragLeave = t35;
|
|
2507
|
+
let t36;
|
|
2508
|
+
$[146] !== forwardedRef || $[147] !== validateSelectionActor ? (t36 = (editorElement) => {
|
|
2509
|
+
if (typeof forwardedRef == "function" ? forwardedRef(editorElement) : forwardedRef && (forwardedRef.current = editorElement), editorElement) {
|
|
2426
2510
|
const mutationObserver = new MutationObserver(() => {
|
|
2427
|
-
|
|
2511
|
+
validateSelectionActor.send({
|
|
2512
|
+
type: "validate selection",
|
|
2513
|
+
editorElement
|
|
2514
|
+
});
|
|
2428
2515
|
});
|
|
2429
|
-
return mutationObserver.observe(
|
|
2516
|
+
return mutationObserver.observe(editorElement, {
|
|
2430
2517
|
attributeOldValue: !1,
|
|
2431
2518
|
attributes: !1,
|
|
2432
2519
|
characterData: !1,
|
|
@@ -2436,35 +2523,14 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
2436
2523
|
mutationObserver.disconnect();
|
|
2437
2524
|
};
|
|
2438
2525
|
}
|
|
2439
|
-
}, $[
|
|
2440
|
-
const callbackRef =
|
|
2526
|
+
}, $[146] = forwardedRef, $[147] = validateSelectionActor, $[148] = t36) : t36 = $[148];
|
|
2527
|
+
const callbackRef = t36;
|
|
2441
2528
|
if (!portableTextEditor)
|
|
2442
2529
|
return null;
|
|
2443
|
-
let
|
|
2444
|
-
return $[
|
|
2530
|
+
let t37;
|
|
2531
|
+
return $[149] !== callbackRef || $[150] !== decorate || $[151] !== handleClick || $[152] !== handleCopy || $[153] !== handleCut || $[154] !== handleDrag || $[155] !== handleDragEnd || $[156] !== handleDragEnter || $[157] !== handleDragLeave || $[158] !== handleDragOver || $[159] !== handleDragStart || $[160] !== handleDrop || $[161] !== handleKeyDown || $[162] !== handleKeyUp || $[163] !== handleOnBeforeInput || $[164] !== handleOnBlur || $[165] !== handleOnFocus || $[166] !== handlePaste || $[167] !== hasInvalidValue || $[168] !== readOnly || $[169] !== renderElement || $[170] !== renderLeaf || $[171] !== restProps || $[172] !== scrollSelectionIntoViewToSlate ? (t37 = hasInvalidValue ? null : /* @__PURE__ */ jsxRuntime.jsx(slateReact.Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }), $[149] = callbackRef, $[150] = decorate, $[151] = handleClick, $[152] = handleCopy, $[153] = handleCut, $[154] = handleDrag, $[155] = handleDragEnd, $[156] = handleDragEnter, $[157] = handleDragLeave, $[158] = handleDragOver, $[159] = handleDragStart, $[160] = handleDrop, $[161] = handleKeyDown, $[162] = handleKeyUp, $[163] = handleOnBeforeInput, $[164] = handleOnBlur, $[165] = handleOnFocus, $[166] = handlePaste, $[167] = hasInvalidValue, $[168] = readOnly, $[169] = renderElement, $[170] = renderLeaf, $[171] = restProps, $[172] = scrollSelectionIntoViewToSlate, $[173] = t37) : t37 = $[173], t37;
|
|
2445
2532
|
});
|
|
2446
2533
|
PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
|
|
2447
|
-
function validateSelection(slateEditor, activeElement) {
|
|
2448
|
-
if (!slateEditor.selection)
|
|
2449
|
-
return;
|
|
2450
|
-
let root;
|
|
2451
|
-
try {
|
|
2452
|
-
root = slateReact.ReactEditor.findDocumentOrShadowRoot(slateEditor);
|
|
2453
|
-
} catch {
|
|
2454
|
-
}
|
|
2455
|
-
if (!root || activeElement !== root.activeElement)
|
|
2456
|
-
return;
|
|
2457
|
-
const domSelection = slateReact.ReactEditor.getWindow(slateEditor).getSelection();
|
|
2458
|
-
if (!domSelection || domSelection.rangeCount === 0)
|
|
2459
|
-
return;
|
|
2460
|
-
const existingDOMRange = domSelection.getRangeAt(0);
|
|
2461
|
-
try {
|
|
2462
|
-
const newDOMRange = slateReact.ReactEditor.toDOMRange(slateEditor, slateEditor.selection);
|
|
2463
|
-
(newDOMRange.startOffset !== existingDOMRange.startOffset || newDOMRange.endOffset !== existingDOMRange.endOffset) && (debug$d("DOM range out of sync, validating selection"), domSelection?.removeAllRanges(), domSelection.addRange(newDOMRange));
|
|
2464
|
-
} catch {
|
|
2465
|
-
debug$d("Could not resolve selection, selecting top document"), slate.Transforms.deselect(slateEditor), slateEditor.children.length > 0 && slate.Transforms.select(slateEditor, [0, 0]), slateEditor.onChange();
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
2534
|
function _temp(s) {
|
|
2469
2535
|
return s.matches({
|
|
2470
2536
|
"edit mode": "read only"
|