• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kommitters / editorjs-toggle-block / 10892547259

16 Sep 2024 09:48PM UTC coverage: 30.939% (-1.2%) from 32.139%
10892547259

push

github

web-flow
General decoupling in functions (#243)

* undocking elements toggle

* undocking elements render

* undocking elements movement

* undocking elements block

* undocking elements nest

* undocking elements actions

* Fix, linter errors

* Bundle production

73 of 367 branches covered (19.89%)

Branch coverage included in aggregate %.

77 of 456 new or added lines in 24 files covered. (16.89%)

4 existing lines in 1 file now uncovered.

250 of 677 relevant lines covered (36.93%)

29.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/toggle/createParagraphFromToggleRoot.js
1
// /toggle/createParagraphFromToggleRoot.js
2
/**
3
 * First it gets the toggle index.
4
 *
5
 * After checks the toggle status, if this is 'closed' then open it.
6
 *
7
 * After inserts a new block after the toggle index and the a method
8
 * is called to add the required properties to the new block.
9
 * gets the focus.
10
 *
11
 * @param {KeyboardEvent} e - key up event
12
 */
13
export default function createParagraphFromToggleRoot(e) {
NEW
14
  if (e.code === 'Enter') {
×
NEW
15
    const currentPosition = document.getSelection().focusOffset;
×
NEW
16
    const originalIndex = this.api.blocks.getCurrentBlockIndex();
×
NEW
17
    const block = this.api.blocks.getBlockByIndex(originalIndex);
×
NEW
18
    const { holder } = block;
×
NEW
19
    const blockCover = holder.firstChild;
×
NEW
20
    const blockContent = blockCover.firstChild;
×
NEW
21
    const content = blockContent.children[1].innerHTML;
×
22

NEW
23
    const breakLine = content.indexOf('<br>');
×
NEW
24
    const end = breakLine === -1 ? content.length : breakLine;
×
25

NEW
26
    if (this.data.status === 'closed') {
×
NEW
27
      this.resolveToggleAction();
×
NEW
28
      this.hideAndShowBlocks();
×
29
    }
30

NEW
31
    const newText = content.slice(end + 4, currentPosition.focusOffset);
×
NEW
32
    blockContent.children[1].innerHTML = content.slice(
×
33
      currentPosition.focusOffset,
34
      end,
35
    );
36

NEW
37
    this.api.blocks.insert(
×
38
      'paragraph',
39
      { text: newText },
40
      {},
41
      originalIndex + 1,
42
      1,
43
    );
NEW
44
    this.setAttributesToNewBlock();
×
45
  }
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc