JavaScript でブロックを追加する / insert a block with JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// var el = wp.element.createElement; var content = "The content"; var name = 'core/paragraph'; // var name = 'core/image'; // var name = 'core/embed'; // var name = 'core/html'; // var name = 'core/file'; insertedBlock = wp.blocks.createBlock(name, { // core/paragraph content: content, // core/embed url: content, // core/file // fileName: content.split(/\//).slice(-1), href: content, }); wp.data.dispatch('core/editor').insertBlocks(insertedBlock); |