htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
HTML MS Word Cleaner


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


ajones
Novice

Nov 10, 2003, 8:25 AM

Post #1 of 16 (15960 views)
Shortcut
HTML MS Word Cleaner Can't Post

Ok...I have posted questions here before, and have always had great help from you all, especiall Luis. However, I have screwed my editor up and need a new one with the following attributes:

1. Disabled right click
2. Automatically clean MS Word HTML on paste
3. Ability to disable font sizes/styles
4. Includes the paste icon on the tool bar

If someone has an editor that does these things, I would GREATLY appreciate it!

THanks.


Luis
Veteran

Nov 10, 2003, 11:20 AM

Post #2 of 16 (15944 views)
Shortcut
Re: [ajones] HTML MS Word Cleaner [In reply to] Can't Post

Hi ajones:

I think I still have the last editor I customized for you. I'm not sure. If I do have it, I'll send it to you tonight, as soon as I get home.

Greetings


Don't give up!!
http://webstationone.com/test/htmlarea


ajones
Novice

Nov 10, 2003, 1:08 PM

Post #3 of 16 (15940 views)
Shortcut
Re: [Luis] HTML MS Word Cleaner [In reply to] Can't Post

Luis,

Thanks. For some reason, the paste button never showed up on the toolbar (even though I had the icon in the proper directory). Many thanks for whatever you can do!


Luis
Veteran

Nov 10, 2003, 8:58 PM

Post #4 of 16 (15924 views)
Shortcut
Re: [ajones] HTML MS Word Cleaner [In reply to] Can't Post

Hi ajones:

This is the editor I have. I hope it's the good one.

It's strange your paste icon doesn't whow up if it's in the correct directory. I attach it here again in case it got corrupted. Make sure to upload it in binary.

Greetings


Don't give up!!
http://webstationone.com/test/htmlarea
Attachments: editor_ajones.js (55.4 KB)
  ed_paste.gif (0.90 KB)


ajones
Novice

Nov 11, 2003, 8:17 AM

Post #5 of 16 (15908 views)
Shortcut
Re: [ajones] HTML MS Word Cleaner [In reply to] Can't Post

Luis,

Ok....since this code is fine, I figure it must be something wrong with my code on the text editor page itself. Perhaps I'm missing a line of javascript below. Any ideas on why the paste icon isn't showing up?

<script language="javascript1.2">
var config = new Object(); // create new config object

config.width = "80%";
config.height = "250px";
config.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
config.debug = 0;

// NOTE: You can remove any of these blocks and use the default config!

config.toolbar = [
// ['fontname'],
// ['fontsize'],
// ['fontstyle'],
['linebreak'],
['bold','italic','underline','separator'],
['strikethrough','subscript','superscript','separator'],
['justifyleft','justifycenter','justifyright','separator'],
['OrderedList','UnOrderedList','Outdent','Indent','separator'],
['forecolor','backcolor','separator'],
['HorizontalRule','Createlink','InsertImage','htmlmode','separator'],
['about','help','popupeditor'],
];

config.fontnames = {
"Arial": "arial, helvetica, sans-serif",
"Courier New": "courier new, courier, mono",
"Georgia": "Georgia, Times New Roman, Times, Serif",
"Tahoma": "Tahoma, Arial, Helvetica, sans-serif",
"Times New Roman": "times new roman, times, serif",
"Verdana": "Verdana, Arial, Helvetica, sans-serif",
"impact": "impact",
"WingDings": "WingDings"
};
config.fontsizes = {
"1 (8 pt)": "1",
"2 (10 pt)": "2",
"3 (12 pt)": "3",
"4 (14 pt)": "4",
"5 (18 pt)": "5",
"6 (24 pt)": "6",
"7 (36 pt)": "7"
};

//config.stylesheet = "http://www.domain.com/sample.css";

config.fontstyles = [ // make sure classNames are defined in the page the content is being display as well in or they won't work!
{ name: "headline", className: "headline", classStyle: "font-family: arial black, arial; font-size: 28px; letter-spacing: -2px;" },
{ name: "arial red", className: "headline2", classStyle: "font-family: arial black, arial; font-size: 12px; letter-spacing: -2px; color:red" },
{ name: "verdana blue", className: "headline4", classStyle: "font-family: verdana; font-size: 18px; letter-spacing: -2px; color:blue" }

// leave classStyle blank if it's defined in config.stylesheet (above), like this:
// { name: "verdana blue", className: "headline4", classStyle: "" }
];

editor_generate('txtMsg',config);


</script>


Luis
Veteran

Nov 11, 2003, 9:21 PM

Post #6 of 16 (15896 views)
Shortcut
Re: [ajones] HTML MS Word Cleaner [In reply to] Can't Post

