Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-webclient
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-webclient
Commits
710ef58e
Commit
710ef58e
authored
Jul 02, 2018
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add context extracting class
parent
a1b515f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
ContextExtractor.js
src/App/ContextExtractor.js
+19
-0
index.js
src/App/index.js
+5
-4
index.js
src/Modal/index.js
+3
-2
No files found.
src/App/ContextExtractor.js
0 → 100644
View file @
710ef58e
// Class that is used to extract context of some word
export
default
class
ContextExtractor
{
constructor
()
{
}
// Returns a context for a current selection
getContextForSelection
()
{
const
text
=
window
.
getSelection
()
.
baseNode
.
parentNode
.
textContent
.
replace
(
/
\n
/g
,
""
)
.
replace
(
/
(\s)
+/g
,
" "
);
return
text
;
}
}
\ No newline at end of file
src/App/index.js
View file @
710ef58e
...
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
...
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
TypoModal
from
'../Modal/'
;
import
TypoModal
from
'../Modal/'
;
import
ContextExtractor
from
'./ContextExtractor'
;
import
{
i18n
}
from
'../Localization'
;
import
{
i18n
}
from
'../Localization'
;
import
{
config
}
from
'../config'
;
import
{
config
}
from
'../config'
;
...
@@ -18,8 +19,8 @@ class App extends Component {
...
@@ -18,8 +19,8 @@ class App extends Component {
isTimeout
:
false
,
isTimeout
:
false
,
}
}
this
.
selectionContext
=
""
;
this
.
typo
=
""
;
this
.
typo
=
""
;
this
.
registerHandlers
();
this
.
registerHandlers
();
}
}
...
@@ -39,7 +40,9 @@ class App extends Component {
...
@@ -39,7 +40,9 @@ class App extends Component {
return
;
return
;
}
}
const
contextExtractor
=
new
ContextExtractor
();
const
selection
=
this
.
getSelectedText
();
const
selection
=
this
.
getSelectedText
();
this
.
selectionContext
=
contextExtractor
.
getContextForSelection
();
if
(
selection
===
""
)
{
if
(
selection
===
""
)
{
return
;
return
;
...
@@ -68,7 +71,7 @@ class App extends Component {
...
@@ -68,7 +71,7 @@ class App extends Component {
if
(
!
this
.
state
.
correctionMode
)
return
null
;
if
(
!
this
.
state
.
correctionMode
)
return
null
;
return
(
return
(
<
TypoModal
text
=
{
this
.
typo
}
<
TypoModal
text
=
{
this
.
typo
}
context
=
{
this
.
selectionContext
}
closeCallback
=
{
this
.
modalClosedCallback
}
closeCallback
=
{
this
.
modalClosedCallback
}
show
=
{
this
.
state
.
correctionMode
}
/
>
show
=
{
this
.
state
.
correctionMode
}
/
>
);
);
...
@@ -82,9 +85,7 @@ class App extends Component {
...
@@ -82,9 +85,7 @@ class App extends Component {
});
});
window
.
setTimeout
(()
=>
{
window
.
setTimeout
(()
=>
{
console
.
log
(
"state"
,
this
.
state
);
this
.
setState
({
isTimeout
:
false
});
this
.
setState
({
isTimeout
:
false
});
console
.
log
(
"afterstate"
,
this
.
state
);
},
config
.
requestTimeout
);
},
config
.
requestTimeout
);
}
}
...
...
src/Modal/index.js
View file @
710ef58e
...
@@ -3,8 +3,8 @@ import { Modal, Button, FormGroup, FormControl, ControlLabel, HelpBlock, Alert }
...
@@ -3,8 +3,8 @@ import { Modal, Button, FormGroup, FormControl, ControlLabel, HelpBlock, Alert }
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
'./Modal.css'
;
import
'./Modal.css'
;
import
{
i18n
}
from
'../Localization'
;
import
{
i18n
}
from
'../Localization'
;
import
{
config
}
from
'../config'
;
import
{
config
}
from
'../config'
;
const
alertify
=
require
(
"alertify.js"
);
const
alertify
=
require
(
"alertify.js"
);
...
@@ -18,6 +18,7 @@ class TypoModal extends Component {
...
@@ -18,6 +18,7 @@ class TypoModal extends Component {
show
:
this
.
props
.
show
,
show
:
this
.
props
.
show
,
text
:
this
.
props
.
text
,
text
:
this
.
props
.
text
,
correct
:
this
.
props
.
text
,
correct
:
this
.
props
.
text
,
context
:
this
.
props
.
context
,
comment
:
""
,
comment
:
""
,
error
:
""
error
:
""
}
}
...
@@ -95,7 +96,7 @@ class TypoModal extends Component {
...
@@ -95,7 +96,7 @@ class TypoModal extends Component {
comment
:
this
.
state
.
correct
,
comment
:
this
.
state
.
correct
,
// TODO: context
// TODO: context
context
:
""
,
context
:
this
.
state
.
context
,
// This is a comment for a correction
// This is a comment for a correction
note
:
this
.
state
.
comment
,
note
:
this
.
state
.
comment
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment