x-star-editor 0.4.2 → 0.6.0
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/dist/components/FileInput.js +16 -16
- package/dist/components/Toolbar.js +47 -82
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/styles/cursor/editor-eraser.png +0 -0
- package/dist/styles/cursor/pencil.png +0 -0
- package/dist/styles/index.css +1455 -1261
- package/dist/themes/lark.css +160 -59
- package/dist/utils/container.js +7 -2
- package/dist/utils/global.d.ts +1 -1
- package/dist/utils/global.js +1 -1
- package/dist/utils/markdown.d.ts +8 -9
- package/dist/utils/markdown.js +36 -21
- package/dist/utils/slide/index.d.ts +0 -0
- package/dist/utils/slide/index.js +32 -0
- package/dist/x-star-editor/index.d.ts +2 -6
- package/dist/x-star-editor/index.js +10 -12
- package/dist/x-star-md-editor/index.js +1 -1
- package/dist/x-star-md-viewer/index.d.ts +0 -4
- package/dist/x-star-md-viewer/index.js +41 -31
- package/dist/x-star-slide-viewer/index.d.ts +42 -0
- package/dist/x-star-slide-viewer/index.js +367 -0
- package/package.json +8 -4
package/dist/themes/lark.css
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
@charset "UTF-8";
|
|
2
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark
|
|
2
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark,
|
|
3
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark {
|
|
3
4
|
line-height: 1.68;
|
|
4
5
|
text-size-adjust: 100%;
|
|
5
6
|
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "Segoe UI", "PingFang SC", "Microsoft Yahei", "Hiragino Sans GB", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
6
7
|
font-size: 16px;
|
|
7
8
|
color: #1f2329;
|
|
8
9
|
}
|
|
9
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark
|
|
10
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark *,
|
|
11
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark * {
|
|
10
12
|
box-sizing: border-box;
|
|
11
13
|
-webkit-font-smoothing: antialiased;
|
|
12
14
|
text-rendering: optimizelegibility;
|
|
13
15
|
}
|
|
14
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark > *:first-child
|
|
16
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark > *:first-child,
|
|
17
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark > *:first-child {
|
|
15
18
|
margin-top: 0;
|
|
16
19
|
}
|
|
17
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark > *:last-child
|
|
20
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark > *:last-child,
|
|
21
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark > *:last-child {
|
|
18
22
|
margin-top: 0;
|
|
19
23
|
}
|
|
20
24
|
.x-star-editor-md-viewer.x-star-editor-theme-lark p,
|
|
@@ -28,57 +32,83 @@
|
|
|
28
32
|
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote,
|
|
29
33
|
.x-star-editor-md-viewer.x-star-editor-theme-lark table,
|
|
30
34
|
.x-star-editor-md-viewer.x-star-editor-theme-lark figure,
|
|
31
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark hr
|
|
35
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark hr,
|
|
36
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark p,
|
|
37
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark details,
|
|
38
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark dl,
|
|
39
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol,
|
|
40
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul,
|
|
41
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark xmp,
|
|
42
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark plaintext,
|
|
43
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark listing,
|
|
44
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark blockquote,
|
|
45
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark table,
|
|
46
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark figure,
|
|
47
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark hr {
|
|
32
48
|
margin-top: 8px;
|
|
33
49
|
margin-bottom: 8px;
|
|
34
50
|
}
|
|
35
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h1
|
|
51
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h1,
|
|
52
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h1 {
|
|
36
53
|
font-size: 26px;
|
|
37
54
|
font-weight: bold;
|
|
38
55
|
margin: 26px 0 10px;
|
|
39
56
|
}
|
|
40
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h2
|
|
57
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h2,
|
|
58
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h2 {
|
|
41
59
|
font-size: 22px;
|
|
42
60
|
font-weight: bold;
|
|
43
61
|
margin: 22px 0 8px;
|
|
44
62
|
}
|
|
45
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h3
|
|
63
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h3,
|
|
64
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h3 {
|
|
46
65
|
font-size: 20px;
|
|
47
66
|
font-weight: bold;
|
|
48
67
|
margin: 20px 0 8px;
|
|
49
68
|
}
|
|
50
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h4
|
|
69
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h4,
|
|
70
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h4 {
|
|
51
71
|
font-size: 18px;
|
|
52
72
|
font-weight: bold;
|
|
53
73
|
margin: 18px 0 8px;
|
|
54
74
|
}
|
|
55
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h5
|
|
75
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h5,
|
|
76
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h5 {
|
|
56
77
|
font-size: 16px;
|
|
57
78
|
font-weight: bold;
|
|
58
79
|
margin: 16px 0 8px;
|
|
59
80
|
}
|
|
60
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h6
|
|
81
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h6,
|
|
82
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h6 {
|
|
61
83
|
font-size: 16px;
|
|
62
84
|
font-weight: bold;
|
|
63
85
|
margin: 16px 0 8px;
|
|
64
86
|
}
|
|
65
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark p
|
|
87
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark p,
|
|
88
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark p {
|
|
66
89
|
margin-left: 0;
|
|
67
90
|
margin-right: 0;
|
|
68
91
|
}
|
|
69
92
|
.x-star-editor-md-viewer.x-star-editor-theme-lark pre,
|
|
70
93
|
.x-star-editor-md-viewer.x-star-editor-theme-lark xmp,
|
|
71
94
|
.x-star-editor-md-viewer.x-star-editor-theme-lark plaintext,
|
|
72
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark listing
|
|
95
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark listing,
|
|
96
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark pre,
|
|
97
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark xmp,
|
|
98
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark plaintext,
|
|
99
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark listing {
|
|
73
100
|
font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
|
|
74
101
|
}
|
|
75
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote > :first-child
|
|
102
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote > :first-child,
|
|
103
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark blockquote > :first-child {
|
|
76
104
|
margin-top: 0;
|
|
77
105
|
}
|
|
78
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote > :last-child
|
|
106
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote > :last-child,
|
|
107
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark blockquote > :last-child {
|
|
79
108
|
margin-bottom: 0;
|
|
80
109
|
}
|
|
81
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark hr
|
|
110
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark hr,
|
|
111
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark hr {
|
|
82
112
|
border-style: inset;
|
|
83
113
|
border-width: 1px;
|
|
84
114
|
margin: 13px 0 12px;
|
|
@@ -88,29 +118,38 @@
|
|
|
88
118
|
background-image: linear-gradient(90deg, #bbbfc4, #bbbfc4);
|
|
89
119
|
background-repeat: no-repeat;
|
|
90
120
|
}
|
|
91
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark img
|
|
121
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark img,
|
|
122
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark img {
|
|
92
123
|
max-width: 100%;
|
|
93
124
|
height: auto;
|
|
94
125
|
}
|
|
95
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark li
|
|
126
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark li,
|
|
127
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark li {
|
|
96
128
|
position: relative;
|
|
97
129
|
word-wrap: break-all;
|
|
98
130
|
}
|
|
99
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark li + li
|
|
131
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark li + li,
|
|
132
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark li + li {
|
|
100
133
|
margin-top: 4px;
|
|
101
134
|
}
|
|
102
135
|
.x-star-editor-md-viewer.x-star-editor-theme-lark ul ul,
|
|
103
136
|
.x-star-editor-md-viewer.x-star-editor-theme-lark ol ul,
|
|
104
137
|
.x-star-editor-md-viewer.x-star-editor-theme-lark ul ol,
|
|
105
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ol ol
|
|
138
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ol ol,
|
|
139
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul ul,
|
|
140
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol ul,
|
|
141
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul ol,
|
|
142
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol ol {
|
|
106
143
|
margin-top: 0;
|
|
107
144
|
margin-bottom: 0;
|
|
108
145
|
}
|
|
109
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item
|
|
146
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item,
|
|
147
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item {
|
|
110
148
|
list-style-type: none;
|
|
111
149
|
padding-left: 0.3rem;
|
|
112
150
|
}
|
|
113
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark a
|
|
151
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark a,
|
|
152
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark a {
|
|
114
153
|
color: #3370ff;
|
|
115
154
|
overflow-wrap: break-word;
|
|
116
155
|
word-wrap: break-word;
|
|
@@ -119,11 +158,14 @@
|
|
|
119
158
|
word-break: break-word;
|
|
120
159
|
text-decoration: none;
|
|
121
160
|
}
|
|
122
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark a img
|
|
161
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark a img,
|
|
162
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark a img {
|
|
123
163
|
border: none;
|
|
124
164
|
}
|
|
125
165
|
.x-star-editor-md-viewer.x-star-editor-theme-lark b,
|
|
126
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark strong
|
|
166
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark strong,
|
|
167
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark b,
|
|
168
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark strong {
|
|
127
169
|
font-weight: bold;
|
|
128
170
|
}
|
|
129
171
|
.x-star-editor-md-viewer.x-star-editor-theme-lark i,
|
|
@@ -131,25 +173,39 @@
|
|
|
131
173
|
.x-star-editor-md-viewer.x-star-editor-theme-lark em,
|
|
132
174
|
.x-star-editor-md-viewer.x-star-editor-theme-lark var,
|
|
133
175
|
.x-star-editor-md-viewer.x-star-editor-theme-lark address,
|
|
134
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark dfn
|
|
176
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark dfn,
|
|
177
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark i,
|
|
178
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark cite,
|
|
179
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark em,
|
|
180
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark var,
|
|
181
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark address,
|
|
182
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark dfn {
|
|
135
183
|
font-style: italic;
|
|
136
184
|
}
|
|
137
185
|
.x-star-editor-md-viewer.x-star-editor-theme-lark code,
|
|
138
186
|
.x-star-editor-md-viewer.x-star-editor-theme-lark kbd,
|
|
139
187
|
.x-star-editor-md-viewer.x-star-editor-theme-lark tt,
|
|
140
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark samp
|
|
188
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark samp,
|
|
189
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark code,
|
|
190
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark kbd,
|
|
191
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark tt,
|
|
192
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark samp {
|
|
141
193
|
font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
|
|
142
194
|
}
|
|
143
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark mark
|
|
195
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark mark,
|
|
196
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark mark {
|
|
144
197
|
color: #1f2329;
|
|
145
198
|
padding: 0.2em 0;
|
|
146
199
|
background-color: rgba(255, 246, 122, 0.8);
|
|
147
200
|
}
|
|
148
201
|
.x-star-editor-md-viewer.x-star-editor-theme-lark del,
|
|
149
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark s
|
|
202
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark s,
|
|
203
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark del,
|
|
204
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark s {
|
|
150
205
|
color: inherit;
|
|
151
206
|
}
|
|
152
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark table
|
|
207
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark table,
|
|
208
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark table {
|
|
153
209
|
color: black;
|
|
154
210
|
border-collapse: collapse;
|
|
155
211
|
background-color: white;
|
|
@@ -157,47 +213,59 @@
|
|
|
157
213
|
font-size: 1em;
|
|
158
214
|
}
|
|
159
215
|
.x-star-editor-md-viewer.x-star-editor-theme-lark th,
|
|
160
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark td
|
|
216
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark td,
|
|
217
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark th,
|
|
218
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark td {
|
|
161
219
|
border-color: #dee0e3;
|
|
162
220
|
border-width: 1px;
|
|
163
221
|
border-style: solid;
|
|
164
222
|
}
|
|
165
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark th
|
|
223
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark th,
|
|
224
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark th {
|
|
166
225
|
padding: 8px;
|
|
167
226
|
font-size: 1em;
|
|
168
227
|
}
|
|
169
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark td
|
|
228
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark td,
|
|
229
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark td {
|
|
170
230
|
padding: 8px;
|
|
171
231
|
font-size: 1em;
|
|
172
232
|
font-weight: normal;
|
|
173
233
|
}
|
|
174
234
|
.x-star-editor-md-viewer.x-star-editor-theme-lark pre.md-fences,
|
|
175
235
|
.x-star-editor-md-viewer.x-star-editor-theme-lark pre.md-meta-block,
|
|
176
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock-control:not(.md-rawblock-tooltip) .md-rawblock-input
|
|
236
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock-control:not(.md-rawblock-tooltip) .md-rawblock-input,
|
|
237
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark pre.md-fences,
|
|
238
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark pre.md-meta-block,
|
|
239
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .md-rawblock-control:not(.md-rawblock-tooltip) .md-rawblock-input {
|
|
177
240
|
border-radius: 3px;
|
|
178
241
|
border: 1px solid #dee0e3;
|
|
179
242
|
padding: 10px;
|
|
180
243
|
background-color: #f5f6f7;
|
|
181
244
|
}
|
|
182
245
|
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-math-block,
|
|
183
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock
|
|
246
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock,
|
|
247
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .md-math-block,
|
|
248
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .md-rawblock {
|
|
184
249
|
margin-top: 1em;
|
|
185
250
|
margin-bottom: 1em;
|
|
186
251
|
}
|
|
187
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock > .md-rawblock-tooltip
|
|
252
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock > .md-rawblock-tooltip,
|
|
253
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .md-rawblock > .md-rawblock-tooltip {
|
|
188
254
|
background-color: #f5f6f7;
|
|
189
255
|
transition: 0.5s;
|
|
190
256
|
display: block;
|
|
191
257
|
visibility: hidden;
|
|
192
258
|
opacity: 0;
|
|
193
259
|
}
|
|
194
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock:hover > .md-rawblock-tooltip
|
|
260
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock:hover > .md-rawblock-tooltip,
|
|
261
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .md-rawblock:hover > .md-rawblock-tooltip {
|
|
195
262
|
transition: 0.5s;
|
|
196
263
|
visibility: visible;
|
|
197
264
|
opacity: 1;
|
|
198
265
|
animation: none;
|
|
199
266
|
}
|
|
200
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock-control:not(.md-rawblock-tooltip)
|
|
267
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .md-rawblock-control:not(.md-rawblock-tooltip),
|
|
268
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .md-rawblock-control:not(.md-rawblock-tooltip) {
|
|
201
269
|
padding-left: 0;
|
|
202
270
|
padding-right: 0;
|
|
203
271
|
}
|
|
@@ -206,19 +274,27 @@
|
|
|
206
274
|
.x-star-editor-md-viewer.x-star-editor-theme-lark h3,
|
|
207
275
|
.x-star-editor-md-viewer.x-star-editor-theme-lark h4,
|
|
208
276
|
.x-star-editor-md-viewer.x-star-editor-theme-lark h5,
|
|
209
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark h6
|
|
277
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark h6,
|
|
278
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h1,
|
|
279
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h2,
|
|
280
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h3,
|
|
281
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h4,
|
|
282
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h5,
|
|
283
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark h6 {
|
|
210
284
|
line-height: 1.4;
|
|
211
285
|
margin-top: 1em;
|
|
212
286
|
margin-bottom: 0.37em;
|
|
213
287
|
}
|
|
214
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote
|
|
288
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark blockquote,
|
|
289
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark blockquote {
|
|
215
290
|
display: block;
|
|
216
291
|
margin-left: 0;
|
|
217
292
|
padding-left: 14px;
|
|
218
293
|
border-left: 2px solid #3370ff;
|
|
219
294
|
color: rgba(31, 35, 41, 0.7);
|
|
220
295
|
}
|
|
221
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark :not(pre) > code
|
|
296
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark :not(pre) > code,
|
|
297
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark :not(pre) > code {
|
|
222
298
|
border-radius: 4px;
|
|
223
299
|
margin-left: 2px;
|
|
224
300
|
margin-right: 2px;
|
|
@@ -228,19 +304,23 @@
|
|
|
228
304
|
line-height: 1.6;
|
|
229
305
|
padding: 0 2px;
|
|
230
306
|
}
|
|
231
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark a:hover
|
|
307
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark a:hover,
|
|
308
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark a:hover {
|
|
232
309
|
text-decoration: underline;
|
|
233
310
|
}
|
|
234
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ul
|
|
311
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ul,
|
|
312
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul {
|
|
235
313
|
margin-left: 0;
|
|
236
314
|
padding-left: 22px;
|
|
237
315
|
list-style: none;
|
|
238
316
|
}
|
|
239
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item])
|
|
317
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]),
|
|
318
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) {
|
|
240
319
|
word-wrap: break-all;
|
|
241
320
|
padding-left: 0;
|
|
242
321
|
}
|
|
243
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item])::before
|
|
322
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item])::before,
|
|
323
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item])::before {
|
|
244
324
|
position: absolute;
|
|
245
325
|
top: 2px;
|
|
246
326
|
content: "•";
|
|
@@ -253,28 +333,33 @@
|
|
|
253
333
|
transform: scale(1.25);
|
|
254
334
|
font-family: PingFangSC-Regular, "PingFang SC", Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
|
|
255
335
|
}
|
|
256
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) li:not([class*=task-list-item])::before
|
|
336
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) li:not([class*=task-list-item])::before,
|
|
337
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) li:not([class*=task-list-item])::before {
|
|
257
338
|
content: "◦";
|
|
258
339
|
transform: scale(1);
|
|
259
340
|
font-weight: 700;
|
|
260
341
|
}
|
|
261
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) li:not([class*=task-list-item]) li:not([class*=task-list-item])::before
|
|
342
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) li:not([class*=task-list-item]) li:not([class*=task-list-item])::before,
|
|
343
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul > li:not([class*=task-list-item]) li:not([class*=task-list-item]) li:not([class*=task-list-item])::before {
|
|
262
344
|
content: "▪";
|
|
263
345
|
transform: scale(1.25);
|
|
264
346
|
font-weight: normal;
|
|
265
347
|
}
|
|
266
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ol
|
|
348
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ol,
|
|
349
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol {
|
|
267
350
|
counter-reset: ol_counter;
|
|
268
351
|
margin-left: 0;
|
|
269
352
|
padding-left: 22px;
|
|
270
353
|
list-style: none;
|
|
271
354
|
}
|
|
272
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ol > li:not([class*=task-list-item])
|
|
355
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ol > li:not([class*=task-list-item]),
|
|
356
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol > li:not([class*=task-list-item]) {
|
|
273
357
|
word-wrap: break-all;
|
|
274
358
|
padding-left: 0;
|
|
275
359
|
position: relative;
|
|
276
360
|
}
|
|
277
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark ol > li:not([class*=task-list-item])::before
|
|
361
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark ol > li:not([class*=task-list-item])::before,
|
|
362
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol > li:not([class*=task-list-item])::before {
|
|
278
363
|
content: counter(ol_counter) ".";
|
|
279
364
|
counter-increment: ol_counter;
|
|
280
365
|
color: #3370ff;
|
|
@@ -297,23 +382,35 @@
|
|
|
297
382
|
.x-star-editor-md-viewer.x-star-editor-theme-lark ul ol,
|
|
298
383
|
.x-star-editor-md-viewer.x-star-editor-theme-lark ol ol,
|
|
299
384
|
.x-star-editor-md-viewer.x-star-editor-theme-lark li ul,
|
|
300
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark li ol
|
|
385
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark li ol,
|
|
386
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark li + li,
|
|
387
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul ul,
|
|
388
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol ul,
|
|
389
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ul ol,
|
|
390
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark ol ol,
|
|
391
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark li ul,
|
|
392
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark li ol {
|
|
301
393
|
margin-top: 4px;
|
|
302
394
|
}
|
|
303
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > p
|
|
395
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > p,
|
|
396
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item > p {
|
|
304
397
|
transition: color 0.3s, opacity 0.3s;
|
|
305
398
|
}
|
|
306
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p
|
|
399
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p,
|
|
400
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p {
|
|
307
401
|
color: #646a73;
|
|
308
402
|
text-decoration: line-through;
|
|
309
403
|
}
|
|
310
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p > .md-emoji
|
|
404
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p > .md-emoji,
|
|
405
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p > .md-emoji {
|
|
311
406
|
opacity: 0.5;
|
|
312
407
|
}
|
|
313
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p > .md-link > a
|
|
408
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p > .md-link > a,
|
|
409
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item.task-list-done > p > .md-link > a {
|
|
314
410
|
opacity: 0.6;
|
|
315
411
|
}
|
|
316
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input
|
|
412
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input,
|
|
413
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item > input {
|
|
317
414
|
appearance: initial;
|
|
318
415
|
display: block;
|
|
319
416
|
position: absolute;
|
|
@@ -324,14 +421,17 @@
|
|
|
324
421
|
width: 1.2rem;
|
|
325
422
|
transition: border-color 0.3s;
|
|
326
423
|
}
|
|
327
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:focus
|
|
424
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:focus,
|
|
425
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item > input:focus {
|
|
328
426
|
outline: none;
|
|
329
427
|
box-shadow: none;
|
|
330
428
|
}
|
|
331
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:hover
|
|
429
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:hover,
|
|
430
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item > input:hover {
|
|
332
431
|
border-color: #3370ff;
|
|
333
432
|
}
|
|
334
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:checked::before
|
|
433
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:checked::before,
|
|
434
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item > input:checked::before {
|
|
335
435
|
content: "";
|
|
336
436
|
position: absolute;
|
|
337
437
|
top: 20%;
|
|
@@ -341,7 +441,8 @@
|
|
|
341
441
|
transform: rotate(40deg);
|
|
342
442
|
background: #3370ff;
|
|
343
443
|
}
|
|
344
|
-
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:checked::after
|
|
444
|
+
.x-star-editor-md-viewer.x-star-editor-theme-lark .task-list-item > input:checked::after,
|
|
445
|
+
.x-star-editor-slide-viewer.x-star-editor-theme-lark .task-list-item > input:checked::after {
|
|
345
446
|
content: "";
|
|
346
447
|
position: absolute;
|
|
347
448
|
top: 46%;
|
package/dist/utils/container.js
CHANGED
|
@@ -109,9 +109,14 @@ export var useContainer = function useContainer(ref) {
|
|
|
109
109
|
for (; oldChild && newChild;) {
|
|
110
110
|
var oldNext = oldChild.nextSibling;
|
|
111
111
|
var newNext = newChild.nextSibling;
|
|
112
|
-
if (oldChild.nodeName !== newChild.nodeName
|
|
113
|
-
//
|
|
112
|
+
if (oldChild.nodeName !== newChild.nodeName) {
|
|
113
|
+
// 节点名称不同,直接替换
|
|
114
114
|
oldChild.replaceWith(newChild);
|
|
115
|
+
} else if (oldChild.nodeType === Node.TEXT_NODE) {
|
|
116
|
+
// 节点均为文本类型,更新文本内容
|
|
117
|
+
if (oldChild.nodeValue !== newChild.nodeValue) {
|
|
118
|
+
oldChild.nodeValue = newChild.nodeValue;
|
|
119
|
+
}
|
|
115
120
|
} else {
|
|
116
121
|
// 节点名称相同,更新属性和子节点
|
|
117
122
|
if (oldChild instanceof HTMLElement && newChild instanceof HTMLElement) {
|
package/dist/utils/global.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const prefix = "x-star-editor
|
|
1
|
+
export declare const prefix = "x-star-editor";
|
package/dist/utils/global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var prefix = 'x-star-editor
|
|
1
|
+
export var prefix = 'x-star-editor';
|
package/dist/utils/markdown.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Root as HastRoot } from 'hast';
|
|
2
|
+
import type { Options as ToStringOptions } from 'mdast-util-to-string';
|
|
2
3
|
import { defaultSchema } from 'rehype-sanitize';
|
|
3
4
|
import type { ViewerOptions } from '../x-star-md-viewer';
|
|
4
5
|
/**
|
|
@@ -20,14 +21,6 @@ export declare const preViewerRender: (sourceCode: string) => Promise<HastRoot>;
|
|
|
20
21
|
*/
|
|
21
22
|
export type Schema = typeof defaultSchema;
|
|
22
23
|
export declare const getDefaultSchema: () => Schema;
|
|
23
|
-
/**
|
|
24
|
-
* 将 Hast 树转成新的 Hast 树
|
|
25
|
-
*
|
|
26
|
-
* @param root Hast 树
|
|
27
|
-
* @param schema 过滤模式
|
|
28
|
-
* @returns 新的 Hast 树
|
|
29
|
-
*/
|
|
30
|
-
export declare const viewerRender: (root: HastRoot, schema: Schema) => HastRoot;
|
|
31
24
|
/**
|
|
32
25
|
* 将 Hast 树映射到 React 虚拟 DOM 树
|
|
33
26
|
*
|
|
@@ -50,10 +43,16 @@ export declare const toHTML: (sourceCode: string) => string;
|
|
|
50
43
|
* @returns Markdown 文本
|
|
51
44
|
*/
|
|
52
45
|
export declare const toMarkdown: (sourceCode: string) => string;
|
|
46
|
+
export interface ToTextOptions extends ToStringOptions {
|
|
47
|
+
/**
|
|
48
|
+
* 替换图片的 alt 文本
|
|
49
|
+
*/
|
|
50
|
+
replaceImageAlt?: string;
|
|
51
|
+
}
|
|
53
52
|
/**
|
|
54
53
|
* 将 Markdown 文本转成纯文本
|
|
55
54
|
*
|
|
56
55
|
* @param sourceCode Markdown 文本
|
|
57
56
|
* @returns 纯文本
|
|
58
57
|
*/
|
|
59
|
-
export declare const toText: (sourceCode: string) => string;
|
|
58
|
+
export declare const toText: (sourceCode: string, options?: ToTextOptions) => string;
|
package/dist/utils/markdown.js
CHANGED
|
@@ -15,7 +15,7 @@ import rehypeMermaid from 'rehype-mermaidjs';
|
|
|
15
15
|
import rehypePrism from 'rehype-prism-plus';
|
|
16
16
|
import rehypeRaw from 'rehype-raw';
|
|
17
17
|
import rehypeRemark, { defaultHandlers } from 'rehype-remark';
|
|
18
|
-
import
|
|
18
|
+
import { defaultSchema } from 'rehype-sanitize';
|
|
19
19
|
import rehypeStringify from 'rehype-stringify';
|
|
20
20
|
import remarkBreaks from 'remark-breaks';
|
|
21
21
|
import remarkGfm from 'remark-gfm';
|
|
@@ -24,9 +24,9 @@ import remarkParse from 'remark-parse';
|
|
|
24
24
|
import remarkRehype from 'remark-rehype';
|
|
25
25
|
import remarkStringify from 'remark-stringify';
|
|
26
26
|
import { unified } from 'unified';
|
|
27
|
+
import { visit } from 'unist-util-visit';
|
|
27
28
|
import { prefix } from "./global";
|
|
28
29
|
import rehypeCustom from "./rehype/rehype-custom";
|
|
29
|
-
import rehypeLine from "./rehype/rehype-line";
|
|
30
30
|
import rehypeMath, { isMathNode } from "./rehype/rehype-math";
|
|
31
31
|
import rehypeRawPositions from "./rehype/rehype-raw-positions";
|
|
32
32
|
|
|
@@ -59,7 +59,7 @@ export var editorRender = function editorRender(sourceCode) {
|
|
|
59
59
|
/**
|
|
60
60
|
* CSS 类名前缀
|
|
61
61
|
*/
|
|
62
|
-
var mdPrefix = "".concat(prefix, "md
|
|
62
|
+
var mdPrefix = "".concat(prefix, "-md");
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* 扫描偏移量,表示已经添加到 DOM 树的文本
|
|
@@ -101,9 +101,9 @@ export var editorRender = function editorRender(sourceCode) {
|
|
|
101
101
|
|
|
102
102
|
// 如果节点为流内容,则将样式添加到该行的 `<div>` 元素上,否则添加到该节点的元素上
|
|
103
103
|
var styleElement = stack[index && !isFlowContent(stack[index - 1].node) ? index : 0].element;
|
|
104
|
-
styleElement.classList.add("".concat(mdPrefix).concat(node.type));
|
|
104
|
+
styleElement.classList.add("".concat(mdPrefix, "-").concat(node.type));
|
|
105
105
|
if (node.type === 'heading') {
|
|
106
|
-
styleElement.classList.add("".concat(mdPrefix, "heading-").concat(node.depth));
|
|
106
|
+
styleElement.classList.add("".concat(mdPrefix, "-heading-").concat(node.depth));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// 如果索引为 0,则父节点为块级元素,否则为前一个索引的 DOM 元素
|
|
@@ -130,7 +130,7 @@ export var editorRender = function editorRender(sourceCode) {
|
|
|
130
130
|
var createDelimiter = function createDelimiter(text) {
|
|
131
131
|
var temp = document.createElement('span');
|
|
132
132
|
temp.append(text);
|
|
133
|
-
temp.classList.add("".concat(mdPrefix, "delimiter"));
|
|
133
|
+
temp.classList.add("".concat(mdPrefix, "-delimiter"));
|
|
134
134
|
return temp;
|
|
135
135
|
};
|
|
136
136
|
|
|
@@ -269,6 +269,26 @@ var toHastProcessor = unified().use(remarkBreaks).use(remarkRehype, {
|
|
|
269
269
|
value: node.value
|
|
270
270
|
}) : h(node, 'div')
|
|
271
271
|
);
|
|
272
|
+
},
|
|
273
|
+
image: function image(h, node) {
|
|
274
|
+
try {
|
|
275
|
+
var _node$alt;
|
|
276
|
+
var styles = (_node$alt = node.alt) === null || _node$alt === void 0 ? void 0 : _node$alt.split(' ');
|
|
277
|
+
return h(node, 'img', {
|
|
278
|
+
src: node.url,
|
|
279
|
+
alt: styles === null || styles === void 0 ? void 0 : styles.filter(function (i) {
|
|
280
|
+
return !i.includes(':');
|
|
281
|
+
}).join(' '),
|
|
282
|
+
style: styles === null || styles === void 0 ? void 0 : styles.filter(function (i) {
|
|
283
|
+
return i.includes(':');
|
|
284
|
+
}).join(';')
|
|
285
|
+
});
|
|
286
|
+
} catch (_unused) {
|
|
287
|
+
return h(node, 'img', {
|
|
288
|
+
src: node.url,
|
|
289
|
+
alt: node.alt
|
|
290
|
+
});
|
|
291
|
+
}
|
|
272
292
|
}
|
|
273
293
|
}
|
|
274
294
|
}).use(rehypeMermaid, {
|
|
@@ -324,17 +344,6 @@ export var getDefaultSchema = function getDefaultSchema() {
|
|
|
324
344
|
tagNames: [].concat(_toConsumableArray((_defaultSchema$tagNam = defaultSchema.tagNames) !== null && _defaultSchema$tagNam !== void 0 ? _defaultSchema$tagNam : []), ['custom'])
|
|
325
345
|
});
|
|
326
346
|
};
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* 将 Hast 树转成新的 Hast 树
|
|
330
|
-
*
|
|
331
|
-
* @param root Hast 树
|
|
332
|
-
* @param schema 过滤模式
|
|
333
|
-
* @returns 新的 Hast 树
|
|
334
|
-
*/
|
|
335
|
-
export var viewerRender = function viewerRender(root, schema) {
|
|
336
|
-
return unified().use(rehypeRawPositions).use(rehypeRaw).use(rehypeMath).use(rehypeSanitize, schema).use(rehypeLine).runSync(root);
|
|
337
|
-
};
|
|
338
347
|
var Input = function Input(_ref2) {
|
|
339
348
|
var checked = _ref2.checked,
|
|
340
349
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -370,7 +379,7 @@ export var postViewerRender = function postViewerRender(root, options) {
|
|
|
370
379
|
jsxs: jsxs,
|
|
371
380
|
components: components
|
|
372
381
|
});
|
|
373
|
-
} catch (
|
|
382
|
+
} catch (_unused2) {
|
|
374
383
|
return jsx('div', {
|
|
375
384
|
style: {
|
|
376
385
|
fontStyle: 'italic',
|
|
@@ -430,13 +439,19 @@ var toMarkdownProcessor = unified().use(rehypeRemark, {
|
|
|
430
439
|
export var toMarkdown = function toMarkdown(sourceCode) {
|
|
431
440
|
return toMarkdownProcessor.stringify(toMarkdownProcessor.runSync(toHTMLProcessor.runSync(toHTMLProcessor.parse(sourceCode))));
|
|
432
441
|
};
|
|
433
|
-
|
|
434
442
|
/**
|
|
435
443
|
* 将 Markdown 文本转成纯文本
|
|
436
444
|
*
|
|
437
445
|
* @param sourceCode Markdown 文本
|
|
438
446
|
* @returns 纯文本
|
|
439
447
|
*/
|
|
440
|
-
export var toText = function toText(sourceCode) {
|
|
441
|
-
|
|
448
|
+
export var toText = function toText(sourceCode, options) {
|
|
449
|
+
var root = toMdastProcessor.parse(sourceCode);
|
|
450
|
+
if (options !== null && options !== void 0 && options.replaceImageAlt) {
|
|
451
|
+
// 遍历 Mdast 树的图片节点,替换 alt 文本
|
|
452
|
+
visit(root, 'image', function (node) {
|
|
453
|
+
node.alt = options.replaceImageAlt;
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return toString(root, options);
|
|
442
457
|
};
|
|
File without changes
|