感谢胡大大分享的的开源项目

Angular 的 UEditor 插件 Angular-UEditor

本文只是修改了angular-ueditor.js,加入了对工具栏的定制,方便项目使用

  1 (function() {
2 "use strict";
3 (function() {
4 var NGUeditor;
5 NGUeditor = angular.module("ng.ueditor", []);
6 NGUeditor.directive("ueditor", [
7 function() {
8 return {
9 restrict: "C",
10 require: "ngModel",
11 scope: {
12 config: "=",
13 ready: "="
14 },
15 link: function($S, element, attr, ctrl) {
16 var _NGUeditor, _updateByRender;
17 _updateByRender = false;
18 _NGUeditor = (function() {
19 function _NGUeditor() {
20 this.bindRender();
21 this.initEditor();
22 return;
23 }
24
25
26 /**
27 * 初始化编辑器
28 * @return {[type]} [description]
29 */
30
31 _NGUeditor.prototype.initEditor = function() {
32 var _UEConfig, _editorId, _self;
33 _self = this;
34 if (typeof UE === 'undefined') {
35 console.error("Please import the local resources of ueditor!");
36 return;
37 }
38 _UEConfig = $S.config ? $S.config : {};
39 _UEConfig.initialFrameHeight = 160;
40 if (attr.toolbars === 'basic') {
41 _UEConfig.toolbars = basic;
42 } else if (attr.toolbars === 'full')
43 {
44 _UEConfig.toolbars = full;
45 }
46 _editorId = attr.id ? attr.id : "_editor" + (Date.now());
47 element[0].id = _editorId;
48 this.editor = new UE.getEditor(_editorId, _UEConfig);
49 return this.editor.ready(function() {
50 _self.editorReady = true;
51 _self.editor.addListener("contentChange", function() {
52 ctrl.$setViewValue(_self.editor.getContent());
53 if (!_updateByRender) {
54 if (!$S.$$phase) {
55 $S.$apply();
56 }
57 }
58 _updateByRender = false;
59 });
60 if (_self.modelContent.length > 0) {
61 _self.setEditorContent();
62 }
63 if (typeof $S.ready === "function") {
64 $S.ready(_self.editor);
65 }
66 $S.$on("$destroy", function() {
67 var _ref;
68 if ((_ref = _self.editor && _self.editor.destory) != null) {
69 _ref.destory();
70 }
71 });
72 });
73 };
74
75 _NGUeditor.prototype.setEditorContent = function(content) {
76 if (content == null) {
77 content = this.modelContent;
78 }
79 if (this.editor && this.editorReady) {
80 this.editor.setContent(content);
81 }
82 };
83
84 _NGUeditor.prototype.bindRender = function() {
85 var _self;
86 _self = this;
87 ctrl.$render = function() {
88 _self.modelContent = (ctrl.$isEmpty(ctrl.$viewValue) ? "" : ctrl.$viewValue);
89 _updateByRender = true;
90 _self.setEditorContent();
91 };
92 };
93
94 return _NGUeditor;
95
96 })();
97 new _NGUeditor();
98 }
99 };
100 }
101 ]);
102 var basic = [
103 [
104 'source', //源代码
105 'undo', //撤销
106 'redo', //重做
107 'bold', //加粗
108 'italic', //斜体
109 'underline', //下划线
110 'link', //超链接
111 'unlink', //取消链接
112 'fontfamily', //字体
113 'fontsize', //字号
114 'justifyleft', //居左对齐
115 'justifyright', //居右对齐
116 'justifycenter', //居中对齐
117 'justifyjustify', //两端对齐
118 'forecolor', //字体颜色
119 'insertorderedlist', //有序列表
120 'insertunorderedlist', //无序列表
121 'fullscreen', //全屏
122 ]
123 ];
124 var full = [[
125 'fullscreen', 'source', '|', 'undo', 'redo', '|',
126 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
127 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
128 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
129 'directionalityltr', 'directionalityrtl', 'indent', '|',
130 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
131 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
132 'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
133 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
134 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
135 'print', 'preview', 'searchreplace', 'help', 'drafts'
136 ]];
137 })();
138
139 }).call(this);

1 angular.module('app', ['ui.router', 'ng.ueditor']);

1 <div style="margin-bottom:1.25rem;width:100%;" class="ueditor" toolbars="basic" ng-model="Agreement"></div>

