Skip to content

Commit 0193230

Browse files
authored
fix(extensions)!: drop support for YouTube iframeView for non-web platforms, remove youtube_player_flutter dependency, throw warnings for anything related to YoutubeVideoApp in development mode (singerdmx#2286)
* fix: drop support for YouTube iframeView for non-web platforms, throw warnings for anything related to YoutubeVideoApp in development mode
1 parent 92e4c74 commit 0193230

File tree

12 files changed

+246
-59
lines changed

12 files changed

+246
-59
lines changed

example/lib/screens/quill/my_quill_editor.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ class MyQuillEditor extends StatelessWidget {
128128
},
129129
),
130130
videoEmbedConfigurations: QuillEditorVideoEmbedConfigurations(
131-
// Loading YouTube videos on Desktop is not supported yet
132-
// when using iframe platform view
133-
youtubeVideoSupportMode: isDesktopApp
134-
? YoutubeVideoSupportMode.customPlayerWithDownloadUrl
135-
: YoutubeVideoSupportMode.iframeView,
131+
customVideoBuilder: (videoUrl, readOnly) {
132+
// Example: Check for YouTube Video URL and return your
133+
// YouTube video widget here.
134+
135+
// Otherwise return null to fallback to the defualt logic
136+
return null;
137+
},
138+
ignoreYouTubeSupport: true,
136139
),
137140
)),
138141
TimeStampEmbedBuilderWidget(),

example/macos/Podfile.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ PODS:
1818
- path_provider_foundation (0.0.1):
1919
- Flutter
2020
- FlutterMacOS
21-
- quill_native_bridge (0.0.1):
22-
- FlutterMacOS
2321
- share_plus (0.0.1):
2422
- FlutterMacOS
2523
- sqflite (0.0.3):
@@ -42,7 +40,6 @@ DEPENDENCIES:
4240
- gal (from `Flutter/ephemeral/.symlinks/plugins/gal/darwin`)
4341
- irondash_engine_context (from `Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos`)
4442
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
45-
- quill_native_bridge (from `Flutter/ephemeral/.symlinks/plugins/quill_native_bridge/macos`)
4643
- share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`)
4744
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
4845
- super_native_extensions (from `Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos`)
@@ -70,8 +67,6 @@ EXTERNAL SOURCES:
7067
:path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos
7168
path_provider_foundation:
7269
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
73-
quill_native_bridge:
74-
:path: Flutter/ephemeral/.symlinks/plugins/quill_native_bridge/macos
7570
share_plus:
7671
:path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos
7772
sqflite:
@@ -93,7 +88,6 @@ SPEC CHECKSUMS:
9388
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
9489
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
9590
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
96-
quill_native_bridge: 1a3a4bfab7cbe4ed0232a17d8aae201a3ce6d302
9791
share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf
9892
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
9993
super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3

flutter_quill_extensions/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ The package uses the following plugins:
5050
platform-specific setup.
5151
2. [`image_picker`](https://pub.dev/packages/image_picker) for picking images.
5252
See the [Installation](https://pub.dev/packages/image_picker#installation) section.
53-
3. [`youtube_player_flutter`](https://pub.dev/packages/youtube_player_flutter) which
54-
uses [`flutter_inappwebview`](https://pub.dev/packages/flutter_inappwebview) which has a requirement setup on web.
55-
See the [Installation - Web support](https://pub.dev/packages/flutter_inappwebview#installation---web-support).
56-
4. [`super_clipboard`](https://pub.dev/packages/super_clipboard) which needs some setup on Android only, it's used to
53+
3. [`super_clipboard`](https://pub.dev/packages/super_clipboard) which needs some setup on Android only, it's used to
5754
support copying images and pasting them into editor, it's also required to support rich text pasting feature on
5855
non-web platforms, Open the [Android Support](https://pub.dev/packages/super_clipboard#android-support) page for
5956
instructions.

flutter_quill_extensions/lib/src/common/utils/utils.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ bool isImageBase64(String imageUrl) {
2525
return !isHttpBasedUrl(imageUrl) && isBase64(imageUrl);
2626
}
2727

28+
@Deprecated(
29+
'Will be removed in future releases. See https://github.com/singerdmx/flutter-quill/issues/2284'
30+
' and https://github.com/singerdmx/flutter-quill/issues/2276',
31+
)
2832
bool isYouTubeUrl(String videoUrl) {
2933
try {
3034
final uri = Uri.parse(videoUrl);

flutter_quill_extensions/lib/src/editor/video/models/video_configurations.dart

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
import 'package:flutter/widgets.dart' show GlobalKey;
2-
import 'package:meta/meta.dart' show immutable;
1+
import 'package:flutter/widgets.dart' show GlobalKey, Widget;
2+
import 'package:meta/meta.dart' show experimental, immutable;
33

44
import 'youtube_video_support_mode.dart';
55

66
@immutable
77
class QuillEditorVideoEmbedConfigurations {
88
const QuillEditorVideoEmbedConfigurations({
99
this.onVideoInit,
10-
this.youtubeVideoSupportMode = YoutubeVideoSupportMode.iframeView,
10+
@Deprecated(
11+
'Loading youtube videos is no longer built-in feature of flutter_quill_extensions.\n'
12+
'See https://github.com/singerdmx/flutter-quill/issues/2284.\n'
13+
'Try to use the experimental `customVideoBuilder` property to implement\n'
14+
'your own YouTube logic using packages such as '
15+
'https://pub.dev/packages/youtube_video_player or https://pub.dev/packages/youtube_player_flutter',
16+
)
17+
this.youtubeVideoSupportMode = YoutubeVideoSupportMode.disabled,
18+
this.ignoreYouTubeSupport = false,
19+
this.customVideoBuilder,
1120
});
1221

1322
/// [onVideoInit] is a callback function that gets triggered when
@@ -27,5 +36,49 @@ class QuillEditorVideoEmbedConfigurations {
2736

2837
/// Specifies how YouTube videos should be loaded if the video URL
2938
/// is YouTube video.
39+
@Deprecated(
40+
'Loading youtube videos is no longer built-in feature of flutter_quill_extensions.\n'
41+
'See https://github.com/singerdmx/flutter-quill/issues/2284.\n'
42+
'Try to use the experimental `customVideoBuilder` property to implement\n'
43+
'your own YouTube logic using packages such as '
44+
'https://pub.dev/packages/youtube_video_player or https://pub.dev/packages/youtube_player_flutter',
45+
)
3046
final YoutubeVideoSupportMode youtubeVideoSupportMode;
47+
48+
/// Pass `true` to ignore anything related to YouTube which will disable
49+
/// This functionality is without any warnings.
50+
///
51+
/// Making it `true`, means that the video embed widget will no longer
52+
/// check for the video URL and expect it a valid and a standrad video URL.
53+
///
54+
/// This property will be removed in future releases once YouTube support is
55+
/// removed.
56+
///
57+
/// Use [customVideoBuilder] to load youtube videos.
58+
@experimental
59+
@Deprecated(
60+
'Will be removed in future releases. Exist to allow users to ignore warnings.',
61+
)
62+
final bool ignoreYouTubeSupport;
63+
64+
/// [customVideoBuilder] is a callback function that receives the
65+
/// video URL and a read-only flag. This allows users to define
66+
/// their own logic for rendering video widgets, enabling support
67+
/// for various video platforms, such as YouTube.
68+
///
69+
/// Example usage:
70+
/// ```dart
71+
/// customVideoBuilder: (videoUrl, readOnly) {
72+
/// // Return `null` to fallback to defualt logic of QuillEditorVideoEmbedBuilder
73+
///
74+
/// // Return a custom video widget based on the videoUrl
75+
/// return CustomVideoWidget(videoUrl: videoUrl, readOnly: readOnly);
76+
/// },
77+
/// ```
78+
///
79+
/// It's a quick solution as response to https://github.com/singerdmx/flutter-quill/issues/2284
80+
///
81+
/// **Might be removed or changed in future releases.**
82+
@experimental
83+
final Widget? Function(String videoUrl, bool readOnly)? customVideoBuilder;
3184
}

