artalk 2.7.0 → 2.7.2
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/README.md +1 -1
- package/dist/Artalk.css +1 -1
- package/dist/Artalk.es.js +209 -188
- package/dist/Artalk.es.js.map +1 -0
- package/dist/Artalk.iife.js +2 -1
- package/dist/Artalk.iife.js.map +1 -0
- package/dist/Artalk.js +2 -1
- package/dist/Artalk.js.map +1 -0
- package/dist/ArtalkLite.css +1 -1
- package/dist/ArtalkLite.es.js +209 -188
- package/dist/ArtalkLite.es.js.map +1 -0
- package/dist/ArtalkLite.iife.js +2 -1
- package/dist/ArtalkLite.iife.js.map +1 -0
- package/dist/ArtalkLite.js +2 -1
- package/dist/ArtalkLite.js.map +1 -0
- package/dist/i18n/jp.js +1 -1
- package/dist/i18n/zh-TW.js +1 -1
- package/dist/src/api/_base.d.ts +7 -0
- package/dist/src/api/_options.d.ts +5 -0
- package/dist/src/artalk.d.ts +0 -2
- package/dist/src/components/checker/index.d.ts +2 -0
- package/dist/src/i18n/en.d.ts +4 -0
- package/dist/src/i18n/external.d.ts +4 -0
- package/dist/src/i18n/index.d.ts +12 -0
- package/dist/src/i18n/jp.d.ts +4 -0
- package/dist/src/i18n/zh-TW.d.ts +4 -0
- package/dist/src/lib/user.d.ts +8 -6
- package/dist/src/main.d.ts +3 -0
- package/dist/src/plugins/editor/_kit.d.ts +7 -1
- package/dist/src/service.d.ts +2 -8
- package/dist/types/event.d.ts +1 -1
- package/package.json +43 -17
- package/dist/src/components/dark-mode.d.ts +0 -2
- package/src/api/_base.ts +0 -18
- package/src/api/_options.ts +0 -25
- package/src/api/_request.ts +0 -104
- package/src/api/admin.ts +0 -18
- package/src/api/captcha.ts +0 -24
- package/src/api/comment.ts +0 -84
- package/src/api/index.ts +0 -29
- package/src/api/page.ts +0 -83
- package/src/api/site.ts +0 -51
- package/src/api/system.ts +0 -49
- package/src/api/upload.ts +0 -28
- package/src/api/user.ts +0 -132
- package/src/artalk.ts +0 -119
- package/src/comment/actions.ts +0 -83
- package/src/comment/comment.html +0 -18
- package/src/comment/comment.ts +0 -192
- package/src/comment/height-limit.ts +0 -100
- package/src/comment/index.ts +0 -3
- package/src/comment/render.ts +0 -150
- package/src/comment/renders/actions.ts +0 -114
- package/src/comment/renders/avatar.ts +0 -22
- package/src/comment/renders/content.ts +0 -39
- package/src/comment/renders/header.ts +0 -84
- package/src/comment/renders/index.ts +0 -19
- package/src/comment/renders/pending.ts +0 -12
- package/src/comment/renders/reply-at.ts +0 -16
- package/src/comment/renders/reply-to.ts +0 -24
- package/src/components/action-btn.ts +0 -170
- package/src/components/checker/admin.ts +0 -37
- package/src/components/checker/captcha-renders.ts +0 -69
- package/src/components/checker/captcha.ts +0 -26
- package/src/components/checker/index.ts +0 -192
- package/src/components/dark-mode.ts +0 -30
- package/src/components/dialog.ts +0 -62
- package/src/components/error-dialog.ts +0 -35
- package/src/components/pagination.ts +0 -153
- package/src/components/read-more-btn.ts +0 -92
- package/src/config.ts +0 -119
- package/src/context.ts +0 -146
- package/src/data.ts +0 -110
- package/src/defaults.ts +0 -61
- package/src/editor/editor.html +0 -18
- package/src/editor/editor.ts +0 -114
- package/src/editor/state.ts +0 -52
- package/src/editor/ui.ts +0 -36
- package/src/i18n/en.ts +0 -81
- package/src/i18n/external.ts +0 -10
- package/src/i18n/index.ts +0 -67
- package/src/i18n/jp.ts +0 -83
- package/src/i18n/zh-CN.ts +0 -85
- package/src/i18n/zh-TW.ts +0 -83
- package/src/layer/index.ts +0 -4
- package/src/layer/layer-manager.ts +0 -32
- package/src/layer/layer.ts +0 -39
- package/src/layer/scrollbar-helper.ts +0 -24
- package/src/layer/sidebar-layer.html +0 -8
- package/src/layer/sidebar-layer.ts +0 -155
- package/src/layer/wrap.ts +0 -77
- package/src/lib/component.ts +0 -12
- package/src/lib/detect.ts +0 -222
- package/src/lib/event-manager.ts +0 -47
- package/src/lib/highlight.ts +0 -5
- package/src/lib/marked-renderer.ts +0 -32
- package/src/lib/marked.ts +0 -72
- package/src/lib/sanitizer.ts +0 -57
- package/src/lib/ui.ts +0 -193
- package/src/lib/user.ts +0 -55
- package/src/lib/utils.ts +0 -236
- package/src/list/comment.ts +0 -20
- package/src/list/layout.ts +0 -120
- package/src/list/list.html +0 -20
- package/src/list/list.ts +0 -79
- package/src/list/nest.ts +0 -66
- package/src/list/page.ts +0 -97
- package/src/list/paginator/index.ts +0 -25
- package/src/list/paginator/read-more.ts +0 -67
- package/src/list/paginator/up-down.ts +0 -51
- package/src/main.ts +0 -5
- package/src/plugins/admin-only-elem.ts +0 -40
- package/src/plugins/conf-remoter.ts +0 -54
- package/src/plugins/dark-mode.ts +0 -12
- package/src/plugins/editor/_kit.ts +0 -57
- package/src/plugins/editor/_plug.ts +0 -60
- package/src/plugins/editor/_sample.ts +0 -8
- package/src/plugins/editor/closable.ts +0 -44
- package/src/plugins/editor/emoticons.scss +0 -72
- package/src/plugins/editor/emoticons.ts +0 -293
- package/src/plugins/editor/header-event.ts +0 -35
- package/src/plugins/editor/header-link.ts +0 -31
- package/src/plugins/editor/header-user.ts +0 -98
- package/src/plugins/editor/index.ts +0 -40
- package/src/plugins/editor/local-storage.ts +0 -36
- package/src/plugins/editor/mover.ts +0 -29
- package/src/plugins/editor/preview.scss +0 -7
- package/src/plugins/editor/preview.ts +0 -41
- package/src/plugins/editor/state-edit.ts +0 -116
- package/src/plugins/editor/state-reply.ts +0 -91
- package/src/plugins/editor/submit-add.ts +0 -33
- package/src/plugins/editor/submit-btn.ts +0 -25
- package/src/plugins/editor/submit.ts +0 -73
- package/src/plugins/editor/textarea.ts +0 -55
- package/src/plugins/editor/upload.ts +0 -145
- package/src/plugins/editor-kit.ts +0 -161
- package/src/plugins/index.ts +0 -16
- package/src/plugins/list/copyright.ts +0 -16
- package/src/plugins/list/count.ts +0 -31
- package/src/plugins/list/dropdown.ts +0 -95
- package/src/plugins/list/error-dialog.ts +0 -22
- package/src/plugins/list/fetch.ts +0 -64
- package/src/plugins/list/goto-first.ts +0 -23
- package/src/plugins/list/goto.ts +0 -72
- package/src/plugins/list/index.ts +0 -25
- package/src/plugins/list/loading.ts +0 -17
- package/src/plugins/list/no-comment.ts +0 -25
- package/src/plugins/list/reach-bottom.ts +0 -46
- package/src/plugins/list/sidebar-btn.ts +0 -39
- package/src/plugins/list/time-ticking.ts +0 -22
- package/src/plugins/list/unread-badge.ts +0 -26
- package/src/plugins/list/unread.ts +0 -38
- package/src/plugins/list/with-editor.ts +0 -59
- package/src/plugins/markdown.ts +0 -10
- package/src/plugins/stat.ts +0 -79
- package/src/plugins/version-check.ts +0 -37
- package/src/service.ts +0 -91
- package/src/style/_color.scss +0 -41
- package/src/style/_extend.scss +0 -20
- package/src/style/_variables.scss +0 -3
- package/src/style/comment.scss +0 -360
- package/src/style/editor.scss +0 -194
- package/src/style/list.scss +0 -212
- package/src/style/main.scss +0 -486
- package/src/style/pagination.scss +0 -58
- package/src/style/sidebar-layer.scss +0 -92
- package/types/config.ts +0 -153
- package/types/context.ts +0 -84
- package/types/data.ts +0 -271
- package/types/editor.ts +0 -95
- package/types/event.ts +0 -40
- package/types/global.d.ts +0 -1
- package/types/index.ts +0 -7
- package/types/plugin.ts +0 -3
- package/types/sidebar.ts +0 -3
package/src/defaults.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { ArtalkConfig } from '~/types'
|
|
2
|
-
|
|
3
|
-
const defaults: ArtalkConfig = {
|
|
4
|
-
el: '',
|
|
5
|
-
pageKey: '',
|
|
6
|
-
pageTitle: '',
|
|
7
|
-
server: '',
|
|
8
|
-
site: '',
|
|
9
|
-
|
|
10
|
-
placeholder: '',
|
|
11
|
-
noComment: '',
|
|
12
|
-
sendBtn: '',
|
|
13
|
-
darkMode: false,
|
|
14
|
-
editorTravel: true,
|
|
15
|
-
|
|
16
|
-
flatMode: 'auto',
|
|
17
|
-
nestMax: 2,
|
|
18
|
-
nestSort: 'DATE_ASC',
|
|
19
|
-
|
|
20
|
-
emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json",
|
|
21
|
-
|
|
22
|
-
vote: true,
|
|
23
|
-
voteDown: false,
|
|
24
|
-
uaBadge: true,
|
|
25
|
-
listSort: true,
|
|
26
|
-
preview: true,
|
|
27
|
-
countEl: '#ArtalkCount',
|
|
28
|
-
pvEl: '#ArtalkPV',
|
|
29
|
-
|
|
30
|
-
gravatar: {
|
|
31
|
-
mirror: 'https://cravatar.cn/avatar/',
|
|
32
|
-
params: 'd=mp&s=240',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
pagination: {
|
|
36
|
-
pageSize: 20,
|
|
37
|
-
readMore: true,
|
|
38
|
-
autoLoad: true,
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
heightLimit: {
|
|
42
|
-
content: 300,
|
|
43
|
-
children: 400,
|
|
44
|
-
scrollable: false,
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
imgUpload: true,
|
|
48
|
-
reqTimeout: 15000,
|
|
49
|
-
versionCheck: true,
|
|
50
|
-
useBackendConf: true,
|
|
51
|
-
|
|
52
|
-
locale: 'zh-CN',
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (ARTALK_LITE) {
|
|
56
|
-
defaults.vote = false
|
|
57
|
-
defaults.uaBadge = false
|
|
58
|
-
defaults.emoticons = false
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default defaults
|
package/src/editor/editor.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<div class="atk-main-editor">
|
|
2
|
-
<div class="atk-header">
|
|
3
|
-
<input name="nick" class="atk-nick" type="text" required="required">
|
|
4
|
-
<input name="email" class="atk-email" type="email" required="required">
|
|
5
|
-
<input name="link" class="atk-link" type="url">
|
|
6
|
-
</div>
|
|
7
|
-
<div class="atk-textarea-wrap">
|
|
8
|
-
<textarea class="atk-textarea"></textarea>
|
|
9
|
-
</div>
|
|
10
|
-
<div class="atk-plug-panel-wrap" style="display: none;"></div>
|
|
11
|
-
<div class="atk-bottom">
|
|
12
|
-
<div class="atk-item atk-plug-btn-wrap"></div>
|
|
13
|
-
<div class="atk-item">
|
|
14
|
-
<button type="button" class="atk-send-btn"></button>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
<div class="atk-notify-wrap"></div>
|
|
18
|
-
</div>
|
package/src/editor/editor.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { CommentData, ContextApi, EditorApi } from '~/types'
|
|
2
|
-
import Component from '../lib/component'
|
|
3
|
-
import * as Ui from '../lib/ui'
|
|
4
|
-
import marked from '../lib/marked'
|
|
5
|
-
import { render, EditorUI } from './ui'
|
|
6
|
-
import EditorStateManager from './state'
|
|
7
|
-
|
|
8
|
-
class Editor extends Component implements EditorApi {
|
|
9
|
-
private ui: EditorUI
|
|
10
|
-
private state: EditorStateManager
|
|
11
|
-
|
|
12
|
-
getUI() { return this.ui }
|
|
13
|
-
getPlugs() { return this.ctx.get('editorPlugs') }
|
|
14
|
-
getState() { return this.state.get() }
|
|
15
|
-
|
|
16
|
-
constructor(ctx: ContextApi) {
|
|
17
|
-
super(ctx)
|
|
18
|
-
|
|
19
|
-
// init editor ui
|
|
20
|
-
this.ui = render()
|
|
21
|
-
this.$el = this.ui.$el
|
|
22
|
-
|
|
23
|
-
// init state manager
|
|
24
|
-
this.state = new EditorStateManager(this)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getHeaderInputEls() {
|
|
28
|
-
return { nick: this.ui.$nick, email: this.ui.$email, link: this.ui.$link }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getContentFinal() {
|
|
32
|
-
let content = this.getContentRaw()
|
|
33
|
-
|
|
34
|
-
// plug hook: final content transformer
|
|
35
|
-
const plugs = this.getPlugs()
|
|
36
|
-
if (plugs) content = plugs.getTransformedContent(content)
|
|
37
|
-
|
|
38
|
-
return content
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getContentRaw() {
|
|
42
|
-
return this.ui.$textarea.value || ''
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
getContentMarked() {
|
|
46
|
-
return marked(this.getContentFinal())
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
setContent(val: string) {
|
|
50
|
-
this.ui.$textarea.value = val
|
|
51
|
-
|
|
52
|
-
// plug hook: content updated
|
|
53
|
-
this.getPlugs()?.getEvents().trigger('content-updated', val)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
insertContent(val: string) {
|
|
57
|
-
if ((document as any).selection) {
|
|
58
|
-
this.ui.$textarea.focus();
|
|
59
|
-
(document as any).selection.createRange().text = val
|
|
60
|
-
this.ui.$textarea.focus()
|
|
61
|
-
} else if (this.ui.$textarea.selectionStart || this.ui.$textarea.selectionStart === 0) {
|
|
62
|
-
const sStart = this.ui.$textarea.selectionStart
|
|
63
|
-
const sEnd = this.ui.$textarea.selectionEnd
|
|
64
|
-
const sT = this.ui.$textarea.scrollTop
|
|
65
|
-
this.setContent(this.ui.$textarea.value.substring(0, sStart) + val + this.ui.$textarea.value.substring(sEnd, this.ui.$textarea.value.length))
|
|
66
|
-
this.ui.$textarea.focus()
|
|
67
|
-
this.ui.$textarea.selectionStart = sStart + val.length
|
|
68
|
-
this.ui.$textarea.selectionEnd = sStart + val.length
|
|
69
|
-
this.ui.$textarea.scrollTop = sT
|
|
70
|
-
} else {
|
|
71
|
-
this.ui.$textarea.focus()
|
|
72
|
-
this.ui.$textarea.value += val
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
focus() {
|
|
77
|
-
this.ui.$textarea.focus()
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
reset() {
|
|
81
|
-
this.setContent('')
|
|
82
|
-
this.resetState()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
resetState() {
|
|
86
|
-
this.state.switch('normal')
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
setReply(comment: CommentData, $comment: HTMLElement) {
|
|
90
|
-
this.state.switch('reply', { comment, $comment })
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
setEditComment(comment: CommentData, $comment: HTMLElement) {
|
|
94
|
-
this.state.switch('edit', { comment, $comment })
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
showNotify(msg: string, type: any) {
|
|
98
|
-
Ui.showNotify(this.ui.$notifyWrap, msg, type)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
showLoading() {
|
|
102
|
-
Ui.showLoading(this.ui.$el)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
hideLoading() {
|
|
106
|
-
Ui.hideLoading(this.ui.$el)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
submit() {
|
|
110
|
-
this.ctx.trigger('editor-submit')
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default Editor
|
package/src/editor/state.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { EditorState, CommentData } from '~/types'
|
|
2
|
-
import * as Ui from '@/lib/ui'
|
|
3
|
-
import type Editor from './editor'
|
|
4
|
-
import Mover from '../plugins/editor/mover'
|
|
5
|
-
|
|
6
|
-
export default class EditorStateManager {
|
|
7
|
-
constructor(private editor: Editor) {}
|
|
8
|
-
|
|
9
|
-
private stateCurt: EditorState = 'normal'
|
|
10
|
-
private stateUnmountFn: (() => void)|null = null
|
|
11
|
-
|
|
12
|
-
/** Get current state */
|
|
13
|
-
get() {
|
|
14
|
-
return this.stateCurt
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Switch editor state
|
|
19
|
-
*
|
|
20
|
-
* @param state The state to switch
|
|
21
|
-
* @param payload The cause of state switch
|
|
22
|
-
*/
|
|
23
|
-
switch(state: EditorState, payload?: { $comment: HTMLElement, comment: CommentData }) {
|
|
24
|
-
// trigger unmount
|
|
25
|
-
if (this.stateUnmountFn) {
|
|
26
|
-
this.stateUnmountFn()
|
|
27
|
-
this.stateUnmountFn = null
|
|
28
|
-
|
|
29
|
-
// move editor back to the initial position
|
|
30
|
-
this.editor.getPlugs()?.get(Mover)?.back()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// invoke effect function and save unmount function
|
|
34
|
-
if (state !== 'normal' && payload) {
|
|
35
|
-
// move editor position
|
|
36
|
-
let moveAfterEl = payload.$comment
|
|
37
|
-
if (!this.editor.conf.flatMode) moveAfterEl = moveAfterEl.querySelector<HTMLElement>('.atk-footer')!
|
|
38
|
-
this.editor.getPlugs()?.get(Mover)?.move(moveAfterEl)
|
|
39
|
-
|
|
40
|
-
const $relative = this.editor.ctx.conf.scrollRelativeTo && this.editor.ctx.conf.scrollRelativeTo()
|
|
41
|
-
Ui.scrollIntoView(this.editor.getUI().$el, true, $relative)
|
|
42
|
-
|
|
43
|
-
const plugin = this.editor.getPlugs()?.getPlugs().find(p => p.editorStateEffectWhen === state)
|
|
44
|
-
if (plugin && plugin.editorStateEffect) {
|
|
45
|
-
this.stateUnmountFn = plugin.editorStateEffect(payload.comment)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// change current state
|
|
50
|
-
this.stateCurt = state
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/editor/ui.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as Utils from '../lib/utils'
|
|
2
|
-
import EditorHTML from './editor.html?raw'
|
|
3
|
-
|
|
4
|
-
const Sel = {
|
|
5
|
-
$header: '.atk-header',
|
|
6
|
-
$nick: '.atk-header [name="nick"]',
|
|
7
|
-
$email: '.atk-header [name="email"]',
|
|
8
|
-
$link: '.atk-header [name="link"]',
|
|
9
|
-
$textareaWrap: '.atk-textarea-wrap',
|
|
10
|
-
$textarea: '.atk-textarea',
|
|
11
|
-
$bottom: '.atk-bottom',
|
|
12
|
-
$submitBtn: '.atk-send-btn',
|
|
13
|
-
$notifyWrap: '.atk-notify-wrap',
|
|
14
|
-
$plugBtnWrap: '.atk-plug-btn-wrap',
|
|
15
|
-
$plugPanelWrap: '.atk-plug-panel-wrap',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface EditorUI extends Record<keyof typeof Sel, HTMLElement> {
|
|
19
|
-
$el: HTMLElement
|
|
20
|
-
$nick: HTMLInputElement
|
|
21
|
-
$email: HTMLInputElement
|
|
22
|
-
$link: HTMLInputElement
|
|
23
|
-
$textarea: HTMLTextAreaElement
|
|
24
|
-
$submitBtn: HTMLButtonElement
|
|
25
|
-
$sendReply?: HTMLElement
|
|
26
|
-
$editCancelBtn?: HTMLElement
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function render() {
|
|
30
|
-
const $el = Utils.createElement(EditorHTML)
|
|
31
|
-
const ui = { $el }
|
|
32
|
-
Object.entries(Sel).forEach(([k, sel]) => {
|
|
33
|
-
ui[k] = $el.querySelector(sel)
|
|
34
|
-
})
|
|
35
|
-
return ui as EditorUI
|
|
36
|
-
}
|
package/src/i18n/en.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
/* Editor */
|
|
3
|
-
placeholder: 'Leave a comment',
|
|
4
|
-
noComment: 'No Comment',
|
|
5
|
-
send: 'Send',
|
|
6
|
-
save: 'Save',
|
|
7
|
-
nick: 'Nickname',
|
|
8
|
-
email: 'Email',
|
|
9
|
-
link: 'Website',
|
|
10
|
-
emoticon: 'Emoji',
|
|
11
|
-
preview: 'Preview',
|
|
12
|
-
image: 'Image',
|
|
13
|
-
uploadFail: 'Upload Failed',
|
|
14
|
-
commentFail: 'Failed to comment',
|
|
15
|
-
restoredMsg: 'Content has been restored',
|
|
16
|
-
onlyAdminCanReply: 'Only admin can reply',
|
|
17
|
-
uploadLoginMsg: 'Please fill in your name and email to upload',
|
|
18
|
-
|
|
19
|
-
/* List */
|
|
20
|
-
counter: '{count} Comments',
|
|
21
|
-
sortLatest: 'Latest',
|
|
22
|
-
sortOldest: 'Oldest',
|
|
23
|
-
sortBest: 'Best',
|
|
24
|
-
sortAuthor: 'Author',
|
|
25
|
-
openComment: 'Open Comment',
|
|
26
|
-
closeComment: 'Close Comment',
|
|
27
|
-
listLoadFailMsg: 'Failed to load comments',
|
|
28
|
-
listRetry: 'Click to retry',
|
|
29
|
-
loadMore: 'Load More',
|
|
30
|
-
|
|
31
|
-
/* Comment */
|
|
32
|
-
admin: 'Admin',
|
|
33
|
-
reply: 'Reply',
|
|
34
|
-
voteUp: 'Up',
|
|
35
|
-
voteDown: 'Down',
|
|
36
|
-
voteFail: 'Vote Failed',
|
|
37
|
-
readMore: 'Read More',
|
|
38
|
-
actionConfirm: 'Confirm',
|
|
39
|
-
collapse: 'Collapse',
|
|
40
|
-
collapsed: 'Collapsed',
|
|
41
|
-
collapsedMsg: 'This comment has been collapsed',
|
|
42
|
-
expand: 'Expand',
|
|
43
|
-
approved: 'Approved',
|
|
44
|
-
pending: 'Pending',
|
|
45
|
-
pendingMsg: 'Pending, visible only to commenter.',
|
|
46
|
-
edit: 'Edit',
|
|
47
|
-
editCancel: 'Cancel Edit',
|
|
48
|
-
delete: 'Delete',
|
|
49
|
-
deleteConfirm: 'Confirm',
|
|
50
|
-
pin: 'Pin',
|
|
51
|
-
unpin: 'Unpin',
|
|
52
|
-
|
|
53
|
-
/* Time */
|
|
54
|
-
seconds: 'seconds ago',
|
|
55
|
-
minutes: 'minutes ago',
|
|
56
|
-
hours: 'hours ago',
|
|
57
|
-
days: 'days ago',
|
|
58
|
-
now: 'just now',
|
|
59
|
-
|
|
60
|
-
/* Checker */
|
|
61
|
-
adminCheck: 'Enter admin password:',
|
|
62
|
-
captchaCheck: 'Enter the CAPTCHA to continue:',
|
|
63
|
-
confirm: 'Confirm',
|
|
64
|
-
cancel: 'Cancel',
|
|
65
|
-
|
|
66
|
-
/* Sidebar */
|
|
67
|
-
msgCenter: 'Messages',
|
|
68
|
-
ctrlCenter: 'Admin',
|
|
69
|
-
|
|
70
|
-
/* General */
|
|
71
|
-
frontend: 'Frontend',
|
|
72
|
-
backend: 'Backend',
|
|
73
|
-
loading: 'Loading',
|
|
74
|
-
loadFail: 'Load Failed',
|
|
75
|
-
editing: 'Editing',
|
|
76
|
-
editFail: 'Edit Failed',
|
|
77
|
-
deleting: 'Deleting',
|
|
78
|
-
deleteFail: 'Delete Failed',
|
|
79
|
-
reqGot: 'Request got',
|
|
80
|
-
reqAborted: 'Request timed out or terminated unexpectedly',
|
|
81
|
-
}
|
package/src/i18n/external.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { I18n } from '.'
|
|
2
|
-
|
|
3
|
-
export const GLOBAL_LOCALES_KEY = "ArtalkI18n"
|
|
4
|
-
|
|
5
|
-
export function defineLocaleExternal(lang: string, locale: I18n, aliases?: string[]) {
|
|
6
|
-
if (!window[GLOBAL_LOCALES_KEY]) window[GLOBAL_LOCALES_KEY] = {}
|
|
7
|
-
window[GLOBAL_LOCALES_KEY][lang] = locale
|
|
8
|
-
if (aliases) aliases.forEach(l => { window[GLOBAL_LOCALES_KEY][l] = locale })
|
|
9
|
-
return locale
|
|
10
|
-
}
|
package/src/i18n/index.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import en from './en'
|
|
2
|
-
import zhCN from './zh-CN'
|
|
3
|
-
import { GLOBAL_LOCALES_KEY } from './external'
|
|
4
|
-
|
|
5
|
-
export type I18n = typeof en
|
|
6
|
-
export type I18nKeys = keyof I18n
|
|
7
|
-
|
|
8
|
-
// @note the key of language is followed by `ISO 639`
|
|
9
|
-
// https://en.wikipedia.org/wiki/ISO_639
|
|
10
|
-
// https://datatracker.ietf.org/doc/html/rfc5646#section-2.1
|
|
11
|
-
export const internal = {
|
|
12
|
-
'en': en,
|
|
13
|
-
'en-US': en,
|
|
14
|
-
'zh-CN': zhCN,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* find a locale object by language name
|
|
19
|
-
*/
|
|
20
|
-
export function findLocaleSet(lang: string): I18n {
|
|
21
|
-
// normalize a key of language to `ISO 639`
|
|
22
|
-
lang = lang.replace(
|
|
23
|
-
/^([a-zA-Z]+)(-[a-zA-Z]+)?$/,
|
|
24
|
-
(_, p1: string, p2: string) => (p1.toLowerCase() + (p2 || '').toUpperCase())
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
// internal finding
|
|
28
|
-
if (internal[lang]) {
|
|
29
|
-
return internal[lang]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// external finding
|
|
33
|
-
if (window[GLOBAL_LOCALES_KEY] && window[GLOBAL_LOCALES_KEY][lang]) {
|
|
34
|
-
return window[GLOBAL_LOCALES_KEY][lang]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// case when not found:
|
|
38
|
-
// use `en` by default
|
|
39
|
-
return internal.en
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* System locale setting
|
|
44
|
-
*/
|
|
45
|
-
let LocaleConf: I18n|string = 'en'
|
|
46
|
-
let LocaleDict: I18n = findLocaleSet(LocaleConf) // en by default
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Set system locale
|
|
50
|
-
*/
|
|
51
|
-
export function setLocale(locale: I18n|string) {
|
|
52
|
-
if (locale === LocaleConf) return
|
|
53
|
-
LocaleConf = locale
|
|
54
|
-
LocaleDict = (typeof locale === 'string') ? findLocaleSet(locale) : locale
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get an i18n message by key
|
|
59
|
-
*/
|
|
60
|
-
export function t(key: I18nKeys, args: {[key: string]: string} = {}) {
|
|
61
|
-
let str = LocaleDict?.[key] || key
|
|
62
|
-
str = str.replace(/\{\s*(\w+?)\s*\}/g, (_, token) => args[token] || '')
|
|
63
|
-
|
|
64
|
-
return str
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default t
|
package/src/i18n/jp.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { defineLocaleExternal } from './external'
|
|
2
|
-
|
|
3
|
-
export default defineLocaleExternal('jp', {
|
|
4
|
-
/* エディタ */
|
|
5
|
-
placeholder: 'コメントを残す',
|
|
6
|
-
noComment: 'コメントなし',
|
|
7
|
-
send: '送信',
|
|
8
|
-
save: '保存',
|
|
9
|
-
nick: 'ニックネーム',
|
|
10
|
-
email: 'メール',
|
|
11
|
-
link: 'ウェブサイト',
|
|
12
|
-
emoticon: '絵文字',
|
|
13
|
-
preview: 'プレビュー',
|
|
14
|
-
image: '画像',
|
|
15
|
-
uploadFail: 'アップロードに失敗しました',
|
|
16
|
-
commentFail: 'コメントに失敗しました',
|
|
17
|
-
restoredMsg: 'コンテンツが復元されました',
|
|
18
|
-
onlyAdminCanReply: '管理者のみが返信できます',
|
|
19
|
-
uploadLoginMsg: 'アップロードするには、名前とメールアドレスを入力してください',
|
|
20
|
-
|
|
21
|
-
/* リスト */
|
|
22
|
-
counter: '{count} コメント',
|
|
23
|
-
sortLatest: '最新のもの',
|
|
24
|
-
sortOldest: '最も古い',
|
|
25
|
-
sortBest: 'ベスト',
|
|
26
|
-
sortAuthor: '著者',
|
|
27
|
-
openComment: 'コメントを開く',
|
|
28
|
-
closeComment: 'コメントを閉じる',
|
|
29
|
-
listLoadFailMsg: 'コメントの読み込みに失敗しました',
|
|
30
|
-
listRetry: 'クリックで再試行',
|
|
31
|
-
loadMore: 'もっと読み込む',
|
|
32
|
-
|
|
33
|
-
/* コメント */
|
|
34
|
-
admin: '管理者',
|
|
35
|
-
reply: '返信',
|
|
36
|
-
voteUp: 'アップ',
|
|
37
|
-
voteDown: 'ダウン',
|
|
38
|
-
voteFail: '投票に失敗しました',
|
|
39
|
-
readMore: '続きを読む',
|
|
40
|
-
actionConfirm: '確認',
|
|
41
|
-
collapse: '折りたたむ',
|
|
42
|
-
collapsed: '折りたたまれた',
|
|
43
|
-
collapsedMsg: 'このコメントは折りたたまれました',
|
|
44
|
-
expand: '展開',
|
|
45
|
-
approved: '承認されました',
|
|
46
|
-
pending: '保留中',
|
|
47
|
-
pendingMsg: '保留中、コメント投稿者にのみ表示されます',
|
|
48
|
-
edit: '編集',
|
|
49
|
-
editCancel: '編集をキャンセル',
|
|
50
|
-
delete: '削除',
|
|
51
|
-
deleteConfirm: '確認',
|
|
52
|
-
pin: 'ピン',
|
|
53
|
-
unpin: 'ピン外し',
|
|
54
|
-
|
|
55
|
-
/* 時間 */
|
|
56
|
-
seconds: '秒前',
|
|
57
|
-
minutes: '分前',
|
|
58
|
-
hours: '時間前',
|
|
59
|
-
days: '数日前',
|
|
60
|
-
now: 'たった今',
|
|
61
|
-
|
|
62
|
-
/* チェッカー */
|
|
63
|
-
adminCheck: '管理者パスワードを入力してください:',
|
|
64
|
-
captchaCheck: '続けるにはCAPTCHAを入力してください:',
|
|
65
|
-
confirm: '確認',
|
|
66
|
-
cancel: '取消',
|
|
67
|
-
|
|
68
|
-
/* サイドバー */
|
|
69
|
-
msgCenter: 'メッセージ',
|
|
70
|
-
ctrlCenter: 'コンソール',
|
|
71
|
-
|
|
72
|
-
/* 一般 */
|
|
73
|
-
frontend: 'フロントエンド',
|
|
74
|
-
backend: 'バックエンド',
|
|
75
|
-
loading: '読み込み中',
|
|
76
|
-
loadFail: '読み込みに失敗しました',
|
|
77
|
-
editing: '編集中',
|
|
78
|
-
editFail: '編集に失敗しました',
|
|
79
|
-
deleting: '削除中',
|
|
80
|
-
deleteFail: '削除に失敗しました',
|
|
81
|
-
reqGot: 'リクエストを取得しました',
|
|
82
|
-
reqAborted: 'リクエストがタイムアウトしたか、予期せず終了した',
|
|
83
|
-
}, ['jp-JP'])
|
package/src/i18n/zh-CN.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { I18n } from '.'
|
|
2
|
-
|
|
3
|
-
const zhCN: I18n = {
|
|
4
|
-
/* Editor */
|
|
5
|
-
placeholder: '键入内容...',
|
|
6
|
-
noComment: '「此时无声胜有声」',
|
|
7
|
-
send: '发送评论',
|
|
8
|
-
save: '保存评论',
|
|
9
|
-
nick: '昵称',
|
|
10
|
-
email: '邮箱',
|
|
11
|
-
link: '网址',
|
|
12
|
-
emoticon: '表情',
|
|
13
|
-
preview: '预览',
|
|
14
|
-
image: '图片',
|
|
15
|
-
uploadFail: '上传失败',
|
|
16
|
-
commentFail: '评论失败',
|
|
17
|
-
restoredMsg: '内容已自动恢复',
|
|
18
|
-
onlyAdminCanReply: '仅管理员可评论',
|
|
19
|
-
uploadLoginMsg: '填入你的名字邮箱才能上传哦',
|
|
20
|
-
|
|
21
|
-
/* List */
|
|
22
|
-
counter: '{count} 条评论',
|
|
23
|
-
sortLatest: '最新',
|
|
24
|
-
sortOldest: '最早',
|
|
25
|
-
sortBest: '最热',
|
|
26
|
-
sortAuthor: '作者',
|
|
27
|
-
openComment: '打开评论',
|
|
28
|
-
closeComment: '关闭评论',
|
|
29
|
-
listLoadFailMsg: '无法获取评论列表数据',
|
|
30
|
-
listRetry: '点击重新获取',
|
|
31
|
-
loadMore: '加载更多',
|
|
32
|
-
|
|
33
|
-
/* Comment */
|
|
34
|
-
admin: '管理员',
|
|
35
|
-
reply: '回复',
|
|
36
|
-
voteUp: '赞同',
|
|
37
|
-
voteDown: '反对',
|
|
38
|
-
voteFail: '投票失败',
|
|
39
|
-
readMore: '阅读更多',
|
|
40
|
-
actionConfirm: '确认操作',
|
|
41
|
-
collapse: '折叠',
|
|
42
|
-
collapsed: '已折叠',
|
|
43
|
-
collapsedMsg: '该评论已被系统或管理员折叠',
|
|
44
|
-
expand: '展开',
|
|
45
|
-
approved: '已审',
|
|
46
|
-
pending: '待审',
|
|
47
|
-
pendingMsg: '审核中,仅本人可见。',
|
|
48
|
-
edit: '编辑',
|
|
49
|
-
editCancel: '取消编辑',
|
|
50
|
-
delete: '删除',
|
|
51
|
-
deleteConfirm: '确认删除',
|
|
52
|
-
pin: '置顶',
|
|
53
|
-
unpin: '取消置顶',
|
|
54
|
-
|
|
55
|
-
/* Time */
|
|
56
|
-
seconds: '秒前',
|
|
57
|
-
minutes: '分钟前',
|
|
58
|
-
hours: '小时前',
|
|
59
|
-
days: '天前',
|
|
60
|
-
now: '刚刚',
|
|
61
|
-
|
|
62
|
-
/* Checker */
|
|
63
|
-
adminCheck: '键入密码来验证管理员身份:',
|
|
64
|
-
captchaCheck: '键入验证码继续:',
|
|
65
|
-
confirm: '确认',
|
|
66
|
-
cancel: '取消',
|
|
67
|
-
|
|
68
|
-
/* Sidebar */
|
|
69
|
-
msgCenter: '通知中心',
|
|
70
|
-
ctrlCenter: '控制中心',
|
|
71
|
-
|
|
72
|
-
/* General */
|
|
73
|
-
frontend: '前端',
|
|
74
|
-
backend: '后端',
|
|
75
|
-
loading: '加载中',
|
|
76
|
-
loadFail: '加载失败',
|
|
77
|
-
editing: '修改中',
|
|
78
|
-
editFail: '修改失败',
|
|
79
|
-
deleting: '删除中',
|
|
80
|
-
deleteFail: '删除失败',
|
|
81
|
-
reqGot: '请求响应',
|
|
82
|
-
reqAborted: '请求超时或意外终止',
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default zhCN
|
package/src/i18n/zh-TW.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { defineLocaleExternal } from './external'
|
|
2
|
-
|
|
3
|
-
export default defineLocaleExternal('zh-TW', {
|
|
4
|
-
/* Editor */
|
|
5
|
-
placeholder: '鍵入內容...',
|
|
6
|
-
noComment: '「此時無聲勝有聲」',
|
|
7
|
-
send: '發送評論',
|
|
8
|
-
save: '保存評論',
|
|
9
|
-
nick: '昵稱',
|
|
10
|
-
email: '郵箱',
|
|
11
|
-
link: '網址',
|
|
12
|
-
emoticon: '表情',
|
|
13
|
-
preview: '預覽',
|
|
14
|
-
image: '圖片',
|
|
15
|
-
uploadFail: '上傳失敗',
|
|
16
|
-
commentFail: '評論失敗',
|
|
17
|
-
restoredMsg: '內容已自動恢復',
|
|
18
|
-
onlyAdminCanReply: '僅管理員可評論',
|
|
19
|
-
uploadLoginMsg: '填入你的名字郵箱才能上傳哦',
|
|
20
|
-
|
|
21
|
-
/* List */
|
|
22
|
-
counter: '{count} 條評論',
|
|
23
|
-
sortLatest: '最新',
|
|
24
|
-
sortOldest: '最早',
|
|
25
|
-
sortBest: '最熱',
|
|
26
|
-
sortAuthor: '作者',
|
|
27
|
-
openComment: '打開評論',
|
|
28
|
-
closeComment: '關閉評論',
|
|
29
|
-
listLoadFailMsg: '無法獲取評論列表數據',
|
|
30
|
-
listRetry: '點擊重新獲取',
|
|
31
|
-
loadMore: '加載更多',
|
|
32
|
-
|
|
33
|
-
/* Comment */
|
|
34
|
-
admin: '管理員',
|
|
35
|
-
reply: '回覆',
|
|
36
|
-
voteUp: '贊同',
|
|
37
|
-
voteDown: '反對',
|
|
38
|
-
voteFail: '投票失敗',
|
|
39
|
-
readMore: '閱讀更多',
|
|
40
|
-
actionConfirm: '確認操作',
|
|
41
|
-
collapse: '摺疊',
|
|
42
|
-
collapsed: '已摺疊',
|
|
43
|
-
collapsedMsg: '該評論已被系統或管理員摺疊',
|
|
44
|
-
expand: '展開',
|
|
45
|
-
approved: '已審',
|
|
46
|
-
pending: '待審',
|
|
47
|
-
pendingMsg: '審核中,僅本人可見。',
|
|
48
|
-
edit: '編輯',
|
|
49
|
-
editCancel: '取消編輯',
|
|
50
|
-
delete: '刪除',
|
|
51
|
-
deleteConfirm: '確認刪除',
|
|
52
|
-
pin: '置頂',
|
|
53
|
-
unpin: '取消置頂',
|
|
54
|
-
|
|
55
|
-
/* Time */
|
|
56
|
-
seconds: '秒前',
|
|
57
|
-
minutes: '分鐘前',
|
|
58
|
-
hours: '小時前',
|
|
59
|
-
days: '天前',
|
|
60
|
-
now: '剛剛',
|
|
61
|
-
|
|
62
|
-
/* Checker */
|
|
63
|
-
adminCheck: '鍵入密碼來驗證管理員身份:',
|
|
64
|
-
captchaCheck: '鍵入驗證碼繼續:',
|
|
65
|
-
confirm: '確認',
|
|
66
|
-
cancel: '取消',
|
|
67
|
-
|
|
68
|
-
/* Sidebar */
|
|
69
|
-
msgCenter: '通知中心',
|
|
70
|
-
ctrlCenter: '控制中心',
|
|
71
|
-
|
|
72
|
-
/* General */
|
|
73
|
-
frontend: '前端',
|
|
74
|
-
backend: '後端',
|
|
75
|
-
loading: '加載中',
|
|
76
|
-
loadFail: '加載失敗',
|
|
77
|
-
editing: '修改中',
|
|
78
|
-
editFail: '修改失敗',
|
|
79
|
-
deleting: '刪除中',
|
|
80
|
-
deleteFail: '刪除失敗',
|
|
81
|
-
reqGot: '請求響應',
|
|
82
|
-
reqAborted: '請求超時或意外終止',
|
|
83
|
-
})
|