tiptap-ruby 0.6.0 → 0.7.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: fd7f762d8377a8a4b86b901315b1b4d3d5bc96abd58f6b469861e84ba87b6296
4
- data.tar.gz: cfaa3409507308edef86236e01b3d563d023546f2fa75eb0c4d7a0b476bbb7d3
3
+ metadata.gz: 4c3416b54084b6d2eee7cb1fa23e935d7fa495578a2dbfac7cb028f91c3bd62e
4
+ data.tar.gz: 9e62d38585790d5efaaed7506f532c20fc6351644f71b370ba32d95638772ed5
5
5
  SHA512:
6
- metadata.gz: 99ceb0b18400d9c1549e433d4c5ed488797f9599366859ebd10d17d75b64a80ffb58628786e464abddb7caea42a58d2d1a498ce901ed96d14b026dcfda85c7b1
7
- data.tar.gz: ac01ac19fd18f06518711922821b5477fc03bc56ea98797b7e4c8e2f35d4d6f9c59c333583a6c136a66d0007f7a1241987baa9c9e657dba812c6ae1b34b97c46
6
+ metadata.gz: 9b8c3a916a053f93f21b0735285bf99c8840b0a5ffed9769cc91ce217fa3bbf4c3e3a9f5a247f8c1c02b5f2f47ff635999d33d6ba3aa9587b7bc5917d8245776
7
+ data.tar.gz: 10e9ae09b3b816041d63d4c8a7feda62f804757608ca49a897955b3acc240911e66d694df86b310bb0874f369bcf84b0466b763c721d8cf932fd8cc42f325397
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.0] - 2023-11-02
4
+
5
+ ### Breaking
6
+
7
+ - Renamed `to_json` to `as_json` to follow Ruby/Rails convention.
8
+
9
+ ## [0.6.1] - 2023-11-01
10
+
11
+ - Allow customizing the `separator` when calling `to_plain_text`.
12
+
13
+ ## [0.6.0] - 2023-11-01
14
+
15
+ - Implement `Enumerable` for the `HasContent` module.
16
+
3
17
  ## [0.5.0] - 2023-10-30
4
18
 
5
19
  - Make `Text` a subclass of `Node`.
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A gem for parsing, generating, and rendering TipTap Documents and Nodes using Ruby.
4
4
 
5
+ ## Note
6
+
7
+ This gem is under active development and is changing somewhat quickly. There is a chance that there may be breaking changes until a stable version is released.
8
+
5
9
  ## Installation
6
10
 
7
11
  Install the gem and add to the application's Gemfile by executing:
@@ -55,7 +59,7 @@ Once you have a Document with some content you can render it to HTML, JSON, and
55
59
  #### JSON
56
60
 
57
61
  ```ruby
58
- document.to_json # => { type: 'doc', content: […nodes]}
62
+ document.as_json # => { type: 'doc', content: […nodes]}
59
63
  ```
60
64
 
61
65
  ### HTML
@@ -9,12 +9,13 @@ module TipTap
9
9
  end
10
10
 
11
11
  # Generate a JSON object that is useable by the editor
12
- def to_json
12
+ def as_json
13
13
  json = {type: type_name}
14
- json = json.merge(content: content.map(&:to_json)) if should_include_content?
14
+ json = json.merge(content: content.map(&:as_json)) if should_include_content?
15
15
  json = json.merge(attrs: attrs.deep_symbolize_keys) if attrs.present?
16
16
  json
17
17
  end
18
+ alias_method :to_h, :as_json
18
19
 
19
20
  private
20
21
 
@@ -21,7 +21,7 @@ module TipTap
21
21
  new(json["text"], marks: Array(json["marks"]))
22
22
  end
23
23
 
24
- def to_json
24
+ def as_json
25
25
  {type: type_name, text: text, marks: marks.map(&:deep_symbolize_keys)}.compact_blank
26
26
  end
27
27
 
@@ -37,7 +37,7 @@ module TipTap
37
37
  value
38
38
  end
39
39
 
40
- def to_plain_text
40
+ def to_plain_text(separator: " ")
41
41
  text
42
42
  end
43
43
 
@@ -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(&:to_plain_text).join(" ")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TipTap
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.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.6.0
4
+ version: 0.7.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-11-01 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview