fix(calendar) + feat(tasks): fix week start off-by-one & add due date with time support#271
Open
KrxkGit wants to merge 4 commits into
Open
fix(calendar) + feat(tasks): fix week start off-by-one & add due date with time support#271KrxkGit wants to merge 4 commits into
KrxkGit wants to merge 4 commits into
Conversation
Previously, only `modify`, `delete`, and `rename` vault events were registered. When a sync tool (e.g. Remotely Save) writes a brand-new file to the local vault, Obsidian fires a `create` event instead of `modify`, so the reminders inside that file were never scanned and the sidebar remained empty until the file was manually edited. Add a `create` event listener with the same logic as `modify`: reload reminders from the file and notify listeners if any were found.
使用 moment().day(n)(绝对星期几)替换 moment().weekday(n)(locale 相对偏移), 修复设置 Monday 为第一天时日历列头从 Tuesday 开始的错位问题。 Replace moment().weekday(n) with moment().day(n) (absolute weekday index) to fix the off-by-one error where setting Monday as the first day of week caused the calendar header to start from Tuesday instead of Monday. weekday() is locale-relative while day() is always absolute (0=Sun, 1=Mon...).
Add a toggleable 'Due Date With Time' option (off by default) for the Tasks plugin reminder format. When enabled and a specific time is selected, both the due date emoji and time emoji fields are written to the markdown, working around the Tasks plugin's lack of native time support so that the reminder sidebar can display the exact reminder time. Also fix setReminderFormatConfig not propagating config updates to static format instances, which caused editor-extension.ts to read stale config. 为 Tasks 插件格式新增「Due Date With Time」开关(默认关闭)。 开启后,选择具体时间时会同时写入日期和时间两个字段, 弥补 Tasks 插件原生不支持精确时间的限制,reminder 侧边栏可正确显示精确提醒时间。 同时修复了 setReminderFormatConfig 未同步更新各 format 静态实例 config 的问题。
fix: trigger (@) does not open date chooser on iOS 移除 buildCodeMirrorPlugin 注册时的 Platform.isDesktopApp 判断, 使 CodeMirror 6 扩展在移动端也能正常注册并响应输入触发。 date-chooser-modal.ts 已有移动端适配,弹窗在 iOS 上可正常工作。 Remove the Platform.isDesktopApp guard around buildCodeMirrorPlugin registration so the CodeMirror 6 extension is also registered on mobile. The date-chooser-modal already handles mobile layout via Platform.isDesktop, so the modal works correctly on iOS.
Owner
|
Thank you for the contribution. The calendar off-by-one analysis is correct and valuable —
Happy to review the split PRs once they're ready. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Summary / 概述
This PR contains two independent changes:
本 PR 包含两个独立改动:
1. fix(calendar): Correct week start day off-by-one error / 修复日历周起始日错位问题
Problem / 问题:
When the user sets "Monday" as the first day of the week, the calendar header incorrectly starts from Tuesday. This is caused by using
moment().weekday(n)(locale-relative offset) instead ofmoment().day(n)(absolute weekday index).当用户将「周起始日」设置为 Monday 时,日历列头从 Tuesday 开始,存在一天的偏移。原因是代码中混用了
moment().weekday(n)(locale 相对偏移)和moment().day(n)(绝对星期几索引)。Fix / 修复:
Replace all
moment().weekday(n)calls withmoment().day(n)inCalendar.svelteandcalendar.tsto ensure the week grid always aligns with the configured start day.将
Calendar.svelte和calendar.ts中的weekday(n)统一替换为day(n),确保日历网格始终与配置的起始日对齐。Files changed / 改动文件:
src/ui/Calendar.sveltesrc/ui/calendar.ts2. feat(tasks): Support due date with time for Tasks plugin format / 为 Tasks 插件格式新增精确时间支持
Background / 背景:
The Tasks plugin uses emoji-based fields (e.g.
📅 2024-01-01) for due dates but does not natively support a time component. This means when using the Tasks plugin format in obsidian-reminder, selecting a specific time via the date picker has no effect — the time is silently dropped and the reminder sidebar cannot show the exact reminder time.Tasks 插件使用 emoji 字段(如
📅 2024-01-01)记录截止日期,但原生不支持具体时间。因此在 obsidian-reminder 中使用 Tasks 插件格式时,通过日期选择器选择的具体时间会被丢弃,reminder 侧边栏也无法显示精确提醒时间。Solution / 方案:
Add a new toggle setting "Due Date With Time" (off by default) under the Tasks plugin format settings. When enabled, if the user selects a specific time, the reminder will write both the
📅 YYYY-MM-DDdue date field and the⏰ HH:mmtime field to the markdown. The reminder sidebar will then correctly display the exact reminder time.在 Tasks 插件格式设置中新增「Due Date With Time」开关(默认关闭)。开启后,若用户选择了具体时间,会同时向 markdown 写入
📅 YYYY-MM-DD日期字段和⏰ HH:mm时间字段,reminder 侧边栏可正确显示精确提醒时间。Also fixed / 附带修复:
setReminderFormatConfigwas not propagating config updates to static format instances, causingeditor-extension.tsto always read stale config (e.g.dueDateWithTimealwaysfalse).setReminderFormatConfig未将配置更新同步到各 format 静态实例,导致editor-extension.ts始终读取到旧配置(如dueDateWithTime始终为false)。Files changed / 改动文件:
src/model/format/reminder-tasks-plugin.tssrc/model/format/reminder-base.tssrc/model/format/index.tssrc/plugin/settings/index.tssrc/plugin/ui/editor-extension.tssrc/plugin/ui/date-chooser-modal.tssrc/ui/DateTimeChooser.svelteTesting / 测试
📅and⏰fields ✅📅date written ✅