(function(editors, elFinder) { if (typeof define === 'function' && define.amd) { define(['elfinder'], editors); } else if (elFinder) { var optEditors = elFinder.prototype._options.commandsOptions.edit.editors; elFinder.prototype._options.commandsOptions.edit.editors = optEditors.concat(editors(elFinder)); } }(function(elFinder) { "use strict"; var apps = {}, // get query of getfile getfile = window.location.search.match(/getfile=([a-z]+)/), useRequire = elFinder.prototype.hasRequire, hasFlash = (function() { var hasFlash; try { hasFlash = !!(new ActiveXObject('ShockwaveFlash.ShockwaveFlash')); } catch (e) { hasFlash = !!(typeof window.orientation === 'undefined' || (navigator && navigator.mimeTypes["application/x-shockwave-flash"])); } return hasFlash; })(), ext2mime = { bmp: 'image/x-ms-bmp', dng: 'image/x-adobe-dng', gif: 'image/gif', jpeg: 'image/jpeg', jpg: 'image/jpeg', pdf: 'application/pdf', png: 'image/png', ppm: 'image/x-portable-pixmap', psd: 'image/vnd.adobe.photoshop', pxd: 'image/x-pixlr-data', svg: 'image/svg+xml', tiff: 'image/tiff', webp: 'image/webp', xcf: 'image/x-xcf', sketch: 'application/x-sketch' }, mime2ext, getExtention = function(mime, fm) { if (!mime2ext) { mime2ext = fm.arrayFlip(ext2mime); } var ext = mime2ext[mime] || fm.mimeTypes[mime]; if (ext === 'jpeg') { ext = 'jpg'; } return ext; }, changeImageType = function(src, toMime) { var dfd = $.Deferred(); try { var canvas = document.createElement('canvas'), ctx = canvas.getContext('2d'), img = new Image(), conv = function() { var url = canvas.toDataURL(toMime), mime, m; if (m = url.match(/^data:([a-z0-9]+\/[a-z0-9.+-]+)/i)) { mime = m[1]; } else { mime = ''; } if (mime.toLowerCase() === toMime.toLowerCase()) { dfd.resolve(canvas.toDataURL(toMime), canvas); } else { dfd.reject(); } }; img.src = src; $(img).on('load', function() { try { canvas.width = img.width; canvas.height = img.height; ctx.drawImage(img, 0, 0); conv(); } catch(e) { dfd.reject(); } }).on('error', function () { dfd.reject(); }); return dfd; } catch(e) { return dfd.reject(); } }, initImgTag = function(id, file, content, fm) { var node = $(this).children('img:first').data('ext', getExtention(file.mime, fm)), spnr = $('
') .html('' + fm.i18n('ntfloadimg') + '') .hide() .appendTo(this), url; if (!content.match(/^data:/)) { url = fm.openUrl(file.hash); node.attr('_src', content); } node.attr('id', id+'-img') .attr('src', url || content) .css({'height':'', 'max-width':'100%', 'max-height':'100%', 'cursor':'pointer'}) .data('loading', function(done) { var btns = node.closest('.elfinder-dialog').find('button,.elfinder-titlebar-button'); btns.prop('disabled', !done)[done? 'removeClass' : 'addClass']('ui-state-disabled'); node.css('opacity', done? '' : '0.3'); spnr[done? 'hide' : 'show'](); return node; }); }, imgBase64 = function(node, mime) { var style = node.attr('style'), img, canvas, ctx, data; try { // reset css for getting image size node.attr('style', ''); // img node img = node.get(0); // New Canvas canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; // restore css node.attr('style', style); // Draw Image canvas.getContext('2d').drawImage(img, 0, 0); // To Base64 data = canvas.toDataURL(mime); } catch(e) { data = node.attr('src'); } return data; }, pixlrCallBack = function() { if (!hasFlash || window.parent === window) { return; } var pixlr = window.location.search.match(/[?&]pixlr=([^&]+)/), image = window.location.search.match(/[?&]image=([^&]+)/), p, ifm, url, node, ext; if (pixlr) { // case of redirected from pixlr.com p = window.parent; ifm = p.$('#'+pixlr[1]+'iframe').hide(); node = p.$('#'+pixlr[1]).data('resizeoff')(); if (image[1].substr(0, 4) === 'http') { url = image[1]; ext = url.replace(/.+\.([^.]+)$/, '$1'); if (node.data('ext') !== ext) { node.closest('.ui-dialog').trigger('changeType', { extention: ext, mime : ext2mime[ext] }); } if (window.location.protocol === 'https:') { url = url.replace(/^http:/, 'https:'); } node.on('load error', function() { node.data('loading')(true); }) .attr('src', url) .data('loading')(); } else { node.data('loading')(true); } ifm.trigger('destroy').remove(); } }, pixlrSetup = function(opts, fm) { if (!hasFlash || fm.UA.ltIE8) { this.disabled = true; } }, pixlrLoad = function(mode, base) { var self = this, fm = this.fm, clPreventBack = fm.res('class', 'preventback'), node = $(base).children('img:first') .data('loading')() .data('resizeoff', function() { $(window).off('resize.'+node.attr('id')); dialog.addClass(clPreventBack); return node; }) .on('click', function() { launch(); }), dialog = $(base).closest('.ui-dialog'), elfNode = fm.getUI(), uiToast = fm.getUI('toast'), container = $('', // setup on elFinder bootup setup : function(opts, fm) { if (fm.UA.IE || fm.UA.Mobile) { this.disabled = true; } }, // Initialization of editing node (this: this editors HTML node) init : function(id, file, dum, fm) { var orig = 'https://www.photopea.com', ifm = $(this).hide() //.css('box-sizing', 'border-box') .on('load', function() { //spnr.remove(); ifm.show(); }) .on('error', function() { spnr.remove(); ifm.show(); }), editor = this.editor, confObj = editor.confObj, spnr = $('
') .html('' + fm.i18n('nowLoading') + '') .appendTo(ifm.parent()), saveMimes = fm.arrayFlip(confObj.info.canMakeEmpty), getType = function(mime) { var ext = getExtention(mime, fm), extmime = ext2mime[ext]; if (!confObj.mimesFlip[extmime]) { ext = ''; } else if (ext === 'jpeg') { ext = 'jpg'; } if (!ext || !!saveMimes[ext]) { ext = 'psd'; extmime = ext2mime[ext]; ifm.closest('.ui-dialog').trigger('changeType', { extention: ext, mime : extmime, keepEditor: true }); } return ext; }, mime = file.mime, liveMsg, type, quty; if (!confObj.mimesFlip) { confObj.mimesFlip = fm.arrayFlip(confObj.mimes, true); } if (!confObj.liveMsg) { confObj.liveMsg = function(ifm, spnr, file) { var url = fm.openUrl(file.hash); if (!fm.isSameOrigin(url)) { url = fm.openUrl(file.hash, true); } var wnd = ifm.get(0).contentWindow, phase = 0, data = null, dfdIni = $.Deferred().done(function() { spnr.remove(); phase = 1; wnd.postMessage(data, '*'); }), dfdGet; this.load = function() { return fm.request({ data : {cmd : 'get'}, options : { url: url, type: 'get', cache : true, dataType : 'binary', responseType :'arraybuffer', processData: false } }) .done(function(d) { data = d; }); }; this.receive = function(e) { var ev = e.originalEvent, state; if (ev.origin === orig && ev.source === wnd) { if (ev.data === 'done') { if (phase === 0) { dfdIni.resolve(); } else if (phase === 1) { phase = 2; ifm.trigger('contentsloaded'); } else { if (dfdGet && dfdGet.state() === 'pending') { dfdGet.reject('errDataEmpty'); } } } else { if (dfdGet && dfdGet.state() === 'pending') { if (typeof ev.data === 'object') { dfdGet.resolve('data:' + mime + ';base64,' + fm.arrayBufferToBase64(ev.data)); } else { dfdGet.reject('errDataEmpty'); } } } } }; this.getContent = function() { var type, q; if (phase > 1) { dfdGet && dfdGet.state() === 'pending' && dfdGet.reject(); dfdGet = null; dfdGet = $.Deferred(); if (phase === 2) { phase = 3; dfdGet.resolve('data:' + mime + ';base64,' + fm.arrayBufferToBase64(data)); data = null; return dfdGet; } if (ifm.data('mime')) { mime = ifm.data('mime'); type = getType(mime); } if (q = ifm.data('quality')) { type += ':' + (q / 100); } wnd.postMessage('app.activeDocument.saveToOE("' + type + '")', orig); return dfdGet; } }; }; } ifm.parent().css('padding', 0); type = getType(file.mime); liveMsg = editor.liveMsg = new confObj.liveMsg(ifm, spnr, file); $(window).on('message.' + fm.namespace, liveMsg.receive); liveMsg.load().done(function() { var d = JSON.stringify({ files : [], environment : { lang: fm.lang.replace(/_/g, '-') } }); ifm.attr('src', orig + '/#' + encodeURI(d)); }).fail(function(err) { err && fm.error(err); editor.initFail = true; }); // jpeg quality controls if (file.mime === 'image/jpeg' || file.mime === 'image/webp') { ifm.data('quality', fm.storage('jpgQuality') || fm.option('jpgQuality')); quty = $('') .attr('min', '1') .attr('max', '100') .attr('title', '1 - 100') .on('change', function() { var q = quty.val(); ifm.data('quality', q); }) .val(ifm.data('quality')); $('
') .append( $('').html(fm.i18n('quality') + ' : '), quty, $('') ) .prependTo(ifm.parent().next()); } }, load : function(base) { var dfd = $.Deferred(), self = this, fm = this.fm, $base = $(base); if (self.initFail) { dfd.reject(); } else { $base.on('contentsloaded', function() { dfd.resolve(self.liveMsg); }); } return dfd; }, getContent : function() { return this.editor.liveMsg? this.editor.liveMsg.getContent() : void(0); }, save : function(base, liveMsg) { var $base = $(base), quality = $base.data('quality'), hash = $base.data('hash'), file; if (typeof quality !== 'undefined') { this.fm.storage('jpgQuality', quality); } if (hash) { file = this.fm.file(hash); $base.data('mime', file.mime); } else { $base.removeData('mime'); } }, // On dialog closed close : function(base, liveMsg) { $(base).attr('src', ''); liveMsg && $(window).off('message.' + this.fm.namespace, liveMsg.receive); } }, { // Pixo is cross-platform image editor info : { id : 'pixo', name : 'Pixo Editor', iconImg : 'img/editor-icons.png 0 -208', dataScheme: true, schemeContent: true, single: true, canMakeEmpty: false, integrate: { title: 'Pixo Editor', link: 'https://pixoeditor.com/privacy-policy/' } }, // MIME types to accept mimes : ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'image/x-ms-bmp'], // HTML of this editor html : '
', // called on initialization of elFinder cmd edit (this: this editor's config object) setup : function(opts, fm) { if (fm.UA.ltIE8 || !opts.extraOptions || !opts.extraOptions.pixo || !opts.extraOptions.pixo.apikey) { this.disabled = true; } else { this.editorOpts = opts.extraOptions.pixo; } }, // Initialization of editing node (this: this editors HTML node) init : function(id, file, content, fm) { initImgTag.call(this, id, file, content, fm); }, // Get data uri scheme (this: this editors HTML node) getContent : function() { return $(this).children('img:first').attr('src'); }, // Launch Pixo editor when dialog open load : function(base) { var self = this, fm = this.fm, $base = $(base), node = $base.children('img:first'), dialog = $base.closest('.ui-dialog'), elfNode = fm.getUI(), dfrd = $.Deferred(), container = $('#elfinder-pixo-container'), init = function(onload) { var opts; if (!container.length) { container = $('
').css({ position: 'fixed', top: 0, right: 0, width: '100%', height: $(window).height(), overflow: 'hidden' }).hide().appendTo(elfNode.hasClass('elfinder-fullscreen')? elfNode : 'body'); // bind switch fullscreen event elfNode.on('resize.'+fm.namespace, function(e, data) { e.preventDefault(); e.stopPropagation(); data && data.fullscreen && container.appendTo(data.fullscreen === 'on'? elfNode : 'body'); }); fm.bind('destroy', function() { editor && editor.cancelEditing(); container.remove(); }); } else { // always moves to last container.appendTo(container.parent()); } node.on('click', launch); // Constructor options opts = Object.assign({ type: 'child', parent: container.get(0), onSave: function(arg) { // Check current file.hash, all callbacks are called on multiple instances var mime = arg.toBlob().type, ext = getExtention(mime, fm), draw = function(url) { node.one('load error', function() { node.data('loading') && node.data('loading')(true); }) .attr('crossorigin', 'anonymous') .attr('src', url); }, url = arg.toDataURL(); node.data('loading')(); delete base._canvas; if (node.data('ext') !== ext) { changeImageType(url, self.file.mime).done(function(res, cv) { if (cv) { base._canvas = canvas = cv; quty.trigger('change'); qBase && qBase.show(); } draw(res); }).fail(function() { dialog.trigger('changeType', { extention: ext, mime : mime }); draw(url); }); } else { draw(url); } }, onClose: function() { dialog.removeClass(fm.res('class', 'preventback')); fm.toggleMaximize(container, false); container.hide(); fm.toFront(dialog); } }, self.confObj.editorOpts); // trigger event 'editEditorPrepare' self.trigger('Prepare', { node: base, editorObj: Pixo, instance: void(0), opts: opts }); // make editor instance editor = new Pixo.Bridge(opts); dfrd.resolve(editor); $base.on('saveAsFail', launch); if (onload) { onload(); } }, launch = function() { dialog.addClass(fm.res('class', 'preventback')); fm.toggleMaximize(container, true); fm.toFront(container); container.show().data('curhash', self.file.hash); editor.edit(node.get(0)); node.data('loading')(true); }, qBase, quty, qutyTm, canvas, editor; node.data('loading')(); // jpeg quality controls if (self.file.mime === 'image/jpeg') { quty = $('') .attr('min', '1') .attr('max', '100') .attr('title', '1 - 100') .on('change', function() { var q = quty.val(); qutyTm && cancelAnimationFrame(qutyTm); qutyTm = requestAnimationFrame(function() { if (canvas) { canvas.toBlob(function(blob) { blob && quty.next('span').text(' (' + fm.formatSize(blob.size) + ')'); }, 'image/jpeg', Math.max(Math.min(q, 100), 1) / 100); } }); }) .val(fm.storage('jpgQuality') || fm.option('jpgQuality')); qBase = $('
') .hide() .append( $('').html(fm.i18n('quality') + ' : '), quty, $('') ) .prependTo($base.parent().next()); $base.data('quty', quty); } // load script then init if (typeof Pixo === 'undefined') { fm.loadScript(['https://pixoeditor.com:8443/editor/scripts/bridge.m.js'], function() { init(launch); }, {loadType: 'tag'}); } else { init(); launch(); } return dfrd; }, // Convert content url to data uri scheme to save content save : function(base) { var self = this, $base = $(base), node = $base.children('img:first'), q; if (base._canvas) { q = $base.data('quty')? Math.max(Math.min($base.data('quty').val(), 100), 1) / 100 : void(0); node.attr('src', base._canvas.toDataURL(self.file.mime, q)); } else if (node.attr('src').substr(0, 5) !== 'data:') { node.attr('src', imgBase64(node, this.file.mime)); } }, close : function(base, editor) { editor && editor.destroy(); } }, { // Adobe Creative SDK Creative Tools Image Editor UI // MIME types to accept info : { id : 'creativecloud', name : 'Creative Cloud', iconImg : 'img/editor-icons.png 0 -192', dataScheme: true, schemeContent: true, single: true, canMakeEmpty: false, integrate: { title: 'Adobe Creative Cloud', link: 'https://www.adobe.io/apis/creativecloud.html' } }, mimes : ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'image/x-ms-bmp'], // HTML of this editor html : '
', // called on initialization of elFinder cmd edit (this: this editor's config object) setup : function(opts, fm) { if (fm.UA.ltIE8 || !opts.extraOptions || !opts.extraOptions.creativeCloudApiKey) { this.disabled = true; } else { this.apiKey = opts.extraOptions.creativeCloudApiKey; } }, // Initialization of editing node (this: this editors HTML node) init : function(id, file, content, fm) { initImgTag.call(this, id, file, content, fm); }, // Get data uri scheme (this: this editors HTML node) getContent : function() { return $(this).children('img:first').attr('src'); }, // Launch Aviary Feather editor when dialog open load : function(base) { var self = this, fm = this.fm, node = $(base).children('img:first'), dialog = $(base).closest('.ui-dialog'), elfNode = fm.getUI(), dfrd = $.Deferred(), container = $('#elfinder-aviary-container'), init = function(onload) { var getLang = function() { var langMap = { 'zh_TW' : 'zh_HANT', 'zh_CN' : 'zh_HANS' }; return langMap[fm.lang]? langMap[fm.lang] : fm.lang; }, opts; if (!container.length) { container = $('
').css({ position: 'fixed', top: 0, right: 0, width: '100%', height: $(window).height(), overflow: 'auto' }).hide().appendTo(elfNode.hasClass('elfinder-fullscreen')? elfNode : 'body'); // bind switch fullscreen event elfNode.on('resize.'+fm.namespace, function(e, data) { e.preventDefault(); e.stopPropagation(); data && data.fullscreen && container.appendTo(data.fullscreen === 'on'? elfNode : 'body'); }); fm.bind('destroy', function() { container.remove(); }); } else { // always moves to last container.appendTo(container.parent()); } node.on('click', launch).data('loading')(); opts = { apiKey: self.confObj.apiKey, onSave: function(imageID, newURL) { var ext; featherEditor.showWaitIndicator(); ext = newURL.replace(/.+\.([^.]+)$/, '$1'); if (node.data('ext') !== ext) { node.closest('.ui-dialog').trigger('changeType', { extention: ext, mime : ext2mime[ext] }); } node.on('load error', function() { node.data('loading')(true); }) .attr('crossorigin', 'anonymous') .attr('src', newURL) .data('loading')(); featherEditor.close(); }, onLoad: onload || function(){}, onClose: function() { dialog.removeClass(fm.res('class', 'preventback')); fm.toggleMaximize(container, false); $(container).hide(); }, appendTo: container.get(0), maxSize: 2048, language: getLang() }; // trigger event 'editEditorPrepare' self.trigger('Prepare', { node: base, editorObj: Aviary, instance: void(0), opts: opts }); featherEditor = new Aviary.Feather(opts); // return editor instance dfrd.resolve(featherEditor); $(base).on('saveAsFail', launch); }, launch = function() { dialog.addClass(fm.res('class', 'preventback')); fm.toggleMaximize(container, true); fm.toFront(container); $(container).show(); featherEditor.launch({ image: node.attr('id'), url: node.attr('src') }); node.data('loading')(true); }, featherEditor, extraOpts; // load script then init if (typeof Aviary === 'undefined') { fm.loadScript(['https://dme0ih8comzn4.cloudfront.net/imaging/v3/editor.js'], function() { init(launch); }, {loadType: 'tag'}); } else { init(); launch(); } return dfrd; }, // Convert content url to data uri scheme to save content save : function(base) { var node = $(base).children('img:first'); if (node.attr('src').substr(0, 5) !== 'data:') { node.attr('src', imgBase64(node, this.file.mime)); } } }, { // ACE Editor // called on initialization of elFinder cmd edit (this: this editor's config object) setup : function(opts, fm) { if (fm.UA.ltIE8 || !fm.options.cdns.ace) { this.disabled = true; } }, // `mimes` is not set for support everything kind of text file info : { id : 'aceeditor', name : 'ACE Editor', iconImg : 'img/editor-icons.png 0 -96' }, load : function(textarea) { var self = this, fm = this.fm, dfrd = $.Deferred(), cdn = fm.options.cdns.ace, start = function() { var editor, editorBase, mode, ta = $(textarea), taBase = ta.parent(), dialog = taBase.parent(), id = textarea.id + '_ace', ext = self.file.name.replace(/^.+\.([^.]+)|(.+)$/, '$1$2').toLowerCase(), // MIME/mode map mimeMode = { 'text/x-php' : 'php', 'application/x-php' : 'php', 'text/html' : 'html', 'application/xhtml+xml' : 'html', 'text/javascript' : 'javascript', 'application/javascript' : 'javascript', 'text/css' : 'css', 'text/x-c' : 'c_cpp', 'text/x-csrc' : 'c_cpp', 'text/x-chdr' : 'c_cpp', 'text/x-c++' : 'c_cpp', 'text/x-c++src' : 'c_cpp', 'text/x-c++hdr' : 'c_cpp', 'text/x-shellscript' : 'sh', 'application/x-csh' : 'sh', 'text/x-python' : 'python', 'text/x-java' : 'java', 'text/x-java-source' : 'java', 'text/x-ruby' : 'ruby', 'text/x-perl' : 'perl', 'application/x-perl' : 'perl', 'text/x-sql' : 'sql', 'text/xml' : 'xml', 'application/docbook+xml' : 'xml', 'application/xml' : 'xml' }; // set base height taBase.height(taBase.height()); // set basePath of ace ace.config.set('basePath', cdn); // Base node of Ace editor editorBase = $('
').text(ta.val()).insertBefore(ta.hide()); // Editor flag ta.data('ace', true); // Aceeditor instance editor = ace.edit(id); // Ace editor configure editor.$blockScrolling = Infinity; editor.setOptions({ theme: 'ace/theme/monokai', fontSize: '14px', wrap: true, }); ace.config.loadModule('ace/ext/modelist', function() { // detect mode mode = ace.require('ace/ext/modelist').getModeForPath('/' + self.file.name).name; if (mode === 'text') { if (mimeMode[self.file.mime]) { mode = mimeMode[self.file.mime]; } } // show MIME:mode in title bar taBase.prev().children('.elfinder-dialog-title').append(' (' + self.file.mime + ' : ' + mode.split(/[\/\\]/).pop() + ')'); editor.setOptions({ mode: 'ace/mode/' + mode }); if (dfrd.state() === 'resolved') { dialog.trigger('resize'); } }); ace.config.loadModule('ace/ext/language_tools', function() { ace.require('ace/ext/language_tools'); editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: false }); }); ace.config.loadModule('ace/ext/settings_menu', function() { ace.require('ace/ext/settings_menu').init(editor); }); // Short cuts editor.commands.addCommand({ name : "saveFile", bindKey: { win : 'Ctrl-s', mac : 'Command-s' }, exec: function(editor) { self.doSave(); } }); editor.commands.addCommand({ name : "closeEditor", bindKey: { win : 'Ctrl-w|Ctrl-q', mac : 'Command-w|Command-q' }, exec: function(editor) { self.doCancel(); } }); editor.resize(); // TextArea button and Setting button $('
').css('float', 'left') .append( $('') .button({ icons: { primary: 'ui-icon-gear', secondary: 'ui-icon-triangle-1-e' }, text: false }) .on('click', function(){ editor.showSettingsMenu(); $('#ace_settingsmenu') .css('font-size', '80%') .find('div[contains="setOptions"]').hide().end() .parent().appendTo($('#elfinder')); }) ) .prependTo(taBase.next()); // trigger event 'editEditorPrepare' self.trigger('Prepare', { node: textarea, editorObj: ace, instance: editor, opts: {} }); //dialog.trigger('resize'); dfrd.resolve(editor); }; // check ace & start if (!self.confObj.loader) { self.confObj.loader = $.Deferred(); self.fm.loadScript([ cdn+'/ace.js' ], function() { self.confObj.loader.resolve(); }, void 0, {obj: window, name: 'ace'}); } self.confObj.loader.done(start); return dfrd; }, close : function(textarea, instance) { instance && instance.destroy(); }, save : function(textarea, instance) { instance && $(textarea).data('ace') && (textarea.value = instance.session.getValue()); }, focus : function(textarea, instance) { instance && $(textarea).data('ace') && instance.focus(); }, resize : function(textarea, instance, e, data) { instance && instance.resize(); } }, { // CodeMirror // called on initialization of elFinder cmd edit (this: this editor's config object) setup : function(opts, fm) { if (fm.UA.ltIE10 || !fm.options.cdns.codemirror) { this.disabled = true; } }, // `mimes` is not set for support everything kind of text file info : { id : 'codemirror', name : 'CodeMirror', iconImg : 'img/editor-icons.png 0 -176' }, load : function(textarea) { var fm = this.fm, cmUrl = fm.options.cdns.codemirror, dfrd = $.Deferred(), self = this, start = function(CodeMirror) { var ta = $(textarea), base = ta.parent(), editor, editorBase, opts; // set base height base.height(base.height()); // CodeMirror configure options opts = { lineNumbers: true, lineWrapping: true, extraKeys : { 'Ctrl-S': function() { self.doSave(); }, 'Ctrl-Q': function() { self.doCancel(); }, 'Ctrl-W': function() { self.doCancel(); } } }; // trigger event 'editEditorPrepare' self.trigger('Prepare', { node: textarea, editorObj: CodeMirror, instance: void(0), opts: opts }); // CodeMirror configure editor = CodeMirror.fromTextArea(textarea, opts); // return editor instance dfrd.resolve(editor); // Auto mode set var info, m, mode, spec; if (! info) { info = CodeMirror.findModeByMIME(self.file.mime); } if (! info && (m = self.file.name.match(/.+\.([^.]+)$/))) { info = CodeMirror.findModeByExtension(m[1]); } if (info) { CodeMirror.modeURL = useRequire? 'codemirror/mode/%N/%N.min' : cmUrl + '/mode/%N/%N.min.js'; mode = info.mode; spec = info.mime; editor.setOption('mode', spec); CodeMirror.autoLoadMode(editor, mode); // show MIME:mode in title bar base.prev().children('.elfinder-dialog-title').append(' (' + spec + ' : ' + mode + ')'); } // editor base node editorBase = $(editor.getWrapperElement()).css({ // fix CSS conflict to SimpleMDE padding: 0, border: 'none' }); ta.data('cm', true); // fit height to base editorBase.height('100%'); // TextArea button and Setting button $('
').css('float', 'left') .append( $('