Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

111 changes: 59 additions & 52 deletions Utils.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,71 @@
const Utils = {
isTextOnly(nodes) {
try {
if (nodes.length) {
for (let i = 0; i < nodes.length; i++) {
if (nodes[i] &&
typeof nodes[i].hasOwnProperty === 'function' &&
nodes[i].hasOwnProperty('type') &&
typeof nodes[i].type.hasOwnProperty === 'function' &&
(
nodes[i].type.hasOwnProperty('displayName') ||
nodes[i].type.hasOwnProperty('name')
)
) {
if (nodes[i].type.displayName !== 'Text' && nodes[i].type.name !== 'Text') {
return false;
}
} else {
return false;
}
}
isTextOnly (nodes) {
try {
if (nodes.length) {
for (let i = 0; i < nodes.length; i++) {
if (
nodes[i] &&
typeof nodes[i].hasOwnProperty === 'function' &&
Object.prototype.hasOwnProperty.call(nodes[i], 'type') &&
typeof nodes[i].type.hasOwnProperty === 'function' &&
(Object.prototype.hasOwnProperty.call(
nodes[i].type,
'displayName'
) ||
Object.prototype.hasOwnProperty.call(nodes[i].type, 'name'))
) {
if (
nodes[i].type.displayName !== 'Text' &&
nodes[i].type.name !== 'Text'
) {
return false
}
} catch(e) {
return false;
} else {
return false
}
}
}
} catch (e) {
return false
}

// It's a miracle, I guess we're text only
return true;
},
// It's a miracle, I guess we're text only
return true
},

concatStyles: function concatStyles(extras, newStyle) {
let newExtras;
if (extras) {
newExtras = JSON.parse(JSON.stringify(extras));
concatStyles: function concatStyles (extras, newStyle) {
let newExtras
if (extras) {
newExtras = JSON.parse(JSON.stringify(extras))

if (extras.style) {
newExtras.style.push(newStyle);
} else {
newExtras.style = [newStyle];
}
} else {
newExtras = {
style: [newStyle]
};
}
return newExtras;
},
if (extras.style) {
newExtras.style.push(newStyle)
} else {
newExtras.style = [newStyle]
}
} else {
newExtras = {
style: [newStyle]
}
}
return newExtras
},

logDebug: function logDebug(nodeTree, level = 0) {
for (let i = 0; i < nodeTree.length; i++) {
const node = nodeTree[i];
logDebug: function logDebug (nodeTree, level = 0) {
for (let i = 0; i < nodeTree.length; i++) {
const node = nodeTree[i]

if (node) {
let prefix = Array(level).join('-');
console.log(prefix + '> ' + node.key + ', NODE TYPE: ' + node.type.displayName);
if (Array.isArray(node.props.children)) {
this.logDebug(node.props.children, level + 1);
}
}
if (node) {
const prefix = Array(level).join('-')
console.log(
prefix + '> ' + node.key + ', NODE TYPE: ' + node.type.displayName
)
if (Array.isArray(node.props.children)) {
this.logDebug(node.props.children, level + 1)
}
}
}
}
}

module.exports = Utils;
module.exports = Utils
2 changes: 0 additions & 2 deletions entry.js

This file was deleted.

70 changes: 37 additions & 33 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
import React from "react";
import { StyleProp, TextStyle, ViewProps, ViewStyle } from "react-native";
import React from 'react'
import { StyleProp, TextStyle, ViewProps, ViewStyle } from 'react-native'

export interface IProps {
debug?: boolean;
parseInline?: boolean;
useDefaultStyles?: boolean;
renderImage?: (src: string, alt: string, title: string) => React.ReactNode;
renderLink?: (href: string, title: string, children: React.ReactNode) => React.ReactNode;
renderListBullet?: (ordered: boolean, index: number) => React.ReactNode;
markdownStyles?: {
block?: StyleProp<ViewStyle>;
blockQuote?: StyleProp<TextStyle>;
del?: StyleProp<TextStyle>;
em?: StyleProp<TextStyle>;
h1?: StyleProp<TextStyle>;
h2?: StyleProp<TextStyle>;
h3?: StyleProp<TextStyle>;
h4?: StyleProp<TextStyle>;
h5?: StyleProp<TextStyle>;
h6?: StyleProp<TextStyle>;
hr?: StyleProp<TextStyle>;
image?: StyleProp<TextStyle>;
imageWrapper?: StyleProp<ViewStyle>;
link?: StyleProp<TextStyle>;
linkWrapper?: StyleProp<TextStyle>;
list?: StyleProp<TextStyle>;
listItem?: StyleProp<TextStyle>;
listItemBullet?: StyleProp<TextStyle>;
listItemContent?: StyleProp<TextStyle>;
listItemNumber?: StyleProp<TextStyle>;
strong?: StyleProp<TextStyle>;
text?: StyleProp<TextStyle>;
u?: StyleProp<TextStyle>;
};
debug?: boolean
parseInline?: boolean
useDefaultStyles?: boolean
renderImage?: (src: string, alt: string, title: string) => React.ReactNode
renderLink?: (
href: string,
title: string,
children: React.ReactNode
) => React.ReactNode
renderListBullet?: (ordered: boolean, index: number) => React.ReactNode
markdownStyles?: {
block?: StyleProp<ViewStyle>
blockQuote?: StyleProp<TextStyle>
del?: StyleProp<TextStyle>
em?: StyleProp<TextStyle>
h1?: StyleProp<TextStyle>
h2?: StyleProp<TextStyle>
h3?: StyleProp<TextStyle>
h4?: StyleProp<TextStyle>
h5?: StyleProp<TextStyle>
h6?: StyleProp<TextStyle>
hr?: StyleProp<TextStyle>
image?: StyleProp<TextStyle>
imageWrapper?: StyleProp<ViewStyle>
link?: StyleProp<TextStyle>
linkWrapper?: StyleProp<TextStyle>
list?: StyleProp<TextStyle>
listItem?: StyleProp<TextStyle>
listItemBullet?: StyleProp<TextStyle>
listItemContent?: StyleProp<TextStyle>
listItemNumber?: StyleProp<TextStyle>
strong?: StyleProp<TextStyle>
text?: StyleProp<TextStyle>
u?: StyleProp<TextStyle>
}
}

export default class Markdown extends React.Component<IProps & ViewProps> {}
Loading