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
5b6b2868
Commit
5b6b2868
authored
Jul 01, 2025
by
Яков
Browse files
fix
parent
8d6f07f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
5b6b2868
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.0.9
3
"
,
"version"
:
"1.0.9
4
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/extensions/Image.jsx
View file @
5b6b2868
...
@@ -106,7 +106,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
...
@@ -106,7 +106,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
const
onMouseMove
=
(
e
)
=>
{
const
onMouseMove
=
(
e
)
=>
{
const
{
startWidth
,
startHeight
,
startX
,
startY
,
aspectRatio
,
direction
,
nodePos
}
=
resizeData
.
current
;
const
{
startWidth
,
startHeight
,
startX
,
startY
,
aspectRatio
,
direction
,
nodePos
}
=
resizeData
.
current
;
// Проверяем, что узел все еще существует
if
(
typeof
nodePos
===
'
number
'
)
{
if
(
typeof
nodePos
===
'
number
'
)
{
try
{
try
{
const
resolvedPos
=
editor
.
view
.
state
.
doc
.
resolve
(
nodePos
);
const
resolvedPos
=
editor
.
view
.
state
.
doc
.
resolve
(
nodePos
);
...
@@ -143,25 +142,25 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
...
@@ -143,25 +142,25 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
}
}
}
}
// Принудительное обновление с новым transaction
// Сохраняем новые размеры в resizeData для использования в onMouseUp
const
{
state
,
dispatch
}
=
editor
.
view
;
resizeData
.
current
.
currentWidth
=
newWidth
;
const
tr
=
state
.
tr
.
setNodeMarkup
(
nodePos
,
undefined
,
{
resizeData
.
current
.
currentHeight
=
newHeight
;
...
node
.
attrs
,
updateAttributes
({
width
:
newWidth
,
width
:
newWidth
,
height
:
newHeight
height
:
newHeight
});
});
dispatch
(
tr
);
};
};
const
onMouseUp
=
()
=>
{
const
onMouseUp
=
()
=>
{
window
.
removeEventListener
(
'
mousemove
'
,
onMouseMove
);
window
.
removeEventListener
(
'
mousemove
'
,
onMouseMove
);
window
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
);
window
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
);
//
Обновляем атрибуты в конце ресайза для синхронизации
//
Фиксируем окончательные размеры
if
(
typeof
resizeData
.
current
.
nodePos
===
'
number
'
)
{
if
(
typeof
resizeData
.
current
.
nodePos
===
'
number
'
)
{
updateAttributes
({
updateAttributes
({
width
:
node
.
attrs
.
w
idth
,
width
:
resizeData
.
current
.
currentW
idth
,
height
:
node
.
attrs
.
h
eight
height
:
resizeData
.
current
.
currentH
eight
});
});
}
}
...
@@ -169,7 +168,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
...
@@ -169,7 +168,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
try
{
try
{
editor
.
commands
.
focus
();
editor
.
commands
.
focus
();
// Принудительное обновление представления
editor
.
view
.
dispatch
(
editor
.
view
.
state
.
tr
.
setMeta
(
'
forceUpdate
'
,
true
));
editor
.
view
.
dispatch
(
editor
.
view
.
state
.
tr
.
setMeta
(
'
forceUpdate
'
,
true
));
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
warn
(
'
Focus error after resize:
'
,
error
);
console
.
warn
(
'
Focus error after resize:
'
,
error
);
...
...
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