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.
40 lines
792 B
40 lines
792 B
1 year ago
|
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,
|
||
|
);
|
||
|
}
|
||
|
}
|