使用Javascript,HTML创建文本编辑器 [英] Creating a text Editor using Javascript, HTML

查看:122
本文介绍了使用Javascript,HTML创建文本编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AoA,

我使用javascript和html创建了一个简单的文本编辑器,它与codeproject的文本编辑器相同,后者显示预览和textarea,

是否有可能创建一个文本编辑器来更改textarea中的文本,即如果我写'某事',它会在文本编辑中自动加粗文本,还是我还能做其他任何事情?



简而言之,我想制作类似文档或文字处理器的东西!



是否有可能?



任何帮助?

AoA,
I have made a simple text editor using javascript and html, it is same as the text editor of codeproject, which shows preview and a textarea,
Is it possible to make a text editor which changes the text in the textarea i.e if I write 'something' it bold the text automatically within the texteditor or is there any other thing I can do?

In short, i want to make something like a document or word processor!

Is it possible or not?

Any help?

推荐答案

对于其他人,谁想要解决这个问题



For others, who want the solution to this problem

Quote:



< html>

< head>

< script type =text / javascript>

功能设计(){

文件.designMode = arguments [0];

}

< / script>

< / head>

< body> ;

< button onclick =design('on');>启用设计模式< / button>

< button onclick =design('off ');>禁用设计模式< /按钮>

我是标题...编辑我



我是一段...编辑我


<html>
<head>
<script type="text/javascript">
function design(){
document.designMode = arguments[0];
}
</script>
</head>
<body>
<button onclick="design('on');">Enable Design Mode</button>
<button onclick="design('off');">Disable Design Mode</button>

I am a heading... edit me


I am a paragraph... edit me



  • 列表项
  • 列表项
  • 列表项目





PS:已复制&粘贴



使用document.designMode或element.designMode来更改段落或正文的文本。

如果您希望用户更改textarea中的文本,或者您可以使用iframe标签和designMode Enabled



P.S: Copied & Paste

use the document.designMode or element.designMode to change the text of paragraph or body.
If you want user to change the text inside the textarea, alternatively you can use iframe tag with designMode Enabled


如果您了解现有编辑器的工作原理,您可以很好地了解如何操作。试着看看像TinyMCE这样的优秀产品,例如:

http://en.wikipedia。 org / wiki / TinyMCE [ ^ ],

http://www.tinymce.com/ [ ^ ]。



在产品的标题页上,你可以尝试一下马上出来。



-SA
You can get a good idea on how to do it if you learn how one of existing editors work. Try to look at such a good one as TinyMCE, for example:
http://en.wikipedia.org/wiki/TinyMCE[^],
http://www.tinymce.com/[^].

On the title page of the product you can try it out immediately.

—SA


这篇关于使用Javascript,HTML创建文本编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