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
5b8e6efe
Commit
5b8e6efe
authored
May 22, 2026
by
Яков
Browse files
update fix issue
parent
fd07d727
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
5b8e6efe
{
{
"name"
:
"react-ag-qeditor"
,
"name"
:
"react-ag-qeditor"
,
"version"
:
"1.1.5
8
"
,
"version"
:
"1.1.5
9
"
,
"description"
:
"WYSIWYG html editor"
,
"description"
:
"WYSIWYG html editor"
,
"author"
:
"atma"
,
"author"
:
"atma"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
...
...
src/QEditor.jsx
View file @
5b8e6efe
...
@@ -51,7 +51,7 @@ import IframeModal from './modals/IframeModal'
...
@@ -51,7 +51,7 @@ import IframeModal from './modals/IframeModal'
import
IframeCustomModal
from
'
./modals/IframeCustomModal
'
import
IframeCustomModal
from
'
./modals/IframeCustomModal
'
import
{
isMobile
}
from
'
react-device-detect
'
import
{
isMobile
}
from
'
react-device-detect
'
import
{
ExportPdf
}
from
'
./extensions/ExportPdf
'
import
{
ExportPdf
}
from
'
./extensions/ExportPdf
'
import
{
mergeAttributes
}
from
"
@tiptap/core
"
;
import
{
mergeAttributes
,
Extension
}
from
"
@tiptap/core
"
;
import
Upload
from
"
rc-upload
"
;
import
Upload
from
"
rc-upload
"
;
import
{
NodeSelection
,
TextSelection
}
from
'
prosemirror-state
'
import
{
NodeSelection
,
TextSelection
}
from
'
prosemirror-state
'
...
@@ -70,6 +70,76 @@ import { NodeSelection, TextSelection } from 'prosemirror-state'
...
@@ -70,6 +70,76 @@ import { NodeSelection, TextSelection } from 'prosemirror-state'
// })
// })
const
{
TextArea
}
=
Input
;
const
{
TextArea
}
=
Input
;
// Word-by-word navigation (Word-like: Ctrl+Arrow)
function
_wordFwd
(
text
,
pos
)
{
let
i
=
pos
while
(
i
<
text
.
length
&&
/
\s
/
.
test
(
text
[
i
]))
i
++
while
(
i
<
text
.
length
&&
/
\S
/
.
test
(
text
[
i
]))
i
++
return
i
}
function
_wordBwd
(
text
,
pos
)
{
let
i
=
pos
while
(
i
>
0
&&
/
\s
/
.
test
(
text
[
i
-
1
]))
i
--
while
(
i
>
0
&&
/
\S
/
.
test
(
text
[
i
-
1
]))
i
--
return
i
}
function
_moveByWord
(
editor
,
forward
,
extend
)
{
const
{
state
}
=
editor
const
{
selection
,
doc
}
=
state
const
{
$anchor
,
$head
}
=
selection
const
$cursor
=
extend
?
$head
:
(
forward
?
selection
.
$to
:
selection
.
$from
)
const
pos
=
$cursor
.
pos
const
blockStart
=
$cursor
.
start
()
const
blockEnd
=
$cursor
.
end
()
const
blockText
=
doc
.
textBetween
(
blockStart
,
blockEnd
,
''
,
''
)
const
relPos
=
pos
-
blockStart
let
newPos
if
(
forward
)
{
const
nr
=
_wordFwd
(
blockText
,
relPos
)
if
(
nr
===
relPos
&&
blockEnd
+
1
<=
doc
.
content
.
size
)
{
// no movement possible in this block — jump into next block
try
{
const
$next
=
doc
.
resolve
(
blockEnd
+
1
)
newPos
=
$next
.
start
()
}
catch
{
newPos
=
blockEnd
}
}
else
{
newPos
=
blockStart
+
nr
}
}
else
{
const
nr
=
_wordBwd
(
blockText
,
relPos
)
if
(
nr
===
relPos
&&
blockStart
-
1
>
0
)
{
// no movement possible in this block — jump to end of previous block
try
{
const
$prev
=
doc
.
resolve
(
blockStart
-
1
)
newPos
=
$prev
.
end
()
}
catch
{
newPos
=
Math
.
max
(
0
,
blockStart
-
1
)
}
}
else
{
newPos
=
blockStart
+
nr
}
}
newPos
=
Math
.
max
(
0
,
Math
.
min
(
newPos
,
doc
.
content
.
size
))
const
anchorPos
=
extend
?
$anchor
.
pos
:
newPos
try
{
const
sel
=
TextSelection
.
create
(
doc
,
anchorPos
,
newPos
)
editor
.
view
.
dispatch
(
state
.
tr
.
setSelection
(
sel
).
scrollIntoView
())
}
catch
{
/* invalid position */
}
return
true
}
const
WordNavigation
=
Extension
.
create
({
name
:
'
wordNavigation
'
,
addKeyboardShortcuts
()
{
return
{
'
Ctrl-ArrowRight
'
:
()
=>
_moveByWord
(
this
.
editor
,
true
,
false
),
'
Ctrl-ArrowLeft
'
:
()
=>
_moveByWord
(
this
.
editor
,
false
,
false
),
'
Ctrl-Shift-ArrowRight
'
:
()
=>
_moveByWord
(
this
.
editor
,
true
,
true
),
'
Ctrl-Shift-ArrowLeft
'
:
()
=>
_moveByWord
(
this
.
editor
,
false
,
true
),
}
}
})
const
initialBubbleItems
=
[
const
initialBubbleItems
=
[
'
bold
'
,
'
bold
'
,
'
italic
'
,
'
italic
'
,
...
@@ -740,6 +810,7 @@ const QEditor = ({
...
@@ -740,6 +810,7 @@ const QEditor = ({
Subscript
,
Subscript
,
ToggleBlock
,
ToggleBlock
,
InteractiveImage
,
InteractiveImage
,
WordNavigation
,
DragAndDrop
.
configure
({
DragAndDrop
.
configure
({
uploadUrl
:
uploadOptions
.
url
,
uploadUrl
:
uploadOptions
.
url
,
allowedFileTypes
:
[
allowedFileTypes
:
[
...
...
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