-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Quoting local dates bbcode regeneration (#17141)
This commit allows quoting of discourse-local-date elements and converts the quoted tags back into bbcode so that the rendered quote will also render the discourse-local-date HTML. This works on single dates as well as date ranges, and supports all of the options used by discourse-local-date. This also necessitated adding addTextDecorateCallback to the to-markdown core lib (similar to addBlockDecorateCallback and addTagDecorateCallback) to transform the text nodes between date ranges to remove the -> in the final quote. c.f. https://meta.discourse.org/t/quotes-that-contain-date-time/101999
- Loading branch information
1 parent
fd294a6
commit 54a518b
Showing
7 changed files
with
331 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
58 changes: 58 additions & 0 deletions
58
plugins/discourse-local-dates/assets/javascripts/lib/local-date-markup-generator.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { isEmpty } from "@ember/utils"; | ||
|
||
export default function generateDateMarkup( | ||
fromDateTime, | ||
options, | ||
isRange, | ||
toDateTime | ||
) { | ||
let text = ``; | ||
|
||
if (isRange) { | ||
let from = [fromDateTime.date, fromDateTime.time] | ||
.filter((element) => !isEmpty(element)) | ||
.join("T"); | ||
let to = [toDateTime.date, toDateTime.time] | ||
.filter((element) => !isEmpty(element)) | ||
.join("T"); | ||
text += `[date-range from=${from} to=${to}`; | ||
} else { | ||
text += `[date=${fromDateTime.date}`; | ||
} | ||
|
||
if (fromDateTime.time && !isRange) { | ||
text += ` time=${fromDateTime.time}`; | ||
} | ||
|
||
if (fromDateTime.format && fromDateTime.format.length) { | ||
text += ` format="${fromDateTime.format}"`; | ||
} | ||
|
||
if (options.timezone) { | ||
text += ` timezone="${options.timezone}"`; | ||
} | ||
|
||
if (options.countdown) { | ||
text += ` countdown="${options.countdown}"`; | ||
} | ||
|
||
if (options.displayedTimezone) { | ||
text += ` displayedTimezone="${options.displayedTimezone}"`; | ||
} | ||
|
||
if (options.timezones && options.timezones.length) { | ||
if (Array.isArray(options.timezones)) { | ||
text += ` timezones="${options.timezones.join("|")}"`; | ||
} else { | ||
text += ` timezones="${options.timezones}"`; | ||
} | ||
} | ||
|
||
if (options.recurring && !isRange) { | ||
text += ` recurring="${options.recurring}"`; | ||
} | ||
|
||
text += `]`; | ||
|
||
return text; | ||
} |
Oops, something went wrong.