diff --git a/www/code/code.less b/www/code/code.less index f90e1a15b..6c620fff8 100644 --- a/www/code/code.less +++ b/www/code/code.less @@ -1,6 +1,7 @@ @import "/customize/src/less/variables.less"; @import "/customize/src/less/mixins.less"; @import "/common/markdown.less"; +@import "/common/file-dialog.less"; html, body{ height: 100%; diff --git a/www/code/main.js b/www/code/main.js index 1b6cb8997..db358018d 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -147,6 +147,17 @@ define([ } }; + var mediaTagModes = [ + 'markdown', + 'html', + 'htmlembedded', + 'htmlmixed', + 'index.html', + 'php', + 'velocity', + 'xml', + ]; + var onModeChanged = function (mode) { var $codeMirror = $iframe.find('.CodeMirror'); window.clearTimeout(APP.previewTo); @@ -154,6 +165,10 @@ define([ APP.previewTo = window.setTimeout(function () { $codeMirror.removeClass('transition'); }, 500); + if (mediaTagModes.indexOf(mode) !== -1) { + APP.$mediaTagButton.show(); + } else { APP.$mediaTagButton.hide(); } + if (mode === "markdown") { APP.$previewButton.show(); Cryptpad.getPadAttribute('previewMode', function (e, data) { @@ -253,6 +268,25 @@ define([ var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb); $rightside.append($forgetPad); + var fileDialogCfg = { + $body: $iframe.find('body'), + onSelect: function (href) { + var parsed = Cryptpad.parsePadUrl(href); + var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel); + var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName; + var mt = ''; + editor.replaceSelection(mt); + }, + data: APP + }; + APP.$mediaTagButton = $('