积分不够,无法下载资源,请看这里! 本站各班级诚招班主任 ! 如何在本论坛上传大文件? 有好源码,想换点钱,来这里!
1/1页1 跳转到查看:2857
发新话题 回复该主题

html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

FreeTextBox 是一个基于 Internet Explorer 中 MSHTML 技术的 ASP.NET 服务器控件。这是一款优秀的自由软件(Free Software),我们可以轻松地将其嵌入到 Web Forms 中实现 HTML 内容的在线编辑,在新闻发布、博客写作、论坛社区等多种 Web 系统中都会有用途,FTB_1.6.3_zh_Source是源码文件夹。该版本可以在Asp.net2.0中使用

 附件: 您所在的用户组无法下载或查看附件
附件:您所在的用户组无法下载或查看附件
最后编辑aspx1 最后编辑于 2008-01-04 08:14:38
http://www.Aspx1.Com
请帮忙宣传Aspx1 , Aspx1是ASP.NET学习者的家园 , 适宜长期居住.

TOP

 

FreeTextBox 1.6.3 中文版使用说明及心得体会

1.直接使用的方法:
(1) 复制 bin 目录下的 FreeTextBox.dll 文件到你的 Web 应用程序目录中的 bin 目录或其上层的虚拟目录下的 bin 目录;
(2) 复制 HelperScripts 目录下的三个文件到你的 Web 应用程序目录中或其子目录中,注意使用时要指定 HelperFilePath 属性;
(3) 复制 images 目录下的 ftb 目录到你的 Web 站点根目录下的 images 目录中。
默认的目录结构如下:
    + Web 根目录
      + bin 目录
          - FreeTextBox.dll
      + images 目录
          + ftb 目录
      + 你的应用程序(虚拟目录)
          + bin 目录
            - FreeTextBox.dll
          + images 目录(这个是你的“图片库”目录,上传的图片都在此)
          - ftb.colorpicker.aspx
        - ftb.imagegallery.aspx
          - ftb.inserttable.aspx
          - test.aspx (测试)
  (注:+ 表示目录,- 表示文件;上面 FreeTextBox.dll 只需要复制一个就行了;)
2.或者你可以更改源代码来简化某些设置。
3.官方网站:http://www.freetextbox.com
中文版: http://www.aspx1.com/
上面网页中都有一些示例程序可以参考。
4.使用本软件请遵照 License Agreement 协议,使用中文版时请不要去掉译者信息。
由于这几天都在钻研BBS怎么贴图片的功能,所以不经意间就发现其实freetextbox这个东东真的很好用,以前排版比如换行空格我还这样做:


CODE:
string content1=this.TaContent.Value.Replace("\r\n","<br><br>");
string content=content1.Replace(" ","nbsp;");


现在这个freetextbox就厉害了,你想怎么输入就怎么输入,比如你想贴图片,文字怎么个排版都可以,自己不用去控制它了,直接把它读入数据库,然后直接用数据控件来显示就可以了,这里我做了小小的例子供自己和大家来参考一下。

先讲讲这个freetextbox怎么个用法吧,把freetextbox下载下来后,就可以把它添加到工具箱里去了,这里当然添加的是freetextbox.dll,然后在设计页面usefreetextbox.aspx中,直接拽入这个控件就可以,不过还要把freetextbox的一个文件夹添加进来,这个文件夹里面又有这么两个文件夹:HelperScripts,IMAGES,HelperScript中里面有这么六个文件folder.big.gif、folder.small.gif、folder.up.gif、ftb.colorpicker.aspx、ftb.imagegallery.aspx、ftb.inserttable.aspx,前面三个就是三张图片,后面三个里面是C#、JS函数,分别是取色、上传图片、插入表格的作用,好,现在看看IMAGES里面放的是什么,其实里面分别放的是office2000、2003、xp这三个版本的一些图片,freetextbox整个的外观就是由它们来构成的了。把这个freetextbox文件夹和我们新建的usefreetextbox.aspx放在同一级目录中。 
现在基本上已经设置好了,不过还有些细节问题,首先,我们要设置freetextbox的各个属性,我把它列出来:


