Commit 668fae9e by ramdayalmunda

enter event with blank line

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