Skip to content

Commit 193dd68

Browse files
committed
Revert "Implements StyledNode"
This reverts commit dfa623a.
1 parent dfa623a commit 193dd68

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

lib/src/models/documents/nodes/block.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'node.dart';
1313
/// - Text Alignment
1414
/// - Text Direction
1515
/// - Code Block
16-
class Block extends Container<Line?> implements StyledNode {
16+
class Block extends Container<Line?> {
1717
/// Creates new unmounted [Block].
1818
@override
1919
Node newInstance() => Block();

lib/src/models/documents/nodes/leaf.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'line.dart';
77
import 'node.dart';
88

99
/// A leaf in Quill document tree.
10-
abstract class Leaf extends Node implements StyledNode {
10+
abstract class Leaf extends Node {
1111
/// Creates a new [Leaf] with specified [data].
1212
factory Leaf(Object data) {
1313
if (data is Embeddable) {

lib/src/models/documents/nodes/line.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'node.dart';
1717
///
1818
/// When a line contains an embed, it fully occupies the line, no other embeds
1919
/// or text nodes are allowed.
20-
class Line extends Container<Leaf?> implements StyledNode {
20+
class Line extends Container<Leaf?> {
2121
@override
2222
Leaf get defaultChild => Text();
2323

lib/src/models/documents/nodes/node.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,33 @@ abstract class StyledNode implements Node {
127127
Style get style;
128128
}
129129

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+
130157
/// Root node of document tree.
131158
class Root extends Container<Container<Node?>> {
132159
@override

0 commit comments

Comments
 (0)