Skip to content

Commit

Permalink
Bug fix and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoEllet committed Oct 28, 2023
1 parent 2610dab commit c2d1942
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 151 deletions.
10 changes: 3 additions & 7 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
---
name: Issue template
about: Common things to fill
title: "[Web] or [Mobile] or [Desktop]"
title: "Issue in [Mobile, Desktop, Web]"
labels: ''
assignees: ''

---

My issue is about [Web]
My issue is about [Mobile]
My issue is about [Desktop]

I have tried running `example` directory successfully before creating an issue here.

Please note that we are using <b>latest</b> flutter version in stable channel on branch master. If you are using beta or master channel, or you are not using <b>latest</b> flutter version in stable channel, you may experience error.

<!-- Did you try the running `example` directory?? How does it goes -->

<!-- Please explain how to encounter the issue in details if possible -->

<!-- Don't forgot to mention the platform you are testing in -->
Expand Down
65 changes: 65 additions & 0 deletions lib/src/models/config/toolbar/buttons/link_style2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import 'package:flutter/widgets.dart';

import '../../../../widgets/controller.dart';
import '../../../themes/quill_dialog_theme.dart';
import '../../../themes/quill_icon_theme.dart';
import 'base.dart';

class QuillToolbarLinkStyleButton2ExtraOptions
extends QuillToolbarBaseButtonExtraOptions {
const QuillToolbarLinkStyleButton2ExtraOptions({
required super.controller,
required super.context,
required super.onPressed,
});
}

class QuillToolbarLinkStyleButton2Options extends QuillToolbarBaseButtonOptions<
QuillToolbarLinkStyleButton2Options,
QuillToolbarLinkStyleButton2ExtraOptions> {
const QuillToolbarLinkStyleButton2Options({
this.iconSize,
this.dialogTheme,
this.constraints,
this.addLinkLabel,
this.editLinkLabel,
this.linkColor,
this.validationMessage,
this.buttonSize,
this.dialogBarrierColor,
this.childrenSpacing = 16.0,
this.autovalidateMode = AutovalidateMode.disabled,
super.iconData,
super.afterButtonPressed,
super.tooltip,
super.iconTheme,
super.childBuilder,
super.controller,
});

final double? iconSize;
final QuillDialogTheme? dialogTheme;

/// The constrains for dialog.
final BoxConstraints? constraints;

/// The text of label in link add mode.
final String? addLinkLabel;

/// The text of label in link edit mode.
final String? editLinkLabel;

/// The color of URL.
final Color? linkColor;

/// The margin between child widgets in the dialog.
final double childrenSpacing;

final AutovalidateMode autovalidateMode;
final String? validationMessage;

/// The size of dialog buttons.
final Size? buttonSize;

final Color? dialogBarrierColor;
}
2 changes: 2 additions & 0 deletions lib/src/models/config/toolbar/buttons/select_alignment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class QuillToolbarSelectAlignmentButtonOptions
this.tooltips,
this.iconSize,
super.afterButtonPressed,

/// This will called on every select alignment button
super.childBuilder,
super.controller,
super.iconTheme,
Expand Down
17 changes: 9 additions & 8 deletions lib/src/models/config/toolbar/buttons/select_header_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ class QuillToolbarSelectHeaderStyleButtonsOptions
super.afterButtonPressed,
super.childBuilder,
super.controller,
super.iconData,
super.iconTheme,
super.tooltip,
this.axis,
this.attributes = const [
Attribute.header,
Attribute.h1,
Attribute.h2,
Attribute.h3,
],
this.attributes,
this.iconSize,
});

final List<Attribute> attributes;
/// Default value:
/// const [
/// Attribute.header,
/// Attribute.h1,
/// Attribute.h2,
/// Attribute.h3,
/// ]
final List<Attribute>? attributes;

