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

EcrituresNumeriques / stylo / 15066626824

16 May 2025 10:41AM UTC coverage: 37.574% (-0.02%) from 37.594%
15066626824

Pull #1517

github

web-flow
Merge e05a1c169 into 607ffe7f9
Pull Request #1517: Mise à jour vers react-router@7

549 of 776 branches covered (70.75%)

Branch coverage included in aggregate %.

13 of 373 new or added lines in 28 files covered. (3.49%)

5 existing lines in 4 files now uncovered.

5319 of 14841 relevant lines covered (35.84%)

2.56 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'
×
NEW
5
import { useMatch } from 'react-router'
×
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()
×
NEW
15
  const routeMatch = useMatch('/article/:id/version/:versionId/*') || useMatch('/article/:id/*')
×
NEW
16
  const { '*': mode = null } = routeMatch?.params ?? {}
×
NEW
17
  const hasHtmlAnchors = mode === 'preview'
×
18

19
  const handleTableOfContentsEntryClicked = useCallback(
×
20
    ({ target }) => {
×
21
      hasHtmlAnchors
×
22
        ? document
×
23
            .querySelector(`#${target.dataset.headingAnchor}`)
×
24
            ?.scrollIntoView()
×
25
        : dispatch({
×
26
            type: 'UPDATE_EDITOR_CURSOR_POSITION',
×
27
            lineNumber: parseInt(target.dataset.index, 10),
×
28
            column: 0,
×
29
          })
×
30
    },
×
31
    [hasHtmlAnchors]
×
32
  )
×
33

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

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