CODE:
<FTB:FreeTextBox id="FreeTextBox1" runat="server"          ToolbarType="Custom" ImageGalleryPath="images" ToolbarBackGroundImage="True" Butt Butt tartMode="DesignMode" AllowHtmlMode="False" HelperFilesPath="FreeTextBox/HelperScripts///"></FTB:FreeTextBox>


这里大家要特别注意ButtonPath和HelperFilesPath的设置,是不是现在就可以使用这个freetextbox了呢?还没有一个重要的细节:如果我们就这样使用的话,会报错了,如下:
从客户端(FreeTextBox1="<div align=center><FON...")中检测到有潜在危险的 Request.Form 值。
说明: 请求验证过程检测到有潜在危险的客户端输入值,对请求的处理已经中止。该值可能指示危及应用程序安全的尝试,如跨站点的脚本攻击。通过在 Page 指令或配置节中设置 validateRequest=false 可以禁用请求验证。但是,在这种情况下,强烈建议应用程序显式检查所有输入。
原因是验证没通过,它都已经提示了,所以我们在web.Config中<system.web>下添加一个配置 <pages validateRequest="false"/> 或在本页面的html源窗口的页面配置中添加validateRequest="false,即<%@ Page validateRequest="false"%>
好,现在OK了,发现这个东东的使用并不难吧,又不需要写什么很难的代码.


----心得-------------------------------------------------------


在使用FreeTextBox控件进行文本编辑后,进行保存时需要取编辑内容对应的HTML文本内容。取编辑内容使用my_freetextbox.ViewStateText属性会比使用my_freetextbox.Text属性,在后续的字符串内容处理上会方便一些。

    在所取出的字符串中,系统自动加上了“\r\n”的回车换行字符串标示,在存储内容到数据库之前最好将这些“\r\n”字符串用空串“”替换掉(如:my_str=my_str.Replace("\r\n","")),否则在将来调用时会导致不正常显示。

    在所取出的字符串中,系统还把编辑文本中的双引号“用转义字符\进行了处理,如原字符串为“wangshixin said "51aspx!"”,所取得的字符串实际为“wangshixin said \"51aspx!\"”,因此需要将所获得的字符串中的全部“\"”用特定的字符串替换掉。在将来提取显示时,再将特定字符串替换为
“\"”(如:my_str=my_str.Replace("\"","wangshixin750920"))。
FreeTextBox1.Text 取得内容(带html标签的)
FreeTextBox1.HtmlStrippedText        也是取得内容(不带Html标签的)


关于WORD中过来的内容,出错解决

      把从word复制的文本粘贴到freetextbox里,提交到数据库的时候会提示有危险代码,也就是单引号,这是为什么?

      在Dottext里的freetextbox,同一篇word文档,提交时就没有问题。
我现在找到的原因是dottext里的freetextbox在提交的时候会把危险代码重新编码,而在我的项目里的freetextbox就不会。
      查看包含freetextbox控件的页面源文件,又发现license不同。
      解决方法:把页面中的validateRequest指令设成false即可,或者直接改web.config:<pages validateRequest="false" buffer="true"/>
最后编辑aspx1 最后编辑于 2008-01-03 17:12:58
http://www.Aspx1.Com
请帮忙宣传Aspx1 , Aspx1是ASP.NET学习者的家园 , 适宜长期居住.

TOP

 

FreeTextBox的实现机制

