draftjs_html 0.30.0 → 0.31.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: 87efa57150dbbe1c730824cea917dbabaad3aec0512232102995863da4f0e30c
4
- data.tar.gz: b634cbce19c5da38dbd36df706f9f4ba90a0391a1e487907bd355c2d4772eda0
3
+ metadata.gz: 664e4ae07bc1d64294767d98e5a41b2adf8f998dcf6b7109d30b924d2947f931
4
+ data.tar.gz: 6e3a4339a7a2c0d812d64b19260a8c57c1ca9b52ee8cb61969645bf1d75a0558
5
5
  SHA512:
6
- metadata.gz: 80fc8946627d72d1d3add5c3e0e6e4a91656aa715cec1d20d4471273ad129abccbbe47c81077b2874c896733528537c8bdcce7a99d825f0d908b3e524f2efd48
7
- data.tar.gz: dd460fa38fea6e915a442ba231993e231c009784618b0ed36f9d7f7e583cedef6246f20447ae16937c0ba98b09f9977390738771161a4a08571ff6ee8ab107e6
6
+ metadata.gz: aa6e7d24bf3389ab5cec981ec5e22f0a1ef10e68b51479a33ae54eaa0701b110b5b21fae3c1b7a14936dff54fb29bf52bc3c92a6202511ed463ffe1c770b1e32
7
+ data.tar.gz: 3897c00b471a7dc3dec926f90c8047d71d38ff9299acc7a9a8435a52b2d4b4ec204892cbadadf3269131a12e0d87d119b01f8eae81cecfd95727ce08644c0ac4
@@ -73,6 +73,10 @@ module DraftjsHtml
73
73
  def add_style(name, range)
74
74
  inline_styles << ApplicableRange.new(name: name, range: range)
75
75
  end
76
+
77
+ def add_entity(key, range)
78
+ entity_ranges << ApplicableRange.new(name: key, range: range)
79
+ end
76
80
  end
77
81
  end
78
82
  end
@@ -18,9 +18,24 @@ module DraftjsHtml
18
18
  entity_map[key]
19
19
  end
20
20
 
21
+ def attach_entity(entity, block, range)
22
+ new_key = new_entity_key
23
+ entity_map[new_key] = entity
24
+ block.add_entity(new_key, range)
25
+ end
26
+
21
27
  def to_raw
22
28
  ToRaw.new.convert(self)
23
29
  end
30
+
31
+ private
32
+
33
+ def new_entity_key
34
+ loop do
35
+ key = SecureRandom.uuid
36
+ break key unless entity_map.key?(key)
37
+ end
38
+ end
24
39
  end
25
40
  end
26
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DraftjsHtml
4
- VERSION = "0.30.0"
4
+ VERSION = "0.31.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draftjs_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Taylor
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -88,7 +88,7 @@ metadata:
88
88
  homepage_uri: https://github.com/dugancathal/draftjs_html
89
89
  source_code_uri: https://github.com/dugancathal/draftjs_html
90
90
  changelog_uri: https://github.com/dugancathal/draftjs_html/tree/main/CHANGELOG.md
91
- post_install_message:
91
+ post_install_message:
92
92
  rdoc_options: []
93
93
  require_paths:
94
94
  - lib
@@ -103,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.3.26
107
- signing_key:
106
+ rubygems_version: 3.4.10
107
+ signing_key:
108
108
  specification_version: 4
109
109
  summary: A tool for converting DraftJS JSON to HTML (and back again)
110
110
  test_files: []