Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add DesignMarkdown #2

Merged
merged 1 commit into from
Nov 2, 2023
Merged
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
18 changes: 9 additions & 9 deletions packages/react-markdown-lowcode-materials/demo/assets.json
Original file line number Diff line number Diff line change
@@ -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"
]
},
{
@@ -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"
},
Original file line number Diff line number Diff line change
@@ -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: {
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
@@ -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": {
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>
);
18 changes: 9 additions & 9 deletions packages/shared/src/services/assets.json
Original file line number Diff line number Diff line change
@@ -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"
]
},
{
@@ -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"
},
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.