1. After uploading, append the obtained address to the rich text.

(Note: I’m using Laui, same with native JS)

Effect:

Two, the code part

< div class=”layui-input-block”>

Var $= layui.jquery,layer = parent. Layer === undefined? layui.layer : top.layer ,form = layui.form; var upload = layui.upload,element = layui.element; Render ({elem: '#test5',url: '') accept: 'video' // done: Function (res){layer. MSG (' uploads successfully '); console.log(res.data.src); // Notice that there are two places to replace in the following HTML, Var VHTML = '<p><span class=" McE-preview-object McE-object-video "contenteditable="false" data-mce-object="video" data-mce-p-controls="controls" data-mce-html="<source src='+res.data.src+' />"><video src="'+res.data.src+'" controls="controls" width="100%" height="auto" frameborder="0"></video><span class="mce-shim"></span></span></p>'; // Append to content = content + VHTML; // Assign edit.setContent(content); }}); Var content = ""; var edit = ""; Layui.extend ({tinymce: './tinymce/tinymce'// your rich text component path}). Use (['tinymce'], function () {var t = layui.tinymce; T.ender ({elem: "#edit", height: 600,// function (blobInfo, success, failure, progress) { var xhr, formData; xhr = new XMLHttpRequest(); xhr.withCredentials = false; xhr.open('POST', ''); // Xhr.upload. Onprogress = function(e){progress(e.loaded/e.total * 100); // Xhr.upload. } xhr.onload = function() { var json; if (xhr.status == 403) { failure('HTTP Error: ' + xhr.status, { remove: true }); return; } if (xhr.status < 200 || xhr.status >= 300 ) { failure('HTTP Error: ' + xhr.status); return; } json = JSON.parse(xhr.responseText); if (! json || typeof json.location ! = 'string') { failure('Invalid JSON: ' + xhr.responseText); return; } success(json.location); }; xhr.onerror = function () { failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status); } formData = new FormData(); formData.append('file', blobInfo.blob(), blobInfo.filename()); xhr.send(formData); }},(opt, d)=>{// edit is an instance of the current editor, equivalent to t.git return value edit = d; d.setContent(content); }); //edit = t.get('#edit'); })Copy the code