Skip to content

Commit

Permalink
feat(TM-38113): Restructure Quill Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed Jun 20, 2024
1 parent 98c291d commit b2450c6
Show file tree
Hide file tree
Showing 11 changed files with 397 additions and 456 deletions.
25 changes: 5 additions & 20 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "bae5e49bc2a867403c43b2aae2de8f8c33b037e4"
revision: "761747bfc538b5af34aa0d3fac380f1bc331ec49"
channel: "stable"

project_type: app
Expand All @@ -13,26 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
- platform: android
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
- platform: ios
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
- platform: linux
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
- platform: macos
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
- platform: web
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
- platform: windows
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
create_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49
base_revision: 761747bfc538b5af34aa0d3fac380f1bc331ec49

# User provided section

Expand Down
52 changes: 39 additions & 13 deletions example/lib/pages/components/quill_editor_demo.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_quill/extensions.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:zds_flutter/zds_flutter.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';

///Example for htmlEditor
class QuillEditorDemo extends StatefulWidget {
Expand All @@ -17,7 +19,7 @@ class _QuillEditorDemoState extends State<QuillEditorDemo> {
void initState() {
super.initState();
ZdsQuillDelta.fromHtml('''
<h1>H1 heading</h1><h2>H2 Heading</h2><h3>H3 Heading</h3><p>Normal <br/><strong>Because</strong></p>
<h3>Google Doodles</h3><p><br/><img style="max-width: 100%;object-fit: contain" src="https://www.google.com/logos/doodles/2024/celebrating-chilaquiles-6753651837110223-2xa.gif"/><br><br/></p><p style="text-align:justify">Doodles celebrate a wide range of events, from national holidays like Independence Day and Christmas to special occasions like the anniversary of the first moon landing or the birth of significant figures in history such as Albert Einstein and Frida Kahlo.</p>
''').then((value) {
controller.document = value.document;
});
Expand All @@ -32,17 +34,20 @@ class _QuillEditorDemoState extends State<QuillEditorDemo> {
IconButton(
icon: const Icon(Icons.html),
onPressed: () {
final html = ZdsQuillDelta(document: controller.document).toHtml();
showDialog(
context: context,
builder: (context) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.7),
child: Dialog(
child: ZdsCard(
child: Text(ZdsQuillDelta(document: controller.document).toHtml()),
),
),
);
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.7),
child: Dialog(
child: SingleChildScrollView(
child: Column(
children: [
Text(html),
],
),
)));
},
);
},
Expand All @@ -55,8 +60,20 @@ class _QuillEditorDemoState extends State<QuillEditorDemo> {
ZdsQuillEditorPage.edit(
context,
title: 'Edit Notes',
embedBuilders: getEmbedBuilders(),
initialDelta: ZdsQuillDelta(document: controller.document),
charLimit: 20000,
embedButtons: FlutterQuillEmbeds.toolbarButtons(
videoButtonOptions: null,
imageButtonOptions: QuillToolbarImageButtonOptions(
imageButtonConfigurations: QuillToolbarImageConfigurations(
onImageInsertCallback: (image, controller) async {
// Upload to cloud
controller.insertImageBlock(imageSource: image);
},
),
),
),
).then((value) {
if (value != null) {
controller.document = value.document;
Expand All @@ -67,11 +84,11 @@ class _QuillEditorDemoState extends State<QuillEditorDemo> {
body: Column(
children: [
Expanded(
child: QuillEditor.basic(
configurations: QuillEditorConfigurations(
padding: const EdgeInsets.all(16),
controller: controller,
),
child: ZdsQuillEditor(
controller: controller,
readOnly: true,
padding: const EdgeInsets.all(16),
embedBuilders: getEmbedBuilders(),
focusNode: FocusNode(canRequestFocus: false),
),
),
Expand All @@ -80,3 +97,12 @@ class _QuillEditorDemoState extends State<QuillEditorDemo> {
);
}
}

/// default embed builders
List<EmbedBuilder> getEmbedBuilders() {
if (isWeb()) {
return FlutterQuillEmbeds.editorWebBuilders();
} else {
return FlutterQuillEmbeds.editorBuilders();
}
}
2 changes: 2 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import device_info_plus
import file_selector_macos
import flutter_image_compress_macos
import flutter_inappwebview_macos
import gal
import irondash_engine_context
import just_audio
import package_info_plus
Expand All @@ -30,6 +31,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterImageCompressMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterImageCompressMacosPlugin"))
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
GalPlugin.register(with: registry.registrar(forPlugin: "GalPlugin"))
IrondashEngineContextPlugin.register(with: registry.registrar(forPlugin: "IrondashEngineContextPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
Expand Down
7 changes: 7 additions & 0 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ PODS:
- FlutterMacOS
- OrderedSet (~> 5.0)
- FlutterMacOS (1.0.0)
- gal (1.0.0):
- Flutter
- FlutterMacOS
- irondash_engine_context (0.0.1):
- FlutterMacOS
- just_audio (0.0.1):
Expand Down Expand Up @@ -51,6 +54,7 @@ DEPENDENCIES:
- flutter_image_compress_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_image_compress_macos/macos`)
- flutter_inappwebview_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_inappwebview_macos/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- gal (from `Flutter/ephemeral/.symlinks/plugins/gal/darwin`)
- irondash_engine_context (from `Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos`)
- just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
Expand Down Expand Up @@ -82,6 +86,8 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/flutter_inappwebview_macos/macos
FlutterMacOS:
:path: Flutter/ephemeral
gal:
:path: Flutter/ephemeral/.symlinks/plugins/gal/darwin
irondash_engine_context:
:path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos
just_audio:
Expand Down Expand Up @@ -116,6 +122,7 @@ SPEC CHECKSUMS:
flutter_image_compress_macos: c26c3c13ea0f28ae6dea4e139b3292e7729f99f1
flutter_inappwebview_macos: 9600c9df9fdb346aaa8933812009f8d94304203d
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
gal: 61e868295d28fe67ffa297fae6dacebf56fd53e1
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
just_audio: 9b67ca7b97c61cfc9784ea23cd8cc55eb226d489
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
Expand Down
Loading

0 comments on commit b2450c6

Please sign in to comment.