tiptap-ruby 0.8.0 → 0.8.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/tip_tap/nodes/text.rb +35 -4
- data/lib/tip_tap/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f985a4c273e2e9e153a0397fec2cd196e4eebafe8e32224492ce25cfd2478cc
|
4
|
+
data.tar.gz: 251ee6f454c8f2968e1e6900045c9d764b97a62509faafad758446551b48efa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42c49923cdb74a54efe6ed6a2a628e3a50d212fbde061949b6aa1f0c042eea84da9647d158351d646def7c2dc3dbb36b5b9cdd2d0bbf60f31bbce45153b9ef7e
|
7
|
+
data.tar.gz: cf622c6c4e157c996f9ce1ef7909dd0dc9611a7fc4c874b6c976c02817f915282ea9dd65e20898f6ac632c37022ae4a40beef26233f76ad7acb6f377f23629aa
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -131,7 +131,7 @@ To release a new version, update the version number in `version.rb`, and then ru
|
|
131
131
|
|
132
132
|
## Contributing
|
133
133
|
|
134
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
134
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/CompanyCam/tiptap-ruby.
|
135
135
|
|
136
136
|
## License
|
137
137
|
|
data/lib/tip_tap/nodes/text.rb
CHANGED
@@ -27,6 +27,9 @@ module TipTap
|
|
27
27
|
|
28
28
|
def to_html
|
29
29
|
value = text
|
30
|
+
value = content_tag(:sup, value) if superscript?
|
31
|
+
value = content_tag(:sub, value) if subscript?
|
32
|
+
value = highlight_tag(value) if highlight?
|
30
33
|
value = content_tag(:code, value) if code?
|
31
34
|
value = content_tag(:u, value) if underline?
|
32
35
|
value = content_tag(:em, value) if italic?
|
@@ -65,10 +68,28 @@ module TipTap
|
|
65
68
|
has_mark_with_type?("code")
|
66
69
|
end
|
67
70
|
|
71
|
+
def superscript?
|
72
|
+
has_mark_with_type?("superscript")
|
73
|
+
end
|
74
|
+
|
75
|
+
def subscript?
|
76
|
+
has_mark_with_type?("subscript")
|
77
|
+
end
|
78
|
+
|
79
|
+
def highlight?
|
80
|
+
has_mark_with_type?("highlight")
|
81
|
+
end
|
82
|
+
|
68
83
|
def text_style?
|
69
84
|
has_mark_with_type?("textStyle")
|
70
85
|
end
|
71
86
|
|
87
|
+
private
|
88
|
+
|
89
|
+
def has_mark_with_type?(type)
|
90
|
+
marks.any? { |mark| mark["type"] == type }
|
91
|
+
end
|
92
|
+
|
72
93
|
def link_href
|
73
94
|
marks.find { |mark| mark["type"] == "link" }&.dig("attrs", "href")
|
74
95
|
end
|
@@ -81,15 +102,25 @@ module TipTap
|
|
81
102
|
marks.find { |mark| mark["type"] == "textStyle" }&.dig("attrs")
|
82
103
|
end
|
83
104
|
|
84
|
-
|
85
|
-
|
86
|
-
def has_mark_with_type?(type)
|
87
|
-
marks.any? { |mark| mark["type"] == type }
|
105
|
+
def highlight_color
|
106
|
+
marks.find { |mark| mark["type"] == "highlight" }&.dig("attrs", "color")
|
88
107
|
end
|
89
108
|
|
90
109
|
def inline_style_content(styles)
|
110
|
+
return nil if styles.empty?
|
91
111
|
styles.reduce("") { |acc, val| acc + "#{val[0]}:#{val[1]};" }
|
92
112
|
end
|
113
|
+
|
114
|
+
def highlight_tag(value)
|
115
|
+
data = {}
|
116
|
+
styles = {}
|
117
|
+
if highlight_color
|
118
|
+
data[:color] = highlight_color
|
119
|
+
styles["background-color"] = highlight_color
|
120
|
+
styles[:color] = "inherit"
|
121
|
+
end
|
122
|
+
content_tag(:mark, text, data: data, style: inline_style_content(styles))
|
123
|
+
end
|
93
124
|
end
|
94
125
|
end
|
95
126
|
end
|
data/lib/tip_tap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiptap-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Wilken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -73,13 +73,13 @@ files:
|
|
73
73
|
- lib/tip_tap/registry.rb
|
74
74
|
- lib/tip_tap/version.rb
|
75
75
|
- lib/tiptap.rb
|
76
|
-
homepage: https://github.com/
|
76
|
+
homepage: https://github.com/CompanyCam/tiptap-ruby
|
77
77
|
licenses:
|
78
78
|
- MIT
|
79
79
|
metadata:
|
80
|
-
homepage_uri: https://github.com/
|
81
|
-
source_code_uri: https://github.com/
|
82
|
-
changelog_uri: https://github.com/
|
80
|
+
homepage_uri: https://github.com/CompanyCam/tiptap-ruby
|
81
|
+
source_code_uri: https://github.com/CompanyCam/tiptap-ruby
|
82
|
+
changelog_uri: https://github.com/CompanyCam/tiptap-ruby/blob/master/CHANGELOG.md
|
83
83
|
post_install_message:
|
84
84
|
rdoc_options: []
|
85
85
|
require_paths:
|