Moodle

Ability to disable HTML editor for specified database fields

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.7.1
  • Fix Version/s: 2.1.5
  • Labels:
    None
  • Environment:
    Any that support HTML editor
  • Database:
    Any
  • Affected Branches:
    MOODLE_17_STABLE
  • Fixed Branches:
    MOODLE_21_STABLE

Description

The HTML editor is overkill for some text areas which are small or where simple unformatted text is the required input.

It would be most useful if there was an option to disable the editor as required (in a similar way to the option for templates).

Activity

Hide
Martin Huntley added a comment -

I agree. Very important to making more useable interfaces for simple data collection tools. Ideally, there would be a general way to selectively disable HTML editor that works across modules, because the database module is not the only one where this is overkill.

Show
Martin Huntley added a comment - I agree. Very important to making more useable interfaces for simple data collection tools. Ideally, there would be a general way to selectively disable HTML editor that works across modules, because the database module is not the only one where this is overkill.
Hide
Martin Dougiamas added a comment -

This is a tricky to do due to how the editor works, but we should tackle it sometime soon.

I'd like to see a little switch next to the editor to toggle it on and off. The trouble is that this will need to reload the page, and so you'd have to lose any/all unsaved changes made to the form. I guess we can live with that.

I'd like to see this toggle be "sticky" for every page too, which means storing a flag in user prefs for every page that a user hits the switch on (that overrides site+user settings for that page only).

Show
Martin Dougiamas added a comment - This is a tricky to do due to how the editor works, but we should tackle it sometime soon. I'd like to see a little switch next to the editor to toggle it on and off. The trouble is that this will need to reload the page, and so you'd have to lose any/all unsaved changes made to the form. I guess we can live with that. I'd like to see this toggle be "sticky" for every page too, which means storing a flag in user prefs for every page that a user hits the switch on (that overrides site+user settings for that page only).
Hide
Ray Lawrence added a comment -

Cheers.

Sounds great. Just in case my initial post was not clear on this point, I'd like the capability to disable the editor when creating the activity but also for the status of the editor for specified text areas to be the status for each participant who subsequently accesses the acivity .

Show
Ray Lawrence added a comment - Cheers. Sounds great. Just in case my initial post was not clear on this point, I'd like the capability to disable the editor when creating the activity but also for the status of the editor for specified text areas to be the status for each participant who subsequently accesses the acivity .
Hide
Itamar Tzadok added a comment -

Wouldn't the simplest although by no means the most general approach for the non-editor-text-area be adding a field type 'simple text area' (as opposed to the current '[rich] text area')?

Show
Itamar Tzadok added a comment - Wouldn't the simplest although by no means the most general approach for the non-editor-text-area be adding a field type 'simple text area' (as opposed to the current '[rich] text area')?
Hide
Itamar Tzadok added a comment -

Instead of disabling individual editors the patch adds a new field type which for lack of a better name is called 'Simple textarea'. This is effectively a multiline text field (no html or other formats; all tags are cleaned as in the text field).

This was a very simple and (too?) easy fix, so much so that I can't help thinking that I've missed something. So before a similar fix for 2.0 Comments will be greatly appreciated.

Show
Itamar Tzadok added a comment - Instead of disabling individual editors the patch adds a new field type which for lack of a better name is called 'Simple textarea'. This is effectively a multiline text field (no html or other formats; all tags are cleaned as in the text field). This was a very simple and (too?) easy fix, so much so that I can't help thinking that I've missed something. So before a similar fix for 2.0 Comments will be greatly appreciated.
Hide
Frank Schweickert added a comment - - edited

I'm not exactly sure what I'm doing... but for Moodle 2.0 in order to get rid of the TinyMCE controls in a table packed with text areas I'm experimenting with a workaround in the CSS and JavaScript templates of my database activity. Maybe that gives ideas to people who do know what the are doing...

Add this to Templates/CSS Template to hide TinyMCE controls and statusbar:

.mceFirst td, .mceStatusbar {
display: none !important;
}

And add something like the following to experiment with the width and height of the input areas, for they seem to behave oddly with the first change alone:

iframe {
height: 100% !important;
width: 100% !important;
}

To get rid of the syntax choice drop down menus beneath each text area I used JavaScript - for they have no class attribute that I could address with CSS. Put this in Javascript template (Not sure if this works under all circumstances, though):

function hideSyntaxChoice() {
var s = document.getElementsByTagName("select");
for(var i=0; i<s.length; i++) {
if((/^field_\d+_content1$/).test(s[i].name)) {
s[i].style.display= 'none';
}
}
}
window.onload = hideSyntaxChoice;

P.S. It was not so easy to put the CSS code into this tracker comment. Preview was fine, but then an error message about missing macros was displayed within the text. That's why I made the curly brackets bold...

Show
Frank Schweickert added a comment - - edited I'm not exactly sure what I'm doing... but for Moodle 2.0 in order to get rid of the TinyMCE controls in a table packed with text areas I'm experimenting with a workaround in the CSS and JavaScript templates of my database activity. Maybe that gives ideas to people who do know what the are doing... Add this to Templates/CSS Template to hide TinyMCE controls and statusbar:
.mceFirst td, .mceStatusbar { display: none !important; }
And add something like the following to experiment with the width and height of the input areas, for they seem to behave oddly with the first change alone:
iframe { height: 100% !important; width: 100% !important; }
To get rid of the syntax choice drop down menus beneath each text area I used JavaScript - for they have no class attribute that I could address with CSS. Put this in Javascript template (Not sure if this works under all circumstances, though):
function hideSyntaxChoice() { var s = document.getElementsByTagName("select"); for(var i=0; i<s.length; i++) { if((/^field_\d+_content1$/).test(s[i].name)) { s[i].style.display= 'none'; } } } window.onload = hideSyntaxChoice;
P.S. It was not so easy to put the CSS code into this tracker comment. Preview was fine, but then an error message about missing macros was displayed within the text. That's why I made the curly brackets bold...
Hide
Itamar Tzadok added a comment -

Actually I resolve this issue in the dataform in a different way. The textarea field offers an option to disable the editor. If the editor is disabled the field is rendered as a simple textarea. See attached images for illustration.

Show
Itamar Tzadok added a comment - Actually I resolve this issue in the dataform in a different way. The textarea field offers an option to disable the editor. If the editor is disabled the field is rendered as a simple textarea. See attached images for illustration.
Hide
Frank Schweickert added a comment - - edited

Itamar's solution is clearly superior as to page loading times and side effects. But I simply didn't know enough about the inner workings of Moodle to be able to port his patch from 1.9 to 2.0. We needed a workaround right now, and I only put it here to illustrate what can be done with CSS/JavaScript and maybe to get a hint if there is some fundamental problem with it, because the students are coming soon...
As soon as Itamar is ready with Moodle 2.0, we'd prefer the simple text areas, too! Please keep going, Itamar!

Show
Frank Schweickert added a comment - - edited Itamar's solution is clearly superior as to page loading times and side effects. But I simply didn't know enough about the inner workings of Moodle to be able to port his patch from 1.9 to 2.0. We needed a workaround right now, and I only put it here to illustrate what can be done with CSS/JavaScript and maybe to get a hint if there is some fundamental problem with it, because the students are coming soon... As soon as Itamar is ready with Moodle 2.0, we'd prefer the simple text areas, too! Please keep going, Itamar!

People

Dates

  • Created:
    Updated: