Skip to content

feat(@clack/core,@clack/prompts): Multiline text input #240

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MacFJA
Copy link
Contributor

@MacFJA MacFJA commented Feb 27, 2025

Add a new prompt: MultiLinePrompt and its rendering multiline

Changes

Added to @clack/core

  • Option to change the key that submit a prompt (default value is return to keep retro-compatibility)
  • A new event that send the raw char and key
  • A new util function (isSameKey) to test if two key are the same (with ctrl, meta, shift included in the check)
  • A new prompt MultiLinePrompt

Added to @clack/prompts

  • A new prompt function multiline

Difficulties and workaround

Issue: The return key is used to submit the prompt and is hardcoded, so impossible to insert new line
Solution: Make the submit key configurable (see: packages/core/src/prompts/prompt.ts:{22,53,210})

Issue: The default cursor management use vim mapping, so when pressing letter k, j, h or l to add those letter, the cursor also moves.
Solution: Re-implementing of the cursor management without vim mapping (see packages/core/src/prompts/multi-line.ts:29)

Issue: The event key lower the inputted char, so uppercased char are never displayed
Solution: Create a new event rawKey to send the untouched value (also used for the cursor management)


  • This PR (except if I miss something) don't create incompatibility with existing usage of the library (as it add new feature, and core changes have default value that behave as it was before)
  • This PR fix the issue [Feature Request] Multiline text #25

Copy link

changeset-bot bot commented Feb 27, 2025

⚠️ No Changeset found

Latest commit: 1993b93

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Mar 18, 2025

Open in Stackblitz@example/basic@example/changesets

npm i https://pkg.pr.new/bombshell-dev/clack/@clack/core@240
npm i https://pkg.pr.new/bombshell-dev/clack/@clack/prompts@240

commit: 83b63b2

@natemoo-re natemoo-re self-requested a review March 18, 2025 14:42
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Wow great stuff, thank you for contributing!

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

Successfully merging this pull request may close these issues.

2 participants