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

Method split

src/components/modules/blockManager.ts:613–632  ·  view source on GitHub ↗

* Split current Block * 1. Extract content from Caret position to the Block`s end * 2. Insert a new Block below current one with extracted content * * @returns {Block}

()

Source from the content-addressed store, hash-verified

611 * @returns {Block}
612 */
613 public split(): Block {
614 const extractedFragment = this.Editor.Caret.extractFragmentFromCaretPosition();
615 const wrapper = $.make('div');
616
617 wrapper.appendChild(extractedFragment as DocumentFragment);
618
619 /**
620 * @todo make object in accordance with Tool
621 */
622 const data = {
623 text: $.isEmpty(wrapper) ? '' : wrapper.innerHTML,
624 };
625
626 /**
627 * Renew current Block
628 *
629 * @type {Block}
630 */
631 return this.insert({ data });
632 }
633
634 /**
635 * Returns Block by passed index

Callers 5

getFileExtensionFunction · 0.80
enterMethod · 0.80
processFileMethod · 0.80
processPlainMethod · 0.80
getNamespaceMethod · 0.80

Calls 4

insertMethod · 0.95
makeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected