Published
Edited
Apr 5, 2019
3 stars
Insert cell
Insert cell
html `<div id="codex-editor"></div>`
Insert cell
Insert cell
JSON_URL = 'https://api.myjson.com/bins/174pfk'
Insert cell
Insert cell
saveToJSON = {
saveButton
await editor.isReady
editor.save().then((outputData) => {
console.log('Article data: ', outputData)

fetch(JSON_URL, {
method: 'PUT',
body: JSON.stringify(outputData),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(response => console.log('Success:', JSON.stringify(response)))
.catch(error => console.error('Error:', error));

}).catch((error) => {
console.log('Saving failed: ', error)
});
}
Insert cell
Insert cell
editor = {
const EditorJS = await require('@editorjs/editorjs');
const Header = await require('@editorjs/header');
const List = await require('@editorjs/list');
const savedData = await fetch(JSON_URL).then(data => data.json());
console.log(savedData)
return new EditorJS({
/**
* Id of Element that should contain the Editor
*/
holderId: 'codex-editor',

/**
* Available Tools list.
* Pass Tool's class or Settings object for each Tool you want to use
*/
tools: {
header: {
class: Header,
inlineToolbar: ['link']
},
list: {
class: List,
inlineToolbar: true
}
},
data: savedData
})
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more