* Creates Block instance by tool name * * @param {object} options - block creation options * @param {string} options.tool - tools passed in editor config EditorConfig#tools * @param {string} [options.id] - unique id for this block * @param {BlockToolData} [options.data] - cons
({
tool: name,
data = {},
id = undefined,
tunes: tunesData = {},
}: {tool: string; id?: string; data?: BlockToolData; tunes?: {[name: string]: BlockTuneData}})
| 228 | * @returns {Block} |
| 229 | */ |
| 230 | public composeBlock({ |
| 231 | tool: name, |
| 232 | data = {}, |
| 233 | id = undefined, |
| 234 | tunes: tunesData = {}, |
| 235 | }: {tool: string; id?: string; data?: BlockToolData; tunes?: {[name: string]: BlockTuneData}}): Block { |
| 236 | const readOnly = this.Editor.ReadOnly.isEnabled; |
| 237 | const tool = this.Editor.Tools.blockTools.get(name); |
| 238 | const block = new Block({ |
| 239 | id, |
| 240 | data, |
| 241 | tool, |
| 242 | api: this.Editor.API, |
| 243 | readOnly, |
| 244 | tunesData, |
| 245 | }, this.eventsDispatcher); |
| 246 | |
| 247 | if (!readOnly) { |
| 248 | window.requestIdleCallback(() => { |
| 249 | this.bindBlockEvents(block); |
| 250 | }, { timeout: 2000 }); |
| 251 | } |
| 252 | |
| 253 | return block; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Insert new block into _blocks |
no test coverage detected