richer_text 0.13.0 → 0.15.0

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: 93af4f6f1d3dba85682d797cd9433f76b557945ea1fef31859ea482cec66f2f6
4
- data.tar.gz: 2537fb3cf9f2706e946e71385507ea035625416e4e730aefa6eb6ffbf345897c
3
+ metadata.gz: d703c776c9c1eea2bddf68c2684bf642a5e788e24e67c2da86ab174a36375fd4
4
+ data.tar.gz: 356b5961abe5334a0f1acfad1ed436e15021c9883bec94076a2658a46c8a7e14
5
5
  SHA512:
6
- metadata.gz: a4b553ac51eb39c4c6dc1cd849c5d3034873f0ad4436ba4fccaa7d5565ca55a3cf090207d2571fcd3ced60e9ad1ac4eb3947a12e9d16d53be32b943cf8769115
7
- data.tar.gz: 3fa4670ddee0a16fc2ac12b878b3e222bd95c8b3dd06aef720aae5807c3c5c46fe19e272af0cffe3244c1c03b5c8704168776eec1a47e9fa857f978d440f5841
6
+ metadata.gz: 3229812766e24565f0cfd8f384f5bf1e62b5bfa4f4d6ff1e912223d475b67556bf54c6b6fb731cb1cbc7778a7c0bae5f86a54df8316d67bd0169e8ef8e1bb545
7
+ data.tar.gz: 7aa2fa96a14b331270ed16ded0c5edf3b540d728664eb7465faeb2a694c52ff2dbdad0b1cf34d9ef21155d40e0b169be804a0887e893387d04758ab3ed48286f
@@ -59,7 +59,7 @@ module RicherText
59
59
  cattr_accessor(:id, instance_accessor: false) { 0 }
60
60
 
61
61
  def richer_text_area_tag(name, value = nil, options = {})
62
- options = options.symbolize_keys
62
+ options = RicherText.default_form_options.merge(options.symbolize_keys).symbolize_keys
63
63
  options[:input] ||= "richer_text_input_#{RicherText::TagHelper.id += 1}"
64
64
 
65
65
  # So that we can access the content in the tiptap editor
@@ -2,7 +2,7 @@ module RicherText
2
2
  class RichText < ApplicationRecord
3
3
  belongs_to :record, polymorphic: true, touch: true
4
4
 
5
- serialize :body, RicherText::Content
5
+ serialize :body, coder: RicherText::Content
6
6
 
7
7
  delegate :to_s, :nil?, to: :body
8
8
  delegate :blank?, :empty?, :present?, to: :to_html
@@ -26,7 +26,11 @@ module RicherText
26
26
 
27
27
  if destination.join("package.json").exist?
28
28
  say "Adding dependencies to package.json", :green
29
- run "yarn add highlight.js @afomera/richer-text@alpha"
29
+
30
+ run "npm install highlight.js @afomera/richer-text@beta" if destination.join("package-lock.json").exist?
31
+ run "bun add highlight.js @afomera/richer-text@beta" if destination.join("bun.lockb").exist?
32
+ run "yarn add highlight.js @afomera/richer-text@beta" if destination.join("yarn.lock").exist?
33
+ run "pnpm add highlight.js @afomera/richer-text@beta" if destination.join("pnpm-lock.yaml").exist?
30
34
  end
31
35
 
32
36
  say "Adding import to application.js", :green
@@ -42,6 +42,10 @@ module RicherText
42
42
  "<div class='richer-text'>#{visit_children(node).join("\n")}</div>".html_safe
43
43
  end
44
44
 
45
+ def visit_iframely_embed(node)
46
+ node.html
47
+ end
48
+
45
49
  def visit_mention(node, marks)
46
50
  if marks.any?
47
51
  content_tag(marks[0].tag, visit_mention(node, marks[1..]), marks[0].attrs)
@@ -0,0 +1,15 @@
1
+ module RicherText
2
+ module Nodes
3
+ class IframelyEmbed < ::RicherText::Node
4
+ def href
5
+ @attrs["href"]
6
+ end
7
+
8
+ def html
9
+ "<div class='iframely'>
10
+ #{@attrs["previewHtml"]}
11
+ </div>"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module RicherText
2
- VERSION = "0.13.0"
2
+ VERSION = "0.15.0"
3
3
  end
data/lib/richer_text.rb CHANGED
@@ -34,6 +34,7 @@ module RicherText
34
34
  autoload :HardBreak
35
35
  autoload :Heading
36
36
  autoload :HorizontalRule
37
+ autoload :IframelyEmbed
37
38
  autoload :Image
38
39
  autoload :ListItem
39
40
  autoload :Mention
@@ -52,6 +53,10 @@ module RicherText
52
53
  @default_renderer ||= RicherText::HTMLVisitor.new
53
54
  end
54
55
 
55
- attr_writer :default_renderer
56
+ def default_form_options
57
+ @default_form_options ||= {}
58
+ end
59
+
60
+ attr_writer :default_renderer, :default_form_options
56
61
  end
57
62
  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.13.0
4
+ version: 0.15.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: 2024-05-08 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -89,6 +89,7 @@ files:
89
89
  - lib/richer_text/nodes/hard_break.rb
90
90
  - lib/richer_text/nodes/heading.rb
91
91
  - lib/richer_text/nodes/horizontal_rule.rb
92
+ - lib/richer_text/nodes/iframely_embed.rb
92
93
  - lib/richer_text/nodes/image.rb
93
94
  - lib/richer_text/nodes/list_item.rb
94
95
  - lib/richer_text/nodes/mention.rb