taoguan / jwysiwyg

Automatically exported from code.google.com/p/jwysiwyg
0 stars 0 forks source link

[Enhancement Request] Additional functionality #171

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
While building an application using jwysiwyg, I realized I wanted to be
able to switch between plain text and rich text formatting (similar to the
way Gmail does it) but jwysiwyg is lacking functionality to let me:

1. Determine if a text area already has a wysiwyg editor created.
2. Destroy a wysiwyg editor when the user decides they want plaintext.

I implemented these functions for myself (and a couple of others): please
let me know if there are things I've missed. I've attached a patch (created
using diff -u) for jwysiwyg-0.6 and copied/pasted the patch contents below.

--- ..\..\..\..\Desktop\jquery.wysiwyg.js   Sun Dec 13 04:04:00 2009
+++ js\jquery\jquery.wysiwyg.js Mon Mar 22 20:25:16 2010
@@ -38,6 +38,11 @@
             return element.contentWindow.getSelection().toString();
     };

+    $.fn.iswysiwyg = function()
+    {
+   return $.data(this.get(0), 'wysiwyg') != null;
+    };
+
     $.fn.wysiwyg = function( options )
     {
         if ( arguments.length > 0 && arguments[0].constructor == String )
@@ -191,6 +196,24 @@
                 self.saveContent();
         },

+   removeFormat : function()
+   {
+            var self = $.data(this, 'wysiwyg');    
+       self.removeFormat();
+   },
+
+   save : function()
+   {
+       var self = $.data(this, 'wysiwyg');     
+       self.saveContent();
+   },
+
+   destroy : function()
+   {
+            var self = $.data(this, 'wysiwyg');    
+       self.destroy();
+   },
+   
         clear : function()
         {
             var self = $.data(this, 'wysiwyg');
@@ -356,15 +379,29 @@
         element  : null,
         editor   : null,

+   removeFormat : function()
+   {
+       if ($.browser.msie) this.focus();
+       this.editorDoc.execCommand('removeFormat', false, []);
+                this.editorDoc.execCommand('unlink', false, []);
+   },
+
+   destroy : function()
+   {
+       $(this.element).remove();
+       $.removeData(this.original, 'wysiwyg');
+       $(this.original).show();
+   },
+
         focus : function()
         {
             $(this.editorDoc.body).focus();

Original issue reported on code.google.com by fomoj...@gmail.com on 23 Mar 2010 at 1:05

Attachments:

GoogleCodeExporter commented 8 years ago
hi fomojola, 

take a look at http://github.com/akzhan/jwysiwyg, there is 0.7 version, it 
doesnt
have that functionality, but you can modify your patch to this version.

Original comment by serg...@gmail.com on 29 Mar 2010 at 6:24

GoogleCodeExporter commented 8 years ago
looks fine, I'll apply it today.

Original comment by akzhan.a...@gmail.com on 29 Mar 2010 at 6:45

GoogleCodeExporter commented 8 years ago
Applied as 
http://github.com/akzhan/jwysiwyg/commit/d0d829a63cd21021e308cee8c259356d43cd9f8
2

Take a look at notes.

Original comment by akzhan.a...@gmail.com on 29 Mar 2010 at 7:09

GoogleCodeExporter commented 8 years ago
Looks good. Thank you. 

Will upgrade upon the next release.

Original comment by fomoj...@gmail.com on 29 Mar 2010 at 7:32

GoogleCodeExporter commented 8 years ago
HI, I know this is an old thread but please bear with me as im already out of 
options elsewhere.

I have a textarea which can be changed to plain text or html.
I have a problem when converting from HTML to plain text because I want to 
retain the new line characters to plain text but replacing <br> or <div> does 
not solve it. There are other tags that creates a new line and that is my 
biggest problem.

I would really like to know how to get the text from the JWYSIWYG, strip off 
the HTML tags, retain the texts and newlines and show it on plain text.

Original comment by jlbrue...@gmail.com on 31 May 2013 at 1:34

Attachments: