@waline/client 2.0.4 → 2.0.5

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.5",
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"
@@ -228,7 +228,7 @@ import {
228
228
  PreviewIcon,
229
229
  LoadingIcon,
230
230
  } from './Icons';
231
- import { useInputs, useUserInfo } from '../composables';
231
+ import { useEditor, useUserMeta, useUserInfo } from '../composables';
232
232
  import {
233
233
  getImagefromDataTransfer,
234
234
  parseMarkdown,
@@ -276,7 +276,8 @@ export default defineComponent({
276
276
  'config'
277
277
  ) as ComputedRef<WalineConfig>;
278
278
 
279
- const inputs = useInputs();
279
+ const editor = useEditor();
280
+ const userMeta = useUserMeta();
280
281
  const userInfo = useUserInfo();
281
282
 
282
283
  const inputRefs = ref<Record<string, HTMLInputElement>>({});
@@ -311,7 +312,7 @@ export default defineComponent({
311
312
  const endPosition = textArea.selectionEnd || 0;
312
313
  const scrollTop = textArea.scrollTop;
313
314
 
314
- inputs.value.editor =
315
+ editor.value =
315
316
  textArea.value.substring(0, startPosition) +
316
317
  content +
317
318
  textArea.value.substring(endPosition, textArea.value.length);
@@ -336,7 +337,7 @@ export default defineComponent({
336
337
  return Promise.resolve()
337
338
  .then(() => (config.value.imageUploader as WalineImageUploader)(file))
338
339
  .then((url) => {
339
- inputs.value.editor = inputs.value.editor.replace(
340
+ editor.value = editor.value.replace(
340
341
  uploadText,
341
342
  `\r\n![${file.name}](${url})`
342
343
  );
@@ -377,9 +378,9 @@ export default defineComponent({
377
378
 
378
379
  const comment: WalineCommentData = {
379
380
  comment: content.value,
380
- nick: inputs.value.nick,
381
- mail: inputs.value.mail,
382
- link: inputs.value.link,
381
+ nick: userMeta.value.nick,
382
+ mail: userMeta.value.mail,
383
+ link: userMeta.value.link,
383
384
  ua: navigator.userAgent,
384
385
  url: config.value.path,
385
386
  };
@@ -449,7 +450,7 @@ export default defineComponent({
449
450
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
450
451
  emit('submit', resp.data!);
451
452
 
452
- inputs.value.editor = '';
453
+ editor.value = '';
453
454
 
454
455
  previewText.value = '';
455
456
 
@@ -577,7 +578,7 @@ export default defineComponent({
577
578
 
578
579
  // watch editor
579
580
  watch(
580
- () => inputs.value.editor,
581
+ () => editor.value,
581
582
  (value) => {
582
583
  const { highlighter, texRenderer } = config.value;
583
584
 
@@ -638,7 +639,8 @@ export default defineComponent({
638
639
  isWordNumberLegal,
639
640
 
640
641
  // inputs
641
- inputs,
642
+ editor,
643
+ userMeta,
642
644
 
643
645
  // emoji
644
646
  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 = '//cdn.jsdelivr.net/npm/@waline/client@v2/dist/waline.css';
22
22
 
23
23
  document.head.appendChild(link);
24
24