diff --git a/packages/frontend/component/src/lit-react/lit-portal/lite-portal.tsx b/packages/frontend/component/src/lit-react/lit-portal/lite-portal.tsx
index 1f7249355c801..bcf68db34c4ad 100644
--- a/packages/frontend/component/src/lit-react/lit-portal/lite-portal.tsx
+++ b/packages/frontend/component/src/lit-react/lit-portal/lite-portal.tsx
@@ -13,10 +13,9 @@ type PortalEvent = {
type PortalListener = (event: PortalEvent) => void;
export function createLitPortalAnchor(callback: (event: PortalEvent) => void) {
- const id = nanoid();
return html``;
}
@@ -119,24 +118,26 @@ export const useLitPortalFactory = () => {
}
const prevId = event.previousPortalId;
- // Ignore first `willUpdate`
- if (!prevId) {
- return;
- }
- // No re-rendering allowed
- // Used in `pdf embed view` scenario
- if (!rerendering) {
+ // Ignores first `willUpdate`
+ if (!prevId) {
return;
}
setPortals(portals => {
const portal = portals.find(p => p.id === prevId);
- if (!portal) return portals;
+ if (!portal) return [...portals];
+ // Updates `ID`
portal.id = id;
- portal.portal.key = id;
- portal.portal.children = element;
+
+ // Re-rendering
+ // true: `inline link`
+ // false: `pdf embed view`
+ if (rerendering) {
+ portal.portal = ReactDOM.createPortal(element, target, id);
+ }
+
return [...portals];
});
});
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx
index 9225fa6fac65f..e45e5b7875dd1 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/bi-directional-link-panel.tsx
@@ -357,7 +357,7 @@ export const BiDirectionalLinkPanel = () => {
{
<>
{portals.map(p => (
- {p.portal}
+ {p.portal}
))}
>
}
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
index 5857f08601b4b..56d971f5f1db4 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/lit-adaper.tsx
@@ -184,7 +184,7 @@ const usePatchSpecs = (shared: boolean, mode: DocMode) => {
() => (
<>
{portals.map(p => (
- {p.portal}
+ {p.portal}
))}
>
),