mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00
Minor fixes (#911)
* Replace full links Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use dark mode hook Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Add overflow for graphviz and abc Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Cap max height of toc overlay Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Remove extension from css import Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Fix hook Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
528e67e11e
commit
bf42b9c460
15 changed files with 39 additions and 28 deletions
|
@ -11,7 +11,7 @@ export const banner = {
|
||||||
|
|
||||||
export const branding = {
|
export const branding = {
|
||||||
name: 'ACME Corp',
|
name: 'ACME Corp',
|
||||||
logo: 'http://localhost:3001/img/acme.png'
|
logo: '/img/acme.png'
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"allowRegister": true,
|
"allowRegister": true,
|
||||||
"branding": {
|
"branding": {
|
||||||
"name": "ACME Corp",
|
"name": "ACME Corp",
|
||||||
"logo": "http://localhost:3001/img/acme.png"
|
"logo": "/img/acme.png"
|
||||||
},
|
},
|
||||||
"banner": {
|
"banner": {
|
||||||
"text": "This is the test banner text",
|
"text": "This is the test banner text",
|
||||||
|
|
|
@ -7,14 +7,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { ToggleButton, ToggleButtonGroup } from 'react-bootstrap'
|
import { ToggleButton, ToggleButtonGroup } from 'react-bootstrap'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useSelector } from 'react-redux'
|
import { useIsDarkModeActivated } from '../../../hooks/common/use-is-dark-mode-activated'
|
||||||
import { ApplicationState } from '../../../redux'
|
|
||||||
import { setDarkMode } from '../../../redux/dark-mode/methods'
|
import { setDarkMode } from '../../../redux/dark-mode/methods'
|
||||||
import { ForkAwesomeIcon } from '../../common/fork-awesome/fork-awesome-icon'
|
import { ForkAwesomeIcon } from '../../common/fork-awesome/fork-awesome-icon'
|
||||||
|
|
||||||
const DarkModeButton: React.FC = () => {
|
const DarkModeButton: React.FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const darkModeEnabled = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
const darkModeEnabled = useIsDarkModeActivated()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToggleButtonGroup
|
<ToggleButtonGroup
|
||||||
|
|
|
@ -6,9 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Navbar } from 'react-bootstrap'
|
import { Navbar } from 'react-bootstrap'
|
||||||
import { useSelector } from 'react-redux'
|
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { ApplicationState } from '../../../redux'
|
import { useIsDarkModeActivated } from '../../../hooks/common/use-is-dark-mode-activated'
|
||||||
import { Branding } from '../../common/branding/branding'
|
import { Branding } from '../../common/branding/branding'
|
||||||
import {
|
import {
|
||||||
HedgeDocLogoSize,
|
HedgeDocLogoSize,
|
||||||
|
@ -17,7 +16,7 @@ import {
|
||||||
} from '../../common/hedge-doc-logo/hedge-doc-logo-with-text'
|
} from '../../common/hedge-doc-logo/hedge-doc-logo-with-text'
|
||||||
|
|
||||||
export const NavbarBranding: React.FC = () => {
|
export const NavbarBranding: React.FC = () => {
|
||||||
const darkModeActivated = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
const darkModeActivated = useIsDarkModeActivated()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar.Brand>
|
<Navbar.Brand>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { useParams } from 'react-router'
|
||||||
import { getAllRevisions, getRevision } from '../../../../api/revisions'
|
import { getAllRevisions, getRevision } from '../../../../api/revisions'
|
||||||
import { Revision, RevisionListEntry } from '../../../../api/revisions/types'
|
import { Revision, RevisionListEntry } from '../../../../api/revisions/types'
|
||||||
import { UserResponse } from '../../../../api/users/types'
|
import { UserResponse } from '../../../../api/users/types'
|
||||||
|
import { useIsDarkModeActivated } from '../../../../hooks/common/use-is-dark-mode-activated'
|
||||||
import { ApplicationState } from '../../../../redux'
|
import { ApplicationState } from '../../../../redux'
|
||||||
import { CommonModal, CommonModalProps } from '../../../common/modals/common-modal'
|
import { CommonModal, CommonModalProps } from '../../../common/modals/common-modal'
|
||||||
import { ShowIf } from '../../../common/show-if/show-if'
|
import { ShowIf } from '../../../common/show-if/show-if'
|
||||||
|
@ -27,7 +28,7 @@ export const RevisionModal: React.FC<CommonModalProps> = ({ show, onHide, icon,
|
||||||
const [selectedRevision, setSelectedRevision] = useState<Revision | null>(null)
|
const [selectedRevision, setSelectedRevision] = useState<Revision | null>(null)
|
||||||
const [error, setError] = useState(false)
|
const [error, setError] = useState(false)
|
||||||
const revisionAuthorListMap = useRef(new Map<number, UserResponse[]>())
|
const revisionAuthorListMap = useRef(new Map<number, UserResponse[]>())
|
||||||
const darkModeEnabled = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
const darkModeEnabled = useIsDarkModeActivated()
|
||||||
const { id } = useParams<{ id: string }>()
|
const { id } = useParams<{ id: string }>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -7,9 +7,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import { Picker } from 'emoji-picker-element'
|
import { Picker } from 'emoji-picker-element'
|
||||||
import { CustomEmoji, EmojiClickEvent, EmojiClickEventDetail } from 'emoji-picker-element/shared'
|
import { CustomEmoji, EmojiClickEvent, EmojiClickEventDetail } from 'emoji-picker-element/shared'
|
||||||
import React, { useEffect, useRef } from 'react'
|
import React, { useEffect, useRef } from 'react'
|
||||||
import { useSelector } from 'react-redux'
|
|
||||||
import { useClickAway } from 'react-use'
|
import { useClickAway } from 'react-use'
|
||||||
import { ApplicationState } from '../../../../../redux'
|
import { useIsDarkModeActivated } from '../../../../../hooks/common/use-is-dark-mode-activated'
|
||||||
import './emoji-picker.scss'
|
import './emoji-picker.scss'
|
||||||
import forkawesomeIcon from './forkawesome.png'
|
import forkawesomeIcon from './forkawesome.png'
|
||||||
import { ForkAwesomeIcons } from './icon-names'
|
import { ForkAwesomeIcons } from './icon-names'
|
||||||
|
@ -41,7 +40,7 @@ const twemojiStyle = (): HTMLStyleElement => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EmojiPicker: React.FC<EmojiPickerProps> = ({ show, onEmojiSelected, onDismiss }) => {
|
export const EmojiPicker: React.FC<EmojiPickerProps> = ({ show, onEmojiSelected, onDismiss }) => {
|
||||||
const darkModeEnabled = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
const darkModeEnabled = useIsDarkModeActivated()
|
||||||
const pickerContainerRef = useRef<HTMLDivElement>(null)
|
const pickerContainerRef = useRef<HTMLDivElement>(null)
|
||||||
const pickerRef = useRef<Picker>()
|
const pickerRef = useRef<Picker>()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
.markdown-toc {
|
.markdown-toc {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
|
max-height: 100vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
|
|
@ -23,5 +23,5 @@ export const AbcFrame: React.FC<AbcFrameProps> = ({ code }) => {
|
||||||
}).catch(() => { console.error('error while loading abcjs') })
|
}).catch(() => { console.error('error while loading abcjs') })
|
||||||
}, [code])
|
}, [code])
|
||||||
|
|
||||||
return <div ref={container} className={'bg-white text-center'}/>
|
return <div ref={container} className={'bg-white text-center overflow-x-auto'}/>
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect, useRef, useState } from 'react'
|
||||||
import { Alert } from 'react-bootstrap'
|
import { Alert } from 'react-bootstrap'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
import { useSelector } from 'react-redux'
|
import { useIsDarkModeActivated } from '../../../../../hooks/common/use-is-dark-mode-activated'
|
||||||
import { ApplicationState } from '../../../../../redux'
|
|
||||||
|
|
||||||
export interface FlowChartProps {
|
export interface FlowChartProps {
|
||||||
code: string
|
code: string
|
||||||
|
@ -17,8 +16,7 @@ export interface FlowChartProps {
|
||||||
export const FlowChart: React.FC<FlowChartProps> = ({ code }) => {
|
export const FlowChart: React.FC<FlowChartProps> = ({ code }) => {
|
||||||
const diagramRef = useRef<HTMLDivElement>(null)
|
const diagramRef = useRef<HTMLDivElement>(null)
|
||||||
const [error, setError] = useState(false)
|
const [error, setError] = useState(false)
|
||||||
|
const darkModeActivated = useIsDarkModeActivated()
|
||||||
const darkModeActivated = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
|
||||||
|
|
||||||
useTranslation()
|
useTranslation()
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ export const GraphvizFrame: React.FC<GraphvizFrameProps> = ({ code }) => {
|
||||||
<ShowIf condition={!!error}>
|
<ShowIf condition={!!error}>
|
||||||
<Alert variant={'warning'}>{error}</Alert>
|
<Alert variant={'warning'}>{error}</Alert>
|
||||||
</ShowIf>
|
</ShowIf>
|
||||||
<div className={'text-center'} ref={container} />
|
<div className={'text-center overflow-x-auto'} ref={container} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import React, { useEffect, useState } from 'react'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
import { getProxiedUrl } from '../../../../api/media'
|
import { getProxiedUrl } from '../../../../api/media'
|
||||||
import { ApplicationState } from '../../../../redux'
|
import { ApplicationState } from '../../../../redux'
|
||||||
import { Frame } from './frame'
|
import { LightboxedImageFrame } from './lightboxedImageFrame'
|
||||||
|
|
||||||
export const ImageFrame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({ src, title, alt, ...props }) => {
|
export const ImageFrame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({ src, title, alt, ...props }) => {
|
||||||
const [imageUrl, setImageUrl] = useState('')
|
const [imageUrl, setImageUrl] = useState('')
|
||||||
|
@ -25,11 +25,11 @@ export const ImageFrame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = (
|
||||||
|
|
||||||
if (imageProxyEnabled) {
|
if (imageProxyEnabled) {
|
||||||
return (
|
return (
|
||||||
<Frame src={imageUrl} title={title ?? alt ?? ''} alt={alt} {...props}/>
|
<LightboxedImageFrame src={imageUrl} title={title ?? alt ?? ''} alt={alt} {...props}/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Frame src={src ?? ''} title={title ?? alt ?? ''} alt={alt} {...props}/>
|
<LightboxedImageFrame src={src ?? ''} title={title ?? alt ?? ''} alt={alt} {...props}/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import React, { Fragment, useState } from 'react'
|
||||||
import { Modal } from 'react-bootstrap'
|
import { Modal } from 'react-bootstrap'
|
||||||
import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon'
|
import { ForkAwesomeIcon } from '../../../common/fork-awesome/fork-awesome-icon'
|
||||||
|
|
||||||
export const Frame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({ alt, ...props }) => {
|
export const LightboxedImageFrame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({ alt, ...props }) => {
|
||||||
const [showFullscreenImage, setShowFullscreenImage] = useState(false)
|
const [showFullscreenImage, setShowFullscreenImage] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -20,8 +20,7 @@ export const Frame: React.FC<React.ImgHTMLAttributes<HTMLImageElement>> = ({ alt
|
||||||
dialogClassName={'text-dark'}
|
dialogClassName={'text-dark'}
|
||||||
show={showFullscreenImage}
|
show={showFullscreenImage}
|
||||||
onHide={() => setShowFullscreenImage(false)}
|
onHide={() => setShowFullscreenImage(false)}
|
||||||
size={'xl'}
|
size={'xl'}>
|
||||||
>
|
|
||||||
<Modal.Header closeButton={true}>
|
<Modal.Header closeButton={true}>
|
||||||
<Modal.Title className={'h6'}>
|
<Modal.Title className={'h6'}>
|
||||||
<ForkAwesomeIcon icon={'picture-o'}/>
|
<ForkAwesomeIcon icon={'picture-o'}/>
|
|
@ -5,11 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useSelector } from 'react-redux'
|
import { useIsDarkModeActivated } from './use-is-dark-mode-activated'
|
||||||
import { ApplicationState } from '../../redux'
|
|
||||||
|
|
||||||
export const useApplyDarkMode = ():void => {
|
export const useApplyDarkMode = ():void => {
|
||||||
const darkModeActivated = useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
const darkModeActivated = useIsDarkModeActivated()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (darkModeActivated) {
|
if (darkModeActivated) {
|
||||||
|
|
12
src/hooks/common/use-is-dark-mode-activated.ts
Normal file
12
src/hooks/common/use-is-dark-mode-activated.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2020 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { useSelector } from 'react-redux'
|
||||||
|
import { ApplicationState } from '../../redux'
|
||||||
|
|
||||||
|
export const useIsDarkModeActivated = (): boolean => {
|
||||||
|
return useSelector((state: ApplicationState) => state.darkMode.darkMode)
|
||||||
|
}
|
|
@ -7,7 +7,7 @@
|
||||||
@import "variables.light";
|
@import "variables.light";
|
||||||
@import "../../node_modules/bootstrap/scss/bootstrap";
|
@import "../../node_modules/bootstrap/scss/bootstrap";
|
||||||
@import '../../node_modules/react-bootstrap-typeahead/css/Typeahead';
|
@import '../../node_modules/react-bootstrap-typeahead/css/Typeahead';
|
||||||
@import "~@fontsource/source-sans-pro/index.css";
|
@import "~@fontsource/source-sans-pro/index";
|
||||||
@import "fonts/twemoji/twemoji";
|
@import "fonts/twemoji/twemoji";
|
||||||
@import '../../node_modules/fork-awesome/css/fork-awesome.min';
|
@import '../../node_modules/fork-awesome/css/fork-awesome.min';
|
||||||
|
|
||||||
|
@ -79,3 +79,7 @@ body {
|
||||||
content: initial;
|
content: initial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.overflow-x-auto {
|
||||||
|
overflow-x: auto !important;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue