From 03a40dfc2deb99c07713f3ef9881469b07f73506 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 09:02:39 +0200 Subject: [PATCH 01/29] added latex --- example/pubspec.lock | 319 ++++++++++++++---- lib/html_editor.dart | 28 +- .../html_editor_controller_unsupported.dart | 39 ++- lib/src/html_editor_unsupported.dart | 2 +- lib/src/widgets/custom_html_editor.dart | 174 ++++++++++ lib/src/widgets/math_keyboard_dialog.dart | 81 +++++ lib/utils/toolbar.dart | 4 +- pubspec.lock | 316 +++++++++++++---- pubspec.yaml | 4 +- 9 files changed, 833 insertions(+), 134 deletions(-) create mode 100644 lib/src/widgets/custom_html_editor.dart create mode 100644 lib/src/widgets/math_keyboard_dialog.dart diff --git a/example/pubspec.lock b/example/pubspec.lock index b98a159b..1a771515 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,83 +1,102 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted version: "1.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file_picker: dependency: transitive description: name: file_picker - url: "https://pub.dartlang.org" + sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 + url: "https://pub.dev" source: hosted version: "5.2.5" flex_color_picker: dependency: transitive description: name: flex_color_picker - url: "https://pub.dartlang.org" + sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" + url: "https://pub.dev" source: hosted version: "3.0.2" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - url: "https://pub.dartlang.org" + sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.0" flutter: dependency: "direct main" description: flutter @@ -87,58 +106,87 @@ packages: dependency: transitive description: name: flutter_inappwebview - url: "https://pub.dartlang.org" + sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf + url: "https://pub.dev" source: hosted version: "5.7.2+3" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility - url: "https://pub.dartlang.org" + sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" + url: "https://pub.dev" source: hosted version: "5.4.0" flutter_keyboard_visibility_linux: dependency: transitive description: name: flutter_keyboard_visibility_linux - url: "https://pub.dartlang.org" + sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: dependency: transitive description: name: flutter_keyboard_visibility_macos - url: "https://pub.dartlang.org" + sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface - url: "https://pub.dartlang.org" + sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web - url: "https://pub.dartlang.org" + sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: dependency: transitive description: name: flutter_keyboard_visibility_windows - url: "https://pub.dartlang.org" + sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 + url: "https://pub.dev" source: hosted version: "1.0.0" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" + url: "https://pub.dev" + source: hosted + version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + url: "https://pub.dev" source: hosted version: "2.0.7" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + url: "https://pub.dev" + source: hosted + version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -149,6 +197,14 @@ packages: description: flutter source: sdk version: "0.0.0" + holding_gesture: + dependency: transitive + description: + name: holding_gesture + sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f + url: "https://pub.dev" + source: hosted + version: "1.2.0" html_editor_enhanced: dependency: "direct main" description: @@ -160,72 +216,130 @@ packages: dependency: transitive description: name: infinite_listview - url: "https://pub.dartlang.org" + sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 + url: "https://pub.dev" source: hosted version: "1.1.0" - js: + intl: dependency: transitive description: - name: js - url: "https://pub.dartlang.org" + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.18.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.5.0" + math_expressions: + dependency: transitive + description: + name: math_expressions + sha256: "3576593617c3870d75728a751f6ec6e606706d44e363f088ac394b5a28a98064" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + math_keyboard: + dependency: transitive + description: + name: math_keyboard + sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" + url: "https://pub.dev" + source: hosted + version: "0.2.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.0.0" numberpicker: dependency: transitive description: name: numberpicker - url: "https://pub.dartlang.org" + sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" + url: "https://pub.dev" source: hosted version: "2.1.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" + source: hosted + version: "5.4.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + url: "https://pub.dev" source: hosted version: "2.1.3" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - url: "https://pub.dartlang.org" + sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 + url: "https://pub.dev" source: hosted version: "0.9.3+3" + provider: + dependency: transitive + description: + name: provider + sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" + url: "https://pub.dev" + source: hosted + version: "6.1.1" sky_engine: dependency: transitive description: flutter @@ -235,65 +349,154 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "2.0.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" visibility_detector: dependency: transitive description: name: visibility_detector - url: "https://pub.dartlang.org" + sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" + url: "https://pub.dev" source: hosted version: "0.3.3" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" + url: "https://pub.dev" + source: hosted + version: "4.4.2" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b + url: "https://pub.dev" + source: hosted + version: "3.13.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 + url: "https://pub.dev" + source: hosted + version: "2.9.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d + url: "https://pub.dev" + source: hosted + version: "3.10.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + url: "https://pub.dev" source: hosted version: "3.1.3" + xml: + dependency: transitive + description: + name: xml + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" + source: hosted + version: "6.3.0" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=3.3.0" + dart: ">=3.2.0-194.0.dev <4.0.0" + flutter: ">=3.10.0" diff --git a/lib/html_editor.dart b/lib/html_editor.dart index c11e5afc..a1bf776c 100644 --- a/lib/html_editor.dart +++ b/lib/html_editor.dart @@ -1,24 +1,23 @@ library html_editor; +export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' + if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; +export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' + if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; +export 'package:html_editor_enhanced/src/widgets/custom_html_editor.dart'; +export 'package:html_editor_enhanced/src/widgets/math_keyboard_dialog.dart'; export 'package:html_editor_enhanced/src/widgets/toolbar_widget.dart'; export 'package:html_editor_enhanced/utils/callbacks.dart'; -export 'package:html_editor_enhanced/utils/toolbar.dart'; -export 'package:html_editor_enhanced/utils/plugins.dart'; export 'package:html_editor_enhanced/utils/file_upload_model.dart'; export 'package:html_editor_enhanced/utils/options.dart'; -export 'package:html_editor_enhanced/utils/utils.dart' - hide setState, intersperse, getRandString; - -export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; - -export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; - +export 'package:html_editor_enhanced/utils/plugins.dart'; export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart' if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart'; +export 'package:html_editor_enhanced/utils/toolbar.dart'; +export 'package:html_editor_enhanced/utils/utils.dart' + hide setState, intersperse, getRandString; /// Defines the 3 different cases for file insertion failing enum UploadError { unsupportedFile, exceededMaxSize, jsException } @@ -72,6 +71,7 @@ enum ButtonType { otherFile, table, hr, + fn, fullscreen, codeview, undo, @@ -99,4 +99,4 @@ enum DropdownMenuDirection { down, up } enum InsertFileType { image, audio, video } /// Sets how the virtual keyboard appears on mobile devices -enum HtmlInputType { decimal, email, numeric, tel, url, text } +enum HtmlInputType { decimal, email, numeric, tel, url, text } \ No newline at end of file diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index 618cbf1a..e79e8f84 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,3 +1,5 @@ +import 'dart:collection'; + import 'package:html_editor_enhanced/html_editor.dart'; import 'package:meta/meta.dart'; @@ -9,6 +11,39 @@ class HtmlEditorController { this.processOutputHtml = true, }); + final HashMap _latexMap = HashMap(); + + void addToHashMap(String key, String value) { + _latexMap.addAll({ + key: value, + }); + } + + Future getHtmlStringWithLatex() async { + var txt = await getText(); + final reg = RegExp('', multiLine: true); + var tags = []; + var res = txt.split(reg); + print('result = $res'); + + res.forEach((element) { + if (element.contains(r'')) { + var split = element.split(r''); + var after = split.last; + element = '${split.first}'; + tags.add(_latexMap[element] ?? element); + tags.add(after); + } else { + tags.add(element); + } + }); + String tag = ''; + tags.forEach((element) { + tag = '$tag$element'; + }); + return tag; + } + /// Toolbar widget state to call various methods. For internal use only. @internal ToolbarWidgetState? toolbar; @@ -84,7 +119,7 @@ class HtmlEditorController { /// A function to execute JS passed as a [WebScript] to the editor. This should /// only be used on Flutter Web. Future evaluateJavascriptWeb(String name, - {bool hasReturnValue = false}) => + {bool hasReturnValue = false}) => Future.value(); /// Gets the text from the editor and returns it as a [String]. @@ -171,4 +206,4 @@ class HtmlEditorController { /// Internal function to insert table on Web @internal void insertTable(String dimensions) {} -} +} \ No newline at end of file diff --git a/lib/src/html_editor_unsupported.dart b/lib/src/html_editor_unsupported.dart index abc6239a..e4443167 100644 --- a/lib/src/html_editor_unsupported.dart +++ b/lib/src/html_editor_unsupported.dart @@ -37,4 +37,4 @@ class HtmlEditor extends StatelessWidget { Widget build(BuildContext context) { return Text('Unsupported in this environment'); } -} +} \ No newline at end of file diff --git a/lib/src/widgets/custom_html_editor.dart b/lib/src/widgets/custom_html_editor.dart new file mode 100644 index 00000000..f12cfbfe --- /dev/null +++ b/lib/src/widgets/custom_html_editor.dart @@ -0,0 +1,174 @@ +// ignore_for_file: avoid_print + +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +import '../../html_editor.dart'; + +class CustomHtmlEditorWidget extends StatelessWidget { + const CustomHtmlEditorWidget({required this.controller, double? height}) + : _height = height ?? 500; + final HtmlEditorController controller; + final double _height; + + Widget _htmlWidget() { + return HtmlEditor( + controller: controller, + htmlEditorOptions: const HtmlEditorOptions( + hint: 'Your text here...', + shouldEnsureVisible: true, + //initialText: "

text content initial, if any

", + ), + htmlToolbarOptions: HtmlToolbarOptions( + toolbarPosition: ToolbarPosition.aboveEditor, + defaultToolbarButtons: [ + const StyleButtons(), + const FontSettingButtons(fontSizeUnit: false), + const FontButtons(clearAll: false), + const ColorButtons(), + const ListButtons(listStyles: false), + const ParagraphButtons( + textDirection: false, lineHeight: false, caseConverter: false), + const InsertButtons( + video: false, + audio: false, + table: true, + hr: true, + fn: true, + otherFile: false), + ], + //by default + toolbarType: ToolbarType.nativeExpandable, + //by default + onButtonPressed: + (ButtonType type, bool? status, Function? updateStatus) { + if (type.name == ButtonType.picture.name) { + print('no image'); + controller.insertHtml(tableTex); + return false; + } + print( + "button '${type.name}' pressed, the current selected status is $status"); + return true; + }, + onDropdownChanged: (DropdownType type, dynamic changed, + Function(dynamic)? updateSelectedItem) { + print("dropdown '${type.name}' changed to $changed"); + return true; + }, + mediaLinkInsertInterceptor: (String url, InsertFileType type) { + print(url); + return true; + }, + mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async { + if (kDebugMode) { + print(file.name); + } //filename + print(file.size); //size in bytes + print(file.extension); //file extension (eg jpeg or mp4) + return true; + }, + ), + otherOptions: OtherOptions(height: _height), + callbacks: Callbacks(onBeforeCommand: (String? currentHtml) { + print('html before change is $currentHtml'); + }, onChangeContent: (String? changed) { + print('content changed to $changed'); + }, onChangeCodeview: (String? changed) { + print('code changed to $changed'); + }, onChangeSelection: (EditorSettings settings) { + print('parent element is ${settings.parentElement}'); + print('font name is ${settings.fontName}'); + }, onDialogShown: () { + print('dialog shown'); + }, onEnter: () { + print('enter/return pressed'); + }, onFocus: () { + print('editor focused'); + }, onBlur: () { + print('editor unfocused'); + }, onBlurCodeview: () { + print('codeview either focused or unfocused'); + }, onInit: () { + print('init'); + }, + //this is commented because it overrides the default Summernote handlers + /*onImageLinkInsert: (String? url) { + print(url ?? "unknown url"); + }, + onImageUpload: (FileUpload file) async { + print(file.name); + print(file.size); + print(file.type); + print(file.base64); + },*/ + onImageUploadError: + (FileUpload? file, String? base64Str, UploadError error) { + print((error.name)); + print(base64Str ?? ''); + if (file != null) { + print(file.name); + print(file.size); + print(file.type); + } + }, onKeyDown: (int? keyCode) { + print('$keyCode key downed'); + print('current character count: ${controller.characterCount}'); + }, onKeyUp: (int? keyCode) { + print('$keyCode key released'); + }, onMouseDown: () { + print('mouse downed'); + }, onMouseUp: () { + print('mouse released'); + }, onNavigationRequestMobile: (String url) { + print(url); + return NavigationActionPolicy.ALLOW; + }, onPaste: () { + print('pasted into editor'); + }, onScroll: () { + print('editor scrolled'); + }), + plugins: [ + SummernoteAtMention( + getSuggestionsMobile: (String value) { + var mentions = ['test1', 'test2', 'test3']; + return mentions + .where((element) => element.contains(value)) + .toList(); + }, + mentionsWeb: ['test1', 'test2', 'test3'], + onSelect: (String value) { + print(value); + }), + ], + ); + } + + @override + Widget build(BuildContext context) { + return _htmlWidget(); + } +} + +const tableTex = r''' + + \begin{array} { | l | l | l | } +\hline \text { Year } & \begin{array} { l } +\text { Number of U.S. } \\ +\text { farms (in } \\ +\text { millions) } +\end{array} & \begin{array} { l } +\text { Average size of } \\ +\text { U.S. farms } \\ +\text { (acres) } +\end{array} \\ +\hline 1950 & 5.6 & 234 \\ +\hline 1960 & 4.0 & 330 \\ +\hline 1970 & 2.9 & 399 \\ +\hline 1980 & 2.4 & 441 \\ +\hline 1990 & 2.1 & 478 \\ +\hline 2000 & 2.2 & 439 \\ +\hline +\end{array} + '''; diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart new file mode 100644 index 00000000..a236e601 --- /dev/null +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -0,0 +1,81 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:math_keyboard/math_keyboard.dart'; + +class MathKeyboardDialog extends StatelessWidget { + MathKeyboardDialog({required this.controller, this.mathField}) { + if (mathField != null && mathField!.controller != null) { + log('', + name: 'Warning', + error: + 'do not set the math field controller as it will get ignored\n'); + } + } + + final MathFieldEditingController controller; + final MathField? mathField; + + @override + Widget build(BuildContext context) { + return Dialog( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + _mathField(context), + const SizedBox(height: 15), + TextButton( + onPressed: () { + controller.setTexString(''); + Navigator.pop(context, ''); + print(controller.texStringAsFun); + }, + child: const Text('Close'), + ), + TextButton( + onPressed: () { + Navigator.pop(context, controller.texStringAsFun); + print(controller.texStringAsFun); + }, + child: const Text('save'), + ), + ], + ), + ), + ); + } + + Widget _mathField(context) { + return SizedBox( + width: MediaQuery.of(context).size.width, + child: MathField( + focusNode: mathField?.focusNode, + autofocus: mathField?.autofocus ?? true, + controller: controller, + variables: mathField?.variables ?? ['x', 'y', 'z', 'A', 'B', 'C'], + decoration: mathField?.decoration ?? + InputDecoration( + suffix: MouseRegion( + cursor: MaterialStateMouseCursor.clickable, + child: GestureDetector( + onTap: controller.clear, + child: const Icon( + Icons.highlight_remove_rounded, + color: Colors.grey, + ), + ), + ), + ), + onChanged: mathField?.onChanged ?? + (str) { + controller.setTexString(str); + }, + onSubmitted: mathField?.onSubmitted, + opensKeyboard: mathField?.opensKeyboard ?? true, + ), + ); + } +} diff --git a/lib/utils/toolbar.dart b/lib/utils/toolbar.dart index 91b491fd..09a95921 100644 --- a/lib/utils/toolbar.dart +++ b/lib/utils/toolbar.dart @@ -153,6 +153,7 @@ class InsertButtons extends Toolbar { final bool otherFile; final bool table; final bool hr; + final bool fn; const InsertButtons({ this.link = true, @@ -162,6 +163,7 @@ class InsertButtons extends Toolbar { this.otherFile = false, this.table = true, this.hr = true, + this.fn = true, }); List getIcons() { @@ -213,4 +215,4 @@ class OtherButtons extends Toolbar { if (paste) icons.add(Icon(Icons.paste)); return icons; } -} +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 88f4be47..2e36c442 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,76 +1,94 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file_picker: dependency: "direct main" description: name: file_picker - url: "https://pub.dartlang.org" + sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 + url: "https://pub.dev" source: hosted version: "5.2.5" flex_color_picker: dependency: "direct main" description: name: flex_color_picker - url: "https://pub.dartlang.org" + sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" + url: "https://pub.dev" source: hosted version: "3.0.2" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - url: "https://pub.dartlang.org" + sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.0" flutter: dependency: "direct main" description: flutter @@ -80,58 +98,87 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - url: "https://pub.dartlang.org" + sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf + url: "https://pub.dev" source: hosted version: "5.7.2+3" flutter_keyboard_visibility: dependency: "direct main" description: name: flutter_keyboard_visibility - url: "https://pub.dartlang.org" + sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" + url: "https://pub.dev" source: hosted version: "5.4.0" flutter_keyboard_visibility_linux: dependency: transitive description: name: flutter_keyboard_visibility_linux - url: "https://pub.dartlang.org" + sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: dependency: transitive description: name: flutter_keyboard_visibility_macos - url: "https://pub.dartlang.org" + sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface - url: "https://pub.dartlang.org" + sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web - url: "https://pub.dartlang.org" + sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: dependency: transitive description: name: flutter_keyboard_visibility_windows - url: "https://pub.dartlang.org" + sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 + url: "https://pub.dev" source: hosted version: "1.0.0" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" + url: "https://pub.dev" + source: hosted + version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + url: "https://pub.dev" source: hosted version: "2.0.7" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + url: "https://pub.dev" + source: hosted + version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -142,76 +189,142 @@ packages: description: flutter source: sdk version: "0.0.0" + holding_gesture: + dependency: transitive + description: + name: holding_gesture + sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f + url: "https://pub.dev" + source: hosted + version: "1.2.0" infinite_listview: dependency: transitive description: name: infinite_listview - url: "https://pub.dartlang.org" + sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 + url: "https://pub.dev" source: hosted version: "1.1.0" - js: + intl: dependency: transitive description: - name: js - url: "https://pub.dartlang.org" + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.18.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.5.0" + math_expressions: + dependency: transitive + description: + name: math_expressions + sha256: "3576593617c3870d75728a751f6ec6e606706d44e363f088ac394b5a28a98064" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + math_keyboard: + dependency: "direct main" + description: + name: math_keyboard + sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" + url: "https://pub.dev" + source: hosted + version: "0.2.1" meta: dependency: "direct main" description: name: meta - url: "https://pub.dartlang.org" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.0.0" numberpicker: dependency: "direct main" description: name: numberpicker - url: "https://pub.dartlang.org" + sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" + url: "https://pub.dev" source: hosted version: "2.1.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" pedantic: dependency: "direct main" description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" + source: hosted + version: "5.4.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + url: "https://pub.dev" source: hosted version: "2.1.3" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - url: "https://pub.dartlang.org" + sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 + url: "https://pub.dev" source: hosted version: "0.9.3+3" + provider: + dependency: transitive + description: + name: provider + sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" + url: "https://pub.dev" + source: hosted + version: "6.1.1" sky_engine: dependency: transitive description: flutter @@ -221,65 +334,154 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "2.0.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" visibility_detector: dependency: "direct main" description: name: visibility_detector - url: "https://pub.dartlang.org" + sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" + url: "https://pub.dev" source: hosted version: "0.3.3" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" + url: "https://pub.dev" + source: hosted + version: "4.4.2" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b + url: "https://pub.dev" + source: hosted + version: "3.13.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 + url: "https://pub.dev" + source: hosted + version: "2.9.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d + url: "https://pub.dev" + source: hosted + version: "3.10.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + url: "https://pub.dev" source: hosted version: "3.1.3" + xml: + dependency: transitive + description: + name: xml + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" + source: hosted + version: "6.3.0" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=3.3.0" + dart: ">=3.2.0-194.0.dev <4.0.0" + flutter: ">=3.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 82d4a1ad..cac25a53 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ version: 2.5.1 homepage: https://github.com/tneotia/html-editor-enhanced environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.15.0 <3.0.0' flutter: ">=3.0.0" dependencies: @@ -32,6 +32,8 @@ dependencies: pedantic: ^1.11.1 # plugin for @internal annotation meta: '>=1.0.0 <2.0.0' + math_keyboard: ^0.2.1 + webview_flutter: ^4.4.2 dev_dependencies: flutter_test: From e184caaced3f7bfe41b447da701a8e22e531166c Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 09:03:44 +0200 Subject: [PATCH 02/29] Revert "added latex" --- example/pubspec.lock | 319 ++++-------------- lib/html_editor.dart | 28 +- .../html_editor_controller_unsupported.dart | 39 +-- lib/src/html_editor_unsupported.dart | 2 +- lib/src/widgets/custom_html_editor.dart | 174 ---------- lib/src/widgets/math_keyboard_dialog.dart | 81 ----- lib/utils/toolbar.dart | 4 +- pubspec.lock | 316 ++++------------- pubspec.yaml | 4 +- 9 files changed, 134 insertions(+), 833 deletions(-) delete mode 100644 lib/src/widgets/custom_html_editor.dart delete mode 100644 lib/src/widgets/math_keyboard_dialog.dart diff --git a/example/pubspec.lock b/example/pubspec.lock index 1a771515..b98a159b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,102 +1,83 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - args: - dependency: transitive - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.18.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.5" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.1" file_picker: dependency: transitive description: name: file_picker - sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.2.5" flex_color_picker: dependency: transitive description: name: flex_color_picker - sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.0.2" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -106,87 +87,58 @@ packages: dependency: transitive description: name: flutter_inappwebview - sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.7.2+3" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility - sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.4.0" flutter_keyboard_visibility_linux: dependency: transitive description: name: flutter_keyboard_visibility_linux - sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: dependency: transitive description: name: flutter_keyboard_visibility_macos - sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface - sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web - sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: dependency: transitive description: name: flutter_keyboard_visibility_windows - sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - flutter_localizations: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - flutter_math_fork: - dependency: transitive - description: - name: flutter_math_fork - sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" - url: "https://pub.dev" - source: hosted - version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.7" - flutter_svg: - dependency: transitive - description: - name: flutter_svg - sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c - url: "https://pub.dev" - source: hosted - version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -197,14 +149,6 @@ packages: description: flutter source: sdk version: "0.0.0" - holding_gesture: - dependency: transitive - description: - name: holding_gesture - sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f - url: "https://pub.dev" - source: hosted - version: "1.2.0" html_editor_enhanced: dependency: "direct main" description: @@ -216,130 +160,72 @@ packages: dependency: transitive description: name: infinite_listview - sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" - intl: + js: dependency: transitive description: - name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" - url: "https://pub.dev" + name: js + url: "https://pub.dartlang.org" source: hosted - version: "0.18.1" + version: "0.6.4" matcher: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.16" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.0" - math_expressions: - dependency: transitive - description: - name: math_expressions - sha256: "3576593617c3870d75728a751f6ec6e606706d44e363f088ac394b5a28a98064" - url: "https://pub.dev" - source: hosted - version: "2.4.0" - math_keyboard: - dependency: transitive - description: - name: math_keyboard - sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" - url: "https://pub.dev" - source: hosted - version: "0.2.1" + version: "0.1.5" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e - url: "https://pub.dev" - source: hosted - version: "1.10.0" - nested: - dependency: transitive - description: - name: nested - sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.8.0" numberpicker: dependency: transitive description: name: numberpicker - sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.1" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" - path_parsing: - dependency: transitive - description: - name: path_parsing - sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf - url: "https://pub.dev" - source: hosted - version: "1.0.1" + version: "1.8.2" pedantic: dependency: transitive description: name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.11.1" - petitparser: - dependency: transitive - description: - name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 - url: "https://pub.dev" - source: hosted - version: "5.4.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.3" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.9.3+3" - provider: - dependency: transitive - description: - name: provider - sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" - url: "https://pub.dev" - source: hosted - version: "6.1.1" sky_engine: dependency: transitive description: flutter @@ -349,154 +235,65 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.10.0" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" - url: "https://pub.dev" - source: hosted - version: "0.6.1" - tuple: - dependency: transitive - description: - name: tuple - sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" visibility_detector: dependency: transitive description: name: visibility_detector - sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.3.3" - web: - dependency: transitive - description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 - url: "https://pub.dev" - source: hosted - version: "0.3.0" - webview_flutter: - dependency: transitive - description: - name: webview_flutter - sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" - url: "https://pub.dev" - source: hosted - version: "4.4.2" - webview_flutter_android: - dependency: transitive - description: - name: webview_flutter_android - sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b - url: "https://pub.dev" - source: hosted - version: "3.13.1" - webview_flutter_platform_interface: - dependency: transitive - description: - name: webview_flutter_platform_interface - sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 - url: "https://pub.dev" - source: hosted - version: "2.9.0" - webview_flutter_wkwebview: - dependency: transitive - description: - name: webview_flutter_wkwebview - sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d - url: "https://pub.dev" - source: hosted - version: "3.10.0" win32: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.1.3" - xml: - dependency: transitive - description: - name: xml - sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" - url: "https://pub.dev" - source: hosted - version: "6.3.0" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.10.0" + dart: ">=2.18.0 <3.0.0" + flutter: ">=3.3.0" diff --git a/lib/html_editor.dart b/lib/html_editor.dart index a1bf776c..c11e5afc 100644 --- a/lib/html_editor.dart +++ b/lib/html_editor.dart @@ -1,24 +1,25 @@ library html_editor; -export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; -export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; -export 'package:html_editor_enhanced/src/widgets/custom_html_editor.dart'; -export 'package:html_editor_enhanced/src/widgets/math_keyboard_dialog.dart'; export 'package:html_editor_enhanced/src/widgets/toolbar_widget.dart'; export 'package:html_editor_enhanced/utils/callbacks.dart'; +export 'package:html_editor_enhanced/utils/toolbar.dart'; +export 'package:html_editor_enhanced/utils/plugins.dart'; export 'package:html_editor_enhanced/utils/file_upload_model.dart'; export 'package:html_editor_enhanced/utils/options.dart'; -export 'package:html_editor_enhanced/utils/plugins.dart'; -export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart' - if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart'; -export 'package:html_editor_enhanced/utils/toolbar.dart'; export 'package:html_editor_enhanced/utils/utils.dart' hide setState, intersperse, getRandString; +export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' + if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; + +export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' + if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; + +export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart' + if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart'; + /// Defines the 3 different cases for file insertion failing enum UploadError { unsupportedFile, exceededMaxSize, jsException } @@ -71,7 +72,6 @@ enum ButtonType { otherFile, table, hr, - fn, fullscreen, codeview, undo, @@ -99,4 +99,4 @@ enum DropdownMenuDirection { down, up } enum InsertFileType { image, audio, video } /// Sets how the virtual keyboard appears on mobile devices -enum HtmlInputType { decimal, email, numeric, tel, url, text } \ No newline at end of file +enum HtmlInputType { decimal, email, numeric, tel, url, text } diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index e79e8f84..618cbf1a 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,5 +1,3 @@ -import 'dart:collection'; - import 'package:html_editor_enhanced/html_editor.dart'; import 'package:meta/meta.dart'; @@ -11,39 +9,6 @@ class HtmlEditorController { this.processOutputHtml = true, }); - final HashMap _latexMap = HashMap(); - - void addToHashMap(String key, String value) { - _latexMap.addAll({ - key: value, - }); - } - - Future getHtmlStringWithLatex() async { - var txt = await getText(); - final reg = RegExp('', multiLine: true); - var tags = []; - var res = txt.split(reg); - print('result = $res'); - - res.forEach((element) { - if (element.contains(r'')) { - var split = element.split(r''); - var after = split.last; - element = '${split.first}'; - tags.add(_latexMap[element] ?? element); - tags.add(after); - } else { - tags.add(element); - } - }); - String tag = ''; - tags.forEach((element) { - tag = '$tag$element'; - }); - return tag; - } - /// Toolbar widget state to call various methods. For internal use only. @internal ToolbarWidgetState? toolbar; @@ -119,7 +84,7 @@ class HtmlEditorController { /// A function to execute JS passed as a [WebScript] to the editor. This should /// only be used on Flutter Web. Future evaluateJavascriptWeb(String name, - {bool hasReturnValue = false}) => + {bool hasReturnValue = false}) => Future.value(); /// Gets the text from the editor and returns it as a [String]. @@ -206,4 +171,4 @@ class HtmlEditorController { /// Internal function to insert table on Web @internal void insertTable(String dimensions) {} -} \ No newline at end of file +} diff --git a/lib/src/html_editor_unsupported.dart b/lib/src/html_editor_unsupported.dart index e4443167..abc6239a 100644 --- a/lib/src/html_editor_unsupported.dart +++ b/lib/src/html_editor_unsupported.dart @@ -37,4 +37,4 @@ class HtmlEditor extends StatelessWidget { Widget build(BuildContext context) { return Text('Unsupported in this environment'); } -} \ No newline at end of file +} diff --git a/lib/src/widgets/custom_html_editor.dart b/lib/src/widgets/custom_html_editor.dart deleted file mode 100644 index f12cfbfe..00000000 --- a/lib/src/widgets/custom_html_editor.dart +++ /dev/null @@ -1,174 +0,0 @@ -// ignore_for_file: avoid_print - -import 'package:file_picker/file_picker.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -import '../../html_editor.dart'; - -class CustomHtmlEditorWidget extends StatelessWidget { - const CustomHtmlEditorWidget({required this.controller, double? height}) - : _height = height ?? 500; - final HtmlEditorController controller; - final double _height; - - Widget _htmlWidget() { - return HtmlEditor( - controller: controller, - htmlEditorOptions: const HtmlEditorOptions( - hint: 'Your text here...', - shouldEnsureVisible: true, - //initialText: "

text content initial, if any

