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

fix: ProBuilder Highlight OverFlow #158

Merged
merged 25 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8645b3f
:memo: docs: add codeemitter
rdmclin2 Feb 1, 2024
6b87197
:bug: fix: ProBuilder highlight code
rdmclin2 Feb 1, 2024
a909e44
:camera_flash: chore: update snapshot
rdmclin2 Feb 2, 2024
aa7d963
:bug: fix: remove highlight wrapper
rdmclin2 Feb 8, 2024
7125595
:sparkles: feat: add Markdown code render
rdmclin2 Feb 8, 2024
d373ffe
:memo: docs: remove interaction container
rdmclin2 Feb 8, 2024
16ae5e5
:sparkles: feat: add Highlight shiki
rdmclin2 Feb 8, 2024
803c8e2
:camera_flash: chore: update snapshot
rdmclin2 Feb 8, 2024
14599ce
:recycle: refactor: remove interfaction container export and optimize…
rdmclin2 Feb 9, 2024
6c89538
:bug: fix: snippet style
rdmclin2 Feb 9, 2024
a0ebeed
:recycle: refactor: 重构 ActionGroup 文档
rdmclin2 Feb 9, 2024
5c95a50
:memo: docs: 整理文档
rdmclin2 Feb 10, 2024
5686ab3
:memo: docs: update docs
rdmclin2 Feb 11, 2024
8bce246
:bug: fix: ProBuilder Code Highlight
rdmclin2 Feb 11, 2024
80a20b7
:bug: fix: code panel scroll
rdmclin2 Feb 11, 2024
d23bbaa
:memo: docs: proeditor docs
rdmclin2 Feb 11, 2024
c54c93b
:bug: fix: markdown scroll
rdmclin2 Feb 12, 2024
bbf6061
:white_check_mark: test: update snapshot && tests
rdmclin2 Feb 12, 2024
db78bce
:memo: docs: cn to en translate
rdmclin2 Feb 12, 2024
bd726f7
:memo: docs: cn demos
rdmclin2 Feb 12, 2024
67ce7b1
:memo: docs: demo doc to en
rdmclin2 Feb 12, 2024
c5811ad
:memo: docs: component docs to en
rdmclin2 Feb 12, 2024
2052185
:memo: docs: component en docs
rdmclin2 Feb 12, 2024
6f93c18
:memo: docs: columnlist and sortablelist demos
rdmclin2 Feb 12, 2024
5c290bd
:camera_flash: test: update snapshot
rdmclin2 Feb 19, 2024
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
1 change: 1 addition & 0 deletions .i18nrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* find src -type f -name "*.en-US.md" -exec rm -f {} +
* @type {import("@lobehub/i18n-cli").Config}
*/
module.exports = {
Expand Down
12 changes: 6 additions & 6 deletions docs/guide/demos/ColumnList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ type SchemaItem = {
};

const INIT_VALUES = [
{ title: '序号', valueType: 'indexBorder', dataIndex: 'index' },
{ title: 'Index', valueType: 'indexBorder', dataIndex: 'index' },
{
title: '授权企业名称',
title: 'Enterprise',
valueType: 'text',
dataIndex: 'name',
},
{ title: '被授权企业', valueType: 'text', dataIndex: 'authCompany' },
{ title: 'Company', valueType: 'text', dataIndex: 'authCompany' },
];

const columns: ColumnItemList<SchemaItem> = [
{
title: '列标题',
title: 'Title',
dataIndex: 'title',
type: 'input',
},
{
title: '值类型',
title: 'ValueType',
dataIndex: 'valueType',
type: 'select',
options: tableColumnValueOptions,
},
{
title: '字段',
title: 'DataIndex',
dataIndex: 'dataIndex',
type: 'select',
},
Expand Down
27 changes: 27 additions & 0 deletions docs/pro-editor/demos/buttonAsset/codeEmitter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { generateJSXCode } from '@ant-design/pro-editor';
import template from 'lodash.template';
import { prettier } from './format';

const codeTemplate = `
import { Button } from 'antd';

export default () => <%= component %>;
`;

interface TemplateParams {
iconDeps?: string;
component: string;
}

const emitter: (params: TemplateParams) => string = template(codeTemplate);

const codeEmitter = (config) => {
const code = emitter({
component: generateJSXCode('Button', {
...config,
}),
});
return prettier(code);
};

export default codeEmitter;
28 changes: 28 additions & 0 deletions docs/pro-editor/demos/buttonAsset/format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 代码格式化
* @param configCode
* @returns
*/
export const prettier = (configCode: string) => {
let prettierCode = '';
try {
const prettier = require('prettier');
const plugins = [require('prettier/parser-typescript')];

prettierCode = prettier.format(configCode, {
parser: 'typescript',
plugins,
// 以下参考 Bigfish 配置
semi: true,
singleQuote: true,
printWidth: 100,
trailingComma: 'all',
proseWrap: 'never',
endOfLine: 'lf',
});
} catch (err) {
console.error('err', err);
prettierCode = `代码格式化失败,格式化前为:\n ${configCode}`;
}
return prettierCode;
};
8 changes: 3 additions & 5 deletions docs/pro-editor/demos/buttonAsset/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { ComponentAssetParams } from '@ant-design/pro-editor';

import { ButtonComponent } from './_Component';
import { ButtonPanel } from './_Panel';

import { createStore } from './store';

import codeEmitter from './codeEmitter';
import { ButtonConfig, buttonModel } from './models';
import { createStore } from './store';

export const buttonAssetParams: ComponentAssetParams<ButtonConfig> = {
id: 'Button',
Expand All @@ -27,5 +25,5 @@ export const buttonAssetParams: ComponentAssetParams<ButtonConfig> = {
devtools: { name: 'ButtonAssetStore' },
},

codeEmitter: () => '',
codeEmitter,
};
6 changes: 1 addition & 5 deletions docs/pro-editor/demos/buttonAssets.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/**
* iframe: 600
*/
import { ComponentAsset, ProBuilder } from '@ant-design/pro-editor';

import { buttonAssetParams } from './buttonAsset';

const ButtonComponentAsset = new ComponentAsset(buttonAssetParams);

export default () => (
<ProBuilder
componentAsset={ButtonComponentAsset}
style={{ height: '100vh' }}
style={{ height: 600 }}
__EDITOR_STORE_DEVTOOLS__={{ name: 'ButtonEditor' }}
/>
);
3 changes: 0 additions & 3 deletions docs/pro-editor/demos/controlledPresence.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* iframe: 800
*/
import { demoAssets } from '@/ComponentAsset/demoAssets';
import { AwarenessEditor, ComponentAsset, ProBuilder } from '@/index';
import { Highlight } from '@ant-design/pro-editor';
Expand Down
6 changes: 1 addition & 5 deletions docs/pro-editor/demos/defaultAssets.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* iframe: 600
*/
import { demoAssets } from '@/ComponentAsset/demoAssets';
import { ComponentAsset, ProBuilder } from '@ant-design/pro-editor';

Expand All @@ -14,10 +11,9 @@ export default () => (
},
})
}
style={{ height: '100vh' }}
style={{ height: 600 }}
onCopy={(children) => {
console.log('代码复制', children);
}}
themeMode={'dark'}
/>
);
5 changes: 1 addition & 4 deletions docs/pro-editor/demos/empty.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* iframe: 300
*/
import { ProBuilder } from '@ant-design/pro-editor';

