Custom blocks do not rerender on editor.isEditable change
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 45/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- frontend
Direção de pesquisa
Start with the createReactBlockSpec custom block and the BlockNoteView editable toggle shown in the reproduction. Review fixes #2121 and #2106 to identify why the block does not react to editor.isEditable changes. Done means toggling the button changes the custom block content between "editable" and "readonly" without interacting with the block.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
In version 0.41.1 custom blocks directly reacted to changes to editor.isEditable and have rerendered.
But at the latest main version they don't (until they are interacted with which forces a rerender).
I suspect this is due to the fix (#2121) for (#2106).
To Reproduce
block-spec:
export const createTestBlock = createReactBlockSpec(
{
type: 'test',
propSchema: {
},
content: 'none',
},
{
render: (props) => {
return (
<div>{props.editor.isEditable ? 'editable' : 'readonly'}</div>
);
},
}
);
editor:
export function Test() {
const [readonly, setReadonly] = useState(false);
const editor = useCreateBlockNote({
schema: BlockNoteSchema.create({
blockSpecs: {
test: createTestBlock(),
},
}),
initialContent: [
{
type: "test",
},
],
});
return <div>
<button onClick={() => setReadonly(r => !r)}>toggle</button>
<BlockNoteView editor={editor} editable={!readonly} />
</div>;
}
Toggling the readonly button does not change block's content to readonly
Misc
- Node version:
- Package manager:
- Browser:
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖
- Linguagem predominante
- TypeScript
- Estrelas
- 10.2k
- Forks
- 772
- Merge médio
- 3d 11h
- PRs com merge (30d)
- 17
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TypeCellOS/BlockNote
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TypeCellOS/BlockNote#3098 ·
-
Off-By-One `RangeError` Crash and Text Duplication in `StyleManager.editLink` and `deleteLink` Abertaneeds-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
TypeCellOS/BlockNote#3073 ·
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
TypeCellOS/BlockNote#3072 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TypeCellOS/BlockNote#2949 · 1 comentário ·
-
a11y
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
TypeCellOS/BlockNote#2855 ·
Todas as issues de TypeCellOS/BlockNote
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
area:tools bug good first issue help wanted priority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
TaewoooPark/Motifcode#14 ·
-
bug 🐞
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
[Bounty proposal] fix(web): memory insights count an evening memory on the next day ($25 proposed) Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
BasedHardware/omi#15320 ·
-
Dificuldade 2/5 Meio dia Facilidade para iniciantes 78/100
vercel/vercel-plugin#199 ·