Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
lib
react-ag-qeditor
Commits
85d05f2c
Commit
85d05f2c
authored
Jun 20, 2022
by
Рамис
Browse files
disable attach file
parent
e5a71955
Changes
5
Hide whitespace changes
Inline
Side-by-side
example/src/App.js
View file @
85d05f2c
...
@@ -7,7 +7,7 @@ import 'react-ag-qeditor/dist/index.css'
...
@@ -7,7 +7,7 @@ import 'react-ag-qeditor/dist/index.css'
const
App
=
()
=>
{
const
App
=
()
=>
{
return
<
div
style
=
{{
padding
:
40
}}
>
return
<
div
style
=
{{
padding
:
40
}}
>
<
QEditor
<
QEditor
value
=
{
'
<iframe src="https://www.youtube.com/embed/I7vc0lESM6c" frameborder="0" allowfullscreen="true"></iframe>
'
}
value
=
{
'
<iframe src="https://www.youtube.com/embed/I7vc0lESM6c" frameborder="0" allowfullscreen="true"></iframe>
<p>asfdnasjkfasf</p>
'
}
onChange
=
{(
value
)
=>
{
onChange
=
{(
value
)
=>
{
console
.
log
(
'
sads
'
,
value
);
console
.
log
(
'
sads
'
,
value
);
}}
}}
...
...
package.json
View file @
85d05f2c
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.0.1
1
"
,
"version"
:
"1.0.1
2
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/QEditor.jsx
View file @
85d05f2c
...
@@ -38,11 +38,20 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
...
@@ -38,11 +38,20 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
const
[
bubbleItems
,
setBubbleItems
]
=
useState
(
initialBubbleItems
);
const
[
bubbleItems
,
setBubbleItems
]
=
useState
(
initialBubbleItems
);
const
[
colorsTabsActive
,
setColorsTabsActive
]
=
useState
(
'
color
'
);
//highlight || color
const
[
colorsTabsActive
,
setColorsTabsActive
]
=
useState
(
'
color
'
);
//highlight || color
const
[
colorsSelected
,
setColorsSelected
]
=
useState
(
null
);
const
[
colorsSelected
,
setColorsSelected
]
=
useState
(
null
);
const
[
focusFromTo
,
setFocusFromTo
]
=
useState
(
null
);
const
[
oldFocusFromTo
,
setOldFocusFromTo
]
=
useState
(
null
);
const
getRgb
=
(
hex
)
=>
{
const
getRgb
=
(
hex
)
=>
{
var
result
=
/^#
?([
a-f
\d]{2})([
a-f
\d]{2})([
a-f
\d]{2})
$/i
.
exec
(
hex
);
var
result
=
/^#
?([
a-f
\d]{2})([
a-f
\d]{2})([
a-f
\d]{2})
$/i
.
exec
(
hex
);
return
result
?
`rgb(
${
parseInt
(
result
[
1
],
16
)}
,
${
parseInt
(
result
[
2
],
16
)}
,
${
parseInt
(
result
[
3
],
16
)}
)`
:
null
;
return
result
?
`rgb(
${
parseInt
(
result
[
1
],
16
)}
,
${
parseInt
(
result
[
2
],
16
)}
,
${
parseInt
(
result
[
3
],
16
)}
)`
:
null
;
}
}
useEffect
(()
=>
{
if
(
focusFromTo
!==
oldFocusFromTo
){
setColorsSelected
(
null
)
setOldFocusFromTo
(
focusFromTo
);
}
},
[
focusFromTo
])
const
modalOpener
=
(
type
,
title
)
=>
{
const
modalOpener
=
(
type
,
title
)
=>
{
setModalTitle
(
title
);
setModalTitle
(
title
);
setInnerModalType
(
type
);
setInnerModalType
(
type
);
...
@@ -174,15 +183,24 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
...
@@ -174,15 +183,24 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
},
},
alignLeft
:
{
alignLeft
:
{
title
:
'
По левому краю
'
,
title
:
'
По левому краю
'
,
onClick
:
()
=>
editor
.
commands
.
setTextAlign
(
'
left
'
)
onClick
:
()
=>
{
editor
.
commands
.
setTextAlign
(
'
left
'
);
editor
.
chain
().
focus
();
}
},
},
alignCenter
:
{
alignCenter
:
{
title
:
'
По центру
'
,
title
:
'
По центру
'
,
onClick
:
()
=>
editor
.
commands
.
setTextAlign
(
'
center
'
)
onClick
:
()
=>
{
editor
.
commands
.
setTextAlign
(
'
center
'
)
editor
.
chain
().
focus
();
}
},
},
alignRight
:
{
alignRight
:
{
title
:
'
По правому краю
'
,
title
:
'
По правому краю
'
,
onClick
:
()
=>
editor
.
commands
.
setTextAlign
(
'
right
'
)
onClick
:
()
=>
{
editor
.
commands
.
setTextAlign
(
'
right
'
);
editor
.
chain
().
focus
();
}
},
},
insertTable
:
{
insertTable
:
{
title
:
'
Вставить таблицу
'
,
title
:
'
Вставить таблицу
'
,
...
@@ -226,7 +244,10 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
...
@@ -226,7 +244,10 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
},
},
colorText
:
{
colorText
:
{
title
:
'
Цвет текста
'
,
title
:
'
Цвет текста
'
,
onClick
:
()
=>
setColorsSelected
(
'
color
'
)
onClick
:
()
=>
{
setColorsSelected
(
'
color
'
)
editor
.
chain
().
focus
();
}
},
},
highlight
:
{
highlight
:
{
...
@@ -284,7 +305,10 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
...
@@ -284,7 +305,10 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
onFocus
:
({
editor
})
=>
{
onFocus
:
({
editor
})
=>
{
let
wrap
=
editor
.
options
.
element
.
closest
(
'
.atma-editor-wrap
'
);
let
wrap
=
editor
.
options
.
element
.
closest
(
'
.atma-editor-wrap
'
);
wrap
.
querySelector
(
'
.atma-editor-toolbar-s
'
).
classList
.
remove
(
'
show
'
);
wrap
.
querySelectorAll
(
'
.atma-editor-toolbar-s
'
).
forEach
(
function
(
s
)
{
s
.
classList
.
remove
(
'
show
'
);
});
}
}
})
})
...
@@ -427,7 +451,8 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
...
@@ -427,7 +451,8 @@ const QEditor = ({ value, onChange = ()=>{}, style, uploadOptions }) => {
if
(
editor
.
isActive
(
'
image
'
)
===
true
){
if
(
editor
.
isActive
(
'
image
'
)
===
true
){
items
=
[
'
alignLeft
'
,
'
alignCenter
'
,
'
alignRight
'
];
items
=
[
'
alignLeft
'
,
'
alignCenter
'
,
'
alignRight
'
];
}
}
setColorsSelected
(
null
);
setFocusFromTo
([
o
.
from
,
o
.
to
].
join
(
'
:
'
));
if
(
items
.
length
>
0
){
if
(
items
.
length
>
0
){
setBubbleItems
(
items
);
setBubbleItems
(
items
);
return
true
;
return
true
;
...
...
src/components/ToolBar.js
View file @
85d05f2c
...
@@ -34,7 +34,8 @@ const ToolBar = ({ editor, toolsLib = [] }) => {
...
@@ -34,7 +34,8 @@ const ToolBar = ({ editor, toolsLib = [] }) => {
]
]
},
},
{
{
type
:
'
g
'
,
type
:
'
s
'
,
toggle
:
true
,
items
:
[
items
:
[
'
alignLeft
'
,
'
alignLeft
'
,
'
alignCenter
'
,
'
alignCenter
'
,
...
@@ -45,7 +46,7 @@ const ToolBar = ({ editor, toolsLib = [] }) => {
...
@@ -45,7 +46,7 @@ const ToolBar = ({ editor, toolsLib = [] }) => {
type
:
'
g
'
,
type
:
'
g
'
,
items
:
[
items
:
[
'
link
'
,
'
link
'
,
'
file
'
,
//
'file',
'
image
'
,
'
image
'
,
'
video
'
,
'
video
'
,
'
iframe
'
,
'
iframe
'
,
...
@@ -105,7 +106,12 @@ const ToolBar = ({ editor, toolsLib = [] }) => {
...
@@ -105,7 +106,12 @@ const ToolBar = ({ editor, toolsLib = [] }) => {
<
div
<
div
key
=
{
idx
}
key
=
{
idx
}
onClick
=
{(
e
)
=>
{
onClick
=
{(
e
)
=>
{
let
wrap
=
editor
.
options
.
element
.
closest
(
'
.atma-editor-wrap
'
);
item
.
onClick
();
item
.
onClick
();
wrap
.
querySelectorAll
(
'
.atma-editor-toolbar-s
'
).
forEach
(
function
(
s
)
{
s
.
classList
.
remove
(
'
show
'
);
});
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
()
e
.
stopPropagation
()
return
false
;
return
false
;
...
...
src/index.scss
View file @
85d05f2c
...
@@ -40,7 +40,7 @@ body{
...
@@ -40,7 +40,7 @@ body{
&
:after
{
&
:after
{
content
:
''
;
content
:
''
;
display
:
inline-block
;
display
:
inline-block
;
width
:
14
px
;
width
:
20
px
;
}
}
}
}
&
-s
{
&
-s
{
...
...
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