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

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. 【POJ】2828 Buy Tickets

    线段树+逆序插入. #include <stdio.h> #include <string.h> #define MAXN 200005 #define lson l, mid ...

  2. Windows 8 关闭无线后无法打开WIFI的解决办法

    转:http://blog.sina.com.cn/s/blog_49d02ed101016b4n.html 在使用 Windows 8 的过程中,遇到过几次使用键盘上的功能键(笔者笔记本上的快捷键是 ...

  3. APP界面设计之页面布局的22条基本原则

    移动 APP 页面布局(Layout)是我们设计 app 界面的时候,最主要的设计任务.一个 app 的好与不好,很大部分取决于移动 APP 页面布局的合理性. 下图为 APP 最原始的布局模型. 页 ...

  4. Delphi实现WebService带身份认证的数据传输

    WebService使得不同开发工具开发出来的程序可以在网络连通的环境下相互通信,它最大的特点就是标准化(基于XML的一系列标准)带来的跨平台.跨开发工具的通用性,基于HTTP带来的畅通无阻的能力(跨 ...

  5. Hibernate(一)JDBC简介

    在了解Hibernate之前,我们先回顾一下传统JDBC访问数据库的相关内容.重点在于分析JDBC访问存在哪些 缺陷,这些缺陷在Hibernate中是如何思考和解决的? JDBC主要对象 DriveM ...

  6. JavaScript 模块化加载

    存在AMD(Asynchronous Module Definition异步模块定义)规范和CMD(Common Module Definition通用模块定义)规范.对于依赖的模块,AMD是提前执行 ...

  7. GDI+ —— Tcanvas 类属性及方法.......

    delphi TCanvas类 类关系   TObject-> TPersistent   对那些作图对象,可使用TCanvas对象作为画布.标准的window控件,例如编辑控件和列表框控件,当 ...

  8. poj 1679 The Unique MST【次小生成树】

    The Unique MST Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24034   Accepted: 8535 D ...

  9. thinkphp 重定向redirect

    /** * URL重定向 * @param string $url 重定向的URL地址 * @param integer $time 重定向的等待时间(秒) * @param string $msg ...

  10. python 写的http后台弱口令爆破工具

    今天来弄一个后台破解的Python小程序,哈哈,直接上代码吧,都有注释~~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...