@waline/client 2.14.3 → 2.14.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/client",
3
- "version": "2.14.3",
3
+ "version": "2.14.5",
4
4
  "description": "client for waline comment system",
5
5
  "keywords": [
6
6
  "valine",
@@ -93,16 +93,6 @@
93
93
  "dist",
94
94
  "src"
95
95
  ],
96
- "scripts": {
97
- "build": "pnpm rollup && pnpm style",
98
- "clean": "rimraf ./dist",
99
- "dev": "vite",
100
- "prepublishOnly": "pnpm clean && pnpm build",
101
- "rollup": "rollup -c",
102
- "style": "pnpm style:main && pnpm style:meta",
103
- "style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
104
- "style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
105
- },
106
96
  "browserslist": {
107
97
  "production": [
108
98
  ">0.5%",
@@ -119,7 +109,7 @@
119
109
  ]
120
110
  },
121
111
  "dependencies": {
122
- "@vueuse/core": "^9.8.2",
112
+ "@vueuse/core": "^9.10.0",
123
113
  "autosize": "^5.0.2",
124
114
  "marked": "^4.2.5",
125
115
  "vue": "^3.2.45"
@@ -135,17 +125,26 @@
135
125
  "@rollup/plugin-terser": "0.2.1",
136
126
  "@types/autosize": "4.0.1",
137
127
  "@types/marked": "4.0.8",
138
- "@types/node": "18.11.17",
128
+ "@types/node": "18.11.18",
139
129
  "@vitejs/plugin-vue": "4.0.0",
140
130
  "recaptcha-v3": "1.10.0",
141
131
  "rimraf": "3.0.2",
142
- "rollup": "3.8.1",
143
- "rollup-plugin-dts": "5.0.0",
132
+ "rollup": "3.9.1",
133
+ "rollup-plugin-dts": "5.1.0",
144
134
  "rollup-plugin-ts": "3.0.2",
145
135
  "typescript": "4.9.4",
146
- "vite": "4.0.3"
136
+ "vite": "4.0.4"
147
137
  },
148
138
  "engines": {
149
139
  "node": ">=14"
140
+ },
141
+ "scripts": {
142
+ "build": "pnpm rollup && pnpm style",
143
+ "clean": "rimraf ./dist",
144
+ "dev": "vite",
145
+ "rollup": "rollup -c",
146
+ "style": "pnpm style:main && pnpm style:meta",
147
+ "style:main": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed",
148
+ "style:meta": "sass ./src/styles/meta.scss ./dist/waline-meta.css --style=compressed"
150
149
  }
151
- }
150
+ }
@@ -1,31 +1,24 @@
1
1
  <template>
2
2
  <div v-if="reactionsInfo.length" class="wl-reaction">
3
- <h4 v-text="locale.reactionTitle" />
3
+ <div class="reaction-title" v-text="locale.reactionTitle" />
4
4
 
5
- <ul class="wl-reaction-list">
5
+ <ul class="reaction-list">
6
6
  <li
7
7
  v-for="({ active, icon, desc }, index) in reactionsInfo"
8
8
  :key="index"
9
- class="wl-reaction-item"
9
+ class="reaction-item"
10
10
  :class="{ active }"
11
11
  @click="vote(index)"
12
12
  >
13
- <div class="wl-reaction-img">
13
+ <div class="reaction-img">
14
14
  <img :src="icon" :alt="desc" />
15
15
 
16
- <LoadingIcon
17
- v-if="votingIndex === index"
18
- class="wl-reaction-loading"
19
- />
16
+ <LoadingIcon v-if="votingIndex === index" class="reaction-loading" />
20
17
 
21
- <div
22
- v-else
23
- class="wl-reaction-votes"
24
- v-text="voteNumbers[index] || 0"
25
- />
18
+ <div v-else class="reaction-votes" v-text="voteNumbers[index] || 0" />
26
19
  </div>
27
20
 
28
- <div class="wl-reaction-text" v-text="desc" />
21
+ <div class="reaction-text" v-text="desc" />
29
22
  </li>
30
23
  </ul>
31
24
  </div>
@@ -84,7 +84,10 @@
84
84
  </template>
85
85
 
86
86
  <script setup lang="ts">
87
+ /* eslint-disable vue/define-props-declaration */
87
88
  /* eslint-disable vue/no-unused-properties */
89
+ /* eslint-disable vue/require-prop-comment */
90
+ /* eslint-disable vue/require-prop-types */
88
91
  import { useStyleTag } from '@vueuse/core';
