Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quill-delta

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quill-delta - npm Package Compare versions

Comparing version 3.4.3 to 3.5.0

29

CHANGELOG.md

@@ -0,1 +1,26 @@

## v3.5.0
- Add counter and early return to `eachLine()`
## v3.4.0
- Support index suggestion in `diff()`
## v3.3.0
- Add `partition()`
## v3.2.0
- Add `eachLine()`, `map()`, `reduce()`, `filter()`, `forEach()`
## v3.1.0
- Pull out quilljs/delta from ottypes/rich-text
## v3.0.0

@@ -7,8 +32,4 @@

#### Features
## v2.1.0
#### Features
- Add `concat()` method for document Deltas

@@ -15,0 +36,0 @@

10

lib/delta.js

@@ -196,3 +196,3 @@ var diff = require('fast-diff');

}
var prep = (ops === other.ops) ? 'on' : 'with';
var prep = (delta === other) ? 'on' : 'with';
throw new Error('diff() called ' + prep + ' non-document');

@@ -240,2 +240,3 @@ }).join('');

var line = new Delta();
var i = 0;
while (iter.hasNext()) {

@@ -252,3 +253,6 @@ if (iter.peekType() !== 'insert') return;

} else {
predicate(line, iter.next(1).attributes || {});
if (predicate(line, iter.next(1).attributes || {}, i) === false) {
return;
}
i += 1;
line = new Delta();

@@ -258,3 +262,3 @@ }

if (line.length() > 0) {
predicate(line, {});
predicate(line, {}, i);
}

@@ -261,0 +265,0 @@ };

{
"name": "quill-delta",
"version": "3.4.3",
"version": "3.5.0",
"description": "Format for representing rich text documents and changes.",

@@ -5,0 +5,0 @@ "author": "Jason Chen <jhchen7@gmail.com>",

@@ -169,3 +169,3 @@ # Delta [![Build Status](https://travis-ci.org/quilljs/delta.svg?branch=master)](http://travis-ci.org/quilljs/delta) [![Coverage Status](https://img.shields.io/coveralls/quilljs/delta.svg)](https://coveralls.io/r/quilljs/delta)

*Note: No validity/sanity check is performed when constructed with ops or delta. The new delta's internal ops array will also be assigned to ops or delta.ops without deep copying.*
*Note: No validity/sanity check is performed when constructed with ops or delta. The new delta's internal ops array will also be assigned from ops or delta.ops without deep copying.*

@@ -341,10 +341,11 @@ #### Example

delta.eachline(function(line, attributes) {
console.log(line, attributes);
delta.eachline(function(line, attributes, i) {
console.log(line, attributes, i);
// Can return false to exit loop early
});
// Should log:
// { ops: [{ insert: 'Hello' }] }, {}
// { ops: [] }, {}
// { ops: [{ insert: 'World' }, { insert: { image: 'octocat.png' } }] }, { align: 'right' }
// { ops: [{ insert: '!' }] }, {}
// { ops: [{ insert: 'Hello' }] }, {}, 0
// { ops: [] }, {}, 1
// { ops: [{ insert: 'World' }, { insert: { image: 'octocat.png' } }] }, { align: 'right' }, 2
// { ops: [{ insert: '!' }] }, {}, 3
```

@@ -599,3 +600,4 @@

- `other` - Delta to transform
- `priority` - Boolean used to break ties
- `priority` - Boolean used to break ties. If `true`, then `this` takes priority
over `other`, that is, its actions are considered to happen "first."

@@ -610,5 +612,6 @@ #### Returns

var a = new Delta().insert('a');
var b = new Delta().insert('b');
var b = new Delta().insert('b').retain(5).insert('c');
b = a.transform(b, true); // new Delta().retain(1).insert('b');
a.transform(b, true); // new Delta().retain(1).insert('b').retain(5).insert('c');
a.transform(b, false); // new Delta().insert('b').retain(6).insert('c');
```

@@ -637,4 +640,5 @@

```js
var index = 12;
var transformedIndex = delta.transformPosition(index);
var delta = new Delta().retain(5).insert('a');
delta.transformPosition(4); // 4
delta.transformPosition(5); // 6
```

@@ -128,2 +128,10 @@ var Delta = require('../../lib/delta');

});
it('non-document', function () {
var a = new Delta().insert('Test');
var b = new Delta().delete(4);
expect(function() {
a.diff(b);
}).toThrow(new Error('diff() called on non-document'));
});
});

@@ -67,9 +67,10 @@ var Delta = require('../../lib/delta');

expect(spy.predicate.calls.count()).toEqual(4);
expect(spy.predicate.calls.argsFor(0)).toEqual([ new Delta().insert('Hello'), {} ]);
expect(spy.predicate.calls.argsFor(1)).toEqual([ new Delta(), {} ]);
expect(spy.predicate.calls.argsFor(0)).toEqual([ new Delta().insert('Hello'), {}, 0 ]);
expect(spy.predicate.calls.argsFor(1)).toEqual([ new Delta(), {}, 1 ]);
expect(spy.predicate.calls.argsFor(2)).toEqual([
new Delta().insert('World', { bold: true }).insert({ image: 'octocat.png' }),
{ align: 'right' }
{ align: 'right' },
2
]);
expect(spy.predicate.calls.argsFor(3)).toEqual([ new Delta().insert('!'), {} ]);
expect(spy.predicate.calls.argsFor(3)).toEqual([ new Delta().insert('!'), {}, 3 ]);
});

@@ -81,4 +82,4 @@

expect(spy.predicate.calls.count()).toEqual(2);
expect(spy.predicate.calls.argsFor(0)).toEqual([ new Delta().insert('Hello'), {} ]);
expect(spy.predicate.calls.argsFor(1)).toEqual([ new Delta().insert('World!'), {} ]);
expect(spy.predicate.calls.argsFor(0)).toEqual([ new Delta().insert('Hello'), {}, 0 ]);
expect(spy.predicate.calls.argsFor(1)).toEqual([ new Delta().insert('World!'), {}, 1 ]);
});

@@ -91,2 +92,16 @@

});
it('early return', function () {
var delta = new Delta().insert('Hello\nNew\nWorld!');
var count = 0;
var spy = {
predicate: function() {
if (count === 1) return false;
count += 1;
}
};
spyOn(spy, 'predicate').and.callThrough();
delta.eachLine(spy.predicate);
expect(spy.predicate.calls.count()).toEqual(2);
});
});

@@ -93,0 +108,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc