mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 17:25:16 -04:00
Add slide mode with reveal.js
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
29565f8f89
commit
36e445e631
70 changed files with 1225 additions and 323 deletions
|
@ -6,7 +6,15 @@
|
|||
|
||||
import { NoteDetails } from './types'
|
||||
import { DateTime } from 'luxon'
|
||||
import { NoteTextDirection, NoteType } from '../../components/common/note-frontmatter/types'
|
||||
import { NoteTextDirection, NoteType, SlideOptions } from '../../components/common/note-frontmatter/types'
|
||||
|
||||
export const initialSlideOptions: SlideOptions = {
|
||||
transition: 'zoom',
|
||||
autoSlide: 0,
|
||||
autoSlideStoppable: true,
|
||||
backgroundTransition: 'fade',
|
||||
slideNumber: false
|
||||
}
|
||||
|
||||
export const initialState: NoteDetails = {
|
||||
markdownContent: '',
|
||||
|
@ -14,7 +22,8 @@ export const initialState: NoteDetails = {
|
|||
frontmatterRendererInfo: {
|
||||
frontmatterInvalid: false,
|
||||
deprecatedSyntax: false,
|
||||
offsetLines: 0
|
||||
lineOffset: 0,
|
||||
slideOptions: initialSlideOptions
|
||||
},
|
||||
id: '',
|
||||
createTime: DateTime.fromSeconds(0),
|
||||
|
@ -39,6 +48,7 @@ export const initialState: NoteDetails = {
|
|||
GA: '',
|
||||
disqus: '',
|
||||
type: NoteType.DOCUMENT,
|
||||
opengraph: new Map<string, string>()
|
||||
opengraph: new Map<string, string>(),
|
||||
slideOptions: initialSlideOptions
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
|
||||
import { Reducer } from 'redux'
|
||||
import { PresentFrontmatterExtractionResult } from '../../components/common/note-frontmatter/types'
|
||||
import { NoteFrontmatter } from '../../components/common/note-frontmatter/note-frontmatter'
|
||||
import {
|
||||
createNoteFrontmatterFromYaml,
|
||||
NoteFrontmatter
|
||||
} from '../../components/common/note-frontmatter/note-frontmatter'
|
||||
import { NoteDetails, NoteDetailsActions, NoteDetailsActionType } from './types'
|
||||
import { extractFrontmatter } from '../../components/common/note-frontmatter/extract-frontmatter'
|
||||
import { NoteDto } from '../../api/notes/types'
|
||||
|
@ -31,8 +34,6 @@ export const NoteDetailsReducer: Reducer<NoteDetails, NoteDetailsActions> = (
|
|||
}
|
||||
}
|
||||
|
||||
const TASK_REGEX = /(\s*(?:[-*+]|\d+[.)]) )(\[[ xX]])( .*)/
|
||||
|
||||
/**
|
||||
* Builds a {@link NoteDetails} redux state from a DTO received as an API response.
|
||||
* @param dto The first DTO received from the API containing the relevant information about the note.
|
||||
|
@ -43,6 +44,7 @@ const buildStateFromServerDto = (dto: NoteDto): NoteDetails => {
|
|||
return buildStateFromMarkdownContentUpdate(newState, newState.markdownContent)
|
||||
}
|
||||
|
||||
const TASK_REGEX = /(\s*(?:[-*+]|\d+[.)]) )(\[[ xX]])( .*)/
|
||||
/**
|
||||
* Builds a {@link NoteDetails} redux state where a checkbox in the markdown content either gets checked or unchecked.
|
||||
* @param state The previous redux state.
|
||||
|
@ -74,7 +76,7 @@ const buildStateFromTaskListUpdate = (
|
|||
*/
|
||||
const buildStateFromMarkdownContentUpdate = (state: NoteDetails, markdownContent: string): NoteDetails => {
|
||||
const frontmatterExtraction = extractFrontmatter(markdownContent)
|
||||
if (!frontmatterExtraction.frontmatterPresent) {
|
||||
if (!frontmatterExtraction.isPresent) {
|
||||
return {
|
||||
...state,
|
||||
markdownContent: markdownContent,
|
||||
|
@ -103,32 +105,34 @@ const buildStateFromFrontmatterUpdate = (
|
|||
state: NoteDetails,
|
||||
frontmatterExtraction: PresentFrontmatterExtractionResult
|
||||
): NoteDetails => {
|
||||
if (frontmatterExtraction.rawFrontmatterText === state.rawFrontmatter) {
|
||||
if (frontmatterExtraction.rawText === state.rawFrontmatter) {
|
||||
return state
|
||||
}
|
||||
try {
|
||||
const frontmatter = NoteFrontmatter.createFromYaml(frontmatterExtraction.rawFrontmatterText)
|
||||
const frontmatter = createNoteFrontmatterFromYaml(frontmatterExtraction.rawText)
|
||||
return {
|
||||
...state,
|
||||
rawFrontmatter: frontmatterExtraction.rawFrontmatterText,
|
||||
rawFrontmatter: frontmatterExtraction.rawText,
|
||||
frontmatter: frontmatter,
|
||||
noteTitle: generateNoteTitle(frontmatter, state.firstHeading),
|
||||
frontmatterRendererInfo: {
|
||||
offsetLines: frontmatterExtraction.frontmatterLines,
|
||||
lineOffset: frontmatterExtraction.lineOffset,
|
||||
deprecatedSyntax: frontmatter.deprecatedTagsSyntax,
|
||||
frontmatterInvalid: false
|
||||
frontmatterInvalid: false,
|
||||
slideOptions: frontmatter.slideOptions
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
...state,
|
||||
noteTitle: generateNoteTitle(initialState.frontmatter, state.firstHeading),
|
||||
rawFrontmatter: frontmatterExtraction.rawFrontmatterText,
|
||||
rawFrontmatter: frontmatterExtraction.rawText,
|
||||
frontmatter: initialState.frontmatter,
|
||||
frontmatterRendererInfo: {
|
||||
offsetLines: frontmatterExtraction.frontmatterLines,
|
||||
lineOffset: frontmatterExtraction.lineOffset,
|
||||
deprecatedSyntax: false,
|
||||
frontmatterInvalid: true
|
||||
frontmatterInvalid: true,
|
||||
slideOptions: initialState.frontmatterRendererInfo.slideOptions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,11 +176,7 @@ const convertNoteDtoToNoteDetails = (note: NoteDto): NoteDetails => {
|
|||
return {
|
||||
markdownContent: note.content,
|
||||
rawFrontmatter: '',
|
||||
frontmatterRendererInfo: {
|
||||
frontmatterInvalid: false,
|
||||
deprecatedSyntax: false,
|
||||
offsetLines: 0
|
||||
},
|
||||
frontmatterRendererInfo: initialState.frontmatterRendererInfo,
|
||||
frontmatter: initialState.frontmatter,
|
||||
id: note.metadata.id,
|
||||
noteTitle: initialState.noteTitle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue