@teselagen/ove 0.7.27 → 0.7.28
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/AASliver.js +187 -0
- package/AddLaddersDialog.js +82 -0
- package/AdditionalCutsiteInfoDialog.js +599 -0
- package/AlignmentView/Mismatches.d.ts +3 -3
- package/AlignmentVisibilityTool.js +105 -0
- package/AnnotationContainerHolder.js +20 -0
- package/AnnotationPositioner.js +27 -0
- package/AutoAnnotate.js +501 -0
- package/AutoAnnotateBpMatchingDialog.js +208 -0
- package/Axis.js +151 -0
- package/AxisNumbers.js +35 -0
- package/Browser.js +106 -0
- package/Caret.js +63 -0
- package/Chromatogram.js +293 -0
- package/CircularDnaSequence.js +73 -0
- package/CircularView/Labels/index.d.ts +1 -1
- package/CircularView/index.d.ts +0 -1
- package/CircularZoomMinimap.js +16 -0
- package/ColorPicker.js +30 -0
- package/CommandHotkeyHandler.js +44 -0
- package/CreateAnnotationsPage.d.ts +4 -4
- package/CreateAnnotationsPage.js +98 -0
- package/Cutsite.js +18 -0
- package/CutsiteProperties.js +176 -0
- package/CutsiteSelectionLayers.js +47 -0
- package/Cutsites.js +271 -0
- package/DeletionLayer.js +28 -0
- package/DigestTool/Ladder.d.ts +1 -1
- package/DropHandler.css +21 -0
- package/DropHandler.js +64 -0
- package/EditCaretPosition.js +234 -0
- package/EditTrackNameDialog.js +30 -0
- package/Feature.js +83 -0
- package/FeatureProperties.js +6 -0
- package/FillWindow.js +47 -0
- package/GenbankView.js +74 -0
- package/GeneralProperties.js +117 -0
- package/GenericAnnotationProperties.js +406 -0
- package/GlobalDialog.js +73 -0
- package/GlobalDialogUtils.js +110 -0
- package/GoToDialog.js +25 -0
- package/HorizontalPanelDragHandle.js +35 -0
- package/Keyboard.js +85 -0
- package/Labels.js +327 -0
- package/Ladder.css +20 -0
- package/Ladder.js +303 -0
- package/MeltingTemp.js +85 -0
- package/Menlo.ttf +0 -0
- package/Minimap.js +515 -0
- package/Mismatches.js +134 -0
- package/Monaco.ttf +0 -0
- package/MultipleSeqsDetectedOnImportDialog.js +74 -0
- package/Orf.js +109 -0
- package/OrfProperties.js +117 -0
- package/Orfs.js +35 -0
- package/PCRTool.js +179 -0
- package/PairwiseAlignmentView.js +68 -0
- package/Part.js +34 -0
- package/PartProperties.js +9 -0
- package/PassThrough.js +3 -0
- package/PerformantSelectionLayer.js +32 -0
- package/PinchHelper.js +24 -0
- package/PointedAnnotation.js +347 -0
- package/PositionAnnotationOnCircle.js +26 -0
- package/Primer.js +41 -0
- package/PrimerProperties.js +19 -0
- package/Reflex/index.d.ts +0 -1
- package/ReflexContainer.js +802 -0
- package/ReflexElement.js +160 -0
- package/ReflexEvents.js +77 -0
- package/ReflexSplitter.js +205 -0
- package/RenameSequenceDialog.js +7 -0
- package/RotateCircularViewSlider.js +93 -0
- package/RowView/index.d.ts +0 -1
- package/SelectDialog.js +150 -0
- package/SequenceName.js +15 -0
- package/SimpleCircularOrLinearView.js +381 -0
- package/SimpleOligoPreview.js +39 -0
- package/SingleEnzymeCutsiteInfo.js +139 -0
- package/ToolBar/ToolbarItem.d.ts +1 -3
- package/ToolbarItem.js +192 -0
- package/Translation.js +198 -0
- package/TranslationProperties.js +149 -0
- package/UncontrolledSliderWithPlusMinusBtns.css +5 -0
- package/UncontrolledSliderWithPlusMinusBtns.js +134 -0
- package/VeTopRightContainer.js +12 -0
- package/ZoomCircularViewSlider.js +62 -0
- package/ZoomLinearView.js +47 -0
- package/addAlignment.js +6 -0
- package/addMetaToActionCreators.js +12 -0
- package/addWrappedAddons.js +20 -0
- package/alignmentTool.js +503 -0
- package/alignments.js +379 -0
- package/annotationLabelVisibility.js +2 -0
- package/annotationSearchSelector.js +24 -0
- package/annotationTypes.js +35 -0
- package/annotationVisibility.js +196 -0
- package/annotationsToSupport.js +104 -0
- package/arrayToObjWithIds.js +17 -0
- package/arrayUtils.js +19 -0
- package/array_move.js +10 -0
- package/calculateTickMarkPositionsForGivenRange.js +47 -0
- package/caretPosition.js +27 -0
- package/cdsFeaturesSelector.js +9 -0
- package/charWidth.js +22 -0
- package/circular.js +19 -0
- package/circularSelector.js +4 -0
- package/clickAndDragUtils.js +576 -0
- package/coerceInitialValue.js +7 -0
- package/combineReducersDontIgnoreKeys.js +12 -0
- package/commandUtils.js +20 -0
- package/constants.js +2 -0
- package/copyOptions.js +34 -0
- package/createFragmentLines.js +120 -0
- package/createMergedDefaultStateReducer.js +30 -0
- package/createMetaAction.js +12 -0
- package/createSequenceInputPopup.js +290 -0
- package/createSequenceInputPopupStyle.css +87 -0
- package/createSimpleDialog.js +89 -0
- package/createYourOwnEnzyme.js +39 -0
- package/cutsiteLabelColorSelector.js +6 -0
- package/cutsiteTool.js +88 -0
- package/cutsitesByRangeSelector.js +5 -0
- package/cutsitesSelector.js +61 -0
- package/darkmode.css +98 -0
- package/defaultConfig.js +150 -0
- package/deletionLayers.js +36 -0
- package/description.js +21 -0
- package/digestTool.js +34 -0
- package/dnaToColor.js +17 -0
- package/downloadTool.js +39 -0
- package/draggableClassnames.js +5 -0
- package/drawAnnotations.js +440 -0
- package/drawDirectedPiePiece.js +142 -0
- package/editTool.js +49 -0
- package/editorSelector.js +2 -0
- package/editorUtils.js +205 -0
- package/estimateRowHeight.js +184 -0
- package/featureLengthsToHide.js +27 -0
- package/featureTool.js +34 -0
- package/features.js +19 -0
- package/featuresSelector.js +8 -0
- package/filteredCutsitesSelector.js +136 -0
- package/filteredFeaturesSelector.js +32 -0
- package/filteredPartsSelector.js +57 -0
- package/filteredPrimersSelector.js +27 -0
- package/filteredRestrictionEnzymesSelector.js +1 -0
- package/find.png +0 -0
- package/findTool.js +79 -0
- package/findToolConstants.js +1 -0
- package/frameTranslations.js +52 -0
- package/fullscreen.png +0 -0
- package/getAdditionalEnzymesSelector.js +46 -0
- package/getAngleForPositionMidpoint.js +3 -0
- package/getAnnotationClassnames.js +12 -0
- package/getAnnotationNameAndStartStopString.js +61 -0
- package/getBpsPerRow.js +19 -0
- package/getCutsiteLabelHeights.js +56 -0
- package/getGapMap.js +12 -0
- package/getGaps.js +27 -0
- package/getInternalLabel.js +40 -0
- package/getOveHotkeyDefs.js +12 -0
- package/getPairwiseOverviewLinearViewOptions.js +38 -0
- package/getRangeAnglesSpecial.js +12 -0
- package/getStructuredBases.js +97 -0
- package/getTrackFromEvent.js +25 -0
- package/getVisibleStartEnd.js +7 -0
- package/getXStartAndWidthFromNonCircularRange.js +12 -0
- package/getXStartAndWidthOfRangeWrtRow.js +27 -0
- package/getXStartAndWidthOfRowAnnotation.js +19 -0
- package/getYOffset.js +15 -0
- package/hoveredAnnotation.js +24 -0
- package/{html2canvas.esm--JN4fLQL.js → html2canvas.esm-DiGWN1gP.js} +187 -229
- package/{html2canvas.esm-B7d7VJmQ.cjs → html2canvas.esm-J1esNpMJ.cjs} +187 -229
- package/importTool.js +27 -0
- package/index.cjs.js +48165 -47142
- package/index.es.js +47699 -46676
- package/index.js +71 -0
- package/inlineFindTool.js +38 -0
- package/isElementInViewport.js +29 -0
- package/isEnzymeFilterAndSelector.js +1 -0
- package/isTargetWithinEl.js +6 -0
- package/labelLineIntensity.js +25 -0
- package/labelSize.js +23 -0
- package/ladderDefaults.js +25 -0
- package/lastSavedId.js +20 -0
- package/lineageLines.js +11 -0
- package/linear.png +0 -0
- package/makeStore.js +34 -0
- package/massageTickSpacing.js +19 -0
- package/materiallyAvailable.js +19 -0
- package/middleware.js +112 -0
- package/minimumOrfSize.js +24 -0
- package/minimumOrfSizeSelector.js +2 -0
- package/modalActions.js +3 -0
- package/moveCaret.js +58 -0
- package/name.js +19 -0
- package/normalizeAngle.js +3 -0
- package/normalizeAngleRange.js +9 -0
- package/oligoTool.js +30 -0
- package/onlyUpdateForKeysDeep.js +31 -0
- package/orfFrameToColorMap.js +10 -0
- package/orfTool.js +136 -0
- package/orfsSelector.js +15 -0
- package/ove.css +12107 -0
- package/package.json +6 -5
- package/panelsShown.js +294 -0
- package/partLengthsToHide.js +23 -0
- package/partOverhangs.js +6 -0
- package/partTagSearch.js +69 -0
- package/partTool.js +45 -0
- package/parts.js +19 -0
- package/partsSelector.js +8 -0
- package/pie.png +0 -0
- package/polarToSpecialCartesian.js +7 -0
- package/positionCutsites.js +6 -0
- package/prepareRowData.js +64 -0
- package/primerBases.js +221 -0
- package/primerLengthsToHide.js +27 -0
- package/primers.js +19 -0
- package/primersSelector.js +8 -0
- package/print.png +0 -0
- package/printTool.js +31 -0
- package/propertiesTool.js +40 -0
- package/proteinUtils.js +3 -0
- package/pureNoFunc.js +18 -0
- package/readOnly.js +25 -0
- package/redoTool.js +30 -0
- package/reflex-styles.css +128 -0
- package/reflex-styles.css.map +9 -0
- package/relaxLabelAngles.js +157 -0
- package/relaxLabels_DEPRECATED.js +105 -0
- package/replacementLayers.js +36 -0
- package/restrictionEnzymes.js +52 -0
- package/restrictionEnzymesSelector.js +34 -0
- package/rowviewContants.js +3 -0
- package/ruler.css +89 -0
- package/save.png +0 -0
- package/saveTool.js +44 -0
- package/searchLayersSelector.js +71 -0
- package/selectedAnnotations.js +89 -0
- package/selectedAnnotationsSelector.js +1 -0
- package/selectedCutsitesSelector.js +21 -0
- package/selectedPartTags.js +21 -0
- package/selectionLayer.js +25 -0
- package/selectors/annotationSearchSelector.d.ts +1 -1
- package/sequence.js +12 -0
- package/sequenceDataHistory.js +43 -0
- package/sequenceDataSelector.js +2 -0
- package/sequenceLengthSelector.js +5 -0
- package/sequenceSelector.js +4 -0
- package/sharedActionCreators.js +0 -0
- package/shouldFlipText.js +4 -0
- package/shouldRerender.js +27 -0
- package/showFileDialog.js +25 -0
- package/showGCContent.js +23 -0
- package/show_cut_sites.png +0 -0
- package/show_features.png +0 -0
- package/show_orfs.png +0 -0
- package/show_primers.png +0 -0
- package/simpleDialog.css +13 -0
- package/specialCutsiteFilterOptions.js +22 -0
- package/src/Editor/DropHandler.js +2 -1
- package/src/Editor/index.js +0 -2
- package/src/RowItem/StackedAnnotations/getStructuredBases.js +20 -6
- package/src/ToolBar/cutsiteTool.js +1 -1
- package/src/helperComponents/PropertiesDialog/TranslationProperties.js +2 -1
- package/style.css +3 -12100
- package/tagsToBoldSelector.js +2 -0
- package/toggle_views.svg +1 -0
- package/toolBar.js +23 -0
- package/translationSearchMatchesSelector.js +14 -0
- package/translations.js +20 -0
- package/translationsRawSelector.js +8 -0
- package/translationsSelector.js +137 -0
- package/typeField.js +24 -0
- package/undoTool.js +30 -0
- package/updateEditor.d.ts +1 -3
- package/updateEditor.js +200 -0
- package/updateLabelsForInViewFeatures.js +55 -0
- package/updateLabelsForInViewFeaturesCircView.js +41 -0
- package/updateTrackHelper.js +58 -0
- package/uppercaseSequenceMapFont.js +25 -0
- package/upsertDeleteActionGenerator.js +31 -0
- package/useAAColorType.js +8 -0
- package/useAdditionalOrfStartCodons.js +24 -0
- package/useAnnotationLimits.js +42 -0
- package/useChromatogramPrefs.js +31 -0
- package/useFormValue.js +7 -0
- package/useLadders.js +6 -0
- package/useMeltingTemp.js +7 -0
- package/useTmType.js +10 -0
- package/userDefinedHandlersAndOpts.js +61 -0
- package/utils/getAnnotationNameAndStartStopString.d.ts +1 -5
- package/utils/selectionLayer.d.ts +2 -2
- package/utils.js +37 -0
- package/versionHistory.js +26 -0
- package/versionHistoryTool.js +21 -0
- package/viewSubmenu.js +479 -0
- package/visibilityTool.js +39 -0
- package/withEditorInteractions/getBpsPerRow.d.ts +1 -3
- package/withHover.js +113 -0
- package/withRestrictionEnzymes.js +15 -0
- package/index.umd.js +0 -188322
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { noop } from "lodash-es";
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function combineReducersDontIgnoreKeys(reducers) {
|
|
2
|
+
return function (state = {}, action) {
|
|
3
|
+
const newState = Object.keys(reducers).reduce((acc, key) => {
|
|
4
|
+
acc[key] = reducers[key](state[key], action);
|
|
5
|
+
return acc;
|
|
6
|
+
}, {});
|
|
7
|
+
return {
|
|
8
|
+
...state,
|
|
9
|
+
...newState
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
package/commandUtils.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { genericCommandFactory } from "@teselagen/ui";
|
|
2
|
+
import { noop } from "lodash-es";
|
|
3
|
+
|
|
4
|
+
export function oveCommandFactory(instance, commandDefs) {
|
|
5
|
+
return genericCommandFactory({
|
|
6
|
+
getArguments(cmdId, [ctxInfo]) {
|
|
7
|
+
const args = [instance.props];
|
|
8
|
+
const { store, editorName } = instance.props;
|
|
9
|
+
if (store && editorName) {
|
|
10
|
+
args.push(store.getState().VectorEditor[editorName]);
|
|
11
|
+
}
|
|
12
|
+
args.push(ctxInfo);
|
|
13
|
+
return args;
|
|
14
|
+
},
|
|
15
|
+
handleReturn: noop,
|
|
16
|
+
commandDefs: instance.props.massageCmds
|
|
17
|
+
? instance.props.massageCmds(commandDefs)
|
|
18
|
+
: commandDefs
|
|
19
|
+
});
|
|
20
|
+
}
|
package/constants.js
ADDED
package/copyOptions.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//./caretPosition.js
|
|
2
|
+
import { createReducer } from "redux-act";
|
|
3
|
+
import createAction from "./utils/createMetaAction";
|
|
4
|
+
|
|
5
|
+
// ------------------------------------
|
|
6
|
+
// Actions
|
|
7
|
+
// ------------------------------------
|
|
8
|
+
export const toggleCopyOption = createAction("TOGGLE_COPY_OPTION"); //NOTE!!:: second argument sanitizes actions so no payload is passed
|
|
9
|
+
|
|
10
|
+
export const defaultCopyOptions = {
|
|
11
|
+
features: true,
|
|
12
|
+
partialFeatures: false,
|
|
13
|
+
parts: true,
|
|
14
|
+
partialParts: false
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// ------------------------------------
|
|
18
|
+
// Reducer
|
|
19
|
+
// ------------------------------------
|
|
20
|
+
export default createReducer(
|
|
21
|
+
{
|
|
22
|
+
[toggleCopyOption]: (state, type) => {
|
|
23
|
+
return {
|
|
24
|
+
...state,
|
|
25
|
+
...(type === "partialFeatures" && !state[type] && { features: true }),
|
|
26
|
+
...(type === "partialParts" && !state[type] && { parts: true }),
|
|
27
|
+
...(type === "features" && { partialFeatures: !state[type] }),
|
|
28
|
+
...(type === "parts" && { partialParts: !state[type] }),
|
|
29
|
+
[type]: !state[type]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultCopyOptions
|
|
34
|
+
);
|