SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
Kissy editor开发与设计
Report
yiming he
Follow
kissyteam engineer at taobao
Oct. 18, 2010
•
0 likes
•
2,229 views
1
of
52
Kissy editor开发与设计
Oct. 18, 2010
•
0 likes
•
2,229 views
Report
Technology
kissy editor dev and design
yiming he
Follow
kissyteam engineer at taobao
Recommended
05 MapKit and Text Input
Tom Fan
609 views
•
37 slides
02 Objective-C
Tom Fan
371 views
•
54 slides
合久必分,分久必合
Qiangning Hong
5.2K views
•
55 slides
深入淺出 Web 容器 - Tomcat 原始碼分析
Justin Lin
3.8K views
•
52 slides
Script with engine
Webrebuild
957 views
•
39 slides
OpenEJB - 另一個選擇
Justin Lin
1.8K views
•
49 slides
More Related Content
What's hot
论 Python 与设计模式。
勇浩 赖
1.9K views
•
36 slides
14 Saving Loading and Application States
Tom Fan
569 views
•
65 slides
页游开发中的 Python 组件与模式
勇浩 赖
2.1K views
•
55 slides
J Query Learn
guestfb42fc
672 views
•
25 slides
Osgi Intro
Ching Yi Chan
788 views
•
37 slides
JavaScript Advanced Skill
firestoke
1K views
•
26 slides
What's hot
(19)
论 Python 与设计模式。
勇浩 赖
•
1.9K views
14 Saving Loading and Application States
Tom Fan
•
569 views
页游开发中的 Python 组件与模式
勇浩 赖
•
2.1K views
J Query Learn
guestfb42fc
•
672 views
Osgi Intro
Ching Yi Chan
•
788 views
JavaScript Advanced Skill
firestoke
•
1K views
JCConf2015: groovy to gradle
Ching Yi Chan
•
1.4K views
JavaScript 80+ Programming and Optimization Skills
Ho Kim
•
2.4K views
Java Thread
艾鍗科技
•
18K views
I os 09
信嘉 陳
•
947 views
Python 于 webgame 的应用
勇浩 赖
•
4.5K views
Underscore
cazhfe
•
1.3K views
A
guested19a2
•
233 views
16 CoreData
Tom Fan
•
583 views
Uliweb框架思想与编程
modou li
•
542 views
前端测试
frontwindysky
•
5.5K views
Ejb工作原理学习笔记
yiditushe
•
267 views
JavaScript 教程
Bobby Zhou
•
79 views
潜力无限的编程语言Javascript
jay li
•
9.4K views
Similar to Kissy editor开发与设计
张所勇:前端开发工具推荐
zhangsuoyong
1.8K views
•
102 slides
Berserk js
taobao.com
2.4K views
•
71 slides
Kind editor设计思路
taobao.com
1.7K views
•
38 slides
KISSY Editor Design 2
yiming he
1.1K views
•
55 slides
Kindeditor设计思路v2
luolonghao
618 views
•
40 slides
Ecma script edition5-小试
lydiafly
780 views
•
43 slides
Similar to Kissy editor开发与设计
(20)
张所勇:前端开发工具推荐
zhangsuoyong
•
1.8K views
Berserk js
taobao.com
•
2.4K views
Kind editor设计思路
taobao.com
•
1.7K views
KISSY Editor Design 2
yiming he
•
1.1K views
Kindeditor设计思路v2
luolonghao
•
618 views
Ecma script edition5-小试
lydiafly
•
780 views
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
Will Huang
•
19.5K views
Kindeditor 设计思路
luolonghao
•
669 views
前端测试
Zheng Biao
•
747 views
Spring 2.x 中文
Guo Albert
•
679 views
I os 16
信嘉 陳
•
710 views
Er introduction
Yubei Li
•
398 views
Spring4.x + hibernate4.x_配置详解
zany_hui
•
471 views
Cfengine培训文档 刘天斯
liuts
•
2.5K views
Flex 4.5 action custom component development
jexchan
•
832 views
Javascript之昨是今非
Tony Deng
•
1.6K views
钱宝坤:多浏览器集成的JavaScript单元测试工具
taobao.com
•
1.8K views
快快樂樂學會 Angular 2 網站開發框架 (Modern Web 2016)
Will Huang
•
10.7K views
A
guested19a2
•
190 views
使用 Visual Studio Code 建構 JavaScript 應用程式
Will Huang
•
15.3K views
More from yiming he
kissy 1.5 progress
yiming he
883 views
•
26 slides
kissy at alibaba
yiming he
959 views
•
34 slides
kissy modularization part2
yiming he
700 views
•
17 slides
kissy modularization part1
yiming he
1.3K views
•
29 slides
KISSY @ 2013-2
yiming he
624 views
•
8 slides
KISSY 1.4.0 released
yiming he
859 views
•
19 slides
More from yiming he
(20)
kissy 1.5 progress
yiming he
•
883 views
kissy at alibaba
yiming he
•
959 views
kissy modularization part2
yiming he
•
700 views
kissy modularization part1
yiming he
•
1.3K views
KISSY @ 2013-2
yiming he
•
624 views
KISSY 1.4.0 released
yiming he
•
859 views
callSuper in kissy
yiming he
•
697 views
KISSY XTemplate
yiming he
•
862 views
Introduction to kissy for adc 2013
yiming he
•
782 views
Kissy component system
yiming he
•
812 views
KISSY@2013.05
yiming he
•
477 views
kissy@2013.03
yiming he
•
660 views
kissy@2013
yiming he
•
709 views
KISSY 1.3-released
yiming he
•
1.4K views
Simple kissy1.3
yiming he
•
578 views
Hujs 总结
yiming he
•
698 views
Kissy in-progress
yiming he
•
1.2K views
Kissy dpl-practice
yiming he
•
359 views
编辑器设计2
yiming he
•
910 views
KISSY Component API Design
yiming he
•
698 views
Recently uploaded
ncuma_函數微分計算_習題2.pptx
NCU MCL
18 views
•
1 slide
ncuma_牛頓法.pptx
NCU MCL
10 views
•
4 slides
ncuma_SymPy符號運算套件_習題2.pptx
NCU MCL
6 views
•
2 slides
黃俊毓講師_以黑客精神黑客自己的家鄉.pdf
俊毓 黃
26 views
•
41 slides
ncuma_Taylor 多項式_習題2.pptx
NCU MCL
9 views
•
2 slides
ncuma_函數畫圖_習題1.pptx
NCU MCL
477 views
•
1 slide
Recently uploaded
(20)
ncuma_函數微分計算_習題2.pptx
NCU MCL
•
18 views
ncuma_牛頓法.pptx
NCU MCL
•
10 views
ncuma_SymPy符號運算套件_習題2.pptx
NCU MCL
•
6 views
黃俊毓講師_以黑客精神黑客自己的家鄉.pdf
俊毓 黃
•
26 views
ncuma_Taylor 多項式_習題2.pptx
NCU MCL
•
9 views
ncuma_函數畫圖_習題1.pptx
NCU MCL
•
477 views
ncuma_串列.pptx
NCU MCL
•
52 views
ncuma_函數微分計算_習題1.pptx
NCU MCL
•
31 views
ncuma_SymPy符號運算套件_習題1.pptx
NCU MCL
•
11 views
ncuma_函數畫圖.pptx
NCU MCL
•
680 views
ncuma_函數畫圖_習題3.pptx
NCU MCL
•
917 views
ncuma_SymPy符號運算套件.pptx
NCU MCL
•
99 views
ncuma_pylab.pptx
NCU MCL
•
276 views
ncuma_函數微分計算.pptx
NCU MCL
•
27 views
ncuma_數值求根法.pptx
NCU MCL
•
15 views
Keysight Recent Press Release for 5G RAN 20220725.pdf
TimmyCheng5
•
7 views
ncuma_Taylor 多項式_習題1.pptx
NCU MCL
•
12 views
ncuma_Taylor 多項式.pptx
NCU MCL
•
21 views
ncuma_微分方程式.pptx
NCU MCL
•
6 views
ncuma_函式.pptx
NCU MCL
•
91 views
Kissy editor开发与设计
1.
Kissy editor 介绍
何一鸣(承玉@taobao)
2.
About me 2003
- 2010 Fudan CS 2010.07 - F2E @ Taobao 目前开发维护 kissy editor
3.
大纲
1. 编辑器的分类 2. 编辑器的实现 3. KISSY Editor的设计 4. 打包与部署 5. 总结与前景展望
4.
1. 编辑器的分类
5.
1.1 所想即所得
6.
1.2 所见即所得
7.
Web 可视化编辑器
8.
2. 编辑器的实现
创建 iframe 元素,设置 body 属性 contenteditable为 true 方法 ◦ 调用 execCommand ◦ Range 自主实现 实现注意
9.
2.1 调用 execCommand
ie 4.0 引入 bSuccess = object.execCommand(sCommand[,bUserInterface][,vValue]) ◦ sCommand : 命令名 ◦ bUserInterface : 用户界面提示 ◦ vValue : 命令参数
10.
execCommand 例子
加粗当前选择文字 ◦ document.execCommand("bold",null,false); 添加链接 ◦ 直接添加 document.execCommand("createlink", null,"http://www.g.cn"); ◦ 弹窗提示用户输入 document.execCommand("createlink", true);
11.
execCommand 问题 ◦
代码生成不一致 行内格式化 ie 会生成 font 标签 <font color=“#ff0000”>x</font> safari 生成私有 class <span class=“Apple-style-span” style=“font-weight:bold;”>x</span> ◦ 能力不一致 Createlink Firefox 不支持用户界面提示 自己 window.prompt
12.
execCommand 兼容性
13.
execCommand
14.
2.2 Range 自主实现
使用 range 实现 execCommand 对等 功能。 ◦ Range api (w3c , ie)
15.
W3c Range
用来获取光标或选择区域信息 W3c api Interface Range { ◦ Node startContainer ◦ Long startOffset ◦ Node endContainer ◦ Long endOffset }
16.
IE Range
ControlRange ◦ 选取整个元素 (div,img,object) ◦ Item (index) : 获取选中元素节点 TextRange ◦ 获取选中的文本区域 ◦ Text : 选中的文本串值 ◦ parentElement() : ◦ compareEndPoints() ◦ moveToElementText()
17.
Do not hurt
web
18.
实现 execCommand
Range + Dom2 + Dtd = execCommand
19.
Dtd 的作用
标签格式化系统需要考虑标签嵌套规则 根据 dtd 以及格式标签进行 Range 的 拆分!
20.
Dtd 例子
加粗 ◦ ^<p>line</p><p>line2</p>^ ◦ 错误: <strong><p>line</p><p>line2</p> </strong> ◦ 正确: <p><strong>line<strong></p> <p><strong>line2</strong></p>
21.
2.3 常见问题
换行代码生成差异 ie 选择区域丢失问题 Firefox 不可编辑问题 光标定位问题…..
22.
Enter 换行差异 ◦
<h1>bla bla^</h1> 末尾换行 ie <h1>bla bla</h1> <p>|</p> Safari <h1>bla bla</h1> <h1>|</h1> Firefox <h1>bla bla</h1> |<br><br>
23.
ie 选择区域丢失
ie 编辑器内 iframe文档失去焦点后, 其选择区域/光标位置也随之丢失 。 解决: ◦ 随时存储当前 range ◦ 即将获取焦点前(focusin)立即恢复 range
24.
Firefox 不可编辑问题
Firefox 编辑器内 iframe 移动后(最 大化),不可再编辑。 解决: ◦ 重置 contenteditable 属性
25.
3. KISSY Editor
的设计 3.1 功能简介与 demo 演示 3.2 总体架构 3.3 插件机制 3.4 动态加载机制 3.5 定制插件开发 3.6 设计模式的应用
26.
3.1 功能介绍
27.
功能介绍
28.
3.2 总体架构
Custom plugins Core plugins Editor core Kissy core
29.
架构介绍
30.
3.3 插件机制
editor.addCommand(“image”,imageSupportObj);
31.
插件实现分离机制
插件的功能定义在 KISSY.Editor ◦ 插件功能类: KISSY.Editor.ColorDef.prototype.do=function(){} ◦ UI插件类 KISSY.Editor.Overlay=function(){ }
32.
插件的实例应用
插件最终要使用在实例上 ◦ KISSY.Editor.use(“colordef”,function(){ editor.addButton({ click:function(){ colorInstance.do(); } }); ◦ }); 实例的use即是应用插件的过程 ◦ editor.use(“color”);
33.
3.4 动态加载机制
1. 插件窗口按需动态加载 2.配置插件间的依赖关系图插件按需动 态加载
34.
3.5 定制插件开发
35.
定制插件开发例子
Sourcearea 与 bangpai-sourcearea 调用execCommand editor.execCommand(“modeChange” ,”source”);
36.
3.6 设计模式应用
Do not repeat yourself ! scalability
37.
Template method
Flash +gen() +getUrl() : string +getDemision() : object music +getUrl() : string +getDemision() : object
38.
Visitor / filter
HtmlParser +parse(in html : string, in fragment : object) Fragment +onNode(in node : object) +onElement(in el : object) +onAttribute(in attr : object)
39.
Observer-listener
最常见 Editor -subject -selectionChangeHanlders : object +on(in selectionChangeHanlder : object) 1 +fire(in selectionChangeEvent : object) * -observer SelectionChangeHanlder +onSelectionChange(in selectionChangeEvent : object) Plugin +onSelectionChange(in selectionChangeEvent : object)
40.
Command
Editor +addCommand(in cmd : string, in func : object) +execCommand(in cmd : string) 复杂的操作用命令封装 editor.addCommand(“align”,alignCmdObj); editor.execCommand(“align”,”left”);
41.
4. 打包与部署
4.1 源码概况 4.2 使用工具 4.3 最终部署
42.
4.1 源码概况
结构
43.
4.2 使用工具
Ant 粘合剂
44.
4.3 部署
静态引入
45.
4.3 部署
动态引入(combo加载) ◦ Kissy-seed.js KISSY.use(“editor”,function(S) { S.Editor(“#e”).use(“font,image,music”); }); Cdn combo 两阶段 http://a.tbcdn.cn/??kissy-core.js,editor/editor-core.js http://a.tbcdn.cn/?? editor/plugins/font/plugin.js,editor/plugins/image/plugin.js
46.
5.总结
1. 再次回顾 2. 与其他编辑器的比较 3. 前景与展望
47.
回顾
48.
其他编辑器
站在巨人肩上 ◦ ckeditor , tinymce,google doc
49.
前景与展望
1. 更少代码完成80%的功能 2. 触摸事件支持,加强Mobile设备 3. Html5 代码生成,使用 video , audio . 生成 header , nav , section , 加强标签语义 .
50.
感谢
Kissy editor 1.0 :玉伯 视觉: 书安倾情奉献 产品经理:向秋 测试:小菊,南玲,周坤,黛霁
51.
特别感谢
52.
FAQ Email:yiminghe@gmail.com Blog:
http://yiminghe.javaeye.com