mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
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.
56 lines
2.9 KiB
JavaScript
Vendored
56 lines
2.9 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/poll/lib/rich-editor-extension";
|
|
|
|
module(
|
|
"Integration | Component | prosemirror-editor - poll plugin extension",
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
resetRichEditorExtensions().then(() => {
|
|
registerRichEditorExtension(richEditorExtension);
|
|
});
|
|
});
|
|
|
|
const voters =
|
|
'<div class="poll-info" contenteditable="false">0 voters</div>';
|
|
|
|
Object.entries({
|
|
"regular poll": [
|
|
"[poll]\n* Option 1\n* Option 2\n[/poll]\n\n",
|
|
`<div class="poll"><ul data-tight="true"><li><p>Option 1</p></li><li><p>Option 2</p></li></ul>${voters}</div>`,
|
|
"[poll]\n* Option 1\n* Option 2\n\n[/poll]\n\n",
|
|
],
|
|
"multiple choice poll": [
|
|
"[poll type=multiple min=1 max=2]\n* Option 1\n* Option 2\n* Option 3\n[/poll]",
|
|
`<div class="poll" data-poll-type="multiple" data-poll-max="2" data-poll-min="1"><ul data-tight="true"><li><p>Option 1</p></li><li><p>Option 2</p></li><li><p>Option 3</p></li></ul>${voters}</div>`,
|
|
"[poll type=multiple max=2 min=1]\n* Option 1\n* Option 2\n* Option 3\n\n[/poll]\n\n",
|
|
],
|
|
"public poll": [
|
|
"[poll public=true]\n* Option 1\n* Option 2\n[/poll]",
|
|
`<div class="poll" data-poll-public="true"><ul data-tight="true"><li><p>Option 1</p></li><li><p>Option 2</p></li></ul>${voters}</div>`,
|
|
"[poll public=true]\n* Option 1\n* Option 2\n\n[/poll]\n\n",
|
|
],
|
|
"poll with name, results, close date, groups": [
|
|
"[poll name=PollName chartType=pie results=always anonymous=true close=2021-01-01 groups=group1,group2]\n* Option 1\n* Option 2\n[/poll]",
|
|
`<div class="poll" data-poll-results="always" data-poll-name="PollName" data-poll-chart-type="pie" data-poll-close="2021-01-01" data-poll-groups="group1,group2"><ul data-tight="true"><li><p>Option 1</p></li><li><p>Option 2</p></li></ul>${voters}</div>`,
|
|
"[poll results=always name=PollName chartType=pie close=2021-01-01 groups=group1,group2]\n* Option 1\n* Option 2\n\n[/poll]\n\n",
|
|
],
|
|
"poll with bar chart type": [
|
|
"[poll chartType=bar]\n* Option 1\n* Option 2\n[/poll]",
|
|
`<div class="poll" data-poll-chart-type="bar"><ul data-tight="true"><li><p>Option 1</p></li><li><p>Option 2</p></li></ul>${voters}</div>`,
|
|
"[poll chartType=bar]\n* Option 1\n* Option 2\n\n[/poll]\n\n",
|
|
],
|
|
}).forEach(([name, [markdown, html, expectedMarkdown]]) => {
|
|
test(name, async function (assert) {
|
|
await testMarkdown(assert, markdown, html, expectedMarkdown);
|
|
});
|
|
});
|
|
}
|
|
);
|