MCPcopy Index your code
hub / github.com/codex-team/editor.js / composeBlock

Method composeBlock

src/components/modules/blockManager.ts:230–254  ·  view source on GitHub ↗

* 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}})

Source from the content-addressed store, hash-verified

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

Callers 5

insertMethod · 0.95
updateMethod · 0.95
renderMethod · 0.80
BlocksAPIClass · 0.80

Calls 2

bindBlockEventsMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected