Skip to content

Commit 0d62835

Browse files
committed
typing fixes
1 parent 568788c commit 0d62835

3 files changed

Lines changed: 35 additions & 31 deletions

File tree

packages/core/src/listeners/mouse.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -339,19 +339,22 @@ function getCursorIcon({
339339
return getIcon("natural");
340340
}
341341
})();
342-
const accidentalDiv = document.createElement("div");
343-
accidentalDiv.innerHTML = accidentalSvg;
344-
const svgEl = accidentalDiv.querySelector("svg");
345-
if (svgEl)
346-
Object.assign(svgEl.style, {
347-
position: "absolute",
348-
right: `${size * 0.65}px`,
349-
top: `${size * 0.35}px`,
350-
height: `${size * 0.7}px`,
351-
width: `${size * 0.7}px`,
352-
color: cursorIconColor,
353-
});
354-
div.appendChild(accidentalDiv);
342+
// TODO add other accidental icons and remove if statement
343+
if (accidentalSvg) {
344+
const accidentalDiv = document.createElement("div");
345+
accidentalDiv.innerHTML = accidentalSvg;
346+
const svgEl = accidentalDiv.querySelector("svg");
347+
if (svgEl)
348+
Object.assign(svgEl.style, {
349+
position: "absolute",
350+
right: `${size * 0.65}px`,
351+
top: `${size * 0.35}px`,
352+
height: `${size * 0.7}px`,
353+
width: `${size * 0.7}px`,
354+
color: cursorIconColor,
355+
});
356+
div.appendChild(accidentalDiv);
357+
}
355358
}
356359
if (dotted) {
357360
const dotDiv = document.createElement("div");

packages/core/src/state/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
editorCommandReducer,
55
} from "./EditorCommand";
66
import EditorState from "./EditorState";
7+
import type { SelectionState } from "./SelectionManager";
78

89
export { EditorState, editorCommandReducer };
9-
export type { EditorCommandAction, EditorCommandState };
10+
export type { EditorCommandAction, EditorCommandState, SelectionState };

packages/react/src/context/EditorContext.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import {
2-
Accidental,
3-
EditorCommandState,
4-
EditorState,
5-
Rhythm,
6-
editorCommandReducer,
7-
setupKeyboardListener,
8-
setupMIDIListener,
9-
setupStaffMouseListeners,
2+
Accidental,
3+
EditorCommandState,
4+
EditorState,
5+
Rhythm,
6+
type SelectionState,
7+
editorCommandReducer,
8+
setupKeyboardListener,
9+
setupMIDIListener,
10+
setupStaffMouseListeners,
1011
} from "@abc-editor/core";
1112
import type { AbcVisualParams, TuneObject } from "abcjs";
1213
import { renderAbc } from "abcjs";
1314
import { createProvider } from "puro";
1415
import {
15-
useCallback,
16-
useContext,
17-
useEffect,
18-
useReducer,
19-
useRef,
20-
useState,
16+
useCallback,
17+
useContext,
18+
useEffect,
19+
useReducer,
20+
useRef,
21+
useState,
2122
} from "react";
2223
import { EditorProps } from "../components/editor/Editor";
2324

@@ -46,10 +47,9 @@ const useEditor = ({
4647
onChange = () => {},
4748
onNote,
4849
}: EditorProviderProps) => {
49-
const [selectedNote, setSelectedNote] =
50-
useState<EditorState["selected"]>(null);
50+
const [selectedNote, setSelectedNote] = useState<SelectionState | null>(null);
5151

52-
const onSelected = useCallback((selected: EditorState["selected"]) => {
52+
const onSelected = useCallback((selected: SelectionState | null) => {
5353
if (selected?.data?.note && selected.data.rhythm) {
5454
setSelectedNote(selected);
5555
} else setSelectedNote(null);

0 commit comments

Comments
 (0)