File tree Expand file tree Collapse file tree 4 files changed +30
-3
lines changed
lib/src/models/documents/nodes Expand file tree Collapse file tree 4 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import 'node.dart';
13
13
/// - Text Alignment
14
14
/// - Text Direction
15
15
/// - Code Block
16
- class Block extends Container <Line ?> implements StyledNode {
16
+ class Block extends Container <Line ?> {
17
17
/// Creates new unmounted [Block] .
18
18
@override
19
19
Node newInstance () => Block ();
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import 'line.dart';
7
7
import 'node.dart' ;
8
8
9
9
/// A leaf in Quill document tree.
10
- abstract class Leaf extends Node implements StyledNode {
10
+ abstract class Leaf extends Node {
11
11
/// Creates a new [Leaf] with specified [data] .
12
12
factory Leaf (Object data) {
13
13
if (data is Embeddable ) {
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import 'node.dart';
17
17
///
18
18
/// When a line contains an embed, it fully occupies the line, no other embeds
19
19
/// or text nodes are allowed.
20
- class Line extends Container <Leaf ?> implements StyledNode {
20
+ class Line extends Container <Leaf ?> {
21
21
@override
22
22
Leaf get defaultChild => Text ();
23
23
Original file line number Diff line number Diff line change @@ -127,6 +127,33 @@ abstract class StyledNode implements Node {
127
127
Style get style;
128
128
}
129
129
130
+ /// Mixin used by nodes that wish to implement [StyledNode] interface.
131
+ abstract class StyledNodeMixin implements StyledNode {
132
+ @override
133
+ Style get style => _style;
134
+ @override
135
+ Style _style = Style ();
136
+
137
+ /// Applies style [attribute] to this node.
138
+ @override
139
+ void applyAttribute (Attribute attribute) {
140
+ _style = _style.merge (attribute);
141
+ }
142
+
143
+ /// Applies new style [value] to this node. Provided [value] is merged
144
+ /// into current style.
145
+ @override
146
+ void applyStyle (Style value) {
147
+ _style = _style.mergeAll (value);
148
+ }
149
+
150
+ /// Clears style of this node.
151
+ @override
152
+ void clearStyle () {
153
+ _style = Style ();
154
+ }
155
+ }
156
+
130
157
/// Root node of document tree.
131
158
class Root extends Container <Container <Node ?>> {
132
159
@override
You can’t perform that action at this time.
0 commit comments