Commit 668fae9e by ramdayalmunda

enter event with blank line

parent 6fbbe974
...@@ -167,17 +167,19 @@ var ADocEditor = function (customConfig) { ...@@ -167,17 +167,19 @@ var ADocEditor = function (customConfig) {
} }
for (let i = 0; i < dataList.length; i++) { for (let i = 0; i < dataList.length; i++) {
if (dataList[i].plainContent.length ==0 ){
y += ( dataList?.[i].style.fontSize )
}
let canvas = canvasList[canvasIndex].el let canvas = canvasList[canvasIndex].el
canvas.setAttribute("tabIndex", -1) canvas.setAttribute("tabIndex", -1)
renderText(canvas, dataList[i]) renderText(canvas, dataList[i])
x = 0; x = 0;
if (dataList[i].id == caretData.activeData.id) { if (dataList[i].id == caretData.activeData.id) {
caretData.canvasIndex = canvasIndex; caretData.canvasIndex = canvasIndex;
} }
} }
function renderText(canvas, dataSet) { function renderText(canvas, dataBlock) {
let ctx = canvas.getContext('2d', { willReadFrequently: true }) let ctx = canvas.getContext('2d', { willReadFrequently: true })
ctx.save() ctx.save()
...@@ -185,27 +187,27 @@ var ADocEditor = function (customConfig) { ...@@ -185,27 +187,27 @@ var ADocEditor = function (customConfig) {
let wordStartIndex = 0 let wordStartIndex = 0
let wordEndIndex = 0 let wordEndIndex = 0
let wordsLength = 0; let wordsLength = 0;
dataSet.formatedText = [] dataBlock.formatedText = []
for (let i = 0; i < dataSet.plainContent.length; i++) { for (let i = 0; i < dataBlock.plainContent.length; i++) {
if (/\s+/.test(dataSet.plainContent[i])) { if (/\s+/.test(dataBlock.plainContent[i])) {
wordEndIndex = i wordEndIndex = i
} }
let style = { ...config.style, ...dataSet?.style?.[i] } let style = { ...config.style, ...dataBlock?.style?.[i] }
if (i == 0) { if (i == 0) {
y += style.fontSize y += style.fontSize
} }
ctx.save() ctx.save()
ctx.font = `${style.fontSize}px ${style.fontFamily}` ctx.font = `${style.fontSize}px ${style.fontFamily}`
ctx.fillStyle = style.fontColor ctx.fillStyle = style.fontColor
let charWidth = ctx.measureText(dataSet.plainContent[i]).width let charWidth = ctx.measureText(dataBlock.plainContent[i]).width
ctx.restore() ctx.restore()
dataSet.formatedText[i] = { dataBlock.formatedText[i] = {
...style, ...style,
char: dataSet.plainContent[i], char: dataBlock.plainContent[i],
width: charWidth, width: charWidth,
x: x, x: x,
y: y, y: y,
...@@ -226,11 +228,11 @@ var ADocEditor = function (customConfig) { ...@@ -226,11 +228,11 @@ var ADocEditor = function (customConfig) {
} }
for (let i = 0; i < dataSet.formatedText.length; i++) { for (let i = 0; i < dataBlock.formatedText.length; i++) {
ctx.save() ctx.save()
ctx.font = `${dataSet.formatedText[i].fontSize}px ${dataSet.formatedText[i].fontFamily}` ctx.font = `${dataBlock.formatedText[i].fontSize}px ${dataBlock.formatedText[i].fontFamily}`
ctx.fillStyle = dataSet.formatedText[i].fontColor ctx.fillStyle = dataBlock.formatedText[i].fontColor
ctx.fillText(dataSet.formatedText[i].char, dataSet.formatedText[i].x, dataSet.formatedText[i].y) ctx.fillText(dataBlock.formatedText[i].char, dataBlock.formatedText[i].x, dataBlock.formatedText[i].y)
ctx.restore() ctx.restore()
} }
......
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