Bug 6759 - Investigate TinyMCE or similar for single-line entries
Investigate TinyMCE or similar for single-line entries
Status: NEW
Product: OJS
Classification: Unclassified
Component: General
2.4.x
All All
: P3 normal
Assigned To: James MacGregor
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-12 13:32 PDT by Alec Smecher
Modified: 2012-03-12 10:12 PDT (History)
5 users (show)

See Also:
Version Reported In:
Also Affects:


Attachments
TinyMCE config to enable rich text on title fields (13.84 KB, application/octet-stream)
2011-10-14 07:00 PDT, Joseph Daddario
Details
Adding title fields to tinymce plugin (957 bytes, application/octet-stream)
2011-10-14 11:12 PDT, Joseph Daddario
Details
builds 2 separate tinymce inits for variable formatting options between fields (13.92 KB, patch)
2011-10-15 07:23 PDT, Joseph Daddario
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alec Smecher 2011-07-12 13:32:30 PDT
Investigate TinyMCE or similar for single-line entries e.g. article titles. Some of these fields permit limited HTML but require the tags to be entered manually.
Comment 1 Erika Manten 2011-08-17 07:20:46 PDT
Dear Alec,
TinyMCE is not an option in the title field.
I can add html codes in the title field and they are not visible in the table of contents in OJS, but after exporting to DSpace or the DOAJ the title contains the html codes for example 'The <i>Universal Review</i> (1888-1890)'.
Our system administrator says we should avoid using italic in the title field (even with TinyMCE, if that was an option) for it would (still) cause this sort of trouble in all kinds of external databases.
Thank you for your kind help anyway.
Best wishes, Erika

(In reply to comment #0)
> Investigate TinyMCE or similar for single-line entries e.g. article titles.
> Some of these fields permit limited HTML but require the tags to be entered
> manually.
Comment 2 Alec Smecher 2011-08-17 08:30:48 PDT
Erika, if we did fully support HTML in titles, we would definitely need to properly strip any included HTML out of titles for use with external tools that don't expect HTML.
Comment 3 Joseph Daddario 2011-10-10 12:27:24 PDT
Specifically tested TinyMCE in case it works for single-line text fields (but somehow wasn't documented) to no avail. Also, I have not located any examples of a single-line text field with any sort of rich text editor attached to it.

Immediate answer seems to be that if visible rich text was desired for single line fields they will need to be converted to text areas. Other options might include:
  1) developing a javascript/jquery/tinymce solution that replaces specific inputs (textfields) in a manner similar to TinyMCE's approach to textareas
  2) simply adding help text beneath fields noting allowed tags and perhaps an example
  3) implement barebones set of icons that wrap selected text in (visible) html tags -- basically like #2 w/ assist. 

Erika notes that, when exporting field titles containing tags, the tags remain. This is an issue with the current support of html in titles, which seems to be allowed in some cases, but not compensated for universally.
Comment 4 Alec Smecher 2011-10-11 09:42:34 PDT
Joe, option #1 sounds like the best solution to me -- and would be best suited for contribution back to the TinyMCE community. We could convert <input type="text" /> into <textarea>...</textarea> in our templates, but that seems a little clumsy. Mind investigating a little further?
Comment 5 Joseph Daddario 2011-10-11 10:14:03 PDT
Hrmph. When reading through the the docs I misinterpreted the "mode" setting. Turns out TinyMCE does allow what is being asked for here, namely, applying the text area to an input (or any other html element for that matter) -- though I'm not sure why my search yielded no examples of this.

Here's an example: 
[code]
<html>
<head>
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		mode : "exact",
		theme : "simple",
		elements: "textfield"
	});
</script>
</head>
<body>
  <input type="text" id="textfield" />
</body>
</html>
[/code]

(In reply to comment #4)
> Joe, option #1 sounds like the best solution to me -- and would be best suited
> for contribution back to the TinyMCE community. We could convert <input
> type="text" /> into <textarea>...</textarea> in our templates, but that seems a
> little clumsy. Mind investigating a little further?
Comment 6 Alec Smecher 2011-10-11 10:16:15 PDT
Better still, Joe -- I guess all that remains is to selectively configure TinyMCE to display a small input for those fields.
Comment 7 Joseph Daddario 2011-10-11 10:34:19 PDT
Yes, but should it always appear?
Comment 8 Alec Smecher 2011-10-11 11:54:16 PDT
Joe, I guess you're asking whether we should accordion out the rich-text editor when the field is clicked? I suspect that's not necessary as long as the editor doesn't look too clunky for these fields; there isn't so many of them that we have to optimize it too heavily IMO.
Comment 9 Joseph Daddario 2011-10-12 13:54:57 PDT
Alec, as I understand, once the TinyMCE plugin is enabled it is "on" for certain textareas throughout the system -- but the user does not have a mechanism to disable/enable this editor for specific textareas, i.e., there is no 'settings' page for the TinyMCE plugin. 

My thought is that even if they have enabled the plugin (because they wish to have tinymce applied to textareas) the user may not wish to have rich-text controls available for single-line entries.
Comment 10 Alec Smecher 2011-10-12 14:39:02 PDT
Gotcha, Joe. The ability of a text field to accept HTML vs. plain text is cooked into the system, beyond whether or not TinyMCE is presented; we've never hard someone complain that rich text was available somewhere they didn't want it (though we have had to add code to strip tags from places they shouldn't appear). I'm not worried about that.
Comment 11 Joseph Daddario 2011-10-14 07:00:36 PDT
Created attachment 3663 [details]
TinyMCE config to enable rich text on title fields

In that case the next step is to identify pages where title field appears and assign the field in /plugins/generic/tinymce/TinyMCEPlugin.inc.php. Attached is my first attempt, but someone with a deeper knowledge of workflows should check to make sure none have been overlooked. 

Presumably we'll also have to designate a distinct set of buttons for title fields as there isn't much sense allowing bullet-ed lists -- will look into this next.
Comment 12 Alec Smecher 2011-10-14 08:25:14 PDT
Joe, can you upload your modifications as .diff files, either using GNU diff or "git diff"?
Comment 13 Joseph Daddario 2011-10-14 11:12:47 PDT
Created attachment 3664 [details]
Adding title fields to tinymce plugin
Comment 14 Alec Smecher 2011-10-14 11:31:47 PDT
Joe, make sure you check the "patch" box when you upload the attachment. Looks good so far. See if you can crack the button set / formatting issues next.
Comment 15 Joseph Daddario 2011-10-15 07:23:35 PDT
Created attachment 3665 [details]
builds 2 separate tinymce inits for variable formatting options between fields

i've extended the $fields array to be multidimensional. each set of arrays off the root represents a unique set of fields which corresponds to unique tinymce configurations.
Comment 16 James MacGregor 2012-03-12 10:12:33 PDT
Deferring. I'm also not entirely sure why this is assigned to me, but I can certainly take a look at it.