flutter_quill_extensions/lib/src/editor/video/models/video_web_configurations.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ class QuillEditorWebVideoEmbedConfigurations {
77
this.constraints,
88
});
99

10+
@Deprecated('This property is no longer used.')
1011
final BoxConstraints? constraints;
1112
}
Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,54 @@
1-
/// Enum represents the different modes for handling YouTube video support.
1+
import 'package:meta/meta.dart';
2+
3+
/// **Will be removed soon in future releases**.
4+
@experimental
5+
@Deprecated(
6+
'YouTube video support will be removed soon and completely in the next releases.',
7+
)
28
enum YoutubeVideoSupportMode {
9+
/// **Will be removed soon in future releases**.
310
/// Disable loading of YouTube videos.
11+
/// **Will be removed soon in future releases**.
12+
@Deprecated('Loading YouTube videos is already disabled by default.')
413
disabled,
514

15+
/// **Will be removed soon in future releases**.
16+
///
617
/// Load the video using the official YouTube IFrame API.
718
/// See [YouTube IFrame API](https://developers.google.com/youtube/iframe_api_reference) for more details.
819
///
920
/// This will use Platform View on native platforms to use WebView
1021
/// The WebView might not be supported on Desktop and will throw an exception
1122
///
1223
/// See [Flutter InAppWebview Support for Flutter Desktop](https://github.com/pichillilorenzo/flutter_inappwebview/issues/460)
24+
///
25+
/// **Important**: We had to remove [flutter_inappwebview](https://pub.dev/packages/flutter_inappwebview)
26+
/// and [youtube_player_flutter](https://pub.dev/packages/youtube_player_flutter)
27+
/// as non breaking change since most users are unable to build the project,
28+
/// preventing them from using
29+
///
30+
/// **Will be removed soon in future releases**.
31+
@Deprecated(
32+
'This functionality has been removed to fix build failure issues. See https://github.com/singerdmx/flutter-quill/issues/2284 for discussion.',
33+
)
1334
iframeView,
1435

36+
/// **Will be removed soon in future releases**.
37+
///
1538
/// Load the video using a custom video player by fetching the YouTube video URL.
1639
/// Note: This might violate YouTube's terms of service.
1740
/// See [YouTube Terms of Service](https://www.youtube.com/static?template=terms) for more details.
41+
///
42+
/// **WARNING**: We highly suggest to not use this solution,
43+
/// can cause issues with YouTube Terms of Service and require a extra dependency for all users.
44+
/// YouTube servers can reject requests and respond with `Sign in to confirm you’re not a bot`
45+
/// See related issue: https://github.com/Hexer10/youtube_explode_dart/issues/282
46+
///
47+
/// **Will be removed soon in future releases**.
48+
@Deprecated(
49+
'Can cause issues with YouTube Terms of Service and require a extra dependency for all users - Will be removed soon.\n'
50+
'YouTube servers can reject requests and respond with "Sign in to confirm you’re not a bot"\n'
51+
'See related issue https://github.com/Hexer10/youtube_explode_dart/issues/282\n',
52+
)
1853
customPlayerWithDownloadUrl,
1954
}

