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.
44 lines
1.1 KiB
44 lines
1.1 KiB
import 'package:flutter_quill/flutter_quill.dart'; |
|
|
|
/// Extension functions on [QuillController] |
|
/// that make it easier to insert the embed blocks |
|
/// |
|
/// and provide some other extra utilities |
|
extension QuillControllerExt on QuillController { |
|
int get index => selection.baseOffset; |
|
int get length => selection.extentOffset - index; |
|
|
|
/// Insert image embed block, it requires the [imageSource] |
|
/// |
|
/// it could be local image on the system file |
|
/// http image on the network |
|
/// |
|
/// image base 64 |
|
void insertImageBlock({ |
|
required String imageSource, |
|
}) { |
|
this |
|
..skipRequestKeyboard = true |
|
..replaceText( |
|
index, |
|
length, |
|
BlockEmbed.image(imageSource), |
|
null, |
|
); |
|
} |
|
|
|
/// Insert video embed block, it requires the [videoUrl] |
|
/// |
|
/// it could be the video url directly (.mp4) |
|
/// either locally on file system |
|
/// or http video on the network |
|
/// |
|
/// it also supports youtube video url |
|
void insertVideoBlock({ |
|
required String videoUrl, |
|
}) { |
|
this |
|
..skipRequestKeyboard = true |
|
..replaceText(index, length, BlockEmbed.video(videoUrl), null); |
|
} |
|
}
|
|
|