richer_text 0.11.0 → 0.13.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: b0896d20faa3ab1fcf20e72e0be2fe6902bf2831b8f21bc5d006f6bbac0d4aad
4
- data.tar.gz: e0b592625c14d7c867087b29129b4bf711e01675eb8e1187a6aa4114fab9eb48
3
+ metadata.gz: 93af4f6f1d3dba85682d797cd9433f76b557945ea1fef31859ea482cec66f2f6
4
+ data.tar.gz: 2537fb3cf9f2706e946e71385507ea035625416e4e730aefa6eb6ffbf345897c
5
5
  SHA512:
6
- metadata.gz: 3f386bd1e15a650db59353b2627224d5dbdcbcfdaa28f49fe7fde165266cac6d876d618da844a00c7c1d7457468543060437aff4a7c2d41736f7eaf6152d92dc
7
- data.tar.gz: 364abb9092c4f8bb13959c3dc13291a22b485e8360f12219064ec4bcb73deeff965c4942d5b0320e8d3977ad7bc107a78133649f72a2b02264fa3945a07adc06
6
+ metadata.gz: a4b553ac51eb39c4c6dc1cd849c5d3034873f0ad4436ba4fccaa7d5565ca55a3cf090207d2571fcd3ced60e9ad1ac4eb3947a12e9d16d53be32b943cf8769115
7
+ data.tar.gz: 3fa4670ddee0a16fc2ac12b878b3e222bd95c8b3dd06aef720aae5807c3c5c46fe19e272af0cffe3244c1c03b5c8704168776eec1a47e9fa857f978d440f5841
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.
@@ -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
@@ -26,7 +26,7 @@ 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
+ run "yarn add highlight.js @afomera/richer-text@alpha"
30
30
  end
31
31
 
32
32
  say "Adding import to application.js", :green
@@ -89,7 +89,7 @@ module RicherText
89
89
  if marks.empty?
90
90
  node.text
91
91
  else
92
- content_tag(marks[0].tag, visit_text(node, marks[1..]), marks[0].attrs)
92
+ content_tag(marks[0].tag, visit_text(node, marks[1..]), parse_mark_attrs(marks[0]))
93
93
  end
94
94
  end
95
95
 
@@ -118,5 +118,20 @@ module RicherText
118
118
  def node_previewable?(node)
119
119
  node.attrs["contentType"].match(previewable_regex)
120
120
  end
121
+
122
+ def parse_mark_attrs(mark)
123
+ attrs = mark.attrs
124
+ tag = mark.tag
125
+
126
+ if attrs.dig("color").present? && tag == "mark"
127
+ attrs.merge(style: "background-color: #{attrs["color"]};")
128
+ elsif attrs.dig("color").present? && tag == "span"
129
+ attrs.merge(style: "color: #{attrs["color"]};")
130
+ elsif attrs.dig("fontSize").present? && tag == "span"
131
+ attrs.merge(style: "font-size: #{attrs["fontSize"]};")
132
+ else
133
+ attrs
134
+ end
135
+ end
121
136
  end
122
137
  end
@@ -4,7 +4,7 @@ module RicherText
4
4
  include RicherText::Rendering
5
5
 
6
6
  STYLES = {
7
- "textAlign" => "text-align",
7
+ "textAlign" => "text-align"
8
8
  }
9
9
 
10
10
  def self.build(json)
@@ -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.11.0"
2
+ VERSION = "0.13.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.11.0
4
+ version: 0.13.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-09-26 00:00:00.000000000 Z
11
+ date: 2024-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -102,6 +102,7 @@ files:
102
102
  - lib/richer_text/nodes/text.rb
103
103
  - lib/richer_text/rendering.rb
104
104
  - lib/richer_text/serialization.rb
105
+ - lib/richer_text/tag_helper.rb
105
106
  - lib/richer_text/version.rb
106
107
  - lib/tasks/richer_text_tasks.rake
107
108
  homepage: https://github.com/afomera/richer_text
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  - !ruby/object:Gem::Version
125
126
  version: '0'
126
127
  requirements: []
127
- rubygems_version: 3.4.10
128
+ rubygems_version: 3.5.3
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: A richer text editor for Rails