Hi ajones:

It's not showing up because you are not declaring it:

config.toolbar = [
// ['fontname'],
// ['fontsize'],
// ['fontstyle'],
['linebreak'],
['paste','bold','italic','underline','separator'],
['strikethrough','subscript','superscript','separator'],
['justifyleft','justifycenter','justifyright','separator'],
['OrderedList','UnOrderedList','Outdent','Indent','separator'],
['forecolor','backcolor','separator'],
['HorizontalRule','Createlink','InsertImage','htmlmode','separator'],
['about','help','popupeditor'],
];


Greetings.


Don't give up!!
http://webstationone.com/test/htmlarea


ajones
Novice

Nov 13, 2003, 8:07 AM

Post #7 of 16 (15855 views)
Shortcut
Re: [Luis] HTML MS Word Cleaner [In reply to] Can't Post

Bingo! That was it. I knew it was something simple.

One last thing. When I paste a word docuemnt using CTL+V, it cleans the html, but not when I click the Paste icon. Is there something special needed for that to work?

Thanks again for all your wonderful and patient help! This is going to be great!


Luis
Veteran

Nov 13, 2003, 11:46 AM

Post #8 of 16 (15834 views)
Shortcut
Re: [Luis] HTML MS Word Cleaner [In reply to] Can't Post

Hi ajones:

I just realized that the editor I sent you is an outdated version. I'll send you a newer one later tonight.

Greetings.


Don't give up!!
http://webstationone.com/test/htmlarea


ajones
Novice

Nov 18, 2003, 10:52 AM

Post #9 of 16 (15730 views)
Shortcut
Re: [Luis] HTML MS Word Cleaner [In reply to] Can't Post

Thanks, Luis. One more thing and I will stop bothering you!

How can I make the paste button clean the MS Word code just the way it cleans code when I paste using CTL+V?

Thanks again.


Luis
Veteran

Nov 20, 2003, 10:09 PM

Post #10 of 16 (15652 views)
Shortcut
Re: [ajones] HTML MS Word Cleaner [In reply to] Can't Post

Hi ajones:

I attach a newer version of the editor with improved functionality and added the function you were missing (clean-up when clicking the icon)

Greetings


Don't give up!!
http://webstationone.com/test/htmlarea
Attachments: editor_ajones.js (62.7 KB)


seng_uk
New User

Jun 5, 2004, 7:00 AM

Post #11 of 16 (14375 views)
Shortcut
Re: [Luis] HTML MS Word Cleaner [In reply to] Can't Post

Hi All,

I just thought I would take a moment to say how pleased I was to find this web based editor.

I have been having problems developing for my Intranet when dealing with Word documents, and I hope that now I have found this editor I will have reduced those challenges greatly.

