From 7265b02b8513dcb18c5024fd97e4db37ad276894 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 18:02:10 +0300 Subject: [PATCH 1/8] [VE] Add embedded viewer --- apps/visioeditor/embed/index.html | 308 ++++++ apps/visioeditor/embed/index.html.deploy | 277 ++++++ apps/visioeditor/embed/index_loader.html | 390 ++++++++ .../embed/index_loader.html.deploy | 360 +++++++ .../embed/js/ApplicationController.js | 929 ++++++++++++++++++ apps/visioeditor/embed/js/ApplicationView.js | 78 ++ apps/visioeditor/embed/js/application.js | 37 + apps/visioeditor/embed/locale/en.json | 56 ++ .../embed/resources/less/application.less | 146 +++ 9 files changed, 2581 insertions(+) create mode 100644 apps/visioeditor/embed/index.html create mode 100644 apps/visioeditor/embed/index.html.deploy create mode 100644 apps/visioeditor/embed/index_loader.html create mode 100644 apps/visioeditor/embed/index_loader.html.deploy create mode 100644 apps/visioeditor/embed/js/ApplicationController.js create mode 100644 apps/visioeditor/embed/js/ApplicationView.js create mode 100644 apps/visioeditor/embed/js/application.js create mode 100644 apps/visioeditor/embed/locale/en.json create mode 100644 apps/visioeditor/embed/resources/less/application.less diff --git a/apps/visioeditor/embed/index.html b/apps/visioeditor/embed/index.html new file mode 100644 index 0000000000..3eb1e6b249 --- /dev/null +++ b/apps/visioeditor/embed/index.html @@ -0,0 +1,308 @@ + + + + + Documents + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+
+
+
+ + +
+
    +
    +
    + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/visioeditor/embed/index.html.deploy b/apps/visioeditor/embed/index.html.deploy new file mode 100644 index 0000000000..42fcb40fe1 --- /dev/null +++ b/apps/visioeditor/embed/index.html.deploy @@ -0,0 +1,277 @@ + + + + + Documents + + + + + + + + + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    + + +
    +
      +
      +
      + +
      + +
      + +
      +
      +
      +
      +
      + +
      +
      + + +
      +
      + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/visioeditor/embed/index_loader.html b/apps/visioeditor/embed/index_loader.html new file mode 100644 index 0000000000..7e51f1e95c --- /dev/null +++ b/apps/visioeditor/embed/index_loader.html @@ -0,0 +1,390 @@ + + + + + Documents + + + + + + + + + + + + + + + + + + + + + + + + + +
      +
      +
      +
      + + +
      +
        +
        +
        + +
        + +
        + +
        +
        +
        +
        +
        + +
        +
        + + +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/visioeditor/embed/index_loader.html.deploy b/apps/visioeditor/embed/index_loader.html.deploy new file mode 100644 index 0000000000..56505d66a9 --- /dev/null +++ b/apps/visioeditor/embed/index_loader.html.deploy @@ -0,0 +1,360 @@ + + + + + Documents + + + + + + + + + + + + + + + +
        +
        +
        +
        + + +
        +
          +
          +
          + +
          + +
          + +
          +
          +
          +
          +
          + +
          +
          + + +
          +
          + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/visioeditor/embed/js/ApplicationController.js b/apps/visioeditor/embed/js/ApplicationController.js new file mode 100644 index 0000000000..d698b07836 --- /dev/null +++ b/apps/visioeditor/embed/js/ApplicationController.js @@ -0,0 +1,929 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +VE.ApplicationController = new(function(){ + var me, + api, + config = {}, + docConfig = {}, + embedConfig = {}, + permissions = {}, + appOptions = {}, + maxPages = 0, + created = false, + currentPage = 0, + ttOffset = [5, -10], + labelDocName, + isRtlSheet = false, + requireUserAction = true; + + var LoadingDocument = -256; + + // Initialize analytics + // ------------------------- + +// Common.Analytics.initialize('UA-12442749-13', 'Embedded Draw Editor'); + + + // Check browser + // ------------------------- + + if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ + Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + return; + } + + common.localStorage.setId('text'); + common.localStorage.setKeysFilter('ve-,asc.visio'); + common.localStorage.sync(); + + // Handlers + // ------------------------- + + function loadConfig(data) { + config = $.extend(config, data.config); + embedConfig = $.extend(embedConfig, data.config.embedded); + + common.controller.modals.init(embedConfig); + // common.controller.SearchBar.init(embedConfig); + + // Docked toolbar + if (embedConfig.toolbarDocked === 'bottom') { + $('#toolbar').addClass('bottom'); + $('.viewer').addClass('bottom'); + $('#box-tools').removeClass('dropdown').addClass('dropup'); + ttOffset[1] = -40; + } else { + $('#toolbar').addClass('top'); + $('.viewer').addClass('top'); + } + + config.mode = 'view'; // always view for embedded + config.canCloseEditor = false; + var _canback = false; + if (typeof config.customization === 'object') { + if (typeof config.customization.goback == 'object' && config.canBackToFolder!==false) { + _canback = config.customization.close===undefined ? + config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose : + config.customization.goback.url && !config.customization.goback.requestClose; + + if (config.customization.goback.requestClose) + console.log("Obsolete: The 'requestClose' parameter of the 'customization.goback' section is deprecated. Please use 'close' parameter in the 'customization' section instead."); + } + if (config.customization.close && typeof config.customization.close === 'object') + config.canCloseEditor = (config.customization.close.visible!==false) && config.canRequestClose && !config.isDesktopApp; + } + config.canBackToFolder = !!_canback; + } + + function loadDocument(data) { + docConfig = data.doc; + + if (docConfig) { + permissions = $.extend(permissions, docConfig.permissions); + + var docInfo = new Asc.asc_CDocInfo(), + _user = new Asc.asc_CUserInfo(); + + var canRenameAnonymous = !((typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (config.customization.anonymous.request===false)), + guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && + (typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ? + common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest, + value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null, + user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous, + common.localStorage.getItem("guest-id") || ('uid-' + Date.now())); + user.anonymous && common.localStorage.setItem("guest-id", user.id); + + _user.put_Id(user.id); + _user.put_FullName(user.fullname); + _user.put_IsAnonymousUser(user.anonymous); + + docInfo.put_Id(docConfig.key); + docInfo.put_Url(docConfig.url); + docInfo.put_DirectUrl(docConfig.directUrl); + docInfo.put_Title(docConfig.title); + docInfo.put_Format(docConfig.fileType); + docInfo.put_VKey(docConfig.vkey); + docInfo.put_UserInfo(_user); + docInfo.put_CallbackUrl(config.callbackUrl); + docInfo.put_Token(docConfig.token); + docInfo.put_Permissions(docConfig.permissions); + docInfo.put_EncryptedInfo(config.encryptionKeys); + docInfo.put_Lang(config.lang); + docInfo.put_Mode(config.mode); + docInfo.put_Wopi(config.wopi); + config.shardkey && docInfo.put_Shardkey(config.shardkey); + + var enable = !config.customization || (config.customization.macros!==false); + docInfo.asc_putIsEnabledMacroses(!!enable); + enable = !config.customization || (config.customization.plugins!==false); + docInfo.asc_putIsEnabledPlugins(!!enable); + + if (api) { + api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); + // api.asc_registerCallback('asc_onRunAutostartMacroses', onRunAutostartMacroses); + api.asc_setDocInfo(docInfo); + api.asc_getEditorPermissions(config.licenseUrl, config.customerId); + api.asc_enableKeyEvents(true); + + Common.Analytics.trackEvent('Load', 'Start'); + } + + embedConfig.docTitle = docConfig.title; + labelDocName = $('#title-doc-name'); + labelDocName.text(embedConfig.docTitle || '') + } + } + + function onCurrentPage(number) { + currentPage = number; + setActiveWorkSheet(number); + } + + function setActiveWorkSheet(index) { + var $box = $('#worksheets'); + $box.find('> li').removeClass('active'); + $box.find('#worksheet' + index).addClass('active'); + } + + function onSheetsChanged(){ + maxPages = api.getCountPages(); + + var handleWorksheet = function(e){ + var $worksheet = $(this); + var index = $worksheet.attr('id').match(/\d+$/); + + if (index.length > 0) { + index = parseInt(index[0]); + + if (index > -1 && index < maxPages) + api.goToPage(index); + } + }; + + var $box = $('#worksheets'); + $box.find('li').off(); + $box.empty(); + + var tpl = '
        • {title}
        • '; + for (var i = 0; i < maxPages; i++) { + // escape html + var name = api.asc_getPageName(i) || me.txtPage + (i+1); + + var item = tpl + .replace(/\{index}/, i) + .replace(/\{tabtitle}/, name) + .replace(/\{title}/, name); + + $(item).appendTo($box).on('click', handleWorksheet); + } + + setActiveWorkSheet(currentPage); + } + + function setupScrollButtons() { + var $container = $('#worksheet-container'); + var $prevButton = $('#worksheet-list-button-prev'); + var $nextButton = $('#worksheet-list-button-next'); + var $box = $('#worksheets'); + + var handleScrollButtonsState = function() { + if ($container[0].scrollWidth > $container[0].clientWidth) { + var scrollLeft = $container.scrollLeft(); + var scrollWidth = $container[0].scrollWidth; + var containerWidth = $container.innerWidth(); + + if (isRtlSheet) { + if (Math.abs(scrollLeft) + containerWidth >= scrollWidth - 1) { + $prevButton.prop('disabled', false); + $nextButton.prop('disabled', true); + } else if (scrollLeft >= 0 ) { + $prevButton.prop('disabled', true); + $nextButton.prop('disabled', false); + } else { + $prevButton.prop('disabled', false); + $nextButton.prop('disabled', false); + } + } else { + if (scrollLeft === 0) { + $prevButton.prop('disabled', true); + $nextButton.prop('disabled', false); + } else if (scrollLeft + containerWidth >= scrollWidth) { + $prevButton.prop('disabled', false); + $nextButton.prop('disabled', true); + } else { + $prevButton.prop('disabled', false); + $nextButton.prop('disabled', false); + } + } + } else { + $prevButton.prop('disabled', true); + $nextButton.prop('disabled', true); + } + }; + + $container.on('scroll', handleScrollButtonsState); + $(window).on('resize', handleScrollButtonsState); + + handleScrollButtonsState(); + + var buttonWidth = $('.worksheet-list-buttons').outerWidth(); + + $prevButton.on('click', function() { + if (isRtlSheet) { + var rightBound = $container.width(); + $($box.children().get().reverse()).each(function () { + var $tab = $(this); + var right = common.utils.getPosition($tab).left + $tab.outerWidth() + buttonWidth; + + if (right > rightBound ) { + $container.scrollLeft($container.scrollLeft() + right - rightBound + ($container.width() > 400 ? 20 : 5)); + return false; + } + }); + } else { + $($box.children().get().reverse()).each(function () { + var $tab = $(this); + var left = common.utils.getPosition($tab).left - buttonWidth; + + if (left < 0) { + $container.scrollLeft($container.scrollLeft() + left - 26); + return false; + } + }); + } + }); + + $nextButton.on('click', function() { + if (isRtlSheet) { + $($box.children()).each(function () { + var $tab = $(this); + var left = common.utils.getPosition($tab).left - buttonWidth; + + if (left < 0) { + $container.scrollLeft($container.scrollLeft() + left - 26); + return false; + } + }); + } else { + var rightBound = $container.width(); + $box.children().each(function () { + var $tab = $(this); + var right = common.utils.getPosition($tab).left + $tab.outerWidth(); + + if (right > rightBound) { + $container.scrollLeft($container.scrollLeft() + right - rightBound + ($container.width() > 400 ? 20 : 5)); + return false; + } + }); + } + }); + } + + function onLongActionBegin(type, id) { + var text = ''; + switch (id) + { + case Asc.c_oAscAsyncAction['Print']: + text = me.downloadTextText; + break; + case LoadingDocument: + text = me.textLoadingDocument + ' '; + break; + default: + text = me.waitText; + break; + } + + if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { + if (!me.loadMask) + me.loadMask = new common.view.LoadMask(); + me.loadMask.setTitle(text); + me.loadMask.show(); + } + } + + function onLongActionEnd(){ + me.loadMask && me.loadMask.hide(); + } + + function onDocMouseMoveStart() { + me.isHideBodyTip = true; + } + + var $ttEl, $tooltip; + function onDocMouseMoveEnd() { + if (me.isHideBodyTip) { + if ( $tooltip ) { + $tooltip.tooltip('hide'); + $tooltip = false; + } + } + } + + function onDocMouseMove(data) { + if (data) { + if (data.get_Type() == 1) { // hyperlink + me.isHideBodyTip = false; + + if ( !$ttEl ) { + $ttEl = $('.hyperlink-tooltip'); + $ttEl.tooltip({'container':'body', 'trigger':'manual'}); + $ttEl.on('shown.bs.tooltip', function(e) { + $tooltip = $ttEl.data('bs.tooltip').tip(); + var pos = $ttEl.ttpos[1] - $tooltip.height() + ttOffset[1]; + (pos<0) && (pos = 0); + $tooltip.css({ + left: $ttEl.ttpos[0] + ttOffset[0], + top: pos + }); + + $tooltip.find('.tooltip-arrow').css({left: 10}); + }); + $ttEl.data('bs.tooltip').options.title = me.txtPressLink; + } + + if ( !$tooltip ) { + $ttEl.ttpos = [data.get_X(), data.get_Y()]; + $ttEl.tooltip('show'); + } else { + var pos = $ttEl.ttpos[1] - $tooltip.height() + ttOffset[1]; + (pos<0) && (pos = 0); + $tooltip.css({ + left:data.get_X() + ttOffset[0], + top:pos + }); + } + } + } + } + + function onDownloadUrl(url, fileType) { + Common.Gateway.downloadAs(url, fileType); + } + + function onPrint() { + if (permissions.print!==false) + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + } + + function onPrintUrl(url) { + common.utils.dialogPrint(url, api); + } + + function hidePreloader() { + $('#loading-mask').fadeOut('slow'); + } + + function onDocumentContentReady() { + api.SetDrawingFreeze(false); + hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + + var zf = (config.customization && config.customization.zoom ? parseInt(config.customization.zoom) : -1); + (zf == -1) ? api.zoomFitToPage() : ((zf == -2) ? api.zoomFitToWidth() : api.zoom(zf>0 ? zf : 100)); + + var dividers = $('#box-tools .divider'); + var itemsCount = $('#box-tools a').length; + + $('#idt-search').hide(); // TO DO: remove when search will be ready + itemsCount--; + + if ( permissions.print === false) { + $('#idt-print').hide(); + itemsCount--; + } + + if (!embedConfig.saveUrl || permissions.download === false) { + $('#idt-download').hide(); + itemsCount--; + } + + if ( !embedConfig.shareUrl ) { + $('#idt-share').hide(); + itemsCount--; + } + + if (!config.canBackToFolder) { + $('#idt-close').hide(); + itemsCount--; + } else { + var text = config.customization.goback.text; + text && (typeof text == 'string') && $('#idt-close .caption').text(text); + } + + if (config.canCloseEditor) { + $('#id-btn-close-editor').removeClass('hidden'); + } + + if (itemsCount < 7) { + $(dividers[0]).hide(); + $(dividers[1]).hide(); + } + + if ( !embedConfig.embedUrl ) { + $('#idt-embed').hide(); + itemsCount--; + } + + if ( !embedConfig.fullscreenUrl ) { + $('#idt-fullscreen').hide(); + itemsCount--; + } + + if (itemsCount < 1) + $('#box-tools').addClass('hidden'); + else if (!embedConfig.embedUrl && !embedConfig.fullscreenUrl) + $(dividers[2]).hide(); + + common.controller.modals.attach({ + share: '#idt-share', + embed: '#idt-embed' + }); + + api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart); + api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd); + api.asc_registerCallback('asc_onMouseMove', onDocMouseMove); + + api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); + api.asc_registerCallback('asc_onPrint', onPrint); + api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); + api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); + api.asc_registerCallback('asc_onStartAction', onLongActionBegin); + api.asc_registerCallback('asc_onEndAction', onLongActionEnd); + + Common.Gateway.on('processmouse', onProcessMouse); + Common.Gateway.on('downloadas', onDownloadAs); + Common.Gateway.on('requestclose', onRequestClose); + + VE.ApplicationView.tools.get('#idt-download') + .on('click', function(){ + if ( !!embedConfig.saveUrl && permissions.download !== false){ + common.utils.openLink(embedConfig.saveUrl); + } + + Common.Analytics.trackEvent('Save'); + }); + + VE.ApplicationView.tools.get('#idt-print') + .on('click', function(){ + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + Common.Analytics.trackEvent('Print'); + }); + + VE.ApplicationView.tools.get('#idt-close') + .on('click', function(){ + if (config.customization && config.customization.goback) { + if (config.customization.goback.requestClose && config.canRequestClose) + Common.Gateway.requestClose(); + else if (config.customization.goback.url) { + if (config.customization.goback.blank!==false) { + window.open(config.customization.goback.url, "_blank"); + } else { + window.parent.location.href = config.customization.goback.url; + } + } + } + }); + + $('#id-btn-close-editor').on('click', function(){ + config.canRequestClose && Common.Gateway.requestClose(); + }); + + // VE.ApplicationView.tools.get('#idt-search') + // .on('click', function(){ + // common.controller.SearchBar.show(); + // }); + + $('#id-btn-zoom-in').on('click', api.zoomIn.bind(this)); + $('#id-btn-zoom-out').on('click', api.zoomOut.bind(this)); + + var documentMoveTimer; + var ismoved = false; + $(document).mousemove(function(event) { + $('#id-btn-zoom-in').fadeIn(); + $('#id-btn-zoom-out').fadeIn(); + + ismoved = true; + if (!documentMoveTimer) { + documentMoveTimer = setInterval(function () { + if (!ismoved) { + $('#id-btn-zoom-in').fadeOut(); + $('#id-btn-zoom-out').fadeOut(); + clearInterval(documentMoveTimer); + documentMoveTimer = undefined; + } + + ismoved = false; + }, 2000); + } + }); + + var ismodalshown = false; + $(document.body).on('show.bs.modal', '.modal', + function(e) { + ismodalshown = true; + api.asc_enableKeyEvents(false); + } + ).on('hidden.bs.modal', '.modal', + function(e) { + ismodalshown = false; + api.asc_enableKeyEvents(true); + } + ).on('hidden.bs.dropdown', '.dropdown', + function(e) { + if ( !ismodalshown ) + api.asc_enableKeyEvents(true); + } + ).on('blur', 'input, textarea', + function(e) { + if ( !ismodalshown ) { + if (!/area_id/.test(e.target.id) ) { + api.asc_enableKeyEvents(true); + } + } + } + ); + + $('#editor_sdk').on('click', function(e) { + if ( e.target.localName == 'canvas' ) { + e.currentTarget.focus(); + } + }); + + Common.Gateway.documentReady(); + Common.Analytics.trackEvent('Load', 'Complete'); + requireUserAction = false; + onSheetsChanged(); + setupScrollButtons(); + } + + function onEditorPermissions(params) { + var licType = params.asc_getLicenseType(); + if (Asc.c_oLicenseResult.Expired === licType || Asc.c_oLicenseResult.Error === licType || Asc.c_oLicenseResult.ExpiredTrial === licType || + Asc.c_oLicenseResult.NotBefore === licType || Asc.c_oLicenseResult.ExpiredLimited === licType) { + $('#id-critical-error-title').text(Asc.c_oLicenseResult.NotBefore === licType ? me.titleLicenseNotActive : me.titleLicenseExp); + $('#id-critical-error-message').html(Asc.c_oLicenseResult.NotBefore === licType ? me.warnLicenseBefore : me.warnLicenseExp); + $('#id-critical-error-close').parent().remove(); + $('#id-critical-error-dialog').css('z-index', 20002).modal({backdrop: 'static', keyboard: false, show: true}); + return; + } + + appOptions.canBranding = params.asc_getCustomization(); + appOptions.canBranding && setBranding(config.customization); + + var $parent = labelDocName.parent(); + var _left_width = common.utils.getPosition($parent).left, + _right_width = $parent.next().outerWidth(); + + if ( _left_width < _right_width ) + $parent.css('padding-left', parseFloat($parent.css('padding-left')) + _right_width - _left_width); + else + $parent.css('padding-right', parseFloat($parent.css('padding-right')) + _left_width - _right_width); + + onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + api.asc_setViewMode(true); + api.asc_LoadDocument(); + api.Resize(); + } + + function onOpenDocument(progress) { + var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); + me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); + } + + function onAdvancedOptions(type, advOptions, mode, formatOptions) { + if (type == Asc.c_oAscAdvancedOptionsID.DRM) { + var isCustomLoader = !!config.customization.loaderName || !!config.customization.loaderLogo; + var submitPassword = function(val) { + api && api.asc_setAdvancedOptions(Asc.c_oAscAdvancedOptionsID.DRM, new Asc.asc_CDRMAdvancedOptions(val)); + me.loadMask && me.loadMask.show(); + if(!isCustomLoader) $('#loading-mask').removeClass("none-animation"); + }; + common.controller.modals.createDlgPassword(submitPassword); + if(isCustomLoader) hidePreloader(); + else $('#loading-mask').addClass("none-animation"); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + } + if (requireUserAction) { + Common.Gateway.userActionRequired(); + requireUserAction = false; + } + } + + function onError(id, level, errData) { + if (id == Asc.c_oAscError.ID.LoadingScriptError) { + $('#id-critical-error-title').text(me.criticalErrorTitle); + $('#id-critical-error-message').text(me.scriptLoadError); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + window.location.reload(); + }); + $('#id-critical-error-dialog').css('z-index', 20002).modal('show'); + return; + } + + hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + + var message; + + switch (id) + { + case Asc.c_oAscError.ID.Unknown: + message = me.unknownErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationTimeout: + message = me.convertationTimeoutText; + break; + + case Asc.c_oAscError.ID.ConvertationError: + message = me.convertationErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationOpenError: + message = me.openErrorText; + break; + + case Asc.c_oAscError.ID.DownloadError: + message = me.downloadErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationPassword: + message = me.errorFilePassProtect; + break; + + case Asc.c_oAscError.ID.UserDrop: + message = me.errorUserDrop; + break; + + case Asc.c_oAscError.ID.ConvertationOpenLimitError: + message = me.errorFileSizeExceed; + break; + + case Asc.c_oAscError.ID.UpdateVersion: + message = me.errorUpdateVersionOnDisconnect; + break; + + case Asc.c_oAscError.ID.AccessDeny: + message = me.errorAccessDeny; + break; + + case Asc.c_oAscError.ID.ForceSaveButton: + case Asc.c_oAscError.ID.ForceSaveTimeout: + message = me.errorForceSave; + break; + + case Asc.c_oAscError.ID.LoadingFontError: + message = me.errorLoadingFont; + break; + + case Asc.c_oAscError.ID.KeyExpire: + message = me.errorTokenExpire; + break; + + case Asc.c_oAscError.ID.VKeyEncrypt: + message= me.errorToken; + break; + + case Asc.c_oAscError.ID.ConvertationOpenFormat: + if (errData === 'pdf') + message = me.errorInconsistentExtPdf.replace('%1', docConfig.fileType || ''); + else if (errData === 'docx') + message = me.errorInconsistentExtDocx.replace('%1', docConfig.fileType || ''); + else if (errData === 'xlsx') + message = me.errorInconsistentExtXlsx.replace('%1', docConfig.fileType || ''); + else if (errData === 'pptx') + message = me.errorInconsistentExtPptx.replace('%1', docConfig.fileType || ''); + else + message = me.errorInconsistentExt; + break; + + case Asc.c_oAscError.ID.SessionToken: // don't show error message + return; + + case Asc.c_oAscError.ID.EditingError: + message = me.errorEditingDownloadas; + break; + + default: + // message = me.errorDefaultMessage.replace('%1', id); + // break; + return; + } + + if (level == Asc.c_oAscError.Level.Critical) { + + // report only critical errors + Common.Gateway.reportError(id, message); + + $('#id-critical-error-title').text(me.criticalErrorTitle); + $('#id-critical-error-message').html(message); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + window.location.reload(); + }); + } + else { + Common.Gateway.reportWarning(id, message); + + $('#id-critical-error-title').text(me.notcriticalErrorTitle); + $('#id-critical-error-message').html(message); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + $('#id-critical-error-dialog').modal('hide'); + }); + } + + $('#id-critical-error-dialog').modal('show'); + + Common.Analytics.trackEvent('Internal Error', id.toString()); + } + + function onExternalMessage(error) { + if (error) { + hidePreloader(); + $('#id-error-mask-title').text(me.criticalErrorTitle); + $('#id-error-mask-text').text(error.msg); + $('#id-error-mask').css('display', 'block'); + + Common.Analytics.trackEvent('External Error'); + } + } + + function onProcessMouse(data) { + if (data.type == 'mouseup') { + var e = document.getElementById('editor_sdk'); + if (e) { + var r = common.utils.getBoundingClientRect(e); + api.OnMouseUp( + data.x - r.left, + data.y - r.top + ); + } + } + } + + function onRequestClose() { + Common.Gateway.requestClose(); + } + + function onDownloadAs() { + if ( permissions.download === false) { + Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); + return; + } + if (api) { + var options = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.VSDX, true); + options.asc_setIsSaveAs(true); + api.asc_DownloadAs(options); + } + } + + function onRunAutostartMacroses() { + if (!config.customization || (config.customization.macros!==false)) + if (api) api.asc_runAutostartMacroses(); + } + + function onBeforeUnload () { + common.localStorage.save(); + } + + function setBranding(value) { + if ( value && value.logo) { + var logo = $('#header-logo'); + if (value.logo.visible===false) { + logo.addClass('hidden'); + return; + } + + if (value.logo.image || value.logo.imageEmbedded) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + + value.logo.imageEmbedded && console.log("Obsolete: The 'imageEmbedded' parameter of the 'customization.logo' section is deprecated. Please use 'image' parameter instead."); + } + + if (value.logo.url) { + logo.attr('href', value.logo.url); + } else if (value.logo.url!==undefined) { + logo.removeAttr('href');logo.removeAttr('target'); + } + } + } + // Helpers + // ------------------------- + + function onDocumentResize() { + if (api) { + api.Resize(); + } + } + + function createController(){ + if (created) + return me; + + me = this; + created = true; + + // popover ui handlers + + $(window).resize(function(){ + onDocumentResize(); + }); + window.onbeforeunload = onBeforeUnload; + + api = new Asc.VisioEditorApi({ + 'id-view' : 'editor_sdk', + 'embedded' : true + }); + + if (api){ + api.SetDrawingFreeze(true); + api.asc_registerCallback('asc_onError', onError); + api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); + api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); + api.asc_registerCallback('asc_onAdvancedOptions', onAdvancedOptions); + api.asc_registerCallback('asc_onCurrentPage', onCurrentPage); + + // Initialize api gateway + Common.Gateway.on('init', loadConfig); + Common.Gateway.on('opendocument', loadDocument); + Common.Gateway.on('showmessage', onExternalMessage); + Common.Gateway.appReady(); + + // common.controller.SearchBar.setApi(api); + } + + return me; + } + + return { + create : createController, + errorDefaultMessage : 'Error code: %1', + unknownErrorText : 'Unknown error.', + convertationTimeoutText : 'Conversion timeout exceeded.', + convertationErrorText : 'Conversion failed.', + downloadErrorText : 'Download failed.', + criticalErrorTitle : 'Error', + notcriticalErrorTitle : 'Warning', + scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.', + errorFilePassProtect: 'The file is password protected and cannot be opened.', + errorAccessDeny: 'You are trying to perform an action you do not have rights for.
          Please contact your Document Server administrator.', + errorUserDrop: 'The file cannot be accessed right now.', + unsupportedBrowserErrorText: 'Your browser is not supported.', + textOf: 'of', + downloadTextText: 'Downloading document...', + waitText: 'Please, wait...', + textLoadingDocument: 'Loading document', + txtClose: 'Close', + errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
          Please contact your Document Server administrator for details.', + errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
          Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', + textGuest: 'Guest', + textAnonymous: 'Anonymous', + errorForceSave: "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.", + errorLoadingFont: 'Fonts are not loaded.
          Please contact your Document Server administrator.', + errorTokenExpire: 'The document security token has expired.
          Please contact your Document Server administrator.', + openErrorText: 'An error has occurred while opening the file', + errorInconsistentExtDocx: 'An error has occurred while opening the file.
          The file content corresponds to text documents (e.g. docx), but the file has the inconsistent extension: %1.', + errorInconsistentExtXlsx: 'An error has occurred while opening the file.
          The file content corresponds to spreadsheets (e.g. xlsx), but the file has the inconsistent extension: %1.', + errorInconsistentExtPptx: 'An error has occurred while opening the file.
          The file content corresponds to presentations (e.g. pptx), but the file has the inconsistent extension: %1.', + errorInconsistentExtPdf: 'An error has occurred while opening the file.
          The file content corresponds to one of the following formats: pdf/djvu/xps/oxps, but the file has the inconsistent extension: %1.', + errorInconsistentExt: 'An error has occurred while opening the file.
          The file content does not match the file extension.', + titleLicenseExp: 'License expired', + titleLicenseNotActive: 'License not active', + warnLicenseBefore: 'License not active. Please contact your administrator.', + warnLicenseExp: 'Your license has expired. Please update your license and refresh the page.', + errorEditingDownloadas: 'An error occurred during the work with the document.
          Use the \'Download as...\' option to save the file backup copy to your computer hard drive.', + errorToken: 'The document security token is not correctly formed.
          Please contact your Document Server administrator.', + txtPressLink: 'Click the link to open it', + txtPage: 'Page' + } +})(); diff --git a/apps/visioeditor/embed/js/ApplicationView.js b/apps/visioeditor/embed/js/ApplicationView.js new file mode 100644 index 0000000000..dd6df8aeb1 --- /dev/null +++ b/apps/visioeditor/embed/js/ApplicationView.js @@ -0,0 +1,78 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +if (VE === undefined) { + var VE = {}; +} + +VE.ApplicationView = new(function(){ + var $btnTools; + + // Initialize view + + function createView(){ + $btnTools = $('#box-tools button'); + + $btnTools.addClass('dropdown-toggle').attr('data-toggle', 'dropdown').attr('aria-expanded', 'true'); + $btnTools.parent().append( + ''); + } + + function getTools(name) { + return $btnTools.parent().find(name); + } + + return { + create: createView + , tools: { + get: getTools + }, + + txtDownload: 'Download', + txtPrint: 'Print', + txtShare: 'Share', + txtEmbed: 'Embed', + txtFullScreen: 'Full Screen', + txtFileLocation: 'Open file location', + txtSearch: 'Search' + } +})(); diff --git a/apps/visioeditor/embed/js/application.js b/apps/visioeditor/embed/js/application.js new file mode 100644 index 0000000000..fe18b84c4a --- /dev/null +++ b/apps/visioeditor/embed/js/application.js @@ -0,0 +1,37 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +(function ($) { + Common.Locale.apply(function() { + VE.ApplicationView.create(); + VE.ApplicationController.create(); + }); +})(window.jQuery); diff --git a/apps/visioeditor/embed/locale/en.json b/apps/visioeditor/embed/locale/en.json new file mode 100644 index 0000000000..2a19c78b98 --- /dev/null +++ b/apps/visioeditor/embed/locale/en.json @@ -0,0 +1,56 @@ +{ + "common.view.modals.txtCopy": "Copy to clipboard", + "common.view.modals.txtEmbed": "Embed", + "common.view.modals.txtHeight": "Height", + "common.view.modals.txtIncorrectPwd": "Password is incorrect", + "common.view.modals.txtOpenFile": "Enter a password to open the file", + "common.view.modals.txtShare": "Share link", + "common.view.modals.txtTitleProtected": "Protected file", + "common.view.modals.txtWidth": "Width", + "common.view.SearchBar.textFind": "Find", + "VE.ApplicationController.convertationErrorText": "Conversion failed.", + "VE.ApplicationController.convertationTimeoutText": "Conversion timeout exceeded.", + "VE.ApplicationController.criticalErrorTitle": "Error", + "VE.ApplicationController.downloadErrorText": "Download failed.", + "VE.ApplicationController.downloadTextText": "Downloading document...", + "VE.ApplicationController.errorAccessDeny": "You are trying to perform an action you do not have rights for.
          Please contact your Document Server administrator.", + "VE.ApplicationController.errorDefaultMessage": "Error code: %1", + "VE.ApplicationController.errorEditingDownloadas": "An error occurred during the work with the document.
          Use the 'Download as' option to save the file backup copy to a drive.", + "VE.ApplicationController.errorFilePassProtect": "The file is password protected and cannot be opened.", + "VE.ApplicationController.errorFileSizeExceed": "The file size exceeds the limitation set for your server.
          Please contact your Document Server administrator for details.", + "VE.ApplicationController.errorForceSave": "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.", + "VE.ApplicationController.errorInconsistentExt": "An error has occurred while opening the file.
          The file content does not match the file extension.", + "VE.ApplicationController.errorInconsistentExtDocx": "An error has occurred while opening the file.
          The file content corresponds to text documents (e.g. docx), but the file has the inconsistent extension: %1.", + "VE.ApplicationController.errorInconsistentExtPdf": "An error has occurred while opening the file.
          The file content corresponds to one of the following formats: pdf/djvu/xps/oxps, but the file has the inconsistent extension: %1.", + "VE.ApplicationController.errorInconsistentExtPptx": "An error has occurred while opening the file.
          The file content corresponds to presentations (e.g. pptx), but the file has the inconsistent extension: %1.", + "VE.ApplicationController.errorInconsistentExtXlsx": "An error has occurred while opening the file.
          The file content corresponds to spreadsheets (e.g. xlsx), but the file has the inconsistent extension: %1.", + "VE.ApplicationController.errorLoadingFont": "Fonts are not loaded.
          Please contact your Document Server administrator.", + "VE.ApplicationController.errorToken": "The document security token is not correctly formed.
          Please contact your Document Server administrator.", + "VE.ApplicationController.errorTokenExpire": "The document security token has expired.
          Please contact your Document Server administrator.", + "VE.ApplicationController.errorUpdateVersionOnDisconnect": "Connection has been restored, and the file version has been changed.
          Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.", + "VE.ApplicationController.errorUserDrop": "The file cannot be accessed right now.", + "VE.ApplicationController.notcriticalErrorTitle": "Warning", + "VE.ApplicationController.openErrorText": "An error has occurred while opening the file.", + "VE.ApplicationController.scriptLoadError": "The connection is too slow, some of the components could not be loaded. Please reload the page.", + "VE.ApplicationController.textAnonymous": "Anonymous", + "VE.ApplicationController.textGuest": "Guest", + "VE.ApplicationController.textLoadingDocument": "Loading document", + "VE.ApplicationController.textOf": "of", + "VE.ApplicationController.titleLicenseExp": "License expired", + "VE.ApplicationController.titleLicenseNotActive": "License not active", + "VE.ApplicationController.txtClose": "Close", + "VE.ApplicationController.txtPressLink": "Click the link to open it", + "VE.ApplicationController.unknownErrorText": "Unknown error.", + "VE.ApplicationController.unsupportedBrowserErrorText": "Your browser is not supported.", + "VE.ApplicationController.waitText": "Please, wait...", + "VE.ApplicationController.warnLicenseBefore": "License not active. Please contact your administrator.", + "VE.ApplicationController.warnLicenseExp": "Your license has expired. Please update your license and refresh the page.", + "VE.ApplicationController.txtPage": "Page", + "VE.ApplicationView.txtDownload": "Download", + "VE.ApplicationView.txtEmbed": "Embed", + "VE.ApplicationView.txtFileLocation": "Open file location", + "VE.ApplicationView.txtFullScreen": "Full screen", + "VE.ApplicationView.txtPrint": "Print", + "VE.ApplicationView.txtSearch": "Find", + "VE.ApplicationView.txtShare": "Share" +} \ No newline at end of file diff --git a/apps/visioeditor/embed/resources/less/application.less b/apps/visioeditor/embed/resources/less/application.less new file mode 100644 index 0000000000..66510f1db8 --- /dev/null +++ b/apps/visioeditor/embed/resources/less/application.less @@ -0,0 +1,146 @@ +// Bootstrap core variables and mixins +@import "../../../../common/embed/resources/less/common.less"; + +.viewer { + display: flex; + flex-direction: column; + + .sdk-view { + position: relative; + flex-grow: 1; + } + + .worksheet-list-container { + display: flex; + border-top: 1px solid #cacaca; + background-color: #f7f7f7; + + .worksheet-list-buttons { + display: flex; + padding: 1px 12px; + height: 24px; + position: fixed; + background: #f7f7f7; + border-right: 1px solid #c0c0cd; + } + &.rtl-sheet .worksheet-list-buttons { + border-left: 1px solid #c0c0cd; + } + + @media screen and (min--moz-device-pixel-ratio:0) { + scrollbar-color: #e8e8e8 #eeeeee; + scrollbar-width: thin; + } + + &::-webkit-scrollbar-thumb { + height: 14px; + border: #c0c0c0 1px solid; + background-color: #e8e8e8; + background-position: center; + background-repeat: no-repeat; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13px' stroke ='rgb(173,173,173)' height='5px'>"); + } + + &:horizontal:increment:hover, &:horizontal:increment:active { + background-image: url("data:image/svg+xml;utf8,"); + } + + &:horizontal:decrement { + background-image: url("data:image/svg+xml;utf8,"); + } + + &:horizontal:decrement:hover, &:horizontal:decrement:active { + background-image: url("data:image/svg+xml;utf8,"); + } + } + + ul.worksheet-list { + background-color: #F7F7F7; + display: flex; + padding: 0; + margin: 0; + white-space: nowrap; + margin-left: 68px; + + li { + display: inline-block; + border-radius: 0; + padding: 0 10px 0; + line-height: 24px; + margin-right: -1px; + margin-left: 0; + border-right: 1px solid #cacaca; + border-left: 1px solid #cacaca; + color: rgba(0, 0, 0, 0.8); + font-size: 11px; + cursor: pointer; + letter-spacing: 0.01em; + text-align: center; + + &.active { + box-shadow: inset 0 4px 0 #444796; + background-color: #ffffff; + color: #000; + font-weight: bold; + } + + &::after { + content: attr(tabtitle); + font-weight: bold; + display: block; + height: 0; + color: transparent; + } + } + } + &.rtl-sheet ul.worksheet-list { + margin-right: 68px; + margin-left: 0; + } + } +} \ No newline at end of file From c5235e4cf1b4903bab41a0e7b56acfe474758416 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 18:20:53 +0300 Subject: [PATCH 2/8] [VE] Fix rtl --- apps/visioeditor/embed/js/ApplicationController.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/visioeditor/embed/js/ApplicationController.js b/apps/visioeditor/embed/js/ApplicationController.js index d698b07836..e4016bf695 100644 --- a/apps/visioeditor/embed/js/ApplicationController.js +++ b/apps/visioeditor/embed/js/ApplicationController.js @@ -168,6 +168,13 @@ VE.ApplicationController = new(function(){ setActiveWorkSheet(number); } + function updateRtlSheet() { + var $container = $('#worksheet-container'); + isRtlSheet = !common.utils.isIE && window.isRtl; + $container.toggleClass('rtl-sheet', isRtlSheet); + $container.attr({dir: isRtlSheet ? 'rtl' : 'ltr'}); + } + function setActiveWorkSheet(index) { var $box = $('#worksheets'); $box.find('> li').removeClass('active'); @@ -207,6 +214,7 @@ VE.ApplicationController = new(function(){ } setActiveWorkSheet(currentPage); + updateRtlSheet(); } function setupScrollButtons() { From 50ef2a965d68068efbc415f680ccf9a806402b41 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 18:50:18 +0300 Subject: [PATCH 3/8] [VE] Fix loading in embed mode --- apps/visioeditor/embed/js/ApplicationController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/visioeditor/embed/js/ApplicationController.js b/apps/visioeditor/embed/js/ApplicationController.js index e4016bf695..8421fdb9c2 100644 --- a/apps/visioeditor/embed/js/ApplicationController.js +++ b/apps/visioeditor/embed/js/ApplicationController.js @@ -412,7 +412,9 @@ VE.ApplicationController = new(function(){ } function onDocumentContentReady() { - api.SetDrawingFreeze(false); + api.ShowThumbnails(false); + api.Resize(); + hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); @@ -620,7 +622,6 @@ VE.ApplicationController = new(function(){ onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); api.asc_setViewMode(true); api.asc_LoadDocument(); - api.Resize(); } function onOpenDocument(progress) { @@ -874,7 +875,6 @@ VE.ApplicationController = new(function(){ }); if (api){ - api.SetDrawingFreeze(true); api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); From 52805127186348cdb021f4ed4bda43e76a3288ae Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 19:13:11 +0300 Subject: [PATCH 4/8] [VE] Refactoring --- apps/visioeditor/embed/index.html | 10 ++-- apps/visioeditor/embed/index.html.deploy | 10 ++-- apps/visioeditor/embed/index_loader.html | 10 ++-- .../embed/index_loader.html.deploy | 10 ++-- .../embed/js/ApplicationController.js | 55 +++++++++---------- .../embed/resources/less/application.less | 10 ++-- 6 files changed, 52 insertions(+), 53 deletions(-) diff --git a/apps/visioeditor/embed/index.html b/apps/visioeditor/embed/index.html index 3eb1e6b249..40ac7a82bc 100644 --- a/apps/visioeditor/embed/index.html +++ b/apps/visioeditor/embed/index.html @@ -195,14 +195,14 @@
          -
          -
          - -
          -
            +
              diff --git a/apps/visioeditor/embed/index.html.deploy b/apps/visioeditor/embed/index.html.deploy index 42fcb40fe1..5ef1e74f03 100644 --- a/apps/visioeditor/embed/index.html.deploy +++ b/apps/visioeditor/embed/index.html.deploy @@ -182,14 +182,14 @@
              -
              -
              - -
              -
                +
                  diff --git a/apps/visioeditor/embed/index_loader.html b/apps/visioeditor/embed/index_loader.html index 7e51f1e95c..d588405d20 100644 --- a/apps/visioeditor/embed/index_loader.html +++ b/apps/visioeditor/embed/index_loader.html @@ -285,14 +285,14 @@
                  -
                  -
                  - -
                  -
                    +
                      diff --git a/apps/visioeditor/embed/index_loader.html.deploy b/apps/visioeditor/embed/index_loader.html.deploy index 56505d66a9..357a287b0c 100644 --- a/apps/visioeditor/embed/index_loader.html.deploy +++ b/apps/visioeditor/embed/index_loader.html.deploy @@ -270,14 +270,14 @@
                      -
                      -
                      - -
                      -
                        +
                          diff --git a/apps/visioeditor/embed/js/ApplicationController.js b/apps/visioeditor/embed/js/ApplicationController.js index 8421fdb9c2..2185c82c69 100644 --- a/apps/visioeditor/embed/js/ApplicationController.js +++ b/apps/visioeditor/embed/js/ApplicationController.js @@ -42,7 +42,6 @@ VE.ApplicationController = new(function(){ currentPage = 0, ttOffset = [5, -10], labelDocName, - isRtlSheet = false, requireUserAction = true; var LoadingDocument = -256; @@ -165,28 +164,27 @@ VE.ApplicationController = new(function(){ function onCurrentPage(number) { currentPage = number; - setActiveWorkSheet(number); + setActivePage(number); } - function updateRtlSheet() { - var $container = $('#worksheet-container'); - isRtlSheet = !common.utils.isIE && window.isRtl; - $container.toggleClass('rtl-sheet', isRtlSheet); - $container.attr({dir: isRtlSheet ? 'rtl' : 'ltr'}); + function updateRtl() { + var $container = $('#pages-container'); + $container.toggleClass('rtl-sheet', window.isRtl); + $container.attr({dir: window.isRtl ? 'rtl' : 'ltr'}); } - function setActiveWorkSheet(index) { - var $box = $('#worksheets'); + function setActivePage(index) { + var $box = $('#id-pages'); $box.find('> li').removeClass('active'); - $box.find('#worksheet' + index).addClass('active'); + $box.find('#id-page' + index).addClass('active'); } - function onSheetsChanged(){ + function onPagesChanged(){ maxPages = api.getCountPages(); - var handleWorksheet = function(e){ - var $worksheet = $(this); - var index = $worksheet.attr('id').match(/\d+$/); + var handlePages = function(e){ + var $page = $(this); + var index = $page.attr('id').match(/\d+$/); if (index.length > 0) { index = parseInt(index[0]); @@ -196,11 +194,11 @@ VE.ApplicationController = new(function(){ } }; - var $box = $('#worksheets'); + var $box = $('#id-pages'); $box.find('li').off(); $box.empty(); - var tpl = '
                        • {title}
                        • '; + var tpl = '
                        • {title}
                        • '; for (var i = 0; i < maxPages; i++) { // escape html var name = api.asc_getPageName(i) || me.txtPage + (i+1); @@ -210,18 +208,19 @@ VE.ApplicationController = new(function(){ .replace(/\{tabtitle}/, name) .replace(/\{title}/, name); - $(item).appendTo($box).on('click', handleWorksheet); + $(item).appendTo($box).on('click', handlePages); } - setActiveWorkSheet(currentPage); - updateRtlSheet(); + setActivePage(currentPage); + updateRtl(); } function setupScrollButtons() { - var $container = $('#worksheet-container'); - var $prevButton = $('#worksheet-list-button-prev'); - var $nextButton = $('#worksheet-list-button-next'); - var $box = $('#worksheets'); + var $container = $('#pages-container'); + var $prevButton = $('#pages-list-button-prev'); + var $nextButton = $('#pages-list-button-next'); + var $box = $('#id-pages'); + var rtlPage = window.isRtl; var handleScrollButtonsState = function() { if ($container[0].scrollWidth > $container[0].clientWidth) { @@ -229,7 +228,7 @@ VE.ApplicationController = new(function(){ var scrollWidth = $container[0].scrollWidth; var containerWidth = $container.innerWidth(); - if (isRtlSheet) { + if (rtlPage) { if (Math.abs(scrollLeft) + containerWidth >= scrollWidth - 1) { $prevButton.prop('disabled', false); $nextButton.prop('disabled', true); @@ -263,10 +262,10 @@ VE.ApplicationController = new(function(){ handleScrollButtonsState(); - var buttonWidth = $('.worksheet-list-buttons').outerWidth(); + var buttonWidth = $('.pages-list-buttons').outerWidth(); $prevButton.on('click', function() { - if (isRtlSheet) { + if (rtlPage) { var rightBound = $container.width(); $($box.children().get().reverse()).each(function () { var $tab = $(this); @@ -291,7 +290,7 @@ VE.ApplicationController = new(function(){ }); $nextButton.on('click', function() { - if (isRtlSheet) { + if (rtlPage) { $($box.children()).each(function () { var $tab = $(this); var left = common.utils.getPosition($tab).left - buttonWidth; @@ -592,7 +591,7 @@ VE.ApplicationController = new(function(){ Common.Gateway.documentReady(); Common.Analytics.trackEvent('Load', 'Complete'); requireUserAction = false; - onSheetsChanged(); + onPagesChanged(); setupScrollButtons(); } diff --git a/apps/visioeditor/embed/resources/less/application.less b/apps/visioeditor/embed/resources/less/application.less index 66510f1db8..e1810fe233 100644 --- a/apps/visioeditor/embed/resources/less/application.less +++ b/apps/visioeditor/embed/resources/less/application.less @@ -10,12 +10,12 @@ flex-grow: 1; } - .worksheet-list-container { + .pages-list-container { display: flex; border-top: 1px solid #cacaca; background-color: #f7f7f7; - .worksheet-list-buttons { + .pages-list-buttons { display: flex; padding: 1px 12px; height: 24px; @@ -23,7 +23,7 @@ background: #f7f7f7; border-right: 1px solid #c0c0cd; } - &.rtl-sheet .worksheet-list-buttons { + &.rtl-sheet .pages-list-buttons { border-left: 1px solid #c0c0cd; } @@ -99,7 +99,7 @@ } } - ul.worksheet-list { + ul.pages-list { background-color: #F7F7F7; display: flex; padding: 0; @@ -138,7 +138,7 @@ } } } - &.rtl-sheet ul.worksheet-list { + &.rtl-sheet ul.pages-list { margin-right: 68px; margin-left: 0; } From 16c87474c8a3bf844f854ad0927b46c3d1e9ca73 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 19:13:37 +0300 Subject: [PATCH 5/8] [VE embed] Fix build --- build/visioeditor.json | 67 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/build/visioeditor.json b/build/visioeditor.json index 08bf6e3672..e6eef877e2 100644 --- a/build/visioeditor.json +++ b/build/visioeditor.json @@ -315,11 +315,76 @@ ] } }, + "embed": { + "clean": { + "prebuild": [ + "../deploy/web-apps/apps/visioeditor/embed" + ], + "postbuild": [ + "../deploy/web-apps/apps/visioeditor/embed/resources/img" + ] + }, + "js": { + "src": [ + "../apps/common/locale.js", + "../apps/common/Gateway.js", + "../apps/common/Analytics.js", + "../apps/common/main/lib/mods/dropdown.js", + "../apps/common/main/lib/mods/modal.js", + "../apps/common/main/lib/mods/tooltip.js", + "../apps/common/embed/lib/util/LocalStorage.js", + "../apps/common/embed/lib/util/utils.js", + "../apps/common/embed/lib/view/LoadMask.js", + "../apps/common/embed/lib/view/modals.js", + "../apps/common/embed/lib/controller/modals.js", + "../apps/visioeditor/embed/js/ApplicationView.js", + "../apps/visioeditor/embed/js/ApplicationController.js", + "../apps/visioeditor/embed/js/application.js" + ], + "dist": "../deploy/web-apps/apps/visioeditor/embed/app-all.js" + }, + "less": { + "files": { + "src": "../apps/visioeditor/embed/resources/less/application.less", + "dist": "../deploy/web-apps/apps/visioeditor/embed/resources/css/app-all.css" + } + }, + "copy": { + "localization": [ + { + "expand": true, + "cwd": "../apps/visioeditor/embed/locale/", + "src": "*", + "dest": "../deploy/web-apps/apps/visioeditor/embed/locale/" + } + ], + "indexhtml": [ + { + "expand": true, + "cwd": "../apps/visioeditor/embed", + "src": [ + "*.html.deploy" + ], + "ext": ".html", + "dest": "../deploy/web-apps/apps/visioeditor/embed" + } + ], + "images-app": [ + { + "expand": true, + "cwd": "../apps/common/embed/resources/img/", + "src": "**", + "dest": "../deploy/web-apps/apps/visioeditor/embed/resources/img/" + } + ] + } + }, "tasks": { "deploy": [ "increment-build", "deploy-app-main", - "deploy-app-mobile" + "deploy-app-mobile", + "deploy-app-embed" ] } } \ No newline at end of file From d7105756a48d3d4058941e7c5a50be609a1d24af Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 19:36:10 +0300 Subject: [PATCH 6/8] [VE] Add translation --- apps/visioeditor/embed/locale/ar.json | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 apps/visioeditor/embed/locale/ar.json diff --git a/apps/visioeditor/embed/locale/ar.json b/apps/visioeditor/embed/locale/ar.json new file mode 100644 index 0000000000..0cc6447cac --- /dev/null +++ b/apps/visioeditor/embed/locale/ar.json @@ -0,0 +1,55 @@ +{ + "common.view.modals.txtCopy": "نسخ إلى الحافظة", + "common.view.modals.txtEmbed": "تضمين", + "common.view.modals.txtHeight": "طول", + "common.view.modals.txtIncorrectPwd": "كلمة المرور غير صحيحة", + "common.view.modals.txtOpenFile": "أدخل كلمة المرور لفتح الملف", + "common.view.modals.txtShare": "مشاركة الرابط", + "common.view.modals.txtTitleProtected": "ملف محمي", + "common.view.modals.txtWidth": "العرض", + "common.view.SearchBar.textFind": "بحث", + "VE.ApplicationController.convertationErrorText": "فشل التحويل.", + "VE.ApplicationController.convertationTimeoutText": "استغرق التحويل وقتا طويلا تم تجاوز المهلة", + "VE.ApplicationController.criticalErrorTitle": "خطأ", + "VE.ApplicationController.downloadErrorText": "فشل التنزيل", + "VE.ApplicationController.downloadTextText": "يتم تحميل المستند", + "VE.ApplicationController.errorAccessDeny": "أنت تحاول تنفيذ إجراء ليس لديك صلاحيات تنفيذه.
                          الرجاء الاتصال بمسؤول خادم المستندات.", + "VE.ApplicationController.errorDefaultMessage": "رمز الخطأ: 1%", + "VE.ApplicationController.errorEditingDownloadas": "حدث خطأ اثناء العمل على المستند.
                          استخدم خيار 'التنزيل كـ' لحفظ نسخة احتياطية من الملف ", + "VE.ApplicationController.errorFilePassProtect": "الملف محمي بكلمة مرور ولا يمكن فتحه.", + "VE.ApplicationController.errorFileSizeExceed": "يتجاوز حجم الملف الحد المحدد في الخادم.
                          يُرجى الاتصال بمسؤول خادم المستندات.", + "VE.ApplicationController.errorForceSave": "حدث خطأ أثناء حفظ الملف.
                          استخدم خيار 'التنزيل كـ'لحفظ نسخة احتياطية من الملف ثم حاول مرة أخرى لاحقا.", + "VE.ApplicationController.errorInconsistentExt": "حدث خطأ أثناء فتح الملف.
                          محتوى الملف لا يطابق الامتداد", + "VE.ApplicationController.errorInconsistentExtDocx": "حدث خطأ أثناء فتح الملف.
                          محتوى الملف متوافق مع المستندات النصية (docx مثلا),لكن الامتداد الحالي(%1) غير متوافق مع المحتوى", + "VE.ApplicationController.errorInconsistentExtPdf": "حدث خطأ أثناء فتح الملف.
                          محتوى الملف متوافق مع أحد الامتدادات التالية:pdf/djvu/xps/oxps,لكن الامتداد الحالي(%1) غير متوافق مع المحتوى", + "VE.ApplicationController.errorInconsistentExtPptx": "حدث خطأ أثناء فتح الملف.
                          محتوى الملف متوافق مع العروض التقديمية(pptx مثلا),لكن الامتداد الحالي(%1) غير متوافق مع المحتوى", + "VE.ApplicationController.errorInconsistentExtXlsx": "حدث خطأ أثناء فتح الملف.
                          محتوى الملف متوافق مع الجداول الحسابية(xlsx مثلا),لكن الامتداد الحالي(%1) غير متوافق مع المحتوى", + "VE.ApplicationController.errorLoadingFont": "لم يتم تحميل الخطوط.
                          الرجاء الاتصال بمسؤول خادم المستندات.", + "VE.ApplicationController.errorToken": "لم يتم تكوين رمز امان المستند بشكل صحيح.
                          برجاء التواصل مع مسئولك", + "VE.ApplicationController.errorTokenExpire": "انتهت صلاحية رمز الأمان الخاص بالمستند.
                          يُرجى الاتصال بمسؤول خادم المستندات.", + "VE.ApplicationController.errorUpdateVersionOnDisconnect": "تم استعادة الاتصال بالإنترنت ، وتم تغيير إصدار الملف.
                          قبل أن تتمكن من متابعة العمل، تحتاج إلى تنزيل الملف أو نسخ محتوياته للتأكد من عدم فقدان أي شيء، ثم إعادة تحميل هذه الصفحة.", + "VE.ApplicationController.errorUserDrop": "لا يمكن الوصول إلى الملف حاليا.", + "VE.ApplicationController.notcriticalErrorTitle": "تحذير", + "VE.ApplicationController.openErrorText": "حدث خطأ أثناء فتح الملف.", + "VE.ApplicationController.scriptLoadError": "الاتصال بطيء جدًا ولا يمكن تحميل بعض المكونات. يُرجى إعادة تحميل الصفحة.", + "VE.ApplicationController.textAnonymous": "مجهول", + "VE.ApplicationController.textGuest": "ضيف", + "VE.ApplicationController.textLoadingDocument": "يتم تحميل المستند", + "VE.ApplicationController.textOf": "من", + "VE.ApplicationController.titleLicenseExp": "الترخيص منتهي الصلاحية", + "VE.ApplicationController.titleLicenseNotActive": "الترخيص غير مُفعّل", + "VE.ApplicationController.txtClose": "إغلاق", + "VE.ApplicationController.unknownErrorText": "خطأ غير محدد.", + "VE.ApplicationController.unsupportedBrowserErrorText": "المتصفح المستخدم غير مدعوم.", + "VE.ApplicationController.waitText": "يُرجى الانتظار...", + "VE.ApplicationController.warnLicenseBefore": "الترخيص غير مُفعّل، يُرجى التواصل مع مسؤول الخادم.", + "VE.ApplicationController.warnLicenseExp": "إنتهت صلاحية الترخيص. قم بتحديث الترخيص وبعدها قم بتحديث الصفحة.", + "VE.ApplicationController.txtPage": "Page", + "VE.ApplicationView.txtDownload": "تنزيل", + "VE.ApplicationView.txtEmbed": "تضمين", + "VE.ApplicationView.txtFileLocation": "فتح موقع الملف", + "VE.ApplicationView.txtFullScreen": "ملء الشاشة", + "VE.ApplicationView.txtPrint": "طباعة", + "VE.ApplicationView.txtSearch": "إيجاد", + "VE.ApplicationView.txtShare": "مشاركة" +} \ No newline at end of file From 6a0be6616d3c44f6249c8ee023b4f86fd3eb6914 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 19:36:50 +0300 Subject: [PATCH 7/8] [VE] Fix translation --- apps/visioeditor/main/app/view/Statusbar.js | 6 +++--- apps/visioeditor/main/locale/en.json | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/visioeditor/main/app/view/Statusbar.js b/apps/visioeditor/main/app/view/Statusbar.js index eb8f391513..b84f0e8fe0 100644 --- a/apps/visioeditor/main/app/view/Statusbar.js +++ b/apps/visioeditor/main/app/view/Statusbar.js @@ -508,9 +508,9 @@ define([ tipZoomFactor : 'Magnification', txtPage : 'Page', sheetIndexText : 'Page {0} of {1}', - tipPrev : 'Previous Page', - tipNext : 'Next Page', - tipListOfSheets : 'List of Page', + tipPrev : 'Previous page', + tipNext : 'Next page', + tipListOfSheets : 'List of pages' }, VE.Views.Statusbar || {})); } diff --git a/apps/visioeditor/main/locale/en.json b/apps/visioeditor/main/locale/en.json index 44f3ecf99e..fc358b9124 100644 --- a/apps/visioeditor/main/locale/en.json +++ b/apps/visioeditor/main/locale/en.json @@ -397,6 +397,11 @@ "VE.Views.Statusbar.tipZoomFactor": "Zoom", "VE.Views.Statusbar.tipZoomIn": "Zoom in", "VE.Views.Statusbar.tipZoomOut": "Zoom out", + "VE.Views.Statusbar.txtPage": "Page", + "VE.Views.Statusbar.sheetIndexText": "Page {0} of {1}", + "VE.Views.Statusbar.tipPrev": "Previous page", + "VE.Views.Statusbar.tipNext": "Next page", + "VE.Views.Statusbar.tipListOfSheets": "List of pages", "VE.Views.Toolbar.textTabFile": "File", "VE.Views.Toolbar.textTabView": "View", "VE.Views.ViewTab.textAlwaysShowToolbar": "Always Show Toolbar", From c46b21b3e7d77da94ad4974f68ff4f2ed99fda99 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 13 Dec 2024 19:44:41 +0300 Subject: [PATCH 8/8] Fix loading --- apps/documenteditor/embed/index_loader.html | 1 - apps/presentationeditor/embed/index_loader.html | 1 - apps/spreadsheeteditor/embed/index_loader.html | 1 - apps/visioeditor/embed/index_loader.html | 1 - 4 files changed, 4 deletions(-) diff --git a/apps/documenteditor/embed/index_loader.html b/apps/documenteditor/embed/index_loader.html index b5c9ad1707..e9b7270d7b 100644 --- a/apps/documenteditor/embed/index_loader.html +++ b/apps/documenteditor/embed/index_loader.html @@ -338,7 +338,6 @@

                          - diff --git a/apps/presentationeditor/embed/index_loader.html b/apps/presentationeditor/embed/index_loader.html index f9b0a6b1f0..319e39781b 100644 --- a/apps/presentationeditor/embed/index_loader.html +++ b/apps/presentationeditor/embed/index_loader.html @@ -333,7 +333,6 @@

                          - diff --git a/apps/spreadsheeteditor/embed/index_loader.html b/apps/spreadsheeteditor/embed/index_loader.html index bd321d5fdd..c9ac59422b 100644 --- a/apps/spreadsheeteditor/embed/index_loader.html +++ b/apps/spreadsheeteditor/embed/index_loader.html @@ -340,7 +340,6 @@

                          - diff --git a/apps/visioeditor/embed/index_loader.html b/apps/visioeditor/embed/index_loader.html index d588405d20..243d3dff70 100644 --- a/apps/visioeditor/embed/index_loader.html +++ b/apps/visioeditor/embed/index_loader.html @@ -339,7 +339,6 @@

                          -