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

update fix issue

parent fe688702
{ {
"name": "react-ag-qeditor", "name": "react-ag-qeditor",
"version": "1.1.54", "version": "1.1.55",
"description": "WYSIWYG html editor", "description": "WYSIWYG html editor",
"author": "atma", "author": "atma",
"license": "MIT", "license": "MIT",
......
...@@ -1542,9 +1542,23 @@ const QEditor = ({ ...@@ -1542,9 +1542,23 @@ const QEditor = ({
}) })
.command(({ tr, state }) => { .command(({ tr, state }) => {
// После setImage курсор — NodeSelection на картинке. // После setImage курсор — NodeSelection на картинке.
// Переводим в TextSelection сразу после неё. // На десктопе: TextSelection сразу после картинки (inline).
// На мобильном: курсор в следующий параграф — иначе он
// растягивается на всю высоту картинки.
const { $to } = state.selection const { $to } = state.selection
tr.setSelection(TextSelection.create(tr.doc, $to.pos)) if (isMobile) {
const afterPara = $to.after(Math.min($to.depth, 1))
const target = afterPara < tr.doc.nodeSize - 1
? afterPara + 1
: afterPara
try {
tr.setSelection(TextSelection.create(tr.doc, target))
} catch {
tr.setSelection(TextSelection.create(tr.doc, $to.pos))
}
} else {
tr.setSelection(TextSelection.create(tr.doc, $to.pos))
}
return true return true
}) })
.run() .run()
......
...@@ -23,8 +23,11 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select ...@@ -23,8 +23,11 @@ const ResizableImageTemplate = ({ node, updateAttributes, editor, getPos, select
const isNoWrap = !node.attrs.wrap && (node.attrs.align === 'left' || node.attrs.align === 'right'); const isNoWrap = !node.attrs.wrap && (node.attrs.align === 'left' || node.attrs.align === 'right');
// Добавляем прозрачный нулевой пробел после изображения // На десктопе вставляем \u200B после картинки, чтобы курсор можно было
// поставить inline сразу после неё. На мобильном это не нужно — там курсор
// всё равно встаёт на всю высоту картинки, выглядит некорректно.
useEffect(() => { useEffect(() => {
if (isMobile) return
if (!editor || !getPos || editor.isDestroyed) return if (!editor || !getPos || editor.isDestroyed) return
let pos let pos
......
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