Commit babead2c by ramdayalmunda

font-size fix when moving caret

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