wupengfei
2025-03-10 6887129e91d32557c2b57178180329f46df09d12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
  <div class="rich-text-wrapper">
    <rich-text :nodes="_content" style="word-wrap: break-word"></rich-text>
  </div>
</template>
 
<script setup lang="ts">
defineOptions({
  name: 'RichEditorContent',
});
 
type Props = {
  content: string;
};
 
const _content = computed(() =>
  props.content.replace(/<img[^>]*>/g, (match) => {
    let str = match.replace(`width=""`, '').replace(`height=""`, '').replace(`style=""`, '');
 
    if (/style="/.test(str)) {
      str = str.replace('style="', 'style="max-width: 100%; ');
    } else {
      str = str.replace('<img', '<img style="max-width: 100%;" ');
    }
 
    return str;
  })
);
 
const props = withDefaults(defineProps<Props>(), {});
</script>
 
<!-- <style>
@import './style.css';
</style> -->
 
<style lang="scss">
@import '@/styles/common.scss';
 
.rich-text-wrapper {
  overflow-x: hidden;
  color: boleGetCssVar('text-color', 'primary');
  font-size: 28px;
 
  rich-text {
    overflow-x: hidden;
    word-wrap: break-word;
    white-space: normal;
  }
 
  /* .h5-img,
  img {
    max-width: 100%;
    min-height: 20px;
    min-width: 20px;
    display: inline !important;
  } */
}
</style>