@alifd/chat 0.2.0-beta.0 → 0.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/HTMLRenderer/index.d.ts +4 -0
- package/es/HTMLRenderer/index.js +138 -0
- package/es/HTMLRenderer/index.less +194 -0
- package/es/HTMLRenderer/main.scss +233 -0
- package/es/HTMLRenderer/style.d.ts +1 -0
- package/es/HTMLRenderer/style.js +1 -0
- package/es/HTMLRenderer/types.d.ts +46 -0
- package/es/HTMLRenderer/types.js +1 -0
- package/es/ImagePreview/index.d.ts +13 -0
- package/es/ImagePreview/index.js +72 -0
- package/es/ImagePreview/main.scss +15 -0
- package/es/ImagePreview/style.d.ts +1 -0
- package/es/ImagePreview/style.js +1 -0
- package/es/ImagePreview/types.d.ts +31 -0
- package/es/ImagePreview/types.js +1 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +4 -1
- package/es/markdown/index.d.ts +6 -0
- package/es/markdown/index.js +138 -0
- package/es/markdown/main.scss +153 -0
- package/es/markdown/style.d.ts +3 -0
- package/es/markdown/style.js +3 -0
- package/es/markdown/types.d.ts +21 -0
- package/es/markdown/types.js +1 -0
- package/es/utils/func.d.ts +1 -0
- package/es/utils/func.js +9 -0
- package/lib/HTMLRenderer/index.d.ts +4 -0
- package/lib/HTMLRenderer/index.js +141 -0
- package/lib/HTMLRenderer/index.less +194 -0
- package/lib/HTMLRenderer/main.scss +233 -0
- package/lib/HTMLRenderer/style.d.ts +1 -0
- package/lib/HTMLRenderer/style.js +3 -0
- package/lib/HTMLRenderer/types.d.ts +46 -0
- package/lib/HTMLRenderer/types.js +2 -0
- package/lib/ImagePreview/index.d.ts +13 -0
- package/lib/ImagePreview/index.js +75 -0
- package/lib/ImagePreview/main.scss +15 -0
- package/lib/ImagePreview/style.d.ts +1 -0
- package/lib/ImagePreview/style.js +3 -0
- package/lib/ImagePreview/types.d.ts +31 -0
- package/lib/ImagePreview/types.js +2 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +8 -2
- package/lib/markdown/index.d.ts +6 -0
- package/lib/markdown/index.js +141 -0
- package/lib/markdown/main.scss +153 -0
- package/lib/markdown/style.d.ts +3 -0
- package/lib/markdown/style.js +5 -0
- package/lib/markdown/types.d.ts +21 -0
- package/lib/markdown/types.js +2 -0
- package/lib/utils/func.d.ts +1 -0
- package/lib/utils/func.js +10 -0
- package/package.json +49 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
@import '../../var.less';
|
|
2
|
+
|
|
3
|
+
.box {
|
|
4
|
+
font-size: 14px;
|
|
5
|
+
// color: hsla(230, 10%, 11%, 0.9);
|
|
6
|
+
word-break: break-word;
|
|
7
|
+
font-family: inherit;
|
|
8
|
+
.loose& {
|
|
9
|
+
font-size: 16px;
|
|
10
|
+
line-height: 1.85;
|
|
11
|
+
}
|
|
12
|
+
@media print {
|
|
13
|
+
color: #000 !important;
|
|
14
|
+
font-family: 'Times New Roman', Times, serif;
|
|
15
|
+
}
|
|
16
|
+
body:global(.dark) & {
|
|
17
|
+
filter: invert(1) hue-rotate(180deg);
|
|
18
|
+
}
|
|
19
|
+
img, video, iframe {
|
|
20
|
+
body:global(.dark) & {
|
|
21
|
+
filter: hue-rotate(180deg) invert(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
img {
|
|
25
|
+
body:global(.dark) & {
|
|
26
|
+
background: #fff;
|
|
27
|
+
}
|
|
28
|
+
body:global(.dark.dim) & {
|
|
29
|
+
filter: hue-rotate(180deg) brightness(.75) invert(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
body:global(.dark) & :global(.symbolic) > img {
|
|
33
|
+
filter: none;
|
|
34
|
+
background: none;
|
|
35
|
+
}
|
|
36
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, table, .syntax-highlighter {
|
|
37
|
+
margin: 0;
|
|
38
|
+
.loose& {
|
|
39
|
+
margin: 20px 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
h1, h2, h3, h4, h5, h6 {
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
}
|
|
45
|
+
h1 {
|
|
46
|
+
font-size: 18px;
|
|
47
|
+
line-height: 1.8;
|
|
48
|
+
.loose& {
|
|
49
|
+
font-size: 28px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
h2 {
|
|
53
|
+
font-size: 16px;
|
|
54
|
+
line-height: 1.8;
|
|
55
|
+
.loose& {
|
|
56
|
+
font-size: 24px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
h3, h4, h5, h6 {
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
line-height: 1.9;
|
|
62
|
+
}
|
|
63
|
+
h3 {
|
|
64
|
+
.loose& {
|
|
65
|
+
font-size: 18px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
h4, h5, h6 {
|
|
69
|
+
.loose& {
|
|
70
|
+
font-size: 16px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
img, video, .image {
|
|
74
|
+
max-width: 100%!important;
|
|
75
|
+
height: auto!important;
|
|
76
|
+
&:only-child {
|
|
77
|
+
display: block;
|
|
78
|
+
margin: 10px auto;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
.image:only-child {
|
|
82
|
+
width: fit-content;
|
|
83
|
+
}
|
|
84
|
+
.image img {
|
|
85
|
+
margin: 0;
|
|
86
|
+
}
|
|
87
|
+
code {
|
|
88
|
+
margin: 0 .15em;
|
|
89
|
+
padding: .12em .25em;
|
|
90
|
+
border-radius: 3px;
|
|
91
|
+
font-size: 86%;
|
|
92
|
+
background: rgba(27,31,35,.05);
|
|
93
|
+
}
|
|
94
|
+
pre {
|
|
95
|
+
font-size: 14px;
|
|
96
|
+
line-height: 1.6;
|
|
97
|
+
border-radius: 2px;
|
|
98
|
+
border: 6px solid transparent;
|
|
99
|
+
overflow: auto;
|
|
100
|
+
margin: 0;
|
|
101
|
+
code {
|
|
102
|
+
font-size: 14px;
|
|
103
|
+
padding: 0;
|
|
104
|
+
margin: 0;
|
|
105
|
+
border: none;
|
|
106
|
+
font-size: inherit;
|
|
107
|
+
background: none;
|
|
108
|
+
border-radius: 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
table, td, th {
|
|
112
|
+
border: 1px solid #caccce;
|
|
113
|
+
body:global(.dark) & {
|
|
114
|
+
border-color: #babcbd;
|
|
115
|
+
// border-color: #c9cace;
|
|
116
|
+
}
|
|
117
|
+
border-collapse: collapse;
|
|
118
|
+
border-spacing: 0;
|
|
119
|
+
}
|
|
120
|
+
table {
|
|
121
|
+
line-height: 1.6;
|
|
122
|
+
margin: 10px auto;
|
|
123
|
+
border-spacing: none;
|
|
124
|
+
border-collapse: collapse;
|
|
125
|
+
empty-cells: show;
|
|
126
|
+
font-size: 14px;
|
|
127
|
+
.loose& p {
|
|
128
|
+
margin: 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
td, th {
|
|
132
|
+
border: 1px solid #e3e3e3;
|
|
133
|
+
padding: 10px 12px;
|
|
134
|
+
line-height: 1.3;
|
|
135
|
+
p {
|
|
136
|
+
margin: 0;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
th {
|
|
140
|
+
background: hsla(230, 90%, 11%,.03);
|
|
141
|
+
}
|
|
142
|
+
a, a:visited {
|
|
143
|
+
color: #0080FF;
|
|
144
|
+
text-decoration: none;
|
|
145
|
+
&:hover {
|
|
146
|
+
text-decoration: underline;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
ul, ol {
|
|
150
|
+
list-style: revert;
|
|
151
|
+
padding-left: 16px;
|
|
152
|
+
.loose& {
|
|
153
|
+
padding-left: 30px;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
li {
|
|
157
|
+
list-style: revert;
|
|
158
|
+
}
|
|
159
|
+
blockquote {
|
|
160
|
+
opacity: 1;
|
|
161
|
+
border: none;
|
|
162
|
+
padding: 0;
|
|
163
|
+
margin-left: 20px;
|
|
164
|
+
opacity: 0.6;
|
|
165
|
+
font-style: italic;
|
|
166
|
+
position: relative;
|
|
167
|
+
margin-top: 6px;
|
|
168
|
+
margin-bottom: 6px;
|
|
169
|
+
.loose& {
|
|
170
|
+
margin-top: 20px;
|
|
171
|
+
margin-bottom: 20px;
|
|
172
|
+
}
|
|
173
|
+
&::before {
|
|
174
|
+
content: '|';
|
|
175
|
+
font-size: 0;
|
|
176
|
+
color: transparent;
|
|
177
|
+
display: inline-block;
|
|
178
|
+
width: 4px;
|
|
179
|
+
border-radius: 1px;
|
|
180
|
+
position: absolute;
|
|
181
|
+
margin-left: -16px;
|
|
182
|
+
top: 0;
|
|
183
|
+
bottom: 0;
|
|
184
|
+
background: hsla(230, 90%, 11%,.2);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
hr {
|
|
188
|
+
height: 0;
|
|
189
|
+
border: none;
|
|
190
|
+
height: 1px;
|
|
191
|
+
background: hsla(230, 90%, 11%,.1);
|
|
192
|
+
margin: 10px 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
.box {
|
|
2
|
+
font-size: 14px;
|
|
3
|
+
// color: hsla(230, 10%, 11%, 0.9);
|
|
4
|
+
word-break: break-word;
|
|
5
|
+
font-family: inherit;
|
|
6
|
+
|
|
7
|
+
&.loose {
|
|
8
|
+
font-size: 16px;
|
|
9
|
+
line-height: 1.85;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@media print {
|
|
13
|
+
color: #000 !important;
|
|
14
|
+
font-family: 'Times New Roman', Times, serif;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
body.global-dark & {
|
|
18
|
+
filter: invert(1) hue-rotate(180deg);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
img, video, iframe {
|
|
22
|
+
body.global-dark & {
|
|
23
|
+
filter: hue-rotate(180deg) invert(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
img {
|
|
28
|
+
body.global-dark & {
|
|
29
|
+
background: #fff;
|
|
30
|
+
}
|
|
31
|
+
body.global-dark-dim & {
|
|
32
|
+
filter: hue-rotate(180deg) brightness(.75) invert(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body.global-dark & .symbolic > img {
|
|
37
|
+
filter: none;
|
|
38
|
+
background: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, table, .syntax-highlighter {
|
|
42
|
+
margin: 0;
|
|
43
|
+
|
|
44
|
+
&.loose {
|
|
45
|
+
margin: 20px 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
h1, h2, h3, h4, h5, h6 {
|
|
50
|
+
font-weight: bold;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
h1 {
|
|
54
|
+
font-size: 18px;
|
|
55
|
+
line-height: 1.8;
|
|
56
|
+
|
|
57
|
+
&.loose {
|
|
58
|
+
font-size: 28px;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
h2 {
|
|
63
|
+
font-size: 16px;
|
|
64
|
+
line-height: 1.8;
|
|
65
|
+
|
|
66
|
+
&.loose {
|
|
67
|
+
font-size: 24px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
h3, h4, h5, h6 {
|
|
72
|
+
font-size: 14px;
|
|
73
|
+
line-height: 1.9;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
h3 {
|
|
77
|
+
&.loose {
|
|
78
|
+
font-size: 18px;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
h4, h5, h6 {
|
|
83
|
+
&.loose {
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
img, video, .image {
|
|
89
|
+
max-width: 100% !important;
|
|
90
|
+
height: auto !important;
|
|
91
|
+
|
|
92
|
+
&:only-child {
|
|
93
|
+
display: block;
|
|
94
|
+
margin: 10px auto;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.image:only-child {
|
|
99
|
+
width: fit-content;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.image img {
|
|
103
|
+
margin: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
code {
|
|
107
|
+
margin: 0 .15em;
|
|
108
|
+
padding: .12em .25em;
|
|
109
|
+
border-radius: 3px;
|
|
110
|
+
font-size: 86%;
|
|
111
|
+
background: rgba(27, 31, 35, .05);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
pre {
|
|
115
|
+
font-size: 14px;
|
|
116
|
+
line-height: 1.6;
|
|
117
|
+
border-radius: 4px;
|
|
118
|
+
border: 6px solid transparent;
|
|
119
|
+
overflow: auto;
|
|
120
|
+
margin: 0 0 8px 0;
|
|
121
|
+
|
|
122
|
+
code {
|
|
123
|
+
font-size: 14px;
|
|
124
|
+
padding: 0;
|
|
125
|
+
margin: 0;
|
|
126
|
+
border: none;
|
|
127
|
+
font-size: inherit;
|
|
128
|
+
background: none;
|
|
129
|
+
border-radius: 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
table, td, th {
|
|
134
|
+
border: 1px solid #caccce;
|
|
135
|
+
|
|
136
|
+
body.global-dark & {
|
|
137
|
+
border-color: #babcbd;
|
|
138
|
+
// border-color: #c9cace;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
border-collapse: collapse;
|
|
142
|
+
border-spacing: 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
table {
|
|
146
|
+
line-height: 1.6;
|
|
147
|
+
margin: 10px auto;
|
|
148
|
+
border-spacing: none;
|
|
149
|
+
border-collapse: collapse;
|
|
150
|
+
empty-cells: show;
|
|
151
|
+
font-size: 14px;
|
|
152
|
+
|
|
153
|
+
&.loose p {
|
|
154
|
+
margin: 0;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
td, th {
|
|
159
|
+
border: 1px solid #e3e3e3;
|
|
160
|
+
padding: 10px 12px;
|
|
161
|
+
line-height: 1.3;
|
|
162
|
+
|
|
163
|
+
p {
|
|
164
|
+
margin: 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
th {
|
|
169
|
+
background: hsla(230, 90%, 11%, .03);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
a, a:visited {
|
|
173
|
+
color: #0080FF;
|
|
174
|
+
text-decoration: none;
|
|
175
|
+
|
|
176
|
+
&:hover {
|
|
177
|
+
text-decoration: underline;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
ul, ol {
|
|
182
|
+
list-style: revert;
|
|
183
|
+
padding-left: 16px;
|
|
184
|
+
margin: 0;
|
|
185
|
+
|
|
186
|
+
&.loose {
|
|
187
|
+
padding-left: 30px;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
li {
|
|
192
|
+
list-style: revert;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
blockquote {
|
|
196
|
+
opacity: 1;
|
|
197
|
+
border: none;
|
|
198
|
+
padding: 0;
|
|
199
|
+
margin-left: 20px;
|
|
200
|
+
opacity: 0.6;
|
|
201
|
+
font-style: italic;
|
|
202
|
+
position: relative;
|
|
203
|
+
margin-top: 6px;
|
|
204
|
+
margin-bottom: 6px;
|
|
205
|
+
|
|
206
|
+
&.loose {
|
|
207
|
+
margin-top: 20px;
|
|
208
|
+
margin-bottom: 20px;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&::before {
|
|
212
|
+
content: '|';
|
|
213
|
+
font-size: 0;
|
|
214
|
+
color: transparent;
|
|
215
|
+
display: inline-block;
|
|
216
|
+
width: 4px;
|
|
217
|
+
border-radius: 1px;
|
|
218
|
+
position: absolute;
|
|
219
|
+
margin-left: -16px;
|
|
220
|
+
top: 0;
|
|
221
|
+
bottom: 0;
|
|
222
|
+
background: hsla(230, 90%, 11%, .2);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
hr {
|
|
227
|
+
height: 0;
|
|
228
|
+
border: none;
|
|
229
|
+
height: 1px;
|
|
230
|
+
background: hsla(230, 90%, 11%, .1);
|
|
231
|
+
margin: 10px 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './main.scss';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @api HTMLRenderer
|
|
4
|
+
*/
|
|
5
|
+
export interface HTMLRendererProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
|
+
/**
|
|
7
|
+
* 自定义类名
|
|
8
|
+
* @en Custom class name
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 是否启用图片预览
|
|
13
|
+
* @en Enable image zoom
|
|
14
|
+
*/
|
|
15
|
+
imagePreview?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 是否使用松散模式
|
|
18
|
+
* @en Enable loose mode
|
|
19
|
+
*/
|
|
20
|
+
loose?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 要渲染的 HTML 字符串
|
|
23
|
+
* @en HTML string to render
|
|
24
|
+
*/
|
|
25
|
+
children?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 处理打开链接的函数
|
|
28
|
+
* @en Function to handle open link
|
|
29
|
+
*/
|
|
30
|
+
handleOpenLink?: (href: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* 发送文本消息的函数
|
|
33
|
+
* @en Function to send text message
|
|
34
|
+
*/
|
|
35
|
+
sendTextMessage?: (message: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 复制文本的函数
|
|
38
|
+
* @en Function to copy text
|
|
39
|
+
*/
|
|
40
|
+
copyText?: (text: string, i18n?: (key: string) => string) => void;
|
|
41
|
+
/**
|
|
42
|
+
* 国际化函数
|
|
43
|
+
* @en Internationalization function
|
|
44
|
+
*/
|
|
45
|
+
i18n?: (key: string) => string;
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component 图片预览
|
|
3
|
+
* @en ImagePreview
|
|
4
|
+
* @type 通用 - General
|
|
5
|
+
* @remarks 图片预览组件用于在钉钉环境中显示和预览图片。 - Image preview component used to display and preview images in DingTalk environment.
|
|
6
|
+
* @when 需要展示图片并提供预览功能时使用。 - Use when you need to display images and provide preview functionality.
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { ImagePreviewProps } from './types';
|
|
11
|
+
export * from './types';
|
|
12
|
+
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<ImagePreviewProps & React.RefAttributes<HTMLElement>, "key" | keyof ImagePreviewProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, HTMLElement, {}>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/**
|
|
5
|
+
* @component 图片预览
|
|
6
|
+
* @en ImagePreview
|
|
7
|
+
* @type 通用 - General
|
|
8
|
+
* @remarks 图片预览组件用于在钉钉环境中显示和预览图片。 - Image preview component used to display and preview images in DingTalk environment.
|
|
9
|
+
* @when 需要展示图片并提供预览功能时使用。 - Use when you need to display images and provide preview functionality.
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
13
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
|
+
const react_photo_view_1 = require("react-photo-view");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
const next_1 = require("@alifd/next");
|
|
17
|
+
const utils_2 = require("../utils");
|
|
18
|
+
const dingtalk_jsapi_1 = require("dingtalk-jsapi");
|
|
19
|
+
function handleClick(e, src) {
|
|
20
|
+
if ((0, utils_1.findAncestor)(e.target, t => t.tagName === 'A' && !!t.href)) {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (src && dingtalk_jsapi_1.env.version) {
|
|
25
|
+
const a = document.createElement('a');
|
|
26
|
+
a.href = src;
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
dingtalk_jsapi_1.biz.util.previewImage({
|
|
29
|
+
urls: [a.href],
|
|
30
|
+
current: a.href,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isInsideLink(e) {
|
|
35
|
+
return !!(0, utils_1.findAncestor)(e.target, (t) => t.tagName === 'A' && !!t.href);
|
|
36
|
+
}
|
|
37
|
+
const ImagePreview = (0, react_1.forwardRef)(({ className, src, children, width, height }, ref) => {
|
|
38
|
+
let child;
|
|
39
|
+
try {
|
|
40
|
+
child = react_1.default.Children.only(children);
|
|
41
|
+
}
|
|
42
|
+
catch (e) { }
|
|
43
|
+
if (child && child.props) {
|
|
44
|
+
const { onClick, onTouchEnd } = child.props;
|
|
45
|
+
child = react_1.default.cloneElement(child, {
|
|
46
|
+
onTouchEnd: (e) => {
|
|
47
|
+
if (isInsideLink(e)) {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
}
|
|
50
|
+
handleClick(e, src);
|
|
51
|
+
onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
|
|
52
|
+
},
|
|
53
|
+
onClick: (e) => {
|
|
54
|
+
if (isInsideLink(e)) {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
}
|
|
57
|
+
handleClick(e, src);
|
|
58
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return (react_1.default.createElement(react_photo_view_1.PhotoProvider, null,
|
|
63
|
+
react_1.default.createElement(react_photo_view_1.PhotoView, { src: src },
|
|
64
|
+
react_1.default.createElement("span", { className: (0, classnames_1.default)('box', className, {
|
|
65
|
+
'hasWidth': !!width,
|
|
66
|
+
'hasHeight': !!height,
|
|
67
|
+
}), style: { width } },
|
|
68
|
+
width && height ? (react_1.default.createElement("span", { className: "placeholder", style: { paddingBottom: `${(height / width) * 100}%` } })) : null,
|
|
69
|
+
child))));
|
|
70
|
+
});
|
|
71
|
+
const ImagePreviewWithSub = (0, utils_2.assignSubComponent)(ImagePreview, {
|
|
72
|
+
displayName: 'ImagePreview',
|
|
73
|
+
});
|
|
74
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
75
|
+
exports.default = next_1.ConfigProvider.config(ImagePreviewWithSub);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './main.scss';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @api ImagePreview
|
|
4
|
+
*/
|
|
5
|
+
export interface ImagePreviewProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
|
+
/**
|
|
7
|
+
* 自定义类名
|
|
8
|
+
* @en Custom class name
|
|
9
|
+
*/
|
|
10
|
+
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 图片的源地址
|
|
13
|
+
* @en Source URL of the image
|
|
14
|
+
*/
|
|
15
|
+
src: string;
|
|
16
|
+
/**
|
|
17
|
+
* 子元素
|
|
18
|
+
* @en Child elements
|
|
19
|
+
*/
|
|
20
|
+
children?: React.ReactElement;
|
|
21
|
+
/**
|
|
22
|
+
* 图片的宽度
|
|
23
|
+
* @en Width of the image
|
|
24
|
+
*/
|
|
25
|
+
width?: number;
|
|
26
|
+
/**
|
|
27
|
+
* 图片的高度
|
|
28
|
+
* @en Height of the image
|
|
29
|
+
*/
|
|
30
|
+
height?: number;
|
|
31
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -13,5 +13,8 @@ export { default as Message } from './message';
|
|
|
13
13
|
export { default as Icon } from './icon';
|
|
14
14
|
export { default as Balloon } from './balloon';
|
|
15
15
|
export { default as List } from './list';
|
|
16
|
+
export { default as ImagePreview } from './ImagePreview';
|
|
17
|
+
export { default as HTMLRenderer } from './HTMLRenderer';
|
|
18
|
+
export { default as Markdown } from './markdown';
|
|
16
19
|
export { default as CardLoading } from './card-loading';
|
|
17
20
|
export declare const version: string;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.version = exports.CardLoading = exports.List = exports.Balloon = exports.Icon = exports.Message = exports.PersonPicker = exports.TimePicker = exports.DatePicker = exports.Input = exports.Tab = exports.Tag = exports.Text = exports.FloatButton = exports.Feedback = exports.Card = exports.Button = void 0;
|
|
3
|
+
exports.version = exports.CardLoading = exports.Markdown = exports.HTMLRenderer = exports.ImagePreview = exports.List = exports.Balloon = exports.Icon = exports.Message = exports.PersonPicker = exports.TimePicker = exports.DatePicker = exports.Input = exports.Tab = exports.Tag = exports.Text = exports.FloatButton = exports.Feedback = exports.Card = exports.Button = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var button_1 = require("./button");
|
|
6
6
|
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return tslib_1.__importDefault(button_1).default; } });
|
|
@@ -32,6 +32,12 @@ var balloon_1 = require("./balloon");
|
|
|
32
32
|
Object.defineProperty(exports, "Balloon", { enumerable: true, get: function () { return tslib_1.__importDefault(balloon_1).default; } });
|
|
33
33
|
var list_1 = require("./list");
|
|
34
34
|
Object.defineProperty(exports, "List", { enumerable: true, get: function () { return tslib_1.__importDefault(list_1).default; } });
|
|
35
|
+
var ImagePreview_1 = require("./ImagePreview");
|
|
36
|
+
Object.defineProperty(exports, "ImagePreview", { enumerable: true, get: function () { return tslib_1.__importDefault(ImagePreview_1).default; } });
|
|
37
|
+
var HTMLRenderer_1 = require("./HTMLRenderer");
|
|
38
|
+
Object.defineProperty(exports, "HTMLRenderer", { enumerable: true, get: function () { return tslib_1.__importDefault(HTMLRenderer_1).default; } });
|
|
39
|
+
var markdown_1 = require("./markdown");
|
|
40
|
+
Object.defineProperty(exports, "Markdown", { enumerable: true, get: function () { return tslib_1.__importDefault(markdown_1).default; } });
|
|
35
41
|
var card_loading_1 = require("./card-loading");
|
|
36
42
|
Object.defineProperty(exports, "CardLoading", { enumerable: true, get: function () { return tslib_1.__importDefault(card_loading_1).default; } });
|
|
37
|
-
exports.version = '0.2.0-beta.
|
|
43
|
+
exports.version = '0.2.0-beta.2';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MarkdownProps } from './types';
|
|
3
|
+
import 'highlight.js/styles/github.css';
|
|
4
|
+
export * from './types';
|
|
5
|
+
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<MarkdownProps & React.RefAttributes<HTMLDivElement>, "key" | keyof MarkdownProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, HTMLDivElement, {}>;
|
|
6
|
+
export default _default;
|