Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Sync up BlockNoteEditor with OP Color Theme (#19627)

Kabiru Mwenja0d4e3b302323
diff --git a/frontend/src/react/OpBlockNoteContainer.tsx b/frontend/src/react/OpBlockNoteContainer.tsx
index 26d6cc483ca..a9790ea1726 100644
--- a/frontend/src/react/OpBlockNoteContainer.tsx
+++ b/frontend/src/react/OpBlockNoteContainer.tsx
@@ -39,6 +39,8 @@ export interface OpBlockNoteContainerProps {
inputText?: string;
}
+type OpTheme = "light" | "dark";
+
const schema = BlockNoteSchema.create({
blockSpecs: {
...defaultBlockSpecs,
@@ -47,6 +49,13 @@ const schema = BlockNoteSchema.create({
},
});
+const detectTheme = (): OpTheme => {
+ if (document.body.getAttribute('data-color-mode') === 'dark') {
+ return 'dark';
+ }
+ return 'light';
+};
+
export default function OpBlockNoteContainer({ inputField, inputText }: OpBlockNoteContainerProps) {
const [isLoading, setIsLoading] = useState(true);
@@ -75,6 +84,7 @@ export default function OpBlockNoteContainer({ inputField, inputText }: OpBlockN
:
<BlockNoteView
editor={editor}
+ theme={detectTheme()}
onChange={async (editor) => {
const content = await editor.blocksToMarkdownLossy();
inputField.value = content;