@portabletext/editor 1.41.2 → 1.41.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.get-focus-inline-object.cjs +11 -0
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -0
- package/lib/_chunks-es/selector.get-focus-inline-object.js +13 -0
- package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -0
- package/lib/index.cjs +14 -7
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +14 -6
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +2 -8
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +3 -8
- package/lib/selectors/index.js.map +1 -1
- package/package.json +1 -1
- package/src/internal-utils/drag-selection.test.ts +1 -1
- package/src/internal-utils/drag-selection.ts +23 -6
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var types = require("@sanity/types"), selector_isAtTheStartOfBlock = require("./selector.is-at-the-start-of-block.cjs");
|
|
3
|
+
const getFocusInlineObject = (snapshot) => {
|
|
4
|
+
const focusChild = selector_isAtTheStartOfBlock.getFocusChild(snapshot);
|
|
5
|
+
return focusChild && !types.isPortableTextSpan(focusChild.node) ? {
|
|
6
|
+
node: focusChild.node,
|
|
7
|
+
path: focusChild.path
|
|
8
|
+
} : void 0;
|
|
9
|
+
};
|
|
10
|
+
exports.getFocusInlineObject = getFocusInlineObject;
|
|
11
|
+
//# sourceMappingURL=selector.get-focus-inline-object.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.get-focus-inline-object.cjs","sources":["../../src/selectors/selector.get-focus-inline-object.ts"],"sourcesContent":["import {\n isPortableTextSpan,\n type KeyedSegment,\n type PortableTextObject,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getFocusChild} from './selectors'\n\n/**\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n | {node: PortableTextObject; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && !isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n"],"names":["getFocusInlineObject","snapshot","focusChild","getFocusChild","isPortableTextSpan","node","path","undefined"],"mappings":";;AAWO,MAAMA,uBAGRC,CAAa,aAAA;AACVC,QAAAA,aAAaC,2CAAcF,QAAQ;AAEzC,SAAOC,cAAc,CAACE,MAAAA,mBAAmBF,WAAWG,IAAI,IACpD;AAAA,IAACA,MAAMH,WAAWG;AAAAA,IAAMC,MAAMJ,WAAWI;AAAAA,EAAAA,IACzCC;AACN;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isPortableTextSpan } from "@sanity/types";
|
|
2
|
+
import { getFocusChild } from "./selector.is-at-the-start-of-block.js";
|
|
3
|
+
const getFocusInlineObject = (snapshot) => {
|
|
4
|
+
const focusChild = getFocusChild(snapshot);
|
|
5
|
+
return focusChild && !isPortableTextSpan(focusChild.node) ? {
|
|
6
|
+
node: focusChild.node,
|
|
7
|
+
path: focusChild.path
|
|
8
|
+
} : void 0;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
getFocusInlineObject
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=selector.get-focus-inline-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.get-focus-inline-object.js","sources":["../../src/selectors/selector.get-focus-inline-object.ts"],"sourcesContent":["import {\n isPortableTextSpan,\n type KeyedSegment,\n type PortableTextObject,\n} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getFocusChild} from './selectors'\n\n/**\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n | {node: PortableTextObject; path: [KeyedSegment, 'children', KeyedSegment]}\n | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && !isPortableTextSpan(focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n"],"names":["getFocusInlineObject","snapshot","focusChild","getFocusChild","isPortableTextSpan","node","path","undefined"],"mappings":";;AAWO,MAAMA,uBAGRC,CAAa,aAAA;AACVC,QAAAA,aAAaC,cAAcF,QAAQ;AAEzC,SAAOC,cAAc,CAACE,mBAAmBF,WAAWG,IAAI,IACpD;AAAA,IAACA,MAAMH,WAAWG;AAAAA,IAAMC,MAAMJ,WAAWI;AAAAA,EAAAA,IACzCC;AACN;"}
|
package/lib/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var editorProvider = require("./_chunks-cjs/editor-provider.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), React = require("react"), slate = require("slate"), slateReact = require("slate-react"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), selector_isAtTheStartOfBlock = require("./_chunks-cjs/selector.is-at-the-start-of-block.cjs"), selector_isOverlappingSelection = require("./_chunks-cjs/selector.is-overlapping-selection.cjs"), slateDom = require("slate-dom"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), util_selectionPointToBlockOffset = require("./_chunks-cjs/util.selection-point-to-block-offset.cjs"), behavior_core = require("./_chunks-cjs/behavior.core.cjs"), reactCompilerRuntime = require("react-compiler-runtime"), uniq = require("lodash/uniq.js"), useEffectEvent = require("use-effect-event");
|
|
3
|
+
var editorProvider = require("./_chunks-cjs/editor-provider.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), React = require("react"), slate = require("slate"), slateReact = require("slate-react"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), selector_isAtTheStartOfBlock = require("./_chunks-cjs/selector.is-at-the-start-of-block.cjs"), selector_getFocusInlineObject = require("./_chunks-cjs/selector.get-focus-inline-object.cjs"), selector_isOverlappingSelection = require("./_chunks-cjs/selector.is-overlapping-selection.cjs"), slateDom = require("slate-dom"), util_isSelectionCollapsed = require("./_chunks-cjs/util.is-selection-collapsed.cjs"), util_selectionPointToBlockOffset = require("./_chunks-cjs/util.selection-point-to-block-offset.cjs"), behavior_core = require("./_chunks-cjs/behavior.core.cjs"), reactCompilerRuntime = require("react-compiler-runtime"), uniq = require("lodash/uniq.js"), useEffectEvent = require("use-effect-event");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -23,25 +23,32 @@ function getDragSelection({
|
|
|
23
23
|
snapshot
|
|
24
24
|
}) {
|
|
25
25
|
let dragSelection = eventSelection;
|
|
26
|
-
|
|
26
|
+
if (selector_getFocusInlineObject.getFocusInlineObject({
|
|
27
27
|
context: {
|
|
28
28
|
...snapshot.context,
|
|
29
29
|
selection: eventSelection
|
|
30
30
|
}
|
|
31
|
-
})
|
|
31
|
+
}))
|
|
32
|
+
return dragSelection;
|
|
33
|
+
const draggingCollapsedSelection = selector_isAtTheStartOfBlock.isSelectionCollapsed({
|
|
32
34
|
context: {
|
|
33
35
|
...snapshot.context,
|
|
34
36
|
selection: eventSelection
|
|
35
37
|
}
|
|
36
|
-
}),
|
|
38
|
+
}), draggedTextBlock = selector_isAtTheStartOfBlock.getFocusTextBlock({
|
|
39
|
+
context: {
|
|
40
|
+
...snapshot.context,
|
|
41
|
+
selection: eventSelection
|
|
42
|
+
}
|
|
43
|
+
}), draggedSpan = selector_isAtTheStartOfBlock.getFocusSpan({
|
|
37
44
|
context: {
|
|
38
45
|
...snapshot.context,
|
|
39
46
|
selection: eventSelection
|
|
40
47
|
}
|
|
41
48
|
});
|
|
42
|
-
|
|
43
|
-
anchor: util_sliceBlocks.getBlockStartPoint(
|
|
44
|
-
focus: util_sliceBlocks.getBlockEndPoint(
|
|
49
|
+
draggingCollapsedSelection && draggedTextBlock && draggedSpan && (dragSelection = {
|
|
50
|
+
anchor: util_sliceBlocks.getBlockStartPoint(draggedTextBlock),
|
|
51
|
+
focus: util_sliceBlocks.getBlockEndPoint(draggedTextBlock)
|
|
45
52
|
});
|
|
46
53
|
const selectedBlocks = selector_isAtTheStartOfBlock.getSelectedBlocks(snapshot);
|
|
47
54
|
if (snapshot.context.selection && selector_isAtTheStartOfBlock.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
|