Commit 5cc0cc1b by ramdayalmunda

list number added

parent a368b0e6
......@@ -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()
......
......@@ -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}`)
} )
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment