tinymce vue拓展多图上传 实现拖拽切换位置,图片排序
创始人
2025-01-08 20:03:39
0

实现功能:基于tinymce TinyMCE中文文档中文手册   拖拽图片排序,去掉全部上传按钮,点击保存上传图片并关闭弹窗,优化了一些交互提示

声明:本人不是做vue前端的,可能有些更好的方法实现拖拽或者其他一些开源库实现。

代码plugin.js:

tinymce.PluginManager.add('axupimgs', function(editor, url) { 	var pluginName='Ax多图片上传'; 	window.axupimgs={}; //扔外部公共变量,也可以扔一个自定义的位置  	var baseURL=tinymce.baseURL; 	// var iframe1 = baseURL+'/plugins/axupimgs/upfiles.html'; 	var iframe1 = location.origin+'/tinymce/axupimgs/upfiles_new.html';     axupimgs.images_upload_handler = editor.getParam('images_upload_handler', undefined, 'function');     axupimgs.images_upload_base_path = editor.getParam('images_upload_base_path', '', 'string');     axupimgs.axupimgs_filetype = editor.getParam('axupimgs_filetype', '.png,.gif,.jpg,.jpeg', 'string'); 	axupimgs.res=[]; 	var openDialog = function() { 		isAddEventListener(true) 		return editor.windowManager.openUrl({ 			title: pluginName, 			size: 'large', 			url:iframe1, 			buttons: [ 				{ 					type: 'custom', 					text: 'Close', 					name: 'close', 				}, 				{ 					type: 'custom', 					text: 'Save', 					name: 'save', 					primary: true 				}, 			], 			onAction: function (api, details) { 				switch (details.name) { 					case 'save': 						//发送给upfiles,上传图片 						window.postMessage({ action: 'upLoadPictureFile' }, '*'); 						break; 					case 'close': 						window.postMessage({ action: 'closeUpLoadPictureFile' }, '*'); 						isAddEventListener(false) 						break; 					default: 						break; 				} 			}, 		}); 	};  	//保存 	function save() { 		// 链接插入富文本显示 		var html = ''; 		var imgs = axupimgs.res; 		var len = imgs.length; 		for (let i = 0; i < len; i++) { 			if (imgs[i].url) { 				html += ''; 			} 		} 		editor.insertContent(html); 		axupimgs.res = []; 		tinymce.activeEditor.windowManager.close() 	};  	//处理消息 	function handleMessage(event){ 		var data = event.data; 		if (data.action === 'savePictureFile') { 			save(); 			isAddEventListener(false) 		} 	}  	//添加监听 	function isAddEventListener(isAdd){ 		if(isAdd){ 			// 接收来自 iframe1 的消息 			window.addEventListener('message', handleMessage, false) 		}else{ 			window.removeEventListener('message',handleMessage, false) 		} 	}  	editor.ui.registry.getAll().icons.axupimgs || editor.ui.registry.addIcon('axupimgs','');  	editor.ui.registry.addButton('axupimgs', { 		icon: 'axupimgs',         tooltip: pluginName, 		onAction: function() { 			openDialog(); 		} 	}); 	editor.ui.registry.addMenuItem('axupimgs', { 		icon: 'axupimgs', 		text: '图片批量上传...', 		onAction: function() { 			openDialog(); 		} 	}); 	return { 		getMetadata: function() { 			return  { 				name: pluginName, 				url: "http://tinymce.ax-z.cn/more-plugins/axupimgs.php", 			}; 		} 	}; });  

htmlupfiles_new.html

             axupimgs                                       

    相关内容

    热门资讯

    1分钟了解!海螺众娱辅助脚本,... 1分钟了解!海螺众娱辅助脚本,收集微乐小程序游戏破解器,规律教程(有挂方法);无需打开直接搜索薇:1...
    三阶段知晓“点星休闲辅助器下载... 三阶段知晓“点星休闲辅助器下载”从来有开挂辅助神器(有挂头条);无需打开直接搜索打开薇:136704...
    第十分钟法子!微乐小程序免费脚... 第十分钟法子!微乐小程序免费脚本(透视)小程序微乐陕西挖坑辅助(竟然有挂)1、下载安装好小程序微乐陕...
    透视能赢!pokemmo手机脚... 透视能赢!pokemmo手机脚本辅助器,wepoker提高好牌率(原生有开挂辅助插件);无需打开直接...
    七分钟了解!微乐小程序黑科技下... 七分钟了解!微乐小程序黑科技下载,德普之星透视辅助软件激活码,新版2026教程(有挂实锤);无需打开...
    6瞬间熟悉“新上游辅助反杀”原... 您好:新上游辅助反杀这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的牌特...
    4分钟练习!新财神辅助器(透视... 4分钟练习!新财神辅助器(透视)新广西老友辅助(有挂教程)1、下载安装好新广西老友辅助,进入游戏主界...
    透明规律!购买wepoker模... 透明规律!购买wepoker模拟器,wepoker插件程序激活码(先前有开挂辅助神器);无需打开直接...
    3分钟了解!约局吧开挂,葫芦娃... 3分钟了解!约局吧开挂,葫芦娃辅助脚本,大神讲解(真是有挂);无需打开直接搜索加(薇:1367043...
    十分钟了解“丰城双剑新版最强高... 十分钟了解“丰城双剑新版最强高分攻略”原先有开挂辅助软件(真的有挂);无需打开直接搜索加(薇:136...