import React from 'react'; import { connect, mapProps, mapReadPretty, observer, useField, useFieldSchema, } from '@formily/react'; import { Button, Dropdown, Input as AntdInput, Menu, Space } from 'antd'; import { InputProps, TextAreaProps } from 'antd/lib/input'; import { Display } from '../display'; import { LoadingOutlined, MenuOutlined, DragOutlined } from '@ant-design/icons'; import micromark from 'micromark'; import { useDesignable } from '../../components/schema-renderer'; import { useContext, useState } from 'react'; import AddNew from '../add-new'; import cls from 'classnames'; import { DraggableBlockContext } from '../../components/drag-and-drop'; import { uid } from '@formily/shared'; import { removeSchema, updateSchema } from '..'; import { isGridRowOrCol } from '../grid'; export const Markdown: any = connect( (props) => { const { schema } = useDesignable(); const field = useField(); const { savedInSchema, ...others } = props; console.log('Markdown', props); return savedInSchema ? (
) : ( ); }, mapProps((props: any, field) => { return { ...props, suffix: ( {field?.['loading'] || field?.['validating'] ? ( ) : ( props.suffix )} ), }; }), mapReadPretty((props) => { console.log('Markdown', props); let text = props.value; let value = (
); return ; }), ); Markdown.DesignableBar = observer((props) => { const field = useField(); const { schema, refresh, deepRemove } = useDesignable(); const [visible, setVisible] = useState(false); const { dragRef } = useContext(DraggableBlockContext); return (
{ e.stopPropagation(); }} className={cls('designable-bar-actions', { active: visible })} > {dragRef && } { setVisible(visible); }} overlay={ { field.readPretty = false; }} > 修改 Markdown { const removed = deepRemove(); // console.log({ removed }) const last = removed.pop(); if (isGridRowOrCol(last)) { await removeSchema(last); } }} > 删除当前区块 } >
); }); export default Markdown;