Skip to content

Commit

Permalink
docs(readme): improve Input / Output section to clarify save/load doc…
Browse files Browse the repository at this point in the history
…ument
  • Loading branch information
EchoEllet committed Nov 17, 2024
1 parent 2b8c9e9 commit 0b9b59e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,31 @@ The Delta format is a compact and versatile method for describing document chang
* Use `_controller.document.toDelta()` to extract the deltas.
* Use `_controller.document.toPlainText()` to extract plain text.

To save the document as JSON:
**To save the document**:

```dart
final json = jsonEncode(_controller.document.toDelta().toJson());
final String json = jsonEncode(_controller.document.toDelta().toJson());
// Stores the JSON Quill Delta
```

To open an existing JSON representation that has been previously stored:
**To load the document**:

```dart
final json = jsonDecode(r'{"insert":"hello\n"}');
final String json = ...; // Load the previously stored JSON Quill Delta
_controller.document = Document.fromJson(json);
_controller.document = Document.fromJson(jsonDecode(json));
```

**To change the read-only mode**:

```dart
_controller.readOnly = true; // Or false to allow edit
```

### 🔗 Links

- [Quill Delta](https://quilljs.com/docs/delta/)
- [Quill Delta Formats](https://quilljs.com/docs/formats)
- [🪶 Quill Delta](https://quilljs.com/docs/delta/)
- [📜 Quill Delta Formats](https://quilljs.com/docs/formats)

## ⚙️ Configurations

Expand Down

0 comments on commit 0b9b59e

Please sign in to comment.