Commit 5fbc768e by ramdayalmunda

doc editor arrow keys events

parent 05994aa9
......@@ -92,8 +92,8 @@ var ADocEditor = function (customConfig) {
function renderCaret() {
let ctx = canvasList[caretData.canvasIndex].getContext('2d', { willReadFrequently: true })
let rectX = caretData.x;
let rectY = caretData.y-caretData.caretSize;
let rectWidth = 3;
let rectY = caretData.y - caretData.caretSize;
let rectWidth = 2;
let rectHeight = caretData.caretSize;
const imageData = ctx.getImageData(rectX, rectY, rectWidth, rectHeight);
......@@ -109,13 +109,6 @@ var ADocEditor = function (customConfig) {
}
}
function calculateCaretPosition() {
return {
x: 146,
y: 21
}
}
function createCanvas() {
let canvas = document.createElement('canvas')
canvas.width = config.pageSetup.canvasWidth
......@@ -128,7 +121,7 @@ var ADocEditor = function (customConfig) {
function renderText(canvas, dataSet) {
let ctx = canvas.getContext('2d',{ willReadFrequently: true })
let ctx = canvas.getContext('2d', { willReadFrequently: true })
ctx.save()
let fontSize = 28;
......@@ -153,6 +146,16 @@ var ADocEditor = function (customConfig) {
caretData.activeData.plainContent = caretData.activeData.plainContent.slice(0, caretData.index - 1) + caretData.activeData.plainContent.slice(caretData.index)
caretData.index = caretData.index <= 0 ? 0 : caretData.index - 1
}
else if (e.keyCode == 37) {
caretData.index = (caretData.index <= 0) ? 0 : caretData.index - 1
console.log('move left')
}
else if (e.keyCode == 38) {}
else if (e.keyCode == 39) {
console.log('move right')
caretData.index = (caretData.index >= caretData.activeData.plainContent.length) ? caretData.activeData.plainContent.length : caretData.index +1
}
else if (e.keyCode == 40) {}
reRenderPages(dataList)
clearInterval(caretData.interval)
......
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