为Angular-UEditor增加工具栏属性的更多相关文章

  1. 富文本编辑器UEditor自定义工具栏(三、自定义工具栏功能按钮图标及工具栏样式简单修改)

    导读 富文本编辑器UEditor提供丰富了定制配置项,如果想设置个性化的工具栏按钮图标有无办法呢?答案是肯定的!前两篇博文简要介绍了通过将原工具栏隐藏,在自定义的外部按钮上,调用UEditor各命令实 ...

  2. 富文本编辑器UEditor自定义工具栏(一、基础配置与字体、背景色、行间距、超链接实现)

    导读:UEditor 是由百度「FEX前端研发团队」开发的所见即所得富文本web编辑器,功能强大,可定制,是一款优秀的国产在线富文本编辑器,编辑器内可插入图片.音频.视频等. 一.UEditor自定义 ...

  3. 富文本编辑器UEditor自定义工具栏(二、插入图片、音频、视频个性化功能按钮和弹层及自定义分页符)

    导读:本篇将简单探讨插入图片.音频.视频的功能按钮实现方式 传送门:富文本编辑器UEditor自定义工具栏(一.基础配置与字体.背景色.行间距.超链接实现) 一.效果图 1.UEditor自定义工具栏 ...

  4. ueditor的工具栏显示乱码解决方法 小问题.. 是你的页面编码与语言包js编码不符所导致的

    ueditor的工具栏显示乱码解决方法 小问题..  是你的页面编码与语言包js编码不符所导致的解决方法:用记事本将ueditor\..\lang\zh-cn\zh-cn.js打开,然后保存为ANSI ...

  5. AE+C# 图层中增加相应属性标注

    原文 AE+C# 图层中增加相应属性标注 ) { IGeoFeatureLayer pGeoFeatureLayer; ILineLabelPosition pLineLabelPosition; I ...

  6. Mybatis增加对象属性不增加mapper.xml的情况

    Mybatis增加对象属性不增加mapper.xml的情况: 只增加Model 对象的属性,在查询语句中返回相同名称的字段,但是在mapper中的 resultMap上面不进行新增字段的增加,查询结果 ...

  7. 动态创建的 CEdit 被限制长度,增加 ES_AUTOHSCROLL 属性;被无法Tab激活焦点,增加 WS_TABSTOP 属性(转)

    动态创建的 CEdit 被限制长度,增加 ES_AUTOHSCROLL 属性:被无法Tab激活焦点,增加 WS_TABSTOP 属性. CEdit m_editUrl; // ES_AUTOHSCRO ...

  8. js给原型增加新属性和方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. 35_张孝祥Java高新技术_为注解增加各种属性

    注解的作用之所以那么强大,就是因为它有属性 注解很像接口,属性很像方法.   什么是注解的属性 一个注解相当于一个胸牌,如果你胸前贴了胸牌,就是传智播客的学生,否则,就不是.如果还想区分出事传智播客 ...

随机推荐

  1. Java静态类

    先要澄清和区别一些概念,“静态类”和“所有方法皆为静态方法的类”. 严格说来,Java中的静态类,指的是“static class”这样修饰的类定义,语法上的要求,使得这样的类一定是内部类,换言之,“ ...

  2. 内存管理(memory allocation内存分配)

    Memory management is the act of managing computer memory. The essential requirement of memory manage ...

  3. 【转】git在eclipse中的配置

    原文网址:http://www.cnblogs.com/zhxiaomiao/archive/2013/05/16/3081148.html 一_安装EGIT插件 http://download.ec ...

  4. MySQL中的类Decode用法

    SELECT DISTINCT ( CASE ' THEN '关羽' ' THEN ' 张飞' ' THEN ' 赵云' ' THEN ' 马超' ' THEN ' 黄忠' ' THEN ' 魏延' ...

  5. MySQL安装没有弹出配置向导

    安装MySQL过程中一切都正常只是没有弹出MySQL配置向导对话框,即出现"launch the MySQL Instance Configuration Wizard" fini ...

  6. 关于Marsedit和我的163博客

    其实我一开始选择的并不是163的博客,感觉没什么新意,勾不起我的兴趣. 第一个我想写的是CSDN的博客,代码嘛,总要找个专业的网站来写,但是我发现了一个及其让我不爽的事情,我竟然在网页上无法新建一篇日 ...

  7. FPGA入门学习第一课:二分频器

    分频器还是比较简单的,一般的思路是:每数几个时钟就输出一个时钟.最简单的当数二分频器了,每当时钟上升沿(或下降沿)就把输出翻转一下.这样就刚好实现了二分频器了. 网上也搜到了最简实现”二分频最简单了, ...

  8. asterisk帮助与国内论坛

    http://www.in2eps.com/fo-abnf/tk-fo-abnf-http.html www.asteriskguru.com/ http://www.voip-info.org/ h ...

  9. Ubuntu 虚拟机环境安装配置指南

    1. 安装Ubuntu到虚拟机. 到 Ubuntu 上下载桌面版iso文件,加载到虚拟机,开始安装,傻瓜式操作不用多说.2. 调整屏幕分辨率. 虚拟机软件我是用的virtual box,在工具栏上设备 ...

  10. XML文件操作指南

    一.XML简介 XML的全名是eXtensible Markup Language(可以扩展的标记语言),它的语法类似HTML,都是用标签来描述数据.HTML的标签是固定的,我们只能使用.不能修改: ...