From b554eb5afe24ba6cdedce3f6f34e1b244bfd702e Mon Sep 17 00:00:00 2001 From: cahrens Date: Tue, 22 Jan 2013 15:28:47 -0500 Subject: [PATCH] Cleanup of format dropdown, toolbar buttons. --- .../xmodule/xmodule/js/src/html/edit.coffee | 25 ++++++++++++++++-- common/static/images/code.gif | Bin 0 -> 1224 bytes 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 common/static/images/code.gif diff --git a/common/lib/xmodule/xmodule/js/src/html/edit.coffee b/common/lib/xmodule/xmodule/js/src/html/edit.coffee index dfb197e204..62038de255 100644 --- a/common/lib/xmodule/xmodule/js/src/html/edit.coffee +++ b/common/lib/xmodule/xmodule/js/src/html/edit.coffee @@ -22,15 +22,24 @@ class @HTMLEditingDescriptor schema: "html5", # TODO: we should share this CSS with studio (and LMS) content_css : "/static/css/tiny-mce.css", + # Disable h4, h5, and h6 styles as we don't have CSS for them. + formats : { + h4: {}, + h5: {}, + h6: {} + }, + # Disable visual aid on borderless table. + visual:false, # We may want to add "styleselect" when we collect all styles used throughout the LMS - theme_advanced_buttons1 : "formatselect,bold,italic,underline,bullist,numlist,outdent,indent,blockquote,link,unlink", + theme_advanced_buttons1 : "formatselect,bold,italic,underline,|,bullist,numlist,outdent,indent,|,blockquote,wrapAsCode,|,link,unlink", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "none", theme_advanced_resizing : true, - theme_advanced_blockformats : "p,code,h2,h3,blockquote", + theme_advanced_blockformats : "p,h1,h2,h3,pre", width: '100%', height: '400px', + setup : HTMLEditingDescriptor.setupTinyMCE, # Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered. # The tinyMCE callback passes in the editor as a paramter. init_instance_callback: @focusVisualEditor @@ -39,6 +48,18 @@ class @HTMLEditingDescriptor @showingVisualEditor = true @element.on('click', '.editor-tabs .tab', @onSwitchEditor) + @setupTinyMCE: (ed) -> + ed.addButton('wrapAsCode', { + title : 'Code Block', + image : '/static/images/code.gif', + onclick : () -> + ed.formatter.toggle('code') + }) + + ed.onNodeChange.add((editor, command, e) -> + command.setActive('wrapAsCode', e.nodeName == 'CODE') + ) + onSwitchEditor: (e)=> e.preventDefault(); diff --git a/common/static/images/code.gif b/common/static/images/code.gif new file mode 100644 index 0000000000000000000000000000000000000000..918e6ddca0698626d7481f47a36515f379b38c43 GIT binary patch literal 1224 zcmZ?wbhEHb6lD-)Sj5htq@;BB?p($f#LuE|BC;)BYXoCToOwX zfwYZ%ML}Y6c4~=2Qfhi;o~_dR-TRdkGE;1o!cBb*d<&dYGcrA@ic*8C{6dnevXd=S zlxV%Qmue&kg&dz0$52&wylyQNJ0T*r*nQ$ zs)DJWfo`&anSp|tp`M|!iMhGCj)IYap@F`Ek-njkuA#Y=v5}R5fdUjL0c|TvNwW%a zaf8|g1^l#~=$>Fbx5m+O@q>*W`v>l<2HT7t|lGSUUA&@HaaD@m--%_~-hnc$LI zoLrPyP?DLSrvNfBF)6>a#8wIDQivCF3*g4)73+b$qnDhYt6z~=pl_&W0P+${p|3A~ zrMbCq)x{-2sR;LCHMlsWvLIDID784hv?w_hs9YIjRe_arQEFmIeo;t%ehw@Y12XbU z@{2R_3lyA#O%;3-lQZ)`e6V_7Un|eN;*!L?e zX-RQWVL^UgZccVqW=48iYD#iaVnTdeY)o`iWJGvaXh?8SV1U1$uaCEvr-!?ntBbRf zql3Mjt&O#nrG>efsfn=>FiYv_>S$|eYN)HJswgWdD#**p%1BE|N{EYziUS{o_%0&Nf4RGb^56E`PF-$^ED