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
d6afd57d
Commit
d6afd57d
authored
Dec 12, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom line fixes
parent
a91248d9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
+46
-4
a-doc-editor.js
dist/assets/a-doc-editor.js
+46
-4
script.js
dist/script.js
+0
-0
No files found.
dist/assets/a-doc-editor.js
View file @
d6afd57d
...
@@ -10,7 +10,7 @@ var ADocEditor = function (customConfig) {
...
@@ -10,7 +10,7 @@ var ADocEditor = function (customConfig) {
element
:
""
,
element
:
""
,
pageSetup
:
{
pageSetup
:
{
width
:
210
,
width
:
210
,
height
:
1
4
0
,
height
:
1
1
0
,
},
},
format
:
{
format
:
{
background
:
"#fff"
,
background
:
"#fff"
,
...
@@ -19,7 +19,7 @@ var ADocEditor = function (customConfig) {
...
@@ -19,7 +19,7 @@ var ADocEditor = function (customConfig) {
fontSize
:
10
,
fontSize
:
10
,
},
},
style
:
{
style
:
{
fontSize
:
7
0
,
fontSize
:
3
0
,
fontFamily
:
'Arial'
,
fontFamily
:
'Arial'
,
bold
:
false
,
bold
:
false
,
italic
:
false
,
italic
:
false
,
...
@@ -136,6 +136,8 @@ var ADocEditor = function (customConfig) {
...
@@ -136,6 +136,8 @@ var ADocEditor = function (customConfig) {
})
})
reRenderPages
(
dataSet
)
reRenderPages
(
dataSet
)
removeStyles
(
dataSet
)
}
}
function
reRenderPages
(
dataList
)
{
function
reRenderPages
(
dataList
)
{
...
@@ -163,13 +165,44 @@ var ADocEditor = function (customConfig) {
...
@@ -163,13 +165,44 @@ var ADocEditor = function (customConfig) {
renderText
(
canvas
,
dataList
[
i
])
renderText
(
canvas
,
dataList
[
i
])
}
}
function
renderText
(
canvas
,
dataBlock
)
{
function
renderText
(
canvas
,
dataBlock
)
{
console
.
log
(
'to render text'
,
dataBlock
)
let
ctx
=
canvas
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
let
ctx
=
canvas
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
ctx
.
save
()
ctx
.
save
()
ctx
.
font
=
`
${
config
.
style
.
fontSize
}
px
${
config
.
style
.
fontFamily
}
`
;
ctx
.
fillStyle
=
"#0006"
;
ctx
.
fillText
(
"A"
,
x
,
y
+
config
.
style
.
fontSize
)
// to calculate the lines
// to calculate the lines
let
dataLineArr
=
[]
let
wordsArr
=
dataBlock
.
plainContent
.
split
(
/
\s
/
);
dataBlock
.
formatedText
=
[]
let
lineObj
=
{
x
:
0
,
y
:
0
,
plainContent
:
""
,
formatedText
:
[],
// { x: 10, y: 25 }, // bold,italic, fontSize, can be pulled from "dataSet"
style
:
{
maxFontSize
:
30
}
}
let
charIndex
=
0
for
(
let
i
=
0
;
i
<
wordsArr
.
length
;
i
++
){
if
(
i
!=
0
){
charIndex
++
;
}
// this is to add style on original dataSet
for
(
let
j
=
0
;
j
<
wordsArr
[
i
].
length
;
j
++
){
// console.log('char:', i, j, wordsArr[i][j], charIndex)
charIndex
++
}
}
ctx
.
fillText
(
dataBlock
.
plainContent
,
0
,
70
)
ctx
.
restore
()
ctx
.
restore
()
...
@@ -334,6 +367,15 @@ var ADocEditor = function (customConfig) {
...
@@ -334,6 +367,15 @@ var ADocEditor = function (customConfig) {
}
}
renderInProgress
=
false
renderInProgress
=
false
}
}
function
removeStyles
(
dataList
){
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
){
console
.
log
(
i
,
dataList
[
i
])
for
(
let
j
=
0
;
j
<
dataList
[
i
].
plainContent
.
length
;
j
++
){
dataList
[
i
].
formatedText
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
config
.
style
)
)
)
}
}
console
.
log
(
'removedStyles'
,
dataList
)
}
...
...
dist/script.js
View file @
d6afd57d
This diff is collapsed.
Click to expand it.
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