flutter_quill_extensions/lib/src/editor/video/video_embed.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,35 @@ class QuillEditorVideoEmbedBuilder extends EmbedBuilder {
3333
assert(!kIsWeb, 'Please provide video EmbedBuilder for Web');
3434

3535
final videoUrl = node.value.data;
36-
if (isYouTubeUrl(videoUrl)) {
36+
37+
final customVideoBuilder = configurations.customVideoBuilder;
38+
if (customVideoBuilder != null) {
39+
final videoWidget = customVideoBuilder(videoUrl, readOnly);
40+
if (videoWidget != null) {
41+
return videoWidget;
42+
}
43+
}
44+
45+
// ignore: deprecated_member_use_from_same_package
46+
if (isYouTubeUrl(videoUrl) && !configurations.ignoreYouTubeSupport) {
47+
assert(() {
48+
debugPrint(
49+
"It seems that you're loading a youtube video URL.\n"
50+
'Loading YouTube videos is no longer built-in feature as part of flutter_quill_extensions.\n'
51+
'This message will only appear in development mode. See https://github.com/singerdmx/flutter-quill/issues/2284\n'
52+
'Consider using the experimental property `QuillEditorVideoEmbedConfigurations.customVideoBuilder` in your configuration.\n'
53+
'This message will only included in development mode.\n',
54+
);
55+
return true;
56+
}());
57+
58+
/// Will be removed soon in future releases
59+
60+
// ignore: deprecated_member_use_from_same_package
3761
return YoutubeVideoApp(
3862
videoUrl: videoUrl,
3963
readOnly: readOnly,
64+
// ignore: deprecated_member_use_from_same_package
4065
youtubeVideoSupportMode: configurations.youtubeVideoSupportMode,
4166
);
4267
}

flutter_quill_extensions/lib/src/editor/video/video_web_embed.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import 'package:flutter/widgets.dart';
22
import 'package:flutter_quill/flutter_quill.dart';
33
import 'package:universal_html/html.dart' as html;
4-
import 'package:youtube_player_flutter/youtube_player_flutter.dart'
5-
show YoutubePlayer;
64

75
import '../../common/utils/dart_ui/dart_ui_fake.dart'
86
if (dart.library.js_interop) '../../common/utils/dart_ui/dart_ui_real.dart'
97
as ui;
108
import '../../common/utils/element_utils/element_web_utils.dart';
119
import '../../common/utils/utils.dart';
1210
import 'models/video_web_configurations.dart';
11+
import 'youtube_video_url.dart';
1312

1413
class QuillEditorWebVideoEmbedBuilder extends EmbedBuilder {
1514
const QuillEditorWebVideoEmbedBuilder({
@@ -34,8 +33,10 @@ class QuillEditorWebVideoEmbedBuilder extends EmbedBuilder {
3433
TextStyle textStyle,
3534
) {
3635
var videoUrl = node.value.data;
36+
// ignore: deprecated_member_use_from_same_package
3737
if (isYouTubeUrl(videoUrl)) {
38-
final youtubeID = YoutubePlayer.convertUrlToId(videoUrl);
38+
// ignore: deprecated_member_use_from_same_package
39+
final youtubeID = convertVideoUrlToId(videoUrl);
3940
if (youtubeID != null) {
4041
videoUrl = 'https://www.youtube.com/embed/$youtubeID';
4142
}

0 commit comments

Comments
 (0)