hzdg / hz-core

HZ's internal library of React Components 🚧
https://hz-core.netlify.com
0 stars 0 forks source link

[draftail-renderer] parse links inlined within paragraph #36

Closed aamorozov closed 4 years ago

aamorozov commented 4 years ago

We're mapping the entityMap (Link data) to the block's entityRanges( link text) based on the key. Looks like when the links are inlined within the paragraph, the link tag is being applied to the whole paragraph. I will add an output from draftail showing that issue shortly.

https://github.com/hzdg/hz-core/blob/master/packages/ui-components/hzcore-draftail-renderer/src/index.tsx#L193-L242

aamorozov commented 4 years ago

I think we can use the offset and the length fields within the entityRange object to make it work

"entityRanges": [
        {
          "offset": 29,
          "length": 4,
          "key": 0
        }
      ]

The offset points to the character that is at the start of the link and the length is well, the length of the link text.

elainen commented 4 years ago

Feature was added in d273728ad2b1b02bd179e048d42c11f6f584a193