BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Small issue: List showing nulls, not numbers, on render

Open james-pratama opened this issue 10 months ago • 13 comments

On render, my lists are showing null instead of numbers. The numbers only show once I click the editor.

Screenshot 2024-04-03 at 8 17 11 AM

Tried adding ref to BlockNoteView to auto focus editor but does not seem to work.

Is there a list somewhere of all the properties taken by BlockNoteView?

james-pratama avatar Apr 03 '24 15:04 james-pratama

@james-pratama could you provide steps or a sandbox to reproduce this?

YousefED avatar Apr 08 '24 08:04 YousefED

I have the same problem.

It can also be found at the following URL example.

https://www.blocknotejs.org/examples/basic/all-blocks

( Line of Numbered List Item)

If you go back and forth between example > basic > (product line-up), number list item becomes null when out of focus

スクリーンショット 2024-04-12 065744

gbfgamemiya avatar Apr 11 '24 22:04 gbfgamemiya

We also have this issue, and any help would be greatly appreciated. https://blog.opengtm.ai/how-strategic-territory-planning-can-boost-sales-performance

Screenshot 2024-05-03 at 12 05 01 AM

rlancejohnson avatar May 03 '24 06:05 rlancejohnson

We have a same issue as well.

jinho-kim-osd avatar May 06 '24 11:05 jinho-kim-osd

I have the same issue, i fix it temporarily using this trick:

useEffect(() => {
    let timeout: NodeJS.Timeout;
    if (editor) {
      timeout = setTimeout(() => {
        const firstBlock = editor.document[0];
        if (firstBlock) editor.updateBlock(firstBlock, { type: firstBlock.type });
      }, 100);
    }

    return () => {
      clearTimeout(timeout);
    };
  }, [editor]);

basically just update a block and it will not show as null after render

Dadangdut33 avatar May 06 '24 13:05 Dadangdut33

I've encountered something similar as well, will try implementing temporary fix used by @Dadangdut33. Screenshot 2024-06-02 at 9 46 46 AM

kevinru2023 avatar Jun 02 '24 16:06 kevinru2023

Hi, haven't seen this issue before - if anyone can post steps to reproduce it that would be great!

matthewlipski avatar Jun 11 '24 12:06 matthewlipski

@matthewlipski If you have multiple tabs using BlockNoteView, the numbered list will become null when you switch tabs. Additionally, when the BlockNoteView is in a non-editable state, the numbered list will also become null when you reload the page.

https://github.com/TypeCellOS/BlockNote/assets/37234239/2729b620-cc0c-494b-b70c-8f0b1599c640

lamtuanamc avatar Jun 13 '24 02:06 lamtuanamc

if anyone can post steps to reproduce it that would be great!

Hope it helps, so basically:

  1. Intialize blocknote with data
  2. Render blocknote
  3. null will be shown for data that is using list until you click on the editor (or do an edit programmatically)

Dadangdut33 avatar Jun 13 '24 05:06 Dadangdut33

Thanks! Helps a lot, we'll look into it next time we do a bugfix release

matthewlipski avatar Jun 13 '24 12:06 matthewlipski

I'm having the same issue, but with the generated HTML. All items will show up as null in the generated HTML.

danlupascu avatar Sep 11 '24 17:09 danlupascu

We have fixed this issue by changing the numberedListItem in the schema, and adding the index prop:

const schema = BlockNoteSchema.create({
  blockSpecs: {
    // first pass all the blockspecs from the built in, default block schema
    ...defaultBlockSpecs,

    numberedListItem: {
      ...defaultBlockSpecs.numberedListItem,
      config: {
        ...defaultBlockSpecs.numberedListItem.config,
        propSchema: {
          ...defaultBlockSpecs.numberedListItem.config.propSchema,
          // add index to fix the null list number items
          index: {
            default: '',
          },
        },
      },
    },
  },
});

I think adding the index prop here should fix the issue https://github.com/TypeCellOS/BlockNote/blob/dce1d03a37234c3dd7ff85169e03ca8ace88ce82/packages/core/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts#L14

danlupascu avatar Sep 11 '24 18:09 danlupascu

I have the same issue when isEditable is false, on reload of page. When I click once, anywhere on the page it sets the numbers.

tolypash avatar Sep 15 '24 14:09 tolypash