File size: 1,344 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import type { CellPlugin } from '@react-page/editor';
import React from 'react';
import { Timeline } from 'react-twitter-widgets';
type Data = {
screenName: string;
height: number;
title: string;
};
// you can pass the shape of the data as the generic type argument
const customContentPluginTwitter: CellPlugin<Data> = {
Renderer: ({ data }) => (
<div>
<h4>{data.title}</h4>
<Timeline
dataSource={{
sourceType: 'profile',
// data has already the right type!
screenName: data.screenName,
}}
options={{
height: data.height || 600,
}}
/>
</div>
),
id: 'twitter-timeline',
title: 'Twitter timeline',
description: 'A twitter timeline',
version: 1,
controls: {
type: 'autoform',
schema: {
// this JSONschema is type checked against the generic type argument
// the autocompletion of your IDE helps to create this schema
properties: {
title: {
type: 'string',
default: 'A Sample Twitter plugin',
},
screenName: {
type: 'string',
default: 'typescript',
},
height: {
type: 'number',
default: 600,
},
},
required: ['screenName'],
},
},
};
export default customContentPluginTwitter;
|