Commit 2470d679 by ramdayalmunda

indentation handled

parent 8b4d6816
......@@ -253,7 +253,6 @@ var ADocEditor = function (customConfig) {
let tempLineWidth = 0;
let maxLineWidth = config.pageSetup.pxWidth - (config.format.margin * pxMmRatio * 2)
let tabWidth =( (dataBlock.type==1?1:0)+ dataBlock.tabCount)*config.format.tabWidth*pxMmRatio
console.log('tabWidth', tabWidth)
lineObj.tabWidth = tabWidth
maxLineWidth -= tabWidth
lineObj.dataType = dataBlock.type
......@@ -307,7 +306,6 @@ var ADocEditor = function (customConfig) {
let ctx = pageList[0].el.getContext('2d', { willReadFrequently: true })
x = config.format.margin * pxMmRatio
x += lines[l].tabWidth
console.log('line',l, lines[l])
y = y + (lines[l].maxFontSize * pxMmRatio)
lines[l].y = y
ctx.save()
......@@ -356,7 +354,6 @@ var ADocEditor = function (customConfig) {
let dataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
let lineObj = lines.find(item => item.dataIndex == dataIndex && caretData.index >= item.charStartIndex)
if (lineObj) {
console.log('line', lineObj)
x += lineObj.tabWidth
y = lineObj.y - lineObj.maxFontSize * pxMmRatio
}
......@@ -364,7 +361,6 @@ var ADocEditor = function (customConfig) {
let width = height / 10
console.log(x,y,width,height)
const imageData = ctx.getImageData(x, y, width, height);
const data = imageData.data;
caretData.previousCaret = { imageData: structuredClone(imageData), x, y }
......@@ -431,12 +427,14 @@ var ADocEditor = function (customConfig) {
}
function keydownHandler(e) {
if (e.key=='Tab'){
if (e.altKey) return
else if (e.key=='Tab'){
e.preventDefault()
caretData.activeData.tabCount += e.shiftKey?(-1):1
caretData.activeData.tabCount = (caretData.activeData.tabCount<0)?0:(caretData.activeData.tabCount>5?5:caretData.activeData.tabCount)
manageIndentation(e.shiftKey?-1:1)
}else if ([']','['].includes(e.key) && e.ctrlKey){
manageIndentation( e.key=='['?-1:1 )
}
if (e.altKey) return
else if (e.key == 'Backspace') {
if (caretData.index == 0) {
let activeDataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
......@@ -475,7 +473,6 @@ var ADocEditor = function (customConfig) {
}
else if (e.key.length == 1 && !e.ctrlKey && !e.metaKey) { // displayable text
// ***** DISPLAYABLE TEXT **** //
e.preventDefault()
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index) + e.key + caretData.activeData.plainContent.slice(caretData.index)
caretData.activeData.formatedText.splice(caretData.index, 0, caretData.style)
......@@ -509,6 +506,14 @@ var ADocEditor = function (customConfig) {
else if (e.key == 'ArrowDown') {
console.log('Down')
}
function manageIndentation(value){
caretData.activeData.tabCount += value
if (caretData.activeData.tabCount<0) caretData.activeData.tabCount = 0
else if (caretData.activeData.tabCount>5 ) caretData.activeData.tabCount = 5
return true
}
caretData.blink = false
caretData.previousCaret = null
reRenderCanvas()
......@@ -565,10 +570,8 @@ var ADocEditor = function (customConfig) {
reRenderCanvas()
}
function onBlurHandler(e) {
// console.log('blur')
caretData.blink = true
focussedPage = null
// renderCaret()
}
}
......
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