Skip to content

Commit

Permalink
feat: add DesignMarkdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Jandiasnow authored and Carrotzpc committed Nov 2, 2023
1 parent 70c270d commit d604a37
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 24 deletions.
18 changes: 9 additions & 9 deletions packages/react-markdown-lowcode-materials/demo/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@
{
"id": "@tenx-ui/materials",
"meta": {
"url": "http://172.22.96.37/@tenx-ui/materials@1.5.11/build/lowcode/meta.js",
"url": "http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/meta.js",
"exportName": "TenxUiMaterialsMeta"
},
"urls": [
"http://172.22.96.37/@tenx-ui/materials@1.5.11/dist/TenxUiMaterials.js",
"http://172.22.96.37/@tenx-ui/materials@1.5.11/dist/TenxUiMaterials.css"
"http://172.22.96.37/@tenx-ui/materials@latest/dist/TenxUiMaterials.js",
"http://172.22.96.37/@tenx-ui/materials@latest/dist/TenxUiMaterials.css"
],
"library": "TenxUiMaterials",
"package": "@tenx-ui/materials",
"version": "1.5.11",
"version": "latest",
"editUrls": [
"http://172.22.96.37/@tenx-ui/materials@1.5.11/build/lowcode/view.css",
"http://172.22.96.37/@tenx-ui/materials@1.5.11/build/lowcode/view.js"
"http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/view.css",
"http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/view.js"
]
},
{
Expand All @@ -95,11 +95,11 @@
],
"components": [
{
"url": "http://172.22.96.37/@tenx-ui/materials@1.5.11/build/lowcode/meta.js",
"version": "1.5.11",
"url": "http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/meta.js",
"version": "latest",
"reference": {
"id": "@tenx-ui/materials",
"version": "1.5.11"
"version": "latest"
},
"exportName": "TenxUiMaterialsMeta"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ const MarkdownMeta: IPublicTypeComponentMetadata = {
label: '内容',
tip: 'children | 内容',
},
setter: ['TextAreaSetter'],
setter: {
componentName: 'TextAreaSetter',
},
},
{
name: 'className',
title: {
label: '类名',
tip: 'className | 类名',
},
setter: ['StringSetter'],
setter: {
componentName: 'StringSetter',
},
},
{
title: {
Expand Down
23 changes: 22 additions & 1 deletion packages/react-markdown-lowcode-materials/lowcode/view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
import React from 'react';
import Markdown from '../src';

// 不需要对设计态进行特殊处理的,直接导出即可
export default Markdown;
const DesignMarkdown = props => {
const { children, ...otherProps } = props;
return (
<div>
<Markdown
{...otherProps}
components={{
// 解决编辑态 a 链接跳转问题
a(props) {
const { href, ...rest } = props;
return <a {...rest} />;
},
...(otherProps.components || {}),
}}
>
{(children || '').toString()}
</Markdown>
</div>
);
};
export default DesignMarkdown;
1 change: 1 addition & 0 deletions packages/react-markdown-lowcode-materials/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@alilc/lowcode-types": "^1.2.1",
"@babel/runtime": "^7.0.0",
"react-markdown": "^9.0.0",
"rehype-highlight": "^7.0.0",
"remark-gfm": "^4.0.0"
},
"peerDependencies": {
Expand Down
10 changes: 7 additions & 3 deletions packages/react-markdown-lowcode-materials/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react';
import OriginalMarkdown, { Options } from 'react-markdown';
import rehypeHighlight from 'rehype-highlight';
import remarkGfm from 'remark-gfm';

const Markdown = (props: Options) => {
const { children, remarkPlugins, ...otherProps } = props;
const { children, rehypePlugins, remarkPlugins, ...otherProps } = props;
return (
<OriginalMarkdown {...otherProps} remarkPlugins={[remarkGfm, ...(remarkPlugins || [])]}>
<OriginalMarkdown
{...otherProps}
rehypePlugins={[rehypeHighlight, ...(rehypePlugins || [])]}
remarkPlugins={[remarkGfm, ...(remarkPlugins || [])]}
>
{(props.children || '').toString()}
</OriginalMarkdown>
);
Expand Down
18 changes: 9 additions & 9 deletions packages/shared/src/services/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@
{
"id": "@tenx-ui/materials",
"meta": {
"url": "http://172.22.96.37/@tenx-ui/materials@1.5.9/build/lowcode/meta.js",
"url": "http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/meta.js",
"exportName": "TenxUiMaterialsMeta"
},
"urls": [
"http://172.22.96.37/@tenx-ui/materials@1.5.9/dist/TenxUiMaterials.js",
"http://172.22.96.37/@tenx-ui/materials@1.5.9/dist/TenxUiMaterials.css"
"http://172.22.96.37/@tenx-ui/materials@latest/dist/TenxUiMaterials.js",
"http://172.22.96.37/@tenx-ui/materials@latest/dist/TenxUiMaterials.css"
],
"library": "TenxUiMaterials",
"package": "@tenx-ui/materials",
"version": "1.5.9",
"version": "latest",
"editUrls": [
"http://172.22.96.37/@tenx-ui/materials@1.5.9/build/lowcode/view.css",
"http://172.22.96.37/@tenx-ui/materials@1.5.9/build/lowcode/view.js"
"http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/view.css",
"http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/view.js"
]
},
{
Expand Down Expand Up @@ -102,11 +102,11 @@
],
"components": [
{
"url": "http://172.22.96.37/@tenx-ui/materials@1.5.9/build/lowcode/meta.js",
"version": "1.5.9",
"url": "http://172.22.96.37/@tenx-ui/materials@latest/build/lowcode/meta.js",
"version": "latest",
"reference": {
"id": "@tenx-ui/materials",
"version": "1.5.9"
"version": "latest"
},
"exportName": "TenxUiMaterialsMeta"
},
Expand Down
48 changes: 48 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d604a37

Please sign in to comment.