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
a4c79ebc
Commit
a4c79ebc
authored
Jan 09, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caret blinking fix
parent
71e1227a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
3 deletions
+43
-3
a-doc-editor2.js
dist/assets/a-doc-editor2.js
+43
-3
No files found.
dist/assets/a-doc-editor2.js
View file @
a4c79ebc
...
@@ -36,8 +36,8 @@ var ADocEditor = function (customConfig) {
...
@@ -36,8 +36,8 @@ var ADocEditor = function (customConfig) {
var
caretData
=
{
var
caretData
=
{
activeData
:
dataList
[
0
],
activeData
:
dataList
[
0
],
index
:
0
,
index
:
0
,
interval
:
null
,
timeout
:
null
,
interval
Duration
:
800
,
timeout
Duration
:
800
,
blink
:
false
,
blink
:
false
,
canvasIndex
:
0
,
canvasIndex
:
0
,
caretSize
:
config
.
style
.
fontSize
,
caretSize
:
config
.
style
.
fontSize
,
...
@@ -165,6 +165,7 @@ var ADocEditor = function (customConfig) {
...
@@ -165,6 +165,7 @@ var ADocEditor = function (customConfig) {
}
}
function
reRenderCanvas
()
{
function
reRenderCanvas
()
{
console
.
clear
()
console
.
log
(
'to rerender the page'
)
console
.
log
(
'to rerender the page'
)
if
(
isRendering
)
return
if
(
isRendering
)
return
let
pageIndex
=
0
let
pageIndex
=
0
...
@@ -200,7 +201,46 @@ var ADocEditor = function (customConfig) {
...
@@ -200,7 +201,46 @@ var ADocEditor = function (customConfig) {
}
}
function
renderCaret
(){
function
renderCaret
(){
console
.
log
(
'handle blinking'
)
clearTimeout
(
caretData
.
timeout
)
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
if
(
caretData
.
previousCaret
){
const
imageData
=
ctx
.
getImageData
(
caretData
.
previousCaret
.
x
,
caretData
.
previousCaret
.
y
,
caretData
.
previousCaret
.
width
,
caretData
.
previousCaret
.
height
);
const
data
=
imageData
.
data
;
// Invert the color of the rectangular region
for
(
let
i
=
0
;
i
<
data
.
length
;
i
+=
4
)
{
data
[
i
]
=
255
-
data
[
i
];
// Red
data
[
i
+
1
]
=
255
-
data
[
i
+
1
];
// Green
data
[
i
+
2
]
=
255
-
data
[
i
+
2
];
// Blue
// Alpha channel remains unchanged (data[i + 3])
ctx
.
putImageData
(
imageData
,
caretData
.
previousCaret
.
x
,
caretData
.
previousCaret
.
y
);
}
caretData
.
previousCaret
=
null
}
if
(
!
caretData
.
blink
){
const
imageData
=
ctx
.
getImageData
(
100
,
200
,
10
,
300
);
const
data
=
imageData
.
data
;
// Invert the color of the rectangular region
for
(
let
i
=
0
;
i
<
data
.
length
;
i
+=
4
)
{
data
[
i
]
=
255
-
data
[
i
];
// Red
data
[
i
+
1
]
=
255
-
data
[
i
+
1
];
// Green
data
[
i
+
2
]
=
255
-
data
[
i
+
2
];
// Blue
// Alpha channel remains unchanged (data[i + 3])
ctx
.
putImageData
(
imageData
,
100
,
200
);
}
caretData
.
previousCaret
=
{
x
:
100
,
y
:
200
,
width
:
10
,
height
:
300
}
caretData
.
blink
=
true
}
else
{
caretData
.
blink
=
false
}
caretData
.
timeout
=
setTimeout
(
()
=>
{
renderCaret
()
},
caretData
.
timeoutDuration
)
}
}
...
...
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