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                                       

    相关内容

    热门资讯

    10分钟辅助挂!搜圈麻将假不假... 10分钟辅助挂!搜圈麻将假不假“详细透视辅助助手教程”原来真的有挂,您好,搜圈麻将假不假这款游戏可以...
    记者发布!福建十三水 辅助器(... 记者发布!福建十三水 辅助器(透视)透视辅助神器(2023已更新)(哔哩哔哩);1、福建十三水 辅助...
    6分钟实锤!博雅红河棋盘外 挂... 您好,博雅红河棋盘外 挂这款游戏可以开挂的,确实是有挂的,需要了解加微【757446909】很多玩家...
    八分钟辅助挂!微乐陕西麻将小程... 八分钟辅助挂!微乐陕西麻将小程序有猫腻吗“详细透视辅助脚本教程”原来真的有挂1、下载好微乐陕西麻将小...
    必备科技!多乐够级捕鱼辅助软件... 必备科技!多乐够级捕鱼辅助软件(透视辅助)透明挂透视辅助挂(2023已更新)(哔哩哔哩)1、多乐够级...
    让我来分享经验!胖猪竞技有外挂... 让我来分享经验!胖猪竞技有外挂没(辅助)确实存在有挂(2026已更新)(哔哩哔哩)胖猪竞技有外挂没辅...
    七分钟攻略!七彩云南游戏有外 ... 七分钟攻略!七彩云南游戏有外 挂吗,wePoke原来真的是有挂,wpk教程(有挂细节)1)七彩云南游...
    交流学习经验!老友广东麻将来牌... 交流学习经验!老友广东麻将来牌规律(透视)外挂透视辅助插件(2024已更新)(哔哩哔哩)1、在老友广...
    13钟辅助挂!闲来贵州麻将可以... 13钟辅助挂!闲来贵州麻将可以挂吗“详细透视辅助app教程”原来真的有挂是一款可以让一直输的玩家,快...
    9分钟攻略!乐乐上海麻将有没有... 9分钟攻略!乐乐上海麻将有没有挂,impoker本来有挂,黑科技教程(有挂教程)乐乐上海麻将有没有挂...