Comments (5)
@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.
from php-quill-renderer.
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
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.
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.
from php-quill-renderer.
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)
- Problems with newlines HOT 8
- How to extend the Parser HOT 9
- Support for complex unknown attributes HOT 1
- Link always gets parsed on new line HOT 14
- wrong output for lists HOT 3
- Option to ignore newline only inserts HOT 1
- Refactoring HOT 1
- Better handle custom attributes HOT 1
- Lots of problems with links HOT 4
- Problem parsing HTML with non standard attribute HOT 2
- Video with attributes not supported HOT 1
- GitHub actions HOT 1
- Code review
- Problem rendering list with a single item HOT 4
- Uncaught Error: Class 'DBlackborough\Quill\Render' not found HOT 1
- Nested lists beta HOT 1
- Markdown renderer and lists HOT 1
- Code duplication HOT 2
- Compound deltas markdown
- Plain text parser HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-quill-renderer.