Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
a-doc-editor
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramdayal Munda
a-doc-editor
Commits
3a3dad06
Commit
3a3dad06
authored
Jan 12, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on list and bullets
parent
4bf60c78
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
9 deletions
+56
-9
a-doc-editor2.css
dist/assets/a-doc-editor2.css
+10
-2
a-doc-editor2.js
dist/assets/a-doc-editor2.js
+42
-2
html-docx.min.js
dist/assets/html-docx.min.js
+0
-0
index.html
dist/index.html
+2
-1
script.js
dist/script.js
+2
-4
No files found.
dist/assets/a-doc-editor2.css
View file @
3a3dad06
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
}
}
.popover
{
.popover
{
position
:
absolute
;
position
:
absolute
;
padding
:
20
px
;
padding
:
5
px
;
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
;
...
...
dist/assets/a-doc-editor2.js
View file @
3a3dad06
...
@@ -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">• Bullets </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()
...
...
dist/assets/html-docx.min.js
0 → 100644
View file @
3a3dad06
This source diff could not be displayed because it is too large. You can
view the blob
instead.
dist/index.html
View file @
3a3dad06
...
@@ -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>
...
...
dist/script.js
View file @
3a3dad06
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment