From ffbc2acf42e96895ae8a1d4b1cf7c4035b0b5b6f Mon Sep 17 00:00:00 2001
From: Rishi Raj Singh <49035175+rish07@users.noreply.github.com>
Date: Sat, 6 Mar 2021 10:39:24 +0530
Subject: [PATCH] Bug Fix and version update in pubspec.yaml (#56)

* Add base64 support in image import

* fix bug

Co-authored-by: Creator <creator@pop-os.localdomain>
---
 app/lib/pages/home_page.dart | 14 +++++++----
 app/pubspec.lock             | 49 ++++++++++++++++++++----------------
 app/pubspec.yaml             |  4 +--
 lib/widgets/editor.dart      | 45 +++++++++++++--------------------
 pubspec.yaml                 | 13 +++++-----
 5 files changed, 64 insertions(+), 61 deletions(-)

diff --git a/app/lib/pages/home_page.dart b/app/lib/pages/home_page.dart
index cee58494..665ce1b9 100644
--- a/app/lib/pages/home_page.dart
+++ b/app/lib/pages/home_page.dart
@@ -92,7 +92,8 @@ class _HomePageState extends State<HomePage> {
 
   Widget _buildWelcomeEditor(BuildContext context) {
     return SafeArea(
-      child: Stack(
+      child: Column(
+        mainAxisAlignment: MainAxisAlignment.spaceBetween,
         children: <Widget>[
           Container(
             height: MediaQuery.of(context).size.height * 0.88,
@@ -124,10 +125,13 @@ class _HomePageState extends State<HomePage> {
               ),
             ),
           ),
-          Container(
-            child: QuillToolbar.basic(
-                controller: _controller,
-                onImagePickCallback: _onImagePickCallback),
+          Padding(
+            padding: const EdgeInsets.all(8.0),
+            child: Container(
+              child: QuillToolbar.basic(
+                  controller: _controller,
+                  onImagePickCallback: _onImagePickCallback),
+            ),
           ),
         ],
       ),
diff --git a/app/pubspec.lock b/app/pubspec.lock
index 407518db..424fec52 100644
--- a/app/pubspec.lock
+++ b/app/pubspec.lock
@@ -70,7 +70,7 @@ packages:
       name: cupertino_icons
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.0.0"
+    version: "1.0.2"
   fake_async:
     dependency: transitive
     description:
@@ -84,7 +84,7 @@ packages:
       name: ffi
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.1.3"
+    version: "1.0.0"
   file:
     dependency: transitive
     description:
@@ -98,7 +98,7 @@ packages:
       name: file_picker
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "3.0.0-nullsafety.2"
+    version: "3.0.0"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -110,28 +110,28 @@ packages:
       name: flutter_colorpicker
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.4.0-nullsafety.0"
+    version: "0.3.5"
   flutter_keyboard_visibility:
     dependency: transitive
     description:
       name: flutter_keyboard_visibility
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "5.0.0-nullsafety.3"
+    version: "5.0.0"
   flutter_keyboard_visibility_platform_interface:
     dependency: transitive
     description:
       name: flutter_keyboard_visibility_platform_interface
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.0-nullsafety.0"
+    version: "2.0.0"
   flutter_keyboard_visibility_web:
     dependency: transitive
     description:
       name: flutter_keyboard_visibility_web
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.0-nullsafety.0"
+    version: "2.0.0"
   flutter_plugin_android_lifecycle:
     dependency: transitive
     description:
@@ -145,7 +145,7 @@ packages:
       path: ".."
       relative: true
     source: path
-    version: "1.0.0"
+    version: "0.3.3"
   flutter_test:
     dependency: "direct dev"
     description: flutter
@@ -225,35 +225,35 @@ packages:
       name: path_provider
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.6.27"
+    version: "2.0.1"
   path_provider_linux:
     dependency: transitive
     description:
       name: path_provider_linux
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.0.1+2"
+    version: "2.0.0"
   path_provider_macos:
     dependency: transitive
     description:
       name: path_provider_macos
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.0.4+8"
+    version: "2.0.0"
   path_provider_platform_interface:
     dependency: transitive
     description:
       name: path_provider_platform_interface
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.0.4"
+    version: "2.0.1"
   path_provider_windows:
     dependency: transitive
     description:
       name: path_provider_windows
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.0.4+3"
+    version: "2.0.0"
   pedantic:
     dependency: transitive
     description:
@@ -281,7 +281,7 @@ packages:
       name: plugin_platform_interface
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.1.0-nullsafety.2"
+    version: "2.0.0"
   process:
     dependency: transitive
     description:
@@ -289,13 +289,20 @@ packages:
       url: "https://pub.dartlang.org"
     source: hosted
     version: "4.1.0"
+  quill_delta:
+    dependency: transitive
+    description:
+      name: quill_delta
+      url: "https://pub.dartlang.org"
+    source: hosted
+    version: "2.0.0"
   quiver:
     dependency: transitive
     description:
       name: quiver
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "3.0.0"
+    version: "2.1.5"
   quiver_hashcode:
     dependency: transitive
     description:
@@ -342,7 +349,7 @@ packages:
       name: string_validator
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.2.0-nullsafety.0"
+    version: "0.1.4"
   term_glyph:
     dependency: transitive
     description:
@@ -363,7 +370,7 @@ packages:
       name: tuple
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.0-nullsafety.0"
+    version: "1.0.3"
   typed_data:
     dependency: transitive
     description:
@@ -440,14 +447,14 @@ packages:
       name: win32
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.7.4+1"
+    version: "2.0.0"
   xdg_directories:
     dependency: transitive
     description:
       name: xdg_directories
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.1.2"
+    version: "0.2.0"
   zone_local:
     dependency: transitive
     description:
@@ -456,5 +463,5 @@ packages:
     source: hosted
     version: "0.1.2"
 sdks:
-  dart: ">=2.12.0-259.9.beta <3.0.0"
-  flutter: ">=1.24.0-10.2.pre"
+  dart: ">=2.12.0 <3.0.0"
+  flutter: ">=1.22.0"
diff --git a/app/pubspec.yaml b/app/pubspec.yaml
index 4d471487..8858a8dc 100644
--- a/app/pubspec.yaml
+++ b/app/pubspec.yaml
@@ -27,8 +27,8 @@ dependencies:
 
   # The following adds the Cupertino Icons font to your application.
   # Use with the CupertinoIcons class for iOS style icons.
-  cupertino_icons: ^1.0.0
-  path_provider: ^1.6.27
+  cupertino_icons: ^1.0.2
+  path_provider: ^2.0.1
   flutter_quill:
     path: ../
 
diff --git a/lib/widgets/editor.dart b/lib/widgets/editor.dart
index d58fb7e4..a2400bd5 100644
--- a/lib/widgets/editor.dart
+++ b/lib/widgets/editor.dart
@@ -20,33 +20,18 @@ import 'package:flutter_quill/widgets/image.dart';
 import 'package:flutter_quill/widgets/raw_editor.dart';
 import 'package:flutter_quill/widgets/responsive_widget.dart';
 import 'package:flutter_quill/widgets/text_selection.dart';
-import 'package:string_validator/string_validator.dart';
 import 'package:universal_html/prefer_universal/html.dart' as html;
 import 'package:url_launcher/url_launcher.dart';
 
-import 'fake_ui.dart' if (dart.library.html) 'real_ui.dart' as ui;
+import 'FakeUi.dart' if (dart.library.html) 'RealUi.dart' as ui;
 import 'box.dart';
 import 'controller.dart';
 import 'cursor.dart';
 import 'default_styles.dart';
 import 'delegate.dart';
 
-const linkPrefixes = [
-  'mailto:', // email
-  'tel:', // telephone
-  'sms:', // SMS
-  'callto:',
-  'wtai:',
-  'market:',
-  'geopoint:',
-  'ymsgr:',
-  'msnim:',
-  'gtalk:', // Google Talk
-  'skype:',
-  'sip:', // Lync
-  'whatsapp:',
-  'http'
-];
+const urlPattern =
+    r"^((https?|http)://)?([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\?[A-Z0-9+&@#/%=~_|!:‌​,.;]*)?$";
 
 abstract class EditorState extends State<RawEditor> {
   TextEditingValue getTextEditingValue();
@@ -331,6 +316,8 @@ class _QuillEditorState extends State<QuillEditor>
 
 class _QuillEditorSelectionGestureDetectorBuilder
     extends EditorTextSelectionGestureDetectorBuilder {
+  static final urlRegExp = new RegExp(urlPattern, caseSensitive: false);
+
   final _QuillEditorState _state;
 
   _QuillEditorSelectionGestureDetectorBuilder(this._state) : super(_state);
@@ -406,12 +393,9 @@ class _QuillEditorSelectionGestureDetectorBuilder
         launchUrl = _launchUrl;
       }
       String link = segment.style.attributes[Attribute.link.key].value;
-      if (getEditor().widget.readOnly && link != null) {
-        link = link.trim();
-        if (!linkPrefixes
-            .any((linkPrefix) => link.toLowerCase().startsWith(linkPrefix))) {
-          link = 'https://$link';
-        }
+      if (getEditor().widget.readOnly &&
+          link != null &&
+          urlRegExp.firstMatch(link.trim()) != null) {
         launchUrl(link);
       }
       return false;
@@ -426,9 +410,13 @@ class _QuillEditorSelectionGestureDetectorBuilder
             builder: (context) => ImageTapWrapper(
               imageProvider: imageUrl.startsWith('http')
                   ? NetworkImage(imageUrl)
-                  : isBase64(imageUrl)
-                      ? Image.memory(base64.decode(imageUrl))
-                      : FileImage(io.File(imageUrl)),
+                  : (isBase64(imageUrl))
+                      ? Image.memory(
+                          base64.decode(imageUrl),
+                        )
+                      : FileImage(
+                          io.File(blockEmbed.data),
+                        ),
             ),
           ),
         );
@@ -467,6 +455,9 @@ class _QuillEditorSelectionGestureDetectorBuilder
   }
 
   void _launchUrl(String url) async {
+    if (!url.startsWith('http')) {
+      url = 'https://$url';
+    }
     await launch(url);
   }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 3e87a468..985e81cc 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: flutter_quill
 description: One client and affiliated collaborator of Flutter Quill is Bullet Journal App.
-version: 1.0.0
+version: 0.3.3
 #author: bulletjournal
 homepage: https://bulletjournal.us/home/index.html
 repository: https://github.com/singerdmx/flutter-quill.git
@@ -12,12 +12,13 @@ environment:
 dependencies:
   flutter:
     sdk: flutter
+  quill_delta: ^2.0.0
   quiver_hashcode: ^2.0.0
-  collection: ^1.15.0
-  tuple: ^2.0.0-nullsafety.0
-  url_launcher: ^6.0.0
-  flutter_colorpicker: ^0.4.0-nullsafety.0
-  image_picker: ^0.7.0
+  collection: ^1.14.13
+  tuple: ^1.0.3
+  url_launcher: ^5.7.10
+  flutter_colorpicker: ^0.3.5
+  image_picker: ^0.6.7+22
   photo_view: ^0.10.3
   universal_html: ^1.2.4
   file_picker: ^3.0.0-nullsafety.4