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

Function resolveBlock

src/components/utils/api.ts:11–21  ·  view source on GitHub ↗
(attribute: BlockAPI | BlockAPI['id'] | number, editor: EditorModules)

Source from the content-addressed store, hash-verified

9 * @param editor - Editor instance
10 */
11export function resolveBlock(attribute: BlockAPI | BlockAPI['id'] | number, editor: EditorModules): Block | undefined {
12 if (typeof attribute === 'number') {
13 return editor.BlockManager.getBlockByIndex(attribute);
14 }
15
16 if (typeof attribute === 'string') {
17 return editor.BlockManager.getBlockById(attribute);
18 }
19
20 return editor.BlockManager.getBlockById(attribute.id);
21}

Callers 1

CaretAPIClass · 0.90

Calls 2

getBlockByIdMethod · 0.80
getBlockByIndexMethod · 0.65

Tested by

no test coverage detected