parent
2bbb80cf84
commit
304f5a5f89
31 changed files with 458 additions and 466 deletions
@ -1,58 +1,58 @@ |
|||||||
import 'dart:convert' show jsonDecode, jsonEncode; |
// import 'dart:convert' show jsonDecode, jsonEncode; |
||||||
|
|
||||||
import 'package:flutter/widgets.dart'; |
// import 'package:flutter/widgets.dart'; |
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart'; |
// import 'package:flutter_inappwebview/flutter_inappwebview.dart'; |
||||||
import 'package:flutter_quill/flutter_quill.dart'; |
// import 'package:flutter_quill/flutter_quill.dart'; |
||||||
import 'package:meta/meta.dart' show experimental; |
// import 'package:meta/meta.dart' show experimental; |
||||||
|
|
||||||
import '../../models/config/editor/webview.dart'; |
// import '../../models/config/editor/webview.dart'; |
||||||
|
|
||||||
@experimental |
// @experimental |
||||||
class QuillEditorWebViewBlockEmbed extends CustomBlockEmbed { |
// class QuillEditorWebViewBlockEmbed extends CustomBlockEmbed { |
||||||
const QuillEditorWebViewBlockEmbed( |
// const QuillEditorWebViewBlockEmbed( |
||||||
String value, |
// String value, |
||||||
) : super(webViewType, value); |
// ) : super(webViewType, value); |
||||||
|
|
||||||
factory QuillEditorWebViewBlockEmbed.fromDocument(Document document) => |
// factory QuillEditorWebViewBlockEmbed.fromDocument(Document document) => |
||||||
QuillEditorWebViewBlockEmbed(jsonEncode(document.toDelta().toJson())); |
// QuillEditorWebViewBlockEmbed(jsonEncode(document.toDelta().toJson())); |
||||||
|
|
||||||
static const String webViewType = 'webview'; |
// static const String webViewType = 'webview'; |
||||||
|
|
||||||
Document get document => Document.fromJson(jsonDecode(data)); |
// Document get document => Document.fromJson(jsonDecode(data)); |
||||||
} |
// } |
||||||
|
|
||||||
@experimental |
// @experimental |
||||||
class QuillEditorWebViewEmbedBuilder extends EmbedBuilder { |
// class QuillEditorWebViewEmbedBuilder extends EmbedBuilder { |
||||||
const QuillEditorWebViewEmbedBuilder({ |
// const QuillEditorWebViewEmbedBuilder({ |
||||||
required this.configurations, |
// required this.configurations, |
||||||
}); |
// }); |
||||||
|
|
||||||
@override |
// @override |
||||||
bool get expanded => false; |
// bool get expanded => false; |
||||||
|
|
||||||
final QuillEditorWebViewEmbedConfigurations configurations; |
// final QuillEditorWebViewEmbedConfigurations configurations; |
||||||
@override |
// @override |
||||||
Widget build( |
// Widget build( |
||||||
BuildContext context, |
// BuildContext context, |
||||||
QuillController controller, |
// QuillController controller, |
||||||
Embed node, |
// Embed node, |
||||||
bool readOnly, |
// bool readOnly, |
||||||
bool inline, |
// bool inline, |
||||||
TextStyle textStyle, |
// TextStyle textStyle, |
||||||
) { |
// ) { |
||||||
final url = node.value.data as String; |
// final url = node.value.data as String; |
||||||
|
|
||||||
return SizedBox( |
// return SizedBox( |
||||||
width: double.infinity, |
// width: double.infinity, |
||||||
height: 200, |
// height: 200, |
||||||
child: InAppWebView( |
// child: InAppWebView( |
||||||
initialUrlRequest: URLRequest( |
// initialUrlRequest: URLRequest( |
||||||
url: Uri.parse(url), |
// url: Uri.parse(url), |
||||||
), |
// ), |
||||||
), |
// ), |
||||||
); |
// ); |
||||||
} |
// } |
||||||
|
|
||||||
@override |
// @override |
||||||
String get key => 'webview'; |
// String get key => 'webview'; |
||||||
} |
// } |
||||||
|
@ -0,0 +1,33 @@ |
|||||||
|
import 'package:flutter/widgets.dart' |
||||||
|
show Axis, WrapAlignment, WrapCrossAlignment, immutable; |
||||||
|
|
||||||
|
import '../../../widgets/toolbar/base_toolbar.dart'; |
||||||
|
import 'toolbar_shared_configurations.dart'; |
||||||
|
|
||||||
|
@immutable |
||||||
|
class QuillBaseToolbarConfigurations extends QuillSharedToolbarProperties { |
||||||
|
const QuillBaseToolbarConfigurations({ |
||||||
|
required this.childrenBuilder, |
||||||
|
super.axis = Axis.horizontal, |
||||||
|
super.toolbarSize = kDefaultIconSize * 2, |
||||||
|
super.toolbarSectionSpacing = kToolbarSectionSpacing, |
||||||
|
super.toolbarIconAlignment = WrapAlignment.center, |
||||||
|
super.toolbarIconCrossAlignment = WrapCrossAlignment.center, |
||||||
|
super.color, |
||||||
|
super.customButtons = const [], |
||||||
|
super.sectionDividerColor, |
||||||
|
super.sectionDividerSpace, |
||||||
|
super.linkDialogAction, |
||||||
|
super.multiRowsDisplay = true, |
||||||
|
super.decoration, |
||||||
|
|
||||||
|
/// Note this only used when you using the quill toolbar buttons like |
||||||
|
/// `QuillToolbarHistoryButton` inside it |
||||||
|
super.buttonOptions = const QuillToolbarButtonOptions(), |
||||||
|
}); |
||||||
|
|
||||||
|
final QuillBaseToolbarChildrenBuilder childrenBuilder; |
||||||
|
|
||||||
|
@override |
||||||
|
List<Object?> get props => []; |
||||||
|
} |
Loading…
Reference in new issue