-
Notifications
You must be signed in to change notification settings - Fork 435
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(core): add default markdown behaviors to PTE #8168
Conversation
This change extends the core behaviors of PTE with default markdown behaviors for a more pleasant writing experience. This allows you to: 1. Use `#` characters to create headings 2. Use `>` to create a blockquote 3. Use `Backspace` at the beginning of block to clear its style 4. Use `-`, `*`, `_` or `1.` to initiate a list This is achieved by providing the `behaviors` configuration for PTE where the `coreBehaviors` are first spread into the array (to preserve core behaviors) and the additional markdown behaviors are added afterwards. The markdown behaviors require us to define what styles to use, and here we just default to the most common names for these. Later, we can figure out how to allow you to configure markdown behaviors through the Schema, but for now these sensible defaults are hard-coded. The only downsides here is that: 1. You can't opt out of markdown behaviors if you for some reason don't like them 2. You can't change the configuration if for example your lists are named something else 3. Things could potentially get confusing if you use unconventional names for styles and lists, for example if `h1` means something completely different in your context. These are downsides we'll have to live with for now.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!! ✨
No changes to documentation |
Component Testing Report Updated Jan 3, 2025 1:49 PM (UTC) ❌ Failed Tests (1) -- expand for details
|
⚡️ Editor Performance ReportUpdated Fri, 03 Jan 2025 13:50:31 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesss! Finally!
Do you have a follow up ticket to allow users to customize this through the schema? It would be great to support that
Thanks for building this!
We don't. But we should! We definitely want to support this in the future.
Thank you 🙇 |
Description
This change extends the core behaviors of PTE with default markdown behaviors for a more pleasant writing experience. This allows you to:
#
characters to create headings>
to create a blockquoteBackspace
at the beginning of block to clear its style-
,*
,_
or1.
to initiate a listThis is achieved by providing the
behaviors
configuration for PTE where thecoreBehaviors
are first spread into the array (to preserve core behaviors) and the additional markdown behaviors are added afterwards. The markdown behaviors require us to define what styles to use, and here we just default to the most common names for these. Later, we can figure out how to allow you to configure markdown behaviors through the Schema, but for now these sensible defaults are hard-coded.The only downsides here is that:
h1
means something completely different in your context.These are downsides we'll have to live with for now.
What to review
Test the new writing experience and see if you like it!
Testing
These markdown behaviors are already used in Create and are backed by automatic tests in the PTE repo: https://github.com/portabletext/editor/blob/main/packages/editor/gherkin-spec/behavior.markdown.feature
Notes for release
The Portable Text Editor now ships with markdown keyboard shortcuts for headings, block quotes and lists