Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/content/docs/react/components/formatting-toolbar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,29 @@ The first element in the default Formatting Toolbar is the Block Type Select, an
<Example name="ui-components/formatting-toolbar-block-type-items" />

Here, we use the `FormattingToolbar` component but keep the default buttons (we don't pass any children). Instead, we pass our customized Block Type Select items using the `blockTypeSelectItems` prop.

## Adding a Text Align Select

You can replace the default text alignment buttons with a `TextAlignSelect` dropdown, which groups all four alignment options (Left, Center, Right, Justify) into a single compact select.

To use it, pass `<TextAlignSelect>` as a child of `FormattingToolbar` in a custom toolbar:

```tsx
import {
BlockTypeSelect,
FormattingToolbar,
FormattingToolbarController,
TextAlignSelect,
} from "@blocknote/react";

const CustomFormattingToolbar = () => (
<FormattingToolbar>
<BlockTypeSelect key="blockTypeSelect" />
{/* ... other toolbar items ... */}
<TextAlignSelect key="textAlignSelect" />
{/* ... other toolbar items ... */}
</FormattingToolbar>
);
```

The select is only rendered when the cursor or selection is on a block that supports the `textAlignment` prop (e.g. paragraphs and headings). For table blocks, it applies the chosen alignment to the individual cells covered by the current cell selection.
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,19 @@ export const ar: Dictionary = {
},
align_left: {
tooltip: "محاذاة النص إلى اليسار",
label: "يسار",
},
align_center: {
tooltip: "محاذاة النص في المنتصف",
label: "وسط",
},
align_right: {
tooltip: "محاذاة النص إلى اليمين",
label: "يمين",
},
align_justify: {
tooltip: "ضبط النص",
label: "ضبط",
},
table_cell_merge: {
tooltip: "جمع الخلايا",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,19 @@ export const de: Dictionary = {
},
align_left: {
tooltip: "Text linksbündig",
label: "Links",
},
align_center: {
tooltip: "Text zentrieren",
label: "Zentriert",
},
align_right: {
tooltip: "Text rechtsbündig",
label: "Rechts",
},
align_justify: {
tooltip: "Text Blocksatz",
label: "Blocksatz",
},
table_cell_merge: {
tooltip: "Zellen zusammenführen",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,19 @@ export const en = {
},
align_left: {
tooltip: "Align text left",
label: "Left"
},
align_center: {
tooltip: "Align text center",
label: "Center"
},
align_right: {
tooltip: "Align text right",
label: "Right"
},
align_justify: {
tooltip: "Justify text",
label: "Justify"
},
table_cell_merge: {
tooltip: "Merge cells",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,19 @@ export const es: Dictionary = {
},
align_left: {
tooltip: "Alinear texto a la izquierda",
label: "Izquierda",
},
align_center: {
tooltip: "Alinear texto al centro",
label: "Centro",
},
align_right: {
tooltip: "Alinear texto a la derecha",
label: "Derecha",
},
align_justify: {
tooltip: "Justificar texto",
label: "Justificar",
},
table_cell_merge: {
tooltip: "Combinar celdas",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,19 @@ export const fa = {
},
align_left: {
tooltip: "تراز متن چپ",
label: "چپ",
},
align_center: {
tooltip: "تراز متن وسط",
label: "وسط",
},
align_right: {
tooltip: "تراز متن راست",
label: "راست",
},
align_justify: {
tooltip: "تراز متن دوطرفه",
label: "دوطرفه",
},
table_cell_merge: {
tooltip: "ادغام سلول‌ها",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,19 @@ export const fr: Dictionary = {
},
align_left: {
tooltip: "Aligner le texte à gauche",
label: "Gauche",
},
align_center: {
tooltip: "Aligner le texte au centre",
label: "Centre",
},
align_right: {
tooltip: "Aligner le texte à droite",
label: "Droite",
},
align_justify: {
tooltip: "Justifier le texte",
label: "Justifier",
},
table_cell_merge: {
tooltip: "Fusionner les cellules",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,19 @@ export const he: Dictionary = {
},
align_left: {
tooltip: "ישר טקסט לשמאל",
label: "שמאל",
},
align_center: {
tooltip: "מרכז טקסט",
label: "מרכז",
},
align_right: {
tooltip: "ישר טקסט לימין",
label: "ימין",
},
align_justify: {
tooltip: "ישר טקסט לשני הצדדים",
label: "יישור",
},
table_cell_merge: {
tooltip: "מיזוג תאים",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,19 @@ export const hr: Dictionary = {
},
align_left: {
tooltip: "Poravnaj tekst lijevo",
label: "Lijevo",
},
align_center: {
tooltip: "Poravnaj tekst po sredini",
label: "Sredina",
},
align_right: {
tooltip: "Poravnaj tekst desno",
label: "Desno",
},
align_justify: {
tooltip: "Poravnaj tekst obostrano",
label: "Obostrano",
},
table_cell_merge: {
tooltip: "Spoji ćelije",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,19 @@ export const is: Dictionary = {
},
align_left: {
tooltip: "Vinstrijafna texta",
label: "Vinstri",
},
align_center: {
tooltip: "Miðjustilla texta",
label: "Miðja",
},
align_right: {
tooltip: "Hægrijafna texta",
label: "Hægri",
},
align_justify: {
tooltip: "Jafna texta",
label: "Jafna",
},
table_cell_merge: {
tooltip: "Sameina dálka",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,19 @@ export const it: Dictionary = {
},
align_left: {
tooltip: "Allinea testo a sinistra",
label: "Sinistra",
},
align_center: {
tooltip: "Allinea testo al centro",
label: "Centro",
},
align_right: {
tooltip: "Allinea testo a destra",
label: "Destra",
},
align_justify: {
tooltip: "Giustifica testo",
label: "Giustifica",
},
table_cell_merge: {
tooltip: "Unisci celle",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,19 @@ export const ja: Dictionary = {
},
align_left: {
tooltip: "左揃え",
label: "左",
},
align_center: {
tooltip: "中央揃え",
label: "中央",
},
align_right: {
tooltip: "右揃え",
label: "右",
},
align_justify: {
tooltip: "両端揃え",
label: "両端",
},
table_cell_merge: {
tooltip: "セルを結合",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,19 @@ export const ko: Dictionary = {
},
align_left: {
tooltip: "텍스트 왼쪽 맞춤",
label: "왼쪽",
},
align_center: {
tooltip: "텍스트 가운데 맞춤",
label: "가운데",
},
align_right: {
tooltip: "텍스트 오른쪽 맞춤",
label: "오른쪽",
},
align_justify: {
tooltip: "텍스트 양쪽 맞춤",
label: "양쪽",
},
table_cell_merge: {
tooltip: "셀 병합",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,19 @@ export const nl: Dictionary = {
},
align_left: {
tooltip: "Tekst links uitlijnen",
label: "Links",
},
align_center: {
tooltip: "Tekst centreren",
label: "Midden",
},
align_right: {
tooltip: "Tekst rechts uitlijnen",
label: "Rechts",
},
align_justify: {
tooltip: "Tekst uitvullen",
label: "Uitvullen",
},
table_cell_merge: {
tooltip: "Voeg cellen samen",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/no.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,19 @@ export const no: Dictionary = {
},
align_left: {
tooltip: "Venstrejuster tekst",
label: "Venstre",
},
align_center: {
tooltip: "Midtstill tekst",
label: "Midtstilt",
},
align_right: {
tooltip: "Høyrejuster tekst",
label: "Høyre",
},
align_justify: {
tooltip: "Juster tekst",
label: "Justert",
},
comment: {
tooltip: "Legg til kommentar",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,19 @@ export const pl: Dictionary = {
},
align_left: {
tooltip: "Wyrównaj tekst do lewej",
label: "Lewo",
},
align_center: {
tooltip: "Wyśrodkuj tekst",
label: "Środek",
},
align_right: {
tooltip: "Wyrównaj tekst do prawej",
label: "Prawo",
},
align_justify: {
tooltip: "Wyjustuj tekst",
label: "Wyjustuj",
},
table_cell_merge: {
tooltip: "Połącz komórki",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,19 @@ export const pt: Dictionary = {
},
align_left: {
tooltip: "Alinhar à esquerda",
label: "Esquerda"
},
align_center: {
tooltip: "Alinhar ao centro",
label: "Centro"
},
align_right: {
tooltip: "Alinhar à direita",
label: "Direita"
},
align_justify: {
tooltip: "Justificar texto",
label: "Justificar"
},
Comment thread
GuiLeme marked this conversation as resolved.
table_cell_merge: {
tooltip: "Juntar células",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,19 @@ export const ru: Dictionary = {
},
align_left: {
tooltip: "Текст по левому краю",
label: "Влево",
},
align_center: {
tooltip: "Текст по середине",
label: "По центру",
},
align_right: {
tooltip: "Текст по правому краю",
label: "Вправо",
},
align_justify: {
tooltip: "По середине текст",
label: "По ширине",
},
table_cell_merge: {
tooltip: "Объединить ячейки",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/i18n/locales/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,19 @@ export const sk = {
},
align_left: {
tooltip: "Zarovnať text vľavo",
label: "Vľavo",
},
align_center: {
tooltip: "Zarovnať text na stred",
label: "Stred",
},
align_right: {
tooltip: "Zarovnať text vpravo",
label: "Vpravo",
},
align_justify: {
tooltip: "Zarovnať text do bloku",
label: "Do bloku",
},
table_cell_merge: {
tooltip: "Zlúčiť bunky",
Expand Down
Loading