mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 23:54:20 +08:00
We believe the rich editor is a great experience for the vast majority of sites and users, so we are enabling it for all sites and all users by default. This commit does the following: * Hides the rich_editor site setting and sets it to true by default. It can still be overridden by sites that want to disable it completely. * Sets `rich_editor` to true for all sites to enable the rich editor everywhere. * Adds a new `default_composition_mode` site setting and corresponding user option that defaults to Rich for all users. The other option is Markdown. * Changes the rich editor toggle in the composer to use the new database-backed user option (`composition_mode`) instead of a local storage key/value store. This makes the preference persistent across devices. Existing key/value store settings for the markdown toggle are kept, the preference will be saved to the user option automatically.
20 lines
390 B
Ruby
20 lines
390 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "enum_site_setting"
|
|
|
|
class CompositionModeSiteSetting < EnumSiteSetting
|
|
def self.valid_value?(val)
|
|
values.any? { |v| v[:value] == val }
|
|
end
|
|
|
|
def self.values
|
|
@values ||= [
|
|
{ name: "composition_mode.markdown", value: 0 },
|
|
{ name: "composition_mode.rich", value: 1 },
|
|
]
|
|
end
|
|
|
|
def self.translate_names?
|
|
true
|
|
end
|
|
end
|