@waline/client 2.3.0 → 2.3.1
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/LICENSE +339 -0
- 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.d.ts +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.d.ts +1 -1
- package/dist/shim.esm.d.ts +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.d.ts +1 -1
- package/dist/waline.cjs.js +1 -1
- package/dist/waline.cjs.js.map +1 -1
- package/dist/waline.d.ts +1 -1
- package/dist/waline.esm.d.ts +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 +11 -12
- package/src/components/Waline.vue +9 -21
- package/src/config/highlighter.ts +74 -0
- package/src/config/index.ts +1 -0
- package/src/typings/base.ts +1 -7
- package/src/utils/config.ts +2 -2
- package/src/shims-hanabi.d.ts +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/client",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "client for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valine",
|
|
@@ -56,15 +56,6 @@
|
|
|
56
56
|
"dist",
|
|
57
57
|
"src"
|
|
58
58
|
],
|
|
59
|
-
"scripts": {
|
|
60
|
-
"build": "npm run rollup && npm run style",
|
|
61
|
-
"clean": "rimraf ./dist",
|
|
62
|
-
"dev": "vite -c config/vite.config.js",
|
|
63
|
-
"lint": "eslint --ext .ts,.vue .",
|
|
64
|
-
"prepublish": "npm run clean && npm run build",
|
|
65
|
-
"rollup": "rollup -c ./config/rollup.config.js",
|
|
66
|
-
"style": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed"
|
|
67
|
-
},
|
|
68
59
|
"browserslist": {
|
|
69
60
|
"production": [
|
|
70
61
|
">0.5%",
|
|
@@ -82,7 +73,6 @@
|
|
|
82
73
|
"dependencies": {
|
|
83
74
|
"@vueuse/core": "^8.4.0",
|
|
84
75
|
"autosize": "^5.0.1",
|
|
85
|
-
"hanabi": "^0.4.0",
|
|
86
76
|
"marked": "^4.0.15",
|
|
87
77
|
"vue": "^3.2.33"
|
|
88
78
|
},
|
|
@@ -94,5 +84,14 @@
|
|
|
94
84
|
},
|
|
95
85
|
"engines": {
|
|
96
86
|
"node": ">=12.20.0"
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "pnpm rollup && pnpm style",
|
|
90
|
+
"clean": "rimraf ./dist",
|
|
91
|
+
"dev": "vite -c config/vite.config.js",
|
|
92
|
+
"lint": "eslint --ext .ts,.vue .",
|
|
93
|
+
"prepublish": "pnpm clean && pnpm build",
|
|
94
|
+
"rollup": "rollup -c ./config/rollup.config.js",
|
|
95
|
+
"style": "sass ./src/styles/index.scss ./dist/waline.css --style=compressed"
|
|
97
96
|
}
|
|
98
|
-
}
|
|
97
|
+
}
|
|
@@ -126,9 +126,7 @@ export default defineComponent({
|
|
|
126
126
|
: {}),
|
|
127
127
|
},
|
|
128
128
|
|
|
129
|
-
dark:
|
|
130
|
-
type: [String, Boolean],
|
|
131
|
-
},
|
|
129
|
+
dark: [String, Boolean],
|
|
132
130
|
|
|
133
131
|
lang: {
|
|
134
132
|
type: String,
|
|
@@ -140,13 +138,9 @@ export default defineComponent({
|
|
|
140
138
|
: {}),
|
|
141
139
|
},
|
|
142
140
|
|
|
143
|
-
locale:
|
|
144
|
-
type: Object as PropType<Partial<WalineLocale>>,
|
|
145
|
-
},
|
|
141
|
+
locale: Object as PropType<Partial<WalineLocale>>,
|
|
146
142
|
|
|
147
|
-
pageSize:
|
|
148
|
-
type: Number,
|
|
149
|
-
},
|
|
143
|
+
pageSize: Number,
|
|
150
144
|
|
|
151
145
|
wordLimit: {
|
|
152
146
|
type: [Number, Array] as PropType<number | [number, number]>,
|
|
@@ -185,21 +179,15 @@ export default defineComponent({
|
|
|
185
179
|
: {}),
|
|
186
180
|
},
|
|
187
181
|
|
|
188
|
-
login:
|
|
189
|
-
type: String as PropType<'enable' | 'disable' | 'force'>,
|
|
190
|
-
},
|
|
182
|
+
login: String as PropType<'enable' | 'disable' | 'force'>,
|
|
191
183
|
|
|
192
|
-
highlighter:
|
|
193
|
-
type: Function as PropType<WalineHighlighter>,
|
|
194
|
-
},
|
|
184
|
+
highlighter: Function as PropType<WalineHighlighter>,
|
|
195
185
|
|
|
196
|
-
imageUploader:
|
|
197
|
-
type: [Function, Boolean] as PropType<WalineImageUploader | false>,
|
|
198
|
-
},
|
|
186
|
+
imageUploader: [Function, Boolean] as PropType<WalineImageUploader | false>,
|
|
199
187
|
|
|
200
|
-
texRenderer:
|
|
201
|
-
|
|
202
|
-
|
|
188
|
+
texRenderer: [Function, Boolean] as PropType<WalineTexRenderer | false>,
|
|
189
|
+
|
|
190
|
+
copyright: Boolean,
|
|
203
191
|
},
|
|
204
192
|
|
|
205
193
|
setup(props) {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) egoist <0x142857@gmail.com> (https://egoistian.com)
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
|
14
|
+
* all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
* THE SOFTWARE.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const WORD_REGEXP =
|
|
27
|
+
/[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|\w+/;
|
|
28
|
+
const LEFT_ANGLE_REGEXP = /</;
|
|
29
|
+
const LINE_COMMENT_REGEXP = /(?:^|\s)\/\/(.+?)$/gm;
|
|
30
|
+
const BLOCK_COMMENT_REGEXP = /\/\*([\S\s]*?)\*\//gm;
|
|
31
|
+
const REGEXP = new RegExp(
|
|
32
|
+
`(${WORD_REGEXP.source}|${LEFT_ANGLE_REGEXP.source})|((?:${LINE_COMMENT_REGEXP.source})|(?:${BLOCK_COMMENT_REGEXP.source}))`,
|
|
33
|
+
'gmi'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const COLORS = [
|
|
37
|
+
'23AC69',
|
|
38
|
+
'91C132',
|
|
39
|
+
'F19726',
|
|
40
|
+
'E8552D',
|
|
41
|
+
'1AAB8E',
|
|
42
|
+
'E1147F',
|
|
43
|
+
'2980C1',
|
|
44
|
+
'1BA1E6',
|
|
45
|
+
'9FA0A0',
|
|
46
|
+
'F19726',
|
|
47
|
+
'E30B20',
|
|
48
|
+
'E30B20',
|
|
49
|
+
'A3338B',
|
|
50
|
+
];
|
|
51
|
+
const cache: Record<string, string> = {};
|
|
52
|
+
|
|
53
|
+
export const defaultHighlighter = (input: string): string => {
|
|
54
|
+
let index = 0;
|
|
55
|
+
|
|
56
|
+
return input.replace(REGEXP, (_match, word: string, comment: string) => {
|
|
57
|
+
if (comment) return `<span style="color: slategray">${comment}</span>`;
|
|
58
|
+
if (word === '<') return '<';
|
|
59
|
+
|
|
60
|
+
let color: string;
|
|
61
|
+
|
|
62
|
+
if (cache[word]) color = cache[word];
|
|
63
|
+
else {
|
|
64
|
+
color = COLORS[index];
|
|
65
|
+
cache[word] = color;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const out = `<span style="color: #${color}">${word}</span>`;
|
|
69
|
+
|
|
70
|
+
index = ++index % COLORS.length;
|
|
71
|
+
|
|
72
|
+
return out;
|
|
73
|
+
});
|
|
74
|
+
};
|
package/src/config/index.ts
CHANGED
package/src/typings/base.ts
CHANGED
|
@@ -43,12 +43,6 @@ export type WalineMeta = 'nick' | 'mail' | 'link';
|
|
|
43
43
|
|
|
44
44
|
export type WalineImageUploader = (image: File) => Promise<string>;
|
|
45
45
|
|
|
46
|
-
export type WalineHighlighter =
|
|
47
|
-
| ((code: string, lang: string) => string)
|
|
48
|
-
| ((
|
|
49
|
-
code: string,
|
|
50
|
-
lang: string,
|
|
51
|
-
callback?: (error: unknown | undefined, code?: string) => void
|
|
52
|
-
) => void);
|
|
46
|
+
export type WalineHighlighter = (code: string, lang: string) => string;
|
|
53
47
|
|
|
54
48
|
export type WalineTexRenderer = (blockMode: boolean, tex: string) => string;
|
package/src/utils/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultLang,
|
|
3
3
|
defaultUploadImage,
|
|
4
|
+
defaultHighlighter,
|
|
4
5
|
defaultTexRenderer,
|
|
5
6
|
getMeta,
|
|
6
7
|
defaultLocales,
|
|
@@ -14,7 +15,6 @@ import type {
|
|
|
14
15
|
WalineLocale,
|
|
15
16
|
WalineProps,
|
|
16
17
|
} from '../typings';
|
|
17
|
-
import hanabi from 'hanabi';
|
|
18
18
|
|
|
19
19
|
export interface WalineEmojiConfig {
|
|
20
20
|
tabs: Pick<WalineEmojiInfo, 'name' | 'icon' | 'items'>[];
|
|
@@ -73,7 +73,7 @@ export const getConfig = ({
|
|
|
73
73
|
meta: getMeta(meta),
|
|
74
74
|
requiredMeta: getMeta(requiredMeta),
|
|
75
75
|
imageUploader: fallback(imageUploader, defaultUploadImage),
|
|
76
|
-
highlighter: fallback(highlighter,
|
|
76
|
+
highlighter: fallback(highlighter, defaultHighlighter),
|
|
77
77
|
texRenderer: fallback(texRenderer, defaultTexRenderer),
|
|
78
78
|
lang,
|
|
79
79
|
dark,
|