Code Monkey home page Code Monkey logo

text_delta's People

Contributors

everzet avatar sroze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

text_delta's Issues

Possible bug in `TextDelta.lines(document)` for a particular edge case

Hello ๐Ÿ‘‹

I'm currently using your awesome library to do a TextDelta to HTML converter on the backend side.

When converting a particular document to lines, I noticed some attributes were lost in translation.

Sample unexpected output

input_textdelta = %TextDelta{
  ops: [
    %{insert: "\nTitle 1"},
    %{attributes: %{header: 1}, insert: "\n"},
    %{insert: "\nTitle 2"},
    %{attributes: %{header: 1}, insert: "\n\n"},
    %{insert: "\n"}
  ]
}

TextDelta.lines(input_textdelta)
# Outputs:
{:ok,
 [
   {%TextDelta{ops: []}, %{}},
   {%TextDelta{ops: [%{insert: " Title 1"}]}, %{header: 1}},
   {%TextDelta{ops: []}, %{}},
   {%TextDelta{ops: [%{insert: " Title 2"}]}, %{}}, # <=== Here, we're missing the attribute `header: 1`
   {%TextDelta{ops: []}, %{}}, # <=== Here as well. ๐Ÿค” 
   {%TextDelta{ops: []}, %{}}
 ]}

As you can see, the %{header: 1} attribute has been lost on Title 2 and the subsequent line. This only seems to happen on the last lines of the document. The rest of the document is properly separated into lines.

What makes me say it's a potential bug is that when comparing with the HTML output of QuillJS, this generates the following HTML:

<p><br><p>
<h1>Title 1</h1>
<p><br><p>
<h1>Title 2</h1>
<h1><br></h1>
<p><br><p>

I'll see if I can provide a pull request fixing the issue and thanks again for this awesome library ๐Ÿ˜ป

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.