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) {
...
@@ -30,6 +30,7 @@ var ADocEditor = function (customConfig) {
plainContent
:
""
,
plainContent
:
""
,
tabCount
:
0
,
tabCount
:
0
,
style
:
{
...
config
.
style
},
style
:
{
...
config
.
style
},
listItemNumber
:
0
,
// newPage: false, // if this is true the data is send to new page
// newPage: false, // if this is true the data is send to new page
},
},
]
]
...
@@ -241,7 +242,7 @@ var ADocEditor = function (customConfig) {
...
@@ -241,7 +242,7 @@ var ADocEditor = function (customConfig) {
dataIndex
:
d
,
dataIndex
:
d
,
charStartIndex
:
0
,
// index from where to check
charStartIndex
:
0
,
// index from where to check
charEndIndex
:
0
,
// index till where to check// not including this index.
charEndIndex
:
0
,
// index till where to check// not including this index.
listItemNumber
:
0
,
}
}
newLineObj
.
maxFontSize
=
newLineObj
.
fontSize
newLineObj
.
maxFontSize
=
newLineObj
.
fontSize
return
newLineObj
return
newLineObj
...
@@ -262,6 +263,23 @@ var ADocEditor = function (customConfig) {
...
@@ -262,6 +263,23 @@ var ADocEditor = function (customConfig) {
lineObj
.
dataType
=
dataBlock
.
type
lineObj
.
dataType
=
dataBlock
.
type
let
wordEndIndex
=
0
;
// this stores the index of the word which can fit in the line;
let
wordEndIndex
=
0
;
// this stores the index of the word which can fit in the line;
let
tempWordWidth
=
0
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
++
)
{
for
(
c
=
0
;
c
<
dataBlock
.
plainContent
.
length
;
c
++
)
{
let
style
=
dataBlock
?.
formatedText
?.[
c
]
let
style
=
dataBlock
?.
formatedText
?.[
c
]
...
@@ -298,7 +316,6 @@ var ADocEditor = function (customConfig) {
...
@@ -298,7 +316,6 @@ var ADocEditor = function (customConfig) {
lineObj
.
maxLineWidth
=
maxLineWidth
lineObj
.
maxLineWidth
=
maxLineWidth
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabWidth
=
tabWidth
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabWidth
=
tabWidth
else
lineObj
.
tabWidth
=
0
else
lineObj
.
tabWidth
=
0
lineObj
.
listIndex
=
dataBlock
.
listIndex
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabCount
=
dataBlock
.
tabCount
if
(
dataBlock
.
type
==
1
)
lineObj
.
tabCount
=
dataBlock
.
tabCount
else
lineObj
.
tabCount
=
0
else
lineObj
.
tabCount
=
0
lineObj
.
charStartIndex
=
wordEndIndex
+
1
lineObj
.
charStartIndex
=
wordEndIndex
+
1
...
@@ -332,6 +349,7 @@ var ADocEditor = function (customConfig) {
...
@@ -332,6 +349,7 @@ var ADocEditor = function (customConfig) {
function
renderLines
()
{
function
renderLines
()
{
let
x
=
0
,
y
=
config
.
format
.
margin
*
pxMmRatio
;
let
x
=
0
,
y
=
config
.
format
.
margin
*
pxMmRatio
;
for
(
let
l
=
0
;
l
<
lines
.
length
;
l
++
)
{
for
(
let
l
=
0
;
l
<
lines
.
length
;
l
++
)
{
let
setData
=
dataList
[
lines
[
l
].
dataIndex
]
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
let
ctx
=
pageList
[
0
].
el
.
getContext
(
'2d'
,
{
willReadFrequently
:
true
})
x
=
config
.
format
.
margin
*
pxMmRatio
x
=
config
.
format
.
margin
*
pxMmRatio
x
+=
lines
[
l
].
tabWidth
x
+=
lines
[
l
].
tabWidth
...
@@ -340,10 +358,19 @@ var ADocEditor = function (customConfig) {
...
@@ -340,10 +358,19 @@ var ADocEditor = function (customConfig) {
ctx
.
save
()
ctx
.
save
()
// this is to render the numbering and bullets etc
// 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
++
)
{
for
(
let
c
=
lines
[
l
].
charStartIndex
;
c
<=
lines
[
l
].
charEndIndex
;
c
++
)
{
let
char
=
setData
?.
plainContent
[
c
]
let
char
=
setData
?.
plainContent
[
c
]
if
(
char
)
{
if
(
char
)
{
...
@@ -687,6 +714,7 @@ var ADocEditor = function (customConfig) {
...
@@ -687,6 +714,7 @@ var ADocEditor = function (customConfig) {
}
}
function focusOnPage(){
function focusOnPage(){
caretData.blink = false
caretData.blink = false
if (!lastFocussedPage) lastFocussedPage = pageList[0].el
if (lastFocussedPage){
if (lastFocussedPage){
const scrollTop = pageScrollingDiv.scrollTop
const scrollTop = pageScrollingDiv.scrollTop
lastFocussedPage.focus()
lastFocussedPage.focus()
...
...
index.js
View file @
5cc0cc1b
...
@@ -2,13 +2,14 @@ const express = require("express")
...
@@ -2,13 +2,14 @@ const express = require("express")
const
port
=
3910
;
const
port
=
3910
;
const
path
=
require
(
"path"
);
const
path
=
require
(
"path"
);
const
app
=
express
()
const
app
=
express
()
app
.
use
(
express
.
json
()
)
app
.
use
(
express
.
json
()
)
app
.
use
(
'/pdf'
,
require
(
"./custom-pdf"
)
)
app
.
use
(
'/pdf'
,
require
(
"./custom-pdf"
)
)
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'dist'
)
)
)
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'dist'
))
)
app
.
listen
(
port
,
()
=>
{
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Doc Editor on http://localhost:
${
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