Tinymce自定义上传图片报错Cannot read properties of undefined (reading 'then')

tinymce 自定义上传图片 会报错 Cannot read properties of undefined (reading 'then')

这是因为在 tinymce 官方文档在 6.0 版本中,给出自定义上传的示例代码如下,和旧版本的有差异。所以报错。

const example_image_upload_handler = (blobInfo, progress) => new Promise((resolve, reject) => {
	const --- = new XMLHttpRequest();
	---.withCredentials = false;
	---.open('POST', 'postAcceptor.php');

	---.upload.onprogress = (e) => {
		progress(-.loaded / -.total * 100);
	};

	---.onload = () => {
		if (---.status === 403) {
			reject({
				message: 'HTTP Error: ' + ---.status,
				remove: true
			});
			return;
		}

		if (---.status < 200 || ---.status >= 300) {
			reject('HTTP Error: ' + ---.status);
			return;
		}

		const ---- = JSON.parse(---.responseText);

		if (!---- || typeof ----.location != 'string') {
			reject('Invalid JSON: ' + ---.responseText);
			return;
		}

		resolve(----.location);
	};

	---.onerror = () => {
		reject('Image upload failed due to a XHR Transport error. Code: ' + ---.status);
	};

	const -------- = new FormData();
	--------.append('file', --------.blob(), --------.filename());

	---.send(--------);
});

-------.init({
	selector: 'textarea', // change this value according to your HTML
	images_upload_handler: ----------------------------
});