Skip to content

feat: allow to override link validation check, and accept mailto and other links by default #2525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

EchoEllet
Copy link
Collaborator

@EchoEllet EchoEllet commented Mar 27, 2025

Description

Allow the toolbar to insert links like mailto by default, allow to override the link validation with a callback rather than Regex to give users more control, improve doc comment of customLinkPrefixes and legacy code and confusing naming, adharing to common best practices.

  • The customLinkPrefixes which is in the editor, is only used to check whether this link is valid, if it's invalid, https:// will be appended as prefix to the link (google.com -> https://google.com).
  • The validateLink in QuillToolbarLinkStyleButtonOptions allows the validation check to be overridden to determine whether this link can be inserted.

However, AutoFormatMultipleLinksRule still uses the old regex and doesn't support mailto and the others.

To test this branch:

dependency_overrides:
  flutter_quill:
    git:
      url: https://github.com/singerdmx/flutter-quill.git
      ref: fix/1776

Related Issues

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

@EchoEllet EchoEllet requested review from singerdmx and CatHood0 March 27, 2025 12:35
@EchoEllet EchoEllet changed the title feat: improve link validation feat: allow to override link validation check, and accept mailto and other links by default Mar 27, 2025
Copy link
Collaborator

@CatHood0 CatHood0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll test it as soon as possible.

@CatHood0
Copy link
Collaborator

My bad jasj.

@EchoEllet
Copy link
Collaborator Author

I will change to draft and add the tests soon before merging this PR.

@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart' show experimental;

import '../../../internal.dart' show AutoFormatMultipleLinksRule;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import should be updated to use the insert.dart file directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants