Code review comments

pull/5302/head
Roman 2021-08-14 21:01:03 +01:00
parent 305d0ffc49
commit ecf718005d
3 changed files with 9 additions and 11 deletions

View File

@ -29,6 +29,7 @@ const Menu = bridge().Menu;
const MenuItem = bridge().MenuItem;
const { substrWithEllipsis } = require('@joplin/lib/string-utils');
const { ALL_NOTES_FILTER_ID } = require('@joplin/lib/reserved-ids');
const { clipboard } = require('electron');
const logger = Logger.create('Sidebar');
@ -331,8 +332,7 @@ class SidebarComponent extends React.Component<Props, State> {
menu.append(
new MenuItem({
label: _('Copy notebook URL'),
click: async () => {
const { clipboard } = require('electron');
click: () => {
clipboard.writeText(getFolderUrl(itemId));
},
})
@ -346,8 +346,7 @@ class SidebarComponent extends React.Component<Props, State> {
menu.append(
new MenuItem({
label: _('Copy tag URL'),
click: async () => {
const { clipboard } = require('electron');
click: () => {
clipboard.writeText(getTagUrl(itemId));
},
})

View File

@ -15,6 +15,7 @@ const MenuItem = bridge().MenuItem;
import Note from '@joplin/lib/models/Note';
import Setting from '@joplin/lib/models/Setting';
const { substrWithEllipsis } = require('@joplin/lib/string-utils');
const { clipboard } = require('electron');
interface ContextMenuProps {
notes: any[];
@ -123,7 +124,6 @@ export default class NoteListUtils {
new MenuItem({
label: _('Copy Markdown link'),
click: async () => {
const { clipboard } = require('electron');
const links = [];
for (let i = 0; i < noteIds.length; i++) {
const note = await Note.load(noteIds[i]);
@ -138,8 +138,7 @@ export default class NoteListUtils {
menu.append(
new MenuItem({
label: _('Copy note URL'),
click: async () => {
const { clipboard } = require('electron');
click: () => {
clipboard.writeText(getNoteUrl(noteIds[0]));
},
})

View File

@ -16,16 +16,16 @@ export function getTagUrl(tagId: string) {
export type Command = 'openNote' | 'openFolder' | 'openTag';
export interface UlrInfo {
export interface CallbackUrlInfo {
command: Command;
params: any;
params: Record<string, string>;
}
export function parseUrl(s: string): UlrInfo {
export function parseUrl(s: string): CallbackUrlInfo {
if (!s.startsWith('joplin://')) return null;
const url = new URL(s);
const params: any = {};
const params: Record<string, string> = {};
for (const [key, value] of url.searchParams) {
params[key] = value;
}