@waline/client 2.0.0-alpha.4 → 2.0.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/dist/component.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/legacy.d.ts +24 -1
- package/dist/legacy.js +1 -1
- package/dist/legacy.js.map +1 -1
- package/dist/pageview.cjs.js +1 -1
- package/dist/pageview.cjs.js.map +1 -1
- package/dist/pageview.d.ts +18 -12
- package/dist/pageview.esm.js +1 -1
- package/dist/pageview.esm.js.map +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/shim.d.ts +90 -18
- package/dist/shim.esm.d.ts +90 -18
- package/dist/shim.esm.js +1 -1
- package/dist/shim.esm.js.map +1 -1
- package/dist/shim.js +1 -1
- package/dist/shim.js.map +1 -1
- package/dist/waline.cjs.d.ts +90 -18
- package/dist/waline.cjs.js +1 -1
- package/dist/waline.cjs.js.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.ts +90 -18
- package/dist/waline.esm.d.ts +90 -18
- package/dist/waline.esm.js +1 -1
- package/dist/waline.esm.js.map +1 -1
- package/dist/waline.js +1 -1
- package/dist/waline.js.map +1 -1
- package/package.json +1 -1
- package/src/comment.ts +25 -2
- package/src/compact/convert.ts +2 -2
- package/src/components/CommentBox.vue +2 -4
- package/src/components/Icons.ts +1 -1
- package/src/components/Waline.vue +22 -22
- package/src/config/default.ts +2 -2
- package/src/entrys/legacy.ts +2 -2
- package/src/init.ts +27 -2
- package/src/pageview.ts +26 -20
- package/src/styles/emoji.scss +1 -1
- package/src/styles/layout.scss +1 -1
- package/src/styles/nomalize.scss +2 -0
- package/src/styles/panel.scss +0 -2
- package/src/typings/options.ts +3 -0
- package/src/utils/markdown.ts +1 -1
- package/src/widgets/recentComments.ts +31 -3
package/package.json
CHANGED
package/src/comment.ts
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
import { useUserInfo } from './composables';
|
|
2
2
|
import { decodePath, errorHandler, fetchCommentCount } from './utils';
|
|
3
|
+
import type { WalineAbort } from './typings';
|
|
3
4
|
|
|
4
|
-
export interface
|
|
5
|
+
export interface WalineCommentCountOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Waline 服务端地址
|
|
8
|
+
*
|
|
9
|
+
* Waline server url
|
|
10
|
+
*/
|
|
5
11
|
serverURL: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 评论数 CSS 选择器
|
|
15
|
+
*
|
|
16
|
+
* Commment count CSS selector
|
|
17
|
+
*
|
|
18
|
+
* @default '.waline-comment-count'
|
|
19
|
+
*/
|
|
6
20
|
selector?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 需要获取的默认路径
|
|
24
|
+
*
|
|
25
|
+
* Path to be fetched by default
|
|
26
|
+
*
|
|
27
|
+
* @default window.location.pathname
|
|
28
|
+
*/
|
|
7
29
|
path?: string;
|
|
8
30
|
}
|
|
9
31
|
|
|
@@ -11,7 +33,8 @@ export const commentCount = ({
|
|
|
11
33
|
serverURL,
|
|
12
34
|
path = window.location.pathname,
|
|
13
35
|
selector = '.waline-comment-count',
|
|
14
|
-
}:
|
|
36
|
+
}: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
WalineCommentCountOptions): WalineAbort => {
|
|
15
38
|
const controller = new AbortController();
|
|
16
39
|
|
|
17
40
|
// comment count
|
package/src/compact/convert.ts
CHANGED
|
@@ -51,12 +51,12 @@ export const covertOptions = (
|
|
|
51
51
|
warning(`Option "${item}" is REMOVED and CAN NOT be polyfilled!`)
|
|
52
52
|
);
|
|
53
53
|
|
|
54
|
-
// warnings with those which
|
|
54
|
+
// warnings with those which is being polyfilled
|
|
55
55
|
DROPPED_OPTIONS_WHICH_CAN_STILL_BE_POLYFILLED.filter(([oldOption]) =>
|
|
56
56
|
Object.keys(options).includes(oldOption)
|
|
57
57
|
).forEach(([oldOption, newOption]) =>
|
|
58
58
|
warning(
|
|
59
|
-
`
|
|
59
|
+
`Deprecated option "${oldOption}" is currently being polyfilled, Please switch to option "${newOption}" in v2!`
|
|
60
60
|
)
|
|
61
61
|
);
|
|
62
62
|
|
|
@@ -58,10 +58,8 @@
|
|
|
58
58
|
@paste="onPaste"
|
|
59
59
|
/>
|
|
60
60
|
|
|
61
|
-
<div
|
|
62
|
-
|
|
63
|
-
:style="{ display: showPreview ? 'block' : 'none' }"
|
|
64
|
-
>
|
|
61
|
+
<div class="wl-preview" v-show="showPreview">
|
|
62
|
+
<hr />
|
|
65
63
|
<h4>{{ locale.preview }}:</h4>
|
|
66
64
|
<div class="wl-content" v-html="previewText" />
|
|
67
65
|
</div>
|
package/src/components/Icons.ts
CHANGED
|
@@ -6,7 +6,19 @@
|
|
|
6
6
|
{{ i18n.comment }}
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
<div
|
|
9
|
+
<div class="wl-cards">
|
|
10
|
+
<CommentCard
|
|
11
|
+
v-for="comment in data"
|
|
12
|
+
:key="comment.objectId"
|
|
13
|
+
:root-id="comment.objectId"
|
|
14
|
+
:comment="comment"
|
|
15
|
+
:reply="reply"
|
|
16
|
+
@reply="onReply"
|
|
17
|
+
@submit="onSubmit"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<div v-if="status === 'error'" class="wl-operation">
|
|
10
22
|
<button
|
|
11
23
|
type="button"
|
|
12
24
|
class="wl-btn"
|
|
@@ -15,27 +27,15 @@
|
|
|
15
27
|
/>
|
|
16
28
|
</div>
|
|
17
29
|
|
|
18
|
-
<div v-else-if="status === 'loading'" class="wl-loading">
|
|
19
|
-
<LoadingIcon :size="30" />
|
|
20
|
-
</div>
|
|
21
|
-
|
|
22
30
|
<template v-else>
|
|
23
|
-
<div v-if="
|
|
24
|
-
|
|
25
|
-
<div v-else class="wl-cards">
|
|
26
|
-
<CommentCard
|
|
27
|
-
v-for="comment in data"
|
|
28
|
-
:key="comment.objectId"
|
|
29
|
-
:root-id="comment.objectId"
|
|
30
|
-
:comment="comment"
|
|
31
|
-
:reply="reply"
|
|
32
|
-
@reply="onReply"
|
|
33
|
-
@submit="onSubmit"
|
|
34
|
-
/>
|
|
31
|
+
<div v-if="status === 'loading'" class="wl-loading">
|
|
32
|
+
<LoadingIcon :size="30" />
|
|
35
33
|
</div>
|
|
36
34
|
|
|
35
|
+
<div v-else-if="!data.length" class="wl-empty" v-text="i18n.sofa" />
|
|
36
|
+
|
|
37
37
|
<!-- Load more button -->
|
|
38
|
-
<div v-if="page < totalPages" class="wl-
|
|
38
|
+
<div v-else-if="page < totalPages" class="wl-operation">
|
|
39
39
|
<button
|
|
40
40
|
type="button"
|
|
41
41
|
class="wl-btn"
|
|
@@ -93,7 +93,7 @@ declare const SHOULD_VALIDATE: boolean;
|
|
|
93
93
|
declare const VERSION: string;
|
|
94
94
|
|
|
95
95
|
export default defineComponent({
|
|
96
|
-
name: '
|
|
96
|
+
name: 'WalineRoot',
|
|
97
97
|
|
|
98
98
|
components: {
|
|
99
99
|
CommentBox,
|
|
@@ -226,12 +226,12 @@ export default defineComponent({
|
|
|
226
226
|
// }),
|
|
227
227
|
},
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
texRenderer: {
|
|
230
230
|
type: Function as PropType<WalineTexRenderer>,
|
|
231
231
|
// default: (blockMode: boolean): string =>
|
|
232
232
|
// blockMode === true
|
|
233
|
-
// ? '<p class="
|
|
234
|
-
// : '<span class="
|
|
233
|
+
// ? '<p class="wl-tex">Tex is not available in preview</p>'
|
|
234
|
+
// : '<span class="wl-tex">Tex is not available in preview</span>',
|
|
235
235
|
},
|
|
236
236
|
},
|
|
237
237
|
|
package/src/config/default.ts
CHANGED
|
@@ -17,5 +17,5 @@ export const defaultUploadImage = (file: File): Promise<string> =>
|
|
|
17
17
|
|
|
18
18
|
export const defaultTexRenderer = (blockMode: boolean): string =>
|
|
19
19
|
blockMode === true
|
|
20
|
-
? '<p class="
|
|
21
|
-
: '<span class="
|
|
20
|
+
? '<p class="wl-tex">Tex is not available in preview</p>'
|
|
21
|
+
: '<span class="wl-tex">Tex is not available in preview</span>';
|
package/src/entrys/legacy.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { WalineInitOptions } from '../typings';
|
|
|
10
10
|
export { WalineInstance } from '../init';
|
|
11
11
|
|
|
12
12
|
warning(
|
|
13
|
-
' This is a legacy package compatable with Valine and Waline@v1, please switch to Waline@v2 using https
|
|
13
|
+
' This is a legacy package compatable with Valine and Waline@v1, please switch to Waline@v2 using https://<CDN.LINK>/@waline/client/dist/waline.js instead!'
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
// inject css styles
|
|
@@ -18,7 +18,7 @@ warning(
|
|
|
18
18
|
const link = document.createElement('link');
|
|
19
19
|
|
|
20
20
|
link.rel = 'stylesheet';
|
|
21
|
-
link.href = '//cdn.jsdelivr.net/npm/@waline/client
|
|
21
|
+
link.href = '//cdn.jsdelivr.net/npm/@waline/client/dist/waline.css';
|
|
22
22
|
|
|
23
23
|
document.head.appendChild(link);
|
|
24
24
|
|
package/src/init.ts
CHANGED
|
@@ -5,11 +5,36 @@ import { commentCount } from './comment';
|
|
|
5
5
|
import { pageviewCount } from './pageview';
|
|
6
6
|
import { getRoot } from './utils';
|
|
7
7
|
|
|
8
|
-
import type { WalineInitOptions
|
|
8
|
+
import type { WalineInitOptions } from './typings';
|
|
9
9
|
|
|
10
10
|
export interface WalineInstance {
|
|
11
|
+
/**
|
|
12
|
+
* Waline 被挂载到的元素
|
|
13
|
+
*
|
|
14
|
+
* @description 当通过 `el: null` 初始化,值为 `null`
|
|
15
|
+
*
|
|
16
|
+
* Element where Waline is mounted
|
|
17
|
+
*
|
|
18
|
+
* @description when initialized with `el: null`, it will be `null`
|
|
19
|
+
*/
|
|
11
20
|
el: HTMLElement | null;
|
|
12
|
-
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 更新 Waline 实例
|
|
24
|
+
*
|
|
25
|
+
* @description 只要不设置`path` 选项,更新时它就会被重置为 `windows.location.pathname`
|
|
26
|
+
*
|
|
27
|
+
* Update Waline instance
|
|
28
|
+
*
|
|
29
|
+
* @description when not setting `path` option, it will be reset to `window.location.pathname`
|
|
30
|
+
*/
|
|
31
|
+
update: (newOptions: Partial<Omit<WalineInitOptions, 'el'>>) => void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 取消挂载并摧毁 Waline 实例
|
|
35
|
+
*
|
|
36
|
+
* Unmount and destroy Waline instance
|
|
37
|
+
*/
|
|
13
38
|
destroy: () => void;
|
|
14
39
|
}
|
|
15
40
|
|
package/src/pageview.ts
CHANGED
|
@@ -5,53 +5,59 @@ import {
|
|
|
5
5
|
updatePageviews,
|
|
6
6
|
} from './utils';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
counts: number[],
|
|
10
|
-
countElements: HTMLElement[]
|
|
11
|
-
): void => {
|
|
12
|
-
countElements.forEach((element, index) => {
|
|
13
|
-
element.innerText = counts[index].toString();
|
|
14
|
-
});
|
|
15
|
-
};
|
|
8
|
+
import type { WalineAbort } from './typings';
|
|
16
9
|
|
|
17
|
-
export interface
|
|
10
|
+
export interface WalinePageviewCountOptions {
|
|
18
11
|
/**
|
|
19
|
-
* Waline server url
|
|
20
|
-
*
|
|
21
12
|
* Waline 服务端地址
|
|
13
|
+
*
|
|
14
|
+
* Waline server url
|
|
22
15
|
*/
|
|
23
16
|
serverURL: string;
|
|
24
17
|
|
|
25
18
|
/**
|
|
26
|
-
*
|
|
19
|
+
* 浏览量 CSS 选择器
|
|
27
20
|
*
|
|
28
|
-
*
|
|
21
|
+
* Pageview CSS selector
|
|
29
22
|
*
|
|
30
|
-
* @default window.location.pathname
|
|
31
|
-
*/
|
|
32
|
-
path?: string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
23
|
* @default '.waline-pageview-count'
|
|
36
24
|
*/
|
|
37
25
|
selector?: string;
|
|
38
26
|
|
|
39
27
|
/**
|
|
40
|
-
*
|
|
28
|
+
* 需要更新和获取的路径
|
|
29
|
+
*
|
|
30
|
+
* Path to be fetched and updated
|
|
41
31
|
*
|
|
32
|
+
* @default window.location.pathname
|
|
33
|
+
*/
|
|
34
|
+
path?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
42
37
|
* 是否在查询时更新 path 的浏览量
|
|
43
38
|
*
|
|
39
|
+
* Whether update pageviews when fetching path result
|
|
40
|
+
*
|
|
44
41
|
* @default true
|
|
45
42
|
*/
|
|
46
43
|
update?: boolean;
|
|
47
44
|
}
|
|
48
45
|
|
|
46
|
+
const renderVisitorCount = (
|
|
47
|
+
counts: number[],
|
|
48
|
+
countElements: HTMLElement[]
|
|
49
|
+
): void => {
|
|
50
|
+
countElements.forEach((element, index) => {
|
|
51
|
+
element.innerText = counts[index].toString();
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
49
55
|
export const pageviewCount = ({
|
|
50
56
|
serverURL,
|
|
51
57
|
path = window.location.pathname,
|
|
52
58
|
selector = '.waline-pageview-count',
|
|
53
59
|
update = true,
|
|
54
|
-
}:
|
|
60
|
+
}: WalinePageviewCountOptions): WalineAbort => {
|
|
55
61
|
const controller = new AbortController();
|
|
56
62
|
|
|
57
63
|
const elements = Array.from(
|
package/src/styles/emoji.scss
CHANGED
package/src/styles/layout.scss
CHANGED
package/src/styles/nomalize.scss
CHANGED
package/src/styles/panel.scss
CHANGED
package/src/typings/options.ts
CHANGED
package/src/utils/markdown.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
export const parseEmoji = (text = '', emojiMap: WalineEmojiMaps = {}): string =>
|
|
11
11
|
text.replace(/:(.+?):/g, (placeholder, key: string) =>
|
|
12
12
|
emojiMap[key]
|
|
13
|
-
? `<img class="
|
|
13
|
+
? `<img class="wl-emoji" src="${emojiMap[key]}" alt="${key}">`
|
|
14
14
|
: placeholder
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -2,14 +2,42 @@ import { fetchRecentComment, getRoot, getUserInfo } from '../utils';
|
|
|
2
2
|
|
|
3
3
|
import type { WalineComment } from '../typings';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface WalineRecentCommentsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Waline 服务端地址
|
|
8
|
+
*
|
|
9
|
+
* Waline serverURL
|
|
10
|
+
*/
|
|
6
11
|
serverURL: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 获取最新评论的数量
|
|
15
|
+
*
|
|
16
|
+
* fetch number of latest comments
|
|
17
|
+
*/
|
|
7
18
|
count: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 需要挂载的元素
|
|
22
|
+
*
|
|
23
|
+
* Element to be mounted
|
|
24
|
+
*/
|
|
8
25
|
el?: string | HTMLElement;
|
|
9
26
|
}
|
|
10
27
|
|
|
11
|
-
export interface
|
|
28
|
+
export interface WalineRecentCommentsResult {
|
|
29
|
+
/**
|
|
30
|
+
* 评论数据
|
|
31
|
+
*
|
|
32
|
+
* Comment Data
|
|
33
|
+
*/
|
|
12
34
|
comments: WalineComment[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 取消挂载挂件
|
|
38
|
+
*
|
|
39
|
+
* Umount widget
|
|
40
|
+
*/
|
|
13
41
|
destroy: () => void;
|
|
14
42
|
}
|
|
15
43
|
|
|
@@ -17,7 +45,7 @@ export const RecentComments = ({
|
|
|
17
45
|
el,
|
|
18
46
|
serverURL,
|
|
19
47
|
count,
|
|
20
|
-
}:
|
|
48
|
+
}: WalineRecentCommentsOptions): Promise<WalineRecentCommentsResult> => {
|
|
21
49
|
const root = getRoot(el);
|
|
22
50
|
const controller = new AbortController();
|
|
23
51
|
|