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
8cae1e5d
Commit
8cae1e5d
authored
Jul 04, 2025
by
Яков
Browse files
fix
parent
c36835e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
8cae1e5d
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.1.0"
,
"version"
:
"1.1.0
01
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/extensions/Image.jsx
View file @
8cae1e5d
...
@@ -101,11 +101,15 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -101,11 +101,15 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
const
initImageSize
=
()
=>
{
const
initImageSize
=
()
=>
{
try
{
try
{
// Если размеры уже заданы в атрибутах - используем их
// Если размеры уже заданы в атрибутах - используем их сразу
if
(
node
.
attrs
.
width
&&
node
.
attrs
.
height
)
{
isInitialized
.
current
=
true
;
return
;
}
const
{
width
:
editorWidth
}
=
getEditorDimensions
();
const
{
width
:
editorWidth
}
=
getEditorDimensions
();
const
naturalWidth
=
node
.
attrs
.
width
||
imgRef
.
current
.
naturalWidth
;
const
naturalWidth
=
imgRef
.
current
.
naturalWidth
;
const
naturalHeight
=
node
.
attrs
.
height
||
imgRef
.
current
.
naturalHeight
;
const
naturalHeight
=
imgRef
.
current
.
naturalHeight
;
if
(
naturalWidth
<=
0
||
naturalHeight
<=
0
)
{
if
(
naturalWidth
<=
0
||
naturalHeight
<=
0
)
{
console
.
warn
(
'
Image has invalid natural dimensions, retrying...
'
);
console
.
warn
(
'
Image has invalid natural dimensions, retrying...
'
);
...
@@ -134,6 +138,11 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -134,6 +138,11 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
};
};
const
handleLoad
=
()
=>
{
const
handleLoad
=
()
=>
{
// Если размеры уже заданы в атрибутах, пропускаем инициализацию
if
(
node
.
attrs
.
width
&&
node
.
attrs
.
height
)
{
isInitialized
.
current
=
true
;
return
;
}
setTimeout
(
initImageSize
,
50
);
setTimeout
(
initImageSize
,
50
);
};
};
...
@@ -304,7 +313,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
...
@@ -304,7 +313,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
draggable
=
{
true
}
draggable
=
{
true
}
style
=
{
getImageStyle
()
}
style
=
{
getImageStyle
()
}
onLoad
=
{
()
=>
{
onLoad
=
{
()
=>
{
if
(
imgRef
.
current
&&
!
isInitialized
.
current
)
{
if
(
imgRef
.
current
&&
!
isInitialized
.
current
&&
!
node
.
attrs
.
width
&&
!
node
.
attrs
.
height
)
{
const
{
width
:
editorWidth
}
=
getEditorDimensions
();
const
{
width
:
editorWidth
}
=
getEditorDimensions
();
const
naturalWidth
=
imgRef
.
current
.
naturalWidth
;
const
naturalWidth
=
imgRef
.
current
.
naturalWidth
;
const
naturalHeight
=
imgRef
.
current
.
naturalHeight
;
const
naturalHeight
=
imgRef
.
current
.
naturalHeight
;
...
...
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