-
Notifications
You must be signed in to change notification settings - Fork 283
✨ Add a custom callout block to the editor #892
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
base: main
Are you sure you want to change the base?
✨ Add a custom callout block to the editor #892
Conversation
Great job! Just small UI considerations here. |
Hey thanks for your feedback Made some changes on the callout. And the emoji's background color transition on hover |
we need functionalities and data to implement a custom emoji picker component, as blocknote's emojipicker component triggers and uses cases are limited. add to \`package.json\` the following packages: - \`emoji-mart\`: provides functions and components for displaying, searching and selecting emojis. - `\@emoji-mart/data\`: offers pre-configured sets of emojis.
Add a custom emoji picker component to use in the editor
Add a custom block to the editor, the callout block.
Adapt modal export to include PDF and Docx export for the callout block.
Add translation for the callout component to be shown in the suggestion menu and slash menu. Add missing "Beautify" AI action in French.
Fix editor's callout block border corner, paddings and margins to match design docs, apply sam fix on paragraph and heading blocks to keep a visual consistency when highlighted.
e7dd4fa
to
1bc17a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ZouicheOmar this looks awesome ! Thanks a lot for your contribution.
Just one feedback, one thing I noticed in your screen capture is that by default the call out block has a white background.
How about we give it yellow background by default that people can change if they want to.
@ZouicheOmar |
Now the default bg for a callout is yellow. Democallout_default_bg.webmSolution is not quite elegant, would be cleaner with a custom side menu, or a change on blocknotejs. Will keep an eye on it. @virgile-dev I am definitely coming to the hack days ! Just waiting for my invite to be checked and I'll be all set. |
Refactor and add typing to callout block to fix lint issues.
Set the default background color to yellow on the callout block.
75adfd5
to
0a3f580
Compare
@@ -38,5 +38,6 @@ | |||
"react-dom": "19.1.0", | |||
"typescript": "5.8.3", | |||
"yjs": "13.6.26" | |||
} | |||
}, | |||
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will not use this part for the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you a lot for the contribution.
I can see you still have some linting issues.
I use the extension https://marketplace.visualstudio.com/items/?itemName=dbaeumer.vscode-eslint to get informations about them.
Your last 3 commits seems more fixing your previous commits, consider using the fixup
commits instead of a new ones.
We are adding tests using Playwright, do you know it ?
If yes maybe you can add test here: https://github.com/suitenumerique/docs/blob/main/src/frontend/apps/e2e/__tests__/app-impress/doc-editor.spec.ts
Otherwise, no problem, I will add tests after your changes.
@@ -22,6 +22,7 @@ | |||
"@blocknote/react": "0.29.1", | |||
"@blocknote/xl-docx-exporter": "0.29.1", | |||
"@blocknote/xl-pdf-exporter": "0.29.1", | |||
"@emoji-mart/data": "^1.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to pin the dependency, we are using renovate
to bump them.
"@emoji-mart/data": "^1.2.1", | |
"@emoji-mart/data": "1.2.1", |
ReactCustomBlockRenderProps, | ||
createReactBlockSpec, | ||
useBlockNoteEditor, | ||
useEditorSelectionChange, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't seem to use it.
CustomBlockConfig, | ||
DefaultInlineContentSchema, | ||
DefaultStyleSchema, | ||
PartialBlock, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't seem to use it.
// this custom block. | ||
useEffect(() => { | ||
if (!block.content.length && block.props.backgroundColor === 'default') { | ||
console.log('in if statement'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log('in if statement'); |
} satisfies CustomBlockConfig; | ||
|
||
const useCalloutBlock = () => { | ||
const editor = useBlockNoteEditor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const editor = useBlockNoteEditor(); | |
const editor = useBlockNoteEditor< | |
DocsBlockSchema, | |
DocsInlineContentSchema, | |
DocsStyleSchema | |
>(); |
By typing the editor, you will not have to cast to "any" inside updateBlock
.
Purpose
This PR addresses issue #305. Add a new custom block to the editor, the callout block.
Proposal
emoji-mart
library, which is already used by blocknote. That's to have custom triggers and use of the component.Demo
callout.webm
PDF and Docx Exports
Would love any feedback if this needs improvements, corrections or any changes.