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

Default placeholder changing problem #403

Closed
gkhngyk opened this issue Oct 30, 2023 · 6 comments · Fixed by #503 or #609
Closed

Default placeholder changing problem #403

gkhngyk opened this issue Oct 30, 2023 · 6 comments · Fixed by #503 or #609
Labels
enhancement New feature or request

Comments

@gkhngyk
Copy link

gkhngyk commented Oct 30, 2023

Hello,

I don't use the slash menu, but in the placeholder of each block it says Enter text or type '/' for commands. I couldn't change this placeholder no matter what I did.

Is there any way to change it?

@gkhngyk gkhngyk added the enhancement New feature or request label Oct 30, 2023
@nacho-villanueva
Copy link

nacho-villanueva commented Nov 3, 2023

A hacky way to change the placeholder is like this:

import styles from "./editor.module.css"

 const editor: BlockNoteEditor = useBlockNote({
        domAttributes: {
            blockContent: { class: styles.myBlockContent },
            inlineContent: { class: styles.myInlineContent }
        }
    });

editor.module.css

/* You can replace the data-content-type="heading" to "paragraph" or which ever block type you want to change the placeholder of.*/
.my-block-content[data-content-type="heading"] .my-inline-content:before {
    content: "Custom Placeholder" !important;
}

I don't think there is another way to change it right now.

@nacho-villanueva
Copy link

Nevermind. Doesn't work. You need to access the internal css classes.

@matthewlipski
Copy link
Collaborator

Yep this is a problem indeed, planning to get rid of CSS modules so that external style sheets can have access to those classes which should at least make it possible to change them.

@achrefBoukhili
Copy link

@gkhngyk there is a draft PR for this #188
but no plan yet to introduce it

@hncheung9
Copy link

I would like to fix my placeholder too. When using editor with short width, the default placeholder take 2 rows and will block the content of the next noteblock. In the last noteblock, placeholder would extend out of the editor area. Although it will not affect usability, any customisation would be appreciated!

Screenshot 2023-11-16 at 11 27 31 A Screenshot 2023-11-16 at 11 28 54 AM M

@dogfootruler-kr
Copy link

dogfootruler-kr commented Jan 23, 2024

I managed to change the default placeholder by adding a data attribute to the inline-content then setting the content of the before to the value of this data attribute like this:

const editor: BlockNoteEditor = useBlockNote({
    domAttributes: {
      inlineContent: {
        "data-placeholder": "This is my new placeholder"
      }
    },
});

and adding this to my global.css file:

.bn-editor .bn-block-content[data-content-type=paragraph].bn-is-empty .bn-inline-content::before {
  content: attr(data-placeholder);
}

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
None yet
6 participants