Skip to content

Commit 4deb486

Browse files
perf: Segmented preview in MD format with operation buttons frozen in the upper right corner(#965)
1 parent e65e8b2 commit 4deb486

1 file changed

Lines changed: 50 additions & 6 deletions

File tree

ui/src/views/knowledge/component/ParagraphList.vue

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
v-for="(child, cIndex) in paragraph_list"
1313
:key="cIndex"
1414
shadow="never"
15-
class="card-never mb-16"
15+
class="paragraph-preview-card card-never mb-16"
16+
@mouseenter="cardEnter(cIndex)"
17+
@mouseleave="cardLeave()"
1618
>
17-
<div class="flex-between">
18-
<span>{{ child.title || '-' }}</span>
19-
<div>
19+
<div v-show="show === cIndex" class="mk-sticky">
20+
<el-card
21+
class="paragraph-box-operation mt-8 mr-8"
22+
shadow="always"
23+
style="--el-card-padding: 8px 12px; --el-card-border-radius: 8px"
24+
@click.stop
25+
>
2026
<!-- 编辑分段按钮 -->
2127
<el-button link @click="editHandle(child, cIndex)">
2228
<AppIcon iconName="app-edit"></AppIcon>
@@ -25,10 +31,20 @@
2531
<el-button link @click="deleteHandle(child, cIndex)">
2632
<AppIcon iconName="app-delete"></AppIcon>
2733
</el-button>
28-
</div>
34+
</el-card>
35+
</div>
36+
<div class="flex-between">
37+
<span>{{ child.title || '-' }}</span>
2938
</div>
3039
<div class="lighter mt-12">
3140
{{ child.content }}
41+
<MdPreview
42+
ref="editorRef"
43+
editorId="preview-only"
44+
:modelValue="child.content"
45+
class="maxkb-md"
46+
style="background: none"
47+
/>
3248
</div>
3349
<div class="lighter mt-12">
3450
<el-text type="info">
@@ -90,6 +106,15 @@ const paragraph_list = computed(() => {
90106
return localParagraphList.value
91107
})
92108
109+
const show = ref<number | null>(null)
110+
function cardEnter(cIndex: number) {
111+
show.value = cIndex
112+
}
113+
114+
function cardLeave() {
115+
show.value = null
116+
}
117+
93118
const next = () => {
94119
if (loading.value) return
95120
loading.value = true
@@ -154,4 +179,23 @@ const deleteHandle = (item: any, cIndex: number) => {
154179
.catch(() => {})
155180
}
156181
</script>
157-
<style lang="scss" scoped></style>
182+
<style lang="scss" scoped>
183+
.paragraph-preview-card {
184+
position: relative;
185+
.mk-sticky {
186+
height: 0;
187+
position: sticky;
188+
right: 0;
189+
top: 12px;
190+
overflow: inherit;
191+
z-index: 10;
192+
}
193+
.paragraph-box-operation {
194+
position: absolute;
195+
right: -10px;
196+
top: -20px;
197+
overflow: inherit;
198+
z-index: 10;
199+
}
200+
}
201+
</style>

0 commit comments

Comments
 (0)