Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Bundle discourse-spoiler-alert plugin into core (#24030)

Blake Erickson89580ee37994
diff --git a/.gitignore b/.gitignore
index 3b60900b38a..0f6a7c6ae5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,7 @@
!/plugins/chat/
!/plugins/poll/
!/plugins/styleguide
+!/plugins/spoiler-alert/
!/plugins/checklist/
!/plugins/footnote/
/plugins/*/auto_generated/
diff --git a/plugins/spoiler-alert/README.md b/plugins/spoiler-alert/README.md
new file mode 100644
index 00000000000..c36980e3c81
--- /dev/null
+++ b/plugins/spoiler-alert/README.md
@@ -0,0 +1,41 @@
+# discourse-spoiler-alert
+
+https://meta.discourse.org/t/discourse-spoiler-alert/12650/
+
+Spoiler plugin for [Discourse](http://discourse.org) highly inspired by the [spoiler-alert](http://joshbuddy.github.io/spoiler-alert/) jQuery plugin.
+
+## Usage
+
+In your posts, surround text or images with `[spoiler]` ... `[/spoiler]`.
+For example:
+
+```
+I watched the murder mystery on TV last night. [spoiler]The butler did it[/spoiler].
+```
+
+## Installation
+
+- Add the plugin's repo url to your container's `app.yml` file
+
+```yml
+hooks:
+ after_code:
+ - exec:
+ cd: $home/plugins
+ cmd:
+ - mkdir -p plugins
+ - git clone https://github.com/discourse/docker_manager.git
+ - git clone https://github.com/discourse/discourse-spoiler-alert.git
+```
+
+- Rebuild the container
+
+```
+cd /var/discourse
+git pull
+./launcher rebuild app
+```
+
+## License
+
+MIT
diff --git a/plugins/spoiler-alert/assets/javascripts/initializers/spoiler-alert.js b/plugins/spoiler-alert/assets/javascripts/initializers/spoiler-alert.js
new file mode 100644
index 00000000000..22221483524
--- /dev/null
+++ b/plugins/spoiler-alert/assets/javascripts/initializers/spoiler-alert.js
@@ -0,0 +1,58 @@
+import { withPluginApi } from "discourse/lib/plugin-api";
+import {
+ addBlockDecorateCallback,
+ addTagDecorateCallback,
+} from "discourse/lib/to-markdown";
+import applySpoiler from "discourse/plugins/discourse-spoiler-alert/lib/apply-spoiler";
+
+function spoil(element) {
+ element.querySelectorAll(".spoiler").forEach((spoiler) => {
+ spoiler.classList.remove("spoiler");
+ spoiler.classList.add("spoiled");
+ applySpoiler(spoiler);
+ });
+}
+
+export function initializeSpoiler(api) {
+ api.decorateCookedElement(spoil, { id: "spoiler-alert" });
+
+ api.addComposerToolbarPopupMenuOption({
+ icon: "magic",
+ label: "spoiler.title",
+ action: (toolbarEvent) => {
+ toolbarEvent.applySurround("[spoiler]", "[/spoiler]", "spoiler_text", {
+ multiline: false,
+ useBlockMode: true,
+ });
+ },
+ });
+
+ addTagDecorateCallback(function () {
+ if (this.element.attributes.class === "spoiled") {
+ this.prefix = "[spoiler]";
+ this.suffix = "[/spoiler]";
+ }
+ });
+
+ addBlockDecorateCallback(function (text) {
+ const { name, attributes } = this.element;
+
+ if (name === "div" && attributes.class === "spoiled") {
+ this.prefix = "[spoiler]";
+ this.suffix = "[/spoiler]";
+ return text.trim();
+ }
+ });
+}
+
+export default {
+ name: "spoiler-alert",
+
+ initialize(container) {
+ const siteSettings = container.lookup("site-settings:main");
+
+ if (siteSettings.spoiler_enabled) {
+ withPluginApi("1.15.0", initializeSpoiler);
+ }
+ },
+};
diff --git a/plugins/spoiler-alert/assets/javascripts/lib/apply-spoiler.js b/plugins/spoiler-alert/assets/javascripts/lib/apply-spoiler.js
new file mode 100644
index 00000000000..9677e73e98e
--- /dev/null
+++ b/plugins/spoiler-alert/assets/javascripts/lib/apply-spoiler.js
@@ -0,0 +1,101 @@
+import I18n from "discourse-i18n";
+
+const INTERACTIVE_SELECTOR = [
+ "a",
+ "area",
+ "audio",
+ "button",
+ "details",
+ "embed",
+ "iframe",
+ "img.animated",
+ "input",
+ "map",
+ "object",
+ "option",
+ "portal",
+ "select",
+ "textarea",
+ "track",
+ "video",
+ ".lightbox",
+].join(", ");
+
+function isInteractive(event) {
+ return event.defaultPrevented || event.target.closest(INTERACTIVE_SELECTOR);
+}
+
+function noTextSelected() {
+ return window.getSelection() + "" === "";
+}
+
+function setAttributes(element, attributes) {
+ Object.entries(attributes).forEach(([key, value]) => {
+ if (value === null) {
+ element.removeAttribute(key);
+ } else {
+ element.setAttribute(key, value);
+ }
+ });
+}
+
+function _setSpoilerHidden(element) {
+ const spoilerHiddenAttributes = {
+ role: "button",
+ tabindex: "0",
+ "data-spoiler-state": "blurred",
+ "aria-expanded": false,
+ "aria-label": I18n.t("spoiler.label.show"),
+ "aria-live": "polite",
+ };
+
+ // Set default attributes & classes on spoiler
+ setAttributes(element, spoilerHiddenAttributes);
+ element.classList.add("spoiler-blurred");
+
+ // Set aria-hidden for all children of the spoiler
+ Array.from(element.children).forEach((e) => {
+ e.setAttribute("aria-hidden", true);
+ });
+}
+
+function _setSpoilerVisible(element) {
+ const spoilerVisibleAttributes = {
+ "data-spoiler-state": "revealed",
+ "aria-expanded": true,
+ "aria-label": null,
+ role: null,
+ };
+
+ // Set attributes & classes for when spoiler is visible
+ setAttributes(element, spoilerVisibleAttributes);
+ element.classList.remove("spoiler-blurred");
+
+ // Remove aria-hidden for all children of the spoiler when visible
+ Array.from(element.children).forEach((e) => {
+ e.removeAttribute("aria-hidden");
+ });
+}
+
+function toggleSpoiler(event, element) {
+ if (element.getAttribute("data-spoiler-state") === "blurred") {
+ _setSpoilerVisible(element);
+ event.preventDefault();
+ } else if (!isInteractive(event) && noTextSelected()) {
+ _setSpoilerHidden(element);
+ }
+}
+
+export default function applySpoiler(element) {
+ _setSpoilerHidden(element);
+
+ element.addEventListener("click", (event) => {
+ toggleSpoiler(event, element);
+ });
+
+ element.addEventListener("keydown", (event) => {
+ if (event.key === "Enter") {
+ toggleSpoiler(event, element);
+ }
+ });
+}
diff --git a/plugins/spoiler-alert/assets/javascripts/lib/discourse-markdown/spoiler-alert.js b/plugins/spoiler-alert/assets/javascripts/lib/discourse-markdown/spoiler-alert.js
new file mode 100644
index 00000000000..8989d4d70ae
--- /dev/null
+++ b/plugins/spoiler-alert/assets/javascripts/lib/discourse-markdown/spoiler-alert.js
@@ -0,0 +1,46 @@
+const CONTAINS_BLOCK_REGEX = /\n|<img|!\[[^\]]*\][(\[]/;
+
+function insertSpoiler(_, spoiler) {
+ const element = CONTAINS_BLOCK_REGEX.test(spoiler) ? "div" : "span";
+ return `<${element} class='spoiler'>${spoiler}</${element}>`;
+}
+
+function replaceSpoilers(text) {
+ text = text || "";
+ while (
+ text !==
+ (text = text.replace(
+ /\[spoiler\]((?:(?!\[spoiler\]|\[\/spoiler\])[\S\s])*)\[\/spoiler\]/gi,
+ insertSpoiler
+ ))
+ ) {}
+ return text;
+}
+
+function setupMarkdownIt(helper) {
+ helper.registerOptions((opts, siteSettings) => {
+ opts.features["spoiler-alert"] = !!siteSettings.spoiler_enabled;
+ });
+
+ helper.registerPlugin((md) => {
+ md.inline.bbcode.ruler.push("spoiler", {
+ tag: "spoiler",
+ wrap: "span.spoiler",
+ });
+
+ md.block.bbcode.ruler.push("spoiler", {
+ tag: "spoiler",
+ wrap: "div.spoiler",
+ });
+ });
+}
+
+export function setup(helper) {
+ helper.allowList(["span.spoiler", "div.spoiler"]);
+
+ if (helper.markdownIt) {
+ setupMarkdownIt(helper);
+ } else {
+ helper.addPreProcessor(replaceSpoilers);
+ }
+}
diff --git a/plugins/spoiler-alert/assets/stylesheets/discourse_spoiler_alert.scss b/plugins/spoiler-alert/assets/stylesheets/discourse_spoiler_alert.scss
new file mode 100644
index 00000000000..1b003e9c656
--- /dev/null
+++ b/plugins/spoiler-alert/assets/stylesheets/discourse_spoiler_alert.scss
@@ -0,0 +1,54 @@
+.spoiled {
+ cursor: auto;
+ -webkit-transform: translateZ(0); // Safari jitter fix
+
+ .lightbox .meta {
+ display: none;
+ }
+
+ svg {
+ vertical-align: middle;
+ }
+}
+
+.spoiler-blurred {
+ @include unselectable;
+ cursor: pointer;
+ filter: blur(0.5em);
+
+ a,
+ area,
+ audio,
+ button,
+ details,
+ embed,
+ iframe,
+ img.animated,
+ input,
+ map,
+ object,
+ option,
+ portal,
+ select,
+ textarea,
+ track,
+ video,
+ .lightbox {
+ pointer-events: none;
+ }
+
+ img {
+ filter: blur(1em);
+ }
+
+ .discourse-no-touch & {
+ &:hover,
+ &:focus {
+ filter: blur(0.18em);
+
+ img {
+ filter: blur(0.5em);
+ }
+ }
+ }
+}
diff --git a/plugins/spoiler-alert/config/locales/client.ar.yml b/plugins/spoiler-alert/config/locales/client.ar.yml
new file mode 100644
index 00000000000..73a5f79dd42
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ar.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ar:
+ js:
+ spoiler:
+ title: تنبيه بالتمويه
+ label:
+ show: "إظهار المحتوى المخفي"
+ composer:
+ spoiler_text: "سيتم تمويه هذا النص"
diff --git a/plugins/spoiler-alert/config/locales/client.be.yml b/plugins/spoiler-alert/config/locales/client.be.yml
new file mode 100644
index 00000000000..2ea77a0d350
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.be.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+be:
diff --git a/plugins/spoiler-alert/config/locales/client.bg.yml b/plugins/spoiler-alert/config/locales/client.bg.yml
new file mode 100644
index 00000000000..52333529d3c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.bg.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bg:
diff --git a/plugins/spoiler-alert/config/locales/client.bs_BA.yml b/plugins/spoiler-alert/config/locales/client.bs_BA.yml
new file mode 100644
index 00000000000..828a7e65af8
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.bs_BA.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bs_BA:
diff --git a/plugins/spoiler-alert/config/locales/client.ca.yml b/plugins/spoiler-alert/config/locales/client.ca.yml
new file mode 100644
index 00000000000..ec737bc1a5b
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ca.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ca:
diff --git a/plugins/spoiler-alert/config/locales/client.cs.yml b/plugins/spoiler-alert/config/locales/client.cs.yml
new file mode 100644
index 00000000000..041b2f0bd05
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.cs.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+cs:
diff --git a/plugins/spoiler-alert/config/locales/client.da.yml b/plugins/spoiler-alert/config/locales/client.da.yml
new file mode 100644
index 00000000000..f39c727c594
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.da.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+da:
diff --git a/plugins/spoiler-alert/config/locales/client.de.yml b/plugins/spoiler-alert/config/locales/client.de.yml
new file mode 100644
index 00000000000..95947de2592
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.de.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+de:
+ js:
+ spoiler:
+ title: Spoiler unkenntlich machen
+ label:
+ show: "Zeige ausgeblendeten Inhalt"
+ composer:
+ spoiler_text: "Dieser Text wird unkenntlich gemacht"
diff --git a/plugins/spoiler-alert/config/locales/client.el.yml b/plugins/spoiler-alert/config/locales/client.el.yml
new file mode 100644
index 00000000000..d872d0ecc40
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.el.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+el:
diff --git a/plugins/spoiler-alert/config/locales/client.en.yml b/plugins/spoiler-alert/config/locales/client.en.yml
new file mode 100644
index 00000000000..f4fb352b93d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.en.yml
@@ -0,0 +1,8 @@
+en:
+ js:
+ spoiler:
+ title: Blur Spoiler
+ label:
+ show: "Show hidden content"
+ composer:
+ spoiler_text: "This text will be blurred"
diff --git a/plugins/spoiler-alert/config/locales/client.en_GB.yml b/plugins/spoiler-alert/config/locales/client.en_GB.yml
new file mode 100644
index 00000000000..2d4fa180ec7
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.en_GB.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+en_GB:
diff --git a/plugins/spoiler-alert/config/locales/client.es.yml b/plugins/spoiler-alert/config/locales/client.es.yml
new file mode 100644
index 00000000000..e1f85a90b9d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.es.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+es:
+ js:
+ spoiler:
+ title: Spoiler Borroso
+ label:
+ show: "Mostrar contenido oculto"
+ composer:
+ spoiler_text: "Este texto será borroso"
diff --git a/plugins/spoiler-alert/config/locales/client.et.yml b/plugins/spoiler-alert/config/locales/client.et.yml
new file mode 100644
index 00000000000..0ea0b6d554b
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.et.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+et:
diff --git a/plugins/spoiler-alert/config/locales/client.fa_IR.yml b/plugins/spoiler-alert/config/locales/client.fa_IR.yml
new file mode 100644
index 00000000000..c92b4b838e8
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.fa_IR.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fa_IR:
+ js:
+ spoiler:
+ label:
+ show: "نمایش محتوای پنهان"
diff --git a/plugins/spoiler-alert/config/locales/client.fi.yml b/plugins/spoiler-alert/config/locales/client.fi.yml
new file mode 100644
index 00000000000..713db335a9c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.fi.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fi:
+ js:
+ spoiler:
+ title: Spoileri
+ label:
+ show: "Näytä piilotettu sisältö"
+ composer:
+ spoiler_text: "Tämä teksti sumennetaan"
diff --git a/plugins/spoiler-alert/config/locales/client.fr.yml b/plugins/spoiler-alert/config/locales/client.fr.yml
new file mode 100644
index 00000000000..561b9a9a9e4
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.fr.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fr:
+ js:
+ spoiler:
+ title: Flouter le texte
+ label:
+ show: "Afficher le contenu masqué"
+ composer:
+ spoiler_text: "Ce texte sera flouté"
diff --git a/plugins/spoiler-alert/config/locales/client.gl.yml b/plugins/spoiler-alert/config/locales/client.gl.yml
new file mode 100644
index 00000000000..fb911ce1635
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.gl.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+gl:
diff --git a/plugins/spoiler-alert/config/locales/client.he.yml b/plugins/spoiler-alert/config/locales/client.he.yml
new file mode 100644
index 00000000000..ff5a55fcc23
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.he.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+he:
+ js:
+ spoiler:
+ title: טשטוש קלקלן
+ label:
+ show: "הצגת תוכן מוסתר"
+ composer:
+ spoiler_text: "טקסט זה יטושטש"
diff --git a/plugins/spoiler-alert/config/locales/client.hr.yml b/plugins/spoiler-alert/config/locales/client.hr.yml
new file mode 100644
index 00000000000..93343ce6e19
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.hr.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hr:
diff --git a/plugins/spoiler-alert/config/locales/client.hu.yml b/plugins/spoiler-alert/config/locales/client.hu.yml
new file mode 100644
index 00000000000..76b6e9d8bcb
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.hu.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hu:
diff --git a/plugins/spoiler-alert/config/locales/client.hy.yml b/plugins/spoiler-alert/config/locales/client.hy.yml
new file mode 100644
index 00000000000..cb18f64d356
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.hy.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hy:
diff --git a/plugins/spoiler-alert/config/locales/client.id.yml b/plugins/spoiler-alert/config/locales/client.id.yml
new file mode 100644
index 00000000000..596e36b2e13
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.id.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+id:
diff --git a/plugins/spoiler-alert/config/locales/client.it.yml b/plugins/spoiler-alert/config/locales/client.it.yml
new file mode 100644
index 00000000000..96cf103a30c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.it.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+it:
+ js:
+ spoiler:
+ title: Rendi illeggibile spoiler
+ label:
+ show: "Mostra contenuti nascosti"
+ composer:
+ spoiler_text: "Questo testo verrà reso illeggibile"
diff --git a/plugins/spoiler-alert/config/locales/client.ja.yml b/plugins/spoiler-alert/config/locales/client.ja.yml
new file mode 100644
index 00000000000..6ef9e2b9259
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ja.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ja:
+ js:
+ spoiler:
+ title: ネタバレをぼかす
+ label:
+ show: "非表示のコンテンツを表示する"
+ composer:
+ spoiler_text: "このテキストはぼかし表示されます"
diff --git a/plugins/spoiler-alert/config/locales/client.ko.yml b/plugins/spoiler-alert/config/locales/client.ko.yml
new file mode 100644
index 00000000000..18dd77fd3ec
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ko.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ko:
diff --git a/plugins/spoiler-alert/config/locales/client.lt.yml b/plugins/spoiler-alert/config/locales/client.lt.yml
new file mode 100644
index 00000000000..16bb19758dc
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.lt.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lt:
diff --git a/plugins/spoiler-alert/config/locales/client.lv.yml b/plugins/spoiler-alert/config/locales/client.lv.yml
new file mode 100644
index 00000000000..59e0ef6f4ed
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.lv.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lv:
diff --git a/plugins/spoiler-alert/config/locales/client.nb_NO.yml b/plugins/spoiler-alert/config/locales/client.nb_NO.yml
new file mode 100644
index 00000000000..2e2224d1472
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.nb_NO.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nb_NO:
diff --git a/plugins/spoiler-alert/config/locales/client.nl.yml b/plugins/spoiler-alert/config/locales/client.nl.yml
new file mode 100644
index 00000000000..e1feb71f951
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.nl.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nl:
+ js:
+ spoiler:
+ title: Spoiler vervagen
+ label:
+ show: "Verborgen inhoud weergeven"
+ composer:
+ spoiler_text: "Deze tekst wordt vervaagd"
diff --git a/plugins/spoiler-alert/config/locales/client.pl_PL.yml b/plugins/spoiler-alert/config/locales/client.pl_PL.yml
new file mode 100644
index 00000000000..890594a4a01
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.pl_PL.yml
@@ -0,0 +1,10 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pl_PL:
+ js:
+ composer:
+ spoiler_text: "Ten tekst zostanie zamazany"
diff --git a/plugins/spoiler-alert/config/locales/client.pt.yml b/plugins/spoiler-alert/config/locales/client.pt.yml
new file mode 100644
index 00000000000..298ba523c1d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.pt.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt:
diff --git a/plugins/spoiler-alert/config/locales/client.pt_BR.yml b/plugins/spoiler-alert/config/locales/client.pt_BR.yml
new file mode 100644
index 00000000000..a161dd690b1
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.pt_BR.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt_BR:
+ js:
+ spoiler:
+ title: Dificuldador de desfoque
+ label:
+ show: "Exibir conteúdo oculto"
+ composer:
+ spoiler_text: "Este texto será desfocado"
diff --git a/plugins/spoiler-alert/config/locales/client.ro.yml b/plugins/spoiler-alert/config/locales/client.ro.yml
new file mode 100644
index 00000000000..08a77f812ee
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ro.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ro:
diff --git a/plugins/spoiler-alert/config/locales/client.ru.yml b/plugins/spoiler-alert/config/locales/client.ru.yml
new file mode 100644
index 00000000000..ccb9deac648
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ru.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ru:
+ js:
+ spoiler:
+ title: Размыть спойлер
+ label:
+ show: "Показать скрытый контент"
+ composer:
+ spoiler_text: "Этот текст будет размыт"
diff --git a/plugins/spoiler-alert/config/locales/client.sk.yml b/plugins/spoiler-alert/config/locales/client.sk.yml
new file mode 100644
index 00000000000..6f815624081
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.sk.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sk:
diff --git a/plugins/spoiler-alert/config/locales/client.sl.yml b/plugins/spoiler-alert/config/locales/client.sl.yml
new file mode 100644
index 00000000000..23489a48b1f
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.sl.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sl:
diff --git a/plugins/spoiler-alert/config/locales/client.sq.yml b/plugins/spoiler-alert/config/locales/client.sq.yml
new file mode 100644
index 00000000000..7f051b7a7cf
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.sq.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sq:
diff --git a/plugins/spoiler-alert/config/locales/client.sr.yml b/plugins/spoiler-alert/config/locales/client.sr.yml
new file mode 100644
index 00000000000..88d63d6ae1a
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.sr.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sr:
diff --git a/plugins/spoiler-alert/config/locales/client.sv.yml b/plugins/spoiler-alert/config/locales/client.sv.yml
new file mode 100644
index 00000000000..a0f4b73038c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.sv.yml
@@ -0,0 +1,12 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sv:
+ js:
+ spoiler:
+ title: Blurra spoiler
+ composer:
+ spoiler_text: "Denna text kommer att blurras"
diff --git a/plugins/spoiler-alert/config/locales/client.sw.yml b/plugins/spoiler-alert/config/locales/client.sw.yml
new file mode 100644
index 00000000000..0d7cdd075bf
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.sw.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sw:
diff --git a/plugins/spoiler-alert/config/locales/client.te.yml b/plugins/spoiler-alert/config/locales/client.te.yml
new file mode 100644
index 00000000000..03967bdbb07
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.te.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+te:
diff --git a/plugins/spoiler-alert/config/locales/client.th.yml b/plugins/spoiler-alert/config/locales/client.th.yml
new file mode 100644
index 00000000000..7de85ff91c4
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.th.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+th:
diff --git a/plugins/spoiler-alert/config/locales/client.tr_TR.yml b/plugins/spoiler-alert/config/locales/client.tr_TR.yml
new file mode 100644
index 00000000000..c3fe2cf5eda
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.tr_TR.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+tr_TR:
+ js:
+ spoiler:
+ title: Spoiler'ı Bulanıklaştır
+ label:
+ show: "Gizli içeriği göster"
+ composer:
+ spoiler_text: "Bu metin bulanıklaştırılacak"
diff --git a/plugins/spoiler-alert/config/locales/client.uk.yml b/plugins/spoiler-alert/config/locales/client.uk.yml
new file mode 100644
index 00000000000..f1390545d1d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.uk.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+uk:
diff --git a/plugins/spoiler-alert/config/locales/client.ur.yml b/plugins/spoiler-alert/config/locales/client.ur.yml
new file mode 100644
index 00000000000..b4a9c21ee2f
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.ur.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ur:
diff --git a/plugins/spoiler-alert/config/locales/client.vi.yml b/plugins/spoiler-alert/config/locales/client.vi.yml
new file mode 100644
index 00000000000..c1dea5be7da
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.vi.yml
@@ -0,0 +1,12 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+vi:
+ js:
+ spoiler:
+ title: Làm Mờ Spoiler
+ composer:
+ spoiler_text: "Đoạn text này sẽ được làm mờ"
diff --git a/plugins/spoiler-alert/config/locales/client.zh_CN.yml b/plugins/spoiler-alert/config/locales/client.zh_CN.yml
new file mode 100644
index 00000000000..9495d235e6d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.zh_CN.yml
@@ -0,0 +1,14 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_CN:
+ js:
+ spoiler:
+ title: 剧透打码
+ label:
+ show: "显示隐藏内容"
+ composer:
+ spoiler_text: "此文本将被打码"
diff --git a/plugins/spoiler-alert/config/locales/client.zh_TW.yml b/plugins/spoiler-alert/config/locales/client.zh_TW.yml
new file mode 100644
index 00000000000..dafff56bb52
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/client.zh_TW.yml
@@ -0,0 +1,12 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_TW:
+ js:
+ spoiler:
+ title: 模糊化劇透
+ composer:
+ spoiler_text: "這段文字會被模糊化"
diff --git a/plugins/spoiler-alert/config/locales/server.ar.yml b/plugins/spoiler-alert/config/locales/server.ar.yml
new file mode 100644
index 00000000000..478efdd4895
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ar.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ar:
+ site_settings:
+ spoiler_enabled: 'تفعيل المكوِّن الإضافي للتمويه. إذا غيَّرت هذا الإعداد، فيجب عليك إعادة إنشاء جميع المنشورات باستخدام: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "تنبيه"
diff --git a/plugins/spoiler-alert/config/locales/server.be.yml b/plugins/spoiler-alert/config/locales/server.be.yml
new file mode 100644
index 00000000000..2ea77a0d350
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.be.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+be:
diff --git a/plugins/spoiler-alert/config/locales/server.bg.yml b/plugins/spoiler-alert/config/locales/server.bg.yml
new file mode 100644
index 00000000000..52333529d3c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.bg.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bg:
diff --git a/plugins/spoiler-alert/config/locales/server.bs_BA.yml b/plugins/spoiler-alert/config/locales/server.bs_BA.yml
new file mode 100644
index 00000000000..828a7e65af8
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.bs_BA.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+bs_BA:
diff --git a/plugins/spoiler-alert/config/locales/server.ca.yml b/plugins/spoiler-alert/config/locales/server.ca.yml
new file mode 100644
index 00000000000..ec737bc1a5b
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ca.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ca:
diff --git a/plugins/spoiler-alert/config/locales/server.cs.yml b/plugins/spoiler-alert/config/locales/server.cs.yml
new file mode 100644
index 00000000000..041b2f0bd05
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.cs.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+cs:
diff --git a/plugins/spoiler-alert/config/locales/server.da.yml b/plugins/spoiler-alert/config/locales/server.da.yml
new file mode 100644
index 00000000000..f39c727c594
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.da.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+da:
diff --git a/plugins/spoiler-alert/config/locales/server.de.yml b/plugins/spoiler-alert/config/locales/server.de.yml
new file mode 100644
index 00000000000..1adc50ba474
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.de.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+de:
+ site_settings:
+ spoiler_enabled: 'Aktiviert das Spoiler-Plug-in. Wenn du dies änderst, musst du alle Beiträge mit folgendem Befehl aktualisieren: „rake posts:rebake“'
+ spoiler_alert:
+ excerpt_spoiler: "Spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.el.yml b/plugins/spoiler-alert/config/locales/server.el.yml
new file mode 100644
index 00000000000..d872d0ecc40
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.el.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+el:
diff --git a/plugins/spoiler-alert/config/locales/server.en.yml b/plugins/spoiler-alert/config/locales/server.en.yml
new file mode 100644
index 00000000000..e19346026a3
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.en.yml
@@ -0,0 +1,5 @@
+en:
+ site_settings:
+ spoiler_enabled: 'Enable the spoiler plugin. If you change this, you must rebake all posts with: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.en_GB.yml b/plugins/spoiler-alert/config/locales/server.en_GB.yml
new file mode 100644
index 00000000000..2d4fa180ec7
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.en_GB.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+en_GB:
diff --git a/plugins/spoiler-alert/config/locales/server.es.yml b/plugins/spoiler-alert/config/locales/server.es.yml
new file mode 100644
index 00000000000..5154957da01
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.es.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+es:
+ site_settings:
+ spoiler_enabled: 'Habilitar plugin de Spoiler. Si cambias esto, debes hacer un rebake para todas las publicaciones con: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.et.yml b/plugins/spoiler-alert/config/locales/server.et.yml
new file mode 100644
index 00000000000..0ea0b6d554b
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.et.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+et:
diff --git a/plugins/spoiler-alert/config/locales/server.fa_IR.yml b/plugins/spoiler-alert/config/locales/server.fa_IR.yml
new file mode 100644
index 00000000000..56512089fb5
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.fa_IR.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fa_IR:
diff --git a/plugins/spoiler-alert/config/locales/server.fi.yml b/plugins/spoiler-alert/config/locales/server.fi.yml
new file mode 100644
index 00000000000..72b0d449a78
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.fi.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fi:
+ site_settings:
+ spoiler_enabled: 'Ota spoilerilisäosa käyttöön. Jos muutat asetusta, sinun täytyy rakentaa viestit uudelleen komennolla: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "spoileri"
diff --git a/plugins/spoiler-alert/config/locales/server.fr.yml b/plugins/spoiler-alert/config/locales/server.fr.yml
new file mode 100644
index 00000000000..5b6d6ea6338
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.fr.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+fr:
+ site_settings:
+ spoiler_enabled: 'Activer l''extension spoiler. Si vous modifiez ceci, vous devez exécuter la commande « rake posts:rebake ».'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.gl.yml b/plugins/spoiler-alert/config/locales/server.gl.yml
new file mode 100644
index 00000000000..fb911ce1635
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.gl.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+gl:
diff --git a/plugins/spoiler-alert/config/locales/server.he.yml b/plugins/spoiler-alert/config/locales/server.he.yml
new file mode 100644
index 00000000000..cb167b53408
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.he.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+he:
+ site_settings:
+ spoiler_enabled: 'הפעלת תוסף הקלקלן. שינוי של הגדרה זו יאלץ אותך לאפות את כל הפוסטים מחדש עם: „rake posts:rebake”.'
+ spoiler_alert:
+ excerpt_spoiler: "קלקלן"
diff --git a/plugins/spoiler-alert/config/locales/server.hr.yml b/plugins/spoiler-alert/config/locales/server.hr.yml
new file mode 100644
index 00000000000..93343ce6e19
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.hr.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hr:
diff --git a/plugins/spoiler-alert/config/locales/server.hu.yml b/plugins/spoiler-alert/config/locales/server.hu.yml
new file mode 100644
index 00000000000..76b6e9d8bcb
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.hu.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hu:
diff --git a/plugins/spoiler-alert/config/locales/server.hy.yml b/plugins/spoiler-alert/config/locales/server.hy.yml
new file mode 100644
index 00000000000..cb18f64d356
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.hy.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+hy:
diff --git a/plugins/spoiler-alert/config/locales/server.id.yml b/plugins/spoiler-alert/config/locales/server.id.yml
new file mode 100644
index 00000000000..596e36b2e13
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.id.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+id:
diff --git a/plugins/spoiler-alert/config/locales/server.it.yml b/plugins/spoiler-alert/config/locales/server.it.yml
new file mode 100644
index 00000000000..a58bdd420e6
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.it.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+it:
+ site_settings:
+ spoiler_enabled: 'Abilita il plugin spoiler. Se modifichi questa opzione devi aggiornare tutti i messaggi con: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.ja.yml b/plugins/spoiler-alert/config/locales/server.ja.yml
new file mode 100644
index 00000000000..b3eb635abcd
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ja.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ja:
+ site_settings:
+ spoiler_enabled: 'スポイラープラグインを有効にします。これを変更すると、"rake posts:rebake" で、すべての投稿をリベイクする必要があります。'
+ spoiler_alert:
+ excerpt_spoiler: "ネタバレ"
diff --git a/plugins/spoiler-alert/config/locales/server.ko.yml b/plugins/spoiler-alert/config/locales/server.ko.yml
new file mode 100644
index 00000000000..18dd77fd3ec
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ko.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ko:
diff --git a/plugins/spoiler-alert/config/locales/server.lt.yml b/plugins/spoiler-alert/config/locales/server.lt.yml
new file mode 100644
index 00000000000..16bb19758dc
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.lt.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lt:
diff --git a/plugins/spoiler-alert/config/locales/server.lv.yml b/plugins/spoiler-alert/config/locales/server.lv.yml
new file mode 100644
index 00000000000..59e0ef6f4ed
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.lv.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+lv:
diff --git a/plugins/spoiler-alert/config/locales/server.nb_NO.yml b/plugins/spoiler-alert/config/locales/server.nb_NO.yml
new file mode 100644
index 00000000000..2e2224d1472
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.nb_NO.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nb_NO:
diff --git a/plugins/spoiler-alert/config/locales/server.nl.yml b/plugins/spoiler-alert/config/locales/server.nl.yml
new file mode 100644
index 00000000000..5793767e216
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.nl.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+nl:
+ site_settings:
+ spoiler_enabled: 'Spoiler-plug-in inschakelen. Als je dit wijzigt, moet je alle berichten opnieuw opbouwen met: ''rake posts:rebake''.'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.pl_PL.yml b/plugins/spoiler-alert/config/locales/server.pl_PL.yml
new file mode 100644
index 00000000000..a260c31c64c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.pl_PL.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pl_PL:
diff --git a/plugins/spoiler-alert/config/locales/server.pt.yml b/plugins/spoiler-alert/config/locales/server.pt.yml
new file mode 100644
index 00000000000..caf5e3d0316
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.pt.yml
@@ -0,0 +1,9 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt:
+ site_settings:
+ spoiler_enabled: 'Activar o plugin "spoiler". Se alterar, terá de fazer "rebake" de todos os tópicos com "rake posts:rebake".'
diff --git a/plugins/spoiler-alert/config/locales/server.pt_BR.yml b/plugins/spoiler-alert/config/locales/server.pt_BR.yml
new file mode 100644
index 00000000000..d39f2579605
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.pt_BR.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+pt_BR:
+ site_settings:
+ spoiler_enabled: 'Ative o plugin dificuldador. Se mudar isso, você deve recompilar todas as postagens com: "rake posts:rebake"'
+ spoiler_alert:
+ excerpt_spoiler: "Dificultador"
diff --git a/plugins/spoiler-alert/config/locales/server.ro.yml b/plugins/spoiler-alert/config/locales/server.ro.yml
new file mode 100644
index 00000000000..08a77f812ee
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ro.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ro:
diff --git a/plugins/spoiler-alert/config/locales/server.ru.yml b/plugins/spoiler-alert/config/locales/server.ru.yml
new file mode 100644
index 00000000000..452f3d0e061
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ru.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ru:
+ site_settings:
+ spoiler_enabled: 'Включить плагин для спойлеров. После изменения этой настройки нужно обновить все записи командой «rake posts:rebake».'
+ spoiler_alert:
+ excerpt_spoiler: "спойлер"
diff --git a/plugins/spoiler-alert/config/locales/server.sk.yml b/plugins/spoiler-alert/config/locales/server.sk.yml
new file mode 100644
index 00000000000..6f815624081
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.sk.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sk:
diff --git a/plugins/spoiler-alert/config/locales/server.sl.yml b/plugins/spoiler-alert/config/locales/server.sl.yml
new file mode 100644
index 00000000000..23489a48b1f
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.sl.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sl:
diff --git a/plugins/spoiler-alert/config/locales/server.sq.yml b/plugins/spoiler-alert/config/locales/server.sq.yml
new file mode 100644
index 00000000000..7f051b7a7cf
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.sq.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sq:
diff --git a/plugins/spoiler-alert/config/locales/server.sr.yml b/plugins/spoiler-alert/config/locales/server.sr.yml
new file mode 100644
index 00000000000..88d63d6ae1a
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.sr.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sr:
diff --git a/plugins/spoiler-alert/config/locales/server.sv.yml b/plugins/spoiler-alert/config/locales/server.sv.yml
new file mode 100644
index 00000000000..2d36bc54b7e
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.sv.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sv:
+ site_settings:
+ spoiler_enabled: 'Aktivera spoiler-plugin. Om du senare ändrar detta måste du arbeta om alla inlägg med: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.sw.yml b/plugins/spoiler-alert/config/locales/server.sw.yml
new file mode 100644
index 00000000000..0d7cdd075bf
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.sw.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+sw:
diff --git a/plugins/spoiler-alert/config/locales/server.te.yml b/plugins/spoiler-alert/config/locales/server.te.yml
new file mode 100644
index 00000000000..03967bdbb07
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.te.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+te:
diff --git a/plugins/spoiler-alert/config/locales/server.th.yml b/plugins/spoiler-alert/config/locales/server.th.yml
new file mode 100644
index 00000000000..7de85ff91c4
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.th.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+th:
diff --git a/plugins/spoiler-alert/config/locales/server.tr_TR.yml b/plugins/spoiler-alert/config/locales/server.tr_TR.yml
new file mode 100644
index 00000000000..b09d64d6aca
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.tr_TR.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+tr_TR:
+ site_settings:
+ spoiler_enabled: 'Spoiler eklentisini etkinleştirin. Bunu değiştirirseniz tüm gönderileri şu şekilde yeniden oluşturmalısınız: "rake posts:rebake".'
+ spoiler_alert:
+ excerpt_spoiler: "spoiler"
diff --git a/plugins/spoiler-alert/config/locales/server.uk.yml b/plugins/spoiler-alert/config/locales/server.uk.yml
new file mode 100644
index 00000000000..f1390545d1d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.uk.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+uk:
diff --git a/plugins/spoiler-alert/config/locales/server.ur.yml b/plugins/spoiler-alert/config/locales/server.ur.yml
new file mode 100644
index 00000000000..b4a9c21ee2f
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.ur.yml
@@ -0,0 +1,7 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+ur:
diff --git a/plugins/spoiler-alert/config/locales/server.vi.yml b/plugins/spoiler-alert/config/locales/server.vi.yml
new file mode 100644
index 00000000000..7aa94ce813d
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.vi.yml
@@ -0,0 +1,9 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+vi:
+ site_settings:
+ spoiler_enabled: 'Bật spoiler plugin. Nếu bạn thay đổi điều này, bạn cần phải rebake toàn bộ bài viết bằng câu lệnh: "rake posts:rebake".'
diff --git a/plugins/spoiler-alert/config/locales/server.zh_CN.yml b/plugins/spoiler-alert/config/locales/server.zh_CN.yml
new file mode 100644
index 00000000000..eb2ef39a573
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.zh_CN.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_CN:
+ site_settings:
+ spoiler_enabled: '启用剧透插件。如果您更改此设置,则必须通过此命令重新发布所有帖子:"rake posts:rebake"。'
+ spoiler_alert:
+ excerpt_spoiler: "剧透"
diff --git a/plugins/spoiler-alert/config/locales/server.zh_TW.yml b/plugins/spoiler-alert/config/locales/server.zh_TW.yml
new file mode 100644
index 00000000000..bb005aa137c
--- /dev/null
+++ b/plugins/spoiler-alert/config/locales/server.zh_TW.yml
@@ -0,0 +1,11 @@
+# WARNING: Never edit this file.
+# It will be overwritten when translations are pulled from Crowdin.
+#
+# To work with us on translations, join this project:
+# https://translate.discourse.org/
+
+zh_TW:
+ site_settings:
+ spoiler_enabled: '啟用劇透插件。如果更改此設定,則必須使用以下命令重新烘焙所有貼文:“rake posts:rebake”。'
+ spoiler_alert:
+ excerpt_spoiler: "劇透"
diff --git a/plugins/spoiler-alert/config/settings.yml b/plugins/spoiler-alert/config/settings.yml
new file mode 100644
index 00000000000..563ffa39f5a
--- /dev/null
+++ b/plugins/spoiler-alert/config/settings.yml
@@ -0,0 +1,4 @@
+plugins:
+ spoiler_enabled:
+ default: true
+ client: true
diff --git a/plugins/spoiler-alert/plugin.rb b/plugins/spoiler-alert/plugin.rb
new file mode 100644
index 00000000000..c14320f0d7f
--- /dev/null
+++ b/plugins/spoiler-alert/plugin.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+# name: spoiler-alert
+# about: Uses the Spoiler Alert plugin to blur text when spoiling it.
+# version: 1.1.0
+# authors: Discourse Team
+# url: https://github.com/discourse/discourse/tree/main/plugins/spoiler-alert
+# transpile_js: true
+
+enabled_site_setting :spoiler_enabled
+
+register_asset "stylesheets/discourse_spoiler_alert.scss"
+
+after_initialize do
+ on(:reduce_cooked) do |fragment, post|
+ fragment
+ .css(".spoiler")
+ .each do |el|
+ link = fragment.document.create_element("a")
+ link["href"] = post.url
+ link.content = I18n.t("spoiler_alert.excerpt_spoiler")
+ el.inner_html = link.to_html
+ end
+ end
+
+ # Remove spoilers from topic excerpts
+ on(:reduce_excerpt) { |doc, post| doc.css(".spoiler").remove }
+end
diff --git a/plugins/spoiler-alert/spec/pretty_text_spec.rb b/plugins/spoiler-alert/spec/pretty_text_spec.rb
new file mode 100644
index 00000000000..24baf26e56f
--- /dev/null
+++ b/plugins/spoiler-alert/spec/pretty_text_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe PrettyText do
+ let(:post) { Fabricate(:post) }
+
+ def n(html)
+ html.strip
+ end
+
+ it "can spoil blocks" do
+ md = PrettyText.cook("[spoiler]\nmy tests fail\n[/spoiler]")
+ html = "<div class=\"spoiler\">\n<p>my tests fail</p>\n</div>"
+
+ expect(md).to eq(html)
+ end
+
+ it "can spoil inline" do
+ md = PrettyText.cook("I like watching [spoiler]my tests fail[/spoiler]")
+ html = '<p>I like watching <span class="spoiler">my tests fail</span></p>'
+
+ expect(md).to eq(html)
+ end
+
+ it "can replace spoilers in emails" do
+ md = PrettyText.cook("I like watching [spoiler]my tests fail[/spoiler]")
+ md = PrettyText.format_for_email(md, post)
+ html =
+ "<p>I like watching <span class=\"spoiler\"><a href=\"#{post.full_url}\">spoiler</a></span></p>"
+
+ expect(md).to eq(html)
+ end
+end
diff --git a/plugins/spoiler-alert/spec/topic_excerpt_spec.rb b/plugins/spoiler-alert/spec/topic_excerpt_spec.rb
new file mode 100644
index 00000000000..a3b599ad7da
--- /dev/null
+++ b/plugins/spoiler-alert/spec/topic_excerpt_spec.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require "rails_helper"
+
+describe PrettyText do
+ it "should remove spoilers from excerpts" do
+ expect(
+ PrettyText.excerpt("<div class='spoiler'><img src='http://cnn.com/a.gif'></div>", 100),
+ ).to match_html ""
+ expect(PrettyText.excerpt("<span class='spoiler'>spoiler</span>", 100)).to match_html ""
+ expect(
+ PrettyText.excerpt("Inline text <span class='spoiler'>spoiler</span> after spoiler", 100),
+ ).to match_html "Inline text after spoiler"
+ end
+end
diff --git a/plugins/spoiler-alert/test/javascripts/acceptance/spoiler-button-test.js b/plugins/spoiler-alert/test/javascripts/acceptance/spoiler-button-test.js
new file mode 100644
index 00000000000..0bcf6bcc39e
--- /dev/null
+++ b/plugins/spoiler-alert/test/javascripts/acceptance/spoiler-button-test.js
@@ -0,0 +1,148 @@
+import { click, fillIn, visit } from "@ember/test-helpers";
+import { test } from "qunit";
+import {
+ acceptance,
+ exists,
+ query,
+} from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import I18n from "discourse-i18n";
+
+acceptance("Spoiler Button", function (needs) {
+ needs.user();
+ needs.settings({ spoiler_enabled: true });
+
+ test("spoiler button", async (assert) => {
+ const popUpMenu = selectKit(".toolbar-popup-menu-options");
+
+ await visit("/");
+
+ assert.ok(exists("#create-topic"), "the create button is visible");
+
+ await click("#create-topic");
+ const categoryChooser = selectKit(".category-chooser");
+ await categoryChooser.expand();
+ await categoryChooser.selectRowByValue(2);
+ await popUpMenu.expand();
+ await popUpMenu.selectRowByName(I18n.t("spoiler.title"));
+
+ assert.strictEqual(
+ query(".d-editor-input").value,
+ `[spoiler]${I18n.t("composer.spoiler_text")}[/spoiler]`,
+ "it should contain the right output"
+ );
+
+ let textarea = query(".d-editor-input");
+ assert.strictEqual(
+ textarea.selectionStart,
+ 9,
+ "it should start highlighting at the right position"
+ );
+ assert.strictEqual(
+ textarea.selectionEnd,
+ I18n.t("composer.spoiler_text").length + 9,
+ "it should end highlighting at the right position"
+ );
+
+ await fillIn(".d-editor-input", "This is hidden");
+
+ textarea.selectionStart = 0;
+ textarea.selectionEnd = textarea.value.length;
+
+ await popUpMenu.expand();
+ await popUpMenu.selectRowByName(I18n.t("spoiler.title"));
+
+ assert.strictEqual(
+ query(".d-editor-input").value,
+ `[spoiler]This is hidden[/spoiler]`,
+ "it should contain the right output"
+ );
+
+ assert.strictEqual(
+ textarea.selectionStart,
+ 9,
+ "it should start highlighting at the right position"
+ );
+ assert.strictEqual(
+ textarea.selectionEnd,
+ 23,
+ "it should end highlighting at the right position"
+ );
+
+ await fillIn(".d-editor-input", "Before this is hidden After");
+
+ textarea.selectionStart = 7;
+ textarea.selectionEnd = 21;
+
+ await popUpMenu.expand();
+ await popUpMenu.selectRowByName(I18n.t("spoiler.title"));
+
+ assert.strictEqual(
+ query(".d-editor-input").value,
+ `Before [spoiler]this is hidden[/spoiler] After`,
+ "it should contain the right output"
+ );
+
+ assert.strictEqual(
+ textarea.selectionStart,
+ 16,
+ "it should start highlighting at the right position"
+ );
+ assert.strictEqual(
+ textarea.selectionEnd,
+ 30,
+ "it should end highlighting at the right position"
+ );
+
+ await fillIn(".d-editor-input", "Before\nthis is hidden\nAfter");
+
+ textarea.selectionStart = 7;
+ textarea.selectionEnd = 21;
+
+ await popUpMenu.expand();
+ await popUpMenu.selectRowByName(I18n.t("spoiler.title"));
+
+ assert.strictEqual(
+ query(".d-editor-input").value,
+ `Before\n[spoiler]this is hidden[/spoiler]\nAfter`,
+ "it should contain the right output"
+ );
+
+ assert.strictEqual(
+ textarea.selectionStart,
+ 16,
+ "it should start highlighting at the right position"
+ );
+ assert.strictEqual(
+ textarea.selectionEnd,
+ 30,
+ "it should end highlighting at the right position"
+ );
+
+ // enforce block mode when selected text is multiline
+ await fillIn(".d-editor-input", "Before\nthis is\n\nhidden\nAfter");
+
+ textarea.selectionStart = 7;
+ textarea.selectionEnd = 22;
+
+ await popUpMenu.expand();
+ await popUpMenu.selectRowByName(I18n.t("spoiler.title"));
+
+ assert.strictEqual(
+ query(".d-editor-input").value,
+ `Before\n[spoiler]\nthis is\n\nhidden\n[/spoiler]\nAfter`,
+ "it should contain the right output"
+ );
+
+ assert.strictEqual(
+ textarea.selectionStart,
+ 17,
+ "it should start highlighting at the right position"
+ );
+ assert.strictEqual(
+ textarea.selectionEnd,
+ 32,
+ "it should end highlighting at the right position"
+ );
+ });
+});
diff --git a/plugins/spoiler-alert/test/javascripts/unit/lib/to-markdown-test.js b/plugins/spoiler-alert/test/javascripts/unit/lib/to-markdown-test.js
new file mode 100644
index 00000000000..3afefc53cff
--- /dev/null
+++ b/plugins/spoiler-alert/test/javascripts/unit/lib/to-markdown-test.js
@@ -0,0 +1,30 @@
+import { test } from "qunit";
+import { withPluginApi } from "discourse/lib/plugin-api";
+import toMarkdown from "discourse/lib/to-markdown";
+import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
+import { initializeSpoiler } from "discourse/plugins/discourse-spoiler-alert/initializers/spoiler-alert";
+
+discourseModule("Spoiler Alert | Unit | to-markdown", function (hooks) {
+ hooks.beforeEach(function () {
+ withPluginApi("0.5", initializeSpoiler);
+ });
+
+ test("handles spoiler tags", function (assert) {
+ let html = `<div>Text with a</div><div class="spoiled">spoiled</div><div>word.</div>`;
+ let markdown = `Text with a\n\n[spoiler]spoiled[/spoiler]\n\nword.`;
+
+ assert.strictEqual(
+ toMarkdown(html),
+ markdown,
+ "it should create block spoiler tag"
+ );
+
+ html = `Inline <span class="spoiled">spoiled</span> word.`;
+ markdown = `Inline [spoiler]spoiled[/spoiler] word.`;
+ assert.strictEqual(
+ toMarkdown(html),
+ markdown,
+ "it should create inline spoiler tag"
+ );
+ });
+});
diff --git a/translator.yml b/translator.yml
index a8215bd30a0..f5d9aefab62 100644
--- a/translator.yml
+++ b/translator.yml
@@ -73,6 +73,13 @@ files:
destination_path: plugins/styleguide/server.yml
label: styleguide
+ - source_path: plugins/spoiler-alert/config/locales/client.en.yml
+ destination_path: plugins/spoiler-alert/client.yml
+ label: spoiler-alert
+ - source_path: plugins/spoiler-alert/config/locales/server.en.yml
+ destination_path: plugins/spoiler-alert/server.yml
+ label: spoiler-alert
+
- source_path: plugins/checklist/config/locales/client.en.yml
destination_path: plugins/checklist/client.yml
label: checklist