dojo 0.4 关于 editor2 的使用
来源:互联网 发布:数据库应用账户管理 编辑:程序博客网 时间:2024/05/24 02:55
dojo 0.4 关于 editor2 的使用
0.4刚出来,我也是刚用上dojo,研究了几天。
由于 editor 在 0.5中将被删除,所以还是用 editor2,不过官方站点的关于 editor2 的文档和例子都比较少,找了半天也没找多少出来,只好自己动手摸了。
我不研究简单的在页面元素中定义 dojo 属性的用法,一般我都不会这么用,一般都是用 javascript 动态创建。
1.创建
var args = {
shareToolbar: false,
toolbarAlwaysVisible: false,
focusOnLoad: true,
closeOnSave: true,
toolbarTemplatePath: "src/widget/templates/EditorToolbar.html",
height: 100
toolbarAlwaysVisible: false,
focusOnLoad: true,
closeOnSave: true,
toolbarTemplatePath: "src/widget/templates/EditorToolbar.html",
height: 100
};
var e = dojo.widget.createWidget("Editor2", args, dojo.byId("divId"));
说明:
官方的例子中还有一个创建参数:commandList: ["bold", "italic", "underline", "insertimage", "save"],但是我怎么试工具栏都出不来,换成 toolbarTemplatePath 就行了。
文件 src/widget/templates/EditorToolbar.html 里面定义了工具栏的内容,可以自行修改。
2.调整
原来提供的几个工具栏的模板文件,如 src/widget/templates/EditorToolbar.html,都不带字体和字号的工具,修改 src/widget/templates/EditorToolbar.html ,在其中加入以下内容:
<td width="36">
<span class="iconContainer dojoEditorToolbarItem" dojoETItemName="fontname">
<span title="设置字体">字体</span>
</span>
</td>
<td width="36">
<span class="iconContainer dojoEditorToolbarItem" dojoETItemName="fontsize">
<span title="设置字号">字号</span>
</span>
</td>
<span class="iconContainer dojoEditorToolbarItem" dojoETItemName="fontname">
<span title="设置字体">字体</span>
</span>
</td>
<td width="36">
<span class="iconContainer dojoEditorToolbarItem" dojoETItemName="fontsize">
<span title="设置字号">字号</span>
</span>
</td>
打开文件 src/widget/templates/Editor2/FontName.html 和 src/widget/templates/Editor2/FontSize.html ,进行字体和字号的定制
3.使用
a.更新内容
e.replaceEditorContent("作者:吴悠");
b.取得内容
alert(e.getEditorContent());
c.执行命令:插入内容
e.execCommand("inserthtml", "作者:吴悠");
注:
commands: inserthtml setbackcolor forecolor backcolor fontsize setfontname setblockformat unlink hilitecolor createlink
4.测试过程中发现一些bug,期待下一版
5.发现与 prototype.js 有冲突
- dojo 0.4 关于 editor2 的使用
- dojo-dojo.xhrGet的使用
- 关于Dojo的Grid
- 关于dojo的认识
- 关于DOJO的介绍
- dojo/query的使用
- DOJO的简单使用
- 使用dojo的tree
- dojo bootstrap的使用
- dojo tree的使用
- dojo enhancedgrid的使用
- 使用dojo的tree
- struts-dojo的使用
- 关于dojo的build系统
- dojo.connect的使用问题
- 使用Dojo的痛苦经历
- dojo的ajax使用入门
- dojo中Tree的使用
- 有些空虚
- 我能算到的阶乘有多大(六)
- XAML 学习(4)
- 22w
- 各地的VPI/VCI
- dojo 0.4 关于 editor2 的使用
- 扎根IE开发拥有自己理想的程序员--张硕
- struts国际化带来的javascript 中文乱码问题
- 从JAWS应用框架谈起
- Ruby on Rails确实很强
- 项目成功的标准
- 使用C#开发SmartPhone程序入门
- 怎样用英语回答外企面试的技巧
- SWT Layout 的注意项