@portabletext/editor 1.55.6 → 1.55.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/selector.get-text-before.cjs +3 -3
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +37 -37
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +9 -9
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +10 -10
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs +5 -5
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/{selection-point.cjs → util.slice-blocks.cjs} +14 -14
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -0
- package/lib/_chunks-cjs/util.slice-text-block.cjs +11 -11
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js +1 -1
- package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
- package/lib/_chunks-es/util.is-equal-selection-points.js +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/{selection-point.js → util.slice-blocks.js} +14 -14
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -0
- package/lib/_chunks-es/util.slice-text-block.js +1 -1
- package/lib/index.cjs +417 -194
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +6 -6
- package/lib/index.d.ts +6 -6
- package/lib/index.js +350 -127
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +11 -11
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2 -2
- package/lib/plugins/index.d.ts +2 -2
- package/lib/plugins/index.js +2 -2
- package/lib/selectors/index.cjs +7 -7
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.js +1 -1
- package/lib/utils/index.cjs +11 -11
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -2
- package/package.json +13 -13
- package/src/behaviors/behavior.abstract.keyboard.ts +28 -3
- package/src/behaviors/behavior.core.block-objects.ts +5 -3
- package/src/behaviors/behavior.core.decorators.ts +5 -5
- package/src/behaviors/behavior.core.lists.ts +5 -3
- package/src/editor/relay-machine.ts +2 -2
- package/src/keyboard-shortcuts/default-keyboard-shortcuts.ts +207 -0
- package/src/keyboard-shortcuts/is-keyboard-shortcut.test.ts +93 -0
- package/src/keyboard-shortcuts/is-keyboard-shortcut.ts +28 -0
- package/src/keyboard-shortcuts/keyboard-shortcuts.ts +120 -0
- package/src/selection/selection-point.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.ts +3 -3
- package/src/types/editor.ts +1 -1
- package/src/utils/util.slice-blocks.ts +2 -1
- package/lib/_chunks-cjs/selection-point.cjs.map +0 -1
- package/lib/_chunks-es/selection-point.js.map +0 -1
- package/src/behaviors/behavior.emoji-picker.ts +0 -402
- package/src/internal-utils/key-is.ts +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.is-selecting-entire-blocks.js","sources":["../../src/selectors/selector.get-selected-blocks.ts","../../src/selectors/selector.get-selection-end-point.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-next-inline-object.ts","../../src/selectors/selector.get-caret-word-selection.ts","../../src/selectors/selector.get-first-block.ts","../../src/selectors/selector.get-focus-block-object.ts","../../src/selectors/selector.get-focus-inline-object.ts","../../src/selectors/selector.get-focus-list-block.ts","../../src/selectors/selector.get-last-block.ts","../../src/selectors/selector.get-selection-end-block.ts","../../src/selectors/selector.get-next-block.ts","../../src/selectors/selector.get-selection-start-block.ts","../../src/selectors/selector.get-previous-block.ts","../../src/selectors/selector.get-selected-text-blocks.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts","../../src/selectors/selector.is-at-the-end-of-block.ts","../../src/selectors/selector.is-at-the-start-of-block.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts","../../src/selectors/selector.is-overlapping-selection.ts","../../src/selectors/selector.is-selecting-entire-blocks.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'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getSelectedBlocks: EditorSelector<\n Array<{node: PortableTextBlock; path: BlockPath}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks: Array<{node: PortableTextBlock; path: BlockPath}> = []\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const startKey = getBlockKeyFromSelectionPoint(startPoint)\n const endKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (!startKey || !endKey) {\n return selectedBlocks\n }\n\n const startBlockIndex = snapshot.blockIndexMap.get(startKey)\n const endBlockIndex = snapshot.blockIndexMap.get(endKey)\n\n if (startBlockIndex === undefined || endBlockIndex === undefined) {\n return selectedBlocks\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n for (const block of slicedValue) {\n if (block._key === startKey) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n\n if (startKey === endKey) {\n break\n }\n continue\n }\n\n if (block._key === endKey) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n break\n }\n\n if (selectedBlocks.length > 0) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n\n return selectedBlocks\n}\n","import type {EditorSelectionPoint} from '..'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectionEndPoint: 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.anchor\n : snapshot.context.selection.focus\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: ChildPath\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: ChildPath\n }> = []\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return selectedSpans\n }\n\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const startSpanKey = getChildKeyFromSelectionPoint(startPoint)\n const endSpanKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\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 selectedSpans\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n let startBlockFound = false\n\n for (const block of slicedValue) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isTextBlock(snapshot.context, block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import type {PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getFocusSpan} from './selector.get-focus-span'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectedSpans = getSelectedSpans(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n if (selectedSpans.length === 0 || !focusSpan) {\n return []\n }\n\n if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {\n if (snapshot.context.selection.focus.offset === 0) {\n return []\n }\n if (\n snapshot.context.selection.focus.offset === focusSpan.node.text.length\n ) {\n return []\n }\n }\n\n const activeAnnotations = snapshot.beta.activeAnnotations\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isTextBlock(snapshot.context, block.node)\n ? (block.node.markDefs ?? [])\n : [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n activeAnnotations.includes(markDef._key),\n )\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter((block) =>\n isTextBlock(snapshot.context, block),\n )\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter((block) =>\n isTextBlock(snapshot.context, block),\n )\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return 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 {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * @public\n */\nexport const getNextInlineObject: EditorSelector<\n | {\n node: PortableTextObject\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n const selectionEndPointChildKey =\n selectionEndPoint && isKeySegment(selectionEndPoint.path[2])\n ? selectionEndPoint.path[2]._key\n : undefined\n\n if (!focusTextBlock || !selectionEndPointChildKey) {\n return undefined\n }\n\n let endPointChildFound = false\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 === selectionEndPointChildKey) {\n endPointChildFound = true\n continue\n }\n\n if (!isSpan(snapshot.context, child) && endPointChildFound) {\n inlineObject = {\n node: child,\n path: [...focusTextBlock.path, 'children', {_key: child._key}],\n }\n break\n }\n }\n\n return inlineObject\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {\n blockOffsetToSpanSelectionPoint,\n getBlockEndPoint,\n getBlockStartPoint,\n spanSelectionPointToBlockOffset,\n} from '../utils'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getNextInlineObject} from './selector.get-next-inline-object'\nimport {getPreviousInlineObject} from './selector.get-previous-inline-object'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {getSelectionText} from './selector.get-selection-text'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n * Returns the selection of the of the word the caret is placed in.\n * Note: Only returns a word selection if the current selection is collapsed\n */\nexport const getCaretWordSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return null\n }\n\n if (!isSelectionCollapsed(snapshot)) {\n return null\n }\n\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartOffset = selectionStartPoint\n ? spanSelectionPointToBlockOffset({\n context: snapshot.context,\n selectionPoint: selectionStartPoint,\n })\n : undefined\n\n if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset) {\n return null\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n const blockStartPoint = getBlockStartPoint({\n context: snapshot.context,\n block: focusTextBlock,\n })\n const textBefore = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: previousInlineObject\n ? {path: previousInlineObject.path, offset: 0}\n : blockStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const textDirectlyBefore = textBefore.split(/\\s+/).at(-1)\n\n const nextInlineObject = getNextInlineObject(snapshot)\n const blockEndPoint = getBlockEndPoint({\n context: snapshot.context,\n block: focusTextBlock,\n })\n const textAfter = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: nextInlineObject\n ? {path: nextInlineObject.path, offset: 0}\n : blockEndPoint,\n },\n },\n })\n const textDirectlyAfter = textAfter.split(/\\s+/).at(0)\n\n if (\n (textDirectlyBefore === undefined || textDirectlyBefore === '') &&\n (textDirectlyAfter === undefined || textDirectlyAfter === '')\n ) {\n return null\n }\n\n const caretWordStartOffset: BlockOffset = textDirectlyBefore\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset - textDirectlyBefore.length,\n }\n : selectionStartOffset\n const caretWordEndOffset: BlockOffset = textDirectlyAfter\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset + textDirectlyAfter.length,\n }\n : selectionStartOffset\n\n const caretWordStartSelectionPoint = blockOffsetToSpanSelectionPoint({\n context: snapshot.context,\n blockOffset: caretWordStartOffset,\n direction: 'backward',\n })\n const caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({\n context: snapshot.context,\n blockOffset: caretWordEndOffset,\n direction: 'forward',\n })\n\n if (!caretWordStartSelectionPoint || !caretWordEndSelectionPoint) {\n return null\n }\n\n const caretWordSelection = {\n anchor: caretWordStartSelectionPoint,\n focus: caretWordEndSelectionPoint,\n }\n\n return isSelectionExpanded({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: caretWordSelection,\n },\n })\n ? caretWordSelection\n : null\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport const getFirstBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const node = snapshot.context.value[0]\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n","import type {PortableTextObject} 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 getFocusBlockObject: EditorSelector<\n {node: PortableTextObject; 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 {isPortableTextSpan, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n {node: PortableTextObject; path: ChildPath} | 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","import type {PortableTextListBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isListBlock} from '../internal-utils/parse-blocks'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\n\n/**\n * @public\n */\nexport const getFocusListBlock: EditorSelector<\n {node: PortableTextListBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n\n return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node)\n ? {node: focusTextBlock.node, path: focusTextBlock.path}\n : undefined\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport const getLastBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const node = snapshot.context.value[snapshot.context.value.length - 1]\n ? snapshot.context.value[snapshot.context.value.length - 1]\n : undefined\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * @public\n */\nexport const getSelectionEndBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: BlockPath\n }\n | undefined\n> = (snapshot) => {\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n if (!endPoint) {\n return undefined\n }\n\n return getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndBlock} from './selector.get-selection-end-block'\n\n/**\n * @public\n */\nexport const getNextBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selectionEndBlock = getSelectionEndBlock(snapshot)\n\n if (!selectionEndBlock) {\n return undefined\n }\n\n const index = snapshot.blockIndexMap.get(selectionEndBlock.node._key)\n\n if (index === undefined || index === snapshot.context.value.length - 1) {\n return undefined\n }\n\n const nextBlock = snapshot.context.value.at(index + 1)\n\n return nextBlock\n ? {node: nextBlock, path: [{_key: nextBlock._key}]}\n : undefined\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * @public\n */\nexport const getSelectionStartBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: BlockPath\n }\n | undefined\n> = (snapshot) => {\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n if (!startPoint) {\n return undefined\n }\n\n return getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionStartBlock} from './selector.get-selection-start-block'\n\n/**\n * @public\n */\nexport const getPreviousBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selectionStartBlock = getSelectionStartBlock(snapshot)\n\n if (!selectionStartBlock) {\n return undefined\n }\n\n const index = snapshot.blockIndexMap.get(selectionStartBlock.node._key)\n\n if (index === undefined || index === 0) {\n return undefined\n }\n\n const previousBlock = snapshot.context.value.at(index - 1)\n\n return previousBlock\n ? {node: previousBlock, path: [{_key: previousBlock._key}]}\n : undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndPoint, getSelectionStartPoint} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedTextBlocks: EditorSelector<\n Array<{node: PortableTextTextBlock; path: BlockPath}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedTextBlocks: Array<{\n node: PortableTextTextBlock\n path: BlockPath\n }> = []\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return selectedTextBlocks\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 selectedTextBlocks\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n for (const block of slicedValue) {\n if (block._key === startBlockKey) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n continue\n }\n\n if (block._key === endBlockKey) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n break\n }\n\n if (selectedTextBlocks.length > 0) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n }\n\n return selectedTextBlocks\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {\n getSelectionEndPoint,\n getSelectionStartPoint,\n isEmptyTextBlock,\n} from '../utils'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\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 snapshot.context.selection\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of slicedValue) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (\n isTextBlock(snapshot.context, block) &&\n isEmptyTextBlock(snapshot.context, block)\n ) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isTextBlock(snapshot.context, block)) {\n continue\n }\n\n if (\n block._key === endBlockKey &&\n isEmptyTextBlock(snapshot.context, block)\n ) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isSpan(snapshot.context, child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isSpan(snapshot.context, child) && block.children.length === 1\n\n if (\n (isSpan(snapshot.context, child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isSpan(snapshot.context, child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isSpan(snapshot.context, child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (\n focusTextBlock &&\n !isEmptyTextBlock(snapshot.context, focusTextBlock.node)\n ) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isTextBlock(snapshot.context, block.node)\n ? (block.node.markDefs ?? [])\n : [],\n )\n const activeMarkDefs = selectionMarkDefs.filter(\n (markDef) =>\n markDef._type === annotation &&\n snapshot.beta.activeAnnotations.includes(markDef._key),\n )\n\n return activeMarkDefs.length > 0\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.beta.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport * as utils from '../utils'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheEndOfBlock(block: {\n node: PortableTextBlock\n path: BlockPath\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockEndPoint = utils.getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockEndPoint,\n )\n }\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport * as utils from '../utils'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheStartOfBlock(block: {\n node: PortableTextBlock\n path: BlockPath\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockStartPoint = utils.getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockStartPoint,\n )\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionEndPoint} from '../utils'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n const pointBlockKey = getBlockKeyFromSelectionPoint(point)\n const pointChildKey = getChildKeyFromSelectionPoint(point)\n\n if (!pointBlockKey || !endBlockKey) {\n return false\n }\n\n const pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey)\n const endBlockIndex = snapshot.blockIndexMap.get(endBlockKey)\n\n if (pointBlockIndex === undefined || endBlockIndex === undefined) {\n return false\n }\n\n if (pointBlockIndex > endBlockIndex) {\n // The point block is after the end block.\n return true\n }\n\n if (pointBlockIndex < endBlockIndex) {\n // The point block is before the end block.\n return false\n }\n\n // The point block is the same as the end block.\n const pointBlock = snapshot.context.value.at(pointBlockIndex)\n\n if (!pointBlock) {\n // The point block is not in the value.\n return false\n }\n\n if (!isTextBlock(snapshot.context, pointBlock)) {\n // The point block is not a text block.\n // Since the point block is the same as the end block, the point is not\n // after the selection.\n return false\n }\n\n let pointChildIndex: number | undefined\n let endChildIndex: number | undefined\n\n let childIndex = -1\n\n // The point block is the same as the end block, so we need to find the\n // child indices and compare them.\n for (const child of pointBlock.children) {\n childIndex++\n\n if (child._key === pointChildKey && child._key === endChildKey) {\n return point.offset > endPoint.offset\n }\n\n if (child._key === pointChildKey) {\n pointChildIndex = childIndex\n }\n\n if (child._key === endChildKey) {\n endChildIndex = childIndex\n }\n\n if (pointChildIndex !== undefined && endChildIndex !== undefined) {\n break\n }\n }\n\n if (pointChildIndex === undefined || endChildIndex === undefined) {\n return false\n }\n\n return pointChildIndex > endChildIndex\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionStartPoint} from '../utils'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n\n const pointBlockKey = getBlockKeyFromSelectionPoint(point)\n const pointChildKey = getChildKeyFromSelectionPoint(point)\n\n if (!pointBlockKey || !startBlockKey) {\n return false\n }\n\n const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey)\n const pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey)\n\n if (startBlockIndex === undefined || pointBlockIndex === undefined) {\n return false\n }\n\n if (pointBlockIndex < startBlockIndex) {\n // The point block is before the start block.\n return true\n }\n\n if (pointBlockIndex > startBlockIndex) {\n // The point block is after the start block.\n return false\n }\n\n // The point block is the same as the start block.\n const pointBlock = snapshot.context.value.at(pointBlockIndex)\n\n if (!pointBlock) {\n // The point block is not in the value.\n return false\n }\n\n if (!isTextBlock(snapshot.context, pointBlock)) {\n // The point block is not a text block.\n // Since the point block is the same as the start block, the point is not\n // before the selection.\n return false\n }\n\n let pointChildIndex: number | undefined\n let startChildIndex: number | undefined\n\n let childIndex = -1\n\n // The point block is the same as the start block, so we need to find the\n // child indices and compare them.\n for (const child of pointBlock.children) {\n childIndex++\n\n if (child._key === pointChildKey && child._key === startChildKey) {\n return point.offset < startPoint.offset\n }\n\n if (child._key === pointChildKey) {\n pointChildIndex = childIndex\n }\n\n if (child._key === startChildKey) {\n startChildIndex = childIndex\n }\n\n if (pointChildIndex !== undefined && startChildIndex !== undefined) {\n break\n }\n }\n\n if (pointChildIndex === undefined || startChildIndex === undefined) {\n return false\n }\n\n return pointChildIndex < startChildIndex\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from '../utils'\nimport type {EditorSelector} from './../editor/editor-selector'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isPointAfterSelection} from './selector.is-point-after-selection'\nimport {isPointBeforeSelection} from './selector.is-point-before-selection'\n\n/**\n * @public\n */\nexport function isOverlappingSelection(\n selection: EditorSelection,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!selection || !snapshot.context.selection) {\n return false\n }\n\n const selectionStartPoint = getSelectionStartPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n const selectionEndPoint = getSelectionEndPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n\n const originalSelectionStartPoint = getSelectionStartPoint(snapshot)\n const originalSelectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (\n !selectionStartPoint ||\n !selectionEndPoint ||\n !originalSelectionStartPoint ||\n !originalSelectionEndPoint\n ) {\n return false\n }\n\n const startPointBeforeSelection =\n isPointBeforeSelection(selectionStartPoint)(snapshot)\n const startPointAfterSelection =\n isPointAfterSelection(selectionStartPoint)(snapshot)\n const endPointBeforeSelection =\n isPointBeforeSelection(selectionEndPoint)(snapshot)\n const endPointAfterSelection =\n isPointAfterSelection(selectionEndPoint)(snapshot)\n\n const originalStartPointBeforeStartPoint = isPointBeforeSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const originalStartPointAfterStartPoint = isPointAfterSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n\n const originalEndPointBeforeEndPoint = isPointBeforeSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n const originalEndPointAfterEndPoint = isPointAfterSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n\n const endPointEqualToOriginalStartPoint = isEqualSelectionPoints(\n selectionEndPoint,\n originalSelectionStartPoint,\n )\n const startPointEqualToOriginalEndPoint = isEqualSelectionPoints(\n selectionStartPoint,\n originalSelectionEndPoint,\n )\n\n if (endPointBeforeSelection && !endPointEqualToOriginalStartPoint) {\n return false\n }\n\n if (startPointAfterSelection && !startPointEqualToOriginalEndPoint) {\n return false\n }\n\n if (\n !originalStartPointBeforeStartPoint &&\n originalStartPointAfterStartPoint &&\n !originalEndPointBeforeEndPoint &&\n originalEndPointAfterEndPoint\n ) {\n return !endPointEqualToOriginalStartPoint\n }\n\n if (\n originalStartPointBeforeStartPoint &&\n !originalStartPointAfterStartPoint &&\n originalEndPointBeforeEndPoint &&\n !originalEndPointAfterEndPoint\n ) {\n return !startPointEqualToOriginalEndPoint\n }\n\n if (\n !startPointAfterSelection ||\n !startPointBeforeSelection ||\n !endPointAfterSelection ||\n !endPointBeforeSelection\n ) {\n return true\n }\n\n return false\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock} from './selector.get-selection-end-block'\nimport {getSelectionStartBlock} from './selector.get-selection-start-block'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint({\n context: snapshot.context,\n block: startBlock,\n })\n const endBlockEndPoint = utils.getBlockEndPoint({\n context: snapshot.context,\n block: endBlock,\n })\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n"],"names":["getSelectedBlocks","snapshot","context","selection","selectedBlocks","startPoint","getSelectionStartPoint","endPoint","getSelectionEndPoint","startKey","getBlockKeyFromSelectionPoint","endKey","startBlockIndex","blockIndexMap","get","endBlockIndex","undefined","slicedValue","value","slice","block","_key","push","node","path","length","backward","anchor","focus","getSelectedSpans","selectedSpans","startBlockKey","endBlockKey","startSpanKey","getChildKeyFromSelectionPoint","endSpanKey","startBlockFound","isTextBlock","child","children","isSpan","offset","text","getActiveAnnotations","focusSpan","getFocusSpan","isSelectionCollapsed","activeAnnotations","beta","flatMap","markDefs","filter","markDef","includes","getActiveListItem","selectedTextBlocks","map","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getNextInlineObject","focusTextBlock","getFocusTextBlock","selectionEndPoint","selectionEndPointChildKey","isKeySegment","endPointChildFound","inlineObject","getCaretWordSelection","selectionStartPoint","selectionStartOffset","spanSelectionPointToBlockOffset","selectionPoint","previousInlineObject","getPreviousInlineObject","blockStartPoint","getBlockStartPoint","textDirectlyBefore","getSelectionText","split","nextInlineObject","blockEndPoint","getBlockEndPoint","textDirectlyAfter","caretWordStartOffset","caretWordEndOffset","caretWordStartSelectionPoint","blockOffsetToSpanSelectionPoint","blockOffset","direction","caretWordEndSelectionPoint","caretWordSelection","isSelectionExpanded","getFirstBlock","getFocusBlockObject","focusBlock","getFocusBlock","getFocusInlineObject","focusChild","getFocusChild","isPortableTextSpan","getFocusListBlock","isListBlock","getLastBlock","getSelectionEndBlock","getNextBlock","selectionEndBlock","index","nextBlock","getSelectionStartBlock","getPreviousBlock","selectionStartBlock","previousBlock","getSelectedTextBlocks","getTrimmedSelection","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","span","lonelySpan","trimmedSelection","isActiveAnnotation","annotation","_type","isActiveDecorator","decorator","marks","activeDecorators","isActiveListItem","isActiveStyle","isAtTheEndOfBlock","utils","isAtTheStartOfBlock","isPointAfterSelection","point","pointBlockKey","pointChildKey","pointBlockIndex","pointBlock","pointChildIndex","endChildIndex","childIndex","isPointBeforeSelection","startChildIndex","isOverlappingSelection","originalSelectionStartPoint","originalSelectionEndPoint","startPointBeforeSelection","startPointAfterSelection","endPointBeforeSelection","endPointAfterSelection","originalStartPointBeforeStartPoint","originalStartPointAfterStartPoint","originalEndPointBeforeEndPoint","originalEndPointAfterEndPoint","endPointEqualToOriginalStartPoint","isEqualSelectionPoints","startPointEqualToOriginalEndPoint","isSelectingEntireBlocks","startBlock","endBlock","startBlockStartPoint","endBlockEndPoint"],"mappings":";;;;AAUO,MAAMA,oBAERC,CAAAA,aAAa;AAChB,MAAI,CAACA,SAASC,QAAQC;AACpB,WAAO,CAAA;AAGT,QAAMC,iBAAoE,CAAA,GACpEC,aAAaC,uBAAuBL,SAASC,QAAQC,SAAS,GAC9DI,WAAWC,uBAAqBP,SAASC,QAAQC,SAAS,GAC1DM,WAAWC,8BAA8BL,UAAU,GACnDM,SAASD,8BAA8BH,QAAQ;AAErD,MAAI,CAACE,YAAY,CAACE;AAChB,WAAOP;AAGT,QAAMQ,kBAAkBX,SAASY,cAAcC,IAAIL,QAAQ,GACrDM,gBAAgBd,SAASY,cAAcC,IAAIH,MAAM;AAEvD,MAAIC,oBAAoBI,UAA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AED,SACE7B,uBAA6B8B,sBAAsBvK,UAAU,KAC7DyI,uBAA6B+B,kBAAkBtK,QAAQ;AAE3D;"}
|
|
1
|
+
{"version":3,"file":"selector.is-selecting-entire-blocks.js","sources":["../../src/selectors/selector.get-selected-blocks.ts","../../src/selectors/selector.get-selection-end-point.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-next-inline-object.ts","../../src/selectors/selector.get-caret-word-selection.ts","../../src/selectors/selector.get-first-block.ts","../../src/selectors/selector.get-focus-block-object.ts","../../src/selectors/selector.get-focus-inline-object.ts","../../src/selectors/selector.get-focus-list-block.ts","../../src/selectors/selector.get-last-block.ts","../../src/selectors/selector.get-selection-end-block.ts","../../src/selectors/selector.get-next-block.ts","../../src/selectors/selector.get-selection-start-block.ts","../../src/selectors/selector.get-previous-block.ts","../../src/selectors/selector.get-selected-text-blocks.ts","../../src/selectors/selector.get-trimmed-selection.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts","../../src/selectors/selector.is-at-the-end-of-block.ts","../../src/selectors/selector.is-at-the-start-of-block.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts","../../src/selectors/selector.is-overlapping-selection.ts","../../src/selectors/selector.is-selecting-entire-blocks.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'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getSelectedBlocks: EditorSelector<\n Array<{node: PortableTextBlock; path: BlockPath}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks: Array<{node: PortableTextBlock; path: BlockPath}> = []\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const startKey = getBlockKeyFromSelectionPoint(startPoint)\n const endKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (!startKey || !endKey) {\n return selectedBlocks\n }\n\n const startBlockIndex = snapshot.blockIndexMap.get(startKey)\n const endBlockIndex = snapshot.blockIndexMap.get(endKey)\n\n if (startBlockIndex === undefined || endBlockIndex === undefined) {\n return selectedBlocks\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n for (const block of slicedValue) {\n if (block._key === startKey) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n\n if (startKey === endKey) {\n break\n }\n continue\n }\n\n if (block._key === endKey) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n break\n }\n\n if (selectedBlocks.length > 0) {\n selectedBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n\n return selectedBlocks\n}\n","import type {EditorSelectionPoint} from '..'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getSelectionEndPoint: 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.anchor\n : snapshot.context.selection.focus\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: ChildPath\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedSpans: Array<{\n node: PortableTextSpan\n path: ChildPath\n }> = []\n\n const startPoint = getSelectionStartPoint(snapshot)\n const endPoint = getSelectionEndPoint(snapshot)\n\n if (!startPoint || !endPoint) {\n return selectedSpans\n }\n\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const startSpanKey = getChildKeyFromSelectionPoint(startPoint)\n const endSpanKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return selectedSpans\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 selectedSpans\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n let startBlockFound = false\n\n for (const block of slicedValue) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n }\n\n if (!isTextBlock(snapshot.context, block)) {\n continue\n }\n\n if (block._key === startBlockKey) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n if (startSpanKey && child._key === startSpanKey) {\n if (startPoint.offset < child.text.length) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n if (startSpanKey === endSpanKey) {\n break\n }\n\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n if (selectedSpans.length > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n if (block._key === endBlockKey) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n if (endSpanKey && child._key === endSpanKey) {\n if (endPoint.offset > 0) {\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n break\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n\n break\n }\n\n if (startBlockFound) {\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n continue\n }\n\n selectedSpans.push({\n node: child,\n path: [{_key: block._key}, 'children', {_key: child._key}],\n })\n }\n }\n }\n\n return selectedSpans\n}\n","import type {PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getFocusSpan} from './selector.get-focus-span'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectedSpans = getSelectedSpans(snapshot)\n const focusSpan = getFocusSpan(snapshot)\n\n if (selectedSpans.length === 0 || !focusSpan) {\n return []\n }\n\n if (selectedSpans.length === 1 && isSelectionCollapsed(snapshot)) {\n if (snapshot.context.selection.focus.offset === 0) {\n return []\n }\n if (\n snapshot.context.selection.focus.offset === focusSpan.node.text.length\n ) {\n return []\n }\n }\n\n const activeAnnotations = snapshot.beta.activeAnnotations\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isTextBlock(snapshot.context, block.node)\n ? (block.node.markDefs ?? [])\n : [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n activeAnnotations.includes(markDef._key),\n )\n}\n","import type {PortableTextListBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter((block) =>\n isTextBlock(snapshot.context, block),\n )\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedBlocks = getSelectedBlocks(snapshot).map((block) => block.node)\n const selectedTextBlocks = selectedBlocks.filter((block) =>\n isTextBlock(snapshot.context, block),\n )\n\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstStyle = firstTextBlock.style\n\n if (!firstStyle) {\n return undefined\n }\n\n if (selectedTextBlocks.every((block) => block.style === firstStyle)) {\n return firstStyle\n }\n\n return 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 {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * @public\n */\nexport const getNextInlineObject: EditorSelector<\n | {\n node: PortableTextObject\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n const selectionEndPointChildKey =\n selectionEndPoint && isKeySegment(selectionEndPoint.path[2])\n ? selectionEndPoint.path[2]._key\n : undefined\n\n if (!focusTextBlock || !selectionEndPointChildKey) {\n return undefined\n }\n\n let endPointChildFound = false\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 === selectionEndPointChildKey) {\n endPointChildFound = true\n continue\n }\n\n if (!isSpan(snapshot.context, child) && endPointChildFound) {\n inlineObject = {\n node: child,\n path: [...focusTextBlock.path, 'children', {_key: child._key}],\n }\n break\n }\n }\n\n return inlineObject\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {\n blockOffsetToSpanSelectionPoint,\n spanSelectionPointToBlockOffset,\n} from '../utils/util.block-offset'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getNextInlineObject} from './selector.get-next-inline-object'\nimport {getPreviousInlineObject} from './selector.get-previous-inline-object'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {getSelectionText} from './selector.get-selection-text'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n * Returns the selection of the of the word the caret is placed in.\n * Note: Only returns a word selection if the current selection is collapsed\n */\nexport const getCaretWordSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return null\n }\n\n if (!isSelectionCollapsed(snapshot)) {\n return null\n }\n\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartOffset = selectionStartPoint\n ? spanSelectionPointToBlockOffset({\n context: snapshot.context,\n selectionPoint: selectionStartPoint,\n })\n : undefined\n\n if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset) {\n return null\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n const blockStartPoint = getBlockStartPoint({\n context: snapshot.context,\n block: focusTextBlock,\n })\n const textBefore = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: previousInlineObject\n ? {path: previousInlineObject.path, offset: 0}\n : blockStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const textDirectlyBefore = textBefore.split(/\\s+/).at(-1)\n\n const nextInlineObject = getNextInlineObject(snapshot)\n const blockEndPoint = getBlockEndPoint({\n context: snapshot.context,\n block: focusTextBlock,\n })\n const textAfter = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: nextInlineObject\n ? {path: nextInlineObject.path, offset: 0}\n : blockEndPoint,\n },\n },\n })\n const textDirectlyAfter = textAfter.split(/\\s+/).at(0)\n\n if (\n (textDirectlyBefore === undefined || textDirectlyBefore === '') &&\n (textDirectlyAfter === undefined || textDirectlyAfter === '')\n ) {\n return null\n }\n\n const caretWordStartOffset: BlockOffset = textDirectlyBefore\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset - textDirectlyBefore.length,\n }\n : selectionStartOffset\n const caretWordEndOffset: BlockOffset = textDirectlyAfter\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset + textDirectlyAfter.length,\n }\n : selectionStartOffset\n\n const caretWordStartSelectionPoint = blockOffsetToSpanSelectionPoint({\n context: snapshot.context,\n blockOffset: caretWordStartOffset,\n direction: 'backward',\n })\n const caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({\n context: snapshot.context,\n blockOffset: caretWordEndOffset,\n direction: 'forward',\n })\n\n if (!caretWordStartSelectionPoint || !caretWordEndSelectionPoint) {\n return null\n }\n\n const caretWordSelection = {\n anchor: caretWordStartSelectionPoint,\n focus: caretWordEndSelectionPoint,\n }\n\n return isSelectionExpanded({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: caretWordSelection,\n },\n })\n ? caretWordSelection\n : null\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport const getFirstBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const node = snapshot.context.value[0]\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n","import type {PortableTextObject} 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 getFocusBlockObject: EditorSelector<\n {node: PortableTextObject; 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 {isPortableTextSpan, type PortableTextObject} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n {node: PortableTextObject; path: ChildPath} | 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","import type {PortableTextListBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isListBlock} from '../internal-utils/parse-blocks'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\n\n/**\n * @public\n */\nexport const getFocusListBlock: EditorSelector<\n {node: PortableTextListBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n\n return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node)\n ? {node: focusTextBlock.node, path: focusTextBlock.path}\n : undefined\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport const getLastBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const node = snapshot.context.value[snapshot.context.value.length - 1]\n ? snapshot.context.value[snapshot.context.value.length - 1]\n : undefined\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * @public\n */\nexport const getSelectionEndBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: BlockPath\n }\n | undefined\n> = (snapshot) => {\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n if (!endPoint) {\n return undefined\n }\n\n return getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndBlock} from './selector.get-selection-end-block'\n\n/**\n * @public\n */\nexport const getNextBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selectionEndBlock = getSelectionEndBlock(snapshot)\n\n if (!selectionEndBlock) {\n return undefined\n }\n\n const index = snapshot.blockIndexMap.get(selectionEndBlock.node._key)\n\n if (index === undefined || index === snapshot.context.value.length - 1) {\n return undefined\n }\n\n const nextBlock = snapshot.context.value.at(index + 1)\n\n return nextBlock\n ? {node: nextBlock, path: [{_key: nextBlock._key}]}\n : undefined\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * @public\n */\nexport const getSelectionStartBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: BlockPath\n }\n | undefined\n> = (snapshot) => {\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n if (!startPoint) {\n return undefined\n }\n\n return getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionStartBlock} from './selector.get-selection-start-block'\n\n/**\n * @public\n */\nexport const getPreviousBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selectionStartBlock = getSelectionStartBlock(snapshot)\n\n if (!selectionStartBlock) {\n return undefined\n }\n\n const index = snapshot.blockIndexMap.get(selectionStartBlock.node._key)\n\n if (index === undefined || index === 0) {\n return undefined\n }\n\n const previousBlock = snapshot.context.value.at(index - 1)\n\n return previousBlock\n ? {node: previousBlock, path: [{_key: previousBlock._key}]}\n : undefined\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getBlockKeyFromSelectionPoint} from '../selection/selection-point'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndPoint, getSelectionStartPoint} from '../utils'\n\n/**\n * @public\n */\nexport const getSelectedTextBlocks: EditorSelector<\n Array<{node: PortableTextTextBlock; path: BlockPath}>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedTextBlocks: Array<{\n node: PortableTextTextBlock\n path: BlockPath\n }> = []\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return selectedTextBlocks\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 selectedTextBlocks\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n for (const block of slicedValue) {\n if (block._key === startBlockKey) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n continue\n }\n\n if (block._key === endBlockKey) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n\n break\n }\n\n if (selectedTextBlocks.length > 0) {\n if (isTextBlock(snapshot.context, block)) {\n selectedTextBlocks.push({node: block, path: [{_key: block._key}]})\n }\n }\n }\n\n return selectedTextBlocks\n}\n","import type {PortableTextSpan} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport {\n getSelectionEndPoint,\n getSelectionStartPoint,\n isEmptyTextBlock,\n} from '../utils'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const getTrimmedSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return snapshot.context.selection\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return snapshot.context.selection\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 snapshot.context.selection\n }\n\n const slicedValue = snapshot.context.value.slice(\n startBlockIndex,\n endBlockIndex + 1,\n )\n\n let startBlockFound = false\n let adjustedStartPoint: EditorSelectionPoint | undefined\n let trimStartPoint = false\n let adjustedEndPoint: EditorSelectionPoint | undefined\n let trimEndPoint = false\n let previousPotentialEndpoint:\n | {blockKey: string; span: PortableTextSpan}\n | undefined\n\n for (const block of slicedValue) {\n if (block._key === startBlockKey) {\n startBlockFound = true\n\n if (\n isTextBlock(snapshot.context, block) &&\n isEmptyTextBlock(snapshot.context, block)\n ) {\n continue\n }\n }\n\n if (!startBlockFound) {\n continue\n }\n\n if (!isTextBlock(snapshot.context, block)) {\n continue\n }\n\n if (\n block._key === endBlockKey &&\n isEmptyTextBlock(snapshot.context, block)\n ) {\n break\n }\n\n for (const child of block.children) {\n if (child._key === endChildKey) {\n if (!isSpan(snapshot.context, child) || endPoint.offset === 0) {\n adjustedEndPoint = previousPotentialEndpoint\n ? {\n path: [\n {_key: previousPotentialEndpoint.blockKey},\n 'children',\n {_key: previousPotentialEndpoint.span._key},\n ],\n offset: previousPotentialEndpoint.span.text.length,\n }\n : undefined\n\n trimEndPoint = true\n break\n }\n }\n\n if (trimStartPoint) {\n const lonelySpan =\n isSpan(snapshot.context, child) && block.children.length === 1\n\n if (\n (isSpan(snapshot.context, child) && child.text.length > 0) ||\n lonelySpan\n ) {\n adjustedStartPoint = {\n path: [{_key: block._key}, 'children', {_key: child._key}],\n offset: 0,\n }\n previousPotentialEndpoint = {blockKey: block._key, span: child}\n trimStartPoint = false\n }\n\n continue\n }\n\n if (child._key === startChildKey) {\n if (!isSpan(snapshot.context, child)) {\n trimStartPoint = true\n continue\n }\n\n if (startPoint.offset === child.text.length) {\n trimStartPoint = true\n previousPotentialEndpoint =\n child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n continue\n }\n }\n\n previousPotentialEndpoint =\n isSpan(snapshot.context, child) && child.text.length > 0\n ? {blockKey: block._key, span: child}\n : previousPotentialEndpoint\n }\n\n if (block._key === endBlockKey) {\n break\n }\n }\n\n const trimmedSelection = snapshot.context.selection.backward\n ? {\n anchor: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n focus: adjustedStartPoint ?? startPoint,\n backward: true,\n }\n : {\n anchor: adjustedStartPoint ?? startPoint,\n focus: trimEndPoint && adjustedEndPoint ? adjustedEndPoint : endPoint,\n }\n\n if (\n isSelectionCollapsed({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n ) {\n const focusTextBlock = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: trimmedSelection,\n },\n })\n\n if (\n focusTextBlock &&\n !isEmptyTextBlock(snapshot.context, focusTextBlock.node)\n ) {\n return null\n }\n }\n\n return trimmedSelection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {getSelectedBlocks} from './selector.get-selected-blocks'\n\n/**\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n): EditorSelector<boolean> {\n return (snapshot) => {\n const selectedBlocks = getSelectedBlocks(snapshot)\n const selectionMarkDefs = selectedBlocks.flatMap((block) =>\n isTextBlock(snapshot.context, block.node)\n ? (block.node.markDefs ?? [])\n : [],\n )\n const activeMarkDefs = selectionMarkDefs.filter(\n (markDef) =>\n markDef._type === annotation &&\n snapshot.beta.activeAnnotations.includes(markDef._key),\n )\n\n return activeMarkDefs.length > 0\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n return (\n selectedSpans.length > 0 &&\n selectedSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n return snapshot.beta.activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport * as utils from '../utils'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheEndOfBlock(block: {\n node: PortableTextBlock\n path: BlockPath\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockEndPoint = utils.getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockEndPoint,\n )\n }\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport * as utils from '../utils'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheStartOfBlock(block: {\n node: PortableTextBlock\n path: BlockPath\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockStartPoint = utils.getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return utils.isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockStartPoint,\n )\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionEndPoint} from '../utils'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n const pointBlockKey = getBlockKeyFromSelectionPoint(point)\n const pointChildKey = getChildKeyFromSelectionPoint(point)\n\n if (!pointBlockKey || !endBlockKey) {\n return false\n }\n\n const pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey)\n const endBlockIndex = snapshot.blockIndexMap.get(endBlockKey)\n\n if (pointBlockIndex === undefined || endBlockIndex === undefined) {\n return false\n }\n\n if (pointBlockIndex > endBlockIndex) {\n // The point block is after the end block.\n return true\n }\n\n if (pointBlockIndex < endBlockIndex) {\n // The point block is before the end block.\n return false\n }\n\n // The point block is the same as the end block.\n const pointBlock = snapshot.context.value.at(pointBlockIndex)\n\n if (!pointBlock) {\n // The point block is not in the value.\n return false\n }\n\n if (!isTextBlock(snapshot.context, pointBlock)) {\n // The point block is not a text block.\n // Since the point block is the same as the end block, the point is not\n // after the selection.\n return false\n }\n\n let pointChildIndex: number | undefined\n let endChildIndex: number | undefined\n\n let childIndex = -1\n\n // The point block is the same as the end block, so we need to find the\n // child indices and compare them.\n for (const child of pointBlock.children) {\n childIndex++\n\n if (child._key === pointChildKey && child._key === endChildKey) {\n return point.offset > endPoint.offset\n }\n\n if (child._key === pointChildKey) {\n pointChildIndex = childIndex\n }\n\n if (child._key === endChildKey) {\n endChildIndex = childIndex\n }\n\n if (pointChildIndex !== undefined && endChildIndex !== undefined) {\n break\n }\n }\n\n if (pointChildIndex === undefined || endChildIndex === undefined) {\n return false\n }\n\n return pointChildIndex > endChildIndex\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionStartPoint} from '../utils'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n\n const pointBlockKey = getBlockKeyFromSelectionPoint(point)\n const pointChildKey = getChildKeyFromSelectionPoint(point)\n\n if (!pointBlockKey || !startBlockKey) {\n return false\n }\n\n const startBlockIndex = snapshot.blockIndexMap.get(startBlockKey)\n const pointBlockIndex = snapshot.blockIndexMap.get(pointBlockKey)\n\n if (startBlockIndex === undefined || pointBlockIndex === undefined) {\n return false\n }\n\n if (pointBlockIndex < startBlockIndex) {\n // The point block is before the start block.\n return true\n }\n\n if (pointBlockIndex > startBlockIndex) {\n // The point block is after the start block.\n return false\n }\n\n // The point block is the same as the start block.\n const pointBlock = snapshot.context.value.at(pointBlockIndex)\n\n if (!pointBlock) {\n // The point block is not in the value.\n return false\n }\n\n if (!isTextBlock(snapshot.context, pointBlock)) {\n // The point block is not a text block.\n // Since the point block is the same as the start block, the point is not\n // before the selection.\n return false\n }\n\n let pointChildIndex: number | undefined\n let startChildIndex: number | undefined\n\n let childIndex = -1\n\n // The point block is the same as the start block, so we need to find the\n // child indices and compare them.\n for (const child of pointBlock.children) {\n childIndex++\n\n if (child._key === pointChildKey && child._key === startChildKey) {\n return point.offset < startPoint.offset\n }\n\n if (child._key === pointChildKey) {\n pointChildIndex = childIndex\n }\n\n if (child._key === startChildKey) {\n startChildIndex = childIndex\n }\n\n if (pointChildIndex !== undefined && startChildIndex !== undefined) {\n break\n }\n }\n\n if (pointChildIndex === undefined || startChildIndex === undefined) {\n return false\n }\n\n return pointChildIndex < startChildIndex\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from '../utils'\nimport type {EditorSelector} from './../editor/editor-selector'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {isPointAfterSelection} from './selector.is-point-after-selection'\nimport {isPointBeforeSelection} from './selector.is-point-before-selection'\n\n/**\n * @public\n */\nexport function isOverlappingSelection(\n selection: EditorSelection,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!selection || !snapshot.context.selection) {\n return false\n }\n\n const selectionStartPoint = getSelectionStartPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n const selectionEndPoint = getSelectionEndPoint({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n\n const originalSelectionStartPoint = getSelectionStartPoint(snapshot)\n const originalSelectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (\n !selectionStartPoint ||\n !selectionEndPoint ||\n !originalSelectionStartPoint ||\n !originalSelectionEndPoint\n ) {\n return false\n }\n\n const startPointBeforeSelection =\n isPointBeforeSelection(selectionStartPoint)(snapshot)\n const startPointAfterSelection =\n isPointAfterSelection(selectionStartPoint)(snapshot)\n const endPointBeforeSelection =\n isPointBeforeSelection(selectionEndPoint)(snapshot)\n const endPointAfterSelection =\n isPointAfterSelection(selectionEndPoint)(snapshot)\n\n const originalStartPointBeforeStartPoint = isPointBeforeSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const originalStartPointAfterStartPoint = isPointAfterSelection(\n originalSelectionStartPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n\n const originalEndPointBeforeEndPoint = isPointBeforeSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n const originalEndPointAfterEndPoint = isPointAfterSelection(\n originalSelectionEndPoint,\n )({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionEndPoint,\n focus: selectionEndPoint,\n },\n },\n })\n\n const endPointEqualToOriginalStartPoint = isEqualSelectionPoints(\n selectionEndPoint,\n originalSelectionStartPoint,\n )\n const startPointEqualToOriginalEndPoint = isEqualSelectionPoints(\n selectionStartPoint,\n originalSelectionEndPoint,\n )\n\n if (endPointBeforeSelection && !endPointEqualToOriginalStartPoint) {\n return false\n }\n\n if (startPointAfterSelection && !startPointEqualToOriginalEndPoint) {\n return false\n }\n\n if (\n !originalStartPointBeforeStartPoint &&\n originalStartPointAfterStartPoint &&\n !originalEndPointBeforeEndPoint &&\n originalEndPointAfterEndPoint\n ) {\n return !endPointEqualToOriginalStartPoint\n }\n\n if (\n originalStartPointBeforeStartPoint &&\n !originalStartPointAfterStartPoint &&\n originalEndPointBeforeEndPoint &&\n !originalEndPointAfterEndPoint\n ) {\n return !startPointEqualToOriginalEndPoint\n }\n\n if (\n !startPointAfterSelection ||\n !startPointBeforeSelection ||\n !endPointAfterSelection ||\n !endPointBeforeSelection\n ) {\n return true\n }\n\n return false\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport * as utils from '../utils'\nimport {getSelectionEndBlock} from './selector.get-selection-end-block'\nimport {getSelectionStartBlock} from './selector.get-selection-start-block'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = utils.getBlockStartPoint({\n context: snapshot.context,\n block: startBlock,\n })\n const endBlockEndPoint = utils.getBlockEndPoint({\n context: snapshot.context,\n block: endBlock,\n })\n\n return (\n utils.isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n utils.isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n"],"names":["getSelectedBlocks","snapshot","context","selection","selectedBlocks","startPoint","getSelectionStartPoint","endPoint","getSelectionEndPoint","startKey","getBlockKeyFromSelectionPoint","endKey","startBlockIndex","blockIndexMap","get","endBlockIndex","undefined","slicedValue","value","slice","block","_key","push","node","path","length","backward","anchor","focus","getSelectedSpans","selectedSpans","startBlockKey","endBlockKey","startSpanKey","getChildKeyFromSelectionPoint","endSpanKey","startBlockFound","isTextBlock","child","children","isSpan","offset","text","getActiveAnnotations","focusSpan","getFocusSpan","isSelectionCollapsed","activeAnnotations","beta","flatMap","markDefs","filter","markDef","includes","getActiveListItem","selectedTextBlocks","map","firstTextBlock","at","firstListItem","listItem","every","getActiveStyle","firstStyle","style","getNextInlineObject","focusTextBlock","getFocusTextBlock","selectionEndPoint","selectionEndPointChildKey","isKeySegment","endPointChildFound","inlineObject","getCaretWordSelection","selectionStartPoint","selectionStartOffset","spanSelectionPointToBlockOffset","selectionPoint","previousInlineObject","getPreviousInlineObject","blockStartPoint","getBlockStartPoint","textDirectlyBefore","getSelectionText","split","nextInlineObject","blockEndPoint","getBlockEndPoint","textDirectlyAfter","caretWordStartOffset","caretWordEndOffset","caretWordStartSelectionPoint","blockOffsetToSpanSelectionPoint","blockOffset","direction","caretWordEndSelectionPoint","caretWordSelection","isSelectionExpanded","getFirstBlock","getFocusBlockObject","focusBlock","getFocusBlock","getFocusInlineObject","focusChild","getFocusChild","isPortableTextSpan","getFocusListBlock","isListBlock","getLastBlock","getSelectionEndBlock","getNextBlock","selectionEndBlock","index","nextBlock","getSelectionStartBlock","getPreviousBlock","selectionStartBlock","previousBlock","getSelectedTextBlocks","getTrimmedSelection","startChildKey","endChildKey","adjustedStartPoint","trimStartPoint","adjustedEndPoint","trimEndPoint","previousPotentialEndpoint","isEmptyTextBlock","blockKey","span","lonelySpan","trimmedSelection","isActiveAnnotation","annotation","_type","isActiveDecorator","decorator","marks","activeDecorators","isActiveListItem","isActiveStyle","isAtTheEndOfBlock","utils","isAtTheStartOfBlock","isPointAfterSelection","point","pointBlockKey","pointChildKey","pointBlockIndex","pointBlock","pointChildIndex","endChildIndex","childIndex","isPointBeforeSelection","startChildIndex","isOverlappingSelection","originalSelectionStartPoint","originalSelectionEndPoint","startPointBeforeSelection","startPointAfterSelection","endPointBeforeSelection","endPointAfterSelection","originalStartPointBeforeStartPoint","originalStartPointAfterStartPoint","originalEndPointBeforeEndPoint","originalEndPointAfterEndPoint","endPointEqualToOriginalStartPoint","isEqualSelectionPoints","startPointEqualToOriginalEndPoint","isSelectingEntireBlocks","startBlock","endBlock","startBlockStartPoint","endBlockEndPoint"],"mappings":";;;;AAUO,MAAMA,oBAERC,CAAAA,aAAa;AAChB,MAAI,CAACA,SAASC,QAAQC;AACpB,WAAO,CAAA;AAGT,QAAMC,iBAAoE,CAAA,GACpEC,aAAa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D,uBAAuBjH,QAAQ,GAC5C0K,WAAW9D,qBAAqB5G,QAAQ;AAE9C,MAAI,CAACyK,cAAc,CAACC;AAClB,WAAO;AAGT,QAAMC,uBAAuB9B,mBAAyB;AAAA,IACpD5I,SAASD,SAASC;AAAAA,IAClBkB,OAAOsJ;AAAAA,EAAAA,CACR,GACKG,mBAAmB/B,iBAAuB;AAAA,IAC9C5I,SAASD,SAASC;AAAAA,IAClBkB,OAAOuJ;AAAAA,EAAAA,CACR;AAED,SACE7B,uBAA6B8B,sBAAsBvK,UAAU,KAC7DyI,uBAA6B+B,kBAAkBtK,QAAQ;AAE3D;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getBlockKeyFromSelectionPoint, isTextBlock, getChildKeyFromSelectionPoint, isSpan$1 as isSpan, isSpan as isSpan$1, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint, sliceBlocks } from "./
|
|
1
|
+
import { getBlockKeyFromSelectionPoint, isTextBlock, getChildKeyFromSelectionPoint, isSpan$1 as isSpan, isSpan as isSpan$1, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint, sliceBlocks } from "./util.slice-blocks.js";
|
|
2
2
|
import { isKeySegment } from "@sanity/types";
|
|
3
3
|
const getFocusBlock = (snapshot) => {
|
|
4
4
|
if (!snapshot.context.selection)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { blockOffsetToSpanSelectionPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isTextBlock, isSpan$1 as isSpan } from "./
|
|
1
|
+
import { blockOffsetToSpanSelectionPoint, getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, isTextBlock, isSpan$1 as isSpan } from "./util.slice-blocks.js";
|
|
2
2
|
function blockOffsetToBlockSelectionPoint({
|
|
3
3
|
context,
|
|
4
4
|
blockOffset
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
function isKeyedSegment(segment) {
|
|
2
|
+
return typeof segment == "object" && segment !== null && "_key" in segment;
|
|
3
|
+
}
|
|
4
|
+
function getBlockKeyFromSelectionPoint(point) {
|
|
5
|
+
const blockPathSegment = point.path.at(0);
|
|
6
|
+
if (isKeyedSegment(blockPathSegment))
|
|
7
|
+
return blockPathSegment._key;
|
|
8
|
+
}
|
|
9
|
+
function getChildKeyFromSelectionPoint(point) {
|
|
10
|
+
const childPathSegment = point.path.at(2);
|
|
11
|
+
if (isKeyedSegment(childPathSegment))
|
|
12
|
+
return childPathSegment._key;
|
|
13
|
+
}
|
|
1
14
|
function isTypedObject(object) {
|
|
2
15
|
return isRecord(object) && typeof object._type == "string";
|
|
3
16
|
}
|
|
@@ -305,9 +318,6 @@ function getSelectionStartPoint(selection) {
|
|
|
305
318
|
function getTextBlockText(block) {
|
|
306
319
|
return block.children.map((child) => child.text ?? "").join("");
|
|
307
320
|
}
|
|
308
|
-
function isKeyedSegment(segment) {
|
|
309
|
-
return typeof segment == "object" && segment !== null && "_key" in segment;
|
|
310
|
-
}
|
|
311
321
|
function isSpan(context, child) {
|
|
312
322
|
return child._type === context.schema.span.name;
|
|
313
323
|
}
|
|
@@ -399,16 +409,6 @@ function sliceBlocks({
|
|
|
399
409
|
}
|
|
400
410
|
return [...startBlock ? [startBlock] : [], ...middleBlocks, ...endBlock ? [endBlock] : []];
|
|
401
411
|
}
|
|
402
|
-
function getBlockKeyFromSelectionPoint(point) {
|
|
403
|
-
const blockPathSegment = point.path.at(0);
|
|
404
|
-
if (isKeyedSegment(blockPathSegment))
|
|
405
|
-
return blockPathSegment._key;
|
|
406
|
-
}
|
|
407
|
-
function getChildKeyFromSelectionPoint(point) {
|
|
408
|
-
const childPathSegment = point.path.at(2);
|
|
409
|
-
if (isKeyedSegment(childPathSegment))
|
|
410
|
-
return childPathSegment._key;
|
|
411
|
-
}
|
|
412
412
|
export {
|
|
413
413
|
blockOffsetToSpanSelectionPoint,
|
|
414
414
|
getBlockKeyFromSelectionPoint,
|
|
@@ -430,4 +430,4 @@ export {
|
|
|
430
430
|
sliceBlocks,
|
|
431
431
|
spanSelectionPointToBlockOffset
|
|
432
432
|
};
|
|
433
|
-
//# sourceMappingURL=
|
|
433
|
+
//# sourceMappingURL=util.slice-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.slice-blocks.js","sources":["../../src/utils/util.is-keyed-segment.ts","../../src/selection/selection-point.ts","../../src/internal-utils/asserters.ts","../../src/internal-utils/parse-blocks.ts","../../src/utils/util.block-offset.ts","../../src/utils/util.get-block-start-point.ts","../../src/utils/util.get-selection-end-point.ts","../../src/utils/util.get-selection-start-point.ts","../../src/utils/util.get-text-block-text.ts","../../src/utils/util.is-span.ts","../../src/utils/util.slice-blocks.ts"],"sourcesContent":["import type {KeyedSegment} from '@sanity/types'\n\n/**\n * @public\n */\nexport function isKeyedSegment(segment: unknown): segment is KeyedSegment {\n return typeof segment === 'object' && segment !== null && '_key' in segment\n}\n","import type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\nexport function getBlockKeyFromSelectionPoint(point: EditorSelectionPoint) {\n const blockPathSegment = point.path.at(0)\n\n if (isKeyedSegment(blockPathSegment)) {\n return blockPathSegment._key\n }\n\n return undefined\n}\n\nexport function getChildKeyFromSelectionPoint(point: EditorSelectionPoint) {\n const childPathSegment = point.path.at(2)\n\n if (isKeyedSegment(childPathSegment)) {\n return childPathSegment._key\n }\n\n return undefined\n}\n","import type {TypedObject} from '@sanity/types'\n\nexport function isTypedObject(object: unknown): object is TypedObject {\n return isRecord(object) && typeof object._type === 'string'\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && (typeof value === 'object' || typeof value === 'function')\n}\n","import type {\n PortableTextBlock,\n PortableTextListBlock,\n PortableTextObject,\n PortableTextSpan,\n PortableTextTextBlock,\n TypedObject,\n} from '@sanity/types'\nimport type {EditorSchema} from '../editor/editor-schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {isTypedObject} from './asserters'\n\nexport function parseBlocks({\n context,\n blocks,\n options,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n blocks: unknown\n options: {\n refreshKeys: boolean\n validateFields: boolean\n }\n}): Array<PortableTextBlock> {\n if (!Array.isArray(blocks)) {\n return []\n }\n\n return blocks.flatMap((block) => {\n const parsedBlock = parseBlock({context, block, options})\n\n return parsedBlock ? [parsedBlock] : []\n })\n}\n\nexport function parseBlock({\n context,\n block,\n options,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n block: unknown\n options: {\n refreshKeys: boolean\n validateFields: boolean\n }\n}): PortableTextBlock | undefined {\n return (\n parseTextBlock({block, context, options}) ??\n parseBlockObject({blockObject: block, context, options})\n )\n}\n\nexport function parseBlockObject({\n blockObject,\n context,\n options,\n}: {\n blockObject: unknown\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n options: {refreshKeys: boolean; validateFields: boolean}\n}): PortableTextObject | undefined {\n if (!isTypedObject(blockObject)) {\n return undefined\n }\n\n const schemaType = context.schema.blockObjects.find(\n ({name}) => name === blockObject._type,\n )\n\n if (!schemaType) {\n return undefined\n }\n\n return parseObject({\n object: blockObject,\n context: {\n keyGenerator: context.keyGenerator,\n schemaType,\n },\n options,\n })\n}\n\nexport function isListBlock(\n context: Pick<EditorContext, 'schema'>,\n block: unknown,\n): block is PortableTextListBlock {\n return (\n isTextBlock(context, block) &&\n block.level !== undefined &&\n block.listItem !== undefined\n )\n}\n\nexport function isTextBlock(\n context: Pick<EditorContext, 'schema'>,\n block: unknown,\n): block is PortableTextTextBlock {\n if (!isTypedObject(block)) {\n return false\n }\n\n if (block._type !== context.schema.block.name) {\n return false\n }\n\n if (!Array.isArray(block.children)) {\n return false\n }\n\n return true\n}\n\nexport function parseTextBlock({\n block,\n context,\n options,\n}: {\n block: unknown\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n options: {refreshKeys: boolean; validateFields: boolean}\n}): PortableTextTextBlock | undefined {\n if (!isTypedObject(block)) {\n return undefined\n }\n\n const customFields: Record<string, unknown> = {}\n\n for (const key of Object.keys(block)) {\n if (\n key !== '_type' &&\n key !== '_key' &&\n key !== 'children' &&\n key !== 'markDefs' &&\n key !== 'style' &&\n key !== 'listItem' &&\n key !== 'level'\n ) {\n customFields[key] = block[key]\n }\n }\n\n if (block._type !== context.schema.block.name) {\n return undefined\n }\n\n const _key = options.refreshKeys\n ? context.keyGenerator()\n : typeof block._key === 'string'\n ? block._key\n : context.keyGenerator()\n\n const unparsedMarkDefs: Array<unknown> = Array.isArray(block.markDefs)\n ? block.markDefs\n : []\n const markDefKeyMap = new Map<string, string>()\n const markDefs = unparsedMarkDefs.flatMap((markDef) => {\n if (!isTypedObject(markDef)) {\n return []\n }\n\n const schemaType = context.schema.annotations.find(\n ({name}) => name === markDef._type,\n )\n\n if (!schemaType) {\n return []\n }\n\n if (typeof markDef._key !== 'string') {\n // If the `markDef` doesn't have a `_key` then we don't know what spans\n // it belongs to and therefore we have to discard it.\n return []\n }\n\n const parsedAnnotation = parseObject({\n object: markDef,\n context: {\n schemaType,\n keyGenerator: context.keyGenerator,\n },\n options,\n })\n\n if (!parsedAnnotation) {\n return []\n }\n\n markDefKeyMap.set(markDef._key, parsedAnnotation._key)\n\n return [parsedAnnotation]\n })\n\n const unparsedChildren: Array<unknown> = Array.isArray(block.children)\n ? block.children\n : []\n\n const children = unparsedChildren\n .map(\n (child) =>\n parseSpan({span: child, context, markDefKeyMap, options}) ??\n parseInlineObject({inlineObject: child, context, options}),\n )\n .filter((child) => child !== undefined)\n\n const parsedBlock: PortableTextTextBlock = {\n _type: context.schema.block.name,\n _key,\n children:\n children.length > 0\n ? children\n : [\n {\n _key: context.keyGenerator(),\n _type: context.schema.span.name,\n text: '',\n marks: [],\n },\n ],\n markDefs,\n ...(options.validateFields ? {} : customFields),\n }\n\n if (\n typeof block.style === 'string' &&\n context.schema.styles.find((style) => style.name === block.style)\n ) {\n parsedBlock.style = block.style\n } else {\n const defaultStyle = context.schema.styles.at(0)?.name\n\n if (defaultStyle !== undefined) {\n parsedBlock.style = defaultStyle\n } else {\n console.error('Expected default style')\n }\n }\n\n if (\n typeof block.listItem === 'string' &&\n context.schema.lists.find((list) => list.name === block.listItem)\n ) {\n parsedBlock.listItem = block.listItem\n }\n\n if (typeof block.level === 'number') {\n parsedBlock.level = block.level\n }\n\n return parsedBlock\n}\n\nexport function isSpan(\n context: Pick<EditorContext, 'schema'>,\n child: unknown,\n): child is PortableTextSpan {\n if (!isTypedObject(child)) {\n return false\n }\n\n if (child._type !== context.schema.span.name) {\n return false\n }\n\n if (typeof child.text !== 'string') {\n return false\n }\n\n return true\n}\n\nexport function parseSpan({\n span,\n context,\n markDefKeyMap,\n options,\n}: {\n span: unknown\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n markDefKeyMap: Map<string, string>\n options: {refreshKeys: boolean; validateFields: boolean}\n}): PortableTextSpan | undefined {\n if (!isTypedObject(span)) {\n return undefined\n }\n\n const customFields: Record<string, unknown> = {}\n\n for (const key of Object.keys(span)) {\n if (\n key !== '_type' &&\n key !== '_key' &&\n key !== 'text' &&\n key !== 'marks'\n ) {\n customFields[key] = span[key]\n }\n }\n\n // In reality, the span schema name is always 'span', but we only the check here anyway\n if (span._type !== context.schema.span.name || span._type !== 'span') {\n return undefined\n }\n\n const unparsedMarks: Array<unknown> = Array.isArray(span.marks)\n ? span.marks\n : []\n const marks = unparsedMarks.flatMap((mark) => {\n if (typeof mark !== 'string') {\n return []\n }\n\n const markDefKey = markDefKeyMap.get(mark)\n\n if (markDefKey !== undefined) {\n return [markDefKey]\n }\n\n if (\n context.schema.decorators.some((decorator) => decorator.name === mark)\n ) {\n return [mark]\n }\n\n return []\n })\n\n return {\n _type: 'span',\n _key: options.refreshKeys\n ? context.keyGenerator()\n : typeof span._key === 'string'\n ? span._key\n : context.keyGenerator(),\n text: typeof span.text === 'string' ? span.text : '',\n marks,\n ...(options.validateFields ? {} : customFields),\n }\n}\n\nexport function parseInlineObject({\n inlineObject,\n context,\n options,\n}: {\n inlineObject: unknown\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n options: {refreshKeys: boolean; validateFields: boolean}\n}): PortableTextObject | undefined {\n if (!isTypedObject(inlineObject)) {\n return undefined\n }\n\n const schemaType = context.schema.inlineObjects.find(\n ({name}) => name === inlineObject._type,\n )\n\n if (!schemaType) {\n return undefined\n }\n\n return parseObject({\n object: inlineObject,\n context: {\n keyGenerator: context.keyGenerator,\n schemaType,\n },\n options,\n })\n}\n\nexport function parseAnnotation({\n annotation,\n context,\n options,\n}: {\n annotation: TypedObject\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n options: {refreshKeys: boolean; validateFields: boolean}\n}): PortableTextObject | undefined {\n if (!isTypedObject(annotation)) {\n return undefined\n }\n\n const schemaType = context.schema.annotations.find(\n ({name}) => name === annotation._type,\n )\n\n if (!schemaType) {\n return undefined\n }\n\n return parseObject({\n object: annotation,\n context: {\n keyGenerator: context.keyGenerator,\n schemaType,\n },\n options,\n })\n}\n\nfunction parseObject({\n object,\n context,\n options,\n}: {\n object: TypedObject\n context: Pick<EditorContext, 'keyGenerator'> & {\n schemaType: EditorSchema['blockObjects'][0]\n }\n options: {refreshKeys: boolean; validateFields: boolean}\n}): PortableTextObject {\n const {_type, _key, ...customFields} = object\n\n // Validates all props on the object and only takes those that match\n // the name of a field\n const values = options.validateFields\n ? context.schemaType.fields.reduce<Record<string, unknown>>(\n (fieldValues, field) => {\n const fieldValue = object[field.name]\n\n if (fieldValue !== undefined) {\n fieldValues[field.name] = fieldValue\n }\n\n return fieldValues\n },\n {},\n )\n : customFields\n\n return {\n _type: context.schemaType.name,\n _key: options.refreshKeys\n ? context.keyGenerator()\n : typeof object._key === 'string'\n ? object._key\n : context.keyGenerator(),\n ...values,\n }\n}\n","import type {EditorContext} from '../editor/editor-snapshot'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport type {ChildPath} from '../types/paths'\n\n/**\n * @public\n */\nexport function blockOffsetToSpanSelectionPoint({\n context,\n blockOffset,\n direction,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}) {\n let offsetLeft = blockOffset.offset\n let selectionPoint: {path: ChildPath; offset: number} | undefined\n let skippedInlineObject = false\n\n for (const block of context.value) {\n if (block._key !== blockOffset.path[0]._key) {\n continue\n }\n\n if (!isTextBlock(context, block)) {\n continue\n }\n\n for (const child of block.children) {\n if (direction === 'forward') {\n if (!isSpan(context, child)) {\n continue\n }\n\n if (offsetLeft <= child.text.length) {\n selectionPoint = {\n path: [...blockOffset.path, 'children', {_key: child._key}],\n offset: offsetLeft,\n }\n break\n }\n\n offsetLeft -= child.text.length\n\n continue\n }\n\n if (!isSpan(context, child)) {\n skippedInlineObject = true\n continue\n }\n\n if (offsetLeft === 0 && selectionPoint && !skippedInlineObject) {\n if (skippedInlineObject) {\n selectionPoint = {\n path: [...blockOffset.path, 'children', {_key: child._key}],\n offset: 0,\n }\n }\n break\n }\n\n if (offsetLeft > child.text.length) {\n offsetLeft -= child.text.length\n continue\n }\n\n if (offsetLeft <= child.text.length) {\n selectionPoint = {\n path: [...blockOffset.path, 'children', {_key: child._key}],\n offset: offsetLeft,\n }\n\n offsetLeft -= child.text.length\n\n if (offsetLeft !== 0) {\n break\n }\n }\n }\n }\n\n return selectionPoint\n}\n\n/**\n * @public\n */\nexport function spanSelectionPointToBlockOffset({\n context,\n selectionPoint,\n}: {\n context: Pick<EditorContext, 'schema' | 'value'>\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n let offset = 0\n\n const blockKey = getBlockKeyFromSelectionPoint(selectionPoint)\n const spanKey = getChildKeyFromSelectionPoint(selectionPoint)\n\n if (!blockKey || !spanKey) {\n return undefined\n }\n\n for (const block of context.value) {\n if (block._key !== blockKey) {\n continue\n }\n\n if (!isTextBlock(context, block)) {\n continue\n }\n\n for (const child of block.children) {\n if (!isSpan(context, child)) {\n continue\n }\n\n if (child._key === spanKey) {\n return {\n path: [{_key: block._key}],\n offset: offset + selectionPoint.offset,\n }\n }\n\n offset += child.text.length\n }\n }\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {isTextBlock} from '../internal-utils/parse-blocks'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport function getBlockStartPoint({\n context,\n block,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: {\n node: PortableTextBlock\n path: BlockPath\n }\n}): EditorSelectionPoint {\n if (isTextBlock(context, block.node)) {\n return {\n path: [...block.path, 'children', {_key: block.node.children[0]._key}],\n offset: 0,\n }\n }\n\n return {\n path: block.path,\n offset: 0,\n }\n}\n","import type {EditorSelection, EditorSelectionPoint} from '..'\n\n/**\n * @public\n */\nexport function getSelectionEndPoint<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n TEditorSelectionPoint extends\n EditorSelectionPoint | null = TEditorSelection extends NonNullable<EditorSelection>\n ? EditorSelectionPoint\n : null,\n>(selection: TEditorSelection): TEditorSelectionPoint {\n if (!selection) {\n return null as TEditorSelectionPoint\n }\n\n return (\n selection.backward ? selection.anchor : selection.focus\n ) as TEditorSelectionPoint\n}\n","import type {EditorSelection, EditorSelectionPoint} from '..'\n\n/**\n * @public\n */\nexport function getSelectionStartPoint<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n TEditorSelectionPoint extends\n EditorSelectionPoint | null = TEditorSelection extends NonNullable<EditorSelection>\n ? EditorSelectionPoint\n : null,\n>(selection: TEditorSelection): TEditorSelectionPoint {\n if (!selection) {\n return null as TEditorSelectionPoint\n }\n\n return (\n selection.backward ? selection.focus : selection.anchor\n ) as TEditorSelectionPoint\n}\n","import type {PortableTextTextBlock} from '@sanity/types'\n\n/**\n * @public\n */\nexport function getTextBlockText(block: PortableTextTextBlock) {\n return block.children.map((child) => child.text ?? '').join('')\n}\n","import type {PortableTextChild, PortableTextSpan} from '@sanity/types'\nimport type {EditorContext} from '..'\n\n/**\n * @public\n */\nexport function isSpan(\n context: Pick<EditorContext, 'schema'>,\n child: PortableTextChild,\n): child is PortableTextSpan {\n return child._type === context.schema.span.name\n}\n","import type {PortableTextBlock} from '@sanity/types'\nimport type {EditorContext} from '..'\nimport {isSpan, isTextBlock} from '../internal-utils/parse-blocks'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from '../selection/selection-point'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport function sliceBlocks({\n context,\n blocks,\n}: {\n context: Pick<EditorContext, 'schema' | 'selection'>\n blocks: Array<PortableTextBlock>\n}): Array<PortableTextBlock> {\n const slice: Array<PortableTextBlock> = []\n\n if (!context.selection) {\n return slice\n }\n\n let startBlock: PortableTextBlock | undefined\n const middleBlocks: PortableTextBlock[] = []\n let endBlock: PortableTextBlock | undefined\n\n const startPoint = getSelectionStartPoint(context.selection)\n const endPoint = getSelectionEndPoint(context.selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return slice\n }\n\n for (const block of blocks) {\n if (!isTextBlock(context, block)) {\n if (block._key === startBlockKey && block._key === endBlockKey) {\n startBlock = block\n break\n }\n }\n\n if (block._key === startBlockKey) {\n if (!isTextBlock(context, block)) {\n startBlock = block\n continue\n }\n\n if (startChildKey) {\n for (const child of block.children) {\n if (child._key === startChildKey) {\n if (isSpan(context, child)) {\n const text =\n child._key === endChildKey\n ? child.text.slice(startPoint.offset, endPoint.offset)\n : child.text.slice(startPoint.offset)\n\n startBlock = {\n ...block,\n children: [\n {\n ...child,\n text,\n },\n ],\n }\n } else {\n startBlock = {\n ...block,\n children: [child],\n }\n }\n\n if (startChildKey === endChildKey) {\n break\n }\n continue\n }\n\n if (startBlock && isTextBlock(context, startBlock)) {\n if (\n endChildKey &&\n child._key === endChildKey &&\n isSpan(context, child)\n ) {\n startBlock.children.push({\n ...child,\n text: child.text.slice(0, endPoint.offset),\n })\n } else {\n startBlock.children.push(child)\n }\n\n if (\n block._key === endBlockKey &&\n endChildKey &&\n child._key === endChildKey\n ) {\n break\n }\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n startBlock = block\n\n if (startBlockKey === endBlockKey) {\n break\n }\n }\n\n if (block._key === endBlockKey) {\n if (!isTextBlock(context, block)) {\n endBlock = block\n break\n }\n\n if (endChildKey) {\n endBlock = {\n ...block,\n children: [],\n }\n\n for (const child of block.children) {\n if (endBlock && isTextBlock(context, endBlock)) {\n if (child._key === endChildKey && isSpan(context, child)) {\n endBlock.children.push({\n ...child,\n text: child.text.slice(0, endPoint.offset),\n })\n\n break\n }\n\n endBlock.children.push(child)\n\n if (endChildKey && child._key === endChildKey) {\n break\n }\n }\n }\n\n break\n }\n\n endBlock = block\n\n break\n }\n\n if (startBlock) {\n middleBlocks.push(block)\n }\n }\n\n return [\n ...(startBlock ? [startBlock] : []),\n ...middleBlocks,\n ...(endBlock ? [endBlock] : []),\n ]\n}\n"],"names":["isKeyedSegment","segment","getBlockKeyFromSelectionPoint","point","blockPathSegment","path","at","_key","getChildKeyFromSelectionPoint","childPathSegment","isTypedObject","object","isRecord","_type","value","parseBlocks","context","blocks","options","Array","isArray","flatMap","block","parsedBlock","parseBlock","parseTextBlock","parseBlockObject","blockObject","schemaType","schema","blockObjects","find","name","parseObject","keyGenerator","isListBlock","isTextBlock","level","undefined","listItem","children","customFields","key","Object","keys","refreshKeys","unparsedMarkDefs","markDefs","markDefKeyMap","Map","markDef","annotations","parsedAnnotation","set","map","child","parseSpan","span","parseInlineObject","inlineObject","filter","length","text","marks","validateFields","style","styles","defaultStyle","console","error","lists","list","isSpan","mark","markDefKey","get","decorators","some","decorator","inlineObjects","parseAnnotation","annotation","values","fields","reduce","fieldValues","field","fieldValue","blockOffsetToSpanSelectionPoint","blockOffset","direction","offsetLeft","offset","selectionPoint","skippedInlineObject","spanSelectionPointToBlockOffset","blockKey","spanKey","getBlockStartPoint","node","getSelectionEndPoint","selection","backward","anchor","focus","getSelectionStartPoint","getTextBlockText","join","sliceBlocks","slice","startBlock","middleBlocks","endBlock","startPoint","endPoint","startBlockKey","startChildKey","endBlockKey","endChildKey","push"],"mappings":"AAKO,SAASA,eAAeC,SAA2C;AACxE,SAAO,OAAOA,WAAY,YAAYA,YAAY,QAAQ,UAAUA;AACtE;ACJO,SAASC,8BAA8BC,OAA6B;AACzE,QAAMC,mBAAmBD,MAAME,KAAKC,GAAG,CAAC;AAExC,MAAIN,eAAeI,gBAAgB;AACjC,WAAOA,iBAAiBG;AAI5B;AAEO,SAASC,8BAA8BL,OAA6B;AACzE,QAAMM,mBAAmBN,MAAME,KAAKC,GAAG,CAAC;AAExC,MAAIN,eAAeS,gBAAgB;AACjC,WAAOA,iBAAiBF;AAI5B;ACnBO,SAASG,cAAcC,QAAwC;AACpE,SAAOC,SAASD,MAAM,KAAK,OAAOA,OAAOE,SAAU;AACrD;AAEA,SAASD,SAASE,OAAkD;AAClE,SAAO,CAAC,CAACA,UAAU,OAAOA,SAAU,YAAY,OAAOA,SAAU;AACnE;ACIO,SAASC,YAAY;AAAA,EAC1BC;AAAAA,EACAC;AAAAA,EACAC;AAQF,GAA6B;AAC3B,SAAKC,MAAMC,QAAQH,MAAM,IAIlBA,OAAOI,QAASC,CAAAA,UAAU;AAC/B,UAAMC,cAAcC,WAAW;AAAA,MAACR;AAAAA,MAASM;AAAAA,MAAOJ;AAAAA,IAA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AAGEwF,kBACFC,aAAaQ,KAAKjG,KAAK;AAAA,EAAA;AAI3B,SAAO,CACL,GAAIwF,aAAa,CAACA,UAAU,IAAI,CAAA,GAChC,GAAGC,cACH,GAAIC,WAAW,CAACA,QAAQ,IAAI,CAAA,CAAG;AAEnC;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getBlockKeyFromSelectionPoint, getSelectionStartPoint, getSelectionEndPoint, getChildKeyFromSelectionPoint, isSpan$1 as isSpan } from "./
|
|
1
|
+
import { getBlockKeyFromSelectionPoint, getSelectionStartPoint, getSelectionEndPoint, getChildKeyFromSelectionPoint, isSpan$1 as isSpan } from "./util.slice-blocks.js";
|
|
2
2
|
import { childSelectionPointToBlockOffset } from "./util.child-selection-point-to-block-offset.js";
|
|
3
3
|
function isSelectionCollapsed(selection) {
|
|
4
4
|
return selection ? JSON.stringify(selection.anchor.path) === JSON.stringify(selection.focus.path) && selection.anchor.offset === selection.focus.offset : !1;
|