Project

General

Profile

Actions

Improvements #11267

open

Improvements #11272: WTextEdit / TinyMCE improvements

Support changing readonly state after editor is rendered.

Added by Dries Mys over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
01/19/2023
Due date:
% Done:

0%

Estimated time:

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);
Actions #1

Updated by Roel Standaert over 1 year ago

  • Parent task set to #11272
Actions #2

Updated by Roel Standaert over 1 year ago

  • Target version set to future
Actions

Also available in: Atom PDF