I was wondering however if it would be a simple enough change to modify the <v:imagedata> tag instead of remove it. If it could be modified to an <img> tag then I am certain that the 'src' attribute could be detected (it's a temp local file) and then automatically uploaded through the upload mechanism.

This really would be of great benefit as many of the documents I deal with contain illustrations, photos, and sketches. The only image types I allows however are gif,jpg, and png.

Thank you in advance if you release an update.

Regards

^SenG^


kwillems
User

Jun 5, 2004, 7:55 AM

Post #12 of 16 (14373 views)
Shortcut
Re: [seng_uk] HTML MS Word Cleaner [In reply to] Can't Post

I've made such a modification using PHP. Is that what you need?


seng_uk
New User

Jun 5, 2004, 3:18 PM

Post #13 of 16 (14363 views)
Shortcut
Re: [kwillems] HTML MS Word Cleaner [In reply to] Can't Post

A PHP version for functionality would be fantastic as that is what the rest of my 'content manager' is written in.

Thank you for you prompt reply, I look forward to trying your code.

Regards



^SenG^


kwillems
User

Jun 5, 2004, 3:50 PM

Post #14 of 16 (14359 views)
Shortcut
Re: [seng_uk] HTML MS Word Cleaner [In reply to] Can't Post

I've written the basic functionality a few weeks ago, which will be implemented in a CMS i'm writing. The script is completely commented in Dutch, so i first have to make some translations.

I'm still working in a testing environment and not on a real server, so I haven't had a proper opportunity to test the uploading part of the script, since I want to use ftp-functionality instead of uploading a file/image true a form.

I'll try to post the script in a few days, ok?


seng_uk
New User

Jun 5, 2004, 4:12 PM

Post #15 of 16 (14358 views)
Shortcut
Re: [kwillems] HTML MS Word Cleaner [In reply to] Can't Post

Sounds great -- Look forward to seeing it.

Thank you once again.


kwillems
User

Jun 6, 2004, 9:42 AM

Post #16 of 16 (14339 views)
Shortcut
Re: [seng_uk] HTML MS Word Cleaner [In reply to] Can't Post

I still wasn't able to test the ftp-routine, but i believe it will work anyway. In fact, ftp-ing the image should not be the biggest problem, so i decided to post the script anyway.
For development purposes i used copy ($original, $copy) on my local machine and furthermore i was able to 'ftp' files from my local machine to servers (which didn't support PHP).

The script only works with jpg-images. It should no be too difficult to let it work with BMP- and PNG-images.

Also, this script won't resize or resampled the uploaded image. In my CMS i use other scripts to do that.

Sice PHP works server sided you have to include the script after you've submitted your text to the Mysql-database.

I hope this script can be usefull to anybody.
I'm not a professional programmer and only working with PHP for a few months, so any improvements are welcome. Since the script works server sided i consider it a sub-optimal solution. Perhaps someone can rewrite it in Javascript.

Regards,
Koen Willems


Code
   

<?php
// Written by Koen Willems, The Netherlands, 2004
// This script will check inserted Word-documents for jpg-images, alters the source with the desired code
// and uploads the images to your server. At last it will update the value of your textarea in your Mysql-database.
// Take care that $id is the id-number of the record you want to change; for example, you can use $id=mysql_insert_id() before including this script
// this script will rename the images, depending on the id-number of the record
// for example: when we are working with a record with id 735, the images wil renamed to 735_3.jpg, 735_4.jpg,and so on
// it's the way i incorporate images in my CMS, but of course you can alter it.
error_reporting(E_ALL);
$path = 'src="http://www.website.com/images/'; // the source should become something like this
$path_copy ='../images/'; // relative path to the folder where we want to put the images
$query = "SELECT id,textarea FROM table WHERE id='".$id."'";
$result = mysql_query ($query,$tabel_db) or die (mysql_error());
$table = mysql_fetch_assoc($result);
$textarea = $table['textarea'];

$preg = '/
src= # src=
"?\'? # quotes optional
([^"\'>]*\.jpg) # not > and no quotes, and then .jpg
[^>]* # not >
> # >
/siUx';

preg_match_all ($preg, $textarea, $matches);

for ($i=0; $i < count($matches[0]); $i++)
{ $src = explode ("/", $matches[0][$i]); // $matches[0][$i] is now like src="file:///C:/DOCUME~1/../clip_image001.jpg">
$src = $src[0]; // everything until the first /

if ($src != 'src="http:') // check if it is src="http: ..."
{ // if not, the sourcecode of the document has to be altered
$part = explode (".jpg", $matches[0][$i]);
$part1 = $part[0]; //everything until .jpg, so now it's like src="file:///.../.../image001

// change the source
$number = 3;
for ($t=3; file_exists($path_copy.$table['id'].'_'.$t.'.jpg'); $t++)
{ $number = $t+1; // if id_3.jpg already exists, we have to check if id_4.jpg exists, etc
}
$textarea = preg_replace('['.$part1.']',$path.$table['id'].'_'.$number, $textarea);
// we change src="file:///.../.../imagename with
// src="http://www.website.com/images/id_number

$part = explode ("///", $matches[0][$i]);
$original = $part[1]; // everything from ///, because we have to find the name of the original
$original = explode ('"', $original); // at the end there is ">
$original = $original[0]; // so now we have the original

$target = $table['id'].'_'.$number.'.jpg';

$copy = $path_copy.$target;

// now we are going to ftp the file to the server
// variables which we use to connect
$ftp_server = "ftp.website.com";
$ftp_user_name = "username";
$ftp_user_pass = "password";

$source_file = $original;
$destination_file = $copy;
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check the connection
if ((!$conn_id) || (!$login_result))
{ echo "FTP connection did not succeed!";
echo "Tried to cennect to ".$ftp_server." as user ".$ftp_user_name;
exit;
}
else
{ echo "Connected with ".$ftp_server.", as user ".$ftp_user_name;
}

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload)
{ echo "FTP upload did not succeed!";
}
else
{ echo "Uploaded: ".$source_file." to ".$ftp_server." as ".$destination_file;
}

// close FTP stream
ftp_close($conn_id);

// finally whe have to update $textarea in our database
$textarea = addslashes($textarea);

// update the field textarea in the database
$query = "UPDATE table
SET
textarea ='".$textarea."'
WHERE id='".$id."'";
mysql_query($query,$tabel_db) or die;
}
}
?>



(This post was edited by kwillems on Jun 6, 2004, 3:30 PM)

 
 
 


Search for (options)