Class: SMEditor::Config
- Inherits:
-
Object
- Object
- SMEditor::Config
- Defined in:
- lib/smeditor/rails/config.rb
Overview
Gem-wide configuration, set in an initializer:
SMEditor.configure do |c|
c.uploads = :active_storage
c. = %w[p h1 h2 strong em a]
end
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.
-
#sanitize_output ⇒ Object
When true, smeditor_render sanitizes content before display.
-
#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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/smeditor/rails/config.rb', line 34 def initialize @uploads = :none @sanitize_output = true = %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 @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 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.
32 33 34 |
# File 'lib/smeditor/rails/config.rb', line 32 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.
29 30 31 |
# File 'lib/smeditor/rails/config.rb', line 29 def max_upload_size @max_upload_size 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 |
#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 |