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

EcrituresNumeriques / stylo / 14865094533

06 May 2025 04:42PM UTC coverage: 37.581% (-0.1%) from 37.729%
14865094533

push

github

web-flow
Prévisualisation en ligne (#1469)

Co-authored-by: Thomas Parisot <thom4parisot@users.noreply.github.com>

532 of 759 branches covered (70.09%)

Branch coverage included in aggregate %.

0 of 124 new or added lines in 14 files covered. (0.0%)

1 existing line in 1 file now uncovered.

5239 of 14597 relevant lines covered (35.89%)

2.51 hits per line

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

0.0
/front/src/components/collaborative/ArticleTableOfContents.jsx
1
import React, { useCallback } from 'react'
×
2
import { ArrowLeft } from 'lucide-react'
×
3
import { useTranslation } from 'react-i18next'
×
4
import { useDispatch, useSelector } from 'react-redux'
×
5
import { useRouteMatch } from 'react-router-dom'
×
6
import { usePandocAnchoring } from '../../hooks/pandoc.js'
×
7

8
import styles from './ArticleTableOfContents.module.scss'
×
9

10
export default function ArticleTableOfContents({ onBack }) {
×
11
  const { t } = useTranslation()
×
12
  const dispatch = useDispatch()
×
13
  const articleStructure = useSelector((state) => state.articleStructure)
×
14
  const getAnchor = usePandocAnchoring()
×
15
  const routeMatch = useRouteMatch()
×
NEW
16
  const hasHtmlAnchors = routeMatch.path === '/article/:id/annotate'
×
17
  const handleTableOfContentsEntryClicked = useCallback(
×
18
    ({ target }) => {
×
19
      hasHtmlAnchors
×
20
        ? document
×
21
            .querySelector(`#${target.dataset.headingAnchor}`)
×
22
            ?.scrollIntoView()
×
23
        : dispatch({
×
24
            type: 'UPDATE_EDITOR_CURSOR_POSITION',
×
25
            lineNumber: parseInt(target.dataset.index, 10),
×
26
            column: 0,
×
27
          })
×
28
    },
×
29
    [hasHtmlAnchors]
×
30
  )
×
31

32
  const title = onBack ? (
×
33
    <h2
×
34
      className={styles.title}
×
35
      onClick={onBack}
×
36
      style={{ cursor: 'pointer', userSelect: 'none' }}
×
37
    >
38
      <span onClick={onBack} style={{ display: 'flex' }}>
×
39
        <ArrowLeft style={{ strokeWidth: 3 }} />
×
40
      </span>
×
41
      <span>{t('toc.title')}</span>
×
42
    </h2>
×
43
  ) : (
44
    <h2 className={styles.title}>{t('toc.title')}</h2>
×
45
  )
46

47
  return (
×
48
    <>
×
49
      <header>{title}</header>
×
50
      <ul>
×
51
        {articleStructure?.map((item) => (
×
52
          <li
×
53
            className={styles.headlineItem}
×
54
            key={`line-${item.index}-${item.line}`}
×
55
            role="button"
×
56
            tabIndex={0}
×
57
            data-index={item.index}
×
58
            data-heading-anchor={getAnchor(item.line)}
×
59
            onClick={handleTableOfContentsEntryClicked}
×
60
          >
61
            {item.title}
×
62
          </li>
×
63
        ))}
×
64
      </ul>
×
65
    </>
×
66
  )
67
}
×
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