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

Is there a way to use CodeMirror's placeholder extension? #53

Closed
davidcelis opened this issue Feb 2, 2023 · 3 comments · Fixed by #55
Closed

Is there a way to use CodeMirror's placeholder extension? #53

davidcelis opened this issue Feb 2, 2023 · 3 comments · Fixed by #55
Labels
enhancement New feature or request

Comments

@davidcelis
Copy link

Hello! First off, thank you so much for Ink. I've been wanting to plug a markdown editor into my personal Rails site for a while and was dreading it, but I couldn't believe how easy it was to put Ink into an import map and just plug it in.

I was wondering if there's an out-of-the-box way to use CodeMirror 6's placeholder extension to get a… well, placeholder into my editor 😄 It's easy enough to provide an initial doc but it would be even better to get true placeholder functionality so that it isn't considered content and is automatically overridden as soon as content is typed in.

@davidmyersdev
Copy link
Owner

Hey there, @davidcelis! It's definitely possible to supply a CodeMirror extension to Ink, but I actually think it makes sense to support this one natively! If you don't want to wait, you can supply an extension to Ink like this, but keep in mind the API for extensions might change in future versions (as I'm still figuring out the best interface for different extension types).

import { placeholder } from '@codemirror/view'
import { ink } from 'ink-mde'

ink(document.querySelector('#editor'), {
  extensions: [
    { type: 'default', value: placeholder() },
  ],
})

@davidmyersdev davidmyersdev added the enhancement New feature or request label Feb 3, 2023
@davidcelis
Copy link
Author

Oh, awesome! Native support would definitely be best and I'm happy to wait for that 🙌

@davidmyersdev
Copy link
Owner

@davidcelis this is available in v0.20.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants