diff --git a/CHANGELOG.md b/CHANGELOG.md index d069358f..6ec72d1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## 8.5.4 +- The `mobileWidth`, `mobileHeight`, `mobileMargin` and `mobileAlignment` is now deprecated in `flutter_quill`, they are are now defined in `flutter_quill_extensions` + ## 8.5.3 - Update doc - Update `README.md` and `CHANGELOG.md` diff --git a/README.md b/README.md index d5ec3667..4db2dd8c 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,13 @@ it in GitHub repo instead. - [Usage](#usage) - [Migration](#migration) - [Input / Output](#input--output) - - [Configurations](#configurations) - [Links](#links) + - [Configurations](#configurations) + - [Links](#links-1) - [Font Family](#font-family) - [Embed Blocks](#embed-blocks) - [Using the embed blocks from `flutter_quill_extensions`](#using-the-embed-blocks-from-flutter_quill_extensions) - - [Links](#links-1) + - [Links](#links-2) - [Conversion to HTML](#conversion-to-html) - [Translation](#translation) - [Testing](#testing) @@ -143,7 +144,7 @@ QuillProvider( And depending on your use case, you might want to dispose the `_controller` in dispose method -in most cases it's better to. +in most cases, it's better to. Check out [Sample Page] for more advanced usage. @@ -153,7 +154,15 @@ We have added [Migration Guide](/doc/migration.md) for migration from different ## Input / Output -This library uses [Quill] as an internal data format. +This library uses [Quill Delta](https://quilljs.com/docs/delta/) +to represent the document content. +The Delta format is a compact and versatile way to describe document changes. +It consists of a series of operations, each representing an insertion, deletion, +or formatting change within the document. + +Don’t be confused by its name Delta—Deltas represents both documents and changes to documents. +If you think of Deltas as the instructions from going from one document to another, +the way Deltas represent a document is by expressing the instructions starting from an empty document. * Use `_controller.document.toDelta()` to extract the deltas. * Use `_controller.document.toPlainText()` to extract plain text. @@ -162,7 +171,7 @@ FlutterQuill provides some JSON serialization support, so that you can save and To save a document as JSON, do something like the following: ```dart -var json = jsonEncode(_controller.document.toDelta().toJson()); +final json = jsonEncode(_controller.document.toDelta().toJson()); ``` You can then write this to storage. @@ -171,13 +180,23 @@ To open a FlutterQuill editor with an existing JSON representation that you've p you can do something like this: ```dart -var myJSON = jsonDecode(r'{"insert":"hello\n"}'); +final json = jsonDecode(r'{"insert":"hello\n"}'); + _controller = QuillController( - document: Document.fromJson(myJSON), - selection: TextSelection.collapsed(offset: 0), - ); + document: Document.fromJson(json), + selection: TextSelection.collapsed(offset: 0), +); ``` +### Links + +- [Quill Delta](https://quilljs.com/docs/delta/) +- [Quill Delta Formats](https://quilljs.com/docs/formats) +- [Why Quill](https://quilljs.com/guides/why-quill/) +- [Quill JS Configurations](https://quilljs.com/docs/configuration/) +- [Quill JS Interactive Playground](https://quilljs.com/playground/) +- [Quill JS GitHub repo](https://github.com/quilljs/quill) + ## Configurations The `QuillToolbar` and `QuillEditor` widgets lets you customize a lot of things diff --git a/flutter_quill_extensions/lib/logic/extensions/attribute.dart b/flutter_quill_extensions/lib/logic/extensions/attribute.dart new file mode 100644 index 00000000..84cdecf6 --- /dev/null +++ b/flutter_quill_extensions/lib/logic/extensions/attribute.dart @@ -0,0 +1,14 @@ +import 'package:flutter_quill/flutter_quill.dart' + show Attribute, AttributeScope; + +class MobileWidthAttribute extends Attribute { + const MobileWidthAttribute(String? val) + : super('mobileWidth', AttributeScope.ignore, val); +} + +class MobileHeightAttribute extends Attribute { + const MobileHeightAttribute(String? val) + : super('mobileHeight', AttributeScope.ignore, val); +} + +extension AttributeExt on Attribute {} diff --git a/lib/src/models/documents/attribute.dart b/lib/src/models/documents/attribute.dart index 03df00fe..b8127881 100644 --- a/lib/src/models/documents/attribute.dart +++ b/lib/src/models/documents/attribute.dart @@ -109,20 +109,20 @@ class Attribute extends Equatable { static final ScriptAttribute script = ScriptAttribute(null); - // TODO: You might want to mark those as key (like mobileWidthKey) - // because it was not very clear to a developer that is new to this project + @Deprecated('This property is no logner used in flutter_quill') static const String mobileWidth = 'mobileWidth'; + @Deprecated('This property is no logner used in flutter_quill') static const String mobileHeight = 'mobileHeight'; + @Deprecated('This property is no logner used in flutter_quill') static const String mobileMargin = 'mobileMargin'; + @Deprecated('This property is no logner used in flutter_quill') static const String mobileAlignment = 'mobileAlignment'; - /// For other platforms, for mobile use [mobileAlignment] static const String alignment = 'alignment'; - /// For other platforms, for mobile use [mobileMargin] static const String margin = 'margin'; static const ImageAttribute image = ImageAttribute(null);