Skip to content
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

feat(extensions)!: Overwrite built-in List/Ordered toggle functions with a smartToggle option #620

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

rfgamaral
Copy link
Member

@rfgamaral rfgamaral commented Jan 18, 2024

Overview

While updating our apps with v2.3.1, I realized that keyboard shortcuts were not using the new smartToggle*List commands, which prompted this PR.

This basically rewrites the extensions to overwrite the built-in toggle*List functions, where we replace hard breaks with paragraphs based on the smartToggle option that can now be passed into the bulletList and orderedList extensions. By default, this value is false and hard breaks are NOT replaced (just like the default and built-in behaviour), otherwise, if true, hard breaks are replaced with paragraphs, thus "smartly toggling" paragraphs/lines into bullet/ordered lists.

PR Checklist

Test plan

  • Open the preview Storybook deployed to Netlify
  • Open the Rich-text → Default story
  • Write some paragraphs, some with newlines, others without
  • Make a selection of those paragraphs (select everything, select them partially, etc.)
  • Click the Bullet List or Ordered List buttons in the editor toolbar
    • Observe that each selected paragraph and/or newline (even partially), is converted into a bullet/ordered list
  • Undo the changes to have the initial content that you wrote on step 3
  • Use the Mod-Shift+7 to toggle the selection into an ordered list
    • Observe that each selected paragraph and/or newline (even partially), is converted into a bullet/ordered list
  • Undo the changes to have the initial content that you wrote on step 3
  • Use the Mod-Shift+8 to toggle the selection into a bullet list
    • Observe that each selected paragraph and/or newline (even partially), is converted into a bullet/ordered list

Note

Mod is usually Ctrl on Windows, and Cmd on macOS.

…ith a `smartToggle` option

BREAKING CHANGE: The `smartToggleBulletList` and
`smartToggleOrderedList` commands were renamed to have the same name as
the built-in toggle functions so that they can easily be used by the
default keyboard shortcuts without having to change the
`addKeyboardShortcuts` function.

The `BulletList` and `OrderedList` extensions now take an additional
option, `smartToggle` (default: `false`), that indicates whether hard
breaks should be replaced by paragraphs before toggling the
selection into a bullet/ordered list, or not.
@rfgamaral rfgamaral added the 🙋 Ask PR Used for PRs that need a review before merging. label Jan 18, 2024
@rfgamaral rfgamaral requested a review from gnapse January 18, 2024 15:08
@rfgamaral rfgamaral self-assigned this Jan 18, 2024
Copy link

netlify bot commented Jan 18, 2024

Deploy Preview for doist-typist ready!

Name Link
🔨 Latest commit 53069d2
🔍 Latest deploy log https://app.netlify.com/sites/doist-typist/deploys/65a93ee81b49430008889839
😎 Deploy Preview https://deploy-preview-620--doist-typist.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rfgamaral rfgamaral merged commit 059da61 into main Jan 18, 2024
12 checks passed
@rfgamaral rfgamaral deleted the ricardo/refactor-bullet-ordered-list-extensions branch January 18, 2024 16:02
doistbot added a commit that referenced this pull request Jan 18, 2024
## [3.0.0](v2.3.1...v3.0.0) (2024-01-18)

### ⚠ BREAKING CHANGES

* **extensions:** The `smartToggleBulletList` and
`smartToggleOrderedList` commands were renamed to have the same name as
the built-in toggle functions so that they can easily be used by the
default keyboard shortcuts without having to change the
`addKeyboardShortcuts` function.

The `BulletList` and `OrderedList` extensions now take an additional
option, `smartToggle` (default: `false`), that indicates whether hard
breaks should be replaced by paragraphs before toggling the
selection into a bullet/ordered list, or not.

### Features

* **extensions:** Overwrite built-in List/Ordered toggle functions with a `smartToggle` option ([#620](#620)) ([059da61](059da61))
@doistbot
Copy link
Member

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@doistbot doistbot added the released Pull requests that have been released to production label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Ask PR Used for PRs that need a review before merging. released Pull requests that have been released to production
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants