richer_text 0.11.0 → 0.12.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: e5520f0457b69a555273d7a738f5257a0951eef4d65153ad783cd2f31246daad
4
+ data.tar.gz: d4978b9880b46a6af9a91868cdbf40ae8306d3dd749c6ec94631e6999820af89
5
5
  SHA512:
6
- metadata.gz: 3f386bd1e15a650db59353b2627224d5dbdcbcfdaa28f49fe7fde165266cac6d876d618da844a00c7c1d7457468543060437aff4a7c2d41736f7eaf6152d92dc
7
- data.tar.gz: 364abb9092c4f8bb13959c3dc13291a22b485e8360f12219064ec4bcb73deeff965c4942d5b0320e8d3977ad7bc107a78133649f72a2b02264fa3945a07adc06
6
+ metadata.gz: faca362e8db800731ec19ade535551664f5bcc2f379e80283229f536a8b06608a6601d50c4672e02394c650f178ec5697244e14adfca4f0a701ec4bba1ca4846
7
+ data.tar.gz: 4662002c357fee3d91db0b96236c2d314c0551ecbc916a41f6e1c3dea63a5a5d30ab3208045160936b312500a72295d26aed2b59b2c487855431c69f5bf5da6a
@@ -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,18 @@ 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
+ else
131
+ attrs
132
+ end
133
+ end
121
134
  end
122
135
  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)
@@ -1,3 +1,3 @@
1
1
  module RicherText
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.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.12.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: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails