ckeditor5 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba0f56261f0c699d67fce659fe6cd4cbc3fc2f288ebedf0fd908f4f6d9555001
4
- data.tar.gz: 9c5b41693f3858a94841b7e6392bbd573a3bc83c3a936c7dd2fbdcfff42fda63
3
+ metadata.gz: 0aee8586159157d2581cefe62cc87ea58d822db618c0f0dd9ceee5c0d3fdba46
4
+ data.tar.gz: 550633bd1bb74e54909f19447f7ced3bff0f6bd10324b44c9076641eb65e08e7
5
5
  SHA512:
6
- metadata.gz: e12b59365223eeeee6cccef5e771ae2df9e17e9500275a871c8f7b41b6a39abe0cec725848f887ead1a3235d2d50447fdb8b99ead940d1dc50c5f795369d9354
7
- data.tar.gz: b163824d28f9867b0bee31e273e5b0be6ad380891d43a1e48ed1fb4df0c38460a4cfddc5fcb7fdf1fa1430950b6cd3d47a6c4cbcf8c4067f5178660f6c991d15
6
+ metadata.gz: ba63dc4631e0703b8d719b7b2c21efc97183455550e6eb6406f96f8e789baaf1ed7dd202d0711ca100f39e906b386c026ef8515042d6441bce465baf6de8b10a
7
+ data.tar.gz: 15a0df8fd18291bc5d47e9a15df2d0192316512b38a85ec07c4bc047895d1111a6bd92afa2c09bdab639f31485a039538d7390048e39d66ea22bf51373e22e38
data/README.md CHANGED
@@ -804,12 +804,26 @@ This section covers frequent questions and scenarios when working with CKEditor
804
804
 
805
805
  ### Setting Initial Content 📝
806
806
 
807
+ You can set the initial content of the editor using the `initial_data` keyword argument or by passing the content directly to the `ckeditor5_editor` helper block.
808
+
809
+ The example below shows how to set the initial content of the editor using the `initial_data` keyword argument:
810
+
807
811
  ```erb
808
812
  <%= ckeditor5_editor initial_data: "<p>Initial content</p>" %>
809
813
  ```
810
814
 
815
+ The example below shows how to set the initial content of the editor using the `ckeditor5_editor` helper block.
816
+
817
+ ```erb
818
+ <%= ckeditor5_editor do %>
819
+ <p>Initial content</p>
820
+ <% end %>
821
+ ```
822
+
811
823
  ### Setting Editor Language 🌐
812
824
 
825
+ You can set the language of the editor using the `language` method in the `config/initializers/ckeditor5.rb` file. The `translations` method fetches the translations files, while the `language` method sets the default language of the editor.
826
+
813
827
  ```rb
814
828
  config.presets.override :default do
815
829
  translations :pl, :es
@@ -819,6 +833,8 @@ end
819
833
 
820
834
  ### Integrating with Forms 📋
821
835
 
836
+ You can integrate CKEditor 5 with Rails form builders like `form_for` or `simple_form`. The example below shows how to integrate CKEditor 5 with a Rails form using the `form_for` helper:
837
+
822
838
  #### Rails form builder integration
823
839
 
824
840
  ```erb
@@ -51,12 +51,17 @@ class CKEditorComponent extends HTMLElement {
51
51
  /** @type {Record<string, HTMLElement>} Map of editable elements by name */
52
52
  editables = {};
53
53
 
54
+ /** @type {String} Initial HTML passed to component */
55
+ #initialHTML = '';
56
+
54
57
  /**
55
58
  * Lifecycle callback when element is connected to DOM
56
59
  * Initializes the editor when DOM is ready
57
60
  * @protected
58
61
  */
59
62
  connectedCallback() {
63
+ this.#initialHTML = this.innerHTML;
64
+
60
65
  try {
61
66
  execIfDOMReady(() => this.#reinitializeEditor());
62
67
  } catch (error) {
@@ -179,7 +184,7 @@ class CKEditorComponent extends HTMLElement {
179
184
  this.style.display = 'block';
180
185
 
181
186
  if (!this.isMultiroot() && !this.isDecoupled()) {
182
- this.innerHTML = `<${this.#editorElementTag}></${this.#editorElementTag}>`;
187
+ this.innerHTML = `<${this.#editorElementTag}>${this.#initialHTML}</${this.#editorElementTag}>`;
183
188
  this.#assignInputAttributes();
184
189
  }
185
190
 
@@ -24,14 +24,15 @@ module CKEditor5::Rails
24
24
  config = config.deep_merge(extra_config)
25
25
  config[:initialData] = initial_data if initial_data
26
26
 
27
+ raise ArgumentError, 'Cannot pass initial data and block at the same time.' if initial_data && block
28
+
27
29
  editor_props = build_editor_props(
28
30
  config: config,
29
31
  type: type,
30
32
  context: context
31
33
  )
32
34
 
33
- render_editor_component(editor_props, html_attributes,
34
- &(%i[multiroot decoupled].include?(type) ? block : nil))
35
+ render_editor_component(editor_props, html_attributes, &block)
35
36
  end
36
37
 
37
38
  def ckeditor5_editable(name = nil, **kwargs, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CKEditor5::Rails
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ckeditor5
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński