diff --git a/packages/client/src/schemas/add-new/index.tsx b/packages/client/src/schemas/add-new/index.tsx
index 9416ee1d3..2648f8d90 100644
--- a/packages/client/src/schemas/add-new/index.tsx
+++ b/packages/client/src/schemas/add-new/index.tsx
@@ -103,16 +103,13 @@ const isGridBlock = (schema: Schema) => {
function generateCardItemSchema(component) {
const defaults = {
- Markdown: {
- type: 'string',
- default: '这是一段演示文字',
- 'x-designable-bar': 'Markdown.DesignableBar',
+ 'Markdown.Void': {
+ type: 'void',
+ default: '这是一段演示文字,**支持使用 Markdown 语法**',
+ 'x-designable-bar': 'Markdown.Void.DesignableBar',
'x-decorator': 'CardItem',
'x-read-pretty': true,
- 'x-component': 'Markdown',
- 'x-component-props': {
- savedInSchema: true,
- },
+ 'x-component': 'Markdown.Void',
},
Table: {
type: 'array',
@@ -487,7 +484,7 @@ AddNew.CardItem = observer((props: any) => {
info.key === 'addNewTable' ? 'Table' : 'Form',
);
resourceName = values.name;
- } else if (info.key !== 'Markdown') {
+ } else if (info.key !== 'Markdown.Void') {
const keys = info.key.split('.');
const component = keys.shift();
const tableName = keys.join('.');
@@ -542,7 +539,7 @@ AddNew.CardItem = observer((props: any) => {
新建数据表
- 新建文本段
+ 新建文本段
模板1
@@ -595,7 +592,7 @@ AddNew.BlockItem = observer((props: any) => {
title: uid(),
'x-designable-bar': 'BlockItem.DesignableBar',
'x-decorator': 'CardItem',
- 'x-component': 'Markdown',
+ 'x-component': 'Markdown.Void',
};
if (schema['key']) {
data['key'] = uid();
@@ -788,15 +785,12 @@ AddNew.FormItem = observer((props: any) => {
onClick={async () => {
let data: ISchema = {
key: uid(),
- type: 'string',
+ type: 'void',
default: '这是一段演示文字,**支持使用 Markdown 语法**',
- 'x-designable-bar': 'Markdown.FormItemDesignableBar',
+ 'x-designable-bar': 'Markdown.Void.DesignableBar',
'x-decorator': 'FormItem',
'x-read-pretty': true,
- 'x-component': 'Markdown',
- 'x-component-props': {
- savedInSchema: true,
- },
+ 'x-component': 'Markdown.Void',
};
if (isGridBlock(schema)) {
path.pop();
diff --git a/packages/client/src/schemas/index.tsx b/packages/client/src/schemas/index.tsx
index b5c127750..53e73a2c5 100644
--- a/packages/client/src/schemas/index.tsx
+++ b/packages/client/src/schemas/index.tsx
@@ -10,12 +10,13 @@ import { useCookieState, useRequest } from 'ahooks';
export * from '../components/schema-renderer';
-export function mapReadPretty(component, readPrettyProps) {
+export function mapReadPretty(component: any, readPrettyProps?: any) {
return function (target) {
return observer(
(props) => {
const field = useField();
- if (!isVoidField(field) && field?.pattern === 'readPretty') {
+ // if (!isVoidField(field) && field?.pattern === 'readPretty') {
+ if (field?.pattern === 'readPretty') {
return React.createElement(component, {
...readPrettyProps,
...props,
diff --git a/packages/client/src/schemas/markdown/index.tsx b/packages/client/src/schemas/markdown/index.tsx
index 98d4d887f..bb1ff4268 100644
--- a/packages/client/src/schemas/markdown/index.tsx
+++ b/packages/client/src/schemas/markdown/index.tsx
@@ -2,10 +2,10 @@ import React from 'react';
import {
connect,
mapProps,
- mapReadPretty,
observer,
useField,
useFieldSchema,
+ mapReadPretty,
} from '@formily/react';
import { Button, Dropdown, Input as AntdInput, Menu, Space } from 'antd';
import { InputProps, TextAreaProps } from 'antd/lib/input';
@@ -23,33 +23,7 @@ import { isGridRowOrCol } from '../grid';
import './style.less';
export const Markdown: any = connect(
- (props) => {
- const { schema } = useDesignable();
- const field = useField();
- const { savedInSchema, ...others } = props;
- console.log('Markdown', props);
- return savedInSchema ? (
-
-
-
-
- ) : (
-
- );
- },
+ AntdInput.TextArea,
mapProps((props: any, field) => {
return {
...props,
@@ -65,16 +39,71 @@ export const Markdown: any = connect(
};
}),
mapReadPretty((props) => {
- console.log('Markdown', props);
let text = props.value;
let value = (
-
+
);
return ;
}),
);
-Markdown.DesignableBar = observer((props) => {
+function MarkdownTextArea(props: any) {
+ const [value, setValue] = useState(props.defaultValue);
+ return (
+
+
{
+ setValue(e.target.value);
+ }}
+ />
+
+
+ );
+}
+
+Markdown.Void = observer((props: any) => {
+ const { schema } = useDesignable();
+ const field = useField();
+ const text = schema['default'];
+ let value = (
+
+ );
+ return field?.pattern !== 'readPretty' ? (
+ {
+ field.readPretty = true;
+ schema['default'] = value;
+ await updateSchema({
+ key: schema['key'],
+ default: value,
+ });
+ }}
+ />
+ ) : (
+
+ );
+});
+
+Markdown.Void.DesignableBar = observer((props) => {
const field = useField();
const { designable, schema, refresh, deepRemove } = useDesignable();
const [visible, setVisible] = useState(false);
@@ -135,7 +164,7 @@ Markdown.DesignableBar = observer((props) => {
);
});
-Markdown.FormItemDesignableBar = observer((props) => {
+Markdown.DesignableBar = observer((props) => {
const field = useField();
const { designable, schema, refresh, deepRemove } = useDesignable();
const [visible, setVisible] = useState(false);
@@ -162,13 +191,8 @@ Markdown.FormItemDesignableBar = observer((props) => {
}}
overlay={
}