artalk 2.7.1 → 2.7.3

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 (305) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/Artalk.cjs +2 -0
  4. package/dist/Artalk.cjs.map +1 -0
  5. package/dist/Artalk.css +1 -1
  6. package/dist/Artalk.iife.js +1 -1
  7. package/dist/Artalk.iife.js.map +1 -1
  8. package/dist/Artalk.js +1 -1
  9. package/dist/Artalk.js.map +1 -1
  10. package/dist/{Artalk.es.js → Artalk.mjs} +250 -222
  11. package/dist/Artalk.mjs.map +1 -0
  12. package/dist/ArtalkLite.cjs +2 -0
  13. package/dist/ArtalkLite.cjs.map +1 -0
  14. package/dist/ArtalkLite.css +1 -1
  15. package/dist/ArtalkLite.iife.js +1 -1
  16. package/dist/ArtalkLite.iife.js.map +1 -1
  17. package/dist/ArtalkLite.js +1 -1
  18. package/dist/ArtalkLite.js.map +1 -1
  19. package/dist/{ArtalkLite.es.js → ArtalkLite.mjs} +250 -227
  20. package/dist/ArtalkLite.mjs.map +1 -0
  21. package/dist/i18n/jp.cjs +1 -0
  22. package/dist/i18n/jp.d.cts +3 -0
  23. package/dist/i18n/jp.d.ts +3 -0
  24. package/dist/i18n/jp.js +1 -1
  25. package/dist/i18n/jp.mjs +93 -0
  26. package/dist/i18n/zh-TW.cjs +1 -0
  27. package/dist/i18n/zh-TW.d.cts +3 -0
  28. package/dist/i18n/zh-TW.d.ts +3 -0
  29. package/dist/i18n/zh-TW.js +1 -1
  30. package/dist/i18n/zh-TW.mjs +93 -0
  31. package/dist/main.d.cts +1476 -0
  32. package/dist/main.d.ts +1476 -0
  33. package/package.json +80 -22
  34. package/dist/Artalk.es.js.map +0 -1
  35. package/dist/ArtalkLite.es.js.map +0 -1
  36. package/dist/src/api/_base.d.ts +0 -10
  37. package/dist/src/api/_options.d.ts +0 -19
  38. package/dist/src/api/_request.d.ts +0 -12
  39. package/dist/src/api/admin.d.ts +0 -10
  40. package/dist/src/api/captcha.d.ts +0 -14
  41. package/dist/src/api/comment.d.ts +0 -29
  42. package/dist/src/api/index.d.ts +0 -29
  43. package/dist/src/api/page.d.ts +0 -22
  44. package/dist/src/api/site.d.ts +0 -17
  45. package/dist/src/api/system.d.ts +0 -33
  46. package/dist/src/api/upload.d.ts +0 -11
  47. package/dist/src/api/user.d.ts +0 -42
  48. package/dist/src/artalk.d.ts +0 -35
  49. package/dist/src/comment/actions.d.ts +0 -17
  50. package/dist/src/comment/comment.d.ts +0 -66
  51. package/dist/src/comment/height-limit.d.ts +0 -30
  52. package/dist/src/comment/index.d.ts +0 -2
  53. package/dist/src/comment/render.d.ts +0 -46
  54. package/dist/src/comment/renders/actions.d.ts +0 -5
  55. package/dist/src/comment/renders/avatar.d.ts +0 -5
  56. package/dist/src/comment/renders/content.d.ts +0 -5
  57. package/dist/src/comment/renders/header.d.ts +0 -5
  58. package/dist/src/comment/renders/index.d.ts +0 -2
  59. package/dist/src/comment/renders/pending.d.ts +0 -5
  60. package/dist/src/comment/renders/reply-at.d.ts +0 -5
  61. package/dist/src/comment/renders/reply-to.d.ts +0 -5
  62. package/dist/src/components/action-btn.d.ts +0 -50
  63. package/dist/src/components/checker/admin.d.ts +0 -3
  64. package/dist/src/components/checker/captcha-renders.d.ts +0 -5
  65. package/dist/src/components/checker/captcha.d.ts +0 -3
  66. package/dist/src/components/checker/index.d.ts +0 -51
  67. package/dist/src/components/dark-mode.d.ts +0 -2
  68. package/dist/src/components/dialog.d.ts +0 -16
  69. package/dist/src/components/error-dialog.d.ts +0 -8
  70. package/dist/src/components/pagination.d.ts +0 -31
  71. package/dist/src/components/read-more-btn.d.ts +0 -33
  72. package/dist/src/config.d.ts +0 -24
  73. package/dist/src/context.d.ts +0 -45
  74. package/dist/src/data.d.ts +0 -27
  75. package/dist/src/defaults.d.ts +0 -3
  76. package/dist/src/editor/editor.d.ts +0 -31
  77. package/dist/src/editor/state.d.ts +0 -20
  78. package/dist/src/editor/ui.d.ts +0 -25
  79. package/dist/src/i18n/en.d.ts +0 -72
  80. package/dist/src/i18n/external.d.ts +0 -73
  81. package/dist/src/i18n/index.d.ts +0 -233
  82. package/dist/src/i18n/jp.d.ts +0 -72
  83. package/dist/src/i18n/zh-CN.d.ts +0 -3
  84. package/dist/src/i18n/zh-TW.d.ts +0 -72
  85. package/dist/src/layer/index.d.ts +0 -4
  86. package/dist/src/layer/layer-manager.d.ts +0 -9
  87. package/dist/src/layer/layer.d.ts +0 -12
  88. package/dist/src/layer/scrollbar-helper.d.ts +0 -5
  89. package/dist/src/layer/sidebar-layer.d.ts +0 -20
  90. package/dist/src/layer/wrap.d.ts +0 -13
  91. package/dist/src/lib/component.d.ts +0 -7
  92. package/dist/src/lib/detect.d.ts +0 -10
  93. package/dist/src/lib/event-manager.d.ts +0 -28
  94. package/dist/src/lib/highlight.d.ts +0 -1
  95. package/dist/src/lib/marked-renderer.d.ts +0 -4
  96. package/dist/src/lib/marked.d.ts +0 -11
  97. package/dist/src/lib/sanitizer.d.ts +0 -1
  98. package/dist/src/lib/ui.d.ts +0 -24
  99. package/dist/src/lib/user.d.ts +0 -19
  100. package/dist/src/lib/utils.d.ts +0 -41
  101. package/dist/src/list/comment.d.ts +0 -3
  102. package/dist/src/list/layout.d.ts +0 -23
  103. package/dist/src/list/list.d.ts +0 -14
  104. package/dist/src/list/nest.d.ts +0 -10
  105. package/dist/src/list/page.d.ts +0 -2
  106. package/dist/src/list/paginator/index.d.ts +0 -25
  107. package/dist/src/list/paginator/read-more.d.ts +0 -18
  108. package/dist/src/list/paginator/up-down.d.ts +0 -14
  109. package/dist/src/main.d.ts +0 -7
  110. package/dist/src/plugins/admin-only-elem.d.ts +0 -2
  111. package/dist/src/plugins/conf-remoter.d.ts +0 -2
  112. package/dist/src/plugins/dark-mode.d.ts +0 -2
  113. package/dist/src/plugins/editor/_kit.d.ts +0 -27
  114. package/dist/src/plugins/editor/_plug.d.ts +0 -29
  115. package/dist/src/plugins/editor/_sample.d.ts +0 -5
  116. package/dist/src/plugins/editor/closable.d.ts +0 -7
  117. package/dist/src/plugins/editor/emoticons.d.ts +0 -30
  118. package/dist/src/plugins/editor/header-event.d.ts +0 -6
  119. package/dist/src/plugins/editor/header-link.d.ts +0 -6
  120. package/dist/src/plugins/editor/header-user.d.ts +0 -16
  121. package/dist/src/plugins/editor/index.d.ts +0 -6
  122. package/dist/src/plugins/editor/local-storage.d.ts +0 -6
  123. package/dist/src/plugins/editor/mover.d.ts +0 -6
  124. package/dist/src/plugins/editor/preview.d.ts +0 -7
  125. package/dist/src/plugins/editor/state-edit.d.ts +0 -11
  126. package/dist/src/plugins/editor/state-reply.d.ts +0 -8
  127. package/dist/src/plugins/editor/submit-add.d.ts +0 -18
  128. package/dist/src/plugins/editor/submit-btn.d.ts +0 -5
  129. package/dist/src/plugins/editor/submit.d.ts +0 -17
  130. package/dist/src/plugins/editor/textarea.d.ts +0 -8
  131. package/dist/src/plugins/editor/upload.d.ts +0 -9
  132. package/dist/src/plugins/editor-kit.d.ts +0 -42
  133. package/dist/src/plugins/index.d.ts +0 -2
  134. package/dist/src/plugins/list/copyright.d.ts +0 -2
  135. package/dist/src/plugins/list/count.d.ts +0 -2
  136. package/dist/src/plugins/list/dropdown.d.ts +0 -2
  137. package/dist/src/plugins/list/error-dialog.d.ts +0 -2
  138. package/dist/src/plugins/list/fetch.d.ts +0 -2
  139. package/dist/src/plugins/list/goto-first.d.ts +0 -3
  140. package/dist/src/plugins/list/goto.d.ts +0 -2
  141. package/dist/src/plugins/list/index.d.ts +0 -3
  142. package/dist/src/plugins/list/loading.d.ts +0 -2
  143. package/dist/src/plugins/list/no-comment.d.ts +0 -2
  144. package/dist/src/plugins/list/reach-bottom.d.ts +0 -2
  145. package/dist/src/plugins/list/sidebar-btn.d.ts +0 -2
  146. package/dist/src/plugins/list/time-ticking.d.ts +0 -3
  147. package/dist/src/plugins/list/unread-badge.d.ts +0 -2
  148. package/dist/src/plugins/list/unread.d.ts +0 -2
  149. package/dist/src/plugins/list/with-editor.d.ts +0 -2
  150. package/dist/src/plugins/markdown.d.ts +0 -2
  151. package/dist/src/plugins/stat.d.ts +0 -13
  152. package/dist/src/plugins/version-check.d.ts +0 -2
  153. package/dist/src/service.d.ts +0 -42
  154. package/dist/tests/e2e/comment-add.spec.d.ts +0 -1
  155. package/dist/types/config.d.ts +0 -110
  156. package/dist/types/context.d.ts +0 -62
  157. package/dist/types/data.d.ts +0 -194
  158. package/dist/types/editor.d.ts +0 -76
  159. package/dist/types/event.d.ts +0 -39
  160. package/dist/types/global.d.ts +0 -1
  161. package/dist/types/index.d.ts +0 -7
  162. package/dist/types/plugin.d.ts +0 -2
  163. package/dist/types/sidebar.d.ts +0 -3
  164. package/src/api/_base.ts +0 -18
  165. package/src/api/_options.ts +0 -25
  166. package/src/api/_request.ts +0 -104
  167. package/src/api/admin.ts +0 -18
  168. package/src/api/captcha.ts +0 -24
  169. package/src/api/comment.ts +0 -84
  170. package/src/api/index.ts +0 -29
  171. package/src/api/page.ts +0 -83
  172. package/src/api/site.ts +0 -51
  173. package/src/api/system.ts +0 -49
  174. package/src/api/upload.ts +0 -28
  175. package/src/api/user.ts +0 -132
  176. package/src/artalk.ts +0 -115
  177. package/src/comment/actions.ts +0 -83
  178. package/src/comment/comment.html +0 -18
  179. package/src/comment/comment.ts +0 -192
  180. package/src/comment/height-limit.ts +0 -100
  181. package/src/comment/index.ts +0 -3
  182. package/src/comment/render.ts +0 -150
  183. package/src/comment/renders/actions.ts +0 -114
  184. package/src/comment/renders/avatar.ts +0 -22
  185. package/src/comment/renders/content.ts +0 -39
  186. package/src/comment/renders/header.ts +0 -84
  187. package/src/comment/renders/index.ts +0 -19
  188. package/src/comment/renders/pending.ts +0 -12
  189. package/src/comment/renders/reply-at.ts +0 -16
  190. package/src/comment/renders/reply-to.ts +0 -24
  191. package/src/components/action-btn.ts +0 -170
  192. package/src/components/checker/admin.ts +0 -37
  193. package/src/components/checker/captcha-renders.ts +0 -69
  194. package/src/components/checker/captcha.ts +0 -26
  195. package/src/components/checker/index.ts +0 -192
  196. package/src/components/dark-mode.ts +0 -30
  197. package/src/components/dialog.ts +0 -62
  198. package/src/components/error-dialog.ts +0 -35
  199. package/src/components/pagination.ts +0 -153
  200. package/src/components/read-more-btn.ts +0 -92
  201. package/src/config.ts +0 -119
  202. package/src/context.ts +0 -146
  203. package/src/data.ts +0 -110
  204. package/src/defaults.ts +0 -61
  205. package/src/editor/editor.html +0 -18
  206. package/src/editor/editor.ts +0 -114
  207. package/src/editor/state.ts +0 -52
  208. package/src/editor/ui.ts +0 -36
  209. package/src/i18n/en.ts +0 -84
  210. package/src/i18n/external.ts +0 -10
  211. package/src/i18n/index.ts +0 -67
  212. package/src/i18n/jp.ts +0 -86
  213. package/src/i18n/zh-CN.ts +0 -88
  214. package/src/i18n/zh-TW.ts +0 -86
  215. package/src/layer/index.ts +0 -4
  216. package/src/layer/layer-manager.ts +0 -32
  217. package/src/layer/layer.ts +0 -39
  218. package/src/layer/scrollbar-helper.ts +0 -24
  219. package/src/layer/sidebar-layer.html +0 -8
  220. package/src/layer/sidebar-layer.ts +0 -155
  221. package/src/layer/wrap.ts +0 -77
  222. package/src/lib/component.ts +0 -12
  223. package/src/lib/detect.ts +0 -222
  224. package/src/lib/event-manager.ts +0 -47
  225. package/src/lib/highlight.ts +0 -5
  226. package/src/lib/marked-renderer.ts +0 -32
  227. package/src/lib/marked.ts +0 -72
  228. package/src/lib/sanitizer.ts +0 -57
  229. package/src/lib/ui.ts +0 -193
  230. package/src/lib/user.ts +0 -55
  231. package/src/lib/utils.ts +0 -236
  232. package/src/list/comment.ts +0 -20
  233. package/src/list/layout.ts +0 -120
  234. package/src/list/list.html +0 -20
  235. package/src/list/list.ts +0 -79
  236. package/src/list/nest.ts +0 -66
  237. package/src/list/page.ts +0 -97
  238. package/src/list/paginator/index.ts +0 -25
  239. package/src/list/paginator/read-more.ts +0 -67
  240. package/src/list/paginator/up-down.ts +0 -51
  241. package/src/main.ts +0 -14
  242. package/src/plugins/admin-only-elem.ts +0 -40
  243. package/src/plugins/conf-remoter.ts +0 -54
  244. package/src/plugins/dark-mode.ts +0 -12
  245. package/src/plugins/editor/_kit.ts +0 -57
  246. package/src/plugins/editor/_plug.ts +0 -60
  247. package/src/plugins/editor/_sample.ts +0 -8
  248. package/src/plugins/editor/closable.ts +0 -44
  249. package/src/plugins/editor/emoticons.scss +0 -72
  250. package/src/plugins/editor/emoticons.ts +0 -293
  251. package/src/plugins/editor/header-event.ts +0 -35
  252. package/src/plugins/editor/header-link.ts +0 -31
  253. package/src/plugins/editor/header-user.ts +0 -98
  254. package/src/plugins/editor/index.ts +0 -40
  255. package/src/plugins/editor/local-storage.ts +0 -36
  256. package/src/plugins/editor/mover.ts +0 -29
  257. package/src/plugins/editor/preview.scss +0 -7
  258. package/src/plugins/editor/preview.ts +0 -41
  259. package/src/plugins/editor/state-edit.ts +0 -116
  260. package/src/plugins/editor/state-reply.ts +0 -91
  261. package/src/plugins/editor/submit-add.ts +0 -33
  262. package/src/plugins/editor/submit-btn.ts +0 -25
  263. package/src/plugins/editor/submit.ts +0 -73
  264. package/src/plugins/editor/textarea.ts +0 -55
  265. package/src/plugins/editor/upload.ts +0 -145
  266. package/src/plugins/editor-kit.ts +0 -161
  267. package/src/plugins/index.ts +0 -16
  268. package/src/plugins/list/copyright.ts +0 -16
  269. package/src/plugins/list/count.ts +0 -31
  270. package/src/plugins/list/dropdown.ts +0 -95
  271. package/src/plugins/list/error-dialog.ts +0 -22
  272. package/src/plugins/list/fetch.ts +0 -64
  273. package/src/plugins/list/goto-first.ts +0 -23
  274. package/src/plugins/list/goto.ts +0 -72
  275. package/src/plugins/list/index.ts +0 -25
  276. package/src/plugins/list/loading.ts +0 -17
  277. package/src/plugins/list/no-comment.ts +0 -25
  278. package/src/plugins/list/reach-bottom.ts +0 -46
  279. package/src/plugins/list/sidebar-btn.ts +0 -39
  280. package/src/plugins/list/time-ticking.ts +0 -22
  281. package/src/plugins/list/unread-badge.ts +0 -26
  282. package/src/plugins/list/unread.ts +0 -38
  283. package/src/plugins/list/with-editor.ts +0 -59
  284. package/src/plugins/markdown.ts +0 -10
  285. package/src/plugins/stat.ts +0 -82
  286. package/src/plugins/version-check.ts +0 -36
  287. package/src/service.ts +0 -91
  288. package/src/style/_color.scss +0 -41
  289. package/src/style/_extend.scss +0 -20
  290. package/src/style/_variables.scss +0 -3
  291. package/src/style/comment.scss +0 -360
  292. package/src/style/editor.scss +0 -194
  293. package/src/style/list.scss +0 -212
  294. package/src/style/main.scss +0 -486
  295. package/src/style/pagination.scss +0 -58
  296. package/src/style/sidebar-layer.scss +0 -92
  297. package/types/config.ts +0 -153
  298. package/types/context.ts +0 -84
  299. package/types/data.ts +0 -271
  300. package/types/editor.ts +0 -95
  301. package/types/event.ts +0 -40
  302. package/types/global.d.ts +0 -1
  303. package/types/index.ts +0 -7
  304. package/types/plugin.ts +0 -3
  305. package/types/sidebar.ts +0 -3