export default () => <ProBuilder style={{ height: '100vh' }} />;
export default () => <ProBuilder style={{ height: 300 }} />;
24 changes: 8 additions & 16 deletions docs/pro-editor/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,20 @@ nav:
order: 3
---

# ProBuilder 装配器容器
# ProBuilder 装配器

使用 ProBuilder 可以快速构建出组件的配置界面。
使用 `ProBuilder` 可以快速构建出组件的配置界面。

## 以 Button 示例
## 代码演示

<code src='./demos/buttonAssets.tsx' ></code>
<code src='./demos/buttonAssets.tsx' compact="true" title="Button 示例"></code>

## 传入 ComponentAssets
<code src='./demos/defaultAssets.tsx' title="传入 `ComponentAssets`"></code>

<code src='./demos/defaultAssets.tsx' ></code>
<code src='./demos/empty.tsx' title="无 `ComponentAssets`"></code>

## 无 ComponentAssets
<code src="./demos/controlledPresence.tsx" title="视图状态受控" description="将 `editorAwareness` 设为受控状态,可以控制当前的视窗状态。"></code>

<code src='./demos/empty.tsx' ></code>

## 视图状态受控

将 `editorAwareness` 设为受控状态,可以控制当前的视窗状态。

<code src="./demos/controlledPresence.tsx" ></code>

# API
## API

<API id="ProEditor"></API>
84 changes: 84 additions & 0 deletions src/ActionGroup/demos/_items.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import {
CopyOutlined,
DeleteOutlined,
DragOutlined,
FullscreenOutlined,
RedoOutlined,
UndoOutlined,
ZoomInOutlined,
ZoomOutOutlined,
} from '@ant-design/icons';
import { ActionIconGroupItemType } from '@ant-design/pro-editor';
import { message } from 'antd';

const defaultItems = [
{ icon: <FullscreenOutlined />, title: '全屏' },
{ icon: <UndoOutlined />, title: '撤销' },
{ icon: <RedoOutlined />, title: '重做' },
{ icon: <DeleteOutlined />, title: '删除' },
];

const customItems: ActionIconGroupItemType[] = [
{
icon: <CopyOutlined />,
placement: 'bottom',
title: '复制',
},
{
icon: <ZoomInOutlined />,
title: '放大!',
},
{
icon: <ZoomOutOutlined />,
style: {
color: '#1890ff',
},
title: '缩小!',
},
{
type: 'divider',
},
{
icon: <DragOutlined />,
title: '快速定位',
},
];

const dropdownMenuItems: ActionIconGroupItemType[] = [
{
icon: <CopyOutlined />,
onClick: () => {
message.info('复制!');
},
label: '复制',
},
{
icon: <ZoomInOutlined />,
onClick: () => {
message.success('放大!');
},
label: '放大!',
},
{
icon: <ZoomOutOutlined />,
style: {
color: '#1890ff',
},
onClick: () => {
message.success('缩小!');
},
label: '缩小!',
},
{
type: 'divider',
},
{
icon: <DragOutlined />,
onClick: () => {
message.loading('快速定位ing');
},
label: '快速定位',
},
];

export { customItems, defaultItems, dropdownMenuItems };
3 changes: 2 additions & 1 deletion src/ActionGroup/demos/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ActionGroup } from '@ant-design/pro-editor';
import { defaultItems } from './_items';

export default () => {
return <ActionGroup />;
return <ActionGroup items={defaultItems} />;
};
50 changes: 2 additions & 48 deletions src/ActionGroup/demos/config.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,6 @@
import { CopyOutlined, DragOutlined, ZoomInOutlined, ZoomOutOutlined } from '@ant-design/icons';
import { ActionGroup } from '@ant-design/pro-editor';
import { message } from 'antd';
import { customItems } from './_items';

export default () => {
const [messageApi, contextHolder] = message.useMessage();

return (
<>
{contextHolder}
<ActionGroup
items={[
{
icon: <CopyOutlined />,
placement: 'bottom',
onClick: () => {
messageApi.info('复制!');
},
label: '复制',
},
{
icon: <ZoomInOutlined />,
onClick: () => {
messageApi.success('放大!');
},
label: '放大!',
},
{
icon: <ZoomOutOutlined />,
style: {
color: '#1890ff',
},
onClick: () => {
messageApi.success('缩小!');
},
label: '缩小!',
},
{
type: 'divider',
},
{
icon: <DragOutlined />,
onClick: () => {
messageApi.loading('快速定位ing');
},
label: '快速定位',
},
]}
/>
</>
);
return <ActionGroup items={customItems} />;
};
8 changes: 4 additions & 4 deletions src/ActionGroup/demos/custom.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ActionGroup, ActionIcon, ActionIconGroupItemType } from '@ant-design/pro-editor';
import { ActionGroup, ActionIcon } from '@ant-design/pro-editor';
import { Card, Input, Rate, Switch } from 'antd';
import { defaultItems } from './_items';

export default () => {
return (
<ActionGroup
render={(config) => {
render={() => {
return (
<Card
title="操作工具箱"
Expand All @@ -19,11 +20,10 @@ export default () => {
flexDirection: 'row',
}}
>
{config.map((item: ActionIconGroupItemType, index) => {
{defaultItems.map((item, index) => {
return (
<ActionIcon
key={`action-btn-${index}`}
title={item?.label}
onClick={() => {
alert('触发动作');
}}
Expand Down
Loading
Loading