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
5.89k stars 381 forks source link

How to get defualt dictionary? #883

Closed softmarshmallow closed 4 days ago

softmarshmallow commented 4 days ago

Below won't work, I don't see a way to get a default dictionary value and only override picked ones.

Attepmp to customize placeholder (initial - for default, only when provided by user)

import { useCreateBlockNote, useDictionary } from "@blocknote/react";

const editor = useCreateBlockNote({
    dictionary: {
      ...dictionary,
      placeholders: {
        ...dictionary.placeholders,
        default: placeholder
      },
    },
    uploadFile: async (file) => {
      return "";
    },
  });
softmarshmallow commented 4 days ago

Found it. - import { locales } from "@blocknote/core";


import { useCreateBlockNote } from "@blocknote/react";
import { locales } from "@blocknote/core";

  const editor = useCreateBlockNote({
    dictionary: {
      ...locales.en,
      placeholders: {
        ...locales.en.placeholders,
        default: placeholder || locales.en.placeholders.default,
      },
    },
  });
YousefED commented 1 day ago

Thanks for sharing your fix! Fyi if you're interested in contributing, this (custom block placeholder) might be a cool example for the website (https://www.blocknotejs.org/examples)