@@ -1,67 +0,0 @@
1
- import type { ListFetchParams } from '~/types'
2
- import ReadMoreBtn from '@/components/read-more-btn'
3
- import $t from '@/i18n'
4
- import type { Paginator, IPgHolderOpt } from '.'
5
-
6
- /**
7
- * 阅读更多形式的分页
8
- */
9
- export default class ReadMorePaginator implements Paginator {
10
- private instance!: ReadMoreBtn
11
- private onReachedBottom: (() => void) | null = null
12
- private opt!: IPgHolderOpt
13
-
14
- create(opt: IPgHolderOpt) {
15
- this.opt = opt
16
-
17
- this.instance = new ReadMoreBtn({
18
- pageSize: opt.pageSize,
19
- onClick: async (o) => {
20
- opt.ctx.fetch({
21
- offset: o,
22
- })
23
- },
24
- text: $t('loadMore'),
25
- })
26
-
27
- // 滚动到底部自动加载
28
- if (opt.readMoreAutoLoad) {
29
- this.onReachedBottom = () => {
30
- if (!this.instance.hasMore || this.opt.ctx.getData().getLoading()) return
31
- this.instance.click()
32
- }
33
- this.opt.ctx.on('list-reach-bottom', this.onReachedBottom)
34
- }
35
-
36
- return this.instance.$el
37
- }
38
-
39
- setLoading(val: boolean) {
40
- this.instance.setLoading(val)
41
- }
42
-
43
- update(offset: number, total: number) {
44
- this.instance.update(offset, total)
45
- }
46
-
47
- showErr(msg: string) {
48
- this.instance.showErr(msg)
49
- }
50
-
51
- next() {
52
- this.instance.click()
53
- }
54
-
55
- getHasMore(): boolean {
56
- return this.instance.hasMore
57
- }
58
-
59
- getIsClearComments(params: Partial<ListFetchParams>): boolean {
60
- return params.offset === 0
61
- }
62
-
63
- dispose(): void {
64
- this.onReachedBottom && this.opt.ctx.off('list-reach-bottom', this.onReachedBottom)
65
- this.instance.$el.remove()
66
- }
67
- }
@@ -1,51 +0,0 @@
1
- import PaginationComponent from '@/components/pagination'
2
- import type { Paginator, IPgHolderOpt } from '.'
3
-
4
- /**
5
- * 翻页形式的分页
6
- */
7
- export default class UpDownPaginator implements Paginator {
8
- private instance!: PaginationComponent
9
-
10
- create(opt: IPgHolderOpt) {
11
- this.instance = new PaginationComponent(opt.total, {
12
- pageSize: opt.pageSize,
13
- onChange: async (o) => {
14
- opt.ctx.editorResetState() // 防止评论框被吞
15
-
16
- opt.ctx.fetch({
17
- offset: o,
18
- onSuccess: () => {
19
- opt.ctx.listGotoFirst()
20
- }
21
- })
22
- }
23
- })
24
-
25
- return this.instance.$el
26
- }
27
-
28
- setLoading(val: boolean) {
29
- this.instance.setLoading(val)
30
- }
31
-
32
- update(offset: number, total: number) {
33
- this.instance.update(offset, total)
34
- }
35
-
36
- next() {
37
- this.instance.next()
38
- }
39
-
40
- getHasMore(): boolean {
41
- return this.instance.getHasMore()
42
- }
43
-
44
- getIsClearComments(): boolean {
45
- return true
46
- }
47
-
48
- dispose(): void {
49
- this.instance.$el.remove()
50
- }
51
- }
package/src/main.ts DELETED
@@ -1,14 +0,0 @@
1
- import Artalk from './artalk'
2
- import * as ArtalkType from '../types'
3
-
4
- export { ArtalkType }
5
- export default Artalk
6
-
7
- // Expose the static methods from the Artalk class
8
- // because direct export of static methods is not supported
9
- // for adapting to different environments like CommonJS and browser IIFE
10
- // for example, we can use `Artalk.init()` rather than `Artalk.default.init()`
11
- // therefore, we need to manually expose the static methods in the Artalk class.
12
- export const init = Artalk.init
13
- export const use = Artalk.use
14
- export const loadCountWidget = Artalk.loadCountWidget
@@ -1,40 +0,0 @@
1
- import type { ArtalkPlugin } from '~/types'
2
-
3
- export const AdminOnlyElem: ArtalkPlugin = (ctx) => {
4
- const scanApply = () => {
5
- applyAdminOnlyEls(ctx.get('user').data.isAdmin, getAdminOnlyEls({
6
- $root: ctx.$root
7
- }))
8
- }
9
-
10
- ctx.on('list-loaded', () => {
11
- scanApply()
12
- })
13
-
14
- ctx.on('user-changed', (user) => {
15
- scanApply()
16
- })
17
- }
18
-
19
- function getAdminOnlyEls(opts: { $root: HTMLElement }): HTMLElement[] {
20
- const els: HTMLElement[] = []
21
-
22
- // elements in $root
23
- opts.$root.querySelectorAll<HTMLElement>(`[atk-only-admin-show]`).forEach(item => els.push(item))
24
-
25
- // TODO provide a Artalk.conf hook to set whitelist of admin-only elements,
26
- // and move following code to that hook (move into packages/artalk-sidebar)
27
-
28
- // elements in sidebar
29
- const $sidebarEl = document.querySelector<HTMLElement>('.atk-sidebar')
30
- if ($sidebarEl) $sidebarEl.querySelectorAll<HTMLElement>(`[atk-only-admin-show]`).forEach(item => els.push(item))
31
-
32
- return els
33
- }
34
-
35
- function applyAdminOnlyEls(isAdmin: boolean, els: HTMLElement[]) {
36
- els.forEach(($item: HTMLElement) => {
37
- if (isAdmin) $item.classList.remove('atk-hide')
38
- else $item.classList.add('atk-hide')
39
- })
40
- }
@@ -1,54 +0,0 @@
1
- import type { ArtalkConfig, ArtalkPlugin, ContextApi } from '~/types'
2
- import { handleConfFormServer } from '@/config'
3
- import { showErrorDialog } from '../components/error-dialog'
4
-
5
- export const ConfRemoter: ArtalkPlugin = (ctx) => {
6
- ctx.on('inited', () => {
7
- loadConf(ctx)
8
- })
9
- }
10
-
11
- function loadConf(ctx: ContextApi) {
12
- ctx.getApi().system.conf().then((data) => {
13
- let conf: Partial<ArtalkConfig> = {
14
- apiVersion: data.version.version, // version info
15
- }
16
-
17
- // reference conf from backend
18
- if (ctx.conf.useBackendConf) {
19
- if (!data.frontend_conf) throw new Error('The remote backend does not respond to the frontend conf, but `useBackendConf` conf is enabled')
20
- conf = { ...conf, ...handleConfFormServer(data.frontend_conf) }
21
- }
22
-
23
- // apply conf modifier
24
- ctx.conf.remoteConfModifier && ctx.conf.remoteConfModifier(conf)
25
-
26
- ctx.updateConf(conf)
27
- }).catch((err) => {
28
- ctx.updateConf({})
29
-
30
- let sidebarOpenView = ''
31
-
32
- // if response err_no_site, modify the sidebar open view to create site
33
- if (err.data?.err_no_site) {
34
- const viewLoadParam = { create_name: ctx.conf.site, create_urls: `${window.location.protocol}//${window.location.host}` }
35
- sidebarOpenView = `sites|${JSON.stringify(viewLoadParam)}`
36
- }
37
-
38
- showErrorDialog({
39
- $err: ctx.get('list').$el,
40
- errMsg: err.msg || String(err),
41
- errData: err.data,
42
- retryFn: () => loadConf(ctx),
43
- onOpenSidebar:() => ctx.showSidebar({
44
- view: sidebarOpenView as any
45
- })
46
- })
47
-
48
- throw err
49
- }).then(() => {
50
- // 评论获取
51
- if (ctx.conf.remoteConfModifier) return // only auto fetch when no remoteConfModifier
52
- ctx.fetch({ offset: 0 })
53
- }).catch(() => {})
54
- }
@@ -1,12 +0,0 @@
1
- import type { ArtalkPlugin } from '~/types'
2
- import { applyDarkMode } from '@/components/dark-mode'
3
-
4
- export const DarkMode: ArtalkPlugin = (ctx) => {
5
- const sync = () => {
6
- applyDarkMode([ctx.$root, ctx.get('layerManager').getEl()], ctx.conf.darkMode)
7
- }
8
-
9
- ctx.on('inited', () => sync())
10
- ctx.on('conf-loaded', () => sync())
11
- ctx.on('dark-mode-changed', () => sync())
12
- }
@@ -1,57 +0,0 @@
1
- import type { PlugManager } from '../editor-kit'
2
- import type EditorPlug from "./_plug"
3
-
4
- /**
5
- * PlugKit provides a set of methods to help you develop editor plug
6
- */
7
- export default class PlugKit {
8
- constructor(
9
- private plugs: PlugManager
10
- ) {
11
- }
12
-
13
- /** Use the editor */
14
- useEditor() {
15
- return this.plugs.editor
16
- }
17
-
18
- /** Use the context of global */
19
- useGlobalCtx() {
20
- return this.plugs.editor.ctx
21
- }
22
-
23
- /** Use the config of Artalk */
24
- useConf() {
25
- return this.plugs.editor.ctx.conf
26
- }
27
-
28
- /** Use the http api client */
29
- useApi() {
30
- return this.plugs.editor.ctx.getApi()
31
- }
32
-
33
- /** Use the ui of editor */
34
- useUI() {
35
- return this.plugs.editor.getUI()
36
- }
37
-
38
- /** Use the events in editor scope */
39
- useEvents() {
40
- return this.plugs.getEvents()
41
- }
42
-
43
- /** Listen the event when plug is mounted */
44
- useMounted(func: () => void) {
45
- this.useEvents().on('mounted', func)
46
- }
47
-
48
- /** Listen the event when plug is unmounted */
49
- useUnmounted(func: () => void) {
50
- this.useEvents().on('unmounted', func)
51
- }
52
-
53
- /** Use the deps of other plug */
54
- useDeps<T extends typeof EditorPlug>(plug: T) {
55
- return this.plugs.get(plug)
56
- }
57
- }
@@ -1,60 +0,0 @@
1
- import type { CommentData, EditorState } from '~/types'
2
- import * as Utils from '@/lib/utils'
3
- import type PlugKit from './_kit'
4
-
5
- /**
6
- * Editor 插件
7
- */
8
- interface EditorPlug {
9
- $btn?: HTMLElement
10
- $panel?: HTMLElement
11
- contentTransformer?(rawContent: string): string
12
- editorStateEffectWhen?: EditorState
13
- editorStateEffect?(comment: CommentData): () => void
14
- }
15
-
16
- class EditorPlug {
17
- constructor(
18
- protected kit: PlugKit
19
- ) {
20
- }
21
-
22
- /** Use plug btn will add a btn on the bottom of editor */
23
- useBtn(html: string = '<div></div>') {
24
- this.$btn = Utils.createElement(`<span class="atk-plug-btn">${html}</span>`)
25
- return this.$btn
26
- }
27
-
28
- /** Use plug panel will show the panel when btn is clicked */
29
- usePanel(html: string = '<div></div>') {
30
- this.$panel = Utils.createElement(html)
31
- return this.$panel
32
- }
33
-
34
- /** Use the content transformer to handle the content of the last submit by the editor */
35
- useContentTransformer(func: (raw: string) => string) {
36
- this.contentTransformer = func
37
- }
38
-
39
- /** Listen the event of panel show */
40
- usePanelShow(func: () => void) {
41
- this.kit.useEvents().on('panel-show', (aPlug) => {
42
- if (aPlug === this) func()
43
- })
44
- }
45
-
46
- /** Listen the event of panel hide */
47
- usePanelHide(func: () => void) {
48
- this.kit.useEvents().on('panel-hide', (aPlug) => {
49
- if (aPlug === this) func()
50
- })
51
- }
52
-
53
- /** Use editor state modifier */
54
- useEditorStateEffect(stateName: EditorState, effectFn: (comment: CommentData) => () => void) {
55
- this.editorStateEffectWhen = stateName
56
- this.editorStateEffect = effectFn
57
- }
58
- }
59
-
60
- export default EditorPlug
@@ -1,8 +0,0 @@
1
- import EditorPlug from './_plug'
2
- import type PlugKit from './_kit'
3
-
4
- export default class SamplePlug extends EditorPlug {
5
- constructor(kit: PlugKit) {
6
- super(kit)
7
- }
8
- }
@@ -1,44 +0,0 @@
1
- import User from '@/lib/user'
2
- import * as Utils from '@/lib/utils'
3
- import $t from '@/i18n'
4
- import EditorPlug from './_plug'
5
- import type PlugKit from './_kit'
6
-
7
- export default class Closable extends EditorPlug {
8
- constructor(kit: PlugKit) {
9
- super(kit)
10
-
11
- const onOpen = () => this.open()
12
- const onClose = () => this.close()
13
-
14
- this.kit.useMounted(() => {
15
- this.kit.useEvents().on('editor-open', onOpen)
16
- this.kit.useEvents().on('editor-close', onClose)
17
- })
18
- this.kit.useUnmounted(() => {
19
- this.kit.useEvents().off('editor-open', onOpen)
20
- this.kit.useEvents().off('editor-close', onClose)
21
- })
22
- }
23
-
24
- private open() {
25
- this.kit.useUI().$textareaWrap.querySelector('.atk-comment-closed')?.remove()
26
- this.kit.useUI().$textarea.style.display = ''
27
- this.kit.useUI().$bottom.style.display = ''
28
- }
29
-
30
- private close() {
31
- if (!this.kit.useUI().$textareaWrap.querySelector('.atk-comment-closed'))
32
- this.kit.useUI().$textareaWrap.prepend(Utils.createElement(`<div class="atk-comment-closed">${$t('onlyAdminCanReply')}</div>`))
33
-
34
- if (!User.data.isAdmin) {
35
- this.kit.useUI().$textarea.style.display = 'none'
36
- this.kit.useEvents().trigger('panel-close')
37
- this.kit.useUI().$bottom.style.display = 'none'
38
- } else {
39
- // 管理员一直打开评论
40
- this.kit.useUI().$textarea.style.display = ''
41
- this.kit.useUI().$bottom.style.display = ''
42
- }
43
- }
44
- }
@@ -1,72 +0,0 @@
1
- .atk-editor-plug-emoticons {
2
- height: 100%;
3
- width: 100%;
4
-
5
- & > .atk-grp-wrap {
6
- @extend .atk-slim-scrollbar;
7
- overflow-y: scroll;
8
- overflow-x: hidden;
9
- height: 100%; // calc(100% - 30px);
10
- width: 100%;
11
-
12
- & > .atk-grp {
13
- display: flex;
14
- flex-wrap: wrap;
15
- flex-direction: row;
16
- padding: 5px 10px 35px 10px;
17
-
18
- &[data-type="image"] > .atk-item {
19
- height: 63px;
20
- width: 63px;
21
- }
22
-
23
- & > .atk-item {
24
- display: flex;
25
- align-items: center;
26
- justify-content: center;
27
- padding: 5px;
28
- cursor: pointer;
29
- user-select: none;
30
- border-radius: calc($block-radius / 2);
31
- font-size: 15px;
32
- min-width: 35px;
33
- margin: 2px;
34
-
35
- & > img {
36
- max-height: 100%;
37
- width: auto;
38
- }
39
-
40
- &:hover {
41
- background: var(--at-color-bg-grey);
42
- }
43
- }
44
- }
45
- }
46
-
47
- & > .atk-grp-switcher {
48
- position: absolute;
49
- bottom: 0;
50
- left: 0;
51
- width: 100%;
52
- background: var(--at-color-bg-transl);
53
- height: 30px;
54
- border-top: 1px solid var(--at-color-border);
55
- border-bottom: 1px solid var(--at-color-border);
56
-
57
- & > span {
58
- user-select: none;
59
- padding: 0 10px;
60
- line-height: 30px;
61
- float: left;
62
- display: block;
63
- cursor: pointer;
64
- font-size: $font-size;
65
-
66
- &:hover,
67
- &.active {
68
- background: var(--at-color-bg-grey);
69
- }
70
- }
71
- }
72
- }