Skip to content

Commit d406846

Browse files
committed
🎨(frontend) format css blocknote editor
We use the "css" function of style components to format correctly the blocknote editor css.
1 parent e85b070 commit d406846

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useCreateBlockNote } from '@blocknote/react';
66
import { HocuspocusProvider } from '@hocuspocus/provider';
77
import { useEffect } from 'react';
88
import { useTranslation } from 'react-i18next';
9+
import { css } from 'styled-components';
910
import * as Y from 'yjs';
1011

1112
import { Box, TextErrors } from '@/components';
@@ -20,17 +21,19 @@ import { randomColor } from '../utils';
2021

2122
import { BlockNoteToolbar } from './BlockNoteToolbar';
2223

23-
const cssEditor = (readonly: boolean) => `
24-
&, & > .bn-container, & .ProseMirror {
25-
height:100%;
26-
27-
.bn-side-menu[data-block-type=heading][data-level="1"] {
28-
height: 50px;
29-
}
30-
.bn-side-menu[data-block-type=heading][data-level="2"] {
31-
height: 43px;
32-
}
33-
.bn-side-menu[data-block-type=heading][data-level="3"] {
24+
const cssEditor = (readonly: boolean) => css`
25+
&,
26+
& > .bn-container,
27+
& .ProseMirror {
28+
height: 100%;
29+
30+
.bn-side-menu[data-block-type='heading'][data-level='1'] {
31+
height: 50px;
32+
}
33+
.bn-side-menu[data-block-type='heading'][data-level='2'] {
34+
height: 43px;
35+
}
36+
.bn-side-menu[data-block-type='heading'][data-level='3'] {
3437
height: 35px;
3538
}
3639
h1 {
@@ -52,11 +55,11 @@ const cssEditor = (readonly: boolean) => `
5255
border-left: none;
5356
}
5457
}
55-
58+
5659
.bn-editor {
57-
5860
color: var(--c--theme--colors--greyscale-700);
5961
}
62+
6063
.bn-block-outer:not(:first-child) {
6164
&:has(h1) {
6265
padding-top: 32px;
@@ -67,25 +70,25 @@ const cssEditor = (readonly: boolean) => `
6770
&:has(h3) {
6871
padding-top: 16px;
6972
}
70-
};
71-
73+
}
74+
7275
& .bn-inline-content code {
7376
background-color: gainsboro;
7477
padding: 2px;
7578
border-radius: 4px;
7679
}
80+
7781
@media screen and (width <= 560px) {
7882
& .bn-editor {
79-
8083
${readonly && `padding-left: 10px;`}
81-
};
82-
.bn-side-menu[data-block-type=heading][data-level="1"] {
83-
height: 46px;
8484
}
85-
.bn-side-menu[data-block-type=heading][data-level="2"] {
85+
.bn-side-menu[data-block-type='heading'][data-level='1'] {
86+
height: 46px;
87+
}
88+
.bn-side-menu[data-block-type='heading'][data-level='2'] {
8689
height: 40px;
8790
}
88-
.bn-side-menu[data-block-type=heading][data-level="3"] {
91+
.bn-side-menu[data-block-type='heading'][data-level='3'] {
8992
height: 40px;
9093
}
9194
& .bn-editor h1 {
@@ -97,7 +100,7 @@ const cssEditor = (readonly: boolean) => `
97100
& .bn-editor h3 {
98101
font-size: 1.2rem;
99102
}
100-
.bn-block-content[data-is-empty-and-focused][data-content-type="paragraph"]
103+
.bn-block-content[data-is-empty-and-focused][data-content-type='paragraph']
101104
.bn-inline-content:has(> .ProseMirror-trailingBreak:only-child)::before {
102105
font-size: 14px;
103106
}

0 commit comments

Comments
 (0)