", - ), - htmlToolbarOptions: HtmlToolbarOptions( - toolbarPosition: ToolbarPosition.aboveEditor, - defaultToolbarButtons: [ - const StyleButtons(), - const FontSettingButtons(fontSizeUnit: false), - const FontButtons(clearAll: false), - const ColorButtons(), - const ListButtons(listStyles: false), - const ParagraphButtons( - textDirection: false, lineHeight: false, caseConverter: false), - const InsertButtons( - video: false, - audio: false, - table: true, - hr: true, - fn: true, - otherFile: false), - ], - //by default - toolbarType: ToolbarType.nativeExpandable, - //by default - onButtonPressed: - (ButtonType type, bool? status, Function? updateStatus) { - if (type.name == ButtonType.picture.name) { - print('no image'); - controller.insertHtml(tableTex); - return false; - } - print( - "button '${type.name}' pressed, the current selected status is $status"); - return true; - }, - onDropdownChanged: (DropdownType type, dynamic changed, - Function(dynamic)? updateSelectedItem) { - print("dropdown '${type.name}' changed to $changed"); - return true; - }, - mediaLinkInsertInterceptor: (String url, InsertFileType type) { - print(url); - return true; - }, - mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async { - if (kDebugMode) { - print(file.name); - } //filename - print(file.size); //size in bytes - print(file.extension); //file extension (eg jpeg or mp4) - return true; - }, - ), - otherOptions: OtherOptions(height: _height), - callbacks: Callbacks(onBeforeCommand: (String? currentHtml) { - print('html before change is $currentHtml'); - }, onChangeContent: (String? changed) { - print('content changed to $changed'); - }, onChangeCodeview: (String? changed) { - print('code changed to $changed'); - }, onChangeSelection: (EditorSettings settings) { - print('parent element is ${settings.parentElement}'); - print('font name is ${settings.fontName}'); - }, onDialogShown: () { - print('dialog shown'); - }, onEnter: () { - print('enter/return pressed'); - }, onFocus: () { - print('editor focused'); - }, onBlur: () { - print('editor unfocused'); - }, onBlurCodeview: () { - print('codeview either focused or unfocused'); - }, onInit: () { - print('init'); - }, - //this is commented because it overrides the default Summernote handlers - /*onImageLinkInsert: (String? url) { - print(url ?? "unknown url"); - }, - onImageUpload: (FileUpload file) async { - print(file.name); - print(file.size); - print(file.type); - print(file.base64); - },*/ - onImageUploadError: - (FileUpload? file, String? base64Str, UploadError error) { - print((error.name)); - print(base64Str ?? ''); - if (file != null) { - print(file.name); - print(file.size); - print(file.type); - } - }, onKeyDown: (int? keyCode) { - print('$keyCode key downed'); - print('current character count: ${controller.characterCount}'); - }, onKeyUp: (int? keyCode) { - print('$keyCode key released'); - }, onMouseDown: () { - print('mouse downed'); - }, onMouseUp: () { - print('mouse released'); - }, onNavigationRequestMobile: (String url) { - print(url); - return NavigationActionPolicy.ALLOW; - }, onPaste: () { - print('pasted into editor'); - }, onScroll: () { - print('editor scrolled'); - }), - plugins: [ - SummernoteAtMention( - getSuggestionsMobile: (String value) { - var mentions = ['test1', 'test2', 'test3']; - return mentions - .where((element) => element.contains(value)) - .toList(); - }, - mentionsWeb: ['test1', 'test2', 'test3'], - onSelect: (String value) { - print(value); - }), - ], - ); - } - - @override - Widget build(BuildContext context) { - return _htmlWidget(); - } -} - -const tableTex = r''' - - \begin{array} { | l | l | l | } -\hline \text { Year } & \begin{array} { l } -\text { Number of U.S. } \\ -\text { farms (in } \\ -\text { millions) } -\end{array} & \begin{array} { l } -\text { Average size of } \\ -\text { U.S. farms } \\ -\text { (acres) } -\end{array} \\ -\hline 1950 & 5.6 & 234 \\ -\hline 1960 & 4.0 & 330 \\ -\hline 1970 & 2.9 & 399 \\ -\hline 1980 & 2.4 & 441 \\ -\hline 1990 & 2.1 & 478 \\ -\hline 2000 & 2.2 & 439 \\ -\hline -\end{array} - '''; diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart deleted file mode 100644 index a236e601..00000000 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'dart:developer'; - -import 'package:flutter/material.dart'; -import 'package:math_keyboard/math_keyboard.dart'; - -class MathKeyboardDialog extends StatelessWidget { - MathKeyboardDialog({required this.controller, this.mathField}) { - if (mathField != null && mathField!.controller != null) { - log('', - name: 'Warning', - error: - 'do not set the math field controller as it will get ignored\n'); - } - } - - final MathFieldEditingController controller; - final MathField? mathField; - - @override - Widget build(BuildContext context) { - return Dialog( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - _mathField(context), - const SizedBox(height: 15), - TextButton( - onPressed: () { - controller.setTexString(''); - Navigator.pop(context, ''); - print(controller.texStringAsFun); - }, - child: const Text('Close'), - ), - TextButton( - onPressed: () { - Navigator.pop(context, controller.texStringAsFun); - print(controller.texStringAsFun); - }, - child: const Text('save'), - ), - ], - ), - ), - ); - } - - Widget _mathField(context) { - return SizedBox( - width: MediaQuery.of(context).size.width, - child: MathField( - focusNode: mathField?.focusNode, - autofocus: mathField?.autofocus ?? true, - controller: controller, - variables: mathField?.variables ?? ['x', 'y', 'z', 'A', 'B', 'C'], - decoration: mathField?.decoration ?? - InputDecoration( - suffix: MouseRegion( - cursor: MaterialStateMouseCursor.clickable, - child: GestureDetector( - onTap: controller.clear, - child: const Icon( - Icons.highlight_remove_rounded, - color: Colors.grey, - ), - ), - ), - ), - onChanged: mathField?.onChanged ?? - (str) { - controller.setTexString(str); - }, - onSubmitted: mathField?.onSubmitted, - opensKeyboard: mathField?.opensKeyboard ?? true, - ), - ); - } -} diff --git a/lib/utils/toolbar.dart b/lib/utils/toolbar.dart index 09a95921..91b491fd 100644 --- a/lib/utils/toolbar.dart +++ b/lib/utils/toolbar.dart @@ -153,7 +153,6 @@ class InsertButtons extends Toolbar { final bool otherFile; final bool table; final bool hr; - final bool fn; const InsertButtons({ this.link = true, @@ -163,7 +162,6 @@ class InsertButtons extends Toolbar { this.otherFile = false, this.table = true, this.hr = true, - this.fn = true, }); List getIcons() { @@ -215,4 +213,4 @@ class OtherButtons extends Toolbar { if (paste) icons.add(Icon(Icons.paste)); return icons; } -} \ No newline at end of file +} diff --git a/pubspec.lock b/pubspec.lock index 2e36c442..88f4be47 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,94 +1,76 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - args: - dependency: transitive - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.18.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.1" file_picker: dependency: "direct main" description: name: file_picker - sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.2.5" flex_color_picker: dependency: "direct main" description: name: flex_color_picker - sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.0.2" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -98,87 +80,58 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.7.2+3" flutter_keyboard_visibility: dependency: "direct main" description: name: flutter_keyboard_visibility - sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.4.0" flutter_keyboard_visibility_linux: dependency: transitive description: name: flutter_keyboard_visibility_linux - sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: dependency: transitive description: name: flutter_keyboard_visibility_macos - sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface - sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web - sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: dependency: transitive description: name: flutter_keyboard_visibility_windows - sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - flutter_localizations: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - flutter_math_fork: - dependency: transitive - description: - name: flutter_math_fork - sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" - url: "https://pub.dev" - source: hosted - version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.7" - flutter_svg: - dependency: transitive - description: - name: flutter_svg - sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c - url: "https://pub.dev" - source: hosted - version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -189,142 +142,76 @@ packages: description: flutter source: sdk version: "0.0.0" - holding_gesture: - dependency: transitive - description: - name: holding_gesture - sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f - url: "https://pub.dev" - source: hosted - version: "1.2.0" infinite_listview: dependency: transitive description: name: infinite_listview - sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" - intl: + js: dependency: transitive description: - name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" - url: "https://pub.dev" + name: js + url: "https://pub.dartlang.org" source: hosted - version: "0.18.1" + version: "0.6.4" matcher: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.16" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.0" - math_expressions: - dependency: transitive - description: - name: math_expressions - sha256: "3576593617c3870d75728a751f6ec6e606706d44e363f088ac394b5a28a98064" - url: "https://pub.dev" - source: hosted - version: "2.4.0" - math_keyboard: - dependency: "direct main" - description: - name: math_keyboard - sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" - url: "https://pub.dev" - source: hosted - version: "0.2.1" + version: "0.1.5" meta: dependency: "direct main" description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e - url: "https://pub.dev" - source: hosted - version: "1.10.0" - nested: - dependency: transitive - description: - name: nested - sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.8.0" numberpicker: dependency: "direct main" description: name: numberpicker - sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.1" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" - path_parsing: - dependency: transitive - description: - name: path_parsing - sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf - url: "https://pub.dev" - source: hosted - version: "1.0.1" + version: "1.8.2" pedantic: dependency: "direct main" description: name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.11.1" - petitparser: - dependency: transitive - description: - name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 - url: "https://pub.dev" - source: hosted - version: "5.4.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.3" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.9.3+3" - provider: - dependency: transitive - description: - name: provider - sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" - url: "https://pub.dev" - source: hosted - version: "6.1.1" sky_engine: dependency: transitive description: flutter @@ -334,154 +221,65 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.10.0" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" - url: "https://pub.dev" - source: hosted - version: "0.6.1" - tuple: - dependency: transitive - description: - name: tuple - sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" visibility_detector: dependency: "direct main" description: name: visibility_detector - sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.3.3" - web: - dependency: transitive - description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 - url: "https://pub.dev" - source: hosted - version: "0.3.0" - webview_flutter: - dependency: "direct main" - description: - name: webview_flutter - sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" - url: "https://pub.dev" - source: hosted - version: "4.4.2" - webview_flutter_android: - dependency: transitive - description: - name: webview_flutter_android - sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b - url: "https://pub.dev" - source: hosted - version: "3.13.1" - webview_flutter_platform_interface: - dependency: transitive - description: - name: webview_flutter_platform_interface - sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 - url: "https://pub.dev" - source: hosted - version: "2.9.0" - webview_flutter_wkwebview: - dependency: transitive - description: - name: webview_flutter_wkwebview - sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d - url: "https://pub.dev" - source: hosted - version: "3.10.0" win32: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.1.3" - xml: - dependency: transitive - description: - name: xml - sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" - url: "https://pub.dev" - source: hosted - version: "6.3.0" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.10.0" + dart: ">=2.18.0 <3.0.0" + flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml index cac25a53..82d4a1ad 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ version: 2.5.1 homepage: https://github.com/tneotia/html-editor-enhanced environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' flutter: ">=3.0.0" dependencies: @@ -32,8 +32,6 @@ dependencies: pedantic: ^1.11.1 # plugin for @internal annotation meta: '>=1.0.0 <2.0.0' - math_keyboard: ^0.2.1 - webview_flutter: ^4.4.2 dev_dependencies: flutter_test: From 234a2a9cac6cb52aea85532ac455ee431b3c0042 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 09:05:24 +0200 Subject: [PATCH 03/29] Revert "Revert "added latex"" --- example/pubspec.lock | 319 ++++++++++++++---- lib/html_editor.dart | 28 +- .../html_editor_controller_unsupported.dart | 39 ++- lib/src/html_editor_unsupported.dart | 2 +- lib/src/widgets/custom_html_editor.dart | 174 ++++++++++ lib/src/widgets/math_keyboard_dialog.dart | 81 +++++ lib/utils/toolbar.dart | 4 +- pubspec.lock | 316 +++++++++++++---- pubspec.yaml | 4 +- 9 files changed, 833 insertions(+), 134 deletions(-) create mode 100644 lib/src/widgets/custom_html_editor.dart create mode 100644 lib/src/widgets/math_keyboard_dialog.dart diff --git a/example/pubspec.lock b/example/pubspec.lock index b98a159b..1a771515 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,83 +1,102 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted version: "1.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file_picker: dependency: transitive description: name: file_picker - url: "https://pub.dartlang.org" + sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 + url: "https://pub.dev" source: hosted version: "5.2.5" flex_color_picker: dependency: transitive description: name: flex_color_picker - url: "https://pub.dartlang.org" + sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" + url: "https://pub.dev" source: hosted version: "3.0.2" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - url: "https://pub.dartlang.org" + sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.0" flutter: dependency: "direct main" description: flutter @@ -87,58 +106,87 @@ packages: dependency: transitive description: name: flutter_inappwebview - url: "https://pub.dartlang.org" + sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf + url: "https://pub.dev" source: hosted version: "5.7.2+3" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility - url: "https://pub.dartlang.org" + sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" + url: "https://pub.dev" source: hosted version: "5.4.0" flutter_keyboard_visibility_linux: dependency: transitive description: name: flutter_keyboard_visibility_linux - url: "https://pub.dartlang.org" + sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: dependency: transitive description: name: flutter_keyboard_visibility_macos - url: "https://pub.dartlang.org" + sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface - url: "https://pub.dartlang.org" + sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web - url: "https://pub.dartlang.org" + sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: dependency: transitive description: name: flutter_keyboard_visibility_windows - url: "https://pub.dartlang.org" + sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 + url: "https://pub.dev" source: hosted version: "1.0.0" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" + url: "https://pub.dev" + source: hosted + version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + url: "https://pub.dev" source: hosted version: "2.0.7" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + url: "https://pub.dev" + source: hosted + version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -149,6 +197,14 @@ packages: description: flutter source: sdk version: "0.0.0" + holding_gesture: + dependency: transitive + description: + name: holding_gesture + sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f + url: "https://pub.dev" + source: hosted + version: "1.2.0" html_editor_enhanced: dependency: "direct main" description: @@ -160,72 +216,130 @@ packages: dependency: transitive description: name: infinite_listview - url: "https://pub.dartlang.org" + sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 + url: "https://pub.dev" source: hosted version: "1.1.0" - js: + intl: dependency: transitive description: - name: js - url: "https://pub.dartlang.org" + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.18.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.5.0" + math_expressions: + dependency: transitive + description: + name: math_expressions + sha256: "3576593617c3870d75728a751f6ec6e606706d44e363f088ac394b5a28a98064" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + math_keyboard: + dependency: transitive + description: + name: math_keyboard + sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" + url: "https://pub.dev" + source: hosted + version: "0.2.1" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.0.0" numberpicker: dependency: transitive description: name: numberpicker - url: "https://pub.dartlang.org" + sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" + url: "https://pub.dev" source: hosted version: "2.1.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" pedantic: dependency: transitive description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" + source: hosted + version: "5.4.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + url: "https://pub.dev" source: hosted version: "2.1.3" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - url: "https://pub.dartlang.org" + sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 + url: "https://pub.dev" source: hosted version: "0.9.3+3" + provider: + dependency: transitive + description: + name: provider + sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" + url: "https://pub.dev" + source: hosted + version: "6.1.1" sky_engine: dependency: transitive description: flutter @@ -235,65 +349,154 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "2.0.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" visibility_detector: dependency: transitive description: name: visibility_detector - url: "https://pub.dartlang.org" + sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" + url: "https://pub.dev" source: hosted version: "0.3.3" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" + url: "https://pub.dev" + source: hosted + version: "4.4.2" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b + url: "https://pub.dev" + source: hosted + version: "3.13.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 + url: "https://pub.dev" + source: hosted + version: "2.9.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d + url: "https://pub.dev" + source: hosted + version: "3.10.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + url: "https://pub.dev" source: hosted version: "3.1.3" + xml: + dependency: transitive + description: + name: xml + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" + source: hosted + version: "6.3.0" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=3.3.0" + dart: ">=3.2.0-194.0.dev <4.0.0" + flutter: ">=3.10.0" diff --git a/lib/html_editor.dart b/lib/html_editor.dart index c11e5afc..a1bf776c 100644 --- a/lib/html_editor.dart +++ b/lib/html_editor.dart @@ -1,24 +1,23 @@ library html_editor; +export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' + if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; +export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' + if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; +export 'package:html_editor_enhanced/src/widgets/custom_html_editor.dart'; +export 'package:html_editor_enhanced/src/widgets/math_keyboard_dialog.dart'; export 'package:html_editor_enhanced/src/widgets/toolbar_widget.dart'; export 'package:html_editor_enhanced/utils/callbacks.dart'; -export 'package:html_editor_enhanced/utils/toolbar.dart'; -export 'package:html_editor_enhanced/utils/plugins.dart'; export 'package:html_editor_enhanced/utils/file_upload_model.dart'; export 'package:html_editor_enhanced/utils/options.dart'; -export 'package:html_editor_enhanced/utils/utils.dart' - hide setState, intersperse, getRandString; - -export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; - -export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; - +export 'package:html_editor_enhanced/utils/plugins.dart'; export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart' if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart'; +export 'package:html_editor_enhanced/utils/toolbar.dart'; +export 'package:html_editor_enhanced/utils/utils.dart' + hide setState, intersperse, getRandString; /// Defines the 3 different cases for file insertion failing enum UploadError { unsupportedFile, exceededMaxSize, jsException } @@ -72,6 +71,7 @@ enum ButtonType { otherFile, table, hr, + fn, fullscreen, codeview, undo, @@ -99,4 +99,4 @@ enum DropdownMenuDirection { down, up } enum InsertFileType { image, audio, video } /// Sets how the virtual keyboard appears on mobile devices -enum HtmlInputType { decimal, email, numeric, tel, url, text } +enum HtmlInputType { decimal, email, numeric, tel, url, text } \ No newline at end of file diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index 618cbf1a..e79e8f84 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,3 +1,5 @@ +import 'dart:collection'; + import 'package:html_editor_enhanced/html_editor.dart'; import 'package:meta/meta.dart'; @@ -9,6 +11,39 @@ class HtmlEditorController { this.processOutputHtml = true, }); + final HashMap _latexMap = HashMap(); + + void addToHashMap(String key, String value) { + _latexMap.addAll({ + key: value, + }); + } + + Future getHtmlStringWithLatex() async { + var txt = await getText(); + final reg = RegExp('', multiLine: true); + var tags = []; + var res = txt.split(reg); + print('result = $res'); + + res.forEach((element) { + if (element.contains(r'')) { + var split = element.split(r''); + var after = split.last; + element = '${split.first}'; + tags.add(_latexMap[element] ?? element); + tags.add(after); + } else { + tags.add(element); + } + }); + String tag = ''; + tags.forEach((element) { + tag = '$tag$element'; + }); + return tag; + } + /// Toolbar widget state to call various methods. For internal use only. @internal ToolbarWidgetState? toolbar; @@ -84,7 +119,7 @@ class HtmlEditorController { /// A function to execute JS passed as a [WebScript] to the editor. This should /// only be used on Flutter Web. Future evaluateJavascriptWeb(String name, - {bool hasReturnValue = false}) => + {bool hasReturnValue = false}) => Future.value(); /// Gets the text from the editor and returns it as a [String]. @@ -171,4 +206,4 @@ class HtmlEditorController { /// Internal function to insert table on Web @internal void insertTable(String dimensions) {} -} +} \ No newline at end of file diff --git a/lib/src/html_editor_unsupported.dart b/lib/src/html_editor_unsupported.dart index abc6239a..e4443167 100644 --- a/lib/src/html_editor_unsupported.dart +++ b/lib/src/html_editor_unsupported.dart @@ -37,4 +37,4 @@ class HtmlEditor extends StatelessWidget { Widget build(BuildContext context) { return Text('Unsupported in this environment'); } -} +} \ No newline at end of file diff --git a/lib/src/widgets/custom_html_editor.dart b/lib/src/widgets/custom_html_editor.dart new file mode 100644 index 00000000..f12cfbfe --- /dev/null +++ b/lib/src/widgets/custom_html_editor.dart @@ -0,0 +1,174 @@ +// ignore_for_file: avoid_print + +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +import '../../html_editor.dart'; + +class CustomHtmlEditorWidget extends StatelessWidget { + const CustomHtmlEditorWidget({required this.controller, double? height}) + : _height = height ?? 500; + final HtmlEditorController controller; + final double _height; + + Widget _htmlWidget() { + return HtmlEditor( + controller: controller, + htmlEditorOptions: const HtmlEditorOptions( + hint: 'Your text here...', + shouldEnsureVisible: true, + //initialText: "

text content initial, if any

", + ), + htmlToolbarOptions: HtmlToolbarOptions( + toolbarPosition: ToolbarPosition.aboveEditor, + defaultToolbarButtons: [ + const StyleButtons(), + const FontSettingButtons(fontSizeUnit: false), + const FontButtons(clearAll: false), + const ColorButtons(), + const ListButtons(listStyles: false), + const ParagraphButtons( + textDirection: false, lineHeight: false, caseConverter: false), + const InsertButtons( + video: false, + audio: false, + table: true, + hr: true, + fn: true, + otherFile: false), + ], + //by default + toolbarType: ToolbarType.nativeExpandable, + //by default + onButtonPressed: + (ButtonType type, bool? status, Function? updateStatus) { + if (type.name == ButtonType.picture.name) { + print('no image'); + controller.insertHtml(tableTex); + return false; + } + print( + "button '${type.name}' pressed, the current selected status is $status"); + return true; + }, + onDropdownChanged: (DropdownType type, dynamic changed, + Function(dynamic)? updateSelectedItem) { + print("dropdown '${type.name}' changed to $changed"); + return true; + }, + mediaLinkInsertInterceptor: (String url, InsertFileType type) { + print(url); + return true; + }, + mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async { + if (kDebugMode) { + print(file.name); + } //filename + print(file.size); //size in bytes + print(file.extension); //file extension (eg jpeg or mp4) + return true; + }, + ), + otherOptions: OtherOptions(height: _height), + callbacks: Callbacks(onBeforeCommand: (String? currentHtml) { + print('html before change is $currentHtml'); + }, onChangeContent: (String? changed) { + print('content changed to $changed'); + }, onChangeCodeview: (String? changed) { + print('code changed to $changed'); + }, onChangeSelection: (EditorSettings settings) { + print('parent element is ${settings.parentElement}'); + print('font name is ${settings.fontName}'); + }, onDialogShown: () { + print('dialog shown'); + }, onEnter: () { + print('enter/return pressed'); + }, onFocus: () { + print('editor focused'); + }, onBlur: () { + print('editor unfocused'); + }, onBlurCodeview: () { + print('codeview either focused or unfocused'); + }, onInit: () { + print('init'); + }, + //this is commented because it overrides the default Summernote handlers + /*onImageLinkInsert: (String? url) { + print(url ?? "unknown url"); + }, + onImageUpload: (FileUpload file) async { + print(file.name); + print(file.size); + print(file.type); + print(file.base64); + },*/ + onImageUploadError: + (FileUpload? file, String? base64Str, UploadError error) { + print((error.name)); + print(base64Str ?? ''); + if (file != null) { + print(file.name); + print(file.size); + print(file.type); + } + }, onKeyDown: (int? keyCode) { + print('$keyCode key downed'); + print('current character count: ${controller.characterCount}'); + }, onKeyUp: (int? keyCode) { + print('$keyCode key released'); + }, onMouseDown: () { + print('mouse downed'); + }, onMouseUp: () { + print('mouse released'); + }, onNavigationRequestMobile: (String url) { + print(url); + return NavigationActionPolicy.ALLOW; + }, onPaste: () { + print('pasted into editor'); + }, onScroll: () { + print('editor scrolled'); + }), + plugins: [ + SummernoteAtMention( + getSuggestionsMobile: (String value) { + var mentions = ['test1', 'test2', 'test3']; + return mentions + .where((element) => element.contains(value)) + .toList(); + }, + mentionsWeb: ['test1', 'test2', 'test3'], + onSelect: (String value) { + print(value); + }), + ], + ); + } + + @override + Widget build(BuildContext context) { + return _htmlWidget(); + } +} + +const tableTex = r''' + + \begin{array} { | l | l | l | } +\hline \text { Year } & \begin{array} { l } +\text { Number of U.S. } \\ +\text { farms (in } \\ +\text { millions) } +\end{array} & \begin{array} { l } +\text { Average size of } \\ +\text { U.S. farms } \\ +\text { (acres) } +\end{array} \\ +\hline 1950 & 5.6 & 234 \\ +\hline 1960 & 4.0 & 330 \\ +\hline 1970 & 2.9 & 399 \\ +\hline 1980 & 2.4 & 441 \\ +\hline 1990 & 2.1 & 478 \\ +\hline 2000 & 2.2 & 439 \\ +\hline +\end{array} + '''; diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart new file mode 100644 index 00000000..a236e601 --- /dev/null +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -0,0 +1,81 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:math_keyboard/math_keyboard.dart'; + +class MathKeyboardDialog extends StatelessWidget { + MathKeyboardDialog({required this.controller, this.mathField}) { + if (mathField != null && mathField!.controller != null) { + log('', + name: 'Warning', + error: + 'do not set the math field controller as it will get ignored\n'); + } + } + + final MathFieldEditingController controller; + final MathField? mathField; + + @override + Widget build(BuildContext context) { + return Dialog( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + _mathField(context), + const SizedBox(height: 15), + TextButton( + onPressed: () { + controller.setTexString(''); + Navigator.pop(context, ''); + print(controller.texStringAsFun); + }, + child: const Text('Close'), + ), + TextButton( + onPressed: () { + Navigator.pop(context, controller.texStringAsFun); + print(controller.texStringAsFun); + }, + child: const Text('save'), + ), + ], + ), + ), + ); + } + + Widget _mathField(context) { + return SizedBox( + width: MediaQuery.of(context).size.width, + child: MathField( + focusNode: mathField?.focusNode, + autofocus: mathField?.autofocus ?? true, + controller: controller, + variables: mathField?.variables ?? ['x', 'y', 'z', 'A', 'B', 'C'], + decoration: mathField?.decoration ?? + InputDecoration( + suffix: MouseRegion( + cursor: MaterialStateMouseCursor.clickable, + child: GestureDetector( + onTap: controller.clear, + child: const Icon( + Icons.highlight_remove_rounded, + color: Colors.grey, + ), + ), + ), + ), + onChanged: mathField?.onChanged ?? + (str) { + controller.setTexString(str); + }, + onSubmitted: mathField?.onSubmitted, + opensKeyboard: mathField?.opensKeyboard ?? true, + ), + ); + } +} diff --git a/lib/utils/toolbar.dart b/lib/utils/toolbar.dart index 91b491fd..09a95921 100644 --- a/lib/utils/toolbar.dart +++ b/lib/utils/toolbar.dart @@ -153,6 +153,7 @@ class InsertButtons extends Toolbar { final bool otherFile; final bool table; final bool hr; + final bool fn; const InsertButtons({ this.link = true, @@ -162,6 +163,7 @@ class InsertButtons extends Toolbar { this.otherFile = false, this.table = true, this.hr = true, + this.fn = true, }); List getIcons() { @@ -213,4 +215,4 @@ class OtherButtons extends Toolbar { if (paste) icons.add(Icon(Icons.paste)); return icons; } -} +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 88f4be47..2e36c442 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,76 +1,94 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file_picker: dependency: "direct main" description: name: file_picker - url: "https://pub.dartlang.org" + sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 + url: "https://pub.dev" source: hosted version: "5.2.5" flex_color_picker: dependency: "direct main" description: name: flex_color_picker - url: "https://pub.dartlang.org" + sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" + url: "https://pub.dev" source: hosted version: "3.0.2" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - url: "https://pub.dartlang.org" + sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.0" flutter: dependency: "direct main" description: flutter @@ -80,58 +98,87 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - url: "https://pub.dartlang.org" + sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf + url: "https://pub.dev" source: hosted version: "5.7.2+3" flutter_keyboard_visibility: dependency: "direct main" description: name: flutter_keyboard_visibility - url: "https://pub.dartlang.org" + sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" + url: "https://pub.dev" source: hosted version: "5.4.0" flutter_keyboard_visibility_linux: dependency: transitive description: name: flutter_keyboard_visibility_linux - url: "https://pub.dartlang.org" + sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_macos: dependency: transitive description: name: flutter_keyboard_visibility_macos - url: "https://pub.dartlang.org" + sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 + url: "https://pub.dev" source: hosted version: "1.0.0" flutter_keyboard_visibility_platform_interface: dependency: transitive description: name: flutter_keyboard_visibility_platform_interface - url: "https://pub.dartlang.org" + sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_web: dependency: transitive description: name: flutter_keyboard_visibility_web - url: "https://pub.dartlang.org" + sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 + url: "https://pub.dev" source: hosted version: "2.0.0" flutter_keyboard_visibility_windows: dependency: transitive description: name: flutter_keyboard_visibility_windows - url: "https://pub.dartlang.org" + sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 + url: "https://pub.dev" source: hosted version: "1.0.0" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_math_fork: + dependency: transitive + description: + name: flutter_math_fork + sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" + url: "https://pub.dev" + source: hosted + version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" + sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + url: "https://pub.dev" source: hosted version: "2.0.7" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + url: "https://pub.dev" + source: hosted + version: "2.0.9" flutter_test: dependency: "direct dev" description: flutter @@ -142,76 +189,142 @@ packages: description: flutter source: sdk version: "0.0.0" + holding_gesture: + dependency: transitive + description: + name: holding_gesture + sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f + url: "https://pub.dev" + source: hosted + version: "1.2.0" infinite_listview: dependency: transitive description: name: infinite_listview - url: "https://pub.dartlang.org" + sha256: f6062c1720eb59be553dfa6b89813d3e8dd2f054538445aaa5edaddfa5195ce6 + url: "https://pub.dev" source: hosted version: "1.1.0" - js: + intl: dependency: transitive description: - name: js - url: "https://pub.dartlang.org" + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.18.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.5.0" + math_expressions: + dependency: transitive + description: + name: math_expressions + sha256: "3576593617c3870d75728a751f6ec6e606706d44e363f088ac394b5a28a98064" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + math_keyboard: + dependency: "direct main" + description: + name: math_keyboard + sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" + url: "https://pub.dev" + source: hosted + version: "0.2.1" meta: dependency: "direct main" description: name: meta - url: "https://pub.dartlang.org" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.0.0" numberpicker: dependency: "direct main" description: name: numberpicker - url: "https://pub.dartlang.org" + sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" + url: "https://pub.dev" source: hosted version: "2.1.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" pedantic: dependency: "direct main" description: name: pedantic - url: "https://pub.dartlang.org" + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" source: hosted version: "1.11.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" + source: hosted + version: "5.4.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + url: "https://pub.dev" source: hosted version: "2.1.3" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - url: "https://pub.dartlang.org" + sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 + url: "https://pub.dev" source: hosted version: "0.9.3+3" + provider: + dependency: transitive + description: + name: provider + sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" + url: "https://pub.dev" + source: hosted + version: "6.1.1" sky_engine: dependency: transitive description: flutter @@ -221,65 +334,154 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + tuple: + dependency: transitive + description: + name: tuple + sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "2.0.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 + url: "https://pub.dev" + source: hosted + version: "1.1.9+1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" visibility_detector: dependency: "direct main" description: name: visibility_detector - url: "https://pub.dartlang.org" + sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" + url: "https://pub.dev" source: hosted version: "0.3.3" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf" + url: "https://pub.dev" + source: hosted + version: "4.4.2" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b + url: "https://pub.dev" + source: hosted + version: "3.13.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 + url: "https://pub.dev" + source: hosted + version: "2.9.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d + url: "https://pub.dev" + source: hosted + version: "3.10.0" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + url: "https://pub.dev" source: hosted version: "3.1.3" + xml: + dependency: transitive + description: + name: xml + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" + source: hosted + version: "6.3.0" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=3.3.0" + dart: ">=3.2.0-194.0.dev <4.0.0" + flutter: ">=3.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 82d4a1ad..cac25a53 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ version: 2.5.1 homepage: https://github.com/tneotia/html-editor-enhanced environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.15.0 <3.0.0' flutter: ">=3.0.0" dependencies: @@ -32,6 +32,8 @@ dependencies: pedantic: ^1.11.1 # plugin for @internal annotation meta: '>=1.0.0 <2.0.0' + math_keyboard: ^0.2.1 + webview_flutter: ^4.4.2 dev_dependencies: flutter_test: From 56023a6c793a5ffb603a237e96e2c9460484d9cc Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 09:53:48 +0200 Subject: [PATCH 04/29] added latex --- example/lib/main.dart | 71 +++++++++---------- example/pubspec.yaml | 2 +- lib/src/html_editor_controller_mobile.dart | 2 +- .../html_editor_controller_unsupported.dart | 2 +- lib/src/html_editor_controller_web.dart | 2 +- .../widgets/html_editor_widget_mobile.dart | 12 ++-- lib/src/widgets/html_editor_widget_web.dart | 18 +++-- lib/src/widgets/toolbar_widget.dart | 71 ++++++++++++++++--- lib/utils/utils.dart | 7 +- 9 files changed, 117 insertions(+), 70 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 85057082..88ce86e8 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,7 @@ +import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:file_picker/file_picker.dart'; void main() => runApp(HtmlEditorExampleApp()); @@ -79,13 +79,12 @@ class _HtmlEditorExampleState extends State { onButtonPressed: (ButtonType type, bool? status, Function? updateStatus) { print( - "button '${describeEnum(type)}' pressed, the current selected status is $status"); + "button '${(type.name)}' pressed, the current selected status is $status"); return true; }, onDropdownChanged: (DropdownType type, dynamic changed, Function(dynamic)? updateSelectedItem) { - print( - "dropdown '${describeEnum(type)}' changed to $changed"); + print("dropdown '${(type.name)}' changed to $changed"); return true; }, mediaLinkInsertInterceptor: @@ -136,7 +135,7 @@ class _HtmlEditorExampleState extends State { },*/ onImageUploadError: (FileUpload? file, String? base64Str, UploadError error) { - print(describeEnum(error)); + print((error.name)); print(base64Str ?? ''); if (file != null) { print(file.name); @@ -144,23 +143,23 @@ class _HtmlEditorExampleState extends State { print(file.type); } }, onKeyDown: (int? keyCode) { - print('$keyCode key downed'); - print( - 'current character count: ${controller.characterCount}'); - }, onKeyUp: (int? keyCode) { - print('$keyCode key released'); - }, onMouseDown: () { - print('mouse downed'); - }, onMouseUp: () { - print('mouse released'); - }, onNavigationRequestMobile: (String url) { - print(url); - return NavigationActionPolicy.ALLOW; - }, onPaste: () { - print('pasted into editor'); - }, onScroll: () { - print('editor scrolled'); - }), + print('$keyCode key downed'); + print( + 'current character count: ${controller.characterCount}'); + }, onKeyUp: (int? keyCode) { + print('$keyCode key released'); + }, onMouseDown: () { + print('mouse downed'); + }, onMouseUp: () { + print('mouse released'); + }, onNavigationRequestMobile: (String url) { + print(url); + return NavigationActionPolicy.ALLOW; + }, onPaste: () { + print('pasted into editor'); + }, onScroll: () { + print('editor scrolled'); + }), plugins: [ SummernoteAtMention( getSuggestionsMobile: (String value) { @@ -187,7 +186,7 @@ class _HtmlEditorExampleState extends State { controller.undo(); }, child: - Text('Undo', style: TextStyle(color: Colors.white)), + Text('Undo', style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -199,7 +198,7 @@ class _HtmlEditorExampleState extends State { controller.clear(); }, child: - Text('Reset', style: TextStyle(color: Colors.white)), + Text('Reset', style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -207,12 +206,12 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { var txt = await controller.getText(); if (txt.contains('src=\"data:')) { txt = - ''; + ''; } setState(() { result = txt; @@ -229,7 +228,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.redo(); }, @@ -265,7 +264,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.enable(); }, @@ -286,7 +285,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.insertText('Google'); }, @@ -299,7 +298,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.insertHtml( '''

