Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax-prosemirror
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wax
wax-prosemirror
Commits
0162d4d2
Commit
0162d4d2
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
insert character
parent
ce33d16a
No related branches found
No related tags found
1 merge request
!205
Special chareacters
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wax-prosemirror-components/src/components/specialCharacters/SpecialCharactersComponent.js
+42
-23
42 additions, 23 deletions
...omponents/specialCharacters/SpecialCharactersComponent.js
wax-prosemirror-core/src/Wax.js
+2
-4
2 additions, 4 deletions
wax-prosemirror-core/src/Wax.js
with
44 additions
and
27 deletions
wax-prosemirror-components/src/components/specialCharacters/SpecialCharactersComponent.js
+
42
−
23
View file @
0162d4d2
...
...
@@ -7,16 +7,15 @@ import React, {
useEffect
,
}
from
'
react
'
;
import
styled
from
'
styled-components
'
;
import
{
grid
}
from
'
@pubsweet/ui-toolkit
'
;
import
{
grid
,
th
}
from
'
@pubsweet/ui-toolkit
'
;
import
{
v4
as
uuidv4
}
from
'
uuid
'
;
import
{
WaxContext
}
from
'
wax-prosemirror-core
'
;
import
{
filter
,
groupBy
,
debounce
}
from
'
lodash
'
;
import
Icon
from
'
../../helpers/Icon
'
;
import
CharactersList
from
'
./CharactersList
'
;
const
Wrapper
=
styled
.
div
`
width: 400px;
height: 2
2
0px;
height: 2
5
0px;
overflow: hidden;
background: #fff;
display: flex;
...
...
@@ -25,9 +24,10 @@ const Wrapper = styled.div`
box-shadow: rgba(9, 30, 66, 0.25) 0px 4px 8px 0px,
rgba(9, 30, 66, 0.31) 0px 0px 1px 0px;
transform-origin: 50% 50% 0px;
padding-bottom:
${
grid
(
2
)}
;
`
;
const
SearchInputContainer
=
styled
.
div
`
padding:
${
grid
(
2
)}
;
padding:
${
grid
(
2
)}
${
grid
(
2
)}
${
grid
(
2
)}
${
grid
(
2
)}
;
`
;
const
SearchInput
=
styled
.
input
`
...
...
@@ -47,7 +47,7 @@ const SearchInput = styled.input`
`
;
const
CharactersListComponent
=
styled
.
div
`
height:
15
0px;
height:
20
0px;
display: flex;
flex-direction: column;
overflow-y: scroll;
...
...
@@ -58,10 +58,12 @@ const CharactersListComponent = styled.div`
const
SpecialCharactersGroup
=
styled
.
div
`
display: flex;
flex-direction: column;
padding-top:
${
grid
(
2
)}
;
`
;
const
GroupTitle
=
styled
.
div
`
font-size: 16px;
font-size: 17px;
color:
${
th
(
'
colorPrimary
'
)}
;
padding: 0
${
grid
(
2
)}
${
grid
(
2
)}
${
grid
(
2
)}
;
`
;
...
...
@@ -76,23 +78,35 @@ const SpecialCharacter = styled.div`
min-width: 25px;
height: 25px;
display: inline-grid;
background:
${
th
(
'
colorPrimary
'
)}
cursor: pointer;
border: 1px solid
black
;
border: 1px solid
${
th
(
'
colorPrimary
'
)}
;
border-radius: 50%;
&:hover {
background: white;
}
span {
font-size: 16px;
text-align: center;
padding-top: 3px;
color: white;
&:hover {
color:
${
th
(
'
colorPrimary
'
)}
;
}
}
`
;
const
LastUsedComponent
=
styled
.
div
``
;
// const LastUsedComponent = styled.div`
// display: flex;
// flex-direction: row;
// height: 30px;
// `;
const
SpecialCharactersComponent
=
({
close
})
=>
{
const
searchRef
=
useRef
(
null
);
const
{
a
pp
,
v
iew
}
=
useContext
(
WaxContext
);
const
{
a
ctiveV
iew
}
=
useContext
(
WaxContext
);
const
[
searchValue
,
setSearchValue
]
=
useState
(
''
);
const
groupedCharacters
=
groupBy
(
CharactersList
,
'
group
'
);
const
[
specialCharactersList
,
setSpecialCharactersList
]
=
useState
(
CharactersList
,
);
...
...
@@ -118,7 +132,11 @@ const SpecialCharactersComponent = ({ close }) => {
delayedSearch
();
},
[
searchValue
,
delayedSearch
]);
const
insertCharacter
=
()
=>
{};
const
insertCharacter
=
character
=>
{
const
{
state
,
dispatch
}
=
activeView
;
const
{
from
,
to
}
=
state
.
selection
;
dispatch
(
state
.
tr
.
insertText
(
character
.
unicode
,
from
,
to
));
};
const
renderList
=
()
=>
{
const
lists
=
[];
...
...
@@ -128,17 +146,19 @@ const SpecialCharactersComponent = ({ close }) => {
<
SpecialCharactersGroup
key
=
{
key
}
>
<
GroupTitle
>
{
key
}
<
/GroupTitle
>
<
GroupCharacters
>
{
groupBy
(
specialCharactersList
,
'
group
'
)[
key
].
map
((
item
,
index
)
=>
{
return
(
<
SpecialCharacter
key
=
{
uuidv4
()}
onMouseDown
=
{
insertCharacter
}
title
=
{
item
.
name
}
>
<
span
>
{
item
.
unicode
}
<
/span
>
<
/SpecialCharacter
>
);
})}
{
groupBy
(
specialCharactersList
,
'
group
'
)[
key
].
map
(
(
character
,
index
)
=>
{
return
(
<
SpecialCharacter
key
=
{
uuidv4
()}
onMouseDown
=
{()
=>
insertCharacter
(
character
)}
title
=
{
character
.
name
}
>
<
span
>
{
character
.
unicode
}
<
/span
>
<
/SpecialCharacter
>
);
},
)}
<
/GroupCharacters
>
<
/SpecialCharactersGroup>
,
);
...
...
@@ -158,7 +178,6 @@ const SpecialCharactersComponent = ({ close }) => {
/
>
<
/SearchInputContainer
>
<
CharactersListComponent
>
{
renderList
()}
<
/CharactersListComponent
>
<
LastUsedComponent
>
Characters
Last
Used
<
/LastUsedComponent
>
<
/Wrapper
>
);
};
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-core/src/Wax.js
+
2
−
4
View file @
0162d4d2
/* eslint react/prop-types: 0 */
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
debounce
from
'
lodash/debounce
'
;
import
{
DOMSerializer
,
DOMParser
}
from
'
prosemirror-model
'
;
import
{
DefaultSchema
}
from
'
wax-prosemirror-utilities
'
;
import
WaxProvider
from
'
./WaxContext
'
;
import
Application
from
'
./Application
'
;
import
WaxView
from
'
./WaxView
'
;
import
defaultPlugins
from
'
./plugins/defaultPlugins
'
;
import
Placeholder
from
'
./plugins/placeholder
'
;
...
...
@@ -137,7 +135,7 @@ const Wax = props => {
};
Wax
.
defaultProps
=
{
config
:
{
services
:
[]
},
config
:
{
SchemaService
:
DefaultSchema
,
services
:
[]
},
};
export
default
Wax
;
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment