sort/components/html/block.tsx

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-09-07 01:22:11 +00:00
import React, { useEffect, useState } from 'react';
import { ScrollView, TouchableOpacity, Alert, Text, GestureResponderEvent, View, Dimensions } from 'react-native';
import RenderHtml, { TChildrenRenderer } from 'react-native-render-html';
import { Cfg } from './action';
import Html from '../HtmlRender';
export function BlockRenderer({
...props
}: {
[key: string]: any;
}) {
const [htm, setHtm] = useState('');
const { tnode } = props;
const { domNode } = tnode;
const { attribs } = domNode;
Cfg.setGlobalState(attribs?.name, '')
const onPress = () => {
const config = Cfg.action as { [key: string]: (event: Function) => void };
const custAction: ((event: Function) => void) | null =
(attribs?.action && typeof config[attribs?.action] === 'function')
? config[attribs?.action]
: null;
if (custAction) {
attribs.pop = custAction;
custAction(attribs);
}
}
Cfg.setGlobalState(attribs?.name, setHtm);
const windowHeight = Dimensions.get('window').height;
const scrollViewHeight = windowHeight - (attribs.min ? attribs.min : 380); // Subtracting 90 from the total height
return (
<View style={{ ...props?.style }}>
<Html html={htm} />
</View>
);
}