diff --git a/example/.metadata b/example/.metadata new file mode 100644 index 000000000..0303b4064 --- /dev/null +++ b/example/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "e1e47221e86272429674bec4f1bd36acc4fc7b77" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 + base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 + - platform: web + create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 + base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/lib/main.dart b/example/lib/main.dart index 481cc34fb..e66427dd1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -149,6 +149,15 @@ class _MyAppState extends State { debugPrint('Editor resized $height'), onSelectionChanged: (sel) => debugPrint('index ${sel.index}, range ${sel.length}'), + customModuleConfig: """ + blotFormatter: {}, + """, + customQuillRegister: """ + Quill.register('modules/blotFormatter', QuillBlotFormatter.default); +""", + customScriptTag: """ + +""", ), ), ], diff --git a/example/pubspec.lock b/example/pubspec.lock index daf8dc23b..cb513195f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" crypto: dependency: transitive description: @@ -69,10 +69,10 @@ packages: dependency: transitive description: name: file_picker - sha256: b1729fc96627dd44012d0a901558177418818d6bd428df59dcfeb594e5f66432 + sha256: "21145c9c268d54b1f771d8380c195d2d6f655e0567dc1ca2f9c134c02c819e0a" url: "https://pub.dev" source: hosted - version: "5.3.2" + version: "5.3.3" flutter: dependency: "direct main" description: flutter @@ -120,14 +120,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" lints: dependency: transitive description: @@ -140,18 +132,18 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -180,17 +172,17 @@ packages: dependency: transitive description: name: pointer_interceptor - sha256: "6aa680b30d96dccef496933d00208ad25f07e047f644dc98ce03ec6141633a9a" + sha256: "7626e034489820fd599380d2bb4d3f4a0a5e3529370b62bfce53ab736b91adb2" url: "https://pub.dev" source: hosted - version: "0.9.3+4" + version: "0.9.3+6" quill_html_editor: dependency: "direct main" description: path: ".." relative: true source: path - version: "2.2.4" + version: "2.2.5" sky_engine: dependency: transitive description: flutter @@ -200,10 +192,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -240,10 +232,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.0" typed_data: dependency: transitive description: @@ -268,38 +260,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" webview_flutter: dependency: transitive description: name: webview_flutter - sha256: "789d52bd789373cc1e100fb634af2127e86c99cf9abde09499743270c5de8d00" + sha256: "82f6787d5df55907aa01e49bd9644f4ed1cc82af7a8257dd9947815959d2e755" url: "https://pub.dev" source: hosted - version: "4.2.2" + version: "4.2.4" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - sha256: d936a09fbfd08cb78f7329e0bbacf6158fbdfe24ffc908b22444c07d295eb193 + sha256: "9427774649fd3c8b7ff53523051395d13aed2ca355822b822e6493d79f5fc05a" url: "https://pub.dev" source: hosted - version: "3.9.2" + version: "3.10.0" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - sha256: "564ef378cafc1a0e29f1d76ce175ef517a0a6115875dff7b43fccbef2b0aeb30" + sha256: "6d9213c65f1060116757a7c473247c60f3f7f332cac33dc417c9e362a9a13e4f" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.6.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - sha256: "5fa098f28b606f699e8ca52d9e4e11edbbfef65189f5f77ae92703ba5408fd25" + sha256: d2f7241849582da80b79acb03bb936422412ce5c0c79fb5f6a1de5421a5aecc4 url: "https://pub.dev" source: hosted - version: "3.7.2" + version: "3.7.4" win32: dependency: transitive description: @@ -309,5 +309,5 @@ packages: source: hosted version: "5.0.3" sdks: - dart: ">=3.0.0 <4.0.0" - flutter: ">=3.3.0" + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.13.0" diff --git a/lib/src/quill_editor_wrapper.dart b/lib/src/quill_editor_wrapper.dart index 16b251b49..3e7932a63 100644 --- a/lib/src/quill_editor_wrapper.dart +++ b/lib/src/quill_editor_wrapper.dart @@ -55,6 +55,9 @@ class QuillHtmlEditor extends StatefulWidget { color: Colors.black87, fontWeight: FontWeight.normal, ), + this.customScriptTag, + this.customQuillRegister, + this.customModuleConfig, }) : super(key: controller._editorKey); /// [text] to set initial text to the editor, please use text @@ -153,6 +156,78 @@ class QuillHtmlEditor extends StatefulWidget { /// **Note** due to limitations of flutter webview at the moment, focus doesn't launch the keyboard in mobile, however, it will set the cursor at the end on focus. final bool? autoFocus; + /// # Use for custom libraries + ///
+ /// [customScriptTag]
+ /// [customQuillRegister]
+ /// [customQuillRegister]
+ ///
+ /// [customScriptTag] to set custom script tag for custom libraries + /// + /// Ex: + /// For Quill Blot Formatter library https://github.com/Fandom-OSS/quill-blot-formatter + ///
+ /// `` + /// + /// Use in flutter like: + /// ``` + /// customScriptTag: """ + /// + /// """ + /// ``` + /// You can use multiple libraries + /// + final String? customScriptTag; + + /// # Use for custom libraries + ///
+ /// [customScriptTag]
+ /// [customQuillRegister]
+ /// [customQuillRegister]
+ ///
+ /// [customQuillRegister] to resister custom libraries + /// + /// Ex: + /// For Quill Blot Formatter library https://github.com/Fandom-OSS/quill-blot-formatter + ///
+ /// `Quill.register('modules/blotFormatter', QuillBlotFormatter.default);` + /// + /// Use in flutter like: + /// ``` + /// customQuillRegister: """ + /// Quill.register('modules/blotFormatter', QuillBlotFormatter.default); + /// """ + /// ``` + /// You can use multiple libraries + /// + final String? customQuillRegister; + + /// # Use for custom libraries + ///
+ /// [customScriptTag]
+ /// [customQuillRegister]
+ /// [customQuillRegister]
+ ///
+ /// [customQuillRegister] to config the custom module + /// + /// Ex: + /// For Quill Blot Formatter library https://github.com/Fandom-OSS/quill-blot-formatter + ///
+ /// ``` + /// blotFormatter: { + /// }, + /// ``` + /// Use in flutter like: + /// ``` + /// customModuleConfig: """ + /// blotFormatter: { + /// }, + /// """ + /// ``` + /// You can use multiple libraries + /// + final String? customModuleConfig; + @override QuillHtmlEditorState createState() => QuillHtmlEditorState(); } @@ -570,6 +645,7 @@ class QuillHtmlEditorState extends State { + ${widget.customScriptTag ?? ""}