{"record":{"id":"fa228f7b7ef3c778","repo":"codex-team/editor.js","slug":"could-not-convert-block-failed-to-extract-origina","errorCode":null,"errorMessage":"Could not convert Block. Failed to extract original Block data.","messagePattern":"Could not convert Block\\. Failed to extract original Block data\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/components/modules/blockManager.ts","lineNumber":838,"sourceCode":"    });\n  }\n\n  /**\n   * Converts passed Block to the new Tool\n   * Uses Conversion Config\n   *\n   * @param blockToConvert - Block that should be converted\n   * @param targetToolName - name of the Tool to convert to\n   * @param blockDataOverrides - optional new Block data overrides\n   */\n  public async convert(blockToConvert: Block, targetToolName: string, blockDataOverrides?: BlockToolData): Promise<Block> {\n    /**\n     * At first, we get current Block data\n     */\n    const savedBlock = await blockToConvert.save();\n\n    if (!savedBlock) {\n      throw new Error('Could not convert Block. Failed to extract original Block data.');\n    }\n\n    /**\n     * Getting a class of the replacing Tool\n     */\n    const replacingTool = this.Editor.Tools.blockTools.get(targetToolName);\n\n    if (!replacingTool) {\n      throw new Error(`Could not convert Block. Tool «${targetToolName}» not found.`);\n    }\n\n    /**\n     * Using Conversion Config \"export\" we get a stringified version of the Block data\n     */\n    const exportedData = await blockToConvert.exportDataAsString();\n\n    /**\n     * Clean exported data with replacing sanitizer config","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/codex-team/editor.js/blob/5f45dabbe5690b7033b2f9047d3985add5045fdd/src/components/modules/blockManager.ts#L820-L856","documentation":"BlockManager.convert first saves the current block to extract its data; if save() returns falsy (tool's save threw or returned nothing), conversion cannot proceed and this error is thrown.","triggerScenarios":"The source block's tool save() returning undefined/null or throwing internally; a block in a broken/internal state (e.g. unresolved tool) when convert is called.","commonSituations":"Custom tools with buggy save() methods; blocks created by paste with incomplete data; calling convert on a block still initializing.","solutions":["Verify the tool's save() works (check editor.save() output for that block)","Re-create the problematic block before converting","Retry after the editor is fully ready (await editor.isReady)"],"exampleFix":"// before\nawait editor.blocks.convert(id, 'header');\n// after\nawait editor.isReady;\nconst saved = await editor.save();\nif (saved.blocks.find(b => b.id === id)) {\n  await editor.blocks.convert(id, 'header');\n}","handlingStrategy":"validation","validationCode":"await editor.isReady; const saved = await editor.save(); if (saved.blocks.some(b => b.id === id)) { await editor.blocks.convert(id, target); }","typeGuard":"const hasSavedData = (b: BlockAPI | undefined): b is BlockAPI => Boolean(b);","tryCatchPattern":"try { await editor.blocks.convert(id, target); } catch (e) { if (e instanceof Error && e.message.includes('Failed to extract')) { /* block in bad state, recreate it */ } throw e; }","preventionTips":["Test each tool's save() output","Convert only after editor.isReady"],"tags":["convert","save","block-data","editorjs"],"backgroundTag":"operation-preconditions-failed","analyzedSha":"5f45dabbe5690b7033b2f9047d3985add5045fdd","analyzedAt":"2026-08-27T22:50:23.124Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}