-
+
+
+
With Multi Page Editors
+
+ Sometimes you need to show a list of pages where each page has its own content for the editor. In many cases,
+ there is a problem with updating content when you navigate between pages. So, this example is just for these
+ cases. Follow the{' '}
+
+ link here
+ {' '}
+ to see how it works and its source code
+
+
);
}
diff --git a/web/next-example/src/components/ui/sheet.tsx b/web/next-example/src/components/ui/sheet.tsx
index 908f1221d..36dc3f033 100644
--- a/web/next-example/src/components/ui/sheet.tsx
+++ b/web/next-example/src/components/ui/sheet.tsx
@@ -102,9 +102,11 @@ SheetDescription.displayName = SheetPrimitive.Description.displayName;
type SheetProps = {
items: { id: string; title: string; href: string }[];
path: string;
+ title?: string;
+ description?: string | React.ReactNode;
};
-const Sheet = ({ items, path }: SheetProps) => {
+const Sheet = ({ items, path, title, description }: SheetProps) => {
const [isMobile, setIsMobile] = React.useState(window.innerWidth < 640);
const [isOpen, onOpenChange] = React.useState(!isMobile);
const { setTheme } = useTheme();
@@ -140,19 +142,22 @@ const Sheet = ({ items, path }: SheetProps) => {
onOpenChange((p) => !p)}>
- Yoopta examples
-
- Found issue?
-
-
- Report it in repo
-
-
+ {title || 'Yoopta examples'}
+ {description || (
+
+ Found issue?
+
+
+ Report it in repo
+
+
+ )}
+
{items &&
items.map((item) => {
diff --git a/web/next-example/src/pages/examples/[example].tsx b/web/next-example/src/pages/examples/[example].tsx
index 78aa2cd7c..ec831f1bb 100644
--- a/web/next-example/src/pages/examples/[example].tsx
+++ b/web/next-example/src/pages/examples/[example].tsx
@@ -20,7 +20,7 @@ import withChatSlack from '@/components/examples/withChatSlack';
import withCustomStyles from '@/components/examples/withCustomStyles';
import withEditorFocusBlur from '@/components/examples/withEditorFocusBlur';
import withCustomRenders from '@/components/examples/withCustomRenders';
-// import withMultiPageEditors from '@/components/examples/withMultiPageEditors';
+import withMultiPageEditors from '@/components/examples/withMultiPageEditors';
import { Head } from '@/components/Head/Head';
import { useRouter } from 'next/router';
@@ -49,7 +49,7 @@ export const EXAMPLES: Record
React.JSX.Element> = {
withLargeDocuments,
withChatSlack,
withEditorFocusBlur,
- // withMultiPageEditors,
+ withMultiPageEditors,
// withCraftExample,
// withOffline,
// withCustomComponent,
@@ -142,7 +142,7 @@ const EXAMPLE_MAP: Record = {
},
};
-const ExampleComponent = () => {
+const ExampleComponentPage = () => {
const router = useRouter();
const ExampleComponent = EXAMPLES[(router.query.example as string) || 'withBaseFullSetup'];
@@ -165,4 +165,4 @@ const ExampleComponent = () => {
);
};
-export default ExampleComponent;
+export default ExampleComponentPage;
diff --git a/web/next-example/src/pages/examples/withMultiPageEditors/[page].tsx b/web/next-example/src/pages/examples/withMultiPageEditors/[page].tsx
new file mode 100644
index 000000000..c46990d71
--- /dev/null
+++ b/web/next-example/src/pages/examples/withMultiPageEditors/[page].tsx
@@ -0,0 +1,31 @@
+import { Head } from '@/components/Head/Head';
+import { useRouter } from 'next/router';
+import dynamic from 'next/dynamic';
+import PAGES_DATA from '../../../components/examples/withMultiPageEditors/db.json';
+import { EveryPageContent } from '@/components/examples/withMultiPageEditors/EveryPageContent';
+import { CheckSourceCode } from '@/components/CheckSourceCode/CheckSourceCode';
+
+const Sheet = dynamic(() => import('@/components/ui/sheet').then((mod) => mod.Sheet), { ssr: false });
+
+const DynamicPageComponent = () => {
+ const router = useRouter();
+
+ const pages = Object.keys(PAGES_DATA).map((pageId) => {
+ return {
+ title: PAGES_DATA[pageId].title,
+ id: pageId,
+ href: `/examples/withMultiPageEditors/${pageId}`,
+ };
+ });
+
+ return (
+
+
+
+
+ >} items={pages} path={router.asPath} />
+
+ );
+};
+
+export default DynamicPageComponent;