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

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. Tomcat默认打开项目设置

    Tomcat设置默认启动项目 Tomcat设置默认启动项目,顾名思义,就是让可以在浏览器的地址栏中输入ip:8080,就能访问到我们的项目.具体操作如下: 1.打开tomcat的安装根目录,找到Tom ...

  2. bzoj1576 3694

    两道题目本质是一样的bzoj1576我们先要用dij+heap处理出最短路径树和起点到每个点的最短路径而bzoj3694已经给出了最短路径树,所以直接dfs即可题目要求的是不走起点到每个点最短路径上的 ...

  3. 如何查看jar包的版本号?

    jar包根目录里的META-INF目录下的MANIFEST.MF文件里一般有会记录版本信息,可以到这个文件里查看   打开Java的JAR文件我们经常可以看到文件中包含着一个META-INF目录,这个 ...

  4. 【游戏框架】Phaser

    PhaserDesktop and Mobile HTML5 game framework Phaser Examples

  5. 踩过的坑之-----selector

    打算踏踏实实的做技术了,以前总是毛毛躁躁的将代码粘贴复制完事能跑起来就行.最近慢慢感觉这样真的对自己的时间和经历是一种浪费. 就从最基本的做起吧,今天做了一个selector,在按钮上面添加效果, & ...

  6. Howto Setup yum repositories to update or install package from ISO CDROM Image

    Step # 1: Mount an ISO file Type the following command (replace iso file name with the actual iso fi ...

  7. Linux process state codes

    Here are the different values that the s, stat and state output specifiers (header "STAT" ...

  8. A Dicey Problem 骰子难题(Uva 810)

    题目描述:https://uva.onlinejudge.org/external/8/810.pdf 把一个骰子放在一个M x N的地图上,让他按照规定滚动,求滚回原点的最短路径. 思路:  记忆化 ...

  9. hdoj 2199 Can you solve this equation?【浮点型数据二分】

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  10. 【Lucene3.6.2入门系列】第14节_SolrJ操作索引和搜索文档以及整合中文分词

    package com.jadyer.solrj; import java.util.ArrayList; import java.util.List; import org.apache.solr. ...