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
55662d19
Commit
55662d19
authored
Dec 08, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style fixes
parent
644d57ce
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
a-doc-editor.js
dist/assets/a-doc-editor.js
+23
-15
No files found.
dist/assets/a-doc-editor.js
View file @
55662d19
...
...
@@ -12,7 +12,7 @@ var ADocEditor = function (customConfig) {
element
:
""
,
pageSetup
:
{
width
:
210
,
height
:
2
10
,
height
:
1
10
,
},
format
:
{
background
:
"#fff"
,
...
...
@@ -25,9 +25,12 @@ var ADocEditor = function (customConfig) {
fontFamily
:
'Arial'
,
bold
:
false
,
italic
:
false
,
fontColor
:
"#1e1f77"
fontColor
:
"#1e1f77"
,
x
:
0
,
y
:
0
},
}
defaultConfig
.
style
.
y
=
defaultConfig
.
style
.
fontSize
var
config
=
JSON
.
parse
(
JSON
.
stringify
(
defaultConfig
)
);
var
canvasList
=
[]
const
dataTypes
=
[
...
...
@@ -201,12 +204,12 @@ var ADocEditor = function (customConfig) {
let
charWidth
=
ctx
.
measureText
(
dataSet
.
plainContent
[
i
]).
width
ctx
.
restore
()
dataSet
.
formatedText
[
i
]
=
{
...
style
,
char
:
dataSet
.
plainContent
[
i
],
width
:
charWidth
,
x
:
x
,
y
:
y
,
canvas
:
canvas
,
...
style
,
}
x
+=
charWidth
...
...
@@ -283,10 +286,11 @@ var ADocEditor = function (customConfig) {
focusedCanvas
=
e
.
target
caretData
.
blink
=
false
reRenderPages
(
dataSet
)
caretData
.
interval
=
setInterval
(()
=>
{
caretData
.
blink
=
!
caretData
.
blink
reRenderPages
(
dataSet
,
true
)
},
caretData
.
intervalDuration
)
// // // uncomment this. This is necessary for blinking caret
// caretData.interval = setInterval(() => {
// caretData.blink = !caretData.blink
// reRenderPages(dataSet, true)
// }, caretData.intervalDuration)
}
function
onBlurHandler
(
e
)
{
focusedCanvas
=
null
...
...
@@ -302,6 +306,9 @@ var ADocEditor = function (customConfig) {
caretData
.
blink
=
false
if
(
e
.
shiftKey
&&
e
.
ctrlKey
)
{
}
// ctr+shift combination
if
(
e
.
keyCode
==
16
||
e
.
keyCode
==
18
||
e
.
keyCode
==
20
)
{
return
}
else
if
(
e
.
ctrlKey
)
{
if
(
e
.
keyCode
==
8
)
{
// ctrl+backspace: delete the entrite word
let
separatedSentence
=
caretData
.
activeData
.
plainContent
.
slice
(
0
,
caretData
.
index
)
...
...
@@ -317,11 +324,14 @@ var ADocEditor = function (customConfig) {
else
if
(
e
.
keyCode
==
13
)
{
// Enter Key
if
(
caretData
){
if
(
caretData
.
activeData
.
type
==
0
){
// for plain text // just go to next line
let
style
=
caretData
?.
activeData
?.
formatedText
?.[
caretData
.
activeData
.
formatedText
.
length
-
1
]
if
(
!
style
)
style
=
caretData
?.
activeData
?.
style
if
(
!
style
)
style
=
config
.
style
let
newLineData
=
{
id
:
++
counter
,
type
:
0
,
plainContent
:
""
,
style
:
JSON
.
parse
(
JSON
.
stringify
(
caretData
.
activeData
.
formatedText
[
caretData
.
activeData
.
formatedText
.
length
-
1
]
)
)
style
:
JSON
.
parse
(
JSON
.
stringify
(
style
)
)
}
newLineData
.
style
.
y
+=
newLineData
.
style
.
fontSize
newLineData
.
style
.
x
=
0
...
...
@@ -378,16 +388,16 @@ var ADocEditor = function (customConfig) {
reRenderPages
(
dataSet
)
clearInterval
(
caretData
.
interval
)
caretData
.
interval
=
setInterval
(()
=>
{
caretData
.
blink
=
!
caretData
.
blink
reRenderPages
(
dataSet
,
true
)
},
caretData
.
intervalDuration
)
// // // uncomment this. This is necessary for blinking caret
// caretData.interval = setInterval(() => {
// caretData.blink = !caretData.blink
// reRenderPages(dataSet, true)
// }, caretData.intervalDuration)
}
function
setCaretPosition
(
e
){
let
rect
=
e
.
target
.
getBoundingClientRect
()
// console.log('rect', rect)
let
position
=
{
xP
:
e
.
offsetX
/
rect
.
width
,
yP
:
e
.
offsetY
/
rect
.
height
,
...
...
@@ -396,11 +406,9 @@ var ADocEditor = function (customConfig) {
position
.
x
=
position
.
xP
*
config
.
pageSetup
.
canvasWidth
position
.
y
=
position
.
yP
*
config
.
pageSetup
.
canvasHeight
let
lineY
=
dataSet
[
canvasData
.
dataIndex
].
style
.
y
console
.
log
(
'positionY'
,
position
.
y
,
dataSet
[
canvasData
.
dataIndex
].
style
.
fontSize
)
for
(
let
i
=
canvasData
.
dataIndex
;
i
<
dataSet
.
length
;
i
++
){
for
(
let
j
=
0
;
j
<
dataSet
[
i
].
formatedText
.
length
;
j
++
){
if
(
Math
.
floor
(
dataSet
[
i
].
formatedText
[
j
].
x
)
==
Math
.
floor
(
position
.
x
)
){
console
.
log
(
'breaked'
)
break
;
}
}
...
...
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