Fix issues of no file extension for pad export
This commit is contained in:
parent
3de9021397
commit
3e918ec1cf
@ -8,7 +8,7 @@ define([
|
|||||||
module.main = function (userDoc, cb) {
|
module.main = function (userDoc, cb) {
|
||||||
var mode = userDoc.highlightMode || 'gfm';
|
var mode = userDoc.highlightMode || 'gfm';
|
||||||
var content = userDoc.content;
|
var content = userDoc.content;
|
||||||
module.type = SFCodeMirror.getContentExtension(mode);
|
module.ext = SFCodeMirror.getContentExtension(mode);
|
||||||
cb(SFCodeMirror.fileExporter(content));
|
cb(SFCodeMirror.fileExporter(content));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ define([
|
|||||||
"C text/x-c++src .cpp",
|
"C text/x-c++src .cpp",
|
||||||
"C-like clike .c",
|
"C-like clike .c",
|
||||||
"Clojure clojure .clj",
|
"Clojure clojure .clj",
|
||||||
"CMake cmake", /* no extension */
|
"CMake cmake _", /* no extension */
|
||||||
"COBOL cobol .cbl",
|
"COBOL cobol .cbl",
|
||||||
"CoffeeScript coffeescript .coffee",
|
"CoffeeScript coffeescript .coffee",
|
||||||
"Common_Lisp commonlisp .lisp",
|
"Common_Lisp commonlisp .lisp",
|
||||||
@ -25,7 +25,7 @@ define([
|
|||||||
"Dart dart .dart",
|
"Dart dart .dart",
|
||||||
"Diff diff .diff",
|
"Diff diff .diff",
|
||||||
"Django django .py",
|
"Django django .py",
|
||||||
"Dockerfile dockerfile", /* no extension */
|
"Dockerfile dockerfile _", /* no extension */
|
||||||
"DTD dtd .dtd",
|
"DTD dtd .dtd",
|
||||||
"Dylan dylan .dylan",
|
"Dylan dylan .dylan",
|
||||||
"EBNF ebnf .ebnf",
|
"EBNF ebnf .ebnf",
|
||||||
@ -47,7 +47,7 @@ define([
|
|||||||
"Haskell-Literate haskell-literate .lhs",
|
"Haskell-Literate haskell-literate .lhs",
|
||||||
"Haxe haxe .hx",
|
"Haxe haxe .hx",
|
||||||
"HTML htmlmixed .html",
|
"HTML htmlmixed .html",
|
||||||
"HTTP http", /* no extension */
|
"HTTP http _", /* no extension */
|
||||||
"IDL idl .idl",
|
"IDL idl .idl",
|
||||||
"JADE jade .jade",
|
"JADE jade .jade",
|
||||||
"Java text/x-java .java",
|
"Java text/x-java .java",
|
||||||
@ -61,7 +61,7 @@ define([
|
|||||||
//"markdown markdown .md",
|
//"markdown markdown .md",
|
||||||
"Mathematica mathematica .nb",
|
"Mathematica mathematica .nb",
|
||||||
"mIRC mirc .irc",
|
"mIRC mirc .irc",
|
||||||
"ML mllike", /* no extension */
|
"ML mllike _", /* no extension */
|
||||||
"Modelica modelica .mo",
|
"Modelica modelica .mo",
|
||||||
"MscGen mscgen .mscgen",
|
"MscGen mscgen .mscgen",
|
||||||
"MUMPS mumps .m",
|
"MUMPS mumps .m",
|
||||||
@ -93,9 +93,9 @@ define([
|
|||||||
"Shell shell .sh",
|
"Shell shell .sh",
|
||||||
"Sieve sieve .sieve",
|
"Sieve sieve .sieve",
|
||||||
"Slim slim .slim",
|
"Slim slim .slim",
|
||||||
"Smalltalk smalltalk", /* no extension */
|
"Smalltalk smalltalk _", /* no extension */
|
||||||
"Smarty smarty", /* no extension */
|
"Smarty smarty _", /* no extension */
|
||||||
"Solr solr", /* no extension */
|
"Solr solr _", /* no extension */
|
||||||
"Soy soy .soy",
|
"Soy soy .soy",
|
||||||
"SPARQL sparql .rq",
|
"SPARQL sparql .rq",
|
||||||
"Spreadsheet spreadsheet .xls",
|
"Spreadsheet spreadsheet .xls",
|
||||||
@ -107,7 +107,7 @@ define([
|
|||||||
"Text text .txt",
|
"Text text .txt",
|
||||||
"Textile textile .textile",
|
"Textile textile .textile",
|
||||||
"TiddlyWiki tiddlywiki .tw",
|
"TiddlyWiki tiddlywiki .tw",
|
||||||
"Tiki tiki", /* no extension */
|
"Tiki tiki _", /* no extension */
|
||||||
"TOML toml .toml",
|
"TOML toml .toml",
|
||||||
"Tornado tornado .tornado",
|
"Tornado tornado .tornado",
|
||||||
"troff troff .troff",
|
"troff troff .troff",
|
||||||
@ -125,22 +125,22 @@ define([
|
|||||||
//"xwiki xwiki21",
|
//"xwiki xwiki21",
|
||||||
"XQuery xquery .xquery",
|
"XQuery xquery .xquery",
|
||||||
"YAML yaml .yaml",
|
"YAML yaml .yaml",
|
||||||
"YAML_Frontmatter yaml-frontmatter", /* no extension */
|
"YAML_Frontmatter yaml-frontmatter _", /* no extension */
|
||||||
"Z80 z80 .z80"
|
"Z80 z80 .z80"
|
||||||
].map(function (line) {
|
].map(function (line) {
|
||||||
var kv = line.split(/\s/);
|
var kv = line.split(/\s/);
|
||||||
return {
|
return {
|
||||||
language: kv[0].replace(/_/g, ' '),
|
language: kv[0].replace(/_/g, ' '),
|
||||||
mode: kv[1],
|
mode: kv[1],
|
||||||
ext: kv[2],
|
ext: kv[2] === '_' ? '' : kv[2],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
Modes.extensionOf = function (mode) {
|
Modes.extensionOf = function (mode) {
|
||||||
var ext = '';
|
var ext;
|
||||||
list.some(function (o) {
|
list.some(function (o) {
|
||||||
if (o.mode !== mode) { return; }
|
if (o.mode !== mode) { return; }
|
||||||
ext = o.ext || '';
|
ext = o.ext;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return ext;
|
return ext;
|
||||||
|
|||||||
@ -401,7 +401,7 @@ define([
|
|||||||
var ext = (typeof(extension) === 'function') ? extension() : extension;
|
var ext = (typeof(extension) === 'function') ? extension() : extension;
|
||||||
var suggestion = title.suggestTitle('cryptpad-document');
|
var suggestion = title.suggestTitle('cryptpad-document');
|
||||||
UI.prompt(Messages.exportPrompt,
|
UI.prompt(Messages.exportPrompt,
|
||||||
Util.fixFileName(suggestion) + '.' + ext, function (filename)
|
Util.fixFileName(suggestion) + ext, function (filename)
|
||||||
{
|
{
|
||||||
if (!(typeof(filename) === 'string' && filename)) { return; }
|
if (!(typeof(filename) === 'string' && filename)) { return; }
|
||||||
if (async) {
|
if (async) {
|
||||||
|
|||||||
@ -39,7 +39,8 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.getContentExtension = function (mode) {
|
module.getContentExtension = function (mode) {
|
||||||
return (Modes.extensionOf(mode) || '.txt').slice(1);
|
var ext = Modes.extensionOf(mode);
|
||||||
|
return ext !== undefined ? ext : '.txt';
|
||||||
};
|
};
|
||||||
module.fileExporter = function (content) {
|
module.fileExporter = function (content) {
|
||||||
return new Blob([ content ], { type: 'text/plain;charset=utf-8' });
|
return new Blob([ content ], { type: 'text/plain;charset=utf-8' });
|
||||||
|
|||||||
@ -2,7 +2,9 @@
|
|||||||
// Pads from the code app will be exported using this format instead of plain text.
|
// Pads from the code app will be exported using this format instead of plain text.
|
||||||
define([
|
define([
|
||||||
], function () {
|
], function () {
|
||||||
var module = {};
|
var module = {
|
||||||
|
ext: '.json'
|
||||||
|
};
|
||||||
|
|
||||||
module.main = function (userDoc, cb) {
|
module.main = function (userDoc, cb) {
|
||||||
var content = userDoc.content;
|
var content = userDoc.content;
|
||||||
|
|||||||
@ -367,7 +367,7 @@ define([
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
framework.setFileExporter('json', function () {
|
framework.setFileExporter('.json', function () {
|
||||||
return new Blob([JSON.stringify(kanban.getBoardsJSON(), 0, 2)], {
|
return new Blob([JSON.stringify(kanban.getBoardsJSON(), 0, 2)], {
|
||||||
type: 'application/json',
|
type: 'application/json',
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,7 +5,7 @@ define([
|
|||||||
'/bower_components/nthen/index.js',
|
'/bower_components/nthen/index.js',
|
||||||
], function ($, Util, Hyperjson, nThen) {
|
], function ($, Util, Hyperjson, nThen) {
|
||||||
var module = {
|
var module = {
|
||||||
type: 'html'
|
ext: '.html'
|
||||||
};
|
};
|
||||||
|
|
||||||
var exportMediaTags = function (inner, cb) {
|
var exportMediaTags = function (inner, cb) {
|
||||||
|
|||||||
@ -786,7 +786,7 @@ define([
|
|||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
framework.setFileExporter(Exporter.type, function (cb) {
|
framework.setFileExporter(Exporter.ext, function (cb) {
|
||||||
Exporter.main(inner, cb);
|
Exporter.main(inner, cb);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,9 @@
|
|||||||
define([
|
define([
|
||||||
'/customize/messages.js',
|
'/customize/messages.js',
|
||||||
], function (Messages) {
|
], function (Messages) {
|
||||||
var module = {};
|
var module = {
|
||||||
|
ext: '.csv'
|
||||||
|
};
|
||||||
|
|
||||||
var copyObject = function (obj) {
|
var copyObject = function (obj) {
|
||||||
return JSON.parse(JSON.stringify(obj));
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
|||||||
@ -34,7 +34,7 @@ define([
|
|||||||
var path = '/' + type + '/export.js';
|
var path = '/' + type + '/export.js';
|
||||||
require([path], function (Exporter) {
|
require([path], function (Exporter) {
|
||||||
Exporter.main(json, function (data) {
|
Exporter.main(json, function (data) {
|
||||||
result.ext = '.' + Exporter.type;
|
result.ext = Exporter.ext || '';
|
||||||
result.data = data;
|
result.data = data;
|
||||||
cb(result);
|
cb(result);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ define([
|
|||||||
'/common/sframe-common-codemirror.js',
|
'/common/sframe-common-codemirror.js',
|
||||||
], function (SFCodeMirror) {
|
], function (SFCodeMirror) {
|
||||||
var module = {
|
var module = {
|
||||||
type: 'md'
|
ext: '.md'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.main = function (userDoc, cb) {
|
module.main = function (userDoc, cb) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ define([
|
|||||||
var canvas = new Fabric.Canvas(canvas_node);
|
var canvas = new Fabric.Canvas(canvas_node);
|
||||||
var content = userDoc.content;
|
var content = userDoc.content;
|
||||||
canvas.loadFromJSON(content, function () {
|
canvas.loadFromJSON(content, function () {
|
||||||
module.type = 'svg';
|
module.ext = '.svg';
|
||||||
cb(canvas.toSVG());
|
cb(canvas.toSVG());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -415,7 +415,7 @@ define([
|
|||||||
setEditable(!locked);
|
setEditable(!locked);
|
||||||
});
|
});
|
||||||
|
|
||||||
framework.setFileExporter('png', function (cb) {
|
framework.setFileExporter('.png', function (cb) {
|
||||||
$canvas[0].toBlob(function (blob) {
|
$canvas[0].toBlob(function (blob) {
|
||||||
cb(blob);
|
cb(blob);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user