0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/plugins/spoiler-alert/test/javascripts/integration/rich-editor-extension-test.js
Renato Atilio b834edd625
DEV: Remove rich_editor site setting (#41873)
The setting has been hidden and enabled by default since it was switched
on for all sites in mid-2025, making it effectively dead configuration.
The rich editor is now always available, and the per-user
`composition_mode` preference remains the only way to pick between the
markdown and rich text editors.

This also makes the first toolbar button focusable when a
`composer-force-editor-mode` transformer hides the editor mode toggle,
which previously left the toolbar without a tabbable button in that
state.

Since it comes from the same rollout, this also drops the shim that
migrated the pre-`composition_mode` localStorage preference
(`d-editor-prefers-rich-editor`) into the user option. The key hasn't
been written since the rich editor was enabled everywhere a year ago,
and the shim deleted it on first composer open, so any remaining copies
belong to browsers that haven't composed since then — for those, the
default mode is rich anyway.
2026-07-23 19:49:20 -03:00

43 lines
1.8 KiB
JavaScript
Vendored

import { module, test } from "qunit";
import {
registerRichEditorExtension,
resetRichEditorExtensions,
} from "discourse/lib/composer/rich-editor-extensions";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { testMarkdown } from "discourse/tests/helpers/rich-editor-helper";
import richEditorExtension from "discourse/plugins/spoiler-alert/lib/rich-editor-extension";
module(
"Integration | Component | prosemirror-editor - spoiler plugin extension",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
resetRichEditorExtensions().then(() => {
registerRichEditorExtension(richEditorExtension);
});
});
Object.entries({
"inline spoiler": [
"Hey [spoiler]did you know the good guys die[/spoiler] in the end?",
'<p>Hey <span class="spoiled spoiler-blurred">did you know the good guys die</span> in the end?</p>',
"Hey [spoiler]did you know the good guys die[/spoiler] in the end?",
],
"block spoiler": [
"hey\n\n[spoiler]\n> did you know the good guys die\n\n[/spoiler]\n\nin the end?",
'<p>hey</p><div class="spoiled spoiler-blurred"><blockquote><p>did you know the good guys die</p></blockquote></div><p>in the end?</p>',
"hey\n\n[spoiler]\n> did you know the good guys die\n\n[/spoiler]\n\nin the end?",
],
"inline spoiler with trailing space": [
"[spoiler]the answer is 42[/spoiler] ",
'<p><span class="spoiled spoiler-blurred">the answer is 42</span> </p>',
"[spoiler]the answer is 42[/spoiler] ",
],
}).forEach(([name, [markdown, html, expectedMarkdown]]) => {
test(name, async function (assert) {
await testMarkdown(assert, markdown, html, expectedMarkdown);
});
});
}
);