Rich text editor for Flutter
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.
|
|
|
import 'package:flutter_quill/flutter_quill.dart';
|
|
|
|
|
|
|
|
import '../../presentation/embeds/editor/webview.dart';
|
|
|
|
|
|
|
|
extension QuillControllerExt on QuillController {
|
|
|
|
int get index => selection.baseOffset;
|
|
|
|
int get length => selection.extentOffset - index;
|
|
|
|
void insertWebViewBlock({
|
|
|
|
required String initialUrl,
|
|
|
|
}) {
|
|
|
|
final block = BlockEmbed.custom(
|
|
|
|
QuillEditorWebViewBlockEmbed(
|
|
|
|
initialUrl,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
this
|
|
|
|
..skipRequestKeyboard = true
|
|
|
|
..replaceText(
|
|
|
|
index,
|
|
|
|
length,
|
|
|
|
block,
|
|
|
|
null,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void insertImageBlock({
|
|
|
|
required String imageUrl,
|
|
|
|
}) {
|
|
|
|
this
|
|
|
|
..skipRequestKeyboard = true
|
|
|
|
..replaceText(
|
|
|
|
index,
|
|
|
|
length,
|
|
|
|
BlockEmbed.image(imageUrl),
|
|
|
|
null,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void insertVideoBlock({
|
|
|
|
required String videoUrl,
|
|
|
|
}) {
|
|
|
|
this
|
|
|
|
..skipRequestKeyboard = true
|
|
|
|
..replaceText(index, length, BlockEmbed.video(videoUrl), null);
|
|
|
|
}
|
|
|
|
}
|