From 591532fa22831b6261220b297d9b9162bd21cfa2 Mon Sep 17 00:00:00 2001 From: Mohamed Shaban Date: Fri, 22 Mar 2019 15:54:28 +0100 Subject: [PATCH 1/2] feat(*): add typescript type definitions --- index.d.ts | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..ea49e21 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for react-native-simple-markdown 1.1.0 +// Project: https://github.com/CharlesMangwa/react-native-simple-markdown +// Definitions by: Mohamed Shaban + +import { Component, ReactNode } from 'react'; +import { ViewStyle, TextStyle, ImageStyle, StyleProp } from 'react-native'; + +export interface ReactNativeSimpleMarkdown { } +export type ValidRules = + | 'autolink' + | 'blockQuote' + | 'br' + | 'codeBlock' + | 'del' + | 'em' + | 'heading' + | 'hr' + | 'image' + | 'inlineCode' + | 'link' + | 'list' + | 'newline' + | 'paragraph' + | 'strong' + | 'table' + | 'url'; + +interface State { + key: string; + withinText: boolean; +} + +export interface Node { + content: any; + target: string; + level: number; + items: any[]; + ordered: boolean; +} + +type Output = (content: any, state: State) => string; + +export interface Rule { + match?: any; + react?: (node: Node, output: Output, state: State) => ReactNode; +} + +export type Rules = Partial<{ [key in ValidRules]: Rule }>; + +export interface Props { + styles?: { [key: string]: StyleProp | StyleProp | StyleProp }; + children?: string | string[]; + rules?: Rules; + whitelist?: string[]; + blacklist?: string[]; +} + +export default class RNSMDComponent extends Component {} \ No newline at end of file From d8f9d915ce9f4d52828d5bd0b38f155bebf7918a Mon Sep 17 00:00:00 2001 From: Mohamed Shaban Date: Mon, 9 Sep 2019 11:14:49 +0200 Subject: [PATCH 2/2] Use style object properties --- index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index ea49e21..d0d32ba 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,6 +4,7 @@ import { Component, ReactNode } from 'react'; import { ViewStyle, TextStyle, ImageStyle, StyleProp } from 'react-native'; +import styles from './styles'; export interface ReactNativeSimpleMarkdown { } export type ValidRules = @@ -48,7 +49,7 @@ export interface Rule { export type Rules = Partial<{ [key in ValidRules]: Rule }>; export interface Props { - styles?: { [key: string]: StyleProp | StyleProp | StyleProp }; + styles: { [key in keyof typeof styles]: StyleProp | StyleProp | StyleProp }; children?: string | string[]; rules?: Rules; whitelist?: string[];