/// By default we will the toolbar axis from [QuillToolbarConfigurations]
final Axis? axis;
Expand Down
14 changes: 7 additions & 7 deletions lib/src/models/rules/insert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ class AutoFormatMultipleLinksRule extends InsertRule {
// TODO: You might want to rename those but everywhere even in
// flutter_quill_extensions

static const _oneLinePattern =
static const _oneLineLinkPattern =
r'^https?:\/\/[\w\-]+(\.[\w\-]+)*(:\d+)?(\/.*)?$';
static const _detectLinkPattern =
r'https?:\/\/[\w\-]+(\.[\w\-]+)*(:\d+)?(\/[^\s]*)?';

/// It requires a valid link in one link
static final oneLineRegExp = RegExp(
_oneLinePattern,
static final oneLineLinkRegExp = RegExp(
_oneLineLinkPattern,
caseSensitive: false,
);

Expand All @@ -375,10 +375,10 @@ class AutoFormatMultipleLinksRule extends InsertRule {
_detectLinkPattern,
caseSensitive: false,
);
@Deprecated(
'Please use [linkRegExp1] or [linkRegExp2]',
)
static final linkRegExp = oneLineRegExp;
// @Deprecated(
// 'Please use [linkRegExp1] or [linkRegExp2]',
// )
static final linkRegExp = oneLineLinkRegExp;

@override
Delta? applyRule(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/toolbar/buttons/arrow_indicated_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class QuillToolbarArrowIndicatedButtonList extends StatefulWidget {
const QuillToolbarArrowIndicatedButtonList({
required this.axis,
required this.buttons,
Key? key,
}) : super(key: key);
super.key,
});

final Axis axis;
final List<Widget> buttons;
Expand Down
18 changes: 10 additions & 8 deletions lib/src/widgets/toolbar/buttons/link_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ class _QuillToolbarLinkStyleButtonState
context.requireQuillSharedConfigurations.dialogBarrierColor;
}

RegExp get linkRegExp {
return options.linkRegExp ?? RegExp(r'https?://\S+');
RegExp? get linkRegExp {
return options.linkRegExp;
}

@override
Widget build(BuildContext context) {
final isToggled = _getLinkAttributeValue() != null;
final pressedHandler = () => _openLinkDialog(context);

final childBuilder =
options.childBuilder ?? baseButtonExtraOptions.childBuilder;
Expand All @@ -124,7 +123,7 @@ class _QuillToolbarLinkStyleButtonState
context: context,
controller: controller,
onPressed: () {
pressedHandler();
_openLinkDialog(context);
afterButtonPressed?.call();
},
),
Expand All @@ -144,10 +143,10 @@ class _QuillToolbarLinkStyleButtonState
: (iconTheme?.iconUnselectedColor ?? theme.iconTheme.color),
),
fillColor: isToggled
? (iconTheme?.iconSelectedFillColor ?? Theme.of(context).primaryColor)
? (iconTheme?.iconSelectedFillColor ?? theme.primaryColor)
: (iconTheme?.iconUnselectedFillColor ?? theme.canvasColor),
borderRadius: iconTheme?.borderRadius ?? 2,
onPressed: pressedHandler,
onPressed: () => _openLinkDialog(context),
afterPressed: afterButtonPressed,
);
}
Expand Down Expand Up @@ -236,7 +235,11 @@ class _LinkDialog extends StatefulWidget {
class _LinkDialogState extends State<_LinkDialog> {
late String _link;
late String _text;
late RegExp linkRegExp;

RegExp get linkRegExp {
return widget.linkRegExp ?? AutoFormatMultipleLinksRule.oneLineLinkRegExp;
}

late TextEditingController _linkController;
late TextEditingController _textController;

Expand All @@ -245,7 +248,6 @@ class _LinkDialogState extends State<_LinkDialog> {
super.initState();
_link = widget.link ?? '';
_text = widget.text ?? '';
linkRegExp = widget.linkRegExp ?? AutoFormatMultipleLinksRule.oneLineRegExp;
_linkController = TextEditingController(text: _link);
_textController = TextEditingController(text: _text);
}
Expand Down
Loading

0 comments on commit c2d1942

Please sign in to comment.