TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
6.56k stars 450 forks source link

Default placeholder changing problem #403

Closed gkhngyk closed 7 months ago

gkhngyk commented 11 months ago

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?

nacho-villanueva commented 11 months ago

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 commented 11 months ago

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

matthewlipski commented 11 months ago

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 commented 11 months ago

@gkhngyk there is a draft PR for this https://github.com/TypeCellOS/BlockNote/pull/188 but no plan yet to introduce it

hncheung9 commented 11 months ago

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](https://github.com/TypeCellOS/BlockNote/assets/62551881/7132e0db-da17-4ac3-a717-e86233067629)
M

dogfootruler-kr commented 9 months ago

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);
}