-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 948 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var MediumEditor = require('medium-editor');
require('medium-editor/dist/css/medium-editor.css');
const inputId = 'notes';
document.addEventListener('DOMContentLoaded', function() {
var editor = new MediumEditor('#notes');
const textarea = document.getElementById(inputId)
chrome.storage.sync.get(inputId, function(items) {
textarea.innerHTML = items[inputId] || ''
})
textarea.addEventListener('input', function(event) {
saveChanges(event.target.innerHTML)
})
});
function saveChanges() {
const textarea = document.getElementById(inputId);
// Get a value saved in a form.
var theValue = textarea.innerHTML;
// Check that there's some code there.
if (!theValue) {
// console.log('Error: No value specified');
return;
}
// Save it using the Chrome extension storage API.
chrome.storage.sync.set({'notes': theValue}, function() {
// Notify that we saved.
// message('Settings saved');
});
}