Skip to content

Added shortcuts for typing current date and time - #944

Merged
chrismaddalena merged 19 commits into
masterfrom
feature/now-command
Jul 22, 2026
Merged

Added shortcuts for typing current date and time#944
chrismaddalena merged 19 commits into
masterfrom
feature/now-command

Conversation

@chrismaddalena

Copy link
Copy Markdown
Collaborator

This adds the following shortcuts:

  • @now / @time inserts HH:mm:ss UTC
  • @today / @date inserts the date using Django’s configured DATE_FORMAT
  • Spaces and unicode punctuation trigger the expansion
  • There are guards in place so code blocks and email-like strings do not trigger expansion
  • If an editor is left open over night, there is a trigger to refresh the date

Copilot AI review requested due to automatic review settings July 21, 2026 20:01
@augmentcode

augmentcode Bot commented Jul 21, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Adds rich-text editor shortcuts to quickly insert the current date or time via @today/@date and @now/@time.

Changes:

  • Introduced a server-provided “current date” config payload (formatted with Django’s DATE_FORMAT) and exposed it via a new authenticated, no-cache AJAX endpoint for refreshes.
  • Added a small frontend helper (editor_shortcuts.js) that reads the embedded JSON config, tracks server/client clock offset, and refreshes the date automatically at the next server-local midnight.
  • Implemented shortcut expansion in TinyMCE (keydown-driven token expansion) and in the Tiptap extension set (InputRules-based expansion) for both aliases.
  • Added guards so expansion triggers only on space/punctuation boundaries and avoids code/inline-code contexts and email-like strings.
  • Updated user-facing documentation/help text to describe the new shortcuts in operation logs and the collaborative editor docs.
  • Added Django view tests for the refresh endpoint and template exposure, plus Playwright coverage for the Tiptap shortcut behavior and date refresh logic.

Technical Notes: Time insertion is formatted as HH:mm:ss UTC, while date insertion is server-formatted text that remains static after insertion and is refreshed for long-lived editor sessions.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread javascript/src/tiptap_gw/now_shortcut.ts
Comment thread ghostwriter/static/js/tinymce/config.js Outdated
Comment thread ghostwriter/templates/base_generic.html
Comment thread ghostwriter/templates/base_generic_empty.html
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.93%. Comparing base (e26dda2) to head (fa320b5).
⚠️ Report is 20 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings July 21, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Comment thread ghostwriter/static/js/tinymce/config.js Outdated
Comment thread javascript/src/tiptap_gw/now_shortcut.ts Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 22:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 28 changed files in this pull request and generated 5 comments.

Comment thread javascript/src/tiptap_gw/now_shortcut.ts
Comment thread javascript/src/tiptap_gw/now_shortcut.ts
Comment thread javascript/src/tiptap_gw/now_shortcut.ts
Comment thread ghostwriter/static/js/tinymce/config.js Outdated
Comment thread CHANGELOG.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 22:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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])$/;

Copilot AI review requested due to automatic review settings July 21, 2026 22:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 27 out of 28 changed files in this pull request and generated 2 comments.

Comment thread ghostwriter/static/js/editor_shortcuts.js
Comment thread ghostwriter/templates/snippets/editor_shortcuts_config.html Outdated
Copilot AI review requested due to automatic review settings July 21, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 1 comment.

Comment thread ghostwriter/static/js/editor_shortcuts.js
Copilot AI review requested due to automatic review settings July 22, 2026 00:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated no new comments.

@chrismaddalena
chrismaddalena merged commit 85c49f0 into master Jul 22, 2026
9 of 10 checks passed
@chrismaddalena
chrismaddalena deleted the feature/now-command branch July 22, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants