@portabletext/editor 1.55.13 → 1.55.15
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-selection-expanded.cjs → selector.get-focus-span.cjs} +27 -27
- package/lib/_chunks-cjs/selector.get-focus-span.cjs.map +1 -0
- package/lib/_chunks-cjs/selector.get-text-before.cjs +3 -3
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +291 -168
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +1 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/{util.is-equal-selection-points.cjs → util.is-selection-collapsed.cjs} +7 -3
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -0
- package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
- package/lib/_chunks-cjs/util.slice-text-block.cjs +2 -6
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-es/{selector.is-selection-expanded.js → selector.get-focus-span.js} +27 -27
- package/lib/_chunks-es/selector.get-focus-span.js.map +1 -0
- package/lib/_chunks-es/selector.get-text-before.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +266 -143
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
- package/lib/_chunks-es/{util.is-equal-selection-points.js → util.is-selection-collapsed.js} +7 -3
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -0
- package/lib/_chunks-es/util.slice-blocks.js +2 -2
- package/lib/_chunks-es/util.slice-text-block.js +1 -5
- package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
- package/lib/behaviors/index.d.cts +3 -6
- package/lib/behaviors/index.d.ts +3 -6
- package/lib/index.cjs +357 -322
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +11 -20
- package/lib/index.d.ts +11 -20
- package/lib/index.js +296 -261
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +16 -16
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +3 -6
- package/lib/plugins/index.d.ts +3 -6
- package/lib/plugins/index.js +1 -1
- package/lib/selectors/index.cjs +14 -14
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +3 -6
- package/lib/selectors/index.d.ts +3 -6
- package/lib/selectors/index.js +2 -2
- package/lib/utils/index.cjs +9 -9
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +3 -6
- package/lib/utils/index.d.ts +3 -6
- package/lib/utils/index.js +5 -5
- package/package.json +3 -3
- package/src/behaviors/behavior.abstract.ts +2 -1
- package/src/behaviors/behavior.core.dnd.ts +4 -4
- package/src/editor/Editable.tsx +8 -1
- package/src/editor/create-slate-editor.tsx +0 -1
- package/src/editor/editor-dom.ts +3 -3
- package/src/editor/editor-selector.ts +1 -13
- package/src/editor/editor-snapshot.ts +4 -19
- package/src/editor/plugins/createWithEditableAPI.ts +52 -13
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +13 -4
- package/src/editor/plugins/with-plugins.ts +4 -8
- package/src/editor/range-decorations-machine.ts +24 -12
- package/src/internal-utils/create-test-snapshot.ts +2 -5
- package/src/internal-utils/paths.ts +65 -17
- package/src/internal-utils/ranges.test.ts +179 -0
- package/src/internal-utils/ranges.ts +39 -22
- package/src/internal-utils/test-editor.tsx +16 -1
- package/src/operations/behavior.operation.block.set.ts +10 -6
- package/src/operations/behavior.operation.block.unset.ts +10 -6
- package/src/operations/behavior.operation.child.set.ts +10 -6
- package/src/operations/behavior.operation.child.unset.ts +10 -6
- package/src/operations/behavior.operation.decorator.add.ts +17 -6
- package/src/operations/behavior.operation.delete.ts +8 -1
- package/src/operations/behavior.operation.insert.text.ts +34 -20
- package/src/operations/behavior.operation.move.block.ts +25 -3
- package/src/operations/behavior.operation.select.ts +9 -2
- package/src/selectors/selector.get-active-annotation-marks.ts +12 -0
- package/src/selectors/selector.get-active-annotations.ts +8 -20
- package/src/{editor/get-active-decorators.ts → selectors/selector.get-active-decorators.ts} +6 -11
- package/src/{internal-utils/mark-state.ts → selectors/selector.get-mark-state.ts} +41 -67
- package/src/selectors/selector.get-next-span.ts +56 -0
- package/src/selectors/selector.get-previous-span.ts +53 -0
- package/src/selectors/selector.is-active-annotation.ts +3 -1
- package/src/selectors/selector.is-active-decorator.ts +4 -1
- package/src/types/editor.ts +0 -2
- package/src/utils/util.is-selection-expanded.ts +13 -0
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +0 -1
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +0 -1
- package/lib/_chunks-es/util.is-equal-selection-points.js.map +0 -1
- package/src/editor/get-active-annotations.ts +0 -15
- package/src/editor/plugins/slate-plugin.update-mark-state.ts +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var types = require("@sanity/types"), util_sliceBlocks = require("./util.slice-blocks.cjs");
|
|
3
3
|
const getFocusBlock = (snapshot) => {
|
|
4
4
|
if (!snapshot.context.selection)
|
|
5
5
|
return;
|
|
@@ -10,35 +10,16 @@ const getFocusBlock = (snapshot) => {
|
|
|
10
10
|
_key: key
|
|
11
11
|
}]
|
|
12
12
|
} : void 0;
|
|
13
|
+
}, getSelectionStartPoint = (snapshot) => {
|
|
14
|
+
if (snapshot.context.selection)
|
|
15
|
+
return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
|
|
13
16
|
}, getFocusTextBlock = (snapshot) => {
|
|
14
17
|
const focusBlock = getFocusBlock(snapshot);
|
|
15
18
|
return focusBlock && util_sliceBlocks.isTextBlock(snapshot.context, focusBlock.node) ? {
|
|
16
19
|
node: focusBlock.node,
|
|
17
20
|
path: focusBlock.path
|
|
18
21
|
} : void 0;
|
|
19
|
-
},
|
|
20
|
-
if (!snapshot.context.selection)
|
|
21
|
-
return;
|
|
22
|
-
const focusBlock = getFocusTextBlock(snapshot);
|
|
23
|
-
if (!focusBlock)
|
|
24
|
-
return;
|
|
25
|
-
const key = util_sliceBlocks.getChildKeyFromSelectionPoint(snapshot.context.selection.focus), node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
|
|
26
|
-
return node && key ? {
|
|
27
|
-
node,
|
|
28
|
-
path: [...focusBlock.path, "children", {
|
|
29
|
-
_key: key
|
|
30
|
-
}]
|
|
31
|
-
} : void 0;
|
|
32
|
-
}, getFocusSpan = (snapshot) => {
|
|
33
|
-
const focusChild = getFocusChild(snapshot);
|
|
34
|
-
return focusChild && util_sliceBlocks.isSpan$1(snapshot.context, focusChild.node) ? {
|
|
35
|
-
node: focusChild.node,
|
|
36
|
-
path: focusChild.path
|
|
37
|
-
} : void 0;
|
|
38
|
-
}, getSelectionStartPoint = (snapshot) => {
|
|
39
|
-
if (snapshot.context.selection)
|
|
40
|
-
return snapshot.context.selection.backward ? snapshot.context.selection.focus : snapshot.context.selection.anchor;
|
|
41
|
-
}, isSelectionCollapsed = (snapshot) => snapshot.context.selection ? JSON.stringify(snapshot.context.selection.anchor.path) === JSON.stringify(snapshot.context.selection.focus.path) && snapshot.context.selection?.anchor.offset === snapshot.context.selection?.focus.offset : !1, getPreviousInlineObject = (snapshot) => {
|
|
22
|
+
}, getPreviousInlineObject = (snapshot) => {
|
|
42
23
|
const focusTextBlock = getFocusTextBlock(snapshot), selectionStartPoint = getSelectionStartPoint(snapshot), selectionStartPointChildKey = selectionStartPoint && types.isKeySegment(selectionStartPoint.path[2]) ? selectionStartPoint.path[2]._key : void 0;
|
|
43
24
|
if (!focusTextBlock || !selectionStartPointChildKey)
|
|
44
25
|
return;
|
|
@@ -46,7 +27,7 @@ const getFocusBlock = (snapshot) => {
|
|
|
46
27
|
for (const child of focusTextBlock.node.children) {
|
|
47
28
|
if (child._key === selectionStartPointChildKey)
|
|
48
29
|
break;
|
|
49
|
-
util_sliceBlocks.isSpan(snapshot.context, child) || (inlineObject = {
|
|
30
|
+
util_sliceBlocks.isSpan$1(snapshot.context, child) || (inlineObject = {
|
|
50
31
|
node: child,
|
|
51
32
|
path: [...focusTextBlock.path, "children", {
|
|
52
33
|
_key: child._key
|
|
@@ -69,7 +50,26 @@ const getFocusBlock = (snapshot) => {
|
|
|
69
50
|
context: snapshot.context,
|
|
70
51
|
blocks: slicedValue
|
|
71
52
|
});
|
|
72
|
-
}, getSelectionText = (snapshot) => getSelectedValue(snapshot).reduce((text, block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? text + block.children.reduce((text2, child) => util_sliceBlocks.isSpan
|
|
53
|
+
}, getSelectionText = (snapshot) => getSelectedValue(snapshot).reduce((text, block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? text + block.children.reduce((text2, child) => util_sliceBlocks.isSpan(snapshot.context, child) ? text2 + child.text : text2, "") : text, ""), isSelectionCollapsed = (snapshot) => snapshot.context.selection ? JSON.stringify(snapshot.context.selection.anchor.path) === JSON.stringify(snapshot.context.selection.focus.path) && snapshot.context.selection?.anchor.offset === snapshot.context.selection?.focus.offset : !1, isSelectionExpanded = (snapshot) => !isSelectionCollapsed(snapshot), getFocusChild = (snapshot) => {
|
|
54
|
+
if (!snapshot.context.selection)
|
|
55
|
+
return;
|
|
56
|
+
const focusBlock = getFocusTextBlock(snapshot);
|
|
57
|
+
if (!focusBlock)
|
|
58
|
+
return;
|
|
59
|
+
const key = util_sliceBlocks.getChildKeyFromSelectionPoint(snapshot.context.selection.focus), node = key ? focusBlock.node.children.find((span) => span._key === key) : void 0;
|
|
60
|
+
return node && key ? {
|
|
61
|
+
node,
|
|
62
|
+
path: [...focusBlock.path, "children", {
|
|
63
|
+
_key: key
|
|
64
|
+
}]
|
|
65
|
+
} : void 0;
|
|
66
|
+
}, getFocusSpan = (snapshot) => {
|
|
67
|
+
const focusChild = getFocusChild(snapshot);
|
|
68
|
+
return focusChild && util_sliceBlocks.isSpan(snapshot.context, focusChild.node) ? {
|
|
69
|
+
node: focusChild.node,
|
|
70
|
+
path: focusChild.path
|
|
71
|
+
} : void 0;
|
|
72
|
+
};
|
|
73
73
|
exports.getFocusBlock = getFocusBlock;
|
|
74
74
|
exports.getFocusChild = getFocusChild;
|
|
75
75
|
exports.getFocusSpan = getFocusSpan;
|
|
@@ -80,4 +80,4 @@ exports.getSelectionStartPoint = getSelectionStartPoint;
|
|
|
80
80
|
exports.getSelectionText = getSelectionText;
|
|
81
81
|
exports.isSelectionCollapsed = isSelectionCollapsed;
|
|
82
82
|
exports.isSelectionExpanded = isSelectionExpanded;
|
|
83
|
-
//# sourceMappingURL=selector.
|
|
83
|
+
//# sourceMappingURL=selector.get-focus-span.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.get-focus-span.cjs","sources":["../../src/selectors/selector.get-focus-block.ts","../../src/selectors/selector.get-selection-start-point.ts","../../src/selectors/selector.get-focus-text-block.ts","../../src/selectors/selector.get-previous-inline-object.ts","../../src/selectors/selector.get-selected-value.ts","../../src/selectors/selector.get-selection-text.ts","../../src/selectors/selector.is-selection-collapsed.ts","../../src/selectors/selector.is-selection-expanded.ts","../../src/selectors/selector.get-focus-child.ts","../../src/selectors/selector.get-focus-span.ts"],"sourcesContent":["import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const key = getBlockKeyFromSelectionPoint(snapshot.context.selection.focus)\n const index = key ? snapshot.blockIndexMap.get(key) : undefined\n\n const node =\n index !== undefined ? snapshot.context.value.at(index) : undefined\n\n return node && key ? {node, path: [{_key: key}]} : undefined\n}\n","import type {EditorSelectionPoint} from '..'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectionStartPoint: EditorSelector<\n EditorSelectionPoint | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n return snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * @public\n */\nexport const getFocusTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n return focusBlock && isTextBlock(snapshot.context, focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n","import {isKeySegment, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {isSpan} from '../utils'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getPreviousInlineObject: EditorSelector<\n | {\n node: PortableTextObject\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartPointChildKey =\n selectionStartPoint && isKeySegment(selectionStartPoint.path[2])\n ? selectionStartPoint.path[2]._key\n : undefined\n\n if (!focusTextBlock || !selectionStartPointChildKey) {\n return undefined\n }\n\n let inlineObject:\n | {\n node: PortableTextObject\n path: ChildPath\n }\n | undefined\n\n for (const child of focusTextBlock.node.children) {\n if (child._key === selectionStartPointChildKey) {\n break\n }\n\n if (!isSpan(snapshot.context, child)) {\n inlineObject = {\n node: child,\n path: [...focusTextBlock.path, 'children', {_key: child._key}],\n }\n }\n }\n\n return inlineObject\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport {\n getSelectionEndPoint,\n getSelectionStartPoint,\n sliceBlocks,\n} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return []\n }\n\n const startPoint = getSelectionStartPoint(selection)\n const endPoint = getSelectionEndPoint(selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return []\n }\n\n const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey)\n const endBlockIndex = snapshot.blockIndexMap.get(endBlockKey)\n\n if (startBlockIndex === undefined || endBlockIndex === undefined) {\n return []\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n return sliceBlocks({\n context: snapshot.context,\n blocks: slicedValue,\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedValue} from './selector.get-selected-value'\n\n/**\n * @public\n */\nexport const getSelectionText: EditorSelector<string> = (snapshot) => {\n const selectedValue = getSelectedValue(snapshot)\n\n return selectedValue.reduce((text, block) => {\n if (!isTextBlock(snapshot.context, block)) {\n return text\n }\n\n return (\n text +\n block.children.reduce((text, child) => {\n if (isSpan(snapshot.context, child)) {\n return text + child.text\n }\n\n return text\n }, '')\n )\n }, '')\n}\n","import type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const isSelectionCollapsed: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n return (\n JSON.stringify(snapshot.context.selection.anchor.path) ===\n JSON.stringify(snapshot.context.selection.focus.path) &&\n snapshot.context.selection?.anchor.offset ===\n snapshot.context.selection?.focus.offset\n )\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const isSelectionExpanded: EditorSelector<boolean> = (snapshot) => {\n return !isSelectionCollapsed(snapshot)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getChildKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\n\n/**\n * @public\n */\nexport const getFocusChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const focusBlock = getFocusTextBlock(snapshot)\n\n if (!focusBlock) {\n return undefined\n }\n\n const key = getChildKeyFromSelectionPoint(snapshot.context.selection.focus)\n\n const node = key\n ? focusBlock.node.children.find((span) => span._key === key)\n : undefined\n\n return node && key\n ? {node, path: [...focusBlock.path, 'children', {_key: key}]}\n : undefined\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan} from '../internal-utils/parse-blocks'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * @public\n */\nexport const getFocusSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && isSpan(snapshot.context, focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n"],"names":["getFocusBlock","snapshot","context","selection","key","getBlockKeyFromSelectionPoint","focus","index","blockIndexMap","get","undefined","node","value","at","path","_key","getSelectionStartPoint","backward","anchor","getFocusTextBlock","focusBlock","isTextBlock","getPreviousInlineObject","focusTextBlock","selectionStartPoint","selectionStartPointChildKey","isKeySegment","inlineObject","child","children","isSpan","getSelectedValue","startPoint","endPoint","getSelectionEndPoint","startBlockKey","endBlockKey","startBlockIndex","endBlockIndex","slicedValue","slice","sliceBlocks","blocks","getSelectionText","reduce","text","block","isSelectionCollapsed","JSON","stringify","offset","isSelectionExpanded","getFocusChild","getChildKeyFromSelectionPoint","find","span","getFocusSpan","focusChild"],"mappings":";;AAQO,MAAMA,gBAERC,CAAAA,aAAa;AAChB,MAAI,CAACA,SAASC,QAAQC;AACpB;AAGF,QAAMC,MAAMC,iBAAAA,8BAA8BJ,SAASC,QAAQC,UAAUG,KAAK,GACpEC,QAAQH,MAAMH,SAASO,cAAcC,IAAIL,GAAG,IAAIM,QAEhDC,OACJJ,UAAUG,SAAYT,SAASC,QAAQU,MAAMC,GAAGN,KAAK,IAAIG;AAE3D,SAAOC,QAAQP,MAAM;AAAA,IAACO;AAAAA,IAAMG,MAAM,CAAC;AAAA,MAACC,MAAMX;AAAAA,IAAAA,CAAI;AAAA,EAAA,IAAKM;AACrD,GChBaM,yBAERf,CAAAA,aAAa;AAChB,MAAKA,SAASC,QAAQC;AAItB,WAAOF,SAASC,QAAQC,UAAUc,WAC9BhB,SAASC,QAAQC,UAAUG,QAC3BL,SAASC,QAAQC,UAAUe;AACjC,GCPaC,oBAERlB,CAAAA,aAAa;AAChB,QAAMmB,aAAapB,cAAcC,QAAQ;AAEzC,SAAOmB,cAAcC,iBAAAA,YAAYpB,SAASC,SAASkB,WAAWT,IAAI,IAC9D;AAAA,IAACA,MAAMS,WAAWT;AAAAA,IAAMG,MAAMM,WAAWN;AAAAA,EAAAA,IACzCJ;AACN,GCPaY,0BAMRrB,CAAAA,aAAa;AAChB,QAAMsB,iBAAiBJ,kBAAkBlB,QAAQ,GAC3CuB,sBAAsBR,uBAAuBf,QAAQ,GACrDwB,8B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.cjs"),
|
|
2
|
+
var util_sliceBlocks = require("./util.slice-blocks.cjs"), selector_getFocusSpan = require("./selector.get-focus-span.cjs");
|
|
3
3
|
const getBlockTextBefore = (snapshot) => {
|
|
4
4
|
if (!snapshot.context.selection)
|
|
5
5
|
return "";
|
|
6
|
-
const startPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), block =
|
|
6
|
+
const startPoint = util_sliceBlocks.getSelectionStartPoint(snapshot.context.selection), block = selector_getFocusSpan.getFocusBlock({
|
|
7
7
|
...snapshot,
|
|
8
8
|
context: {
|
|
9
9
|
...snapshot.context,
|
|
@@ -19,7 +19,7 @@ const getBlockTextBefore = (snapshot) => {
|
|
|
19
19
|
context: snapshot.context,
|
|
20
20
|
block
|
|
21
21
|
});
|
|
22
|
-
return
|
|
22
|
+
return selector_getFocusSpan.getSelectionText({
|
|
23
23
|
...snapshot,
|
|
24
24
|
context: {
|
|
25
25
|
...snapshot.context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.get-text-before.cjs","sources":["../../src/selectors/selector.get-text-before.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectionStartPoint} from '../utils'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getFocusBlock} from './selector.get-focus-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const block = getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: startPoint,\n },\n },\n })\n}\n"],"names":["getBlockTextBefore","snapshot","context","selection","startPoint","getSelectionStartPoint","block","getFocusBlock","anchor","focus","startOfBlock","getBlockStartPoint","getSelectionText"],"mappings":";;AASO,MAAMA,qBAA8CC,CAAAA,aAAa;AACtE,MAAI,CAACA,SAASC,QAAQC;AACpB,WAAO;AAGT,QAAMC,aAAaC,iBAAAA,uBAAuBJ,SAASC,QAAQC,SAAS,GAC9DG,QAAQC,
|
|
1
|
+
{"version":3,"file":"selector.get-text-before.cjs","sources":["../../src/selectors/selector.get-text-before.ts"],"sourcesContent":["import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectionStartPoint} from '../utils'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getFocusBlock} from './selector.get-focus-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const block = getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: startPoint,\n },\n },\n })\n}\n"],"names":["getBlockTextBefore","snapshot","context","selection","startPoint","getSelectionStartPoint","block","getFocusBlock","anchor","focus","startOfBlock","getBlockStartPoint","getSelectionText"],"mappings":";;AASO,MAAMA,qBAA8CC,CAAAA,aAAa;AACtE,MAAI,CAACA,SAASC,QAAQC;AACpB,WAAO;AAGT,QAAMC,aAAaC,iBAAAA,uBAAuBJ,SAASC,QAAQC,SAAS,GAC9DG,QAAQC,oCAAc;AAAA,IAC1B,GAAGN;AAAAA,IACHC,SAAS;AAAA,MACP,GAAGD,SAASC;AAAAA,MACZC,WAAW;AAAA,QACTK,QAAQJ;AAAAA,QACRK,OAAOL;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AAED,MAAI,CAACE;AACH,WAAO;AAGT,QAAMI,eAAeC,iBAAAA,mBAAmB;AAAA,IACtCT,SAASD,SAASC;AAAAA,IAClBI;AAAAA,EAAAA,CACD;AAED,SAAOM,uCAAiB;AAAA,IACtB,GAAGX;AAAAA,IACHC,SAAS;AAAA,MACP,GAAGD,SAASC;AAAAA,MACZC,WAAW;AAAA,QACTK,QAAQE;AAAAA,QACRD,OAAOL;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH;;"}
|