From 4b1c3512fe3534d87de16f5486d0510ce07955d1 Mon Sep 17 00:00:00 2001
From: JiHong88 <0125ses@hanmail.net>
Date: Sun, 28 Jun 2020 03:17:42 +0900
Subject: [PATCH 1/3] fix: typo
---
src/lib/core.d.ts | 12 ++++++------
src/lib/core.js | 23 +++++++++++++++++++++++
src/plugins/dialog/audio.js | 4 +---
3 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts
index ba62a24af..ac1b3ab8b 100644
--- a/src/lib/core.d.ts
+++ b/src/lib/core.d.ts
@@ -613,7 +613,7 @@ export default class SunEditor {
/**
* @description It replaces the default callback function of the image upload
- * @param xmlHttpRequest xmlHttpRequest object
+ * @param xmlHttp xmlHttpRequest object
* @param info Input information
* - linkValue: Link url value
* - linkNewWindow: Open in new window Check Value
@@ -624,11 +624,11 @@ export default class SunEditor {
* - element: If isUpdate is true, the currently selected image.
* @param core Core object
*/
- imageUploadHandler: (xmlHttpRequest: XMLHttpRequest, info: imageInputInformation, core: Core) => void;
+ imageUploadHandler: (xmlHttp: XMLHttpRequest, info: imageInputInformation, core: Core) => void;
/**
* @description It replaces the default callback function of the video upload
- * @param xmlHttpRequest xmlHttpRequest object
+ * @param xmlHttp xmlHttpRequest object
* @param info Input information
* - inputWidth: Value of width input
* - inputHeight: Value of height input
@@ -637,17 +637,17 @@ export default class SunEditor {
* - element: If isUpdate is true, the currently selected video.
* @param core Core object
*/
- videoUploadHandler: (xmlHttpRequest: XMLHttpRequest, info: videoInputInformation, core: Core) => void;
+ videoUploadHandler: (xmlHttp: XMLHttpRequest, info: videoInputInformation, core: Core) => void;
/**
* @description It replaces the default callback function of the audio upload
- * @param xmlHttpRequest xmlHttpRequest object
+ * @param xmlHttp xmlHttpRequest object
* @param info Input information
* - isUpdate: Update audio if true, create audio if false
* - element: If isUpdate is true, the currently selected audio.
* @param core Core object
*/
- audioUploadHandler: (xmlHttpRequest: XMLHttpRequest, info: audioInputInformation, core: Core) => void;
+ audioUploadHandler: (xmlHttp: XMLHttpRequest, info: audioInputInformation, core: Core) => void;
/**
* @description Called before the image is uploaded
diff --git a/src/lib/core.js b/src/lib/core.js
index 7f915bcba..9e8e07130 100755
--- a/src/lib/core.js
+++ b/src/lib/core.js
@@ -6635,6 +6635,29 @@ export default function (context, pluginCallButtons, plugins, lang, options, _ic
*/
imageUploadHandler: null,
+ /**
+ * @description It replaces the default callback function of the video upload
+ * @param xmlHttp xmlHttpRequest object
+ * @param info Input information
+ * - inputWidth: Value of width input
+ * - inputHeight: Value of height input
+ * - align: Align Check Value
+ * - isUpdate: Update video if true, create video if false
+ * - element: If isUpdate is true, the currently selected video.
+ * @param core Core object
+ */
+ videoUploadHandler: null,
+
+ /**
+ * @description It replaces the default callback function of the audio upload
+ * @param xmlHttp xmlHttpRequest object
+ * @param info Input information
+ * - isUpdate: Update audio if true, create audio if false
+ * - element: If isUpdate is true, the currently selected audio.
+ * @param core Core object
+ */
+ audioUploadHandler: null,
+
/**
* @description Called before the image is uploaded
* If false is returned, no image upload is performed.
diff --git a/src/plugins/dialog/audio.js b/src/plugins/dialog/audio.js
index 3fd54ecfa..31629debf 100644
--- a/src/plugins/dialog/audio.js
+++ b/src/plugins/dialog/audio.js
@@ -368,9 +368,7 @@ export default {
} else {
const response = JSON.parse(xmlHttp.responseText);
if (response.errorMessage) {
- if (this.functions.onAudioUploadError !== 'function' || this.functions.onAudioUploadError(response.errorMessage, response, this)) {
- this.functions.noticeOpen(response.errorMessage);
- }
+ this.plugins.audio.error.call(this, response.errorMessage, response);
} else {
this.plugins.audio.register.call(this, info, response);
}
From a8fd6aa87ad6f7b217ea86faa7fa577d4ffb8089 Mon Sep 17 00:00:00 2001
From: JiHong88 <0125ses@hanmail.net>
Date: Sun, 28 Jun 2020 03:33:57 +0900
Subject: [PATCH 2/3] update sample
---
README.md | 63 ++++++++++++-----
sample/html/out/document-user.html | 105 ++++++++++++++---------------
2 files changed, 98 insertions(+), 70 deletions(-)
diff --git a/README.md b/README.md
index f690e6260..af7e3d189 100644
--- a/README.md
+++ b/README.md
@@ -1128,8 +1128,8 @@ editor.onAudioUploadError = function (errorMessage, result, core) {
// It replaces the default callback function of the image upload
/**
- * xmlHttpRequest: xmlHttpRequest object
- * info (Input information): {
+ * xmlHttp: xmlHttpRequest object
+ * info: Input information
* - linkValue: Link url value
* - linkNewWindow: Open in new window Check Value
* - inputWidth: Value of width input
@@ -1137,24 +1137,53 @@ editor.onAudioUploadError = function (errorMessage, result, core) {
* - align: Align Check Value
* - isUpdate: Update image if true, create image if false
* - element: If isUpdate is true, the currently selected image.
- * }
* core: Core object
*/
-editor.imageUploadHandler = function (xmlHttpRequest, info, core) {
- // Example of upload method
- const res = JSON.parse(xmlHttpRequest.responseText);
-
- // Error
- if (res.errorMessage) {
- if (core.functions.onImageUploadError !== 'function' || core.functions.onImageUploadError(res.errorMessage, res, core)) {
- core.notice.open.call(core, res.errorMessage);
- } else {
- core.notice.open.call(core, res.errorMessage);
- }
+editor.imageUploadHandler = function (xmlHttp, info, core) {
+ // Editor code
+ const response = JSON.parse(xmlHttp.responseText);
+ if (response.errorMessage) {
+ this.plugins.image.error.call(this, response.errorMessage, response);
+ } else {
+ this.plugins.image.register.call(this, info, response);
}
- // Success
- else {
- core.plugins.image.register.call(core, info, res);
+}
+/**
+ * @description It replaces the default callback function of the video upload
+ * xmlHttp: xmlHttpRequest object
+ * info: Input information
+ * - inputWidth: Value of width input
+ * - inputHeight: Value of height input
+ * - align: Align Check Value
+ * - isUpdate: Update video if true, create video if false
+ * - element: If isUpdate is true, the currently selected video.
+ * core: Core object
+ */
+editor.videoUploadHandler = function (xmlHttp, info, core) {
+ // Editor code
+ const response = JSON.parse(xmlHttp.responseText);
+ if (response.errorMessage) {
+ this.plugins.video.error.call(this, response.errorMessage, response);
+ } else {
+ this.plugins.video.register.call(this, info, response);
+ }
+}
+
+/**
+ * @description It replaces the default callback function of the audio upload
+ * xmlHttp xmlHttpRequest object
+ * info Input information
+ * - isUpdate: Update audio if true, create audio if false
+ * - element: If isUpdate is true, the currently selected audio.
+ * core Core object
+ */
+editor.audioUploadHandler = function (xmlHttp, info, core) {
+ // Editor code
+ const response = JSON.parse(xmlHttp.responseText);
+ if (response.errorMessage) {
+ this.plugins.audio.error.call(this, response.errorMessage, response);
+ } else {
+ this.plugins.audio.register.call(this, info, response);
}
}
diff --git a/sample/html/out/document-user.html b/sample/html/out/document-user.html
index 812654f41..f92317aac 100644
--- a/sample/html/out/document-user.html
+++ b/sample/html/out/document-user.html
@@ -914,7 +914,7 @@
on
@example Also you can call directly image register not execute "uploadHandler". This work is not execute default upload handler.
- const response = { // Same format as "imageUploadUrl" response
+ const response = { // Same format as "imageUploadUrl" response
"errorMessage": "insert error message",
"result": [ { "url": "...", "name": "...", "size": "999" }, ]
};
@@ -1086,7 +1086,7 @@
onI
imageUploadHandler(xmlHttpRequest, info, core)
+ class="signature">(xmlHttp, info, core)
It replaces the default callback function of the image upload.
@@ -1100,7 +1100,7 @@
ima
-
xmlHttpRequest
+
xmlHttp
XMLHttpRequest
@@ -1143,7 +1143,7 @@
on
@example Also you can call directly image register not execute "uploadHandler". This work is not execute default upload handler.
- const response = { // Same format as "imageUploadUrl" response
+ const response = { // Same format as "imageUploadUrl" response
"errorMessage": "insert error message",
"result": [ { "url": "...", "name": "...", "size": "999" }, ]
};
@@ -1312,20 +1312,10 @@
- Called before the audio is uploaded.
- If false is returned, no audio upload is performed.
- If new fileList are returned, replaced the previous fileList
- @example
- Also you can call directly image register not execute "uploadHandler".
- This work is not execute default upload handler.
- const response = { // Same format as "imageUploadUrl" response
- "errorMessage": "insert error message",
- "result": [ { "url": "...", "name": "...", "size": "999" }, ]
- };
- core.plugins.image.register.call(core, info, response);
+ It replaces the default callback function of the video upload.
@@ -1337,11 +1327,11 @@
on
-
files
+
xmlHttp
- FileList
+ XMLHttpRequest
-
Files array
+
xmlHttpRequest object
info
@@ -1349,8 +1339,12 @@
on
Object
- isUpdate: Update audio if true, create audio if false
- element: If isUpdate is true, the currently selected audio
+ -- Input information --
+ inputWidth: Value of width input
+ inputHeight: Value of height input
+ align: Align Check Value
+ isUpdate: Update video if true, create video if false
+ element: If isUpdate is true, the currently selected video.
- If undefined is returned, it waits until "uploadHandler" is executed.
- "uploadHandler" is an upload function with "core" and "info" bound. (plugin.upload.bind(core, info))
- [upload files] : uploadHandler(files or [new File(...),])
- [error] : uploadHandler("Error message")
- [Just finish] : uploadHandler()
-
- It replaces the default callback function of the video upload.
-
+ Called before the audio is uploaded.
+ If false is returned, no audio upload is performed.
+ If new fileList are returned, replaced the previous fileList
+ @example
+ Also you can call directly image register not execute "uploadHandler".
+ This work is not execute default upload handler.
+ const response = { // Same format as "imageUploadUrl" response
+ "errorMessage": "insert error message",
+ "result": [ { "url": "...", "name": "...", "size": "999" }, ]
+ };
+ core.plugins.image.register.call(core, info, response);
@@ -1393,11 +1383,11 @@
vid
-
xmlHttpRequest
+
files
- XMLHttpRequest
+ FileList
-
xmlHttpRequest object
+
Files array
info
@@ -1405,12 +1395,8 @@
vid
Object
- -- Input information --
- inputWidth: Value of width input
- inputHeight: Value of height input
- align: Align Check Value
- isUpdate: Update video if true, create video if false
- element: If isUpdate is true, the currently selected video.
+ isUpdate: Update audio if true, create audio if false
+ element: If isUpdate is true, the currently selected audio
+ If undefined is returned, it waits until "uploadHandler" is executed.
+ "uploadHandler" is an upload function with "core" and "info" bound. (plugin.upload.bind(core, info))
+ [upload files] : uploadHandler(files or [new File(...),])
+ [error] : uploadHandler("Error message")
+ [Just finish] : uploadHandler()
+
+
@@ -1534,10 +1533,10 @@
onA
-
videoUploadHandler(xmlHttpRequest, info, core)
+
audioUploadHandler(xmlHttp, info, core)
- It replaces the default callback function of the audio upload.
+ It replaces the default callback function of the audio upload
@@ -1549,7 +1548,7 @@
vid
-
xmlHttpRequest
+
xmlHttp
XMLHttpRequest
@@ -1563,7 +1562,7 @@
vid
-- Input information -- isUpdate: Update audio if true, create audio if false
- element: If isUpdate is true, the currently selected audio.
+ element: If isUpdate is true, the currently selected audio