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 @@ ...@@ -78,7 +78,7 @@
key: options.key, key: options.key,
editable: options.editable === undefined ? true : options.editable 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'; model_language = 'html';
} else if (options.portal_type === 'Web Script') { } else if (options.portal_type === 'Web Script') {
model_language = 'javascript'; model_language = 'javascript';
...@@ -171,6 +171,8 @@ ...@@ -171,6 +171,8 @@
.push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs')) .push(addExtraLibrary('./monaco-renderjs.d.ts', 'renderjs'))
.push(addExtraLibrary('./monaco-jio.d.ts', 'jio')); .push(addExtraLibrary('./monaco-jio.d.ts', 'jio'));
} }
if (modification_dict.hasOwnProperty('editable')){
gadget.editor.updateOptions({readOnly: !this.state.editable});
} }
return queue; return queue;
}) })
......
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <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> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -112,6 +112,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/ ...@@ -112,6 +112,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(editor_dict.hasOwnProperty(gadget.state.editor))) || (editor_dict.hasOwnProperty(gadget.state.editor))) ||
(!gadget.state.editable && gadget.state.editor === 'fck_editor') || (!gadget.state.editable && gadget.state.editor === 'fck_editor') ||
(!gadget.state.editable && gadget.state.editor === 'jsmd_editor') || (!gadget.state.editable && gadget.state.editor === 'jsmd_editor') ||
(!gadget.state.editable && gadget.state.editor === 'monaco') ||
(gadget.state.editor === 'pdf')) { (gadget.state.editor === 'pdf')) {
queue queue
.push(function () { .push(function () {
...@@ -143,6 +144,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/ ...@@ -143,6 +144,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
(editor_dict.hasOwnProperty(gadget.state.editor))) || (editor_dict.hasOwnProperty(gadget.state.editor))) ||
(!gadget.state.editable && gadget.state.editor === 'fck_editor') || (!gadget.state.editable && gadget.state.editor === 'fck_editor') ||
(!gadget.state.editable && gadget.state.editor === 'jsmd_editor') || (!gadget.state.editable && gadget.state.editor === 'jsmd_editor') ||
(!gadget.state.editable && gadget.state.editor === 'monaco') ||
(gadget.state.editor === 'pdf')) { (gadget.state.editor === 'pdf')) {
queue queue
.push(function () { .push(function () {
......
...@@ -98,6 +98,12 @@ ...@@ -98,6 +98,12 @@
.allowPublicAcquisition('translateHtml', function (argument_list) { .allowPublicAcquisition('translateHtml', function (argument_list) {
return argument_list[0]; 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 // 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