Commit 5b6b2868 by Яков

fix

parent 8d6f07f5
{ {
"name": "react-ag-qeditor", "name": "react-ag-qeditor",
"version": "1.0.93", "version": "1.0.94",
"description": "WYSIWYG html editor", "description": "WYSIWYG html editor",
"author": "atma", "author": "atma",
"license": "MIT", "license": "MIT",
......
...@@ -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.width, width: resizeData.current.currentWidth,
height: node.attrs.height height: resizeData.current.currentHeight
}); });
} }
...@@ -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);
......
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