@@ -18,53 +18,57 @@ export default class Renderer extends Module {
1818 return new Promise ( ( resolve ) => {
1919 const { Tools, BlockManager } = this . Editor ;
2020
21- /**
22- * Create Blocks instances
23- */
24- const blocks = blocksData . map ( ( { type : tool , data, tunes, id } ) => {
25- if ( Tools . available . has ( tool ) === false ) {
26- _ . logLabeled ( `Tool «${ tool } » is not found. Check 'tools' property at the Editor.js config.` , 'warn' ) ;
21+ if ( blocksData . length === 0 ) {
22+ BlockManager . insert ( ) ;
23+ } else {
24+ /**
25+ * Create Blocks instances
26+ */
27+ const blocks = blocksData . map ( ( { type : tool , data, tunes, id } ) => {
28+ if ( Tools . available . has ( tool ) === false ) {
29+ _ . logLabeled ( `Tool «${ tool } » is not found. Check 'tools' property at the Editor.js config.` , 'warn' ) ;
2730
28- data = this . composeStubDataForTool ( tool , data , id ) ;
29- tool = Tools . stubTool ;
30- }
31+ data = this . composeStubDataForTool ( tool , data , id ) ;
32+ tool = Tools . stubTool ;
33+ }
3134
32- let block : Block ;
35+ let block : Block ;
3336
34- try {
35- block = BlockManager . composeBlock ( {
36- id,
37- tool,
38- data,
39- tunes,
40- } ) ;
41- } catch ( error ) {
42- _ . log ( `Block «${ tool } » skipped because of plugins error` , 'error' , {
43- data,
44- error,
45- } ) ;
37+ try {
38+ block = BlockManager . composeBlock ( {
39+ id,
40+ tool,
41+ data,
42+ tunes,
43+ } ) ;
44+ } catch ( error ) {
45+ _ . log ( `Block «${ tool } » skipped because of plugins error` , 'error' , {
46+ data,
47+ error,
48+ } ) ;
4649
47- /**
48- * If tool throws an error during render, we should render stub instead of it
49- */
50- data = this . composeStubDataForTool ( tool , data , id ) ;
51- tool = Tools . stubTool ;
50+ /**
51+ * If tool throws an error during render, we should render stub instead of it
52+ */
53+ data = this . composeStubDataForTool ( tool , data , id ) ;
54+ tool = Tools . stubTool ;
5255
53- block = BlockManager . composeBlock ( {
54- id,
55- tool,
56- data,
57- tunes,
58- } ) ;
59- }
56+ block = BlockManager . composeBlock ( {
57+ id,
58+ tool,
59+ data,
60+ tunes,
61+ } ) ;
62+ }
6063
61- return block ;
62- } ) ;
64+ return block ;
65+ } ) ;
6366
64- /**
65- * Insert batch of Blocks
66- */
67- BlockManager . insertMany ( blocks ) ;
67+ /**
68+ * Insert batch of Blocks
69+ */
70+ BlockManager . insertMany ( blocks ) ;
71+ }
6872
6973 /**
7074 * Wait till browser will render inserted Blocks and resolve a promise
0 commit comments