Skip to content

Commit

Permalink
fix(generator): copy fieldKey is not effective (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengshang918 committed Mar 17, 2022
1 parent dca0687 commit 857fe65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@monaco-editor/react": "^4.2.2",
"antd": "^4.16.13",
"classnames": "^2.3.1",
"copy-to-clipboard": "^3.3.1",
"file-saver": "^2.0.5",
"immer": "^9.0.6",
"nanoid": "^3.1.23",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { Select, Input, Button } from 'antd'
import { CopyOutlined } from '@ant-design/icons'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { usePrevious } from '@jdfed/hooks'
import copy from 'copy-to-clipboard'

import type { SetType } from '@jdfed/hooks'
import type { Map, UnitedSchema } from '@jdfed/utils'

Expand Down Expand Up @@ -410,6 +412,11 @@ const PropertyConfig = () => {
[prevEditFieldKey, setCurEditFieldKey]
)

// copy fieldKey
const copyFieldKeyFn = useCallback(() => {
copy(curEditFieldKey)
}, [curEditFieldKey])

return (
<Fragment>
<div className={styles.panelConfig}>
Expand Down Expand Up @@ -447,7 +454,7 @@ const PropertyConfig = () => {
// 父元素为数组容器无法修改
disabled={parentType === 'array'}
/>
<Button icon={<CopyOutlined />} />
<Button icon={<CopyOutlined />} onClick={copyFieldKeyFn} />
</Input.Group>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6401,7 +6401,7 @@ copy-text-to-clipboard@^3.0.1:
resolved "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz#8cbf8f90e0a47f12e4a24743736265d157bce69c"
integrity sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q==

copy-to-clipboard@^3.2.0:
copy-to-clipboard@^3.2.0, copy-to-clipboard@^3.3.1:
version "3.3.1"
resolved "https://registry.npmjs.org/copy-to-clipboard/-/copy-to-clipboard-3.3.1.tgz#115aa1a9998ffab6196f93076ad6da3b913662ae"
integrity sha512-i13qo6kIHTTpCm8/Wup+0b1mVWETvu2kIMzKoK8FpkLkFxlt0znUAHcMzox+T8sPlqtZXq3CulEjQHsYiGFJUw==
Expand Down

0 comments on commit 857fe65

Please sign in to comment.