Skip to content

Commit

Permalink
⏪️ Revert "Merge pull request #2841 from nextcloud/feature/heading-an…
Browse files Browse the repository at this point in the history
…chors" until #2868 be fixed

This reverts commit 0f2c48e, reversing
changes made to 9973d1f.

Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
  • Loading branch information
Vinicius Reis committed Sep 8, 2022
1 parent 6ba3218 commit c363e46
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 253 deletions.
74 changes: 74 additions & 0 deletions cypress/e2e/outline.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { randHash } from '../utils/index.js'

const currentUser = randHash()

const refresh = () => cy.get('.files-controls .crumb:not(.hidden) a')
.last()
.click({ force: true })

const clickOutline = () => {
cy.getActionEntry('headings')
.click()

cy.get('.v-popper__wrapper .open').getActionEntry('outline')
.click()
}

const createMarkdown = (fileName, content) => {
return cy.createFile(fileName, content, 'text/markdown')
.then(refresh)
}

describe('Table of Contents', () => {
before(() => {
// Init user
cy.nextcloudCreateUser(currentUser, 'password')
cy.login(currentUser, 'password')
})

beforeEach(() => {
cy.login(currentUser, 'password')
})

it('sidebar toc', () => {
const fileName = 'toc.md'

createMarkdown(fileName, '# T1 \n ## T2 \n ### T3 \n #### T4 \n ##### T5 \n ###### T6')
.then(refresh)
.then(() => cy.openFile(fileName, { force: true }))
.then(clickOutline)

cy.getOutline()
.find('header')
.should('exist')

cy.getTOC()
.find('ul li')
.should('have.length', 6)
cy.getTOC()
.find('ul li')
.each((el, index) => {
cy.wrap(el)
.should('have.attr', 'data-toc-level')
.and('equal', String(index + 1))

cy.wrap(el)
.find('a')
.should('have.attr', 'href')
.and('equal', `#t${index + 1}`)
})
})

it('empty toc', () => {
const fileName = 'empty.md'

createMarkdown(fileName, '')
.then(refresh)
.then(() => cy.openFile(fileName, { force: true }))
.then(clickOutline)

cy.getOutline()
.find('ul')
.should('be.empty')
})
})
124 changes: 0 additions & 124 deletions cypress/e2e/sections.spec.js

This file was deleted.

114 changes: 0 additions & 114 deletions src/nodes/Heading/HeadingView.vue

This file was deleted.

15 changes: 0 additions & 15 deletions src/nodes/Heading/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import TipTapHeading from '@tiptap/extension-heading'
import { VueNodeViewRenderer } from '@tiptap/vue-2'
import debounce from 'debounce'

import HeadingView from './HeadingView.vue'
import { setHeadings, extractHeadings } from './extractor.js'

const Heading = TipTapHeading.extend({
addOptions() {
return {
...this.parent?.(),
linkSymbol: '#',
}
},

addAttributes() {
return {
...this.parent(),
Expand All @@ -26,11 +16,6 @@ const Heading = TipTapHeading.extend({
},
}
},

addNodeView() {
return VueNodeViewRenderer(HeadingView)
},

addKeyboardShortcuts() {
return this.options.levels.reduce((items, level) => ({
...items,
Expand Down

0 comments on commit c363e46

Please sign in to comment.