mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 05:06:51 +08:00
When editing posts in the rich text editor, custom date formats and
advanced options (recurring, timezones, countdown, displayedTimezone)
were silently dropped. Users who carefully configured dates via the
Advanced Mode dialog would lose those settings as soon as they touched
the post in rich text mode.
This happened because the rich-editor-extension only tracked the basic
date/time/timezone attributes, ignoring everything else. Similarly,
copy-pasting date ranges would crash with "No value supplied for
attribute fromDate" because the parseDOM logic was reading attributes
from the wrapper span instead of the inner date spans.
Changes:
- Extend `formatLocalDate` to accept all LocalDateBuilder options so
dates render correctly with custom formats in the editor
- Update rich-editor-extension to parse, store, and serialize all
date attributes for both single dates and date ranges
- Fix date range copy/paste by querying the inner spans via
`dom.querySelector('[data-range="from"]')` instead of reading from
the wrapper element
- Add shared `serializeBBCodeAttr` and `buildBBCodeAttrs` helpers to
`discourse/lib/text.js` that only quote values when necessary
(whitespace or `]` characters)
- Refactor local-dates, poll, calendar, and chat plugins to use the
shared BBCode serialization helpers, eliminating duplicated logic
Internal ref - t/165719
**MARKDOWN (reference)**
<img width="1477" height="548" alt="2025-12-18 @ 18 20 25"
src="https://github.com/user-attachments/assets/f7a20835-ec09-4b41-aff7-6894451fae72"
/>
**RTE (before)**
<img width="759" height="549" alt="2025-12-18 @ 18 22 36"
src="https://github.com/user-attachments/assets/ea914a84-d087-43b6-9007-5807523a6c7c"
/>
**RTE (after)**
<img width="762" height="547" alt="2025-12-18 @ 18 20 35"
src="https://github.com/user-attachments/assets/79c6c70f-80b2-44ff-a1a5-f2564c53b3da"
/>
|
||
|---|---|---|
| .. | ||
| rich-editor-extension-test.js | ||