mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 09:04:44 -04:00
Enhance share dialog (#860)
This commit is contained in:
parent
1c6e6e10fb
commit
721c8c0e5a
10 changed files with 120 additions and 25 deletions
|
@ -5,12 +5,18 @@
|
|||
*/
|
||||
|
||||
import { store } from '..'
|
||||
import { DocumentContentActionType, SetDocumentContentAction, SetNoteIdAction } from './types'
|
||||
import { YAMLMetaData } from '../../components/editor/yaml-metadata/yaml-metadata'
|
||||
import {
|
||||
DocumentContentActionType,
|
||||
SetDocumentContentAction,
|
||||
SetDocumentMetadataAction,
|
||||
SetNoteIdAction
|
||||
} from './types'
|
||||
|
||||
export const setDocumentContent = (content: string): void => {
|
||||
const action: SetDocumentContentAction = {
|
||||
type: DocumentContentActionType.SET_DOCUMENT_CONTENT,
|
||||
content: content
|
||||
content
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
@ -18,7 +24,18 @@ export const setDocumentContent = (content: string): void => {
|
|||
export const setNoteId = (noteId: string): void => {
|
||||
const action: SetNoteIdAction = {
|
||||
type: DocumentContentActionType.SET_NOTE_ID,
|
||||
noteId: noteId
|
||||
noteId
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
||||
export const setDocumentMetadata = (metadata: YAMLMetaData | undefined): void => {
|
||||
if (!metadata) {
|
||||
return
|
||||
}
|
||||
const action: SetDocumentMetadataAction = {
|
||||
type: DocumentContentActionType.SET_DOCUMENT_METADATA,
|
||||
metadata
|
||||
}
|
||||
store.dispatch(action)
|
||||
}
|
||||
|
|
|
@ -9,13 +9,26 @@ import {
|
|||
DocumentContent,
|
||||
DocumentContentAction,
|
||||
DocumentContentActionType,
|
||||
SetDocumentContentAction,
|
||||
SetDocumentContentAction, SetDocumentMetadataAction,
|
||||
SetNoteIdAction
|
||||
} from './types'
|
||||
|
||||
export const initialState: DocumentContent = {
|
||||
content: '',
|
||||
noteId: ''
|
||||
noteId: '',
|
||||
metadata: {
|
||||
title: '',
|
||||
description: '',
|
||||
tags: [],
|
||||
robots: '',
|
||||
lang: 'en',
|
||||
dir: 'ltr',
|
||||
breaks: true,
|
||||
GA: '',
|
||||
disqus: '',
|
||||
type: '',
|
||||
opengraph: new Map<string, string>()
|
||||
}
|
||||
}
|
||||
|
||||
export const DocumentContentReducer: Reducer<DocumentContent, DocumentContentAction> = (state: DocumentContent = initialState, action: DocumentContentAction) => {
|
||||
|
@ -30,6 +43,11 @@ export const DocumentContentReducer: Reducer<DocumentContent, DocumentContentAct
|
|||
...state,
|
||||
noteId: (action as SetNoteIdAction).noteId
|
||||
}
|
||||
case DocumentContentActionType.SET_DOCUMENT_METADATA:
|
||||
return {
|
||||
...state,
|
||||
metadata: (action as SetDocumentMetadataAction).metadata
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
|
|
@ -5,15 +5,18 @@
|
|||
*/
|
||||
|
||||
import { Action } from 'redux'
|
||||
import { YAMLMetaData } from '../../components/editor/yaml-metadata/yaml-metadata'
|
||||
|
||||
export enum DocumentContentActionType {
|
||||
SET_DOCUMENT_CONTENT = 'document-content/set',
|
||||
SET_NOTE_ID = 'document-content/noteid/set'
|
||||
SET_NOTE_ID = 'document-content/noteid/set',
|
||||
SET_DOCUMENT_METADATA = 'document-content/metadata/set'
|
||||
}
|
||||
|
||||
export interface DocumentContent {
|
||||
content: string
|
||||
noteId: string
|
||||
noteId: string,
|
||||
metadata: YAMLMetaData
|
||||
}
|
||||
|
||||
export interface DocumentContentAction extends Action<DocumentContentActionType> {
|
||||
|
@ -27,3 +30,7 @@ export interface SetDocumentContentAction extends DocumentContentAction {
|
|||
export interface SetNoteIdAction extends DocumentContentAction {
|
||||
noteId: string
|
||||
}
|
||||
|
||||
export interface SetDocumentMetadataAction extends DocumentContentAction {
|
||||
metadata: YAMLMetaData
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue