...
 
Commits (11)
    https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/1851cdc458ece532c3aac01814f9b73675c8c871 doc 2023-05-28T18:14:05+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/c328ab2ed5c7147018c96aabaa9c8c9c14bef420 UI 提醒 2023-05-28T18:33:37+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/ffbcc8a7dad1b9b97851466b4ae30867e7f631c1 README 2023-05-28T18:41:36+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/43569532dc1230593eb8556a327d1167f3e30a3c 临时使用一下图床 2023-05-28T20:28:42+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/ea2bd27a676b6de4ff56e448ced17cd182552603 增加明后天匹配 2023-05-29T00:51:52+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/665167e5d468d00a3707968332872601c10e09b1 图片链接 2023-05-29T01:01:21+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/0058d4680831f9bdf6d6b5247a104595283d985d 更新介绍 2023-05-29T01:20:35+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/fac7d53dc347d0a2e315e49fcd36e2f0aecc1b61 style: log 2023-05-29T01:25:58+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/d27932363030706fce6cfcd03b3d6f1d69b4c00a Merge pull request #69 from frostime/dev 2023-05-29T01:29:21+08:00 Frostime frostime@foxmail.com 增加了「明后天」日期匹配以及去掉了一些多余的日志 https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/17d1cedcdb570796eed818c77d172dfd39e785e0 imgbed 2023-05-29T09:33:02+08:00 frostime frostime@foxmail.com https://gitcode.net/frostime/siyuan-plugin-daily-note/-/commit/cc2246b68882f235e6f8408d6875e8b1430ab8de readme 2023-05-29T09:33:42+08:00 frostime frostime@foxmail.com
