artalk 2.2.11 → 2.3.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 (78) hide show
  1. package/dist/Artalk.css +1 -1
  2. package/dist/Artalk.es.js +1872 -1143
  3. package/dist/Artalk.iife.js +1 -1
  4. package/dist/Artalk.js +1 -1
  5. package/dist/ArtalkLite.css +1 -0
  6. package/dist/ArtalkLite.es.js +5123 -0
  7. package/dist/ArtalkLite.iife.js +1 -0
  8. package/dist/ArtalkLite.js +1 -0
  9. package/index.html +5 -3
  10. package/package.json +7 -5
  11. package/src/api/index.ts +24 -4
  12. package/src/api/request.ts +50 -81
  13. package/src/artalk.ts +131 -127
  14. package/src/comment/actions.ts +86 -0
  15. package/src/{components/html → comment}/comment.html +1 -1
  16. package/src/comment/comment.ts +191 -0
  17. package/src/comment/index.ts +3 -0
  18. package/src/comment/render.ts +425 -0
  19. package/src/components/action-btn.ts +6 -3
  20. package/src/components/dialog.ts +7 -3
  21. package/src/components/read-more-btn.ts +6 -2
  22. package/src/context.ts +204 -13
  23. package/src/defaults.ts +15 -4
  24. package/src/editor/editor.html +18 -0
  25. package/src/editor/editor.ts +419 -0
  26. package/src/editor/index.ts +3 -0
  27. package/src/editor/plugs/editor-plug.ts +51 -0
  28. package/src/{components/editor-plugs → editor/plugs}/emoticons-plug.less +2 -1
  29. package/src/{components/editor-plugs → editor/plugs}/emoticons-plug.ts +65 -63
  30. package/src/editor/plugs/header-input-plug.ts +78 -0
  31. package/src/{components/editor-plugs → editor/plugs}/preview-plug.less +0 -0
  32. package/src/editor/plugs/preview-plug.ts +40 -0
  33. package/src/editor/plugs/upload-plug.ts +124 -0
  34. package/src/i18n/en.ts +78 -0
  35. package/src/i18n/index.ts +21 -0
  36. package/src/i18n/zh-CN.ts +82 -0
  37. package/src/layer/index.ts +4 -0
  38. package/src/{components → layer}/layer.ts +9 -9
  39. package/src/{components/html → layer}/sidebar-layer.html +0 -0
  40. package/src/{components → layer}/sidebar-layer.ts +17 -47
  41. package/src/lib/checker/admin-checker.ts +7 -7
  42. package/src/lib/checker/captcha-checker.ts +5 -6
  43. package/src/lib/checker/index.ts +22 -17
  44. package/src/lib/component.ts +7 -2
  45. package/src/lib/stat.ts +63 -0
  46. package/src/lib/ui.ts +3 -10
  47. package/src/lib/user.ts +20 -3
  48. package/src/lib/utils.ts +23 -9
  49. package/src/list/index.ts +3 -0
  50. package/src/{components → list}/list-lite.ts +83 -111
  51. package/src/{components → list}/list-nest.ts +0 -0
  52. package/src/{components/html → list}/list.html +3 -6
  53. package/src/{components → list}/list.ts +44 -42
  54. package/src/style/_variables.less +1 -2
  55. package/src/style/comment.less +26 -13
  56. package/src/style/editor.less +22 -14
  57. package/src/style/list.less +6 -9
  58. package/src/style/main.less +9 -8
  59. package/src/style/pagination.less +1 -1
  60. package/test/ArtalkCount.html +16 -0
  61. package/test/ArtalkI18n.html +15 -0
  62. package/test/ArtalkLite.html +15 -0
  63. package/types/artalk-config.d.ts +50 -32
  64. package/types/context.d.ts +128 -0
  65. package/types/event.d.ts +6 -66
  66. package/types/global.d.ts +1 -0
  67. package/types/plug.d.ts +4 -0
  68. package/{vite-common.config.ts → vite-base.config.ts} +6 -4
  69. package/vite-demo.config.ts +2 -4
  70. package/vite-lite.config.ts +22 -0
  71. package/vite.config.ts +9 -18
  72. package/src/components/_component.ts.txt +0 -10
  73. package/src/components/comment.ts +0 -605
  74. package/src/components/editor-plugs/_example-plug.ts.txt +0 -29
  75. package/src/components/editor-plugs/editor-plug.ts +0 -20
  76. package/src/components/editor-plugs/preview-plug.ts +0 -48
  77. package/src/components/editor.ts +0 -604
  78. package/src/components/html/editor.html +0 -18
