Commit d296f504 authored by Jérome Perrin's avatar Jérome Perrin

Improve read only HTML

We receive feedback from users saying that "when I view a mail message in event module, I see ugly html source", this was because user had set preferred text editor to monaco. Improve a bit monaco integration so that we display something better than code in a `<pre>`  for non editable editors.

We had another feedback that when using CKEditor as preferred text editor in old UI, users can not click on links when viewing an html Mail Message. But it works in new UI. I did something minimal so that this looks working until the migration to new UI is complete.

/reviewed-on !1011
parents 3eafdf3f 7356aefb
......@@ -78,7 +78,7 @@
key: options.key,
editable: options.editable === undefined ? true : options.editable
};
if (options.portal_type === 'Web Page') {
if (options.portal_type === 'Web Page' || options.content_type == 'text/html') {
model_language = 'html';
} else if (options.portal_type === 'Web Script') {
model_language = 'javascript';
......@@ -171,6 +171,8 @@
.push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs'))
.push(addExtraLibrary('./monaco-jio.d.ts', 'jio'));
}
if (modification_dict.hasOwnProperty('editable')){
gadget.editor.updateOptions({readOnly: !this.state.editable});
}
return queue;
})
......
......@@ -157,7 +157,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'editor\', context.Base_getEditorFieldPreferredTextEditor()), (\'portal_type\', context.getPortalType()), (\'maximize\', \'listbox\' not in field.id)]</string> </value>
<value> <string>python: [(\'editor\', context.Base_getEditorFieldPreferredTextEditor()), (\'portal_type\', context.getPortalType()), (\'maximize\', \'listbox\' not in field.id), (\'content_type\', context.getProperty(\'content_type\'))]</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -112,6 +112,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(editor_dict.hasOwnProperty(gadget.state.editor))) ||
(!gadget.state.editable && gadget.state.editor === 'fck_editor') ||
(!gadget.state.editable && gadget.state.editor === 'jsmd_editor') ||
(!gadget.state.editable && gadget.state.editor === 'monaco') ||
(gadget.state.editor === 'pdf')) {
queue
.push(function () {
......@@ -143,6 +144,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(editor_dict.hasOwnProperty(gadget.state.editor))) ||
(!gadget.state.editable && gadget.state.editor === 'fck_editor') ||
(!gadget.state.editable && gadget.state.editor === 'jsmd_editor') ||
(!gadget.state.editable && gadget.state.editor === 'monaco') ||
(gadget.state.editor === 'pdf')) {
queue
.push(function () {
......
......@@ -98,6 +98,12 @@
.allowPublicAcquisition('translateHtml', function (argument_list) {
return argument_list[0];
})
.allowPublicAcquisition('redirect', function (argument_list) {
var argument = argument_list[0];
if (argument.command === 'raw' && argument.options && argument.options.url) {
location.replace(argument.options.url);
}
})
/////////////////////////////////////////////////////////////////
// declared methods
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment