@dxos/plugin-presenter 0.8.4-main.ae835ea → 0.8.4-main.bcb3aa67d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/PresenterSettings-DSPIGNOL.mjs +32 -0
- package/dist/lib/browser/PresenterSettings-DSPIGNOL.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +533 -46
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +30 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/types/src/PresenterPlugin.d.ts +2 -1
- package/dist/types/src/PresenterPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +8 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +8 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/components/Markdown/Panel.d.ts +8 -0
- package/dist/types/src/components/Markdown/Panel.d.ts.map +1 -0
- package/dist/types/src/components/Markdown/{Container.stories.d.ts → Panel.stories.d.ts} +1 -1
- package/dist/types/src/components/Markdown/Panel.stories.d.ts.map +1 -0
- package/dist/types/src/components/Markdown/index.d.ts +1 -1
- package/dist/types/src/components/Markdown/index.d.ts.map +1 -1
- package/dist/types/src/components/Presenter/Layout.d.ts +9 -5
- package/dist/types/src/components/Presenter/Layout.d.ts.map +1 -1
- package/dist/types/src/components/Presenter/Pager.d.ts +1 -1
- package/dist/types/src/components/Presenter/Pager.d.ts.map +1 -1
- package/dist/types/src/components/PresenterSettings/PresenterSettings.d.ts +6 -0
- package/dist/types/src/components/PresenterSettings/PresenterSettings.d.ts.map +1 -0
- package/dist/types/src/components/PresenterSettings/PresenterSettings.stories.d.ts +25 -0
- package/dist/types/src/components/PresenterSettings/PresenterSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/PresenterSettings/index.d.ts +3 -0
- package/dist/types/src/components/PresenterSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/RevealPlayer/RevealPlayer.d.ts +9 -4
- package/dist/types/src/components/RevealPlayer/RevealPlayer.d.ts.map +1 -1
- package/dist/types/src/components/RevealPlayer/RevealPlayer.stories.d.ts +12 -5
- package/dist/types/src/components/RevealPlayer/RevealPlayer.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -27
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/CollectionPresenterContainer/CollectionPresenterContainer.d.ts +7 -0
- package/dist/types/src/containers/CollectionPresenterContainer/CollectionPresenterContainer.d.ts.map +1 -0
- package/dist/types/src/containers/CollectionPresenterContainer/index.d.ts +3 -0
- package/dist/types/src/containers/CollectionPresenterContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components/MarkdownSlide.d.ts → containers/DocumentPresenterContainer/DocumentPresenterContainer.d.ts} +2 -3
- package/dist/types/src/containers/DocumentPresenterContainer/DocumentPresenterContainer.d.ts.map +1 -0
- package/dist/types/src/containers/DocumentPresenterContainer/index.d.ts +3 -0
- package/dist/types/src/containers/DocumentPresenterContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownSlide/MarkdownSlide.d.ts +8 -0
- package/dist/types/src/containers/MarkdownSlide/MarkdownSlide.d.ts.map +1 -0
- package/dist/types/src/containers/MarkdownSlide/index.d.ts +3 -0
- package/dist/types/src/containers/MarkdownSlide/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +17 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +2 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +6 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +6 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +18 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/useExitPresenter.d.ts +3 -4
- package/dist/types/src/useExitPresenter.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -40
- package/src/PresenterPlugin.tsx +12 -25
- package/src/capabilities/app-graph-builder.ts +91 -100
- package/src/capabilities/index.ts +4 -4
- package/src/capabilities/react-surface.tsx +57 -53
- package/src/capabilities/settings.ts +24 -12
- package/src/components/Markdown/{Container.stories.tsx → Panel.stories.tsx} +7 -7
- package/src/components/Markdown/{Container.tsx → Panel.tsx} +6 -6
- package/src/components/Markdown/Slide.stories.tsx +4 -4
- package/src/components/Markdown/index.ts +1 -1
- package/src/components/Markdown/theme.ts +5 -5
- package/src/components/Presenter/Layout.tsx +24 -23
- package/src/components/Presenter/Pager.stories.tsx +2 -2
- package/src/components/Presenter/Pager.tsx +53 -18
- package/src/components/PresenterSettings/PresenterSettings.stories.tsx +32 -0
- package/src/components/PresenterSettings/PresenterSettings.tsx +32 -0
- package/src/components/PresenterSettings/index.ts +7 -0
- package/src/components/RevealPlayer/RevealPlayer.stories.tsx +3 -3
- package/src/components/RevealPlayer/RevealPlayer.tsx +104 -93
- package/src/components/index.ts +5 -5
- package/src/containers/CollectionPresenterContainer/CollectionPresenterContainer.tsx +43 -0
- package/src/containers/CollectionPresenterContainer/index.ts +7 -0
- package/src/containers/DocumentPresenterContainer/DocumentPresenterContainer.tsx +23 -0
- package/src/containers/DocumentPresenterContainer/index.ts +7 -0
- package/src/{components → containers/MarkdownSlide}/MarkdownSlide.tsx +9 -7
- package/src/containers/MarkdownSlide/index.ts +7 -0
- package/src/containers/index.ts +9 -0
- package/src/meta.ts +3 -3
- package/src/operations/definitions.ts +23 -0
- package/src/operations/index.ts +5 -0
- package/src/translations.ts +6 -5
- package/src/types/Settings.ts +15 -0
- package/src/types/index.ts +30 -0
- package/src/useExitPresenter.ts +26 -24
- package/dist/lib/browser/CollectionPresenterContainer-ASH2TGJR.mjs +0 -191
- package/dist/lib/browser/CollectionPresenterContainer-ASH2TGJR.mjs.map +0 -7
- package/dist/lib/browser/DocumentPresenterContainer-F42V4KAL.mjs +0 -183
- package/dist/lib/browser/DocumentPresenterContainer-F42V4KAL.mjs.map +0 -7
- package/dist/lib/browser/MarkdownSlide-BLVWTH3U.mjs +0 -223
- package/dist/lib/browser/MarkdownSlide-BLVWTH3U.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-UGCZOBA6.mjs +0 -106
- package/dist/lib/browser/app-graph-builder-UGCZOBA6.mjs.map +0 -7
- package/dist/lib/browser/chunk-EOT6RIHJ.mjs +0 -39
- package/dist/lib/browser/chunk-EOT6RIHJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-TMTUZQCK.mjs +0 -18
- package/dist/lib/browser/chunk-TMTUZQCK.mjs.map +0 -7
- package/dist/lib/browser/chunk-UVGTHJUO.mjs +0 -36
- package/dist/lib/browser/chunk-UVGTHJUO.mjs.map +0 -7
- package/dist/lib/browser/chunk-WWKBVJB3.mjs +0 -41
- package/dist/lib/browser/chunk-WWKBVJB3.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UIAHN2NJ.mjs +0 -57
- package/dist/lib/browser/react-surface-UIAHN2NJ.mjs.map +0 -7
- package/dist/lib/browser/settings-RZWQTJI2.mjs +0 -22
- package/dist/lib/browser/settings-RZWQTJI2.mjs.map +0 -7
- package/dist/types/src/components/CollectionPresenterContainer.d.ts +0 -7
- package/dist/types/src/components/CollectionPresenterContainer.d.ts.map +0 -1
- package/dist/types/src/components/DocumentPresenterContainer.d.ts +0 -7
- package/dist/types/src/components/DocumentPresenterContainer.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/Container.d.ts +0 -8
- package/dist/types/src/components/Markdown/Container.d.ts.map +0 -1
- package/dist/types/src/components/Markdown/Container.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownSlide.d.ts.map +0 -1
- package/dist/types/src/components/PresenterSettings.d.ts +0 -6
- package/dist/types/src/components/PresenterSettings.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -40
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/components/CollectionPresenterContainer.tsx +0 -44
- package/src/components/DocumentPresenterContainer.tsx +0 -23
- package/src/components/PresenterSettings.tsx +0 -30
- package/src/types.ts +0 -46
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
7
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
8
8
|
|
|
9
|
-
import { createSlide } from '
|
|
9
|
+
import { createSlide } from '#testing';
|
|
10
10
|
|
|
11
11
|
import { Slide } from './Slide';
|
|
12
12
|
|
|
13
13
|
const meta = {
|
|
14
|
-
title: 'plugins/plugin-presenter/Slide',
|
|
14
|
+
title: 'plugins/plugin-presenter/components/Slide',
|
|
15
15
|
component: Slide,
|
|
16
|
-
decorators: [withTheme],
|
|
16
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
17
17
|
parameters: {
|
|
18
18
|
layout: 'fullscreen',
|
|
19
19
|
},
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
// TODO(burdon): Create theme type and picker.
|
|
6
6
|
|
|
7
7
|
export const theme = {
|
|
8
|
-
root: 'bg-attention leading-relaxed font-mono',
|
|
8
|
+
root: 'bg-attention-surface leading-relaxed font-mono',
|
|
9
9
|
|
|
10
10
|
padding: 'px-40 py-16 gap-8',
|
|
11
11
|
|
|
12
12
|
nodes: {
|
|
13
|
-
h1: 'text-[80px] text-
|
|
14
|
-
h2: 'text-[60px] text-
|
|
15
|
-
h3: 'text-[48px] text-
|
|
13
|
+
h1: 'text-[80px] text-accent-text',
|
|
14
|
+
h2: 'text-[60px] text-accent-text',
|
|
15
|
+
h3: 'text-[48px] text-accent-text',
|
|
16
16
|
|
|
17
17
|
p: 'text-[48px]',
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ export const theme = {
|
|
|
20
20
|
ol: 'my-[16px] ml-24 leading-relaxed list-decimal',
|
|
21
21
|
li: 'pl-6 text-[48px]',
|
|
22
22
|
|
|
23
|
-
pre: 'w-full mx-0 my-[32px] p-
|
|
23
|
+
pre: 'w-full mx-0 my-[32px] p-4 bg-input-surface',
|
|
24
24
|
code: 'p-0 text-[40px]',
|
|
25
25
|
},
|
|
26
26
|
};
|
|
@@ -4,30 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type PropsWithChildren, type ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
7
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
9
8
|
|
|
10
|
-
export type LayoutProps =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
bottomRight?: ReactNode;
|
|
17
|
-
}>
|
|
18
|
-
>;
|
|
9
|
+
export type LayoutProps = PropsWithChildren<{
|
|
10
|
+
topLeft?: ReactNode;
|
|
11
|
+
topRight?: ReactNode;
|
|
12
|
+
bottomLeft?: ReactNode;
|
|
13
|
+
bottomRight?: ReactNode;
|
|
14
|
+
}>;
|
|
19
15
|
|
|
20
|
-
export const Layout =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<div
|
|
16
|
+
export const Layout = composable<HTMLDivElement, LayoutProps>(
|
|
17
|
+
({ children, topLeft, topRight, bottomLeft, bottomRight, ...props }, forwardedRef) => {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
{...composableProps(props, { classNames: 'flex grow relative overflow-hidden bg-attention-surface' })}
|
|
21
|
+
ref={forwardedRef}
|
|
22
|
+
>
|
|
23
|
+
<div className='flex flex-col grow overflow-hidden'>{children}</div>
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
<div className='z-[200]'>
|
|
26
|
+
<div className='absolute top-4 left-4'>{topLeft}</div>
|
|
27
|
+
<div className='absolute top-4 right-4'>{topRight}</div>
|
|
28
|
+
<div className='absolute bottom-4 left-4'>{bottomLeft}</div>
|
|
29
|
+
<div className='absolute bottom-4 right-4'>{bottomRight}</div>
|
|
30
|
+
</div>
|
|
30
31
|
</div>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
);
|
|
@@ -23,9 +23,9 @@ const DefaultStory = ({ count = 20 }: PagerProps) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const meta = {
|
|
26
|
-
title: 'plugins/plugin-presenter/Pager',
|
|
26
|
+
title: 'plugins/plugin-presenter/components/Pager',
|
|
27
27
|
render: DefaultStory,
|
|
28
|
-
decorators: [withTheme],
|
|
28
|
+
decorators: [withTheme()],
|
|
29
29
|
parameters: {
|
|
30
30
|
layout: 'centered',
|
|
31
31
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { IconButton, useControlledState } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
9
|
export type PagerProps = {
|
|
10
10
|
index?: number;
|
|
@@ -14,8 +14,8 @@ export type PagerProps = {
|
|
|
14
14
|
onExit?: () => void;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const Pager = ({ index:
|
|
18
|
-
const [index, setIndex] = useControlledState(
|
|
17
|
+
export const Pager = ({ index: indexProp = 0, count = 0, keys, onChange, onExit }: PagerProps) => {
|
|
18
|
+
const [index, setIndex] = useControlledState(indexProp);
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
onChange?.(index);
|
|
21
21
|
}, [index]);
|
|
@@ -76,18 +76,46 @@ export const Pager = ({ index: indexParam = 0, count = 0, keys, onChange, onExit
|
|
|
76
76
|
|
|
77
77
|
return (
|
|
78
78
|
<div className='flex items-center text-neutral-500'>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
<IconButton
|
|
80
|
+
icon='ph--caret-double-left--regular'
|
|
81
|
+
size={6}
|
|
82
|
+
label='Jump to first'
|
|
83
|
+
iconOnly
|
|
84
|
+
noTooltip
|
|
85
|
+
variant='ghost'
|
|
86
|
+
classNames='p-0'
|
|
87
|
+
onClick={() => onChange?.(0)}
|
|
88
|
+
/>
|
|
89
|
+
<IconButton
|
|
90
|
+
icon='ph--caret-left--regular'
|
|
91
|
+
size={6}
|
|
92
|
+
label='Previous'
|
|
93
|
+
iconOnly
|
|
94
|
+
noTooltip
|
|
95
|
+
variant='ghost'
|
|
96
|
+
classNames='p-0'
|
|
97
|
+
onClick={() => handleChangeIndex(-1)}
|
|
98
|
+
/>
|
|
99
|
+
<IconButton
|
|
100
|
+
icon='ph--caret-right--regular'
|
|
101
|
+
size={6}
|
|
102
|
+
label='Next'
|
|
103
|
+
iconOnly
|
|
104
|
+
noTooltip
|
|
105
|
+
variant='ghost'
|
|
106
|
+
classNames='p-0'
|
|
107
|
+
onClick={() => handleChangeIndex(1)}
|
|
108
|
+
/>
|
|
109
|
+
<IconButton
|
|
110
|
+
icon='ph--caret-double-right--regular'
|
|
111
|
+
size={6}
|
|
112
|
+
label='Jump to last'
|
|
113
|
+
iconOnly
|
|
114
|
+
noTooltip
|
|
115
|
+
variant='ghost'
|
|
116
|
+
classNames='p-0'
|
|
117
|
+
onClick={() => onChange?.(count - 1)}
|
|
118
|
+
/>
|
|
91
119
|
</div>
|
|
92
120
|
);
|
|
93
121
|
};
|
|
@@ -113,8 +141,15 @@ export const PageNumber = ({ index = 0, count = 1 }: PageNumberProps) => {
|
|
|
113
141
|
|
|
114
142
|
export const StartButton = ({ running, onClick }: { running?: boolean; onClick?: (start: boolean) => void }) => {
|
|
115
143
|
return (
|
|
116
|
-
<
|
|
117
|
-
{
|
|
118
|
-
|
|
144
|
+
<IconButton
|
|
145
|
+
icon={running ? 'ph--x--regular' : 'ph--play--regular'}
|
|
146
|
+
size={6}
|
|
147
|
+
label={running ? 'Stop' : 'Play'}
|
|
148
|
+
iconOnly
|
|
149
|
+
noTooltip
|
|
150
|
+
variant='ghost'
|
|
151
|
+
classNames='p-0'
|
|
152
|
+
onClick={() => onClick?.(!running)}
|
|
153
|
+
/>
|
|
119
154
|
);
|
|
120
155
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
|
|
7
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
8
|
+
|
|
9
|
+
import { translations } from '../../translations';
|
|
10
|
+
|
|
11
|
+
import { PresenterSettings } from './PresenterSettings';
|
|
12
|
+
|
|
13
|
+
const meta = {
|
|
14
|
+
title: 'plugins/plugin-presenter/components/PresenterSettings',
|
|
15
|
+
component: PresenterSettings,
|
|
16
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
17
|
+
tags: ['settings'],
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'fullscreen',
|
|
20
|
+
translations,
|
|
21
|
+
},
|
|
22
|
+
} satisfies Meta<typeof PresenterSettings>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
export const Default: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
settings: { presentCollections: true },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SettingsSurfaceProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { Input, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { Settings as SettingsForm } from '@dxos/react-ui-form';
|
|
10
|
+
|
|
11
|
+
import { meta } from '#meta';
|
|
12
|
+
import { type Settings } from '#types';
|
|
13
|
+
|
|
14
|
+
export type PresenterSettingsProps = SettingsSurfaceProps<Settings.Settings>;
|
|
15
|
+
|
|
16
|
+
export const PresenterSettings = ({ settings, onSettingsChange }: PresenterSettingsProps) => {
|
|
17
|
+
const { t } = useTranslation(meta.id);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<SettingsForm.Viewport>
|
|
21
|
+
<SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
|
|
22
|
+
<SettingsForm.Item title={t('present-collections.label')} description={t('present-collections.description')}>
|
|
23
|
+
<Input.Switch
|
|
24
|
+
disabled={!onSettingsChange}
|
|
25
|
+
checked={settings.presentCollections}
|
|
26
|
+
onCheckedChange={(checked) => onSettingsChange?.((s) => ({ ...s, presentCollections: !!checked }))}
|
|
27
|
+
/>
|
|
28
|
+
</SettingsForm.Item>
|
|
29
|
+
</SettingsForm.Section>
|
|
30
|
+
</SettingsForm.Viewport>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Meta } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
7
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
8
8
|
|
|
9
9
|
import CONTENT from '../../../testing/deck.md?raw';
|
|
10
10
|
import { translations } from '../../translations';
|
|
@@ -20,9 +20,9 @@ import { RevealPlayer } from './RevealPlayer';
|
|
|
20
20
|
// https://fonts.google.com
|
|
21
21
|
|
|
22
22
|
const meta = {
|
|
23
|
-
title: 'plugins/plugin-presenter/RevealPlayer',
|
|
23
|
+
title: 'plugins/plugin-presenter/components/RevealPlayer',
|
|
24
24
|
component: RevealPlayer,
|
|
25
|
-
decorators: [withTheme],
|
|
25
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
26
26
|
parameters: {
|
|
27
27
|
layout: 'fullscreen',
|
|
28
28
|
translations,
|
|
@@ -17,8 +17,8 @@ import Reveal from 'reveal.js';
|
|
|
17
17
|
import RevealHighlight from 'reveal.js/plugin/highlight/highlight';
|
|
18
18
|
import RevealMarkdown from 'reveal.js/plugin/markdown/plugin.js';
|
|
19
19
|
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
21
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
22
22
|
|
|
23
23
|
const styles = `
|
|
24
24
|
<style type="text/css">
|
|
@@ -61,108 +61,119 @@ const styles = `
|
|
|
61
61
|
</style>
|
|
62
62
|
`;
|
|
63
63
|
|
|
64
|
-
export type RevealProps =
|
|
64
|
+
export type RevealProps = {
|
|
65
65
|
content: string;
|
|
66
66
|
slide?: number;
|
|
67
67
|
fullscreen?: boolean;
|
|
68
68
|
onExit?: () => void;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const RevealPlayer = ({ classNames, content, slide, fullscreen = true, onExit }: RevealProps) => {
|
|
72
|
-
const deckDivRef = useRef<HTMLDivElement>(null);
|
|
73
|
-
const deckRef = useRef<Reveal.Api | null>(null);
|
|
74
|
-
|
|
75
|
-
useAsyncEffect(async () => {
|
|
76
|
-
if (deckRef.current) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Required for syntax highlighting.
|
|
81
|
-
hljs.registerLanguage('typescript', typescript);
|
|
82
|
-
|
|
83
|
-
// https://revealjs.com/react
|
|
84
|
-
// https://revealjs.com/config
|
|
85
|
-
// https://github.com/hakimel/reveal.js
|
|
86
|
-
// TODO(burdon): Fragments and scroll view steps 2 at a time (safe mode?)
|
|
87
|
-
deckRef.current = new Reveal(deckDivRef.current!, {
|
|
88
|
-
// view: 'scroll',
|
|
89
|
-
progress: false,
|
|
90
|
-
transition: 'none',
|
|
91
|
-
slideNumber: false,
|
|
92
|
-
embedded: true,
|
|
93
|
-
|
|
94
|
-
// TODO(burdon): Speaker view requires server to serve popout window.
|
|
95
|
-
// https://revealjs.com/speaker-view
|
|
96
|
-
showNotes: false,
|
|
97
|
-
|
|
98
|
-
// width: 1600,
|
|
99
|
-
// height: 900,
|
|
100
|
-
margin: 0.1,
|
|
101
|
-
// center: false,
|
|
102
|
-
// minScale: 0.1,
|
|
103
|
-
// maxScale: 1.4,
|
|
104
|
-
|
|
105
|
-
// https://revealjs.com/markdown
|
|
106
|
-
// TODO(burdon): Requires server to serve popout window.
|
|
107
|
-
plugins: [RevealMarkdown, RevealHighlight],
|
|
108
|
-
|
|
109
|
-
// See https://marked.js.org/using_advanced#options
|
|
110
|
-
markdown: {
|
|
111
|
-
gfm: true,
|
|
112
|
-
smartypants: true,
|
|
113
|
-
highlight: (code, language) => {
|
|
114
|
-
if (language) {
|
|
115
|
-
return hljs.highlight(code, { language }).value;
|
|
116
|
-
}
|
|
69
|
+
};
|
|
117
70
|
|
|
118
|
-
|
|
71
|
+
export const RevealPlayer = composable<HTMLDivElement, RevealProps>(
|
|
72
|
+
({ content, slide, fullscreen = true, onExit, children, ...props }, forwardedRef) => {
|
|
73
|
+
const deckDivRef = useRef<HTMLDivElement>(null);
|
|
74
|
+
const deckRef = useRef<Reveal.Api | null>(null);
|
|
75
|
+
|
|
76
|
+
useAsyncEffect(async () => {
|
|
77
|
+
if (deckRef.current) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Required for syntax highlighting.
|
|
82
|
+
hljs.registerLanguage('typescript', typescript);
|
|
83
|
+
|
|
84
|
+
// https://revealjs.com/react
|
|
85
|
+
// https://revealjs.com/config
|
|
86
|
+
// https://github.com/hakimel/reveal.js
|
|
87
|
+
// TODO(burdon): Fragments and scroll view steps 2 at a time (safe mode?)
|
|
88
|
+
deckRef.current = new Reveal(deckDivRef.current!, {
|
|
89
|
+
// view: 'scroll',
|
|
90
|
+
progress: false,
|
|
91
|
+
transition: 'none',
|
|
92
|
+
slideNumber: false,
|
|
93
|
+
embedded: true,
|
|
94
|
+
|
|
95
|
+
// Disable autoplay to prevent errors in headless environments (e.g., CI).
|
|
96
|
+
autoPlayMedia: false,
|
|
97
|
+
|
|
98
|
+
// TODO(burdon): Speaker view requires server to serve popout window.
|
|
99
|
+
// https://revealjs.com/speaker-view
|
|
100
|
+
showNotes: false,
|
|
101
|
+
|
|
102
|
+
// width: 1600,
|
|
103
|
+
// height: 900,
|
|
104
|
+
margin: 0.1,
|
|
105
|
+
// center: false,
|
|
106
|
+
// minScale: 0.1,
|
|
107
|
+
// maxScale: 1.4,
|
|
108
|
+
|
|
109
|
+
// https://revealjs.com/markdown
|
|
110
|
+
// TODO(burdon): Requires server to serve popout window.
|
|
111
|
+
plugins: [RevealMarkdown, RevealHighlight],
|
|
112
|
+
|
|
113
|
+
// See https://marked.js.org/using_advanced#options
|
|
114
|
+
markdown: {
|
|
115
|
+
gfm: true,
|
|
116
|
+
smartypants: true,
|
|
117
|
+
highlight: (code, language) => {
|
|
118
|
+
if (language) {
|
|
119
|
+
return hljs.highlight(code, { language }).value;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return hljs.highlightAuto(code).value;
|
|
123
|
+
},
|
|
119
124
|
},
|
|
120
|
-
}
|
|
121
|
-
});
|
|
125
|
+
});
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
await deckRef.current.initialize();
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
if (slide !== undefined) {
|
|
130
|
+
deckRef.current.slide(slide < 0 ? deckRef.current?.getTotalSlides() + slide : slide - 1);
|
|
131
|
+
}
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
deckRef.current.addKeyBinding({ keyCode: 27, key: 'Escape', description: 'Exit full screen' }, () => {
|
|
134
|
+
onExit?.();
|
|
135
|
+
});
|
|
132
136
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
return () => {
|
|
138
|
+
try {
|
|
139
|
+
if (deckRef.current) {
|
|
140
|
+
deckRef.current.destroy();
|
|
141
|
+
deckRef.current = null;
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
// Ignore.
|
|
138
145
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
<
|
|
154
|
-
rel='
|
|
155
|
-
href='https://fonts.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// TOOD(burdon): Trap cursor keys (otherwise tabster grabs focus.)
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
{...composableProps(props, {
|
|
153
|
+
classNames: ['dx-container grid place-items-center bg-black', fullscreen && 'absolute inset-0'],
|
|
154
|
+
})}
|
|
155
|
+
ref={forwardedRef}
|
|
156
|
+
>
|
|
157
|
+
<div role='none' className='relative aspect-video h-full w-full h-auto max-h-full overflow-hidden'>
|
|
158
|
+
<div ref={deckDivRef} className='absolute inset-0 reveal'>
|
|
159
|
+
{/* NOTE: Must be in head. */}
|
|
160
|
+
<style>
|
|
161
|
+
<link rel='preconnect' href='https://fonts.googleapis.com' />
|
|
162
|
+
<link rel='preconnect' href='https://fonts.gstatic.com' {...{ crossOrigin: '' }} />
|
|
163
|
+
<link
|
|
164
|
+
rel='stylesheet'
|
|
165
|
+
href='https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap'
|
|
166
|
+
/>
|
|
167
|
+
</style>
|
|
168
|
+
<div className='slides'>
|
|
169
|
+
<div className='text-center!' />
|
|
170
|
+
<section {...{ 'data-markdown': [] }}>
|
|
171
|
+
<textarea {...{ 'data-template': true }} defaultValue={[styles, content].join('\n')}></textarea>
|
|
172
|
+
</section>
|
|
173
|
+
</div>
|
|
163
174
|
</div>
|
|
164
175
|
</div>
|
|
165
176
|
</div>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
);
|
|
178
|
+
},
|
|
179
|
+
);
|
package/src/components/index.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { lazy } from 'react';
|
|
5
|
+
import { type ComponentType, lazy } from 'react';
|
|
6
6
|
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './Markdown';
|
|
8
|
+
export * from './Presenter';
|
|
9
|
+
export * from './RevealPlayer';
|
|
8
10
|
|
|
9
|
-
export const
|
|
10
|
-
export const DocumentPresenterContainer = lazy(() => import('./DocumentPresenterContainer'));
|
|
11
|
-
export const CollectionPresenterContainer = lazy(() => import('./CollectionPresenterContainer'));
|
|
11
|
+
export const PresenterSettings: ComponentType<any> = lazy(() => import('./PresenterSettings'));
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useContext, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { type ObjectSurfaceProps } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { type Collection } from '@dxos/echo';
|
|
10
|
+
import { Panel } from '@dxos/react-ui';
|
|
11
|
+
|
|
12
|
+
import { PageNumber, Pager, Layout as PresenterLayout } from '#components';
|
|
13
|
+
import { PresenterContext } from '#types';
|
|
14
|
+
import { useExitPresenter } from '../../useExitPresenter';
|
|
15
|
+
|
|
16
|
+
type CollectionPresenterContainerProps = ObjectSurfaceProps<Collection.Collection>;
|
|
17
|
+
|
|
18
|
+
export const CollectionPresenterContainer = ({ role, subject: collection }: CollectionPresenterContainerProps) => {
|
|
19
|
+
const [slide, setSlide] = useState(0);
|
|
20
|
+
const { running } = useContext(PresenterContext);
|
|
21
|
+
const handleExit = useExitPresenter(collection);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Panel.Root role={role} classNames='relative'>
|
|
25
|
+
<Panel.Content asChild>
|
|
26
|
+
<PresenterLayout
|
|
27
|
+
bottomRight={<PageNumber index={slide} count={collection.objects.length} />}
|
|
28
|
+
bottomLeft={
|
|
29
|
+
<Pager
|
|
30
|
+
index={slide}
|
|
31
|
+
count={collection.objects.length}
|
|
32
|
+
keys={running}
|
|
33
|
+
onChange={setSlide}
|
|
34
|
+
onExit={handleExit}
|
|
35
|
+
/>
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
<Surface.Surface role='slide' data={{ subject: collection.objects[slide] }} />
|
|
39
|
+
</PresenterLayout>
|
|
40
|
+
</Panel.Content>
|
|
41
|
+
</Panel.Root>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type FC } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Markdown } from '@dxos/plugin-markdown/types';
|
|
8
|
+
import { Panel } from '@dxos/react-ui';
|
|
9
|
+
|
|
10
|
+
import { RevealPlayer } from '#components';
|
|
11
|
+
import { useExitPresenter } from '../../useExitPresenter';
|
|
12
|
+
|
|
13
|
+
export const DocumentPresenterContainer: FC<{ document: Markdown.Document }> = ({ document }) => {
|
|
14
|
+
const handleExit = useExitPresenter(document);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Panel.Root classNames='relative'>
|
|
18
|
+
<Panel.Content asChild>
|
|
19
|
+
<RevealPlayer content={document.content.target?.content ?? ''} onExit={handleExit} />
|
|
20
|
+
</Panel.Content>
|
|
21
|
+
</Panel.Root>
|
|
22
|
+
);
|
|
23
|
+
};
|