remove useAppMode hook file (#829)
This commit is contained in:
@ -16,7 +16,7 @@ import { faSearch, faX } from '@fortawesome/free-solid-svg-icons'
|
||||
import { Popover, Transition } from '@headlessui/react'
|
||||
import styles from './Toolbar.module.css'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { isCursorInSketchCommandRange } from 'hooks/useAppMode'
|
||||
import { isCursorInSketchCommandRange } from 'lang/util'
|
||||
import { ActionIcon } from 'components/ActionIcon'
|
||||
import { engineCommandManager } from './lang/std/engineConnection'
|
||||
import { useModelingContext } from 'hooks/useModelingContext'
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
import { SetSelections, modelingMachine } from 'machines/modelingMachine'
|
||||
import { useSetupEngineManager } from 'hooks/useSetupEngineManager'
|
||||
import { useGlobalStateContext } from 'hooks/useGlobalStateContext'
|
||||
import { isCursorInSketchCommandRange } from 'hooks/useAppMode'
|
||||
import { isCursorInSketchCommandRange } from 'lang/util'
|
||||
import { engineCommandManager } from 'lang/std/engineConnection'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { addStartSketch } from 'lang/modifyAst'
|
||||
|
@ -1,27 +0,0 @@
|
||||
import { Selections } from 'useStore'
|
||||
import { ArtifactMap, EngineCommandManager } from 'lang/std/engineConnection'
|
||||
import { isOverlap } from 'lib/utils'
|
||||
|
||||
export function isCursorInSketchCommandRange(
|
||||
artifactMap: ArtifactMap,
|
||||
selectionRanges: Selections
|
||||
): string | false {
|
||||
const overlapingEntries: [string, ArtifactMap[string]][] = Object.entries(
|
||||
artifactMap
|
||||
).filter(([id, artifact]: [string, ArtifactMap[string]]) =>
|
||||
selectionRanges.codeBasedSelections.some(
|
||||
(selection) =>
|
||||
Array.isArray(selection?.range) &&
|
||||
Array.isArray(artifact?.range) &&
|
||||
isOverlap(selection.range, artifact.range) &&
|
||||
(artifact.commandType === 'start_path' ||
|
||||
artifact.commandType === 'extend_path' ||
|
||||
artifact.commandType === 'close_path')
|
||||
)
|
||||
)
|
||||
return overlapingEntries.length && overlapingEntries[0][1].parentId
|
||||
? overlapingEntries[0][1].parentId
|
||||
: overlapingEntries.find(
|
||||
([, artifact]) => artifact.commandType === 'start_path'
|
||||
)?.[0] || false
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
import { Selections, StoreState } from '../useStore'
|
||||
import { Program, PathToNode } from './wasm'
|
||||
import { getNodeFromPath } from './queryAst'
|
||||
import { ArtifactMap } from './std/engineConnection'
|
||||
import { isOverlap } from 'lib/utils'
|
||||
|
||||
export function pathMapToSelections(
|
||||
ast: Program,
|
||||
@ -32,3 +34,27 @@ export function isReducedMotion(): boolean {
|
||||
window.matchMedia('(prefers-reduced-motion)').matches
|
||||
)
|
||||
}
|
||||
|
||||
export function isCursorInSketchCommandRange(
|
||||
artifactMap: ArtifactMap,
|
||||
selectionRanges: Selections
|
||||
): string | false {
|
||||
const overlapingEntries: [string, ArtifactMap[string]][] = Object.entries(
|
||||
artifactMap
|
||||
).filter(([id, artifact]: [string, ArtifactMap[string]]) =>
|
||||
selectionRanges.codeBasedSelections.some(
|
||||
(selection) =>
|
||||
Array.isArray(selection?.range) &&
|
||||
Array.isArray(artifact?.range) &&
|
||||
isOverlap(selection.range, artifact.range) &&
|
||||
(artifact.commandType === 'start_path' ||
|
||||
artifact.commandType === 'extend_path' ||
|
||||
artifact.commandType === 'close_path')
|
||||
)
|
||||
)
|
||||
return overlapingEntries.length && overlapingEntries[0][1].parentId
|
||||
? overlapingEntries[0][1].parentId
|
||||
: overlapingEntries.find(
|
||||
([, artifact]) => artifact.commandType === 'start_path'
|
||||
)?.[0] || false
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { isReducedMotion } from 'lang/util'
|
||||
import { Axis, Selection, SelectionRangeTypeMap, Selections } from 'useStore'
|
||||
import { assign, createMachine } from 'xstate'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { isCursorInSketchCommandRange } from 'hooks/useAppMode'
|
||||
import { isCursorInSketchCommandRange } from 'lang/util'
|
||||
import {
|
||||
doesPipeHaveCallExp,
|
||||
getNodePathFromSourceRange,
|
||||
|
Reference in New Issue
Block a user