@jswork/weibo-ckeditor-upload-adpater 1.0.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.txt +21 -0
- package/README.md +40 -0
- package/dist/cjs/index.d.ts +17 -0
- package/dist/cjs/index.js +97 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.js +92 -0
- package/package.json +52 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 afei <1290657123@qq.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# weibo-ckeditor-upload-adpater
|
|
2
|
+
> Weibo ckeditor upload adapter.
|
|
3
|
+
|
|
4
|
+
[![version][version-image]][version-url]
|
|
5
|
+
[![license][license-image]][license-url]
|
|
6
|
+
[![size][size-image]][size-url]
|
|
7
|
+
[![download][download-image]][download-url]
|
|
8
|
+
|
|
9
|
+
## installation
|
|
10
|
+
```shell
|
|
11
|
+
npm install @jswork/weibo-ckeditor-upload-adpater
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## usage
|
|
15
|
+
```js
|
|
16
|
+
import WeiboCkeditorUploadAdpater from '@jswork/weibo-ckeditor-upload-adpater';
|
|
17
|
+
import ReactCkeditor from '@jswork/react-ckeditor';
|
|
18
|
+
|
|
19
|
+
// usage
|
|
20
|
+
<ReactCkeditor
|
|
21
|
+
value={this.state.value}
|
|
22
|
+
onChange={this.handleChange}
|
|
23
|
+
imageUploadAdapter={WeiboCkeditorUploadAdpater}
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## license
|
|
28
|
+
Code released under [the MIT license](https://github.com/afeiship/weibo-ckeditor-upload-adpater/blob/master/LICENSE.txt).
|
|
29
|
+
|
|
30
|
+
[version-image]: https://img.shields.io/npm/v/@jswork/weibo-ckeditor-upload-adpater
|
|
31
|
+
[version-url]: https://npmjs.org/package/@jswork/weibo-ckeditor-upload-adpater
|
|
32
|
+
|
|
33
|
+
[license-image]: https://img.shields.io/npm/l/@jswork/weibo-ckeditor-upload-adpater
|
|
34
|
+
[license-url]: https://github.com/afeiship/weibo-ckeditor-upload-adpater/blob/master/LICENSE.txt
|
|
35
|
+
|
|
36
|
+
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/weibo-ckeditor-upload-adpater
|
|
37
|
+
[size-url]: https://github.com/afeiship/weibo-ckeditor-upload-adpater/blob/master/dist/weibo-ckeditor-upload-adpater.min.js
|
|
38
|
+
|
|
39
|
+
[download-image]: https://img.shields.io/npm/dm/@jswork/weibo-ckeditor-upload-adpater
|
|
40
|
+
[download-url]: https://www.npmjs.com/package/@jswork/weibo-ckeditor-upload-adpater
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: @jswork/weibo-ckeditor-upload-adpater
|
|
3
|
+
* description: Weibo ckeditor upload adapter.
|
|
4
|
+
* homepage:
|
|
5
|
+
* version: 1.0.1
|
|
6
|
+
* date: 2021-10-17 15:38:55
|
|
7
|
+
* license: MIT
|
|
8
|
+
*/
|
|
9
|
+
export default class {
|
|
10
|
+
private loader;
|
|
11
|
+
private options;
|
|
12
|
+
private lcOpts;
|
|
13
|
+
private weiboOss;
|
|
14
|
+
constructor(inLoader: any, inOptions: any);
|
|
15
|
+
upload(): Promise<unknown>;
|
|
16
|
+
private weiboOssClient;
|
|
17
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* name: @jswork/weibo-ckeditor-upload-adpater
|
|
4
|
+
* description: Weibo ckeditor upload adapter.
|
|
5
|
+
* homepage:
|
|
6
|
+
* version: 1.0.1
|
|
7
|
+
* date: 2021-10-17 15:38:55
|
|
8
|
+
* license: MIT
|
|
9
|
+
*/
|
|
10
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
20
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
21
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
22
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
23
|
+
function step(op) {
|
|
24
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
25
|
+
while (_) try {
|
|
26
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
27
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
28
|
+
switch (op[0]) {
|
|
29
|
+
case 0: case 1: t = op; break;
|
|
30
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
31
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
32
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
33
|
+
default:
|
|
34
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
35
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
36
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
37
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
38
|
+
if (t[2]) _.ops.pop();
|
|
39
|
+
_.trys.pop(); continue;
|
|
40
|
+
}
|
|
41
|
+
op = body.call(thisArg, _);
|
|
42
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
43
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var next_weibo_oss_1 = __importDefault(require("@jswork/next-weibo-oss"));
|
|
51
|
+
var next_leancloud_options_1 = __importDefault(require("@afeiship/next-leancloud-options"));
|
|
52
|
+
var WEIBO_LC_ID = '60f768f6d9f1465d3b1d5c43';
|
|
53
|
+
var default_1 = /** @class */ (function () {
|
|
54
|
+
function default_1(inLoader, inOptions) {
|
|
55
|
+
this.loader = inLoader;
|
|
56
|
+
this.options = inOptions;
|
|
57
|
+
this.lcOpts = new next_leancloud_options_1.default({ fetch: fetch, id: WEIBO_LC_ID });
|
|
58
|
+
}
|
|
59
|
+
default_1.prototype.upload = function () {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var _this = this;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, this.weiboOssClient()];
|
|
65
|
+
case 1:
|
|
66
|
+
_a.sent();
|
|
67
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
68
|
+
_this.loader.file.then(function (file) {
|
|
69
|
+
_this.weiboOss(file).then(function (url) {
|
|
70
|
+
resolve({ default: url });
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
})];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
default_1.prototype.weiboOssClient = function () {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var value;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (this.weiboOss)
|
|
85
|
+
return [2 /*return*/, Promise.resolve(this.weiboOss)];
|
|
86
|
+
return [4 /*yield*/, this.lcOpts.get()];
|
|
87
|
+
case 1:
|
|
88
|
+
value = (_a.sent()).value;
|
|
89
|
+
this.weiboOss = new next_weibo_oss_1.default(value);
|
|
90
|
+
return [2 /*return*/, this.weiboOss];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
return default_1;
|
|
96
|
+
}());
|
|
97
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: @jswork/weibo-ckeditor-upload-adpater
|
|
3
|
+
* description: Weibo ckeditor upload adapter.
|
|
4
|
+
* homepage:
|
|
5
|
+
* version: 1.0.1
|
|
6
|
+
* date: 2021-10-17 15:38:58
|
|
7
|
+
* license: MIT
|
|
8
|
+
*/
|
|
9
|
+
export default class {
|
|
10
|
+
private loader;
|
|
11
|
+
private options;
|
|
12
|
+
private lcOpts;
|
|
13
|
+
private weiboOss;
|
|
14
|
+
constructor(inLoader: any, inOptions: any);
|
|
15
|
+
upload(): Promise<unknown>;
|
|
16
|
+
private weiboOssClient;
|
|
17
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: @jswork/weibo-ckeditor-upload-adpater
|
|
3
|
+
* description: Weibo ckeditor upload adapter.
|
|
4
|
+
* homepage:
|
|
5
|
+
* version: 1.0.1
|
|
6
|
+
* date: 2021-10-17 15:38:58
|
|
7
|
+
* license: MIT
|
|
8
|
+
*/
|
|
9
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
19
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
20
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
21
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
22
|
+
function step(op) {
|
|
23
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
24
|
+
while (_) try {
|
|
25
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
26
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
27
|
+
switch (op[0]) {
|
|
28
|
+
case 0: case 1: t = op; break;
|
|
29
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
30
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
31
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
32
|
+
default:
|
|
33
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
34
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
35
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
36
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
37
|
+
if (t[2]) _.ops.pop();
|
|
38
|
+
_.trys.pop(); continue;
|
|
39
|
+
}
|
|
40
|
+
op = body.call(thisArg, _);
|
|
41
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
42
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
import NxWeiboOss from '@jswork/next-weibo-oss';
|
|
46
|
+
import NxLcOptions from '@afeiship/next-leancloud-options';
|
|
47
|
+
var WEIBO_LC_ID = '60f768f6d9f1465d3b1d5c43';
|
|
48
|
+
var default_1 = /** @class */ (function () {
|
|
49
|
+
function default_1(inLoader, inOptions) {
|
|
50
|
+
this.loader = inLoader;
|
|
51
|
+
this.options = inOptions;
|
|
52
|
+
this.lcOpts = new NxLcOptions({ fetch: fetch, id: WEIBO_LC_ID });
|
|
53
|
+
}
|
|
54
|
+
default_1.prototype.upload = function () {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var _this = this;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, this.weiboOssClient()];
|
|
60
|
+
case 1:
|
|
61
|
+
_a.sent();
|
|
62
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
63
|
+
_this.loader.file.then(function (file) {
|
|
64
|
+
_this.weiboOss(file).then(function (url) {
|
|
65
|
+
resolve({ default: url });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
})];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
default_1.prototype.weiboOssClient = function () {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
var value;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
if (this.weiboOss)
|
|
80
|
+
return [2 /*return*/, Promise.resolve(this.weiboOss)];
|
|
81
|
+
return [4 /*yield*/, this.lcOpts.get()];
|
|
82
|
+
case 1:
|
|
83
|
+
value = (_a.sent()).value;
|
|
84
|
+
this.weiboOss = new NxWeiboOss(value);
|
|
85
|
+
return [2 /*return*/, this.weiboOss];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
return default_1;
|
|
91
|
+
}());
|
|
92
|
+
export default default_1;
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jswork/weibo-ckeditor-upload-adpater",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Weibo ckeditor upload adapter.",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"typings": "dist/esm/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "gulp",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"release": "release-it"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@babel/core": "^7.14.3",
|
|
16
|
+
"@babel/preset-env": "^7.14.2",
|
|
17
|
+
"@babel/preset-typescript": "^7.13.0",
|
|
18
|
+
"@jswork/gulp-pkg-header": "^1.0.4",
|
|
19
|
+
"@types/jest": "^26.0.23",
|
|
20
|
+
"babel-jest": "^27.0.1",
|
|
21
|
+
"del": "^5.1.0",
|
|
22
|
+
"gulp": "^4.0.2",
|
|
23
|
+
"gulp-header": "^2.0.9",
|
|
24
|
+
"gulp-ignore": "^3.0.0",
|
|
25
|
+
"gulp-load-plugins": "^2.0.1",
|
|
26
|
+
"gulp-rename": "^1.4.0",
|
|
27
|
+
"gulp-size": "^3.0.0",
|
|
28
|
+
"gulp-tsc": "^1.3.2",
|
|
29
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
30
|
+
"gulp-uglify": "^3.0.2",
|
|
31
|
+
"jest": "^26.6.3",
|
|
32
|
+
"prettier": "^2.2.1",
|
|
33
|
+
"release-it": "^14.2.1",
|
|
34
|
+
"typescript": "^4.1.3"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@afeiship/next-leancloud-options": "^1.0.2",
|
|
42
|
+
"@jswork/next": "^1.0.9",
|
|
43
|
+
"@jswork/next-weibo-oss": "^1.0.0"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"weibo",
|
|
47
|
+
"oss",
|
|
48
|
+
"ckeditor",
|
|
49
|
+
"adapter",
|
|
50
|
+
"upload"
|
|
51
|
+
]
|
|
52
|
+
}
|