Module: Cdn::Helpers
- Includes:
- ActionView::Helpers::TagHelper, CKEditor5::Rails::Cdn::Concerns::BundleBuilder, CKEditor5::Rails::Cdn::Concerns::InlinePluginsTagsBuilder
- Included in:
- CKEditor5::Rails::Helpers
- Defined in:
- lib/ckeditor5/rails/cdn/helpers.rb
Defined Under Namespace
Classes: ImportmapAlreadyRenderedError
Instance Method Summary collapse
-
#ckeditor5_assets(preset: :default, importmap: true, lazy: false, **kwargs) ⇒ Object
The ‘ckeditor5_assets` helper includes CKEditor 5 assets in your application.
-
#ckeditor5_lazy_javascript_tags ⇒ Object
Helper for dynamically loading CKEditor assets when working with Turbo/Stimulus.
Methods included from CKEditor5::Rails::Cdn::Concerns::InlinePluginsTagsBuilder
#ckeditor5_inline_plugins_tags
Methods included from CKEditor5::Rails::Cdn::Concerns::BundleBuilder
Instance Method Details
#ckeditor5_assets(preset: :default, importmap: true, lazy: false, **kwargs) ⇒ Object
The ‘ckeditor5_assets` helper includes CKEditor 5 assets in your application. It’s responsible for generating the necessary JavaScript and CSS imports based on the specified preset and configuration.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ckeditor5/rails/cdn/helpers.rb', line 70 def ckeditor5_assets( preset: :default, importmap: true, lazy: false, **kwargs ) ensure_importmap_not_rendered! mapped_preset = merge_with_editor_preset(preset, **kwargs) bundle = create_preset_bundle(mapped_preset) @__ckeditor_context = { license_key: mapped_preset.license_key, bundle: bundle, preset: mapped_preset } (bundle, mapped_preset, importmap: importmap, lazy: lazy) end |
#ckeditor5_lazy_javascript_tags ⇒ Object
Do not use this helper if ckeditor5_assets is already included on the page as it will cause duplicate imports.
Helper for dynamically loading CKEditor assets when working with Turbo/Stimulus. Adds importmap containing imports from all presets and includes only web component initialization code. Useful when dynamically adding editors to the page with unknown preset configuration.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ckeditor5/rails/cdn/helpers.rb', line 101 def ensure_importmap_not_rendered! = [ Assets::WebComponentBundle.instance.to_html(nonce: content_security_policy_nonce), ] if importmap_available? @__ckeditor_context = { bundle: combined_bundle } else .prepend( Assets::AssetsImportMap.new(combined_bundle).to_html(nonce: content_security_policy_nonce) ) end safe_join() end |