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
6c606c3b
Commit
6c606c3b
authored
Jan 14, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loading and saving completed
parent
1aec68cb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
a-doc-editor.js
dist/assets/a-doc-editor.js
+20
-0
index.html
dist/index.html
+2
-1
script.js
dist/script.js
+14
-2
No files found.
dist/assets/a-doc-editor.js
View file @
6c606c3b
...
...
@@ -830,6 +830,26 @@ var ADocEditor = function (customConfig) {
}
var returnObj = {
getDocumentData(){
let activeDataIndex = dataList.findIndex( item => item.id == caretData.activeData.id )
let returnObj = {
config: JSON.parse( JSON.stringify(config) ),
content: JSON.parse( JSON.stringify(dataList) ),
caretData: JSON.parse( JSON.stringify(caretData) )
}
delete returnObj.caretData.activeData
returnObj.caretData.activeDataIndex = activeDataIndex
return returnObj
},
setDocumentData(data){
// might need to change some configuration
dataList = JSON.parse( JSON.stringify( data.content ) )
config = JSON.parse( JSON.stringify( data.config ) )
caretData = JSON.parse( JSON.stringify( data.caretData ) )
caretData.activeData = dataList[data.caretData.activeDataIndex]
reRenderCanvas()
},
addFonts,
getConfiguration() { return JSON.parse(JSON.stringify(config)) },
getPages() {
...
...
dist/index.html
View file @
6c606c3b
...
...
@@ -25,7 +25,8 @@
<p
style=
"font-family: 'Calibri';"
>
Click on the
<span>
canvas
</span>
and start typing
<input
/>
<button
onclick=
"log()"
>
Log
</button>
<button
onclick=
"setData()"
>
Set Data
</button>
<button
onclick=
"getDocumentData()"
>
Save Data
</button>
<button
onclick=
"setData()"
>
Load Saved Data
</button>
<button
onclick=
"generatePDF()"
>
Generate PDF
</button>
</p>
<div
id=
"user-container-for-editor"
></div>
...
...
dist/script.js
View file @
6c606c3b
...
...
@@ -13,15 +13,27 @@ var tempDocData = [
var
editor
=
new
ADocEditor
({
container
:
document
.
getElementById
(
"user-container-for-editor"
)
})
var
extractedData
=
null
editor
.
focusOnPage
()
var
extractedData
=
null
function
getDocumentData
(){
let
data
=
editor
.
getDocumentData
()
console
.
log
(
data
)
localStorage
.
setItem
(
'oldData'
,
JSON
.
stringify
(
data
))
extractedData
=
data
return
data
}
function
log
()
{
editor
.
log
()
}
function
setData
()
{
editor
.
loadContent
(
extractedData
)
if
(
!
extractedData
)
extractedData
=
JSON
.
parse
(
localStorage
.
getItem
(
'oldData'
)
)
if
(
extractedData
){
editor
.
setDocumentData
(
extractedData
)
}
}
function
generatePDF
()
{
...
...
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