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

Method paste

src/components/modules/blockManager.ts:398–424  ·  view source on GitHub ↗

* Insert pasted content. Call onPaste callback after insert. * * @param {string} toolName - name of Tool to insert * @param {PasteEvent} pasteEvent - pasted data * @param {boolean} replace - should replace current block

(
    toolName: string,
    pasteEvent: PasteEvent,
    replace = false
  )

Source from the content-addressed store, hash-verified

396 * @param {boolean} replace - should replace current block
397 */
398 public paste(
399 toolName: string,
400 pasteEvent: PasteEvent,
401 replace = false
402 ): Block {
403 const block = this.insert({
404 tool: toolName,
405 replace,
406 });
407
408 try {
409 /**
410 * We need to call onPaste after Block will be ready
411 * because onPaste could change tool's root element, and we need to do that after block.watchBlockMutations() bound
412 * to detect tool root element change
413 *
414 * @todo make this.insert() awaitable and remove requestIdleCallback
415 */
416 window.requestIdleCallback(() => {
417 block.call(BlockToolAPI.ON_PASTE, pasteEvent);
418 });
419 } catch (e) {
420 _.log(`${toolName}: onPaste callback call is failed`, 'error', e);
421 }
422
423 return block;
424 }
425
426 /**
427 * Insert new default block at passed index

Callers

nothing calls this directly

Calls 2

insertMethod · 0.95
callMethod · 0.65

Tested by

no test coverage detected