mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 19:28:42 +08:00
This commit responds to feedback in the Discourse Meta discussion https://meta.discourse.org/t/monospace-font-in-the-markdown-only-editor/359936 This change introduces a user preference that allows users to choose whether the Markdown editor uses a monospace font. The default setting is `true` for new sites, but set to `false` for existing sites to avoid disrupting current users' experiences. Admins can change the `default_other_enable_markdown_monospace_font` site setting to manage this for all users.
29 lines
941 B
Ruby
29 lines
941 B
Ruby
# frozen_string_literal: true
|
|
class EnableMarkdownMonospaceFontUserOption < ActiveRecord::Migration[8.0]
|
|
def up
|
|
add_column :user_options, :enable_markdown_monospace_font, :boolean, default: true, null: false
|
|
|
|
if Migration::Helpers.existing_site?
|
|
execute <<~SQL
|
|
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
|
VALUES('default_other_enable_markdown_monospace_font', 5, 'f', NOW(), NOW())
|
|
ON CONFLICT (name) DO NOTHING
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
UPDATE user_options
|
|
SET enable_markdown_monospace_font = false
|
|
SQL
|
|
end
|
|
end
|
|
|
|
def down
|
|
if column_exists?(:user_options, :enable_markdown_monospace_font)
|
|
remove_column :user_options, :enable_markdown_monospace_font
|
|
end
|
|
|
|
execute <<~SQL if Migration::Helpers.existing_site?
|
|
DELETE FROM site_settings WHERE name = 'default_other_enable_markdown_monospace_font'
|
|
SQL
|
|
end
|
|
end
|