Added custom callback to transform a link before it is launched#2727
Open
Alspb wants to merge 3 commits into
Open
Added custom callback to transform a link before it is launched#2727Alspb wants to merge 3 commits into
Alspb wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new editor configuration callback to allow callers to transform/normalize a link string immediately before it is launched from a tap inside the editor, enabling custom schemes or alternative prefixing logic.
Changes:
- Added
transformLinktoQuillEditorConfigandQuillRawEditorConfigand wired it throughQuillEditor→QuillRawEditor→ text widgets. - Updated link-tap handling in
TextLineto applytransformLink(or fall back to the existing defaulthttps://prefixing behavior). - Added widget tests verifying both custom transformation behavior and default prefix behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/editor/editor_test.dart | Adds widget tests covering transformLink override and default https:// prefixing. |
| lib/src/editor/widgets/text/text_line.dart | Applies transformLink (or default transform) before calling the URL launcher callback. |
| lib/src/editor/widgets/text/text_block.dart | Plumbs transformLink through block rendering to TextLine. |
| lib/src/editor/raw_editor/raw_editor_state.dart | Forwards transformLink from raw editor config into text widgets. |
| lib/src/editor/raw_editor/config/raw_editor_config.dart | Introduces transformLink API on raw editor config with documentation. |
| lib/src/editor/editor.dart | Wires QuillEditorConfig.transformLink into QuillRawEditorConfig. |
| lib/src/editor/config/editor_config.dart | Introduces transformLink API on editor config + copyWith support and documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+692
to
696
| final transformLink = widget.transformLink ?? _transformLink; | ||
| link = transformLink(link); | ||
|
|
||
| // TODO(EchoEllet): Refactor onLaunchUrl or add a new API to give full control of the launch? See https://github.com/singerdmx/flutter-quill/issues/1776 | ||
| final launchUrl = widget.onLaunchUrl ?? _launchUrl; | ||
| launchUrl(link); |
Comment on lines
+433
to
+438
| /// Callback to transform a link before it is launched on tap in the editor. | ||
| /// | ||
| /// Receives the trimmed link string and returns the final URL to launch. | ||
| /// When not set (`null`), the link is validated against known prefixes and | ||
| /// `https://` is prepended if no recognized prefix is found. | ||
| final String Function(String link)? transformLink; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a
transformLinkcallback toQuillEditorConfigthat lets callers control how a linkis transformed before it is launched. This is used when tapping links within the editor.
Previously, the editor unconditionally prepended
https://to any link that didn't match aknown scheme. This is too rigid — it breaks workflows that rely on scheme-less links such as
local file paths.
When
transformLinkisnull, the existing behavior is preserved, so this is a non-breakingchange.
Type of Change