编写一个简单的自定义编辑器需要多快?
简单地说,我的意思是,有按钮:
- 粗体,
- 斜体,
- 编号列表项目
- 符号列表
- 缩进左
- 缩进右
- 拼写检查(显然由现成的js组件支持)
自定义我的意思是:有自定义图标 - 所以实际上只是自定义设计
没有框架,编写从头开始,轻量级,兼容主流浏览器
这是web应用程序的主要组件之一,所以它必须是超轻量级的,这就是为什么我不想要框架
by simple I mean, having buttons:
- bold,
- italic,
- numbered list
- bullet point list
- indent left
- indent right
- spell check (obviously supported by ready made js component)
by custom I mean: having custom icons - so really just custom design
no frameworks, written from scratch, lightweight, compatible with major browsers
this is one of the main components of the webapp, so it has to be super lightweight, that's why I don't want frameworks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
除非您针对一种浏览器,否则编辑器是跨浏览器工作的极其复杂的组件。 除非您想学习,否则没有理由自己做。
使用允许自定义的众多可用选项之一:
tinymce,
fckeditor,
wysihat,
其他
Unless you are targeting one browser, editors are immensely complicated components to get to work cross browser. There's no reason to do it yourself, unless you want to learn.
Use one of the many available that allow customization:
tinymce,
fckeditor,
wysihat,
others
编写一个跨平台工作的编辑器可能很困难,但是,您应该在编写时创建自己的框架,因为这是一个大型项目。
如果您只想要自定义图标,这取决于您制作它们需要多长时间,但是,获得一些基本功能并不难,如果您知道自己在做什么,可能需要不到 40 小时的工作时间。
在 Unix 中,编写自己的 shell 曾经是一种仪式,在 javascript 中可能是编写自己的编辑器。 :)
棘手的是,如果我
决定从该文本中删除标签,那么如何修复它就会变得棘手。
如果您只想使用 css,那么当您对 span 标记中的文本进行分组并修复 css 类时,问题就更大了,而用户仍在继续进行更改。
我目前正在处理这个问题,因为我想要一个在 XHTML2.0 中工作的编辑器,这不是一个小问题,比在桌面应用程序中困难得多。
我建议先让它在 Firefox 3 和 Safari 上工作,然后,一旦工作正常,返回并添加代码以使其在 IE8 上工作,如果你想要 IE7,因为微软正在将 IE8 作为一个现在进行重要更新。
Writing an editor that works cross-platform can be difficult, but, you should create your own framework as you do it, as it is a large project.
If you just want custom icons, that will depend on how long it takes you to make them, but, to get some basic functionality isn't that hard, probably less than 40 hrs of work if you know what you are doing.
In Unix writing your own shell used to be a rite of passage, in javascript it may be writing your own editor. :)
Where it gets tricky is if I have
and I decide to remove the tags from this text, then how to fix it will get tricky.
If you want to use only css then it gets to be more of a problem as you are grouping text from span tags, and fixing css classes, while the user is continuing to make changes.
I am dealing with this currently as I want an editor that works in XHTML2.0, and it is not a trivial issue, much harder than it is to do in a desktop application.
I would suggest getting it to work on Firefox 3 and Safari first, then, once it is working, go back and add in the code to get it to work on IE8, and if you want IE7, since MS is pushing IE8 out as a critical update now.
不。
去获取其他东西(Jason 提到的任何一个,或者例如 SO 本身使用的东西,WMD)。 交换它的图像。 结束。
说真的,你不想编写自己的编辑器,除非你在功能上有很好的理由,而不仅仅是它的外观。
Don't.
Go get something else (any of those Jason mentioned, or e.g. what SO itself uses, WMD). Swap out its images. The end.
Seriously you don't want to write your own editor unless you have a very good reason for it functionally, not just what it looks like.
通读 emacs 教程的第一章,你会发现没有什么比“简单”的编辑器更好的了。 但谷歌会给你很多简单的可定制编辑器。
Read through the first chapters of the emacs tutorial, and you will see that there is not anything like a "simple" editor. But google will give you lots of easy customizable editors.