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

kommitters / editorjs-toggle-block / 10905088009

17 Sep 2024 02:24PM UTC coverage: 30.939% (-1.2%) from 32.139%
10905088009

push

github

web-flow
Merge pull request #246 from kommitters/v0.3

Release v0.3.17

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/render/renderItems.js
1
/**
2
   * Renders the items view and assigns the properties required to look
3
   * like a block inside the toggle.
4
   */
5
export default function renderItems() {
NEW
6
  const blocksInEditor = this.api.blocks.getBlocksCount();
×
NEW
7
  const icon = this.wrapper.firstChild;
×
8
  let toggleRoot;
9

NEW
10
  if (this.readOnly) {
×
NEW
11
    const redactor = document.getElementsByClassName(
×
12
      'codex-editor__redactor',
13
    )[0];
NEW
14
    const { children } = redactor;
×
NEW
15
    const { length } = children;
×
16

NEW
17
    for (let i = 0; i < length; i += 1) {
×
NEW
18
      const blockCover = children[i].firstChild;
×
NEW
19
      const blockContainer = blockCover.firstChild;
×
NEW
20
      const { id } = blockContainer;
×
21

NEW
22
      if (id === this.wrapper.id) {
×
NEW
23
        toggleRoot = i;
×
NEW
24
        break;
×
25
      }
26
    }
27
  } else {
NEW
28
    const toggle = this.wrapper.children[1];
×
NEW
29
    let currentBlock = {};
×
NEW
30
    let index = this.api.blocks.getCurrentBlockIndex();
×
NEW
31
    const delta = index === blocksInEditor - 1 ? -1 : 1;
×
32

NEW
33
    while (currentBlock[1] !== toggle) {
×
NEW
34
      toggleRoot = index;
×
NEW
35
      const block = this.api.blocks.getBlockByIndex(toggleRoot);
×
NEW
36
      if (!block) break;
×
NEW
37
      const { holder } = block;
×
NEW
38
      const blockCover = holder.firstChild;
×
NEW
39
      const blockContent = blockCover.firstChild;
×
NEW
40
      currentBlock = blockContent.children;
×
41

NEW
42
      index += delta;
×
43
    }
44
  }
45

NEW
46
  if (toggleRoot + this.data.items < blocksInEditor) {
×
NEW
47
    for (
×
NEW
48
      let i = toggleRoot + 1, j = 0;
×
49
      i <= toggleRoot + this.data.items;
50
      i += 1
51
    ) {
NEW
52
      const block = this.api.blocks.getBlockByIndex(i);
×
NEW
53
      const { holder } = block;
×
NEW
54
      const cover = holder.firstChild;
×
NEW
55
      const content = cover.firstChild;
×
56

NEW
57
      if (!this.isPartOfAToggle(content)) {
×
NEW
58
        this.setAttributesToNewBlock(i);
×
NEW
59
        j += 1;
×
60
      } else {
NEW
61
        this.data.items = j;
×
NEW
62
        break;
×
63
      }
64
    }
65
  } else {
NEW
66
    this.data.items = 0;
×
67
  }
68

NEW
69
  icon.addEventListener('click', () => {
×
NEW
70
    this.resolveToggleAction();
×
NEW
71
    setTimeout(() => {
×
NEW
72
      this.hideAndShowBlocks();
×
73
    });
74
  });
75

NEW
76
  this.hideAndShowBlocks();
×
77
}
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