Skip to content

Conversation

@buob
Copy link

@buob buob commented Feb 14, 2019

Inline style ranges (right now only BOLD and ITALIC) and entity
ranges (right now only LINK)

@buob buob requested a review from crossman February 14, 2019 18:08
Copy link

@crossman crossman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questments

lib/draft.ex Outdated
input
|> Map.get("blocks")
|> Enum.map(&Draft.Block.to_html/1)
|> Enum.map(fn block -> Draft.Block.to_html(block, entity_map) end)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely style but I prefer the more compact

Suggested change
|> Enum.map(fn block -> Draft.Block.to_html(block, entity_map) end)
|> Enum.map(&(Draft.Block.to_html(&1, entity_map)))

[{0, 2}, {2, 4}, {4, 5}, {5, 8}]
"""
defp consolidate_ranges(ranges) do
ranges

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my one overall note on this (aside from it being somewhat hard to follow). Why not us Elixir's actual ranges for this? (didn't really consider that in light of adjusting ranges as the text is modified but it would make finding overlaps and inclusions a little simpler if they could be used)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great minds. I started using ranges, which 1. were introduced in 1.8, so I wasn't pumped about that in a lib, but moreover 2. they are always inclusive, so it was cumbersome translating to/from the ranges that come from draftjs (which can be easily treated as non-inclusive "ranges," but really the offset+length thing made for some rough overhead)

@buob buob force-pushed the jb/inline-and-entities branch from cdfe851 to 678a4f3 Compare February 15, 2019 18:10
Inline style ranges (right now only `BOLD` and `ITALIC`) and entity
ranges (right now only `LINK`)
@buob buob force-pushed the jb/inline-and-entities branch from 678a4f3 to 5b6be92 Compare February 15, 2019 18:14
@buob buob merged commit 58a0676 into master Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants