Commit 3a3dad06 by ramdayalmunda

working on list and bullets

parent 4bf60c78
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
} }
.popover{ .popover{
position: absolute; position: absolute;
padding: 20px; padding: 5px;
background-color: gray; background-color: gray;
border: 1px solid purple; border: 1px solid purple;
opacity: 0; opacity: 0;
...@@ -52,7 +52,15 @@ ...@@ -52,7 +52,15 @@
.toolbar .item:hover { .toolbar .item:hover {
background: #5fad5f; background: #5fad5f;
} }
.option {
border: 1px solid black;
padding: 5px;
margin: 5px;
border-radius: 4px;
}
.option:hover {
background-color: #f5c468;
}
.page-list { .page-list {
position: relative; position: relative;
display: block; display: block;
......
...@@ -60,7 +60,10 @@ var ADocEditor = function (customConfig) { ...@@ -60,7 +60,10 @@ var ADocEditor = function (customConfig) {
<select class="item" adc="font-select"></select> <select class="item" adc="font-select"></select>
<div class="item" adc="list-handler" adc-target="list-popover"> <div class="item" adc="list-handler" adc-target="list-popover">
<span>L</span> <span>L</span>
<div class="popover" adc="list-popover" adc-type="popover"></div> <div class="popover" adc="list-popover" adc-type="popover">
<div class="option" adc-toggle="list-bullet">•&nbsp;&nbsp;Bullets&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="option" adc-toggle="list-number">1. Numbers</div>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -142,6 +145,25 @@ var ADocEditor = function (customConfig) { ...@@ -142,6 +145,25 @@ var ADocEditor = function (customConfig) {
})() })()
!(function handleList(){
let toggleNumber = shadow.querySelector('[adc-toggle="list-number"]')
let toggleBullet = shadow.querySelector('[adc-toggle="list-bullet"]')
toggleNumber.addEventListener('click', (e)=>{
if (caretData.activeData){
caretData.activeData.type = caretData.activeData.type==1?0:1
caretData.blink=false
reRenderCanvas()
}
})
toggleBullet.addEventListener('click', (e)=>{
if (caretData.activeData){
caretData.activeData.type = caretData.activeData.type==1?0:1
caretData.blink=false
reRenderCanvas()
}
})
})()
reConfigure(customConfig) reConfigure(customConfig)
reRenderCanvas() reRenderCanvas()
addGlobalEvents() addGlobalEvents()
...@@ -177,6 +199,7 @@ var ADocEditor = function (customConfig) { ...@@ -177,6 +199,7 @@ var ADocEditor = function (customConfig) {
function reRenderCanvas() { function reRenderCanvas() {
if (isRendering) return if (isRendering) return
console.log('to rendering')
let pageIndex = 0 let pageIndex = 0
if (!pageList.length) { if (!pageList.length) {
pageList[pageIndex] = { id: ++counter, el: createNewPage(), dataIndex: 0 } pageList[pageIndex] = { id: ++counter, el: createNewPage(), dataIndex: 0 }
...@@ -437,11 +460,23 @@ var ADocEditor = function (customConfig) { ...@@ -437,11 +460,23 @@ var ADocEditor = function (customConfig) {
else if (e.key == 'ArrowLeft') { else if (e.key == 'ArrowLeft') {
if (caretData.index) { if (caretData.index) {
--caretData.index --caretData.index
}else{
let dataIndex = dataList.findIndex( item => item.id == caretData.activeData.id )
if (dataIndex>0){
caretData.activeData = dataList[dataIndex-1]
caretData.index = caretData.activeData.plainContent.length
}
} }
} }
else if (e.key == 'ArrowRight') { else if (e.key == 'ArrowRight') {
if (caretData.index < caretData.activeData.plainContent.length) { if (caretData.index < caretData.activeData.plainContent.length) {
++caretData.index ++caretData.index
}else{
let dataIndex = dataList.findIndex( item => item.id == caretData.activeData.id )
if (dataList[dataIndex+1]){
caretData.activeData = dataList[dataIndex+1]
caretData.index = 0
}
} }
} }
else if (e.key == 'ArrowUp') { else if (e.key == 'ArrowUp') {
...@@ -509,7 +544,7 @@ var ADocEditor = function (customConfig) { ...@@ -509,7 +544,7 @@ var ADocEditor = function (customConfig) {
// console.log('blur') // console.log('blur')
caretData.blink = true caretData.blink = true
focussedPage = null focussedPage = null
renderCaret() // renderCaret()
} }
} }
...@@ -598,6 +633,11 @@ var ADocEditor = function (customConfig) { ...@@ -598,6 +633,11 @@ var ADocEditor = function (customConfig) {
for (let i = 0; i < pagesToReturn.length; i++) pagesToReturn[i].canvas = pageList[i].canvas for (let i = 0; i < pagesToReturn.length; i++) pagesToReturn[i].canvas = pageList[i].canvas
return pagesToReturn return pagesToReturn
}, },
log(){
console.log('dataList', dataList)
console.log('lines', lines)
console.log('caretData', caretData)
}
} }
initialize() initialize()
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<script src="./assets/fontkit.umd.min.js"></script> <script src="./assets/fontkit.umd.min.js"></script>
<script src="./assets/pdf-lib.min.js" ></script> <script src="./assets/pdf-lib.min.js" ></script>
<script src="./assets/a-doc-editor2.js"></script> <script src="./assets/a-doc-editor2.js"></script>
<script src="./assets/html-docx.min.js"></script>
<style> <style>
body { body {
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
<body> <body>
<div class="body"></div> <div class="body"></div>
<p style="font-family: 'Calibri';">Click on the <span>canvas</span> and start typing <p style="font-family: 'Calibri';">Click on the <span>canvas</span> and start typing
<button onclick="extractData()">Extract</button> <button onclick="log()">Log</button>
<button onclick="setData()">Set Data</button> <button onclick="setData()">Set Data</button>
<button onclick="generatePDF()">Generate PDF</button> <button onclick="generatePDF()">Generate PDF</button>
</p> </p>
......
...@@ -15,10 +15,8 @@ var editor = new ADocEditor({ ...@@ -15,10 +15,8 @@ var editor = new ADocEditor({
}) })
var extractedData = null var extractedData = null
function extractData() { function log() {
let data = editor.getContent() editor.log()
extractedData = data
console.log(data)
} }
function setData() { function setData() {
......
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