@waline/client 2.4.0 → 2.5.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.
Files changed (53) 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 +19 -4
  29. package/src/components/CommentBox.vue +123 -0
  30. package/src/components/CommentCard.vue +26 -23
  31. package/src/components/Icons.ts +20 -0
  32. package/src/components/Waline.vue +34 -12
  33. package/src/composables/index.ts +1 -1
  34. package/src/composables/{likeStorage.ts → like.ts} +4 -1
  35. package/src/composables/userInfo.ts +7 -1
  36. package/src/config/i18n/en.ts +2 -0
  37. package/src/config/i18n/generate.ts +2 -0
  38. package/src/config/i18n/jp.ts +8 -0
  39. package/src/config/i18n/pt-BR.ts +8 -0
  40. package/src/config/i18n/ru.ts +8 -0
  41. package/src/config/i18n/vi-VN.ts +8 -0
  42. package/src/config/i18n/zh-CN.ts +2 -0
  43. package/src/config/i18n/zh-TW.ts +2 -0
  44. package/src/init.ts +7 -2
  45. package/src/styles/card.scss +35 -30
  46. package/src/styles/gif.scss +151 -0
  47. package/src/styles/nomalize.scss +0 -1
  48. package/src/styles/panel.scss +2 -1
  49. package/src/typings/locale.ts +2 -0
  50. package/src/typings/waline.ts +1 -1
  51. package/src/utils/fetchGif.ts +62 -0
  52. package/src/utils/index.ts +2 -0
  53. package/src/utils/throttle.ts +16 -0
@@ -0,0 +1,151 @@
1
+ @mixin gif() {
2
+ .wl-gif-popup {
3
+ position: absolute;
4
+ top: 100%;
5
+ left: 1.25em;
6
+ z-index: 10;
7
+
8
+ width: 436px;
9
+ padding: 12px 12px 4px;
10
+ border: var(--waline-border);
11
+ border-radius: 6px;
12
+
13
+ background: var(--waline-bgcolor);
14
+ box-shadow: var(--waline-box-shadow);
15
+
16
+ opacity: 0;
17
+ visibility: hidden;
18
+
19
+ transition: transform 0.2s ease-out, opacity 0.2s ease-out;
20
+ transform: scale(0.9, 0.9);
21
+ transform-origin: 0 0;
22
+
23
+ &.display {
24
+ opacity: 1;
25
+ visibility: visible;
26
+ transform: none;
27
+ }
28
+
29
+ input {
30
+ box-sizing: border-box;
31
+
32
+ width: 100%;
33
+ margin-bottom: 10px;
34
+ padding: 3px 5px;
35
+ border: var(--waline-border);
36
+ }
37
+
38
+ img {
39
+ display: block;
40
+
41
+ box-sizing: border-box;
42
+
43
+ width: 100%;
44
+ border-width: 2px;
45
+ border-style: solid;
46
+ border-color: #fff;
47
+
48
+ cursor: pointer;
49
+
50
+ &:hover {
51
+ border-color: var(--waline-theme-color);
52
+ border-radius: 2px;
53
+ }
54
+ }
55
+
56
+ .wl-gif-waterfall {
57
+ overflow-y: auto;
58
+ max-height: 800px;
59
+ }
60
+
61
+ button {
62
+ display: inline-block;
63
+ vertical-align: middle;
64
+
65
+ width: 2em;
66
+ margin: 0.125em;
67
+ padding: 0;
68
+ border-width: 0;
69
+
70
+ background: transparent;
71
+
72
+ font-size: inherit;
73
+ line-height: 2;
74
+ text-align: center;
75
+
76
+ cursor: pointer;
77
+
78
+ &:hover {
79
+ background: var(--waline-bgcolor-hover);
80
+ }
81
+ }
82
+
83
+ .wl-gif {
84
+ display: inline-block;
85
+ vertical-align: middle;
86
+ max-width: 1.5em;
87
+ max-height: 1.5em;
88
+ }
89
+
90
+ .wl-tab-wrapper {
91
+ overflow-y: auto;
92
+ max-height: 145px;
93
+ padding: 0.5em;
94
+
95
+ &::-webkit-scrollbar {
96
+ width: 6px;
97
+ height: 6px;
98
+ }
99
+
100
+ &::-webkit-scrollbar-track-piece:vertical {
101
+ -webkit-border-radius: 6px;
102
+ border-radius: 6px;
103
+ background: rgb(0 0 0 / 10%);
104
+ }
105
+
106
+ &::-webkit-scrollbar-thumb:vertical {
107
+ width: 6px;
108
+ -webkit-border-radius: 6px;
109
+ border-radius: 6px;
110
+ background: var(--waline-theme-color);
111
+ }
112
+ }
113
+
114
+ .wl-tabs {
115
+ position: relative;
116
+ height: 2em;
117
+ padding: 0 6px 1px;
118
+
119
+ &::before {
120
+ content: ' ';
121
+
122
+ position: absolute;
123
+ top: 0;
124
+ right: 0;
125
+ left: 0;
126
+ z-index: 2;
127
+
128
+ height: 1px;
129
+
130
+ background: var(--waline-border-color);
131
+ }
132
+ }
133
+
134
+ .wl-tab {
135
+ position: relative;
136
+ margin: 0;
137
+ padding: 0 0.5em;
138
+
139
+ &.active {
140
+ z-index: 3;
141
+
142
+ border: 1px solid var(--waline-border-color);
143
+ border-top-width: 0;
144
+ border-bottom-right-radius: 6px;
145
+ border-bottom-left-radius: 6px;
146
+
147
+ background: var(--waline-bgcolor);
148
+ }
149
+ }
150
+ }
151
+ }
@@ -19,7 +19,6 @@
19
19
  color: var(--waline-theme-color);
20
20
 
21
21
  text-decoration: none;
22
-
23
22
  word-break: break-word;
24
23
 
25
24
  cursor: pointer;
@@ -1,4 +1,5 @@
1
1
  @use 'emoji';
2
+ @use 'gif';
2
3
 
3
4
  .wl-comment {
4
5
  position: relative;
@@ -196,7 +197,6 @@
196
197
  .wl-content {
197
198
  min-height: 1.25em;
198
199
  padding: 0.25em;
199
-
200
200
  word-break: break-word;
201
201
  hyphens: auto;
202
202
 
@@ -289,3 +289,4 @@
289
289
  }
290
290
 
291
291
  @include emoji.emoji;
292
+ @include gif.gif;
@@ -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,62 @@
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
+ 'Content-Type': 'application/json',
60
+ },
61
+ }).then((resp) => resp.json() as Promise<FetchGifResponse>);
62
+ };
@@ -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,16 @@
1
+ export function throttle(
2
+ func: (...args: any[]) => void,
3
+ timeout = 300
4
+ ): (...args: []) => void {
5
+ let timer: number | null;
6
+ return (...args: []): void => {
7
+ if (timer) {
8
+ clearTimeout(timer);
9
+ }
10
+
11
+ timer = window.setTimeout(() => {
12
+ func(...args);
13
+ timer = null;
14
+ }, timeout);
15
+ };
16
+ }