MCPcopy
hub / github.com/codex-team/editor.js / processSingleBlock

Method processSingleBlock

src/components/modules/paste.ts:744–762  ·  view source on GitHub ↗

* Process paste of single Block tool content * * @param {PasteData} dataToInsert - data of Block to insert

(dataToInsert: PasteData)

Source from the content-addressed store, hash-verified

742 * @param {PasteData} dataToInsert - data of Block to insert
743 */
744 private async processSingleBlock(dataToInsert: PasteData): Promise<void> {
745 const { Caret, BlockManager } = this.Editor;
746 const { currentBlock } = BlockManager;
747
748 /**
749 * If pasted tool isn`t equal current Block or if pasted content contains block elements, insert it as new Block
750 */
751 if (
752 !currentBlock ||
753 dataToInsert.tool !== currentBlock.name ||
754 !$.containsOnlyInlineElements(dataToInsert.content.innerHTML)
755 ) {
756 this.insertBlock(dataToInsert, currentBlock?.tool.isDefault && currentBlock.isEmpty);
757
758 return;
759 }
760
761 Caret.insertContentAtCaretPosition(dataToInsert.content.innerHTML);
762 }
763
764 /**
765 * Process paste to single Block:

Callers 1

processTextMethod · 0.95

Calls 3

insertBlockMethod · 0.95

Tested by

no test coverage detected