89
92
  import { computed, onMounted, onUnmounted, provide, ref, watch } from 'vue';
90
93
  import Reaction from './ArticleReaction.vue';
@@ -98,372 +101,34 @@ import { version } from '../version.js';
98
101
 
99
102
  import type {
100
103
  WalineComment,
104
+ WalineCommentSorting,
101
105
  WalineCommentStatus,
102
- WalineLocale,
106
+ WalineProps,
103
107
  } from '../typings/index.js';
104
108
 
105
109
  type SortKey = 'insertedAt_desc' | 'insertedAt_asc' | 'like_desc';
106
110
 
107
- // TODO: Currently complex types and type imports from other files are not supported. It is possible to support type imports in the future.
108
- // @see https://vuejs.org/api/sfc-script-setup.html#typescript-only-features
109
- // this issue may be addressed in Vue3.3
110
- // the following line is the same as WalineProps
111
-
112
- type WalineCommentSorting = 'latest' | 'oldest' | 'hottest';
113
-
114
- type WalineEmojiPresets =
115
- | `//${string}`
116
- | `http://${string}`
117
- | `https://${string}`;
118
-
119
- interface WalineEmojiInfo {
120
- /**
121
- * 选项卡上的 Emoji 名称
122
- *
123
- * Emoji name show on tab
124
- */
125
- name: string;
126
- /**
127
- * 所在文件夹链接
128
- *
129
- * Current folder link
130
- */
131
- folder?: string;
132
- /**
133
- * Emoji 通用路径前缀
134
- *
135
- * Common prefix of Emoji icons
136
- */
137
- prefix?: string;
138
- /**
139
- * Emoji 图片的类型,会作为文件扩展名使用
140
- *
141
- * Type of Emoji icons, will be regarded as file extension
142
- */
143
- type?: string;
144
- /**
145
- * 选项卡显示的 Emoji 图标
146
- *
147
- * Emoji icon show on tab
148
- */
149
- icon: string;
150
- /**
151
- * Emoji 图片列表
152
- *
153
- * Emoji image list
154
- */
155
- items: string[];
156
- }
157
-
158
- type WalineLoginStatus = 'enable' | 'disable' | 'force';
159
-
160
- interface WalineSearchImageData extends Record<string, unknown> {
161
- /**
162
- * 图片链接
163
- *
164
- * Image link
165
- */
166
- src: string;
167
-
168
- /**
169
- * 图片标题
170
- *
171
- * @description 用于图片的 alt 属性
172
- *
173
- * Image title
174
- *
175
- * @description Used for alt attribute of image
176
- */
177
- title?: string;
178
-
179
- /**
180
- * 图片缩略图
181
- *
182
- * @description 为了更好的加载性能,我们会优先在列表中使用此缩略图
183
- *
184
- * Image preview link
185
- *
186
- * @description For better loading performance, we will use this thumbnail first in the list
187
- *
188
- * @default src
189
- */
190
- preview?: string;
191
- }
192
-
193
- type WalineSearchResult = WalineSearchImageData[];
194
-
195
- interface WalineSearchOptions {
196
- /**
197
- * 搜索操作
198
- *
199
- * Search action
200
- */
201
- search: (word: string) => Promise<WalineSearchResult>;
202
-
203
- /**
204
- * 打开列表时展示的默认结果
205
- *
206
- * Default result when opening list
207
- *
208
- * @default () => search('')
209
- */
210
- default?: () => Promise<WalineSearchResult>;
211
-
212
- /**
213
- * 获取更多的操作
214
- *
215
- * @description 会在列表滚动到底部时触发,如果你的搜索服务支持分页功能,你应该设置此项实现无限滚动
216
- *
217
- * Fetch more action
218
- *
219
- * @description It will be triggered when the list scrolls to the bottom. If your search service supports paging, you should set this to achieve infinite scrolling
220
- *
221
- * @default (word) => search(word)
222
- */
223
- more?: (word: string, currentCount: number) => Promise<WalineSearchResult>;
224
- }
225
-
226
- type WalineMeta = 'nick' | 'mail' | 'link';
227
-
228
- type WalineImageUploader = (image: File) => Promise<string>;
229
-
230
- type WalineHighlighter = (code: string, lang: string) => string;
231
-
232
- type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
233
-
234
- const props = defineProps<{
235
- /**
236
- * Waline 的服务端地址
237
- *
238
- * Waline server address url
239
- */
240
- serverURL: string;
241
-
242
- /**
243
- * 当前 _文章页_ 路径,用于区分不同的 _文章页_ ,以保证正确读取该 _文章页_ 下的评论列表
244
- *
245
- * 你可以将其设置为 `window.location.pathname`
246
- *
247
- * Article path id. Used to distinguish different _article pages_ to ensure loading the correct comment list under the _article page_.
248
- *
249
- * You can set it to `window.location.pathname`
250
- */
251
- path: string;
252
-
253
- /**
254
- * 评论者相关属性
255
- *
256
- * `Meta` 可选值: `'nick'`, `'mail'`, `'link'`
257
- *
258
- * Reviewer attributes.
259
- *
260
- * Optional values for `Meta`: `'nick'`, `'mail'`, `'link'`
261
- *
262
- * @default ['nick', 'mail', 'link']
263
- */
264
- meta?: WalineMeta[];
265
-
266
- /**
267
- * 设置**必填项**,默认昵称为匿名
268
- *
269
- * Set required fields, default anonymous with nickname
270
- *
271
- * @default []
272
- */
273
- requiredMeta?: WalineMeta[];
274
-
275
- /**
276
- * 评论字数限制。填入单个数字时为最大字数限制
277
- *
278
- * @more 设置为 `0` 时无限制
279
- *
280
- * Comment word s limit. When a single number is filled in, it 's the maximum number of comment words.
281
- *
282
- * @more No limit when set to `0`.
283
- *
284
- * @default 0
285
- */
286
- wordLimit?: number | [number, number];
287
-
288
- /**
289
- * 评论列表分页,每页条数
290
- *
291
- * number of pages per page
292
- *
293
- * @default 10
294
- */
295
- pageSize?: number;
296
-
297
- /**
298
- * Waline 显示语言
299
- *
300
- * 可选值:
301
- *
302
- * - `'zh'`
303
- * - `'zh-cn'`
304
- * - `'zh-CN'`
305
- * - `'zh-tw'`
306
- * - `'zh-TW'`
307
- * - `'en'`
308
- * - `'en-US'`
309
- * - `'en-us'`
310
- * - `'jp'`
311
- * - `'jp-jp'`
312
- * - `'jp-JP'`
313
- * - `'pt-br'`
314
- * - `'pt-BR'`
315
- * - `'ru'`
316
- * - `'ru-ru'`
317
- * - `'ru-RU'`
318
- *
319
- * Display language for waline
320
- *
321
- * Optional value:
322
- *
323
- * - `'zh'`
324
- * - `'zh-cn'`
325
- * - `'zh-CN'`
326
- * - `'zh-tw'`
327
- * - `'zh-TW'`
328
- * - `'en'`
329
- * - `'en-US'`
330
- * - `'en-us'`
331
- * - `'jp'`
332
- * - `'jp-jp'`
333
- * - `'jp-JP'`
334
- * - `'pt-br'`
335
- * - `'pt-BR'`
336
- * - `'ru'`
337
- * - `'ru-ru'`
338
- * - `'ru-RU'`
339
- *
340
- * @default 'zh-CN'
341
- */
342
- lang?: string;
343
-
344
- /**
345
- * 自定义 waline 语言显示
346
- *
347
- * @see [自定义语言](https://waline.js.org/client/i18n.html)
348
- *
349
- * Custom display language in waline
350
- *
351
- * @see [I18n](https://waline.js.org/en/client/i18n.html)
352
- */
353
- locale?: Partial<WalineLocale>;
354
-
355
- /**
356
- * 评论列表排序方式
357
- *
358
- * Sorting method for comment list
359
- *
360
- * @default 'latest'
361
- */
362
- commentSorting?: WalineCommentSorting;
363
-
364
- /**
365
- * 是否启用暗黑模式适配
366
- *
367
- * @more 设置 `'auto'` 会根据设备暗黑模式自适应。填入 CSS 选择器会在对应选择器生效时启用夜间模式。
368
- *
369
- * Whether to enable darkmode support
370
- *
371
- * @more Setting `'auto'` will display darkmode due to device settings. Filling in CSS selector will enable darkmode only when the selector match waline ancestor nodes.
372
- */
373
- dark?: string | boolean;
374
-
375
- /**
376
- * 设置表情包
377
- *
378
- * Set Emojis
379
- *
380
- * @default ['//unpkg.com/@waline/emojis@1.1.0/weibo']
381
- */
382
- emoji?: (WalineEmojiInfo | WalineEmojiPresets)[] | boolean;
383
-
384
- /**
385
- * 设置搜索功能
386
- *
387
- * Customize Search feature
388
- *
389
- * @default true
390
- */
391
- search?: WalineSearchOptions | boolean;
392
-
393
- /**
394
- * 代码高亮
395
- *
396
- * Code highlighting
397
- *
398
- * @default true
399
- */
400
-
401
- highlighter?: WalineHighlighter | boolean;
402
-
403
- /**
404
- * 自定义图片上传方法,方便更好的存储图片
405
- *
406
- * 方法执行时会将图片对象传入。
407
- *
408
- * Custom image upload callback to manage picture by yourself.
409
- *
410
- * We will pass a picture file object when execute it.
411
- *
412
- * @default true
413
- */
414
-
415
- imageUploader?: WalineImageUploader | boolean;
416
-
417
- /**
418
- * 自定义数学公式处理方法,用于预览。
419
- *
420
- * Custom math formula parse callback for preview.
421
- *
422
- * @default true
423
- */
424
- texRenderer?: WalineTexRenderer | boolean;
425
-
426
- /**
427
- *
428
- * 登录模式状态,可选值:
429
- *
430
- * - `'enable'`: 启用登录 (默认)
431
- * - `'disable'`: 禁用登录,用户只能填写信息评论
432
- * - `'force'`: 强制登录,用户必须注册并登录才可发布评论
433
- *
434
- * Login mode status, optional values:
435
- *
436
- * - `'enable'`: enable login (default)
437
- * - `'disable'`: Login is disabled, users should fill in information to comment
438
- * - `'force'`: Forced login, users must login to comment
439
- *
440
- * @default 'enable'
441
- */
442
- login?: WalineLoginStatus;
443
-
444
- /**
445
- * 是否在页脚展示版权信息
446
- *
447
- * 为了支持 Waline,我们强烈建议你开启它
448
- *
449
- * Whether show copyright in footer
450
- *
451
- * We strongly recommended you to keep it on to support waline
452
- *
453
- * @default true
454
- */
455
- copyright?: boolean;
456
-
457
- /**
458
- * recaptcha v3 client key
459
- */
460
- recaptchaV3Key?: string;
461
-
462
- /**
463
- * reaction
464
- */
465
- reaction?: string[] | boolean;
466
- }>();
111
+ const props = defineProps([
112
+ 'serverURL',
113
+ 'path',
114
+ 'meta',
115
+ 'requiredMeta',
116
+ 'dark',
117
+ 'commentSorting',
118
+ 'lang',
119
+ 'locale',
120
+ 'pageSize',
121
+ 'wordLimit',
122
+ 'emoji',
123
+ 'login',
124
+ 'highlighter',
125
+ 'texRenderer',
126
+ 'imageUploader',
127
+ 'search',
128
+ 'copyright',
129
+ 'recaptchaV3Key',
130
+ 'reaction',
131
+ ]);
467
132
 
