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
5cc0cc1b
Commit
5cc0cc1b
authored
Jan 12, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list number added
parent
a368b0e6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
+37
-8
a-doc-editor2.js
dist/assets/a-doc-editor2.js
+31
-3
index.js
index.js
+6
-5
No files found.
dist/assets/a-doc-editor2.js
View file @
5cc0cc1b
...
...
@@ -30,6 +30,7 @@ var ADocEditor = function (customConfig) {
plainContent
:
""
,
tabCount
:
0
,
style
:
{
...
config
.
style
},
listItemNumber
:
0
,
// newPage: false, // if this is true the data is send to new page
},
]
...
...
@@ -241,7 +242,7 @@ var ADocEditor = function (customConfig) {
dataIndex
:
d
,
charStartIndex
:
0
,
// index from where to check
charEndIndex
:
0
,
// index till where to check// not including this index.
listItemNumber
:
0
,
}
newLineObj
.
maxFontSize
=
newLineObj
.
fontSize
return
newLineObj
...
...
@@ -262,6 +263,23 @@ var ADocEditor = function (customConfig) {
lineObj
.
dataType
=
dataBlock
.
type
let
wordEndIndex
=
0
;
// this stores the index of the word which can fit in the line;
let
tempWordWidth
=
0
if
(
dataBlock
.
type
==
1
){
let
previousBlock
=
dataList
[
d
-
1
]
if
(
!
previousBlock
||
previousBlock
?.
type
!=
1
)
dataBlock
.
listItemNumber
=
1
else
if
(
previousBlock
.
tabCount
==
dataBlock
.
tabCount
)
{
dataBlock
.
listItemNumber
=
previousBlock
.
listItemNumber
+
1
}
else
{
dataBlock
.
listItemNumber
=
1
let
olderBlockIndex
=
d
-
1
while
(
dataList
?.[
olderBlockIndex
]?.
type
==
1
&&
dataList
?.[
olderBlockIndex
]?.
tabCount
>=
dataBlock
.
tabCount
){
if
(
dataList
?.[
olderBlockIndex
]?.
tabCount
==
dataBlock
.
tabCount
){
dataBlock
.
listItemNumber
=
dataList
?.[
olderBlockIndex
].
listItemNumber
+
1
break
;
}
--
olderBlockIndex
;
}
}
}
for
(
c
=
0
;
c
<
dataBlock
.
plainContent
.
length
;
c
++
)
{
let
style
=
dataBlock
?.
formatedText
?.[
c
]
...
...
@@ -298,7 +316,6 @@ var ADocEditor = function (customConfig) {
lineObj
.
maxLineWidth
=
maxLineWidth
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabWidth
=
tabWidth
else
lineObj
.
tabWidth
=
0
lineObj
.
listIndex
=
dataBlock
.
listIndex
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabCount
=
dataBlock
.
tabCount
else
lineObj
.
tabCount
=
0
lineObj
.
charStartIndex
=
wordEndIndex
+
1
...
...
@@ -332,6 +349,7 @@ var ADocEditor = function (customConfig) {
function
renderLines
()
{
let
x
=
0
,
y
=
config
.
format
.
margin
*
pxMmRatio
;
for
(
let
l
=
0
;
l
<
lines
.
length
;
l
++
)
{
let
setData
=
dataList
[
lines
[
l
].
dataIndex
]
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
x
=
config
.
format
.
margin
*
pxMmRatio
x
+=
lines
[
l
].
tabWidth
...
...
@@ -340,10 +358,19 @@ var ADocEditor = function (customConfig) {
ctx
.
save
()
// this is to render the numbering and bullets etc
if
(
lines
[
l
].
dataType
==
1
){
ctx
.
save
()
ctx
.
font
=
`
${
setData
.
style
.
fontSize
*
pxMmRatio
}
px
${
setData
.
style
.
fontFamily
}
`
ctx
.
fillStyle
=
`
${
setData
.
style
.
fontColor
}
`
let
label
=
`
${
setData
.
listItemNumber
?
setData
.
listItemNumber
:
'X'
}
.`
let
labelWidth
=
ctx
.
measureText
(
label
).
width
labelWidth
+=
pxMmRatio
*
5
ctx
.
fillText
(
label
,
x
-
labelWidth
,
y
)
ctx
.
restore
()
}
let
setData
=
dataList
[
lines
[
l
].
dataIndex
]
for
(
let
c
=
lines
[
l
].
charStartIndex
;
c
<=
lines
[
l
].
charEndIndex
;
c
++
)
{
let
char
=
setData
?.
plainContent
[
c
]
if
(
char
)
{
...
...
@@ -687,6 +714,7 @@ var ADocEditor = function (customConfig) {
}
function focusOnPage(){
caretData.blink = false
if (!lastFocussedPage) lastFocussedPage = pageList[0].el
if (lastFocussedPage){
const scrollTop = pageScrollingDiv.scrollTop
lastFocussedPage.focus()
...
...
index.js
View file @
5cc0cc1b
...
...
@@ -2,13 +2,14 @@ const express = require("express")
const
port
=
3910
;
const
path
=
require
(
"path"
);
const
app
=
express
()
app
.
use
(
express
.
json
()
)
app
.
use
(
express
.
json
()
)
app
.
use
(
'/pdf'
,
require
(
"./custom-pdf"
)
)
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'dist'
)
)
)
app
.
use
(
'/pdf'
,
require
(
"./custom-pdf"
)
)
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'dist'
))
)
app
.
listen
(
port
,
()
=>
{
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Doc Editor on http://localhost:
${
port
}
`
)
}
)
})
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