File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { Accidental , Rhythm } from "@abc-editor/core" ;
1+ import { Accidental , Decoration , Rhythm } from "@abc-editor/core" ;
22import clsx from "clsx" ;
33import { useEditorContext } from "../../context/EditorContext" ;
44import EditorControlIcon from "./EditorControlIcon" ;
@@ -14,6 +14,7 @@ export default function EditorControls() {
1414 onNewLine,
1515 onChangeAccidental,
1616 onToggleBeaming,
17+ onToggleDecoration,
1718 onToggleTie,
1819 history,
1920 onUndo,
@@ -279,6 +280,22 @@ export default function EditorControls() {
279280 >
280281 < EditorControlIcon icon = "natural" size = { iconSize } />
281282 </ button >
283+ < button
284+ role = "switch"
285+ title = "Toggle staccato"
286+ aria-checked = { selectedNote ?. data ?. decorations ?. includes (
287+ Decoration . Staccato ,
288+ ) }
289+ className = { clsx ( styles . iconButton , {
290+ [ styles . selected ] : selectedNote ?. data ?. decorations ?. includes (
291+ Decoration . Staccato ,
292+ ) ,
293+ } ) }
294+ disabled = { ! selectedNote ?. data || selectedNote . data . rest }
295+ onClick = { ( ) => onToggleDecoration ( Decoration . Staccato ) }
296+ >
297+ < EditorControlIcon icon = "dot" size = { iconSize } />
298+ </ button >
282299 < button
283300 title = "Toggle tied note"
284301 role = "switch"
Original file line number Diff line number Diff line change 11import {
2- Accidental ,
3- EditorCommandState ,
4- EditorState ,
5- Rhythm ,
6- type SelectionState ,
7- editorCommandReducer ,
8- setupKeyboardListener ,
9- setupMIDIListener ,
10- setupStaffMouseListeners ,
2+ Accidental ,
3+ Decoration ,
4+ EditorCommandState ,
5+ EditorState ,
6+ Rhythm ,
7+ type SelectionState ,
8+ editorCommandReducer ,
9+ setupKeyboardListener ,
10+ setupMIDIListener ,
11+ setupStaffMouseListeners ,
1112} from "@abc-editor/core" ;
1213import type { AbcVisualParams , TuneObject } from "abcjs" ;
1314import { renderAbc } from "abcjs" ;
1415import { createProvider } from "puro" ;
1516import {
16- useCallback ,
17- useContext ,
18- useEffect ,
19- useReducer ,
20- useRef ,
21- useState ,
17+ useCallback ,
18+ useContext ,
19+ useEffect ,
20+ useReducer ,
21+ useRef ,
22+ useState ,
2223} from "react" ;
2324import { EditorProps } from "../components/editor/Editor" ;
2425
@@ -215,6 +216,11 @@ const useEditor = ({
215216 setAbc ( editorState . current . abc ) ;
216217 } , [ ] ) ;
217218
219+ const onToggleDecoration = useCallback ( ( decoration : Decoration ) => {
220+ editorState . current . toggleDecoration ( decoration ) ;
221+ setAbc ( editorState . current . abc ) ;
222+ } , [ ] ) ;
223+
218224 const onToggleTie = useCallback ( ( ) => {
219225 editorState . current . toggleTie ( ) ;
220226 setAbc ( editorState . current . abc ) ;
@@ -318,6 +324,7 @@ const useEditor = ({
318324 onNewLine,
319325 onChangeAccidental,
320326 onToggleBeaming,
327+ onToggleDecoration,
321328 onToggleTie,
322329 onUndo,
323330 onRedo,
You can’t perform that action at this time.
0 commit comments