Commit 0e974ad6 by ramdayalmunda

list and bullet structure completed

parent 08459ade
...@@ -65,8 +65,8 @@ var ADocEditor = function (customConfig) { ...@@ -65,8 +65,8 @@ var ADocEditor = function (customConfig) {
<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 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="listing-option" value="1">•&nbsp;&nbsp;Bullets&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="option" adc-toggle="list-number">1. Numbers</div> <div class="option" adc-toggle="listing-option" value="0">1. Numbers</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -148,30 +148,26 @@ var ADocEditor = function (customConfig) { ...@@ -148,30 +148,26 @@ var ADocEditor = function (customConfig) {
})() })()
!(function handleList() { !(function handleList() {
let toggleNumber = shadow.querySelector('[adc-toggle="list-number"]') let listItems = shadow.querySelectorAll('[adc-toggle="listing-option"]')
let toggleBullet = shadow.querySelector('[adc-toggle="list-bullet"]')
let popover = shadow.querySelector('[adc-type="popover"]') let popover = shadow.querySelector('[adc-type="popover"]')
toggleNumber.addEventListener('click', (e) => { for(let i=0; i<listItems.length; i++){
if (caretData.activeData) { listItems[i].addEventListener('click', (e) => {
caretData.activeData.type = caretData.activeData.type == 1 ? 0 : 1 let value = Number(e.target.getAttribute('value'))
caretData.activeData.listStyle = 0 value = value?value:0
caretData.blink = false if (caretData.activeData) {
reRenderCanvas() caretData.activeData.type = (caretData.activeData.type == 1 && caretData.activeData.listStyle==value) ? 0 : 1
popover.classList.remove('show') if (caretData.activeData.type==1){
focusOnPage() caretData.activeData.listStyle = value
}
} changeListStyle()
}) caretData.blink = false
toggleBullet.addEventListener('click', (e) => { reRenderCanvas()
if (caretData.activeData) { popover.classList.remove('show')
caretData.activeData.type = caretData.activeData.type == 1 ? 0 : 1 focusOnPage()
caretData.activeData.listStyle = 1
caretData.blink = false }
reRenderCanvas() })
popover.classList.remove('show') }
focusOnPage()
}
})
})() })()
reConfigure(customConfig) reConfigure(customConfig)
...@@ -351,7 +347,6 @@ var ADocEditor = function (customConfig) { ...@@ -351,7 +347,6 @@ var ADocEditor = function (customConfig) {
} }
function renderLines() { function renderLines() {
console.clear()
let x = 0, y = config.format.margin * pxMmRatio; let x = 0, y = config.format.margin * pxMmRatio;
for (let l = 0; l < lines.length; l++) { for (let l = 0; l < lines.length; l++) {
let setData = dataList[lines[l].dataIndex] let setData = dataList[lines[l].dataIndex]
...@@ -407,7 +402,7 @@ var ADocEditor = function (customConfig) { ...@@ -407,7 +402,7 @@ var ADocEditor = function (customConfig) {
else if (tabCount % 3 == 1) label = `${convertToLetter(dataList[dataIndex].listItemNumber)}.` else if (tabCount % 3 == 1) label = `${convertToLetter(dataList[dataIndex].listItemNumber)}.`
else label = `${convertToRoman(dataList[dataIndex].listItemNumber).toLowerCase()}.` else label = `${convertToRoman(dataList[dataIndex].listItemNumber).toLowerCase()}.`
} }
else if (dataList[dataIndex].listStyle == 0) { // > else if (dataList[dataIndex].listStyle == 1) { // >
label = `>` label = `>`
} }
...@@ -504,7 +499,11 @@ var ADocEditor = function (customConfig) { ...@@ -504,7 +499,11 @@ var ADocEditor = function (customConfig) {
if (caretData.index == 0) { if (caretData.index == 0) {
let activeDataIndex = dataList.findIndex(item => item.id == caretData.activeData.id) let activeDataIndex = dataList.findIndex(item => item.id == caretData.activeData.id)
if (caretData.activeData.tabCount) { if (caretData.activeData.tabCount) {
caretData.activeData.tabCount-- if (caretData.activeData.type==1){
caretData.activeData.type = 0
}else{
caretData.activeData.tabCount--
}
} }
else if (activeDataIndex > 0) { else if (activeDataIndex > 0) {
if (caretData.activeData.type == 0) { if (caretData.activeData.type == 0) {
...@@ -641,6 +640,21 @@ var ADocEditor = function (customConfig) { ...@@ -641,6 +640,21 @@ var ADocEditor = function (customConfig) {
} }
} }
function changeListStyle(){
let activeDataIndex = dataList.findIndex( item => item.id == caretData.activeData.id )
let d = activeDataIndex-1
while( dataList?.[d]?.type==1){
dataList[d].listStyle = caretData.activeData.listStyle
--d
}
d = activeDataIndex+1
while(dataList?.[d]?.type==1){
dataList[d].listStyle = caretData.activeData.listStyle
++d
}
}
......
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