Class: Rails::Domternal::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/domternal/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rails/domternal/configuration.rb', line 31

def initialize
  @default_extensions = %i[starter_kit image]
  @toolbar = :full
  @theme = :light
  @asset_strategy = :importmap
  @npm_version = "latest"
  @allowed_mime_types = %w[image/png image/jpeg image/gif image/webp image/svg+xml image/avif]
  @max_file_size = 10.megabytes

  @sanitizer_allowed_tags = %w[
    p br div span
    h1 h2 h3 h4 h5 h6
    strong em b i u s del ins mark sub sup code pre
    ul ol li blockquote
    a img figure figcaption
    table thead tbody tr th td
    hr details summary
  ]
  @sanitizer_allowed_attributes = %w[
    href src alt title width height loading crossorigin
    colspan rowspan align style class data-type data-id data-label
  ]
end

Instance Attribute Details

#allowed_mime_typesObject

Returns the value of attribute allowed_mime_types.



24
25
26
# File 'lib/rails/domternal/configuration.rb', line 24

def allowed_mime_types
  @allowed_mime_types
end

#asset_strategyObject

:importmap, :jsbundling, or :cdn — how the install generator wires up JS. Informational at runtime; only the generator branches on it.



19
20
21
# File 'lib/rails/domternal/configuration.rb', line 19

def asset_strategy
  @asset_strategy
end

#default_extensionsObject

Symbolic extension keys resolved client-side by app/assets/javascripts/domternal/extensions.js



7
8
9
# File 'lib/rails/domternal/configuration.rb', line 7

def default_extensions
  @default_extensions
end

#max_file_sizeObject

Returns the value of attribute max_file_size.



25
26
27
# File 'lib/rails/domternal/configuration.rb', line 25

def max_file_size
  @max_file_size
end

#npm_versionObject

npm dist-tag/version used when pinning packages from a CDN (importmap/:cdn strategies).



22
23
24
# File 'lib/rails/domternal/configuration.rb', line 22

def npm_version
  @npm_version
end

#sanitizer_allowed_attributesObject

Returns the value of attribute sanitizer_allowed_attributes.



29
30
31
# File 'lib/rails/domternal/configuration.rb', line 29

def sanitizer_allowed_attributes
  @sanitizer_allowed_attributes
end

#sanitizer_allowed_tagsObject

HTML tags/attributes allowed through the safelist sanitizer applied to incoming bodies.



28
29
30
# File 'lib/rails/domternal/configuration.rb', line 28

def sanitizer_allowed_tags
  @sanitizer_allowed_tags
end

#themeObject

:light, :dark, or :auto



15
16
17
# File 'lib/rails/domternal/configuration.rb', line 15

def theme
  @theme
end

#toolbarObject

:full, :minimal, :notion, or false. :notion swaps the fixed toolbar for a selection bubble menu + a "+" floating menu, matching the block handle/slash command UI the :block_controls extension adds — pair the two.



12
13
14
# File 'lib/rails/domternal/configuration.rb', line 12

def toolbar
  @toolbar
end