getAllBlocks EDITOR
¶
getAllBlocks API extracts the content from the INK Editor in the blocks format. It provides meta data for each block including it’s current value, path, key, children nodes, etc.
Syntax¶
getAllBlocks() : Promise<[Object]>
Example¶
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 34 35 36 37 38 39 40 41 42 43 44 | import INKAPI from './inkapi.js'
INKAPI.ready(async () => {
const EDITOR = INKAPI.editor;
EDITOR.getAllBlocks().then(blocks => {
console.log(blocks);
})
//Or use async/await
const blocks = await EDITOR.getAllBlocks();
console.log(blocks);
/*
Console Output:
[
{
"type": "heading-one",
"align": "left",
"children": [ ... ],
"key": 58,
"path": [0],
"text": "My Title",
"isBlock": true
},
{
"type": "paragraph",
"align": "left",
"children": [ ... ],
"key": 59,
"path": [1],
"text": "My content here!...",
"isBlock": true
}
]
*/
});
|
Note
Learn more about how blocks work in INK editor here.