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
05f1f83f
Commit
05f1f83f
authored
Dec 13, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
left right last char not reading fixed
parent
cd8e544e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
17 deletions
+8
-17
a-doc-editor.js
dist/assets/a-doc-editor.js
+8
-17
No files found.
dist/assets/a-doc-editor.js
View file @
05f1f83f
...
...
@@ -166,11 +166,9 @@ var ADocEditor = function (customConfig) {
lines
=
[]
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
let
canvas
=
canvasList
[
canvasIndex
].
el
calculateTextSizeAndPosition
(
canvasIndex
,
i
)
}
renderTheLines
()
console
.
log
(
'render lines:'
,
lines
[
0
])
if
(
!
caretData
.
blink
&&
caretData
.
activeData
)
renderCaret
()
...
...
@@ -239,11 +237,6 @@ var ADocEditor = function (customConfig) {
tempLineWidth
=
0
}
// counter++
// if (counter >= 500){
// console.log('was stuck', counter)
// break
// }
}
lineObj
.
plainContent
=
dataBlock
.
plainContent
.
slice
(
lineObj
.
charStartIndex
,
lineObj
.
charEndIndex
)
// there is chance that the last line is not at the width// so we need to handle the last line separately
...
...
@@ -306,13 +299,9 @@ var ADocEditor = function (customConfig) {
function renderCaret() {
let ctx = canvasList[caretData.canvasIndex].el.getContext('2d', { willReadFrequently: true })
ctx.save()
console.log( 'lines', lines)
console.log( 'dataSet', dataSet)
let activeDataIndex = dataSet.findIndex( item => item.id == caretData.activeData.id )
let activeLine = lines.find( (item, i) => {
console.log(i, 'line', item.dataSetIndex, activeDataIndex, '--',item.charEndIndex , caretData.index )
console.log(i+1, 'line+1', lines[i+1]?.dataSetIndex, activeDataIndex, '--',lines[i+1]?.charEndIndex , caretData.index )
if (item.dataSetIndex == activeDataIndex){
if (item.charEndIndex == -1) return true
if (item.charEndIndex>=caretData.index) return true
...
...
@@ -322,9 +311,16 @@ var ADocEditor = function (customConfig) {
})
// handle left right on multiple pages
if (activeLine){
canvasList[ activeLine.canvasIndex ].el.focus()
caretData.canvasIndex = activeLine.canvasIndex
ctx.restore()
ctx = canvasList[activeLine.canvasIndex].el.getContext('2d', { willReadFrequently: true })
ctx.save()
}
console.log('activeLine', activeLine)
let characterData = dataSet[activeDataIndex].formatedText[ caretData.index ]
let rectX = characterData?.x,
...
...
@@ -332,16 +328,12 @@ var ADocEditor = function (customConfig) {
rectWidth = 2,
rectHeight = 5 * activeLine.maxFontSize / 4;
if (!characterData && dataSet[activeDataIndex].formatedText?.[ caretData.index-1 ]){
console.log('handle X on the last char of the parapgraph')
rectX = dataSet[activeDataIndex].formatedText?.[ caretData.index-1 ]?.x+dataSet[activeDataIndex].formatedText?.[ caretData.index-1 ]?.width
}
if ( activeLine.charEndIndex == caretData.index ){
console.log('handle X on last char of the line')
rectX = dataSet[activeDataIndex].formatedText?.[ caretData.index-1 ]?.x+dataSet[activeDataIndex].formatedText?.[ caretData.index-1 ]?.width
}
if (!(rectX>0 || rectX==0)){ rectX = activeLine.x }
console.log('rectX:', rectX)
console.log('rectY:', rectY)
const imageData = ctx.getImageData(rectX, rectY, rectWidth, rectHeight);
const data = imageData.data;
...
...
@@ -354,7 +346,6 @@ var ADocEditor = function (customConfig) {
// Alpha channel remains unchanged (data[i + 3])
ctx.putImageData(imageData, rectX, rectY);
}
console.log('caretData', caretData)
ctx.restore()
}
...
...
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