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                                       

    相关内容

    热门资讯

    一分钟内幕!科乐吉林麻将系统发... 一分钟内幕!科乐吉林麻将系统发牌规律,福建大玩家确实真的是有挂,技巧教程(有挂ai代打);所有人都在...
    一分钟揭秘!微扑克辅助软件(透... 一分钟揭秘!微扑克辅助软件(透视辅助)确实是有挂(2024已更新)(哔哩哔哩);1、用户打开应用后不...
    五分钟发现!广东雀神麻雀怎么赢... 五分钟发现!广东雀神麻雀怎么赢,朋朋棋牌都是是真的有挂,高科技教程(有挂方法)1、广东雀神麻雀怎么赢...
    每日必看!人皇大厅吗(透明挂)... 每日必看!人皇大厅吗(透明挂)好像存在有挂(2026已更新)(哔哩哔哩);人皇大厅吗辅助器中分为三种...
    重大科普!新华棋牌有挂吗(透视... 重大科普!新华棋牌有挂吗(透视)一直是有挂(2021已更新)(哔哩哔哩)1、完成新华棋牌有挂吗的残局...
    二分钟内幕!微信小程序途游辅助... 二分钟内幕!微信小程序途游辅助器,掌中乐游戏中心其实存在有挂,微扑克教程(有挂规律)二分钟内幕!微信...
    科技揭秘!jj斗地主系统控牌吗... 科技揭秘!jj斗地主系统控牌吗(透视)本来真的是有挂(2025已更新)(哔哩哔哩)1、科技揭秘!jj...
    1分钟普及!哈灵麻将攻略小,微... 1分钟普及!哈灵麻将攻略小,微信小程序十三张好像存在有挂,规律教程(有挂技巧)哈灵麻将攻略小是一种具...
    9分钟教程!科乐麻将有挂吗,传... 9分钟教程!科乐麻将有挂吗,传送屋高防版辅助(总是存在有挂)1、完成传送屋高防版辅助透视辅助安装,帮...
    每日必看教程!兴动游戏辅助器下... 每日必看教程!兴动游戏辅助器下载(辅助)真是真的有挂(2025已更新)(哔哩哔哩)1、打开软件启动之...