Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: improve notion database visibility
Marc Seitz60edf2379dbe
diff --git a/components/view/view-data.tsx b/components/view/view-data.tsxindex 96d39b39..112e0828 100644--- a/components/view/view-data.tsx+++ b/components/view/view-data.tsx@@ -1,5 +1,7 @@import dynamic from "next/dynamic";+import { useMemo } from "react";+import { ViewerChatPanel } from "@/ee/features/ai/components/viewer-chat-panel";import {ViewerChatLayout,@@ -46,6 +48,8 @@ export type TViewDocumentData = Document & {versions: DocumentVersion[];};+const EMPTY_PAGES: never[] = [];+const isDownloadAllowed = (canDownload: boolean | undefined,linkAllowDownload: boolean | undefined,@@ -92,32 +96,52 @@ export default function ViewData({const documentVersionId = document.versions[0]?.id;const { pages: lazyPages, ensurePagesLoaded } = useLazyPages({- initialPages: viewData.pages ?? [],+ initialPages: viewData.pages ?? EMPTY_PAGES,viewId: viewData.viewId,documentVersionId: documentVersionId,});- const navData: TNavData = {- viewId: viewData.viewId,- isPreview: viewData.isPreview,- linkId: link.id,- brand: brand,- viewerId: "viewerId" in viewData ? viewData.viewerId : undefined,- isMobile: isMobile,- isDataroom: !!dataroomId,- documentId: document.id,- dataroomId: dataroomId,- conversationsEnabled:- !!dataroomId &&- ("conversationsEnabled" in viewData- ? viewData.conversationsEnabled- : false),- allowDownload:- document.downloadOnly ||- isDownloadAllowed(canDownload, link.allowDownload ?? false),- isTeamMember: viewData.isTeamMember,- annotationsFeatureEnabled: annotationsEnabled,- };+ const viewerId = "viewerId" in viewData ? viewData.viewerId : undefined;+ const conversationsEnabled =+ !!dataroomId &&+ ("conversationsEnabled" in viewData+ ? viewData.conversationsEnabled+ : false);+ const allowDownload =+ document.downloadOnly ||+ isDownloadAllowed(canDownload, link.allowDownload ?? false);++ const navData: TNavData = useMemo(+ () => ({+ viewId: viewData.viewId,+ isPreview: viewData.isPreview,+ linkId: link.id,+ brand: brand,+ viewerId,+ isMobile: isMobile,+ isDataroom: !!dataroomId,+ documentId: document.id,+ dataroomId: dataroomId,+ conversationsEnabled,+ allowDownload,+ isTeamMember: viewData.isTeamMember,+ annotationsFeatureEnabled: annotationsEnabled,+ }),+ [+ viewData.viewId,+ viewData.isPreview,+ viewData.isTeamMember,+ link.id,+ brand,+ viewerId,+ isMobile,+ dataroomId,+ document.id,+ conversationsEnabled,+ allowDownload,+ annotationsEnabled,+ ],+ );// Check if agents are enabled (returned from views API after access is granted)const agentsEnabled =diff --git a/ee/features/ai/components/viewer-chat-provider.tsx b/ee/features/ai/components/viewer-chat-provider.tsxindex 8094fc13..655a05c6 100644--- a/ee/features/ai/components/viewer-chat-provider.tsx+++ b/ee/features/ai/components/viewer-chat-provider.tsx@@ -5,6 +5,7 @@ import {createContext,useCallback,useContext,+ useMemo,useState,} from "react";@@ -110,26 +111,32 @@ export function ViewerChatProvider({const close = useCallback(() => setIsOpen(false), []);const toggle = useCallback(() => setIsOpen((prev) => !prev), []);- const config: ViewerChatConfig = {- dataroomId,- dataroomName,- documentId,- documentName,- linkId,- viewId,- viewerId,- };-- const value: ViewerChatContextType = {- isOpen,- isEnabled: enabled,- config,- documents,- folders,- open,- close,- toggle,- };+ const config: ViewerChatConfig = useMemo(+ () => ({+ dataroomId,+ dataroomName,+ documentId,+ documentName,+ linkId,+ viewId,+ viewerId,+ }),+ [dataroomId, dataroomName, documentId, documentName, linkId, viewId, viewerId],+ );++ const value: ViewerChatContextType = useMemo(+ () => ({+ isOpen,+ isEnabled: enabled,+ config,+ documents,+ folders,+ open,+ close,+ toggle,+ }),+ [isOpen, enabled, config, documents, folders, open, close, toggle],+ );return (<ViewerChatContext.Provider value={value}>diff --git a/styles/custom-notion-styles.css b/styles/custom-notion-styles.cssindex 46df7f07..e79f64d1 100644--- a/styles/custom-notion-styles.css+++ b/styles/custom-notion-styles.css@@ -1,74 +1,100 @@/*- * Notion layout:- * - Regular content (text, headings, lists): 708px max- * - Tables and wide elements: up to 990px on desktop+ * Notion-style CSS Grid layout.+ * The grid lives on .notion-page-content-inner (the <article> rendered by react-notion-x)+ * so individual blocks become grid items.+ * Named lines: full-start | margin | content-start | 708px | content-end | margin | full-end*/:root {--notion-max-width: 990px;+ --notion-content-width: 708px;+ --notion-margin-width: minmax(96px, 1fr);}.dark-mode {--bg-color: rgb(25, 25, 25);}-/*- * Constrain regular content blocks to 708px (Notion's default text width).- * Tables and collections will use the full 990px container width.- */-.notion-text,-.notion-h1,-.notion-h2,-.notion-h3,-.notion-hr,-.notion-quote,-.notion-callout,-.notion-toggle,-.notion-bulleted_list,-.notion-numbered_list,-.notion-to_do,-.notion-list,-.notion-code,-.notion-bookmark,-.notion-column_list {- max-width: 708px;+.notion-page-content {+ max-width: 100%;}-/* Tables size to content, scroll horizontally if needed */-.notion-simple-table {- display: block;+.notion-page-content-inner {+ display: grid;+ grid-template-columns:+ [full-start] var(--notion-margin-width)+ [content-start] minmax(auto, var(--notion-content-width))+ [content-end] var(--notion-margin-width)+ [full-end];max-width: 100%;+}++.notion-page-content-inner > * {+ grid-column: content;+ min-width: 0;+}++.notion-page-content-inner > .notion-collection {+ grid-column: full;+ overflow-x: auto;+}++.notion-collection .notion-table-cell {+ flex-shrink: 0;+}++@media (min-width: 769px) {+ .notion-collection .notion-table {+ width: 100% !important;+ max-width: 100% !important;+ }++ .notion-collection .notion-table-view {+ padding-left: max(+ 96px,+ calc((100% - var(--notion-content-width)) / 2)+ ) !important;+ padding-right: max(+ 96px,+ calc((100% - var(--notion-content-width)) / 2)+ ) !important;+ min-width: 100% !important;+ width: max-content;+ float: none !important;+ }+}++/* Simple tables: left-aligned with content, extends to right edge of page.+ Scrolls horizontally only if the table is wider than the available space. */+.notion-page-content-inner > .notion-simple-table {+ grid-column: content-start / -1;overflow-x: auto;-webkit-overflow-scrolling: touch;}-.notion-simple-table > table {- table-layout: auto;- width: auto; /* Size to content, don't force full width */+.notion-simple-table > tbody {+ display: table;+ border-collapse: collapse;+ border-spacing: 0;+ width: max-content;}-/* Give table cells proper spacing */+/* Match Notion's cell padding */.notion-simple-table td {- padding: 8px 10px;+ padding: 7px 9px;}-/* On mobile, everything uses full width */+/* On mobile, shrink margins and let react-notion-x handle table sizing natively */@media (max-width: 768px) {- .notion-text,- .notion-h1,- .notion-h2,- .notion-h3,- .notion-hr,- .notion-quote,- .notion-callout,- .notion-toggle,- .notion-bulleted_list,- .notion-numbered_list,- .notion-to_do,- .notion-list,- .notion-code,- .notion-bookmark,- .notion-column_list {+ .notion-page.notion-full-page,+ .notion-page-content-inner {+ --notion-margin-width: 24px;+ }++ .notion-page-content-inner > .notion-simple-table {+ grid-column: content;+ display: block;max-width: 100%;+ overflow-x: auto;}}@@ -178,93 +204,42 @@ textarea,overflow-x: hidden;}-/* Allow notion-page to show icon without clipping, content handles its own overflow */-.notion-page {+/* Apply the same content grid to .notion-page so icon + title align with body content */+.notion-page.notion-full-page {+ display: grid !important;+ grid-template-columns:+ [full-start] var(--notion-margin-width)+ [content-start] minmax(auto, var(--notion-content-width))+ [content-end] var(--notion-margin-width)+ [full-end];max-width: 100%;+ padding-left: 0 !important;+ padding-right: 0 !important;}-.notion-page-content {- max-width: 100%;- overflow-x: hidden;-}--/* Table overflow handling - make tables horizontally scrollable */-.notion-table {- width: 100%;- display: block;- overflow-x: auto;- -webkit-overflow-scrolling: touch;- max-width: 100%;+.notion-page.notion-full-page > * {+ grid-column: content;+ min-width: 0;}-/* Ensure table content can scroll when needed */-.notion-table > table {- min-width: max-content;+.notion-page.notion-full-page > .notion-page-cover-wrapper,+.notion-page.notion-full-page > .notion-page-content {+ grid-column: full;}.notion-simple-table-row td {vertical-align: top;}-/* Collection/Database table wrapper for horizontal scroll */-.notion-collection {- max-width: 100%;- overflow-x: auto;- -webkit-overflow-scrolling: touch;-}--.notion-collection-table {- overflow-x: auto;- -webkit-overflow-scrolling: touch;- max-width: 100%;-}--.notion-collection-table-wrapper {- overflow-x: auto;- -webkit-overflow-scrolling: touch;- max-width: 100%;-}--/* Ensure the table body allows scrolling */-.notion-collection-table-body {- overflow-x: auto;- -webkit-overflow-scrolling: touch;+/* Fix react-notion-x 7.10.0 rendering tabs before collection title.+ Notion shows the title first, then tabs — use flex ordering to match. */+div:has(> .notion-collection-header) {+ display: flex;+ flex-direction: column;}-/* Mobile-specific table overflow handling */-@media (max-width: 768px) {- .notion-table,- .notion-collection,- .notion-collection-table,- .notion-collection-table-wrapper {- max-width: calc(100vw - 2rem);- overflow-x: auto;- margin-left: 0;- margin-right: 0;- }-- /* Simple tables on mobile - contained width with scroll */- .notion-simple-table {- max-width: calc(100vw - 2rem);- overflow-x: auto;- }-- /* Ensure full-width tables on mobile have proper containment */- .notion-page-content-inner {- max-width: 100%;- overflow-x: hidden;- }-- /* Prevent body/html from scrolling horizontally */- .notion-app,- .notion-frame {- max-width: 100vw;- overflow-x: hidden;- }-- .notion-page {- max-width: 100vw;- }+.notion-collection-header {+ order: -1;}/* Video blocks - match Notion's video layout */@@ -322,7 +297,8 @@ textarea,}/* Video wrapper default aspect ratio when not specified */-.notion-asset-wrapper > div:has(> video):not([style*="padding-bottom"]):not([style*="height"]) {+.notion-asset-wrapper+ > div:has(> video):not([style*="padding-bottom"]):not([style*="height"]) {aspect-ratio: 16 / 9;}@@ -355,7 +331,7 @@ textarea,.notion-asset-wrapper iframe {max-width: 100%;}-+.notion-asset-wrapper:has(video),.notion-asset-wrapper:has(iframe) {max-width: calc(100vw - 2rem);