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
7872ba43
Commit
7872ba43
authored
May 12, 2022
by
Рамис
Browse files
fix bug
parent
59021c3c
Changes
7
Hide whitespace changes
Inline
Side-by-side
example/src/App.js
View file @
7872ba43
...
@@ -8,7 +8,7 @@ const App = () => {
...
@@ -8,7 +8,7 @@ const App = () => {
return
<
div
style
=
{{
padding
:
40
}}
>
return
<
div
style
=
{{
padding
:
40
}}
>
<
QEditor
<
QEditor
value
=
{
'
<p><b>bold</b></p>
'
+
value
=
{
'
<p><b>bold</b></p>
'
+
'
<p><img src="https://cdn.atmaguru.online/2/atma/4/e/4edof0juw55fUp6TC41r7Swt4eCMWFGHJKBvtZxyglvI2B7aae1NRsqkvV7CLkny.jpeg" width
="
100"></p>
'
}
'
<p><img src="https://cdn.atmaguru.online/2/atma/4/e/4edof0juw55fUp6TC41r7Swt4eCMWFGHJKBvtZxyglvI2B7aae1NRsqkvV7CLkny.jpeg"
style="
width
:
100
px;
"></p>
'
}
onChange
=
{(
value
)
=>
{
onChange
=
{(
value
)
=>
{
console
.
log
(
'
sads
'
,
value
);
console
.
log
(
'
sads
'
,
value
);
}}
}}
...
...
package.json
View file @
7872ba43
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"0.0.
5
"
,
"version"
:
"0.0.
6
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/QEditor.jsx
View file @
7872ba43
import
React
,
{
Fragment
}
from
'
react
'
import
React
,
{
Fragment
}
from
'
react
'
import
ReactQuill
,
{
Quill
}
from
'
react-quill
'
;
import
ReactQuill
,
{
Quill
}
from
'
react-quill
'
import
'
./index.scss
'
;
import
'
./index.scss
'
import
'
react-quill/dist/quill.snow.css
'
;
import
'
react-quill/dist/quill.snow.css
'
import
ImageBlot
from
"
./blots/ImageBlot
"
;
import
"
katex/dist/katex.min.css
"
import
Video
Blot
from
"
./blots/
Video
Blot
"
;
import
Image
Blot
from
"
./blots/
Image
Blot
"
import
Video
Local
Blot
from
"
./blots/Video
Local
Blot
"
;
import
VideoBlot
from
"
./blots/VideoBlot
"
import
EditorModal
from
"
./components/EditorModal
"
;
import
VideoLocalBlot
from
"
./blots/VideoLocalBlot
"
import
Uploader
from
"
./components/
Uploader
"
;
import
EditorModal
from
"
./components/
EditorModal
"
import
"
katex/dist/katex.min.css
"
;
import
Uploader
from
"
./components/Uploader
"
import
ImageResize
from
"
quill-
image-resize-module-react
"
;
import
BlotFormatter
from
'
quill-
blot-formatter
'
import
BlotFormatter
from
'
quill-blot-formatter
'
;
import
ResizeImageBlot
from
"
./blots/ResizeImageBlot
"
import
katex
from
"
katex
"
;
import
katex
from
"
katex
"
;
Quill
.
register
(
'
modules/blotFormatter
'
,
BlotFormatter
);
export
default
class
QEditor
extends
React
.
Component
{
export
default
class
QEditor
extends
React
.
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
...
@@ -32,7 +27,7 @@ export default class QEditor extends React.Component {
...
@@ -32,7 +27,7 @@ export default class QEditor extends React.Component {
Quill
.
register
(
'
formats/video
'
,
VideoBlot
)
Quill
.
register
(
'
formats/video
'
,
VideoBlot
)
Quill
.
register
(
'
formats/videoLocal
'
,
VideoLocalBlot
)
Quill
.
register
(
'
formats/videoLocal
'
,
VideoLocalBlot
)
//
Quill.register('modules/
imageResize', ImageResize
)
Quill
.
register
(
'
modules/
blotFormatter
'
,
BlotFormatter
)
Quill
.
register
(
'
formats/image
'
,
ImageBlot
)
Quill
.
register
(
'
formats/image
'
,
ImageBlot
)
}
}
...
@@ -75,32 +70,15 @@ export default class QEditor extends React.Component {
...
@@ -75,32 +70,15 @@ export default class QEditor extends React.Component {
},
()
=>
this
.
editorModal
.
show
({
title
:
'
Загрузить видео
'
}));
},
()
=>
this
.
editorModal
.
show
({
title
:
'
Загрузить видео
'
}));
},
},
image
:
(
a
)
=>
{
image
:
(
a
)
=>
{
console
.
log
(
a
);
this
.
setState
({
this
.
setState
({
innerModalType
:
'
image
'
innerModalType
:
'
image
'
},
()
=>
this
.
editorModal
.
show
({
title
:
'
Загрузить изображение
'
}));
},
()
=>
this
.
editorModal
.
show
({
title
:
'
Загрузить изображение
'
}));
}
}
}
}
},
},
// imageResize: {
blotFormatter
:
{
// parchment: Quill.import("parchment"),
specs
:
[
ResizeImageBlot
],
// modules: ["Resize", "DisplaySize"]
}
// },
blotFormatter
:
{}
/* clipboard: {
matchers: [
['IMG', (node, delta)=>{
console.log(delta)
return delta.compose(new Delta().retain(delta.length(), { width: 100, title: 'ekwgon' }));
}]
]
} */
}
}
formats
=
[
formats
=
[
...
@@ -144,6 +122,7 @@ export default class QEditor extends React.Component {
...
@@ -144,6 +122,7 @@ export default class QEditor extends React.Component {
<
li
className
=
{
'
vimeo
'
}
/>
<
li
className
=
{
'
vimeo
'
}
/>
{
/* <li className={'vk'}/> */
}
{
/* <li className={'vk'}/> */
}
<
li
className
=
{
'
ok
'
}
/>
<
li
className
=
{
'
ok
'
}
/>
<
li
className
=
{
'
rutube
'
}
/>
</
ul
>
</
ul
>
</
Fragment
>
</
Fragment
>
)
)
...
...
src/blots/ImageBlot.js
View file @
7872ba43
...
@@ -13,6 +13,16 @@ export default class ImageBlot extends Image {
...
@@ -13,6 +13,16 @@ export default class ImageBlot extends Image {
}
}
static
value
(
domNode
)
{
static
value
(
domNode
)
{
if
(
domNode
.
hasAttribute
(
'
style
'
))
{
domNode
.
style
.
height
=
'
none
'
;
if
(
domNode
.
style
.
width
!==
''
&&
domNode
.
style
.
width
!==
'
auto
'
){
domNode
.
setAttribute
(
'
width
'
,
domNode
.
style
.
width
);
domNode
.
style
.
width
=
''
;
}
}
return
domNode
;
return
domNode
;
}
}
...
...
src/blots/ResizeImageBlot.js
0 → 100644
View file @
7872ba43
import
{
AlignAction
,
DeleteAction
,
ImageSpec
,
ResizeAction
}
from
"
quill-blot-formatter
"
;
export
default
class
ResizeImageBlot
extends
ImageSpec
{
getActions
()
{
return
[
AlignAction
,
DeleteAction
,
ResizeAction
];
}
}
src/blots/VideoBlot.js
View file @
7872ba43
...
@@ -16,6 +16,10 @@ export default class VideoBlot extends Video {
...
@@ -16,6 +16,10 @@ export default class VideoBlot extends Video {
case
'
rutube.ru
'
:
case
'
rutube.ru
'
:
case
'
www.rutube.ru
'
:
case
'
www.rutube.ru
'
:
value
=
`https://rutube.ru/pl/?pl_id&pl_type&pl_video=
${
id
}
`
;
value
=
`https://rutube.ru/pl/?pl_id&pl_type&pl_video=
${
id
}
`
;
break
case
'
vimeo.com
'
:
value
=
`https://player.vimeo.com/video/
${
id
}
`
;
break
break
case
'
ok.ru
'
:
case
'
ok.ru
'
:
case
'
www.ok.ru
'
:
case
'
www.ok.ru
'
:
...
...
src/index.scss
View file @
7872ba43
...
@@ -243,6 +243,12 @@
...
@@ -243,6 +243,12 @@
width
:
24px
;
width
:
24px
;
height
:
24px
;
height
:
24px
;
}
}
&
.rutube
{
background-image
:
url('data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%2246%22%20height%3D%2221%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill-rule%3D%22nonzero%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M13.902%206H0v15h3.87v-4.88h7.414L14.667%2021H19l-3.73-4.902c1.158-.18%201.992-.608%202.502-1.282.51-.675.765-1.755.765-3.194v-1.124c0-.855-.093-1.53-.255-2.047a3.399%203.399%200%200%200-.834-1.372%203.799%203.799%200%200%200-1.437-.832C15.455%206.09%2014.76%206%2013.903%206zm-.625%206.814H3.87V9.306h9.407c.533%200%20.904.09%201.089.247.185.158.301.45.301.877v1.26c0%20.45-.116.742-.301.9-.185.157-.556.224-1.09.224zM24.758%2016.57V6H21v10.48c0%20.854.067%201.552.225%202.069.157.54.427.99.832%201.372.383.404.833.674%201.373.832.54.18%201.215.247%202.07.247h9c.833%200%201.508-.067%202.047-.247.54-.158.99-.428%201.396-.832.382-.383.652-.832.81-1.372.157-.517.247-1.215.247-2.07V6h-3.758v10.57c0%20.45-.112.742-.292.9-.18.157-.54.224-1.058.224h-7.785c-.54%200-.9-.067-1.08-.225-.18-.157-.27-.45-.27-.9z%22%20fill%3D%22%2314191E%22%2F%3E%3Cpath%20d%3D%22M42.682%205.252a2.623%202.623%200%200%200%202.619-2.626A2.623%202.623%200%200%200%2042.682%200a2.623%202.623%200%200%200-2.62%202.626%202.623%202.623%200%200%200%202.62%202.626z%22%20fill%3D%22%23F41240%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E')
;
width
:
32px
;
height
:
24px
;
background-size
:
contain
;
}
}
}
}
}
...
...
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