1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { Dispatch } from 'redux';
7 import { connect } from 'react-redux';
8 import { withStyles, StyleRulesCallback, WithStyles, Typography } from '@material-ui/core';
9 import { ArvadosTheme } from 'common/custom-theme';
10 import { openRichTextEditorDialog } from 'store/rich-text-editor-dialog/rich-text-editor-dialog-actions';
12 type CssRules = "root";
14 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
16 color: theme.palette.primary.main,
21 interface RichTextEditorLinkData {
27 interface RichTextEditorLinkActions {
28 onClick: (title: string, content: string) => void;
31 type RichTextEditorLinkProps = RichTextEditorLinkData & RichTextEditorLinkActions & WithStyles<CssRules>;
33 const mapDispatchToProps = (dispatch: Dispatch) => ({
34 onClick: (title: string, content: string) => dispatch<any>(openRichTextEditorDialog(title, content))
37 export const RichTextEditorLink = connect(undefined, mapDispatchToProps)(
38 withStyles(styles)(({ classes, title, content, label, onClick }: RichTextEditorLinkProps) =>
39 <Typography component='span' className={classes.root}
40 onClick={() => onClick(title, content) }>