richer_text 0.3.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59e668e5d18697e8b1c568ac541fc821d1a83538040d3464625c8ac91c53dcb5
4
- data.tar.gz: 1a20ee315751b8165c4038e1f79183e120d44f7e867221b26a910693cdc004b1
3
+ metadata.gz: bc9681628df0cea14882f90ddc28774653a87d2d7db1ef38049bcbc3e67ddb49
4
+ data.tar.gz: e99f8e2774aede03570dd03ec2f995f6b3e8ab46a9c7f4eedcdd7527fde69995
5
5
  SHA512:
6
- metadata.gz: 0dcc392bcfbed5598bfb4f902af9644d6cb75d54f2cffec27bedb6086fc96624b01227f46dfb0df07658fefe92859862ea60f7ae43d69ca34b8ed2a817238ca5
7
- data.tar.gz: 881eb8e296ef1052e36a8c485d48e8d06ab73657ac98a3693abcaf24566a3111878e598cbf63fcff3fe2b39495fc0ae8eed8d13c66a78277f0f0b498f5a8eafe
6
+ metadata.gz: 93038afde3fae59acedbdd62d1879cdb7825e2d134d8aa520ae620a66619de0b32a594e5f34114e7dac66566f66523150d689a39500968076317313f15f00267
7
+ data.tar.gz: 176ea00a46823251b32ddcb0cd8e9a59eb00eb6f452a2c7c98b43a797bf95e683f4d6df99452ad903ef5c5d6bc2fadf3ff9174f19a31476d07a44455d00b4dd0
@@ -4,12 +4,15 @@ module ActionView::Helpers
4
4
  class Tags::Editor < Tags::Base
5
5
  include Tags::Placeholderable
6
6
 
7
+ delegate :dom_id, to: ActionView::RecordIdentifier
8
+
7
9
  def render
8
10
  options = @options.stringify_keys
9
- options["value"] = options.fetch("value") { value&.to_html }
10
11
  add_default_name_and_id(options)
12
+ options["input"] ||= dom_id(object, [options["id"], :richer_text_input].compact.join("_")) if object
13
+ options["value"] = options.fetch("value") { value&.to_html }
11
14
 
12
- @template_object.richer_text_area_tag(options["name"], options["value"], options.except("value"))
15
+ @template_object.richer_text_area_tag(options.delete("name"), options["value"], options.except("value"))
13
16
  end
14
17
  end
15
18
 
@@ -26,24 +29,21 @@ module ActionView::Helpers
26
29
  end
27
30
  end
28
31
 
29
-
30
32
  module RicherText
31
33
  module TagHelper
32
34
  cattr_accessor(:id, instance_accessor: false) { 0 }
33
35
 
34
36
  def richer_text_area_tag(name, value = nil, options = {})
35
37
  options = options.symbolize_keys
36
- options[:id] ||= "editor_input_#{TagHelper.id += 1}"
37
- options[:class] ||= "editor-input"
38
+ options[:input] ||= "richer_text_input_#{RicherText::TagHelper.id += 1}"
38
39
 
39
40
  # So that we can access the content in the tiptap editor
40
41
  options[:content] ||= value
41
42
 
42
- # editor_toolbar(id: options[:id]) + content_tag("textarea", value, options)
43
- content_tag("div", data: { controller: "richer-text-editor", action: "editor:update->richer-text-editor#update" }) do
44
- hidden_field_tag(name, value, { class: "w-full", data: { richer_text_editor_target: "input" } }) +
45
- tag("richer-text-editor", options)
46
- end
43
+ input_tag = hidden_field_tag(name, value, id: options[:input])
44
+ editor_tag = tag("richer-text-editor", options)
45
+
46
+ input_tag + editor_tag
47
47
  end
48
48
  end
49
49
  end
@@ -1,3 +1,3 @@
1
1
  <div class="richer-text">
2
- <%= sanitize(content.to_html, tags: %w(div img h1 h2 blockquote s del strong i em br pre code ol ul li table tbody th td tr p), attributes: %w(id class style data-color src alt colspan rowspan)) %>
2
+ <%= sanitize(content.to_html, tags: %w(a div img h1 h2 blockquote s del strong i em br pre code ol ul li table tbody th td tr p), attributes: %w(id class href style data-color src alt colspan rowspan)) %>
3
3
  </div>
@@ -44,14 +44,6 @@ module RicherText
44
44
  prepend_to_file stylesheets.first, %(@import "@afomera/richer-text/dist/css/richer-text";\n@import "highlight.js/styles/github-dark";\n@import "richer-text";\n)
45
45
  end
46
46
  end
47
-
48
- def generate_stimulus_controller
49
- say "Copying Stimulus controller", :green
50
- copy_file "app/javascript/controllers/richer_text_editor_controller.js", "app/javascript/controllers/richer_text_editor_controller.js"
51
-
52
- say "Updating Stimulus manifest", :green
53
- rails_command "stimulus:manifest:update"
54
- end
55
47
  end
56
48
  end
57
49
  end
@@ -1,3 +1,3 @@
1
1
  module RicherText
2
- VERSION = "0.3.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: richer_text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Fomera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-04 00:00:00.000000000 Z
11
+ date: 2023-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -40,7 +40,6 @@ files:
40
40
  - app/controllers/richer_text/application_controller.rb
41
41
  - app/helpers/richer_text/application_helper.rb
42
42
  - app/helpers/richer_text/tag_helper.rb
43
- - app/javascript/controllers/richer_text_editor_controller.js
44
43
  - app/jobs/richer_text/application_job.rb
45
44
  - app/mailers/richer_text/application_mailer.rb
46
45
  - app/models/richer_text/application_record.rb
@@ -1,10 +0,0 @@
1
- import { Controller } from "@hotwired/stimulus"
2
-
3
- // Connects to data-controller="richer-text-editor"
4
- export default class extends Controller {
5
- static targets = ["input"];
6
-
7
- update(event) {
8
- this.inputTarget.value = event.detail.html;
9
- }
10
- }