SPAW editor. Net edition V.2 misuse

Source: Internet
Author: User

There are many HTML editors, such as FCKeditor, which have their own advantages and disadvantages. It is hard to compare them when they are actually used. Some time ago, I saw someone recommending SPAW editor, so I downloaded a trial at SourceForge. This editor is quite distinctive, such as floating and supporting multiple editing areas and better file managers (uploading and managing files. However, the reason is ". net edition "was launched only after the editor was first used by PHP developers. net edition ,. NET developers seldom involve this editor, and Google rarely finds this editor in. NET environment, even worse, the help of the editor,CodeAnnotations and other documents are very incomplete and difficult to use. It is not easy for a developer to open the editor to the source. Maybe his main focus is still on the PHP side. No way, I can only use it as a. Net developer.

 

 

1. download the latest version of SPAW editor. Net Edition Release from sourceforge.net: SPAW Editor-web based WYSIWYG editor;

 

2. Decompress spaw-net-2701-gpl.zip, copy the spaw2 directory to the root directory of the Visual Studio 2005 website, and copy the two DLL files under the bin directory to the bin directory of the website (you can also add references directly ), of course, to drag the control from the toolbox to the page, you can set solmetra. add spaw2.dll to the toolbox. Note: The spaw2 directory must be located in the root directory of the website. This is written to the source files of the two DLL files. If you change the directory location, you may not be able to find the editor. config File (two. the config file is located in the config directory under the spaw2 directory. The demo directory under the spaw2 directory contains two simple examples for reference. The docs directory contains two simple documents about the use of spaw2, which is basically unnecessary;

 

3. SPAW editor itself supports multiple languages, and the simplified Chinese language file of the editor itself is a zh-gb2312.lang (located in the spaw2/plugins/CORE/lib/lang directory ), however, when using a simplified Chinese language file, you may encounter the following problems: 1) Where to specify the language file, you should be able to solve the problem through the configuration file, however, there are few instructions on configuration options. 2) This simplified Chinese language file is not complete, and the language specified on the Editor interface is not complete yet, what's more, the independent File Manager. As for the first problem, we can directly name the Simplified Chinese language file with the name en. lang to solve (of course, the original en. lang file deletion or rename). English is the default language of SPAW editor, so we don't have to worry about how to configure the language. Of course, if your website is an international site that needs to change the language settings, do not use it like this ...... There is no way to solve the second problem. I tried to fill in the missing language settings related to the editor itself (download) and recreate a language file (download) for the File Manager) (The same name is en. lang, put it in the directory spaw2/plugins/spawfm/lib/lang). At the same time, there are some places in spaw2.config that need to be compiled (download );

 

4. pop-up windows including File Manager are generally called through the editor toolbar button. We may find that the size of these pop-up windows is obviously incorrect. check some SPAW values. JS files, we can find that the size of these pop-up windows is managed in a unified manner, and we can make some corrections to them, so that the size of the pop-up window exactly matches the space occupied by the window content:

Open the spaw2/dialogs/dialog. aspx file in Visual Studio 2005 and add the following functions between the <SCRIPT> start and end labels:

 Function Getquerystring ( Name )    {           VaR Reg = New   Regexp (" (^ | \\? | &) "+ Name +" = ([^ &] *) (\ S | & | $) "," I "); If (Reg. Test ( Location . Href )) Return   Unescape ( Regexp . $2. Replace (/\ +/g ,"   ")); Return "  ";}

This function is similar to the server-side request. querystring set. You can obtain the parameter values passed through the URL by using the parameter name;

Modify the resizedialogtocontent method:

