Exemple #1
0
 def inst_ops(self):
     return [
         Insert('abc', None),
         Retain(1, {'color': 'red'}),
         Delete(4),
         Insert('def', {'bold': True}),
         Retain(6, None)
     ]
Exemple #2
0
    def test_delta_chain(self):
        delta = (Delta().insert('Hello').insert({
            'image': True
        }).insert('World'))

        assert delta.ops == [
            Insert('Hello', None),
            Insert({'image': True}, None),
            Insert('World', None),
        ]
Exemple #3
0
    def test_delta_delete_text(self):
        delta = (Delta().insert('foo').insert(' ').insert('bar'))

        assert delta.ops == [Insert('foo bar', None)]

        delta = delta.delete(2).delete(2)

        delta.insert(' ')
        delta.insert('baz')

        assert delta.ops == [Insert('foo bar baz', None), Delete(4)]
Exemple #4
0
    def test_push_consecutive_embeds_with_matching_attributes(self):
        delta = Delta().insert(1, {'alt': 'Description'})
        delta.push({
            'insert': {
                'url': 'http://quilljs.com'
            },
            'attributes': {
                'alt': 'Description'
            }
        })

        assert len(delta.ops) == 2
        assert delta.ops == [
            Insert(1, {'alt': 'Description'}),
            Insert({'url': 'http://quilljs.com'}, {'alt': 'Description'})
        ]
Exemple #5
0
    def test_insert_embed_non_integer(self):
        value = {'url': 'https://quilljs.com'}
        attrs = {'alt': 'Quill'}
        delta = Delta().insert(value, attrs)

        assert len(delta.ops) == 1
        assert delta.ops == [Insert(value, attrs)]
Exemple #6
0
    def test_delta_insert_text(self):
        delta = Delta()

        assert delta.ops == []

        delta = (delta.insert('Hello',
                              None).insert(' ', None).insert('World!', None))

        assert len(delta.ops) == 1, delta.ops
        assert delta.ops == [Insert('Hello World!', None)]

        delta.insert('\n', None)
        delta.insert('Hello World', None)
        delta.insert('!', None)

        assert len(delta.ops) == 1, delta.ops
        assert delta.ops == [Insert('Hello World!\nHello World!', None)]
Exemple #7
0
    def test_insert_text_none(self):
        delta = Delta().insert('test', None)

        assert len(delta.ops) == 1
        assert delta.ops == [Insert('test', None)]
Exemple #8
0
    def test_push_consecutive_text_with_not_matching_attributes(self):
        delta = Delta().insert('a', {'bold': True})
        delta.push({'insert': 'b'})

        assert len(delta.ops) == 2
        assert delta.ops == [Insert('a', {'bold': True}), Insert('b', None)]
Exemple #9
0
    def test_push_consecutive_text_with_matching_attributes(self):
        delta = Delta().insert('a', {'bold': True})
        delta.push({'insert': 'b', 'attributes': {'bold': True}})

        assert len(delta.ops) == 1
        assert delta.ops == [Insert('ab', {'bold': True})]
Exemple #10
0
    def test_push_consecutive_text(self):
        delta = Delta().insert('a')
        delta.push({'insert': 'b'})

        assert len(delta.ops) == 1
        assert delta.ops == [Insert('ab', None)]
Exemple #11
0
    def test_insert_text_attributes(self):
        delta = Delta().insert('test', {'bold': True})

        assert len(delta.ops) == 1
        assert delta.ops == [Insert('test', {'bold': True})]
Exemple #12
0
    def test_insert_embed_attributes(self):
        obj = {'url': 'https://quilljs.com', 'alt': 'Quill'}
        delta = Delta().insert(1, obj)

        assert len(delta.ops) == 1
        assert delta.ops == [Insert(1, obj)]
Exemple #13
0
    def test_insert_embed(self):
        delta = Delta().insert(1)

        assert len(delta.ops) == 1
        assert delta.ops == [Insert(1, None)]