@@ -1,7 +1,7 @@
1
1
  .atk-comment-wrap {
2
2
  overflow: hidden;
3
3
  position: relative;
4
- border-bottom: 1px solid var(--at-color-border);
4
+ border-bottom: 1px solid transparent;
5
5
 
6
6
  &.atk-flash-once {
7
7
  animation: atkFlashOnce 1s ease-in-out 0s;
@@ -49,20 +49,20 @@
49
49
  float: left;
50
50
 
51
51
  img {
52
- width: 48px;
53
- height: 48px;
54
- border-radius: 3px;
52
+ width: 50px;
53
+ height: 50px;
54
+ border-radius: (@block-radius / 2);
55
55
  }
56
56
  }
57
57
 
58
58
  & > .atk-main {
59
59
  display: block;
60
- margin-left: 62px;
60
+ margin-left: 63px;
61
61
 
62
62
  & > .atk-header {
63
63
  line-height: 1;
64
64
  font-size: 13px;
65
- margin-bottom: 3px;
65
+ margin-bottom: .5em;
66
66
  overflow: hidden;
67
67
  position: relative;
68
68
  display: flex;
@@ -71,6 +71,8 @@
71
71
 
72
72
  .atk-item {
73
73
  display: flex;
74
+ align-items: center;
75
+ margin-top: 2px;
74
76
  margin-bottom: 2px;
75
77
  color: var(--at-color-meta);
76
78
 
@@ -107,17 +109,22 @@
107
109
  }
108
110
 
109
111
  .badge() {
112
+ display: inline-block;
110
113
  color: var(--at-color-meta);
111
114
  background: var(--at-color-bg-grey);
112
- padding: 0 6px;
113
- line-height: 18px;
114
- border-radius: 3px;
115
+ padding: 0px 6px;
116
+ line-height: 17px;
117
+ border-radius: (@block-radius / 2);
115
118
 
116
119
  &:not(:last-child) {
117
120
  margin-right: 6px;
118
121
  }
119
122
  }
120
123
 
124
+ .atk-badge-wrap > *:last-child {
125
+ margin-right: 6px;
126
+ }
127
+
121
128
  .atk-badge {
122
129
  .badge();
123
130
  color: #fff;
@@ -136,6 +143,7 @@
136
143
  .atk-ua-wrap {
137
144
  @media only screen and (max-width: 768px) {
138
145
  display: block;
146
+ margin-top: 5px;
139
147
  }
140
148
  }
141
149
  }
@@ -253,7 +261,6 @@
253
261
  &:not(:first-child):not(.atk-hide) {
254
262
  margin-left: 8px;
255
263
  padding-left: 8px;
256
- border-left: 1px solid var(--at-color-border);
257
264
  }
258
265
 
259
266
  &:hover {
@@ -291,6 +298,10 @@
291
298
  font-size: 15px;
292
299
  color: var(--at-color-meta);
293
300
  user-select: none;
301
+
302
+ &:hover {
303
+ background: var(--at-color-bg-grey);
304
+ }
294
305
  }
295
306
 
296
307
  // 避免重复显示按钮
@@ -303,15 +314,14 @@
303
314
  .atk-comment-children {
304
315
  & > .atk-comment-wrap {
305
316
  margin-top: 10px;
306
- border-left: 1px dashed var(--at-color-border);
317
+ border-left: 1px dashed transparent;
307
318
  border-bottom-color: transparent;
308
319
  &:not(:last-child) {
309
320
  margin-bottom: 5px;
310
321
  }
311
322
 
312
323
  & > .atk-comment {
313
- padding-top: 4px;
314
- padding-bottom: 4px;
324
+ padding: 4px 0;
315
325
 
316
326
  & > .atk-avatar img {
317
327
  width: 36px;
@@ -320,6 +330,9 @@
320
330
 
321
331
  & > .atk-main {
322
332
  margin-left: 47px;
333
+
334
+ & > .atk-body > .atk-content {
335
+ }
323
336
  }
324
337
  }
325
338
  }
@@ -6,7 +6,7 @@
6
6
  background: var(--at-color-bg);
7
7
  border: 1px solid var(--at-color-border);
8
8
  border-radius: @block-radius;
9
- margin-bottom: 15px;
9
+ margin-bottom: 10px;
10
10
 
11
11
  @media only screen and (max-width: 768px) {
12
12
  margin-bottom: 7px;
@@ -15,7 +15,7 @@
15
15
  & > .atk-header {
16
16
  display: flex;
17
17
  flex-direction: row;
18
- padding: calc(@editor-padding / 2) @editor-padding 0;
18
+ padding: 10px 14px 0;
19
19
 
20
20
  input {
21
21
  flex: 1;
@@ -23,7 +23,7 @@
23
23
  font-size: 14px;
24
24
  background: transparent;
25
25
  border: 2px solid transparent;
26
- border-radius: calc(@block-radius / 2);
26
+ border-radius: (@block-radius / 2);
27
27
  padding: 6px 5px;
28
28
  resize: none;
29
29
  outline: none;
@@ -44,11 +44,11 @@
44
44
  font-size: 15px;
45
45
  background-color: var(--at-color-bg);
46
46
  border: 2px solid transparent;
47
- border-radius: calc(@block-radius / 2);
47
+ border-radius: (@block-radius / 2);
48
48
  width: 100%;
49
- min-height: 130px;
49
+ min-height: 120px;
50
50
  margin-top: 2px;
51
- padding: @editor-padding calc(10px + 5px);
51
+ padding: 10px 20px;
52
52
  resize: none;
53
53
  word-wrap: break-word;
54
54
  outline: none;
@@ -61,15 +61,16 @@
61
61
  background-color: var(--at-color-bg);
62
62
  border-top: 1px solid var(--at-color-border);
63
63
  padding: 5px 15px;
64
+ margin-top: 10px;
64
65
  // background: repeating-linear-gradient(145deg, #f2f2f2, #f2f2f2 15px, #fff 0, #fff 30px);
65
66
  }
66
67
 
67
68
  & > .atk-send-reply {
68
69
  z-index: 2;
69
70
  position: absolute;
70
- right: 10px;
71
- bottom: 8px;
72
- max-width: calc(100% - 20px);
71
+ right: 7px;
72
+ bottom: 2px;
73
+ max-width: (100% - 20px);
73
74
  height: 30px;
74
75
  line-height: 30px;
75
76
  font-size: 14px;
@@ -79,6 +80,7 @@
79
80
  text-overflow: ellipsis;
80
81
  white-space: nowrap;
81
82
  cursor: pointer;
83
+ border-radius: (@block-radius / 2);
82
84
 
83
85
  .atk-text {
84
86
  }
@@ -100,7 +102,7 @@
100
102
  }
101
103
  }
102
104
 
103
- & > .atk-plug-wrap {
105
+ & > .atk-plug-panel-wrap {
104
106
  position: relative;
105
107
  height: 180px;
106
108
  width: 100%;
@@ -114,8 +116,7 @@
114
116
  display: flex;
115
117
  flex-direction: row;
116
118
  justify-content: space-between;
117
- border-top: 1px solid var(--at-color-border);
118
- padding: 0 0 0 calc(@editor-padding - 5px);
119
+ padding: 5px 5px 5px 10px;
119
120
 
120
121
  & > .atk-item {
121
122
  display: flex;
@@ -125,13 +126,19 @@
125
126
 
126
127
  .atk-plug-btn {
127
128
  padding: 0 8px;
129
+ line-height: 24px;
128
130
  cursor: pointer;
129
131
  color: var(--at-color-grey);
130
132
  font-size: @font-size;
131
133
  user-select: none;
134
+ border-radius: (@block-radius / 2);
132
135
 
133
136
  &:not(:last-child) {
134
- border-right: 1px solid var(--at-color-border);
137
+ margin-right: 2px;
138
+ }
139
+
140
+ &:hover {
141
+ background: var(--at-color-bg-grey);
135
142
  }
136
143
 
137
144
  &.active {
@@ -164,6 +171,7 @@
164
171
  cursor: pointer;
165
172
  transition: opacity 0.3s ease-in-out;
166
173
  outline: none;
174
+ border-radius: (@block-radius / 2);
167
175
 
168
176
  &:active {
169
177
  opacity: 0.9;
@@ -175,7 +183,7 @@
175
183
  z-index: 9;
176
184
  position: absolute;
177
185
  right: -2px;
178
- bottom: 36px;
186
+ bottom: 40px;
179
187
  width: 225px;
180
188
  opacity: 0.83;
181
189
  }
@@ -4,8 +4,7 @@
4
4
  & > .atk-list-header {
5
5
  display: flex;
6
6
  flex-direction: row;
7
- padding: 10px 10px 5px 10px;
8
- border-bottom: 1px solid var(--at-color-border);
7
+ padding: 10px 17px 10px 17px;
9
8
 
10
9
  .atk-text {
11
10
  display: inline-block;
@@ -23,7 +22,7 @@
23
22
  border-left: 3px solid transparent;
24
23
  border-right: 3px solid transparent;
25
24
  margin-top: -1px;
26
- margin-left: 0.4rem;
25
+ margin-left: 0.8rem;
27
26
  display: inline-block;
28
27
  }
29
28
 
@@ -47,7 +46,7 @@
47
46
  padding: 0.6rem 0;
48
47
  border: 1px solid var(--at-color-border);
49
48
  text-align: center;
50
- border-radius: 0.25rem;
49
+ border-radius: @block-radius;
51
50
  white-space: nowrap;
52
51
  margin: 0;
53
52
  list-style: none;
@@ -103,7 +102,6 @@
103
102
  &:not(:last-child):not(.atk-hide) {
104
103
  margin-right: 10px;
105
104
  padding-right: 10px;
106
- border-right: 1px solid var(--at-color-border);
107
105
  }
108
106
 
109
107
  .atk-unread-badge {
@@ -129,7 +127,6 @@
129
127
 
130
128
  .atk-list-comments-wrap {
131
129
  .atk-main-editor {
132
- margin-top: -1px;
133
130
  }
134
131
  }
135
132
  }
@@ -171,8 +168,8 @@
171
168
 
172
169
  .atk-list-read-more {
173
170
  border-top: 1px dashed var(--at-color-border);
174
- margin-top: 20px;
175
- padding-bottom: 20px;
171
+ margin-top: 28px;
172
+ padding-bottom: 25px;
176
173
 
177
174
  @media only screen and (max-width: 768px) {
178
175
  padding-bottom: 10px;
@@ -210,8 +207,8 @@
210
207
  }
211
208
 
212
209
  &:hover {
210
+ background: var(--at-color-bg-grey);
213
211
  & > .atk-text {
214
- color: var(--at-color-main);
215
212
  }
216
213
  }
217
214
  }
@@ -7,9 +7,7 @@
7
7
  }
8
8
 
9
9
  .artalk, .atk-layer-wrap {
10
- line-height: @line-height;
11
10
  color: var(--at-color-font);
12
- font-family: @font-family;
13
11
  word-wrap: break-word;
14
12
  word-break: break-all;
15
13
 
@@ -28,7 +26,9 @@
28
26
  code {
29
27
  font-family: @codeFont;
30
28
  margin: 0 .3em;
31
- padding: .1em .2em;
29
+ padding: 0 .5em;
30
+ display: inline-block;
31
+ font-size: .9em;
32
32
  background-color: var(--at-color-bg-grey);
33
33
  color: var(--at-color-font);
34
34
  border-radius: @block-radius;
@@ -62,6 +62,7 @@
62
62
  padding: 10px 20px 10px 20px;
63
63
  background: var(--at-color-bg-grey);
64
64
  border-left: 4px solid #687a86;
65
+ color: var(--at-color-font);
65
66
  }
66
67
 
67
68
  p:first-child {
@@ -309,10 +310,10 @@ i.atk-icon {
309
310
 
310
311
  input {
311
312
  width: 100%;
312
- line-height: calc(@formInputHeight + 4px);
313
+ line-height: (@formInputHeight + 4px);
313
314
  background-color: var(--at-color-bg);
314
315
  border: 1px solid var(--at-color-border);
315
- border-radius: calc(@block-radius / 2);
316
+ border-radius: (@block-radius / 2);
316
317
  outline: none;
317
318
  padding: 0 6px;
318
319
  display: block;
@@ -333,7 +334,7 @@ i.atk-icon {
333
334
  border: 1px solid var(--at-color-main);
334
335
  background: transparent;
335
336
  color: var(--at-color-main);
336
- border-radius: calc(@block-radius / 2);
337
+ border-radius: (@block-radius / 2);
337
338
  padding: 0 15px;
338
339
  line-height: @formInputHeight;
339
340
  outline: none;
@@ -403,10 +404,10 @@ i.atk-icon {
403
404
  overflow: hidden;
404
405
  background-color: #2c2c2c;
405
406
  color: #FFF;
406
- border-radius: 2px;
407
+ border-radius: (@block-radius / 2);
407
408
  cursor: pointer;
408
409
  font-size: 14px;
409
- padding: 4px 15px;
410
+ padding: 5px 15px;
410
411
 
411
412
  &:not(:last-child) {
412
413
  margin-bottom: 3px;
@@ -8,7 +8,7 @@
8
8
  & > .atk-btn,
9
9
  & > .atk-input {
10
10
  font-size: 15px;
11
- height: 32px;
11
+ height: 30px;
12
12
  border: 1px solid var(--at-color-border);
13
13
  border-radius: 3px;
14
14
  padding: 0 5px;
@@ -0,0 +1,16 @@
1
+ <script src="../dist/Artalk.js"></script>
2
+
3
+ <div class="pv" data-page-key="https://artalk.js.org/">0</div>
4
+ <div class="pv" data-page-key="https://artalk.js.org/guide/intro.html">0</div>
5
+
6
+ <div class="count" data-page-key="https://artalk.js.org/">0</div>
7
+ <div class="count" data-page-key="https://artalk.js.org/guide/intro.html">0</div>
8
+
9
+ <script>
10
+ var artalk = Artalk.LoadCountWidget({
11
+ server: 'http://localhost:23366',
12
+ site: 'ArtalkDocs',
13
+ pvEl: '.pv',
14
+ countEl: ".count",
15
+ });
16
+ </script>
@@ -0,0 +1,15 @@
1
+ <link rel="stylesheet" href="../dist/Artalk.css">
2
+ <script src="../dist/Artalk.js"></script>
3
+
4
+ <div id="comments"></div>
5
+
6
+ <script>
7
+ var artalk = new Artalk({
8
+ el: '#comments',
9
+ pageKey: 'https://artalk.js.org/',
10
+ pageTitle: 'Artalk Home',
11
+ server: 'http://localhost:23366',
12
+ site: 'ArtalkDocs',
13
+ locale: 'auto',
14
+ });
15
+ </script>
@@ -0,0 +1,15 @@
1
+ <!-- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> -->
2
+ <link rel="stylesheet" href="../dist/ArtalkLite.css">
3
+ <script src="../dist/ArtalkLite.js"></script>
4
+
5
+ <div id="comments"></div>
6
+
7
+ <script>
8
+ var artalk = new Artalk({
9
+ el: '#comments',
10
+ pageKey: 'https://artalk.js.org/',
11
+ pageTitle: 'Artalk Home',
12
+ server: 'http://localhost:23366',
13
+ site: 'ArtalkDocs',
14
+ });
15
+ </script>
@@ -1,3 +1,5 @@
1
+ import { I18n } from '~/src/i18n'
2
+
1
3
  export default interface ArtalkConfig {
2
4
  /** 装载元素 */
3
5
  el: string|HTMLElement
@@ -6,96 +8,112 @@ export default interface ArtalkConfig {
6
8
  pageKey: string
7
9
 
8
10
  /** 页面标题 */
9
- pageTitle?: string
11
+ pageTitle: string
10
12
 
11
13
  /** 服务器地址 */
12
14
  server: string
13
15
 
14
16
  /** 站点名 */
15
- site?: string
17
+ site: string
16
18
 
17
19
  /** 评论框占位字符 */
18
- placeholder?: string
20
+ placeholder: string
19
21
 
20
22
  /** 评论为空时显示字符 */
21
- noComment?: string
23
+ noComment: string
22
24
 
23
25
  /** 发送按钮文字 */
24
- sendBtn?: string
26
+ sendBtn: string
25
27
 
26
28
  /** 评论框旅行(显示在待回复评论后面) */
27
- editorTravel?: boolean
29
+ editorTravel: boolean
28
30
 
29
31
  /** 表情包 */
30
- emoticons?: any
32
+ emoticons: object|any[]|string|false
31
33
 
32
34
  /** Gravatar 头像 */
33
- gravatar?: {
35
+ gravatar: {
34
36
  /** 镜像 */
35
- mirror?: string
37
+ mirror: string
36
38
  /** 默认头像(URL or Gravatar Type) */
37
- default?: string
39
+ default: string
38
40
  }
39
41
 
40
42
  /** 分页配置 */
41
- pagination?: {
43
+ pagination: {
42
44
  /** 每次请求获取数量 */
43
- pageSize?: number
45
+ pageSize: number
44
46
  /** 阅读更多模式 */
45
- readMore?: boolean
47
+ readMore: boolean
46
48
  /** 滚动到底部自动加载 */
47
- autoLoad?: boolean
49
+ autoLoad: boolean
48
50
  }
49
51
 
50
52
  /** 内容限高 */
51
- heightLimit?: {
53
+ heightLimit: {
52
54
  /** 评论内容限高 */
53
- content?: number
55
+ content: number
54
56
 
55
57
  /** 子评论区域限高 */
56
- children?: number
58
+ children: number
57
59
  }
58
60
 
59
61
  /** 评论投票按钮 */
60
- vote?: boolean
62
+ vote: boolean
61
63
 
62
64
  /** 评论投票反对按钮 */
63
- voteDown?: boolean
65
+ voteDown: boolean
66
+
67
+ /** 评论预览功能 */
68
+ preview: boolean
69
+
70
+ /** 评论数绑定元素 Selector */
71
+ countEl: string
64
72
 
65
- /** PV 元素 Selector */
66
- pvEl?: string
73
+ /** PV 数绑定元素 Selector */
74
+ pvEl: string
67
75
 
68
76
  /** 暗黑模式 */
69
- darkMode?: boolean
77
+ darkMode: boolean|'auto'
70
78
 
71
79
  /** 请求超时(单位:秒) */
72
- reqTimeout?: number
80
+ reqTimeout: number
73
81
 
74
82
  /** 平铺模式 */
75
- flatMode?: boolean|'auto'
83
+ flatMode: boolean|'auto'
76
84
 
77
85
  /** 嵌套模式 · 最大层数 */
78
- nestMax?: number
86
+ nestMax: number
79
87
 
80
88
  /** 嵌套模式 · 排序方式 */
81
- nestSort?: 'DATE_ASC'|'DATE_DESC'
89
+ nestSort: 'DATE_ASC'|'DATE_DESC'
82
90
 
83
91
  /** 显示 UA 徽标 */
84
- uaBadge?: boolean
92
+ uaBadge: boolean
85
93
 
86
94
  /** 评论列表排序功能 (显示 Dropdown) */
87
- listSort?: boolean
95
+ listSort: boolean
88
96
 
89
97
  /** 图片上传功能 */
90
- imgUpload?: boolean
98
+ imgUpload: boolean
99
+
100
+ /** 图片上传器 */
101
+ imgUploader?: (file: File) => Promise<{ img_url: string }>
91
102
 
92
103
  /** 版本检测 */
93
- versionCheck?: boolean
104
+ versionCheck: boolean
105
+
106
+ /** 应用后端配置 */
107
+ useBackendConf: boolean
94
108
 
95
- /** 复用后端配置 */
96
- useBackendConf?: boolean
109
+ /** 语言本地化 */
110
+ locale: I18n|string
97
111
  }
98
112
 
113
+ /**
114
+ * 本地持久化用户数据
115
+ * @note 始终保持一层结构,不支持多层结构
116
+ */
99
117
  export interface LocalUser {
100
118
  /** 昵称 */
101
119
  nick: string