Implements StyledNode

pull/555/head
X Code 3 years ago
parent 71793e5bd8
commit dfa623a4fd
  1. 2
      lib/src/models/documents/nodes/block.dart
  2. 2
      lib/src/models/documents/nodes/leaf.dart
  3. 2
      lib/src/models/documents/nodes/line.dart
  4. 27
      lib/src/models/documents/nodes/node.dart

@ -13,7 +13,7 @@ import 'node.dart';
/// - Text Alignment
/// - Text Direction
/// - Code Block
class Block extends Container<Line?> {
class Block extends Container<Line?> implements StyledNode {
/// Creates new unmounted [Block].
@override
Node newInstance() => Block();

@ -7,7 +7,7 @@ import 'line.dart';
import 'node.dart';
/// A leaf in Quill document tree.
abstract class Leaf extends Node {
abstract class Leaf extends Node implements StyledNode {
/// Creates a new [Leaf] with specified [data].
factory Leaf(Object data) {
if (data is Embeddable) {

@ -17,7 +17,7 @@ import 'node.dart';
///
/// When a line contains an embed, it fully occupies the line, no other embeds
/// or text nodes are allowed.
class Line extends Container<Leaf?> {
class Line extends Container<Leaf?> implements StyledNode {
@override
Leaf get defaultChild => Text();

@ -127,33 +127,6 @@ abstract class StyledNode implements Node {
Style get style;
}
/// Mixin used by nodes that wish to implement [StyledNode] interface.
abstract class StyledNodeMixin implements StyledNode {
@override
Style get style => _style;
@override
Style _style = Style();
/// Applies style [attribute] to this node.
@override
void applyAttribute(Attribute attribute) {
_style = _style.merge(attribute);
}
/// Applies new style [value] to this node. Provided [value] is merged
/// into current style.
@override
void applyStyle(Style value) {
_style = _style.mergeAll(value);
}
/// Clears style of this node.
@override
void clearStyle() {
_style = Style();
}
}
/// Root node of document tree.
class Root extends Container<Container<Node?>> {
@override

Loading…
Cancel
Save