ÔõÑùÔÚThinkPHP6ÖÐʹÓÃWangEditor¸»Îı¾±à¼Æ÷£¿
Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤£¬¸»Îı¾±à¼Æ÷ÒѾ³ÉΪÁËÍøÕ¾¿ª·¢Àú³ÌÖв»¿Éȱ°±ÉÄÒ»²¿·Ö¡£¶øwangeditor×÷Ϊº£ÄÚ¿ªÔ´µÄÒ»¿î¸»Îı¾±à¼Æ÷£¬Æä¾ß±¸Ò×Óá¢ÇáÁ¿¡¢¹¦Ð§¸»ºñµÈÓÅÒìÌص㣬ÒѾÖð½¥³ÉΪÁËÐí¶à¿ª·¢ÕßµÄÊ×Ñ¡¡£
¶øThinkPHP6×÷ΪÏÖÔÚº£ÄÚ×îÖ÷Á÷µÄPHP¿ª·¢¿ò¼ÜÖ®Ò»£¬Ò²ÌṩÁ˸»ºñµÄÀ©Õ¹¹¦Ð§£¬¿ÉÒÔ×ÊÖú¿ª·¢Õß¿ìËٵؼ¯³ÉWangEditor¸»Îı¾±à¼Æ÷¡£±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùÔÚThinkPHP6ÖÐʹÓÃWangEditor¸»Îı¾±à¼Æ÷¡£
Ò»¡¢ÏÂÔØWangEditor
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏÂÔØWangEditor±à¼Æ÷Ô´Âë¡£¿ÉÒÔÔÚWangEditorµÄ¹Ù·½ÍøÕ¾£¨https://www.wangeditor.com/£©ÉÏÏÂÔØ×îа档½âѹԴÂëºó£¬½«Ä¿Â¼¸´ÖƵ½ÎÒÃǵÄThinkPHP6ÏîÄ¿ÖеÄpublicĿ¼Ï¡£
¶þ¡¢ÒýÈëWangEditor×ÊÔ´Îļþ
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÔÚÎÒÃÇÐèҪʹÓÃWangEditorµÄÒ³ÃæÖУ¬ÎÒÃÇÐèÒªÒýÈëÒÔÏÂ×ÊÔ´Îļþ£º
<link rel="stylesheet" type="text/css" href="/public/wangEditor-3.1.1/release/wangEditor.min.css"> <script type="text/javascript" src="/public/wangEditor-3.1.1/release/wangEditor.min.js"></script>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬wangEditor.min.cssÊÇWangEditorµÄÑùʽÎļþ£¬wangEditor.min.jsÊÇWangEditorµÄÖ÷ÒªJavascriptÎļþ¡£
Èý¡¢½¨ÉèÒ³Ãæ
ÔÚÎÒÃÇÐèҪʹÓÃWangEditorµÄÒ³ÃæÖУ¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öÓÃÀ´ÏÔʾ±à¼Æ÷µÄdivÈÝÆ÷£¬²¢ÉèÖÃÒ»¸öID¡£ÀýÈ磺
<div id="editor"></div>
µÇ¼ºó¸´ÖÆ
ËÄ¡¢³õʼ»¯WangEditor
ÔÚÒ³Ãæ¼ÓÔØÍê³Éºó£¬ÎÒÃÇÐèÒª¶ÔWangEditor¾ÙÐгõʼ»¯£¬ÎªÆäÉèÖÃÏà¹ØµÄ²ÎÊý¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄʾÀý£º
<script type="text/javascript"> var editor = new wangEditor('#editor'); editor.create(); </script>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬#editorÊÇÎÒÃÇÉèÖõÄdivµÄID¡£Í¨¹ývar editor = new wangEditor(‘#editor’);¾ÙÐÐʵÀý»¯£¬È»ºóͨ¹ýeditor.create()ÒªÁì³õʼ»¯±à¼Æ÷¡£´Ëʱ£¬ÎÒÃǵÄÒ³Ãæ¾Í¿ÉÒÔʹÓÃWangEditor¸»Îı¾±à¼Æ÷ÁË¡£
Îå¡¢ÉèÖñà¼Æ÷²ÎÊý
³ýÁ˳õʼ»¯±à¼Æ÷Í⣬ÎÒÃÇ»¹¿ÉÒÔƾ֤ÐèÒªÉèÖñà¼Æ÷µÄ²ÎÊý¡£ÒÔÏÂÊÇһЩʾÀý£¬¸÷ÈË¿ÉÒÔƾ֤ÐèÇó×ÔÐÐÑ¡Ôñ£º
ÉèÖñà¼Æ÷µÄ¿í¶ÈºÍ¸ß¶È
var editor = new wangEditor('#editor'); editor.config.height = 500; //ÉèÖñà¼Æ÷¸ß¶È editor.config.width = '100%'; //ÉèÖñà¼Æ÷¿í¶È
µÇ¼ºó¸´ÖÆ
ÉèÖñà¼Æ÷µÄ×ÖÌåÑÕÉ«ºÍÅä¾°ÑÕÉ«
var editor = new wangEditor('#editor'); editor.config.colors = [ //ÉèÖÃÑÕÉ«Ñ¡Ïî '#000000', '#eeece0', '#1c487f', '#4d80bf', '#c9c9c9', '#999999', '#005bac', '#ccb8b8', '#7f7f7f', '#f5f5f5', '#c3d69b', '#acc8cc', '#d5e8d4', '#f6cfca', '#ff5555' ]; editor.config.menus = [ 'forecolor', //×ÖÌåÑÕÉ« 'bgcolor' //Åä¾°ÑÕÉ« ];
µÇ¼ºó¸´ÖÆ
ÉèÖñà¼Æ÷µÄ×ÖÌå
var editor = new wangEditor('#editor'); editor.config.fontNames = [ '΢ÈíÑźÚ', 'ËÎÌå', 'Arial', 'Tahoma', 'Verdana' ];
µÇ¼ºó¸´ÖÆ
ÉèÖÃÉÏ´«Í¼Æ¬µÄ½Ó¿Ú
var editor = new wangEditor('#editor'); editor.config.uploadImgUrl = '/upload' //ÉÏ´«Í¼Æ¬½Ó¿ÚµÄURL
µÇ¼ºó¸´ÖÆ
Áù¡¢»ñÈ¡±à¼Æ÷ÖеÄÄÚÈÝ
ÔÚÓû§Íê³É±à¼ºó£¬ÎÒÃÇÐèÒª»ñÈ¡±à¼Æ÷ÖеÄÄÚÈÝ¡£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄʾÀý£º
<script type="text/javascript"> var editor = new wangEditor('#editor'); editor.create(); //»ñÈ¡±à¼Æ÷ÖеÄÄÚÈÝ var content = editor.txt.html(); </script>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬editor.txt.html()ÒªÁì·µ»Ø±à¼Æ÷ÖеÄHTML×Ö·û´®¡£
×ܽá
ÒÔÉϾÍÊÇÔÚThinkPHP6ÖÐʹÓÃWangEditor¸»Îı¾±à¼Æ÷µÄÏêϸÏÈÈÝ¡£Í¨¹ý¼òÆÓµØÒýÈë×ÊÔ´Îļþ¡¢½¨ÉèÒ³Ãæ¡¢³õʼ»¯±à¼Æ÷ÒÔ¼°ÉèÖòÎÊý£¬ÎÒÃÇ¿ÉÒÔ¿ìËٵؼ¯³ÉWangEditor¸»Îı¾±à¼Æ÷£¬ÇáËÉʵÏÖ¸»Îı¾±à¼¹¦Ð§¡£
ÒÔÉϾÍÊÇÔõÑùÔÚThinkPHP6ÖÐʹÓÃWangEditor¸»Îı¾±à¼Æ÷£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