From 450fa70971457aabde27cde75b4e577adc8203ae Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 28 Feb 2024 22:02:40 +0300 Subject: [PATCH 1/8] Open pdf-form in DE --- apps/api/documents/api.js | 28 ++++++--- apps/common/main/index.html | 61 +++++++++++++++++++ apps/common/main/index.html.deploy | 61 +++++++++++++++++++ .../main/resources/less/asc-mixins.less | 20 ++++++ apps/common/main/resources/less/calendar.less | 3 - apps/common/main/resources/less/header.less | 7 ++- .../main/resources/less/synchronize-tip.less | 16 ++--- apps/common/main/resources/less/toolbar.less | 20 +++--- .../common/main/resources/less/variables.less | 5 ++ .../main/app/controller/Main.js | 12 ++-- apps/documenteditor/main/index.html | 10 ++- apps/documenteditor/main/index.html.deploy | 10 ++- apps/documenteditor/main/index_loader.html | 8 ++- .../main/index_loader.html.deploy | 9 ++- 14 files changed, 224 insertions(+), 46 deletions(-) create mode 100644 apps/common/main/index.html create mode 100644 apps/common/main/index.html.deploy diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index e689381f5c..eed2312ba8 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -477,7 +477,7 @@ } } - var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(_config.document.fileType); + var type = /^(?:(djvu|xps|oxps))$/.exec(_config.document.fileType); if (type && typeof type[1] === 'string') { _config.editorConfig.canUseHistory = false; } @@ -960,25 +960,29 @@ 'word': 'documenteditor', 'cell': 'spreadsheeteditor', 'slide': 'presentationeditor', - 'pdf': 'pdfeditor' + 'pdf': 'pdfeditor', + 'checker': config.document && config.document.isForm ? 'documenteditor' : + config.document && config.document.isForm===false ? 'pdfeditor' : 'common' }, appType = 'word'; if (typeof config.documentType === 'string') { appType = config.documentType.toLowerCase(); if (config.type !== 'mobile' && config.type !== 'embedded' && !!config.document && typeof config.document.fileType === 'string') { - var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(config.document.fileType); - if (type && typeof type[1] === 'string') + var type = /^(?:(pdf)|(djvu|xps|oxps))$/.exec(config.document.fileType); + if (type && typeof type[2] === 'string') appType = 'pdf'; + if (type && typeof type[1] === 'string') + appType = 'checker'; } - } else - if (!!config.document && typeof config.document.fileType === 'string') { - var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp)|(pdf|djvu|xps|oxps))$/ + } else if (!!config.document && typeof config.document.fileType === 'string') { + var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp)|(pdf)|(djvu|xps|oxps))$/ .exec(config.document.fileType); if (type) { if (typeof type[1] === 'string') appType = 'cell'; else if (typeof type[2] === 'string') appType = 'slide'; else - if (typeof type[3] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'pdf'; + if (typeof type[4] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'pdf'; else + if (typeof type[3] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'checker'; } } if (appType === 'pdf' && (config.type === 'mobile' || config.type === 'embedded')) { @@ -994,7 +998,7 @@ var index = "/index.html"; if (config.editorConfig && path_type!=="forms") { var customization = config.editorConfig.customization; - if ( typeof(customization) == 'object' && ( customization.toolbarNoTabs || + if ( appType!=='checker' && typeof(customization) == 'object' && ( customization.toolbarNoTabs || (config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) { index = "/index_loader.html"; } else if (config.editorConfig.mode === 'editdiagram' || config.editorConfig.mode === 'editmerge' || config.editorConfig.mode === 'editole') @@ -1064,6 +1068,12 @@ if (config.document && config.document.fileType) params += "&fileType=" + config.document.fileType; + if (config.editorConfig) { + var customization = config.editorConfig.customization; + if ( customization && typeof(customization) == 'object' && ( customization.toolbarNoTabs || (config.editorConfig.targetApp!=='desktop') && (customization.loaderName || customization.loaderLogo))) { + params += "&indexPostfix=_loader"; + } + } return params; } diff --git a/apps/common/main/index.html b/apps/common/main/index.html new file mode 100644 index 0000000000..7045ae5618 --- /dev/null +++ b/apps/common/main/index.html @@ -0,0 +1,61 @@ + + + + ONLYOFFICE Documents + + + + + + + + + + + + +
+ + + diff --git a/apps/common/main/index.html.deploy b/apps/common/main/index.html.deploy new file mode 100644 index 0000000000..a0d1523a73 --- /dev/null +++ b/apps/common/main/index.html.deploy @@ -0,0 +1,61 @@ + + + + ONLYOFFICE Documents + + + + + + + + + + + + +
+ + + diff --git a/apps/common/main/resources/less/asc-mixins.less b/apps/common/main/resources/less/asc-mixins.less index cedc33457b..07d7a9a666 100644 --- a/apps/common/main/resources/less/asc-mixins.less +++ b/apps/common/main/resources/less/asc-mixins.less @@ -844,3 +844,23 @@ // } // } //} + +.header-background-color { + background-color: @header-background-color-ie; + background-color: @header-background-color; + + .pdf-form & { + background-color: @header-background-color-pdf-ie; + background-color: @header-background-color-pdf; + } +} + +.header-border-color { + border-color: @header-background-color-ie !important; + border-color: @header-background-color !important; + + .pdf-form & { + border-color: @header-background-color-pdf-ie !important; + border-color: @header-background-color-pdf !important; + } +} diff --git a/apps/common/main/resources/less/calendar.less b/apps/common/main/resources/less/calendar.less index 97fe8653b2..57e3b47873 100644 --- a/apps/common/main/resources/less/calendar.less +++ b/apps/common/main/resources/less/calendar.less @@ -1,6 +1,3 @@ -@calendar-bg-color: @header-background-color-ie; -@calendar-bg-color: @header-background-color; - .calendar-window { border-radius: 0; box-shadow: none; diff --git a/apps/common/main/resources/less/header.less b/apps/common/main/resources/less/header.less index fd5e028c57..078a0f7035 100644 --- a/apps/common/main/resources/less/header.less +++ b/apps/common/main/resources/less/header.less @@ -403,6 +403,10 @@ background-color: @icon-toolbar-header; color: @toolbar-header-text-on-background-ie; color: @toolbar-header-text-on-background; + .pdf-form & { + color: @toolbar-header-text-on-background-pdf-ie; + color: @toolbar-header-text-on-background-pdf; + } vertical-align: middle; background-size: cover; background-position: center; @@ -517,8 +521,7 @@ } #box-document-title { - background-color: @header-background-color-ie; - background-color: @header-background-color; + .header-background-color(); display: flex; height: 100%; color: @text-toolbar-header-ie; diff --git a/apps/common/main/resources/less/synchronize-tip.less b/apps/common/main/resources/less/synchronize-tip.less index 2300df36c6..5154cda520 100644 --- a/apps/common/main/resources/less/synchronize-tip.less +++ b/apps/common/main/resources/less/synchronize-tip.less @@ -29,13 +29,10 @@ &.theme-color { .asc-synchronizetip { - background-color: @header-background-color-ie; - background-color: @header-background-color; + .header-background-color(); color: @text-toolbar-header-ie; color: @text-toolbar-header; - border-color: @header-background-color-ie; - border-color: @header-background-color; - + .header-border-color(); .close { &:before, &:after { background-color: @text-toolbar-header-ie; @@ -45,14 +42,11 @@ } .tip-arrow:before { - background-color: @header-background-color-ie; - background-color: @header-background-color; - border-color: @header-background-color-ie !important; - border-color: @header-background-color !important; + .header-background-color(); + .header-border-color(); } .tip-arrow:after { - border-color: @header-background-color-ie !important; - border-color: @header-background-color !important; + .header-border-color(); } } diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index 249778a258..8b19f96f98 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -38,9 +38,7 @@ align-items: stretch; .extra { - background-color: @header-background-color-ie; - background-color: @header-background-color; - + .header-background-color(); box-shadow: inset 0 @minus-px 0 0 @border-toolbar-active-panel-top; } @@ -60,8 +58,7 @@ .tabs { //flex-grow: 1; - background-color: @header-background-color-ie; - background-color: @header-background-color; + .header-background-color(); position: relative; overflow: hidden; display: flex; @@ -174,6 +171,10 @@ &.left{ box-shadow: 5px 0 20px 5px @header-background-color-ie; box-shadow: 18px calc(@tabs-scroller-height - @scaled-one-px-value) 0 10px @border-toolbar-active-panel-top, 5px 0 20px 5px @header-background-color; + .pdf-form & { + box-shadow: 5px 0 20px 5px @header-background-color-pdf-ie; + box-shadow: 18px calc(@tabs-scroller-height - @scaled-one-px-value) 0 10px @border-toolbar-active-panel-top, 5px 0 20px 5px @header-background-color-pdf; + } &:after { transform: rotate(135deg); @@ -188,6 +189,10 @@ &.right{ box-shadow: -5px 0 20px 5px @header-background-color-ie; box-shadow: -10px calc(@tabs-scroller-height - @scaled-one-px-value) 0 10px @border-toolbar-active-panel-top, -5px 0 20px 5px @header-background-color; + .pdf-form & { + box-shadow: -5px 0 20px 5px @header-background-color-pdf-ie; + box-shadow: -10px calc(@tabs-scroller-height - @scaled-one-px-value) 0 10px @border-toolbar-active-panel-top, -5px 0 20px 5px @header-background-color-pdf; + } &:after { transform: rotate(-45deg); @@ -466,7 +471,7 @@ .toolbar { @underscore_height: 3px; - .tabs, .extra { + .tabs, .box-tabs .extra { background-color: transparent; box-shadow: inset 0 -1px 0 0 @border-regular-control-ie; box-shadow: inset 0 -1px 0 0 @border-regular-control; @@ -652,8 +657,7 @@ &.editor-native-color { .tabs li:after { - border-color: @header-background-color-ie; - border-color: @header-background-color; + .header-border-color(); } } } diff --git a/apps/common/main/resources/less/variables.less b/apps/common/main/resources/less/variables.less index d02a0fef86..2d03274209 100644 --- a/apps/common/main/resources/less/variables.less +++ b/apps/common/main/resources/less/variables.less @@ -40,6 +40,11 @@ @brand-danger: #d9534f; @brand-info: #5bc0de; +@header-background-color-pdf-ie: @toolbar-header-pdf-ie; +@header-background-color-pdf: var(--toolbar-header-pdf); +@toolbar-header-text-on-background-pdf-ie: @text-toolbar-header-on-background-pdf-ie; +@toolbar-header-text-on-background-pdf: var(--text-toolbar-header-on-background-pdf); + // Scaffolding // ------------------------- diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index fbb551e92d..2c13d20ffb 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -549,13 +549,13 @@ define([ // docInfo.put_Review(this.permissions.review); var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(data.doc.fileType); - var coEditMode = (type && typeof type[1] === 'string') ? 'strict' : // offline viewer for pdf|djvu|xps|oxps + var coEditMode = (type && typeof type[1] === 'string' && !window.isPDFForm) ? 'strict' : // offline viewer for pdf|djvu|xps|oxps !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer this.editorConfig.coEditing.mode || 'fast'; docInfo.put_CoEditingMode(coEditMode); - if (type && typeof type[1] === 'string') { + if (type && typeof type[1] === 'string' && !window.isPDFForm) { this.permissions.edit = this.permissions.review = false; } } @@ -568,8 +568,8 @@ define([ $('#editor-container').find('.doc-placeholder').css('margin-top', 19); } - var type = data.doc ? /^(?:(docxf|oform))$/.exec(data.doc.fileType) : false; - this.appOptions.isFormCreator = !!(type && typeof type[1] === 'string') && this.appOptions.canFeatureForms; // show forms only for docxf or oform + var type = data.doc ? /^(?:(docxf|oform)|(pdf))$/.exec(data.doc.fileType) : false; + this.appOptions.isFormCreator = !!(type && (typeof type[1] === 'string' || typeof type[2] === 'string' && window.isPDFForm)) && this.appOptions.canFeatureForms; // show forms only for docxf or oform type = data.doc ? /^(?:(oform))$/.exec(data.doc.fileType) : false; this.appOptions.isOForm = !!(type && typeof type[1] === 'string'); @@ -642,7 +642,7 @@ define([ Asc.c_oAscFileType.PNG ]; var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(this.document.fileType); - if (type && typeof type[1] === 'string') { + if (type && typeof type[1] === 'string' && !window.isPDFForm) { if (!(format && (typeof format == 'string')) || type[1]===format.toLowerCase()) { var options = new Asc.asc_CDownloadOptions(); options.asc_setIsDownloadEvent(true); @@ -1564,7 +1564,7 @@ define([ if ( this.onServerVersion(params.asc_getBuildVersion()) || !this.onLanguageLoaded()) return; - var isPDFViewer = /^(?:(pdf|djvu|xps|oxps))$/.test(this.document.fileType); + var isPDFViewer = /^(?:(pdf|djvu|xps|oxps))$/.test(this.document.fileType) && !window.isPDFForm; this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review; diff --git a/apps/documenteditor/main/index.html b/apps/documenteditor/main/index.html index 2ab030ebe4..6aed627542 100644 --- a/apps/documenteditor/main/index.html +++ b/apps/documenteditor/main/index.html @@ -59,6 +59,11 @@ background: var(--toolbar-header-document, #446995); } + .pdf-form .loadmask > .brendpanel { + background: #AA5252; + background: var(--toolbar-header-pdf, #AA5252); + } + .loadmask > .brendpanel > div { display: flex; align-items: center; @@ -255,10 +260,12 @@ lang = (params["lang"] || 'en').split(/[\-\_]/)[0], hideLogo = params["headerlogo"]==='', logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null, - logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null; + logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null, + isForm = params["isForm"]==='true'; window.frameEditorId = params["frameEditorId"]; window.parentOrigin = params["parentOrigin"]; + window.isPDFForm = isForm; if(/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) { document.write(' @@ -258,6 +265,7 @@ view = params["mode"] == 'view', visible = true; + isForm && document.body.classList.add('pdf-form'); (compact || view || notoolbar) && document.querySelector('.brendpanel > :nth-child(2)').remove(); if (compact || view) { diff --git a/apps/documenteditor/main/index_loader.html b/apps/documenteditor/main/index_loader.html index 6bb5a21201..701351df10 100644 --- a/apps/documenteditor/main/index_loader.html +++ b/apps/documenteditor/main/index_loader.html @@ -219,9 +219,11 @@ customer = params["customer"] ? ('
' + encodeUrlParam(params["customer"]) + '
') : '', margin = (customer !== '') ? 50 : 20, loading = 'Loading...', - logo = params["logo"] ? ((params["logo"] !== 'none') ? ('') : '') : null; + logo = params["logo"] ? ((params["logo"] !== 'none') ? ('') : '') : null, + isForm = params["isForm"]==='true'; window.frameEditorId = params["frameEditorId"]; window.parentOrigin = params["parentOrigin"]; + window.isPDFForm = isForm; if ( lang == 'de') loading = 'Ladevorgang...'; else if ( lang == 'es') loading = 'Cargando...'; else if ( lang == 'fr') loading = 'Chargement en cours...'; @@ -267,7 +269,9 @@
- + diff --git a/apps/documenteditor/main/index_loader.html.deploy b/apps/documenteditor/main/index_loader.html.deploy index 3f42947d24..88dfd295c5 100644 --- a/apps/documenteditor/main/index_loader.html.deploy +++ b/apps/documenteditor/main/index_loader.html.deploy @@ -241,11 +241,12 @@ customer = params["customer"] ? ('
' + encodeUrlParam(params["customer"]) + '
') : '', margin = (customer !== '') ? 50 : 20, loading = 'Loading...', - logo = params["logo"] ? ((params["logo"] !== 'none') ? ('') : '') : null; + logo = params["logo"] ? ((params["logo"] !== 'none') ? ('') : '') : null, + isForm = params["isForm"]==='true'; window.frameEditorId = params["frameEditorId"]; window.parentOrigin = params["parentOrigin"]; - + window.isPDFForm = isForm; if ( lang == 'de') loading = 'Ladevorgang...'; else if ( lang == 'es') loading = 'Cargando...'; else if ( lang == 'fr') loading = 'Chargement en cours...'; @@ -290,7 +291,9 @@ - + - + - - + +
diff --git a/apps/common/main/index.html.deploy b/apps/common/index.html.deploy similarity index 72% rename from apps/common/main/index.html.deploy rename to apps/common/index.html.deploy index a0d1523a73..444d04e20e 100644 --- a/apps/common/main/index.html.deploy +++ b/apps/common/index.html.deploy @@ -5,7 +5,6 @@ -