• CKEditor(用户使用版)


    第一步:

    打开bbcode.html文件

    第二步:复制下面这段代码封装成一个方法,在$(function (){调用})

    第三步:打开这个api.html,右键查看源代码

    第四步:找到这两个方法,不能像以前通过$("#id").val()这种方式取文本框的值,要通过下面两个方法取值

    取值

    赋值

    第五步:在WebCommon.cs共同工具类里面粘贴以下方法,通过正则表达式把UBB编码转成HTML编码

    /// <summary>
            /// 将UBB编码转成HTML编码
            /// </summary>
            /// <param name="argString"></param>
            /// <returns></returns>
            public static string UbbToHtml(string argString)
            {
                string tString = argString;
                if (tString != "")
                {
                    Regex tRegex;
                    bool tState = true;
                    tString = tString.Replace("&", "&amp;");
                    tString = tString.Replace(">", "&gt;");
                    tString = tString.Replace("<", "&lt;");
                    tString = tString.Replace(""", "&quot;");
                    tString = Regex.Replace(tString, @"[br]", "<br />", RegexOptions.IgnoreCase);
                    string[,] tRegexAry = {
              {@"[p]([^[]*?)[/p]", "$1<br />"},
              {@"[b]([^[]*?)[/b]", "<b>$1</b>"},
              {@"[i]([^[]*?)[/i]", "<i>$1</i>"},
              {@"[u]([^[]*?)[/u]", "<u>$1</u>"},
              {@"[ol]([^[]*?)[/ol]", "<ol>$1</ol>"},
              {@"[ul]([^[]*?)[/ul]", "<ul>$1</ul>"},
              {@"[li]([^[]*?)[/li]", "<li>$1</li>"},
              {@"[code]([^[]*?)[/code]", "<div class="ubb_code">$1</div>"},
              {@"[quote]([^[]*?)[/quote]", "<div class="ubb_quote">$1</div>"},
              {@"[color=([^]]*)]([^[]*?)[/color]", "<font style="color: $1">$2</font>"},
              {@"[hilitecolor=([^]]*)]([^[]*?)[/hilitecolor]", "<font style="background-color: $1">$2</font>"},
              {@"[align=([^]]*)]([^[]*?)[/align]", "<div style="text-align: $1">$2</div>"},
              {@"[url=([^]]*)]([^[]*?)[/url]", "<a href="$1">$2</a>"},
              {@"[img]([^[]*?)[/img]", "<img src="$1" />"}
            };
                    while (tState)
                    {
                        tState = false;
                        for (int ti = 0; ti < tRegexAry.GetLength(0); ti++)
                        {
                            tRegex = new Regex(tRegexAry[ti, 0], RegexOptions.IgnoreCase);
                            if (tRegex.Match(tString).Success)
                            {
                                tState = true;
                                tString = Regex.Replace(tString, tRegexAry[ti, 0], tRegexAry[ti, 1], RegexOptions.IgnoreCase);
                            }
                        }
                    }
                }
                return tString;
            }

    第六步:在加载评论的方法里面,取出模型的值放到一个ViewModel里面之前,调用上面工具类的UBB转HTML方法

  • 相关阅读:
    典型用户和用户场景
    每日站立会议个人博客(冲刺周)-Tuesday
    WPS中VB编辑器的安装
    WARN hdfs.DataStreamer: Caught exception
    java.net.ConnectException: Your endpoint configuration is wrong; For more details see: http://wiki.apache.org/hadoop/UnsetHostnameOrPort
    “初始化 Java 工具”期间发生了内部错误, java.lang.NullPointerException
    在Github上搭建个人主页
    关于新版的MySQL安装教程
    stopping hbasecat:/tmp/hbase-root-master.pid:No such file or directory
    途牛订单的服务化演进
  • 原文地址:https://www.cnblogs.com/BOSET/p/6927506.html
Copyright © 2020-2023  润新知