@waline/client 2.15.5 → 2.15.7
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/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.mjs.map +1 -1
- package/dist/comment.cjs +1 -1
- package/dist/comment.cjs.map +1 -1
- package/dist/comment.d.cts +1 -1
- package/dist/comment.d.mts +1 -1
- package/dist/comment.d.ts +1 -1
- package/dist/comment.js +1 -1
- package/dist/comment.js.map +1 -1
- package/dist/comment.mjs +1 -1
- package/dist/comment.mjs.map +1 -1
- package/dist/component.mjs +1 -1
- package/dist/component.mjs.map +1 -1
- package/dist/legacy.umd.d.ts +5 -5
- package/dist/legacy.umd.js +1 -1
- package/dist/legacy.umd.js.map +1 -1
- package/dist/pageview.cjs +1 -1
- package/dist/pageview.cjs.map +1 -1
- package/dist/pageview.d.cts +1 -1
- package/dist/pageview.d.mts +1 -1
- package/dist/pageview.d.ts +1 -1
- package/dist/pageview.js +1 -1
- package/dist/pageview.js.map +1 -1
- package/dist/pageview.mjs +1 -1
- package/dist/pageview.mjs.map +1 -1
- package/dist/shim.cjs +1 -1
- package/dist/shim.cjs.map +1 -1
- package/dist/shim.d.cts +3 -3
- package/dist/shim.d.mts +3 -3
- package/dist/shim.mjs +1 -1
- package/dist/shim.mjs.map +1 -1
- package/dist/waline.cjs +1 -1
- package/dist/waline.cjs.map +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.cts +3 -3
- package/dist/waline.d.mts +3 -3
- package/dist/waline.d.ts +3 -3
- package/dist/waline.js +1 -1
- package/dist/waline.js.map +1 -1
- package/dist/waline.mjs +1 -1
- package/dist/waline.mjs.map +1 -1
- package/package.json +13 -11
- package/src/api/articleCounter.ts +2 -2
- package/src/api/comment.ts +2 -2
- package/src/api/commentCount.ts +2 -2
- package/src/api/login.ts +1 -1
- package/src/api/pageview.ts +1 -1
- package/src/api/utils.ts +1 -1
- package/src/comment.ts +1 -1
- package/src/compact/convert.ts +9 -8
- package/src/compact/logger.ts +1 -1
- package/src/compact/v1.ts +3 -3
- package/src/compact/valine.ts +1 -1
- package/src/components/ArticleReaction.vue +12 -5
- package/src/components/CommentBox.vue +10 -11
- package/src/components/CommentCard.vue +6 -6
- package/src/components/Icons.ts +10 -10
- package/src/components/ImageWall.vue +5 -5
- package/src/components/WalineComment.vue +8 -8
- package/src/composables/turnstile.ts +22 -24
- package/src/composables/userInfo.ts +1 -1
- package/src/config/default.ts +6 -6
- package/src/config/highlighter.ts +1 -1
- package/src/config/i18n/generate.ts +1 -1
- package/src/entries/legacy.ts +4 -2
- package/src/pageview.ts +4 -4
- package/src/styles/emoji.scss +3 -1
- package/src/styles/gif.scss +3 -1
- package/src/typings/base.ts +1 -1
- package/src/typings/waline.ts +2 -2
- package/src/utils/config.ts +4 -4
- package/src/utils/date.ts +1 -1
- package/src/utils/emoji.ts +4 -4
- package/src/utils/getRoot.ts +1 -1
- package/src/utils/image.ts +1 -1
- package/src/utils/markdown.ts +6 -6
- package/src/utils/markedMathExtension.ts +3 -3
- package/src/utils/wordCount.ts +1 -1
- package/src/widgets/recentComments.ts +1 -1
- package/src/widgets/userList.ts +1 -1
package/src/config/default.ts
CHANGED
|
@@ -39,10 +39,10 @@ export const defaultUploadImage = (file: File): Promise<string> =>
|
|
|
39
39
|
reader.onerror = reject;
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
export const
|
|
42
|
+
export const defaultTeXRenderer = (blockMode: boolean): string =>
|
|
43
43
|
blockMode === true
|
|
44
|
-
? '<p class="wl-tex">
|
|
45
|
-
: '<span class="wl-tex">
|
|
44
|
+
? '<p class="wl-tex">TeX is not available in preview</p>'
|
|
45
|
+
: '<span class="wl-tex">TeX is not available in preview</span>';
|
|
46
46
|
|
|
47
47
|
export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
|
|
48
48
|
interface GifResult {
|
|
@@ -63,7 +63,7 @@ export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
|
|
|
63
63
|
|
|
64
64
|
const fetchGiphy = async (
|
|
65
65
|
url: string,
|
|
66
|
-
params: Record<string, string> = {}
|
|
66
|
+
params: Record<string, string> = {},
|
|
67
67
|
): Promise<WalineSearchResult> =>
|
|
68
68
|
fetch(
|
|
69
69
|
`https://api.giphy.com/v1/gifs/${url}?${new URLSearchParams({
|
|
@@ -73,14 +73,14 @@ export const getDefaultSearchOptions = (lang: string): WalineSearchOptions => {
|
|
|
73
73
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
74
74
|
api_key: '6CIMLkNMMOhRcXPoMCPkFy4Ybk2XUiMp',
|
|
75
75
|
...params,
|
|
76
|
-
}).toString()}
|
|
76
|
+
}).toString()}`,
|
|
77
77
|
)
|
|
78
78
|
.then((resp) => <Promise<GifResult>>resp.json())
|
|
79
79
|
.then(({ data }) =>
|
|
80
80
|
data.map((gif) => ({
|
|
81
81
|
title: gif.title,
|
|
82
82
|
src: gif.images.downsized_medium.url,
|
|
83
|
-
}))
|
|
83
|
+
})),
|
|
84
84
|
);
|
|
85
85
|
|
|
86
86
|
return {
|
|
@@ -30,7 +30,7 @@ const LINE_COMMENT_REGEXP = /(?:^|\s)\/\/(.+?)$/gm;
|
|
|
30
30
|
const BLOCK_COMMENT_REGEXP = /\/\*([\S\s]*?)\*\//gm;
|
|
31
31
|
const REGEXP = new RegExp(
|
|
32
32
|
`(${WORD_REGEXP.source}|${LEFT_ANGLE_REGEXP.source})|((?:${LINE_COMMENT_REGEXP.source})|(?:${BLOCK_COMMENT_REGEXP.source}))`,
|
|
33
|
-
'gmi'
|
|
33
|
+
'gmi',
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
const COLORS = [
|
package/src/entries/legacy.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type WalineInitOptions } from '../typings/index.js';
|
|
|
10
10
|
export { WalineInstance } from '../init.js';
|
|
11
11
|
|
|
12
12
|
warning(
|
|
13
|
-
' This is a legacy package compatible with Valine and Waline@v1, please switch to Waline@v2 using https://<CDN.LINK>/@waline/client/dist/waline.js instead!'
|
|
13
|
+
' This is a legacy package compatible 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
|
|
@@ -23,7 +23,9 @@ link.href = '//unpkg.com/@waline/client@v2/dist/waline.css';
|
|
|
23
23
|
document.head.appendChild(link);
|
|
24
24
|
|
|
25
25
|
export default function legacyWaline(
|
|
26
|
-
options: WalineInitOptions &
|
|
26
|
+
options: WalineInitOptions &
|
|
27
|
+
DeprecatedValineOptions &
|
|
28
|
+
DeprecatedWalineOptions,
|
|
27
29
|
): WalineInstance | null {
|
|
28
30
|
return init(covertOptions(options));
|
|
29
31
|
}
|
package/src/pageview.ts
CHANGED
|
@@ -49,7 +49,7 @@ export interface WalinePageviewCountOptions {
|
|
|
49
49
|
|
|
50
50
|
const renderVisitorCount = (
|
|
51
51
|
counts: number[],
|
|
52
|
-
countElements: HTMLElement[]
|
|
52
|
+
countElements: HTMLElement[],
|
|
53
53
|
): void => {
|
|
54
54
|
countElements.forEach((element, index) => {
|
|
55
55
|
element.innerText = counts[index].toString();
|
|
@@ -67,7 +67,7 @@ export const pageviewCount = ({
|
|
|
67
67
|
|
|
68
68
|
const elements = Array.from(
|
|
69
69
|
// pageview selectors
|
|
70
|
-
document.querySelectorAll<HTMLElement>(selector)
|
|
70
|
+
document.querySelectorAll<HTMLElement>(selector),
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
const filter = (element: HTMLElement): boolean => {
|
|
@@ -98,8 +98,8 @@ export const pageviewCount = ({
|
|
|
98
98
|
}).then((count) =>
|
|
99
99
|
renderVisitorCount(
|
|
100
100
|
new Array<number>(normalElements.length).fill(count),
|
|
101
|
-
normalElements
|
|
102
|
-
)
|
|
101
|
+
normalElements,
|
|
102
|
+
),
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
// if we should fetch count of other pages
|
package/src/styles/emoji.scss
CHANGED
package/src/styles/gif.scss
CHANGED
package/src/typings/base.ts
CHANGED
|
@@ -120,4 +120,4 @@ export type WalineImageUploader = (image: File) => Promise<string>;
|
|
|
120
120
|
|
|
121
121
|
export type WalineHighlighter = (code: string, lang: string) => string;
|
|
122
122
|
|
|
123
|
-
export type
|
|
123
|
+
export type WalineTeXRenderer = (blockMode: boolean, tex: string) => string;
|
package/src/typings/waline.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type WalineImageUploader,
|
|
7
7
|
type WalineLoginStatus,
|
|
8
8
|
type WalineMeta,
|
|
9
|
-
type
|
|
9
|
+
type WalineTeXRenderer,
|
|
10
10
|
type WalineSearchOptions,
|
|
11
11
|
} from './base.js';
|
|
12
12
|
import { type WalineLocale } from './locale.js';
|
|
@@ -201,7 +201,7 @@ export interface WalineProps {
|
|
|
201
201
|
*
|
|
202
202
|
* @default true
|
|
203
203
|
*/
|
|
204
|
-
texRenderer?:
|
|
204
|
+
texRenderer?: WalineTeXRenderer | boolean;
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
207
|
*
|
package/src/utils/config.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
DEFAULT_REACTION,
|
|
7
7
|
defaultUploadImage,
|
|
8
8
|
defaultHighlighter,
|
|
9
|
-
|
|
9
|
+
defaultTeXRenderer,
|
|
10
10
|
getDefaultSearchOptions,
|
|
11
11
|
getMeta,
|
|
12
12
|
} from '../config/index.js';
|
|
@@ -52,13 +52,13 @@ export const getServerURL = (serverURL: string): string => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
const getWordLimit = (
|
|
55
|
-
wordLimit: WalineProps['wordLimit']
|
|
55
|
+
wordLimit: WalineProps['wordLimit'],
|
|
56
56
|
): [number, number] | false =>
|
|
57
57
|
Array.isArray(wordLimit) ? wordLimit : wordLimit ? [0, wordLimit] : false;
|
|
58
58
|
|
|
59
59
|
const fallback = <T = unknown>(
|
|
60
60
|
value: T | boolean | undefined,
|
|
61
|
-
fallback: T
|
|
61
|
+
fallback: T,
|
|
62
62
|
): T | false =>
|
|
63
63
|
typeof value === 'function' ? value : value === false ? false : fallback;
|
|
64
64
|
|
|
@@ -97,7 +97,7 @@ export const getConfig = ({
|
|
|
97
97
|
requiredMeta: getMeta(requiredMeta),
|
|
98
98
|
imageUploader: fallback(imageUploader, defaultUploadImage),
|
|
99
99
|
highlighter: fallback(highlighter, defaultHighlighter),
|
|
100
|
-
texRenderer: fallback(texRenderer,
|
|
100
|
+
texRenderer: fallback(texRenderer, defaultTeXRenderer),
|
|
101
101
|
lang: Object.keys(DEFAULT_LOCALES).includes(lang) ? lang : 'en-US',
|
|
102
102
|
dark,
|
|
103
103
|
emoji: typeof emoji === 'boolean' ? (emoji ? DEFAULT_EMOJI : []) : emoji,
|
package/src/utils/date.ts
CHANGED
package/src/utils/emoji.ts
CHANGED
|
@@ -10,7 +10,7 @@ const hasVersion = (url: string): boolean =>
|
|
|
10
10
|
const fetchEmoji = (link: string): Promise<WalineEmojiInfo> => {
|
|
11
11
|
const emojiStore = useStorage<Record<string, WalineEmojiInfo>>(
|
|
12
12
|
'WALINE_EMOJI',
|
|
13
|
-
{}
|
|
13
|
+
{},
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
const result = hasVersion(link);
|
|
@@ -39,14 +39,14 @@ const getLink = (name: string, folder = '', prefix = '', type = ''): string =>
|
|
|
39
39
|
`${folder ? `${folder}/` : ''}${prefix}${name}${type ? `.${type}` : ''}`;
|
|
40
40
|
|
|
41
41
|
export const getEmojis = (
|
|
42
|
-
emojis: (string | WalineEmojiInfo)[]
|
|
42
|
+
emojis: (string | WalineEmojiInfo)[],
|
|
43
43
|
): Promise<WalineEmojiConfig> =>
|
|
44
44
|
Promise.all(
|
|
45
45
|
emojis.map((emoji) =>
|
|
46
46
|
typeof emoji === 'string'
|
|
47
47
|
? fetchEmoji(removeEndingSplash(emoji))
|
|
48
|
-
: Promise.resolve(emoji)
|
|
49
|
-
)
|
|
48
|
+
: Promise.resolve(emoji),
|
|
49
|
+
),
|
|
50
50
|
).then((emojiInfos) => {
|
|
51
51
|
const emojiConfig: WalineEmojiConfig = {
|
|
52
52
|
tabs: [],
|
package/src/utils/getRoot.ts
CHANGED
package/src/utils/image.ts
CHANGED
package/src/utils/markdown.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { marked } from 'marked';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { markedTeXExtensions } from './markedMathExtension.js';
|
|
4
4
|
import {
|
|
5
5
|
type WalineEmojiMaps,
|
|
6
6
|
type WalineHighlighter,
|
|
7
|
-
type
|
|
7
|
+
type WalineTeXRenderer,
|
|
8
8
|
} from '../typings/index.js';
|
|
9
9
|
|
|
10
10
|
export const parseEmoji = (text = '', emojiMap: WalineEmojiMaps = {}): string =>
|
|
11
11
|
text.replace(/:(.+?):/g, (placeholder, key: string) =>
|
|
12
12
|
emojiMap[key]
|
|
13
13
|
? `<img class="wl-emoji" src="${emojiMap[key]}" alt="${key}">`
|
|
14
|
-
: placeholder
|
|
14
|
+
: placeholder,
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
export interface ParseMarkdownOptions {
|
|
18
18
|
emojiMap: WalineEmojiMaps;
|
|
19
19
|
highlighter: WalineHighlighter | false;
|
|
20
|
-
texRenderer:
|
|
20
|
+
texRenderer: WalineTeXRenderer | false;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const parseMarkdown = (
|
|
24
24
|
content: string,
|
|
25
|
-
{ emojiMap, highlighter, texRenderer }: ParseMarkdownOptions
|
|
25
|
+
{ emojiMap, highlighter, texRenderer }: ParseMarkdownOptions,
|
|
26
26
|
): string => {
|
|
27
27
|
marked.setOptions({
|
|
28
28
|
highlight: highlighter || undefined,
|
|
@@ -32,7 +32,7 @@ export const parseMarkdown = (
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
if (texRenderer) {
|
|
35
|
-
const extensions =
|
|
35
|
+
const extensions = markedTeXExtensions(texRenderer);
|
|
36
36
|
|
|
37
37
|
marked.use({ extensions });
|
|
38
38
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type marked } from 'marked';
|
|
2
2
|
|
|
3
|
-
import { type
|
|
3
|
+
import { type WalineTeXRenderer } from '../typings/index.js';
|
|
4
4
|
|
|
5
5
|
const inlineMathStart = /\$.*?\$/;
|
|
6
6
|
const inlineMathReg = /^\$(.*?)\$/;
|
|
7
7
|
const blockMathReg = /^(?:\s{0,3})\$\$((?:[^\n]|\n[^\n])+?)\n{0,1}\$\$/;
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
texRenderer:
|
|
9
|
+
export const markedTeXExtensions = (
|
|
10
|
+
texRenderer: WalineTeXRenderer,
|
|
11
11
|
): marked.TokenizerExtension[] => {
|
|
12
12
|
const blockMathExtension: marked.TokenizerExtension = {
|
|
13
13
|
name: 'blockMath',
|
package/src/utils/wordCount.ts
CHANGED
|
@@ -72,7 +72,7 @@ export const RecentComments = ({
|
|
|
72
72
|
root.innerHTML = `<ul class="wl-recent-list">${comments
|
|
73
73
|
.map(
|
|
74
74
|
(comment) =>
|
|
75
|
-
`<li class="wl-recent-item"><a href="${comment.url}">${comment.nick}</a>:${comment.comment}</li
|
|
75
|
+
`<li class="wl-recent-item"><a href="${comment.url}">${comment.nick}</a>:${comment.comment}</li>`,
|
|
76
76
|
)
|
|
77
77
|
.join('')}</ul>`;
|
|
78
78
|
|