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                                       

    相关内容

    热门资讯

    2024新版教程!wpk辅助透... 2024新版教程!wpk辅助透视(德扑数据软件)其实真的有挂(详细透明挂教程)1、德扑数据软件系统规...
    AI辅助!德扑之星刷数据(透视... AI辅助!德扑之星刷数据(透视)外挂透明挂辅助器安装(有挂存在)-哔哩哔哩1、让任何用户在无需AI插...
    教你攻略!德州ai辅助器(德扑... 教你攻略!德州ai辅助器(德扑ai助手)其实真的是有挂(详细透视辅助教程)教你攻略!德州ai辅助器(...
    教你攻略辅助!德扑数据分析软件... 教你攻略辅助!德扑数据分析软件(透明)外挂透明挂辅助app(有挂工具)-哔哩哔哩1、德扑数据分析软件...
    wpk教程!wpk微扑克有辅助... wpk教程!wpk微扑克有辅助吗(wepoke模拟器)原来确实真的有挂(详细透视辅助教程)1、这是跨...
    2024新版总结辅助!德州辅助... 2024新版总结辅助!德州辅助软件线上(透视)外挂透明挂辅助插件(真的有挂)-哔哩哔哩1、下载好德州...
    透明挂教程!wepoke软件收... 透明挂教程!wepoke软件收费是真的吗(德州之星辅助)原来真的是有挂(详细辅助挂教程)1)wepo...
    2024新版技巧辅助!wepo... 2024新版技巧辅助!wepoke游戏数据有说法吗(透视)外挂透明挂辅助器安装(有挂详情)-哔哩哔哩...
    技巧教程!pokerworld... 技巧教程!pokerworld下载(WPK透视辅助)原来真的有挂(详细透明挂教程);1分钟了解详细教...
    德州论坛辅助!wpk外挂被实锤... 德州论坛辅助!wpk外挂被实锤(透明)外挂透明挂辅助app(有挂分析)-哔哩哔哩是一款可以让一直输的...