@teselagen/ove 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.umd.js +164751 -135808
- package/package.json +78 -2
- package/src/AlignmentTool/index.js +16 -0
- package/src/AlignmentView/AlignmentVisibilityTool.js +105 -0
- package/src/AlignmentView/EditTrackNameDialog.js +34 -0
- package/src/AlignmentView/HorizontalPanelDragHandle.js +35 -0
- package/src/AlignmentView/Minimap.js +520 -0
- package/src/AlignmentView/Mismatches.js +134 -0
- package/src/AlignmentView/PairwiseAlignmentView.js +68 -0
- package/src/AlignmentView/PerformantSelectionLayer.js +32 -0
- package/src/AlignmentView/coerceInitialValue.js +7 -0
- package/src/AlignmentView/getGapMap.js +12 -0
- package/src/AlignmentView/getGaps.js +27 -0
- package/src/AlignmentView/getPairwiseOverviewLinearViewOptions.js +38 -0
- package/src/AlignmentView/getTrackFromEvent.js +25 -0
- package/src/AlignmentView/index.js +2058 -0
- package/src/AlignmentView/isTargetWithinEl.js +6 -0
- package/src/AlignmentView/style.css +100 -0
- package/src/AlignmentView/updateTrackHelper.js +58 -0
- package/src/AutoAnnotate.js +500 -0
- package/src/AutoAnnotateBpMatchingDialog.js +208 -0
- package/src/CircularView/Axis.js +40 -0
- package/src/CircularView/AxisNumbers.js +35 -0
- package/src/CircularView/Caret.js +63 -0
- package/src/CircularView/CircularDnaSequence.js +73 -0
- package/src/CircularView/CircularZoomMinimap.js +16 -0
- package/src/CircularView/Cutsite.js +18 -0
- package/src/CircularView/Cutsites.js +113 -0
- package/src/CircularView/DeletionLayer.js +28 -0
- package/src/CircularView/Feature.js +83 -0
- package/src/CircularView/Labels/index.js +536 -0
- package/src/CircularView/Labels/relaxLabelAngles.js +157 -0
- package/src/CircularView/Labels/relaxLabels_DEPRECATED.js +105 -0
- package/src/CircularView/Labels/style.css +55 -0
- package/src/CircularView/Orf.js +25 -0
- package/src/CircularView/Part.js +34 -0
- package/src/CircularView/PositionAnnotationOnCircle.js +26 -0
- package/src/CircularView/Primer.js +41 -0
- package/src/CircularView/RotateCircularViewSlider.js +82 -0
- package/src/CircularView/SelectionLayer.js +132 -0
- package/src/CircularView/VeTopRightContainer.js +12 -0
- package/src/CircularView/ZoomCircularViewSlider.js +62 -0
- package/src/CircularView/drawAnnotations.js +433 -0
- package/src/CircularView/drawDirectedPiePiece.js +142 -0
- package/src/CircularView/getAngleForPositionMidpoint.js +3 -0
- package/src/CircularView/getInternalLabel.js +40 -0
- package/src/CircularView/getRangeAnglesSpecial.js +12 -0
- package/src/CircularView/getYOffset.js +15 -0
- package/src/CircularView/index.d.ts +20 -0
- package/src/CircularView/index.js +930 -0
- package/src/CircularView/normalizeAngle.js +3 -0
- package/src/CircularView/normalizeAngleRange.js +9 -0
- package/src/CircularView/positionCutsites.js +6 -0
- package/src/CircularView/shouldFlipText.js +4 -0
- package/src/CircularView/style.css +47 -0
- package/src/CircularView/utils/polarToSpecialCartesian.js +7 -0
- package/src/CreateAnnotationsPage.js +96 -0
- package/src/CreateCustomEnzyme/index.js +337 -0
- package/src/CreateCustomEnzyme/style.css +100 -0
- package/src/CutsiteFilter/AdditionalCutsiteInfoDialog.js +599 -0
- package/src/CutsiteFilter/index.js +408 -0
- package/src/CutsiteFilter/style.css +23 -0
- package/src/CutsiteFilter/withRestrictionEnzymes.js +15 -0
- package/src/DigestTool/AddLaddersDialog.js +82 -0
- package/src/DigestTool/DigestTool.js +223 -0
- package/src/DigestTool/Ladder.css +20 -0
- package/src/DigestTool/Ladder.js +303 -0
- package/src/DigestTool/createFragmentLines.js +120 -0
- package/src/DigestTool/ladderDefaults.js +26 -0
- package/src/DigestTool/ruler.css +89 -0
- package/src/Editor/CommandHotkeyHandler.js +44 -0
- package/src/Editor/DropHandler.css +21 -0
- package/src/Editor/DropHandler.js +64 -0
- package/src/Editor/FillWindow.js +46 -0
- package/src/Editor/darkmode.css +98 -0
- package/src/Editor/index.js +1005 -0
- package/src/Editor/style.css +235 -0
- package/src/Editor/userDefinedHandlersAndOpts.js +56 -0
- package/src/EnzymeViewer/index.js +81 -0
- package/src/EnzymeViewer/style.css +6 -0
- package/src/FindBar/index.js +411 -0
- package/src/FindBar/style.css +46 -0
- package/src/GlobalDialog.js +66 -0
- package/src/GlobalDialogUtils.js +85 -0
- package/src/LinearView/SequenceName.js +15 -0
- package/src/LinearView/ZoomLinearView.js +47 -0
- package/src/LinearView/index.js +374 -0
- package/src/LinearView/style.css +12 -0
- package/src/ManageEnzymes/index.js +326 -0
- package/src/ManageEnzymes/style.css +100 -0
- package/src/MenuBar/defaultConfig.js +149 -0
- package/src/MenuBar/index.js +98 -0
- package/src/MenuBar/viewSubmenu.js +479 -0
- package/src/PCRTool/PCRTool.js +173 -0
- package/src/Reflex/Browser.js +107 -0
- package/src/Reflex/ReflexContainer.js +802 -0
- package/src/Reflex/ReflexElement.js +160 -0
- package/src/Reflex/ReflexEvents.js +77 -0
- package/src/Reflex/ReflexSplitter.js +205 -0
- package/src/Reflex/index.js +5 -0
- package/src/Reflex/reflex-styles.css +128 -0
- package/src/Reflex/reflex-styles.css.map +9 -0
- package/src/RowItem/AnnotationContainerHolder.js +20 -0
- package/src/RowItem/AnnotationPositioner.js +27 -0
- package/src/RowItem/Axis.js +149 -0
- package/src/RowItem/Caret/index.js +64 -0
- package/src/RowItem/Caret/style.css +8 -0
- package/src/RowItem/Chromatograms/Chromatogram.js +289 -0
- package/src/RowItem/CutsiteSelectionLayers.js +47 -0
- package/src/RowItem/Cutsites.js +271 -0
- package/src/RowItem/DeletionLayers/index.js +113 -0
- package/src/RowItem/DeletionLayers/style.css +5 -0
- package/src/RowItem/Labels.js +327 -0
- package/src/RowItem/Orf.js +109 -0
- package/src/RowItem/Orfs.js +35 -0
- package/src/RowItem/ReplacementLayers/style.css +5 -0
- package/src/RowItem/SelectionLayer/index.js +184 -0
- package/src/RowItem/SelectionLayer/style.css +21 -0
- package/src/RowItem/Sequence.js +269 -0
- package/src/RowItem/StackedAnnotations/PointedAnnotation.js +347 -0
- package/src/RowItem/StackedAnnotations/getStructuredBases.js +97 -0
- package/src/RowItem/StackedAnnotations/index.js +182 -0
- package/src/RowItem/StackedAnnotations/primerBases.js +218 -0
- package/src/RowItem/StackedAnnotations/style.css +14 -0
- package/src/RowItem/Translations/AASliver.js +190 -0
- package/src/RowItem/Translations/Translation.js +162 -0
- package/src/RowItem/Translations/index.js +54 -0
- package/src/RowItem/Translations/style.css +3 -0
- package/src/RowItem/constants.js +3 -0
- package/src/RowItem/getCutsiteLabelHeights.js +56 -0
- package/src/RowItem/getXStartAndWidthFromNonCircularRange.js +12 -0
- package/src/RowItem/getXStartAndWidthOfRangeWrtRow.js +27 -0
- package/src/RowItem/getXStartAndWidthOfRowAnnotation.js +19 -0
- package/src/RowItem/index.js +647 -0
- package/src/RowItem/partOverhangs.js +6 -0
- package/src/RowItem/style.css +103 -0
- package/src/RowItem/utils.js +32 -0
- package/src/RowView/estimateRowHeight.js +184 -0
- package/src/RowView/index.d.ts +10 -0
- package/src/RowView/index.js +554 -0
- package/src/RowView/style.css +12 -0
- package/src/SimpleCircularOrLinearView.js +379 -0
- package/src/SimpleOligoPreview.js +39 -0
- package/src/StatusBar/MeltingTemp.js +81 -0
- package/src/StatusBar/index.js +275 -0
- package/src/StatusBar/style.css +38 -0
- package/src/ToolBar/ToolbarItem.js +194 -0
- package/src/ToolBar/alignmentTool.js +503 -0
- package/src/ToolBar/array_move.js +10 -0
- package/src/ToolBar/cutsiteTool.js +88 -0
- package/src/ToolBar/downloadTool.js +38 -0
- package/src/ToolBar/editTool.js +26 -0
- package/src/ToolBar/featureTool.js +34 -0
- package/src/ToolBar/findTool.js +2 -0
- package/src/ToolBar/importTool.js +27 -0
- package/src/ToolBar/index.js +231 -0
- package/src/ToolBar/inlineFindTool.js +38 -0
- package/src/ToolBar/oligoTool.js +30 -0
- package/src/ToolBar/orfTool.js +141 -0
- package/src/ToolBar/partTool.js +47 -0
- package/src/ToolBar/printTool.js +31 -0
- package/src/ToolBar/redoTool.js +30 -0
- package/src/ToolBar/saveTool.js +48 -0
- package/src/ToolBar/style.css +138 -0
- package/src/ToolBar/undoTool.js +30 -0
- package/src/ToolBar/veToolbarIcons/find.png +0 -0
- package/src/ToolBar/veToolbarIcons/fullscreen.png +0 -0
- package/src/ToolBar/veToolbarIcons/linear.png +0 -0
- package/src/ToolBar/veToolbarIcons/pie.png +0 -0
- package/src/ToolBar/veToolbarIcons/print.png +0 -0
- package/src/ToolBar/veToolbarIcons/save.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_cut_sites.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_features.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_orfs.png +0 -0
- package/src/ToolBar/veToolbarIcons/show_primers.png +0 -0
- package/src/ToolBar/veToolbarIcons/toggle_views.svg +1 -0
- package/src/ToolBar/versionHistoryTool.js +20 -0
- package/src/ToolBar/visibilityTool.js +39 -0
- package/src/VersionHistoryView/index.js +215 -0
- package/src/addAlignment.js +6 -0
- package/src/commands/getOveHotkeyDefs.js +12 -0
- package/src/commands/index.js +1585 -0
- package/src/constants/constants.js +2 -0
- package/src/constants/dnaToColor.js +17 -0
- package/src/constants/draggableClassnames.js +5 -0
- package/src/constants/findToolConstants.js +1 -0
- package/src/constants/orfFrameToColorMap.js +10 -0
- package/src/constants/rowviewContants.js +3 -0
- package/src/constants/specialCutsiteFilterOptions.js +22 -0
- package/src/constants.js +1 -0
- package/src/createVectorEditor/index.js +138 -0
- package/src/createVectorEditor/makeStore.js +34 -0
- package/src/fileUtils.js +103 -0
- package/src/helperComponents/AddOrEditAnnotationDialog/index.js +711 -0
- package/src/helperComponents/AddOrEditAnnotationDialog/style.css +11 -0
- package/src/helperComponents/AddOrEditFeatureDialog/index.js +58 -0
- package/src/helperComponents/AddOrEditPartDialog/index.js +101 -0
- package/src/helperComponents/AddOrEditPrimerDialog/EditCaretPosition.js +234 -0
- package/src/helperComponents/AddOrEditPrimerDialog/index.js +329 -0
- package/src/helperComponents/AddOrEditPrimerDialog/style.css +41 -0
- package/src/helperComponents/EnzymesDialog/index.js +904 -0
- package/src/helperComponents/EnzymesDialog/style.css +21 -0
- package/src/helperComponents/GoToDialog.js +21 -0
- package/src/helperComponents/MergeFeaturesDialog/index.js +253 -0
- package/src/helperComponents/MergeFeaturesDialog/style.css +3 -0
- package/src/helperComponents/MultipleSeqsDetectedOnImportDialog.js +74 -0
- package/src/helperComponents/PinchHelper/PinchHelper.js +24 -0
- package/src/helperComponents/PrintDialog/index.js +396 -0
- package/src/helperComponents/PrintDialog/style.css +4 -0
- package/src/helperComponents/PropertiesDialog/ColorPicker.js +30 -0
- package/src/helperComponents/PropertiesDialog/CutsiteProperties.js +185 -0
- package/src/helperComponents/PropertiesDialog/FeatureProperties.js +6 -0
- package/src/helperComponents/PropertiesDialog/GenbankView.js +74 -0
- package/src/helperComponents/PropertiesDialog/GeneralProperties.js +140 -0
- package/src/helperComponents/PropertiesDialog/GenericAnnotationProperties.js +406 -0
- package/src/helperComponents/PropertiesDialog/OrfProperties.js +117 -0
- package/src/helperComponents/PropertiesDialog/PartProperties.js +9 -0
- package/src/helperComponents/PropertiesDialog/PrimerProperties.js +19 -0
- package/src/helperComponents/PropertiesDialog/SingleEnzymeCutsiteInfo.js +131 -0
- package/src/helperComponents/PropertiesDialog/TranslationProperties.js +149 -0
- package/src/helperComponents/PropertiesDialog/index.js +166 -0
- package/src/helperComponents/PropertiesDialog/style.css +68 -0
- package/src/helperComponents/PropertiesDialog/typeField.js +24 -0
- package/src/helperComponents/PropertiesDialog/utils.js +37 -0
- package/src/helperComponents/RemoveDuplicates/index.js +194 -0
- package/src/helperComponents/RenameSequenceDialog.js +7 -0
- package/src/helperComponents/SelectDialog.js +150 -0
- package/src/helperComponents/UncontrolledSliderWithPlusMinusBtns.css +5 -0
- package/src/helperComponents/UncontrolledSliderWithPlusMinusBtns.js +134 -0
- package/src/helperComponents/VeWarning/index.js +22 -0
- package/src/helperComponents/VeWarning/style.css +10 -0
- package/src/helperComponents/createSimpleDialog.js +89 -0
- package/src/helperComponents/partTagSearch.js +72 -0
- package/src/helperComponents/simpleDialog.css +13 -0
- package/src/helperComponents/withHover.js +90 -0
- package/src/index.js +60 -0
- package/src/redux/alignments.js +373 -0
- package/src/redux/annotationLabelVisibility.js +53 -0
- package/src/redux/annotationVisibility.js +196 -0
- package/src/redux/annotationsToSupport.js +104 -0
- package/src/redux/caretPosition.js +27 -0
- package/src/redux/charWidth.js +22 -0
- package/src/redux/copyOptions.js +34 -0
- package/src/redux/createYourOwnEnzyme.js +39 -0
- package/src/redux/deletionLayers.js +36 -0
- package/src/redux/digestTool.js +34 -0
- package/src/redux/featureLengthsToHide.js +27 -0
- package/src/redux/findTool.js +79 -0
- package/src/redux/frameTranslations.js +52 -0
- package/src/redux/hoveredAnnotation.js +24 -0
- package/src/redux/index.js +196 -0
- package/src/redux/labelLineIntensity.js +25 -0
- package/src/redux/labelSize.js +23 -0
- package/src/redux/lastSavedId.js +20 -0
- package/src/redux/middleware.js +112 -0
- package/src/redux/minimumOrfSize.js +24 -0
- package/src/redux/modalActions.js +3 -0
- package/src/redux/panelsShown.js +273 -0
- package/src/redux/partLengthsToHide.js +23 -0
- package/src/redux/primerLengthsToHide.js +27 -0
- package/src/redux/propertiesTool.js +40 -0
- package/src/redux/readOnly.js +28 -0
- package/src/redux/replacementLayers.js +36 -0
- package/src/redux/restrictionEnzymes.js +52 -0
- package/src/redux/selectedAnnotations.js +89 -0
- package/src/redux/selectedPartTags.js +21 -0
- package/src/redux/selectionLayer.js +46 -0
- package/src/redux/sequenceData/circular.js +19 -0
- package/src/redux/sequenceData/description.js +21 -0
- package/src/redux/sequenceData/features.js +19 -0
- package/src/redux/sequenceData/index.js +81 -0
- package/src/redux/sequenceData/lineageLines.js +11 -0
- package/src/redux/sequenceData/materiallyAvailable.js +19 -0
- package/src/redux/sequenceData/name.js +19 -0
- package/src/redux/sequenceData/parts.js +19 -0
- package/src/redux/sequenceData/primers.js +19 -0
- package/src/redux/sequenceData/sequence.js +12 -0
- package/src/redux/sequenceData/sharedActionCreators.js +0 -0
- package/src/redux/sequenceData/translations.js +20 -0
- package/src/redux/sequenceData/upsertDeleteActionGenerator.js +31 -0
- package/src/redux/sequenceDataHistory.js +43 -0
- package/src/redux/showGCContent.js +23 -0
- package/src/redux/toolBar.js +25 -0
- package/src/redux/uppercaseSequenceMapFont.js +25 -0
- package/src/redux/useAdditionalOrfStartCodons.js +24 -0
- package/src/redux/utils/addDashesForMatchStartAndEndForTracks/index.js +71 -0
- package/src/redux/utils/addMetaToActionCreators.js +12 -0
- package/src/redux/utils/createMergedDefaultStateReducer.js +30 -0
- package/src/redux/utils/createMetaAction.js +12 -0
- package/src/redux/versionHistory.js +27 -0
- package/src/selectors/annotationLabelVisibility.js +2 -0
- package/src/selectors/annotationSearchSelector.js +24 -0
- package/src/selectors/cdsFeaturesSelector.js +9 -0
- package/src/selectors/circularSelector.js +4 -0
- package/src/selectors/cutsiteLabelColorSelector.js +6 -0
- package/src/selectors/cutsitesByRangeSelector.js +5 -0
- package/src/selectors/cutsitesSelector.js +61 -0
- package/src/selectors/editorSelector.js +2 -0
- package/src/selectors/featuresSelector.js +8 -0
- package/src/selectors/filteredCutsitesSelector.js +137 -0
- package/src/selectors/filteredFeaturesSelector.js +32 -0
- package/src/selectors/filteredPartsSelector.js +57 -0
- package/src/selectors/filteredPrimersSelector.js +27 -0
- package/src/selectors/filteredRestrictionEnzymesSelector.js +1 -0
- package/src/selectors/getAdditionalEnzymesSelector.js +46 -0
- package/src/selectors/index.js +41 -0
- package/src/selectors/isEnzymeFilterAndSelector.js +1 -0
- package/src/selectors/minimumOrfSizeSelector.js +2 -0
- package/src/selectors/orfsSelector.js +15 -0
- package/src/selectors/partsSelector.js +8 -0
- package/src/selectors/primersSelector.js +8 -0
- package/src/selectors/restrictionEnzymesSelector.js +34 -0
- package/src/selectors/searchLayersSelector.js +71 -0
- package/src/selectors/selectedAnnotationsSelector.js +1 -0
- package/src/selectors/selectedCutsitesSelector.js +21 -0
- package/src/selectors/sequenceDataSelector.js +2 -0
- package/src/selectors/sequenceLengthSelector.js +5 -0
- package/src/selectors/sequenceSelector.js +4 -0
- package/src/selectors/tagsToBoldSelector.js +2 -0
- package/src/selectors/translationSearchMatchesSelector.js +14 -0
- package/src/selectors/translationsRawSelector.js +8 -0
- package/src/selectors/translationsSelector.js +137 -0
- package/src/style.css +82 -0
- package/src/updateEditor.js +198 -0
- package/src/utils/PassThrough.js +3 -0
- package/src/utils/addWrappedAddons.js +20 -0
- package/src/utils/annotationTypes.js +37 -0
- package/src/utils/arrayUtils.js +19 -0
- package/src/utils/calculateTickMarkPositionsForGivenRange.js +47 -0
- package/src/utils/cleanSequenceData_DEPRECATED/arrayToObjWithIds.js +17 -0
- package/src/utils/combineReducersDontIgnoreKeys.js +12 -0
- package/src/utils/commandUtils.js +18 -0
- package/src/utils/editorUtils.js +223 -0
- package/src/utils/getAnnotationClassnames.js +12 -0
- package/src/utils/getAnnotationNameAndStartStopString.js +61 -0
- package/src/utils/getVisibleStartEnd.js +7 -0
- package/src/utils/massageTickSpacing.js +19 -0
- package/src/utils/onlyUpdateForKeysDeep.js +31 -0
- package/src/utils/prepareRowData.js +64 -0
- package/src/utils/proteinUtils.js +3 -0
- package/src/utils/pureNoFunc.js +18 -0
- package/src/utils/selectionLayer.js +25 -0
- package/src/utils/shouldRerender.js +27 -0
- package/src/utils/showFileDialog.js +26 -0
- package/src/utils/updateLabelsForInViewFeatures.js +55 -0
- package/src/utils/updateLabelsForInViewFeaturesCircView.js +41 -0
- package/src/utils/useAAColorType.js +8 -0
- package/src/utils/useAnnotationLimits.js +42 -0
- package/src/utils/useChromatogramPrefs.js +31 -0
- package/src/utils/useLadders.js +6 -0
- package/src/utils/useMeltingTemp.js +7 -0
- package/src/utils/useTmType.js +10 -0
- package/src/withEditorInteractions/Keyboard.js +86 -0
- package/src/withEditorInteractions/clickAndDragUtils.js +576 -0
- package/src/withEditorInteractions/createSequenceInputPopup.js +296 -0
- package/src/withEditorInteractions/createSequenceInputPopupStyle.css +85 -0
- package/src/withEditorInteractions/getBpsPerRow.js +19 -0
- package/src/withEditorInteractions/index.js +1252 -0
- package/src/withEditorInteractions/isElementInViewport.js +29 -0
- package/src/withEditorInteractions/moveCaret.js +58 -0
- package/src/withEditorProps/index.js +1010 -0
- package/index.mjs +0 -193201
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { noop } from "lodash";
|
|
2
|
+
import {
|
|
3
|
+
getRangeLength,
|
|
4
|
+
trimRangeByAnotherRange,
|
|
5
|
+
trimNumberToFitWithin0ToAnotherNumber,
|
|
6
|
+
normalizePositionByRangeLength,
|
|
7
|
+
expandOrContractRangeToPosition
|
|
8
|
+
} from "@teselagen/range-utils";
|
|
9
|
+
|
|
10
|
+
let dragInProgress = false;
|
|
11
|
+
let selectionStartOrEndGrabbed;
|
|
12
|
+
|
|
13
|
+
let caretPositionOnDragStart;
|
|
14
|
+
export const editorDragged = function ({
|
|
15
|
+
nearestCaretPos,
|
|
16
|
+
doNotWrapOrigin,
|
|
17
|
+
caretPosition = -1,
|
|
18
|
+
easyStore,
|
|
19
|
+
caretPositionUpdate = noop,
|
|
20
|
+
selectionLayerUpdate = noop,
|
|
21
|
+
selectionLayer = { start: -1, end: -1 },
|
|
22
|
+
sequenceLength
|
|
23
|
+
}) {
|
|
24
|
+
if (easyStore && easyStore.selectionLayer) {
|
|
25
|
+
caretPosition = easyStore.caretPosition;
|
|
26
|
+
selectionLayer = easyStore.selectionLayer;
|
|
27
|
+
}
|
|
28
|
+
if (!dragInProgress) {
|
|
29
|
+
//we're starting the drag, so update the caret position!
|
|
30
|
+
dragInProgress = new Date().getTime();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (selectionLayer.start > -1 && selectionStartOrEndGrabbed === "start") {
|
|
35
|
+
handleSelectionStartGrabbed({
|
|
36
|
+
caretPosition,
|
|
37
|
+
selectionLayer,
|
|
38
|
+
caretPositionUpdate: caretPositionUpdate,
|
|
39
|
+
selectionLayerUpdate: selectionLayerUpdate,
|
|
40
|
+
nearestCaretPos,
|
|
41
|
+
sequenceLength,
|
|
42
|
+
doNotWrapOrigin
|
|
43
|
+
});
|
|
44
|
+
} else if (
|
|
45
|
+
selectionLayer.start > -1 &&
|
|
46
|
+
selectionStartOrEndGrabbed === "end"
|
|
47
|
+
) {
|
|
48
|
+
handleSelectionEndGrabbed({
|
|
49
|
+
caretPosition,
|
|
50
|
+
selectionLayer,
|
|
51
|
+
caretPositionUpdate: caretPositionUpdate,
|
|
52
|
+
selectionLayerUpdate: selectionLayerUpdate,
|
|
53
|
+
nearestCaretPos,
|
|
54
|
+
sequenceLength,
|
|
55
|
+
doNotWrapOrigin
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
handleNoSelectionLayerYet({
|
|
59
|
+
caretPosition: caretPositionOnDragStart,
|
|
60
|
+
selectionLayer: caretPositionOnDragStart
|
|
61
|
+
? { start: -1, end: -1 }
|
|
62
|
+
: selectionLayer,
|
|
63
|
+
selectionLayerUpdate: selectionLayerUpdate,
|
|
64
|
+
nearestCaretPos,
|
|
65
|
+
sequenceLength,
|
|
66
|
+
doNotWrapOrigin
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const editorClicked = function ({
|
|
72
|
+
nearestCaretPos,
|
|
73
|
+
shiftHeld,
|
|
74
|
+
updateSelectionOrCaret
|
|
75
|
+
}) {
|
|
76
|
+
const timeDif = new Date().getTime() - dragInProgress;
|
|
77
|
+
if (!dragInProgress || 200 > timeDif) {
|
|
78
|
+
//if the drag is less than 200 ms it probably isn't a real drag!
|
|
79
|
+
//we're not dragging the caret or selection handles
|
|
80
|
+
updateSelectionOrCaret(shiftHeld, nearestCaretPos);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const editorDragStarted = function (opts) {
|
|
85
|
+
document?.body.classList.add("sequenceDragging"); //needed to prevent the input bubble from losing focus post user drag
|
|
86
|
+
window.__veDragging = true;
|
|
87
|
+
|
|
88
|
+
caretPositionOnDragStart = opts.nearestCaretPos; //bump the drag counter
|
|
89
|
+
selectionStartOrEndGrabbed = opts.selectionStartGrabbed
|
|
90
|
+
? "start"
|
|
91
|
+
: opts.selectionEndGrabbed
|
|
92
|
+
? "end"
|
|
93
|
+
: null;
|
|
94
|
+
};
|
|
95
|
+
export const editorDragStopped = function () {
|
|
96
|
+
document.body.classList.remove("sequenceDragging"); //needed to prevent the input bubble from losing focus post user drag
|
|
97
|
+
window.__veDragging = false;
|
|
98
|
+
caretPositionOnDragStart = null;
|
|
99
|
+
setTimeout(function () {
|
|
100
|
+
dragInProgress = false;
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export function handleCaretMoved({
|
|
105
|
+
moveBy,
|
|
106
|
+
circular,
|
|
107
|
+
sequenceLength,
|
|
108
|
+
caretPosition,
|
|
109
|
+
selectionLayer,
|
|
110
|
+
shiftHeld,
|
|
111
|
+
type,
|
|
112
|
+
caretPositionUpdate,
|
|
113
|
+
selectionLayerUpdate
|
|
114
|
+
}) {
|
|
115
|
+
let newCaretPosition;
|
|
116
|
+
if (selectionLayer.start > -1) {
|
|
117
|
+
if (shiftHeld) {
|
|
118
|
+
newCaretPosition = normalizeNewCaretPos(
|
|
119
|
+
Number(
|
|
120
|
+
(selectionLayer.cursorAtEnd
|
|
121
|
+
? selectionLayer.end + 1
|
|
122
|
+
: selectionLayer.start) + moveBy
|
|
123
|
+
),
|
|
124
|
+
sequenceLength,
|
|
125
|
+
circular
|
|
126
|
+
);
|
|
127
|
+
// newCaretPosition = normalizeNewCaretPos(Number(caretPosition + moveBy), sequenceLength, circular);
|
|
128
|
+
let anchorPos;
|
|
129
|
+
if (selectionLayer.start <= selectionLayer.end) {
|
|
130
|
+
//non-circular selection
|
|
131
|
+
//define an anchor pos
|
|
132
|
+
if (selectionLayer.cursorAtEnd) {
|
|
133
|
+
if (newCaretPosition === selectionLayer.start && moveBy < 0) {
|
|
134
|
+
return caretPositionUpdate(newCaretPosition);
|
|
135
|
+
}
|
|
136
|
+
anchorPos = selectionLayer.start;
|
|
137
|
+
} else {
|
|
138
|
+
if (newCaretPosition === selectionLayer.end + 1 && moveBy > 0) {
|
|
139
|
+
return caretPositionUpdate(newCaretPosition);
|
|
140
|
+
}
|
|
141
|
+
anchorPos = selectionLayer.end + 1;
|
|
142
|
+
}
|
|
143
|
+
if (newCaretPosition > anchorPos) {
|
|
144
|
+
if (circular && selectionLayer.start + moveBy < 0) {
|
|
145
|
+
//we've gone around the origin in this case
|
|
146
|
+
selectionLayerUpdate({
|
|
147
|
+
start: newCaretPosition,
|
|
148
|
+
end: anchorPos - 1,
|
|
149
|
+
cursorAtEnd: false
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
selectionLayerUpdate({
|
|
153
|
+
start: anchorPos,
|
|
154
|
+
end: normalizePositionByRangeLength(
|
|
155
|
+
newCaretPosition - 1,
|
|
156
|
+
sequenceLength
|
|
157
|
+
),
|
|
158
|
+
cursorAtEnd: true
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
if (circular && selectionLayer.end + moveBy >= sequenceLength) {
|
|
163
|
+
//we've gone around the origin in this case
|
|
164
|
+
selectionLayerUpdate({
|
|
165
|
+
start: anchorPos,
|
|
166
|
+
end: normalizePositionByRangeLength(
|
|
167
|
+
newCaretPosition - 1,
|
|
168
|
+
sequenceLength
|
|
169
|
+
),
|
|
170
|
+
cursorAtEnd: true
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
selectionLayerUpdate({
|
|
174
|
+
start: newCaretPosition,
|
|
175
|
+
end: normalizePositionByRangeLength(
|
|
176
|
+
anchorPos - 1,
|
|
177
|
+
sequenceLength
|
|
178
|
+
),
|
|
179
|
+
cursorAtEnd: false
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
//circular selection
|
|
185
|
+
if (selectionLayer.cursorAtEnd) {
|
|
186
|
+
anchorPos = selectionLayer.start;
|
|
187
|
+
} else {
|
|
188
|
+
anchorPos = selectionLayer.end + 1;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (
|
|
192
|
+
(newCaretPosition <= anchorPos &&
|
|
193
|
+
!(!selectionLayer.cursorAtEnd && newCaretPosition - moveBy < 0)) || // if the move by is crossing the origin then we should make the new selection non circular
|
|
194
|
+
(selectionLayer.cursorAtEnd && selectionLayer.end + moveBy < 0)
|
|
195
|
+
) {
|
|
196
|
+
selectionLayerUpdate({
|
|
197
|
+
start: anchorPos,
|
|
198
|
+
end: normalizePositionByRangeLength(
|
|
199
|
+
newCaretPosition - 1,
|
|
200
|
+
sequenceLength
|
|
201
|
+
),
|
|
202
|
+
cursorAtEnd: true
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
selectionLayerUpdate({
|
|
206
|
+
start: normalizePositionByRangeLength(
|
|
207
|
+
newCaretPosition,
|
|
208
|
+
sequenceLength
|
|
209
|
+
),
|
|
210
|
+
end: normalizePositionByRangeLength(anchorPos - 1, sequenceLength),
|
|
211
|
+
cursorAtEnd: false
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
//no shiftHeld
|
|
217
|
+
//handle special cases
|
|
218
|
+
if (moveBy === 0) {
|
|
219
|
+
if (type === "moveCaretRightOne") {
|
|
220
|
+
return caretPositionUpdate(selectionLayer.end + 1);
|
|
221
|
+
} else if (type === "moveCaretLeftOne") {
|
|
222
|
+
return caretPositionUpdate(selectionLayer.start);
|
|
223
|
+
} else {
|
|
224
|
+
throw new Error("this case should not be hit...");
|
|
225
|
+
}
|
|
226
|
+
} else if (moveBy > 0) {
|
|
227
|
+
newCaretPosition = normalizeNewCaretPos(
|
|
228
|
+
Number(selectionLayer.end + moveBy),
|
|
229
|
+
sequenceLength,
|
|
230
|
+
circular
|
|
231
|
+
);
|
|
232
|
+
caretPositionUpdate(1);
|
|
233
|
+
} else {
|
|
234
|
+
newCaretPosition = normalizeNewCaretPos(
|
|
235
|
+
Number(selectionLayer.start + moveBy),
|
|
236
|
+
sequenceLength,
|
|
237
|
+
circular
|
|
238
|
+
);
|
|
239
|
+
caretPositionUpdate(newCaretPosition);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
//no selection layer
|
|
244
|
+
newCaretPosition = normalizeNewCaretPos(
|
|
245
|
+
Number(caretPosition + moveBy),
|
|
246
|
+
sequenceLength,
|
|
247
|
+
circular
|
|
248
|
+
);
|
|
249
|
+
if (shiftHeld) {
|
|
250
|
+
if (moveBy > 0) {
|
|
251
|
+
if (newCaretPosition === caretPosition) {
|
|
252
|
+
caretPositionUpdate(newCaretPosition);
|
|
253
|
+
} else {
|
|
254
|
+
selectionLayerUpdate({
|
|
255
|
+
start: caretPosition,
|
|
256
|
+
end: normalizePositionByRangeLength(
|
|
257
|
+
newCaretPosition - 1,
|
|
258
|
+
sequenceLength
|
|
259
|
+
),
|
|
260
|
+
cursorAtEnd: true
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
//moving to the left
|
|
265
|
+
if (newCaretPosition === caretPosition) {
|
|
266
|
+
caretPositionUpdate(newCaretPosition);
|
|
267
|
+
} else {
|
|
268
|
+
selectionLayerUpdate({
|
|
269
|
+
start: newCaretPosition,
|
|
270
|
+
end: normalizePositionByRangeLength(
|
|
271
|
+
caretPosition - 1,
|
|
272
|
+
sequenceLength
|
|
273
|
+
),
|
|
274
|
+
cursorAtEnd: false
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
//no shiftHeld
|
|
280
|
+
caretPositionUpdate(newCaretPosition);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function normalizeNewCaretPos(caretPosition, sequenceLength, circular) {
|
|
286
|
+
if (circular) {
|
|
287
|
+
return normalizePositionByRangeLength(caretPosition, sequenceLength, true);
|
|
288
|
+
} else {
|
|
289
|
+
return trimNumberToFitWithin0ToAnotherNumber(caretPosition, sequenceLength);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function handleSelectionStartGrabbed({
|
|
294
|
+
caretPosition,
|
|
295
|
+
selectionLayer,
|
|
296
|
+
selectionLayerUpdate,
|
|
297
|
+
nearestCaretPos,
|
|
298
|
+
sequenceLength,
|
|
299
|
+
doNotWrapOrigin,
|
|
300
|
+
caretPositionUpdate
|
|
301
|
+
}) {
|
|
302
|
+
if (selectionLayer.start < 0) {
|
|
303
|
+
handleNoSelectionLayerYet({
|
|
304
|
+
caretPosition,
|
|
305
|
+
selectionLayer,
|
|
306
|
+
selectionLayerUpdate,
|
|
307
|
+
nearestCaretPos,
|
|
308
|
+
sequenceLength,
|
|
309
|
+
doNotWrapOrigin
|
|
310
|
+
});
|
|
311
|
+
} else {
|
|
312
|
+
if (
|
|
313
|
+
doNotWrapOrigin &&
|
|
314
|
+
selectionLayer.end > -1 &&
|
|
315
|
+
nearestCaretPos === selectionLayer.end + 1
|
|
316
|
+
) {
|
|
317
|
+
caretPositionUpdate(nearestCaretPos);
|
|
318
|
+
caretPositionOnDragStart = nearestCaretPos;
|
|
319
|
+
} else if (doNotWrapOrigin && nearestCaretPos > selectionLayer.end + 1) {
|
|
320
|
+
caretPositionOnDragStart = selectionLayer.end + 1;
|
|
321
|
+
selectionLayerUpdate({
|
|
322
|
+
start: selectionLayer.end + 1,
|
|
323
|
+
end: nearestCaretPos
|
|
324
|
+
});
|
|
325
|
+
selectionStartOrEndGrabbed = "end";
|
|
326
|
+
} else {
|
|
327
|
+
selectionStartOrEndGrabbed = "start";
|
|
328
|
+
//there must be a selection layer
|
|
329
|
+
//we need to move the selection layer
|
|
330
|
+
selectionLayerUpdate({
|
|
331
|
+
start: nearestCaretPos,
|
|
332
|
+
end: selectionLayer.end
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function handleSelectionEndGrabbed({
|
|
339
|
+
caretPosition,
|
|
340
|
+
selectionLayer,
|
|
341
|
+
selectionLayerUpdate,
|
|
342
|
+
nearestCaretPos,
|
|
343
|
+
sequenceLength,
|
|
344
|
+
doNotWrapOrigin,
|
|
345
|
+
caretPositionUpdate
|
|
346
|
+
}) {
|
|
347
|
+
if (selectionLayer.start < 0) {
|
|
348
|
+
handleNoSelectionLayerYet({
|
|
349
|
+
caretPosition,
|
|
350
|
+
selectionLayerUpdate,
|
|
351
|
+
nearestCaretPos,
|
|
352
|
+
sequenceLength,
|
|
353
|
+
doNotWrapOrigin
|
|
354
|
+
});
|
|
355
|
+
} else {
|
|
356
|
+
if (
|
|
357
|
+
doNotWrapOrigin &&
|
|
358
|
+
selectionLayer.start > -1 &&
|
|
359
|
+
nearestCaretPos === selectionLayer.start
|
|
360
|
+
) {
|
|
361
|
+
caretPositionUpdate(nearestCaretPos);
|
|
362
|
+
caretPositionOnDragStart = nearestCaretPos;
|
|
363
|
+
} else if (doNotWrapOrigin && nearestCaretPos < selectionLayer.start) {
|
|
364
|
+
selectionLayerUpdate({
|
|
365
|
+
start: nearestCaretPos,
|
|
366
|
+
end: selectionLayer.start - 1
|
|
367
|
+
});
|
|
368
|
+
caretPositionOnDragStart = selectionLayer.start;
|
|
369
|
+
selectionStartOrEndGrabbed = "start";
|
|
370
|
+
} else {
|
|
371
|
+
selectionStartOrEndGrabbed = "end";
|
|
372
|
+
//there must be a selection layer
|
|
373
|
+
//we need to move the selection layer
|
|
374
|
+
const newEnd = Math.min(nearestCaretPos - 1, sequenceLength - 1);
|
|
375
|
+
selectionLayerUpdate({
|
|
376
|
+
start: selectionLayer.start,
|
|
377
|
+
end: newEnd,
|
|
378
|
+
cursorAtEnd: true
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
export function handleNoSelectionLayerYet({
|
|
384
|
+
caretPosition,
|
|
385
|
+
selectionLayerUpdate,
|
|
386
|
+
nearestCaretPos,
|
|
387
|
+
sequenceLength,
|
|
388
|
+
doNotWrapOrigin
|
|
389
|
+
}) {
|
|
390
|
+
//no selection layer yet, so we'll start one if necessary
|
|
391
|
+
// 0 1 2 3 4 5 6 7 8 9
|
|
392
|
+
// c
|
|
393
|
+
// n
|
|
394
|
+
//
|
|
395
|
+
|
|
396
|
+
const dragEnd = {
|
|
397
|
+
start: caretPosition,
|
|
398
|
+
end: normalizePositionByRangeLength(
|
|
399
|
+
nearestCaretPos - 1,
|
|
400
|
+
sequenceLength,
|
|
401
|
+
true
|
|
402
|
+
)
|
|
403
|
+
};
|
|
404
|
+
const dragStart = {
|
|
405
|
+
start: nearestCaretPos,
|
|
406
|
+
end: normalizePositionByRangeLength(caretPosition - 1, sequenceLength, true)
|
|
407
|
+
};
|
|
408
|
+
if (caretPosition === nearestCaretPos) {
|
|
409
|
+
return; // do nothing because nearestCaretPos === caretPosition
|
|
410
|
+
} else if (
|
|
411
|
+
(doNotWrapOrigin && caretPosition < nearestCaretPos) ||
|
|
412
|
+
(!doNotWrapOrigin &&
|
|
413
|
+
getRangeLength(dragEnd, sequenceLength) <
|
|
414
|
+
getRangeLength(dragStart, sequenceLength))
|
|
415
|
+
) {
|
|
416
|
+
selectionStartOrEndGrabbed = "end";
|
|
417
|
+
selectionLayerUpdate(dragEnd);
|
|
418
|
+
caretPositionOnDragStart = null;
|
|
419
|
+
} else {
|
|
420
|
+
selectionStartOrEndGrabbed = "start";
|
|
421
|
+
selectionLayerUpdate(dragStart);
|
|
422
|
+
caretPositionOnDragStart = null;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export function updateSelectionOrCaret({
|
|
427
|
+
shiftHeld,
|
|
428
|
+
sequenceLength,
|
|
429
|
+
newRangeOrCaret,
|
|
430
|
+
caretPosition,
|
|
431
|
+
selectionLayer,
|
|
432
|
+
selectionLayerUpdate = noop,
|
|
433
|
+
caretPositionUpdate = noop,
|
|
434
|
+
doNotWrapOrigin
|
|
435
|
+
}) {
|
|
436
|
+
let newCaret;
|
|
437
|
+
let newRange;
|
|
438
|
+
if (typeof newRangeOrCaret !== "object") {
|
|
439
|
+
newCaret = newRangeOrCaret;
|
|
440
|
+
} else {
|
|
441
|
+
newRange = {
|
|
442
|
+
isFromRowView: newRangeOrCaret.isFromRowView,
|
|
443
|
+
start: newRangeOrCaret.start,
|
|
444
|
+
end: newRangeOrCaret.end,
|
|
445
|
+
forward: newRangeOrCaret.forward,
|
|
446
|
+
forceUpdate: newRangeOrCaret.forceUpdate,
|
|
447
|
+
overlapsSelf: newRangeOrCaret.overlapsSelf,
|
|
448
|
+
isWrappedAddon: newRangeOrCaret.isWrappedAddon
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
if (shiftHeld) {
|
|
452
|
+
if (caretPosition > 0) {
|
|
453
|
+
//there is a caret already down
|
|
454
|
+
if (newCaret > -1) {
|
|
455
|
+
//a new caret is being passed
|
|
456
|
+
handleNoSelectionLayerYet({
|
|
457
|
+
caretPosition,
|
|
458
|
+
selectionLayer,
|
|
459
|
+
selectionLayerUpdate,
|
|
460
|
+
nearestCaretPos: newCaret,
|
|
461
|
+
sequenceLength,
|
|
462
|
+
doNotWrapOrigin
|
|
463
|
+
});
|
|
464
|
+
} else {
|
|
465
|
+
simpleUpdate();
|
|
466
|
+
}
|
|
467
|
+
} else if (selectionLayer.start > -1) {
|
|
468
|
+
//there is already a selection layer
|
|
469
|
+
if (newCaret > -1) {
|
|
470
|
+
//new caret passed
|
|
471
|
+
const distanceFromStart = getMinRangeLength(
|
|
472
|
+
selectionLayer.start,
|
|
473
|
+
newCaret,
|
|
474
|
+
sequenceLength,
|
|
475
|
+
doNotWrapOrigin
|
|
476
|
+
);
|
|
477
|
+
const distanceFromEnd = getMinRangeLength(
|
|
478
|
+
selectionLayer.end,
|
|
479
|
+
newCaret,
|
|
480
|
+
sequenceLength,
|
|
481
|
+
doNotWrapOrigin
|
|
482
|
+
);
|
|
483
|
+
if (distanceFromStart < distanceFromEnd) {
|
|
484
|
+
selectionLayerUpdate({
|
|
485
|
+
start: newCaret,
|
|
486
|
+
end: selectionLayer.end
|
|
487
|
+
});
|
|
488
|
+
} else {
|
|
489
|
+
selectionLayerUpdate({
|
|
490
|
+
start: selectionLayer.start,
|
|
491
|
+
end: normalizePositionByRangeLength(
|
|
492
|
+
newCaret - 1,
|
|
493
|
+
sequenceLength,
|
|
494
|
+
true
|
|
495
|
+
)
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
} else {
|
|
499
|
+
//new range passed
|
|
500
|
+
// return selectionLayerUpdate(newRange);
|
|
501
|
+
const selectionFullyContained = !trimRangeByAnotherRange(
|
|
502
|
+
selectionLayer,
|
|
503
|
+
newRange
|
|
504
|
+
);
|
|
505
|
+
if (selectionFullyContained) {
|
|
506
|
+
return selectionLayerUpdate(newRange);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const newRangeFullyContained = !trimRangeByAnotherRange(
|
|
510
|
+
newRange,
|
|
511
|
+
selectionLayer
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
const { newRange: range1 } = expandOrContractRangeToPosition(
|
|
515
|
+
selectionLayer,
|
|
516
|
+
newRange.start,
|
|
517
|
+
sequenceLength
|
|
518
|
+
);
|
|
519
|
+
const { newRange: range2 } = expandOrContractRangeToPosition(
|
|
520
|
+
selectionLayer,
|
|
521
|
+
newRange.end + 1,
|
|
522
|
+
sequenceLength
|
|
523
|
+
); //+1 to go from range end to position
|
|
524
|
+
const range1Shorter =
|
|
525
|
+
getRangeLength(range1, sequenceLength) <
|
|
526
|
+
getRangeLength(range2, sequenceLength);
|
|
527
|
+
|
|
528
|
+
if (newRangeFullyContained) {
|
|
529
|
+
range1Shorter
|
|
530
|
+
? selectionLayerUpdate(range1)
|
|
531
|
+
: selectionLayerUpdate(range2);
|
|
532
|
+
} else {
|
|
533
|
+
selectionLayerUpdate({
|
|
534
|
+
forward: newRange.forward,
|
|
535
|
+
start: selectionLayer.start,
|
|
536
|
+
end: newRange.end
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
//no caret, no selection, so just do a simple update
|
|
542
|
+
simpleUpdate();
|
|
543
|
+
}
|
|
544
|
+
} else {
|
|
545
|
+
//no shift held, so just update the selection or caret
|
|
546
|
+
simpleUpdate();
|
|
547
|
+
}
|
|
548
|
+
function simpleUpdate() {
|
|
549
|
+
//shift not held, so just make a new selection layer or move the caret
|
|
550
|
+
if (newCaret > -1) {
|
|
551
|
+
caretPositionUpdate(newCaret);
|
|
552
|
+
} else {
|
|
553
|
+
selectionLayerUpdate(newRange);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// function isRangeShorterIfFlipped(start, end, sequenceLength) {
|
|
559
|
+
// return !(
|
|
560
|
+
// getRangeLength({ start, end }, sequenceLength) <
|
|
561
|
+
// getRangeLength({ start: end, end: start }, sequenceLength)
|
|
562
|
+
// );
|
|
563
|
+
// }
|
|
564
|
+
|
|
565
|
+
function getMinRangeLength(start, end, sequenceLength, doNotWrapOrigin) {
|
|
566
|
+
const range1 = getRangeLength({ start, end }, sequenceLength);
|
|
567
|
+
const range2 = getRangeLength({ start: end, end: start }, sequenceLength);
|
|
568
|
+
if (doNotWrapOrigin) {
|
|
569
|
+
if (start < end) {
|
|
570
|
+
return range1;
|
|
571
|
+
} else {
|
|
572
|
+
return range2;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return range1 < range2 ? range1 : range2;
|
|
576
|
+
}
|