Added shortcuts for typing current date and time - #944
Conversation
🤖 Augment PR SummarySummary: Adds rich-text editor shortcuts to quickly insert the current date or time via Changes:
Technical Notes: Time insertion is formatted as 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
Adds @today/@date and @now/@time typing shortcuts to Ghostwriter rich-text editors, backed by server-provided date formatting (Django DATE_FORMAT) and a lightweight refresh mechanism to keep long-lived editor sessions current.
Changes:
- Added Tiptap input rules to expand
@now/@time(UTC time) and@today/@date(server-formatted date) on whitespace/punctuation boundaries. - Added a server-provided date config + AJAX refresh endpoint and a small browser helper (
GW_EDITOR_SHORTCUTS) to keep “today” current past midnight. - Extended TinyMCE key handling and updated docs/UI help text; added Playwright coverage for shortcut logic and refresh behavior.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| javascript/tests/e2e/now_shortcut.spec.ts | Adds Playwright tests covering regex matching, input-rule replacement, config reading, and refresh behavior. |
| javascript/src/tiptap_gw/now_shortcut.ts | Implements Tiptap @now/@time + @today/@date input rules and reads server-configured current date. |
| javascript/src/tiptap_gw/index.ts | Registers the new Tiptap DateTimeShortcuts extension in the editor extension list. |
| ghostwriter/templates/snippets/editor_shortcuts_config.html | Injects JSON config for current date + loads editor_shortcuts.js. |
| ghostwriter/templates/base_generic.html | Includes the editor shortcuts config/snippet globally in the main base template. |
| ghostwriter/templates/base_generic_empty.html | Includes the editor shortcuts config/snippet globally in the “empty” base template variant. |
| ghostwriter/static/js/tinymce/config.js | Adds TinyMCE keydown expansion logic for @now/@time and @today/@date, with code/email boundary guards. |
| ghostwriter/static/js/editor_shortcuts.js | Implements window.GW_EDITOR_SHORTCUTS (current date + refresh scheduling/fetch). |
| ghostwriter/oplog/tests/test_views.py | Adds regression test asserting oplog help + date shortcut config are present in rendered output. |
| ghostwriter/oplog/templates/oplog/oplog_detail.html | Documents the new shortcuts in the Oplog help modal. |
| ghostwriter/home/views.py | Adds a login-protected, never-cached GET endpoint to refresh the server-formatted date config. |
| ghostwriter/home/urls.py | Wires the new /ajax/editor-shortcuts/date endpoint. |
| ghostwriter/home/tests/test_views.py | Adds tests for login requirement, response payload, cache headers, and method restriction. |
| ghostwriter/home/editor_shortcuts.py | Generates the server date config (date string, expiry at next midnight, server time, refresh URL). |
| ghostwriter/context_processors.py | Exposes EDITOR_SHORTCUTS_DATE_CONFIG in template context. |
| ghostwriter/commandcenter/templates/user_extra_fields/admin_change_form.html | Includes the shortcuts config/snippet in the admin change form template. |
| DOCS/features/reporting/collaborative-editor/editor-features.mdx | Documents shortcut usage/behavior in collaborative editor docs. |
| DOCS/features/operation-logs/create-a-new-entry.mdx | Adds a tip callout describing the shortcuts for rich-text fields. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #944 +/- ##
==========================================
+ Coverage 93.91% 93.93% +0.02%
==========================================
Files 429 431 +2
Lines 31891 31992 +101
==========================================
+ Hits 29951 30053 +102
+ Misses 1940 1939 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 28 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
ghostwriter/static/js/tinymce/config.js:288
- The fallback for Unicode property escapes currently catches all errors, which could mask unrelated failures (e.g., if the RegExp constructor throws for a different reason). This should only fall back on SyntaxError and rethrow anything else (matching the behavior of the TipTap implementation).
function gwCreateShortcutBoundaryPattern() {
try {
return new RegExp('^(?:\\s|\\p{P})$', 'u');
} catch (error) {
return /^(?:\s|[\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e])$/;
This adds the following shortcuts:
@now/@timeinsertsHH:mm:ss UTC@today/@dateinserts the date using Django’s configuredDATE_FORMAT