Google in blue

'''); @@ -318,7 +317,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.insertLink( 'Google linked', 'https://google.com', true); @@ -334,7 +333,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.insertNetworkImage( 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png', @@ -362,7 +361,7 @@ class _HtmlEditorExampleState extends State { 'Info notification', NotificationType.info); }, child: - Text('Info', style: TextStyle(color: Colors.white)), + Text('Info', style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -383,7 +382,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.addNotification( 'Success notification', NotificationType.success); @@ -399,7 +398,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.addNotification( 'Danger notification', NotificationType.danger); @@ -434,7 +433,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.removeNotification(); }, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5e1c4814..3d6cad01 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,7 +6,7 @@ description: Demonstrates how to use the html_editor_enhanced plugin. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.15.0 <3.0.0' dependencies: flutter: diff --git a/lib/src/html_editor_controller_mobile.dart b/lib/src/html_editor_controller_mobile.dart index 7210d11c..36547428 100644 --- a/lib/src/html_editor_controller_mobile.dart +++ b/lib/src/html_editor_controller_mobile.dart @@ -224,7 +224,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void addNotification(String html, NotificationType notificationType) async { await _evaluateJavascript(source: """ \$('.note-status-output').html( - '
$html
' + '
$html
' ); """); recalculateHeight(); diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index e79e8f84..419e92d3 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -37,7 +37,7 @@ class HtmlEditorController { tags.add(element); } }); - String tag = ''; + var tag = ''; tags.forEach((element) { tag = '$tag$element'; }); diff --git a/lib/src/html_editor_controller_web.dart b/lib/src/html_editor_controller_web.dart index 01ff3dec..9a6324e6 100644 --- a/lib/src/html_editor_controller_web.dart +++ b/lib/src/html_editor_controller_web.dart @@ -288,7 +288,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { _evaluateJavascriptWeb(data: { 'type': 'toIframe: addNotification', 'html': html, - 'alertType': 'alert alert-${describeEnum(notificationType)}' + 'alertType': 'alert alert-${(notificationType.name)}' }); } recalculateHeight(); diff --git a/lib/src/widgets/html_editor_widget_mobile.dart b/lib/src/widgets/html_editor_widget_mobile.dart index a2458ca8..94f46fcd 100644 --- a/lib/src/widgets/html_editor_widget_mobile.dart +++ b/lib/src/widgets/html_editor_widget_mobile.dart @@ -180,9 +180,8 @@ class _HtmlEditorWidgetMobileState extends State { print(message.message); }, onWindowFocus: (controller) async { - if (widget.htmlEditorOptions.shouldEnsureVisible && - Scrollable.of(context) != null) { - await Scrollable.of(context)!.position.ensureVisible( + if (widget.htmlEditorOptions.shouldEnsureVisible) { + await Scrollable.of(context).position.ensureVisible( context.findRenderObject()!, ); } @@ -451,7 +450,7 @@ class _HtmlEditorWidgetMobileState extends State { "document.onselectionchange = onSelectionChange; console.log('done');"); await controller.evaluateJavascript( source: - "document.getElementsByClassName('note-editable')[0].setAttribute('inputmode', '${describeEnum(widget.htmlEditorOptions.inputType)}');"); + "document.getElementsByClassName('note-editable')[0].setAttribute('inputmode', '${(widget.htmlEditorOptions.inputType.name)}');"); if ((Theme.of(context).brightness == Brightness.dark || widget.htmlEditorOptions.darkMode == true) && widget.htmlEditorOptions.darkMode != false) { @@ -526,9 +525,8 @@ class _HtmlEditorWidgetMobileState extends State { controller.addJavaScriptHandler( handlerName: 'onChangeContent', callback: (contents) { - if (widget.htmlEditorOptions.shouldEnsureVisible && - Scrollable.of(context) != null) { - Scrollable.of(context)!.position.ensureVisible( + if (widget.htmlEditorOptions.shouldEnsureVisible) { + Scrollable.of(context).position.ensureVisible( context.findRenderObject()!, ); } diff --git a/lib/src/widgets/html_editor_widget_web.dart b/lib/src/widgets/html_editor_widget_web.dart index c348920f..103d35c2 100644 --- a/lib/src/widgets/html_editor_widget_web.dart +++ b/lib/src/widgets/html_editor_widget_web.dart @@ -1,15 +1,14 @@ -export 'dart:html'; - import 'dart:convert'; +// ignore: avoid_web_libraries_in_flutter +import 'dart:html' as html; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/utils/utils.dart'; -// ignore: avoid_web_libraries_in_flutter -import 'dart:html' as html; import 'package:html_editor_enhanced/utils/shims/dart_ui.dart' as ui; +import 'package:html_editor_enhanced/utils/utils.dart'; + +export 'dart:html'; /// The HTML Editor widget itself, for web (uses IFrameElement) class HtmlEditorWidget extends StatefulWidget { @@ -241,7 +240,7 @@ class _HtmlEditorWidgetWebState extends State { window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: htmlHeight", "height": height}), "*"); } if (data["type"].includes("setInputType")) { - document.getElementsByClassName('note-editable')[0].setAttribute('inputmode', '${describeEnum(widget.htmlEditorOptions.inputType)}'); + document.getElementsByClassName('note-editable')[0].setAttribute('inputmode', '${(widget.htmlEditorOptions.inputType).name}'); } if (data["type"].includes("setText")) { \$('#summernote-2').summernote('code', data["text"]); @@ -513,9 +512,8 @@ class _HtmlEditorWidgetWebState extends State { widget.callbacks!.onChangeContent != null) { widget.callbacks!.onChangeContent!.call(data['contents']); } - if (widget.htmlEditorOptions.shouldEnsureVisible && - Scrollable.of(context) != null) { - Scrollable.of(context)!.position.ensureVisible( + if (widget.htmlEditorOptions.shouldEnsureVisible) { + Scrollable.of(context).position.ensureVisible( context.findRenderObject()!, duration: const Duration(milliseconds: 100), curve: Curves.easeIn); diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index 2e33f27f..bdce4767 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -1,3 +1,5 @@ +import 'dart:async'; +import 'dart:collection'; import 'dart:convert'; import 'package:file_picker/file_picker.dart'; @@ -7,8 +9,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:html_editor_enhanced/html_editor.dart'; import 'package:html_editor_enhanced/utils/utils.dart'; +import 'package:math_keyboard/math_keyboard.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; +import 'package:webview_flutter/webview_flutter.dart'; /// Toolbar widget class class ToolbarWidget extends StatefulWidget { @@ -90,6 +94,7 @@ class ToolbarWidgetState extends State { /// Tracks the expanded status of the toolbar bool _isExpanded = false; + final HashMap _latexMap = HashMap(); @override void initState() { @@ -498,7 +503,7 @@ class ToolbarWidgetState extends State { dropdownColor: widget.htmlToolbarOptions.dropdownBackgroundColor, menuDirection: widget.htmlToolbarOptions.dropdownMenuDirection ?? (widget.htmlToolbarOptions.toolbarPosition == - ToolbarPosition.belowEditor + ToolbarPosition.belowEditor ? DropdownMenuDirection.up : DropdownMenuDirection.down), menuMaxHeight: widget.htmlToolbarOptions.dropdownMenuMaxHeight ?? @@ -1120,7 +1125,7 @@ class ToolbarWidgetState extends State { newColor = color; }, title: Text('Choose a Color', - style: Theme.of(context).textTheme.headline6), + style: Theme.of(context).textTheme.titleLarge), width: 40, height: 40, spacing: 0, @@ -1134,7 +1139,7 @@ class ToolbarWidgetState extends State { ColorPickerType.wheel: true, }, copyPasteBehavior: - const ColorPickerCopyPasteBehavior( + const ColorPickerCopyPasteBehavior( parseShortHexCode: true, ), actionButtons: const ColorPickerActionButtons( @@ -1758,6 +1763,7 @@ class ToolbarWidgetState extends State { t.picture || t.link || t.hr || + t.fn || t.table)) { toolbarChildren.add(ToggleButtons( constraints: BoxConstraints.tightFor( @@ -1872,7 +1878,7 @@ class ToolbarWidgetState extends State { style: TextStyle( color: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.color)), ), ], @@ -1986,7 +1992,7 @@ class ToolbarWidgetState extends State { style: TextStyle( color: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.color)), ), suffixIcon: result != null @@ -2146,7 +2152,7 @@ class ToolbarWidgetState extends State { style: TextStyle( color: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.color)), ), suffixIcon: result != null @@ -2298,7 +2304,7 @@ class ToolbarWidgetState extends State { style: TextStyle( color: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.color)), ), suffixIcon: result != null @@ -2450,7 +2456,7 @@ class ToolbarWidgetState extends State { style: TextStyle( color: Theme.of(context) .textTheme - .bodyText1 + .bodyLarge ?.color)), ), suffixIcon: result != null @@ -2600,6 +2606,29 @@ class ToolbarWidgetState extends State { widget.controller.insertHtml('
'); } } + if (t.getIcons()[index].icon == Icons.functions) { + var proceed = await widget.htmlToolbarOptions.onButtonPressed + ?.call(ButtonType.fn, null, null) ?? + true; + if (proceed) { + final c = MathFieldEditingController(); + await showDialog( + context: context, + builder: (context) => MathKeyboardDialog(controller: c)); + var math = c.texString; + if (math != '') { + var texAsFun = c.texStringAsFun; + var result = + await _latexToHtml(math.replaceAll('\\', '\\\\')); + result = '$result'; + _latexMap.addAll({ + result: texAsFun, + }); + widget.controller.addToHashMap(result, texAsFun); + widget.controller.insertHtml(result); + } + } + } }, isSelected: List.filled(t.getIcons().length, false), children: t.getIcons(), @@ -2688,7 +2717,7 @@ class ToolbarWidgetState extends State { child: SingleChildScrollView( child: DataTable( columnSpacing: 5, - dataRowHeight: 75, + dataRowMinHeight: 75, columns: const [ DataColumn( label: Text( @@ -2998,4 +3027,28 @@ class ToolbarWidgetState extends State { } return toolbarChildren; } + + Future _latexToHtml(String latex) async { + var completer = Completer(); + var controller = WebViewController(); + await controller.setJavaScriptMode(JavaScriptMode.unrestricted); + await controller.addJavaScriptChannel('MathMLChannel', + onMessageReceived: (JavaScriptMessage message) { + print('Received message: ${message.message}'); + completer.complete(message.message); + }); + WebViewWidget(controller: controller); + await controller.runJavaScript(''' + (async () => { + try { + const mathlive = await import("https://unpkg.com/mathlive?module"); + const mathML = mathlive.convertLatexToMathMl('\$\$$latex\$\$'); + MathMLChannel.postMessage(mathML); + } catch (error) { + console.error('Error:', error); + } + })(); + '''); + return completer.future; + } } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 8d9c6c8d..cbe2c46f 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -949,7 +949,7 @@ class _DropdownButtonState extends State> } TextStyle? get _textStyle => - widget.style ?? Theme.of(context).textTheme.subtitle1; + widget.style ?? Theme.of(context).textTheme.titleMedium; void _handleTap() { final textDirection = Directionality.maybeOf(context); @@ -1009,7 +1009,7 @@ class _DropdownButtonState extends State> double get _denseButtonHeight { final fontSize = _textStyle!.fontSize ?? - Theme.of(context).textTheme.subtitle1!.fontSize!; + Theme.of(context).textTheme.titleMedium!.fontSize!; return max(fontSize, max(widget.iconSize, _kDenseButtonHeight)); } @@ -1090,8 +1090,7 @@ class _DropdownButtonState extends State> hintIndex = items.length; items.add(DefaultTextStyle( style: _textStyle!.copyWith(color: Theme.of(context).hintColor), - child: IgnorePointer( - ignoringSemantics: false, + child: ExcludeSemantics( child: displayedHint, ), )); From 16d2a26cf76d0732bc9a22b0ed47a63f8604468d Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 10:01:59 +0200 Subject: [PATCH 05/29] added latex --- lib/utils/toolbar.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/utils/toolbar.dart b/lib/utils/toolbar.dart index 09a95921..6146ae8d 100644 --- a/lib/utils/toolbar.dart +++ b/lib/utils/toolbar.dart @@ -175,6 +175,7 @@ class InsertButtons extends Toolbar { if (otherFile) icons.add(Icon(Icons.attach_file)); if (table) icons.add(Icon(Icons.table_chart_outlined)); if (hr) icons.add(Icon(Icons.horizontal_rule)); + if (fn) icons.add(Icon(Icons.functions)); return icons; } } From 7bfa428d50c756655178fd200920a95df3413417 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 10:12:10 +0200 Subject: [PATCH 06/29] bug fixes --- lib/src/widgets/custom_html_editor.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/widgets/custom_html_editor.dart b/lib/src/widgets/custom_html_editor.dart index f12cfbfe..e7bb9e0b 100644 --- a/lib/src/widgets/custom_html_editor.dart +++ b/lib/src/widgets/custom_html_editor.dart @@ -150,7 +150,6 @@ class CustomHtmlEditorWidget extends StatelessWidget { return _htmlWidget(); } } - const tableTex = r''' \begin{array} { | l | l | l | } From a154ca1c5350701c665b5cb1bd8f6abfd0b710f0 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 10:42:29 +0200 Subject: [PATCH 07/29] Create dart.yml --- .github/workflows/dart.yml | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/dart.yml diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 00000000..f45e642e --- /dev/null +++ b/.github/workflows/dart.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Dart + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + # Note: This workflow uses the latest stable version of the Dart SDK. + # You can specify other versions if desired, see documentation here: + # https://github.com/dart-lang/setup-dart/blob/main/README.md + # - uses: dart-lang/setup-dart@v1 + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + + - name: Install dependencies + run: dart pub get + + # Uncomment this step to verify the use of 'dart format' on each commit. + # - name: Verify formatting + # run: dart format --output=none --set-exit-if-changed . + + # Consider passing '--fatal-infos' for slightly stricter analysis. + - name: Analyze project source + run: dart analyze + + # Your project will need to have tests in test/ and a dependency on + # package:test for this step to succeed. Note that Flutter projects will + # want to change this to 'flutter test'. + - name: Run tests + run: dart test From 2372872aa257c2229cbd9305128e72e2e9c5bedc Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 10:46:57 +0200 Subject: [PATCH 08/29] Create flutter.yml --- .github/workflows/flutter.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/flutter.yml diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml new file mode 100644 index 00000000..97c5382e --- /dev/null +++ b/.github/workflows/flutter.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Dart + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + # Note: This workflow uses the latest stable version of the Dart SDK. + # You can specify other versions if desired, see documentation here: + # https://github.com/dart-lang/setup-dart/blob/main/README.md + # - uses: dart-lang/setup-dart@v1 + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + + - name: Install dependencies + run: flutter pub get + + # Uncomment this step to verify the use of 'dart format' on each commit. + # - name: Verify formatting + # run: dart format --output=none --set-exit-if-changed . + + # Consider passing '--fatal-infos' for slightly stricter analysis. + - name: Analyze project source + run: flutter analyze + + # Your project will need to have tests in test/ and a dependency on + # package:test for this step to succeed. Note that Flutter projects will + # want to change this to 'flutter test'. + - name: Run tests + run: flutter test From 26aa25259e1316988a80a01dbef180dc6240ec0a Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 11:17:15 +0200 Subject: [PATCH 09/29] changed from 'html_editor_enhanced' to 'html_editor_enhanced_fork_latex' --- example/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/lib/main.dart | 2 +- example/pubspec.lock | 4 +-- example/pubspec.yaml | 2 +- lib/html_editor.dart | 32 +++++++++---------- lib/src/html_editor_controller_mobile.dart | 4 +-- .../html_editor_controller_unsupported.dart | 2 +- lib/src/html_editor_controller_web.dart | 4 +-- lib/src/html_editor_mobile.dart | 8 ++--- lib/src/html_editor_unsupported.dart | 2 +- lib/src/html_editor_web.dart | 4 +-- .../widgets/html_editor_widget_mobile.dart | 4 +-- lib/src/widgets/html_editor_widget_web.dart | 6 ++-- lib/src/widgets/toolbar_widget.dart | 4 +-- lib/utils/callbacks.dart | 2 +- lib/utils/options.dart | 2 +- lib/utils/utils.dart | 4 +-- pubspec.yaml | 4 +-- 19 files changed, 47 insertions(+), 47 deletions(-) diff --git a/example/android/build.gradle b/example/android/build.gradle index 714549c2..05744a00 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index bc6a58af..cfe88f69 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/example/lib/main.dart b/example/lib/main.dart index 88ce86e8..56115b85 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,7 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; void main() => runApp(HtmlEditorExampleApp()); diff --git a/example/pubspec.lock b/example/pubspec.lock index 1a771515..3e04836c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -205,13 +205,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" - html_editor_enhanced: + html_editor_enhanced_fork_latex: dependency: "direct main" description: path: ".." relative: true source: path - version: "2.5.1" + version: "2.5.2" infinite_listview: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 3d6cad01..9e5b1cf9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter - html_editor_enhanced: + html_editor_enhanced_fork_latex: # When depending on this package from a real application you should use: # html_editor_enhanced: ^x.y.z # See https://dart.dev/tools/pub/dependencies#version-constraints diff --git a/lib/html_editor.dart b/lib/html_editor.dart index a1bf776c..c280cc13 100644 --- a/lib/html_editor.dart +++ b/lib/html_editor.dart @@ -1,22 +1,22 @@ library html_editor; -export 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_controller_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; -export 'package:html_editor_enhanced/src/html_editor_unsupported.dart' - if (dart.library.html) 'package:html_editor_enhanced/src/html_editor_web.dart' - if (dart.library.io) 'package:html_editor_enhanced/src/html_editor_mobile.dart'; -export 'package:html_editor_enhanced/src/widgets/custom_html_editor.dart'; -export 'package:html_editor_enhanced/src/widgets/math_keyboard_dialog.dart'; -export 'package:html_editor_enhanced/src/widgets/toolbar_widget.dart'; -export 'package:html_editor_enhanced/utils/callbacks.dart'; -export 'package:html_editor_enhanced/utils/file_upload_model.dart'; -export 'package:html_editor_enhanced/utils/options.dart'; -export 'package:html_editor_enhanced/utils/plugins.dart'; -export 'package:html_editor_enhanced/utils/shims/flutter_inappwebview_fake.dart' +export 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_web.dart' + if (dart.library.io) 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_mobile.dart'; +export 'package:html_editor_enhanced_fork_latex/src/html_editor_unsupported.dart' + if (dart.library.html) 'package:html_editor_enhanced_fork_latex/src/html_editor_web.dart' + if (dart.library.io) 'package:html_editor_enhanced_fork_latex/src/html_editor_mobile.dart'; +export 'package:html_editor_enhanced_fork_latex/src/widgets/custom_html_editor.dart'; +export 'package:html_editor_enhanced_fork_latex/src/widgets/math_keyboard_dialog.dart'; +export 'package:html_editor_enhanced_fork_latex/src/widgets/toolbar_widget.dart'; +export 'package:html_editor_enhanced_fork_latex/utils/callbacks.dart'; +export 'package:html_editor_enhanced_fork_latex/utils/file_upload_model.dart'; +export 'package:html_editor_enhanced_fork_latex/utils/options.dart'; +export 'package:html_editor_enhanced_fork_latex/utils/plugins.dart'; +export 'package:html_editor_enhanced_fork_latex/utils/shims/flutter_inappwebview_fake.dart' if (dart.library.io) 'package:flutter_inappwebview/flutter_inappwebview.dart'; -export 'package:html_editor_enhanced/utils/toolbar.dart'; -export 'package:html_editor_enhanced/utils/utils.dart' +export 'package:html_editor_enhanced_fork_latex/utils/toolbar.dart'; +export 'package:html_editor_enhanced_fork_latex/utils/utils.dart' hide setState, intersperse, getRandString; /// Defines the 3 different cases for file insertion failing diff --git a/lib/src/html_editor_controller_mobile.dart b/lib/src/html_editor_controller_mobile.dart index 36547428..5cac876b 100644 --- a/lib/src/html_editor_controller_mobile.dart +++ b/lib/src/html_editor_controller_mobile.dart @@ -1,8 +1,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' as unsupported; /// Controller for mobile diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index 419e92d3..87b687f7 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,6 +1,6 @@ import 'dart:collection'; -import 'package:html_editor_enhanced/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:meta/meta.dart'; /// Fallback controller (should never be used) diff --git a/lib/src/html_editor_controller_web.dart b/lib/src/html_editor_controller_web.dart index 9a6324e6..b1b0e717 100644 --- a/lib/src/html_editor_controller_web.dart +++ b/lib/src/html_editor_controller_web.dart @@ -3,8 +3,8 @@ import 'dart:convert'; import 'dart:html' as html; import 'package:flutter/foundation.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/src/html_editor_controller_unsupported.dart' +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' as unsupported; import 'package:meta/meta.dart'; diff --git a/lib/src/html_editor_mobile.dart b/lib/src/html_editor_mobile.dart index 50faf109..e52dc809 100644 --- a/lib/src/html_editor_mobile.dart +++ b/lib/src/html_editor_mobile.dart @@ -1,9 +1,9 @@ -import 'package:html_editor_enhanced/html_editor.dart' - hide HtmlEditorController; -import 'package:html_editor_enhanced/src/html_editor_controller_mobile.dart'; -import 'package:html_editor_enhanced/src/widgets/html_editor_widget_mobile.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart' + hide HtmlEditorController; +import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_mobile.dart'; +import 'package:html_editor_enhanced_fork_latex/src/widgets/html_editor_widget_mobile.dart'; /// HtmlEditor class for mobile class HtmlEditor extends StatelessWidget { diff --git a/lib/src/html_editor_unsupported.dart b/lib/src/html_editor_unsupported.dart index e4443167..47664389 100644 --- a/lib/src/html_editor_unsupported.dart +++ b/lib/src/html_editor_unsupported.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; /// Fallback HtmlEditor class (should never be called) class HtmlEditor extends StatelessWidget { diff --git a/lib/src/html_editor_web.dart b/lib/src/html_editor_web.dart index 3de5c787..f7ed1b41 100644 --- a/lib/src/html_editor_web.dart +++ b/lib/src/html_editor_web.dart @@ -1,7 +1,7 @@ -import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/src/widgets/html_editor_widget_web.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/src/widgets/html_editor_widget_web.dart'; /// HtmlEditor class for web class HtmlEditor extends StatelessWidget { diff --git a/lib/src/widgets/html_editor_widget_mobile.dart b/lib/src/widgets/html_editor_widget_mobile.dart index 94f46fcd..aba91df2 100644 --- a/lib/src/widgets/html_editor_widget_mobile.dart +++ b/lib/src/widgets/html_editor_widget_mobile.dart @@ -8,9 +8,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; -import 'package:html_editor_enhanced/html_editor.dart' +import 'package:html_editor_enhanced_fork_latex/html_editor.dart' hide NavigationActionPolicy, UserScript, ContextMenu; -import 'package:html_editor_enhanced/utils/utils.dart'; +import 'package:html_editor_enhanced_fork_latex/utils/utils.dart'; import 'package:visibility_detector/visibility_detector.dart'; /// The HTML Editor widget itself, for mobile (uses InAppWebView) diff --git a/lib/src/widgets/html_editor_widget_web.dart b/lib/src/widgets/html_editor_widget_web.dart index 103d35c2..1f0224f2 100644 --- a/lib/src/widgets/html_editor_widget_web.dart +++ b/lib/src/widgets/html_editor_widget_web.dart @@ -4,9 +4,9 @@ import 'dart:html' as html; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/utils/shims/dart_ui.dart' as ui; -import 'package:html_editor_enhanced/utils/utils.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/utils/shims/dart_ui.dart' as ui; +import 'package:html_editor_enhanced_fork_latex/utils/utils.dart'; export 'dart:html'; diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index bdce4767..fefbeadb 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -7,8 +7,8 @@ import 'package:flex_color_picker/flex_color_picker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/utils/utils.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/utils/utils.dart'; import 'package:math_keyboard/math_keyboard.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; diff --git a/lib/utils/callbacks.dart b/lib/utils/callbacks.dart index 366a6a94..daefdbd9 100644 --- a/lib/utils/callbacks.dart +++ b/lib/utils/callbacks.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:html_editor_enhanced/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; /// Manages all the callback functions the library provides class Callbacks { diff --git a/lib/utils/options.dart b/lib/utils/options.dart index 8212be6c..6ad3a959 100644 --- a/lib/utils/options.dart +++ b/lib/utils/options.dart @@ -3,7 +3,7 @@ import 'dart:collection'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; /// Options that modify the editor and its behavior class HtmlEditorOptions { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index cbe2c46f..37c7449d 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -5,8 +5,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; -import 'package:html_editor_enhanced/utils/shims/dart_ui.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/utils/shims/dart_ui.dart'; /// small function to always check if mounted before running setState() void setState( diff --git a/pubspec.yaml b/pubspec.yaml index cac25a53..d0d6abee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ -name: html_editor_enhanced +name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.5.1 +version: 2.5.2 homepage: https://github.com/tneotia/html-editor-enhanced environment: From 409cff88e79f3beb959a7467e1cdc0aaa0e2a8e1 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 12:11:49 +0200 Subject: [PATCH 10/29] changed from 'html_editor_enhanced' to 'html_editor_enhanced_fork_latex' --- analysis_options.yaml | 1 - example/pubspec.lock | 92 +++++++++++++-------- lib/src/widgets/math_keyboard_dialog.dart | 70 ++++++++-------- lib/src/widgets/toolbar_widget.dart | 4 +- lib/utils/custom_math_field_controller.dart | 17 ++++ pubspec.lock | 86 ++++++++++++------- pubspec.yaml | 19 +++-- 7 files changed, 177 insertions(+), 112 deletions(-) create mode 100644 lib/utils/custom_math_field_controller.dart diff --git a/analysis_options.yaml b/analysis_options.yaml index d4fcc1ad..e69de29b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +0,0 @@ -include: package:pedantic/analysis_options.yaml \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 3e04836c..8d05b2e9 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -53,10 +53,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.6" fake_async: dependency: transitive description: @@ -69,26 +69,26 @@ packages: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" file_picker: dependency: transitive description: name: file_picker - sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 + sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" url: "https://pub.dev" source: hosted - version: "5.2.5" + version: "6.1.1" flex_color_picker: dependency: transitive description: name: flex_color_picker - sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" + sha256: f37476ab3e80dcaca94e428e159944d465dd16312fda9ff41e07e86f04bfa51c url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.3.0" flex_seed_scheme: dependency: transitive description: @@ -106,18 +106,18 @@ packages: dependency: transitive description: name: flutter_inappwebview - sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf + sha256: d198297060d116b94048301ee6749cd2e7d03c1f2689783f52d210a6b7aba350 url: "https://pub.dev" source: hosted - version: "5.7.2+3" + version: "5.8.0" flutter_keyboard_visibility: dependency: transitive description: name: flutter_keyboard_visibility - sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" + sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.4.1" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -175,10 +175,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da url: "https://pub.dev" source: hosted - version: "2.0.7" + version: "2.0.17" flutter_svg: dependency: transitive description: @@ -211,7 +211,7 @@ packages: path: ".." relative: true source: path - version: "2.5.2" + version: "2.6.0" infinite_listview: dependency: transitive description: @@ -228,6 +228,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.18.1" + lints: + dependency: transitive + description: + name: lints + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + url: "https://pub.dev" + source: hosted + version: "3.0.0" matcher: dependency: transitive description: @@ -280,10 +288,10 @@ packages: dependency: transitive description: name: numberpicker - sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" + sha256: "4c129154944b0f6b133e693f8749c3f8bfb67c4d07ef9dcab48b595c22d1f156" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" path: dependency: transitive description: @@ -300,14 +308,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - pedantic: - dependency: transitive - description: - name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" - source: hosted - version: "1.11.1" petitparser: dependency: transitive description: @@ -320,18 +320,42 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.7" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 + sha256: fda979f3eb65558a389517521c8315060289dda5a1a6087f3892bdea9550eade + url: "https://pub.dev" + source: hosted + version: "0.10.0" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: "4282ebfe21b54e21e26ab982c6086f0a67dc63423026bfba8db39a2e22045f26" + url: "https://pub.dev" + source: hosted + version: "0.10.0" + pointer_interceptor_platform_interface: + dependency: transitive + description: + name: pointer_interceptor_platform_interface + sha256: "59a446ead3be360bde72c3725f5ecacbba203c8a760e3061024c20f7da53f825" + url: "https://pub.dev" + source: hosted + version: "0.10.0" + pointer_interceptor_web: + dependency: transitive + description: + name: pointer_interceptor_web + sha256: "2a8a069206f7b234a895d30ccab8b18ea267eeb79a832e5e3d1b6464d659eb6a" url: "https://pub.dev" source: hosted - version: "0.9.3+3" + version: "0.10.0" provider: dependency: transitive description: @@ -437,10 +461,10 @@ packages: dependency: transitive description: name: visibility_detector - sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 url: "https://pub.dev" source: hosted - version: "0.3.3" + version: "0.4.0+2" web: dependency: transitive description: @@ -485,10 +509,10 @@ packages: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574 url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "5.1.1" xml: dependency: transitive description: @@ -499,4 +523,4 @@ packages: version: "6.3.0" sdks: dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.10.0" + flutter: ">=3.13.0" diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart index a236e601..1ccb67ea 100644 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -1,6 +1,7 @@ import 'dart:developer'; import 'package:flutter/material.dart'; +import 'package:html_editor_enhanced_fork_latex/utils/custom_math_field_controller.dart'; import 'package:math_keyboard/math_keyboard.dart'; class MathKeyboardDialog extends StatelessWidget { @@ -13,11 +14,12 @@ class MathKeyboardDialog extends StatelessWidget { } } - final MathFieldEditingController controller; + final CustomMathFieldEditingController controller; final MathField? mathField; @override Widget build(BuildContext context) { + var tex = ''; return Dialog( child: Padding( padding: const EdgeInsets.all(8.0), @@ -25,20 +27,47 @@ class MathKeyboardDialog extends StatelessWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - _mathField(context), + SizedBox( + width: MediaQuery.of(context).size.width, + child: MathField( + focusNode: mathField?.focusNode, + autofocus: mathField?.autofocus ?? true, + controller: controller, + variables: + mathField?.variables ?? ['x', 'y', 'z', 'A', 'B', 'C'], + decoration: mathField?.decoration ?? + InputDecoration( + suffix: MouseRegion( + cursor: MaterialStateMouseCursor.clickable, + child: GestureDetector( + onTap: controller.clear, + child: const Icon( + Icons.highlight_remove_rounded, + color: Colors.grey, + ), + ), + ), + ), + onChanged: mathField?.onChanged ?? + (str) { + tex = str; + }, + onSubmitted: mathField?.onSubmitted, + opensKeyboard: mathField?.opensKeyboard ?? true, + ), + ), const SizedBox(height: 15), TextButton( onPressed: () { - controller.setTexString(''); Navigator.pop(context, ''); - print(controller.texStringAsFun); + print(texStringAsFun(tex)); }, child: const Text('Close'), ), TextButton( onPressed: () { Navigator.pop(context, controller.texStringAsFun); - print(controller.texStringAsFun); + print(texStringAsFun(tex)); }, child: const Text('save'), ), @@ -48,34 +77,5 @@ class MathKeyboardDialog extends StatelessWidget { ); } - Widget _mathField(context) { - return SizedBox( - width: MediaQuery.of(context).size.width, - child: MathField( - focusNode: mathField?.focusNode, - autofocus: mathField?.autofocus ?? true, - controller: controller, - variables: mathField?.variables ?? ['x', 'y', 'z', 'A', 'B', 'C'], - decoration: mathField?.decoration ?? - InputDecoration( - suffix: MouseRegion( - cursor: MaterialStateMouseCursor.clickable, - child: GestureDetector( - onTap: controller.clear, - child: const Icon( - Icons.highlight_remove_rounded, - color: Colors.grey, - ), - ), - ), - ), - onChanged: mathField?.onChanged ?? - (str) { - controller.setTexString(str); - }, - onSubmitted: mathField?.onSubmitted, - opensKeyboard: mathField?.opensKeyboard ?? true, - ), - ); - } + String texStringAsFun(String str) => '\\($str\\)'; } diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index fefbeadb..70b94032 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -8,8 +8,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/utils/custom_math_field_controller.dart'; import 'package:html_editor_enhanced_fork_latex/utils/utils.dart'; -import 'package:math_keyboard/math_keyboard.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -2611,7 +2611,7 @@ class ToolbarWidgetState extends State { ?.call(ButtonType.fn, null, null) ?? true; if (proceed) { - final c = MathFieldEditingController(); + final c = CustomMathFieldEditingController(); await showDialog( context: context, builder: (context) => MathKeyboardDialog(controller: c)); diff --git a/lib/utils/custom_math_field_controller.dart b/lib/utils/custom_math_field_controller.dart new file mode 100644 index 00000000..34b28132 --- /dev/null +++ b/lib/utils/custom_math_field_controller.dart @@ -0,0 +1,17 @@ +import 'package:math_keyboard/math_keyboard.dart'; + +class CustomMathFieldEditingController extends MathFieldEditingController { + /// Constructs a [MathKeyboardViewModel]. + CustomMathFieldEditingController() { + currentNode = root; + currentNode.setCursor(); + } + + String texString = ''; + + void setTexString(String str) { + texString = str; + } + + String get texStringAsFun => '\\($texString\\)'; +} diff --git a/pubspec.lock b/pubspec.lock index 2e36c442..52ecca82 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -61,26 +61,26 @@ packages: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" file_picker: dependency: "direct main" description: name: file_picker - sha256: d090ae03df98b0247b82e5928f44d1b959867049d18d73635e2e0bc3f49542b9 + sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" url: "https://pub.dev" source: hosted - version: "5.2.5" + version: "6.1.1" flex_color_picker: dependency: "direct main" description: name: flex_color_picker - sha256: "40c1cbf8426a05c2b418ecf6c0fce386429fd7f9d238abbb2182985e8e6c5596" + sha256: f37476ab3e80dcaca94e428e159944d465dd16312fda9ff41e07e86f04bfa51c url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.3.0" flex_seed_scheme: dependency: transitive description: @@ -98,18 +98,18 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - sha256: f73505c792cf083d5566e1a94002311be497d984b5607f25be36d685cf6361cf + sha256: d198297060d116b94048301ee6749cd2e7d03c1f2689783f52d210a6b7aba350 url: "https://pub.dev" source: hosted - version: "5.7.2+3" + version: "5.8.0" flutter_keyboard_visibility: dependency: "direct main" description: name: flutter_keyboard_visibility - sha256: "86b71bbaffa38e885f5c21b1182408b9be6951fd125432cf6652c636254cef2d" + sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.4.1" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -167,10 +167,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da url: "https://pub.dev" source: hosted - version: "2.0.7" + version: "2.0.17" flutter_svg: dependency: transitive description: @@ -213,6 +213,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.18.1" + lints: + dependency: "direct main" + description: + name: lints + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + url: "https://pub.dev" + source: hosted + version: "3.0.0" matcher: dependency: transitive description: @@ -265,10 +273,10 @@ packages: dependency: "direct main" description: name: numberpicker - sha256: "73723bd13c940ebcd9e5f0ed56b4874588c1748a9a6a38254f97ad627715142e" + sha256: "4c129154944b0f6b133e693f8749c3f8bfb67c4d07ef9dcab48b595c22d1f156" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" path: dependency: transitive description: @@ -285,14 +293,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - pedantic: - dependency: "direct main" - description: - name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" - source: hosted - version: "1.11.1" petitparser: dependency: transitive description: @@ -305,18 +305,42 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.7" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - sha256: fee6ba42b910637465bc0d367ba27066c6eccfbc3bc0ceb14831915acc600db0 + sha256: fda979f3eb65558a389517521c8315060289dda5a1a6087f3892bdea9550eade + url: "https://pub.dev" + source: hosted + version: "0.10.0" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: "4282ebfe21b54e21e26ab982c6086f0a67dc63423026bfba8db39a2e22045f26" + url: "https://pub.dev" + source: hosted + version: "0.10.0" + pointer_interceptor_platform_interface: + dependency: transitive + description: + name: pointer_interceptor_platform_interface + sha256: "59a446ead3be360bde72c3725f5ecacbba203c8a760e3061024c20f7da53f825" + url: "https://pub.dev" + source: hosted + version: "0.10.0" + pointer_interceptor_web: + dependency: transitive + description: + name: pointer_interceptor_web + sha256: "2a8a069206f7b234a895d30ccab8b18ea267eeb79a832e5e3d1b6464d659eb6a" url: "https://pub.dev" source: hosted - version: "0.9.3+3" + version: "0.10.0" provider: dependency: transitive description: @@ -422,10 +446,10 @@ packages: dependency: "direct main" description: name: visibility_detector - sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 url: "https://pub.dev" source: hosted - version: "0.3.3" + version: "0.4.0+2" web: dependency: transitive description: @@ -470,10 +494,10 @@ packages: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574 url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "5.1.1" xml: dependency: transitive description: @@ -484,4 +508,4 @@ packages: version: "6.3.0" sdks: dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.10.0" + flutter: ">=3.13.0" diff --git a/pubspec.yaml b/pubspec.yaml index d0d6abee..dfdcfd59 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,9 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.5.2 +version: 2.6.1 homepage: https://github.com/tneotia/html-editor-enhanced +repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git environment: sdk: '>=2.15.0 <3.0.0' @@ -12,26 +13,26 @@ dependencies: flutter: sdk: flutter # webview plugin - flutter_inappwebview: ^5.7.2+3 + flutter_inappwebview: ^5.8.0 # plugin to get webview's visible fraction for keyboard height adjustment - visibility_detector: ^0.3.3 + visibility_detector: ^0.4.0+2 # plugin to get when the keyboard is hidden via back (Android) # or "done" (iOS) to reset the editor's height flutter_keyboard_visibility: ^5.4.0 # plugin to show a color picker for foreground/highlight color - flex_color_picker: ^3.0.2 + flex_color_picker: ^3.3.0 # plugin to get files from filesystem - file_picker: ^5.2.0+1 + file_picker: ^6.1.1 # plugin to show a scrollable number picker for inserting tables - numberpicker: ^2.1.1 + numberpicker: ^2.1.2 # plugin to allow dropdowns and dialogs to be interactable when displaying over the editor # related to https://github.com/flutter/flutter/issues/54027 # pinned to 0.9.1 because of issues with CanvasKit in the latest versions - pointer_interceptor: ^0.9.3+3 + pointer_interceptor: ^0.10.0 # plugin to help maintain effective Dart standards - pedantic: ^1.11.1 + lints: ^3.0.0 # plugin for @internal annotation - meta: '>=1.0.0 <2.0.0' + meta: ^1.10.0 math_keyboard: ^0.2.1 webview_flutter: ^4.4.2 From 1fa09ae06c768fe3ef32092840a39083fa400d69 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 14:59:15 +0200 Subject: [PATCH 11/29] fixed bugs in math keyboard and did dart format --- CHANGELOG.md | 41 ++- README.md | 16 +- example/android/build.gradle | 2 +- example/lib/main.dart | 4 +- example/pubspec.lock | 2 +- lib/html_editor.dart | 2 +- lib/src/html_editor_controller_mobile.dart | 4 +- .../html_editor_controller_unsupported.dart | 4 +- lib/src/html_editor_controller_web.dart | 6 +- lib/src/html_editor_mobile.dart | 2 +- lib/src/html_editor_unsupported.dart | 2 +- lib/src/html_editor_web.dart | 2 +- lib/src/widgets/custom_html_editor.dart | 1 + .../widgets/html_editor_widget_mobile.dart | 7 +- lib/src/widgets/html_editor_widget_web.dart | 10 +- lib/src/widgets/math_keyboard_dialog.dart | 11 +- lib/src/widgets/toolbar_widget.dart | 2 +- lib/utils/custom_classes.dart | 270 ++++++++++++++++++ lib/utils/custom_math_field_controller.dart | 18 ++ lib/utils/plugins.dart | 2 +- lib/utils/toolbar.dart | 2 +- lib/utils/utils.dart | 2 + pubspec.yaml | 22 +- 23 files changed, 378 insertions(+), 56 deletions(-) create mode 100644 lib/utils/custom_classes.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index a145802f..2fed830e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,47 @@ -## [2.5.1] = 2023-01-25 +## [2.6.4] = 2023-12-20 + +* Fixed Cursor bug in math keyboard + +## [2.6.3] = 2023-12-20 + +* Fixed the assets for name change + +## [2.6.2] = 2023-12-20 + +* Dart formatter +* + +## [2.6.1] = 2023-12-20 + +* Update pubspec +* Added repo url + +## [2.6.0] = 2023-12-20 + +* Bug fixes +* Added a Custom Math Keyboard + +## [2.5.2] = 2023-12-20 + +* Added latex +* Added dependencies + +## [2.5.1] = 2023-12-20 + * Fix build issues on Flutter 3.4.0+ due to assets directory * Update dependencies ## [2.5.0] - 2022-06-04 + * Support Flutter 3.0 (remove warnings) (@Cteq3132) -* [BREAKING] Support modifying `foreColorSelected` and `backColorSelected` when using a custom dialog for font coloring - * If you are using a custom `updateStatus` function for the font coloring, that function is now defined as `updateStatus(Color)` +* [BREAKING] Support modifying `foreColorSelected` and `backColorSelected` when using a custom + dialog for font coloring + * If you are using a custom `updateStatus` function for the font coloring, that function is now + defined as `updateStatus(Color)` * Added `disabled` parameter to automatically disable editor on initial load * Fixed white background color appearing sometimes when pressing backspace on text -* Added `useHybridComposition` parameter in case devs want to disable this behavior (improves animations of app) +* Added `useHybridComposition` parameter in case devs want to disable this behavior (improves + animations of app) * [WEB] Fixed editor height being 0 when `initialText` is `null` (@dab246) * Migrated example to Android embedding V2 * Removed woff fonts to allow iOS App Store submissions diff --git a/README.md b/README.md index 7dce292a..f2202616 100644 --- a/README.md +++ b/README.md @@ -481,9 +481,11 @@ Notes: You can use these files from the package to avoid adding more asset files: ```html - - - + + + + ``` See the example HTML file [below](#example-html-for-filepath) for an actual example. @@ -848,7 +850,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:html_editor_enhanced/html_editor.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; class _ExampleState extends State { final HtmlEditorController controller = HtmlEditorController(); @@ -950,9 +952,9 @@ class _ExampleState extends State { Summernote Text Editor HTML - - - + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index 05744a00..7849bedc 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:7.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 56115b85..cfac4eae 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -208,10 +208,10 @@ class _HtmlEditorExampleState extends State { backgroundColor: Theme.of(context).colorScheme.secondary), onPressed: () async { - var txt = await controller.getText(); + var txt = await controller.getHtmlStringWithLatex(); if (txt.contains('src=\"data:')) { txt = - ''; + ''; } setState(() { result = txt; diff --git a/example/pubspec.lock b/example/pubspec.lock index 8d05b2e9..f9666903 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -211,7 +211,7 @@ packages: path: ".." relative: true source: path - version: "2.6.0" + version: "2.6.3" infinite_listview: dependency: transitive description: diff --git a/lib/html_editor.dart b/lib/html_editor.dart index c280cc13..c5c2c9f1 100644 --- a/lib/html_editor.dart +++ b/lib/html_editor.dart @@ -99,4 +99,4 @@ enum DropdownMenuDirection { down, up } enum InsertFileType { image, audio, video } /// Sets how the virtual keyboard appears on mobile devices -enum HtmlInputType { decimal, email, numeric, tel, url, text } \ No newline at end of file +enum HtmlInputType { decimal, email, numeric, tel, url, text } diff --git a/lib/src/html_editor_controller_mobile.dart b/lib/src/html_editor_controller_mobile.dart index 5cac876b..6033e7fe 100644 --- a/lib/src/html_editor_controller_mobile.dart +++ b/lib/src/html_editor_controller_mobile.dart @@ -195,7 +195,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { @override void reloadWeb() { throw Exception( - 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart and check kIsWeb before calling this function'); + 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart and check kIsWeb before calling this function'); } /// Resets the height of the editor back to the original if it was changed to @@ -265,7 +265,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { return result; } else { throw Exception( - 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart'); + 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart'); } } diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index 87b687f7..e69be568 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -119,7 +119,7 @@ class HtmlEditorController { /// A function to execute JS passed as a [WebScript] to the editor. This should /// only be used on Flutter Web. Future evaluateJavascriptWeb(String name, - {bool hasReturnValue = false}) => + {bool hasReturnValue = false}) => Future.value(); /// Gets the text from the editor and returns it as a [String]. @@ -206,4 +206,4 @@ class HtmlEditorController { /// Internal function to insert table on Web @internal void insertTable(String dimensions) {} -} \ No newline at end of file +} diff --git a/lib/src/html_editor_controller_web.dart b/lib/src/html_editor_controller_web.dart index b1b0e717..2f7e826d 100644 --- a/lib/src/html_editor_controller_web.dart +++ b/lib/src/html_editor_controller_web.dart @@ -187,7 +187,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { @override void clearFocus() { throw Exception( - 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart and check kIsWeb before calling this method.'); + 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart and check kIsWeb before calling this method.'); } /// Resets the height of the editor back to the original if it was changed to @@ -196,7 +196,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { @override void resetHeight() { throw Exception( - 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart and check kIsWeb before calling this method.'); + 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart and check kIsWeb before calling this method.'); } /// Refresh the page @@ -323,7 +323,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { html.window.postMessage(json, '*'); } else { throw Exception( - 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart'); + 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart'); } } } diff --git a/lib/src/html_editor_mobile.dart b/lib/src/html_editor_mobile.dart index e52dc809..0afe5ce4 100644 --- a/lib/src/html_editor_mobile.dart +++ b/lib/src/html_editor_mobile.dart @@ -51,7 +51,7 @@ class HtmlEditor extends StatelessWidget { ); } else { return Text( - 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart'); + 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart'); } } } diff --git a/lib/src/html_editor_unsupported.dart b/lib/src/html_editor_unsupported.dart index 47664389..a8eabf55 100644 --- a/lib/src/html_editor_unsupported.dart +++ b/lib/src/html_editor_unsupported.dart @@ -37,4 +37,4 @@ class HtmlEditor extends StatelessWidget { Widget build(BuildContext context) { return Text('Unsupported in this environment'); } -} \ No newline at end of file +} diff --git a/lib/src/html_editor_web.dart b/lib/src/html_editor_web.dart index f7ed1b41..81f072bf 100644 --- a/lib/src/html_editor_web.dart +++ b/lib/src/html_editor_web.dart @@ -50,7 +50,7 @@ class HtmlEditor extends StatelessWidget { ); } else { return Text( - 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced/html_editor.dart'); + 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart'); } } } diff --git a/lib/src/widgets/custom_html_editor.dart b/lib/src/widgets/custom_html_editor.dart index e7bb9e0b..f12cfbfe 100644 --- a/lib/src/widgets/custom_html_editor.dart +++ b/lib/src/widgets/custom_html_editor.dart @@ -150,6 +150,7 @@ class CustomHtmlEditorWidget extends StatelessWidget { return _htmlWidget(); } } + const tableTex = r''' \begin{array} { | l | l | l | } diff --git a/lib/src/widgets/html_editor_widget_mobile.dart b/lib/src/widgets/html_editor_widget_mobile.dart index aba91df2..f2c064a6 100644 --- a/lib/src/widgets/html_editor_widget_mobile.dart +++ b/lib/src/widgets/html_editor_widget_mobile.dart @@ -72,9 +72,10 @@ class _HtmlEditorWidgetMobileState extends State { filePath = widget.htmlEditorOptions.filePath!; } else if (widget.plugins.isEmpty) { filePath = - 'packages/html_editor_enhanced/assets/summernote-no-plugins.html'; + 'packages/html_editor_enhanced_fork_latex/assets/summernote-no-plugins.html'; } else { - filePath = 'packages/html_editor_enhanced/assets/summernote.html'; + filePath = + 'packages/html_editor_enhanced_fork_latex/assets/summernote.html'; } super.initState(); } @@ -456,7 +457,7 @@ class _HtmlEditorWidgetMobileState extends State { widget.htmlEditorOptions.darkMode != false) { //todo fix for iOS (https://github.com/pichillilorenzo/flutter_inappwebview/issues/695) var darkCSS = - ''; + ''; await controller.evaluateJavascript( source: "\$('head').append('$darkCSS');"); } diff --git a/lib/src/widgets/html_editor_widget_web.dart b/lib/src/widgets/html_editor_widget_web.dart index 1f0224f2..2bae694d 100644 --- a/lib/src/widgets/html_editor_widget_web.dart +++ b/lib/src/widgets/html_editor_widget_web.dart @@ -186,7 +186,7 @@ class _HtmlEditorWidgetWebState extends State { widget.htmlEditorOptions.darkMode == true) && widget.htmlEditorOptions.darkMode != false) { darkCSS = - ''; + ''; } var jsCallbacks = ''; if (widget.callbacks != null) { @@ -446,7 +446,7 @@ class _HtmlEditorWidgetWebState extends State { """; var filePath = - 'packages/html_editor_enhanced/assets/summernote-no-plugins.html'; + 'packages/html_editor_enhanced_fork_latex/assets/summernote-no-plugins.html'; if (widget.htmlEditorOptions.filePath != null) { filePath = widget.htmlEditorOptions.filePath!; } @@ -456,11 +456,11 @@ class _HtmlEditorWidgetWebState extends State { .replaceFirst('', headString) .replaceFirst('', summernoteScripts) .replaceFirst('"jquery.min.js"', - '"assets/packages/html_editor_enhanced/assets/jquery.min.js"') + '"assets/packages/html_editor_enhanced_fork_latex/assets/jquery.min.js"') .replaceFirst('"summernote-lite.min.css"', - '"assets/packages/html_editor_enhanced/assets/summernote-lite.min.css"') + '"assets/packages/html_editor_enhanced_fork_latex/assets/summernote-lite.min.css"') .replaceFirst('"summernote-lite.min.js"', - '"assets/packages/html_editor_enhanced/assets/summernote-lite.min.js"'); + '"assets/packages/html_editor_enhanced_fork_latex/assets/summernote-lite.min.js"'); if (widget.callbacks != null) addJSListener(widget.callbacks!); final iframe = html.IFrameElement() ..width = MediaQuery.of(widget.initBC).size.width.toString() //'800' diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart index 1ccb67ea..0a205c99 100644 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -19,7 +19,6 @@ class MathKeyboardDialog extends StatelessWidget { @override Widget build(BuildContext context) { - var tex = ''; return Dialog( child: Padding( padding: const EdgeInsets.all(8.0), @@ -48,10 +47,7 @@ class MathKeyboardDialog extends StatelessWidget { ), ), ), - onChanged: mathField?.onChanged ?? - (str) { - tex = str; - }, + onChanged: mathField?.onChanged ?? controller.setTexString, onSubmitted: mathField?.onSubmitted, opensKeyboard: mathField?.opensKeyboard ?? true, ), @@ -60,14 +56,14 @@ class MathKeyboardDialog extends StatelessWidget { TextButton( onPressed: () { Navigator.pop(context, ''); - print(texStringAsFun(tex)); + print(controller.texStringAsFun); }, child: const Text('Close'), ), TextButton( onPressed: () { Navigator.pop(context, controller.texStringAsFun); - print(texStringAsFun(tex)); + print(controller.texStringAsFun); }, child: const Text('save'), ), @@ -77,5 +73,4 @@ class MathKeyboardDialog extends StatelessWidget { ); } - String texStringAsFun(String str) => '\\($str\\)'; } diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index 70b94032..a4298b30 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -503,7 +503,7 @@ class ToolbarWidgetState extends State { dropdownColor: widget.htmlToolbarOptions.dropdownBackgroundColor, menuDirection: widget.htmlToolbarOptions.dropdownMenuDirection ?? (widget.htmlToolbarOptions.toolbarPosition == - ToolbarPosition.belowEditor + ToolbarPosition.belowEditor ? DropdownMenuDirection.up : DropdownMenuDirection.down), menuMaxHeight: widget.htmlToolbarOptions.dropdownMenuMaxHeight ?? diff --git a/lib/utils/custom_classes.dart b/lib/utils/custom_classes.dart new file mode 100644 index 00000000..331ddc36 --- /dev/null +++ b/lib/utils/custom_classes.dart @@ -0,0 +1,270 @@ +// import 'dart:ui'; +// +// import 'package:flutter/foundation.dart'; +// import 'package:math_keyboard/src/foundation/node.dart' as mk; +// +// /// Block representing a node of TeX. +// class TeXNode { +// /// Constructs a [TeXNode]. +// TeXNode(this.parent); +// +// /// The parent of the node. +// TeXFunction? parent; +// +// /// The courser position in this node. +// int courserPosition = 0; +// +// /// A block can have one or more child blocks. +// final List children = []; +// +// /// Sets the courser to the actual position. +// void setCursor() { +// children.insert(courserPosition, const Cursor()); +// } +// +// /// Removes the courser. +// void removeCursor() { +// children.removeAt(courserPosition); +// } +// +// /// Returns whether the last child node is the cursor. +// /// +// /// This does *not* traverse the children recursively as that might not be +// /// a guarantee for visually being all the way on the right with the cursor. +// /// Imagine a `\frac` node with a horizontally long string in the nominator: +// /// now, when the cursor is at the end, it is not visually on the right of the +// /// node as the denominator might not even be visible when scrolling to the +// /// right. +// bool cursorAtTheEnd() { +// if (children.isEmpty) return false; +// if (children.last is Cursor) return true; +// +// return false; +// } +// +// /// Shift courser to the left. +// NavigationState shiftCursorLeft() { +// if (courserPosition == 0) { +// return NavigationState.end; +// } +// removeCursor(); +// courserPosition--; +// if (children[courserPosition] is TeXFunction) { +// return NavigationState.func; +// } +// setCursor(); +// return NavigationState.success; +// } +// +// /// Shift courser to the right. +// NavigationState shiftCursorRight() { +// if (courserPosition == children.length - 1) { +// return NavigationState.end; +// } +// removeCursor(); +// courserPosition++; +// if (children[courserPosition - 1] is TeXFunction) { +// return NavigationState.func; +// } +// setCursor(); +// return NavigationState.success; +// } +// +// /// Adds a new node. +// void addTeX(TeX teX) { +// children.insert(courserPosition, teX); +// courserPosition++; +// } +// +// /// Removes the last node. +// NavigationState remove() { +// if (courserPosition == 0) { +// return NavigationState.end; +// } +// removeCursor(); +// courserPosition--; +// if (children[courserPosition] is TeXFunction) { +// return NavigationState.func; +// } +// children.removeAt(courserPosition); +// setCursor(); +// return NavigationState.success; +// } +// +// /// Builds the TeX representation of this node. +// /// +// /// This includes the representation of the children of the node. +// /// +// /// Returns the TeX expression as a [String]. +// static String buildTeXStringFromMathKeyboard({ +// Color? cursorColor, +// bool placeholderWhenEmpty = true, +// required mk.TeXNode root, +// }) { +// if (root.children.isEmpty) { +// return placeholderWhenEmpty ? '\\Box' : ''; +// } +// final buffer = StringBuffer(); +// for (final tex in root.children) { +// buffer.write(tex.buildString(cursorColor: cursorColor)); +// } +// return buffer.toString(); +// } +// +// String buildTeXString({ +// Color? cursorColor, +// bool placeholderWhenEmpty = true, +// }) { +// if (children.isEmpty) { +// return placeholderWhenEmpty ? '\\Box' : ''; +// } +// final buffer = StringBuffer(); +// for (final tex in children) { +// buffer.write(tex.buildString(cursorColor: cursorColor)); +// } +// return buffer.toString(); +// } +// } +// +// /// Class holding a TeX function. +// class TeXFunction extends TeX { +// /// Constructs a [TeXFunction]. +// /// +// /// [argNodes] can be passed directly if the nodes are already known. In that +// /// case, the [TeXNode.parent] is set in the constructor body. If [argNodes] +// /// is passed empty (default), empty [TeXNode]s will be inserted for each +// /// arg. +// TeXFunction(String expression, this.parent, this.args, +// [List? argNodes]) +// : assert(args.isNotEmpty, 'A function needs at least one argument.'), +// assert(argNodes == null || argNodes.length == args.length), +// argNodes = argNodes ?? List.empty(growable: true), +// super(expression) { +// if (this.argNodes.isEmpty) { +// for (var i = 0; i < args.length; i++) { +// this.argNodes.add(TeXNode(this)); +// } +// } else { +// for (final node in this.argNodes) { +// node.parent = this; +// } +// } +// } +// +// /// The functions parent node. +// TeXNode parent; +// +// /// The delimiters of the arguments. +// final List args; +// +// /// The arguments to this function. +// final List argNodes; +// +// /// Returns the opening character for a function argument. +// String openingChar(TeXArg type) { +// switch (type) { +// case TeXArg.braces: +// return '{'; +// case TeXArg.brackets: +// return '['; +// default: +// return '('; +// } +// } +// +// /// Returns the closing character for a function argument. +// String closingChar(TeXArg type) { +// switch (type) { +// case TeXArg.braces: +// return '}'; +// case TeXArg.brackets: +// return ']'; +// default: +// return ')'; +// } +// } +// +// @override +// String buildString({Color? cursorColor}) { +// final buffer = StringBuffer(expression); +// for (var i = 0; i < args.length; i++) { +// buffer.write(openingChar(args[i])); +// buffer.write(argNodes[i].buildTeXString( +// cursorColor: cursorColor, +// )); +// buffer.write(closingChar(args[i])); +// } +// return buffer.toString(); +// } +// } +// +// /// Class holding a single TeX expression. +// class TeXLeaf extends TeX { +// /// Constructs a [TeXLeaf]. +// const TeXLeaf(String expression) : super(expression); +// +// @override +// String buildString({Color? cursorColor}) { +// return expression; +// } +// } +// +// /// Class holding TeX. +// abstract class TeX { +// /// Constructs a [TeX]. +// const TeX(this.expression); +// +// /// The expression of this TeX +// final String expression; +// +// /// Builds the string representation of this TeX expression. +// String buildString({required Color? cursorColor}); +// } +// +// /// Class describing the cursor as a TeX expression. +// class Cursor extends TeX { +// /// Creates a TeX [Cursor]. +// const Cursor() : super(''); +// +// @override +// String buildString({required Color? cursorColor}) { +// if (cursorColor == null) { +// return ''; +// } +// final colorString = +// '#${(cursorColor.value & 0xFFFFFF).toRadixString(16).padLeft(6, '0')}'; +// return '\\textcolor{$colorString}{\\cursor}'; +// } +// } +// +// /// The state of a node when trying to navigate back- or forward. +// enum NavigationState { +// /// The upcoming tex expression in navigation direction is a function. +// func, +// +// /// The current courser position is already at the end. +// end, +// +// /// Navigating was successful. +// success, +// } +// +// /// How the argument is marked. +// enum TeXArg { +// /// { } +// /// +// /// In most of the cases, braces will be used. (E.g arguments of fractions). +// braces, +// +// /// [ ] +// /// +// /// Brackets are only used for the nth root at the moment. +// brackets, +// +// /// () +// /// +// /// Parentheses are used for base n logarithm right now, but could be used +// /// for functions like sin, cos, tan, etc. as well, so the user doesn't have +// /// to close the parentheses manually. +// parentheses, +// } diff --git a/lib/utils/custom_math_field_controller.dart b/lib/utils/custom_math_field_controller.dart index 34b28132..223d6cc0 100644 --- a/lib/utils/custom_math_field_controller.dart +++ b/lib/utils/custom_math_field_controller.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:math_keyboard/math_keyboard.dart'; class CustomMathFieldEditingController extends MathFieldEditingController { @@ -14,4 +15,21 @@ class CustomMathFieldEditingController extends MathFieldEditingController { } String get texStringAsFun => '\\($texString\\)'; + + @override + String currentEditingValue({bool placeholderWhenEmpty = true}) { + currentNode.removeCursor(); + // Store the expression as a TeX string. + final expression = root.buildTeXString( + // By passing null as the cursor color here, we are asserting + // that the cursor is not part of the tree in a way. + cursorColor: Colors.transparent, + placeholderWhenEmpty: placeholderWhenEmpty, + ); + currentNode.setCursor(); + final colorString = + '#${(Colors.transparent.value & 0xFFFFFF).toRadixString(16).padLeft(6, '0')}'; + var text = '\\textcolor{$colorString}{\\cursor}'; + return expression.replaceAll(text, ''); + } } diff --git a/lib/utils/plugins.dart b/lib/utils/plugins.dart index 7fe4b8a7..14c58869 100644 --- a/lib/utils/plugins.dart +++ b/lib/utils/plugins.dart @@ -34,7 +34,7 @@ class SummernoteAtMention extends Plugins { @override String getHeadString() { - return ''; + return ''; } @override diff --git a/lib/utils/toolbar.dart b/lib/utils/toolbar.dart index 6146ae8d..f3788ce4 100644 --- a/lib/utils/toolbar.dart +++ b/lib/utils/toolbar.dart @@ -216,4 +216,4 @@ class OtherButtons extends Toolbar { if (paste) icons.add(Icon(Icons.paste)); return icons; } -} \ No newline at end of file +} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 37c7449d..43100f9f 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -491,6 +491,7 @@ class _DropdownRouteResult { class _MenuLimits { const _MenuLimits(this.top, this.bottom, this.height, this.scrollOffset); + final double top; final double bottom; final double height; @@ -845,6 +846,7 @@ class _DropdownButtonState extends State> _DropdownRoute? _dropdownRoute; Orientation? _lastOrientation; FocusNode? _internalNode; + FocusNode? get focusNode => widget.focusNode ?? _internalNode; bool _hasPrimaryFocus = false; late Map> _actionMap; diff --git a/pubspec.yaml b/pubspec.yaml index dfdcfd59..dca106c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,12 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.1 +version: 2.6.3 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' flutter: ">=3.0.0" dependencies: @@ -47,15 +47,15 @@ dev_dependencies: flutter: assets: - - packages/html_editor_enhanced/assets/summernote.html - - packages/html_editor_enhanced/assets/summernote-no-plugins.html - - packages/html_editor_enhanced/assets/summernote-lite.min.css - - packages/html_editor_enhanced/assets/summernote-lite-dark.css - - packages/html_editor_enhanced/assets/summernote-lite.min.js - - packages/html_editor_enhanced/assets/jquery.min.js - - packages/html_editor_enhanced/assets/font/summernote.eot - - packages/html_editor_enhanced/assets/font/summernote.ttf - - packages/html_editor_enhanced/assets/plugins/summernote-at-mention/summernote-at-mention.js + - packages/html_editor_enhanced_fork_latex/assets/summernote.html + - packages/html_editor_enhanced_fork_latex/assets/summernote-no-plugins.html + - packages/html_editor_enhanced_fork_latex/assets/summernote-lite.min.css + - packages/html_editor_enhanced_fork_latex/assets/summernote-lite-dark.css + - packages/html_editor_enhanced_fork_latex/assets/summernote-lite.min.js + - packages/html_editor_enhanced_fork_latex/assets/jquery.min.js + - packages/html_editor_enhanced_fork_latex/assets/font/summernote.eot + - packages/html_editor_enhanced_fork_latex/assets/font/summernote.ttf + - packages/html_editor_enhanced_fork_latex/assets/plugins/summernote-at-mention/summernote-at-mention.js # This section identifies this Flutter project as a plugin project. # The 'pluginClass' and Android 'package' identifiers should not ordinarily # be modified. They are used by the tooling to maintain consistency when From 6811f48de6427173f11dc1b5ac5b63cd5c011e2b Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 15:02:03 +0200 Subject: [PATCH 12/29] changed version number --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index dca106c2..2f4718ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.3 +version: 2.6.4 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From 0e38855614c8a0a5c4d5b3d3d3a1ddc46fabfb62 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 15:37:16 +0200 Subject: [PATCH 13/29] changed version number --- CHANGELOG.md | 227 ++++++++++++++-------- lib/src/widgets/math_keyboard_dialog.dart | 1 - lib/src/widgets/toolbar_widget.dart | 2 +- pubspec.yaml | 2 +- 4 files changed, 151 insertions(+), 81 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fed830e..bf107741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.6.5] = 2023-12-20 + +* Version Name + ## [2.6.4] = 2023-12-20 * Fixed Cursor bug in math keyboard @@ -47,9 +51,10 @@ * Removed woff fonts to allow iOS App Store submissions ## [2.4.0] - 2021-10-30 + * Improved color picker - * Added scrollable support to picker - * Fixed issue where keyboard would disappear and prevent users from selecting a new color + * Added scrollable support to picker + * Fixed issue where keyboard would disappear and prevent users from selecting a new color * Added support for getting selected text in Flutter Web (`controller.getSelectedTextWeb()`) * Added support for spellcheck * Added support for custom options in summernote initialization @@ -59,6 +64,7 @@ * Updated dependencies and fixed flutter_colorpicker dependency error (@eliudio) ## [2.3.0] - 2021-09-09 + * Potentially fixed bad state error for `stream.first` * Fixed Summernote-@-Mention not inserting text after selecting the dropdown item * Fixed whitespace after @ sign when inserting a mention @@ -74,208 +80,273 @@ NOTE: If you are on Flutter Beta+, you must use `dependency_overrides` in `pubsp ```yaml dependency_overrides: - flutter_colorpicker: ^0.5.0 + flutter_colorpicker: ^0.5.0 ``` ## [2.2.0+1] - 2021-06-15 (BETA) + * Updated `flutter_colorpicker` to the latest version to fix deprecations on Flutter beta+ * [NOTE] Do not use this version on Flutter stable! ## [2.2.0] - 2021-06-14 + * Fixed null safety warnings due to latest `file_picker` version * Potentially fixed editor controller creating a new instance on widget rebuild * Fixed issue where custom HTML files would have custom JS replaced with built-in JS * Fixed darkMode not applying when `filePath` is used on Android * Fixed "null" text showing as the hint when no hint is given * Added new `onChangeSelection` callback that passes the editor settings whenever the user changes -their current selection (e.g. tap on a different word, create a new node, select text, etc) + their current selection (e.g. tap on a different word, create a new node, select text, etc) * Added support for custom JS injection on Flutter Web * Fixed minor bug with automatic height adjustment on mobile -* Added new `ToolbarType.nativeExpandable` which allows the user to switch between the -scrollview or gridview toolbar on the fly -* Support setting the `inputmode` for the editor, which changes the virtual keyboard display on mobile devices (e.g. number pad, email keyboard, etc) +* Added new `ToolbarType.nativeExpandable` which allows the user to switch between the + scrollview or gridview toolbar on the fly +* Support setting the `inputmode` for the editor, which changes the virtual keyboard display on + mobile devices (e.g. number pad, email keyboard, etc) * [BREAKING] renamed `onChange` callback to `onChangeContent` * [BREAKING] disabled a lot of the buttons by default, now only around half of the editor buttons -are enabled to improve the UX. You can still re-enable the rest if you want. + are enabled to improve the UX. You can still re-enable the rest if you want. * [BREAKING] min Flutter version requirement bumped to 2.2.0 ## [2.1.1] - 2021-05-22 + * Fixed bottom overflow error on `AlertDialog`s if the screen size is small * Fixed `StyleButtons(style: false)` would not remove the style dropdown * Fixed JS/Dart communication hiccup on Web (make sure `postMessage` data is not null) * Code cleanup ## [2.1.0+1] - 2021-05-11 + * Hotfix for `copyWith` not defined for `ScrollBehavior` in v2.1.0 ## [2.1.0] - 2021-05-10 + * Fixed `setState` and `Stream.first` error on page dispose * Fixed height adjustment not working * Fixed `getText` on Web -* Improved dropdown UX when `ToolbarPosition.belowEditor` by opening upwards and making it scrollable after a certain height +* Improved dropdown UX when `ToolbarPosition.belowEditor` by opening upwards and making it + scrollable after a certain height ## [2.0.1] - 2021-04-28 + * Added support for setting custom `UserScript`s on the webview (mobile only) -* Added support for customizing the context menu (menu when user selects text) for the webview (mobile only) -* Added `LongPressGestureRecognizer` to the webview to allow users to select text via a long press (mobile only) - * You can set the duration before the long press is recognized via `HtmlEditorOptions > mobileLongPressDuration` -* Added support for placing the toolbar wherever using `HtmlToolbarOptions > toolbarPosition: ToolbarPosition.custom` -* See the README if you'd like to use any of these new features. `UserScript` and the context menu customization have external documentation via flutter_inappwebview - the docs are linked in the README. +* Added support for customizing the context menu (menu when user selects text) for the webview ( + mobile only) +* Added `LongPressGestureRecognizer` to the webview to allow users to select text via a long press ( + mobile only) + * You can set the duration before the long press is recognized + via `HtmlEditorOptions > mobileLongPressDuration` +* Added support for placing the toolbar wherever + using `HtmlToolbarOptions > toolbarPosition: ToolbarPosition.custom` +* See the README if you'd like to use any of these new features. `UserScript` and the context menu + customization have external documentation via flutter_inappwebview - the docs are linked in the + README. ## [2.0.0+1] - 2021-04-22 -* Transitioned to fully native controls! These are extremely customizable and have much better UX than the previous controls. + +* Transitioned to fully native controls! These are extremely customizable and have much better UX + than the previous controls. * [BREAKING] refactored a lot of options into separate constructors * [BREAKING] refactored toolbar classes, so toolbar customizations will need updating * Added a bunch of interceptors and callbacks for button presses * Added the ability to make custom buttons and set their positions * Added native support for numerous Summernote plugins - * [BREAKING] removed all Summernote plugins except Summernote @ Mention. The package now supports the majority of plugins out of the box. - * Reduced package size by removing the Summernote plugin files - * Reduced size further by using a stripped-down version of Summernote @ Mention libs + * [BREAKING] removed all Summernote plugins except Summernote @ Mention. The package now + supports the majority of plugins out of the box. + * Reduced package size by removing the Summernote plugin files + * Reduced size further by using a stripped-down version of Summernote @ Mention libs * Added `execCommand` to controller to help you create custom toolbar buttons * Improved automatic height adjustment * Bumped dependencies * [BREAKING] Require Flutter 2.0.0+ * As always, see the README for full documentation on these changes -* See the [Migration Guide](https://github.com/tneotia/html-editor-enhanced/wiki/v2.0.0-Migration-Guide) for help migrating your v1.x.x widget code +* See + the [Migration Guide](https://github.com/tneotia/html-editor-enhanced/wiki/v2.0.0-Migration-Guide) + for help migrating your v1.x.x widget code ## [1.8.0] - 2021-04-07 -* Add support for `getSuggestionsMobile` (Summernote @ Mentions Plugin) - allows you to programatically return the list of mentions. - * Only supported on mobile. - * [BREAKING] renamed `mentions` to `mentionsWeb` as a result of this change + +* Add support for `getSuggestionsMobile` (Summernote @ Mentions Plugin) - allows you to + programatically return the list of mentions. + * Only supported on mobile. + * [BREAKING] renamed `mentions` to `mentionsWeb` as a result of this change * Added support for the remainder of Summernote callbacks: - * `onBeforeCommand` - * `onChangeCodeview` - * `onDialogShown` - * `onImageUploadError` - * `onMouseDown` - * `onMouseUp` - * `onScroll` - * See the README for how these work. + * `onBeforeCommand` + * `onChangeCodeview` + * `onDialogShown` + * `onImageUploadError` + * `onMouseDown` + * `onMouseUp` + * `onScroll` + * See the README for how these work. * Added a few new functions: - * recalculateHeight(): recalculates the editor height and applies it - * addNotification(): adds a notification bar to the bottom of the editor in a specified style with specified text - * removeNotification(): removes the current notification from the bottom of the editor + * recalculateHeight(): recalculates the editor height and applies it + * addNotification(): adds a notification bar to the bottom of the editor in a specified style + with specified text + * removeNotification(): removes the current notification from the bottom of the editor * Fixed blank space at the bottom of the editor when `showBottomToolbar: false` * Fixed 'Android resource linking failed' (bumped flutter_inappwebview to 5.3.1+1) ## [1.7.1] - 2021-03-26 -* Fixed bug where initial text would not be inserted and default toolbar would be shown regardless of editor options + +* Fixed bug where initial text would not be inserted and default toolbar would be shown regardless + of editor options * Significantly improved keyboard height detection (detect when keyboard comes up and goes down) -* Adjusted HTML processing algorithm to fix issues where `"` and `'` would not be properly escaped on HTML insertion - * Added `processNewLineAsBr` - this will replace any `\n` in the input string to `
` rather than the default `""` - * Applied processing to `setHint()` and `insertHtml()` functions +* Adjusted HTML processing algorithm to fix issues where `"` and `'` would not be properly escaped + on HTML insertion + * Added `processNewLineAsBr` - this will replace any `\n` in the input string to `
` rather + than the default `""` + * Applied processing to `setHint()` and `insertHtml()` functions * Added support for returning the file's base64 data in `onImageUpload` and `onFileUpload` - * Now you can use `MultipartFile.fromBytes()` to upload to server - [example](https://github.com/tneotia/html-editor-enhanced#example-for-onimageupload-and-onimagelinkinsert) + * Now you can use `MultipartFile.fromBytes()` to upload to + server - [example](https://github.com/tneotia/html-editor-enhanced#example-for-onimageupload-and-onimagelinkinsert) * Added support for `onFileUploadError` and `onFileLinkInsert` (Summernote File plugin) * Added support for `maximumFileSize` (Summernote File plugin) * See the README for more details on these changes ## [1.7.0+1] - 2021-03-22 + * Fixed `type 'double' is not a subtype of type 'int?' in type cast` on iOS - * By extension this fixes the `adjustHeightForKeyboard` not working on iOS -* Fixed `Bad state: Cannot add new events after calling close` exception when disposing the page containing the editor -* Fixed web page not found when inserting a video URL (see [here](https://github.com/summernote/summernote/issues/3252)) + * By extension this fixes the `adjustHeightForKeyboard` not working on iOS +* Fixed `Bad state: Cannot add new events after calling close` exception when disposing the page + containing the editor +* Fixed web page not found when inserting a video URL ( + see [here](https://github.com/summernote/summernote/issues/3252)) ## [1.7.0] - 2021-03-17 + * [BREAKING]: - * Refactored `height`, `autoAdjustHeight`, `decoration`, `showBottomToolbar`, and `darkMode` into new `HtmlEditorOptions` class - see README for how to migrate - * Removed 'Summernote Classes' plugin - * Sorry for all the breaking changes lately - I think I've finally figured out how I want to do the API design so there should be far less in future releases + * Refactored `height`, `autoAdjustHeight`, `decoration`, `showBottomToolbar`, and `darkMode` + into new `HtmlEditorOptions` class - see README for how to migrate + * Removed 'Summernote Classes' plugin + * Sorry for all the breaking changes lately - I think I've finally figured out how I want to do + the API design so there should be far less in future releases * Added `onImageUpload` callback that fires when an image is inserted via `` * Added `onImageLinkInsert` callback that fires when an image is inserted via URL -* Added `shouldEnsureVisible` that scrolls the editor into view when it is focused or text is typed, kind of like `TextField`s -* Added `adjustHeightForKeyboard` (default true) that adjusts the editor's height when the keyboard is active to ensure no content is cut off by the keyboard +* Added `shouldEnsureVisible` that scrolls the editor into view when it is focused or text is typed, + kind of like `TextField`s +* Added `adjustHeightForKeyboard` (default true) that adjusts the editor's height when the keyboard + is active to ensure no content is cut off by the keyboard * Added `filePath` which allows you to provide a completely custom HTML file to load -* If you plan on using any of the above, it is highly recommend looking at the README for more details and examples. -* Removed disabled scroll feature since it prevented the editor from scrolling even when the editor content was larger than the height +* If you plan on using any of the above, it is highly recommend looking at the README for more + details and examples. +* Removed disabled scroll feature since it prevented the editor from scrolling even when the editor + content was larger than the height * Code cleanup ## [1.6.0] - 2021-03-13 + * [BREAKING] removed `dispose()` method on controller - * The editor no longer uses a `Stream` to get text and therefore nothing needs to be disposed + * The editor no longer uses a `Stream` to get text and therefore nothing needs to be disposed * Added `onInit` callback that fires once the editor is ready to function and accept JS * Added a few new parameters: - * `autoAdjustHeight` - for `HtmlEditor`: default true, automatically adjusts the height of the editor to make sure scrolling is not necessary - * `processInputHtml` - for `HtmlEditorController`: processes input HTML (e.g. new lines become `
`) - * `processOutputHtml` - for `HtmlEditorController`: processes output HTML (e.g. `