刚开始试用FTB2.0的时候,感觉FTB真的很神,居然可以在网页状态实现编辑过程的What you see is what you get。看完FTB的文档(其实也不是很多的东西,估计就是用个NDOC或者什么类似的工具生成的SDK文档)又仔细试做了几个程序,觉得FTB的实现思路不复杂,但十分巧妙。它通过FTB这个中间部件将客户端(浏览器)的程序(javascript代码)和后台程序(C#写的aspx等ASP.NET代码)紧密结合,从而实现了这种所见即所得的效果。

FTB的结构主要有三个命名空间组成:
FreeTextBoxControls,FreeTextBoxControls.Design和FreeTextBoxControls.Support。

      使用得最多的是FreeTextBoxControls,基本上用到的界面部件都来自于这里,例如ToolBar上每个功能Button可以在这里找到映射,而每个Button又对应着javascrip中的一个函数功能。

例如:下划线这个功能,有个Underline的类(继承于ToolbarButton)实现,而这个类实际调用客户端的一段javascript代码FTB_Underline(在FreeTextBox-ToolbarItemsSrcipt.js中)。


CODE:

function FTB_Underline(ftbName) {
    FTB_Format(ftbName,'underline');


如果再深究下去,仔细跟踪下这段js的代码又可以它调用FTB_Format这段代码(在FreeTextBox-MainScript.js中)。

CODE:


function FTB_Format(ftbName,commandName) {
    editor = FTB_GetIFrame(ftbName);
    if (FTB_IsHtmlMode(ftbName)) return;
    editor.focus();
    editor.document.execCommand(commandName,'',null);
}


它正是通过document的execCommand方法来实现效果的,查MSDN文挡可以发现它对应执行的正是Underline的命令参数。
execCommand可以执行的命令参数:


CODE:

Command Identifiers
2D-Position
Allows absolutely positioned elements to be moved by dragging.
AbsolutePosition
Sets an element's position property to "absolute."
BackColor
Sets or retrieves the background color of the current selection.
BlockDirLTR
Not currently supported.
BlockDirRTL
Not currently supported.
Bold
Toggles the current selection between bold and nonbold.
BrowseMode
Not currently supported.
ClearAuthenticationCache
Clears all authentication credentials from the cache. Applies only to execCommand.
Copy
Copies the current selection to the clipboard.
CreateBookmark
Creates a bookmark anchor or retrieves the name of a bookmark anchor for the current selection or insertion point.
CreateLink
Inserts a hyperlink on the current selection, or displays a dialog box enabling the user to specify a URL to insert as a hyperlink on the current selection.
Cut
Copies the current selection to the clipboard and then deletes it.
Delete
Deletes the current selection.
DirLTR
Not currently supported.
DirRTL
Not currently supported.
EditMode
Not currently supported.
FontName
Sets or retrieves the font for the current selection.
FontSize
Sets or retrieves the font size for the current selection.
ForeColor
Sets or retrieves the foreground (text) color of the current selection.
FormatBlock
Sets the current block format tag.
Indent
Increases the indent of the selected text by one indentation increment.
InlineDirLTR
Not currently supported.
InlineDirRTL
Not currently supported.
InsertButton
Overwrites a button control on the text selection.
InsertFieldset
Overwrites a box on the text selection.
InsertHorizontalRule
Overwrites a horizontal line on the text selection.
InsertIFrame
Overwrites an inline frame on the text selection.
InsertImage
Overwrites an image on the text selection.
InsertInputButton
Overwrites a button control on the text selection.
InsertInputCheckbox
Overwrites a check box control on the text selection.
InsertInputFileUpload
Overwrites a file upload control on the text selection.
InsertInputHidden
Inserts a hidden control on the text selection.
InsertInputImage
Overwrites an image control on the text selection.
InsertInputPassword
Overwrites a password control on the text selection.
InsertInputRadio
Overwrites a radio control on the text selection.
InsertInputReset
Overwrites a reset control on the text selection.
InsertInputSubmit
Overwrites a submit control on the text selection.
InsertInputText
Overwrites a text control on the text selection.
InsertMarquee
Overwrites an empty marquee on the text selection.
InsertOrderedList
Toggles the text selection between an ordered list and a normal format block.
InsertParagraph
Overwrites a line break on the text selection.
InsertSelectDropdown
Overwrites a drop-down selection control on the text selection.
InsertSelectListbox
Overwrites a list box selection control on the text selection.
InsertTextArea
Overwrites a multiline text input control on the text selection.
InsertUnorderedList
Toggles the text selection between an ordered list and a normal format block.
Italic
Toggles the current selection between italic and nonitalic.
JustifyCenter
Centers the format block in which the current selection is located.
JustifyFull
Not currently supported.
JustifyLeft
Left-justifies the format block in which the current selection is located.
JustifyNone
Not currently supported.
JustifyRight
Right-justifies the format block in which the current selection is located.
LiveResize
Causes the MSHTML Editor to update an element's appearance continuously during a resizing or moving operation, rather than updating only at the completion of the move or resize.
MultipleSelection
Allows for the selection of more than one site selectable element at a time when the user holds down the SHIFT or CTRL keys.
Open
Not currently supported.
Outdent
Decreases by one increment the indentation of the format block in which the current selection is located.
OverWrite
Toggles the text-entry mode between insert and overwrite.
Paste
Overwrites the contents of the clipboard on the current selection.
PlayImage
Not currently supported.
Print
Opens the print dialog box so the user can print the current page.
Redo
Not currently supported.
Refresh
Refreshes the current document.
RemoveFormat
Removes the formatting tags from the current selection.
RemoveParaFormat
Not currently supported.
SaveAs
Saves the current Web page to a file.
SelectAll
Selects the entire document.
SizeToControl
Not currently supported.
SizeToControlHeight
Not currently supported.
SizeToControlWidth
Not currently supported.
Stop
Not currently supported.
StopImage
Not currently supported.
StrikeThrough
Not currently supported.
Subscript
Not currently supported.
Superscript
Not currently supported.
UnBookmark
Removes any bookmark from the current selection.
Underline
Toggles the current selection between underlined and not underlined.
Undo
Not currently supported.
Unlink
Removes any hyperlink from the current selection.
Unselect
Clears the current selection.


基本上每个命令参数都可以在FTB的FreeTextBoxControls中找到对应的实现类,如果觉得有些没有实现,自己参照已经实现的功能来增加也十分简单和方便。

        FTB还提供了公开的接口,例如继承于ToolbarButton可以实现对应的工具按钮,继承于ToolbarDropDownList则实现下拉式选择(如选择字体那种),对应javascript的方法只须传递对应的方法名字符串给类即可,自己写的javascript可以放在js中,也可以放在ScriptBlock的字符串参数里面,前者前端查看源码看不到,后者则将整个函数源码传回,一切都十分公开和方便。

        这种思路是否也和ASP.NET的思路类似?
        由于javascript可以被多种浏览器支持(估计有些小兼容问题,可以通过javascript来兼容),因此FTB可以在多种环境下正常工作。现在用的这个blog系统(.Text)也用了FTB,但版本是1.6.3.26037(汉化版),有兴趣可以在发表文章的地方查看网页源代码看看,就会发现好多的FTB_XXX的javascript函数。这些在2.0已经全部集中放到FreeTextBox-ToolbarItemsSrcipt.js和FreeTextBox-MainScript.js中了,应该说这样比较归一些。

        如果担心FTB的免费协议对商业用途有些影响的话,自己根据这个思路来开发一个适合自己产品用的所见即所得编辑器控件应该也不是难事。
http://www.Aspx1.Com
请帮忙宣传Aspx1 , Aspx1是ASP.NET学习者的家园 , 适宜长期居住.

TOP

 

法通援助电话回复: html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

[quote] 原帖由 [b]aspx1          [/b] 于 2008-1-3 179:43 发表
1.直接使用的方法:
(1) 复制 bin 目录下的 FreeTextBox.dll 文件到你的 Web 应用程序目录中的 bin 目录或其上层的虚拟目录下的 bin 目录;
(2) 复制 HelperScripts 目录下的三个文件到你的 Web 应用程序目录中或其子目录中,注意使用时要指定 HelperFilePath 属性;
(3) 复制 images 目录下的 ftb 目录到你的 W [/quote]

TOP

 

回复: html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

good thanks

TOP

 

回复:html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

好,谢谢啦

TOP

 

回复:html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

不错!!!

TOP

 

回复:html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

不错...不过我用的时候怎么插入图片时就出来个空白页面....

TOP

 

回复:html编辑器FTB---FreeTextBox 1.6.3 中文版及源码

真的是很不错的东东

TOP

 
1/1页1 跳转到
发表新主题 回复该主题