Skip to content
Closed
12 changes: 6 additions & 6 deletions examples/02-backend/04-rendering-static-documents/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ This example has the HTML hard-coded, but shows at least how the document will b
export default function App() {
// This HTML is generated by the ServerBlockNoteEditor.blocksToFullHTML method
const html = `<div class="bn-block-group" data-node-type="blockGroup">
<div class="bn-block-outer" data-node-type="blockOuter" data-id="1" data-text-color="yellow" data-background-color="blue">
<div class="bn-block" data-node-type="blockContainer" data-id="1" data-text-color="yellow" data-background-color="blue">
<div class="bn-block-content" data-content-type="heading" data-text-alignment="right" data-level="2">
<div class="bn-block-outer" data-node-type="blockOuter" data-id="1">
<div class="bn-block" data-node-type="blockContainer" data-id="1">
<div class="bn-block-content" data-content-type="heading" data-background-color="blue" data-text-color="yellow" data-text-alignment="right" data-level="2">
<h2 class="bn-inline-content">
<strong><u>Heading </u></strong><em><s>2</s></em>
</h2>
</div>
<div class="bn-block-group" data-node-type="blockGroup">
<div class="bn-block-outer" data-node-type="blockOuter" data-id="2" data-background-color="red">
<div class="bn-block" data-node-type="blockContainer" data-id="2" data-background-color="red">
<div class="bn-block-content" data-content-type="paragraph">
<div class="bn-block-outer" data-node-type="blockOuter" data-id="2">
<div class="bn-block" data-node-type="blockContainer" data-id="2">
<div class="bn-block-content" data-content-type="paragraph" data-background-color="red">
<p class="bn-inline-content">Paragraph</p>
</div>
</div>
Expand Down
47 changes: 38 additions & 9 deletions packages/core/src/blocks/Table/TableExtension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { callOrReturn, Extension, getExtensionField } from "@tiptap/core";
import { columnResizing, goToNextCell, tableEditing } from "prosemirror-tables";
import { TextSelection } from "prosemirror-state";
import {
columnResizing,
goToNextCell,
isInTable,
moveCellForward,
nextCell,
selectionCell,
tableEditing,
} from "prosemirror-tables";

export const RESIZE_MIN_WIDTH = 35;
export const EMPTY_CELL_WIDTH = 120;
Expand All @@ -24,19 +33,39 @@ export const TableExtension = Extension.create({

addKeyboardShortcuts() {
return {
// Makes enter create a new line within the cell.
// Moves the selection to the cell below.
Enter: () => {
if (
this.editor.state.selection.empty &&
this.editor.state.selection.$head.parent.type.name ===
"tableParagraph"
this.editor.state.selection.$head.parent.type.name !==
"tableParagraph"
) {
this.editor.commands.insertContent({ type: "hardBreak" });

return true;
return false;
}

return false;
return this.editor.commands.command(({ state, dispatch }) => {
if (!isInTable(state)) {
return false;
}

const $cell = selectionCell(state);
const $nextCell = nextCell($cell, "vert", 1);

if (!$nextCell) {
return false;
}

if (dispatch) {
dispatch(
state.tr
.setSelection(
TextSelection.between($nextCell, moveCellForward($nextCell)),
)
.scrollIntoView(),
);
}

return true;
});
},
// Ensures that backspace won't delete the table if the text cursor is at
// the start of a cell and the selection is empty.
Expand Down
31 changes: 13 additions & 18 deletions packages/core/src/editor/Block.css
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,25 @@ NESTED BLOCKS
padding: 12px;
}

[data-file-block] .bn-add-file-button:where(.dark, .dark *) {
background-color: rgb(70, 70, 70);
color: rgb(190, 190, 190);
}

.bn-editor[contenteditable="true"] [data-file-block] .bn-add-file-button:hover,
[data-file-block] .bn-file-name-with-icon:hover,
.ProseMirror-selectednode .bn-file-name-with-icon {
background-color: rgb(225, 225, 225);
}

.bn-editor[contenteditable="true"]
[data-file-block]
.bn-add-file-button:hover:where(.dark, .dark *),
[data-file-block] .bn-file-name-with-icon:hover:where(.dark, .dark *),
.ProseMirror-selectednode .bn-file-name-with-icon:where(.dark, .dark *) {
background-color: rgb(90, 90, 90);
}

[data-file-block] .bn-add-file-button-icon,
[data-file-block] .bn-file-icon {
width: 24px;
Expand Down Expand Up @@ -561,110 +574,92 @@ NESTED BLOCKS

/* TEXT COLORS */
[data-style-type="textColor"][data-value="gray"],
[data-text-color="gray"],
.bn-block:has(> .bn-block-content[data-text-color="gray"]) {
color: #9b9a97;
}

[data-style-type="textColor"][data-value="brown"],
[data-text-color="brown"],
.bn-block:has(> .bn-block-content[data-text-color="brown"]) {
color: #64473a;
}

[data-style-type="textColor"][data-value="red"],
[data-text-color="red"],
.bn-block:has(> .bn-block-content[data-text-color="red"]) {
color: #e03e3e;
}

[data-style-type="textColor"][data-value="orange"],
[data-text-color="orange"],
.bn-block:has(> .bn-block-content[data-text-color="orange"]) {
color: #d9730d;
}

[data-style-type="textColor"][data-value="yellow"],
[data-text-color="yellow"],
.bn-block:has(> .bn-block-content[data-text-color="yellow"]) {
color: #dfab01;
}

[data-style-type="textColor"][data-value="green"],
[data-text-color="green"],
.bn-block:has(> .bn-block-content[data-text-color="green"]) {
color: #4d6461;
}

[data-style-type="textColor"][data-value="blue"],
[data-text-color="blue"],
.bn-block:has(> .bn-block-content[data-text-color="blue"]) {
color: #0b6e99;
}

[data-style-type="textColor"][data-value="purple"],
[data-text-color="purple"],
.bn-block:has(> .bn-block-content[data-text-color="purple"]) {
color: #6940a5;
}

[data-style-type="textColor"][data-value="pink"],
[data-text-color="pink"],
.bn-block:has(> .bn-block-content[data-text-color="pink"]) {
color: #ad1a72;
}

/* BACKGROUND COLORS */
[data-style-type="backgroundColor"][data-value="gray"],
[data-background-color="gray"],
.bn-block:has(> .bn-block-content[data-background-color="gray"]) {
background-color: #ebeced;
}

[data-style-type="backgroundColor"][data-value="brown"],
[data-background-color="brown"],
.bn-block:has(> .bn-block-content[data-background-color="brown"]) {
background-color: #e9e5e3;
}

[data-style-type="backgroundColor"][data-value="red"],
[data-background-color="red"],
.bn-block:has(> .bn-block-content[data-background-color="red"]) {
background-color: #fbe4e4;
}

[data-style-type="backgroundColor"][data-value="orange"],
[data-background-color="orange"],
.bn-block:has(> .bn-block-content[data-background-color="orange"]) {
background-color: #f6e9d9;
}

[data-style-type="backgroundColor"][data-value="yellow"],
[data-background-color="yellow"],
.bn-block:has(> .bn-block-content[data-background-color="yellow"]) {
background-color: #fbf3db;
}

[data-style-type="backgroundColor"][data-value="green"],
[data-background-color="green"],
.bn-block:has(> .bn-block-content[data-background-color="green"]) {
background-color: #ddedea;
}

[data-style-type="backgroundColor"][data-value="blue"],
[data-background-color="blue"],
.bn-block:has(> .bn-block-content[data-background-color="blue"]) {
background-color: #ddebf1;
}

[data-style-type="backgroundColor"][data-value="purple"],
[data-background-color="purple"],
.bn-block:has(> .bn-block-content[data-background-color="purple"]) {
background-color: #eae4f2;
}

[data-style-type="backgroundColor"][data-value="pink"],
[data-background-color="pink"],
.bn-block:has(> .bn-block-content[data-background-color="pink"]) {
background-color: #f4dfeb;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const ar: Dictionary = {
text_title: "نص",
background_title: "خلفية",
colors: {
default: "افتراضي",
default: "تلقائي",
gray: "رمادي",
brown: "بني",
red: "أحمر",
Expand Down Expand Up @@ -369,9 +369,11 @@ export const ar: Dictionary = {
edited: "تم التحرير",
save_button_text: "حفظ",
cancel_button_text: "إلغاء",
deleted_reference_text: "تم حذف المحتوى الأصلي",
actions: {
add_reaction: "أضف تفاعلًا",
resolve: "حل",
reopen: "إعادة فتح",
edit_comment: "تحرير التعليق",
delete_comment: "حذف التعليق",
more_actions: "المزيد من الإجراءات",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export const de: Dictionary = {
text_title: "Text",
background_title: "Hintergrund",
colors: {
default: "Standard",
default: "Automatisch",
gray: "Grau",
brown: "Braun",
red: "Rot",
Expand Down Expand Up @@ -403,9 +403,11 @@ export const de: Dictionary = {
edited: "bearbeitet",
save_button_text: "Speichern",
cancel_button_text: "Abbrechen",
deleted_reference_text: "Originalinhalt gelöscht",
actions: {
add_reaction: "Reaktion hinzufügen",
resolve: "Lösen",
reopen: "Wieder öffnen",
edit_comment: "Kommentar bearbeiten",
delete_comment: "Kommentar löschen",
more_actions: "Weitere Aktionen",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const en = {
text_title: "Text",
background_title: "Background",
colors: {
default: "Default",
default: "Auto",
gray: "Gray",
brown: "Brown",
red: "Red",
Expand Down Expand Up @@ -384,9 +384,11 @@ export const en = {
edited: "edited",
save_button_text: "Save",
cancel_button_text: "Cancel",
deleted_reference_text: "Original content deleted",
actions: {
add_reaction: "Add reaction",
resolve: "Resolve",
reopen: "Re-open",
edit_comment: "Edit comment",
delete_comment: "Delete comment",
more_actions: "More actions",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const es: Dictionary = {
text_title: "Texto",
background_title: "Fondo",
colors: {
default: "Por defecto",
default: "Automático",
gray: "Gris",
brown: "Marrón",
red: "Rojo",
Expand Down Expand Up @@ -382,9 +382,11 @@ export const es: Dictionary = {
edited: "editado",
save_button_text: "Guardar",
cancel_button_text: "Cancelar",
deleted_reference_text: "Contenido original eliminado",
actions: {
add_reaction: "Agregar reacción",
resolve: "Resolver",
reopen: "Reabrir",
edit_comment: "Editar comentario",
delete_comment: "Eliminar comentario",
more_actions: "Más acciones",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const fa = {
text_title: "متن",
background_title: "پس‌زمینه",
colors: {
default: "پیش‌فرض",
default: "خودکار",
gray: "خاکستری",
brown: "قهوه‌ای",
red: "قرمز",
Expand Down Expand Up @@ -352,9 +352,11 @@ export const fa = {
edited: "ویرایش شده",
save_button_text: "ذخیره",
cancel_button_text: "لغو",
deleted_reference_text: "محتوای اصلی حذف شد",
actions: {
add_reaction: "افزودن واکنش",
resolve: "حل کردن",
reopen: "باز کردن مجدد",
edit_comment: "ویرایش دیدگاه",
delete_comment: "حذف دیدگاه",
more_actions: "اقدامات بیشتر",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export const fr: Dictionary = {
text_title: "Texte",
background_title: "Fond",
colors: {
default: "Défaut",
default: "Auto",
gray: "Gris",
brown: "Marron",
red: "Rouge",
Expand Down Expand Up @@ -430,9 +430,11 @@ export const fr: Dictionary = {
edited: "modifié",
save_button_text: "Enregistrer",
cancel_button_text: "Annuler",
deleted_reference_text: "Contenu d'origine supprimé",
actions: {
add_reaction: "Ajouter une réaction",
resolve: "Résoudre",
reopen: "Rouvrir",
edit_comment: "Modifier le commentaire",
delete_comment: "Supprimer le commentaire",
more_actions: "Plus d'actions",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const he: Dictionary = {
text_title: "טקסט",
background_title: "רקע",
colors: {
default: "ברירת מחדל",
default: "אוטומטי",
gray: "אפור",
brown: "חום",
red: "אדום",
Expand Down Expand Up @@ -384,9 +384,11 @@ export const he: Dictionary = {
edited: "נערך",
save_button_text: "שמור",
cancel_button_text: "בטל",
deleted_reference_text: "התוכן המקורי נמחק",
actions: {
add_reaction: "הוסף תגובה",
resolve: "סמן כפתור",
reopen: "פתח מחדש",
edit_comment: "ערוך תגובה",
delete_comment: "מחק תגובה",
more_actions: "פעולות נוספות",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/i18n/locales/hr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const hr: Dictionary = {
text_title: "Tekst",
background_title: "Pozadina",
colors: {
default: "Zadano",
default: "Automatski",
gray: "Siva",
brown: "Smeđa",
red: "Crvena",
Expand Down Expand Up @@ -397,9 +397,11 @@ export const hr: Dictionary = {
edited: "uredio",
save_button_text: "Spremi",
cancel_button_text: "Odustani",
deleted_reference_text: "Originalni sadržaj je obrisan",
actions: {
add_reaction: "Dodaj reakciju",
resolve: "Riješi",
reopen: "Ponovno otvori",
edit_comment: "Uredi komentar",
delete_comment: "Obriši komentar",
more_actions: "Više radnji",
Expand Down
Loading