` becomes `""`) + * `autoAdjustHeight` - for `HtmlEditor`: default true, automatically adjusts the height of the + editor to make sure scrolling is not necessary + * `processInputHtml` - for `HtmlEditorController`: processes input HTML (e.g. new lines + become `
`) + * `processOutputHtml` - for `HtmlEditorController`: processes output HTML (e.g. `


` + becomes `""`) * Added more plugins: - * Summernote Case Converter - * Summernote List Styles - * Summernote RTL - * Summernote @ Mention - * Summernote Codewrapper - * Summernote File - * See the README for more details. + * Summernote Case Converter + * Summernote List Styles + * Summernote RTL + * Summernote @ Mention + * Summernote Codewrapper + * Summernote File + * See the README for more details. * Added shim for dart:ui to remove the `ui.PlatformViewRegistry not found` error -* Added the summernote-no-plugins.html file to load a de-bloated HTML file when no plugins are active +* Added the summernote-no-plugins.html file to load a de-bloated HTML file when no plugins are + active * Fixed bug where two editors would be initialized in the same webview in some cases * Reduced the size of assets to ~650kb - ~300kb summernote libs, ~350kb plugin libs * Code cleanup ## [1.5.0+1] - 2021-03-10 + * Fixed getText() returning null on mobile for any device ## [1.5.0] - 2021-03-01 + * Nullsafety preview -* Added Flutter's Hybrid Composition to the HTML Editor. This significantly improves the keyboard experience on Android. +* Added Flutter's Hybrid Composition to the HTML Editor. This significantly improves the keyboard + experience on Android. ## [1.4.0] - 2021-03-01 -* [BREAKING] removed `HtmlParser` for calling methods, instead you now must pass an `HtmlEditorController` to the plugin (like a `TextField`). All methods are accessible from that controller. See the usage section in the README for an example. - * This allows you to have multiple independent editors on a page, whereas earlier the package would not know which editor the method should be called on. -* Add support for certain Summernote plugins from [Summernote Awesome](https://github.com/summernote/awesome-summernote). See the README for details on the API and the currently supported plugins. + +* [BREAKING] removed `HtmlParser` for calling methods, instead you now must pass + an `HtmlEditorController` to the plugin (like a `TextField`). All methods are accessible from that + controller. See the usage section in the README for an example. + * This allows you to have multiple independent editors on a page, whereas earlier the package + would not know which editor the method should be called on. +* Add support for certain Summernote plugins + from [Summernote Awesome](https://github.com/summernote/awesome-summernote). See the README for + details on the API and the currently supported plugins. * Nullsafety pre-release coming soon. ## [1.3.0] - 2021-02-23 + * Add official support for Flutter Web * Add support for modifying the toolbar options. See the README for details on the API. * Add support for a native dark mode -* Removed image_picker plugin and image button in toolbar because users can insert images via the image button in Summernote - * [BREAKING] Removed the `imageWidth` and `useBottomSheet` params due to the above change +* Removed image_picker plugin and image button in toolbar because users can insert images via the + image button in Summernote + * [BREAKING] Removed the `imageWidth` and `useBottomSheet` params due to the above change ## [1.2.0+1] - 2021-02-20 + * Add support for accessing `InAppWebViewController` via a getter * Add support for inserting files via the editor dialog itself * Add methods: - * toggle code view - * enable/disable editor - * undo/redo - * inserting plaintext/HTML/images/links + * toggle code view + * enable/disable editor + * undo/redo + * inserting plaintext/HTML/images/links * Add callbacks: - * onChange - * onEnter - * onFocus/onBlur/onBlurCodeview - * onKeyUp/onKeyDown - * onPaste + * onChange + * onEnter + * onFocus/onBlur/onBlurCodeview + * onKeyUp/onKeyDown + * onPaste * Downgraded dependencies to non-nullsafety to prevent errors -* Updated docs and example app to showcase new features, refer to those for info on the above changes +* Updated docs and example app to showcase new features, refer to those for info on the above + changes ## [1.1.1] - 2021-02-19 + * Minor update to add documentation to code and completely refactor/reorganize code ## [1.1.0] - 2021-02-19 + * Switch webview dependency to `flutter_inappwebview` -* Remove localserver, instead get Summernote HTML directly from assets (improves performance and loading speeds) +* Remove localserver, instead get Summernote HTML directly from assets (improves performance and + loading speeds) * [BREAKING] Switch to `StatelessWidget` - * You no longer need a `GlobalKey` for the `HtmlEditorState`. All of the methods are static and can be called like so: + * You no longer need a `GlobalKey` for the `HtmlEditorState`. All of the methods are static and + can be called like so: ```dart HtmlEditor.setEmpty(); ``` * Fix deprecations and update dependencies ## Flutter HTML Editor changes by xrb21 + ## [1.0.1] - 2020-05-07 + * Update Readme usage for iOS ## [1.0.0] - 2020-05-07 + * fixing iOS blank screen * fixing text hint ## [0.0.2+1] - 2020-05-02 + * fixing path packages ## [0.0.2] - 2020-05-02 + * Change link repo ## [0.0.1] - 2020-05-02 + * Initial Release \ No newline at end of file diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart index 0a205c99..c6e6dafd 100644 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -72,5 +72,4 @@ class MathKeyboardDialog extends StatelessWidget { ), ); } - } diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index a4298b30..0514c02f 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -1139,7 +1139,7 @@ class ToolbarWidgetState extends State { ColorPickerType.wheel: true, }, copyPasteBehavior: - const ColorPickerCopyPasteBehavior( + const ColorPickerCopyPasteBehavior( parseShortHexCode: true, ), actionButtons: const ColorPickerActionButtons( diff --git a/pubspec.yaml b/pubspec.yaml index 2f4718ee..be0b1528 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.4 +version: 2.6.5 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From 23ae82487a9e809100143fef854318420be571b9 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 15:39:23 +0200 Subject: [PATCH 14/29] changed version number --- lib/utils/custom_classes.dart | 270 ---------------------------------- 1 file changed, 270 deletions(-) delete mode 100644 lib/utils/custom_classes.dart diff --git a/lib/utils/custom_classes.dart b/lib/utils/custom_classes.dart deleted file mode 100644 index 331ddc36..00000000 --- a/lib/utils/custom_classes.dart +++ /dev/null @@ -1,270 +0,0 @@ -// import 'dart:ui'; -// -// import 'package:flutter/foundation.dart'; -// import 'package:math_keyboard/src/foundation/node.dart' as mk; -// -// /// Block representing a node of TeX. -// class TeXNode { -// /// Constructs a [TeXNode]. -// TeXNode(this.parent); -// -// /// The parent of the node. -// TeXFunction? parent; -// -// /// The courser position in this node. -// int courserPosition = 0; -// -// /// A block can have one or more child blocks. -// final List children = []; -// -// /// Sets the courser to the actual position. -// void setCursor() { -// children.insert(courserPosition, const Cursor()); -// } -// -// /// Removes the courser. -// void removeCursor() { -// children.removeAt(courserPosition); -// } -// -// /// Returns whether the last child node is the cursor. -// /// -// /// This does *not* traverse the children recursively as that might not be -// /// a guarantee for visually being all the way on the right with the cursor. -// /// Imagine a `\frac` node with a horizontally long string in the nominator: -// /// now, when the cursor is at the end, it is not visually on the right of the -// /// node as the denominator might not even be visible when scrolling to the -// /// right. -// bool cursorAtTheEnd() { -// if (children.isEmpty) return false; -// if (children.last is Cursor) return true; -// -// return false; -// } -// -// /// Shift courser to the left. -// NavigationState shiftCursorLeft() { -// if (courserPosition == 0) { -// return NavigationState.end; -// } -// removeCursor(); -// courserPosition--; -// if (children[courserPosition] is TeXFunction) { -// return NavigationState.func; -// } -// setCursor(); -// return NavigationState.success; -// } -// -// /// Shift courser to the right. -// NavigationState shiftCursorRight() { -// if (courserPosition == children.length - 1) { -// return NavigationState.end; -// } -// removeCursor(); -// courserPosition++; -// if (children[courserPosition - 1] is TeXFunction) { -// return NavigationState.func; -// } -// setCursor(); -// return NavigationState.success; -// } -// -// /// Adds a new node. -// void addTeX(TeX teX) { -// children.insert(courserPosition, teX); -// courserPosition++; -// } -// -// /// Removes the last node. -// NavigationState remove() { -// if (courserPosition == 0) { -// return NavigationState.end; -// } -// removeCursor(); -// courserPosition--; -// if (children[courserPosition] is TeXFunction) { -// return NavigationState.func; -// } -// children.removeAt(courserPosition); -// setCursor(); -// return NavigationState.success; -// } -// -// /// Builds the TeX representation of this node. -// /// -// /// This includes the representation of the children of the node. -// /// -// /// Returns the TeX expression as a [String]. -// static String buildTeXStringFromMathKeyboard({ -// Color? cursorColor, -// bool placeholderWhenEmpty = true, -// required mk.TeXNode root, -// }) { -// if (root.children.isEmpty) { -// return placeholderWhenEmpty ? '\\Box' : ''; -// } -// final buffer = StringBuffer(); -// for (final tex in root.children) { -// buffer.write(tex.buildString(cursorColor: cursorColor)); -// } -// return buffer.toString(); -// } -// -// String buildTeXString({ -// Color? cursorColor, -// bool placeholderWhenEmpty = true, -// }) { -// if (children.isEmpty) { -// return placeholderWhenEmpty ? '\\Box' : ''; -// } -// final buffer = StringBuffer(); -// for (final tex in children) { -// buffer.write(tex.buildString(cursorColor: cursorColor)); -// } -// return buffer.toString(); -// } -// } -// -// /// Class holding a TeX function. -// class TeXFunction extends TeX { -// /// Constructs a [TeXFunction]. -// /// -// /// [argNodes] can be passed directly if the nodes are already known. In that -// /// case, the [TeXNode.parent] is set in the constructor body. If [argNodes] -// /// is passed empty (default), empty [TeXNode]s will be inserted for each -// /// arg. -// TeXFunction(String expression, this.parent, this.args, -// [List? argNodes]) -// : assert(args.isNotEmpty, 'A function needs at least one argument.'), -// assert(argNodes == null || argNodes.length == args.length), -// argNodes = argNodes ?? List.empty(growable: true), -// super(expression) { -// if (this.argNodes.isEmpty) { -// for (var i = 0; i < args.length; i++) { -// this.argNodes.add(TeXNode(this)); -// } -// } else { -// for (final node in this.argNodes) { -// node.parent = this; -// } -// } -// } -// -// /// The functions parent node. -// TeXNode parent; -// -// /// The delimiters of the arguments. -// final List args; -// -// /// The arguments to this function. -// final List argNodes; -// -// /// Returns the opening character for a function argument. -// String openingChar(TeXArg type) { -// switch (type) { -// case TeXArg.braces: -// return '{'; -// case TeXArg.brackets: -// return '['; -// default: -// return '('; -// } -// } -// -// /// Returns the closing character for a function argument. -// String closingChar(TeXArg type) { -// switch (type) { -// case TeXArg.braces: -// return '}'; -// case TeXArg.brackets: -// return ']'; -// default: -// return ')'; -// } -// } -// -// @override -// String buildString({Color? cursorColor}) { -// final buffer = StringBuffer(expression); -// for (var i = 0; i < args.length; i++) { -// buffer.write(openingChar(args[i])); -// buffer.write(argNodes[i].buildTeXString( -// cursorColor: cursorColor, -// )); -// buffer.write(closingChar(args[i])); -// } -// return buffer.toString(); -// } -// } -// -// /// Class holding a single TeX expression. -// class TeXLeaf extends TeX { -// /// Constructs a [TeXLeaf]. -// const TeXLeaf(String expression) : super(expression); -// -// @override -// String buildString({Color? cursorColor}) { -// return expression; -// } -// } -// -// /// Class holding TeX. -// abstract class TeX { -// /// Constructs a [TeX]. -// const TeX(this.expression); -// -// /// The expression of this TeX -// final String expression; -// -// /// Builds the string representation of this TeX expression. -// String buildString({required Color? cursorColor}); -// } -// -// /// Class describing the cursor as a TeX expression. -// class Cursor extends TeX { -// /// Creates a TeX [Cursor]. -// const Cursor() : super(''); -// -// @override -// String buildString({required Color? cursorColor}) { -// if (cursorColor == null) { -// return ''; -// } -// final colorString = -// '#${(cursorColor.value & 0xFFFFFF).toRadixString(16).padLeft(6, '0')}'; -// return '\\textcolor{$colorString}{\\cursor}'; -// } -// } -// -// /// The state of a node when trying to navigate back- or forward. -// enum NavigationState { -// /// The upcoming tex expression in navigation direction is a function. -// func, -// -// /// The current courser position is already at the end. -// end, -// -// /// Navigating was successful. -// success, -// } -// -// /// How the argument is marked. -// enum TeXArg { -// /// { } -// /// -// /// In most of the cases, braces will be used. (E.g arguments of fractions). -// braces, -// -// /// [ ] -// /// -// /// Brackets are only used for the nth root at the moment. -// brackets, -// -// /// () -// /// -// /// Parentheses are used for base n logarithm right now, but could be used -// /// for functions like sin, cos, tan, etc. as well, so the user doesn't have -// /// to close the parentheses manually. -// parentheses, -// } From 2d3f53ab7f5fd6311f0bfd7439b4aa9852445cc8 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 20 Dec 2023 16:29:58 +0200 Subject: [PATCH 15/29] changed version number --- CHANGELOG.md | 4 ++++ lib/src/widgets/custom_html_editor.dart | 5 ----- pubspec.yaml | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf107741..7156968a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.6.6] = 2023-12-20 + +* Image Upload was turned off, now its on + ## [2.6.5] = 2023-12-20 * Version Name diff --git a/lib/src/widgets/custom_html_editor.dart b/lib/src/widgets/custom_html_editor.dart index f12cfbfe..cb9f6a04 100644 --- a/lib/src/widgets/custom_html_editor.dart +++ b/lib/src/widgets/custom_html_editor.dart @@ -43,11 +43,6 @@ class CustomHtmlEditorWidget extends StatelessWidget { //by default onButtonPressed: (ButtonType type, bool? status, Function? updateStatus) { - if (type.name == ButtonType.picture.name) { - print('no image'); - controller.insertHtml(tableTex); - return false; - } print( "button '${type.name}' pressed, the current selected status is $status"); return true; diff --git a/pubspec.yaml b/pubspec.yaml index be0b1528..bb6032de 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.5 +version: 2.6.6 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From d31e8fccba27ee3ebe7ba2e49f42f1cdbcd8a414 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Sun, 24 Dec 2023 09:20:26 +0200 Subject: [PATCH 16/29] updated performance --- CHANGELOG.md | 4 + example/lib/main.dart | 154 ++++++++++++++++++++++------ example/pubspec.lock | 10 +- example/pubspec.yaml | 2 +- lib/src/widgets/toolbar_widget.dart | 37 +++++-- pubspec.yaml | 2 +- 6 files changed, 162 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7156968a..d55b05f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.6.7] = 2023-12-20 + +* improved performance + ## [2.6.6] = 2023-12-20 * Image Upload was turned off, now its on diff --git a/example/lib/main.dart b/example/lib/main.dart index cfac4eae..37479a61 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,7 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; void main() => runApp(HtmlEditorExampleApp()); @@ -14,10 +15,95 @@ class HtmlEditorExampleApp extends StatelessWidget { theme: ThemeData(), darkTheme: ThemeData.dark(), home: HtmlEditorExample(title: 'Flutter HTML Editor Example'), + // home: MyApp2(title: 'Flutter HTML Editor Example'), ); } } +class MyApp2 extends StatelessWidget { + final String title; + + MyApp2({Key? key, required this.title}) : super(key: key); + final HtmlEditorController controller = HtmlEditorController(); + final HtmlEditorController controller2 = HtmlEditorController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SingleChildScrollView( + child: Column( + children: [ + tb(controller), + tb(controller2), + ], + ), + ), + appBar: AppBar( + title: Text(this.title), + ), + ); + } + + Widget tb(HtmlEditorController controller) { + var isVisible = false.obs; + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Obx( + () => isVisible.value + ? ToolbarWidget( + controller: controller, + htmlToolbarOptions: HtmlToolbarOptions( + toolbarType: kIsWeb + ? ToolbarType.nativeGrid + : ToolbarType.nativeScrollable, + toolbarPosition: ToolbarPosition + .custom, //required to place toolbar anywhere! + //other options + ), + callbacks: null) + : IconButton( + onPressed: () { + controller.insertHtml( + r'yy'); + }, + icon: Icon(Icons.functions_outlined)), + ), + //other widgets here + HtmlEditor( + controller: controller, + callbacks: Callbacks( + onBlur: () { + print('onBlur'); + isVisible.value = false; + }, + onNavigationRequestMobile: (s) async { + print('on NavReq to $s'); + return NavigationActionPolicy.ALLOW; + }, + onDialogShown: () => print('onDialogOpen'), + onFocus: () { + print('onFocus'); + isVisible.value = true; + }, + ), + htmlEditorOptions: HtmlEditorOptions( + hint: 'Your text here...', + shouldEnsureVisible: true, + //initialText: "

text content initial, if any

", + ), + htmlToolbarOptions: HtmlToolbarOptions( + toolbarPosition: + ToolbarPosition.custom, // required to place toolbar anywhere! + + //other options + ), + otherOptions: OtherOptions(height: 550), + ), + ]); + } +} + class HtmlEditorExample extends StatefulWidget { HtmlEditorExample({Key? key, required this.title}) : super(key: key); @@ -74,8 +160,10 @@ class _HtmlEditorExampleState extends State { //initialText: "

text content initial, if any

", ), htmlToolbarOptions: HtmlToolbarOptions( - toolbarPosition: ToolbarPosition.aboveEditor, //by default - toolbarType: ToolbarType.nativeScrollable, //by default + toolbarPosition: ToolbarPosition.aboveEditor, + //by default + toolbarType: ToolbarType.nativeScrollable, + //by default onButtonPressed: (ButtonType type, bool? status, Function? updateStatus) { print( @@ -135,7 +223,7 @@ class _HtmlEditorExampleState extends State { },*/ onImageUploadError: (FileUpload? file, String? base64Str, UploadError error) { - print((error.name)); + print((error.name)); print(base64Str ?? ''); if (file != null) { print(file.name); @@ -143,23 +231,23 @@ class _HtmlEditorExampleState extends State { print(file.type); } }, onKeyDown: (int? keyCode) { - print('$keyCode key downed'); - print( - 'current character count: ${controller.characterCount}'); - }, onKeyUp: (int? keyCode) { - print('$keyCode key released'); - }, onMouseDown: () { - print('mouse downed'); - }, onMouseUp: () { - print('mouse released'); - }, onNavigationRequestMobile: (String url) { - print(url); - return NavigationActionPolicy.ALLOW; - }, onPaste: () { - print('pasted into editor'); - }, onScroll: () { - print('editor scrolled'); - }), + print('$keyCode key downed'); + print( + 'current character count: ${controller.characterCount}'); + }, onKeyUp: (int? keyCode) { + print('$keyCode key released'); + }, onMouseDown: () { + print('mouse downed'); + }, onMouseUp: () { + print('mouse released'); + }, onNavigationRequestMobile: (String url) { + print(url); + return NavigationActionPolicy.ALLOW; + }, onPaste: () { + print('pasted into editor'); + }, onScroll: () { + print('editor scrolled'); + }), plugins: [ SummernoteAtMention( getSuggestionsMobile: (String value) { @@ -186,7 +274,7 @@ class _HtmlEditorExampleState extends State { controller.undo(); }, child: - Text('Undo', style: TextStyle(color: Colors.white)), + Text('Undo', style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -198,7 +286,7 @@ class _HtmlEditorExampleState extends State { controller.clear(); }, child: - Text('Reset', style: TextStyle(color: Colors.white)), + Text('Reset', style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -206,7 +294,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { var txt = await controller.getHtmlStringWithLatex(); if (txt.contains('src=\"data:')) { @@ -228,7 +316,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.redo(); }, @@ -264,7 +352,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.enable(); }, @@ -285,7 +373,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.insertText('Google'); }, @@ -298,7 +386,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.insertHtml( '''

Google in blue

'''); @@ -317,7 +405,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.insertLink( 'Google linked', 'https://google.com', true); @@ -333,7 +421,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.insertNetworkImage( 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png', @@ -361,7 +449,7 @@ class _HtmlEditorExampleState extends State { 'Info notification', NotificationType.info); }, child: - Text('Info', style: TextStyle(color: Colors.white)), + Text('Info', style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -382,7 +470,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.addNotification( 'Success notification', NotificationType.success); @@ -398,7 +486,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () { controller.addNotification( 'Danger notification', NotificationType.danger); @@ -433,7 +521,7 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: - Theme.of(context).colorScheme.secondary), + Theme.of(context).colorScheme.secondary), onPressed: () async { controller.removeNotification(); }, diff --git a/example/pubspec.lock b/example/pubspec.lock index f9666903..fddf3045 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -197,6 +197,14 @@ packages: description: flutter source: sdk version: "0.0.0" + get: + dependency: "direct main" + description: + name: get + sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e + url: "https://pub.dev" + source: hosted + version: "4.6.6" holding_gesture: dependency: transitive description: @@ -211,7 +219,7 @@ packages: path: ".." relative: true source: path - version: "2.6.3" + version: "2.6.7" infinite_listview: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9e5b1cf9..b1d8abe8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: flutter: sdk: flutter - + get: ^4.0.0 html_editor_enhanced_fork_latex: # When depending on this package from a real application you should use: # html_editor_enhanced: ^x.y.z diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index 0514c02f..9a688d15 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -95,6 +95,8 @@ class ToolbarWidgetState extends State { /// Tracks the expanded status of the toolbar bool _isExpanded = false; final HashMap _latexMap = HashMap(); + var _completer = Completer(); + var _webController = WebViewController(); @override void initState() { @@ -118,9 +120,21 @@ class ToolbarWidgetState extends State { _alignSelected = List.filled(t.getIcons1().length, false); } } + _initWebController(); super.initState(); } + _initWebController() async { + await _webController.setJavaScriptMode(JavaScriptMode.unrestricted); + await _webController.addJavaScriptChannel('MathMLChannel', + onMessageReceived: (JavaScriptMessage message) { + print('Received message: ${message.message}'); + _completer.complete(message.message); + _completer = Completer(); + }); + WebViewWidget(controller: _webController); + } + void disable() { setState(mounted, this.setState, () { _enabled = false; @@ -2612,9 +2626,17 @@ class ToolbarWidgetState extends State { true; if (proceed) { final c = CustomMathFieldEditingController(); + if (!kIsWeb) { + widget.controller.clearFocus(); + } + await showDialog( context: context, builder: (context) => MathKeyboardDialog(controller: c)); + if (!kIsWeb) { + widget.controller.setFocus(); + } + var math = c.texString; if (math != '') { var texAsFun = c.texStringAsFun; @@ -2626,6 +2648,7 @@ class ToolbarWidgetState extends State { }); widget.controller.addToHashMap(result, texAsFun); widget.controller.insertHtml(result); + widget.controller.insertText(' '); } } } @@ -3029,16 +3052,7 @@ class ToolbarWidgetState extends State { } Future _latexToHtml(String latex) async { - var completer = Completer(); - var controller = WebViewController(); - await controller.setJavaScriptMode(JavaScriptMode.unrestricted); - await controller.addJavaScriptChannel('MathMLChannel', - onMessageReceived: (JavaScriptMessage message) { - print('Received message: ${message.message}'); - completer.complete(message.message); - }); - WebViewWidget(controller: controller); - await controller.runJavaScript(''' + await _webController.runJavaScript(''' (async () => { try { const mathlive = await import("https://unpkg.com/mathlive?module"); @@ -3049,6 +3063,7 @@ class ToolbarWidgetState extends State { } })(); '''); - return completer.future; + + return _completer.future; } } diff --git a/pubspec.yaml b/pubspec.yaml index bb6032de..3483615e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.6 +version: 2.6.7 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From bf190ec103d70c813cb008485a5d7f1a446f67fb Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Wed, 27 Dec 2023 12:47:59 +0200 Subject: [PATCH 17/29] math keyboard is now customizable --- CHANGELOG.md | 4 + example/lib/main.dart | 10 +- example/lib/two_editors.dart | 199 ++++++++++++++++++ example/pubspec.lock | 4 +- example/pubspec.yaml | 1 + lib/src/html_editor_controller_mobile.dart | 3 + .../html_editor_controller_unsupported.dart | 3 + lib/src/html_editor_controller_web.dart | 2 +- lib/src/widgets/math_keyboard_dialog.dart | 2 + lib/src/widgets/toolbar_widget.dart | 6 +- pubspec.yaml | 2 +- 11 files changed, 229 insertions(+), 7 deletions(-) create mode 100644 example/lib/two_editors.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index d55b05f8..a305a8d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [2.6.7] = 2023-12-20 +* customizable math keyboard + +## [2.6.7] = 2023-12-20 + * improved performance ## [2.6.6] = 2023-12-20 diff --git a/example/lib/main.dart b/example/lib/main.dart index 37479a61..c2536750 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,6 +3,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:math_keyboard/math_keyboard.dart'; void main() => runApp(HtmlEditorExampleApp()); @@ -24,7 +25,14 @@ class MyApp2 extends StatelessWidget { final String title; MyApp2({Key? key, required this.title}) : super(key: key); - final HtmlEditorController controller = HtmlEditorController(); + late final HtmlEditorController controller = HtmlEditorController( + mathField: MathField( + autofocus: true, + keyboardType: MathKeyboardType.numberOnly, + variables: ['x', 'y', 'z', 'A', 'B', 'C'], + opensKeyboard: true, + ), + ); final HtmlEditorController controller2 = HtmlEditorController(); @override diff --git a/example/lib/two_editors.dart b/example/lib/two_editors.dart new file mode 100644 index 00000000..eee38188 --- /dev/null +++ b/example/lib/two_editors.dart @@ -0,0 +1,199 @@ +import 'package:flutter/material.dart'; +import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; + +class EditorWithFocusChange extends StatefulWidget { + const EditorWithFocusChange(); + + @override + createState() => _EditorWithFocusChangeState(); +} + +class _EditorWithFocusChangeState extends State { + final HtmlEditorController controller = HtmlEditorController(); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + VisibleToolbar(controller: controller), + HtmlEditor( + controller: controller, + htmlEditorOptions: HtmlEditorOptions( + hint: 'Your text here...', + shouldEnsureVisible: true, + //initialText: "

text content initial, if any

", + ), + htmlToolbarOptions: HtmlToolbarOptions( + toolbarPosition: ToolbarPosition.custom, + // toolbarType: ToolbarType.nativeScrollable, + // onButtonPressed: + // (ButtonType type, bool? status, Function? updateStatus) { + // print( + // "button '${(type.name)}' pressed, the current selected status is $status"); + // return true; + // }, + // onDropdownChanged: (DropdownType type, dynamic changed, + // Function(dynamic)? updateSelectedItem) { + // print("dropdown '${(type.name)}' changed to $changed"); + // return true; + // }, + // mediaLinkInsertInterceptor: (String url, InsertFileType type) { + // print(url); + // return true; + // }, + // mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async { + // print(file.name); //filename + // print(file.size); //size in bytes + // print(file.extension); //file extension (eg jpeg or mp4) + // return true; + // }, + ), + otherOptions: OtherOptions(height: 550), + plugins: [ + SummernoteAtMention( + getSuggestionsMobile: (String value) { + var mentions = ['test1', 'test2', 'test3']; + return mentions + .where((element) => element.contains(value)) + .toList(); + }, + mentionsWeb: ['test1', 'test2', 'test3'], + onSelect: (String value) { + print(value); + }, + ), + ], + ), + ], + ); + } +} + +class VisibleToolbar extends StatefulWidget { + const VisibleToolbar({required this.controller}); + + final HtmlEditorController controller; + + @override + State createState() => _VisibleToolbarState(); +} + +class _VisibleToolbarState extends State { + bool _isVisible = false; + + @override + Widget build(BuildContext context) { + return Visibility( + visible: _isVisible, + child: ToolbarWidget( + controller: widget.controller, + htmlToolbarOptions: HtmlToolbarOptions( + toolbarPosition: ToolbarPosition.custom, + toolbarType: ToolbarType.nativeScrollable, + defaultToolbarButtons: const [ + StyleButtons(), + FontSettingButtons(fontSizeUnit: false, fontName: false), + FontButtons(clearAll: false), + ColorButtons(highlightColor: false), + ListButtons(listStyles: false), + ParagraphButtons( + textDirection: false, + lineHeight: false, + caseConverter: false, + alignJustify: false), + InsertButtons( + video: false, + link: false, + audio: false, + table: true, + hr: true, + otherFile: false), + ], + ), + callbacks: Callbacks( + onBeforeCommand: (String? currentHtml) { + print('html before change is $currentHtml'); + }, + onChangeContent: (String? changed) { + print('content changed to $changed'); + }, + onChangeCodeview: (String? changed) { + print('code changed to $changed'); + }, + onChangeSelection: (EditorSettings settings) { + print('parent element is ${settings.parentElement}'); + print('font name is ${settings.fontName}'); + }, + onDialogShown: () { + print('dialog shown'); + }, + onEnter: () { + print('enter/return pressed'); + }, + onFocus: () { + setState(() { + _isVisible = true; + }); + print('editor focused'); + }, + onBlur: () { + setState(() { + _isVisible = false; + }); + print('editor unfocused'); + }, + onBlurCodeview: () { + print('codeview either focused or unfocused'); + }, + onInit: () { + print('init'); + }, + //this is commented because it overrides the default Summernote handlers + /*onImageLinkInsert: (String? url) { + print(url ?? "unknown url"); + }, + onImageUpload: (FileUpload file) async { + print(file.name); + print(file.size); + print(file.type); + print(file.base64); + },*/ + onImageUploadError: + (FileUpload? file, String? base64Str, UploadError error) { + print((error.name)); + print(base64Str ?? ''); + if (file != null) { + print(file.name); + print(file.size); + print(file.type); + } + }, + onKeyDown: (int? keyCode) { + print('$keyCode key downed'); + print( + 'current character count: ${widget.controller.characterCount}'); + }, + onKeyUp: (int? keyCode) { + print('$keyCode key released'); + }, + onMouseDown: () { + print('mouse downed'); + }, + onMouseUp: () { + print('mouse released'); + }, + onNavigationRequestMobile: (String url) { + print(url); + return NavigationActionPolicy.ALLOW; + }, + onPaste: () { + print('pasted into editor'); + }, + onScroll: () { + print('editor scrolled'); + }, + ), + ), + ); + } +} diff --git a/example/pubspec.lock b/example/pubspec.lock index fddf3045..158464ae 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -219,7 +219,7 @@ packages: path: ".." relative: true source: path - version: "2.6.7" + version: "2.6.8" infinite_listview: dependency: transitive description: @@ -269,7 +269,7 @@ packages: source: hosted version: "2.4.0" math_keyboard: - dependency: transitive + dependency: "direct main" description: name: math_keyboard sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b1d8abe8..6872fce4 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: flutter: sdk: flutter get: ^4.0.0 + math_keyboard: ^0.2.1 html_editor_enhanced_fork_latex: # When depending on this package from a real application you should use: # html_editor_enhanced: ^x.y.z diff --git a/lib/src/html_editor_controller_mobile.dart b/lib/src/html_editor_controller_mobile.dart index 6033e7fe..451caa86 100644 --- a/lib/src/html_editor_controller_mobile.dart +++ b/lib/src/html_editor_controller_mobile.dart @@ -4,6 +4,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' as unsupported; +import 'package:math_keyboard/math_keyboard.dart'; /// Controller for mobile class HtmlEditorController extends unsupported.HtmlEditorController { @@ -11,6 +12,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { this.processInputHtml = true, this.processNewLineAsBr = false, this.processOutputHtml = true, + this.mathField, }); /// Toolbar widget state to call various methods. For internal use only. @@ -38,6 +40,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { /// The default value is true. @override final bool processOutputHtml; + final MathField? mathField; /// Manages the [InAppWebViewController] for the [HtmlEditorController] InAppWebViewController? _editorController; diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index e69be568..585ec91a 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,6 +1,7 @@ import 'dart:collection'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; +import 'package:math_keyboard/math_keyboard.dart'; import 'package:meta/meta.dart'; /// Fallback controller (should never be used) @@ -9,6 +10,7 @@ class HtmlEditorController { this.processInputHtml = true, this.processNewLineAsBr = false, this.processOutputHtml = true, + this.mathField, }); final HashMap _latexMap = HashMap(); @@ -66,6 +68,7 @@ class HtmlEditorController { /// /// The default value is true. final bool processOutputHtml; + final MathField? mathField; /// Internally tracks the character count in the editor int _characterCount = 0; diff --git a/lib/src/html_editor_controller_web.dart b/lib/src/html_editor_controller_web.dart index 2f7e826d..308e5dd1 100644 --- a/lib/src/html_editor_controller_web.dart +++ b/lib/src/html_editor_controller_web.dart @@ -14,7 +14,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { this.processInputHtml = true, this.processNewLineAsBr = false, this.processOutputHtml = true, - }); + }) : super(mathField: null); /// Toolbar widget state to call various methods. For internal use only. @override diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart index c6e6dafd..4e6d3fdb 100644 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -32,6 +32,8 @@ class MathKeyboardDialog extends StatelessWidget { focusNode: mathField?.focusNode, autofocus: mathField?.autofocus ?? true, controller: controller, + keyboardType: + mathField?.keyboardType ?? MathKeyboardType.expression, variables: mathField?.variables ?? ['x', 'y', 'z', 'A', 'B', 'C'], decoration: mathField?.decoration ?? diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index 9a688d15..dc73e487 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -2632,11 +2632,13 @@ class ToolbarWidgetState extends State { await showDialog( context: context, - builder: (context) => MathKeyboardDialog(controller: c)); + builder: (context) => MathKeyboardDialog( + controller: c, + mathField: widget.controller.mathField, + )); if (!kIsWeb) { widget.controller.setFocus(); } - var math = c.texString; if (math != '') { var texAsFun = c.texStringAsFun; diff --git a/pubspec.yaml b/pubspec.yaml index 3483615e..9d68e2e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.7 +version: 2.6.8 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From 3895f1e089aa3d438c42d44909224425a5cfcab1 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Thu, 28 Dec 2023 16:13:29 +0200 Subject: [PATCH 18/29] math keyboard is now customizable --- lib/src/widgets/toolbar_widget.dart | 56 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index dc73e487..ca66bc8e 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -2625,33 +2625,7 @@ class ToolbarWidgetState extends State { ?.call(ButtonType.fn, null, null) ?? true; if (proceed) { - final c = CustomMathFieldEditingController(); - if (!kIsWeb) { - widget.controller.clearFocus(); - } - - await showDialog( - context: context, - builder: (context) => MathKeyboardDialog( - controller: c, - mathField: widget.controller.mathField, - )); - if (!kIsWeb) { - widget.controller.setFocus(); - } - var math = c.texString; - if (math != '') { - var texAsFun = c.texStringAsFun; - var result = - await _latexToHtml(math.replaceAll('\\', '\\\\')); - result = '$result'; - _latexMap.addAll({ - result: texAsFun, - }); - widget.controller.addToHashMap(result, texAsFun); - widget.controller.insertHtml(result); - widget.controller.insertText(' '); - } + await openMathDialog(); } } }, @@ -3053,6 +3027,34 @@ class ToolbarWidgetState extends State { return toolbarChildren; } + openMathDialog() async { + final c = CustomMathFieldEditingController(); + if (!kIsWeb) { + widget.controller.clearFocus(); + } + await showDialog( + context: context, + builder: (context) => MathKeyboardDialog( + controller: c, + mathField: widget.controller.mathField, + )); + if (!kIsWeb) { + widget.controller.setFocus(); + } + var math = c.texString; + if (math != '') { + var texAsFun = c.texStringAsFun; + var result = await _latexToHtml(math.replaceAll('\\', '\\\\')); + result = '$result'; + _latexMap.addAll({ + result: texAsFun, + }); + widget.controller.addToHashMap(result, texAsFun); + widget.controller.insertHtml(result); + widget.controller.insertText(' '); + } + } + Future _latexToHtml(String latex) async { await _webController.runJavaScript(''' (async () => { From 86fda78e286ccfc51d02cdbfd16b6741fc01a577 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Sun, 31 Dec 2023 12:08:23 +0200 Subject: [PATCH 19/29] math keyboard is now customizable --- CHANGELOG.md | 4 + .../html_editor_controller_unsupported.dart | 66 +++++++++++- lib/src/widgets/toolbar_widget.dart | 100 ++++++++---------- 3 files changed, 115 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a305a8d4..75d37706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.6.8] = 2023-12-31 + +* moved the math keyboard to the controller + ## [2.6.7] = 2023-12-20 * customizable math keyboard diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index 585ec91a..aeccfcf7 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,8 +1,14 @@ +import 'dart:async'; import 'dart:collection'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:math_keyboard/math_keyboard.dart'; import 'package:meta/meta.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +import '../utils/custom_math_field_controller.dart'; /// Fallback controller (should never be used) class HtmlEditorController { @@ -13,8 +19,66 @@ class HtmlEditorController { this.mathField, }); + var _completer = Completer(); + var _webController = WebViewController(); + final HashMap _latexMap = HashMap(); + initWebController() async { + await _webController.setJavaScriptMode(JavaScriptMode.unrestricted); + await _webController.addJavaScriptChannel('MathMLChannel', + onMessageReceived: (JavaScriptMessage message) { + print('Received message: ${message.message}'); + _completer.complete(message.message); + _completer = Completer(); + }); + WebViewWidget(controller: _webController); + } + + openMathDialog(BuildContext context) async { + final c = CustomMathFieldEditingController(); + if (!kIsWeb) { + this.clearFocus(); + } + await showDialog( + context: context, + builder: (context) => MathKeyboardDialog( + controller: c, + mathField: this.mathField, + )); + if (!kIsWeb) { + this.setFocus(); + } + var math = c.texString; + if (math != '') { + var texAsFun = c.texStringAsFun; + var result = await _latexToHtml(math.replaceAll('\\', '\\\\')); + result = '$result'; + _latexMap.addAll({ + result: texAsFun, + }); + this.addToHashMap(result, texAsFun); + this.insertHtml(result); + this.insertText(' '); + } + } + + Future _latexToHtml(String latex) async { + await _webController.runJavaScript(''' + (async () => { + try { + const mathlive = await import("https://unpkg.com/mathlive?module"); + const mathML = mathlive.convertLatexToMathMl('\$\$$latex\$\$'); + MathMLChannel.postMessage(mathML); + } catch (error) { + console.error('Error:', error); + } + })(); + '''); + + return _completer.future; + } + void addToHashMap(String key, String value) { _latexMap.addAll({ key: value, @@ -122,7 +186,7 @@ class HtmlEditorController { /// A function to execute JS passed as a [WebScript] to the editor. This should /// only be used on Flutter Web. Future evaluateJavascriptWeb(String name, - {bool hasReturnValue = false}) => + {bool hasReturnValue = false}) => Future.value(); /// Gets the text from the editor and returns it as a [String]. diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index ca66bc8e..42926c4e 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -8,7 +8,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; -import 'package:html_editor_enhanced_fork_latex/utils/custom_math_field_controller.dart'; import 'package:html_editor_enhanced_fork_latex/utils/utils.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; @@ -125,14 +124,7 @@ class ToolbarWidgetState extends State { } _initWebController() async { - await _webController.setJavaScriptMode(JavaScriptMode.unrestricted); - await _webController.addJavaScriptChannel('MathMLChannel', - onMessageReceived: (JavaScriptMessage message) { - print('Received message: ${message.message}'); - _completer.complete(message.message); - _completer = Completer(); - }); - WebViewWidget(controller: _webController); + await widget.controller.initWebController(); } void disable() { @@ -2625,7 +2617,7 @@ class ToolbarWidgetState extends State { ?.call(ButtonType.fn, null, null) ?? true; if (proceed) { - await openMathDialog(); + await widget.controller.openMathDialog(context); } } }, @@ -3026,48 +3018,48 @@ class ToolbarWidgetState extends State { } return toolbarChildren; } - - openMathDialog() async { - final c = CustomMathFieldEditingController(); - if (!kIsWeb) { - widget.controller.clearFocus(); - } - await showDialog( - context: context, - builder: (context) => MathKeyboardDialog( - controller: c, - mathField: widget.controller.mathField, - )); - if (!kIsWeb) { - widget.controller.setFocus(); - } - var math = c.texString; - if (math != '') { - var texAsFun = c.texStringAsFun; - var result = await _latexToHtml(math.replaceAll('\\', '\\\\')); - result = '$result'; - _latexMap.addAll({ - result: texAsFun, - }); - widget.controller.addToHashMap(result, texAsFun); - widget.controller.insertHtml(result); - widget.controller.insertText(' '); - } - } - - Future _latexToHtml(String latex) async { - await _webController.runJavaScript(''' - (async () => { - try { - const mathlive = await import("https://unpkg.com/mathlive?module"); - const mathML = mathlive.convertLatexToMathMl('\$\$$latex\$\$'); - MathMLChannel.postMessage(mathML); - } catch (error) { - console.error('Error:', error); - } - })(); - '''); - - return _completer.future; - } +// +// openMathDialog() async { +// final c = CustomMathFieldEditingController(); +// if (!kIsWeb) { +// widget.controller.clearFocus(); +// } +// await showDialog( +// context: context, +// builder: (context) => MathKeyboardDialog( +// controller: c, +// mathField: widget.controller.mathField, +// )); +// if (!kIsWeb) { +// widget.controller.setFocus(); +// } +// var math = c.texString; +// if (math != '') { +// var texAsFun = c.texStringAsFun; +// var result = await _latexToHtml(math.replaceAll('\\', '\\\\')); +// result = '$result'; +// _latexMap.addAll({ +// result: texAsFun, +// }); +// widget.controller.addToHashMap(result, texAsFun); +// widget.controller.insertHtml(result); +// widget.controller.insertText(' '); +// } +// } +// +// Future _latexToHtml(String latex) async { +// await _webController.runJavaScript(''' +// (async () => { +// try { +// const mathlive = await import("https://unpkg.com/mathlive?module"); +// const mathML = mathlive.convertLatexToMathMl('\$\$$latex\$\$'); +// MathMLChannel.postMessage(mathML); +// } catch (error) { +// console.error('Error:', error); +// } +// })(); +// '''); +// +// return _completer.future; +// } } From 5222177ba3283f00d37fa5d9c460b251378af32e Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Tue, 2 Jan 2024 09:27:26 +0200 Subject: [PATCH 20/29] math dialog is enhanced --- CHANGELOG.md | 4 +++ lib/src/widgets/math_keyboard_dialog.dart | 33 +++++++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75d37706..0fa9ade9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.6.9] = 2023-1-2 + +* improved the math keyboard dialog + ## [2.6.8] = 2023-12-31 * moved the math keyboard to the controller diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart index 4e6d3fdb..67fefe76 100644 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -43,7 +43,7 @@ class MathKeyboardDialog extends StatelessWidget { child: GestureDetector( onTap: controller.clear, child: const Icon( - Icons.highlight_remove_rounded, + Icons.cleaning_services_rounded, color: Colors.grey, ), ), @@ -55,19 +55,24 @@ class MathKeyboardDialog extends StatelessWidget { ), ), const SizedBox(height: 15), - TextButton( - onPressed: () { - Navigator.pop(context, ''); - print(controller.texStringAsFun); - }, - child: const Text('Close'), - ), - TextButton( - onPressed: () { - Navigator.pop(context, controller.texStringAsFun); - print(controller.texStringAsFun); - }, - child: const Text('save'), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () { + Navigator.pop(context, ''); + print(controller.texStringAsFun); + }, + child: const Text('Close'), + ), + TextButton( + onPressed: () { + Navigator.pop(context, controller.texStringAsFun); + print(controller.texStringAsFun); + }, + child: const Text('Save'), + ), + ], ), ], ), From cd7b0d3c90403162fde083fff2427a634c2e3663 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Tue, 2 Jan 2024 09:27:44 +0200 Subject: [PATCH 21/29] math dialog is enhanced --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9d68e2e4..f0a09a4f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.8 +version: 2.6.9 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From 1c4d2c943957c474bfb88fb6523a81b7fb75e276 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Tue, 2 Jan 2024 09:44:02 +0200 Subject: [PATCH 22/29] math dialog is enhanced --- CHANGELOG.md | 4 ++++ lib/src/widgets/math_keyboard_dialog.dart | 2 ++ pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa9ade9..2785e249 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.6.9+1] = 2023-1-2 + +* improved the math keyboard dialog + ## [2.6.9] = 2023-1-2 * improved the math keyboard dialog diff --git a/lib/src/widgets/math_keyboard_dialog.dart b/lib/src/widgets/math_keyboard_dialog.dart index 67fefe76..287a6339 100644 --- a/lib/src/widgets/math_keyboard_dialog.dart +++ b/lib/src/widgets/math_keyboard_dialog.dart @@ -20,6 +20,7 @@ class MathKeyboardDialog extends StatelessWidget { @override Widget build(BuildContext context) { return Dialog( + insetPadding: EdgeInsets.all(10), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( @@ -28,6 +29,7 @@ class MathKeyboardDialog extends StatelessWidget { children: [ SizedBox( width: MediaQuery.of(context).size.width, + height: 100, child: MathField( focusNode: mathField?.focusNode, autofocus: mathField?.autofocus ?? true, diff --git a/pubspec.yaml b/pubspec.yaml index f0a09a4f..9426dc7d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.9 +version: 2.6.9+1 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From 01bd7359836da8c3f10bf0d8074edd00f644da0b Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Thu, 4 Jan 2024 10:46:14 +0200 Subject: [PATCH 23/29] compatibility --- CHANGELOG.md | 4 + example/pubspec.lock | 198 ++++++++++------------------ example/pubspec.yaml | 2 +- lib/src/widgets/toolbar_widget.dart | 7 +- pubspec.lock | 194 ++++++++++----------------- pubspec.yaml | 12 +- 6 files changed, 152 insertions(+), 265 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2785e249..f2ea2366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.0.0] = 2023-1-4 + +* compatibility + ## [2.6.9+1] = 2023-1-2 * improved the math keyboard dialog diff --git a/example/pubspec.lock b/example/pubspec.lock index 158464ae..804e2f2f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,22 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - args: - dependency: transitive - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.10.0" boolean_selector: dependency: transitive description: @@ -29,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: @@ -45,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.17.0" cupertino_icons: dependency: "direct main" description: @@ -69,18 +61,18 @@ packages: dependency: transitive description: name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.0.2" file_picker: dependency: transitive description: name: file_picker - sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" + sha256: "9d6e95ec73abbd31ec54d0e0df8a961017e165aba1395e462e5b31ea0c165daf" url: "https://pub.dev" source: hosted - version: "6.1.1" + version: "5.3.1" flex_color_picker: dependency: transitive description: @@ -93,10 +85,10 @@ packages: dependency: transitive description: name: flex_seed_scheme - sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" + sha256: e4168a6fc88a3e5bc3d6b7a748c6a6083eedc193d343ddc26bbad7fb1b258555 url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -167,10 +159,10 @@ packages: dependency: transitive description: name: flutter_math_fork - sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" + sha256: fa511bdcb91fc35eac155ec5790883886dd9de6572fea549f1ad4660ef6804e9 url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.6.3+1" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -183,10 +175,10 @@ packages: dependency: transitive description: name: flutter_svg - sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "1.1.6" flutter_test: dependency: "direct dev" description: flutter @@ -201,25 +193,25 @@ packages: dependency: "direct main" description: name: get - sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e + sha256: "2ba20a47c8f1f233bed775ba2dd0d3ac97b4cf32fc17731b3dfc672b06b0e92a" url: "https://pub.dev" source: hosted - version: "4.6.6" + version: "4.6.5" holding_gesture: dependency: transitive description: name: holding_gesture - sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f + sha256: "6d12a991c498357f9c8a532656facf97c47858be9a7249d5caaa84707aecc052" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.1.0" html_editor_enhanced_fork_latex: dependency: "direct main" description: path: ".." relative: true source: path - version: "2.6.8" + version: "2.6.9+1" infinite_listview: dependency: transitive description: @@ -232,34 +224,34 @@ packages: dependency: transitive description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" url: "https://pub.dev" source: hosted - version: "0.18.1" - lints: + version: "0.17.0" + js: dependency: transitive description: - name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "0.6.5" matcher: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.2.0" math_expressions: dependency: transitive description: @@ -272,18 +264,18 @@ packages: dependency: "direct main" description: name: math_keyboard - sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" + sha256: "81d465aff32ca5a5976b6e04269848899a55623ddc91723a623b2d6ebca5831e" url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.1.9" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.8.0" nested: dependency: transitive description: @@ -304,10 +296,18 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.8.2" + path_drawing: + dependency: transitive + description: + name: path_drawing + sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 + url: "https://pub.dev" + source: hosted + version: "1.0.1" path_parsing: dependency: transitive description: @@ -320,50 +320,26 @@ packages: dependency: transitive description: name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d url: "https://pub.dev" source: hosted - version: "2.1.7" + version: "2.1.6" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - sha256: fda979f3eb65558a389517521c8315060289dda5a1a6087f3892bdea9550eade - url: "https://pub.dev" - source: hosted - version: "0.10.0" - pointer_interceptor_ios: - dependency: transitive - description: - name: pointer_interceptor_ios - sha256: "4282ebfe21b54e21e26ab982c6086f0a67dc63423026bfba8db39a2e22045f26" - url: "https://pub.dev" - source: hosted - version: "0.10.0" - pointer_interceptor_platform_interface: - dependency: transitive - description: - name: pointer_interceptor_platform_interface - sha256: "59a446ead3be360bde72c3725f5ecacbba203c8a760e3061024c20f7da53f825" - url: "https://pub.dev" - source: hosted - version: "0.10.0" - pointer_interceptor_web: - dependency: transitive - description: - name: pointer_interceptor_web - sha256: "2a8a069206f7b234a895d30ccab8b18ea267eeb79a832e5e3d1b6464d659eb6a" + sha256: acfcd63c00ec3d5a7894b0e2a875893716d31958fe03f064734dba7dfd9113d9 url: "https://pub.dev" source: hosted - version: "0.10.0" + version: "0.9.3+5" provider: dependency: transitive description: @@ -381,26 +357,26 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.1" string_scanner: dependency: transitive description: @@ -421,10 +397,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.4.16" tuple: dependency: transitive description: @@ -433,30 +409,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" vector_math: dependency: transitive description: @@ -473,14 +425,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.0+2" - web: - dependency: transitive - description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 - url: "https://pub.dev" - source: hosted - version: "0.3.0" webview_flutter: dependency: transitive description: @@ -493,42 +437,42 @@ packages: dependency: transitive description: name: webview_flutter_android - sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b + sha256: "8326ee235f87605a2bfc444a4abc897f4abc78d83f054ba7d3d1074ce82b4fbf" url: "https://pub.dev" source: hosted - version: "3.13.1" + version: "3.12.1" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 + sha256: "6d9213c65f1060116757a7c473247c60f3f7f332cac33dc417c9e362a9a13e4f" url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.6.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d + sha256: accdaaa49a2aca2dc3c3230907988954cdd23fed0a19525d6c9789d380f4dc76 url: "https://pub.dev" source: hosted - version: "3.10.0" + version: "3.9.4" win32: dependency: transitive description: name: win32 - sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574 + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" url: "https://pub.dev" source: hosted - version: "5.1.1" + version: "4.1.4" xml: dependency: transitive description: name: xml - sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" url: "https://pub.dev" source: hosted - version: "6.3.0" + version: "6.2.2" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.13.0" + dart: ">=2.19.0 <3.0.0" + flutter: ">=3.7.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6872fce4..4baf0f0e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter get: ^4.0.0 - math_keyboard: ^0.2.1 + math_keyboard: ^0.1.1 html_editor_enhanced_fork_latex: # When depending on this package from a real application you should use: # html_editor_enhanced: ^x.y.z diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index 42926c4e..cb863121 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:collection'; import 'dart:convert'; import 'package:file_picker/file_picker.dart'; @@ -11,7 +10,6 @@ import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:html_editor_enhanced_fork_latex/utils/utils.dart'; import 'package:numberpicker/numberpicker.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; -import 'package:webview_flutter/webview_flutter.dart'; /// Toolbar widget class class ToolbarWidget extends StatefulWidget { @@ -93,9 +91,6 @@ class ToolbarWidgetState extends State { /// Tracks the expanded status of the toolbar bool _isExpanded = false; - final HashMap _latexMap = HashMap(); - var _completer = Completer(); - var _webController = WebViewController(); @override void initState() { @@ -2708,7 +2703,7 @@ class ToolbarWidgetState extends State { child: SingleChildScrollView( child: DataTable( columnSpacing: 5, - dataRowMinHeight: 75, + dataRowHeight: 75, columns: const [ DataColumn( label: Text( diff --git a/pubspec.lock b/pubspec.lock index 52ecca82..a19c7bd5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,22 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - args: - dependency: transitive - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.10.0" boolean_selector: dependency: transitive description: @@ -29,10 +21,10 @@ packages: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: @@ -45,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.17.0" fake_async: dependency: transitive description: @@ -61,18 +53,18 @@ packages: dependency: transitive description: name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.0.2" file_picker: dependency: "direct main" description: name: file_picker - sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" + sha256: "9d6e95ec73abbd31ec54d0e0df8a961017e165aba1395e462e5b31ea0c165daf" url: "https://pub.dev" source: hosted - version: "6.1.1" + version: "5.3.1" flex_color_picker: dependency: "direct main" description: @@ -85,10 +77,10 @@ packages: dependency: transitive description: name: flex_seed_scheme - sha256: "29c12aba221eb8a368a119685371381f8035011d18de5ba277ad11d7dfb8657f" + sha256: e4168a6fc88a3e5bc3d6b7a748c6a6083eedc193d343ddc26bbad7fb1b258555 url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -159,10 +151,10 @@ packages: dependency: transitive description: name: flutter_math_fork - sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" + sha256: fa511bdcb91fc35eac155ec5790883886dd9de6572fea549f1ad4660ef6804e9 url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.6.3+1" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -175,10 +167,10 @@ packages: dependency: transitive description: name: flutter_svg - sha256: d39e7f95621fc84376bc0f7d504f05c3a41488c562f4a8ad410569127507402c + sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" url: "https://pub.dev" source: hosted - version: "2.0.9" + version: "1.1.6" flutter_test: dependency: "direct dev" description: flutter @@ -193,10 +185,10 @@ packages: dependency: transitive description: name: holding_gesture - sha256: beb26bb731d7d67595c4895b42fa7962c209cecee8def42b665c495648d4620f + sha256: "6d12a991c498357f9c8a532656facf97c47858be9a7249d5caaa84707aecc052" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.1.0" infinite_listview: dependency: transitive description: @@ -209,34 +201,34 @@ packages: dependency: transitive description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" url: "https://pub.dev" source: hosted - version: "0.18.1" - lints: - dependency: "direct main" + version: "0.17.0" + js: + dependency: transitive description: - name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "0.6.5" matcher: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.2.0" math_expressions: dependency: transitive description: @@ -249,18 +241,18 @@ packages: dependency: "direct main" description: name: math_keyboard - sha256: "4f5d4eb4b7f003715e2ae7d1f58f5f1fddd9dd746d1f1bbc27f1c967e10124d4" + sha256: "81d465aff32ca5a5976b6e04269848899a55623ddc91723a623b2d6ebca5831e" url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.1.9" meta: dependency: "direct main" description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.8.0" nested: dependency: transitive description: @@ -281,10 +273,18 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" + source: hosted + version: "1.8.2" + path_drawing: + dependency: transitive + description: + name: path_drawing + sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.0.1" path_parsing: dependency: transitive description: @@ -297,50 +297,26 @@ packages: dependency: transitive description: name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d url: "https://pub.dev" source: hosted - version: "2.1.7" + version: "2.1.6" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - sha256: fda979f3eb65558a389517521c8315060289dda5a1a6087f3892bdea9550eade - url: "https://pub.dev" - source: hosted - version: "0.10.0" - pointer_interceptor_ios: - dependency: transitive - description: - name: pointer_interceptor_ios - sha256: "4282ebfe21b54e21e26ab982c6086f0a67dc63423026bfba8db39a2e22045f26" - url: "https://pub.dev" - source: hosted - version: "0.10.0" - pointer_interceptor_platform_interface: - dependency: transitive - description: - name: pointer_interceptor_platform_interface - sha256: "59a446ead3be360bde72c3725f5ecacbba203c8a760e3061024c20f7da53f825" - url: "https://pub.dev" - source: hosted - version: "0.10.0" - pointer_interceptor_web: - dependency: transitive - description: - name: pointer_interceptor_web - sha256: "2a8a069206f7b234a895d30ccab8b18ea267eeb79a832e5e3d1b6464d659eb6a" + sha256: acfcd63c00ec3d5a7894b0e2a875893716d31958fe03f064734dba7dfd9113d9 url: "https://pub.dev" source: hosted - version: "0.10.0" + version: "0.9.3+5" provider: dependency: transitive description: @@ -358,26 +334,26 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.1" string_scanner: dependency: transitive description: @@ -398,10 +374,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.4.16" tuple: dependency: transitive description: @@ -410,30 +386,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: "0f0c746dd2d6254a0057218ff980fc7f5670fd0fcf5e4db38a490d31eed4ad43" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: "0edf6d630d1bfd5589114138ed8fada3234deacc37966bec033d3047c29248b7" - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: d24333727332d9bd20990f1483af4e09abdb9b1fc7c3db940b56ab5c42790c26 - url: "https://pub.dev" - source: hosted - version: "1.1.9+1" vector_math: dependency: transitive description: @@ -450,14 +402,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.0+2" - web: - dependency: transitive - description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 - url: "https://pub.dev" - source: hosted - version: "0.3.0" webview_flutter: dependency: "direct main" description: @@ -470,42 +414,42 @@ packages: dependency: transitive description: name: webview_flutter_android - sha256: b54c89fe14a6d26a2a46e24880da0441cdd2bf1f6d01a5b3e1d39558feb1de0b + sha256: "8326ee235f87605a2bfc444a4abc897f4abc78d83f054ba7d3d1074ce82b4fbf" url: "https://pub.dev" source: hosted - version: "3.13.1" + version: "3.12.1" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - sha256: dbe745ee459a16b6fec296f7565a8ef430d0d681001d8ae521898b9361854943 + sha256: "6d9213c65f1060116757a7c473247c60f3f7f332cac33dc417c9e362a9a13e4f" url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.6.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - sha256: eebfabfa8a115b535b52031b8b26f7a4b58ceceab378bc9db8762b0fb46f7b5d + sha256: accdaaa49a2aca2dc3c3230907988954cdd23fed0a19525d6c9789d380f4dc76 url: "https://pub.dev" source: hosted - version: "3.10.0" + version: "3.9.4" win32: dependency: transitive description: name: win32 - sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574 + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" url: "https://pub.dev" source: hosted - version: "5.1.1" + version: "4.1.4" xml: dependency: transitive description: name: xml - sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" url: "https://pub.dev" source: hosted - version: "6.3.0" + version: "6.2.2" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.13.0" + dart: ">=2.19.0 <3.0.0" + flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9426dc7d..b1733de2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 2.6.9+1 +version: 3.0.0 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git @@ -22,18 +22,18 @@ dependencies: # plugin to show a color picker for foreground/highlight color flex_color_picker: ^3.3.0 # plugin to get files from filesystem - file_picker: ^6.1.1 + file_picker: ^5.2.0+1 # plugin to show a scrollable number picker for inserting tables numberpicker: ^2.1.2 # plugin to allow dropdowns and dialogs to be interactable when displaying over the editor # related to https://github.com/flutter/flutter/issues/54027 # pinned to 0.9.1 because of issues with CanvasKit in the latest versions - pointer_interceptor: ^0.10.0 + pointer_interceptor: ^0.9.3+3 # plugin to help maintain effective Dart standards - lints: ^3.0.0 + # plugin for @internal annotation - meta: ^1.10.0 - math_keyboard: ^0.2.1 + meta: ^1.0.0 + math_keyboard: ^0.1.1 webview_flutter: ^4.4.2 dev_dependencies: From ed7f17a3517399c16e7fde899065d121bd127582 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Mon, 8 Jan 2024 14:17:14 +0200 Subject: [PATCH 24/29] compatibility --- CHANGELOG.md | 4 + example/lib/main.dart | 95 ++++++++++--------- example/pubspec.lock | 2 +- lib/src/html_editor_controller_mobile.dart | 61 +++++++++++- .../html_editor_controller_unsupported.dart | 68 +------------ lib/src/html_editor_controller_web.dart | 14 +++ lib/src/widgets/toolbar_widget.dart | 5 - lib/utils/toolbar.dart | 3 +- pubspec.yaml | 4 +- 9 files changed, 136 insertions(+), 120 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ea2366..195254f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.1.0] = 2023-1-8 + +* changed how the latex to mathMl works, now faster + ## [3.0.0] = 2023-1-4 * compatibility diff --git a/example/lib/main.dart b/example/lib/main.dart index c2536750..7947e01e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,9 +1,10 @@ -import 'package:file_picker/file_picker.dart'; +import 'dart:developer'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart' as inApp; import 'package:get/get.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; -import 'package:math_keyboard/math_keyboard.dart'; void main() => runApp(HtmlEditorExampleApp()); @@ -15,39 +16,67 @@ class HtmlEditorExampleApp extends StatelessWidget { title: 'Flutter Demo', theme: ThemeData(), darkTheme: ThemeData.dark(), - home: HtmlEditorExample(title: 'Flutter HTML Editor Example'), + home: MyApp2(title: 'Flutter HTML Editor Example'), // home: MyApp2(title: 'Flutter HTML Editor Example'), ); } } -class MyApp2 extends StatelessWidget { +class MyApp2 extends StatefulWidget { final String title; MyApp2({Key? key, required this.title}) : super(key: key); - late final HtmlEditorController controller = HtmlEditorController( - mathField: MathField( - autofocus: true, - keyboardType: MathKeyboardType.numberOnly, - variables: ['x', 'y', 'z', 'A', 'B', 'C'], - opensKeyboard: true, - ), - ); - final HtmlEditorController controller2 = HtmlEditorController(); + + @override + State createState() => _MyApp2State(); +} + +class _MyApp2State extends State { + final HtmlEditorController controller1 = HtmlEditorController(); + inApp.InAppWebViewController controller = + inApp.InAppWebViewController(0123, inApp.InAppWebView()); + + final controller2 = HtmlEditorController(); + + @override + void initState() { + (_latexToHtml('{x}', controller)); + super.initState(); + } + + Future _latexToHtml(String latex, editorController) async { + var res = await editorController!.callAsyncJavaScript(functionBody: r''' + func(string latex)async{ + const mathlive = await import("https://unpkg.com/mathlive?module"); + const mathML = mathlive.convertLatexToMathMl('\$\$latex\$\$'); + MathMLChannel.postMessage(mathML); + return(mathML); + }); + var p = await func(); + return p; + ''', arguments: {'latex': latex}); + log(res.toString()); + log(res?.toMap().toString() ?? ''); + return res!.value.toString(); + } @override Widget build(BuildContext context) { return Scaffold( - body: SingleChildScrollView( - child: Column( - children: [ - tb(controller), - tb(controller2), - ], - ), + body: Stack( + children: [ + SingleChildScrollView( + child: Column( + children: [ + tb(controller1), + tb(controller2), + ], + ), + ), + ], ), appBar: AppBar( - title: Text(this.title), + title: Text(this.widget.title), ), ); } @@ -74,6 +103,7 @@ class MyApp2 extends StatelessWidget { onPressed: () { controller.insertHtml( r'yy'); + isVisible.value = true; }, icon: Icon(Icons.functions_outlined)), ), @@ -172,29 +202,6 @@ class _HtmlEditorExampleState extends State { //by default toolbarType: ToolbarType.nativeScrollable, //by default - onButtonPressed: - (ButtonType type, bool? status, Function? updateStatus) { - print( - "button '${(type.name)}' pressed, the current selected status is $status"); - return true; - }, - onDropdownChanged: (DropdownType type, dynamic changed, - Function(dynamic)? updateSelectedItem) { - print("dropdown '${(type.name)}' changed to $changed"); - return true; - }, - mediaLinkInsertInterceptor: - (String url, InsertFileType type) { - print(url); - return true; - }, - mediaUploadInterceptor: - (PlatformFile file, InsertFileType type) async { - print(file.name); //filename - print(file.size); //size in bytes - print(file.extension); //file extension (eg jpeg or mp4) - return true; - }, ), otherOptions: OtherOptions(height: 550), callbacks: Callbacks(onBeforeCommand: (String? currentHtml) { diff --git a/example/pubspec.lock b/example/pubspec.lock index 804e2f2f..eb1502f0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -211,7 +211,7 @@ packages: path: ".." relative: true source: path - version: "2.6.9+1" + version: "3.0.0" infinite_listview: dependency: transitive description: diff --git a/lib/src/html_editor_controller_mobile.dart b/lib/src/html_editor_controller_mobile.dart index 451caa86..d9a49254 100644 --- a/lib/src/html_editor_controller_mobile.dart +++ b/lib/src/html_editor_controller_mobile.dart @@ -1,9 +1,13 @@ +import 'dart:developer'; + import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' as unsupported; +import 'package:html_editor_enhanced_fork_latex/utils/custom_math_field_controller.dart'; import 'package:math_keyboard/math_keyboard.dart'; /// Controller for mobile @@ -63,7 +67,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void execCommand(String command, {String? argument}) { _evaluateJavascript( source: - "document.execCommand('$command', false${argument == null ? "" : ", '$argument'"});"); + "document.execCommand('$command', false${argument == null ? "" : ", '$argument'"});"); } /// Gets the text from the editor and returns it as a [String]. @@ -171,7 +175,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void insertNetworkImage(String url, {String filename = ''}) { _evaluateJavascript( source: - "\$('#summernote-2').summernote('insertImage', '$url', '$filename');"); + "\$('#summernote-2').summernote('insertImage', '$url', '$filename');"); } /// Insert a link at the position of the cursor in the editor @@ -208,7 +212,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void resetHeight() { _evaluateJavascript( source: - "window.flutter_inappwebview.callHandler('setHeight', 'reset');"); + "window.flutter_inappwebview.callHandler('setHeight', 'reset');"); } /// Recalculates the height of the editor to remove any vertical scrolling. @@ -217,7 +221,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void recalculateHeight() { _evaluateJavascript( source: - "var height = document.body.scrollHeight; window.flutter_inappwebview.callHandler('setHeight', height);"); + "var height = document.body.scrollHeight; window.flutter_inappwebview.callHandler('setHeight', height);"); } /// Add a notification to the bottom of the editor. This is styled similar to @@ -291,4 +295,53 @@ class HtmlEditorController extends unsupported.HtmlEditorController { /// Internal function to insert table on Web @override void insertTable(String dimensions) {} + + @override + openMathDialog(BuildContext context) async { + final c = CustomMathFieldEditingController(); + if (!kIsWeb) { + this.clearFocus(); + } + await showDialog( + context: context, + builder: (context) => MathKeyboardDialog( + controller: c, + mathField: this.mathField, + )); + if (!kIsWeb) { + this.setFocus(); + } + var math = c.texString; + if (math != '') { + var texAsFun = c.texStringAsFun; + var result = await latexToHtml(math.replaceAll('\\', '\\\\')); + result = '$result'; + latexMap.addAll({ + result: texAsFun, + }); + this.addToHashMap(result, texAsFun); + this.insertHtml(result); + this.insertText(' '); + } + } + + @override + Future latexToHtml(String latex) async { + var res = await editorController!.callAsyncJavaScript( + functionBody: r''' + async function func(){ + const mathlive = await import("https://unpkg.com/mathlive?module"); + const mathML = mathlive.convertLatexToMathMl('\$\$''' + '$latex' + r'''\$\$'); + return(mathML); + }; + var p = await func(); + return p; + ''', + arguments: {'latex': latex}); + log(res.toString()); + log(res?.toMap().toString() ?? ''); + return res!.value.toString(); + } } diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index aeccfcf7..da7322ce 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -1,14 +1,10 @@ import 'dart:async'; import 'dart:collection'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:math_keyboard/math_keyboard.dart'; import 'package:meta/meta.dart'; -import 'package:webview_flutter/webview_flutter.dart'; - -import '../utils/custom_math_field_controller.dart'; /// Fallback controller (should never be used) class HtmlEditorController { @@ -19,68 +15,14 @@ class HtmlEditorController { this.mathField, }); - var _completer = Completer(); - var _webController = WebViewController(); + final HashMap latexMap = HashMap(); - final HashMap _latexMap = HashMap(); + openMathDialog(BuildContext context) async {} - initWebController() async { - await _webController.setJavaScriptMode(JavaScriptMode.unrestricted); - await _webController.addJavaScriptChannel('MathMLChannel', - onMessageReceived: (JavaScriptMessage message) { - print('Received message: ${message.message}'); - _completer.complete(message.message); - _completer = Completer(); - }); - WebViewWidget(controller: _webController); - } - - openMathDialog(BuildContext context) async { - final c = CustomMathFieldEditingController(); - if (!kIsWeb) { - this.clearFocus(); - } - await showDialog( - context: context, - builder: (context) => MathKeyboardDialog( - controller: c, - mathField: this.mathField, - )); - if (!kIsWeb) { - this.setFocus(); - } - var math = c.texString; - if (math != '') { - var texAsFun = c.texStringAsFun; - var result = await _latexToHtml(math.replaceAll('\\', '\\\\')); - result = '$result'; - _latexMap.addAll({ - result: texAsFun, - }); - this.addToHashMap(result, texAsFun); - this.insertHtml(result); - this.insertText(' '); - } - } - - Future _latexToHtml(String latex) async { - await _webController.runJavaScript(''' - (async () => { - try { - const mathlive = await import("https://unpkg.com/mathlive?module"); - const mathML = mathlive.convertLatexToMathMl('\$\$$latex\$\$'); - MathMLChannel.postMessage(mathML); - } catch (error) { - console.error('Error:', error); - } - })(); - '''); - - return _completer.future; - } + latexToHtml(String latex) {} void addToHashMap(String key, String value) { - _latexMap.addAll({ + latexMap.addAll({ key: value, }); } @@ -97,7 +39,7 @@ class HtmlEditorController { var split = element.split(r''); var after = split.last; element = '${split.first}'; - tags.add(_latexMap[element] ?? element); + tags.add(latexMap[element] ?? element); tags.add(after); } else { tags.add(element); diff --git a/lib/src/html_editor_controller_web.dart b/lib/src/html_editor_controller_web.dart index 308e5dd1..0065cea1 100644 --- a/lib/src/html_editor_controller_web.dart +++ b/lib/src/html_editor_controller_web.dart @@ -3,6 +3,8 @@ import 'dart:convert'; import 'dart:html' as html; import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' as unsupported; @@ -326,4 +328,16 @@ class HtmlEditorController extends unsupported.HtmlEditorController { 'Non-Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart'); } } + + @override + openMathDialog(BuildContext context) async { + throw Exception( + 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart and check kIsWeb before calling this method.'); + } + + @override + Future latexToHtml(String latex) async { + throw Exception( + 'Flutter Web environment detected, please make sure you are importing package:html_editor_enhanced_fork_latex/html_editor.dart and check kIsWeb before calling this method.'); + } } diff --git a/lib/src/widgets/toolbar_widget.dart b/lib/src/widgets/toolbar_widget.dart index cb863121..3a188e15 100644 --- a/lib/src/widgets/toolbar_widget.dart +++ b/lib/src/widgets/toolbar_widget.dart @@ -114,14 +114,9 @@ class ToolbarWidgetState extends State { _alignSelected = List.filled(t.getIcons1().length, false); } } - _initWebController(); super.initState(); } - _initWebController() async { - await widget.controller.initWebController(); - } - void disable() { setState(mounted, this.setState, () { _enabled = false; diff --git a/lib/utils/toolbar.dart b/lib/utils/toolbar.dart index f3788ce4..2e71b2b5 100644 --- a/lib/utils/toolbar.dart +++ b/lib/utils/toolbar.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; /// Abstract class that all the toolbar classes extend @@ -175,7 +176,7 @@ class InsertButtons extends Toolbar { if (otherFile) icons.add(Icon(Icons.attach_file)); if (table) icons.add(Icon(Icons.table_chart_outlined)); if (hr) icons.add(Icon(Icons.horizontal_rule)); - if (fn) icons.add(Icon(Icons.functions)); + if (fn && !kIsWeb) icons.add(Icon(Icons.functions)); return icons; } } diff --git a/pubspec.yaml b/pubspec.yaml index b1733de2..bd3362aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 3.0.0 +version: 3.1.0 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git @@ -34,7 +34,7 @@ dependencies: # plugin for @internal annotation meta: ^1.0.0 math_keyboard: ^0.1.1 - webview_flutter: ^4.4.2 + webview_flutter: ^4.0.0 dev_dependencies: flutter_test: From 2d7302f5c873121542de8a7de3871803cdfd2b9e Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Thu, 11 Jan 2024 09:28:05 +0200 Subject: [PATCH 25/29] implemented mathMl to Latex without a map --- example/lib/main.dart | 69 +++++--- example/pubspec.lock | 2 +- lib/src/html_editor_controller_mobile.dart | 166 +++++++++++++++++- .../html_editor_controller_unsupported.dart | 28 ++- pubspec.lock | 8 + pubspec.yaml | 1 + 6 files changed, 232 insertions(+), 42 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 7947e01e..aa69f9b6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -16,7 +16,7 @@ class HtmlEditorExampleApp extends StatelessWidget { title: 'Flutter Demo', theme: ThemeData(), darkTheme: ThemeData.dark(), - home: MyApp2(title: 'Flutter HTML Editor Example'), + home: HtmlEditorExample(title: 'Flutter HTML Editor Example'), // home: MyApp2(title: 'Flutter HTML Editor Example'), ); } @@ -40,36 +40,35 @@ class _MyApp2State extends State { @override void initState() { - (_latexToHtml('{x}', controller)); super.initState(); } Future _latexToHtml(String latex, editorController) async { - var res = await editorController!.callAsyncJavaScript(functionBody: r''' - func(string latex)async{ - const mathlive = await import("https://unpkg.com/mathlive?module"); - const mathML = mathlive.convertLatexToMathMl('\$\$latex\$\$'); - MathMLChannel.postMessage(mathML); - return(mathML); - }); - var p = await func(); - return p; - ''', arguments: {'latex': latex}); - log(res.toString()); - log(res?.toMap().toString() ?? ''); - return res!.value.toString(); + const breakPoint = 'break'; + var mathMl = + 'xxxxxx'; + + var a = await controller2.mathMlToLatex( + mathMl.replaceAll('', breakPoint), context); + for (var value in a.split('break')) { + log(value.trim(), name: 'latex'); + } + log(a, name: 'MathMl'); + return a; } @override Widget build(BuildContext context) { return Scaffold( + floatingActionButton: FloatingActionButton(onPressed: () { + (_latexToHtml('{x}', controller)); + }), body: Stack( children: [ SingleChildScrollView( child: Column( children: [ tb(controller1), - tb(controller2), ], ), ), @@ -155,6 +154,17 @@ class _HtmlEditorExampleState extends State { String result = ''; final HtmlEditorController controller = HtmlEditorController(); + Future _latexToHtml(String latex) async { + const breakPoint = 'break'; + var a = await controller.mathMlToLatex( + latex.replaceAll('', breakPoint), context); + for (var value in a.split('break')) { + log(value.trim(), name: 'latex'); + } + log(a, name: 'MathMl'); + return a; + } + @override Widget build(BuildContext context) { return GestureDetector( @@ -286,10 +296,11 @@ class _HtmlEditorExampleState extends State { style: TextButton.styleFrom( backgroundColor: Colors.blueGrey), onPressed: () { - controller.undo(); + controller.insertHtmlStringWithLatex( + r'

Hello

\(\sqrt{x} e \pi \)

'); }, - child: - Text('Undo', style: TextStyle(color: Colors.white)), + child: Text('insert mathMl', + style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -297,11 +308,13 @@ class _HtmlEditorExampleState extends State { TextButton( style: TextButton.styleFrom( backgroundColor: Colors.blueGrey), - onPressed: () { - controller.clear(); + onPressed: () async { + var text = await controller.getText(); + var res = await _latexToHtml(text); + log(res, name: 'result'); }, - child: - Text('Reset', style: TextStyle(color: Colors.white)), + child: Text('Get Latex', + style: TextStyle(color: Colors.white)), ), SizedBox( width: 16, @@ -311,7 +324,11 @@ class _HtmlEditorExampleState extends State { backgroundColor: Theme.of(context).colorScheme.secondary), onPressed: () async { - var txt = await controller.getHtmlStringWithLatex(); + // var txt = await controller.getHtmlStringWithLatex(context); + var txt = + await controller.getHtmlStringWithLatex(context); + print(txt); + // print(res); if (txt.contains('src=\"data:')) { txt = ''; @@ -333,10 +350,10 @@ class _HtmlEditorExampleState extends State { backgroundColor: Theme.of(context).colorScheme.secondary), onPressed: () { - controller.redo(); + controller.insertLatex(r'\(\sqrt{x}\)'); }, child: Text( - 'Redo', + 'insert latex', style: TextStyle(color: Colors.white), ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index eb1502f0..a0357de7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -211,7 +211,7 @@ packages: path: ".." relative: true source: path - version: "3.0.0" + version: "3.1.0" infinite_listview: dependency: transitive description: diff --git a/lib/src/html_editor_controller_mobile.dart b/lib/src/html_editor_controller_mobile.dart index d9a49254..92571cba 100644 --- a/lib/src/html_editor_controller_mobile.dart +++ b/lib/src/html_editor_controller_mobile.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:developer'; import 'package:flutter/foundation.dart'; @@ -6,9 +7,10 @@ import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:html_editor_enhanced_fork_latex/html_editor.dart'; import 'package:html_editor_enhanced_fork_latex/src/html_editor_controller_unsupported.dart' - as unsupported; +as unsupported; import 'package:html_editor_enhanced_fork_latex/utils/custom_math_field_controller.dart'; import 'package:math_keyboard/math_keyboard.dart'; +import 'package:webview_flutter/webview_flutter.dart'; /// Controller for mobile class HtmlEditorController extends unsupported.HtmlEditorController { @@ -67,7 +69,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void execCommand(String command, {String? argument}) { _evaluateJavascript( source: - "document.execCommand('$command', false${argument == null ? "" : ", '$argument'"});"); + "document.execCommand('$command', false${argument == null ? "" : ", '$argument'"});"); } /// Gets the text from the editor and returns it as a [String]. @@ -175,7 +177,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void insertNetworkImage(String url, {String filename = ''}) { _evaluateJavascript( source: - "\$('#summernote-2').summernote('insertImage', '$url', '$filename');"); + "\$('#summernote-2').summernote('insertImage', '$url', '$filename');"); } /// Insert a link at the position of the cursor in the editor @@ -212,7 +214,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void resetHeight() { _evaluateJavascript( source: - "window.flutter_inappwebview.callHandler('setHeight', 'reset');"); + "window.flutter_inappwebview.callHandler('setHeight', 'reset');"); } /// Recalculates the height of the editor to remove any vertical scrolling. @@ -221,7 +223,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { void recalculateHeight() { _evaluateJavascript( source: - "var height = document.body.scrollHeight; window.flutter_inappwebview.callHandler('setHeight', height);"); + "var height = document.body.scrollHeight; window.flutter_inappwebview.callHandler('setHeight', height);"); } /// Add a notification to the bottom of the editor. This is styled similar to @@ -305,16 +307,16 @@ class HtmlEditorController extends unsupported.HtmlEditorController { await showDialog( context: context, builder: (context) => MathKeyboardDialog( - controller: c, - mathField: this.mathField, - )); + controller: c, + mathField: this.mathField, + )); if (!kIsWeb) { this.setFocus(); } var math = c.texString; if (math != '') { var texAsFun = c.texStringAsFun; - var result = await latexToHtml(math.replaceAll('\\', '\\\\')); + var result = await latexToHtml(math); result = '$result'; latexMap.addAll({ result: texAsFun, @@ -327,6 +329,7 @@ class HtmlEditorController extends unsupported.HtmlEditorController { @override Future latexToHtml(String latex) async { + latex = latex.replaceAll('\\', '\\\\'); var res = await editorController!.callAsyncJavaScript( functionBody: r''' async function func(){ @@ -344,4 +347,149 @@ class HtmlEditorController extends unsupported.HtmlEditorController { log(res?.toMap().toString() ?? ''); return res!.value.toString(); } + + @override + Future mathMlToLatex(String mathMl, BuildContext context) async { + String result = ''; + late BuildContext dialogContext; + Completer completer = Completer(); + final webViewController = WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setOnConsoleMessage((message) async { + log( + message.message, + name: 'ON_CONSOLE_MESSAGE', + ); + result = message.message; + completer.complete(result); + await Future.delayed(Duration(milliseconds: 150)); + Navigator.pop(dialogContext); + }) + ..loadHtmlString(_getHtmlMathMlToLatex(mathMl)); + showDialog( + context: context, + builder: (context) { + dialogContext = context; + return Stack( + children: [ + Center(child: CircularProgressIndicator()), + Visibility( + visible: false, + child: WebViewWidget( + controller: webViewController, + )), + ], + ); + }); + return completer.future; + } + + insertLatex(String latex) async { + var html = await latexToHtml(latex); + this.insertHtml('$html'); + } + + Future getHtmlStringWithLatex(context) async { + var txt = await getText(); + final reg = RegExp('', multiLine: true); + var tags = []; + var res = txt.split(reg); + print('result = $res'); + String latexString = ''; + const bp = 'break'; + int index = 0; + res.forEach((element) { + if (element.contains(r'')) { + var split = element.split(r''); + var after = split.last; + element = '${split.first}'; + latexString = '$latexString$element'; + // tags.add(latexMap[element + // .replaceAll('π', 'pi') + // .replaceAll('π', 'pi') + // .replaceAll(' ', '') + // .trim()] ?? + // ''); + tags.add('LATEX#'); + if (after.isNotEmpty) tags.add(after); + } else { + tags.add(element); + } + }); + latexString = latexString.replaceAll('', bp); + log(latexString, name: 'latex string'); + var latexRes = await mathMlToLatex(latexString, context); + log(latexRes, name: 'mathMlToLatex'); + var latexList = latexRes.split('break'); + bool isTrue = true; + + var tag = ''; + tags.forEach((element) { + if (element.isNotEmpty) tag = '$tag$element'; + }); + while (isTrue) { + if (tag.contains('LATEX#')) { + tag = tag.replaceFirst('LATEX#', '\\(${latexList[index++]}\\)'); + } else { + isTrue = false; + } + } + return tag.replaceAll('

', ''); + } + + Future insertHtmlStringWithLatex(String latex) async { + var txt = latex; + final reg = RegExp(r'\(', multiLine: true); + var tags = []; + var res = txt.split(reg); + print('result = $res'); + String latexString = ''; + const bp = 'break'; + int index = 0; + res.forEach((element) { + if (element.contains(r'\)')) { + var split = element.split(r'\)'); + var after = split.last; + element = '\\(${split.first}\\)'; + latexString = '$latexString$element'; + tags.add('LATEX#'); + if (after.isNotEmpty) tags.add(after); + } else { + tags.add(element); + } + }); + latexString = latexString.replaceAll('\\)\\(', bp); + log(latexString, name: 'latex string'); + var latexRes = await latexToHtml( + latexString, + ); + log(latexRes, name: 'LatexToMathMl'); + var latexList = latexRes.split('break'); + bool isTrue = true; + var tag = ''; + tags.forEach((element) { + if (element.isNotEmpty) tag = '$tag$element'; + }); + while (isTrue) { + if (tag.contains('LATEX#')) { + tag = tag.replaceFirst('LATEX#', + '${latexList[index++]}'); + } else { + isTrue = false; + } + } + this.insertHtml(tag.replaceAll('

', '')); + return tag.replaceAll('

', ''); + } + + String _getHtmlMathMlToLatex(String mathMl) => ''' + + ' + ' + '''; } diff --git a/lib/src/html_editor_controller_unsupported.dart b/lib/src/html_editor_controller_unsupported.dart index da7322ce..b1ed75f5 100644 --- a/lib/src/html_editor_controller_unsupported.dart +++ b/lib/src/html_editor_controller_unsupported.dart @@ -21,13 +21,21 @@ class HtmlEditorController { latexToHtml(String latex) {} + Future mathMlToLatex(String mathMl, BuildContext context) { + throw Exception('UnImplemented'); + } + void addToHashMap(String key, String value) { latexMap.addAll({ - key: value, + key + .replaceAll('π', 'pi') + .replaceAll('π', 'pi') + .replaceAll(' ', '') + .trim(): value, }); } - Future getHtmlStringWithLatex() async { + Future getHtmlStringWithLatex(context) async { var txt = await getText(); final reg = RegExp('', multiLine: true); var tags = []; @@ -39,19 +47,25 @@ class HtmlEditorController { var split = element.split(r''); var after = split.last; element = '${split.first}'; - tags.add(latexMap[element] ?? element); - tags.add(after); + tags.add(latexMap[element + .replaceAll('π', 'pi') + .replaceAll('π', 'pi') + .trim()] ?? + ''); + if (after.isNotEmpty) tags.add(after); } else { tags.add(element); } }); var tag = ''; tags.forEach((element) { - tag = '$tag$element'; + if (element.isNotEmpty) tag = '$tag$element'; }); return tag; } + insertLatex(String latex) {} + /// Toolbar widget state to call various methods. For internal use only. @internal ToolbarWidgetState? toolbar; @@ -128,7 +142,7 @@ class HtmlEditorController { /// A function to execute JS passed as a [WebScript] to the editor. This should /// only be used on Flutter Web. Future evaluateJavascriptWeb(String name, - {bool hasReturnValue = false}) => + {bool hasReturnValue = false}) => Future.value(); /// Gets the text from the editor and returns it as a [String]. @@ -215,4 +229,6 @@ class HtmlEditorController { /// Internal function to insert table on Web @internal void insertTable(String dimensions) {} + + insertHtmlStringWithLatex(String latex) {} } diff --git a/pubspec.lock b/pubspec.lock index a19c7bd5..ff627f8d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -181,6 +181,14 @@ packages: description: flutter source: sdk version: "0.0.0" + get: + dependency: "direct main" + description: + name: get + sha256: "2ba20a47c8f1f233bed775ba2dd0d3ac97b4cf32fc17731b3dfc672b06b0e92a" + url: "https://pub.dev" + source: hosted + version: "4.6.5" holding_gesture: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bd3362aa..e1fd025a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,6 +35,7 @@ dependencies: meta: ^1.0.0 math_keyboard: ^0.1.1 webview_flutter: ^4.0.0 + get: ^4.0.0 dev_dependencies: flutter_test: From d837eb7a8e010c159fb85c9f5dbdabc7ac92484f Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Thu, 11 Jan 2024 09:30:35 +0200 Subject: [PATCH 26/29] CHANGELOG.md and pubspec.yaml --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 195254f8..0e90216c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.1.0] = 2023-1-11 + +* changed how the mathMl to Latex works, now faster + ## [3.1.0] = 2023-1-8 * changed how the latex to mathMl works, now faster diff --git a/pubspec.yaml b/pubspec.yaml index e1fd025a..fbb2d585 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 3.1.0 +version: 3.2.0 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git From cc5e37a2a33a1901e67bef6cb20aed14d7963d6e Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Thu, 11 Jan 2024 09:31:17 +0200 Subject: [PATCH 27/29] CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e90216c..cc22b2c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [3.1.0] = 2023-1-11 +## [3.2.0] = 2023-1-11 * changed how the mathMl to Latex works, now faster From 61da49f955a3f147a892f84d912102574d458666 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Tue, 22 Oct 2024 10:16:57 +0300 Subject: [PATCH 28/29] update dependencies --- example/pubspec.yaml | 2 +- pubspec.lock | 208 ++++++++++++++++++++++++++++++------------- pubspec.yaml | 16 ++-- 3 files changed, 157 insertions(+), 69 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 4baf0f0e..72cf9a63 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter get: ^4.0.0 - math_keyboard: ^0.1.1 + math_keyboard: 0.2.0 html_editor_enhanced_fork_latex: # When depending on this package from a real application you should use: # html_editor_enhanced: ^x.y.z diff --git a/pubspec.lock b/pubspec.lock index ff627f8d..9e50104b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,14 +1,22 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + url: "https://pub.dev" + source: hosted + version: "2.6.0" async: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +29,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +45,18 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "0.3.4+2" fake_async: dependency: transitive description: @@ -53,34 +69,34 @@ packages: dependency: transitive description: name: ffi - sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.3" file_picker: dependency: "direct main" description: name: file_picker - sha256: "9d6e95ec73abbd31ec54d0e0df8a961017e165aba1395e462e5b31ea0c165daf" + sha256: "04a7b85852255759fd3010530cafac250eaa1f8202546670834d25057bb3251a" url: "https://pub.dev" source: hosted - version: "5.3.1" + version: "8.0.0" flex_color_picker: dependency: "direct main" description: name: flex_color_picker - sha256: f37476ab3e80dcaca94e428e159944d465dd16312fda9ff41e07e86f04bfa51c + sha256: "5c846437069fb7afdd7ade6bf37e628a71d2ab0787095ddcb1253bf9345d5f3a" url: "https://pub.dev" source: hosted - version: "3.3.0" + version: "3.4.1" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - sha256: e4168a6fc88a3e5bc3d6b7a748c6a6083eedc193d343ddc26bbad7fb1b258555 + sha256: "4cee2f1d07259f77e8b36f4ec5f35499d19e74e17c7dce5b819554914082bc01" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.5.0" flutter: dependency: "direct main" description: flutter @@ -98,10 +114,10 @@ packages: dependency: "direct main" description: name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "6.0.0" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -151,10 +167,10 @@ packages: dependency: transitive description: name: flutter_math_fork - sha256: fa511bdcb91fc35eac155ec5790883886dd9de6572fea549f1ad4660ef6804e9 + sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" url: "https://pub.dev" source: hosted - version: "0.6.3+1" + version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -167,10 +183,10 @@ packages: dependency: transitive description: name: flutter_svg - sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" + sha256: f991fdb1533c3caeee0cdc14b04f50f0c3916f0dbcbc05237ccbe4e3c6b93f3f url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "2.0.5" flutter_test: dependency: "direct dev" description: flutter @@ -209,34 +225,50 @@ packages: dependency: transitive description: name: intl - sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 url: "https://pub.dev" source: hosted - version: "0.17.0" - js: + version: "2.0.1" + leak_tracker_testing: dependency: transitive description: - name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "2.0.1" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" math_expressions: dependency: transitive description: @@ -249,18 +281,18 @@ packages: dependency: "direct main" description: name: math_keyboard - sha256: "81d465aff32ca5a5976b6e04269848899a55623ddc91723a623b2d6ebca5831e" + sha256: "7a7a644ce4313f31b74bc31c9d522dbdc08e5462dfa7beb4d0973cd4232e9ba3" url: "https://pub.dev" source: hosted - version: "0.1.9" + version: "0.2.0" meta: dependency: "direct main" description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.11.0" nested: dependency: transitive description: @@ -281,18 +313,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" - path_drawing: - dependency: transitive - description: - name: path_drawing - sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 - url: "https://pub.dev" - source: hosted - version: "1.0.1" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -313,18 +337,42 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.1.8" pointer_interceptor: dependency: "direct main" description: name: pointer_interceptor - sha256: acfcd63c00ec3d5a7894b0e2a875893716d31958fe03f064734dba7dfd9113d9 + sha256: "57210410680379aea8b1b7ed6ae0c3ad349bfd56fe845b8ea934a53344b9d523" + url: "https://pub.dev" + source: hosted + version: "0.10.1+2" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: a6906772b3205b42c44614fcea28f818b1e5fdad73a4ca742a7bd49818d9c917 + url: "https://pub.dev" + source: hosted + version: "0.10.1" + pointer_interceptor_platform_interface: + dependency: transitive + description: + name: pointer_interceptor_platform_interface + sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506" + url: "https://pub.dev" + source: hosted + version: "0.10.0+1" + pointer_interceptor_web: + dependency: transitive + description: + name: pointer_interceptor_web + sha256: "7a7087782110f8c1827170660b09f8aa893e0e9a61431dbbe2ac3fc482e8c044" url: "https://pub.dev" source: hosted - version: "0.9.3+5" + version: "0.10.2+1" provider: dependency: transitive description: @@ -342,26 +390,26 @@ 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: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -382,10 +430,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.6.1" tuple: dependency: transitive description: @@ -394,6 +442,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: ea8d3fc7b2e0f35de38a7465063ecfcf03d8217f7962aa2a6717132cb5d43a79 + url: "https://pub.dev" + source: hosted + version: "1.1.5" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: a5eaa5d19e123ad4f61c3718ca1ed921c4e6254238d9145f82aa214955d9aced + url: "https://pub.dev" + source: hosted + version: "1.1.5" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "15edc42f7eaa478ce854eaf1fbb9062a899c0e4e56e775dd73b7f4709c97c4ca" + url: "https://pub.dev" + source: hosted + version: "1.1.5" vector_math: dependency: transitive description: @@ -410,6 +482,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.0+2" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" webview_flutter: dependency: "direct main" description: @@ -446,10 +534,10 @@ packages: dependency: transitive description: name: win32 - sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "5.5.0" xml: dependency: transitive description: @@ -459,5 +547,5 @@ packages: source: hosted version: "6.2.2" sdks: - dart: ">=2.19.0 <3.0.0" - flutter: ">=3.7.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/pubspec.yaml b/pubspec.yaml index fbb2d585..e7433d91 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: html_editor_enhanced_fork_latex description: HTML rich text editor for Android, iOS, and Web, using the Summernote library. Enhanced with highly customizable widget-based controls, bug fixes, callbacks, dark mode, and more. -version: 3.2.0 +version: 4.0.0 homepage: https://github.com/tneotia/html-editor-enhanced repository: https://github.com/AhmadKhateebq/html-editor-enhanced-with-latex.git @@ -13,27 +13,27 @@ dependencies: flutter: sdk: flutter # webview plugin - flutter_inappwebview: ^5.8.0 + flutter_inappwebview: 5.8.0 # plugin to get webview's visible fraction for keyboard height adjustment visibility_detector: ^0.4.0+2 # plugin to get when the keyboard is hidden via back (Android) # or "done" (iOS) to reset the editor's height - flutter_keyboard_visibility: ^5.4.0 + flutter_keyboard_visibility: ^6.0.0 # plugin to show a color picker for foreground/highlight color - flex_color_picker: ^3.3.0 + flex_color_picker: ^3.4.0 # plugin to get files from filesystem - file_picker: ^5.2.0+1 + file_picker: 8.0.0 # plugin to show a scrollable number picker for inserting tables numberpicker: ^2.1.2 # plugin to allow dropdowns and dialogs to be interactable when displaying over the editor # related to https://github.com/flutter/flutter/issues/54027 # pinned to 0.9.1 because of issues with CanvasKit in the latest versions - pointer_interceptor: ^0.9.3+3 + pointer_interceptor: ^0.10.1+2 # plugin to help maintain effective Dart standards # plugin for @internal annotation - meta: ^1.0.0 - math_keyboard: ^0.1.1 + meta: ^1.11.0 + math_keyboard: 0.2.0 webview_flutter: ^4.0.0 get: ^4.0.0 From 6ab28288dfe068afd12da8997ed012a599a21583 Mon Sep 17 00:00:00 2001 From: Ahmad Khateeb Date: Tue, 22 Oct 2024 10:17:37 +0300 Subject: [PATCH 29/29] update dependencies --- example/pubspec.lock | 210 ++++++++++++++++++++++++++++++------------- 1 file changed, 149 insertions(+), 61 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index a0357de7..fb5f6e94 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,14 +1,22 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + url: "https://pub.dev" + source: hosted + version: "2.6.0" async: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -21,10 +29,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -37,10 +45,18 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "0.3.4+2" cupertino_icons: dependency: "direct main" description: @@ -61,34 +77,34 @@ packages: dependency: transitive description: name: ffi - sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.3" file_picker: dependency: transitive description: name: file_picker - sha256: "9d6e95ec73abbd31ec54d0e0df8a961017e165aba1395e462e5b31ea0c165daf" + sha256: "04a7b85852255759fd3010530cafac250eaa1f8202546670834d25057bb3251a" url: "https://pub.dev" source: hosted - version: "5.3.1" + version: "8.0.0" flex_color_picker: dependency: transitive description: name: flex_color_picker - sha256: f37476ab3e80dcaca94e428e159944d465dd16312fda9ff41e07e86f04bfa51c + sha256: "5c846437069fb7afdd7ade6bf37e628a71d2ab0787095ddcb1253bf9345d5f3a" url: "https://pub.dev" source: hosted - version: "3.3.0" + version: "3.4.1" flex_seed_scheme: dependency: transitive description: name: flex_seed_scheme - sha256: e4168a6fc88a3e5bc3d6b7a748c6a6083eedc193d343ddc26bbad7fb1b258555 + sha256: "4cee2f1d07259f77e8b36f4ec5f35499d19e74e17c7dce5b819554914082bc01" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.5.0" flutter: dependency: "direct main" description: flutter @@ -106,10 +122,10 @@ packages: dependency: transitive description: name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "6.0.0" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -159,10 +175,10 @@ packages: dependency: transitive description: name: flutter_math_fork - sha256: fa511bdcb91fc35eac155ec5790883886dd9de6572fea549f1ad4660ef6804e9 + sha256: "94bee4642892a94939af0748c6a7de0ff8318feee588379dcdfea7dc5cba06c8" url: "https://pub.dev" source: hosted - version: "0.6.3+1" + version: "0.7.2" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -175,10 +191,10 @@ packages: dependency: transitive description: name: flutter_svg - sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" + sha256: f991fdb1533c3caeee0cdc14b04f50f0c3916f0dbcbc05237ccbe4e3c6b93f3f url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "2.0.5" flutter_test: dependency: "direct dev" description: flutter @@ -211,7 +227,7 @@ packages: path: ".." relative: true source: path - version: "3.1.0" + version: "4.0.0" infinite_listview: dependency: transitive description: @@ -224,34 +240,50 @@ packages: dependency: transitive description: name: intl - sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 url: "https://pub.dev" source: hosted - version: "0.17.0" - js: + version: "2.0.1" + leak_tracker_testing: dependency: transitive description: - name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "2.0.1" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" math_expressions: dependency: transitive description: @@ -264,18 +296,18 @@ packages: dependency: "direct main" description: name: math_keyboard - sha256: "81d465aff32ca5a5976b6e04269848899a55623ddc91723a623b2d6ebca5831e" + sha256: "7a7a644ce4313f31b74bc31c9d522dbdc08e5462dfa7beb4d0973cd4232e9ba3" url: "https://pub.dev" source: hosted - version: "0.1.9" + version: "0.2.0" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.11.0" nested: dependency: transitive description: @@ -296,18 +328,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" - path_drawing: - dependency: transitive - description: - name: path_drawing - sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 - url: "https://pub.dev" - source: hosted - version: "1.0.1" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -328,18 +352,42 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.1.8" pointer_interceptor: dependency: transitive description: name: pointer_interceptor - sha256: acfcd63c00ec3d5a7894b0e2a875893716d31958fe03f064734dba7dfd9113d9 + sha256: "57210410680379aea8b1b7ed6ae0c3ad349bfd56fe845b8ea934a53344b9d523" + url: "https://pub.dev" + source: hosted + version: "0.10.1+2" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: a6906772b3205b42c44614fcea28f818b1e5fdad73a4ca742a7bd49818d9c917 + url: "https://pub.dev" + source: hosted + version: "0.10.1" + pointer_interceptor_platform_interface: + dependency: transitive + description: + name: pointer_interceptor_platform_interface + sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506" + url: "https://pub.dev" + source: hosted + version: "0.10.0+1" + pointer_interceptor_web: + dependency: transitive + description: + name: pointer_interceptor_web + sha256: "7a7087782110f8c1827170660b09f8aa893e0e9a61431dbbe2ac3fc482e8c044" url: "https://pub.dev" source: hosted - version: "0.9.3+5" + version: "0.10.2+1" provider: dependency: transitive description: @@ -357,26 +405,26 @@ 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: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -397,10 +445,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.6.1" tuple: dependency: transitive description: @@ -409,6 +457,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: ea8d3fc7b2e0f35de38a7465063ecfcf03d8217f7962aa2a6717132cb5d43a79 + url: "https://pub.dev" + source: hosted + version: "1.1.5" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: a5eaa5d19e123ad4f61c3718ca1ed921c4e6254238d9145f82aa214955d9aced + url: "https://pub.dev" + source: hosted + version: "1.1.5" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "15edc42f7eaa478ce854eaf1fbb9062a899c0e4e56e775dd73b7f4709c97c4ca" + url: "https://pub.dev" + source: hosted + version: "1.1.5" vector_math: dependency: transitive description: @@ -425,6 +497,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.0+2" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" webview_flutter: dependency: transitive description: @@ -461,10 +549,10 @@ packages: dependency: transitive description: name: win32 - sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "5.5.0" xml: dependency: transitive description: @@ -474,5 +562,5 @@ packages: source: hosted version: "6.2.2" sdks: - dart: ">=2.19.0 <3.0.0" - flutter: ">=3.7.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0"