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

Method assignInlineToolsToBlockTool

src/components/modules/tools.ts:306–341  ·  view source on GitHub ↗

* Assign enabled Inline Tools for Block Tool * * @param tool - Block Tool

(tool: BlockToolAdapter)

Source from the content-addressed store, hash-verified

304 * @param tool - Block Tool
305 */
306 private assignInlineToolsToBlockTool(tool: BlockToolAdapter): void {
307 /**
308 * If common inlineToolbar property is false no Inline Tools should be assigned
309 */
310 if (this.config.inlineToolbar === false) {
311 return;
312 }
313
314 /**
315 * If user pass just 'true' for tool, get common inlineToolbar settings
316 * - if common settings is an array, use it
317 * - if common settings is 'true' or not specified, get default order
318 */
319 if (tool.enabledInlineTools === true) {
320 tool.inlineTools = new ToolsCollection<InlineToolAdapter>(
321 Array.isArray(this.config.inlineToolbar)
322 ? this.config.inlineToolbar.map(name => [name, this.inlineTools.get(name)])
323 /**
324 * If common settings is 'true' or not specified (will be set as true at core.ts), get the default order
325 */
326 : Array.from(this.inlineTools.entries())
327 );
328
329 return;
330 }
331
332 /**
333 * If user pass the list of inline tools for the particular tool, return it.
334 */
335 if (Array.isArray(tool.enabledInlineTools)) {
336 tool.inlineTools = new ToolsCollection<InlineToolAdapter>(
337 /** Prepend ConvertTo Inline Tool */
338 ['convertTo', ...tool.enabledInlineTools].map(name => [name, this.inlineTools.get(name)])
339 );
340 }
341 }
342
343 /**
344 * Assign enabled Block Tunes for Block Tool

Callers 1

prepareBlockToolsMethod · 0.95

Calls 2

entriesMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected