Skip to content

Commit

Permalink
feat: double click to open current periodic note
Browse files Browse the repository at this point in the history
  • Loading branch information
linyibing committed Mar 30, 2024
1 parent b9b8a30 commit a02aa54
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
32 changes: 29 additions & 3 deletions src/component/CreateNote/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useApp } from '../../hooks/useApp';
import { Notice } from 'obsidian';
import {
Expand Down Expand Up @@ -142,6 +142,7 @@ export const CreateNote = (props: { width: number }) => {

setTagOptions(filteredOptions);
};
const singleClickRef = useRef<number | null>(null);
const handleTagInput = (item: string) => {
const itemTag = form.getFieldValue(`${item}Tag`).replace(/^#/, '');
const itemFolder = itemTag.replace(/\//g, '-');
Expand Down Expand Up @@ -224,7 +225,23 @@ export const CreateNote = (props: { width: number }) => {
<Tabs
key={PERIODIC}
activeKey={periodicActiveTab}
onChange={setPeriodicActiveTab}
onTabClick={(key) => {
if (singleClickRef.current) {
clearTimeout(singleClickRef.current);
createPeriodicFile(
dayjs(new Date()),
key,
settings.periodicNotesPath,
app
);
singleClickRef.current = null;
} else {
singleClickRef.current = window.setTimeout(() => {
setPeriodicActiveTab(key);
singleClickRef.current = null;
}, 200);
}
}}
centered
size="small"
indicator={{ size: 0 }}
Expand All @@ -244,7 +261,16 @@ export const CreateNote = (props: { width: number }) => {
const label = localeMap[periodic];

return {
label,
label: (
<Tooltip
mouseEnterDelay={1}
title={`${
localeMap.QUICK_JUMP
}${label.toLocaleLowerCase()}`}
>
{label}
</Tooltip>
),
key: periodic,
children: (
<Form.Item name={periodic}>
Expand Down
6 changes: 4 additions & 2 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const EN = {
[FOLDER]: 'Folder',
[INDEX]: 'Index',

QUICK_JUMP: 'Double click to open periodic note for this ',
[`${TAG}ToolTip`]:
'Tags in PARA notes serve as the unique identifiers for indexing tasks, notes, and files',
[`${FOLDER}ToolTip`]:
Expand All @@ -58,8 +59,7 @@ const EN = {
[`${ERROR_MESSAGE}FAILED_DATAVIEW_API`]: 'Dataview API enable failed!',
[`${ERROR_MESSAGE}NO_VIEW_PROVIDED`]:
'Please provide the name of the view you want to query!',
[`${ERROR_MESSAGE}NO_VIEW_EXISTED`]:
'There is no this view in LifeOS plugin',
[`${ERROR_MESSAGE}NO_VIEW_EXISTED`]: 'There is no this view in LifeOS plugin',
[`${ERROR_MESSAGE}NO_INDEX_FILE_EXIST`]:
'There is no Index file exists(README.md/xxx.README.md/the same as the name of the folder it resides in)',
[`${ERROR_MESSAGE}NO_TEMPLATE_EXIST`]: 'There is no template file exist',
Expand Down Expand Up @@ -95,6 +95,8 @@ const ZH = {
[TAG]: '标签',
[FOLDER]: '目录',
[INDEX]: '索引',

QUICK_JUMP: '双击打开本周期的',
[`${TAG}ToolTip`]: 'PARA 笔记的标签,作为索引任务、记录、文件的唯一标识',
[`${FOLDER}ToolTip`]: 'PARA 笔记所在的文件夹,用于存放对应主题的笔记',
[`${INDEX}ToolTip`]:
Expand Down

0 comments on commit a02aa54

Please sign in to comment.