mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 21:51:49 +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.
55 lines
1.8 KiB
Ruby
Vendored
55 lines
1.8 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe "Composer - ProseMirror - Container" do
|
|
include_context "with prosemirror editor"
|
|
|
|
it "hides the Composer container's preview button" do
|
|
page.visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
expect(composer).to have_no_composer_preview_toggle
|
|
|
|
composer.toggle_rich_editor
|
|
|
|
expect(composer).to have_composer_preview_toggle
|
|
end
|
|
|
|
it "saves the user's rich editor preference and remembers it when reopening the composer" do
|
|
open_composer
|
|
expect(composer).to have_rich_editor_active
|
|
composer.toggle_rich_editor
|
|
expect(composer).to have_markdown_editor_active
|
|
|
|
try_until_success(reason: "Relies on an Ember timer to update the user option") do
|
|
expect(current_user.user_option.reload.composition_mode).to eq(
|
|
UserOption.composition_mode_types[:markdown],
|
|
)
|
|
end
|
|
|
|
visit("/")
|
|
open_composer
|
|
expect(composer).to have_markdown_editor_active
|
|
end
|
|
|
|
it "remembers the user's rich editor preference when starting a new PM" do
|
|
current_user.user_option.update!(composition_mode: UserOption.composition_mode_types[:rich])
|
|
page.visit("/u/#{current_user.username}/messages")
|
|
find(".new-private-message").click
|
|
expect(composer).to be_opened
|
|
expect(composer).to have_rich_editor_active
|
|
end
|
|
|
|
it "handles uploads and disables the editor toggle while uploading" do
|
|
open_composer
|
|
|
|
file_path = file_from_fixtures("logo.png", "images").path
|
|
cdp.with_slow_upload do
|
|
attach_file("file-uploader", file_path, make_visible: true)
|
|
expect(composer).to have_in_progress_uploads
|
|
expect(composer.editor_toggle_switch).to be_disabled
|
|
end
|
|
|
|
expect(composer).to have_no_in_progress_uploads
|
|
expect(rich).to have_css("img:not(.ProseMirror-separator)", count: 1)
|
|
end
|
|
end
|