forked from singerdmx/flutter-quill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
466 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,115 @@ | ||
library universal_ui; | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter_quill/flutter_quill.dart'; | ||
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart'; | ||
import 'package:universal_html/html.dart' as html; | ||
import 'package:youtube_player_flutter/youtube_player_flutter.dart'; | ||
|
||
import '../widgets/responsive_widget.dart'; | ||
import 'fake_ui.dart' if (dart.library.html) 'real_ui.dart' as ui_instance; | ||
// import '../widgets/responsive_widget.dart'; | ||
// import 'fake_ui.dart' if (dart.library.html) 'real_ui.dart' as ui_instance; | ||
|
||
class PlatformViewRegistryFix { | ||
void registerViewFactory(dynamic x, dynamic y) { | ||
if (kIsWeb) { | ||
ui_instance.PlatformViewRegistry.registerViewFactory( | ||
x, | ||
y, | ||
); | ||
} | ||
} | ||
} | ||
// class PlatformViewRegistryFix { | ||
// void registerViewFactory(dynamic x, dynamic y) { | ||
// if (kIsWeb) { | ||
// ui_instance.PlatformViewRegistry.registerViewFactory( | ||
// x, | ||
// y, | ||
// ); | ||
// } | ||
// } | ||
// } | ||
|
||
class UniversalUI { | ||
PlatformViewRegistryFix platformViewRegistry = PlatformViewRegistryFix(); | ||
} | ||
// class UniversalUI { | ||
// PlatformViewRegistryFix platformViewRegistry = PlatformViewRegistryFix(); | ||
// } | ||
|
||
var ui = UniversalUI(); | ||
// var ui = UniversalUI(); | ||
|
||
class ImageEmbedBuilderWeb extends EmbedBuilder { | ||
@override | ||
String get key => BlockEmbed.imageType; | ||
// class ImageEmbedBuilderWeb extends EmbedBuilder { | ||
// @override | ||
// String get key => BlockEmbed.imageType; | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
QuillController controller, | ||
Embed node, | ||
bool readOnly, | ||
bool inline, | ||
TextStyle textStyle, | ||
) { | ||
final imageUrl = node.value.data; | ||
if (isImageBase64(imageUrl)) { | ||
// TODO: handle imageUrl of base64 | ||
return const SizedBox(); | ||
} | ||
final size = MediaQuery.sizeOf(context); | ||
UniversalUI().platformViewRegistry.registerViewFactory(imageUrl, (viewId) { | ||
return html.ImageElement() | ||
..src = imageUrl | ||
..style.height = 'auto' | ||
..style.width = 'auto'; | ||
}); | ||
return Padding( | ||
padding: EdgeInsets.only( | ||
right: ResponsiveWidget.isMediumScreen(context) | ||
? size.width * 0.5 | ||
: (ResponsiveWidget.isLargeScreen(context)) | ||
? size.width * 0.75 | ||
: size.width * 0.2, | ||
), | ||
child: SizedBox( | ||
height: size.height * 0.45, | ||
child: HtmlElementView( | ||
viewType: imageUrl, | ||
), | ||
), | ||
); | ||
} | ||
} | ||
// @override | ||
// Widget build( | ||
// BuildContext context, | ||
// QuillController controller, | ||
// Embed node, | ||
// bool readOnly, | ||
// bool inline, | ||
// TextStyle textStyle, | ||
// ) { | ||
// final imageUrl = node.value.data; | ||
// if (isImageBase64(imageUrl)) { | ||
// // TODO: handle imageUrl of base64 | ||
// return const SizedBox(); | ||
// } | ||
// final size = MediaQuery.sizeOf(context); | ||
// UniversalUI().platformViewRegistry.registerViewFactory(imageUrl, | ||
//(viewId) { | ||
// return html.ImageElement() | ||
// ..src = imageUrl | ||
// ..style.height = 'auto' | ||
// ..style.width = 'auto'; | ||
// }); | ||
// return Padding( | ||
// padding: EdgeInsets.only( | ||
// right: ResponsiveWidget.isMediumScreen(context) | ||
// ? size.width * 0.5 | ||
// : (ResponsiveWidget.isLargeScreen(context)) | ||
// ? size.width * 0.75 | ||
// : size.width * 0.2, | ||
// ), | ||
// child: SizedBox( | ||
// height: size.height * 0.45, | ||
// child: HtmlElementView( | ||
// viewType: imageUrl, | ||
// ), | ||
// ), | ||
// ); | ||
// } | ||
// } | ||
|
||
class VideoEmbedBuilderWeb extends EmbedBuilder { | ||
@override | ||
String get key => BlockEmbed.videoType; | ||
// class VideoEmbedBuilderWeb extends EmbedBuilder { | ||
// @override | ||
// String get key => BlockEmbed.videoType; | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
QuillController controller, | ||
Embed node, | ||
bool readOnly, | ||
bool inline, | ||
TextStyle textStyle, | ||
) { | ||
var videoUrl = node.value.data; | ||
if (videoUrl.contains('youtube.com') || videoUrl.contains('youtu.be')) { | ||
final youtubeID = YoutubePlayer.convertUrlToId(videoUrl); | ||
if (youtubeID != null) { | ||
videoUrl = 'https://www.youtube.com/embed/$youtubeID'; | ||
} | ||
} | ||
// @override | ||
// Widget build( | ||
// BuildContext context, | ||
// QuillController controller, | ||
// Embed node, | ||
// bool readOnly, | ||
// bool inline, | ||
// TextStyle textStyle, | ||
// ) { | ||
// var videoUrl = node.value.data; | ||
// if (videoUrl.contains('youtube.com') || videoUrl.contains('youtu.be')) { | ||
// final youtubeID = YoutubePlayer.convertUrlToId(videoUrl); | ||
// if (youtubeID != null) { | ||
// videoUrl = 'https://www.youtube.com/embed/$youtubeID'; | ||
// } | ||
// } | ||
|
||
final size = MediaQuery.sizeOf(context); | ||
// final size = MediaQuery.sizeOf(context); | ||
|
||
UniversalUI().platformViewRegistry.registerViewFactory( | ||
videoUrl, | ||
(id) => html.IFrameElement() | ||
..width = size.width.toString() | ||
..height = size.height.toString() | ||
..src = videoUrl | ||
..style.border = 'none', | ||
); | ||
// UniversalUI().platformViewRegistry.registerViewFactory( | ||
// videoUrl, | ||
// (id) => html.IFrameElement() | ||
// ..width = size.width.toString() | ||
// ..height = size.height.toString() | ||
// ..src = videoUrl | ||
// ..style.border = 'none', | ||
// ); | ||
|
||
return SizedBox( | ||
height: 500, | ||
child: HtmlElementView( | ||
viewType: videoUrl, | ||
), | ||
); | ||
} | ||
} | ||
// return SizedBox( | ||
// height: 500, | ||
// child: HtmlElementView( | ||
// viewType: videoUrl, | ||
// ), | ||
// ); | ||
// } | ||
// } | ||
|
||
List<EmbedBuilder> get defaultEmbedBuildersWeb => [ | ||
...FlutterQuillEmbeds.editorsWebBuilders(), | ||
// ImageEmbedBuilderWeb(), | ||
const QuillEditorWebImageEmbedBuilder(), | ||
VideoEmbedBuilderWeb(), | ||
// VideoEmbedBuilderWeb(), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.6.0-dev.6 | ||
- Better support for web | ||
- Smal fixes and updates | ||
|
||
## 0.6.0-dev.5 | ||
- Update the camera button | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.