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.
42 lines
866 B
42 lines
866 B
4 years ago
|
import 'dart:collection';
|
||
|
|
||
|
import 'package:flutter_quill/models/documents/style.dart';
|
||
|
|
||
|
import 'attribute.dart';
|
||
|
|
||
|
/* node in a document tree */
|
||
|
abstract class Node extends LinkedListEntry<Node> {}
|
||
|
|
||
|
abstract class StyledNode implements Node {
|
||
|
Style get style => _style;
|
||
|
Style _style = Style();
|
||
|
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
abstract class Container<T extends Node> extends Node {
|
||
|
Container _parent;
|
||
|
|
||
|
Container get parent => _parent;
|
||
|
|
||
|
bool get isFirst => list.first == this;
|
||
|
|
||
|
bool get isLast => list.last == this;
|
||
|
}
|
||
|
|
||
|
/* Root node of document tree */
|
||
|
class Root extends Container<Container<Node>> {}
|