轻量级jQuery文本编辑器插件Froala WYSIWYG Editor

所属分类:输入-丰富的输入

 301639  608  查看评论 (192)
分享到微信朋友圈
X
轻量级jQuery文本编辑器插件Froala WYSIWYG Editor ie兼容9

网友晴朗编辑

$(function() {
	$('.editor').editable({
		inlineMode: false,
		theme: 'gray',
		//模版
		height: '200px' //高度
	});

})


实现中文菜单和上传图片保存到本地路径

<script src="js/editor/libs/jquery-1.11.1.min.js"></script> 
<script src="js/editor/froala_editor.min.js"></script> 
<!--[if lt IE 9]>
    <script src="../js/froala_editor_ie8.min.js"></script>
<![endif]--> 
<script src="js/editor/plugins/tables.min.js"></script> 
<script src="js/editor/plugins/lists.min.js"></script> 
<script src="js/editor/plugins/colors.min.js"></script> 
<script src="js/editor/plugins/media_manager.min.js"></script> 
<script src="js/editor/plugins/font_family.min.js"></script> 
<script src="js/editor/plugins/font_size.min.js"></script> 
<script src="js/editor/plugins/block_styles.min.js"></script> 
<script src="js/editor/plugins/video.min.js"></script> 
<script src="js/editor/langs/zh_cn.js"></script>
    <script>
        $(function () {
            $('#edit').editable({
                inlineMode: false,
                alwaysBlank: true,
                language: "zh_cn",
                direction: "ltr",
                allowedImageTypes: ["jpeg", "jpg", "png", "gif"],
                autosave: true,
                autosaveInterval: 2500,
                saveURL: 'hander/FroalaHandler.ashx',
                saveParams: { postId: "123" },
                spellcheck: true,
                plainPaste: true,
                imageButtons: ["floatImageLeft", "floatImageNone", "floatImageRight", "linkImage", "replaceImage", "removeImage"],
                imageUploadURL: 'hander/FroalaHandler.ashx',
                imageParams: { postId: "123" },
                enableScript: false

            })
        });
    </script>

=======以下内容由 SunRay 提供========

<script>
      $(function(){
          $('#edit').editable({
              inlineMode: false, alwaysBlank: true,
              language: "zh_cn",
              imageUploadURL: 'lib/imgupload.php',//上传到本地服务器
              imageUploadParams: {id: "edit"},
              imageDeleteURL: 'lib/delete_image.php',//删除图片
              imagesLoadURL: 'lib/load_images.php'//管理图片
            }).on('editable.afterRemoveImage', function (e, editor, $img) {
               // Set the image source to the image delete params.        
               editor.options.imageDeleteParams = {src: $img.attr('src')};
               // Make the delete request
.              editor.deleteImage($img);
           });
      });
</script>

上传图片服务器端的PHP代码:

<?php
    // Allowed extentions.
   $allowedExts = array("gif", "jpeg", "jpg", "png");
    // Get filename.
    $temp = explode(".", $_FILES["file"]["name"]);
    // Get extension.
    $extension = end($temp);
    // An image check is being done in the editor but it is best to
    // check that again on the server side.
    // Do not use $_FILES["file"]["type"] as it can be easily forged.
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);
    if ((($mime == "image/gif")    || ($mime == "image/jpeg")    || ($mime == "image/pjpeg")    || ($mime == "image/x-png")    || ($mime == "image/png"))    && in_array($extension, $allowedExts)) {
        // Generate new random name.
        $name = sha1(microtime()) . "." . $extension;
        // Save file in the uploads folder.
        move_uploaded_file($_FILES["file"]["tmp_name"], "../uploads/" . $name);
        // Generate response.
        $response = new StdClass;
        $response->link = "../../uploads/" . $name;
        echo stripslashes(json_encode($response));
      }
?>


相关插件-丰富的输入

Javascript模拟键盘事件

Javascript模拟键盘事件 可对应键盘每一个键
  丰富的输入
 32929  319

jQuery评论插件

这是一个评论插件,传入一个评论体即可,支持对留言的回复
  丰富的输入
 70855  554

仿多说留言、评论框,带微博表情。

仿多说留言、评论框,带微博表情。
  丰富的输入
 56960  625

vue健康问卷调查(原创)

vue实现移动端问卷调查,健康自测等等
  丰富的输入
 29337  339

讨论这个项目(192)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    一寸光阴一寸心 0
    2021/1/4 15:34:47
    有大佬解答下吗?感谢! 这个插件能上传附件吗? 回复
    U+2721(?) 0
    2020/8/8 11:10:01
    请问怎么点击提交获取富文本的内容啊?
        一寸光阴一寸心0
        2021/1/4 15:21:56
        这个插件能上传附件吗
    回复
    ??? 0
    2019/9/30 9:56:27
    怎么设置中文菜单啊,我按照上面的设置没用
        U+2721(?)0
        2020/8/8 10:26:29
        一年过去了解决了吗??
    回复
    还好吗 0
    2019/8/14 6:42:22
    我就想知道怎么获取编辑器里的html内容 回复
    Alixios 0
    2019/7/16 10:05:10
    麻烦问下 我已经拿到图片想在光标处插入图片怎么实现,我怎么获取光标位置
    回复
    少年的猫咪在树上 0
    2019/6/16 22:47:02
    修改本地上传的文件.ashx是什么文件
        WK0
        2019/6/16 22:48:06
        是一般处理程序
        少年的猫咪在树上0
        2019/6/16 22:49:16
        好的谢谢
    回复
    WK 0
    2019/6/10 15:07:18
    上传到本地的图片怎么显示啊 回复
    听? 0
    2019/5/8 16:42:15
    有上传图片服务器端的PHP代码吗,谢谢 回复
    Master 0
    2019/4/10 8:29:14
    有bug, 点击完编号列表或者项目符号后,点击其它按钮无效。 回复
    也许会更好。 0
    2019/2/18 16:05:33
    编辑部分的图片显示不了怎么解决? 回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复