Adds a shortcut to insert the date and time.

Closes #521
pull/628/head
Abijeet 2018-06-16 20:46:27 +05:30
parent 553b086ba2
commit 07b85388fc
2 changed files with 30 additions and 7 deletions

View File

@ -155,7 +155,7 @@ class Application extends BaseApplication {
if (action.type == 'SETTING_UPDATE_ONE' && action.key == 'locale' || action.type == 'SETTING_UPDATE_ALL') {
setLocale(Setting.value('locale'));
// The bridge runs within the main process, with its own instance of locale.js
// so it needs to be set too here.
// so it needs to be set too here.
bridge().setLocale(Setting.value('locale'));
this.refreshMenu();
}
@ -334,7 +334,7 @@ class Application extends BaseApplication {
}
}, {
label: _('New notebook'),
accelerator: 'CommandOrControl+B',
accelerator: 'CommandOrControl+Shift+B',
screens: ['Main'],
click: () => {
this.dispatch({
@ -414,6 +414,17 @@ class Application extends BaseApplication {
name: 'textItalic',
});
},
}, {
label: _('Insert Date Time'),
screens: ['Main'],
visible: false,
accelerator: 'CommandOrControl+Shift+T',
click: () => {
this.dispatch({
type: 'WINDOW_COMMAND',
name: 'insertDateTime',
});
},
}, {
type: 'separator',
screens: ['Main'],

View File

@ -172,7 +172,7 @@ class NoteTextComponent extends React.Component {
}
}
return pos;
return pos;
}
mdToHtml() {
@ -557,8 +557,8 @@ class NoteTextComponent extends React.Component {
const letters = ['F', 'T', 'P', 'Q', 'L', ','];
for (let i = 0; i < letters.length; i++) {
const l = letters[i];
cancelledKeys.push('Ctrl+' + l);
cancelledKeys.push('Command+' + l);
cancelledKeys.push('Ctrl+' + l);
cancelledKeys.push('Command+' + l);
}
for (let i = 0; i < cancelledKeys.length; i++) {
@ -696,6 +696,8 @@ class NoteTextComponent extends React.Component {
this.commandTextBold();
} else if (command.name === 'textItalic') {
this.commandTextItalic();
} else if (command.name === 'insertDateTime' ) {
this.commandDateTime();
} else {
commandProcessed = false;
}
@ -858,6 +860,10 @@ class NoteTextComponent extends React.Component {
this.wrapSelectionWithStrings('*', '*', _('emphasized text'));
}
commandDateTime() {
this.wrapSelectionWithStrings(time.formatMsToLocal(new Date().getTime()));
}
commandTextCode() {
this.wrapSelectionWithStrings('`', '`');
}
@ -950,7 +956,7 @@ class NoteTextComponent extends React.Component {
tooltip: _('Hyperlink'),
iconName: 'fa-link',
onClick: () => { return this.commandTextLink(); },
});
});
toolbarItems.push({
tooltip: _('Code'),
@ -998,6 +1004,12 @@ class NoteTextComponent extends React.Component {
onClick: () => { return this.commandTextHorizontalRule(); },
});
toolbarItems.push({
tooltip: _('Insert Date Time'),
iconName: 'fa-calendar-plus-o',
onClick: () => { return this.commandDateTime(); },
});
toolbarItems.push({
type: 'separator',
});
@ -1214,7 +1226,7 @@ class NoteTextComponent extends React.Component {
editorProps={{$blockScrolling: true}}
// This is buggy (gets outside the container)
highlightActiveLine={false}
highlightActiveLine={false}
/>
return (