468
133
  const sortKeyMap: Record<WalineCommentSorting, SortKey> = {
469
134
  latest: 'insertedAt_desc',
@@ -481,7 +146,7 @@ const count = ref(0);
481
146
  const page = ref(1);
482
147
  const totalPages = ref(0);
483
148
 
484
- const config = computed(() => getConfig(props));
149
+ const config = computed(() => getConfig(props as WalineProps));
485
150
 
486
151
  // eslint-disable-next-line vue/no-ref-object-destructure
487
152
  const commentSorting = ref(config.value.commentSorting);
@@ -674,6 +339,7 @@ provide('config', config);
674
339
 
675
340
  onMounted(() => {
676
341
  watch(
342
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
677
343
  () => [props.serverURL, props.path],
678
344
  () => refresh(),
679
345
  { immediate: true }
@@ -11,7 +11,7 @@
11
11
 
12
12
  .wl-card {
13
13
  .wl-item {
14
- padding-right: 0;
14
+ padding-inline-end: 0;
15
15
  }
16
16
  }
17
17
 
@@ -19,7 +19,7 @@
19
19
  --avatar-size: var(--waline-avatar-size);
20
20
 
21
21
  position: relative;
22
- margin-right: 0.75em;
22
+ margin-inline-end: 0.75em;
23
23
 
24
24
  @media (max-width: 720px) {
25
25
  --avatar-size: var(--waline-m-avatar-size);
@@ -35,7 +35,7 @@
35
35
  .verified-icon {
36
36
  position: absolute;
37
37
  top: calc(var(--avatar-size) * 3 / 4);
38
- left: calc(var(--avatar-size) * 3 / 4);
38
+ inset-inline-start: calc(var(--avatar-size) * 3 / 4);
39
39
 
40
40
  border-radius: 50%;
41
41
 
@@ -52,7 +52,7 @@
52
52
  border-bottom: 1px dashed var(--waline-border-color);
53
53
 
54
54
  &:first-child {
55
- margin-left: 1em;
55
+ margin-inline-start: 1em;
56
56
  }
57
57
 
58
58
  .wl-head {
@@ -65,7 +65,7 @@
65
65
 
66
66
  display: inline-block;
67
67
 
68
- margin-right: 0.5em;
68
+ margin-inline-end: 0.5em;
69
69
 
70
70
  font-weight: bold;
71
71
  font-size: 0.875em;
@@ -86,7 +86,7 @@
86
86
  .wl-badge {
87
87
  display: inline-block;
88
88
 
89
- margin-right: 1em;
89
+ margin-inline-end: 1em;
90
90
  padding: 0 0.3em;
91
91
  border: 1px solid var(--waline-badge-color);
92
92
  border-radius: 4px;
@@ -97,7 +97,7 @@
97
97
  }
98
98
 
99
99
  .wl-time {
100
- margin-right: 0.875em;
100
+ margin-inline-end: 0.875em;
101
101
  color: var(--waline-info-color);
102
102
  font-size: 0.75em;
103
103
  }
@@ -109,7 +109,7 @@
109
109
  > span {
110
110
  display: inline-block;
111
111
 
112
- margin-right: 0.25em;
112
+ margin-inline-end: 0.25em;
113
113
  padding: 2px 4px;
114
114
  border-radius: 0.2em;
115
115
 
@@ -128,6 +128,10 @@
128
128
  .wl-comment-actions {
129
129
  float: right;
130
130
  line-height: 1;
131
+
132
+ [dir='rtl'] & {
133
+ float: left;
134
+ }
131
135
  }
132
136
 
133
137
  .wl-delete,
@@ -179,7 +183,7 @@
179
183
  position: absolute;
180
184
  top: 0;
181
185
  bottom: 3.15em;
182
- left: 0;
186
+ inset-inline-start: 0;
183
187
  z-index: 999;
184
188
 
185
189
  display: block;
@@ -194,7 +198,7 @@
194
198
 
195
199
  position: absolute;
196
200
  bottom: 0;
197
- left: 0;
201
+ inset-inline-start: 0;
198
202
  z-index: 999;
199
203
 
200
204
  display: block;
@@ -232,19 +236,19 @@
232
236
  border-radius: 0;
233
237
 
234
238
  &:first-child {
235
- border-right: 0;
239
+ border-inline-end: 0;
236
240
  border-radius: 0.5em 0 0 0.5em;
237
241
  }
238
242
 
239
243
  &:last-child {
240
- border-left: 0;
244
+ border-inline-start: 0;
241
245
  border-radius: 0 0.5em 0.5em 0;
242
246
  }
243
247
  }
244
248
  }
245
249
 
246
250
  .wl-quote {
247
- border-left: 1px dashed rgb(237 237 237 / 50%);
251
+ border-inline-start: 1px dashed rgb(237 237 237 / 50%);
248
252
 
249
253
  .wl-user {
250
254
  --avatar-size: var(--waline-m-avatar-size);
@@ -1,7 +1,7 @@
1
1
  .wl-emoji-popup {
2
2
  position: absolute;
3
3
  top: 100%;
4
- left: 1.25em;
4
+ inset-inline-start: 1.25em;
5
5
  z-index: 10;
6
6
 
7
7
  max-width: 526px;
@@ -1,7 +1,7 @@
1
1
  .wl-gif-popup {
2
2
  position: absolute;
3
3
  top: 100%;
4
- left: 1.25em;
4
+ inset-inline-start: 1.25em;
5
5
  z-index: 10;
6
6
 
7
7
  width: calc(100% - 3em);
@@ -13,6 +13,7 @@
13
13
  line-height: 1.4;
14
14
 
15
15
  code {
16
+ direction: ltr;
16
17
  padding: 0;
17
18
  border-radius: 0;
18
19
  background: transparent !important;