draftjs_html 0.15.0 → 0.16.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7195ba4d0f0e659dfd6cb335ee461ca122d3db48f379e8c88c01000fbedefccb
4
- data.tar.gz: 0ee5ec82ddcac4ae7acb99399a7fd6d52054d21f23abcb2a2ff61cca6bc2c9b7
3
+ metadata.gz: 770a91eea2ce6ff069f3ccf80d8d9857e15ea8882cfd7a426fe9b8aea2b6ca4e
4
+ data.tar.gz: 1dfef55358fb964b0a6ac6c98458b1d04a59c0e115c11a2d32a5f4042c747777
5
5
  SHA512:
6
- metadata.gz: 9ee9d2f946504b1c79b936d215edda2a17ec94970c356e2b59be224da471ace3c0389af24418a7c9d93b0d343b3d6681e4a8638e8bf83b7e776257f8f5babb2e
7
- data.tar.gz: ebb33f7bfa4fd9a0ca6de27c4bd6a5ff8b24b4d0f480706edff7dbf1065ac89b28f4f6f075f06d9dcc03825c33e6e07df36166c4f1d333e5316b68a9b80454a1
6
+ metadata.gz: '0830e5b529717b67fd2dbdd2627c53e68332bbc66601e6b405ecd60d993aef9eca797211bfc442c95c6cf00d9996d65b22cdacd12982094b4d3c33f04e86f0c2'
7
+ data.tar.gz: 47f94740645254e51675033bcb1d23d331eaa054d0d73382d689e4d10e18441177622b8fb9d66d51008c06f3d432eda1809014fd541ae2f52fa1b5d5d5905c9b
@@ -54,9 +54,14 @@ module DraftjsHtml
54
54
  while current.pending_entities.any?
55
55
  pending_entity = current.pending_entities.pop
56
56
  range = pending_entity[:start]..current_character_offset
57
- user_created_entity = conversion.call(pending_entity[:tagname], current_text_buffer[range], pending_entity[:attrs])
57
+ content = current_text_buffer[range]
58
+ user_created_entity = conversion.call(pending_entity[:tagname], content, pending_entity[:attrs])
58
59
  next unless user_created_entity
59
60
 
61
+ if content == '' && !user_created_entity[:atomic]
62
+ current.text_buffer << ' '
63
+ range = range.begin..(range.end+1)
64
+ end
60
65
  current.entities << user_created_entity.merge(start: range.begin, finish: range.end)
61
66
  end
62
67
  end
@@ -39,7 +39,7 @@ module DraftjsHtml
39
39
  def flush_to(draftjs, styles)
40
40
  if text_buffer.any?
41
41
  chars.join.lines.each do |line|
42
- draftjs.typed_block(block_name, line.strip, depth: [depth, 0].max)
42
+ draftjs.typed_block(block_name, line.chomp, depth: [depth, 0].max)
43
43
  end
44
44
 
45
45
  styles.each do |descriptor|
@@ -57,10 +57,7 @@ module DraftjsHtml
57
57
  range = entity[:start]..entity[:finish]
58
58
  if entity[:atomic]
59
59
  draftjs.typed_block('atomic', ' ', depth: [depth, 0].max)
60
- range = 0..1
61
- elsif range.size < 1
62
- draftjs.typed_block('atomic', ' ', depth: [depth, 0].max) unless draftjs.has_blocks?
63
- range = (range.begin..range.end + 1)
60
+ range = 0..0
64
61
  end
65
62
 
66
63
  draftjs.apply_entity entity[:type], range, data: entity[:data], mutability: entity.fetch(:mutability, 'IMMUTABLE')
@@ -44,7 +44,7 @@ module DraftjsHtml
44
44
 
45
45
  ENTITY_CONVERSION_MAP = {
46
46
  'LINK' => ->(entity, content, *) {
47
- attributes = entity.data.slice('url', 'rel', 'target', 'title', 'className').each_with_object({}) do |(attr, value), h|
47
+ attributes = entity.data.slice('url', 'href', 'rel', 'target', 'title', 'className').each_with_object({}) do |(attr, value), h|
48
48
  h[ENTITY_ATTRIBUTE_NAME_MAP.fetch(attr, attr)] = value
49
49
  end
50
50
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DraftjsHtml
4
- VERSION = "0.15.0"
4
+ VERSION = "0.16.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.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Taylor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-03 00:00:00.000000000 Z
11
+ date: 2022-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri