@waline/client 2.0.3 → 2.0.4
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.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.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.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.js +1 -1
- package/dist/waline.cjs.js.map +1 -1
- 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/compact/convert.ts +1 -1
- package/src/components/CommentBox.vue +38 -34
- package/src/components/CommentCard.vue +4 -2
- package/src/components/Waline.vue +0 -4
- package/src/pageview.ts +1 -1
- package/src/utils/config.ts +17 -30
- package/src/utils/emoji.ts +3 -3
package/package.json
CHANGED
package/src/compact/convert.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const covertOptions = (
|
|
|
27
27
|
visitor,
|
|
28
28
|
|
|
29
29
|
pageview = visitor === true
|
|
30
|
-
? '.leancloud_visitors,.waline-visitor-count,.waline-pageview-count'
|
|
30
|
+
? '.leancloud_visitors,.leancloud-visitors,.waline-visitor-count,.waline-pageview-count'
|
|
31
31
|
: visitor,
|
|
32
32
|
locale = langMode,
|
|
33
33
|
emoji,
|
|
@@ -235,11 +235,12 @@ import {
|
|
|
235
235
|
getWordNumber,
|
|
236
236
|
parseEmoji,
|
|
237
237
|
postComment,
|
|
238
|
+
getEmojis,
|
|
238
239
|
} from '../utils';
|
|
239
240
|
|
|
240
241
|
import type { ComputedRef, DeepReadonly } from 'vue';
|
|
241
242
|
import type { WalineCommentData, WalineImageUploader } from '../typings';
|
|
242
|
-
import type {
|
|
243
|
+
import type { WalineConfig, WalineEmojiConfig } from '../utils';
|
|
243
244
|
|
|
244
245
|
export default defineComponent({
|
|
245
246
|
name: 'CommentBox',
|
|
@@ -271,7 +272,9 @@ export default defineComponent({
|
|
|
271
272
|
emits: ['submit', 'cancel-reply'],
|
|
272
273
|
|
|
273
274
|
setup(props, { emit }) {
|
|
274
|
-
const config = inject<ComputedRef<
|
|
275
|
+
const config = inject<ComputedRef<WalineConfig>>(
|
|
276
|
+
'config'
|
|
277
|
+
) as ComputedRef<WalineConfig>;
|
|
275
278
|
|
|
276
279
|
const inputs = useInputs();
|
|
277
280
|
const userInfo = useUserInfo();
|
|
@@ -282,7 +285,7 @@ export default defineComponent({
|
|
|
282
285
|
const emojiButtonRef = ref<HTMLDivElement | null>(null);
|
|
283
286
|
const emojiPopupRef = ref<HTMLDivElement | null>(null);
|
|
284
287
|
|
|
285
|
-
const emoji = ref<DeepReadonly<
|
|
288
|
+
const emoji = ref<DeepReadonly<WalineEmojiConfig>>({ tabs: [], map: {} });
|
|
286
289
|
const emojiTabIndex = ref(0);
|
|
287
290
|
const showEmoji = ref(false);
|
|
288
291
|
const showPreview = ref(false);
|
|
@@ -544,37 +547,6 @@ export default defineComponent({
|
|
|
544
547
|
showEmoji.value = false;
|
|
545
548
|
};
|
|
546
549
|
|
|
547
|
-
// watch editor
|
|
548
|
-
watch(
|
|
549
|
-
() => inputs.value.editor,
|
|
550
|
-
(value) => {
|
|
551
|
-
const { highlighter, texRenderer } = config.value;
|
|
552
|
-
|
|
553
|
-
content.value = value;
|
|
554
|
-
previewText.value = parseMarkdown(value, {
|
|
555
|
-
emojiMap: emoji.value.map,
|
|
556
|
-
highlighter,
|
|
557
|
-
texRenderer,
|
|
558
|
-
});
|
|
559
|
-
wordNumber.value = getWordNumber(value);
|
|
560
|
-
|
|
561
|
-
if (editorRef.value)
|
|
562
|
-
if (value) autosize(editorRef.value);
|
|
563
|
-
else autosize.destroy(editorRef.value);
|
|
564
|
-
},
|
|
565
|
-
{ immediate: true }
|
|
566
|
-
);
|
|
567
|
-
|
|
568
|
-
// watch emoji value change
|
|
569
|
-
watch(
|
|
570
|
-
() => config.value.emoji,
|
|
571
|
-
(emojiConfig) =>
|
|
572
|
-
emojiConfig.then((config) => {
|
|
573
|
-
emoji.value = config;
|
|
574
|
-
}),
|
|
575
|
-
{ immediate: true }
|
|
576
|
-
);
|
|
577
|
-
|
|
578
550
|
// update wordNumber
|
|
579
551
|
watch(
|
|
580
552
|
[config, wordNumber],
|
|
@@ -602,6 +574,38 @@ export default defineComponent({
|
|
|
602
574
|
|
|
603
575
|
onMounted(() => {
|
|
604
576
|
document.body.addEventListener('click', popupHandler);
|
|
577
|
+
|
|
578
|
+
// watch editor
|
|
579
|
+
watch(
|
|
580
|
+
() => inputs.value.editor,
|
|
581
|
+
(value) => {
|
|
582
|
+
const { highlighter, texRenderer } = config.value;
|
|
583
|
+
|
|
584
|
+
content.value = value;
|
|
585
|
+
previewText.value = parseMarkdown(value, {
|
|
586
|
+
emojiMap: emoji.value.map,
|
|
587
|
+
highlighter,
|
|
588
|
+
texRenderer,
|
|
589
|
+
});
|
|
590
|
+
wordNumber.value = getWordNumber(value);
|
|
591
|
+
|
|
592
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
593
|
+
if (value) autosize(editorRef.value!);
|
|
594
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
595
|
+
else autosize.destroy(editorRef.value!);
|
|
596
|
+
},
|
|
597
|
+
{ immediate: true }
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
// watch emoji value change
|
|
601
|
+
watch(
|
|
602
|
+
() => config.value.emoji,
|
|
603
|
+
(emojiConfig) =>
|
|
604
|
+
getEmojis(emojiConfig).then((config) => {
|
|
605
|
+
emoji.value = config;
|
|
606
|
+
}),
|
|
607
|
+
{ immediate: true }
|
|
608
|
+
);
|
|
605
609
|
});
|
|
606
610
|
|
|
607
611
|
onUnmounted(() => {
|
|
@@ -73,7 +73,7 @@ import { isLinkHttp } from '../utils';
|
|
|
73
73
|
import { useTimeAgo } from '../composables';
|
|
74
74
|
|
|
75
75
|
import type { ComputedRef, PropType } from 'vue';
|
|
76
|
-
import type {
|
|
76
|
+
import type { WalineConfig } from '../utils';
|
|
77
77
|
import type { WalineComment } from '../typings';
|
|
78
78
|
|
|
79
79
|
export default defineComponent({
|
|
@@ -100,7 +100,9 @@ export default defineComponent({
|
|
|
100
100
|
emits: ['submit', 'reply'],
|
|
101
101
|
|
|
102
102
|
setup(props) {
|
|
103
|
-
const config = inject<ComputedRef<
|
|
103
|
+
const config = inject<ComputedRef<WalineConfig>>(
|
|
104
|
+
'config'
|
|
105
|
+
) as ComputedRef<WalineConfig>;
|
|
104
106
|
const locale = computed(() => config.value.locale);
|
|
105
107
|
|
|
106
108
|
const link = computed(() => {
|
package/src/pageview.ts
CHANGED
package/src/utils/config.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
} from '../config';
|
|
8
8
|
|
|
9
9
|
import { decodePath, isLinkHttp, removeEndingSplash } from './path';
|
|
10
|
-
import { getEmojis } from './emoji';
|
|
11
10
|
|
|
12
11
|
import type {
|
|
13
12
|
WalineEmojiInfo,
|
|
@@ -17,31 +16,15 @@ import type {
|
|
|
17
16
|
} from '../typings';
|
|
18
17
|
import hanabi from 'hanabi';
|
|
19
18
|
|
|
20
|
-
export interface
|
|
19
|
+
export interface WalineEmojiConfig {
|
|
21
20
|
tabs: Pick<WalineEmojiInfo, 'name' | 'icon' | 'items'>[];
|
|
22
21
|
map: WalineEmojiMaps;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
export interface
|
|
26
|
-
extends Required<
|
|
27
|
-
Pick<
|
|
28
|
-
WalineProps,
|
|
29
|
-
| 'path'
|
|
30
|
-
| 'lang'
|
|
31
|
-
| 'meta'
|
|
32
|
-
| 'pageSize'
|
|
33
|
-
| 'requiredMeta'
|
|
34
|
-
| 'imageUploader'
|
|
35
|
-
| 'highlighter'
|
|
36
|
-
| 'texRenderer'
|
|
37
|
-
| 'copyright'
|
|
38
|
-
| 'login'
|
|
39
|
-
>
|
|
40
|
-
>,
|
|
41
|
-
Pick<WalineProps, 'dark' | 'serverURL'> {
|
|
24
|
+
export interface WalineConfig extends Required<Omit<WalineProps, 'wordLimit'>> {
|
|
42
25
|
locale: WalineLocale;
|
|
43
26
|
wordLimit: [number, number] | false;
|
|
44
|
-
emoji: Promise<EmojiConfig>;
|
|
27
|
+
// emoji: Promise<EmojiConfig>;
|
|
45
28
|
}
|
|
46
29
|
|
|
47
30
|
const getServerURL = (serverURL: string): string => {
|
|
@@ -50,6 +33,11 @@ const getServerURL = (serverURL: string): string => {
|
|
|
50
33
|
return isLinkHttp(result) ? result : `https://${result}`;
|
|
51
34
|
};
|
|
52
35
|
|
|
36
|
+
const getWordLimit = (
|
|
37
|
+
wordLimit: WalineProps['wordLimit']
|
|
38
|
+
): [number, number] | false =>
|
|
39
|
+
Array.isArray(wordLimit) ? wordLimit : wordLimit ? [0, wordLimit] : false;
|
|
40
|
+
|
|
53
41
|
const fallback = <T = unknown>(
|
|
54
42
|
value: T | false | undefined,
|
|
55
43
|
fallback: T
|
|
@@ -65,6 +53,7 @@ export const getConfig = ({
|
|
|
65
53
|
emoji = ['https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo'],
|
|
66
54
|
meta = ['nick', 'mail', 'link'],
|
|
67
55
|
requiredMeta = [],
|
|
56
|
+
dark = false,
|
|
68
57
|
pageSize = 10,
|
|
69
58
|
wordLimit,
|
|
70
59
|
imageUploader,
|
|
@@ -73,27 +62,25 @@ export const getConfig = ({
|
|
|
73
62
|
copyright = true,
|
|
74
63
|
login = 'enable',
|
|
75
64
|
...more
|
|
76
|
-
}: WalineProps):
|
|
65
|
+
}: WalineProps): WalineConfig => ({
|
|
77
66
|
serverURL: getServerURL(serverURL),
|
|
78
67
|
path: decodePath(path),
|
|
79
|
-
lang,
|
|
80
68
|
locale: {
|
|
81
69
|
...(locales[lang] || locales[defaultLang]),
|
|
82
70
|
...(typeof locale === 'object' ? locale : {}),
|
|
83
71
|
},
|
|
84
|
-
emoji: getEmojis(emoji),
|
|
85
|
-
wordLimit:
|
|
86
|
-
? wordLimit
|
|
87
|
-
: wordLimit
|
|
88
|
-
? [0, wordLimit]
|
|
89
|
-
: false,
|
|
72
|
+
// emoji: getEmojis(emoji),
|
|
73
|
+
wordLimit: getWordLimit(wordLimit),
|
|
90
74
|
meta: getMeta(meta),
|
|
91
75
|
requiredMeta: getMeta(requiredMeta),
|
|
92
|
-
pageSize,
|
|
93
|
-
login,
|
|
94
76
|
imageUploader: fallback(imageUploader, defaultUploadImage),
|
|
95
77
|
highlighter: fallback(highlighter, hanabi),
|
|
96
78
|
texRenderer: fallback(texRenderer, defaultTexRenderer),
|
|
79
|
+
lang,
|
|
80
|
+
dark,
|
|
81
|
+
emoji,
|
|
82
|
+
pageSize,
|
|
83
|
+
login,
|
|
97
84
|
copyright,
|
|
98
85
|
...more,
|
|
99
86
|
});
|
package/src/utils/emoji.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useStorage } from '@vueuse/core';
|
|
2
2
|
import { removeEndingSplash } from './path';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { WalineEmojiConfig } from './config';
|
|
5
5
|
import type { WalineEmojiInfo } from '../typings';
|
|
6
6
|
|
|
7
7
|
const hasVersion = (url: string): boolean =>
|
|
@@ -40,7 +40,7 @@ const getLink = (name: string, folder = '', prefix = '', type = ''): string =>
|
|
|
40
40
|
|
|
41
41
|
export const getEmojis = (
|
|
42
42
|
emojis: (string | WalineEmojiInfo)[]
|
|
43
|
-
): Promise<
|
|
43
|
+
): Promise<WalineEmojiConfig> =>
|
|
44
44
|
Promise.all(
|
|
45
45
|
emojis.map((emoji) =>
|
|
46
46
|
typeof emoji === 'string'
|
|
@@ -48,7 +48,7 @@ export const getEmojis = (
|
|
|
48
48
|
: Promise.resolve(emoji)
|
|
49
49
|
)
|
|
50
50
|
).then((emojiInfos) => {
|
|
51
|
-
const emojiConfig:
|
|
51
|
+
const emojiConfig: WalineEmojiConfig = {
|
|
52
52
|
tabs: [],
|
|
53
53
|
map: {},
|
|
54
54
|
};
|