Ueditor 在线文本编辑器

1.index.htmljavascript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>完整demo</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
    <!--建议手动加在语言,避免在ie下有时由于加载语言失败致使编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,好比你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script>
</head>
<body>

<form action="index.php" method="post">
<script id="editor" type="text/plain" style="width:1024px;height:500px;" name="content"></script>
<input type="submit" value="提交">
</form>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor建立和引用编辑器实例,若是在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
    //修改toolbars 工具栏的自定义
    var ue = UE.getEditor('editor',{
        toolbars:[[
            'undo', //撤销
            'redo', //重作
            'bold', //加粗
            'fontfamily', //字体
            'fontsize', //字号
            'emotion', //表情
            'spechars', //特殊字符

        ],[            
            'justifyleft', //居左对齐
            'justifyright', //居右对齐
            'justifycenter', //居中对齐
            'justifyjustify', //两端对齐
            'forecolor', //字体颜色
            'insertcode', //代码语言
            'simpleupload', //单图上传
            'insertimage', //多图上传
            'insertvideo', //视频
        ]],
        autoHeightEnabled:false,
        isshow:true,
        //initialContent:'hello world',
        focus:true,
        //readonly:true,
        enableAutoSave:true,
        saveInterval:100,

    })


  
</script>
</body>
</html>

2.index.phpphp

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- 引入文件 -->
<script type="text/javascript" src="third-party/SyntaxHighlighter/shCore.js"></script>
<link rel="stylesheet" href="third-party/SyntaxHighlighter/shCoreDefault.css"> 

    <title></title>
</head>
<body>
    <?php
    echo $_POST['content'];
    ?>
</body>
<script type="text/javascript">
    SyntaxHighlighter.all();//代码高亮
</script>
 
</html>
相关文章
相关标签/搜索