Skip to content

Commit c005307

Browse files
authored
Merge pull request hexlet-rus#695 from DmitryBalandin/issue689
Issue689
2 parents 1f28f6b + 595f528 commit c005307

File tree

21 files changed

+12333
-376
lines changed

21 files changed

+12333
-376
lines changed

frontend/.eslintrc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ settings:
4343

4444
rules:
4545
import/no-cycle: [2, { maxDepth: 1 }]
46-
"react/jsx-filename-extension": ["error","extensions": [".jsx", ".tsx"]]
46+
'react/jsx-filename-extension': ['error', 'extensions': ['.jsx', '.tsx']]
4747
import/prefer-default-export: 0
4848
import/extensions: 0
4949
no-console: 0
5050
react/prop-types: 'off'
5151
consistent-return: 0
5252
react/jsx-sort-props: 1
53+
'import/no-relative-packages': 'off'
5354
'@typescript-eslint/interface-name-prefix': 'off'
5455
'@typescript-eslint/explicit-function-return-type': 'off'
5556
'@typescript-eslint/explicit-module-boundary-types': 'off'

frontend/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
### Установка зависимостей
1+
### Установка зависимостей
2+
23
```bash
34
cd frontend && make install
45
```
5-
или```make install```из ***~*/frontend**
6+
7+
или`make install`из **_~_/frontend**
68

79
### Запуск приложения (front)
10+
811
```bash
912
cd frontend && make start
10-
```
13+
```

frontend/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

frontend/public/index.js

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
const handleTypoReporter = (options) => {
2-
if (!options || !options.authorizationToken && !options.workSpaceId) {
3-
throw new Error('Для работы модуля требуется указать workSpaceId и authorizationToken');
2+
if (!options || (!options.authorizationToken && !options.workSpaceId)) {
3+
throw new Error(
4+
'Для работы модуля требуется указать workSpaceId и authorizationToken',
5+
);
46
}
5-
const { workSpaceUrl = 'https://hexlet-correction.herokuapp.com/api/workspaces', userName = null, authorizationToken, workSpaceId } = options;
7+
const {
8+
workSpaceUrl = 'https://hexlet-correction.herokuapp.com/api/workspaces',
9+
userName = null,
10+
authorizationToken,
11+
workSpaceId,
12+
} = options;
613
const state = {
714
modalShown: false,
815
};
@@ -52,16 +59,24 @@ const handleTypoReporter = (options) => {
5259

5360
const submitButton = document.createElement('button');
5461
submitButton.type = 'button';
55-
submitButton.id = 'hexlet-correction-modal_ReportTypo-submit'
62+
submitButton.id = 'hexlet-correction-modal_ReportTypo-submit';
5663
submitButton.textContent = 'Отправить';
5764

5865
const cancelButton = document.createElement('button');
5966
cancelButton.type = 'button';
60-
cancelButton.id = 'hexlet-correction-modal_ReportTypo-cancel'
67+
cancelButton.id = 'hexlet-correction-modal_ReportTypo-cancel';
6168
cancelButton.textContent = 'Отмена';
6269

6370
divButtons.append(submitButton, cancelButton);
64-
divTypoReporter.append(divHeader, divFirstLabel, divMessage, inputName, textareaComment, divSecondLabel, divButtons);
71+
divTypoReporter.append(
72+
divHeader,
73+
divFirstLabel,
74+
divMessage,
75+
inputName,
76+
textareaComment,
77+
divSecondLabel,
78+
divButtons,
79+
);
6580
const body = document.querySelector('body');
6681
body.append(divModal);
6782

@@ -175,7 +190,7 @@ const handleTypoReporter = (options) => {
175190
#hexlet-correction-modal_ReportTypo-cancel:hover {
176191
background-color: #e2e6ea;
177192
}
178-
`
193+
`;
179194
document.head.append(style);
180195
};
181196

@@ -200,11 +215,21 @@ const handleTypoReporter = (options) => {
200215
renderModal();
201216
}
202217
const modal = document.getElementById('hexlet-correction-modal_modal');
203-
const selectedText = document.getElementById('hexlet-correction-modal_ReportTypo-message');
204-
const commentField = document.getElementById('hexlet-correction-modal_ReportTypo-comment');
205-
const submitButton = document.getElementById('hexlet-correction-modal_ReportTypo-submit');
206-
const cancelBtn = document.getElementById('hexlet-correction-modal_ReportTypo-cancel');
207-
const name = document.getElementById('hexlet-correction-modal_ReportTypo-name');
218+
const selectedText = document.getElementById(
219+
'hexlet-correction-modal_ReportTypo-message',
220+
);
221+
const commentField = document.getElementById(
222+
'hexlet-correction-modal_ReportTypo-comment',
223+
);
224+
const submitButton = document.getElementById(
225+
'hexlet-correction-modal_ReportTypo-submit',
226+
);
227+
const cancelBtn = document.getElementById(
228+
'hexlet-correction-modal_ReportTypo-cancel',
229+
);
230+
const name = document.getElementById(
231+
'hexlet-correction-modal_ReportTypo-name',
232+
);
208233

209234
const closeModal = () => {
210235
modal.style.display = 'none';
@@ -214,7 +239,6 @@ const handleTypoReporter = (options) => {
214239
cancelBtn.removeEventListener('click', sendDataHandler);
215240
};
216241

217-
218242
const sendData = async (event) => {
219243
event.preventDefault();
220244
data.pageUrl = window.location.href;
@@ -225,9 +249,9 @@ const handleTypoReporter = (options) => {
225249
method: 'POST',
226250
headers: {
227251
'Content-Type': 'application/json',
228-
'Authorization': `Basic ${authorizationToken}`
252+
Authorization: `Basic ${authorizationToken}`,
229253
},
230-
body: JSON.stringify(data)
254+
body: JSON.stringify(data),
231255
});
232256
closeModal();
233257
} catch (error) {
@@ -243,8 +267,13 @@ const handleTypoReporter = (options) => {
243267
const maxLength = 50;
244268
const end = Math.min(focusOffset + maxLength, anchorNode.length);
245269
const start = Math.max(anchorOffset - maxLength, 0);
246-
const textBeforeSelection = anchorNode.textContent.substring(start, anchorOffset);
247-
const textAfterSelection = anchorNode.substringData ? anchorNode.substringData(focusOffset, end - focusOffset) : '';
270+
const textBeforeSelection = anchorNode.textContent.substring(
271+
start,
272+
anchorOffset,
273+
);
274+
const textAfterSelection = anchorNode.substringData
275+
? anchorNode.substringData(focusOffset, end - focusOffset)
276+
: '';
248277

249278
selectedText.innerHTML = `${textBeforeSelection}<u id="hexlet-correction-modal_ReportTypo-highlight">${selectionText}</u>${textAfterSelection}`;
250279
commentField.focus();

0 commit comments

Comments
 (0)