NotionX / react-notion-x

Fast and accurate React renderer for Notion. TS batteries included. ⚑️
https://react-notion-x-demo.transitivebullsh.it
MIT License
4.69k stars 544 forks source link

Mirror Notion in hiding block_width "0" assets #550

Open PascalPixel opened 3 months ago

PascalPixel commented 3 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-notion-x@6.16.0 for the project I'm working on.

Sometimes, images that seem 'deleted' in Notion are still in the blocks, but simply have a "block_width" of 0. This diff would hide those blocks to match Notion.

Here is the diff that solved my problem:

diff --git a/node_modules/react-notion-x/build/index.js b/node_modules/react-notion-x/build/index.js
index a18bcfd..1bc6916 100644
--- a/node_modules/react-notion-x/build/index.js
+++ b/node_modules/react-notion-x/build/index.js
@@ -1757,8 +1760,9 @@ var AssetWrapper = ({ blockId, block }) => {
       "notion-asset-wrapper",
       `notion-asset-wrapper-${block.type}`,
       ((_d = value.format) == null ? void 0 : _d.block_full_width) && "notion-asset-wrapper-full",
-    )
+    ),
+    style: ((_d = value.format) == null ? void 0 : _d.block_width) === 0 ? { display: "none" } : undefined,
   }, /* @__PURE__ */ React20.createElement(Asset, {
     block: value,
     zoomable: zoom && !isURL

This issue body was partially generated by patch-package.