......@@ -82,17 +82,22 @@
1. 点击块,选择「预约此块」
![](asset/Reserve1.png)
<!-- ![](asset/Reserve1.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/69479868c4da8344.png)
2. 插件会自动匹配块内容中的日期时间,确定后,插件会帮你把这份预约记录下来
被匹配到的时间会在确认对话框中高亮显示;。如下图所示, 插件匹配到了 `6月01号`, 并解析为 `2023-06-01`。
![](asset/Reserve2.png)
<!-- ![](asset/Reserve2.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/2a30bad068dc534f.png)
3. 等到当天的时候,插件在自动创建完日记后,会帮你把相关的预约以嵌入块的形式插入日记中
![](asset/Reserve3.png)
<!-- ![](asset/Reserve3.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/f10c726b06042635.png)
4. 如果你发现预约的嵌入块没有自动插入,可以点击图标菜单中的「更新」按钮更新文档
#### 注意
......@@ -101,11 +106,12 @@
3. 目前支持的日期匹配规则有限,只有:
- 标准年月日: `2020-04-01`, `2020/04/01`
- 中文年月日: `2020年5月2号`, `2020年5月2日`
- 明后天: `明天`, `后天`, `大后天`
- 日期之间可以有空格: `2020年5月2号``2020 年 5 月 2 号`都是可以的
- 月份和日期可以加 0: `6月01日` , `06月01日`, `6月1日` 都是可以的
- 可以不写年份, 这样默认会认为是同一年: 例如在 23 年的某一天, 写下的 `9月8号` 会被认为是 `2023-09-08`
- 不可以写过去
- 如果有多个合规范的日期, 那么只有第一个会被匹配
- 如果有多个合规范的日期, 那么只有第一个会被匹配
4. 此功能**默认关闭**,请在手动在设置中开启
### 5. 移动块到今天的 Daily Note 中
......
......@@ -78,17 +78,24 @@ You can think of the reservation block as a simple schedule management or task r
1. Click the block and select "Reserve this block".
![](asset/Reserve1.png)
<!-- ![](asset/Reserve1.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/69479868c4da8344.png)
2. The plugin will automatically match the date and time in the block content, and after confirmation, the plugin will help you record the reservation.
The matched time will be highlighted in the confirmation dialog;. As you can see below, the plug-in matches `6月01号` and resolves to `2023-06-01`.
> `6月01号` is the date representative in chinese.
![](asset/Reserve2.png)
4. When the day arrives, the plugin will automatically insert the related reservations as embedded blocks into the diary entry.
<!-- ![](asset/Reserve2.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/2a30bad068dc534f.png)
3. When the day arrives, the plugin will automatically insert the related reservations as embedded blocks into the diary entry.
<!-- ![](asset/Reserve3.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/f10c726b06042635.png)
![](asset/Reserve3.png)
4. If you find that the embedded block for the reservation is not inserted automatically, you can update the document by clicking on the 'Update' button in the icon menu
### Notice
......
......@@ -9,8 +9,8 @@
"version": "1.1.0",
"minAppVersion": "2.8.9",
"description": {
"zh_CN": "1. 启动思源笔记之后,自动开启今天的笔记\n2. 工具栏提供下拉框,快速查看今天的笔记并打开\n3. 点开块菜单, 可以将块移动到别的笔记文档下",
"en_US": "1. After starting siyuan-note, automatically open today's notes\n2. The toolbar provides a drop-down box to quickly view today's notes and open them\n3. Click to open the block menu, you can move the block to daily note under another notebook"
"zh_CN": "自动创建日记 + 快速打开日记 + 今日 TODO 管理 + 移动块功能",
"en_US": "Automatically open today's notes + Quickly open today's notes + TODO mangagement for today + Move blocks"
},
"readme": {
"zh_CN": "README.md",
......
......@@ -29,7 +29,7 @@ let clickEvent: any;
const DatePatternRules = [
{
pattern: /(?:(?<year>\d{4})[ ]?[-年/])?(?:[ ]?(?<month>\d{1,2})[ ]?[-月/])[ ]?(?<day>\d{1,2})[ ]?[日号]?/,
parse(match: RegExpMatchArray) {
parse(match: RegExpMatchArray): [string, string, string] {
console.log(match);
let year = match.groups.year;
let month = match.groups.month;
......@@ -38,10 +38,29 @@ const DatePatternRules = [
let today = new Date();
year = today.getFullYear().toString();
}
console.log(year, month, day);
return [year, month, day];
}
},
{
pattern: /(?<prefix>明|大?)天/,
parse(match: RegExpMatchArray): [string, string, string] {
console.log(match);
let today = new Date();
if (match.groups.prefix === '') {
today.setDate(today.getDate() + 1);
} else if (match.groups.prefix === '') {
today.setDate(today.getDate() + 2);
} else if (match.groups.prefix === '大后') {
today.setDate(today.getDate() + 3);
}
let year = today.getFullYear().toString();
let month = (today.getMonth() + 1).toString();
let day = today.getDate().toString();
return [year, month, day];
}
}
// /(?<next>下个?)?(?:周|星期)(?<day>[一二三四五六七日])/
// /(?<month>[一二三四五六七八九]|十[一二])\s*月\s*(?<day>[一二三四五六七八九十]|二?十[一二三四五六七八九]|三十一?)\s*[日号]/
]
//后面会用来替代原来的菜单组件
......@@ -145,6 +164,7 @@ export class GutterMenu {
console.log(blockId, date);
reservation.doReserve(date, blockId);
reservation.save();
showMessage(`${i18n.ReserveMenu.Success} ${date.toLocaleDateString()}`, 3000, 'info');
}
}
......
......@@ -21,7 +21,7 @@ export class ContextMenu {
bindMenuOnCurrentTabs() {
//每个 Tab 标签页都绑定了一个 gutter
let gutters: NodeListOf<Element> = document.querySelectorAll('div.protyle-gutters');
info(`监听当前的 ${gutters.length} 个 Tab 标签上的 gutter`);
// info(`监听当前的 ${gutters.length} 个 Tab 标签上的 gutter`);
for (let g of gutters) {
// info(`监听 Tab ${g.parentElement?.getAttribute('data-id')}`);
g.addEventListener('contextmenu', gutterContextMenuEventObj);
......@@ -30,7 +30,7 @@ export class ContextMenu {
releaseMenuOnCurrentTabs() {
let gutters: NodeListOf<Element> = document.querySelectorAll('div.protyle-gutters');
info(`解除监听当前的 ${gutters.length} 个 Tab 标签上的 gutter`);
// info(`解除监听当前的 ${gutters.length} 个 Tab 标签上的 gutter`);
for (let g of gutters) {
// info(`解除对 ${g.parentElement?.getAttribute('data-id')} 的监听`);
g.removeEventListener('contextmenu', gutterContextMenuEventObj);
......@@ -52,7 +52,7 @@ export class ContextMenu {
);
gutter?.addEventListener('contextmenu', gutterContextMenuEventObj);
let data_id = protyle.getAttribute('data-id');
info(`标签页发生变化, Add Listener to protyle-${data_id}`);
// info(`标签页发生变化, Add Listener to protyle-${data_id}`);
}
}
if (mutation.type == 'childList' && mutation.removedNodes.length) {
......@@ -64,7 +64,7 @@ export class ContextMenu {
);
gutter?.removeEventListener('contextmenu', gutterContextMenuEventObj);
let data_id = protyle.getAttribute('data-id');
info(`标签页发生变化 Del Listener of protyle-${data_id}`);
// info(`标签页发生变化 Del Listener of protyle-${data_id}`);
}
}
}
......@@ -81,7 +81,7 @@ export class ContextMenu {
removeEditorTabObserver() {
if (this.observer) {
info(`停止对 Tab 标签变化的监听`);
// info(`停止对 Tab 标签变化的监听`);
this.observer.disconnect();
}
}
......
......@@ -42,7 +42,7 @@ export async function moveBlocksToDailyNote(srcBlockId: string, notebook: Notebo
let ans = await serverApi.prependBlock(doc_id, '* ', 'markdown');
let newListId = ans[0].doOperations[0].id;
await serverApi.moveBlock(block.id, null, newListId);
console.log(`移动列表项 ${block.id} --> ${newListId}`);
info(`移动列表项 ${block.id} --> ${newListId}`);
//获取新的列表的子项
let allChild = await serverApi.getChildBlocks(newListId);
let blankItem = allChild[1]; // 上述行为会导致出现一个额外的多余列表项
......@@ -220,7 +220,7 @@ export async function initTodayReservation(notebook: Notebook) {
while (retry < MAX_RETRY) {
//插件自动创建日记的情况下可能会出现第一次拿不到的情况, 需要重试几次
let docs = await getDocsByHpath(todayDiaryPath!, notebook);
console.log(`In initResrv, retry: ${retry}, docs:`, docs);
info(`In initResrv, retry: ${retry}`);
if (docs[0]?.id !== undefined) {
docId = docs[0].id;
break;
......@@ -253,7 +253,7 @@ export async function updateDocReservation(docId: string, refresh: boolean = fal
let blocks = await serverApi.sql(sql);
if (blocks.length > 0) {
if (!refresh) {
console.log(`今日已经插入过预约了`);
info(`今日已经插入过预约了`);
return;
} else {
blockIDs = blockIDs.map((id) => `"${id}"`);
......
......@@ -152,7 +152,7 @@ class ReservationManger {
//添加预约
doReserve(date: Date, blockId: string) {
// YYYYMMDD
console.log(`预约: ${blockId}${date}`);
info(`预约: ${blockId}${date}`);
let date_str = this.dateTemplate(date);
if (!(date_str in this.reservations.OnDate)) {
this.reservations.OnDate[date_str] = [];
......
......@@ -6,11 +6,16 @@ Introducing the new feature in this version: the ability to reserve blocks. You
- Reserve This Block: Select a block and click on "Reserve" menu. If the block's content includes future dates, the block will be added to the reserve list.
![](asset/Reserve2.png)
![](https://cdn.jsdelivr.net/gh/frostime/siyuan-dailynote-today@1.1.0-dev3/asset/Reserve1.png)
<!-- ![](asset/Reserve2.png) -->
<!-- ![](https://s3.bmp.ovh/imgs/2023/05/28/69479868c4da8344.png) -->
![](https://cdn.jsdelivr.net/gh/frostime/siyuan-dailynote-today@1.1.0-dev3/asset/Reserve2.png)
- Automatic Insertion: On the day corresponding to the reserved date, the plug-in will automatically embed all reserved blocks for that day into the diary when creating today's notes.
![](asset/Reserve3.png)
<!-- ![](asset/Reserve3.png) -->
<!-- ![](https://s3.bmp.ovh/imgs/2023/05/28/f10c726b06042635.png) -->
![](https://cdn.jsdelivr.net/gh/frostime/siyuan-dailynote-today@1.1.0-dev3/asset/Reserve3.png)
Read the latest plugin documentation (README) for details of how to use it, which is still being worked on. This feature is disabled by default and should be turned on manually in the settings.
......
......@@ -2,17 +2,23 @@
### 新功能: 预约此块
隆重介绍这个版本推出的新功能: 预约日记功能。你可以把它理解为一个简单的 TODO 功能。
隆重介绍这个版本推出的新功能: **预约日记功能**。你可以把它理解为一个简单的 TODO 功能。
- 预约此块: 选中一个块, 并点击今日笔记的「预约」菜单,如果块中的内容包含有未来的日期,那么这个块就会加入预约列表中
![](asset/Reserve2.png)
<!-- ![](https://cdn.jsdelivr.net/gh/frostime/siyuan-dailynote-today@1.1.0-dev3/asset/Reserve1.png) -->
<!-- ![](asset/Reserve2.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/69479868c4da8344.png)
![](https://s3.bmp.ovh/imgs/2023/05/28/2a30bad068dc534f.png)
<!-- ![](https://cdn.jsdelivr.net/gh/frostime/siyuan-dailynote-today@1.1.0-dev3/asset/Reserve2.png) -->
- 自动插入: 当对应的日期到来的那一天, 插件会在创建当日的日记的时候, 自动把所有过去的预约块以嵌入块的形式插入到日记中
![](asset/Reserve3.png)
<!-- ![](asset/Reserve3.png) -->
![](https://s3.bmp.ovh/imgs/2023/05/28/f10c726b06042635.png)
<!-- ![](https://cdn.jsdelivr.net/gh/frostime/siyuan-dailynote-today@1.1.0-dev3/asset/Reserve3.png) -->
具体用法也阅读最新的插件文档 (README), 相关功能还在完善中。另外此功能默认关闭,请在手动在设置中开启
具体用法请阅读最新的插件文档 (README), 相关功能还在完善中。另外此功能**默认关闭,请在手动在设置中开启**
> 取名废, 如果你觉得这个功能有更好的命名, 欢迎来提 issue.
......
......@@ -61,7 +61,8 @@
"Title": "Reserve this block to",
"Date404": "No date time found for reserving!",
"DateInvalid": "is not a valid date!",
"DatePast": "Can not reserve for past time!"
"DatePast": "Can not reserve for past time!",
"Success": "Reservation success!"
},
"NewDay": [
"Today is ",
......
......@@ -61,7 +61,8 @@
"Title": "确认将目标块预约到",
"Date404": "没有找到可用于预约的日期!",
"DateInvalid": "不是一个合法的日期!",
"DatePast": "预约日期只能是未来!"
"DatePast": "预约日期只能是未来!",
"Success": "预约成功!"
},
"NewDay": [
"今天是",
......