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(code): add word-wrap prop #2129

Merged
merged 2 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

### Feats

- `n-code` support soft wrap, closes [#2111](https://github.com/TuSimple/naive-ui/issues/2111).
- `n-modal` adds `z-index` prop, closes [#2088](https://github.com/TuSimple/naive-ui/issues/2088).
- `n-drawer` adds `z-index` closes.
- `n-drawer` adds wai-aria support.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

### Feats

- `n-code` 支持软换行,关闭 [#2111](https://github.com/TuSimple/naive-ui/issues/2111)
- `n-modal` 新增 `z-index` 属性,关闭 [#2088](https://github.com/TuSimple/naive-ui/issues/2088)
- `n-drawer` 新增 `z-index` 属性
- `n-drawer` 新增 wai-aria 支持
Expand Down
1 change: 1 addition & 0 deletions src/code/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following code shows how to set hljs of Code. Importing highlight.js on dema
```demo
basic.vue
inline.vue
softwrap.vue
```

## API
Expand Down
23 changes: 23 additions & 0 deletions src/code/demos/enUS/softwrap.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<markdown>
# soft wrap
</markdown>

<template>
<div>
<n-code :code="code" language="html" />
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
setup () {
return {
code: `
<p class="n-p" data-v-79af885b="" style="--n-bezier:cubic-bezier(0.4, 0, 0.2, 1); --n-font-size:14px; --n-line-height:1.6; --n-text-color:rgb(51, 54, 57); font-size: 16px; margin-top: 0px; margin-bottom: 0px;">sometimes naive</p>
`
}
}
})
</script>
1 change: 1 addition & 0 deletions src/code/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
```demo
basic.vue
inline.vue
softwrap.vue
loop-debug.vue
```

Expand Down
23 changes: 23 additions & 0 deletions src/code/demos/zhCN/softwrap.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<markdown>
# 软换行
</markdown>
Copy link
Collaborator

Choose a reason for hiding this comment

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

加个描述

“code 可以在溢出时自动换行“

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok


<template>
<div>
<n-code :code="code" language="html" />
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
setup () {
return {
code: `
<p class="n-p" data-v-79af885b="" style="--n-bezier:cubic-bezier(0.4, 0, 0.2, 1); --n-font-size:14px; --n-line-height:1.6; --n-text-color:rgb(51, 54, 57); font-size: 16px; margin-top: 0px; margin-bottom: 0px;">还是得再学习一个</p>
`
Copy link
Collaborator

@07akioni 07akioni Jan 7, 2022

Choose a reason for hiding this comment

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

这代码感觉有点迷惑性啊,换一个更直观的?某种编程语言的

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}
}
})
</script>
1 change: 1 addition & 0 deletions src/code/src/styles/index.cssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default c([
c('pre', `
margin: 0;
font-family: inherit;
white-space: pre-wrap;
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个需要加一个新的属性,叫 word-wrap,默认关闭。

不换行才是默认的需求。

换行需要加属性。

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

`),
c('[class^=hljs]', `
color: var(--n-text-color);
Expand Down