-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ProBuilder Highlight OverFlow (#158)
fix: 修复 Highlight 组件变更导致的滚动问题。 feat: Highlight 支持关闭 shiki 模式,默认开启。 refactor: 去掉 Highlight wrapper 模式,直接集成到 Markdown 组件中。 refactor: ActionGroup 去掉默认的按钮集成,没有多大意义。 docs: 统一所有文档格式,重新生成英文文档。
- Loading branch information
Showing
123 changed files
with
6,460 additions
and
5,192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.