uniGUI学习之UniHTMLMemo1富文本编辑器

1]系统自带的富文本编辑器

2]jQuery+Bootstarp富文本编辑器插件summernote.js


1]系统自带的富文本编辑器


1、末尾增加<p>

2、增加字体

3、解决滚屏问题

4、输入长度限制问题

5、显示 并 编辑 HTML源代码(主要是图片处理)


1、末尾增加<p>

复制代码
UniHTMLMemo1.Lines.Add("<p>"+UniHTMLMemo3.Text);
UniHTMLMemo1.Lines.Clear();//清空输入框

在这里你会发现我在发送文字处增加了"<p>",那是因为如果不增加这个,接收窗口显示时会把多次信息链接到一起,没有换行。

2、增加字体

复制代码
function beforeInit(sender, config)
{
  config.fontFamilies = ['楷体','黑体','隶书','幼圆','华文中宋'];
}

3、解决滚屏问题

也许是uniHTMLMemo的BUG,uniMemo在不断增加新的消息时会自动滚屏,但是UniHTMOMemo不会,可在发完消息后和收到消息后添加调用javaScript函数解决。

/*HTMLMemo好友聊天滚屏*/

复制代码
UniSession.AddJS('Ext.defer(function(){var me='+ UniHTMLMemo1.JSName +'.iframeEl.el.dom; me.contentWindow.scrollTo(0, me.contentDocument.scrollingElement.scrollHeight)}, 200);');

4、输入长度限制问题

该控件没有了MaxLength属性,可以在ClientEvents的UniEvents的beforeinit事件中实现

复制代码
function beforeInit(sender, config)
{ config.enforceMaxLength=true;
config.maxLength=450;
}

5、显示 并 编辑 HTML源代码(主要是图片处理)

5.1引用本地图片

5.2先从Word里等复制图片,再 粘贴到UniHTMLMemo1


2]jQuery+Bootstarp富文本编辑器插件summernote.js,

解决系统自带的不能插入图片,字体少等问题 https://www.lanrenzhijia.com/comm/4520.html

最终效果:

将文件解压到与EXE同一个目录下

将UniHTMLFrame1的HTML设置为

更多初始设置: https://www.likecs.com/show-540425.html

复制代码
<style>
    .m{ width: 800px; margin-left: auto; margin-right: auto; }
</style>

<script>
$(function(){
 $('.summernote').summernote({
        height: 200,
        tabsize: 2,
        lang: 'zh-CN'
    });
});
</script>    
<div class="m">        
    <div class="summernote">涂磊  欢迎您!</div>
</div>

同时 ,加入引用CSS和JS文件

复制代码
js/bootstrap.min.js
dist/summernote.js
dist/lang/summernote-zh-CN.js
dist/bootstrap.css
dist/summernote.css

登录后复制

复制代码
lang: \'zh-CN\',
         height: 300,
         placeholder: "详情...",
         minHeight: null, // set minimum height of editor
         maxHeight: null, // set maximum height of editor
         focus: false,
         disableDragAndDrop: true,
         dialogsInBody: true,
         dialogsFade: true,
         fontSizes: [\'8\', \'9\', \'10\', \'11\', \'12\', \'13\', \'14\', \'15\', \'16\', \'17\', \'18\', \'19\', \'20\', \'21\', \'22\', \'23\', \'24\', \'25\'],
         fontNames: [
             \'Arial\', \'Arial Black\', \'Comic Sans MS\', \'Courier New\',
             \'Helvetica Neue\', \'Helvetica\', \'Impact\', \'Lucida Grande\',
             \'Tahoma\', \'Times New Roman\', \'Verdana\', \'Microsoft YaHei\'
         ],
         toolbar: [
             // [groupName, [list of button]]
             [\'style\', [\'bold\', \'italic\', \'underline\', \'clear\', \'fontsize\', \'fontname\']],
             [\'color\', [\'color\']],
             [\'font\', [\'style\', \'strikethrough\', \'superscript\', \'subscript\', \'height\']],
             //[\'para\', [\'ul\', \'ol\', \'paragraph\']],
             [\'para\', [\'paragraph\']],
             //[\'video\', [\'video\']],
             [\'picture\', [\'picture\']],
             [\'link\', [\'link\']],
             [\'table\', [\'table\']],
             //[\'hr\', [\'hr\']],
             [\'undo\', [\'undo\']],
             [\'redo\', [\'redo\']],
             [\'help\', [\'help\']],
             [\'codeview\', [\'codeview\']]
         ],
相关推荐
diablobaal2 小时前
云计算学习100天-第21天
学习
好望角雾眠13 小时前
第一阶段C#基础-10:集合(Arraylist,list,Dictionary等)
笔记·学习·c#
艾伦~耶格尔13 小时前
【集合框架LinkedList底层添加元素机制】
java·开发语言·学习·面试
星仔编程14 小时前
python学习DAY46打卡
学习
大霞上仙14 小时前
实现自学习系统,输入excel文件,能学习后进行相应回答
python·学习·excel
yatingliu201916 小时前
HiveQL | 个人学习笔记
hive·笔记·sql·学习
武当豆豆16 小时前
C++编程学习(第25天)
开发语言·c++·学习
风和日丽 随波逐流16 小时前
java17学习笔记-Deprecate the Applet API for Removal
笔记·学习
淮北也生橘1216 小时前
Linux的ALSA音频框架学习笔记
linux·笔记·学习
diablobaal16 小时前
云计算学习100天-第17天
学习