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) {
...
@@ -193,12 +193,11 @@ var ADocEditor = function (customConfig) {
}
}
dataList
[
i
].
style
.
canvasX
=
x
dataList
[
i
].
style
.
canvasX
=
x
let
canvas
=
canvasList
[
canvasIndex
].
el
let
canvas
=
canvasList
[
canvasIndex
].
el
canvas
.
setAttribute
(
"tabIndex"
,
-
1
)
calculateTextPositions
(
canvas
,
dataList
[
i
])
calculateTextPositions
(
canvas
,
dataList
[
i
])
x
=
0
;
x
=
0
;
if
(
dataList
[
i
].
id
==
caretData
.
activeData
.
id
)
{
//
if (dataList[i].id == caretData.activeData.id) {
caretData
.
canvasIndex
=
canvasIndex
;
// // caretData.canvasIndex = canvasIndex; // this was the issue
;
}
//
}
}
}
renderFormattedData
()
renderFormattedData
()
if
(
!
caretData
.
blink
&&
caretData
.
activeData
)
renderCaret
()
if
(
!
caretData
.
blink
&&
caretData
.
activeData
)
renderCaret
()
...
@@ -324,7 +323,7 @@ var ADocEditor = function (customConfig) {
...
@@ -324,7 +323,7 @@ var ADocEditor = function (customConfig) {
// to render caret
// to render caret
function
renderCaret
()
{
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
ctx
=
canvasList
[
caretData
.
canvasIndex
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
let
activeTextData
=
caretData
.
activeData
.
formatedText
[
caretData
.
index
-
1
]
let
activeTextData
=
caretData
.
activeData
.
formatedText
[
caretData
.
index
-
1
]
if
(
!
activeTextData
)
activeTextData
=
caretData
.
activeData
.
style
if
(
!
activeTextData
)
activeTextData
=
caretData
.
activeData
.
style
...
@@ -350,6 +349,7 @@ var ADocEditor = function (customConfig) {
...
@@ -350,6 +349,7 @@ var ADocEditor = function (customConfig) {
function
createCanvas
()
{
function
createCanvas
()
{
let
canvas
=
document
.
createElement
(
'canvas'
)
let
canvas
=
document
.
createElement
(
'canvas'
)
canvas
.
setAttribute
(
"tabIndex"
,
-
1
)
canvas
.
setAttribute
(
'class'
,
'page'
)
canvas
.
setAttribute
(
'class'
,
'page'
)
canvas
.
setAttribute
(
'id'
,
`canvas_
${
++
counter
}
`
)
canvas
.
setAttribute
(
'id'
,
`canvas_
${
++
counter
}
`
)
canvas
.
width
=
config
.
pageSetup
.
canvasWidth
canvas
.
width
=
config
.
pageSetup
.
canvasWidth
...
@@ -494,7 +494,6 @@ var ADocEditor = function (customConfig) {
...
@@ -494,7 +494,6 @@ var ADocEditor = function (customConfig) {
}
}
function
setCaretPosition
(
e
)
{
function
setCaretPosition
(
e
)
{
console
.
clear
()
let
rect
=
e
.
target
.
getBoundingClientRect
()
let
rect
=
e
.
target
.
getBoundingClientRect
()
let
canvasIndex
=
canvasList
.
findIndex
(
item
=>
item
.
el
==
e
.
target
)
let
canvasIndex
=
canvasList
.
findIndex
(
item
=>
item
.
el
==
e
.
target
)
...
@@ -539,15 +538,14 @@ var ADocEditor = function (customConfig) {
...
@@ -539,15 +538,14 @@ var ADocEditor = function (customConfig) {
if
(
!
dataSet
[
setIndex
].
plainContent
.
length
){
if
(
!
dataSet
[
setIndex
].
plainContent
.
length
){
charIndex
=
0
charIndex
=
0
}
else
{
}
else
{
console
.
log
(
'after loop, '
,
dataSet
[
setIndex
].
formatedText
[
86
])
let
i
=
0
for
(
let
i
=
charIndex
;
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasY
&&
dataSet
[
setIndex
].
formatedText
[
i
].
canvasY
==
lineY
);
i
++
){
for
(
i
=
charIndex
;
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasY
&&
dataSet
[
setIndex
].
formatedText
[
i
].
canvasY
==
lineY
);
i
++
){
console
.
log
(
'i'
,
i
)
if
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasX
>=
position
.
x
){
if
(
dataSet
[
setIndex
].
formatedText
[
i
]?.
canvasX
>=
position
.
x
){
charIndex
=
i
;
i
++
break
;
break
;
}
}
}
}
c
onsole
.
log
(
'after loop'
)
c
harIndex
=
i
-
1
}
}
...
@@ -555,7 +553,6 @@ var ADocEditor = function (customConfig) {
...
@@ -555,7 +553,6 @@ var ADocEditor = function (customConfig) {
caretData
.
activeData
=
dataSet
[
setIndex
];
caretData
.
activeData
=
dataSet
[
setIndex
];
caretData
.
index
=
charIndex
;
caretData
.
index
=
charIndex
;
caretData
.
canvasIndex
=
canvasIndex
;
caretData
.
canvasIndex
=
canvasIndex
;
console
.
log
(
"caretDatacanvasIndex:"
,
caretData
.
canvasIndex
)
caretData
.
blink
=
false
caretData
.
blink
=
false
break
;
break
;
}
}
...
@@ -575,9 +572,9 @@ var ADocEditor = function (customConfig) {
...
@@ -575,9 +572,9 @@ var ADocEditor = function (customConfig) {
charIndex
++
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