Skip to content

Commit 3a05201

Browse files
committed
fix: adjust bbox circle size range to 0-50
refs: #1240
1 parent f3b6826 commit 3a05201

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

src/TextEditMode.ts

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { unselect } from './utils/SelectTools';
22
import DragHandler from './utils/DragHandler';
33
import NeonView from './NeonView';
4-
import { setSelectHelperObjects, dragSelect, clickSelect } from './utils/Select';
4+
import {
5+
setSelectHelperObjects,
6+
dragSelect,
7+
clickSelect,
8+
} from './utils/Select';
59
import { setGroupingHighlight } from './utils/Color';
610
import { TextEditInterface } from './Interfaces';
7-
import { ModalWindowView } from './utils/ModalWindow';
11+
import { ModalWindowView } from './utils/ModalWindow';
812
import { setSettings } from './utils/LocalSettings';
913
import { setCircleSizeControls } from './DisplayPanel/DisplayControls';
1014

@@ -19,26 +23,33 @@ function formatRaw (rawString: string): string {
1923
}
2024
*/
2125

22-
function selByBBoxListener (): void {
26+
function selByBBoxListener(): void {
2327
if (!document.getElementById('selByBBox').classList.contains('is-active')) {
2428
unselect();
25-
setSettings({ selectionMode : 'selByBBox' });
29+
setSettings({ selectionMode: 'selByBBox' });
2630
try {
2731
document.getElementById('moreEdit').innerHTML = '';
2832
document.getElementById('extraEdit').innerHTML = '';
2933
document.getElementById('moreEdit').parentElement.classList.add('hidden');
30-
document.getElementById('extraEdit').parentElement.classList.add('hidden');
34+
document
35+
.getElementById('extraEdit')
36+
.parentElement.classList.add('hidden');
3137
} catch (e) {}
3238
document.getElementById('selByBBox').classList.add('is-active');
3339
try {
3440
document.getElementById('selByNc').classList.remove('is-active');
3541
document.getElementById('selByNeume').classList.remove('is-active');
3642
document.getElementById('selByStaff').classList.remove('is-active');
3743
document.getElementById('selBySyllable').classList.remove('is-active');
38-
document.getElementById('selByLayerElement').classList.remove('is-active');
44+
document
45+
.getElementById('selByLayerElement')
46+
.classList.remove('is-active');
3947
} catch (e) {}
4048
try {
41-
if (document.querySelector('.highlight-selected').id === 'highlight-selection') {
49+
if (
50+
document.querySelector('.highlight-selected').id ===
51+
'highlight-selection'
52+
) {
4253
setGroupingHighlight('syllable');
4354
}
4455
} catch (e) {}
@@ -57,19 +68,19 @@ export default class TextEditMode implements TextEditInterface {
5768
* Constructor for a TextEdit
5869
* @param neonView - The calling [[NeonView]] for the instance.
5970
*/
60-
constructor (neonView: NeonView) {
71+
constructor(neonView: NeonView) {
6172
this.neonView = neonView;
6273
this.initTextEdit();
6374
}
6475

6576
/**
66-
* Set text to edit mode
67-
*/
68-
initTextEdit (): void {
77+
* Set text to edit mode
78+
*/
79+
initTextEdit(): void {
6980
const spans = document.getElementById('syl_text').querySelectorAll('span');
7081
const modal = this.neonView.modal;
7182
spans.forEach((span: HTMLSpanElement) => {
72-
function selectSylText (): void {
83+
function selectSylText(): void {
7384
span.classList.add('selected-to-edit');
7485
modal.setModalWindowView(ModalWindowView.EDIT_TEXT);
7586
modal.openModalWindow();
@@ -89,14 +100,13 @@ export default class TextEditMode implements TextEditInterface {
89100
});
90101
}
91102

92-
93103
/**
94-
* Add the selectByBBox button.
95-
* If neume edit mode is there, add it to the bar with the other select by buttons.
96-
* Otherwise add an invisible button
97-
* since the only edit mode is selectByRect in that case
98-
*/
99-
initSelectByBBoxButton (): void {
104+
* Add the selectByBBox button.
105+
* If neume edit mode is there, add it to the bar with the other select by buttons.
106+
* Otherwise add an invisible button
107+
* since the only edit mode is selectByRect in that case
108+
*/
109+
initSelectByBBoxButton(): void {
100110
if (this.neonView.NeumeEdit !== undefined) {
101111
const selByBBox = document.getElementById('selByBBox');
102112
if (selByBBox) {
@@ -139,28 +149,33 @@ export default class TextEditMode implements TextEditInterface {
139149
/**
140150
* Initialize select by bbox mode
141151
*/
142-
addBBoxListeners (): void {
152+
addBBoxListeners(): void {
143153
if (document.getElementById('selByBBox').classList.contains('is-active')) {
144154
unselect();
145155
if (this.neonView.NeumeEdit === undefined) {
146156
// just in case
147-
this.dragHandler = new DragHandler(this.neonView, '.sylTextRect-display');
157+
this.dragHandler = new DragHandler(
158+
this.neonView,
159+
'.sylTextRect-display',
160+
);
148161
setSelectHelperObjects(this.neonView, this.dragHandler);
149162
if (this.neonView.view.constructor.name === 'SingleView') {
150163
clickSelect('#mei_output, #mei_output rect');
151164
dragSelect('#svg_group');
152165
} else {
153-
clickSelect('.active-page > svg > svg, .active-page > svg > svg rect');
166+
clickSelect(
167+
'.active-page > svg > svg, .active-page > svg > svg rect',
168+
);
154169
dragSelect('.active-page svg');
155170
}
156171
}
157172
}
158173
}
159174

160175
/**
161-
* Add the bbox circle size slider.
162-
*/
163-
initBBoxCircleSlider (): void {
176+
* Add the bbox circle size slider.
177+
*/
178+
initBBoxCircleSlider(): void {
164179
const circleSlider = document.getElementById('bbox-circle-slider');
165180
if (circleSlider) {
166181
circleSlider.style.display = '';
@@ -169,7 +184,10 @@ export default class TextEditMode implements TextEditInterface {
169184

170185
const sliderSection = document.getElementById('display-slider-section');
171186
const circleSliderContainer = document.createElement('div');
172-
circleSliderContainer.classList.add('slider-and-slider-actions-container', 'display-panel');
187+
circleSliderContainer.classList.add(
188+
'slider-and-slider-actions-container',
189+
'display-panel',
190+
);
173191
circleSliderContainer.style.cursor = 'default';
174192
circleSliderContainer.id = 'bbox-circle-slider';
175193
circleSliderContainer.innerHTML = `
@@ -181,7 +199,7 @@ export default class TextEditMode implements TextEditInterface {
181199
</div>
182200
<div class="slider-container">
183201
<input type="range"
184-
step="1" min="0" max="25" value="25"
202+
step="1" min="0" max="50" value="25"
185203
aria-labelledby="reset-circle-size"
186204
class="slider is-fullwidth is-large"
187205
id="circleSlider"
@@ -191,11 +209,11 @@ export default class TextEditMode implements TextEditInterface {
191209
<output id="circleOutput" for="circleSlider">25</output>
192210
</div>`;
193211
sliderSection.appendChild(circleSliderContainer);
194-
212+
195213
if (this.neonView.NeumeEdit === undefined) {
196214
circleSliderContainer.style.display = 'none';
197215
}
198216

199217
setCircleSizeControls();
200218
}
201-
}
219+
}

0 commit comments

Comments
 (0)