mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixed global create new day note
This commit is contained in:
parent
c3b44b9a91
commit
72cc54a83f
@ -71,7 +71,7 @@ import bundleService from "./services/bundle.js";
|
|||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
require('electron').ipcRenderer.on('globalShortcut', async function(event, actionName) {
|
require('electron').ipcRenderer.on('globalShortcut', async function(event, actionName) {
|
||||||
keyboardActionService.triggerAction(actionName);
|
appContext.triggerCommand(actionName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import appContext from "./app_context.js";
|
|||||||
import Component from "../widgets/component.js";
|
import Component from "../widgets/component.js";
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import noteCreateService from "./note_create.js";
|
import noteCreateService from "./note_create.js";
|
||||||
|
import ws from "./ws.js";
|
||||||
|
|
||||||
export default class Entrypoints extends Component {
|
export default class Entrypoints extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -65,18 +66,18 @@ export default class Entrypoints extends Component {
|
|||||||
async createNoteIntoDayNoteCommand() {
|
async createNoteIntoDayNoteCommand() {
|
||||||
const todayNote = await dateNoteService.getTodayNote();
|
const todayNote = await dateNoteService.getTodayNote();
|
||||||
|
|
||||||
const {note} = await server.post(`notes/${todayNote.noteId}/children?target=into`, {
|
const {note} = await noteCreateService.createNote(todayNote.noteId, {
|
||||||
title: 'new note',
|
isProtected: todayNote.isProtected,
|
||||||
content: '',
|
|
||||||
type: 'text',
|
type: 'text',
|
||||||
isProtected: todayNote.isProtected
|
title: 'new note',
|
||||||
|
content: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
await treeService.expandToNote(note.noteId);
|
await ws.waitForMaxKnownSyncId();
|
||||||
|
|
||||||
const tabContext = await appContext.tabManager.openTabWithNote(note.noteId, true);
|
await appContext.tabManager.openTabWithNote(note.noteId, false);
|
||||||
|
|
||||||
appContext.triggerCommand('focusAndSelectTitle');
|
appContext.triggerEvent('focusAndSelectTitle');
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleNoteHoistingCommand() {
|
async toggleNoteHoistingCommand() {
|
||||||
@ -137,6 +138,7 @@ export default class Entrypoints extends Component {
|
|||||||
|
|
||||||
backInNoteHistoryCommand() {
|
backInNoteHistoryCommand() {
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
|
// standard JS version does not work completely correctly in electron
|
||||||
const webContents = require('electron').remote.getCurrentWebContents();
|
const webContents = require('electron').remote.getCurrentWebContents();
|
||||||
const activeIndex = parseInt(webContents.getActiveIndex());
|
const activeIndex = parseInt(webContents.getActiveIndex());
|
||||||
|
|
||||||
@ -149,6 +151,7 @@ export default class Entrypoints extends Component {
|
|||||||
|
|
||||||
forwardInNoteHistoryCommand() {
|
forwardInNoteHistoryCommand() {
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
|
// standard JS version does not work completely correctly in electron
|
||||||
const webContents = require('electron').remote.getCurrentWebContents();
|
const webContents = require('electron').remote.getCurrentWebContents();
|
||||||
const activeIndex = parseInt(webContents.getActiveIndex());
|
const activeIndex = parseInt(webContents.getActiveIndex());
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
await ws.waitForMaxKnownSyncId();
|
await ws.waitForMaxKnownSyncId();
|
||||||
|
|
||||||
await appContext.tabManager.getActiveTabContext().setNote(notePath);
|
await appContext.tabManager.getActiveTabContext().setNote(notePath);
|
||||||
appContext.triggerCommand('focusAndSelectTitle');
|
appContext.triggerEvent('focusAndSelectTitle');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,16 +66,6 @@ function setElementActionHandler($el, actionName, handler) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function triggerAction(actionName) {
|
|
||||||
const action = await getAction(actionName);
|
|
||||||
|
|
||||||
if (!action.handler) {
|
|
||||||
throw new Error(`Action ${actionName} has no handler`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await action.handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getAction(actionName, silent = false) {
|
async function getAction(actionName, silent = false) {
|
||||||
await keyboardActionsLoaded;
|
await keyboardActionsLoaded;
|
||||||
|
|
||||||
@ -119,8 +109,6 @@ function updateDisplayedShortcuts($container) {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
setElementActionHandler,
|
setElementActionHandler,
|
||||||
triggerAction,
|
|
||||||
getAction,
|
|
||||||
updateDisplayedShortcuts,
|
updateDisplayedShortcuts,
|
||||||
setupActionsForElement,
|
setupActionsForElement,
|
||||||
getActionsForScope
|
getActionsForScope
|
||||||
|
@ -18,7 +18,7 @@ export default class LoadResults {
|
|||||||
this.options = [];
|
this.options = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
addNote(noteId, sourceId) {console.log("Adding", noteId, sourceId);
|
addNote(noteId, sourceId) {
|
||||||
this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || [];
|
this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || [];
|
||||||
|
|
||||||
if (!this.noteIdToSourceId[noteId].includes(sourceId)) {
|
if (!this.noteIdToSourceId[noteId].includes(sourceId)) {
|
||||||
|
@ -70,7 +70,7 @@ export default class NoteTitleWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
focusAndSelectTitleCommand() {
|
focusAndSelectTitleEvent() {
|
||||||
if (this.tabContext && this.tabContext.isActive()) {
|
if (this.tabContext && this.tabContext.isActive()) {
|
||||||
this.$noteTitle
|
this.$noteTitle
|
||||||
.trigger('focus')
|
.trigger('focus')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user