Skip to content

Commit

Permalink
feat(spoiler): pass and reserve spoiler body content
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Nov 19, 2024
1 parent 479caa8 commit 33b6b17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/editor_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ final class BBCodeEditorController {
void setDocumentFromJson(List<dynamic> json) =>
_quillController.document = Document.fromJson(json);

/// Set the document from delta
void setDocumentFromDelta(Delta delta) =>
_quillController.document = Document.fromDelta(delta);

/// Set the document from raw text without format.
void setDocumentFromRawText(String text) {
final String fixedText;
Expand Down
12 changes: 12 additions & 0 deletions lib/src/tags/spoiler/spoiler_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_bbcode_editor/src/tags/spoiler/spoiler_embed.dart';
import 'package:flutter_bbcode_editor/src/tags/spoiler/spoiler_keys.dart';
import 'package:flutter_bbcode_editor/src/types.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill/quill_delta.dart';

/// Editor widget builder for embed spoiler types.
///
Expand Down Expand Up @@ -324,6 +325,13 @@ class _SpoilerEditPageState extends State<_SpoilerEditPage> {
super.initState();
titleController = TextEditingController(text: widget.initialData?.title);
bodyController = BBCodeEditorController();
if (widget.initialData != null) {
bodyController.setDocumentFromDelta(
Delta.fromJson(
jsonDecode(widget.initialData!.body) as List<dynamic>,
),
);
}
}

@override
Expand Down Expand Up @@ -384,6 +392,10 @@ class _SpoilerEditPageState extends State<_SpoilerEditPage> {
urlPicker: widget.urlPicker,
imagePicker: widget.imagePicker,
usernamePicker: widget.usernamePicker,
// Disable font family
showFontFamily: false,
// Disable nested spoiler
showSpoilerButton: false,
),
],
),
Expand Down

0 comments on commit 33b6b17

Please sign in to comment.