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

kommitters / editorjs-toggle-block / 10856842690

13 Sep 2024 10:17PM UTC coverage: 31.442% (-0.7%) from 32.139%
10856842690

Pull #242

github

web-flow
Merge c2da1ab21 into 152a5cd00
Pull Request #242: General decoupling in functions

77 of 370 branches covered (20.81%)

Branch coverage included in aggregate %.

95 of 477 new or added lines in 22 files covered. (19.92%)

3 existing lines in 1 file now uncovered.

250 of 670 relevant lines covered (37.31%)

29.51 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 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