@waline/client 2.0.4 → 2.0.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/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.esm.js +1 -1
- package/dist/pageview.js +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 +2 -1
- package/src/components/CommentBox.vue +15 -12
- package/src/composables/inputs.ts +6 -5
- package/src/entrys/legacy.ts +1 -1
- package/src/utils/config.ts +1 -2
- package/src/utils/emoji.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./dist": "./dist/shim.js",
|
|
28
28
|
"./dist/waline.css": "./dist/waline.css",
|
|
29
29
|
"./dist/*": "./dist/*.js",
|
|
30
|
+
"./src/*": "./src/*",
|
|
30
31
|
"./package.json": "./package.json"
|
|
31
32
|
},
|
|
32
33
|
"main": "./dist/shim.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
:class="['wl-input', `wl-${kind}`]"
|
|
43
43
|
:name="kind"
|
|
44
44
|
:type="kind === 'mail' ? 'email' : 'text'"
|
|
45
|
-
v-model="
|
|
45
|
+
v-model="userMeta[kind]"
|
|
46
46
|
/>
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
ref="editorRef"
|
|
53
53
|
id="wl-edit"
|
|
54
54
|
:placeholder="replyUser ? `@${replyUser}` : locale.placeholder"
|
|
55
|
-
v-model="
|
|
55
|
+
v-model="editor"
|
|
56
56
|
@keydown="onKeyDown"
|
|
57
57
|
@drop="onDrop"
|
|
58
58
|
@paste="onPaste"
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
</a>
|
|
79
79
|
|
|
80
80
|
<button
|
|
81
|
+
v-show="config.emoji.length"
|
|
81
82
|
ref="emojiButtonRef"
|
|
82
83
|
class="wl-action"
|
|
83
84
|
:class="{ actived: showEmoji }"
|
|
@@ -228,7 +229,7 @@ import {
|
|
|
228
229
|
PreviewIcon,
|
|
229
230
|
LoadingIcon,
|
|
230
231
|
} from './Icons';
|
|
231
|
-
import {
|
|
232
|
+
import { useEditor, useUserMeta, useUserInfo } from '../composables';
|
|
232
233
|
import {
|
|
233
234
|
getImagefromDataTransfer,
|
|
234
235
|
parseMarkdown,
|
|
@@ -276,7 +277,8 @@ export default defineComponent({
|
|
|
276
277
|
'config'
|
|
277
278
|
) as ComputedRef<WalineConfig>;
|
|
278
279
|
|
|
279
|
-
const
|
|
280
|
+
const editor = useEditor();
|
|
281
|
+
const userMeta = useUserMeta();
|
|
280
282
|
const userInfo = useUserInfo();
|
|
281
283
|
|
|
282
284
|
const inputRefs = ref<Record<string, HTMLInputElement>>({});
|
|
@@ -311,7 +313,7 @@ export default defineComponent({
|
|
|
311
313
|
const endPosition = textArea.selectionEnd || 0;
|
|
312
314
|
const scrollTop = textArea.scrollTop;
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
editor.value =
|
|
315
317
|
textArea.value.substring(0, startPosition) +
|
|
316
318
|
content +
|
|
317
319
|
textArea.value.substring(endPosition, textArea.value.length);
|
|
@@ -336,7 +338,7 @@ export default defineComponent({
|
|
|
336
338
|
return Promise.resolve()
|
|
337
339
|
.then(() => (config.value.imageUploader as WalineImageUploader)(file))
|
|
338
340
|
.then((url) => {
|
|
339
|
-
|
|
341
|
+
editor.value = editor.value.replace(
|
|
340
342
|
uploadText,
|
|
341
343
|
`\r\n`
|
|
342
344
|
);
|
|
@@ -377,9 +379,9 @@ export default defineComponent({
|
|
|
377
379
|
|
|
378
380
|
const comment: WalineCommentData = {
|
|
379
381
|
comment: content.value,
|
|
380
|
-
nick:
|
|
381
|
-
mail:
|
|
382
|
-
link:
|
|
382
|
+
nick: userMeta.value.nick,
|
|
383
|
+
mail: userMeta.value.mail,
|
|
384
|
+
link: userMeta.value.link,
|
|
383
385
|
ua: navigator.userAgent,
|
|
384
386
|
url: config.value.path,
|
|
385
387
|
};
|
|
@@ -449,7 +451,7 @@ export default defineComponent({
|
|
|
449
451
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
450
452
|
emit('submit', resp.data!);
|
|
451
453
|
|
|
452
|
-
|
|
454
|
+
editor.value = '';
|
|
453
455
|
|
|
454
456
|
previewText.value = '';
|
|
455
457
|
|
|
@@ -577,7 +579,7 @@ export default defineComponent({
|
|
|
577
579
|
|
|
578
580
|
// watch editor
|
|
579
581
|
watch(
|
|
580
|
-
() =>
|
|
582
|
+
() => editor.value,
|
|
581
583
|
(value) => {
|
|
582
584
|
const { highlighter, texRenderer } = config.value;
|
|
583
585
|
|
|
@@ -638,7 +640,8 @@ export default defineComponent({
|
|
|
638
640
|
isWordNumberLegal,
|
|
639
641
|
|
|
640
642
|
// inputs
|
|
641
|
-
|
|
643
|
+
editor,
|
|
644
|
+
userMeta,
|
|
642
645
|
|
|
643
646
|
// emoji
|
|
644
647
|
emoji,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { useStorage } from '@vueuse/core';
|
|
2
2
|
import type { RemovableRef } from '@vueuse/core';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface UserMeta {
|
|
5
5
|
nick: string;
|
|
6
6
|
mail: string;
|
|
7
7
|
link: string;
|
|
8
|
-
editor: string;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export const
|
|
12
|
-
useStorage<
|
|
10
|
+
export const useUserMeta = (): RemovableRef<UserMeta> =>
|
|
11
|
+
useStorage<UserMeta>('WALINE_USER_META', {
|
|
13
12
|
nick: '',
|
|
14
13
|
mail: '',
|
|
15
14
|
link: '',
|
|
16
|
-
editor: '',
|
|
17
15
|
});
|
|
16
|
+
|
|
17
|
+
export const useEditor = (): RemovableRef<string> =>
|
|
18
|
+
useStorage<string>('WALINE_COMMENT_BOX_EDITOR', '');
|
package/src/entrys/legacy.ts
CHANGED
|
@@ -18,7 +18,7 @@ warning(
|
|
|
18
18
|
const link = document.createElement('link');
|
|
19
19
|
|
|
20
20
|
link.rel = 'stylesheet';
|
|
21
|
-
link.href = '//
|
|
21
|
+
link.href = '//unpkg.com/@waline/client@v2/dist/waline.css';
|
|
22
22
|
|
|
23
23
|
document.head.appendChild(link);
|
|
24
24
|
|
package/src/utils/config.ts
CHANGED
|
@@ -50,7 +50,7 @@ export const getConfig = ({
|
|
|
50
50
|
path = location.pathname,
|
|
51
51
|
lang = defaultLang,
|
|
52
52
|
locale,
|
|
53
|
-
emoji = ['
|
|
53
|
+
emoji = ['//unpkg.com/@waline/emojis@1.0.1/weibo'],
|
|
54
54
|
meta = ['nick', 'mail', 'link'],
|
|
55
55
|
requiredMeta = [],
|
|
56
56
|
dark = false,
|
|
@@ -69,7 +69,6 @@ export const getConfig = ({
|
|
|
69
69
|
...(locales[lang] || locales[defaultLang]),
|
|
70
70
|
...(typeof locale === 'object' ? locale : {}),
|
|
71
71
|
},
|
|
72
|
-
// emoji: getEmojis(emoji),
|
|
73
72
|
wordLimit: getWordLimit(wordLimit),
|
|
74
73
|
meta: getMeta(meta),
|
|
75
74
|
requiredMeta: getMeta(requiredMeta),
|
package/src/utils/emoji.ts
CHANGED
|
@@ -16,7 +16,7 @@ const fetchEmoji = (link: string): Promise<WalineEmojiInfo> => {
|
|
|
16
16
|
const result = hasVersion(link);
|
|
17
17
|
|
|
18
18
|
if (result) {
|
|
19
|
-
const info = emojiStore.value
|
|
19
|
+
const info = emojiStore.value[link];
|
|
20
20
|
|
|
21
21
|
if (info) return Promise.resolve(info);
|
|
22
22
|
}
|
|
@@ -29,7 +29,7 @@ const fetchEmoji = (link: string): Promise<WalineEmojiInfo> => {
|
|
|
29
29
|
...emojiInfo,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
if (result) emojiStore.value
|
|
32
|
+
if (result) emojiStore.value[link] = info;
|
|
33
33
|
|
|
34
34
|
return info;
|
|
35
35
|
});
|