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
5d537563
Commit
5d537563
authored
Jun 17, 2026
by
Яков
Browse files
update fix issue
parent
dce5c6ec
Changes
2
Show whitespace changes
Inline
Side-by-side
package.json
View file @
5d537563
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.1.7
4
"
,
"version"
:
"1.1.7
5
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/extensions/ToggleBlock.js
View file @
5d537563
...
@@ -210,10 +210,50 @@ const ToggleBlock = Node.create({
...
@@ -210,10 +210,50 @@ const ToggleBlock = Node.create({
return
additionalOffset
>
0
?
tr
:
null
return
additionalOffset
>
0
?
tr
:
null
}
}
const
cleanLeadingEmptyParagraphs
=
(
state
)
=>
{
const
doc
=
state
.
doc
const
tr
=
state
.
tr
let
offset
=
0
doc
.
forEach
((
node
,
pos
)
=>
{
if
(
node
.
type
.
name
!==
'
toggleBlock
'
)
return
// Считаем сколько пустых параграфов стоят первыми подряд
let
emptyCount
=
0
for
(
let
i
=
0
;
i
<
node
.
childCount
;
i
++
)
{
const
child
=
node
.
child
(
i
)
if
(
child
.
type
.
name
===
'
paragraph
'
&&
child
.
childCount
===
0
)
{
emptyCount
++
}
else
{
break
}
}
// Оставляем хотя бы один блок — удаляем только если после пустых есть что-то ещё
const
removable
=
node
.
childCount
>
emptyCount
?
emptyCount
:
Math
.
max
(
0
,
emptyCount
-
1
)
if
(
removable
===
0
)
return
// Удаляем removable пустых параграфов с начала содержимого toggle-блока
const
contentStart
=
pos
+
offset
+
1
// +1 = открывающий токен toggle-блока
let
deleteEnd
=
contentStart
for
(
let
i
=
0
;
i
<
removable
;
i
++
)
{
deleteEnd
+=
node
.
child
(
i
).
nodeSize
}
tr
.
delete
(
contentStart
,
deleteEnd
)
offset
-=
(
deleteEnd
-
contentStart
)
})
return
tr
.
steps
.
length
>
0
?
tr
:
null
}
return
[
return
[
new
Plugin
({
new
Plugin
({
key
:
new
PluginKey
(
'
toggleBlockGap
'
),
key
:
new
PluginKey
(
'
toggleBlockGap
'
),
view
(
editorView
)
{
view
(
editorView
)
{
// Миграция: убираем пустые параграфы в начале toggle-блоков (артефакт старого бага)
const
cleanTr
=
cleanLeadingEmptyParagraphs
(
editorView
.
state
)
if
(
cleanTr
)
editorView
.
dispatch
(
cleanTr
)
// Fix adjacent toggle blocks present in initially loaded content
// Fix adjacent toggle blocks present in initially loaded content
const
tr
=
buildGapFix
(
editorView
.
state
)
const
tr
=
buildGapFix
(
editorView
.
state
)
if
(
tr
)
editorView
.
dispatch
(
tr
)
if
(
tr
)
editorView
.
dispatch
(
tr
)
...
...
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