@waline/client 2.7.1 → 2.8.0
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.esm.js +1 -1
- package/dist/component.esm.js.map +1 -1
- 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.d.ts +5 -0
- package/dist/shim.esm.d.ts +5 -0
- 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.d.ts +5 -0
- package/dist/waline.cjs.js +1 -1
- package/dist/waline.cjs.js.map +1 -1
- package/dist/waline.css +1 -1
- package/dist/waline.css.map +1 -1
- package/dist/waline.d.ts +5 -0
- package/dist/waline.esm.d.ts +5 -0
- 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 +8 -8
- package/src/components/CommentBox.vue +16 -4
- package/src/components/CommentCard.vue +35 -9
- package/src/components/Icons.ts +10 -0
- package/src/components/Waline.vue +13 -1
- package/src/styles/card.scss +2 -5
- package/src/typings/comment.ts +6 -0
- package/src/utils/fetch.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -83,25 +83,25 @@
|
|
|
83
83
|
"@vueuse/core": "^9.2.0",
|
|
84
84
|
"autosize": "^5.0.1",
|
|
85
85
|
"marked": "^4.1.0",
|
|
86
|
-
"vue": "^3.2.
|
|
86
|
+
"vue": "^3.2.39"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@babel/core": "7.
|
|
90
|
-
"@babel/preset-env": "7.
|
|
89
|
+
"@babel/core": "7.19.0",
|
|
90
|
+
"@babel/preset-env": "7.19.0",
|
|
91
91
|
"@rollup/plugin-babel": "5.3.1",
|
|
92
92
|
"@rollup/plugin-commonjs": "22.0.2",
|
|
93
|
-
"@rollup/plugin-node-resolve": "
|
|
93
|
+
"@rollup/plugin-node-resolve": "14.0.1",
|
|
94
94
|
"@rollup/plugin-replace": "4.0.0",
|
|
95
95
|
"@types/autosize": "4.0.1",
|
|
96
|
-
"@types/marked": "4.0.
|
|
97
|
-
"@types/node": "18.7.
|
|
96
|
+
"@types/marked": "4.0.7",
|
|
97
|
+
"@types/node": "18.7.16",
|
|
98
98
|
"@vitejs/plugin-vue": "3.1.0",
|
|
99
99
|
"rimraf": "3.0.2",
|
|
100
100
|
"rollup": "2.79.0",
|
|
101
101
|
"rollup-plugin-dts": "4.2.2",
|
|
102
102
|
"rollup-plugin-terser": "7.0.2",
|
|
103
103
|
"rollup-plugin-ts": "3.0.2",
|
|
104
|
-
"typescript": "4.8.
|
|
104
|
+
"typescript": "4.8.3",
|
|
105
105
|
"vite": "3.1.0"
|
|
106
106
|
},
|
|
107
107
|
"engines": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="wl-comment">
|
|
3
|
-
<div v-if="config.login !== 'disable' && isLogin" class="wl-login-info">
|
|
3
|
+
<div v-if="config.login !== 'disable' && isLogin && !edit?.objectId" class="wl-login-info">
|
|
4
4
|
<div class="wl-avatar">
|
|
5
5
|
<button class="wl-logout-btn" :title="locale.logout" @click="onLogout">
|
|
6
6
|
<CloseIcon :size="14" />
|
|
@@ -248,10 +248,10 @@
|
|
|
248
248
|
</div>
|
|
249
249
|
|
|
250
250
|
<button
|
|
251
|
-
v-if="replyId"
|
|
251
|
+
v-if="replyId || edit?.objectId"
|
|
252
252
|
class="wl-close"
|
|
253
253
|
:title="locale.cancelReply"
|
|
254
|
-
@click="$emit('cancel-reply')"
|
|
254
|
+
@click="$emit(replyId ? 'cancel-reply' : 'cancel-edit')"
|
|
255
255
|
>
|
|
256
256
|
<CloseIcon :size="24" />
|
|
257
257
|
</button>
|
|
@@ -267,6 +267,7 @@ import {
|
|
|
267
267
|
inject,
|
|
268
268
|
onMounted,
|
|
269
269
|
onUnmounted,
|
|
270
|
+
PropType,
|
|
270
271
|
reactive,
|
|
271
272
|
ref,
|
|
272
273
|
watch,
|
|
@@ -294,6 +295,7 @@ import {
|
|
|
294
295
|
|
|
295
296
|
import type { ComputedRef, DeepReadonly } from 'vue';
|
|
296
297
|
import type {
|
|
298
|
+
WalineComment,
|
|
297
299
|
WalineCommentData,
|
|
298
300
|
WalineImageUploader,
|
|
299
301
|
WalineSearchOptions,
|
|
@@ -328,9 +330,13 @@ export default defineComponent({
|
|
|
328
330
|
type: String,
|
|
329
331
|
default: '',
|
|
330
332
|
},
|
|
333
|
+
edit: {
|
|
334
|
+
type: Object as PropType<WalineComment | null>,
|
|
335
|
+
default: null,
|
|
336
|
+
},
|
|
331
337
|
},
|
|
332
338
|
|
|
333
|
-
emits: ['submit', 'cancel-reply'],
|
|
339
|
+
emits: ['submit', 'cancel-reply', 'cancel-edit'],
|
|
334
340
|
|
|
335
341
|
setup(props, { emit }) {
|
|
336
342
|
const config = inject<ComputedRef<WalineConfig>>(
|
|
@@ -510,6 +516,8 @@ export default defineComponent({
|
|
|
510
516
|
comment.pid = props.replyId;
|
|
511
517
|
comment.rid = props.rootId;
|
|
512
518
|
comment.at = props.replyUser;
|
|
519
|
+
} else if (props.edit) {
|
|
520
|
+
comment.eid = props.edit.objectId;
|
|
513
521
|
}
|
|
514
522
|
|
|
515
523
|
isSubmitting.value = true;
|
|
@@ -532,6 +540,7 @@ export default defineComponent({
|
|
|
532
540
|
previewText.value = '';
|
|
533
541
|
|
|
534
542
|
if (props.replyId) emit('cancel-reply');
|
|
543
|
+
if (props.edit?.objectId) emit('cancel-edit');
|
|
535
544
|
})
|
|
536
545
|
.catch((err: TypeError) => {
|
|
537
546
|
isSubmitting.value = false;
|
|
@@ -701,6 +710,9 @@ export default defineComponent({
|
|
|
701
710
|
onMounted(() => {
|
|
702
711
|
document.body.addEventListener('click', popupHandler);
|
|
703
712
|
window.addEventListener('message', onMessageRecive);
|
|
713
|
+
if (props.edit?.objectId) {
|
|
714
|
+
editor.value = props.edit.orig;
|
|
715
|
+
}
|
|
704
716
|
|
|
705
717
|
// watch editor
|
|
706
718
|
watch(
|
|
@@ -32,6 +32,14 @@
|
|
|
32
32
|
<span class="wl-time" v-text="time" />
|
|
33
33
|
|
|
34
34
|
<div class="wl-comment-actions">
|
|
35
|
+
<button
|
|
36
|
+
v-if="isAdmin || isOwner"
|
|
37
|
+
class="wl-edit"
|
|
38
|
+
@click="$emit('edit', comment)"
|
|
39
|
+
>
|
|
40
|
+
<EditIcon />
|
|
41
|
+
</button>
|
|
42
|
+
|
|
35
43
|
<button
|
|
36
44
|
v-if="isAdmin || isOwner"
|
|
37
45
|
class="wl-delete"
|
|
@@ -60,14 +68,14 @@
|
|
|
60
68
|
</div>
|
|
61
69
|
</div>
|
|
62
70
|
<div class="wl-meta" aria-hidden="true">
|
|
63
|
-
<span v-if="comment.addr" v-text="comment.addr" />
|
|
64
|
-
<span v-if="comment.browser" v-text="comment.browser" />
|
|
65
|
-
<span v-if="comment.os" v-text="comment.os" />
|
|
71
|
+
<span v-if="comment.addr" class="wl-addr" :data-value="comment.addr" v-text="comment.addr" />
|
|
72
|
+
<span v-if="comment.browser" class="wl-browser" :data-value="comment.browser" v-text="comment.browser" />
|
|
73
|
+
<span v-if="comment.os" class="wl-os" :data-value="comment.os" v-text="comment.os" />
|
|
66
74
|
</div>
|
|
67
75
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
68
|
-
<div class="wl-content" v-html="comment.comment" />
|
|
76
|
+
<div v-if="!isEditingCurrent" class="wl-content" v-html="comment.comment" />
|
|
69
77
|
|
|
70
|
-
<div v-if="isAdmin" class="wl-admin-actions">
|
|
78
|
+
<div v-if="isAdmin && !isEditingCurrent" class="wl-admin-actions">
|
|
71
79
|
<span class="wl-comment-status">
|
|
72
80
|
<button
|
|
73
81
|
v-for="status in commentStatus"
|
|
@@ -88,13 +96,18 @@
|
|
|
88
96
|
</button>
|
|
89
97
|
</div>
|
|
90
98
|
|
|
91
|
-
<div
|
|
99
|
+
<div
|
|
100
|
+
v-if="isReplyingCurrent || isEditingCurrent"
|
|
101
|
+
:class="{'wl-reply-wrapper': isReplyingCurrent, 'wl-edit-wrapper': isEditingCurrent}"
|
|
102
|
+
>
|
|
92
103
|
<CommentBox
|
|
93
|
-
:
|
|
104
|
+
:edit="edit"
|
|
105
|
+
:reply-id="reply?.objectId"
|
|
94
106
|
:reply-user="comment.nick"
|
|
95
107
|
:root-id="rootId"
|
|
96
108
|
@submit="$emit('submit', $event)"
|
|
97
109
|
@cancel-reply="$emit('reply', null)"
|
|
110
|
+
@cancel-edit="$emit('edit', null)"
|
|
98
111
|
/>
|
|
99
112
|
</div>
|
|
100
113
|
<div v-if="comment.children" class="wl-quote">
|
|
@@ -103,10 +116,12 @@
|
|
|
103
116
|
:key="child.objectId"
|
|
104
117
|
:comment="child"
|
|
105
118
|
:reply="reply"
|
|
119
|
+
:edit="edit"
|
|
106
120
|
:root-id="rootId"
|
|
107
121
|
@reply="$emit('reply', $event)"
|
|
108
122
|
@submit="$emit('submit', $event)"
|
|
109
123
|
@like="$emit('like', $event)"
|
|
124
|
+
@edit="$emit('edit', $event)"
|
|
110
125
|
@delete="$emit('delete', $event)"
|
|
111
126
|
@status="$emit('status', $event)"
|
|
112
127
|
@sticky="$emit('sticky', $event)"
|
|
@@ -119,7 +134,7 @@
|
|
|
119
134
|
<script lang="ts">
|
|
120
135
|
import { computed, defineComponent, inject } from 'vue';
|
|
121
136
|
import CommentBox from './CommentBox.vue';
|
|
122
|
-
import { DeleteIcon, LikeIcon, ReplyIcon, VerifiedIcon } from './Icons';
|
|
137
|
+
import { DeleteIcon, LikeIcon, ReplyIcon, EditIcon, VerifiedIcon } from './Icons';
|
|
123
138
|
import { isLinkHttp } from '../utils';
|
|
124
139
|
import { useTimeAgo, useLikeStorage, useUserInfo } from '../composables';
|
|
125
140
|
|
|
@@ -135,6 +150,7 @@ export default defineComponent({
|
|
|
135
150
|
DeleteIcon,
|
|
136
151
|
LikeIcon,
|
|
137
152
|
ReplyIcon,
|
|
153
|
+
EditIcon,
|
|
138
154
|
VerifiedIcon,
|
|
139
155
|
},
|
|
140
156
|
|
|
@@ -151,9 +167,13 @@ export default defineComponent({
|
|
|
151
167
|
type: Object as PropType<WalineComment | null>,
|
|
152
168
|
default: null,
|
|
153
169
|
},
|
|
170
|
+
edit: {
|
|
171
|
+
type: Object as PropType<WalineComment | null>,
|
|
172
|
+
default: null,
|
|
173
|
+
}
|
|
154
174
|
},
|
|
155
175
|
|
|
156
|
-
emits: ['submit', 'reply', 'like', 'delete', 'status', 'sticky'],
|
|
176
|
+
emits: ['submit', 'reply', 'like', 'delete', 'status', 'sticky', 'edit'],
|
|
157
177
|
|
|
158
178
|
setup(props) {
|
|
159
179
|
const config = inject<ComputedRef<WalineConfig>>(
|
|
@@ -181,16 +201,22 @@ export default defineComponent({
|
|
|
181
201
|
props.comment.user_id &&
|
|
182
202
|
userInfo.value.objectId === props.comment.user_id
|
|
183
203
|
);
|
|
204
|
+
console.log('lizheming:', props.comment.user_id, userInfo.value.objectId, isOwner.value);
|
|
184
205
|
|
|
185
206
|
const isReplyingCurrent = computed(
|
|
186
207
|
() => props.comment.objectId === props.reply?.objectId
|
|
187
208
|
);
|
|
188
209
|
|
|
210
|
+
const isEditingCurrent = computed(
|
|
211
|
+
() => props.comment.objectId === props.edit?.objectId
|
|
212
|
+
)
|
|
213
|
+
|
|
189
214
|
return {
|
|
190
215
|
config,
|
|
191
216
|
locale,
|
|
192
217
|
|
|
193
218
|
isReplyingCurrent,
|
|
219
|
+
isEditingCurrent,
|
|
194
220
|
link,
|
|
195
221
|
like,
|
|
196
222
|
time,
|
package/src/components/Icons.ts
CHANGED
|
@@ -102,6 +102,16 @@ export const ReplyIcon: FunctionalComponent = () =>
|
|
|
102
102
|
})
|
|
103
103
|
);
|
|
104
104
|
|
|
105
|
+
export const EditIcon: FunctionalComponent = () =>
|
|
106
|
+
h(
|
|
107
|
+
'svg',
|
|
108
|
+
{ viewBox: '0 0 1024 1024', width: '24', height: '24'},
|
|
109
|
+
h('path', {
|
|
110
|
+
d: 'M813.039 318.772L480.53 651.278H360.718V531.463L693.227 198.961C697.904 194.284 704.027 192 710.157 192C716.302 192 722.436 194.284 727.114 198.961L813.039 284.88C817.72 289.561 820 295.684 820 301.825C820 307.95 817.72 314.093 813.039 318.772ZM710.172 261.888L420.624 551.431V591.376H460.561L750.109 301.825L710.172 261.888ZM490.517 291.845H240.906V771.09H720.156V521.479C720.156 504.947 733.559 491.529 750.109 491.529C766.653 491.529 780.063 504.947 780.063 521.479V791.059C780.063 813.118 762.18 831 740.125 831H220.937C198.882 831 181 813.118 181 791.059V271.872C181 249.817 198.882 231.935 220.937 231.935H490.517C507.06 231.935 520.47 245.352 520.47 261.888C520.47 278.424 507.06 291.845 490.517 291.845Z',
|
|
111
|
+
fill: 'currentColor',
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
|
|
105
115
|
export const VerifiedIcon: FunctionalComponent = () =>
|
|
106
116
|
h(
|
|
107
117
|
'svg',
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
:root-id="comment.objectId"
|
|
26
26
|
:comment="comment"
|
|
27
27
|
:reply="reply"
|
|
28
|
+
:edit="edit"
|
|
28
29
|
@reply="onReply"
|
|
30
|
+
@edit="onEdit"
|
|
29
31
|
@submit="onSubmit"
|
|
30
32
|
@status="onStatusChange"
|
|
31
33
|
@delete="onDelete"
|
|
@@ -263,6 +265,7 @@ export default defineComponent({
|
|
|
263
265
|
|
|
264
266
|
const data = ref<WalineComment[]>([]);
|
|
265
267
|
const reply = ref<WalineComment | null>(null);
|
|
268
|
+
const edit = ref<WalineComment | null>(null);
|
|
266
269
|
|
|
267
270
|
const darkmodeStyle = computed(() => getDarkStyle(config.value.dark));
|
|
268
271
|
|
|
@@ -326,8 +329,15 @@ export default defineComponent({
|
|
|
326
329
|
reply.value = comment;
|
|
327
330
|
};
|
|
328
331
|
|
|
332
|
+
const onEdit = (comment: WalineComment | null): void => {
|
|
333
|
+
edit.value = comment;
|
|
334
|
+
};
|
|
335
|
+
|
|
329
336
|
const onSubmit = (comment: WalineComment): void => {
|
|
330
|
-
if (
|
|
337
|
+
if (edit.value) {
|
|
338
|
+
edit.value.comment = comment.comment;
|
|
339
|
+
edit.value.orig = comment.orig;
|
|
340
|
+
} else if (comment.rid) {
|
|
331
341
|
const repliedComment = data.value.find(
|
|
332
342
|
({ objectId }) => objectId === comment.rid
|
|
333
343
|
);
|
|
@@ -456,6 +466,7 @@ export default defineComponent({
|
|
|
456
466
|
sortByItems,
|
|
457
467
|
data,
|
|
458
468
|
reply,
|
|
469
|
+
edit,
|
|
459
470
|
|
|
460
471
|
loadMore,
|
|
461
472
|
refresh,
|
|
@@ -466,6 +477,7 @@ export default defineComponent({
|
|
|
466
477
|
onDelete,
|
|
467
478
|
onSticky,
|
|
468
479
|
onLike,
|
|
480
|
+
onEdit,
|
|
469
481
|
|
|
470
482
|
version: VERSION,
|
|
471
483
|
};
|
package/src/styles/card.scss
CHANGED
|
@@ -118,10 +118,6 @@
|
|
|
118
118
|
font-size: var(--waline-info-font-size);
|
|
119
119
|
line-height: 1.5;
|
|
120
120
|
|
|
121
|
-
@media (max-width: 520px) {
|
|
122
|
-
display: none;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
121
|
&:empty {
|
|
126
122
|
display: none;
|
|
127
123
|
}
|
|
@@ -134,7 +130,8 @@
|
|
|
134
130
|
|
|
135
131
|
.wl-delete,
|
|
136
132
|
.wl-like,
|
|
137
|
-
.wl-reply
|
|
133
|
+
.wl-reply,
|
|
134
|
+
.wl-edit {
|
|
138
135
|
display: inline-flex;
|
|
139
136
|
align-items: center;
|
|
140
137
|
|
package/src/typings/comment.ts
CHANGED
|
@@ -40,6 +40,11 @@ export interface WalineCommentData {
|
|
|
40
40
|
*/
|
|
41
41
|
at?: string;
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* edit comment id
|
|
45
|
+
*/
|
|
46
|
+
eid?: string;
|
|
47
|
+
|
|
43
48
|
/**
|
|
44
49
|
* Comment link
|
|
45
50
|
*/
|
|
@@ -80,4 +85,5 @@ export interface WalineComment extends Exclude<WalineCommentData, 'ua'> {
|
|
|
80
85
|
user_id?: string | number;
|
|
81
86
|
status?: WalineCommentStatus;
|
|
82
87
|
like?: number;
|
|
88
|
+
orig?: string;
|
|
83
89
|
}
|
package/src/utils/fetch.ts
CHANGED
|
@@ -146,6 +146,14 @@ export const postComment = ({
|
|
|
146
146
|
|
|
147
147
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
148
148
|
|
|
149
|
+
if (comment.eid) {
|
|
150
|
+
return fetch(`${serverURL}/comment/${comment.eid}?lang=${lang}`, {
|
|
151
|
+
method: 'PUT',
|
|
152
|
+
headers,
|
|
153
|
+
body: JSON.stringify(comment),
|
|
154
|
+
}).then((resp) => resp.json() as Promise<PostCommentResponse>);
|
|
155
|
+
}
|
|
156
|
+
|
|
149
157
|
return fetch(`${serverURL}/comment?lang=${lang}`, {
|
|
150
158
|
method: 'POST',
|
|
151
159
|
headers,
|