mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 22:54:42 -04:00
Add YAML-metadata for notes and change the document title accordingly (#310)
* Added yaml-frontmatter extracting and error handling * add tests * changed document-title, so the editor can change the title to the title of the yaml metadata. closes #303 * extracted first line parsing in a core rule of markdown-it document title will now be determined like this: 1. yaml metadata title 2. opengraph title 3. first level one heading 4. 'Untitled' * added documentTitle e2e test Co-authored-by: Erik Michelson <github@erik.michelson.eu> Co-authored-by: Philip Molares <philip@mauricedoepke.de> Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: mrdrogdrog <mr.drogdrog@gmail.com>
This commit is contained in:
parent
07fed5c67e
commit
29709d2ba4
13 changed files with 499 additions and 20 deletions
67
cypress/integration/documentTitle.spec.ts
Normal file
67
cypress/integration/documentTitle.spec.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
import { branding } from '../support/config'
|
||||
|
||||
const title = 'This is a test title'
|
||||
describe('Document Title', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/n/test')
|
||||
cy.get('.btn.active.btn-outline-secondary > i.fa-columns')
|
||||
.should('exist')
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type('{ctrl}a', { force: true })
|
||||
.type('{backspace}')
|
||||
})
|
||||
|
||||
describe('title should be yaml metadata title', () => {
|
||||
it('just yaml metadata title', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`---\ntitle: ${title}\n---`)
|
||||
cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
|
||||
it('yaml metadata title and opengraph title', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`---\ntitle: ${title}\nopengraph:\n title: False title\n{backspace}{backspace}---`)
|
||||
cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
|
||||
it('yaml metadata title, opengraph title and first heading', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`---\ntitle: ${title}\nopengraph:\n title: False title\n{backspace}{backspace}---\n# a first title`)
|
||||
cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('title should be opengraph title', () => {
|
||||
it('just opengraph title', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`---\nopengraph:\n title: ${title}\n{backspace}{backspace}---`)
|
||||
cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
|
||||
it('opengraph title and first heading', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`---\nopengraph:\n title: ${title}\n{backspace}{backspace}---\n# a first title`)
|
||||
cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('title should be first heading', () => {
|
||||
it('just first heading', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`# ${title}`)
|
||||
cy.title().should('eq', `${title} - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
|
||||
it('just first heading with alt-text instead of image', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`# ${title} `)
|
||||
cy.title().should('eq', `${title} abc - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
|
||||
it('just first heading without link syntax', () => {
|
||||
cy.get('.CodeMirror textarea')
|
||||
.type(`# ${title} [link](https://hedgedoc.org)`)
|
||||
cy.title().should('eq', `${title} link - CodiMD @ ${branding.name}`)
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue