tiptap-ruby 0.5.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tip_tap/has_content.rb +14 -2
- data/lib/tip_tap/nodes/text.rb +1 -1
- data/lib/tip_tap/plain_text_renderable.rb +2 -2
- data/lib/tip_tap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 509879e5f27755a131f63f83c7375eb4aa2eaffb575d7f7e10531f402a59a617
|
4
|
+
data.tar.gz: 9a6006a38ca591dca214830907e3a258d6829db4aac044d0b2052c80d281c6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62a148965cdaccfc5ba2f18637c681563ee73e83947b6e907d27669ec81f9b24b74a069daf479095433a1ce8c717da7e0846f01217675b2677efdfb109468e7b
|
7
|
+
data.tar.gz: f72265d70fe15905adade16d29abda9b4b3425c1080e50d4ae34b14aeb29a2017d9276bb6b8352005dfd3d7774164f0a959e7357925353a6e2ae1e46b6c84c9e
|
data/lib/tip_tap/has_content.rb
CHANGED
@@ -4,6 +4,8 @@ require "active_support/core_ext/hash"
|
|
4
4
|
|
5
5
|
module TipTap
|
6
6
|
module HasContent
|
7
|
+
include Enumerable
|
8
|
+
|
7
9
|
attr_reader :attrs, :content
|
8
10
|
|
9
11
|
def self.included(base)
|
@@ -20,13 +22,23 @@ module TipTap
|
|
20
22
|
yield self if block_given?
|
21
23
|
end
|
22
24
|
|
23
|
-
def
|
24
|
-
content.
|
25
|
+
def each
|
26
|
+
content.each { |child| yield child }
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_node(type_class_or_name)
|
30
|
+
node_type = type_class_or_name.is_a?(String) ? TipTap.node_for(type_class_or_name) : type_class_or_name
|
31
|
+
find { |child| child.is_a?(node_type) }
|
25
32
|
end
|
26
33
|
|
27
34
|
def add_content(node)
|
28
35
|
@content << node
|
29
36
|
end
|
37
|
+
alias_method :<<, :add_content
|
38
|
+
|
39
|
+
def size
|
40
|
+
content.size
|
41
|
+
end
|
30
42
|
|
31
43
|
module ClassMethods
|
32
44
|
# Create a new instance from a TipTap JSON object.
|
data/lib/tip_tap/nodes/text.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
module TipTap
|
4
4
|
module PlainTextRenderable
|
5
5
|
# Useful for searching
|
6
|
-
def to_plain_text
|
7
|
-
content.map(
|
6
|
+
def to_plain_text(separator: " ")
|
7
|
+
content.map { |node| node.to_plain_text(separator: separator) }.join(separator)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
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.
|
4
|
+
version: 0.6.1
|
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-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|