Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/components/PreferencesModal/GeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
usePreferences,
GeneralThemeOptions,
GeneralLanguageOptions,
GeneralNoteListViewOptions,
} from '../../lib/preferences'
import { useTranslation } from 'react-i18next'
import { SelectChangeEventHandler } from '../../lib/events'
Expand Down Expand Up @@ -57,6 +58,16 @@ const GeneralTab = () => {
[setPreferences]
)

const selectNoteListView: SelectChangeEventHandler = useCallback(
(event) => {
setPreferences({
'general.noteListView': event.target
.value as GeneralNoteListViewOptions,
})
},
[setPreferences]
)

const toggleEnableAutoSync: React.ChangeEventHandler<HTMLInputElement> = useCallback(
(event) => {
setPreferences({
Expand Down Expand Up @@ -141,6 +152,18 @@ const GeneralTab = () => {
</SectionSelect>
</SectionControl>
</Section>
<Section>
<SectionHeader>Note List view</SectionHeader>
<SectionControl>
<SectionSelect
value={preferences['general.noteListView']}
onChange={selectNoteListView}
>
<option value='default'>Default</option>
<option value='compact'>Compact</option>
</SectionSelect>
</SectionControl>
</Section>
<Section>
<SectionHeader>Enable auto sync</SectionHeader>
<SectionControl>
Expand Down
52 changes: 0 additions & 52 deletions src/components/atoms/ToolbarExportButton.tsx

This file was deleted.

58 changes: 52 additions & 6 deletions src/components/molecules/NoteDetailToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import React, { useMemo, useCallback } from 'react'
import styled from '../../lib/styled'
import { NoteDoc, NoteStorage } from '../../lib/db/types'
import {
Expand All @@ -7,15 +7,22 @@ import {
mdiViewSplitVertical,
mdiTrashCan,
mdiRestore,
mdiDotsVertical,
} from '@mdi/js'
import { borderBottom, flexCenter } from '../../lib/styled/styleFunctions'
import ToolbarIconButton from '../atoms/ToolbarIconButton'
import ToolbarExportButton from '../atoms/ToolbarExportButton'
import { ViewModeType } from '../../lib/generalStatus'
import ToolbarSeparator from '../atoms/ToolbarSeparator'
import NoteDetailFolderNavigator from './NoteDetailFolderNavigator'
import NoteDetailTagNavigator from './NoteDetailTagNavigator'
import { values } from '../../lib/db/utils'
import { MenuTypes, useContextMenu } from '../../lib/contextMenu'
import {
exportNoteAsHtmlFile,
exportNoteAsMarkdownFile,
} from '../../lib/exports'
import { usePreferences } from '../../lib/preferences'
import { usePreviewStyle } from '../../lib/preview'

const NoteDetailToolbarContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -59,8 +66,44 @@ const NoteDetailToolbar = ({
return values(storage.tagMap).map((tag) => tag.name)
}, [storage])

const { popup } = useContextMenu()
const { preferences } = usePreferences()
const { previewStyle } = usePreviewStyle()
const storageId = storage.id
const storageName = storage.name

const selectEditMode = useCallback(() => {
selectViewMode('edit')
}, [selectViewMode])

const selectSplitMode = useCallback(() => {
selectViewMode('split')
}, [selectViewMode])

const selectPreviewMode = useCallback(() => {
selectViewMode('preview')
}, [selectViewMode])

const openContextMenu = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault()
popup(event, [
{
type: MenuTypes.Normal,
label: 'HTML export',
onClick: async () =>
await exportNoteAsHtmlFile(note, preferences, previewStyle),
},
{
type: MenuTypes.Normal,
label: 'Markdown export',
onClick: async () => await exportNoteAsMarkdownFile(note),
},
])
},
[popup, note, preferences, previewStyle]
)

return (
<NoteDetailToolbarContainer>
<NoteDetailFolderNavigator
Expand All @@ -81,17 +124,17 @@ const NoteDetailToolbar = ({
<Control>
<ToolbarIconButton
active={viewMode === 'edit'}
onClick={() => selectViewMode('edit')}
onClick={selectEditMode}
iconPath={mdiCodeTags}
/>
<ToolbarIconButton
active={viewMode === 'split'}
onClick={() => selectViewMode('split')}
onClick={selectSplitMode}
iconPath={mdiViewSplitVertical}
/>
<ToolbarIconButton
active={viewMode === 'preview'}
onClick={() => selectViewMode('preview')}
onClick={selectPreviewMode}
iconPath={mdiTextSubject}
/>
<ToolbarSeparator />
Expand All @@ -103,7 +146,10 @@ const NoteDetailToolbar = ({
) : (
<ToolbarIconButton onClick={trashNote} iconPath={mdiTrashCan} />
)}
<ToolbarExportButton note={note} />
<ToolbarIconButton
onClick={openContextMenu}
iconPath={mdiDotsVertical}
/>
</Control>
</NoteDetailToolbarContainer>
)
Expand Down
Loading