tiptap-ruby 0.5.0 → 0.6.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: 234920a15c4fa07aec094cdfc999631c005cbef531c13eb69ec706bca5ac866f
4
- data.tar.gz: 2cdbb32cc437b0490027e94335ce7e57f7f1cd89184642a08590bc3e82e7e6d3
3
+ metadata.gz: fd7f762d8377a8a4b86b901315b1b4d3d5bc96abd58f6b469861e84ba87b6296
4
+ data.tar.gz: cfaa3409507308edef86236e01b3d563d023546f2fa75eb0c4d7a0b476bbb7d3
5
5
  SHA512:
6
- metadata.gz: 5999cd5ccc9e0772ebbb4c7e5df486499671ae4f34c881a9259bcf0d309a42ccb640ec63f83f901ced8c26909c0ef88c51fb72d1a5ac2cd8184c357b0fbd4e31
7
- data.tar.gz: 60b0011c676856731fc1809c6fd8380282b0175ef235fa4a6edaf946275638dd0a9a4b21a307d267d3caf6cf5a1b11e919ccf458262f04f9218e78a9ff9dda4d
6
+ metadata.gz: 99ceb0b18400d9c1549e433d4c5ed488797f9599366859ebd10d17d75b64a80ffb58628786e464abddb7caea42a58d2d1a498ce901ed96d14b026dcfda85c7b1
7
+ data.tar.gz: ac01ac19fd18f06518711922821b5477fc03bc56ea98797b7e4c8e2f35d4d6f9c59c333583a6c136a66d0007f7a1241987baa9c9e657dba812c6ae1b34b97c46
@@ -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 find_node(node_type)
24
- content.find { |child| child.is_a?(node_type) }
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TipTap
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
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.5.0
4
+ version: 0.6.0
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-10-30 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview