richer_text 0.12.0 → 0.14.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: e5520f0457b69a555273d7a738f5257a0951eef4d65153ad783cd2f31246daad
4
- data.tar.gz: d4978b9880b46a6af9a91868cdbf40ae8306d3dd749c6ec94631e6999820af89
3
+ metadata.gz: fff049eb5287d1b4033a4cbd8b42b7e1cb8048273e6be55383ec282dc923feb1
4
+ data.tar.gz: 641adc8fdc6fa45dfe9aa0d9efb6971d3ed29d448335518d7069c1e306f8d0a2
5
5
  SHA512:
6
- metadata.gz: faca362e8db800731ec19ade535551664f5bcc2f379e80283229f536a8b06608a6601d50c4672e02394c650f178ec5697244e14adfca4f0a701ec4bba1ca4846
7
- data.tar.gz: 4662002c357fee3d91db0b96236c2d314c0551ecbc916a41f6e1c3dea63a5a5d30ab3208045160936b312500a72295d26aed2b59b2c487855431c69f5bf5da6a
6
+ metadata.gz: 6735d25685c7efc9dfc22e709edd2c6f32b443d9c0f82d93d6697ead4467ee5e2946330be133d3693b589954fe65ef4242b86885b2c080fb370ec6d0f8cc9b96
7
+ data.tar.gz: 29319df08e89a28d230ff7b45f7d2c4bad11aae0b8927940c15827b2d6fa3ad4970af53ad908415d519c3697c07393d863cfa8c03b446ded0e42ccd08c394964
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  RicherText aims to provide a richer text editing experience than what comes out of the box with ActionText in Rails. **It is however a seperate thing from ActionText** and is **not** backwards compatible.
4
4
 
5
- RicherText uses React and TipTap under the hood to create an editor, this does mean that you'll have react and react-dom in your project, but you absolutely don't need to use it outside of the RicherText editor. Additionally there's currently a hard requirement for ActiveStorage as well.
5
+ RicherText uses Lit and TipTap under the hood to create an editor. Additionally there's currently a hard requirement for ActiveStorage as well.
6
6
 
7
7
  ## Installation
8
8
 
@@ -50,10 +50,12 @@ Take a Post model where you'd like to add RicherText to write, and edit the body
50
50
 
51
51
  ```ruby
52
52
  class Post < ApplicationRecord
53
- has_richer_text :body
53
+ has_richer_text :body, store_as: :json
54
54
  end
55
55
  ```
56
56
 
57
+ We recommend storing your Richer Text records as JSON for full compatibility with the TipTap schema under the hood.
58
+
57
59
  **Add the form helper to the form**
58
60
 
59
61
  Inside of your form partial:
@@ -83,3 +85,25 @@ Contribution directions go here.
83
85
  ## License
84
86
 
85
87
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+
89
+ Portions of the code related to the `has_richer_text` attribute, and parsing of the HTML content for the RicherText::RichText model are licensed under the Rails source code license, as it falls under the substantial portion of Software:
90
+
91
+ Copyright (c) 37signals LLC
92
+
93
+ Permission is hereby granted, free of charge, to any person obtaining a copy
94
+ of this software and associated documentation files (the "Software"), to deal
95
+ in the Software without restriction, including without limitation the rights
96
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97
+ copies of the Software, and to permit persons to whom the Software is
98
+ furnished to do so, subject to the following conditions:
99
+
100
+ The above copyright notice and this permission notice shall be included in all
101
+ copies or substantial portions of the Software.
102
+
103
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
109
+ SOFTWARE.
@@ -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
@@ -4,7 +4,7 @@ module RicherText
4
4
 
5
5
  belongs_to :record, polymorphic: true, touch: true
6
6
 
7
- serialize :body, JSON, default: DEFAULT_BODY.to_json
7
+ serialize :body, coder: JSON, default: DEFAULT_BODY.to_json
8
8
 
9
9
  has_many_attached :images
10
10
  has_many_attached :rhino_attachments # For handling attachments in the Rhino 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 react react-dom highlight.js @afomera/richer-text"
29
+
30
+ run "npm install highlight.js @afomera/richer-text@alpha" if destination.join("package-lock.json").exist?
31
+ run "bun add highlight.js @afomera/richer-text@alpha" if destination.join("bun.lockb").exist?
32
+ run "yarn add highlight.js @afomera/richer-text@alpha" if destination.join("yarn.lock").exist?
33
+ run "pnpm add highlight.js @afomera/richer-text@alpha" 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)
@@ -127,6 +131,8 @@ module RicherText
127
131
  attrs.merge(style: "background-color: #{attrs["color"]};")
128
132
  elsif attrs.dig("color").present? && tag == "span"
129
133
  attrs.merge(style: "color: #{attrs["color"]};")
134
+ elsif attrs.dig("fontSize").present? && tag == "span"
135
+ attrs.merge(style: "font-size: #{attrs["fontSize"]};")
130
136
  else
131
137
  attrs
132
138
  end
@@ -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
@@ -0,0 +1,4 @@
1
+ module RicherText
2
+ module TagHelper
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module RicherText
2
- VERSION = "0.12.0"
2
+ VERSION = "0.14.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.12.0
4
+ version: 0.14.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-10-03 00:00:00.000000000 Z
11
+ date: 2024-06-03 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
@@ -102,6 +103,7 @@ files:
102
103
  - lib/richer_text/nodes/text.rb
103
104
  - lib/richer_text/rendering.rb
104
105
  - lib/richer_text/serialization.rb
106
+ - lib/richer_text/tag_helper.rb
105
107
  - lib/richer_text/version.rb
106
108
  - lib/tasks/richer_text_tasks.rake
107
109
  homepage: https://github.com/afomera/richer_text
@@ -124,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
126
  - !ruby/object:Gem::Version
125
127
  version: '0'
126
128
  requirements: []
127
- rubygems_version: 3.4.10
129
+ rubygems_version: 3.5.3
128
130
  signing_key:
129
131
  specification_version: 4
130
132
  summary: A richer text editor for Rails