-
Notifications
You must be signed in to change notification settings - Fork 845
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First step of improving flutter quill extensions
- Loading branch information
Ellet
committed
Dec 4, 2023
1 parent
7ccd61e
commit 0d88c02
Showing
61 changed files
with
395 additions
and
525 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
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...tation/embeds/toolbar/formula_button.dart → ...mbeds/formula/toolbar/formula_button.dart
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
86 changes: 86 additions & 0 deletions
86
flutter_quill_extensions/lib/embeds/image/editor/image_embed.dart
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import 'package:flutter/foundation.dart' show kIsWeb; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_quill/extensions.dart' as base; | ||
import 'package:flutter_quill/flutter_quill.dart' hide OptionalSize; | ||
|
||
import '../../../models/config/editor/image/image.dart'; | ||
import '../../../models/config/shared_configurations.dart'; | ||
import '../../../utils/element_utils/element_utils.dart'; | ||
import '../../widgets/image.dart'; | ||
import 'image_menu.dart'; | ||
|
||
class QuillEditorImageEmbedBuilder extends EmbedBuilder { | ||
QuillEditorImageEmbedBuilder({ | ||
required this.configurations, | ||
}); | ||
final QuillEditorImageEmbedConfigurations configurations; | ||
|
||
@override | ||
String get key => BlockEmbed.imageType; | ||
|
||
@override | ||
bool get expanded => false; | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
QuillController controller, | ||
base.Embed node, | ||
bool readOnly, | ||
bool inline, | ||
TextStyle textStyle, | ||
) { | ||
assert(!kIsWeb, 'Please provide image EmbedBuilder for Web'); | ||
|
||
final imageSource = standardizeImageUrl(node.value.data); | ||
final ((imageSize), margin, alignment) = getElementAttributes(node); | ||
|
||
final width = imageSize.width; | ||
final height = imageSize.height; | ||
|
||
final image = getImageWidgetByImageSource( | ||
imageSource, | ||
imageProviderBuilder: configurations.imageProviderBuilder, | ||
imageErrorWidgetBuilder: configurations.imageErrorWidgetBuilder, | ||
alignment: alignment, | ||
height: height, | ||
width: width, | ||
assetsPrefix: QuillSharedExtensionsConfigurations.get(context: context) | ||
.assetsPrefix, | ||
); | ||
|
||
final imageSaverService = | ||
QuillSharedExtensionsConfigurations.get(context: context) | ||
.imageSaverService; | ||
return GestureDetector( | ||
onTap: configurations.onImageClicked ?? | ||
() => showDialog( | ||
context: context, | ||
builder: (_) => QuillProvider.value( | ||
value: context.requireQuillProvider, | ||
child: FlutterQuillLocalizationsWidget( | ||
child: ImageOptionsMenu( | ||
controller: controller, | ||
configurations: configurations, | ||
imageSource: imageSource, | ||
imageSize: imageSize, | ||
isReadOnly: readOnly, | ||
imageSaverService: imageSaverService, | ||
), | ||
), | ||
), | ||
), | ||
child: Builder( | ||
builder: (context) { | ||
if (margin != null) { | ||
return Padding( | ||
padding: EdgeInsets.all(margin), | ||
child: image, | ||
); | ||
} | ||
return image; | ||
}, | ||
), | ||
); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...bar/image_button/select_image_source.dart → ...ds/image/toolbar/select_image_source.dart
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
4 changes: 2 additions & 2 deletions
4
...esentation/embeds/embed_types/camera.dart → ...ds/others/camera_button/camera_types.dart
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
2 changes: 1 addition & 1 deletion
2
...r/camera_button/select_camera_action.dart → ...s/camera_button/select_camera_action.dart
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...bar/video_button/select_video_source.dart → ...ds/video/toolbar/select_video_source.dart
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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.