Custom blocks do not rerender on editor.isEditable change

Đang mở
#2,134 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug:P2

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 💖
Ngôn ngữ chính
TypeScript
Star
10.2k
Fork
772
Merge trung bình
3 ngày 11 giờ
Pull request đã merge (30 ngày)
17

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TypeCellOS/BlockNote

Tất cả issue của TypeCellOS/BlockNote

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.