Commit 5b6b2868 by Яков

fix

parent 8d6f07f5
{
"name": "react-ag-qeditor",
"version": "1.0.93",
"version": "1.0.94",
"description": "WYSIWYG html editor",
"author": "atma",
"license": "MIT",
......
......@@ -106,7 +106,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
const onMouseMove = (e) => {
const { startWidth, startHeight, startX, startY, aspectRatio, direction, nodePos } = resizeData.current;
// Проверяем, что узел все еще существует
if (typeof nodePos === 'number') {
try {
const resolvedPos = editor.view.state.doc.resolve(nodePos);
......@@ -143,25 +142,25 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
}
}
// Принудительное обновление с новым transaction
const { state, dispatch } = editor.view;
const tr = state.tr.setNodeMarkup(nodePos, undefined, {
...node.attrs,
// Сохраняем новые размеры в resizeData для использования в onMouseUp
resizeData.current.currentWidth = newWidth;
resizeData.current.currentHeight = newHeight;
updateAttributes({
width: newWidth,
height: newHeight
});
dispatch(tr);
};
const onMouseUp = () => {
window.removeEventListener('mousemove', onMouseMove);
window.removeEventListener('mouseup', onMouseUp);
// Обновляем атрибуты в конце ресайза для синхронизации
// Фиксируем окончательные размеры
if (typeof resizeData.current.nodePos === 'number') {
updateAttributes({
width: node.attrs.width,
height: node.attrs.height
width: resizeData.current.currentWidth,
height: resizeData.current.currentHeight
});
}
......@@ -169,7 +168,6 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos }) => {
setTimeout(() => {
try {
editor.commands.focus();
// Принудительное обновление представления
editor.view.dispatch(editor.view.state.tr.setMeta('forceUpdate', true));
} catch (error) {
console.warn('Focus error after resize:', error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment