mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
$(function(){
|
|
var fileUploadUri = "/api/cms-kit-admin/media";
|
|
var fileUriPrefix = "/api/cms-kit/media/"
|
|
|
|
var editor = $('#content-editor');
|
|
|
|
function getUppyHeaders() {
|
|
var headers = {};
|
|
headers[abp.security.antiForgery.tokenHeaderName] = abp.security.antiForgery.getToken();
|
|
|
|
return headers;
|
|
}
|
|
|
|
var uploadImage = function (blob, callback, source) {
|
|
var UPPY_OPTIONS = {
|
|
endpoint: fileUploadUri,
|
|
formData: true,
|
|
fieldName: "file",
|
|
method: "post",
|
|
headers: getUppyHeaders()
|
|
};
|
|
|
|
var UPPY = Uppy.Core().use(Uppy.XHRUpload, UPPY_OPTIONS);
|
|
|
|
UPPY.reset();
|
|
|
|
UPPY.addFile({
|
|
id: "content-file",
|
|
name: blob.name,
|
|
type: blob.type,
|
|
data: blob,
|
|
});
|
|
|
|
UPPY.upload().then((result) => {
|
|
if (result.failed.length > 0) {
|
|
abp.message.error("File upload failed");
|
|
} else {
|
|
var mediaDto = result.successful[0].response.body;
|
|
var fileUrl = (fileUriPrefix + mediaDto.id);
|
|
|
|
callback(fileUrl, mediaDto.name);
|
|
}
|
|
});
|
|
};
|
|
|
|
new toastui.Editor({
|
|
el: editor[0],
|
|
usageStatistics: false,
|
|
useCommandShortcut: true,
|
|
initialEditType: 'wysiwyg',
|
|
previewStyle: 'tab',
|
|
height: "25em",
|
|
minHeight: "25em",
|
|
language: abp.localization.currentCulture.cultureName,
|
|
hooks: {
|
|
addImageBlobHook: uploadImage,
|
|
},
|
|
});
|
|
});
|