UNPKG

synapse-react-client

Version:

[![Build Status](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client.svg?branch=main)](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synaps

118 lines (117 loc) 4.71 kB
import * as React from 'react'; import { FileHandleResults, ObjectType, WikiPage } from '../utils/synapseTypes/'; import { SynapseClientError } from '../utils/SynapseClient'; export declare type MarkdownSynapseProps = { ownerId?: string; wikiId?: string; markdown?: string; renderInline?: boolean; objectType?: ObjectType; }; declare type MarkdownSynapseState = { md: any; data: Partial<WikiPage>; fileHandles?: FileHandleResults; error: SynapseClientError | undefined; isLoading: boolean; }; /** * Basic Markdown functionality for Synapse, supporting Images/Plots/References/Bookmarks/buttonlinks * * @class Markdown * @extends {React.Component} */ export default class MarkdownSynapse extends React.Component<MarkdownSynapseProps, MarkdownSynapseState> { markupRef: React.RefObject<HTMLInputElement>; static contextType: React.Context<import("../utils/SynapseContext").SynapseContextType | undefined>; /** * Creates an instance of Markdown. * @param {*} props */ constructor(props: MarkdownSynapseProps); componentWillUnmount(): void; handleLinkClicks(event: React.MouseEvent<HTMLElement>): void; /** * Given input text, generate markdown object to be passed onto inner html of some container. * @param {String} markdown The text being written in plain markdown * @returns {Object} Dictionary to be passed into dangerouslySetInnerHTML with markdown text */ createHTML(markdown?: string): { __html: any; }; /** * Find all math identified elements of the form [id^=\"mathjax-\"] * (e.g. <dom element id="mathjax-10"> text </dom element>) * and transform them to their math markedown equivalents */ processMath(): void; /** * Process all the corresponding bookmark tags of the references made throughout the page * * @memberof MarkdownSynapse */ addBookmarks(): JSX.Element | undefined; /** * Get wiki page markdown and file attachment handles */ getWikiPageMarkdown(): Promise<void>; getWikiAttachments(wikiId: string): Promise<FileHandleResults | undefined>; addIdsToReferenceWidgets(text: string): string; addIdsToTocWidgets(text: string): string; /** * The 'main' method of this class that process all the markdown and transforms it to the appropriate * Synapse widgets. * * @returns JSX of the markdown into widgets * @memberof MarkdownSynapse */ renderMarkdown(): JSX.Element | undefined; /** * recursiveRender will render react tree from HTML tree * * @param {Node} element This will be either a text Node or an HTMLElement * @param {string} markdown The original markdown, its kept as a special case for the table of contents widget * @returns {*} * @memberof MarkdownSynapse */ recursiveRender(element: Node, markdown: string): any; /** * When the markdown string is transfered over the network certain characters get transformed, * this does a simple transformation back to the original user's string. * * @param {string} xml * @returns * @memberof MarkdownSynapse */ decodeXml(xml: string): string; /** * Given widgetMap renders it in a React component (or originalMarkup in special cases.) * * @param {string} widgetMatch The synapse widget to be rendered * @param {string} originalMarkup The original markup text, this is a special case for widgets that * are html specific. * @returns JSX of the widget to render * @memberof MarkdownSynapse */ processHTMLWidgetMapping(widgetParams: string, originalMarkup: string): JSX.Element | undefined; /** * Given widgetType renders the apppropriate widget * * @param {string} widgetType The type of synapse widget. (e.g. 'image', 'plot') * @param {*} widgetparamsMapped The parameters for this widget * @param {string} originalMarkup The original markup. * @returns * @memberof MarkdownSynapse */ renderWidget(widgetType: string, widgetparamsMapped: any, originalMarkup: string): JSX.Element | undefined; renderSynapseButton(widgetparamsMapped: any): JSX.Element; renderSynapsePlot(widgetparamsMapped: any): JSX.Element; renderVideo(widgetparamsMapped: any): JSX.Element; renderSynapseImage(widgetparamsMapped: any): JSX.Element | undefined; renderSynapseTOC(originalMarkup: string): JSX.Element; renderUserBadge(widgetparamsMapped: any): JSX.Element; componentDidMount(): Promise<void>; componentDidUpdate(prevProps: MarkdownSynapseProps): Promise<void>; render(): JSX.Element; } export {};