Giter Club home page Giter Club logo

Comments (5)

deanblackborough avatar deanblackborough commented on September 13, 2024

@pdiveris Thank you.

I've had a quick look at your changes and they break the build, there should only be one failing test, 24 fail because the code is trying to use an undefined index which makes sense given the changes.

A better solution would be dropping those deltas before they reach the rest of the code, I'm not sure how you have invalid deltas (missing "") but I'd suggest a new method, called before localLists() in parse() to drop invalid/empty deltas as early as possible by doing a similar check, something like.

// Untested code

$deltas = $this->deltas['ops'];
$this->deltas = array();

foreach ($deltas as $k => $delta) {
    if (array_key_exists('insert', $delta) === true &&
    $delta['insert'] !== null) {
         $this->deltas[] = delta;
    }
}

If I get time tomorrow I'll add it or you could update your PR, it will need a test as well, I don't want the bug to reappear at a later date or in version 3.0.

You'll get credited in the README, everyone does, I very much appreciate bug submissions.

from php-quill-renderer.

pdiveris avatar pdiveris commented on September 13, 2024

from php-quill-renderer.

pdiveris avatar pdiveris commented on September 13, 2024

OK, I can confirm that when pasting from pages such as this:

https://www.diveris.org/habari/some-thoughts-on-may-the-election-and-the-eu

screen shot 2018-04-15 at 10 32 12

I am getting a series of "insert":null ops. Here's what this particular paste produced in terms of ops

{"ops":[{"insert":"Theresa May"},{"attributes":{"align":"justify","header":4},"insert":null},{"insert":"As you almost certainly know by now, Theresa May announced in early April 2017 a surprise general election. The accepted wisdom is that with this election\u00a0"},{"attributes":{"align":"justify"},"insert":null},{"attributes":{"header":4},"insert":null}]}

So, a cleanup is indeed required.

My versions of Quill and Quill Delta are 3.6.2 and I have observed this behaviour with Chrome 64.0.3282.119 (Official Build) (64-bit).

from php-quill-renderer.

pdiveris avatar pdiveris commented on September 13, 2024

OK, the plot thickens. Quill adds a newline 'insert' op after every text insert op. In an ugly fashion those ops might well contain the formatting for your string. Look at the attached screenshot. The H1 and justify attrs for the text sitting at position 0 are attached to an operation which inserts a new line. I have no idea what problem Chen was trying to solve when he implemented that, but it only causes problems. In my case, since I was pushing the text to be rendered on a server component via async calls it means that it broke JSON and I got nulls instead. So, I am looking now at merging those in a single operation. Let me know your thoughts on this.

screen shot 2018-04-15 at 13 51 01

slab/quill#890

from php-quill-renderer.

deanblackborough avatar deanblackborough commented on September 13, 2024

I've just released an update that removes any inserts which are null.

I've not seen anything like the above before, up till now I've only seen deltas with either content in the insert or at a minimum newlines.

I'll look into this for version v3.00, I'm starting development this evening and have a better design so if there have been changes it will be easier to deal with them.

For now I will leave this issue open as it is handy to collect all the data, I've closed your pull request because my changes deal with the original issue. One of the first tasks for version 3.00 will be making sure Quill generates the same deltas as I'm testing in my tests.

from php-quill-renderer.

Related Issues (20)

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.