Change config parameter documentType: it must take one of the values word/cell/slide (deprecate text/spreadsheet/presentation values).

This commit is contained in:
Julia Radzhabova 2020-09-11 16:34:29 +03:00 committed by Maxim Kadushkin
parent 0fea919d9c
commit da273fd8f8
4 changed files with 22 additions and 13 deletions

View file

@ -14,7 +14,7 @@
type: 'desktop or mobile', type: 'desktop or mobile',
width: '100% by default', width: '100% by default',
height: '100% by default', height: '100% by default',
documentType: 'text' | 'spreadsheet' | 'presentation', documentType: 'word' | 'cell' | 'slide',// deprecate 'text' | 'spreadsheet' | 'presentation',
document: { document: {
title: 'document title', title: 'document title',
url: 'document url' url: 'document url'
@ -163,7 +163,7 @@
type: 'embedded', type: 'embedded',
width: '100% by default', width: '100% by default',
height: '100% by default', height: '100% by default',
documentType: 'text' | 'spreadsheet' | 'presentation', documentType: 'word' | 'cell' | 'slide',// deprecate 'text' | 'spreadsheet' | 'presentation',
document: { document: {
title: 'document title', title: 'document title',
url: 'document url', url: 'document url',
@ -334,9 +334,15 @@
'text': 'docx', 'text': 'docx',
'text-pdf': 'pdf', 'text-pdf': 'pdf',
'spreadsheet': 'xlsx', 'spreadsheet': 'xlsx',
'presentation': 'pptx' 'presentation': 'pptx',
'word': 'docx',
'cell': 'xlsx',
'slide': 'pptx'
}, app; }, app;
if (_config.documentType=='text' || _config.documentType=='spreadsheet' ||_config.documentType=='presentation')
console.warn("The \"documentType\" parameter for the config object must take one of the values word/cell/slide.");
if (typeof _config.documentType === 'string' && _config.documentType != '') { if (typeof _config.documentType === 'string' && _config.documentType != '') {
app = appMap[_config.documentType.toLowerCase()]; app = appMap[_config.documentType.toLowerCase()];
if (!app) { if (!app) {
@ -355,9 +361,9 @@
window.alert("The \"document.fileType\" parameter for the config object is invalid. Please correct it."); window.alert("The \"document.fileType\" parameter for the config object is invalid. Please correct it.");
return false; return false;
} else if (typeof _config.documentType !== 'string' || _config.documentType == ''){ } else if (typeof _config.documentType !== 'string' || _config.documentType == ''){
if (typeof type[1] === 'string') _config.documentType = 'spreadsheet'; else if (typeof type[1] === 'string') _config.documentType = 'cell'; else
if (typeof type[2] === 'string') _config.documentType = 'presentation'; else if (typeof type[2] === 'string') _config.documentType = 'slide'; else
if (typeof type[3] === 'string') _config.documentType = 'text'; if (typeof type[3] === 'string') _config.documentType = 'word';
} }
} }
@ -737,9 +743,12 @@
'text': 'documenteditor', 'text': 'documenteditor',
'text-pdf': 'documenteditor', 'text-pdf': 'documenteditor',
'spreadsheet': 'spreadsheeteditor', 'spreadsheet': 'spreadsheeteditor',
'presentation': 'presentationeditor' 'presentation': 'presentationeditor',
'word': 'documenteditor',
'cell': 'spreadsheeteditor',
'slide': 'presentationeditor'
}, },
app = appMap['text']; app = appMap['word'];
if (typeof config.documentType === 'string') { if (typeof config.documentType === 'string') {
app = appMap[config.documentType.toLowerCase()]; app = appMap[config.documentType.toLowerCase()];
@ -748,8 +757,8 @@
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp))$/ var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp))$/
.exec(config.document.fileType); .exec(config.document.fileType);
if (type) { if (type) {
if (typeof type[1] === 'string') app = appMap['spreadsheet']; else if (typeof type[1] === 'string') app = appMap['cell']; else
if (typeof type[2] === 'string') app = appMap['presentation']; if (typeof type[2] === 'string') app = appMap['slide'];
} }
} }

View file

@ -53,7 +53,7 @@
type: urlParams['type'], type: urlParams['type'],
width: '100%', width: '100%',
height: '100%', height: '100%',
documentType: urlParams['doctype'] || 'text', documentType: urlParams['doctype'] || 'word',
document: doc, document: doc,
editorConfig: cfg, editorConfig: cfg,
events: { events: {

View file

@ -59,7 +59,7 @@ define([
externalEditor = new DocsAPI.DocEditor('id-diagram-editor-placeholder', { externalEditor = new DocsAPI.DocEditor('id-diagram-editor-placeholder', {
width : '100%', width : '100%',
height : '100%', height : '100%',
documentType: 'spreadsheet', documentType: 'cell',
document : { document : {
url : '_chart_', url : '_chart_',
permissions : { permissions : {

View file

@ -58,7 +58,7 @@ define([
externalEditor = new DocsAPI.DocEditor('id-merge-editor-placeholder', { externalEditor = new DocsAPI.DocEditor('id-merge-editor-placeholder', {
width : '100%', width : '100%',
height : '100%', height : '100%',
documentType: 'spreadsheet', documentType: 'cell',
document : { document : {
url : '_chart_', url : '_chart_',
permissions : { permissions : {