diff --git a/README.md b/README.md index b23a354..aac6c15 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A text block timing tool designed for Obsidian, allowing you to add a **count-up ## Features -![Demo](https://github.com/wth461694678/text-block-timer/blob/main/demo.gif) +![Demo](https://github.com/wth461694678/text-block-timer/blob/main/demo/demo.gif) - Add timers to any text line, supporting multiple timers running simultaneously (stopwatch function). - ▶️/⏸️ Start, pause, and resume timing for tasks. @@ -22,14 +22,14 @@ A text block timing tool designed for Obsidian, allowing you to add a **count-up 2. When the cursor is on a text block, press the shortcut key to start, pause, or resume. 3. The timer will be displayed in the format `【⏳00:00:00 】` at the beginning of the text line. -![Command Shortcut](https://github.com/wth461694678/text-block-timer/blob/main/command_shortcut.gif) +![Command Shortcut](https://github.com/wth461694678/text-block-timer/blob/main/demo/command_shortcut.gif) ### 2. Mouse Operations 1. Right-click on a text line. 2. Select "Start Timer," "Pause Timer," or "Resume Timer." -![Right Click](https://github.com/wth461694678/text-block-timer/blob/main/right_click.gif) +![Right Click](https://github.com/wth461694678/text-block-timer/blob/main/demo/right_click.gif) ## Custom Settings @@ -41,22 +41,22 @@ Users can freely choose whether to continue the timing after closing the file or #### 1.1 never stops unless the user stops manually After a user closes a file or exits Obsidian, the timer will still "time in the background". When the file is opened next time, the time spent during the closure period will be counted as the timer time and the timing will automatically resume. - + #### 1.2 auto-stop only when exiting Obsidian. Background timing continues when closing files (recommended, default option) After the user closes a file, the timer will still "time in the background". When the file is opened next time, the time spent during the closing period will be counted as the timer time and the timing will automatically resume. However, once the user exits Obsidian, all timers will stop immediately to prevent significant data errors caused by the user forgetting to manually close the timers. - + #### 1.3 auto-stop immediately when closing a file After the user closes a file, all timers will stop immediately. However, if a file is closed by mistake, it may cause the timer to pause. - + ### 2. Timer insert position Users can choose to insert a timer label either before or after the text block. - + ## Version Log: diff --git a/README.zh.md b/README.zh.md index 877e642..1026c57 100644 --- a/README.zh.md +++ b/README.zh.md @@ -6,7 +6,7 @@ ## 功能特性 - + - 为任意文本行添加计时器,支持同时执行多个计时器(正计时) - ▶️/⏸️ 支持开始、暂停、继续计时,支持任务分段耗时累计 @@ -21,13 +21,13 @@ 1. 为命令 "Text Block Timer: Toggle timer" 配置快捷键,方便快速使用 2. 当光标在某个文本块时,按下快捷键,即可实现timer的开始、暂停、继续操作 3. 计时器会以 `【⏳00:00:00 】`格式显示在文本块的行首 - + ### 2. 鼠标操作 1. 在文本行上右键点击 2. 选择"开始计时"、"暂停计时"或"继续计时" - + ## 自定义设置 @@ -39,23 +39,23 @@ #### 1.1 从不停止,除非用户手动停止 用户关闭文件、退出Obsidian后,计时器依然会“后台计时”,在下次打开文件时,会讲关闭期间的耗时计入计时器耗时,并自动恢复计时。 - + #### 1.2 仅退出Obsidian时停止,关闭文件依然后台计时(推荐,默认选项) 用户关闭文件后,计时器依然会“后台计时”,在下次打开文件时,会讲关闭期间的耗时计入计时器耗时,并自动恢复计时。 然而,用户退出Obsidian后,所有计时器会立即停止,防止用户忘记手动关闭计时器导致数据产生重大误差。 - + #### 1.3 关闭文件时立即停止 用户关闭文件后,所有计时器会立即停止,但在误关文件时,可能导致计时暂停。 - + ### 2. 插入位置 用户可以选择在文本块的前面或后面插入计时器标签。 - + ## 版本日志: diff --git a/command_shortcut.gif b/demo/command_shortcut.gif similarity index 100% rename from command_shortcut.gif rename to demo/command_shortcut.gif diff --git a/demo.gif b/demo/demo.gif similarity index 100% rename from demo.gif rename to demo/demo.gif diff --git a/insert_position.png b/demo/insert_position.png similarity index 100% rename from insert_position.png rename to demo/insert_position.png diff --git a/right_click.gif b/demo/right_click.gif similarity index 100% rename from right_click.gif rename to demo/right_click.gif diff --git a/settings_close.gif b/demo/settings_close.gif similarity index 100% rename from settings_close.gif rename to demo/settings_close.gif diff --git a/settings_never.gif b/demo/settings_never.gif similarity index 100% rename from settings_never.gif rename to demo/settings_never.gif diff --git a/settings_quit.gif b/demo/settings_quit.gif similarity index 100% rename from settings_quit.gif rename to demo/settings_quit.gif diff --git a/main.js b/main.js index d6153e5..f31dd2c 100644 --- a/main.js +++ b/main.js @@ -62,7 +62,7 @@ class TimerManager { if (this.timers.has(timerId)) return; const id = setInterval(() => tickCallback(timerId), UPDATE_INTERVAL); this.timers.set(timerId, id); - console.log('start timerId:', timerId); + // console.log('start timerId:', timerId); } stop(timerId) { @@ -70,7 +70,7 @@ class TimerManager { if (id) { clearInterval(id); this.timers.delete(timerId); - console.log('stop timerId:', timerId); + // console.log('stop timerId:', timerId); } } @@ -463,27 +463,27 @@ class TimerPlugin extends obsidian.Plugin { if (olcheckboxLen > 0) { var textleft textleft = lineText.slice(olcheckboxLen); - console.log('textleft after olcheckbox:', textleft); + // console.log('textleft after olcheckbox:', textleft); before = after = olcheckboxLen; } else if (ulcheckboxLen > 0) { var textleft textleft = lineText.slice(ulcheckboxLen); - console.log('textleft after checkbox:', textleft); + // console.log('textleft after checkbox:', textleft); before = after = ulcheckboxLen; } else if (orderedListLen > 0) { var textleft textleft = lineText.slice(orderedListLen); - console.log('textleft after ol:', textleft); + // console.log('textleft after ol:', textleft); before = after = orderedListLen; } else if (ulLen > 0) { var textleft textleft = lineText.slice(ulLen); - console.log('textleft after ul:', textleft); + // console.log('textleft after ul:', textleft); before = after = ulLen; } else if (headerLen > 0) { var textleft textleft = lineText.slice(headerLen); - console.log('textleft after header:', textleft); + // console.log('textleft after header:', textleft); before = after = headerLen; } else { before = after = 0; @@ -497,7 +497,7 @@ class TimerPlugin extends obsidian.Plugin { editor.replaceRange( newSpan, { line: lineNum, ch: before }, { line: lineNum, ch: after } ); - console.log('lineNum:', lineNum, 'before:', before, 'after:', after); + // console.log('lineNum:', lineNum, 'before:', before, 'after:', after); return data.timerId; } @@ -553,7 +553,7 @@ class TimerPlugin extends obsidian.Plugin { this.handleRestore(parsed, editor, i); } else if (this.settings.autoStopTimers === 'quit') { // 对于状态为Running且timerId不在this.manager中的计时器,如果计时器的本次启动时间 等于 当前插件启动时间,则继续,否则强行暂停 - console.log('PLT:', parsed.PLT, 'pluginLoadTime:', this.pluginLoadTime); + // console.log('PLT:', parsed.PLT, 'pluginLoadTime:', this.pluginLoadTime); if (parsed.PLT === this.pluginLoadTime) { this.handleRestore(parsed, editor, i); } else {