Commit a6ac6046 authored by Яков's avatar Яков
Browse files

update fix issue

parent b4462e85
{ {
"name": "react-ag-qeditor", "name": "react-ag-qeditor",
"version": "1.1.63", "version": "1.1.64",
"description": "WYSIWYG html editor", "description": "WYSIWYG html editor",
"author": "atma", "author": "atma",
"license": "MIT", "license": "MIT",
......
...@@ -140,6 +140,31 @@ const WordNavigation = Extension.create({ ...@@ -140,6 +140,31 @@ const WordNavigation = Extension.create({
} }
}) })
const ImageWrapEnter = Extension.create({
name: 'imageWrapEnter',
addKeyboardShortcuts() {
return {
'Enter': ({ editor }) => {
const { state } = editor
const { $from } = state.selection
const parent = $from.parent
const cursorOffset = $from.parentOffset
let lastWrappedEnd = null
parent.forEach((child, offset) => {
if (child.type.name === 'image' && child.attrs.wrap && offset >= cursorOffset) {
lastWrappedEnd = $from.start() + offset + child.nodeSize
}
})
if (lastWrappedEnd === null) return false
return editor.chain()
.setTextSelection(lastWrappedEnd)
.splitBlock()
.run()
}
}
}
})
const initialBubbleItems = [ const initialBubbleItems = [
'bold', 'bold',
'italic', 'italic',
...@@ -811,6 +836,7 @@ const QEditor = ({ ...@@ -811,6 +836,7 @@ const QEditor = ({
ToggleBlock, ToggleBlock,
InteractiveImage, InteractiveImage,
WordNavigation, WordNavigation,
ImageWrapEnter,
DragAndDrop.configure({ DragAndDrop.configure({
uploadUrl: uploadOptions.url, uploadUrl: uploadOptions.url,
allowedFileTypes: [ allowedFileTypes: [
...@@ -829,18 +855,6 @@ const QEditor = ({ ...@@ -829,18 +855,6 @@ const QEditor = ({
}) })
], ],
content: value, content: value,
onTransaction: ({ transaction }) => {
if (!transaction.docChanged) return
// Ищем шаги, которые затрагивают image-ноды
transaction.steps.forEach((step, i) => {
const json = step.toJSON?.()
if (!json) return
const str = JSON.stringify(json)
if (str.includes('"image"') || str.includes('image')) {
console.log(`[TxDebug] шаг #${i} type=${json.stepType || json.type}`, json)
}
})
},
onUpdate: ({editor}) => onChange(editor.getHTML()), onUpdate: ({editor}) => onChange(editor.getHTML()),
onFocus: ({editor}) => { onFocus: ({editor}) => {
const wrap = editor.options.element.closest('.atma-editor-wrap') const wrap = editor.options.element.closest('.atma-editor-wrap')
......
...@@ -15,28 +15,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select ...@@ -15,28 +15,7 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
const imgRef = useRef(null); const imgRef = useRef(null);
const wrapperRef = useRef(null); const wrapperRef = useRef(null);
const isInitialized = useRef(false); const isInitialized = useRef(false);
const prevPosRef = useRef(null);
const prevWrapRef = useRef(node.attrs.wrap);
const [isResizing, setIsResizing] = useState(false); const [isResizing, setIsResizing] = useState(false);
// ── DEBUG: отслеживаем смещение ноды и изменения wrap ──────────────────
useEffect(() => {
const pos = getPos?.()
const src = node.attrs.src?.split('/').pop()
if (prevPosRef.current !== null && prevPosRef.current !== pos) {
console.warn(
`[ImageDebug] ПОЗИЦИЯ ИЗМЕНИЛАСЬ src=${src} было=${prevPosRef.current} стало=${pos}`,
new Error().stack.split('\n').slice(1, 4).join(' | ')
)
}
if (prevWrapRef.current !== node.attrs.wrap) {
console.log(`[ImageDebug] wrap изменился src=${src} wrap=${node.attrs.wrap} pos=${pos}`)
}
prevPosRef.current = pos
prevWrapRef.current = node.attrs.wrap
})
const [altModalVisible, setAltModalVisible] = useState(false); const [altModalVisible, setAltModalVisible] = useState(false);
const [tempAlt, setTempAlt] = useState(node.attrs.alt || ''); const [tempAlt, setTempAlt] = useState(node.attrs.alt || '');
const [tempFrontAlt, setTempFrontAlt] = useState(node.attrs.frontAlt || ''); const [tempFrontAlt, setTempFrontAlt] = useState(node.attrs.frontAlt || '');
......
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