@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waline/client",
3
- "version": "2.0.4",
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="inputs[kind]"
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="inputs.editor"
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 { useInputs, useUserInfo } from '../composables';
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 inputs = useInputs();
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
- inputs.value.editor =
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
- inputs.value.editor = inputs.value.editor.replace(
341
+ editor.value = editor.value.replace(
340
342
  uploadText,
341
343
  `\r\n![${file.name}](${url})`
342
344
  );
@@ -377,9 +379,9 @@ export default defineComponent({
377
379
 
378
380
  const comment: WalineCommentData = {
379
381
  comment: content.value,
380
- nick: inputs.value.nick,
381
- mail: inputs.value.mail,
382
- link: inputs.value.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
- inputs.value.editor = '';
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
- () => inputs.value.editor,
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
- inputs,
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 Inputs {
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 useInputs = (): RemovableRef<Inputs> =>
12
- useStorage<Inputs>('WALINE_USER_CACHE', {
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', '');
@@ -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/dist/waline.css';
21
+ link.href = '//unpkg.com/@waline/client@v2/dist/waline.css';
22
22
 
23
23
  document.head.appendChild(link);
24
24
 
@@ -50,7 +50,7 @@ export const getConfig = ({
50
50
  path = location.pathname,
51
51
  lang = defaultLang,
52
52
  locale,
53
- emoji = ['https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo'],
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),
@@ -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.link;
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.link = info;
32
+ if (result) emojiStore.value[link] = info;
33
33
 
34
34
  return info;
35
35
  });