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

feat: split out localization files for optimized bundle #1533

Merged
merged 5 commits into from
Mar 25, 2025
Merged
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
2 changes: 1 addition & 1 deletion docs/components/pages/landing/hero/DemoEditor.tsx
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ import {
BlockNoteSchema,
combineByGroup,
filterSuggestionItems,
locales,
uploadToTmpFilesDotOrg_DEV_ONLY,
} from "@blocknote/core";
import * as locales from "@blocknote/core/locales";
import "@blocknote/core/fonts/inter.css";
import {
getDefaultReactSlashMenuItems,
2 changes: 1 addition & 1 deletion examples/01-basic/03-multi-column/App.tsx
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ import {
BlockNoteSchema,
combineByGroup,
filterSuggestionItems,
locales,
} from "@blocknote/core";
import * as locales from "@blocknote/core/locales";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
4 changes: 2 additions & 2 deletions examples/01-basic/10-localization/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { locales } from "@blocknote/core";
import { nl } from "@blocknote/core/locales";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
@@ -12,7 +12,7 @@ export default function App() {
// Passes the Dutch (NL) dictionary to the editor instance.
// You can also provide your own dictionary here to customize the strings used in the editor,
// or submit a Pull Request to add support for your language of your choice
dictionary: locales.nl,
dictionary: nl,
// dictionary: locales[lang as keyof typeof locales], // Use the language from the i18n library dynamically
});

4 changes: 2 additions & 2 deletions examples/01-basic/11-custom-placeholder/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { locales } from "@blocknote/core";
import { en } from "@blocknote/core/locales";
import "@blocknote/core/fonts/inter.css";
import { BlockNoteView } from "@blocknote/mantine";
import "@blocknote/mantine/style.css";
import { useCreateBlockNote } from "@blocknote/react";

export default function App() {
// We use the English, default dictionary
const locale = locales["en"];
const locale = en;

// Creates a new editor instance.
const editor = useCreateBlockNote({
5 changes: 5 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -49,6 +49,11 @@
"types": "./types/src/comments/index.d.ts",
"import": "./dist/comments.js",
"require": "./dist/comments.cjs"
},
"./locales": {
"types": "./types/src/i18n/index.d.ts",
"import": "./dist/locales.js",
"require": "./dist/locales.cjs"
}
},
"scripts": {
2 changes: 2 additions & 0 deletions packages/core/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./locales/index.js";
export * from "./dictionary.js";
3 changes: 0 additions & 3 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as locales from "./i18n/locales/index.js";
export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
export * from "./api/exporters/html/externalHTMLExporter.js";
export * from "./api/exporters/html/internalHTMLSerializer.js";
@@ -57,7 +56,6 @@ export * from "./util/table.js";
export * from "./util/string.js";
export * from "./util/typescript.js";
export { UnreachableCaseError, assertEmpty } from "./util/typescript.js";
export { locales };

// for testing from react (TODO: move):
export * from "./api/nodeConversions/blockToNode.js";
@@ -69,4 +67,3 @@ export * from "./extensions/UniqueID/UniqueID.js";
export * from "./api/exporters/markdown/markdownExporter.js";
export * from "./api/parsers/html/parseHTML.js";
export * from "./api/parsers/markdown/parseMarkdown.js";

1 change: 1 addition & 0 deletions packages/core/vite.config.ts
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ export default defineConfig({
entry: {
blocknote: path.resolve(__dirname, "src/index.ts"),
comments: path.resolve(__dirname, "src/comments/index.ts"),
locales: path.resolve(__dirname, "src/i18n/index.ts"),
},
name: "blocknote",
formats: ["es", "cjs"],
Loading
Oops, something went wrong.