Class: SMEditor::Config
- Inherits:
-
Object
- Object
- SMEditor::Config
- Defined in:
- lib/smeditor/rails/config.rb
Overview
Instance Attribute Summary collapse
-
#allowed_tags ⇒ Object
Tag allow-list for the server-side renderer.
-
#allowed_upload_types ⇒ Object
Content types the upload endpoint accepts.
-
#auto_include_assets ⇒ Object
Include the packaged JS/CSS automatically with the first editor field.
-
#default_kit ⇒ Object
Which bundle the form helper boots: "starter" or "full".
-
#max_upload_size ⇒ Object
Hard ceiling on an uploaded file, in bytes.
-
#min_height ⇒ Object
Default minimum editor heights.
-
#mobile_min_height ⇒ Object
Returns the value of attribute mobile_min_height.
-
#sanitize_output ⇒ Object
When true, smeditor_render sanitizes content before display.
-
#tablet_min_height ⇒ Object
Returns the value of attribute tablet_min_height.
-
#upload_path ⇒ Object
Upload endpoint used by the JavaScript adapter when uploads are enabled.
-
#uploads ⇒ Object
:none (default) or :active_storage — whether the gem mounts an upload endpoint.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/smeditor/rails/config.rb', line 41 def initialize @uploads = :none @sanitize_output = true @allowed_tags = %w[ p br h1 h2 h3 h4 h5 h6 strong em u s code pre blockquote ul ol li a img figure figcaption hr span table thead tbody tr td th ] @default_kit = "starter" @upload_path = "/smeditor/uploads" @auto_include_assets = true @min_height = "320px" @tablet_min_height = "280px" @mobile_min_height = "220px" @max_upload_size = 10 * 1024 * 1024 @allowed_upload_types = %w[ image/png image/jpeg image/gif image/webp image/avif image/bmp ] end |
Instance Attribute Details
#allowed_tags ⇒ Object
Tag allow-list for the server-side renderer.
18 19 20 |
# File 'lib/smeditor/rails/config.rb', line 18 def @allowed_tags end |
#allowed_upload_types ⇒ Object
Content types the upload endpoint accepts. SVG is excluded on purpose — it can carry script and is served from the app's origin.
39 40 41 |
# File 'lib/smeditor/rails/config.rb', line 39 def allowed_upload_types @allowed_upload_types end |
#auto_include_assets ⇒ Object
Include the packaged JS/CSS automatically with the first editor field.
Set false when the host app calls smeditor_assets in its layout.
25 26 27 |
# File 'lib/smeditor/rails/config.rb', line 25 def auto_include_assets @auto_include_assets end |
#default_kit ⇒ Object
Which bundle the form helper boots: "starter" or "full".
20 21 22 |
# File 'lib/smeditor/rails/config.rb', line 20 def default_kit @default_kit end |
#max_upload_size ⇒ Object
Hard ceiling on an uploaded file, in bytes. The endpoint is reachable by anyone who can reach the host app unless the controller is subclassed with authentication, so it refuses anything larger.
36 37 38 |
# File 'lib/smeditor/rails/config.rb', line 36 def max_upload_size @max_upload_size end |
#min_height ⇒ Object
Default minimum editor heights. They are responsive by viewport width: desktop (> 1024px), tablet (641-1024px), and mobile (<= 640px). Numeric values are interpreted as pixels; CSS lengths such as "24rem" and "45vh" are accepted too.
30 31 32 |
# File 'lib/smeditor/rails/config.rb', line 30 def min_height @min_height end |
#mobile_min_height ⇒ Object
Returns the value of attribute mobile_min_height.
32 33 34 |
# File 'lib/smeditor/rails/config.rb', line 32 def mobile_min_height @mobile_min_height end |
#sanitize_output ⇒ Object
When true, smeditor_render sanitizes content before display.
16 17 18 |
# File 'lib/smeditor/rails/config.rb', line 16 def sanitize_output @sanitize_output end |
#tablet_min_height ⇒ Object
Returns the value of attribute tablet_min_height.
31 32 33 |
# File 'lib/smeditor/rails/config.rb', line 31 def tablet_min_height @tablet_min_height end |
#upload_path ⇒ Object
Upload endpoint used by the JavaScript adapter when uploads are enabled.
22 23 24 |
# File 'lib/smeditor/rails/config.rb', line 22 def upload_path @upload_path end |
#uploads ⇒ Object
:none (default) or :active_storage — whether the gem mounts an upload endpoint.
14 15 16 |
# File 'lib/smeditor/rails/config.rb', line 14 def uploads @uploads end |