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
bae5be2c
Commit
bae5be2c
authored
Jan 10, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caret position when typing fixed
parent
9b2648a1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
a-doc-editor2.js
dist/assets/a-doc-editor2.js
+13
-4
No files found.
dist/assets/a-doc-editor2.js
View file @
bae5be2c
...
@@ -275,13 +275,12 @@ var ADocEditor = function (customConfig) {
...
@@ -275,13 +275,12 @@ var ADocEditor = function (customConfig) {
}
}
function
renderLines
()
{
function
renderLines
()
{
console
.
log
(
'render lines'
,
lines
)
let
x
=
0
,
y
=
config
.
format
.
margin
*
pxMmRatio
;
let
x
=
0
,
y
=
config
.
format
.
margin
*
pxMmRatio
;
for
(
let
l
=
0
;
l
<
lines
.
length
;
l
++
)
{
for
(
let
l
=
0
;
l
<
lines
.
length
;
l
++
)
{
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
console
.
log
(
lines
[
l
])
x
=
config
.
format
.
margin
*
pxMmRatio
x
=
config
.
format
.
margin
*
pxMmRatio
y
=
y
+
(
lines
[
l
].
maxFontSize
*
pxMmRatio
)
y
=
y
+
(
lines
[
l
].
maxFontSize
*
pxMmRatio
)
lines
[
l
].
y
=
y
ctx
.
save
()
ctx
.
save
()
let
setData
=
dataList
[
lines
[
l
].
dataIndex
]
let
setData
=
dataList
[
lines
[
l
].
dataIndex
]
...
@@ -311,7 +310,6 @@ var ADocEditor = function (customConfig) {
...
@@ -311,7 +310,6 @@ var ADocEditor = function (customConfig) {
clearTimeout(caretData.timeout)
clearTimeout(caretData.timeout)
let ctx = pageList[0].el.getContext('2d', { willReadFrequently: true })
let ctx = pageList[0].el.getContext('2d', { willReadFrequently: true })
ctx.save()
ctx.save()
if (caretData.previousCaret) {
if (caretData.previousCaret) {
ctx.putImageData(caretData.previousCaret.imageData, caretData.previousCaret.x, caretData.previousCaret.y);
ctx.putImageData(caretData.previousCaret.imageData, caretData.previousCaret.x, caretData.previousCaret.y);
caretData.previousCaret = null
caretData.previousCaret = null
...
@@ -321,6 +319,18 @@ var ADocEditor = function (customConfig) {
...
@@ -321,6 +319,18 @@ var ADocEditor = function (customConfig) {
let x = config.format.margin*pxMmRatio
let x = config.format.margin*pxMmRatio
let y = (config.format.margin)*pxMmRatio
let y = (config.format.margin)*pxMmRatio
let height = config.style.fontSize*pxMmRatio*5/4
let height = config.style.fontSize*pxMmRatio*5/4
let charData = caretData.activeData.formatedText[caretData.index-1]
if (charData){
x = charData.x+charData.width
y = charData.y-charData.fontSize*pxMmRatio
}else{
let dataIndex = dataList.findIndex( item => item.id == caretData.activeData.id )
let lineObj = lines.find( item => item.dataIndex==dataIndex && caretData.index>=item.charStartIndex)
if (lineObj){
y = lineObj.y-lineObj.maxFontSize*pxMmRatio
}
}
let width = height/8
let width = height/8
const imageData = ctx.getImageData(x, y, width, height);
const imageData = ctx.getImageData(x, y, width, height);
const data = imageData.data;
const data = imageData.data;
...
@@ -345,7 +355,6 @@ var ADocEditor = function (customConfig) {
...
@@ -345,7 +355,6 @@ var ADocEditor = function (customConfig) {
return
return
}
}
function getCharacterWidth(char, style) {
function getCharacterWidth(char, style) {
console.log('style', style)
let canvas = pageList[0].el
let canvas = pageList[0].el
let ctx = canvas.getContext('2d', { willReadFrequently: true })
let ctx = canvas.getContext('2d', { willReadFrequently: true })
ctx.save()
ctx.save()
...
...
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