Skip to content

Commit c363e46

Browse files
author
Vinicius Reis
committed
⏪️ Revert "Merge pull request #2841 from nextcloud/feature/heading-anchors" until #2868 be fixed
This reverts commit 0f2c48e, reversing changes made to 9973d1f. Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
1 parent 6ba3218 commit c363e46

4 files changed

Lines changed: 74 additions & 253 deletions

File tree

cypress/e2e/outline.spec.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { randHash } from '../utils/index.js'
2+
3+
const currentUser = randHash()
4+
5+
const refresh = () => cy.get('.files-controls .crumb:not(.hidden) a')
6+
.last()
7+
.click({ force: true })
8+
9+
const clickOutline = () => {
10+
cy.getActionEntry('headings')
11+
.click()
12+
13+
cy.get('.v-popper__wrapper .open').getActionEntry('outline')
14+
.click()
15+
}
16+
17+
const createMarkdown = (fileName, content) => {
18+
return cy.createFile(fileName, content, 'text/markdown')
19+
.then(refresh)
20+
}
21+
22+
describe('Table of Contents', () => {
23+
before(() => {
24+
// Init user
25+
cy.nextcloudCreateUser(currentUser, 'password')
26+
cy.login(currentUser, 'password')
27+
})
28+
29+
beforeEach(() => {
30+
cy.login(currentUser, 'password')
31+
})
32+
33+
it('sidebar toc', () => {
34+
const fileName = 'toc.md'
35+
36+
createMarkdown(fileName, '# T1 \n ## T2 \n ### T3 \n #### T4 \n ##### T5 \n ###### T6')
37+
.then(refresh)
38+
.then(() => cy.openFile(fileName, { force: true }))
39+
.then(clickOutline)
40+
41+
cy.getOutline()
42+
.find('header')
43+
.should('exist')
44+
45+
cy.getTOC()
46+
.find('ul li')
47+
.should('have.length', 6)
48+
cy.getTOC()
49+
.find('ul li')
50+
.each((el, index) => {
51+
cy.wrap(el)
52+
.should('have.attr', 'data-toc-level')
53+
.and('equal', String(index + 1))
54+
55+
cy.wrap(el)
56+
.find('a')
57+
.should('have.attr', 'href')
58+
.and('equal', `#t${index + 1}`)
59+
})
60+
})
61+
62+
it('empty toc', () => {
63+
const fileName = 'empty.md'
64+
65+
createMarkdown(fileName, '')
66+
.then(refresh)
67+
.then(() => cy.openFile(fileName, { force: true }))
68+
.then(clickOutline)
69+
70+
cy.getOutline()
71+
.find('ul')
72+
.should('be.empty')
73+
})
74+
})

cypress/e2e/sections.spec.js

Lines changed: 0 additions & 124 deletions
This file was deleted.

src/nodes/Heading/HeadingView.vue

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/nodes/Heading/index.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
import TipTapHeading from '@tiptap/extension-heading'
2-
import { VueNodeViewRenderer } from '@tiptap/vue-2'
32
import debounce from 'debounce'
4-
5-
import HeadingView from './HeadingView.vue'
63
import { setHeadings, extractHeadings } from './extractor.js'
74

85
const Heading = TipTapHeading.extend({
9-
addOptions() {
10-
return {
11-
...this.parent?.(),
12-
linkSymbol: '#',
13-
}
14-
},
15-
166
addAttributes() {
177
return {
188
...this.parent(),
@@ -26,11 +16,6 @@ const Heading = TipTapHeading.extend({
2616
},
2717
}
2818
},
29-
30-
addNodeView() {
31-
return VueNodeViewRenderer(HeadingView)
32-
},
33-
3419
addKeyboardShortcuts() {
3520
return this.options.levels.reduce((items, level) => ({
3621
...items,

0 commit comments

Comments
 (0)