Commit 55662d19 by ramdayalmunda

style fixes

parent 644d57ce
......@@ -12,7 +12,7 @@ var ADocEditor = function (customConfig) {
element: "",
pageSetup: {
width: 210,
height: 210,
height: 110,
},
format: {
background: "#fff",
......@@ -25,9 +25,12 @@ var ADocEditor = function (customConfig) {
fontFamily: 'Arial',
bold: false,
italic: false,
fontColor: "#1e1f77"
fontColor: "#1e1f77",
x: 0,
y: 0
},
}
defaultConfig.style.y = defaultConfig.style.fontSize
var config = JSON.parse( JSON.stringify( defaultConfig ) );
var canvasList = []
const dataTypes = [
......@@ -201,12 +204,12 @@ var ADocEditor = function (customConfig) {
let charWidth = ctx.measureText(dataSet.plainContent[i]).width
ctx.restore()
dataSet.formatedText[i] = {
...style,
char: dataSet.plainContent[i],
width: charWidth,
x: x,
y: y,
canvas: canvas,
...style,
}
x += charWidth
......@@ -283,10 +286,11 @@ var ADocEditor = function (customConfig) {
focusedCanvas = e.target
caretData.blink = false
reRenderPages(dataSet)
caretData.interval = setInterval(() => {
caretData.blink = !caretData.blink
reRenderPages(dataSet, true)
}, caretData.intervalDuration)
// // // uncomment this. This is necessary for blinking caret
// caretData.interval = setInterval(() => {
// caretData.blink = !caretData.blink
// reRenderPages(dataSet, true)
// }, caretData.intervalDuration)
}
function onBlurHandler(e) {
focusedCanvas = null
......@@ -302,6 +306,9 @@ var ADocEditor = function (customConfig) {
caretData.blink = false
if (e.shiftKey && e.ctrlKey) { } // ctr+shift combination
if (e.keyCode == 16 || e.keyCode==18 || e.keyCode==20) {
return
}
else if (e.ctrlKey) {
if (e.keyCode == 8) { // ctrl+backspace: delete the entrite word
let separatedSentence = caretData.activeData.plainContent.slice(0, caretData.index)
......@@ -317,11 +324,14 @@ var ADocEditor = function (customConfig) {
else if (e.keyCode == 13) { // Enter Key
if (caretData){
if (caretData.activeData.type == 0){ // for plain text // just go to next line
let style = caretData?.activeData?.formatedText?.[caretData.activeData.formatedText.length-1]
if (!style) style = caretData?.activeData?.style
if (!style) style = config.style
let newLineData = {
id: ++counter,
type: 0,
plainContent: "",
style: JSON.parse( JSON.stringify(caretData.activeData.formatedText[caretData.activeData.formatedText.length-1]) )
style: JSON.parse( JSON.stringify(style) )
}
newLineData.style.y += newLineData.style.fontSize
newLineData.style.x = 0
......@@ -378,16 +388,16 @@ var ADocEditor = function (customConfig) {
reRenderPages(dataSet)
clearInterval(caretData.interval)
caretData.interval = setInterval(() => {
caretData.blink = !caretData.blink
reRenderPages(dataSet, true)
}, caretData.intervalDuration)
// // // uncomment this. This is necessary for blinking caret
// caretData.interval = setInterval(() => {
// caretData.blink = !caretData.blink
// reRenderPages(dataSet, true)
// }, caretData.intervalDuration)
}
function setCaretPosition(e){
let rect = e.target.getBoundingClientRect()
// console.log('rect', rect)
let position = {
xP: e.offsetX/rect.width,
yP: e.offsetY/rect.height,
......@@ -396,11 +406,9 @@ var ADocEditor = function (customConfig) {
position.x = position.xP*config.pageSetup.canvasWidth
position.y = position.yP*config.pageSetup.canvasHeight
let lineY = dataSet[canvasData.dataIndex].style.y
console.log('positionY', position.y, dataSet[canvasData.dataIndex].style.fontSize)
for (let i=canvasData.dataIndex; i<dataSet.length; i++){
for ( let j=0; j< dataSet[i].formatedText.length; j++ ){
if ( Math.floor( dataSet[i].formatedText[j].x ) == Math.floor(position.x) ){
console.log('breaked')
break;
}
}
......
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