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: added placeholder example #1252

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

Conversation

ezhil56x
Copy link
Contributor

Fixes #1242
/claim #1242

Added an example for placeholder

image

Copy link

vercel bot commented Nov 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Nov 18, 2024 11:04am
blocknote-website ✅ Ready (Inspect) Visit Preview Nov 18, 2024 11:04am

Copy link

vercel bot commented Nov 16, 2024

@ezhil56x is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@Blapi
Copy link

Blapi commented Nov 17, 2024

This only works for en locales, if your locale is set to french it won't work, how would you handle that depending on the user locale then?

@ezhil56x
Copy link
Contributor Author

@Blapi Updated, now the user locale can be set

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

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

nice, some requests commented, then we should be good

const editor = useCreateBlockNote({
dictionary: {
...locales[userLocale],
placeholders: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Besides the default, please also show how you can change the "heading" placeholder

Copy link
Collaborator

Choose a reason for hiding this comment

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

add a comment to explain code

// We override the `placeholders` in our dictionary


export default function App() {
// Set the user locale.
const userLocale = "en";
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's change to

// We use the English, default dictionary
const locale = locales["en";]

...locales[userLocale],
placeholders: {
...locales[userLocale].placeholders,
default: placeholder ?? locales[userLocale].placeholders.default,
Copy link
Collaborator

Choose a reason for hiding this comment

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

just pass in "This is a custom placeholder" directly, and remove the placeholder variable

@@ -0,0 +1,3 @@
# Placeholder

In this example, we pass in a custom placeholder to change the placeholder text of the editor.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this example, we customize the dictionary to pass in custom placeholder texts. This way, we change the text of an empty block (and empty heading block) in the editor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, follow the default template and add a link to relevant docs, same as on https://www.blocknotejs.org/examples/basic/localization

"Basic"
]
},
"title": "Placeholder",
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Custom placeholder"

@@ -0,0 +1,3 @@
# Placeholder
Copy link
Collaborator

Choose a reason for hiding this comment

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

# Change placeholder text

@ezhil56x
Copy link
Contributor Author

2024-11-18.10-06-45.mp4

@YousefED Updated my PR

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

Successfully merging this pull request may close these issues.

How to change the placeholder
3 participants