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

Json viewer #2561

Open
wants to merge 17 commits into
base: release
Choose a base branch
from
Open

Conversation

anjiazhuyouxing
Copy link

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Fixes #

Changelog

🇨🇳 Chinese

  • Feat: 新增json-viewer组件

🇺🇸 English

  • Feat: add json-viewer component

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

```jsx import
import { JsonViewer } from '@douyinfe/semi-ui';
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后续加一个 【使用场景】
描述一下与直接使用 Monaco的区别
什么场景建议使用 Mocaco
什么场景建议使用 JsonViewer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以及 我们底层依赖什么包来做什么事情,例如使用 jsonc-parser来干什么,而在什么地方做了额外的改动处理。(2-3句话简短解释就行)

@@ -242,5 +243,6 @@
"stylelint"
]
},
"license": "MIT"
"license": "MIT",
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个pacakgeMannger 这行不要带上去

});
});

this._view.contentDom.addEventListener('beforeinput', (e: InputEvent) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要有对应的事件销毁吧

@@ -0,0 +1,10 @@


import BaseFoundation from '../base/foundation';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.ts 可以直接跟 foudation 合成一个文件。就叫 foundation就行。

}

render() {
return <div style={this.getStyle()} ref={this.editorRef}></div>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最外层元素统一暴露 className、style 的 api,对齐其他组件。

一些 method可以通过 ref 暴露出来。例如主动格式化、折叠什么的。

content/show/jsonviewer/index.md Show resolved Hide resolved
| 属性 | 说明 | 类型 | 默认值 |
|-------------------|------------------------------------------------|---------------------------------|-----------|
| lineHeight | 设置行高 属性 | number | 20 |
| autoHeight | 设置是否自动换行 属性 | boolean | true |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoHeight 作为是否自动换行的 api 名字是不是有点抽象?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get,改成autoWrap了

| width | 设置宽度 属性 | number | - |
| options | 设置格式化配置 属性 | JsonViewerOptions | - |
| onChange | 设置 value 变化回调 属性 | (value: string) => void | - |
| onValueHover | 设置 value 悬浮回调 属性 | ({value: string, target: HTMLElement}) => HTMLElement | - |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是你 storybook 里写的 hoverHandler 吗?

e.preventDefault();
let insertText = '';

if (this._view.options?.formatOptions?.insertSpaces) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥要在 this._view.options?.formatOptions?.insertSpaces 为 true 的时候才能让 Tab 自定义缩进生效?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外我试了一下,给 formatOptions { tabSize: 8 } 的默认值以后,insertSpaces 的值也不是 true 而是 undefined

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabSize表示缩进的距离,insertSpaces为true表示用空格表示缩进,比如4个空格,为fasle表示用制表符缩进,不过我发现逻辑存在问题,我后续修一下

"lib/*"
],
"dependencies": {
"esbuild": "0.24.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esbuild挪到 devDepenencies里去吧,用这个的用户不需要装 esbuild

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bf4630c:

Sandbox Source
pr-story Configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants