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

kommitters / editorjs-toggle-block / 10892436159

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

Pull #243

github

web-flow
Merge 1c88c2761 into 152a5cd00
Pull Request #243: General decoupling in functions

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/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 default function setAttributesToNewBlock(
9
  entryIndex = null,
×
10
  foreignKey = this.wrapper.id,
×
11
  block = null,
×
12
) {
NEW
13
  const index = entryIndex === null ? this.api.blocks.getCurrentBlockIndex() : entryIndex;
×
NEW
14
  const newBlock = block || this.api.blocks.getBlockByIndex(index);
×
15

NEW
16
  const id = uuidv4();
×
NEW
17
  if (!this.itemsId.includes(newBlock.id)) {
×
NEW
18
    this.itemsId.splice(index - 1, 0, newBlock.id);
×
19
  }
20

NEW
21
  const { holder } = newBlock;
×
NEW
22
  const content = holder.firstChild;
×
NEW
23
  const item = content.firstChild;
×
24

NEW
25
  holder.setAttribute('foreignKey', foreignKey);
×
NEW
26
  holder.setAttribute('id', id);
×
27

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

NEW
30
  if (!this.readOnly) {
×
NEW
31
    holder.onkeydown = this.setEventsToNestedBlock.bind(this);
×
NEW
32
    item.focus();
×
33
  }
34
}
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