support for custom non-styling attribute

pull/31/head
ritheshSalyan 4 years ago
parent 6203c1d4a6
commit 38299176ab
  1. 15
      .vscode/launch.json
  2. 3
      lib/models/documents/attribute.dart
  3. 2
      lib/models/documents/style.dart
  4. 1
      lib/widgets/toolbar.dart

@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "flutter-quill",
"request": "launch",
"type": "dart",
"program": "app/lib/main.dart"
},
]
}

@ -155,7 +155,8 @@ class Attribute<T> {
static Attribute fromKeyValue(String key, dynamic value) { static Attribute fromKeyValue(String key, dynamic value) {
if (!_registry.containsKey(key)) { if (!_registry.containsKey(key)) {
throw ArgumentError.value(key, 'key "$key" not found.'); return null;
// throw ArgumentError.value(key, 'key "$key" not found.');
} }
Attribute origin = _registry[key]; Attribute origin = _registry[key];
Attribute attribute = clone(origin, value); Attribute attribute = clone(origin, value);

@ -17,7 +17,7 @@ class Style {
Map<String, Attribute> result = attributes.map((String key, dynamic value) { Map<String, Attribute> result = attributes.map((String key, dynamic value) {
Attribute attr = Attribute.fromKeyValue(key, value); Attribute attr = Attribute.fromKeyValue(key, value);
return MapEntry<String, Attribute>(key, attr); return MapEntry<String, Attribute>(key, attr??Attribute(key, AttributeScope.INLINE, value));
}); });
return Style.attr(result); return Style.attr(result);
} }

@ -742,6 +742,7 @@ class _HistoryButtonState extends State<HistoryButton> {
} }
void _setIconColor() { void _setIconColor() {
if(!mounted) return;
if (widget.undo) { if (widget.undo) {
setState(() { setState(() {
_iconColor = widget.controller.hasUndo _iconColor = widget.controller.hasUndo

Loading…
Cancel
Save