mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Moved note-related toolbar button next to tag bar
This commit is contained in:
parent
d9601f3136
commit
e85d4fca5d
@ -134,6 +134,20 @@ class HeaderComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
makeButton(key, style, options) {
|
makeButton(key, style, options) {
|
||||||
|
// TODO: "tab" type is not finished
|
||||||
|
if (options.type === 'tab') {
|
||||||
|
const buttons = [];
|
||||||
|
for (let i = 0; i < options.items.length; i++) {
|
||||||
|
const item = options.items[i];
|
||||||
|
buttons.push(this.makeButton(key + item.title, style, Object.assign({}, options, {
|
||||||
|
title: item.title,
|
||||||
|
type: 'button',
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
return <span style={{ display: 'flex', flexDirection: 'row' }}>{buttons}</span>;
|
||||||
|
}
|
||||||
|
|
||||||
const theme = themeStyle(this.props.theme);
|
const theme = themeStyle(this.props.theme);
|
||||||
|
|
||||||
let icon = null;
|
let icon = null;
|
||||||
|
@ -2,7 +2,7 @@ import * as React from 'react';
|
|||||||
|
|
||||||
const ToolbarBase = require('../../../Toolbar.min.js');
|
const ToolbarBase = require('../../../Toolbar.min.js');
|
||||||
const { _ } = require('lib/locale');
|
const { _ } = require('lib/locale');
|
||||||
const { buildStyle } = require('../../../../theme.js');
|
const { buildStyle, themeStyle } = require('../../../../theme.js');
|
||||||
|
|
||||||
interface ToolbarProps {
|
interface ToolbarProps {
|
||||||
theme: number,
|
theme: number,
|
||||||
@ -11,10 +11,12 @@ interface ToolbarProps {
|
|||||||
|
|
||||||
function styles_(props:ToolbarProps) {
|
function styles_(props:ToolbarProps) {
|
||||||
return buildStyle('AceEditorToolbar', props.theme, (/* theme:any*/) => {
|
return buildStyle('AceEditorToolbar', props.theme, (/* theme:any*/) => {
|
||||||
|
const theme = themeStyle(props.theme);
|
||||||
return {
|
return {
|
||||||
root: {
|
root: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
marginBottom: 0,
|
marginBottom: 0,
|
||||||
|
borderTop: `1px solid ${theme.dividerColor}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -381,6 +381,7 @@ const TinyMCE = (props:NoteBodyEditorProps, ref:any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tox .tox-editor-header {
|
.tox .tox-editor-header {
|
||||||
|
border-top: 1px solid ${theme.dividerColor};
|
||||||
border-bottom: 1px solid ${theme.dividerColor};
|
border-bottom: 1px solid ${theme.dividerColor};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ const NoteRevisionViewer = require('../NoteRevisionViewer.min');
|
|||||||
const TagList = require('../TagList.min.js');
|
const TagList = require('../TagList.min.js');
|
||||||
|
|
||||||
function NoteEditor(props: NoteEditorProps) {
|
function NoteEditor(props: NoteEditorProps) {
|
||||||
const theme = themeStyle(props.theme);
|
|
||||||
|
|
||||||
const [showRevisions, setShowRevisions] = useState(false);
|
const [showRevisions, setShowRevisions] = useState(false);
|
||||||
const [titleHasBeenManuallyChanged, setTitleHasBeenManuallyChanged] = useState(false);
|
const [titleHasBeenManuallyChanged, setTitleHasBeenManuallyChanged] = useState(false);
|
||||||
const [scrollWhenReady, setScrollWhenReady] = useState<ScrollOptions>(null);
|
const [scrollWhenReady, setScrollWhenReady] = useState<ScrollOptions>(null);
|
||||||
@ -391,6 +389,28 @@ function NoteEditor(props: NoteEditorProps) {
|
|||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderTagBar() {
|
||||||
|
return props.selectedNoteTags.length ? <TagList items={props.selectedNoteTags} /> : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTitleBar() {
|
||||||
|
const titleBarDate = <span style={styles.titleDate}>{time.formatMsToLocal(formNote.user_updated_time)}</span>;
|
||||||
|
return (
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
ref={titleInputRef}
|
||||||
|
placeholder={props.isProvisional ? _('Creating new %s...', formNote.is_todo ? _('to-do') : _('note')) : ''}
|
||||||
|
style={styles.titleInput}
|
||||||
|
onChange={onTitleChange}
|
||||||
|
onKeyDown={onTitleKeydown}
|
||||||
|
value={formNote.title}
|
||||||
|
/>
|
||||||
|
{titleBarDate}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const searchMarkers = useSearchMarkers(showLocalSearch, localSearchMarkerOptions, props.searches, props.selectedSearchId);
|
const searchMarkers = useSearchMarkers(showLocalSearch, localSearchMarkerOptions, props.searches, props.selectedSearchId);
|
||||||
|
|
||||||
const editorProps:NoteBodyEditorProps = {
|
const editorProps:NoteBodyEditorProps = {
|
||||||
@ -439,12 +459,6 @@ function NoteEditor(props: NoteEditorProps) {
|
|||||||
setShowRevisions(false);
|
setShowRevisions(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const tagStyle = {
|
|
||||||
marginBottom: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
const tagList = props.selectedNoteTags.length ? <TagList style={tagStyle} items={props.selectedNoteTags} /> : null;
|
|
||||||
|
|
||||||
if (showRevisions) {
|
if (showRevisions) {
|
||||||
const theme = themeStyle(props.theme);
|
const theme = themeStyle(props.theme);
|
||||||
|
|
||||||
@ -475,8 +489,6 @@ function NoteEditor(props: NoteEditorProps) {
|
|||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const titleBarDate = <span style={styles.titleDate}>{time.formatMsToLocal(formNote.user_updated_time)}</span>;
|
|
||||||
|
|
||||||
function renderSearchBar() {
|
function renderSearchBar() {
|
||||||
if (!showLocalSearch) return false;
|
if (!showLocalSearch) return false;
|
||||||
|
|
||||||
@ -509,19 +521,9 @@ function NoteEditor(props: NoteEditorProps) {
|
|||||||
return (
|
return (
|
||||||
<div style={styles.root} onDrop={onDrop}>
|
<div style={styles.root} onDrop={onDrop}>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
||||||
{tagList}
|
{renderTitleBar()}
|
||||||
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingBottom: 5, borderBottomWidth: 1, borderBottomColor: theme.dividerColor, borderBottomStyle: 'solid' }}>
|
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
||||||
{renderNoteToolbar()}
|
{renderNoteToolbar()}{renderTagBar()}
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
ref={titleInputRef}
|
|
||||||
placeholder={props.isProvisional ? _('Creating new %s...', formNote.is_todo ? _('to-do') : _('note')) : ''}
|
|
||||||
style={styles.titleInput}
|
|
||||||
onChange={onTitleChange}
|
|
||||||
onKeyDown={onTitleKeydown}
|
|
||||||
value={formNote.title}
|
|
||||||
/>
|
|
||||||
{titleBarDate}
|
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', flex: 1 }}>
|
<div style={{ display: 'flex', flex: 1 }}>
|
||||||
{editor}
|
{editor}
|
||||||
|
@ -84,32 +84,39 @@ function useToolbarItems(props:NoteToolbarProps) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (watchedNoteFiles.indexOf(note.id) >= 0) {
|
|
||||||
toolbarItems.push({
|
toolbarItems.push({
|
||||||
tooltip: _('Click to stop external editing'),
|
tooltip: _('Note properties'),
|
||||||
title: _('Watching...'),
|
iconName: 'fa-info-circle',
|
||||||
iconName: 'fa-external-link',
|
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
onButtonClick({ name: 'stopExternalEditing' });
|
dispatch({
|
||||||
|
type: 'WINDOW_COMMAND',
|
||||||
|
name: 'commandNoteProperties',
|
||||||
|
noteId: note.id,
|
||||||
|
onRevisionLinkClick: () => {
|
||||||
|
onButtonClick({ name: 'showRevisions' });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
toolbarItems.push({
|
|
||||||
tooltip: _('Edit in external editor'),
|
|
||||||
iconName: 'fa-external-link',
|
|
||||||
onClick: () => {
|
|
||||||
onButtonClick({ name: 'startExternalEditing' });
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
toolbarItems.push({
|
if (watchedNoteFiles.indexOf(note.id) >= 0) {
|
||||||
tooltip: _('Tags'),
|
// toolbarItems.push({
|
||||||
iconName: 'fa-tags',
|
// tooltip: _('Click to stop external editing'),
|
||||||
onClick: () => {
|
// title: _('Watching...'),
|
||||||
onButtonClick({ name: 'setTags' });
|
// iconName: 'fa-external-link',
|
||||||
},
|
// onClick: () => {
|
||||||
});
|
// onButtonClick({ name: 'stopExternalEditing' });
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
} else {
|
||||||
|
// toolbarItems.push({
|
||||||
|
// tooltip: _('Edit in external editor'),
|
||||||
|
// iconName: 'fa-external-link',
|
||||||
|
// onClick: () => {
|
||||||
|
// onButtonClick({ name: 'startExternalEditing' });
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
if (note.is_todo) {
|
if (note.is_todo) {
|
||||||
const item:any = {
|
const item:any = {
|
||||||
@ -128,17 +135,10 @@ function useToolbarItems(props:NoteToolbarProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toolbarItems.push({
|
toolbarItems.push({
|
||||||
tooltip: _('Note properties'),
|
tooltip: _('Tags'),
|
||||||
iconName: 'fa-info-circle',
|
iconName: 'fa-tags',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
dispatch({
|
onButtonClick({ name: 'setTags' });
|
||||||
type: 'WINDOW_COMMAND',
|
|
||||||
name: 'commandNoteProperties',
|
|
||||||
noteId: note.id,
|
|
||||||
onRevisionLinkClick: () => {
|
|
||||||
onButtonClick({ name: 'showRevisions' });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class ToolbarComponent extends React.Component {
|
|||||||
const theme = themeStyle(this.props.theme);
|
const theme = themeStyle(this.props.theme);
|
||||||
|
|
||||||
const style = Object.assign({
|
const style = Object.assign({
|
||||||
height: theme.toolbarHeight,
|
// height: theme.toolbarHeight,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
borderBottom: `1px solid ${theme.dividerColor}`,
|
borderBottom: `1px solid ${theme.dividerColor}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user