Spawdialog. resizedialogtocontent = Function (){ If ( Window . Sizetocontent ){ // Gecko                  Window . Sizetocontent ();} Else { // Resize window so there are no scrollbars visible                 // If (! Spaweditor. _ dialog_chrome_width)                  //{                      // Do these calculations only once for each SPAW instance on a page                      // Window. resizeTo (600,500 );                      // Spaweditor. _ dialog_chrome_width = 600-document. Body. clientwidth;                      // Spaweditor. _ dialog_chrome_height = 500-document. Body. clientheight;                  //}                  // Window. resizeTo (50, 40 );                  // Window. resizeTo (document. Body. scrollwidth + spaweditor. _ dialog_chrome_width,
// Document. Body. scrollheight + spaweditor. _ dialog_chrome_height ); Switch (Getquerystring (" Dialog ")){ Case 'Hyperlink ': Window . ResizeTo (395,308 ); Break ; Case 'Spawfs ': Window . ResizeTo (780,465 ); Break ; Case 'Image _ prop ':Window . ResizeTo (600,360 ); Break ; Case 'Flash _ prop ': Window . ResizeTo (385,200 ); Break ; Case 'Table _ prop ': Window . ResizeTo (400,310 ); Break ; Case 'Colorpicker ': Window . ResizeTo (410,455 ); Break ;}}}

The preceding switch branch promptly obtains the dialog parameter passed through the URL Based on the added getquerystring function. This parameter value indicates the type of the browser window to be opened, for example, hyperlink is the browser window used to insert a hyperlink. By judging different window types, you can re-adjust the size of the Opened Window to match the content size;

 

5. We can see a configuration piece about folder Management in spaw2.config:

 <! -- Directories -->  <  Setting  Name = "Pg_spawfm_directories"   Transfermode = "Secure"  >          <  Directory   Path = "% Spaw_dir % uploads/flash /"   Caption = "Flash"  >          <  Allowedfiletypes  >         <  Filetype   Value = "Flash"   />          </  Allowedfiletypes  >          </  Directory  >          <  Directory   Path = "% Spaw_dir % uploads/images /"   Caption ="Up. Images"  >          <  Allowedfiletypes  >          <  Filetype   Value = "Flash"   />          </  Allowedfiletypes  >         </  Directory  >          < Directory   Path = "~ /Spaw2/dialogs/img /"   Caption = "Images"   Defadirectory directory = "True"  >          <  Allowedfiletypes  >          <  Filetype   Value = "Images"   />         </  Allowedfiletypes  >         </  Directory  >          <  Directory   Path = "% Spaw_dir % uploads/files /"   Caption = "Files"  >          <  Allowedfiletypes   Any ="True"   />          <  Settings   Allowupload = "True"   />          </  Directory  >  </  Setting  > 

It can be seen that the configuration file can be used to manage the upload Folder Tasks: what types of files are allowed to be uploaded, whether to allow uploading, and so on. However, from this example, we can only find such clues, in many cases, we cannot see how the configuration is implemented. Supported file types include Flash, images ( < Allowedfiletypes > < Filetype Value = "Images" /> </ Allowedfiletypes > In the spaw2/plugins/spawfm/config/spawfm file. find the file in the config file. Of course, you can extend the file to limit the specific upload type. If you allow all types of files, you can use < Allowedfiletypes Any = "True" /> . The management of uploaded folders is obviously not limited to this. For example, whether a folder can be added, deleted, or renamed to a subfolder can also be set through the configuration file, unfortunately, due to incomplete documents, we can only. perform related settings in the CS file. See the following code:

         Protected   Void Page_load ( Object Sender, eventargs e ){ // Spawmain is the name of the SPAW editor control on the page. Solmetra. spaw2.spawfm. spawfmconfiguration SFMC = solmetra. spaw2.spawfm. spawfmconfiguration. getfilemanagerconfiguration ( This . Spawmain ); If (SFMC. directories. indexof (solmetra. spaw2.configuration. spawdirectory +" Uploads/images/ ")>-1) {solmetra. spaw2.spawfm. Directory dirimages = SFMC. directories [SFMC. directories. indexof (solmetra. spaw2.configuration. spawdirectory +" Uploads/images/ ")]; Dirimages. settings. allowcreatesubdirectories = True ; Dirimages. settings. allowmodifysubdirectories = True ; Dirimages. settings. Recursive = True ; Dirimages. settings. allowmodify = True ; Dirimages. settings. allowupload = True ; Solmetra. spaw2.spawfm. Directory dirflash = SFMC. directories [SFMC. directories. indexof (solmetra. spaw2.configuration. spawdirectory +" Uploads/flash/ ")]; Dirflash. settings. allowmodifysubdirectories = True ; Dirflash. settings. allowcreatesubdirectories = True ; Dirflash. settings. Recursive = True ; Dirflash. settings. allowmodify = True ; Dirflash. settings. allowupload = True ; Solmetra. spaw2.spawfm. Directory dirother = SFMC. directories [SFMC. directories. indexof (solmetra. spaw2.configuration. spawdirectory +" Uploads/other/ ")]; Dirother. settings. allowmodifysubdirectories = True ; Dirother. settings. allowcreatesubdirectories = True ; Dirother. settings. Recursive = True ; Dirother. settings. allowmodify = True ; Dirother. settings. allowupload = True ; SFMC. directories. clear (); SFMC. directories. add (dirimages); SFMC. directories. add (dirflash); SFMC. directories. add (dirother); SFMC. apply ();}}

The code comments are incomplete. We can only understand the attributes and methods of the control literally, but basically we can effectively manage the upload directories and files, note that the folders in the above C # code must be in spaw2.config <! -- Directories --> partially defined;

 

6. In the server code, we can use the text property of the SPAW editor control to obtain the HTML being edited in the control.Source codeSegment; sometimes, we want to complete this operation in the browser-side JavaScript code. At this time, we can useSpawmain_ Obj. getpagehtml (Spawmain_ Page ).SpawmainThe name attribute value set for the server control SPAW editor.

 

Now, at least this control can be used together. Despite some usage, we should expect SPAW editor to provide a complete document ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.