Commit babead2c by ramdayalmunda

font-size fix when moving caret

parent 3ab11020
......@@ -260,7 +260,6 @@ var ADocEditor = function (customConfig) {
function calculateTextSizeAndPosition() {
let d = 0, c = 0;
function getLineObj() {
let newLineObj = {
...config.style,
x: 0, // this is the starting point x; it will change based on the tabNumber
......@@ -309,6 +308,7 @@ var ADocEditor = function (customConfig) {
}
for (c = 0; c < dataBlock.plainContent.length; c++) {
let style = dataBlock?.formatedText?.[c]
lineObj.maxFontSize = (lineObj.maxFontSize<dataBlock?.formatedText?.[c].fontSize)?dataBlock?.formatedText?.[c].fontSize:lineObj.maxFontSize
if (/\s/.test(dataBlock.plainContent[c])) {
// condition to check if a blank character is found.
......@@ -768,23 +768,19 @@ var ADocEditor = function (customConfig) {
caretData.previousCaret = null
}
if (!caretData.blink) {
let x = config.format.margin * pxMmRatio
let dataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
let lineObj = lines.find(item => item.dataIndex == dataIndex && caretData.index >= item.charStartIndex)
let x = (config.format.margin * pxMmRatio) + lineObj.tabWidth
let y = (config.format.margin) * pxMmRatio
let height = config.style.fontSize * pxMmRatio * 5 / 4
let height = lineObj.maxFontSize * pxMmRatio * 5 / 4
let width = height / 10
let charData = caretData.activeData.formatedText[caretData.index - 1]
if (charData) {
x = charData.x + charData.width
y = charData.y - charData.fontSize * pxMmRatio
} else {
let dataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
let lineObj = lines.find(item => item.dataIndex == dataIndex && caretData.index >= item.charStartIndex)
if (lineObj) {
x += lineObj.tabWidth
y = lineObj.y - lineObj.maxFontSize * pxMmRatio
}
if (lineObj) {
x = (charData?(charData.x+charData.width):x)
y = lineObj.y-(lineObj.maxFontSize*pxMmRatio)
}
let width = height / 10
const imageData = ctx.getImageData(x, y, width, height);
const data = imageData.data;
......
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