• 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/blocks/setAttributesToNewBlock.js
1
import { v4 as uuidv4 } from 'uuid';
2

3
/**
4
   * Gets the index of the new block, then assigns the required properties,
5
   * and finally sends the focus.
6
   */
7

8
export function setAttributesToNewBlock(entryIndex = null, foreignKey = this.wrapper.id, block = null) {
×
NEW
9
    const index = entryIndex === null ? this.api.blocks.getCurrentBlockIndex() : entryIndex;
×
NEW
10
    const newBlock = block || this.api.blocks.getBlockByIndex(index);
×
11

NEW
12
    const id = uuidv4();
×
NEW
13
    if (!this.itemsId.includes(newBlock.id)) {
×
NEW
14
      this.itemsId.splice(index - 1, 0, newBlock.id);
×
15
    }
16

NEW
17
    const { holder } = newBlock;
×
NEW
18
    const content = holder.firstChild;
×
NEW
19
    const item = content.firstChild;
×
20

NEW
21
    holder.setAttribute('foreignKey', foreignKey);
×
NEW
22
    holder.setAttribute('id', id);
×
23

NEW
24
    setTimeout(() => holder.classList.add('toggle-block__item'));
×
25

NEW
26
    if (!this.readOnly) {
×
NEW
27
      holder.onkeydown = this.setEventsToNestedBlock.bind(this);
×
NEW
28
      item.focus();
×
29
    }
30
  }
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

© 2026 Coveralls, Inc