@waline/client 2.4.1 → 2.5.1

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.
Files changed (51) hide show
  1. package/dist/component.esm.js +1 -1
  2. package/dist/component.esm.js.map +1 -1
  3. package/dist/component.js +1 -1
  4. package/dist/component.js.map +1 -1
  5. package/dist/legacy.d.ts +3 -1
  6. package/dist/legacy.js +1 -1
  7. package/dist/legacy.js.map +1 -1
  8. package/dist/pageview.cjs.js +1 -1
  9. package/dist/pageview.esm.js +1 -1
  10. package/dist/pageview.js +1 -1
  11. package/dist/shim.d.ts +3 -1
  12. package/dist/shim.esm.d.ts +3 -1
  13. package/dist/shim.esm.js +1 -1
  14. package/dist/shim.esm.js.map +1 -1
  15. package/dist/shim.js +1 -1
  16. package/dist/shim.js.map +1 -1
  17. package/dist/waline.cjs.d.ts +3 -1
  18. package/dist/waline.cjs.js +1 -1
  19. package/dist/waline.cjs.js.map +1 -1
  20. package/dist/waline.css +1 -1
  21. package/dist/waline.css.map +1 -1
  22. package/dist/waline.d.ts +3 -1
  23. package/dist/waline.esm.d.ts +3 -1
  24. package/dist/waline.esm.js +1 -1
  25. package/dist/waline.esm.js.map +1 -1
  26. package/dist/waline.js +1 -1
  27. package/dist/waline.js.map +1 -1
  28. package/package.json +11 -12
  29. package/src/components/CommentBox.vue +115 -4
  30. package/src/components/CommentCard.vue +1 -1
  31. package/src/components/Icons.ts +20 -0
  32. package/src/components/ImageWall.vue +152 -0
  33. package/src/composables/like.ts +1 -1
  34. package/src/config/i18n/en.ts +2 -0
  35. package/src/config/i18n/generate.ts +2 -0
  36. package/src/config/i18n/jp.ts +8 -0
  37. package/src/config/i18n/pt-BR.ts +8 -0
  38. package/src/config/i18n/ru.ts +8 -0
  39. package/src/config/i18n/vi-VN.ts +8 -0
  40. package/src/config/i18n/zh-CN.ts +2 -0
  41. package/src/config/i18n/zh-TW.ts +2 -0
  42. package/src/styles/card.scss +1 -0
  43. package/src/styles/emoji.scss +92 -94
  44. package/src/styles/gif.scss +70 -0
  45. package/src/styles/index.scss +3 -0
  46. package/src/styles/panel.scss +0 -4
  47. package/src/typings/locale.ts +2 -0
  48. package/src/typings/waline.ts +1 -1
  49. package/src/utils/fetchGif.ts +63 -0
  50. package/src/utils/index.ts +2 -0
  51. package/src/utils/throttle.ts +15 -0
@@ -1,118 +1,116 @@
1
- @mixin emoji() {
2
- .wl-emoji-popup {
3
- position: absolute;
4
- top: 100%;
5
- left: 1.25em;
6
- z-index: 10;
7
-
8
- max-width: 526px;
9
- border: var(--waline-border);
10
- border-radius: 6px;
11
-
12
- background: var(--waline-bgcolor);
13
- box-shadow: var(--waline-box-shadow);
14
-
15
- opacity: 0;
16
- visibility: hidden;
17
-
18
- transition: transform 0.2s ease-out, opacity 0.2s ease-out;
19
- transform: scale(0.9, 0.9);
20
- transform-origin: 0 0;
21
-
22
- &.display {
23
- opacity: 1;
24
- visibility: visible;
25
- transform: none;
26
- }
1
+ .wl-emoji-popup {
2
+ position: absolute;
3
+ top: 100%;
4
+ left: 1.25em;
5
+ z-index: 10;
6
+
7
+ max-width: 526px;
8
+ border: var(--waline-border);
9
+ border-radius: 6px;
10
+
11
+ background: var(--waline-bgcolor);
12
+ box-shadow: var(--waline-box-shadow);
13
+
14
+ opacity: 0;
15
+ visibility: hidden;
16
+
17
+ transition: transform 0.2s ease-out, opacity 0.2s ease-out;
18
+ transform: scale(0.9, 0.9);
19
+ transform-origin: 0 0;
20
+
21
+ &.display {
22
+ opacity: 1;
23
+ visibility: visible;
24
+ transform: none;
25
+ }
26
+
27
+ button {
28
+ display: inline-block;
29
+ vertical-align: middle;
30
+
31
+ width: 2em;
32
+ margin: 0.125em;
33
+ padding: 0;
34
+ border-width: 0;
35
+
36
+ background: transparent;
27
37
 
28
- button {
29
- display: inline-block;
30
- vertical-align: middle;
38
+ font-size: inherit;
39
+ line-height: 2;
40
+ text-align: center;
31
41
 
32
- width: 2em;
33
- margin: 0.125em;
34
- padding: 0;
35
- border-width: 0;
42
+ cursor: pointer;
36
43
 
37
- background: transparent;
44
+ &:hover {
45
+ background: var(--waline-bgcolor-hover);
46
+ }
47
+ }
38
48
 
39
- font-size: inherit;
40
- line-height: 2;
41
- text-align: center;
49
+ .wl-emoji {
50
+ display: inline-block;
51
+ vertical-align: middle;
52
+ max-width: 1.5em;
53
+ max-height: 1.5em;
54
+ }
42
55
 
43
- cursor: pointer;
56
+ .wl-tab-wrapper {
57
+ overflow-y: auto;
58
+ max-height: 145px;
59
+ padding: 0.5em;
44
60
 
45
- &:hover {
46
- background: var(--waline-bgcolor-hover);
47
- }
61
+ &::-webkit-scrollbar {
62
+ width: 6px;
63
+ height: 6px;
48
64
  }
49
65
 
50
- .wl-emoji {
51
- display: inline-block;
52
- vertical-align: middle;
53
- max-width: 1.5em;
54
- max-height: 1.5em;
66
+ &::-webkit-scrollbar-track-piece:vertical {
67
+ -webkit-border-radius: 6px;
68
+ border-radius: 6px;
69
+ background: rgb(0 0 0 / 10%);
55
70
  }
56
71
 
57
- .wl-tab-wrapper {
58
- overflow-y: auto;
59
- max-height: 145px;
60
- padding: 0.5em;
61
-
62
- &::-webkit-scrollbar {
63
- width: 6px;
64
- height: 6px;
65
- }
66
-
67
- &::-webkit-scrollbar-track-piece:vertical {
68
- -webkit-border-radius: 6px;
69
- border-radius: 6px;
70
- background: rgb(0 0 0 / 10%);
71
- }
72
-
73
- &::-webkit-scrollbar-thumb:vertical {
74
- width: 6px;
75
- -webkit-border-radius: 6px;
76
- border-radius: 6px;
77
- background: var(--waline-theme-color);
78
- }
72
+ &::-webkit-scrollbar-thumb:vertical {
73
+ width: 6px;
74
+ -webkit-border-radius: 6px;
75
+ border-radius: 6px;
76
+ background: var(--waline-theme-color);
79
77
  }
78
+ }
80
79
 
81
- .wl-tabs {
82
- position: relative;
83
- height: 2em;
84
- padding: 0 6px 1px;
80
+ .wl-tabs {
81
+ position: relative;
82
+ height: 2em;
83
+ padding: 0 6px 1px;
85
84
 
86
- &::before {
87
- content: ' ';
85
+ &::before {
86
+ content: ' ';
88
87
 
89
- position: absolute;
90
- top: 0;
91
- right: 0;
92
- left: 0;
93
- z-index: 2;
88
+ position: absolute;
89
+ top: 0;
90
+ right: 0;
91
+ left: 0;
92
+ z-index: 2;
94
93
 
95
- height: 1px;
94
+ height: 1px;
96
95
 
97
- background: var(--waline-border-color);
98
- }
96
+ background: var(--waline-border-color);
99
97
  }
98
+ }
100
99
 
101
- .wl-tab {
102
- position: relative;
103
- margin: 0;
104
- padding: 0 0.5em;
100
+ .wl-tab {
101
+ position: relative;
102
+ margin: 0;
103
+ padding: 0 0.5em;
105
104
 
106
- &.active {
107
- z-index: 3;
105
+ &.active {
106
+ z-index: 3;
108
107
 
109
- border: 1px solid var(--waline-border-color);
110
- border-top-width: 0;
111
- border-bottom-right-radius: 6px;
112
- border-bottom-left-radius: 6px;
108
+ border: 1px solid var(--waline-border-color);
109
+ border-top-width: 0;
110
+ border-bottom-right-radius: 6px;
111
+ border-bottom-left-radius: 6px;
113
112
 
114
- background: var(--waline-bgcolor);
115
- }
113
+ background: var(--waline-bgcolor);
116
114
  }
117
115
  }
118
116
  }
@@ -0,0 +1,70 @@
1
+ .wl-gif-popup {
2
+ position: absolute;
3
+ top: 100%;
4
+ left: 1.25em;
5
+ z-index: 10;
6
+
7
+ width: calc(100% - 3em);
8
+ padding: 0.75em 0.75em 0.25em;
9
+ border: var(--waline-border);
10
+ border-radius: 6px;
11
+
12
+ background: var(--waline-bgcolor);
13
+ box-shadow: var(--waline-box-shadow);
14
+
15
+ opacity: 0;
16
+ visibility: hidden;
17
+
18
+ transition: transform 0.2s ease-out, opacity 0.2s ease-out;
19
+ transform: scale(0.9, 0.9);
20
+ transform-origin: 0 0;
21
+
22
+ &.display {
23
+ opacity: 1;
24
+ visibility: visible;
25
+ transform: none;
26
+ }
27
+
28
+ input {
29
+ box-sizing: border-box;
30
+
31
+ width: 100%;
32
+ margin-bottom: 10px;
33
+ padding: 3px 5px;
34
+ border: var(--waline-border);
35
+ }
36
+
37
+ img {
38
+ display: block;
39
+
40
+ box-sizing: border-box;
41
+
42
+ width: 100%;
43
+ border-width: 2px;
44
+ border-style: solid;
45
+ border-color: #fff;
46
+
47
+ cursor: pointer;
48
+
49
+ &:hover {
50
+ border-color: var(--waline-theme-color);
51
+ border-radius: 2px;
52
+ }
53
+ }
54
+ }
55
+
56
+ .wl-gallery {
57
+ max-height: 80vh;
58
+ display: flex;
59
+ overflow-y: auto;
60
+ }
61
+
62
+ .wl-gallery-column {
63
+ height: -webkit-max-content;
64
+ height: -moz-max-content;
65
+ height: max-content;
66
+
67
+ flex: 1;
68
+ display: flex;
69
+ flex-direction: column;
70
+ }
@@ -4,6 +4,9 @@
4
4
  @use 'base';
5
5
 
6
6
  @use 'panel';
7
+ @use 'emoji';
8
+ @use 'gif';
9
+
7
10
  @use 'card';
8
11
  @use 'layout';
9
12
 
@@ -1,5 +1,3 @@
1
- @use 'emoji';
2
-
3
1
  .wl-comment {
4
2
  position: relative;
5
3
  display: flex;
@@ -286,5 +284,3 @@
286
284
  }
287
285
  }
288
286
  }
289
-
290
- @include emoji.emoji;
@@ -36,4 +36,6 @@ export interface WalineLocale extends WalineDateLocale, WalineLevelLocale {
36
36
  word: string;
37
37
  wordHint: string;
38
38
  anonymous: string;
39
+ gif: string;
40
+ gifSearchPlaceholder: string;
39
41
  }
@@ -144,7 +144,7 @@ export interface WalineProps {
144
144
  *
145
145
  * Set Emojis
146
146
  *
147
- * @default ['https://cdn.jsdelivr.net/gh/walinejs/emojis/weibo']
147
+ * @default ['//unpkg.com/@waline/emojis@1.0.1/weibo']
148
148
  */
149
149
  emoji?: (string | WalineEmojiInfo)[] | false;
150
150
 
@@ -0,0 +1,63 @@
1
+ export type GifFormat =
2
+ | 'gif'
3
+ | 'mediumgif'
4
+ | 'tinygif'
5
+ | 'nanogif'
6
+ | 'mp4'
7
+ | 'loopedmp4'
8
+ | 'tinymp4'
9
+ | 'nanomp4'
10
+ | 'webm'
11
+ | 'tinywebm'
12
+ | 'nanowebm';
13
+ export interface MediaObject {
14
+ preview: string;
15
+ url: string;
16
+ dims: number[];
17
+ size: number;
18
+ }
19
+
20
+ export interface FetchGifRequest {
21
+ key?: string;
22
+ keyword: string;
23
+ pos?: string;
24
+ limit?: number;
25
+ }
26
+
27
+ export interface GifObject {
28
+ created: number;
29
+ hasaudio: boolean;
30
+ id: string;
31
+ media: Record<GifFormat, MediaObject>[];
32
+ tags: string[];
33
+ title: string;
34
+ itemurl: string;
35
+ hascaption: boolean;
36
+ url: string;
37
+ }
38
+
39
+ export interface FetchGifResponse {
40
+ next: string;
41
+ results: GifObject[];
42
+ }
43
+
44
+ export const fetchGif = ({
45
+ key,
46
+ keyword,
47
+ pos,
48
+ limit,
49
+ }: FetchGifRequest): Promise<FetchGifResponse> => {
50
+ const baseUrl = `https://g.tenor.com/v1/search`;
51
+ const query = new URLSearchParams('media_filter=minimal');
52
+ query.set('key', key || 'PAY5JLFIH6V6');
53
+ query.set('limit', (limit || 20).toString());
54
+ query.set('pos', pos || '');
55
+ query.set('q', keyword);
56
+
57
+ return fetch(`${baseUrl}?${query.toString()}`, {
58
+ headers: {
59
+ // eslint-disable-next-line @typescript-eslint/naming-convention
60
+ 'Content-Type': 'application/json',
61
+ },
62
+ }).then((resp) => resp.json() as Promise<FetchGifResponse>);
63
+ };
@@ -10,3 +10,5 @@ export * from './markdown';
10
10
  export * from './path';
11
11
  export * from './query';
12
12
  export * from './wordCount';
13
+ export * from './fetchGif';
14
+ export * from './throttle';
@@ -0,0 +1,15 @@
1
+ export const throttle = (
2
+ func: (...args: any[]) => void,
3
+ timeout = 300
4
+ ): ((...args: []) => void) => {
5
+ let timer: number | null;
6
+
7
+ return (...args: []): void => {
8
+ if (timer) clearTimeout(timer);
9
+
10
+ timer = window.setTimeout(() => {
11
+ func(...args);
12
+ timer = null;
13
+ }, timeout);
14
+ };
15
+ };