Commit 9cf6d76d by ramdayalmunda

Merge branch 'ram_dev2' of https://git.agamitechnologies.com/ramdayal/a-doc-editor into ram_dev2

parents f4171454 f24fdc10
...@@ -14,7 +14,7 @@ var ADocEditor = function (customConfig) { ...@@ -14,7 +14,7 @@ var ADocEditor = function (customConfig) {
tabWidth: 20, // mm tabWidth: 20, // mm
}, },
style: { style: {
fontSize: 16, // this is in mm fontSize: 20, // this is in mm
fontFamily: 'Calibri', fontFamily: 'Calibri',
bold: false, bold: false,
italic: false, italic: false,
...@@ -233,9 +233,11 @@ var ADocEditor = function (customConfig) { ...@@ -233,9 +233,11 @@ var ADocEditor = function (customConfig) {
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;
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]
let isBlankChar = false
if (/\s/.test(dataBlock.plainContent[c])) { if (/\s/.test(dataBlock.plainContent[c])) {
wordEndIndex = c wordEndIndex = c
lineObj.charEndIndex = c lineObj.charEndIndex = c
isBlankChar = true
} }
let charWidth = getCharacterWidth(dataBlock.plainContent[c], style) let charWidth = getCharacterWidth(dataBlock.plainContent[c], style)
dataBlock.formatedText[c] = { dataBlock.formatedText[c] = {
...@@ -243,21 +245,19 @@ var ADocEditor = function (customConfig) { ...@@ -243,21 +245,19 @@ var ADocEditor = function (customConfig) {
...style, ...style,
width: charWidth width: charWidth
} }
tempLineWidth += charWidth if (tempLineWidth+charWidth > maxLineWidth) {
if (tempLineWidth > maxLineWidth) {
// cannot add this// new line should be added// // cannot add this// new line should be added//
i = wordEndIndex; i = wordEndIndex;
lineObj.plainContent = dataBlock.plainContent.slice(lineObj.charStartIndex, lineObj.charEndIndex+1)
lineObj.plainContent = dataBlock.plainContent.slice(lineObj.charStartIndex, lineObj.charEndIndex + 1)
lines.push(lineObj) lines.push(lineObj)
lineObj = new getLineObj() lineObj = new getLineObj()
lineObj.listIndex = dataBlock.listIndex lineObj.listIndex = dataBlock.listIndex
lineObj.maxLineWidth = maxLineWidth lineObj.maxLineWidth = maxLineWidth
lineObj.tabCount = dataBlock.tabCount lineObj.tabCount = dataBlock.tabCount
lineObj.charStartIndex = i lineObj.charStartIndex = i+1
lineObj.charEndIndex = i lineObj.charEndIndex = i+1
tempLineWidth = 0 tempLineWidth = 0
} }else tempLineWidth+=charWidth
} }
...@@ -270,9 +270,6 @@ var ADocEditor = function (customConfig) { ...@@ -270,9 +270,6 @@ var ADocEditor = function (customConfig) {
lines.push(lineObj) lines.push(lineObj)
ctx.restore() ctx.restore()
} }
return return
......
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