Skip to content

Commit fa40f2c

Browse files
OtomakanJack Misteli
andauthored
Add local storage save feature in the demo (#1368)
* Add local storage save feature in the demo * Update browser.js * Update browser.js * Update browser.js --------- Co-authored-by: Jack Misteli <jack@itio.dev>
1 parent 225a427 commit fa40f2c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

examples/browserify/browser.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ var editor = ace.edit('editor');
8585
editor.setTheme('ace/theme/monokai');
8686
editor.getSession().setMode('ace/mode/javascript');
8787
editor.setValue(
88+
localStorage.getItem('editorText') ||
8889
makePDF
8990
.toString()
9091
.split('\n')
@@ -107,12 +108,14 @@ editor.getSession().on('change', function() {
107108
if (debounceTimeout) {
108109
clearTimeout(debounceTimeout);
109110
}
111+
const text = editor.getValue()
112+
localStorage.setItem('editorText', text)
110113
var fn = new Function(
111114
'PDFDocument',
112115
'blobStream',
113116
'lorem',
114117
'iframe',
115-
editor.getValue()
118+
text
116119
);
117120
debounceTimeout = setTimeout(() => {
118121
fn(PDFDocument, blobStream, lorem, iframe);

0 commit comments

Comments
 (0)