-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split control for URL and Text within Link UI (#33849)
* Implement basic mechanics and UI * Grab the selected/link text to use in Link UI * Try to update the existing value with the new link and text * Retain existing formats when applying new link format * Document scenarios for clarity * Only show text control once a link has been committed * Strip HTML from Link Preview * Strip HTML from link text control * Allow submission of text changes via enter key * Ensure user provided text has length before commiting as label value * Migrate to using existing title prop of LinkControl * Undo overzealous stripping of HTML. Leave this to escape on output. Fixes issue whereby leading/trailing spaces would be stripped off the text value. HTML is stripped out on render in the LinkControl now so we should be all ok. * No change to text should preserve all formatting * Avoid complications of preserving existing formats when amending link text via LinkControl * Expand boundary seek algorithm in order to fix bugs We'll circle back shortly to simplify this. * Abstract walking loops to functions * Reduce and simplify boundary algorithm * Avoid reassignment of startIndex and prefer self documenting variable * Improve edge case handling and function naming * Add initial unit tests for Text control * Add tests for more edge cases * Correct text naming * Don't modify value internally. * Add tests to ensure LinkControl does not modify the value's title property * Have Nav Link block strip HTML formatting before passing to LinkControl * Avoid passing new function ref for handleSubmit * Remove outdated reference to `text` prop of value * Add guard against empty label * Move utils to utils to expose for testing purposes * Slice target text +1 beyond the end of the format boundary * Add tests for getFormatValue and adjust implementation to get correct bounds * Augment tests for getFormatBoundary * Fix bug whereby rich text value passed to LinkControl when no active link format present * Extract function for retrieving RichTextValue for a given selection * Add basic e2e tests for link text * Add test for preservation of whitespace * Add e2e test covering modification of link text via Link UI * Ensure focus is reliably placed within Link UI * Fix test name typo * Standardise test nomenclature on "submit" not "commit" * Restore avoiding focus on mount to ensure collapsed selection can be made * Improve e2e test code comments to explain creation of a collapsed selection * Remove duplicate test * Add doc block to getFormatBoundary function * Conditionally show the visible URL input label * Remove magic numbers from submit button positioning Resolves #33849 (comment) * Fix overflow bug introduced in earlier commit * Remove stripHTML dependency and hand roll internal method * Re-inline utility function to simplify. * Reduce verbosity of walkToBoundary method * Add doc block to walkToBoundary * Refactor to reduce verbosity of getFormatBoundary * Improve comments and self documentation of e2e test Attempts to address #33849 (comment) * Remove unwanted comment * Rename helper util to disambiguate from text input focus * Refine e2e tests Avoid need to show the block toolbar and also avoid forcing stress testing the collapsed selection. Addresses #33849 (comment) * Rename an annotate unit tests * Ensure boundary tests actually exercise code under test * Refactor getFormatBoundary to handle more edge cases and put more of the code under test * Fix to target icon based Edit button * For currently active links use the full link text as the value of LinkControl ignoring any text selection Resolves #33849 (review) * Conform to style guide for coercion of Booleans * Fix outdated test helper refs
- Loading branch information
Showing
10 changed files
with
1,115 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.