dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
4 years ago
|
import 'dart:collection';
|
||
|
|
||
|
import 'package:flutter_quill/models/documents/style.dart';
|
||
|
|
||
4 years ago
|
import '../attribute.dart';
|
||
4 years ago
|
|
||
|
/* node in a document tree */
|
||
4 years ago
|
class Node extends LinkedListEntry<Node> {
|
||
|
Container _parent;
|
||
|
Style _style = Style();
|
||
4 years ago
|
|
||
|
Style get style => _style;
|
||
4 years ago
|
|
||
|
Container get parent => _parent;
|
||
4 years ago
|
|
||
|
void applyAttribute(Attribute attribute) {
|
||
|
_style = _style.merge(attribute);
|
||
|
}
|
||
|
|
||
|
void applyStyle(Style value) {
|
||
|
if (value == null) {
|
||
|
throw ArgumentError('null value');
|
||
|
}
|
||
|
_style = _style.mergeAll(value);
|
||
|
}
|
||
|
|
||
|
void clearStyle() {
|
||
|
_style = Style();
|
||
|
}
|
||
|
|
||
|
bool get isFirst => list.first == this;
|
||
|
|
||
|
bool get isLast => list.last == this;
|
||
4 years ago
|
|
||
|
@override
|
||
|
void insertBefore(Node entry) {
|
||
|
assert(entry._parent == null && _parent != null);
|
||
|
entry._parent = _parent;
|
||
|
super.insertBefore(entry);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void insertAfter(Node entry) {
|
||
|
assert(entry._parent == null && _parent != null);
|
||
|
entry._parent = _parent;
|
||
|
super.insertAfter(entry);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void unlink() {
|
||
|
assert(_parent != null);
|
||
|
_parent = null;
|
||
|
super.unlink();
|
||
|
}
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
abstract class Container<T extends Node> extends Node {}
|
||
|
|
||
4 years ago
|
/* Root node of document tree */
|
||
|
class Root extends Container<Container<Node>> {}
|