Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
a-doc-editor
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramdayal Munda
a-doc-editor
Commits
2767b644
Commit
2767b644
authored
Dec 11, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caret position on multiple pages fixed
parent
76cb7969
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
a-doc-editor.js
dist/assets/a-doc-editor.js
+11
-14
No files found.
dist/assets/a-doc-editor.js
View file @
2767b644
...
...
@@ -193,12 +193,11 @@ var ADocEditor = function (customConfig) {
}
dataList
[
i
].
style
.
canvasX
=
x
let
canvas
=
canvasList
[
canvasIndex
].
el
canvas
.
setAttribute
(
"tabIndex"
,
-
1
)
calculateTextPositions
(
canvas
,
dataList
[
i
])
x
=
0
;
if
(
dataList
[
i
].
id
==
caretData
.
activeData
.
id
)
{
caretData
.
canvasIndex
=
canvasIndex
;
}
//
if (dataList[i].id == caretData.activeData.id) {
// // caretData.canvasIndex = canvasIndex; // this was the issue
;
//
}
}
renderFormattedData
()
if
(
!
caretData
.
blink
&&
caretData
.
activeData
)
renderCaret
()
...
...
@@ -324,7 +323,7 @@ var ADocEditor = function (customConfig) {
// to render caret
function
renderCaret
()
{
console
.
log
(
'
caretCanvas'
,
caretData
.
canvasI
ndex
)
console
.
log
(
'
renderCaret'
,
caretData
.
canvasIndex
,
caretData
.
i
ndex
)
let
ctx
=
canvasList
[
caretData
.
canvasIndex
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
let
activeTextData
=
caretData
.
activeData
.
formatedText
[
caretData
.
index
-
1
]
if
(
!
activeTextData
)
activeTextData
=
caretData
.
activeData
.
style
...
...
@@ -350,6 +349,7 @@ var ADocEditor = function (customConfig) {
function
createCanvas
()
{
let
canvas
=
document
.
createElement
(
'canvas'
)
canvas
.
setAttribute
(
"tabIndex"
,
-
1
)
canvas
.
setAttribute
(
'class'
,
'page'
)
canvas
.
setAttribute
(
'id'
,
`canvas_
${
++
counter
}
`
)
canvas
.
width
=
config
.
pageSetup
.
canvasWidth
...
...
@@ -494,7 +494,6 @@ var ADocEditor = function (customConfig) {
}
function
setCaretPosition
(
e
)
{
console
.
clear
()
let
rect
=
e
.
target
.
getBoundingClientRect
()
let
canvasIndex
=
canvasList
.
findIndex
(
item
=>
item
.
el
==
e
.
target
)
...
...
@@ -539,15 +538,14 @@ var ADocEditor = function (customConfig) {
if
(
!
dataSet
[
setIndex
].
plainContent
.
length
){
charIndex
=
0
}
else
{
console
.
log
(
'after loop, '
,
dataSet
[
setIndex
].
formatedText
[
86
])
for
(
let
i
=
charIndex
;
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasY
&&
dataSet
[
setIndex
].
formatedText
[
i
].
canvasY
==
lineY
);
i
++
){
console
.
log
(
'i'
,
i
)
let
i
=
0
for
(
i
=
charIndex
;
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasY
&&
dataSet
[
setIndex
].
formatedText
[
i
].
canvasY
==
lineY
);
i
++
){
if
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasX
>=
position
.
x
){
charIndex
=
i
;
i
++
break
;
}
}
c
onsole
.
log
(
'after loop'
)
c
harIndex
=
i
-
1
}
...
...
@@ -555,7 +553,6 @@ var ADocEditor = function (customConfig) {
caretData
.
activeData
=
dataSet
[
setIndex
];
caretData
.
index
=
charIndex
;
caretData
.
canvasIndex
=
canvasIndex
;
console
.
log
(
"caretDatacanvasIndex:"
,
caretData
.
canvasIndex
)
caretData
.
blink
=
false
break
;
}
...
...
@@ -575,9 +572,9 @@ var ADocEditor = function (customConfig) {
charIndex
++
}
console
.
log
(
"
final careCanvasIndex
:"
,
caretData
.
canvasIndex
)
console
.
log
(
"
last line
:"
,
caretData
.
canvasIndex
)
}
console
.
log
(
'full break;'
)
console
.
log
(
'full break;'
,
caretData
.
canvasIndex
,
caretData
.
index
)
...
...
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