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
b84ed9a4
Commit
b84ed9a4
authored
Dec 01, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor position fix
parent
40a9ddfd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
12 deletions
+10
-12
a-doc-editor.css
dist/assets/a-doc-editor.css
+3
-3
a-doc-editor.js
dist/assets/a-doc-editor.js
+7
-8
index.html
dist/index.html
+0
-1
No files found.
dist/assets/a-doc-editor.css
View file @
b84ed9a4
.a-doc-editor
{
.a-doc-editor
{
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
height
:
40
0px
;
height
:
59
0px
;
}
}
.a-doc-editor
canvas
:focus-visible
{
.a-doc-editor
canvas
:focus-visible
{
outline
:
red
auto
1px
;
/* outline: auto rgb(0, 68, 255, 50%); */
}
}
...
@@ -45,7 +45,6 @@
...
@@ -45,7 +45,6 @@
right
:
20%
;
right
:
20%
;
top
:
0
;
top
:
0
;
bottom
:
0
;
bottom
:
0
;
background-color
:
#3756be
;
text-align
:
center
;
text-align
:
center
;
align-items
:
center
;
align-items
:
center
;
overflow
:
auto
;
overflow
:
auto
;
...
@@ -54,6 +53,7 @@
...
@@ -54,6 +53,7 @@
.a-doc-editor
.body
.scrolling-area
canvas
.page
{
.a-doc-editor
.body
.scrolling-area
canvas
.page
{
background
:
#f3f3f3
;
background
:
#f3f3f3
;
margin-bottom
:
10px
;
margin-bottom
:
10px
;
width
:
100%
;
}
}
.a-doc-editor
.body
.scrolling-area
canvas
.page
:first-child
{
.a-doc-editor
.body
.scrolling-area
canvas
.page
:first-child
{
...
...
dist/assets/a-doc-editor.js
View file @
b84ed9a4
...
@@ -108,14 +108,9 @@ var ADocEditor = function (customConfig) {
...
@@ -108,14 +108,9 @@ var ADocEditor = function (customConfig) {
// container.append(mainComponent)
// container.append(mainComponent)
reRenderPages
(
dataSet
)
reRenderPages
(
dataSet
)
// caretData.interval = setInterval(() => {
// caretData.blink = !caretData.blink
// reRenderPages(dataSet, true)
// }, caretData.intervalDuration)
}
}
function
reRenderPages
(
dataList
,
blinking
=
false
)
{
function
reRenderPages
(
dataList
,
blinking
=
false
)
{
console
.
log
(
'rendering'
,
dataList
)
if
(
renderInProgress
)
return
if
(
renderInProgress
)
return
renderInProgress
=
true
renderInProgress
=
true
...
@@ -199,7 +194,6 @@ var ADocEditor = function (customConfig) {
...
@@ -199,7 +194,6 @@ var ADocEditor = function (customConfig) {
for
(
let
i
=
0
;
i
<
dataSet
.
formatedText
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
dataSet
.
formatedText
.
length
;
i
++
)
{
ctx
.
save
()
ctx
.
save
()
ctx
.
font
=
`
${
dataSet
.
formatedText
[
i
].
fontSize
}
px
${
dataSet
.
formatedText
[
i
].
fontFamily
}
`
ctx
.
font
=
`
${
dataSet
.
formatedText
[
i
].
fontSize
}
px
${
dataSet
.
formatedText
[
i
].
fontFamily
}
`
console
.
log
(
'dataSet.formatedText[i].fontColor'
,
dataSet
.
formatedText
[
i
].
fontColor
)
ctx
.
fillStyle
=
dataSet
.
formatedText
[
i
].
fontColor
ctx
.
fillStyle
=
dataSet
.
formatedText
[
i
].
fontColor
ctx
.
fillText
(
dataSet
.
formatedText
[
i
].
char
,
dataSet
.
formatedText
[
i
].
x
,
dataSet
.
formatedText
[
i
].
y
)
ctx
.
fillText
(
dataSet
.
formatedText
[
i
].
char
,
dataSet
.
formatedText
[
i
].
x
,
dataSet
.
formatedText
[
i
].
y
)
ctx
.
restore
()
ctx
.
restore
()
...
@@ -240,7 +234,9 @@ var ADocEditor = function (customConfig) {
...
@@ -240,7 +234,9 @@ var ADocEditor = function (customConfig) {
}
}
function
createCanvas
()
{
function
createCanvas
()
{
console
.
log
(
'pageSetup'
,
config
.
pageSetup
)
let
canvas
=
document
.
createElement
(
'canvas'
)
let
canvas
=
document
.
createElement
(
'canvas'
)
canvas
.
setAttribute
(
'class'
,
'page'
)
canvas
.
width
=
config
.
pageSetup
.
canvasWidth
canvas
.
width
=
config
.
pageSetup
.
canvasWidth
canvas
.
height
=
config
.
pageSetup
.
canvasHeight
canvas
.
height
=
config
.
pageSetup
.
canvasHeight
canvas
.
addEventListener
(
'keydown'
,
keydownHandler
)
canvas
.
addEventListener
(
'keydown'
,
keydownHandler
)
...
@@ -255,11 +251,16 @@ var ADocEditor = function (customConfig) {
...
@@ -255,11 +251,16 @@ var ADocEditor = function (customConfig) {
focusedCanvas
=
e
.
target
focusedCanvas
=
e
.
target
caretData
.
blink
=
false
caretData
.
blink
=
false
reRenderPages
(
dataSet
)
reRenderPages
(
dataSet
)
caretData
.
interval
=
setInterval
(()
=>
{
caretData
.
blink
=
!
caretData
.
blink
reRenderPages
(
dataSet
,
true
)
},
caretData
.
intervalDuration
)
}
}
function
onBlurHandler
(
e
)
{
function
onBlurHandler
(
e
)
{
focusedCanvas
=
null
focusedCanvas
=
null
caretData
.
blink
=
true
caretData
.
blink
=
true
reRenderPages
(
dataSet
)
reRenderPages
(
dataSet
)
clearInterval
(
caretData
.
interval
)
}
}
...
@@ -328,9 +329,7 @@ var ADocEditor = function (customConfig) {
...
@@ -328,9 +329,7 @@ var ADocEditor = function (customConfig) {
var
returnObj
=
{
var
returnObj
=
{
destory
,
destory
,
loadContent
:
function
(
data
)
{
loadContent
:
function
(
data
)
{
console
.
log
(
'to load'
,
JSON
.
parse
(
JSON
.
stringify
(
dataSet
)))
dataSet
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
dataSet
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
console
.
log
(
'new Data'
,
JSON
.
parse
(
JSON
.
stringify
(
dataSet
)))
caretData
.
activeData
=
null
caretData
.
activeData
=
null
caretData
.
activeData
=
dataSet
[
0
]
caretData
.
activeData
=
dataSet
[
0
]
caretData
.
index
=
dataSet
[
0
].
plainContent
.
length
caretData
.
index
=
dataSet
[
0
].
plainContent
.
length
...
...
dist/index.html
View file @
b84ed9a4
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
</style>
</style>
</head>
</head>
<body>
<body>
<h2>
To create a custom doc editor
</h2>
<p>
Click on the canvas and start typing
</p>
<p>
Click on the canvas and start typing
</p>
<div
id=
"user-container-for-editor"
></div>
<div
id=
"user-container-for-editor"
></div>
...
...
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