Improve attachment upload methods (#30513)
* Use dropzone to handle file uploading for all cases, including pasting and dragging * Merge duplicate code, use consistent behavior for link generating Close #20130 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
00fc29aee1
commit
9bc5552c11
10 changed files with 169 additions and 97 deletions
|
@ -1,7 +1,7 @@
|
|||
import {
|
||||
basename, extname, isObject, stripTags, parseIssueHref,
|
||||
parseUrl, translateMonth, translateDay, blobToDataURI,
|
||||
toAbsoluteUrl, encodeURLEncodedBase64, decodeURLEncodedBase64,
|
||||
toAbsoluteUrl, encodeURLEncodedBase64, decodeURLEncodedBase64, isImageFile, isVideoFile,
|
||||
} from './utils.js';
|
||||
|
||||
test('basename', () => {
|
||||
|
@ -15,6 +15,7 @@ test('extname', () => {
|
|||
expect(extname('/path/')).toEqual('');
|
||||
expect(extname('/path')).toEqual('');
|
||||
expect(extname('file.js')).toEqual('.js');
|
||||
expect(extname('/my.path/file')).toEqual('');
|
||||
});
|
||||
|
||||
test('isObject', () => {
|
||||
|
@ -112,3 +113,18 @@ test('encodeURLEncodedBase64, decodeURLEncodedBase64', () => {
|
|||
expect(Array.from(decodeURLEncodedBase64('YQ'))).toEqual(Array.from(uint8array('a')));
|
||||
expect(Array.from(decodeURLEncodedBase64('YQ=='))).toEqual(Array.from(uint8array('a')));
|
||||
});
|
||||
|
||||
test('file detection', () => {
|
||||
for (const name of ['a.jpg', '/a.jpeg', '.file.png', '.webp', 'file.svg']) {
|
||||
expect(isImageFile({name})).toBeTruthy();
|
||||
}
|
||||
for (const name of ['', 'a.jpg.x', '/path.png/x', 'webp']) {
|
||||
expect(isImageFile({name})).toBeFalsy();
|
||||
}
|
||||
for (const name of ['a.mpg', '/a.mpeg', '.file.mp4', '.webm', 'file.mkv']) {
|
||||
expect(isVideoFile({name})).toBeTruthy();
|
||||
}
|
||||
for (const name of ['', 'a.mpg.x', '/path.mp4/x', 'webm']) {
|
||||
expect(isVideoFile({name})).toBeFalsy();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue