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
2bf763b4
Commit
2bf763b4
authored
Jun 17, 2026
by
Яков
Browse files
update fix issue
parent
66da5bdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
2bf763b4
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.1.7
6
"
,
"version"
:
"1.1.7
7
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/extensions/ToggleBlock.js
View file @
2bf763b4
import
{
Node
}
from
'
@tiptap/core
'
import
{
Node
}
from
'
@tiptap/core
'
import
{
ReactNodeViewRenderer
,
NodeViewWrapper
,
NodeViewContent
}
from
'
@tiptap/react
'
import
{
ReactNodeViewRenderer
,
NodeViewWrapper
,
NodeViewContent
}
from
'
@tiptap/react
'
import
React
,
{
useEffect
,
useRef
,
useState
}
from
'
react
'
import
React
,
{
useEffect
,
useRef
,
useState
}
from
'
react
'
import
{
TextSelection
,
Plugin
,
PluginKey
}
from
'
prosemirror-state
'
import
{
TextSelection
,
NodeSelection
,
Plugin
,
PluginKey
}
from
'
prosemirror-state
'
const
DragHandleIcon
=
()
=>
(
const
DragHandleIcon
=
()
=>
(
<
svg
width
=
"
10
"
height
=
"
16
"
viewBox
=
"
0 0 10 16
"
fill
=
"
none
"
xmlns
=
"
http://www.w3.org/2000/svg
"
>
<
svg
width
=
"
10
"
height
=
"
16
"
viewBox
=
"
0 0 10 16
"
fill
=
"
none
"
xmlns
=
"
http://www.w3.org/2000/svg
"
>
...
@@ -77,8 +77,21 @@ export const ToggleBlockComponent = ({node, updateAttributes, getPos, editor, se
...
@@ -77,8 +77,21 @@ export const ToggleBlockComponent = ({node, updateAttributes, getPos, editor, se
<
div
<
div
className
=
"
toggle-drag-handle
"
className
=
"
toggle-drag-handle
"
contentEditable
=
{
false
}
contentEditable
=
{
false
}
draggable
=
{
true
}
data
-
drag
-
handle
=
""
data
-
drag
-
handle
=
""
title
=
"
Перетащить
"
title
=
"
Перетащить
"
onDragStart
=
{(
e
)
=>
{
try
{
const
pos
=
getPos
?.()
if
(
typeof
pos
===
'
number
'
)
{
editor
.
view
.
dispatch
(
editor
.
view
.
state
.
tr
.
setSelection
(
NodeSelection
.
create
(
editor
.
view
.
state
.
doc
,
pos
)
)
)
}
}
catch
{}
}}
>
>
<
DragHandleIcon
/>
<
DragHandleIcon
/>
<
/div
>
<
/div
>
...
@@ -169,12 +182,15 @@ const ToggleBlock = Node.create({
...
@@ -169,12 +182,15 @@ const ToggleBlock = Node.create({
return
[{
return
[{
tag
:
'
div.toggle-block
'
,
tag
:
'
div.toggle-block
'
,
getAttrs
:
(
element
)
=>
{
getAttrs
:
(
element
)
=>
{
const
wrapp
er
=
element
.
querySelector
(
'
.toggle-block-inner
'
)
const
inn
er
=
element
.
querySelector
(
'
.toggle-block-inner
'
)
const
titleEl
=
wrapp
er
?.
querySelector
(
'
.toggle-header
'
)
const
titleEl
=
inn
er
?.
querySelector
(
'
.toggle-header
'
)
const
title
=
titleEl
?.
textContent
?.
trim
()
||
'
Заголовок
'
const
title
=
titleEl
?.
textContent
?.
trim
()
||
'
Заголовок
'
if
(
titleEl
?.
parentNode
)
{
// Удаляем весь toggle-block-inner из DOM — иначе его содержимое
titleEl
.
parentNode
.
removeChild
(
titleEl
)
// (span.toggle-button и пр.) парсится ProseMirror как блочный контент
// и создаёт лишний параграф перед текстом блока
if
(
inner
?.
parentNode
)
{
inner
.
parentNode
.
removeChild
(
inner
)
}
}
return
{
title
}
return
{
title
}
...
...
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