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
09d32905
Commit
09d32905
authored
May 20, 2026
by
Яков
Browse files
верстка
parent
08d24f68
Changes
2
Show whitespace changes
Inline
Side-by-side
package.json
View file @
09d32905
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.1.4
7
"
,
"version"
:
"1.1.4
8
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/QEditor.jsx
View file @
09d32905
...
@@ -51,42 +51,10 @@ import IframeModal from './modals/IframeModal'
...
@@ -51,42 +51,10 @@ import IframeModal from './modals/IframeModal'
import
IframeCustomModal
from
'
./modals/IframeCustomModal
'
import
IframeCustomModal
from
'
./modals/IframeCustomModal
'
import
{
isMobile
}
from
'
react-device-detect
'
import
{
isMobile
}
from
'
react-device-detect
'
import
{
ExportPdf
}
from
'
./extensions/ExportPdf
'
import
{
ExportPdf
}
from
'
./extensions/ExportPdf
'
import
{
mergeAttributes
,
Extension
}
from
"
@tiptap/core
"
;
import
{
mergeAttributes
}
from
"
@tiptap/core
"
;
import
Upload
from
"
rc-upload
"
;
import
Upload
from
"
rc-upload
"
;
import
{
NodeSelection
}
from
'
prosemirror-state
'
import
{
NodeSelection
}
from
'
prosemirror-state
'
// Выход из code block по Enter на пустой последней строке
const
ExitCodeBlock
=
Extension
.
create
({
name
:
'
exitCodeBlock
'
,
addKeyboardShortcuts
()
{
return
{
Enter
:
({
editor
})
=>
{
if
(
!
editor
.
isActive
(
'
codeBlock
'
))
return
false
const
{
$anchor
}
=
editor
.
state
.
selection
if
(
!
editor
.
state
.
selection
.
empty
)
return
false
const
nodeText
=
$anchor
.
parent
.
textContent
const
offset
=
$anchor
.
parentOffset
// Если курсор на последней строке и она пустая — выходим из блока
const
lastNewline
=
nodeText
.
lastIndexOf
(
'
\n
'
,
offset
-
1
)
const
currentLine
=
nodeText
.
slice
(
lastNewline
+
1
,
offset
)
if
(
currentLine
===
''
)
{
// Удаляем пустую строку и создаём параграф после блока
return
editor
.
chain
()
.
command
(({
tr
,
state
})
=>
{
const
from
=
$anchor
.
pos
-
1
tr
.
delete
(
from
,
$anchor
.
pos
)
return
true
})
.
exitCode
()
.
run
()
}
return
false
}
}
}
})
// const CustomImage = Image.extend({
// const CustomImage = Image.extend({
// options: {inline: true},
// options: {inline: true},
// // addNodeView() {
// // addNodeView() {
...
@@ -496,7 +464,25 @@ const QEditor = ({
...
@@ -496,7 +464,25 @@ const QEditor = ({
},
},
codeBlock
:
{
codeBlock
:
{
title
:
'
Код
'
,
title
:
'
Код
'
,
onClick
:
()
=>
editor
.
chain
().
focus
().
toggleCodeBlock
().
run
()
onClick
:
()
=>
{
const
{
empty
,
from
,
to
}
=
editor
.
state
.
selection
if
(
!
empty
)
{
// Есть выделение — применяем только к нему
editor
.
chain
().
focus
().
toggleCode
().
run
()
}
else
{
// Нет выделения — выделяем весь текущий блок
const
{
$anchor
}
=
editor
.
state
.
selection
const
blockStart
=
$anchor
.
start
()
const
blockEnd
=
$anchor
.
end
()
editor
.
chain
()
.
focus
()
.
setTextSelection
({
from
:
blockStart
,
to
:
blockEnd
})
.
toggleCode
()
.
setTextSelection
(
from
)
// возвращаем курсор на место
.
run
()
}
}
},
},
clearMarks
:
{
clearMarks
:
{
title
:
'
Очистить форматирование
'
,
title
:
'
Очистить форматирование
'
,
...
@@ -705,7 +691,6 @@ const QEditor = ({
...
@@ -705,7 +691,6 @@ const QEditor = ({
const
editor
=
useEditor
({
const
editor
=
useEditor
({
extensions
:
[
extensions
:
[
StarterKit
,
StarterKit
,
ExitCodeBlock
,
Underline
,
Underline
,
ImageResize
,
ImageResize
,
Link
.
configure
({
Link
.
configure
({
...
...
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