Improvements #11267
openImprovements #11272: WTextEdit / TinyMCE improvements
Support changing readonly state after editor is rendered.
0%
Description
Currently the readonly attribute is only correctly applied on first render. Later changes are applied on the hidden textarea, but are not applied to the tinyMCE editor.
Possible solution:
Explicitly update the tinyMCE mode to reflect the readonly state, by adding the following code to the end of WTextEdit::setReadOnly
:
if (isRendered()) {
if (readOnly)
doJavaScript(jsRef() + ".ed.mode.set('readonly');");
else
doJavaScript(jsRef() + ".ed.mode.set('design');");
}
See TinyMCE documentation: https://www.tiny.cloud/docs/tinymce/6/apis/tinymce.editormode/#set
Note that this does not seem to work (when the editor is initially readonly), due to a bad initial readonly configuration setting. Wt uses std::string("1") and cpp17::any() (see WTextEdit::setReadOnly
), although the documented values are true and false.
See TinyMCE documentation: https://www.tiny.cloud/docs/tinymce/6/editor-important-options/#starting-the-editor-in-a-read-only-state
Correctly using true and false inside WTextEdit::setReadOnly
, resolves this issue:
if (readOnly)
setConfigurationSetting("readonly", true);
else
setConfigurationSetting("readonly", false);
Updated by Matthias Van Ceulebroeck 3 months ago
- Assignee set to Romain Mardulyn
- Target version changed from future to 4.11.1
Updated by Romain Mardulyn 3 months ago
- Status changed from InProgress to Review
Updated by Romain Mardulyn 3 months ago
- Status changed from Review to InProgress
Updated by Romain Mardulyn 3 months ago
- Status changed from InProgress to Review
- Assignee deleted (
Romain Mardulyn)
Updated by Matthias Van Ceulebroeck about 1 month ago
- Target version changed from 4.11.1 to 4.11.2