一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
44 行
1.6 KiB
TypeScript
44 行
1.6 KiB
TypeScript
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
|
import { _ } from '@joplin/lib/locale';
|
|
import { stateUtils } from '@joplin/lib/reducer';
|
|
import Note from '@joplin/lib/models/Note';
|
|
import Folder from '@joplin/lib/models/Folder';
|
|
import { createAppDefaultWindowState } from '../app.reducer';
|
|
import Setting from '@joplin/lib/models/Setting';
|
|
import { getDisplayParentId } from '@joplin/lib/services/trash';
|
|
import { ALL_NOTES_FILTER_ID } from '@joplin/lib/reserved-ids';
|
|
|
|
export const declaration: CommandDeclaration = {
|
|
name: 'openNoteInNewWindow',
|
|
label: () => _('Open in new window'),
|
|
iconName: 'icon-share',
|
|
};
|
|
|
|
let idCounter = 0;
|
|
|
|
export const runtime = (): CommandRuntime => {
|
|
return {
|
|
execute: async (context: CommandContext, noteId: string = null) => {
|
|
noteId = noteId || stateUtils.selectedNoteId(context.state);
|
|
|
|
const note = await Note.load(noteId, { fields: Note.previewFields() });
|
|
const parentFolder = await Folder.load(note.parent_id);
|
|
let folderId = note.is_conflict && !note.deleted_time ? Folder.conflictFolderId() : getDisplayParentId(note, parentFolder);
|
|
if (!note.is_conflict && !note.deleted_time && !parentFolder) folderId = ALL_NOTES_FILTER_ID;
|
|
context.dispatch({
|
|
type: 'WINDOW_OPEN',
|
|
noteId,
|
|
folderId,
|
|
windowId: `window-${noteId}-${idCounter++}`,
|
|
defaultAppWindowState: {
|
|
...createAppDefaultWindowState(),
|
|
notes: [note],
|
|
noteVisiblePanes: Setting.value('noteVisiblePanes'),
|
|
editorCodeView: Setting.value('editor.codeView'),
|
|
},
|
|
});
|
|
},
|
|
enabledCondition: 'oneNoteSelected',
|
|
};
|
|
};
|