From dfa623a4fdd477ad21a317bf14daaff93d530524 Mon Sep 17 00:00:00 2001 From: X Code Date: Thu, 23 Dec 2021 17:26:24 -0800 Subject: [PATCH] Implements StyledNode --- lib/src/models/documents/nodes/block.dart | 2 +- lib/src/models/documents/nodes/leaf.dart | 2 +- lib/src/models/documents/nodes/line.dart | 2 +- lib/src/models/documents/nodes/node.dart | 27 ----------------------- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/lib/src/models/documents/nodes/block.dart b/lib/src/models/documents/nodes/block.dart index 095f1183..c69d6a8f 100644 --- a/lib/src/models/documents/nodes/block.dart +++ b/lib/src/models/documents/nodes/block.dart @@ -13,7 +13,7 @@ import 'node.dart'; /// - Text Alignment /// - Text Direction /// - Code Block -class Block extends Container { +class Block extends Container implements StyledNode { /// Creates new unmounted [Block]. @override Node newInstance() => Block(); diff --git a/lib/src/models/documents/nodes/leaf.dart b/lib/src/models/documents/nodes/leaf.dart index 3895fd62..48817a10 100644 --- a/lib/src/models/documents/nodes/leaf.dart +++ b/lib/src/models/documents/nodes/leaf.dart @@ -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) { diff --git a/lib/src/models/documents/nodes/line.dart b/lib/src/models/documents/nodes/line.dart index bccd7fb8..b0977500 100644 --- a/lib/src/models/documents/nodes/line.dart +++ b/lib/src/models/documents/nodes/line.dart @@ -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 { +class Line extends Container implements StyledNode { @override Leaf get defaultChild => Text(); diff --git a/lib/src/models/documents/nodes/node.dart b/lib/src/models/documents/nodes/node.dart index 8863138a..090c1ba8 100644 --- a/lib/src/models/documents/nodes/node.dart +++ b/lib/src/models/documents/nodes/node.dart @@ -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> { @override