@configuratorware/configurator-frontendgui 1.28.4 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App/Constant.js +73 -0
- package/App/Error/DevelopmentErrorPage/index.js +74 -0
- package/App/Error/ErrorBoundary.js +98 -0
- package/App/Error/ProductionErrorPage/Style.scss +47 -0
- package/App/Error/ProductionErrorPage/index.js +43 -0
- package/App/Error/ProductionErrorPage/index.story.js +13 -0
- package/App/Error/ProductionErrorPage/res/error_gears.png +0 -0
- package/App/Frame.js +95 -0
- package/App/Modules/Creator/Components/ConfigurationvariantItem/Styles.scss +33 -0
- package/App/Modules/Creator/Components/ConfigurationvariantItem/index.js +118 -0
- package/App/Modules/Creator/Components/ConfigurationvariantSelection/Styles.scss +47 -0
- package/App/Modules/Creator/Components/ConfigurationvariantSelection/index.js +130 -0
- package/App/Modules/Creator/Components/CustomTitleEditor/Styles.scss +43 -0
- package/App/Modules/Creator/Components/CustomTitleEditor/index.js +144 -0
- package/App/Modules/Creator/Components/ExternalVisualization/index.js +140 -0
- package/App/Modules/Creator/Components/FastConfiguration/SelectableRow.js +128 -0
- package/App/Modules/Creator/Components/FastConfiguration/Styles.scss +53 -0
- package/App/Modules/Creator/Components/FastConfiguration/index.js +280 -0
- package/App/Modules/Creator/Components/FastConfigurationRow/Styles.scss +45 -0
- package/App/Modules/Creator/Components/FastConfigurationRow/index.js +78 -0
- package/App/Modules/Creator/Components/FastConfigurationSelect/Styles.scss +35 -0
- package/App/Modules/Creator/Components/FastConfigurationSelect/index.js +251 -0
- package/App/Modules/Creator/Components/FormattedNumber/index.js +45 -0
- package/App/Modules/Creator/Components/FormattedPrice/index.js +57 -0
- package/App/Modules/Creator/Components/FullScreenView/FullScreenView.js +104 -0
- package/App/Modules/Creator/Components/Incompatibility/OptionRule/index.js +182 -0
- package/App/Modules/Creator/Components/Incompatibility/RuleComponent.js +88 -0
- package/App/Modules/Creator/Components/Incompatibility/index.js +251 -0
- package/App/Modules/Creator/Components/InvalidConfigurationNotice/index.js +164 -0
- package/App/Modules/Creator/Components/LoginForm/Styles.scss +9 -0
- package/App/Modules/Creator/Components/LoginForm/index.js +129 -0
- package/App/Modules/Creator/Components/Option/index.js +545 -0
- package/App/Modules/Creator/Components/Option/index.story.js +154 -0
- package/App/Modules/Creator/Components/OptionAmount/index.js +236 -0
- package/App/Modules/Creator/Components/OptionGroup/index.js +55 -0
- package/App/Modules/Creator/Components/Optiondetail/ZoomImage/index.js +173 -0
- package/App/Modules/Creator/Components/Optiondetail/index.js +499 -0
- package/App/Modules/Creator/Components/Optiondetail/index.story.js +117 -0
- package/App/Modules/Creator/Components/OptionsList/index.js +193 -0
- package/App/Modules/Creator/Components/Price/Styles.scss +3 -0
- package/App/Modules/Creator/Components/Price/index.js +79 -0
- package/App/Modules/Creator/Components/ProductPart/index.js +185 -0
- package/App/Modules/Creator/Components/ProductPart/index.story.js +88 -0
- package/App/Modules/Creator/Components/ProductPartsList/index.js +150 -0
- package/App/Modules/Creator/Components/ProductPartsList/index.story.js +101 -0
- package/App/Modules/Creator/Components/SavedConfiguration/Styles.scss +19 -0
- package/App/Modules/Creator/Components/SavedConfiguration/index.js +82 -0
- package/App/Modules/Creator/Components/ShareConfiguration/Styles.scss +23 -0
- package/App/Modules/Creator/Components/ShareConfiguration/index.js +224 -0
- package/App/Modules/Creator/Components/StockInformation/index.js +93 -0
- package/App/Modules/Creator/Components/StoreConfigurationForm/Styles.scss +5 -0
- package/App/Modules/Creator/Components/StoreConfigurationForm/index.js +123 -0
- package/App/Modules/Creator/Components/Tools/Styles.scss +44 -0
- package/App/Modules/Creator/Components/Tools/index.js +102 -0
- package/App/Modules/Creator/Components/ValidationResult/Styles.scss +45 -0
- package/App/Modules/Creator/Components/ValidationResult/index.js +165 -0
- package/App/Modules/Creator/Components/index.js +84 -0
- package/App/Modules/Creator/Containers/AmountPrice/index.js +26 -0
- package/App/Modules/Creator/Containers/ConfigurationvariantSelection/index.js +60 -0
- package/App/Modules/Creator/Containers/CustomTitleEditor/index.js +52 -0
- package/App/Modules/Creator/Containers/FastConfiguration/index.js +62 -0
- package/App/Modules/Creator/Containers/FormattedPrice/index.js +31 -0
- package/App/Modules/Creator/Containers/Incompatibility/index.js +40 -0
- package/App/Modules/Creator/Containers/InvalidConfigurationNotice/index.js +89 -0
- package/App/Modules/Creator/Containers/LoadingOverlay/index.js +26 -0
- package/App/Modules/Creator/Containers/Optiondetail/index.js +48 -0
- package/App/Modules/Creator/Containers/OptionsList/index.js +49 -0
- package/App/Modules/Creator/Containers/ProductPart/index.js +26 -0
- package/App/Modules/Creator/Containers/ProductPartsList/index.js +49 -0
- package/App/Modules/Creator/Containers/SavedConfigurationContainer/index.js +25 -0
- package/App/Modules/Creator/Containers/ShareConfiguration/index.js +42 -0
- package/App/Modules/Creator/Containers/StockInformation/index.js +33 -0
- package/App/Modules/Creator/Containers/Tools/index.js +44 -0
- package/App/Modules/Creator/Containers/ValidationResult/index.js +34 -0
- package/App/Modules/Creator/Containers/index.js +175 -0
- package/App/Modules/Creator/CreatorScreen.js +307 -0
- package/App/Modules/Creator/Layouts/DefaultLayout.js +260 -0
- package/App/Modules/Creator/Styles.scss +216 -0
- package/App/Modules/Designer/Components/AddGalleryImage/index.js +234 -0
- package/App/Modules/Designer/Components/AddGalleryImage/index.story.js +94 -0
- package/App/Modules/Designer/Components/AddGalleryImage/index.test.js +151 -0
- package/App/Modules/Designer/Components/AddVisualElement/Styles.scss +0 -0
- package/App/Modules/Designer/Components/AddVisualElement/index.js +278 -0
- package/App/Modules/Designer/Components/AddVisualElement/index.story.js +24 -0
- package/App/Modules/Designer/Components/AddVisualElement/index.test.js +47 -0
- package/App/Modules/Designer/Components/CloseDesignEditor/index.js +130 -0
- package/App/Modules/Designer/Components/CloseGraphicsEditorButton/index.js +54 -0
- package/App/Modules/Designer/Components/ColorPalettes/ColorPalettesSearch.js +175 -0
- package/App/Modules/Designer/Components/ColorPalettes/index.js +814 -0
- package/App/Modules/Designer/Components/ColorPalettes/index.story.js +158 -0
- package/App/Modules/Designer/Components/ColorPalettes/index.test.js +150 -0
- package/App/Modules/Designer/Components/DesignAreaControlbox/Styles.scss +0 -0
- package/App/Modules/Designer/Components/DesignAreaControlbox/index.js +467 -0
- package/App/Modules/Designer/Components/DesignAreaControlbox/index.story.js +272 -0
- package/App/Modules/Designer/Components/DesignAreaControlbox/index.test.js +164 -0
- package/App/Modules/Designer/Components/DesignerSelectionToolbox/CustomFontOverlay.js +162 -0
- package/App/Modules/Designer/Components/DesignerSelectionToolbox/DesignerSelectionToolbox.js +425 -0
- package/App/Modules/Designer/Components/DesignerSelectionToolbox/fontItemUtils.js +48 -0
- package/App/Modules/Designer/Components/Dialog/index.js +125 -0
- package/App/Modules/Designer/Components/EditDesignButton/index.js +128 -0
- package/App/Modules/Designer/Components/FeedbackNotice/index.js +110 -0
- package/App/Modules/Designer/Components/FeedbackNotice/index.test.js +16 -0
- package/App/Modules/Designer/Components/FullScreenView/FullScreenView.js +63 -0
- package/App/Modules/Designer/Components/ImageColorPicker/ImageColorPicker.dev.js +32 -0
- package/App/Modules/Designer/Components/ImageColorPicker/ImageColorPicker.js +430 -0
- package/App/Modules/Designer/Components/ImageColorize/index.js +636 -0
- package/App/Modules/Designer/Components/ImageColorize/index.story.js +73 -0
- package/App/Modules/Designer/Components/ImageControlbox/index.js +302 -0
- package/App/Modules/Designer/Components/ImageEditDialog/ImageThumbnail.js +171 -0
- package/App/Modules/Designer/Components/ImageEditDialog/ImageUpload.js +478 -0
- package/App/Modules/Designer/Components/ImageEditDialog/index.js +716 -0
- package/App/Modules/Designer/Components/ImageEditDialog/res/baseline_colorize_black_24dp.png +0 -0
- package/App/Modules/Designer/Components/ImageEditDialog/res/checkers_tile.png +0 -0
- package/App/Modules/Designer/Components/ImageLibraryFilter/index.js +179 -0
- package/App/Modules/Designer/Components/ImageLibraryThumbnail/Styles.scss +14 -0
- package/App/Modules/Designer/Components/ImageLibraryThumbnail/index.js +165 -0
- package/App/Modules/Designer/Components/ObjectTools/index.js +146 -0
- package/App/Modules/Designer/Components/Select/index.js +171 -0
- package/App/Modules/Designer/Components/TextControlbox/TextFormatIcon.js +48 -0
- package/App/Modules/Designer/Components/TextControlbox/index.js +656 -0
- package/App/Modules/Designer/Components/TextControlbox/index.story.js +109 -0
- package/App/Modules/Designer/Components/TextControlbox/index.test.js +172 -0
- package/App/Modules/Designer/Containers/AddGalleryImage.js +90 -0
- package/App/Modules/Designer/Containers/AddVisualElement.js +166 -0
- package/App/Modules/Designer/Containers/CloseDesignEditor.js +32 -0
- package/App/Modules/Designer/Containers/CloseGraphicsEditorButton.js +32 -0
- package/App/Modules/Designer/Containers/ColorPalettes.js +145 -0
- package/App/Modules/Designer/Containers/DesignAreaControlbox.js +54 -0
- package/App/Modules/Designer/Containers/Designer.js +37 -0
- package/App/Modules/Designer/Containers/DesignerSelectionToolbox.js +116 -0
- package/App/Modules/Designer/Containers/EditDesignButton.js +35 -0
- package/App/Modules/Designer/Containers/ImageEditDialog.js +1130 -0
- package/App/Modules/Designer/Designer.js +231 -0
- package/App/Modules/Designer/DesignerScreen.js +255 -0
- package/App/Modules/Designer/DesignerUI.js +241 -0
- package/App/Modules/Designer/Layouts/DefaultLayout.js +221 -0
- package/App/Modules/Designer/Layouts/Mobile/TwoSideBottomBar.js +50 -0
- package/App/Modules/Designer/Layouts/PopupAreaProvider.js +186 -0
- package/App/Modules/Designer/MultilayerComponents/DesignerClickAwayListener.js +53 -0
- package/App/Modules/Designer/MultilayerComponents/InlineToolboxPortal.js +106 -0
- package/App/Modules/Designer/MultilayerComponents/StandardToolboxPortal.js +64 -0
- package/App/Modules/Designer/Utils/FontFaceRepository.js +82 -0
- package/App/Modules/Designer/Utils/ImageEditUtils.js +104 -0
- package/App/Modules/Designer/Utils/Transformers.js +164 -0
- package/App/Modules/Designer/setupDesigner.js +182 -0
- package/App/Modules/Designer/withActiveCanvas.js +136 -0
- package/App/Modules/Visualization/AlignTargetContainer.js +55 -0
- package/App/Modules/Visualization/CreatorAlignTarget.js +41 -0
- package/App/Modules/Visualization/DefaultVisualizationProvider.js +105 -0
- package/App/Modules/Visualization/DesignerAlignTarget.js +45 -0
- package/App/Modules/Visualization/Utils/getFirstDataURLFromScreenshotsObj.js +20 -0
- package/App/Reducers/Actions.js +297 -0
- package/App/Reducers/ConfigurationMode/Actions.js +21 -0
- package/App/Reducers/ConfigurationMode/Reducer.js +80 -0
- package/App/Reducers/ConfigurationMode/Selectors.js +84 -0
- package/App/Reducers/Configurator/Actions.js +1417 -0
- package/App/Reducers/Configurator/AttributeSelectors.js +32 -0
- package/App/Reducers/Configurator/Modifiers.js +35 -0
- package/App/Reducers/Configurator/Reducer.js +639 -0
- package/App/Reducers/Configurator/Selectors.js +242 -0
- package/App/Reducers/Confirm/Actions.js +84 -0
- package/App/Reducers/Confirm/Reducer.js +30 -0
- package/App/Reducers/DesignArea/Actions.js +76 -0
- package/App/Reducers/DesignArea/DesignElementSelectors.js +114 -0
- package/App/Reducers/DesignArea/MaskSelectors.js +101 -0
- package/App/Reducers/DesignArea/Reducer.js +150 -0
- package/App/Reducers/DesignArea/Selectors.js +1304 -0
- package/App/Reducers/DesignArea/Transformers.js +333 -0
- package/App/Reducers/DesignData/Actions.js +232 -0
- package/App/Reducers/DesignData/Modifiers.js +328 -0
- package/App/Reducers/DesignData/Reducer.js +189 -0
- package/App/Reducers/DesignData/Selectors.js +94 -0
- package/App/Reducers/DesignData/Transformers.js +27 -0
- package/App/Reducers/DesignView/Actions.js +19 -0
- package/App/Reducers/DesignView/Reducer.js +165 -0
- package/App/Reducers/DesignView/Selectors.js +130 -0
- package/App/Reducers/DesignView/Transformers.js +32 -0
- package/App/Reducers/Device/Actions.js +16 -0
- package/App/Reducers/Device/Reducer.js +51 -0
- package/App/Reducers/Fonts/Actions.js +137 -0
- package/App/Reducers/Fonts/Reducer.js +39 -0
- package/App/Reducers/Fonts/Selectors.js +98 -0
- package/App/Reducers/GeneralActions.js +16 -0
- package/App/Reducers/ImageGallery/Actions.js +336 -0
- package/App/Reducers/ImageGallery/Modifiers.js +67 -0
- package/App/Reducers/ImageGallery/Reducer.js +320 -0
- package/App/Reducers/ImageGallery/Selectors.js +206 -0
- package/App/Reducers/Reducer.js +107 -0
- package/App/Reducers/UI/Actions.js +191 -0
- package/App/Reducers/UI/Reducer.js +98 -0
- package/App/Reducers/UI/Selectors.js +32 -0
- package/App/Reducers.js +48 -0
- package/App/Routing.js +168 -0
- package/App/Screens/Configurator/CalculationWidgetScreen.js +84 -0
- package/App/Screens/Configurator/Components/AmountSelection/Styles.scss +17 -0
- package/App/Screens/Configurator/Components/AmountSelection/index.js +170 -0
- package/App/Screens/Configurator/Components/AmountSelection/index.story.js +36 -0
- package/App/Screens/Configurator/Components/CalculationWidget/index.js +652 -0
- package/App/Screens/Configurator/Components/CalculationWidget/index.story.js +154 -0
- package/App/Screens/Configurator/Components/CalculationWidget/index.test.js +142 -0
- package/App/Screens/Configurator/Components/ConfigurationModeSwitch/ConfigurationModeSwitch.js +82 -0
- package/App/Screens/Configurator/Components/ConfigurationModeSwitch/index.js +15 -0
- package/App/Screens/Configurator/Components/Confirm/Styles.scss +0 -0
- package/App/Screens/Configurator/Components/Confirm/index.js +105 -0
- package/App/Screens/Configurator/Components/DesignApproval/index.js +76 -0
- package/App/Screens/Configurator/Components/DesignApproval/index.story.js +27 -0
- package/App/Screens/Configurator/Components/DesignApproval/index.test.js +31 -0
- package/App/Screens/Configurator/Components/Error/index.js +106 -0
- package/App/Screens/Configurator/Components/FallbackVisualization/FallbackVisualization.js +96 -0
- package/App/Screens/Configurator/Components/FileUpload/FileUploadBase.js +1 -0
- package/App/Screens/Configurator/Components/FullScreenView/index.js +304 -0
- package/App/Screens/Configurator/Components/FullScreenView/index.test.js +28 -0
- package/App/Screens/Configurator/Components/ImageLoader/ImageLoader.js +96 -0
- package/App/Screens/Configurator/Components/LandscapeInformation/index.js +75 -0
- package/App/Screens/Configurator/Components/NoVisualization/NoVisualization.js +35 -0
- package/App/Screens/Configurator/Components/PreviewPortal/index.js +249 -0
- package/App/Screens/Configurator/Components/Styles.scss +1 -0
- package/App/Screens/Configurator/Components/Thumbnail/index.js +394 -0
- package/App/Screens/Configurator/Components/Thumbnail/index.test.js +50 -0
- package/App/Screens/Configurator/Components/TotalPrice/TotalPrice.js +57 -0
- package/App/Screens/Configurator/Containers/AmountPrice.js +84 -0
- package/App/Screens/Configurator/Containers/CalculationWidget.js +278 -0
- package/App/Screens/Configurator/Containers/ConfigurationModeSwitch.js +81 -0
- package/App/Screens/Configurator/Containers/Confirm.js +37 -0
- package/App/Screens/Configurator/Containers/DesignApproval.js +129 -0
- package/App/Screens/Configurator/Containers/FallbackVisualization.js +32 -0
- package/App/Screens/Configurator/Containers/FullScreenView.js +47 -0
- package/App/Screens/Configurator/Containers/Thumbnail.js +41 -0
- package/App/Screens/Configurator/Containers/Visualization.js +13 -0
- package/App/Screens/Configurator/DynamicComponents.js +40 -0
- package/App/Screens/Configurator/Screen.js +238 -0
- package/App/Screens/Configurator/ScreenPropTypes.js +45 -0
- package/App/Screens/Configurator/ThemeProvider.js +298 -0
- package/App/Screens/DesignerProductPreview/Constants.js +12 -0
- package/App/Screens/DesignerProductPreview/DesignerProductPreviewManager.js +554 -0
- package/App/Screens/DesignerProductPreview/Screen.js +407 -0
- package/App/Screens.js +42 -0
- package/App/ServiceLocator.js +309 -0
- package/App/Services/AdminareaCommunicationService.js +149 -0
- package/App/Services/AnalyticsService.js +403 -0
- package/App/Services/ConfiguratorService.js +1166 -0
- package/App/Services/DesignDataService.js +3249 -0
- package/App/Services/DesignerService.js +496 -0
- package/App/Services/InteractionService.js +784 -0
- package/App/Services/UIService.js +129 -0
- package/App/Services/VisualizationService.js +844 -0
- package/App/Shared/Components/AcceptDesign/index.js +166 -0
- package/App/Shared/Components/AddToBasket/index.js +194 -0
- package/App/Shared/Components/AddToBasket/index.story.js +47 -0
- package/App/Shared/Components/AlertDialog/index.js +138 -0
- package/App/Shared/Components/AmountInput/Styles.scss +6 -0
- package/App/Shared/Components/AmountInput/index.js +296 -0
- package/App/Shared/Components/AmountInput/index.story.js +29 -0
- package/App/Shared/Components/AmountPrice/index.js +925 -0
- package/App/Shared/Components/AmountPrice/index.story.js +112 -0
- package/App/Shared/Components/AmountPrice/index.test.js +125 -0
- package/App/Shared/Components/Analytics/AnalyticsWrapper.js +49 -0
- package/App/Shared/Components/BulkNames/index.js +319 -0
- package/App/Shared/Components/CallToAction/index.js +220 -0
- package/App/Shared/Components/Header/Header.js +150 -0
- package/App/Shared/Components/Header/index.js +15 -0
- package/App/Shared/Components/Header/index.story.js +143 -0
- package/App/Shared/Components/InformationTag/InformationTag.js +155 -0
- package/App/Shared/Components/LicenseNotice/LicenseNotice.js +148 -0
- package/App/Shared/Components/LicenseNotice/index.js +15 -0
- package/App/Shared/Components/LoadConfiguration/index.js +218 -0
- package/App/Shared/Components/MessageBox/index.js +84 -0
- package/App/Shared/Components/MessageBox/index.story.js +49 -0
- package/App/Shared/Components/Notification/index.js +105 -0
- package/App/Shared/Components/Notification/index.story.js +55 -0
- package/App/Shared/Components/PdfDownload/index.js +150 -0
- package/App/Shared/Components/PlusMinusInput/index.js +118 -0
- package/App/Shared/Components/PriceList/index.js +237 -0
- package/App/Shared/Components/PriceList/index.story.js +114 -0
- package/App/Shared/Components/PriceOverview/index.js +177 -0
- package/App/Shared/Components/PriceOverview/index.story.js +215 -0
- package/App/Shared/Components/ProductVariant/Image.js +75 -0
- package/App/Shared/Components/ProductVariant/Styles.scss +11 -0
- package/App/Shared/Components/ProductVariant/index.js +477 -0
- package/App/Shared/Components/ProductVariant/index.story.js +283 -0
- package/App/Shared/Components/Progress/Progress.js +59 -0
- package/App/Shared/Components/ReceiveOfferForm/index.js +432 -0
- package/App/Shared/Components/ReceiveOfferForm/index.story.js +32 -0
- package/App/Shared/Components/ReceiveOfferForm/index.test.js +36 -0
- package/App/Shared/Components/SaveConfiguration/index.js +286 -0
- package/App/Shared/Components/SendEmail/index.js +103 -0
- package/App/Shared/Components/Stepper/index.js +136 -0
- package/App/Shared/Components/Stepper/index.story.js +38 -0
- package/App/Shared/Components/ToolbarList/index.js +231 -0
- package/App/Shared/Components/ToolbarList/index.story.js +33 -0
- package/App/Shared/Components/VariantChooser/index.js +270 -0
- package/App/Shared/Components/VariantChooser/index.story.js +100 -0
- package/App/Shared/Containers/AlertMessages.js +37 -0
- package/App/Shared/Containers/AmountPrice/AmountPriceAdminareaWrapper.js +40 -0
- package/App/Shared/Containers/AmountPrice/index.js +284 -0
- package/App/Shared/Containers/BulkNames.js +310 -0
- package/App/Shared/Containers/Error.js +37 -0
- package/App/Shared/Containers/GlobalLoader.js +25 -0
- package/App/Shared/Containers/Header/index.js +178 -0
- package/App/Shared/Containers/LicenseNotice/LicenseNotice.js +26 -0
- package/App/Shared/Containers/LicenseNotice/index.js +15 -0
- package/App/Shared/Containers/LoadConfiguration/LoadConfiguration.js +146 -0
- package/App/Shared/Containers/LoadConfiguration/index.js +15 -0
- package/App/Shared/Containers/PdfDownload/index.js +39 -0
- package/App/Shared/Containers/ProductVariant/ProductVariant.js +339 -0
- package/App/Shared/Containers/ProductVariant/index.js +15 -0
- package/App/Shared/Containers/SaveConfiguration.js +49 -0
- package/App/Shared/Containers/SendEmail/SendEmail.js +45 -0
- package/App/Shared/Containers/SendEmail/index.js +15 -0
- package/App/Shared/Providers/DefaultCanvasProvider.js +86 -0
- package/App/Storage.js +17 -0
- package/App/Store.js +87 -0
- package/App/Styles.scss +0 -0
- package/App/Translations.js +88 -0
- package/App/Utils/createMessageInterface.js +65 -0
- package/App/Utils/customClassName.js +12 -0
- package/App/Utils/getContrastText.js +27 -0
- package/App/Utils/getImageUrl.js +32 -0
- package/App/Variables.scss +84 -0
- package/App/configuration.js +421 -0
- package/App/index.js +52 -0
- package/App/initServices.js +67 -0
- package/App/setup.js +22 -0
- package/App/versionInfo.js +8 -0
- package/Framework/Api.js +178 -0
- package/Framework/ComponentContainer.js +165 -0
- package/Framework/Components/Carousel/Styles.scss +85 -0
- package/Framework/Components/Carousel/index.js +322 -0
- package/Framework/Components/Dialog/Style.scss +79 -0
- package/Framework/Components/Dialog/index.js +721 -0
- package/Framework/Components/DialogSelect/Styles.scss +53 -0
- package/Framework/Components/DialogSelect/index.js +331 -0
- package/Framework/Components/Input/index.js +147 -0
- package/Framework/Components/LoadingOverlay/Styles.scss +37 -0
- package/Framework/Components/LoadingOverlay/index.js +33 -0
- package/Framework/Components/Markdown/index.js +62 -0
- package/Framework/Components/Mobile/index.js +33 -0
- package/Framework/CustomError.js +51 -0
- package/Framework/Helpers/TransitionDetect.js +116 -0
- package/Framework/Helpers/isLandscapeMobile.js +14 -0
- package/Framework/Helpers/isMobileDevice.js +17 -0
- package/Framework/Helpers/isMobileSize.js +13 -0
- package/Framework/Mixins.scss +235 -0
- package/Framework/Services/AbstractAdminareaCommunicationService.js +48 -0
- package/Framework/Services/AbstractAsyncService.js +44 -0
- package/Framework/Services/AbstractConfiguratorService.js +47 -0
- package/Framework/Services/AbstractInteractionService.js +50 -0
- package/Framework/Services/AbstractStoreService.js +42 -0
- package/Framework/Services/AbstractUIService.js +53 -0
- package/Framework/Services/AbstractVisualizationService.js +47 -0
- package/Framework/Services/AsyncService.js +93 -0
- package/Framework/Services/StoreService.js +237 -0
- package/Framework/Variables.scss +22 -0
- package/Framework/bindDecorator.js +173 -0
- package/Framework/i18n.js +382 -0
- package/README.md +5 -26
- package/Resources/Icons/MaterialUI/Icons/AddCircle.js +13 -0
- package/Resources/Icons/MaterialUI/Icons/RemoveCircle.js +13 -0
- package/Resources/Icons/MaterialUI/fontFace.scss +37 -0
- package/Resources/Icons/MaterialUI/fonts/MaterialIcons-Regular.eot +0 -0
- package/Resources/Icons/MaterialUI/fonts/MaterialIcons-Regular.svg +2373 -0
- package/Resources/Icons/MaterialUI/fonts/MaterialIcons-Regular.ttf +0 -0
- package/Resources/Icons/MaterialUI/fonts/MaterialIcons-Regular.woff +0 -0
- package/Resources/Icons/MaterialUI/fonts/MaterialIcons-Regular.woff2 +0 -0
- package/Resources/Icons/fonts/ionicons.eot +0 -0
- package/Resources/Icons/fonts/ionicons.svg +2230 -0
- package/Resources/Icons/fonts/ionicons.ttf +0 -0
- package/Resources/Icons/fonts/ionicons.woff +0 -0
- package/Resources/Icons/ionicons.scss +1489 -0
- package/Resources/Icons/ioniconsExtend.scss +1469 -0
- package/Resources/Icons/v4/fontFace.scss +11 -0
- package/Resources/Icons/v4/fonts/ionicons.eot +0 -0
- package/Resources/Icons/v4/fonts/ionicons.svg +2090 -0
- package/Resources/Icons/v4/fonts/ionicons.ttf +0 -0
- package/Resources/Icons/v4/fonts/ionicons.woff +0 -0
- package/Resources/Icons/v4/fonts/ionicons.woff2 +0 -0
- package/Resources/Icons/v4/icons.scss +15 -0
- package/Resources/Icons/v4/iconsExtend.scss +7 -0
- package/Resources/Images/designer_placeholder_logo.svg +1 -0
- package/Resources/Masks/circle.svg +4 -0
- package/Shared/Components/CustomDialog.js +133 -0
- package/Shared/Components/CustomDialogSelect.js +161 -0
- package/Shared/Components/MainButton.js +81 -0
- package/Shared/ErrorTypes/DeferredError.js +51 -0
- package/Shared/HOCs/ResizeDetect/ResizeDetect.dev.js +60 -0
- package/Shared/HOCs/ResizeDetect/ResizeDetect.js +217 -0
- package/Shared/HOCs/getDisplayName.js +10 -0
- package/Shared/HOCs/withFixedChangeHandler.js +46 -0
- package/Shared/PropTypes/ReactComponent.js +13 -0
- package/Shared/Styles/absoluteCenter.js +17 -0
- package/Utils/Array/isIdentical.js +38 -0
- package/Utils/Async/AsyncManager.js +128 -0
- package/Utils/Async/Deferred.js +145 -0
- package/Utils/Async/ObjectLock.js +38 -0
- package/Utils/Decorators/Observable.js +130 -0
- package/Utils/Dev/HOCs/withFilePicker.js +101 -0
- package/Utils/Dev/isDev.js +21 -0
- package/Utils/Events/pointerEvent.js +199 -0
- package/Utils/Events/preventEventDoubling.js +23 -0
- package/Utils/Function/cached.js +64 -0
- package/Utils/Function/createDebounceManager.js +77 -0
- package/Utils/Function/createSelector.js +62 -0
- package/Utils/Function/memoize.js +46 -0
- package/Utils/Function/sendMessage.js +22 -0
- package/Utils/Helper/createSelectionRangeMemo.js +45 -0
- package/Utils/Immutable/set.js +81 -0
- package/Utils/Math/conversions.js +13 -0
- package/Utils/Math/isPositiveNumber.js +12 -0
- package/Utils/Redux/createActionWithGlobalState.js +23 -0
- package/Utils/Styles/combineMediaQueries.js +24 -0
- package/Utils/Styles/createCheckerBoardBackground.js +22 -0
- package/Utils/Test/CallOrderChecker.js +29 -0
- package/Utils/Test/createStoreProvider.js +33 -0
- package/Utils/Test/formDataToJSON.js +20 -0
- package/Utils/Test/mountWithState.js +40 -0
- package/index.js +8 -0
- package/package.json +22 -103
- package/scripts/cpPublic.js +3 -3
- package/scripts/getDefaultWebpackConfig.js +11 -10
- package/src/App/Error/ProductionErrorPage/Style.scss +1 -1
- package/src/App/Modules/Creator/Components/Option/index.test.js +1 -1
- package/src/App/Modules/Creator/Components/OptionAmount/index.test.js +1 -1
- package/src/App/Modules/Creator/Components/ProductPart/index.test.js +1 -1
- package/src/App/Modules/Designer/Components/AddGalleryImage/index.story.js +1 -1
- package/src/App/Modules/Designer/Components/ColorPalettes/index.test.jsx +1 -1
- package/src/App/Modules/Designer/Components/DesignAreaControlbox/index.js +21 -4
- package/src/App/Modules/Designer/Components/DesignAreaControlbox/index.test.jsx +1 -1
- package/src/App/Modules/Designer/Components/TextControlbox/index.test.jsx +1 -1
- package/src/App/Modules/Designer/Containers/Designer.js +1 -1
- package/src/App/Modules/Designer/DesignerScreen.js +32 -8
- package/src/App/{Screens/Configurator → Modules/Designer}/DesignerUI.js +42 -26
- package/src/App/Modules/Designer/Layouts/DefaultLayout.js +35 -1
- package/src/App/Modules/Designer/MultilayerComponents/DesignerClickAwayListener.js +18 -0
- package/src/App/Modules/Designer/MultilayerComponents/InlineToolboxPortal.js +54 -0
- package/src/App/Modules/Designer/MultilayerComponents/StandardToolboxPortal.js +38 -0
- package/src/App/Reducers/DesignView/Actions.js +1 -2
- package/src/App/Reducers/DesignView/Reducer.js +2 -10
- package/src/App/Reducers/DesignView/__mocks__/designerViewData.js +0 -1
- package/src/App/Reducers/DesignView/__tests__/Reducer.test.js +0 -22
- package/src/App/Reducers/ImageGallery/Actions.js +1 -1
- package/src/App/Screens/Configurator/Components/CalculationWidget/index.test.jsx +1 -1
- package/src/App/Screens/Configurator/Components/DesignApproval/index.test.jsx +1 -1
- package/src/App/Screens/Configurator/Components/FullScreenView/index.js +3 -2
- package/src/App/Screens/Configurator/Components/FullScreenView/index.test.jsx +1 -1
- package/src/App/Screens/Configurator/Components/PreviewPortal/index.js +7 -3
- package/src/App/Screens/Configurator/Containers/AmountPrice.js +1 -1
- package/src/App/Screens/Configurator/Containers/Confirm.js +1 -1
- package/src/App/Screens/Configurator/Containers/FullScreenView.js +1 -0
- package/src/App/Screens/Configurator/Containers/__tests__/Designer.test.js +1 -1
- package/src/App/Screens/Configurator/Screen.js +4 -2
- package/src/App/Screens/Configurator/__tests__/Screen.test.js +3 -0
- package/src/App/Services/ConfiguratorService.js +25 -4
- package/src/App/Services/InteractionService.js +2 -1
- package/src/App/Services/VisualizationService.js +3 -0
- package/src/App/Services/__tests__/DesignDataService.selectViewForComponent.test.js +0 -53
- package/src/App/Shared/Containers/AlertMessages.js +1 -1
- package/src/App/Shared/Containers/AmountPrice/index.test.js +1 -1
- package/src/App/Shared/Containers/Error.js +1 -1
- package/src/App/Shared/Containers/SaveConfiguration.js +1 -1
- package/src/App/Translations.js +1 -1
- package/src/App/Utils/createMessageInterface.js +10 -0
- package/src/App/configuration.js +3 -0
- package/src/Framework/i18n.js +2 -3
- package/babel.config.js +0 -46
- package/public/ConfigurationMessagingDemo.html +0 -55
- package/scripts/cpPath.js +0 -135
- package/scripts/moveLibToPackageRoot.js +0 -40
- package/scripts/rmDir.js +0 -29
- package/scripts/updateLocalPackages.js +0 -68
- package/scripts/utils/process.js +0 -19
- package/tsconfig.json +0 -22
|
@@ -0,0 +1,3249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.EventTypes = exports.updateColorAmountOnDesignProductionMethodChange = exports.isWidget = exports.getSvgColors = exports.applySvgContentOperations = exports.getSvgContent = exports.makeOperationsCompatible = exports.getMissingColorPalettesColors = exports.getClosestColorPaletteColor = exports.getColorPalettesIndex = exports.calculateImageBrightness = exports.isColorTooBright = exports.getColorsDistance = exports.rgbStrToHex = exports.getRgbValuesFromString = exports.isTextColorChange = exports.checkColorUsage = void 0;
|
|
7
|
+
|
|
8
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
9
|
+
|
|
10
|
+
var _first = _interopRequireDefault(require("lodash/first"));
|
|
11
|
+
|
|
12
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
13
|
+
|
|
14
|
+
var _find = _interopRequireDefault(require("lodash/find"));
|
|
15
|
+
|
|
16
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
17
|
+
|
|
18
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
19
|
+
|
|
20
|
+
var _i18n = require("../../Framework/i18n");
|
|
21
|
+
|
|
22
|
+
var _ServiceLocator = require("../ServiceLocator");
|
|
23
|
+
|
|
24
|
+
var _configuration = require("../configuration");
|
|
25
|
+
|
|
26
|
+
var _Observable = _interopRequireDefault(require("../../Utils/Decorators/Observable"));
|
|
27
|
+
|
|
28
|
+
var _setupDesigner = _interopRequireDefault(require("../Modules/Designer/setupDesigner"));
|
|
29
|
+
|
|
30
|
+
var _Actions = require("../Reducers/DesignData/Actions");
|
|
31
|
+
|
|
32
|
+
var _Actions2 = require("../Reducers/ImageGallery/Actions");
|
|
33
|
+
|
|
34
|
+
var _Modifiers = require("../Reducers/DesignData/Modifiers");
|
|
35
|
+
|
|
36
|
+
var _Actions3 = require("../Reducers/DesignArea/Actions");
|
|
37
|
+
|
|
38
|
+
var _Actions4 = require("../Reducers/DesignView/Actions");
|
|
39
|
+
|
|
40
|
+
var _Selectors = require("../Reducers/DesignArea/Selectors");
|
|
41
|
+
|
|
42
|
+
var _Selectors2 = require("../Reducers/ImageGallery/Selectors");
|
|
43
|
+
|
|
44
|
+
var _Selectors3 = require("../Reducers/Configurator/Selectors");
|
|
45
|
+
|
|
46
|
+
var _Selectors4 = require("../Reducers/Fonts/Selectors");
|
|
47
|
+
|
|
48
|
+
var _Actions5 = require("../Reducers/Confirm/Actions");
|
|
49
|
+
|
|
50
|
+
var _ObjectLock = require("../../Utils/Async/ObjectLock");
|
|
51
|
+
|
|
52
|
+
var _Transformers = require("../Reducers/DesignData/Transformers");
|
|
53
|
+
|
|
54
|
+
var _Modifiers2 = require("../Reducers/ImageGallery/Modifiers");
|
|
55
|
+
|
|
56
|
+
var _FontFaceRepository = require("../Modules/Designer/Utils/FontFaceRepository");
|
|
57
|
+
|
|
58
|
+
var _Selectors5 = require("../Reducers/DesignData/Selectors");
|
|
59
|
+
|
|
60
|
+
var _ImageEditUtils = require("../Modules/Designer/Utils/ImageEditUtils");
|
|
61
|
+
|
|
62
|
+
var _DesignElementSelectors = require("../Reducers/DesignArea/DesignElementSelectors");
|
|
63
|
+
|
|
64
|
+
var _designer_placeholder_logo = _interopRequireDefault(require("../../Resources/Images/designer_placeholder_logo.svg"));
|
|
65
|
+
|
|
66
|
+
var _this = void 0;
|
|
67
|
+
|
|
68
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
69
|
+
|
|
70
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
71
|
+
|
|
72
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
73
|
+
|
|
74
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
75
|
+
|
|
76
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
77
|
+
|
|
78
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
79
|
+
|
|
80
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
81
|
+
|
|
82
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
83
|
+
|
|
84
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
85
|
+
|
|
86
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
87
|
+
|
|
88
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
89
|
+
|
|
90
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
91
|
+
|
|
92
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
93
|
+
|
|
94
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
95
|
+
|
|
96
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
97
|
+
|
|
98
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
99
|
+
|
|
100
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Preload all fonts for the given canvasData
|
|
104
|
+
* @param {object} canvasData The canvas data object
|
|
105
|
+
* @return {Promise<[]>}
|
|
106
|
+
*/
|
|
107
|
+
var preloadFonts = function preloadFonts(canvasData) {
|
|
108
|
+
return Promise.all(canvasData.objects.filter(function (_ref) {
|
|
109
|
+
var type = _ref.type;
|
|
110
|
+
return type === 'Text';
|
|
111
|
+
}).map(function (_ref2) {
|
|
112
|
+
var content = _ref2.content;
|
|
113
|
+
return _FontFaceRepository.FontFaceRepository.collectFromHTML(content);
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var checkColorUsage = function () {
|
|
118
|
+
var alreadyAlertedColorCountState = {};
|
|
119
|
+
return function (canvasDataJSON, changeEvent) {
|
|
120
|
+
var _getSelectedDesignAre = (0, _Selectors.getSelectedDesignAreaProperties)(_ServiceLocator.Services.store.state),
|
|
121
|
+
maxColorCount = _getSelectedDesignAre.maxColorAmount,
|
|
122
|
+
designAreaIdentifier = _getSelectedDesignAre.selectedDesignArea.identifier,
|
|
123
|
+
currentColorCount = _getSelectedDesignAre.colorAmount;
|
|
124
|
+
|
|
125
|
+
if (!designAreaIdentifier) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var changedObjectColorCount = (0, _Selectors.getColorsFromCanvasData)({
|
|
130
|
+
objects: [changeEvent.target.toObject()]
|
|
131
|
+
}).length;
|
|
132
|
+
var colorCount = (0, _Selectors.getColorsFromCanvasData)(canvasDataJSON).length;
|
|
133
|
+
var colorCountState = {
|
|
134
|
+
colorCount: changedObjectColorCount,
|
|
135
|
+
maxColorCount: maxColorCount
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (colorCount !== currentColorCount) {
|
|
139
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions.setColorAmount)(colorCount));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var showAlert = maxColorCount && isTextColorChange(changeEvent) && changedObjectColorCount > maxColorCount && alreadyAlertedColorCountState[designAreaIdentifier].colorCount !== colorCountState.colorCount;
|
|
143
|
+
alreadyAlertedColorCountState[designAreaIdentifier] = colorCountState;
|
|
144
|
+
return showAlert;
|
|
145
|
+
};
|
|
146
|
+
}();
|
|
147
|
+
|
|
148
|
+
exports.checkColorUsage = checkColorUsage;
|
|
149
|
+
|
|
150
|
+
var isTextColorChange = function isTextColorChange(changeEvent) {
|
|
151
|
+
if (changeEvent.target.type !== 'Text') {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var prevStyles = (0, _get2["default"])(changeEvent, 'eventData.prevState.style', {});
|
|
156
|
+
|
|
157
|
+
if ((0, _isEmpty["default"])(prevStyles)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
var prevColors = (0, _get2["default"])(prevStyles, 'colors', []);
|
|
162
|
+
var colors = (0, _get2["default"])(changeEvent.target.toObject(), 'style.colors', []);
|
|
163
|
+
return !(0, _isEqual["default"])(prevColors, colors);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
exports.isTextColorChange = isTextColorChange;
|
|
167
|
+
|
|
168
|
+
var getRgbValuesFromString = function getRgbValuesFromString(str) {
|
|
169
|
+
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
170
|
+
r: 0,
|
|
171
|
+
g: 0,
|
|
172
|
+
b: 0
|
|
173
|
+
};
|
|
174
|
+
var matches = str.match(/rgb\((.*)\)/);
|
|
175
|
+
|
|
176
|
+
if (!matches) {
|
|
177
|
+
return defaultValue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
var values = matches[1].split(',').map(function (number) {
|
|
181
|
+
return parseInt(number);
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
r: values[0],
|
|
185
|
+
g: values[1],
|
|
186
|
+
b: values[2]
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
exports.getRgbValuesFromString = getRgbValuesFromString;
|
|
191
|
+
|
|
192
|
+
var rgbStrToHex = function rgbStrToHex(str) {
|
|
193
|
+
return (0, _Selectors.rgbObjToHex)(getRgbValuesFromString(str));
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
exports.rgbStrToHex = rgbStrToHex;
|
|
197
|
+
|
|
198
|
+
var getColorsDistance = function getColorsDistance(color1, color2) {
|
|
199
|
+
return Math.pow(color1.r - color2.r, 2) + Math.pow(color1.g - color2.g, 2) + Math.pow(color1.b - color2.b, 2);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
exports.getColorsDistance = getColorsDistance;
|
|
203
|
+
|
|
204
|
+
var isColorTooBright = function isColorTooBright(rgbColors) {
|
|
205
|
+
if (!rgbColors) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
var red = rgbColors.r,
|
|
210
|
+
green = rgbColors.g,
|
|
211
|
+
blue = rgbColors.b;
|
|
212
|
+
|
|
213
|
+
if (typeof red !== 'number' || typeof green !== 'number' || typeof blue !== 'number' || red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
var maxBrightness = 210;
|
|
218
|
+
var luma = 0.2126 * red + 0.7152 * green + 0.0722 * blue; // see https://bit.ly/2BXPOld
|
|
219
|
+
|
|
220
|
+
return luma > maxBrightness;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
exports.isColorTooBright = isColorTooBright;
|
|
224
|
+
|
|
225
|
+
var calculateImageBrightness = function calculateImageBrightness(image) {
|
|
226
|
+
if (!image) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var imageUrl = "".concat((0, _configuration.getConf)('network.host')).concat(image.data.thumbnail.url);
|
|
231
|
+
var fuzzy = 0.1;
|
|
232
|
+
return new Promise(function (resolve, reject) {
|
|
233
|
+
var downloadedImg = new Image(200, 200);
|
|
234
|
+
downloadedImg.crossOrigin = 'anonymous';
|
|
235
|
+
downloadedImg.addEventListener('load', function () {
|
|
236
|
+
var canvas = document.createElement('canvas');
|
|
237
|
+
var context = canvas.getContext('2d');
|
|
238
|
+
canvas.width = downloadedImg.width;
|
|
239
|
+
canvas.height = downloadedImg.height;
|
|
240
|
+
context.drawImage(downloadedImg, 0, 0);
|
|
241
|
+
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
242
|
+
var data = imageData.data;
|
|
243
|
+
var light = 0,
|
|
244
|
+
dark = 0;
|
|
245
|
+
|
|
246
|
+
for (var x = 0; x < data.length; x += 4) {
|
|
247
|
+
var red = data[x];
|
|
248
|
+
var green = data[x + 1];
|
|
249
|
+
var blue = data[x + 2];
|
|
250
|
+
var alpha = data[x + 3];
|
|
251
|
+
|
|
252
|
+
if (alpha === 0) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
var maxRgb = Math.max(Math.max(red, green), blue);
|
|
257
|
+
if (maxRgb < 128) dark++;else light++;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var dlDiff = (light - dark) / (canvas.width * canvas.height);
|
|
261
|
+
image.data.thumbnail.isThumbnailBright = dlDiff + fuzzy > 0;
|
|
262
|
+
resolve(image);
|
|
263
|
+
}, false);
|
|
264
|
+
downloadedImg.addEventListener('error', reject);
|
|
265
|
+
downloadedImg.src = imageUrl;
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
exports.calculateImageBrightness = calculateImageBrightness;
|
|
270
|
+
|
|
271
|
+
var getColorPalettesIndex = function getColorPalettesIndex(colorPalettes) {
|
|
272
|
+
var colorPalettesIndexes = [];
|
|
273
|
+
|
|
274
|
+
var _iterator = _createForOfIteratorHelper(colorPalettes),
|
|
275
|
+
_step;
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
279
|
+
var colorPalette = _step.value;
|
|
280
|
+
|
|
281
|
+
var _iterator2 = _createForOfIteratorHelper(colorPalette.colors),
|
|
282
|
+
_step2;
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
286
|
+
var colorPaletteColor = _step2.value;
|
|
287
|
+
var colorIndex = {
|
|
288
|
+
palette: colorPalette.identifier,
|
|
289
|
+
identifier: colorPaletteColor.identifier,
|
|
290
|
+
value: (0, _Selectors.hexToRgb)('#' + colorPaletteColor.hex_value)
|
|
291
|
+
};
|
|
292
|
+
colorIndex.valueObject = getRgbValuesFromString(colorIndex.value);
|
|
293
|
+
colorPalettesIndexes.push(colorIndex);
|
|
294
|
+
}
|
|
295
|
+
} catch (err) {
|
|
296
|
+
_iterator2.e(err);
|
|
297
|
+
} finally {
|
|
298
|
+
_iterator2.f();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
_iterator.e(err);
|
|
303
|
+
} finally {
|
|
304
|
+
_iterator.f();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return colorPalettesIndexes;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
exports.getColorPalettesIndex = getColorPalettesIndex;
|
|
311
|
+
|
|
312
|
+
var getClosestColorPaletteColor = function getClosestColorPaletteColor(colorValueObject, colorPalettesIndexes) {
|
|
313
|
+
var closestDistance = null;
|
|
314
|
+
var closestColor = null;
|
|
315
|
+
|
|
316
|
+
var _iterator3 = _createForOfIteratorHelper(colorPalettesIndexes),
|
|
317
|
+
_step3;
|
|
318
|
+
|
|
319
|
+
try {
|
|
320
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
321
|
+
var colorPalettesIndex = _step3.value;
|
|
322
|
+
var distance = getColorsDistance(colorValueObject, colorPalettesIndex.valueObject);
|
|
323
|
+
|
|
324
|
+
if (closestDistance === null || distance < closestDistance) {
|
|
325
|
+
closestDistance = distance;
|
|
326
|
+
var rgb = colorPalettesIndex.valueObject;
|
|
327
|
+
var hexValue = (0, _Selectors.rgbToHex)(rgb.r, rgb.g, rgb.b);
|
|
328
|
+
closestColor = (0, _Selectors.createColorData)(colorPalettesIndex.identifier, colorPalettesIndex.palette, false, hexValue);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} catch (err) {
|
|
332
|
+
_iterator3.e(err);
|
|
333
|
+
} finally {
|
|
334
|
+
_iterator3.f();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return closestColor;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
exports.getClosestColorPaletteColor = getClosestColorPaletteColor;
|
|
341
|
+
|
|
342
|
+
var getMissingColorPalettesColors = function getMissingColorPalettesColors(colors, colorPalettes, replaceCustomColors) {
|
|
343
|
+
var availableColorPalettes = colorPalettes.map(function (colorPalette) {
|
|
344
|
+
return colorPalette.identifier;
|
|
345
|
+
}); // skip if no available color palettes (most likely a data issue)
|
|
346
|
+
|
|
347
|
+
if (!availableColorPalettes.length) {
|
|
348
|
+
return [];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var colorsToReplace = colors.filter(function (color) {
|
|
352
|
+
var _parseColorData = (0, _Selectors.parseColorData)(color.identifier),
|
|
353
|
+
palette = _parseColorData.palette;
|
|
354
|
+
|
|
355
|
+
if (replaceCustomColors && palette === null) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return palette && availableColorPalettes.indexOf(palette) === -1;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
if (!colorsToReplace.length) {
|
|
363
|
+
return [];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
var colorPalettesIndexes = getColorPalettesIndex(colorPalettes);
|
|
367
|
+
return colorsToReplace.map(function (color) {
|
|
368
|
+
var closestColor = getClosestColorPaletteColor(getRgbValuesFromString(color.value.startsWith('#') ? (0, _Selectors.hexToRgb)(color.value) : color.value), colorPalettesIndexes);
|
|
369
|
+
return {
|
|
370
|
+
color: color,
|
|
371
|
+
closestColor: closestColor
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
exports.getMissingColorPalettesColors = getMissingColorPalettesColors;
|
|
377
|
+
|
|
378
|
+
var makeOperationsCompatible = function makeOperationsCompatible(operations, compatibilityInfo, colorPalettes) {
|
|
379
|
+
if (!operations) {
|
|
380
|
+
return operations;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
var missingColorPalettesColors = getMissingColorPalettesColors(Object.values(operations.vectorizeColorsMap || {}), colorPalettes, !operations.vectorize && compatibilityInfo.vectorsRequired);
|
|
384
|
+
|
|
385
|
+
var _iterator4 = _createForOfIteratorHelper(missingColorPalettesColors),
|
|
386
|
+
_step4;
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
390
|
+
var missingColor = _step4.value;
|
|
391
|
+
operations = (0, _Modifiers.replaceColorOnOperations)(operations, missingColor.color, missingColor.closestColor);
|
|
392
|
+
}
|
|
393
|
+
} catch (err) {
|
|
394
|
+
_iterator4.e(err);
|
|
395
|
+
} finally {
|
|
396
|
+
_iterator4.f();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return operations;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
exports.makeOperationsCompatible = makeOperationsCompatible;
|
|
403
|
+
|
|
404
|
+
var getSvgContent = function () {
|
|
405
|
+
var svgContentMap = new Map();
|
|
406
|
+
return /*#__PURE__*/function () {
|
|
407
|
+
var _getSvgContent = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url) {
|
|
408
|
+
var absolute,
|
|
409
|
+
forceFetch,
|
|
410
|
+
absUrl,
|
|
411
|
+
result,
|
|
412
|
+
svgContent,
|
|
413
|
+
_args = arguments;
|
|
414
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
415
|
+
while (1) {
|
|
416
|
+
switch (_context.prev = _context.next) {
|
|
417
|
+
case 0:
|
|
418
|
+
absolute = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
419
|
+
forceFetch = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
|
420
|
+
absUrl = absolute ? url : "".concat((0, _configuration.getConf)('network.host')).concat(url);
|
|
421
|
+
|
|
422
|
+
if (!(!forceFetch && svgContentMap.has(absUrl))) {
|
|
423
|
+
_context.next = 5;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return _context.abrupt("return", svgContentMap.get(absUrl));
|
|
428
|
+
|
|
429
|
+
case 5:
|
|
430
|
+
_context.prev = 5;
|
|
431
|
+
_context.next = 8;
|
|
432
|
+
return _axios["default"].get(absUrl);
|
|
433
|
+
|
|
434
|
+
case 8:
|
|
435
|
+
result = _context.sent;
|
|
436
|
+
svgContent = (0, _Transformers.initDefaultColor)(result.data);
|
|
437
|
+
svgContentMap.set(absUrl, svgContent);
|
|
438
|
+
return _context.abrupt("return", svgContent);
|
|
439
|
+
|
|
440
|
+
case 14:
|
|
441
|
+
_context.prev = 14;
|
|
442
|
+
_context.t0 = _context["catch"](5);
|
|
443
|
+
return _context.abrupt("return", '');
|
|
444
|
+
|
|
445
|
+
case 17:
|
|
446
|
+
case "end":
|
|
447
|
+
return _context.stop();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}, _callee, null, [[5, 14]]);
|
|
451
|
+
}));
|
|
452
|
+
|
|
453
|
+
function getSvgContent(_x) {
|
|
454
|
+
return _getSvgContent.apply(this, arguments);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return getSvgContent;
|
|
458
|
+
}();
|
|
459
|
+
}();
|
|
460
|
+
|
|
461
|
+
exports.getSvgContent = getSvgContent;
|
|
462
|
+
|
|
463
|
+
var applySvgContentOperations = function applySvgContentOperations(preview, operations, svgContent) {
|
|
464
|
+
// add missing attributes to svg tag if needed
|
|
465
|
+
var svgTags = svgContent.match(/<svg(?:(?!>)[\s\S])*>/);
|
|
466
|
+
|
|
467
|
+
if (svgTags && svgTags[0]) {
|
|
468
|
+
var svgTag = svgTags[0];
|
|
469
|
+
|
|
470
|
+
if (svgTag.indexOf('viewBox=') === -1) {
|
|
471
|
+
svgContent = svgContent.replace('<svg', "<svg viewBox=\"0 0 ".concat(preview.width, " ").concat(preview.height, "\""));
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (svgTag.indexOf('height=') === -1) {
|
|
475
|
+
svgContent = svgContent.replace('<svg', "<svg height=\"".concat(preview.height, "px\""));
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (svgTag.indexOf('width=') === -1) {
|
|
479
|
+
svgContent = svgContent.replace('<svg', "<svg width=\"".concat(preview.width, "px\""));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
if (operations && operations.vectorize && operations.vectorizeColorsMap && Object.keys(operations.vectorizeColorsMap).length) {
|
|
484
|
+
var colorRegex = new RegExp("(".concat(Object.keys(operations.vectorizeColorsMap).join('|'), ")"), 'ig');
|
|
485
|
+
svgContent = svgContent.replace(colorRegex, function (match) {
|
|
486
|
+
var value = operations.vectorizeColorsMap[match.toLowerCase()].value;
|
|
487
|
+
return (0, _Selectors.isValidHex)(value) ? value : '#000000';
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return 'data:image/svg+xml;base64,' + btoa(svgContent);
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
exports.applySvgContentOperations = applySvgContentOperations;
|
|
495
|
+
|
|
496
|
+
var getSvgColors = function getSvgColors(svgContent, designProductionMethod) {
|
|
497
|
+
var colors = svgContent.toLowerCase().match(/#[0-9a-f]{3,6}/g);
|
|
498
|
+
var colorsMap = [];
|
|
499
|
+
|
|
500
|
+
var _iterator5 = _createForOfIteratorHelper(designProductionMethod.colorPalettes),
|
|
501
|
+
_step5;
|
|
502
|
+
|
|
503
|
+
try {
|
|
504
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
505
|
+
var colorPalette = _step5.value;
|
|
506
|
+
|
|
507
|
+
var _iterator6 = _createForOfIteratorHelper(colorPalette.colors),
|
|
508
|
+
_step6;
|
|
509
|
+
|
|
510
|
+
try {
|
|
511
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
512
|
+
var color = _step6.value;
|
|
513
|
+
colorsMap.push({
|
|
514
|
+
identifier: color.identifier,
|
|
515
|
+
paletteIdentifier: colorPalette.identifier,
|
|
516
|
+
value: '#' + color.hex_value
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
} catch (err) {
|
|
520
|
+
_iterator6.e(err);
|
|
521
|
+
} finally {
|
|
522
|
+
_iterator6.f();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
} catch (err) {
|
|
526
|
+
_iterator5.e(err);
|
|
527
|
+
} finally {
|
|
528
|
+
_iterator5.f();
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
var colorPalettesIndexes = getColorPalettesIndex(designProductionMethod.colorPalettes);
|
|
532
|
+
return colors.map(function (color) {
|
|
533
|
+
var paletteColor = (0, _find["default"])(colorsMap, function (colorsMapColor) {
|
|
534
|
+
return colorsMapColor.value === color;
|
|
535
|
+
}); // the color has a matching palette color
|
|
536
|
+
|
|
537
|
+
if (paletteColor) {
|
|
538
|
+
return {
|
|
539
|
+
key: color,
|
|
540
|
+
color: (0, _Selectors.createColorData)(paletteColor.identifier, paletteColor.paletteIdentifier, false, paletteColor.value)
|
|
541
|
+
};
|
|
542
|
+
} // find the closest color in the palettes
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
if (colorPalettesIndexes.length) {
|
|
546
|
+
return {
|
|
547
|
+
key: color,
|
|
548
|
+
color: getClosestColorPaletteColor(getRgbValuesFromString((0, _Selectors.hexToRgb)(color)), colorPalettesIndexes)
|
|
549
|
+
};
|
|
550
|
+
} // treat it as a custom color (fallback case)
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
return {
|
|
554
|
+
key: color,
|
|
555
|
+
color: (0, _Selectors.createColorData)(color, null, true, color)
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
exports.getSvgColors = getSvgColors;
|
|
561
|
+
|
|
562
|
+
var isWidget = function isWidget(pathname) {
|
|
563
|
+
return /\/widget\//.test(pathname);
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
exports.isWidget = isWidget;
|
|
567
|
+
|
|
568
|
+
var updateColorAmountOnDesignProductionMethodChange = function updateColorAmountOnDesignProductionMethodChange(selectedDesignProductionMethod) {
|
|
569
|
+
var state = _ServiceLocator.Services.store.state;
|
|
570
|
+
var selectedProductionMethod = (0, _Selectors.getDesignProductionMethodByIdentifier)(state, selectedDesignProductionMethod);
|
|
571
|
+
var designAreaData = (0, _Selectors.getDesignDataForSelectedDesignArea)(state);
|
|
572
|
+
var colorAmount = designAreaData.colorAmount;
|
|
573
|
+
var selectedDesignArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
574
|
+
var maxColorAmount = Number((0, _get2["default"])(selectedProductionMethod, 'options.maxColorAmount') || 0);
|
|
575
|
+
var activeDesignAreas = (0, _Selectors.getActiveDesignAreas)(state);
|
|
576
|
+
var isDesignAreaSelected = activeDesignAreas[selectedDesignArea.identifier];
|
|
577
|
+
|
|
578
|
+
if (colorAmount !== 1 && colorAmount > maxColorAmount) {
|
|
579
|
+
_ServiceLocator.Services.designData.getSampleCanvasEditorForDesignArea().setColorAmount(1);
|
|
580
|
+
|
|
581
|
+
isDesignAreaSelected && _this.getSampleCanvasEditorForDesignArea().setColorAmount(1);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
exports.updateColorAmountOnDesignProductionMethodChange = updateColorAmountOnDesignProductionMethodChange;
|
|
586
|
+
var EventTypes = {
|
|
587
|
+
DesignAreaListChange: 'DesignDataService/DesignAreaListChange',
|
|
588
|
+
DesignViewListChange: 'DesignDataService/DesignViewListChange'
|
|
589
|
+
};
|
|
590
|
+
exports.EventTypes = EventTypes;
|
|
591
|
+
|
|
592
|
+
var DesignDataService = /*#__PURE__*/function () {
|
|
593
|
+
function DesignDataService() {
|
|
594
|
+
var _this2 = this;
|
|
595
|
+
|
|
596
|
+
_classCallCheck(this, DesignDataService);
|
|
597
|
+
|
|
598
|
+
_defineProperty(this, "observable", new _Observable["default"](this));
|
|
599
|
+
|
|
600
|
+
_defineProperty(this, "isInPreviewMode", false);
|
|
601
|
+
|
|
602
|
+
_defineProperty(this, "_loadCanvasData", null);
|
|
603
|
+
|
|
604
|
+
_defineProperty(this, "_getCanvas", null);
|
|
605
|
+
|
|
606
|
+
_defineProperty(this, "_serializeCanvas", null);
|
|
607
|
+
|
|
608
|
+
_defineProperty(this, "_syncCanvasChange", null);
|
|
609
|
+
|
|
610
|
+
_defineProperty(this, "_isCanvasDataUpdateEnabled", true);
|
|
611
|
+
|
|
612
|
+
_defineProperty(this, "handleDesignProductionMethodChangeFromVectorizationToNonVectorization", /*#__PURE__*/function () {
|
|
613
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(designProductionMethodIdentifier) {
|
|
614
|
+
var state, _getVectorizeForDesig, currentVectorsRequired, newVectorsRequired, designArea, images;
|
|
615
|
+
|
|
616
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
617
|
+
while (1) {
|
|
618
|
+
switch (_context2.prev = _context2.next) {
|
|
619
|
+
case 0:
|
|
620
|
+
state = _ServiceLocator.Services.store.state;
|
|
621
|
+
_getVectorizeForDesig = (0, _Selectors.getVectorizeForDesignProductionMethods)(state, designProductionMethodIdentifier), currentVectorsRequired = _getVectorizeForDesig.currentVectorsRequired, newVectorsRequired = _getVectorizeForDesig.newVectorsRequired;
|
|
622
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
623
|
+
images = (0, _Selectors.getImagesByDesignArea)(state, designArea.identifier);
|
|
624
|
+
|
|
625
|
+
if (!(currentVectorsRequired && !newVectorsRequired && images.length)) {
|
|
626
|
+
_context2.next = 8;
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
_context2.next = 7;
|
|
631
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showSwitchToProductionMethodWithoutVectorization)());
|
|
632
|
+
|
|
633
|
+
case 7:
|
|
634
|
+
return _context2.abrupt("return", true);
|
|
635
|
+
|
|
636
|
+
case 8:
|
|
637
|
+
case "end":
|
|
638
|
+
return _context2.stop();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}, _callee2);
|
|
642
|
+
}));
|
|
643
|
+
|
|
644
|
+
return function (_x2) {
|
|
645
|
+
return _ref3.apply(this, arguments);
|
|
646
|
+
};
|
|
647
|
+
}());
|
|
648
|
+
|
|
649
|
+
_defineProperty(this, "handleDesignProductionMethodChangeFromNonVectorizationToVectorization", /*#__PURE__*/function () {
|
|
650
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(designProductionMethodIdentifier) {
|
|
651
|
+
var state, _getVectorizeForDesig2, currentVectorsRequired, newVectorsRequired, designArea, images;
|
|
652
|
+
|
|
653
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
654
|
+
while (1) {
|
|
655
|
+
switch (_context3.prev = _context3.next) {
|
|
656
|
+
case 0:
|
|
657
|
+
state = _ServiceLocator.Services.store.state;
|
|
658
|
+
_getVectorizeForDesig2 = (0, _Selectors.getVectorizeForDesignProductionMethods)(state, designProductionMethodIdentifier), currentVectorsRequired = _getVectorizeForDesig2.currentVectorsRequired, newVectorsRequired = _getVectorizeForDesig2.newVectorsRequired;
|
|
659
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
660
|
+
images = (0, _Selectors.getImagesByDesignArea)(state, designArea.identifier);
|
|
661
|
+
|
|
662
|
+
if (!(images.length === 1 && (!currentVectorsRequired && newVectorsRequired || !(0, _Selectors2.isColorPreviewCompatible)(state, images[0].imageData, designProductionMethodIdentifier)))) {
|
|
663
|
+
_context3.next = 8;
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
_context3.next = 7;
|
|
668
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showSwitchToProductionMethodWithVectorization)());
|
|
669
|
+
|
|
670
|
+
case 7:
|
|
671
|
+
return _context3.abrupt("return", true);
|
|
672
|
+
|
|
673
|
+
case 8:
|
|
674
|
+
case "end":
|
|
675
|
+
return _context3.stop();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}, _callee3);
|
|
679
|
+
}));
|
|
680
|
+
|
|
681
|
+
return function (_x3) {
|
|
682
|
+
return _ref4.apply(this, arguments);
|
|
683
|
+
};
|
|
684
|
+
}());
|
|
685
|
+
|
|
686
|
+
_defineProperty(this, "checkColorUsageForDesignProductionMethod", /*#__PURE__*/function () {
|
|
687
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(designProductionMethodIdentifier) {
|
|
688
|
+
var state, _getSelectedDesignAre2, maxColorAmount, designProductionMethod, newProductionMethod, newMaxColorAmount, currentVectorsRequired, newVectorsRequired, designArea, colorPreviewRequired, canvas, images, missingColorPalettesColors;
|
|
689
|
+
|
|
690
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
691
|
+
while (1) {
|
|
692
|
+
switch (_context4.prev = _context4.next) {
|
|
693
|
+
case 0:
|
|
694
|
+
state = _ServiceLocator.Services.store.state;
|
|
695
|
+
_getSelectedDesignAre2 = (0, _Selectors.getSelectedDesignAreaProperties)(state), maxColorAmount = _getSelectedDesignAre2.maxColorAmount, designProductionMethod = _getSelectedDesignAre2.designProductionMethod;
|
|
696
|
+
newProductionMethod = (0, _Selectors.getDesignProductionMethodByIdentifier)(state, designProductionMethodIdentifier);
|
|
697
|
+
newMaxColorAmount = parseInt((0, _get2["default"])(newProductionMethod, 'options.maxColorAmount', 0));
|
|
698
|
+
currentVectorsRequired = !!(0, _get2["default"])(designProductionMethod, 'options.vectorsRequired');
|
|
699
|
+
newVectorsRequired = !!(0, _get2["default"])(newProductionMethod, 'options.vectorsRequired');
|
|
700
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
701
|
+
colorPreviewRequired = (0, _Selectors.designProductionMethodHasEmbroideryVisualizationEffect)(newProductionMethod);
|
|
702
|
+
|
|
703
|
+
if (!(newMaxColorAmount !== 0 && newMaxColorAmount < maxColorAmount || !currentVectorsRequired && newVectorsRequired || colorPreviewRequired)) {
|
|
704
|
+
_context4.next = 15;
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
canvas = _this2._getCanvas(designArea);
|
|
709
|
+
images = canvas ? canvas.objects.filter(function (obj) {
|
|
710
|
+
if (obj.type !== 'Image') {
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
return !(0, _Selectors2.isEditableVectorImage)(obj.imageData.preview) || !(0, _Selectors2.isColorPreviewCompatible)(state, obj.imageData, designProductionMethodIdentifier);
|
|
715
|
+
}) : [];
|
|
716
|
+
|
|
717
|
+
if (!(images.length > 1)) {
|
|
718
|
+
_context4.next = 15;
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
_context4.next = 14;
|
|
723
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showProductionMethodRemoveImagesConfirm)());
|
|
724
|
+
|
|
725
|
+
case 14:
|
|
726
|
+
images.forEach(function (object) {
|
|
727
|
+
object.remove();
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
case 15:
|
|
731
|
+
missingColorPalettesColors = getMissingColorPalettesColors((0, _Selectors.getColorsWithPalette)(state), newProductionMethod.colorPalettes, !currentVectorsRequired && newVectorsRequired);
|
|
732
|
+
|
|
733
|
+
if (!missingColorPalettesColors.length) {
|
|
734
|
+
_context4.next = 22;
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if ((0, _Selectors.isColoringDisabled)(state, newProductionMethod.identifier)) {
|
|
739
|
+
_context4.next = 22;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
_context4.next = 20;
|
|
744
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showProductionMethodChangeColorsConfirm)());
|
|
745
|
+
|
|
746
|
+
case 20:
|
|
747
|
+
_context4.next = 22;
|
|
748
|
+
return _this2.replaceSelectedDesignAreaElementsColor(missingColorPalettesColors, newProductionMethod);
|
|
749
|
+
|
|
750
|
+
case 22:
|
|
751
|
+
case "end":
|
|
752
|
+
return _context4.stop();
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}, _callee4);
|
|
756
|
+
}));
|
|
757
|
+
|
|
758
|
+
return function (_x4) {
|
|
759
|
+
return _ref5.apply(this, arguments);
|
|
760
|
+
};
|
|
761
|
+
}());
|
|
762
|
+
|
|
763
|
+
_defineProperty(this, "replaceSelectedDesignAreaElementsColor", /*#__PURE__*/function () {
|
|
764
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(missingColorPalettesColors, designProductionMethod) {
|
|
765
|
+
var state, designArea, designData, objects, _iterator7, _step7, missingColor;
|
|
766
|
+
|
|
767
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
768
|
+
while (1) {
|
|
769
|
+
switch (_context5.prev = _context5.next) {
|
|
770
|
+
case 0:
|
|
771
|
+
state = _ServiceLocator.Services.store.state;
|
|
772
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
773
|
+
designData = (0, _Selectors.getDesignDataByDesignAreaIdentifier)(state, designArea.identifier);
|
|
774
|
+
objects = (0, _get2["default"])(designData, 'canvasData.objects', []);
|
|
775
|
+
_context5.next = 6;
|
|
776
|
+
return Promise.all(objects.filter(function (_ref7) {
|
|
777
|
+
var type = _ref7.type;
|
|
778
|
+
return type === 'Image';
|
|
779
|
+
}).map(function (_ref8) {
|
|
780
|
+
var imageData = _ref8.imageData;
|
|
781
|
+
return (0, _Selectors2.getUserImage)(state, imageData.identifier);
|
|
782
|
+
}).filter(function (image, idx, arr) {
|
|
783
|
+
return arr.indexOf(image) === idx && // uniq
|
|
784
|
+
!(0, _Selectors2.isColorMappingCompatible)(designProductionMethod.colorPalettes, (0, _get2["default"])(image, 'operations.vectorizeColorsMap'));
|
|
785
|
+
}).map(function (image) {
|
|
786
|
+
var operations = missingColorPalettesColors.reduce(function (currentOperations, missingColor) {
|
|
787
|
+
return (0, _Modifiers.replaceColorOnOperations)(currentOperations, missingColor.color, missingColor.closestColor);
|
|
788
|
+
}, image.operations);
|
|
789
|
+
return _ServiceLocator.Services.designData.editFile(operations, image, {
|
|
790
|
+
immediateCommit: true,
|
|
791
|
+
forceUpdate: true,
|
|
792
|
+
designProductionMethod: designProductionMethod
|
|
793
|
+
});
|
|
794
|
+
}));
|
|
795
|
+
|
|
796
|
+
case 6:
|
|
797
|
+
_iterator7 = _createForOfIteratorHelper(missingColorPalettesColors);
|
|
798
|
+
|
|
799
|
+
try {
|
|
800
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
801
|
+
missingColor = _step7.value;
|
|
802
|
+
|
|
803
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions.replaceDesignAreaTextsColor)(designArea.identifier, missingColor.color.identifier, {
|
|
804
|
+
rgb: missingColor.color.value,
|
|
805
|
+
hex: rgbStrToHex(missingColor.color.value)
|
|
806
|
+
}, missingColor.closestColor.identifier, missingColor.closestColor.value));
|
|
807
|
+
}
|
|
808
|
+
} catch (err) {
|
|
809
|
+
_iterator7.e(err);
|
|
810
|
+
} finally {
|
|
811
|
+
_iterator7.f();
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
_context5.next = 10;
|
|
815
|
+
return _this2.loadCanvasDataFromState([designArea]);
|
|
816
|
+
|
|
817
|
+
case 10:
|
|
818
|
+
case "end":
|
|
819
|
+
return _context5.stop();
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}, _callee5);
|
|
823
|
+
}));
|
|
824
|
+
|
|
825
|
+
return function (_x5, _x6) {
|
|
826
|
+
return _ref6.apply(this, arguments);
|
|
827
|
+
};
|
|
828
|
+
}());
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
_createClass(DesignDataService, [{
|
|
832
|
+
key: "init",
|
|
833
|
+
value: function init() {
|
|
834
|
+
var _this3 = this;
|
|
835
|
+
|
|
836
|
+
_ServiceLocator.Services.store.observeStore(function (state) {
|
|
837
|
+
return state.designArea.filteredDesignAreas;
|
|
838
|
+
}, /*#__PURE__*/function () {
|
|
839
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(filteredDesignAreas, prevDesignAreas) {
|
|
840
|
+
var initList, areasToLoad;
|
|
841
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
842
|
+
while (1) {
|
|
843
|
+
switch (_context6.prev = _context6.next) {
|
|
844
|
+
case 0:
|
|
845
|
+
_context6.prev = 0;
|
|
846
|
+
_context6.next = 3;
|
|
847
|
+
return _this3.initCanvases(filteredDesignAreas, prevDesignAreas);
|
|
848
|
+
|
|
849
|
+
case 3:
|
|
850
|
+
initList = _context6.sent;
|
|
851
|
+
// only the newly initialized canvases has to be loaded
|
|
852
|
+
areasToLoad = initList.filter(function (_ref10) {
|
|
853
|
+
var isNew = _ref10.isNew;
|
|
854
|
+
return isNew;
|
|
855
|
+
}).map(function (_ref11) {
|
|
856
|
+
var designArea = _ref11.designArea;
|
|
857
|
+
return designArea;
|
|
858
|
+
}); // the canvas data is there first with the configuration, but since the canvas instances are
|
|
859
|
+
// associated with the design areas the data can be loaded only when the design areas are available
|
|
860
|
+
|
|
861
|
+
_context6.t0 = !(0, _Selectors3.isDesignerProductPreviewMode)() && areasToLoad.length;
|
|
862
|
+
|
|
863
|
+
if (!_context6.t0) {
|
|
864
|
+
_context6.next = 9;
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
_context6.next = 9;
|
|
869
|
+
return _this3.loadCanvasDataFromState(areasToLoad);
|
|
870
|
+
|
|
871
|
+
case 9:
|
|
872
|
+
_this3.selectInitialDesignView();
|
|
873
|
+
|
|
874
|
+
_this3.designAreaListChangeListener(filteredDesignAreas, prevDesignAreas);
|
|
875
|
+
|
|
876
|
+
_context6.next = 16;
|
|
877
|
+
break;
|
|
878
|
+
|
|
879
|
+
case 13:
|
|
880
|
+
_context6.prev = 13;
|
|
881
|
+
_context6.t1 = _context6["catch"](0);
|
|
882
|
+
// eslint-disable-next-line no-console
|
|
883
|
+
console.error('Error occurred in processing design area list change:', _context6.t1);
|
|
884
|
+
|
|
885
|
+
case 16:
|
|
886
|
+
case "end":
|
|
887
|
+
return _context6.stop();
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}, _callee6, null, [[0, 13]]);
|
|
891
|
+
}));
|
|
892
|
+
|
|
893
|
+
return function (_x7, _x8) {
|
|
894
|
+
return _ref9.apply(this, arguments);
|
|
895
|
+
};
|
|
896
|
+
}());
|
|
897
|
+
|
|
898
|
+
_ServiceLocator.Services.store.observeStore(function (state) {
|
|
899
|
+
return state.designArea.maxZoom2d;
|
|
900
|
+
}, function (maxZoom2d) {
|
|
901
|
+
_ServiceLocator.Services.visualization.update2DMaxZoom(maxZoom2d);
|
|
902
|
+
}); // in calculation widget mode the canvas events should be disabled,
|
|
903
|
+
// the update is done directly after the modifications
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
if (isWidget(location.pathname)) {
|
|
907
|
+
this.toggleCanvasDataUpdate(false);
|
|
908
|
+
|
|
909
|
+
_ServiceLocator.Services.store.observeStore(_Selectors.getSelectedDesignProductionMethodIdentifier, function (selectedDesignProductionMethod) {
|
|
910
|
+
updateColorAmountOnDesignProductionMethodChange(selectedDesignProductionMethod);
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
_ServiceLocator.Services.store.observeStore(function (_ref12) {
|
|
915
|
+
var selectedoptionclassification = _ref12.configurator.selectedoptionclassification;
|
|
916
|
+
return selectedoptionclassification;
|
|
917
|
+
}, this.componentChangeHandler.bind(this));
|
|
918
|
+
|
|
919
|
+
(0, _setupDesigner["default"])(this);
|
|
920
|
+
}
|
|
921
|
+
}, {
|
|
922
|
+
key: "componentChangeHandler",
|
|
923
|
+
value: function componentChangeHandler(component, prevComponent) {
|
|
924
|
+
var identifier = (0, _get2["default"])(component, 'identifier');
|
|
925
|
+
|
|
926
|
+
if (identifier && identifier !== (0, _get2["default"])(prevComponent, 'identifier')) {
|
|
927
|
+
this.selectViewForComponent(component);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}, {
|
|
931
|
+
key: "selectViewForComponent",
|
|
932
|
+
value: function selectViewForComponent(component) {
|
|
933
|
+
var designViewIdentifier = // use the view linked to the component
|
|
934
|
+
(0, _get2["default"])(component, 'creatorView.identifier') || // if no linked view, use the last selected view
|
|
935
|
+
(0, _get2["default"])(_ServiceLocator.Services.store.state, 'designView.lastSelectedDesignView.identifier') || // if nothing was selected, use the initial design view
|
|
936
|
+
this.getInitialDesignViewIdentifier() || // if no initial design view, use the first view from the list
|
|
937
|
+
(0, _get2["default"])(_ServiceLocator.Services.store.state, 'designView.designViews[0].identifier');
|
|
938
|
+
var currentDesignViewIdentifier = (0, _get2["default"])(_ServiceLocator.Services.store.state, 'designView.selectedDesignView.identifier');
|
|
939
|
+
|
|
940
|
+
if (currentDesignViewIdentifier !== designViewIdentifier) {
|
|
941
|
+
var switchViewOnComponentSelection = (0, _configuration.getConf)('switchViewOnComponentSelection', true);
|
|
942
|
+
this.selectDesignView(designViewIdentifier, {
|
|
943
|
+
saveLast: !switchViewOnComponentSelection
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Register a function to be called to load the canvas data into the active canvas
|
|
949
|
+
* or into the one that's related to the provided design area.
|
|
950
|
+
* @param {function} fn
|
|
951
|
+
* @see loadCanvasDataFromState
|
|
952
|
+
* @see createCanvasChangeListener
|
|
953
|
+
*/
|
|
954
|
+
|
|
955
|
+
}, {
|
|
956
|
+
key: "registerLoadCanvasData",
|
|
957
|
+
value: function registerLoadCanvasData(fn) {
|
|
958
|
+
this._loadCanvasData = fn;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Register a function to be called to load the canvas data into the active canvas
|
|
962
|
+
* or into the one that's related to the provided design area.
|
|
963
|
+
* @param {function} fn
|
|
964
|
+
* @see updateCanvasData
|
|
965
|
+
* @see createCanvasChangeListener
|
|
966
|
+
*/
|
|
967
|
+
|
|
968
|
+
}, {
|
|
969
|
+
key: "registerUpdateCanvasData",
|
|
970
|
+
value: function registerUpdateCanvasData(fn) {
|
|
971
|
+
this._updateCanvasData = fn;
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Register a function to be called to get the canvas that is associated with the given design area
|
|
975
|
+
* @param {function} fn
|
|
976
|
+
* @see redrawAllDesignAreas
|
|
977
|
+
*/
|
|
978
|
+
|
|
979
|
+
}, {
|
|
980
|
+
key: "registerGetCanvas",
|
|
981
|
+
value: function registerGetCanvas(fn) {
|
|
982
|
+
this._getCanvas = fn;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Register a function to be called to initialize a canvas
|
|
986
|
+
* @param {function} fn
|
|
987
|
+
* @see initCanvases
|
|
988
|
+
*/
|
|
989
|
+
|
|
990
|
+
}, {
|
|
991
|
+
key: "registerInitCanvas",
|
|
992
|
+
value: function registerInitCanvas(fn) {
|
|
993
|
+
this._initCanvas = fn;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Register a function to be called to remove a canvas
|
|
997
|
+
* @param {function} fn
|
|
998
|
+
* @see initCanvases
|
|
999
|
+
*/
|
|
1000
|
+
|
|
1001
|
+
}, {
|
|
1002
|
+
key: "registerRemoveCanvas",
|
|
1003
|
+
value: function registerRemoveCanvas(fn) {
|
|
1004
|
+
this._removeCanvas = fn;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Calls the registered _initCanvas function for all design areas
|
|
1008
|
+
* @param designAreas
|
|
1009
|
+
* @param prevDesignAreas
|
|
1010
|
+
*/
|
|
1011
|
+
|
|
1012
|
+
}, {
|
|
1013
|
+
key: "initCanvases",
|
|
1014
|
+
value: function () {
|
|
1015
|
+
var _initCanvases = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(designAreas, prevDesignAreas) {
|
|
1016
|
+
var _this4 = this;
|
|
1017
|
+
|
|
1018
|
+
var state;
|
|
1019
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
1020
|
+
while (1) {
|
|
1021
|
+
switch (_context7.prev = _context7.next) {
|
|
1022
|
+
case 0:
|
|
1023
|
+
// clean up first: remove canvases that are not mapped to any design areas
|
|
1024
|
+
this._removeCanvas && prevDesignAreas.filter(function (prevArea) {
|
|
1025
|
+
return !designAreas.some(function (area) {
|
|
1026
|
+
return prevArea.identifier === area.identifier;
|
|
1027
|
+
});
|
|
1028
|
+
}).forEach(function (prevArea) {
|
|
1029
|
+
return _this4._removeCanvas(prevArea);
|
|
1030
|
+
});
|
|
1031
|
+
state = _ServiceLocator.Services.store.state;
|
|
1032
|
+
_context7.next = 4;
|
|
1033
|
+
return Promise.all(designAreas.map(function (designArea) {
|
|
1034
|
+
var maskData = (0, _Selectors.getMaskDataForDesignArea)(state, designArea);
|
|
1035
|
+
var canvasSize = (0, _Selectors.getCanvasSizeFromDesignArea)(state, designArea);
|
|
1036
|
+
var prevDesignArea = (0, _find["default"])(prevDesignAreas, {
|
|
1037
|
+
identifier: designArea.identifier
|
|
1038
|
+
});
|
|
1039
|
+
return _this4._initCanvas && _this4._initCanvas({
|
|
1040
|
+
designArea: designArea,
|
|
1041
|
+
prevDesignArea: prevDesignArea,
|
|
1042
|
+
canvasSize: canvasSize,
|
|
1043
|
+
maskData: maskData
|
|
1044
|
+
});
|
|
1045
|
+
}));
|
|
1046
|
+
|
|
1047
|
+
case 4:
|
|
1048
|
+
return _context7.abrupt("return", _context7.sent);
|
|
1049
|
+
|
|
1050
|
+
case 5:
|
|
1051
|
+
case "end":
|
|
1052
|
+
return _context7.stop();
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}, _callee7, this);
|
|
1056
|
+
}));
|
|
1057
|
+
|
|
1058
|
+
function initCanvases(_x9, _x10) {
|
|
1059
|
+
return _initCanvases.apply(this, arguments);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
return initCanvases;
|
|
1063
|
+
}()
|
|
1064
|
+
/**
|
|
1065
|
+
* Calls syncCanvases with the registered _loadCanvasData function
|
|
1066
|
+
* @param {array} designAreas
|
|
1067
|
+
*/
|
|
1068
|
+
|
|
1069
|
+
}, {
|
|
1070
|
+
key: "updateCanvasDataFromState",
|
|
1071
|
+
value: function () {
|
|
1072
|
+
var _updateCanvasDataFromState = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
|
|
1073
|
+
var designAreas,
|
|
1074
|
+
_args8 = arguments;
|
|
1075
|
+
return regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
1076
|
+
while (1) {
|
|
1077
|
+
switch (_context8.prev = _context8.next) {
|
|
1078
|
+
case 0:
|
|
1079
|
+
designAreas = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : this.getDesignAreas();
|
|
1080
|
+
_context8.next = 3;
|
|
1081
|
+
return this.syncCanvases(this._updateCanvasData, designAreas);
|
|
1082
|
+
|
|
1083
|
+
case 3:
|
|
1084
|
+
return _context8.abrupt("return", _context8.sent);
|
|
1085
|
+
|
|
1086
|
+
case 4:
|
|
1087
|
+
case "end":
|
|
1088
|
+
return _context8.stop();
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
}, _callee8, this);
|
|
1092
|
+
}));
|
|
1093
|
+
|
|
1094
|
+
function updateCanvasDataFromState() {
|
|
1095
|
+
return _updateCanvasDataFromState.apply(this, arguments);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
return updateCanvasDataFromState;
|
|
1099
|
+
}()
|
|
1100
|
+
/**
|
|
1101
|
+
* Calls syncCanvases with the registered _loadCanvasData function
|
|
1102
|
+
* @param {array} designAreas
|
|
1103
|
+
*/
|
|
1104
|
+
|
|
1105
|
+
}, {
|
|
1106
|
+
key: "loadCanvasDataFromState",
|
|
1107
|
+
value: function () {
|
|
1108
|
+
var _loadCanvasDataFromState = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
|
|
1109
|
+
var designAreas,
|
|
1110
|
+
_args9 = arguments;
|
|
1111
|
+
return regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
1112
|
+
while (1) {
|
|
1113
|
+
switch (_context9.prev = _context9.next) {
|
|
1114
|
+
case 0:
|
|
1115
|
+
designAreas = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : this.getDesignAreas();
|
|
1116
|
+
_context9.next = 3;
|
|
1117
|
+
return this.syncCanvases(this._loadCanvasData, designAreas);
|
|
1118
|
+
|
|
1119
|
+
case 3:
|
|
1120
|
+
return _context9.abrupt("return", _context9.sent);
|
|
1121
|
+
|
|
1122
|
+
case 4:
|
|
1123
|
+
case "end":
|
|
1124
|
+
return _context9.stop();
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}, _callee9, this);
|
|
1128
|
+
}));
|
|
1129
|
+
|
|
1130
|
+
function loadCanvasDataFromState() {
|
|
1131
|
+
return _loadCanvasDataFromState.apply(this, arguments);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
return loadCanvasDataFromState;
|
|
1135
|
+
}()
|
|
1136
|
+
/**
|
|
1137
|
+
* Calls the given updateFn function for all the design areas
|
|
1138
|
+
* which have associated canvasData in the configuration
|
|
1139
|
+
* @param {function} updateFn
|
|
1140
|
+
* @param {array} designAreas
|
|
1141
|
+
* @return {Promise<void>}
|
|
1142
|
+
*/
|
|
1143
|
+
|
|
1144
|
+
}, {
|
|
1145
|
+
key: "syncCanvases",
|
|
1146
|
+
value: function () {
|
|
1147
|
+
var _syncCanvases = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(updateFn, designAreas) {
|
|
1148
|
+
var _this5 = this;
|
|
1149
|
+
|
|
1150
|
+
var state;
|
|
1151
|
+
return regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1152
|
+
while (1) {
|
|
1153
|
+
switch (_context11.prev = _context11.next) {
|
|
1154
|
+
case 0:
|
|
1155
|
+
state = _ServiceLocator.Services.store.state;
|
|
1156
|
+
_context11.next = 3;
|
|
1157
|
+
return Promise.all(designAreas.map( /*#__PURE__*/function () {
|
|
1158
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(designArea) {
|
|
1159
|
+
var designData, canvasData, canvasSize;
|
|
1160
|
+
return regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
1161
|
+
while (1) {
|
|
1162
|
+
switch (_context10.prev = _context10.next) {
|
|
1163
|
+
case 0:
|
|
1164
|
+
designData = (0, _Selectors.getDesignDataByDesignAreaIdentifier)(state, designArea.identifier);
|
|
1165
|
+
canvasData = (0, _get2["default"])(designData, 'canvasData');
|
|
1166
|
+
|
|
1167
|
+
if (!canvasData) {
|
|
1168
|
+
_context10.next = 7;
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
_context10.next = 5;
|
|
1173
|
+
return preloadFonts(canvasData);
|
|
1174
|
+
|
|
1175
|
+
case 5:
|
|
1176
|
+
canvasSize = (0, _Selectors.getCanvasSizeFromDesignArea)(state, designArea);
|
|
1177
|
+
return _context10.abrupt("return", updateFn && updateFn(canvasData, designArea, canvasSize));
|
|
1178
|
+
|
|
1179
|
+
case 7:
|
|
1180
|
+
case "end":
|
|
1181
|
+
return _context10.stop();
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}, _callee10);
|
|
1185
|
+
}));
|
|
1186
|
+
|
|
1187
|
+
return function (_x13) {
|
|
1188
|
+
return _ref13.apply(this, arguments);
|
|
1189
|
+
};
|
|
1190
|
+
}()));
|
|
1191
|
+
|
|
1192
|
+
case 3:
|
|
1193
|
+
window.setTimeout(function () {
|
|
1194
|
+
_this5.updateVisualization();
|
|
1195
|
+
}, 100);
|
|
1196
|
+
|
|
1197
|
+
case 4:
|
|
1198
|
+
case "end":
|
|
1199
|
+
return _context11.stop();
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}, _callee11);
|
|
1203
|
+
}));
|
|
1204
|
+
|
|
1205
|
+
function syncCanvases(_x11, _x12) {
|
|
1206
|
+
return _syncCanvases.apply(this, arguments);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
return syncCanvases;
|
|
1210
|
+
}()
|
|
1211
|
+
}, {
|
|
1212
|
+
key: "getDesignAreas",
|
|
1213
|
+
value: function getDesignAreas() {
|
|
1214
|
+
var designArea = _ServiceLocator.Services.store.state.designArea;
|
|
1215
|
+
var filteredDesignAreas = designArea.filteredDesignAreas;
|
|
1216
|
+
return filteredDesignAreas;
|
|
1217
|
+
}
|
|
1218
|
+
}, {
|
|
1219
|
+
key: "getDesignAreaByIdentifier",
|
|
1220
|
+
value: function getDesignAreaByIdentifier(designAreaIdentifier) {
|
|
1221
|
+
return this.getDesignAreas().find(function (_ref14) {
|
|
1222
|
+
var identifier = _ref14.identifier;
|
|
1223
|
+
return identifier === designAreaIdentifier;
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
}, {
|
|
1227
|
+
key: "removeBulkNameItems",
|
|
1228
|
+
value: function removeBulkNameItems(designData) {
|
|
1229
|
+
var designArea = (0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state);
|
|
1230
|
+
var canvasData = designData.canvasData;
|
|
1231
|
+
|
|
1232
|
+
if (!canvasData) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
var objects = canvasData ? canvasData.objects.filter(function (obj) {
|
|
1237
|
+
return !obj.isBulkName;
|
|
1238
|
+
}) : [];
|
|
1239
|
+
this.setCanvasData(_objectSpread(_objectSpread({}, canvasData), {}, {
|
|
1240
|
+
objects: objects
|
|
1241
|
+
}));
|
|
1242
|
+
this.loadCanvasDataFromState([designArea]);
|
|
1243
|
+
}
|
|
1244
|
+
}, {
|
|
1245
|
+
key: "designAreaListChangeListener",
|
|
1246
|
+
value: function designAreaListChangeListener(filteredDesignAreas, prevDesignAreas) {
|
|
1247
|
+
// apply pre-selection only after loading the design areas
|
|
1248
|
+
if (filteredDesignAreas.length && !prevDesignAreas.length) {
|
|
1249
|
+
this.applyDesignAreaPreSelection(filteredDesignAreas);
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
_ServiceLocator.Services.visualization.updateDesignAreaList(filteredDesignAreas);
|
|
1253
|
+
}
|
|
1254
|
+
}, {
|
|
1255
|
+
key: "registerCanvasSerializer",
|
|
1256
|
+
value: function registerCanvasSerializer(fn) {
|
|
1257
|
+
this._serializeCanvas = fn;
|
|
1258
|
+
}
|
|
1259
|
+
}, {
|
|
1260
|
+
key: "updateCanvasData",
|
|
1261
|
+
value: function () {
|
|
1262
|
+
var _updateCanvasData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(canvas, eventData) {
|
|
1263
|
+
var canvasDataJSON, showAlert, _getDesignDataForSele, canvasData;
|
|
1264
|
+
|
|
1265
|
+
return regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1266
|
+
while (1) {
|
|
1267
|
+
switch (_context12.prev = _context12.next) {
|
|
1268
|
+
case 0:
|
|
1269
|
+
if (this._serializeCanvas) {
|
|
1270
|
+
_context12.next = 2;
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
throw new TypeError("The registerCanvasSerializer method has to be called first with a valid function!");
|
|
1275
|
+
|
|
1276
|
+
case 2:
|
|
1277
|
+
canvasDataJSON = this._serializeCanvas(canvas); // check the color usage before storing the canvas data, so the user can decide to
|
|
1278
|
+
// 1. proceed with more colors than the allowed or
|
|
1279
|
+
// 2. undo the changes
|
|
1280
|
+
//added check to avoid the checkColorUsage in Widget view(as evenData is undefined)
|
|
1281
|
+
|
|
1282
|
+
showAlert = eventData ? checkColorUsage(canvasDataJSON, eventData.changeEvent) : false;
|
|
1283
|
+
|
|
1284
|
+
if (!(showAlert && (0, _configuration.getConf)('displayColorAmountWarnings', true))) {
|
|
1285
|
+
_context12.next = 9;
|
|
1286
|
+
break;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
_ServiceLocator.Services.ui.reportError((0, _i18n.t)('colorAmountAlert.colorChangeReverted'));
|
|
1290
|
+
|
|
1291
|
+
_getDesignDataForSele = (0, _Selectors.getDesignDataForSelectedDesignArea)(_ServiceLocator.Services.store.state), canvasData = _getDesignDataForSele.canvasData; // Restore Graphics Editor state
|
|
1292
|
+
|
|
1293
|
+
this._loadCanvasData && this._loadCanvasData(canvasData);
|
|
1294
|
+
return _context12.abrupt("return");
|
|
1295
|
+
|
|
1296
|
+
case 9:
|
|
1297
|
+
this.setCanvasData(canvasDataJSON);
|
|
1298
|
+
|
|
1299
|
+
case 10:
|
|
1300
|
+
case "end":
|
|
1301
|
+
return _context12.stop();
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}, _callee12, this);
|
|
1305
|
+
}));
|
|
1306
|
+
|
|
1307
|
+
function updateCanvasData(_x14, _x15) {
|
|
1308
|
+
return _updateCanvasData.apply(this, arguments);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
return updateCanvasData;
|
|
1312
|
+
}()
|
|
1313
|
+
}, {
|
|
1314
|
+
key: "createCanvasChangeListener",
|
|
1315
|
+
value: function createCanvasChangeListener(_ref15) {
|
|
1316
|
+
var _this6 = this;
|
|
1317
|
+
|
|
1318
|
+
var syncCanvasChange = _ref15.syncCanvasChange;
|
|
1319
|
+
this._syncCanvasChange = syncCanvasChange;
|
|
1320
|
+
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
|
|
1321
|
+
var _args13 = arguments;
|
|
1322
|
+
return regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1323
|
+
while (1) {
|
|
1324
|
+
switch (_context13.prev = _context13.next) {
|
|
1325
|
+
case 0:
|
|
1326
|
+
if (!_this6._isCanvasDataUpdateEnabled) {
|
|
1327
|
+
_context13.next = 3;
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
_context13.next = 3;
|
|
1332
|
+
return _this6.updateCanvasData.apply(_this6, _args13);
|
|
1333
|
+
|
|
1334
|
+
case 3:
|
|
1335
|
+
case "end":
|
|
1336
|
+
return _context13.stop();
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}, _callee13);
|
|
1340
|
+
}));
|
|
1341
|
+
}
|
|
1342
|
+
}, {
|
|
1343
|
+
key: "syncCanvasChange",
|
|
1344
|
+
value: function syncCanvasChange() {
|
|
1345
|
+
this._syncCanvasChange && this._syncCanvasChange();
|
|
1346
|
+
}
|
|
1347
|
+
}, {
|
|
1348
|
+
key: "toggleCanvasDataUpdate",
|
|
1349
|
+
value: function toggleCanvasDataUpdate() {
|
|
1350
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !this._isCanvasDataUpdateEnabled;
|
|
1351
|
+
this._isCanvasDataUpdateEnabled = value;
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Call the registered listener function when the design area changes
|
|
1355
|
+
* Passes the selected design area and the canvas size to the listener function
|
|
1356
|
+
* @param listenerFn
|
|
1357
|
+
*/
|
|
1358
|
+
|
|
1359
|
+
}, {
|
|
1360
|
+
key: "registerDesignAreaChangeListener",
|
|
1361
|
+
value: function registerDesignAreaChangeListener(listenerFn) {
|
|
1362
|
+
_ServiceLocator.Services.store.observeStore(_Selectors.getSelectedDesignArea, function (selectedDesignArea, prevSelectedDesignArea) {
|
|
1363
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1364
|
+
var canvasSize = (0, _Selectors.getCanvasSizeFromDesignArea)(state, selectedDesignArea);
|
|
1365
|
+
listenerFn({
|
|
1366
|
+
selectedDesignArea: selectedDesignArea,
|
|
1367
|
+
prevSelectedDesignArea: prevSelectedDesignArea,
|
|
1368
|
+
canvasSize: canvasSize
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
}, {
|
|
1373
|
+
key: "registerDesignProductionMethodChangeListener",
|
|
1374
|
+
value: function registerDesignProductionMethodChangeListener(listenerFn) {
|
|
1375
|
+
_ServiceLocator.Services.store.observeStore(_Selectors.getSelectedDesignProductionMethodIdentifier, listenerFn);
|
|
1376
|
+
}
|
|
1377
|
+
}, {
|
|
1378
|
+
key: "getDesignAreaCanvases",
|
|
1379
|
+
value: function getDesignAreaCanvases() {
|
|
1380
|
+
var _this7 = this;
|
|
1381
|
+
|
|
1382
|
+
return this.getDesignAreas().map(function (designArea) {
|
|
1383
|
+
return {
|
|
1384
|
+
designArea: designArea,
|
|
1385
|
+
canvas: _this7._getCanvas(designArea)
|
|
1386
|
+
};
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
}, {
|
|
1390
|
+
key: "removeAllDesignAreaPlaceholders",
|
|
1391
|
+
value: function removeAllDesignAreaPlaceholders(configuration) {
|
|
1392
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1393
|
+
var updatedConfiguration = configuration;
|
|
1394
|
+
|
|
1395
|
+
if (!isWidget(location.pathname)) {
|
|
1396
|
+
var designAreas = (0, _get2["default"])(state, 'designArea.filteredDesignAreas', []);
|
|
1397
|
+
designAreas.forEach(function (designArea) {
|
|
1398
|
+
var _get = (0, _get2["default"])(updatedConfiguration, "designdata.".concat(designArea.identifier), {}),
|
|
1399
|
+
canvasData = _get.canvasData;
|
|
1400
|
+
|
|
1401
|
+
if (canvasData) {
|
|
1402
|
+
var objects = canvasData.objects.filter(function (obj) {
|
|
1403
|
+
if (!(0, _Selectors5.isPlaceholderObject)(obj)) {
|
|
1404
|
+
return true;
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
updatedConfiguration = _objectSpread(_objectSpread({}, updatedConfiguration), {}, {
|
|
1408
|
+
designdata: _objectSpread(_objectSpread({}, updatedConfiguration.designdata), {}, _defineProperty({}, designArea.identifier, _objectSpread(_objectSpread({}, updatedConfiguration.designdata[designArea.identifier]), {}, {
|
|
1409
|
+
canvasData: objects.length > 0 ? _objectSpread(_objectSpread({}, canvasData), {}, {
|
|
1410
|
+
objects: objects
|
|
1411
|
+
}) : null
|
|
1412
|
+
})))
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
return updatedConfiguration;
|
|
1419
|
+
}
|
|
1420
|
+
}, {
|
|
1421
|
+
key: "removeDesignAreaPlaceholders",
|
|
1422
|
+
value: function removeDesignAreaPlaceholders() {
|
|
1423
|
+
var removeTextPlaceholders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1424
|
+
var removeImagePlaceholders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1425
|
+
var designArea = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state);
|
|
1426
|
+
this.syncCanvasChange();
|
|
1427
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1428
|
+
|
|
1429
|
+
if (!designArea.identifier) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
var _getDesignDataByDesig = (0, _Selectors.getDesignDataByDesignAreaIdentifier)(state, designArea.identifier),
|
|
1434
|
+
canvasData = _getDesignDataByDesig.canvasData;
|
|
1435
|
+
|
|
1436
|
+
if (!canvasData) {
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
var objects = canvasData.objects.filter(function (obj) {
|
|
1441
|
+
if (removeTextPlaceholders && obj.type === 'Text') {
|
|
1442
|
+
return !(0, _Selectors.isPlaceholderContent)(obj.content) && (0, _Selectors.contentHasText)(obj.content);
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
if (removeImagePlaceholders && obj.type === 'Image') {
|
|
1446
|
+
return !obj.imageData.isPlaceHolderImage;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
return true;
|
|
1450
|
+
}); // replace objects and sync canvas if something was removed
|
|
1451
|
+
|
|
1452
|
+
if (objects.length !== canvasData.objects.length) {
|
|
1453
|
+
this.setCanvasData(_objectSpread(_objectSpread({}, canvasData), {}, {
|
|
1454
|
+
objects: objects
|
|
1455
|
+
}));
|
|
1456
|
+
this.loadCanvasDataFromState([designArea]);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}, {
|
|
1460
|
+
key: "selectDesignArea",
|
|
1461
|
+
value: function selectDesignArea(identifier) {
|
|
1462
|
+
_ServiceLocator.Services.ui.show('designer');
|
|
1463
|
+
|
|
1464
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions3.selectDesignArea)(identifier));
|
|
1465
|
+
|
|
1466
|
+
if (!this.isInPreviewMode) {
|
|
1467
|
+
_ServiceLocator.Services.visualization.disableUserMovement();
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}, {
|
|
1471
|
+
key: "selectDesignView",
|
|
1472
|
+
value: function selectDesignView(identifier, options) {
|
|
1473
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions4.selectDesignView)(identifier, options));
|
|
1474
|
+
}
|
|
1475
|
+
}, {
|
|
1476
|
+
key: "getInitialDesignViewIdentifier",
|
|
1477
|
+
value: function getInitialDesignViewIdentifier() {
|
|
1478
|
+
var designAreaToShow;
|
|
1479
|
+
var preselectedDesignArea = (0, _get2["default"])((0, _configuration.getConf)('designerPreSelection', {}), 'designAreas[0].identifier');
|
|
1480
|
+
|
|
1481
|
+
if (preselectedDesignArea) {
|
|
1482
|
+
designAreaToShow = this.getDesignAreaByIdentifier(preselectedDesignArea);
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
if (!designAreaToShow) {
|
|
1486
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1487
|
+
var designAreaIdentifier = (0, _Selectors.getSelectedDesignArea)(state).identifier || (0, _Selectors.getDefaultDesignAreaIdentifierFromProductionMethod)(state);
|
|
1488
|
+
designAreaToShow = this.getDesignAreaByIdentifier(designAreaIdentifier) || (0, _first["default"])(state.designArea.filteredDesignAreas);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
if (designAreaToShow) {
|
|
1492
|
+
return designAreaToShow.designView.identifier;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
return false;
|
|
1496
|
+
}
|
|
1497
|
+
}, {
|
|
1498
|
+
key: "selectInitialDesignView",
|
|
1499
|
+
value: function selectInitialDesignView() {
|
|
1500
|
+
var initialDesignViewIdentifier = this.getInitialDesignViewIdentifier();
|
|
1501
|
+
initialDesignViewIdentifier && this.selectDesignView(initialDesignViewIdentifier);
|
|
1502
|
+
}
|
|
1503
|
+
}, {
|
|
1504
|
+
key: "selectFirstDesignArea",
|
|
1505
|
+
value: function selectFirstDesignArea() {
|
|
1506
|
+
var firstDesignAreaIdentifier = (0, _get2["default"])(_ServiceLocator.Services.store.state, 'designArea.filteredDesignAreas[0].identifier');
|
|
1507
|
+
|
|
1508
|
+
if (firstDesignAreaIdentifier) {
|
|
1509
|
+
this.selectDesignArea(firstDesignAreaIdentifier);
|
|
1510
|
+
} else {
|
|
1511
|
+
// eslint-disable-next-line no-console
|
|
1512
|
+
console.log('There is no design area to select.');
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}, {
|
|
1516
|
+
key: "clearDesignAreaSelection",
|
|
1517
|
+
value: function clearDesignAreaSelection() {
|
|
1518
|
+
this.removeDesignAreaPlaceholders();
|
|
1519
|
+
var hasActiveDesignArea = !(0, _isEmpty["default"])(_ServiceLocator.Services.visualization.getActiveDesignArea()); // If default Design Area is set then the clear would skip as there will be no selected designArea
|
|
1520
|
+
// So forcing clearDesignAreaSelection when there is ActiveDesignArea(Default).
|
|
1521
|
+
|
|
1522
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions3.clearDesignAreaSelection)(hasActiveDesignArea));
|
|
1523
|
+
|
|
1524
|
+
_ServiceLocator.Services.visualization.enableUserMovement();
|
|
1525
|
+
|
|
1526
|
+
_ServiceLocator.Services.visualization.freeUserMovement();
|
|
1527
|
+
}
|
|
1528
|
+
}, {
|
|
1529
|
+
key: "openDesignAreaEditor",
|
|
1530
|
+
value: function openDesignAreaEditor() {
|
|
1531
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1532
|
+
|
|
1533
|
+
_ServiceLocator.Services.ui.show('designer');
|
|
1534
|
+
|
|
1535
|
+
var designAreaIdentifier = (0, _Selectors.getDesignAreaIdentifierToOpen)(state);
|
|
1536
|
+
this.clearDesignAreaSelection();
|
|
1537
|
+
|
|
1538
|
+
if (designAreaIdentifier) {
|
|
1539
|
+
this.selectDesignArea(designAreaIdentifier);
|
|
1540
|
+
} else {
|
|
1541
|
+
this.selectFirstDesignArea();
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}, {
|
|
1545
|
+
key: "closeDesignAreaEditor",
|
|
1546
|
+
value: function closeDesignAreaEditor() {
|
|
1547
|
+
if (_ServiceLocator.Services.ui.isVisible('designer')) {
|
|
1548
|
+
_ServiceLocator.Services.ui.hide('designer');
|
|
1549
|
+
|
|
1550
|
+
_ServiceLocator.Services.visualization.enableUserMovement();
|
|
1551
|
+
|
|
1552
|
+
_ServiceLocator.Services.visualization.restrictUserMovement();
|
|
1553
|
+
|
|
1554
|
+
_ServiceLocator.Services.designData.clearSelectionOnCurrentDesignArea(); // the canvases should be drawn on the textures to see the changes that were made in the editor
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
_ServiceLocator.Services.designData.updateVisualization();
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* General close handler for design area editor, that calls the correct actions based on the state
|
|
1562
|
+
* @return {boolean}
|
|
1563
|
+
*/
|
|
1564
|
+
|
|
1565
|
+
}, {
|
|
1566
|
+
key: "handleCloseIfNeeded",
|
|
1567
|
+
value: function handleCloseIfNeeded() {
|
|
1568
|
+
var state = _ServiceLocator.Services.store.state; // if it's 3D and the editor is open, then close it, so we can enter into the "closer look" mode
|
|
1569
|
+
// this lets the user see the visualization in the same view, but without the design area editor
|
|
1570
|
+
|
|
1571
|
+
if ((0, _Selectors3.visualizationModeCheck)(state).is3D() && _ServiceLocator.Services.ui.isVisible('designer')) {
|
|
1572
|
+
_ServiceLocator.Services.designData.closeDesignAreaEditor();
|
|
1573
|
+
|
|
1574
|
+
return true;
|
|
1575
|
+
} // in this case it's 2D, or the design area was already closed by the previous block
|
|
1576
|
+
// so the second "click away" should clear the selection (which will trigger switching to default view)
|
|
1577
|
+
// if a design area was selected, clear the selection
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
if ((0, _Selectors.isAnyDesignAreaSelected)(state)) {
|
|
1581
|
+
_ServiceLocator.Services.designData.clearDesignAreaSelection();
|
|
1582
|
+
|
|
1583
|
+
return true;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
return false;
|
|
1587
|
+
}
|
|
1588
|
+
}, {
|
|
1589
|
+
key: "vectorizeSingleImageAndShowEditDialog",
|
|
1590
|
+
value: function () {
|
|
1591
|
+
var _vectorizeSingleImageAndShowEditDialog = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(identifier) {
|
|
1592
|
+
var showImageEditDialog, state, designArea, canvas, images, operations, imageData, imageToSelect;
|
|
1593
|
+
return regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1594
|
+
while (1) {
|
|
1595
|
+
switch (_context14.prev = _context14.next) {
|
|
1596
|
+
case 0:
|
|
1597
|
+
_context14.next = 2;
|
|
1598
|
+
return this.handleDesignProductionMethodChangeFromNonVectorizationToVectorization(identifier);
|
|
1599
|
+
|
|
1600
|
+
case 2:
|
|
1601
|
+
showImageEditDialog = _context14.sent;
|
|
1602
|
+
|
|
1603
|
+
if (!showImageEditDialog) {
|
|
1604
|
+
_context14.next = 23;
|
|
1605
|
+
break;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
_ServiceLocator.Services.ui.show('globalLoader');
|
|
1609
|
+
|
|
1610
|
+
state = _ServiceLocator.Services.store.state;
|
|
1611
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
1612
|
+
canvas = this._getCanvas(designArea);
|
|
1613
|
+
images = (0, _Selectors.getImagesByDesignArea)(state, designArea.identifier);
|
|
1614
|
+
operations = _objectSpread(_objectSpread({}, images[0].imageData.operations), {}, {
|
|
1615
|
+
vectorize: true
|
|
1616
|
+
});
|
|
1617
|
+
imageData = images[0].imageData;
|
|
1618
|
+
_context14.prev = 11;
|
|
1619
|
+
|
|
1620
|
+
if (!imageData.isPlaceHolderImage) {
|
|
1621
|
+
_context14.next = 14;
|
|
1622
|
+
break;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
return _context14.abrupt("return");
|
|
1626
|
+
|
|
1627
|
+
case 14:
|
|
1628
|
+
_context14.next = 16;
|
|
1629
|
+
return _ServiceLocator.Services.designData.editFile(operations, imageData, {
|
|
1630
|
+
immediateCommit: true
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
case 16:
|
|
1634
|
+
imageToSelect = canvas.objects.filter(function (object) {
|
|
1635
|
+
return object.type === 'Image';
|
|
1636
|
+
}).find(function (obj) {
|
|
1637
|
+
return obj._imageData.identifier === imageData.identifier;
|
|
1638
|
+
});
|
|
1639
|
+
imageToSelect.selected = true;
|
|
1640
|
+
_context14.next = 20;
|
|
1641
|
+
return _ServiceLocator.Services.designer.openImageEditDialog(images[0].imageData.identifier, canvas, {
|
|
1642
|
+
placeholderImageUpdate: false,
|
|
1643
|
+
submitOnExitClick: true
|
|
1644
|
+
});
|
|
1645
|
+
|
|
1646
|
+
case 20:
|
|
1647
|
+
_context14.prev = 20;
|
|
1648
|
+
|
|
1649
|
+
_ServiceLocator.Services.ui.hide('globalLoader');
|
|
1650
|
+
|
|
1651
|
+
return _context14.finish(20);
|
|
1652
|
+
|
|
1653
|
+
case 23:
|
|
1654
|
+
case "end":
|
|
1655
|
+
return _context14.stop();
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}, _callee14, this, [[11,, 20, 23]]);
|
|
1659
|
+
}));
|
|
1660
|
+
|
|
1661
|
+
function vectorizeSingleImageAndShowEditDialog(_x16) {
|
|
1662
|
+
return _vectorizeSingleImageAndShowEditDialog.apply(this, arguments);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
return vectorizeSingleImageAndShowEditDialog;
|
|
1666
|
+
}()
|
|
1667
|
+
}, {
|
|
1668
|
+
key: "restoreVectorizedImages",
|
|
1669
|
+
value: function () {
|
|
1670
|
+
var _restoreVectorizedImages = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(identifier) {
|
|
1671
|
+
var displayImagesAsUnVectorized, state, designArea, images, _iterator8, _step8, image, operations;
|
|
1672
|
+
|
|
1673
|
+
return regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1674
|
+
while (1) {
|
|
1675
|
+
switch (_context15.prev = _context15.next) {
|
|
1676
|
+
case 0:
|
|
1677
|
+
_context15.next = 2;
|
|
1678
|
+
return this.handleDesignProductionMethodChangeFromVectorizationToNonVectorization(identifier);
|
|
1679
|
+
|
|
1680
|
+
case 2:
|
|
1681
|
+
displayImagesAsUnVectorized = _context15.sent;
|
|
1682
|
+
|
|
1683
|
+
if (!displayImagesAsUnVectorized) {
|
|
1684
|
+
_context15.next = 28;
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
state = _ServiceLocator.Services.store.state;
|
|
1689
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
1690
|
+
images = (0, _Selectors.getImagesByDesignArea)(state, designArea.identifier);
|
|
1691
|
+
images = images.filter(function (img) {
|
|
1692
|
+
return !(0, _get2["default"])(img, 'imageData.isPlaceHolderImage', false);
|
|
1693
|
+
}); //excluding placeHolderImage from executing edit operations
|
|
1694
|
+
|
|
1695
|
+
_iterator8 = _createForOfIteratorHelper(images);
|
|
1696
|
+
_context15.prev = 9;
|
|
1697
|
+
|
|
1698
|
+
_iterator8.s();
|
|
1699
|
+
|
|
1700
|
+
case 11:
|
|
1701
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1702
|
+
_context15.next = 18;
|
|
1703
|
+
break;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
image = _step8.value;
|
|
1707
|
+
operations = (0, _Modifiers.removeVectorizeFromOperations)(image.imageData.operations);
|
|
1708
|
+
_context15.next = 16;
|
|
1709
|
+
return _ServiceLocator.Services.designData.editFile(operations, image.imageData, {
|
|
1710
|
+
immediateCommit: true,
|
|
1711
|
+
displayColorPreview: (0, _configuration.getConf)('autoPreviewVectorization', true)
|
|
1712
|
+
});
|
|
1713
|
+
|
|
1714
|
+
case 16:
|
|
1715
|
+
_context15.next = 11;
|
|
1716
|
+
break;
|
|
1717
|
+
|
|
1718
|
+
case 18:
|
|
1719
|
+
_context15.next = 23;
|
|
1720
|
+
break;
|
|
1721
|
+
|
|
1722
|
+
case 20:
|
|
1723
|
+
_context15.prev = 20;
|
|
1724
|
+
_context15.t0 = _context15["catch"](9);
|
|
1725
|
+
|
|
1726
|
+
_iterator8.e(_context15.t0);
|
|
1727
|
+
|
|
1728
|
+
case 23:
|
|
1729
|
+
_context15.prev = 23;
|
|
1730
|
+
|
|
1731
|
+
_iterator8.f();
|
|
1732
|
+
|
|
1733
|
+
return _context15.finish(23);
|
|
1734
|
+
|
|
1735
|
+
case 26:
|
|
1736
|
+
_context15.next = 28;
|
|
1737
|
+
return this.loadCanvasDataFromState([designArea]);
|
|
1738
|
+
|
|
1739
|
+
case 28:
|
|
1740
|
+
case "end":
|
|
1741
|
+
return _context15.stop();
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}, _callee15, this, [[9, 20, 23, 26]]);
|
|
1745
|
+
}));
|
|
1746
|
+
|
|
1747
|
+
function restoreVectorizedImages(_x17) {
|
|
1748
|
+
return _restoreVectorizedImages.apply(this, arguments);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
return restoreVectorizedImages;
|
|
1752
|
+
}()
|
|
1753
|
+
}, {
|
|
1754
|
+
key: "updateObjectsAfterProductionMethodChange",
|
|
1755
|
+
value: function () {
|
|
1756
|
+
var _updateObjectsAfterProductionMethodChange = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(oldProductionMethod, newProductionMethod) {
|
|
1757
|
+
var _getDesignDataForSele2, canvasData, objects, newObjects, designArea;
|
|
1758
|
+
|
|
1759
|
+
return regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1760
|
+
while (1) {
|
|
1761
|
+
switch (_context16.prev = _context16.next) {
|
|
1762
|
+
case 0:
|
|
1763
|
+
_getDesignDataForSele2 = (0, _Selectors.getDesignDataForSelectedDesignArea)(_ServiceLocator.Services.store.state), canvasData = _getDesignDataForSele2.canvasData;
|
|
1764
|
+
|
|
1765
|
+
if (canvasData) {
|
|
1766
|
+
_context16.next = 3;
|
|
1767
|
+
break;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
return _context16.abrupt("return");
|
|
1771
|
+
|
|
1772
|
+
case 3:
|
|
1773
|
+
objects = canvasData.objects;
|
|
1774
|
+
newObjects = (0, _Modifiers.applyProductionMethodChangeToCanvasObjects)(newProductionMethod, oldProductionMethod, objects);
|
|
1775
|
+
|
|
1776
|
+
if (!(newObjects === objects)) {
|
|
1777
|
+
_context16.next = 7;
|
|
1778
|
+
break;
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
return _context16.abrupt("return");
|
|
1782
|
+
|
|
1783
|
+
case 7:
|
|
1784
|
+
this.setCanvasData(_objectSpread(_objectSpread({}, canvasData), {}, {
|
|
1785
|
+
objects: newObjects
|
|
1786
|
+
}));
|
|
1787
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state);
|
|
1788
|
+
_context16.next = 11;
|
|
1789
|
+
return this.updateCanvasDataFromState([designArea]);
|
|
1790
|
+
|
|
1791
|
+
case 11:
|
|
1792
|
+
case "end":
|
|
1793
|
+
return _context16.stop();
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}, _callee16, this);
|
|
1797
|
+
}));
|
|
1798
|
+
|
|
1799
|
+
function updateObjectsAfterProductionMethodChange(_x18, _x19) {
|
|
1800
|
+
return _updateObjectsAfterProductionMethodChange.apply(this, arguments);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
return updateObjectsAfterProductionMethodChange;
|
|
1804
|
+
}()
|
|
1805
|
+
}, {
|
|
1806
|
+
key: "checkDesignElementRestrictions",
|
|
1807
|
+
value: function checkDesignElementRestrictions(targetDesignProductionMethodIdentifier) {
|
|
1808
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1809
|
+
var designData = (0, _Selectors.getDesignDataForSelectedDesignArea)(state);
|
|
1810
|
+
var designProductionMethod = (0, _Selectors.getDesignProductionMethodByIdentifier)(state, targetDesignProductionMethodIdentifier);
|
|
1811
|
+
var result = (0, _DesignElementSelectors.checkDesignElementRestrictionsWithRemovalCount)(designData, designProductionMethod);
|
|
1812
|
+
|
|
1813
|
+
if (result) {
|
|
1814
|
+
_ServiceLocator.Services.ui.reportError((0, _i18n.t)("designElementRestrictions.productionMethodSwitchMessages.".concat(result.type).concat(result.max === 0 ? '_0' : result.toBeRemovedCount === 1 ? '_1' : ''), result));
|
|
1815
|
+
|
|
1816
|
+
return false;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
return true;
|
|
1820
|
+
}
|
|
1821
|
+
}, {
|
|
1822
|
+
key: "setDesignProductionMethod",
|
|
1823
|
+
value: function () {
|
|
1824
|
+
var _setDesignProductionMethod2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(identifier) {
|
|
1825
|
+
var state, designData, selectedDesignProduction, bulkNameSelected, fontSizeMin, smallestFontSize, oldDesignProductionMethod;
|
|
1826
|
+
return regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1827
|
+
while (1) {
|
|
1828
|
+
switch (_context17.prev = _context17.next) {
|
|
1829
|
+
case 0:
|
|
1830
|
+
if (this.checkDesignElementRestrictions(identifier)) {
|
|
1831
|
+
_context17.next = 2;
|
|
1832
|
+
break;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
return _context17.abrupt("return");
|
|
1836
|
+
|
|
1837
|
+
case 2:
|
|
1838
|
+
this.clearSelectionOnCurrentDesignArea(); // check if the selected design production method has a higher minimum font size
|
|
1839
|
+
// than any of the text elements on the canvas
|
|
1840
|
+
|
|
1841
|
+
state = _ServiceLocator.Services.store.state;
|
|
1842
|
+
designData = (0, _Selectors.getDesignDataForSelectedDesignArea)(state);
|
|
1843
|
+
selectedDesignProduction = (0, _Selectors.getDesignProductionMethodByIdentifier)(state, identifier);
|
|
1844
|
+
bulkNameSelected = (0, _Selectors.hasSelectedBulkName)(designData);
|
|
1845
|
+
|
|
1846
|
+
if (isWidget(location.pathname)) {
|
|
1847
|
+
_context17.next = 44;
|
|
1848
|
+
break;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
fontSizeMin = (0, _Selectors.getFontSizeMin)(state, identifier);
|
|
1852
|
+
smallestFontSize = (0, _Selectors.findSmallestFontSizeInCanvasData)(designData.canvasData);
|
|
1853
|
+
_context17.prev = 10;
|
|
1854
|
+
_context17.t0 = smallestFontSize < fontSizeMin;
|
|
1855
|
+
|
|
1856
|
+
if (!_context17.t0) {
|
|
1857
|
+
_context17.next = 15;
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
_context17.next = 15;
|
|
1862
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showMinFontSizeConfirm)(fontSizeMin));
|
|
1863
|
+
|
|
1864
|
+
case 15:
|
|
1865
|
+
_context17.next = 20;
|
|
1866
|
+
break;
|
|
1867
|
+
|
|
1868
|
+
case 17:
|
|
1869
|
+
_context17.prev = 17;
|
|
1870
|
+
_context17.t1 = _context17["catch"](10);
|
|
1871
|
+
return _context17.abrupt("return");
|
|
1872
|
+
|
|
1873
|
+
case 20:
|
|
1874
|
+
_context17.prev = 20;
|
|
1875
|
+
_context17.next = 23;
|
|
1876
|
+
return this.checkColorUsageForDesignProductionMethod(identifier);
|
|
1877
|
+
|
|
1878
|
+
case 23:
|
|
1879
|
+
_context17.next = 25;
|
|
1880
|
+
return this.vectorizeSingleImageAndShowEditDialog(identifier);
|
|
1881
|
+
|
|
1882
|
+
case 25:
|
|
1883
|
+
_context17.next = 27;
|
|
1884
|
+
return this.restoreVectorizedImages(identifier);
|
|
1885
|
+
|
|
1886
|
+
case 27:
|
|
1887
|
+
_context17.next = 34;
|
|
1888
|
+
break;
|
|
1889
|
+
|
|
1890
|
+
case 29:
|
|
1891
|
+
_context17.prev = 29;
|
|
1892
|
+
_context17.t2 = _context17["catch"](20);
|
|
1893
|
+
|
|
1894
|
+
if (!(0, _Actions5.isConfirmResult)(_context17.t2)) {
|
|
1895
|
+
_context17.next = 33;
|
|
1896
|
+
break;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
return _context17.abrupt("return");
|
|
1900
|
+
|
|
1901
|
+
case 33:
|
|
1902
|
+
throw _context17.t2;
|
|
1903
|
+
|
|
1904
|
+
case 34:
|
|
1905
|
+
_context17.prev = 34;
|
|
1906
|
+
_context17.t3 = bulkNameSelected && !selectedDesignProduction.allowBulkNames;
|
|
1907
|
+
|
|
1908
|
+
if (!_context17.t3) {
|
|
1909
|
+
_context17.next = 39;
|
|
1910
|
+
break;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
_context17.next = 39;
|
|
1914
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showProductionMethodChangeConfirm)());
|
|
1915
|
+
|
|
1916
|
+
case 39:
|
|
1917
|
+
_context17.next = 44;
|
|
1918
|
+
break;
|
|
1919
|
+
|
|
1920
|
+
case 41:
|
|
1921
|
+
_context17.prev = 41;
|
|
1922
|
+
_context17.t4 = _context17["catch"](34);
|
|
1923
|
+
return _context17.abrupt("return");
|
|
1924
|
+
|
|
1925
|
+
case 44:
|
|
1926
|
+
oldDesignProductionMethod = (0, _Selectors.getSelectedDesignProductionMethod)(state);
|
|
1927
|
+
|
|
1928
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions.setDesignProductionMethod)(identifier));
|
|
1929
|
+
|
|
1930
|
+
if ((0, _Selectors.isCanvasUpdateRequired)((0, _Selectors.getSelectedDesignArea)(state), selectedDesignProduction)) {
|
|
1931
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions3.recalculateDesignArea)());
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
this.updateMaskToCurrentDesignProductionMethod();
|
|
1935
|
+
|
|
1936
|
+
if (bulkNameSelected && !selectedDesignProduction.allowBulkNames) {
|
|
1937
|
+
this.removeBulkNameItems(designData);
|
|
1938
|
+
!(0, _Selectors.isBulkNamesSelected)(_ServiceLocator.Services.store.state.configurator) && _ServiceLocator.Services.configurator.clearBulkNames();
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
_context17.next = 51;
|
|
1942
|
+
return this.updateObjectsAfterProductionMethodChange(oldDesignProductionMethod, selectedDesignProduction);
|
|
1943
|
+
|
|
1944
|
+
case 51:
|
|
1945
|
+
case "end":
|
|
1946
|
+
return _context17.stop();
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}, _callee17, this, [[10, 17], [20, 29], [34, 41]]);
|
|
1950
|
+
}));
|
|
1951
|
+
|
|
1952
|
+
function setDesignProductionMethod(_x20) {
|
|
1953
|
+
return _setDesignProductionMethod2.apply(this, arguments);
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
return setDesignProductionMethod;
|
|
1957
|
+
}()
|
|
1958
|
+
}, {
|
|
1959
|
+
key: "updateMaskToCurrentDesignProductionMethod",
|
|
1960
|
+
value: function updateMaskToCurrentDesignProductionMethod() {
|
|
1961
|
+
// the mask should be updated when switching design production method
|
|
1962
|
+
var state = _ServiceLocator.Services.store.state;
|
|
1963
|
+
var designArea = (0, _Selectors.getSelectedDesignArea)(state);
|
|
1964
|
+
|
|
1965
|
+
var canvas = this._getCanvas(designArea);
|
|
1966
|
+
|
|
1967
|
+
var maskHandler = canvas.getMaskHandler();
|
|
1968
|
+
var maskData = (0, _Selectors.getMaskDataForDesignArea)(state, designArea);
|
|
1969
|
+
|
|
1970
|
+
if (maskData) {
|
|
1971
|
+
maskHandler.init(maskData);
|
|
1972
|
+
} else {
|
|
1973
|
+
maskHandler && maskHandler.dispose();
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
}, {
|
|
1977
|
+
key: "setCanvasData",
|
|
1978
|
+
value: function setCanvasData(canvasData, targetDesignAreaIdentifier) {
|
|
1979
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions.setCanvasData)(canvasData, targetDesignAreaIdentifier));
|
|
1980
|
+
}
|
|
1981
|
+
}, {
|
|
1982
|
+
key: "setColorAmount",
|
|
1983
|
+
value: function () {
|
|
1984
|
+
var _setColorAmount2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(maxColorCount) {
|
|
1985
|
+
var currentColorCount, colorCount;
|
|
1986
|
+
return regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1987
|
+
while (1) {
|
|
1988
|
+
switch (_context18.prev = _context18.next) {
|
|
1989
|
+
case 0:
|
|
1990
|
+
// check the current color usage before applying the selected color count
|
|
1991
|
+
// so if the color count is more than the selected maxColorCount the user can decide to
|
|
1992
|
+
// 1. proceed with the new value
|
|
1993
|
+
// 2. leave the current value (skip applying the newly selected one)
|
|
1994
|
+
currentColorCount = (0, _Selectors.getSelectedDesignAreaProperties)(_ServiceLocator.Services.store.state).colorAmount;
|
|
1995
|
+
colorCount = (0, _Selectors.getColors)(_ServiceLocator.Services.store.state).length;
|
|
1996
|
+
|
|
1997
|
+
if (!(maxColorCount && colorCount > maxColorCount && !isWidget(location.pathname) && (0, _configuration.getConf)('displayColorAmountWarnings', true))) {
|
|
1998
|
+
_context18.next = 11;
|
|
1999
|
+
break;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
_context18.prev = 3;
|
|
2003
|
+
_context18.next = 6;
|
|
2004
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions.showMaxColorChangeConfirm)(colorCount, maxColorCount, currentColorCount));
|
|
2005
|
+
|
|
2006
|
+
case 6:
|
|
2007
|
+
_context18.next = 11;
|
|
2008
|
+
break;
|
|
2009
|
+
|
|
2010
|
+
case 8:
|
|
2011
|
+
_context18.prev = 8;
|
|
2012
|
+
_context18.t0 = _context18["catch"](3);
|
|
2013
|
+
return _context18.abrupt("return");
|
|
2014
|
+
|
|
2015
|
+
case 11:
|
|
2016
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions.setColorAmount)(maxColorCount));
|
|
2017
|
+
|
|
2018
|
+
case 12:
|
|
2019
|
+
case "end":
|
|
2020
|
+
return _context18.stop();
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
}, _callee18, null, [[3, 8]]);
|
|
2024
|
+
}));
|
|
2025
|
+
|
|
2026
|
+
function setColorAmount(_x21) {
|
|
2027
|
+
return _setColorAmount2.apply(this, arguments);
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
return setColorAmount;
|
|
2031
|
+
}()
|
|
2032
|
+
/**
|
|
2033
|
+
* Call the updateTexture function to update every area on the visualization.
|
|
2034
|
+
* That calls back to the provided drawingFunction with the getDrawingContext at the first argument.
|
|
2035
|
+
*
|
|
2036
|
+
*/
|
|
2037
|
+
|
|
2038
|
+
}, {
|
|
2039
|
+
key: "updateVisualization",
|
|
2040
|
+
value: function () {
|
|
2041
|
+
var _updateVisualization = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
|
|
2042
|
+
var updateEventObject,
|
|
2043
|
+
isDesignAreaSelected,
|
|
2044
|
+
isDesignerOpen,
|
|
2045
|
+
isScreenshotEvent,
|
|
2046
|
+
drawingFunction,
|
|
2047
|
+
_args19 = arguments;
|
|
2048
|
+
return regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
2049
|
+
while (1) {
|
|
2050
|
+
switch (_context19.prev = _context19.next) {
|
|
2051
|
+
case 0:
|
|
2052
|
+
updateEventObject = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
|
|
2053
|
+
|
|
2054
|
+
if (_ServiceLocator.Services.visualization.isReadyToRender()) {
|
|
2055
|
+
_context19.next = 3;
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
return _context19.abrupt("return");
|
|
2060
|
+
|
|
2061
|
+
case 3:
|
|
2062
|
+
if (_ServiceLocator.Services.visualization.isReadyToRenderCustomDesign()) {
|
|
2063
|
+
_context19.next = 6;
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
_ServiceLocator.Services.visualization.render();
|
|
2068
|
+
|
|
2069
|
+
return _context19.abrupt("return");
|
|
2070
|
+
|
|
2071
|
+
case 6:
|
|
2072
|
+
isDesignAreaSelected = !!(0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state).identifier;
|
|
2073
|
+
isDesignerOpen = isDesignAreaSelected && _ServiceLocator.Services.ui.isVisible('designer');
|
|
2074
|
+
isScreenshotEvent = (0, _get2["default"])(updateEventObject, 'data.screenshot');
|
|
2075
|
+
drawingFunction = isDesignerOpen && !isScreenshotEvent && !this.isInPreviewMode ? this.redrawEmptyAreas : this.redrawAllDesignAreas;
|
|
2076
|
+
_context19.next = 12;
|
|
2077
|
+
return _ServiceLocator.Services.visualization.updateTexture({
|
|
2078
|
+
updateEventObject: updateEventObject,
|
|
2079
|
+
drawingFunction: drawingFunction.bind(this)
|
|
2080
|
+
});
|
|
2081
|
+
|
|
2082
|
+
case 12:
|
|
2083
|
+
case "end":
|
|
2084
|
+
return _context19.stop();
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}, _callee19, this);
|
|
2088
|
+
}));
|
|
2089
|
+
|
|
2090
|
+
function updateVisualization() {
|
|
2091
|
+
return _updateVisualization.apply(this, arguments);
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
return updateVisualization;
|
|
2095
|
+
}()
|
|
2096
|
+
}, {
|
|
2097
|
+
key: "getFontSizeMin",
|
|
2098
|
+
value: function getFontSizeMin() {
|
|
2099
|
+
return (0, _Selectors.getFontSizeMin)(_ServiceLocator.Services.store.state);
|
|
2100
|
+
}
|
|
2101
|
+
/**
|
|
2102
|
+
* Gets the drawing context and draws all design areas (that has existing canvas) on the texture.
|
|
2103
|
+
* It also handles the highlighting of the design areas.
|
|
2104
|
+
* @param {function} getDrawingContext
|
|
2105
|
+
* @param {object} updateEventObject
|
|
2106
|
+
*/
|
|
2107
|
+
|
|
2108
|
+
}, {
|
|
2109
|
+
key: "redrawAllDesignAreas",
|
|
2110
|
+
value: function () {
|
|
2111
|
+
var _redrawAllDesignAreas = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(getDrawingContext, updateEventObject) {
|
|
2112
|
+
var _this8 = this;
|
|
2113
|
+
|
|
2114
|
+
var state, showHighlight, textureBuilderConfig, variantIdentifier, effectEnabled, drawingFn;
|
|
2115
|
+
return regeneratorRuntime.wrap(function _callee21$(_context22) {
|
|
2116
|
+
while (1) {
|
|
2117
|
+
switch (_context22.prev = _context22.next) {
|
|
2118
|
+
case 0:
|
|
2119
|
+
state = _ServiceLocator.Services.store.state;
|
|
2120
|
+
showHighlight = (0, _get2["default"])(state, 'designArea.showHighlight');
|
|
2121
|
+
textureBuilderConfig = {
|
|
2122
|
+
highlight: {
|
|
2123
|
+
borderColor: (0, _Selectors3.getClientHighlightColor)(state),
|
|
2124
|
+
backgroundColor: (0, _configuration.getConf)('visualization.designAreaHighlightBackgroundColor')
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
variantIdentifier = (0, _get2["default"])(updateEventObject, 'data.variant', false);
|
|
2128
|
+
effectEnabled = !(0, _Selectors3.isDesignerProductPreviewMode)();
|
|
2129
|
+
|
|
2130
|
+
drawingFn = /*#__PURE__*/function () {
|
|
2131
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(textureCtx, getTextureBuilder) {
|
|
2132
|
+
var designAreas,
|
|
2133
|
+
_getTextureBuilder,
|
|
2134
|
+
getTextureImage,
|
|
2135
|
+
drawCanvasToArea,
|
|
2136
|
+
highlightDesignAreas,
|
|
2137
|
+
drawOn,
|
|
2138
|
+
getParams,
|
|
2139
|
+
_iterator9,
|
|
2140
|
+
_step9,
|
|
2141
|
+
_loop,
|
|
2142
|
+
_args21 = arguments;
|
|
2143
|
+
|
|
2144
|
+
return regeneratorRuntime.wrap(function _callee20$(_context21) {
|
|
2145
|
+
while (1) {
|
|
2146
|
+
switch (_context21.prev = _context21.next) {
|
|
2147
|
+
case 0:
|
|
2148
|
+
designAreas = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : _this8.getDesignAreas();
|
|
2149
|
+
_getTextureBuilder = getTextureBuilder(textureBuilderConfig), getTextureImage = _getTextureBuilder.getTextureImage, drawCanvasToArea = _getTextureBuilder.drawCanvasToArea, highlightDesignAreas = _getTextureBuilder.highlightDesignAreas, drawOn = _getTextureBuilder.drawOn, getParams = _getTextureBuilder.getParams;
|
|
2150
|
+
|
|
2151
|
+
if (getTextureImage()) {
|
|
2152
|
+
_context21.next = 5;
|
|
2153
|
+
break;
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
// eslint-disable-next-line no-console
|
|
2157
|
+
console.warn('Texture image is missing!', designAreas);
|
|
2158
|
+
return _context21.abrupt("return");
|
|
2159
|
+
|
|
2160
|
+
case 5:
|
|
2161
|
+
if (showHighlight) {
|
|
2162
|
+
// highlight only the design areas with no mask
|
|
2163
|
+
// for the others the outline is added by the maskHandler
|
|
2164
|
+
highlightDesignAreas(designAreas.filter(function (designArea) {
|
|
2165
|
+
return !(0, _Selectors.designAreaAppliesMask)(state, designArea);
|
|
2166
|
+
}));
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
_iterator9 = _createForOfIteratorHelper(designAreas);
|
|
2170
|
+
_context21.prev = 7;
|
|
2171
|
+
_loop = /*#__PURE__*/regeneratorRuntime.mark(function _loop() {
|
|
2172
|
+
var designArea, canvas, releaseLock, selectedObject, maskHandler, restoreOutlineVisibility, drawToContext, getSvg;
|
|
2173
|
+
return regeneratorRuntime.wrap(function _loop$(_context20) {
|
|
2174
|
+
while (1) {
|
|
2175
|
+
switch (_context20.prev = _context20.next) {
|
|
2176
|
+
case 0:
|
|
2177
|
+
designArea = _step9.value;
|
|
2178
|
+
canvas = _this8._getCanvas(_this8.getDesignAreaByIdentifier(designArea.identifier));
|
|
2179
|
+
|
|
2180
|
+
if (!canvas) {
|
|
2181
|
+
_context20.next = 16;
|
|
2182
|
+
break;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
_context20.next = 5;
|
|
2186
|
+
return (0, _ObjectLock.requestLock)(canvas);
|
|
2187
|
+
|
|
2188
|
+
case 5:
|
|
2189
|
+
releaseLock = _context20.sent;
|
|
2190
|
+
selectedObject = (0, _get2["default"])(canvas, 'selectedObject');
|
|
2191
|
+
|
|
2192
|
+
if (selectedObject) {
|
|
2193
|
+
selectedObject.selected = false;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
maskHandler = canvas.getMaskHandler();
|
|
2197
|
+
|
|
2198
|
+
if (maskHandler) {
|
|
2199
|
+
restoreOutlineVisibility = maskHandler.toggleOutline(showHighlight, {
|
|
2200
|
+
getZoomFactor: function getZoomFactor(_ref18) {
|
|
2201
|
+
var zoom = _ref18.zoom;
|
|
2202
|
+
// currentZoom is only available for 2D, for 3D it is always 1
|
|
2203
|
+
var threeFactor = Math.min(getParams().currentZoom, 1) || 1;
|
|
2204
|
+
return zoom * threeFactor;
|
|
2205
|
+
}
|
|
2206
|
+
});
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
drawToContext = canvas.drawToContext.bind(canvas);
|
|
2210
|
+
|
|
2211
|
+
getSvg = function getSvg() {
|
|
2212
|
+
return canvas.getScreenshot((0, _Selectors4.getFontMapping)(state));
|
|
2213
|
+
};
|
|
2214
|
+
|
|
2215
|
+
_context20.next = 14;
|
|
2216
|
+
return drawCanvasToArea(_objectSpread({
|
|
2217
|
+
drawToContext: drawToContext,
|
|
2218
|
+
designArea: designArea,
|
|
2219
|
+
getSvg: getSvg
|
|
2220
|
+
}, effectEnabled && (0, _Selectors.getVisualizationEffectWithOptions)(state, designArea, variantIdentifier)));
|
|
2221
|
+
|
|
2222
|
+
case 14:
|
|
2223
|
+
if (maskHandler) {
|
|
2224
|
+
restoreOutlineVisibility();
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
releaseLock();
|
|
2228
|
+
|
|
2229
|
+
case 16:
|
|
2230
|
+
case "end":
|
|
2231
|
+
return _context20.stop();
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}, _loop);
|
|
2235
|
+
});
|
|
2236
|
+
|
|
2237
|
+
_iterator9.s();
|
|
2238
|
+
|
|
2239
|
+
case 10:
|
|
2240
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
2241
|
+
_context21.next = 14;
|
|
2242
|
+
break;
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
return _context21.delegateYield(_loop(), "t0", 12);
|
|
2246
|
+
|
|
2247
|
+
case 12:
|
|
2248
|
+
_context21.next = 10;
|
|
2249
|
+
break;
|
|
2250
|
+
|
|
2251
|
+
case 14:
|
|
2252
|
+
_context21.next = 19;
|
|
2253
|
+
break;
|
|
2254
|
+
|
|
2255
|
+
case 16:
|
|
2256
|
+
_context21.prev = 16;
|
|
2257
|
+
_context21.t1 = _context21["catch"](7);
|
|
2258
|
+
|
|
2259
|
+
_iterator9.e(_context21.t1);
|
|
2260
|
+
|
|
2261
|
+
case 19:
|
|
2262
|
+
_context21.prev = 19;
|
|
2263
|
+
|
|
2264
|
+
_iterator9.f();
|
|
2265
|
+
|
|
2266
|
+
return _context21.finish(19);
|
|
2267
|
+
|
|
2268
|
+
case 22:
|
|
2269
|
+
drawOn(textureCtx);
|
|
2270
|
+
|
|
2271
|
+
case 23:
|
|
2272
|
+
case "end":
|
|
2273
|
+
return _context21.stop();
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
}, _callee20, null, [[7, 16, 19, 22]]);
|
|
2277
|
+
}));
|
|
2278
|
+
|
|
2279
|
+
return function drawingFn(_x24, _x25) {
|
|
2280
|
+
return _ref17.apply(this, arguments);
|
|
2281
|
+
};
|
|
2282
|
+
}();
|
|
2283
|
+
|
|
2284
|
+
_context22.prev = 6;
|
|
2285
|
+
_context22.next = 9;
|
|
2286
|
+
return getDrawingContext(drawingFn, true
|
|
2287
|
+
/* update alpha */
|
|
2288
|
+
, true
|
|
2289
|
+
/* clean up texture before drawing */
|
|
2290
|
+
);
|
|
2291
|
+
|
|
2292
|
+
case 9:
|
|
2293
|
+
_context22.next = 14;
|
|
2294
|
+
break;
|
|
2295
|
+
|
|
2296
|
+
case 11:
|
|
2297
|
+
_context22.prev = 11;
|
|
2298
|
+
_context22.t0 = _context22["catch"](6);
|
|
2299
|
+
// eslint-disable-next-line no-console
|
|
2300
|
+
console.warn('Could not get drawing context, texture update is skipped!', _context22.t0.message);
|
|
2301
|
+
|
|
2302
|
+
case 14:
|
|
2303
|
+
case "end":
|
|
2304
|
+
return _context22.stop();
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}, _callee21, null, [[6, 11]]);
|
|
2308
|
+
}));
|
|
2309
|
+
|
|
2310
|
+
function redrawAllDesignAreas(_x22, _x23) {
|
|
2311
|
+
return _redrawAllDesignAreas.apply(this, arguments);
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
return redrawAllDesignAreas;
|
|
2315
|
+
}()
|
|
2316
|
+
}, {
|
|
2317
|
+
key: "redrawEmptyAreas",
|
|
2318
|
+
value: function redrawEmptyAreas(getDrawingContext) {
|
|
2319
|
+
getDrawingContext( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
|
|
2320
|
+
return regeneratorRuntime.wrap(function _callee22$(_context23) {
|
|
2321
|
+
while (1) {
|
|
2322
|
+
switch (_context23.prev = _context23.next) {
|
|
2323
|
+
case 0:
|
|
2324
|
+
case "end":
|
|
2325
|
+
return _context23.stop();
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
}, _callee22);
|
|
2329
|
+
})), true
|
|
2330
|
+
/* update alpha */
|
|
2331
|
+
, true
|
|
2332
|
+
/* clean up texture before drawing */
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2335
|
+
}, {
|
|
2336
|
+
key: "toggleHighlight",
|
|
2337
|
+
value: function toggleHighlight(show) {
|
|
2338
|
+
var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
2339
|
+
|
|
2340
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions3.toggleHighlight)(show));
|
|
2341
|
+
|
|
2342
|
+
if (update) {
|
|
2343
|
+
this.updateVisualization();
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}, {
|
|
2347
|
+
key: "toggleIsInPreviewMode",
|
|
2348
|
+
value: function toggleIsInPreviewMode(isInPreviewMode) {
|
|
2349
|
+
this.isInPreviewMode = isInPreviewMode;
|
|
2350
|
+
|
|
2351
|
+
if (!this.isInPreviewMode) {
|
|
2352
|
+
var hasSelectedDesignArea = !!(0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state).identifier;
|
|
2353
|
+
|
|
2354
|
+
if (hasSelectedDesignArea) {
|
|
2355
|
+
_ServiceLocator.Services.visualization.disableUserMovement();
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
}, {
|
|
2360
|
+
key: "createHighlightMemo",
|
|
2361
|
+
value: function createHighlightMemo(tmpState) {
|
|
2362
|
+
var _this9 = this;
|
|
2363
|
+
|
|
2364
|
+
var origState = (0, _Selectors.isHighlighted)(_ServiceLocator.Services.store.state);
|
|
2365
|
+
this.toggleHighlight(tmpState, false);
|
|
2366
|
+
return {
|
|
2367
|
+
restore: function restore() {
|
|
2368
|
+
_this9.toggleHighlight(origState, true);
|
|
2369
|
+
}
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
}, {
|
|
2373
|
+
key: "getScreenshots",
|
|
2374
|
+
value: function () {
|
|
2375
|
+
var _getScreenshots = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(fontMapping) {
|
|
2376
|
+
var _this10 = this;
|
|
2377
|
+
|
|
2378
|
+
var options,
|
|
2379
|
+
_options$screenshotFn,
|
|
2380
|
+
screenshotFn,
|
|
2381
|
+
_args25 = arguments;
|
|
2382
|
+
|
|
2383
|
+
return regeneratorRuntime.wrap(function _callee24$(_context25) {
|
|
2384
|
+
while (1) {
|
|
2385
|
+
switch (_context25.prev = _context25.next) {
|
|
2386
|
+
case 0:
|
|
2387
|
+
options = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
|
|
2388
|
+
_options$screenshotFn = options.screenshotFn, screenshotFn = _options$screenshotFn === void 0 ? 'getScreenshot' : _options$screenshotFn;
|
|
2389
|
+
_context25.next = 4;
|
|
2390
|
+
return Promise.all(this.getDesignAreas().map(function (area) {
|
|
2391
|
+
return {
|
|
2392
|
+
id: area.identifier,
|
|
2393
|
+
canvas: _this10._getCanvas(area)
|
|
2394
|
+
};
|
|
2395
|
+
}).filter(function (_ref20) {
|
|
2396
|
+
var canvas = _ref20.canvas;
|
|
2397
|
+
return canvas && canvas[screenshotFn] && canvas.objects && canvas.objects.length > 0;
|
|
2398
|
+
}).map( /*#__PURE__*/function () {
|
|
2399
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(_ref21) {
|
|
2400
|
+
var id, canvas, releaseLock, maskHandler, restoreOutlineVisibility, result;
|
|
2401
|
+
return regeneratorRuntime.wrap(function _callee23$(_context24) {
|
|
2402
|
+
while (1) {
|
|
2403
|
+
switch (_context24.prev = _context24.next) {
|
|
2404
|
+
case 0:
|
|
2405
|
+
id = _ref21.id, canvas = _ref21.canvas;
|
|
2406
|
+
_context24.next = 3;
|
|
2407
|
+
return (0, _ObjectLock.requestLock)(canvas);
|
|
2408
|
+
|
|
2409
|
+
case 3:
|
|
2410
|
+
releaseLock = _context24.sent;
|
|
2411
|
+
maskHandler = canvas.getMaskHandler();
|
|
2412
|
+
restoreOutlineVisibility = maskHandler && maskHandler.toggleOutline(false);
|
|
2413
|
+
_context24.t0 = id;
|
|
2414
|
+
_context24.next = 9;
|
|
2415
|
+
return canvas[screenshotFn](fontMapping);
|
|
2416
|
+
|
|
2417
|
+
case 9:
|
|
2418
|
+
_context24.t1 = _context24.sent;
|
|
2419
|
+
result = [_context24.t0, _context24.t1];
|
|
2420
|
+
restoreOutlineVisibility && restoreOutlineVisibility();
|
|
2421
|
+
releaseLock();
|
|
2422
|
+
return _context24.abrupt("return", result);
|
|
2423
|
+
|
|
2424
|
+
case 14:
|
|
2425
|
+
case "end":
|
|
2426
|
+
return _context24.stop();
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
}, _callee23);
|
|
2430
|
+
}));
|
|
2431
|
+
|
|
2432
|
+
return function (_x27) {
|
|
2433
|
+
return _ref22.apply(this, arguments);
|
|
2434
|
+
};
|
|
2435
|
+
}()));
|
|
2436
|
+
|
|
2437
|
+
case 4:
|
|
2438
|
+
return _context25.abrupt("return", _context25.sent.reduce(function (screenShots, _ref23) {
|
|
2439
|
+
var _ref24 = _slicedToArray(_ref23, 2),
|
|
2440
|
+
id = _ref24[0],
|
|
2441
|
+
screenshot = _ref24[1];
|
|
2442
|
+
|
|
2443
|
+
return _objectSpread(_objectSpread({}, screenShots), {}, _defineProperty({}, id, screenshot));
|
|
2444
|
+
}, {}));
|
|
2445
|
+
|
|
2446
|
+
case 5:
|
|
2447
|
+
case "end":
|
|
2448
|
+
return _context25.stop();
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
}, _callee24, this);
|
|
2452
|
+
}));
|
|
2453
|
+
|
|
2454
|
+
function getScreenshots(_x26) {
|
|
2455
|
+
return _getScreenshots.apply(this, arguments);
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
return getScreenshots;
|
|
2459
|
+
}()
|
|
2460
|
+
}, {
|
|
2461
|
+
key: "getScreenshotsOfElements",
|
|
2462
|
+
value: function () {
|
|
2463
|
+
var _getScreenshotsOfElements = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(fontMapping) {
|
|
2464
|
+
return regeneratorRuntime.wrap(function _callee25$(_context26) {
|
|
2465
|
+
while (1) {
|
|
2466
|
+
switch (_context26.prev = _context26.next) {
|
|
2467
|
+
case 0:
|
|
2468
|
+
_context26.next = 2;
|
|
2469
|
+
return this.getScreenshots(fontMapping, {
|
|
2470
|
+
screenshotFn: 'getScreenshotsOfElements'
|
|
2471
|
+
});
|
|
2472
|
+
|
|
2473
|
+
case 2:
|
|
2474
|
+
return _context26.abrupt("return", _context26.sent);
|
|
2475
|
+
|
|
2476
|
+
case 3:
|
|
2477
|
+
case "end":
|
|
2478
|
+
return _context26.stop();
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
}, _callee25, this);
|
|
2482
|
+
}));
|
|
2483
|
+
|
|
2484
|
+
function getScreenshotsOfElements(_x28) {
|
|
2485
|
+
return _getScreenshotsOfElements.apply(this, arguments);
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
return getScreenshotsOfElements;
|
|
2489
|
+
}()
|
|
2490
|
+
/**
|
|
2491
|
+
* Provides a simple interface to add or remove sample text to the canvas related to the given designAreaIdentifier.
|
|
2492
|
+
* It also provides a function to modify the color amount, it simply clears the canvas and re-adds the sample text
|
|
2493
|
+
* with the planned number of colors.
|
|
2494
|
+
* Note: this function has more notable side effects
|
|
2495
|
+
* - it modifies the selected design area if the designAreaIdentifier is provided
|
|
2496
|
+
* - it clears the canvas in the interface methods, so all the previously added items will be removed
|
|
2497
|
+
* @param designAreaIdentifier
|
|
2498
|
+
* @returns {{toggleSampleText: (function(*=)), setColorAmount: (function(*=))}}
|
|
2499
|
+
*/
|
|
2500
|
+
|
|
2501
|
+
}, {
|
|
2502
|
+
key: "getSampleCanvasEditorForDesignArea",
|
|
2503
|
+
value: function getSampleCanvasEditorForDesignArea() {
|
|
2504
|
+
var _this11 = this;
|
|
2505
|
+
|
|
2506
|
+
var designAreaIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
2507
|
+
designAreaIdentifier && _ServiceLocator.Services.store.dispatch((0, _Actions3.selectDesignArea)(designAreaIdentifier));
|
|
2508
|
+
var designArea = _ServiceLocator.Services.store.state.designArea.selectedDesignArea;
|
|
2509
|
+
var identifier = designArea.identifier;
|
|
2510
|
+
|
|
2511
|
+
var canvas = this._getCanvas(designArea);
|
|
2512
|
+
|
|
2513
|
+
if (canvas) {
|
|
2514
|
+
var previouslyContainedSampleText = canvas.getLength() > 0;
|
|
2515
|
+
|
|
2516
|
+
var addSampleText = function addSampleText() {
|
|
2517
|
+
var state = _ServiceLocator.Services.store.state;
|
|
2518
|
+
var designAreaData = (0, _Selectors.getDesignDataByDesignAreaIdentifier)(state, identifier);
|
|
2519
|
+
var colorAmount = Math.max((0, _get2["default"])(designAreaData, 'colorAmount', 0), 1);
|
|
2520
|
+
var text = (0, _i18n.t)('calculationWidget.textContent', {
|
|
2521
|
+
colorAmount: colorAmount
|
|
2522
|
+
});
|
|
2523
|
+
|
|
2524
|
+
_ServiceLocator.Services.designer.addText(canvas, text, colorAmount); // eslint-disable-next-line no-console
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
console.log("Sample text added to canvas: ".concat(identifier));
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
var clearTextObjects = function clearTextObjects() {
|
|
2531
|
+
var objects = canvas.objects.filter(function (obj) {
|
|
2532
|
+
return obj.type === 'Text';
|
|
2533
|
+
});
|
|
2534
|
+
objects.forEach(function (obj) {
|
|
2535
|
+
return obj.remove();
|
|
2536
|
+
});
|
|
2537
|
+
};
|
|
2538
|
+
|
|
2539
|
+
return {
|
|
2540
|
+
toggleSampleText: function toggleSampleText(active) {
|
|
2541
|
+
if (active) {
|
|
2542
|
+
addSampleText();
|
|
2543
|
+
} else {
|
|
2544
|
+
canvas.clear();
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
_this11.updateCanvasData(canvas);
|
|
2548
|
+
},
|
|
2549
|
+
setColorAmount: function setColorAmount(value) {
|
|
2550
|
+
clearTextObjects();
|
|
2551
|
+
|
|
2552
|
+
_this11.setColorAmount(value);
|
|
2553
|
+
|
|
2554
|
+
previouslyContainedSampleText && addSampleText();
|
|
2555
|
+
var imgObjects = canvas.objects.filter(function (obj) {
|
|
2556
|
+
return obj.type !== 'Text';
|
|
2557
|
+
});
|
|
2558
|
+
|
|
2559
|
+
var canvasData = _this11._serializeCanvas(canvas);
|
|
2560
|
+
|
|
2561
|
+
if (imgObjects.length > 0) {
|
|
2562
|
+
canvasData = _this11.calculateObjectPosition(canvas);
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
_this11.setCanvasData(canvasData, identifier);
|
|
2566
|
+
}
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
}, {
|
|
2571
|
+
key: "addSampleImageForDesignAreas",
|
|
2572
|
+
value: function () {
|
|
2573
|
+
var _addSampleImageForDesignAreas = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(designAreaIdentifiers, active) {
|
|
2574
|
+
var _this12 = this;
|
|
2575
|
+
|
|
2576
|
+
return regeneratorRuntime.wrap(function _callee27$(_context28) {
|
|
2577
|
+
while (1) {
|
|
2578
|
+
switch (_context28.prev = _context28.next) {
|
|
2579
|
+
case 0:
|
|
2580
|
+
_context28.next = 2;
|
|
2581
|
+
return Promise.all(designAreaIdentifiers.map( /*#__PURE__*/function () {
|
|
2582
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(designAreaIdentifier) {
|
|
2583
|
+
var designArea, canvas, state, imageSrc, imageData, canvasDataJSON, designData, canvasData, objects;
|
|
2584
|
+
return regeneratorRuntime.wrap(function _callee26$(_context27) {
|
|
2585
|
+
while (1) {
|
|
2586
|
+
switch (_context27.prev = _context27.next) {
|
|
2587
|
+
case 0:
|
|
2588
|
+
designArea = _this12.getDesignAreaByIdentifier(designAreaIdentifier);
|
|
2589
|
+
canvas = _this12._getCanvas(designArea);
|
|
2590
|
+
state = _ServiceLocator.Services.store.state;
|
|
2591
|
+
imageSrc = _designer_placeholder_logo["default"];
|
|
2592
|
+
|
|
2593
|
+
if (!active) {
|
|
2594
|
+
_context27.next = 13;
|
|
2595
|
+
break;
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
imageData = (0, _Modifiers2.createSVGImageData)({
|
|
2599
|
+
fileName: 'designer_placeholder_logo.svg',
|
|
2600
|
+
imageUrl: imageSrc,
|
|
2601
|
+
thumbUrl: imageSrc,
|
|
2602
|
+
isPlaceHolderImage: true,
|
|
2603
|
+
galleryImage: false
|
|
2604
|
+
});
|
|
2605
|
+
_context27.next = 8;
|
|
2606
|
+
return _ServiceLocator.Services.designer.addImageFromUrl(canvas, (0, _Selectors2.getPreviewUrlFromImageData)(imageData.preview), imageData, {
|
|
2607
|
+
enlargeImage: true
|
|
2608
|
+
});
|
|
2609
|
+
|
|
2610
|
+
case 8:
|
|
2611
|
+
canvasDataJSON = _this12.calculateObjectPosition(canvas); // eslint-disable-next-line no-console
|
|
2612
|
+
|
|
2613
|
+
// eslint-disable-next-line no-console
|
|
2614
|
+
console.log("Sample image added to canvas: ".concat(designAreaIdentifier));
|
|
2615
|
+
|
|
2616
|
+
_this12.setCanvasData(canvasDataJSON, designAreaIdentifier);
|
|
2617
|
+
|
|
2618
|
+
_context27.next = 21;
|
|
2619
|
+
break;
|
|
2620
|
+
|
|
2621
|
+
case 13:
|
|
2622
|
+
designData = (0, _Selectors.getDesignDataByDesignAreaIdentifier)(state, designAreaIdentifier);
|
|
2623
|
+
canvasData = designData.canvasData;
|
|
2624
|
+
|
|
2625
|
+
if (canvasData) {
|
|
2626
|
+
_context27.next = 17;
|
|
2627
|
+
break;
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
return _context27.abrupt("return");
|
|
2631
|
+
|
|
2632
|
+
case 17:
|
|
2633
|
+
objects = canvasData ? canvasData.objects.filter(function (obj) {
|
|
2634
|
+
return obj.type === 'Text';
|
|
2635
|
+
}) : [];
|
|
2636
|
+
|
|
2637
|
+
_this12.setCanvasData(_objectSpread(_objectSpread({}, canvasData), {}, {
|
|
2638
|
+
objects: objects
|
|
2639
|
+
}), designAreaIdentifier);
|
|
2640
|
+
|
|
2641
|
+
_context27.next = 21;
|
|
2642
|
+
return _this12.loadCanvasDataFromState([designArea]);
|
|
2643
|
+
|
|
2644
|
+
case 21:
|
|
2645
|
+
return _context27.abrupt("return", {
|
|
2646
|
+
canvas: canvas,
|
|
2647
|
+
designAreaIdentifier: designAreaIdentifier
|
|
2648
|
+
});
|
|
2649
|
+
|
|
2650
|
+
case 22:
|
|
2651
|
+
case "end":
|
|
2652
|
+
return _context27.stop();
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
}, _callee26);
|
|
2656
|
+
}));
|
|
2657
|
+
|
|
2658
|
+
return function (_x31) {
|
|
2659
|
+
return _ref25.apply(this, arguments);
|
|
2660
|
+
};
|
|
2661
|
+
}()));
|
|
2662
|
+
|
|
2663
|
+
case 2:
|
|
2664
|
+
case "end":
|
|
2665
|
+
return _context28.stop();
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}, _callee27);
|
|
2669
|
+
}));
|
|
2670
|
+
|
|
2671
|
+
function addSampleImageForDesignAreas(_x29, _x30) {
|
|
2672
|
+
return _addSampleImageForDesignAreas.apply(this, arguments);
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
return addSampleImageForDesignAreas;
|
|
2676
|
+
}()
|
|
2677
|
+
}, {
|
|
2678
|
+
key: "addImageToDesignArea",
|
|
2679
|
+
value: function () {
|
|
2680
|
+
var _addImageToDesignArea = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28(designArea, imageData) {
|
|
2681
|
+
var canvas;
|
|
2682
|
+
return regeneratorRuntime.wrap(function _callee28$(_context29) {
|
|
2683
|
+
while (1) {
|
|
2684
|
+
switch (_context29.prev = _context29.next) {
|
|
2685
|
+
case 0:
|
|
2686
|
+
canvas = this._getCanvas(designArea);
|
|
2687
|
+
|
|
2688
|
+
if (canvas) {
|
|
2689
|
+
_context29.next = 3;
|
|
2690
|
+
break;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
return _context29.abrupt("return", false);
|
|
2694
|
+
|
|
2695
|
+
case 3:
|
|
2696
|
+
_context29.next = 5;
|
|
2697
|
+
return _ServiceLocator.Services.designer.addImageFromUrl(canvas, (0, _Selectors2.getPreviewUrlFromImageData)(imageData.preview), imageData, {
|
|
2698
|
+
enlargeImage: true,
|
|
2699
|
+
scaleToHalf: false,
|
|
2700
|
+
autoSelect: false
|
|
2701
|
+
});
|
|
2702
|
+
|
|
2703
|
+
case 5:
|
|
2704
|
+
return _context29.abrupt("return", _context29.sent);
|
|
2705
|
+
|
|
2706
|
+
case 6:
|
|
2707
|
+
case "end":
|
|
2708
|
+
return _context29.stop();
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
}, _callee28, this);
|
|
2712
|
+
}));
|
|
2713
|
+
|
|
2714
|
+
function addImageToDesignArea(_x32, _x33) {
|
|
2715
|
+
return _addImageToDesignArea.apply(this, arguments);
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
return addImageToDesignArea;
|
|
2719
|
+
}()
|
|
2720
|
+
}, {
|
|
2721
|
+
key: "calculateObjectPosition",
|
|
2722
|
+
value: function calculateObjectPosition(canvas) {
|
|
2723
|
+
var canvasData = this._serializeCanvas(canvas);
|
|
2724
|
+
|
|
2725
|
+
var textObject = canvasData ? canvasData.objects.find(function (obj) {
|
|
2726
|
+
return obj.type === 'Text';
|
|
2727
|
+
}) : [];
|
|
2728
|
+
var imageObject = canvasData ? canvasData.objects.find(function (obj) {
|
|
2729
|
+
return obj.type === 'Image';
|
|
2730
|
+
}) : [];
|
|
2731
|
+
var canvasTextObject = canvas.objects.find(function (obj) {
|
|
2732
|
+
return obj.uuid === textObject.uuid;
|
|
2733
|
+
});
|
|
2734
|
+
var canvasImageObject = canvas.objects.find(function (obj) {
|
|
2735
|
+
return obj.uuid === imageObject.uuid;
|
|
2736
|
+
});
|
|
2737
|
+
|
|
2738
|
+
if (canvasTextObject && canvasImageObject) {
|
|
2739
|
+
var canvasImageObjectSize = canvasImageObject.getBoundSize();
|
|
2740
|
+
var canvasTextObjectSize = canvasTextObject.getBoundSize();
|
|
2741
|
+
textObject.y = imageObject.y + canvasImageObjectSize.height / 2 + canvasTextObjectSize.height;
|
|
2742
|
+
var objects = [].concat(textObject, imageObject);
|
|
2743
|
+
return _objectSpread(_objectSpread({}, canvasData), {}, {
|
|
2744
|
+
objects: objects
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
return canvasData;
|
|
2749
|
+
}
|
|
2750
|
+
}, {
|
|
2751
|
+
key: "applyDesignAreaPreSelection",
|
|
2752
|
+
value: function applyDesignAreaPreSelection(filteredDesignAreas) {
|
|
2753
|
+
var preSelectionDesignAreaIdentifier = (0, _get2["default"])((0, _configuration.getConf)('designerPreSelection', {}), 'designAreas[0].identifier');
|
|
2754
|
+
|
|
2755
|
+
if (preSelectionDesignAreaIdentifier) {
|
|
2756
|
+
this.selectDesignArea(preSelectionDesignAreaIdentifier);
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
var _iterator10 = _createForOfIteratorHelper(filteredDesignAreas),
|
|
2760
|
+
_step10;
|
|
2761
|
+
|
|
2762
|
+
try {
|
|
2763
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
2764
|
+
var area = _step10.value;
|
|
2765
|
+
var selectedDesignArea = (0, _Selectors.getDesignAreaPreSelection)(area.identifier);
|
|
2766
|
+
|
|
2767
|
+
if (selectedDesignArea.identifier) {
|
|
2768
|
+
var preSelectionColorAmount = +(0, _get2["default"])(selectedDesignArea, 'colorAmount', 1);
|
|
2769
|
+
|
|
2770
|
+
if (!isNaN(preSelectionColorAmount)) {
|
|
2771
|
+
var sampleCanvasEditor = _ServiceLocator.Services.designData.getSampleCanvasEditorForDesignArea(area.identifier);
|
|
2772
|
+
|
|
2773
|
+
sampleCanvasEditor.setColorAmount(preSelectionColorAmount);
|
|
2774
|
+
sampleCanvasEditor.toggleSampleText(true);
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
} catch (err) {
|
|
2779
|
+
_iterator10.e(err);
|
|
2780
|
+
} finally {
|
|
2781
|
+
_iterator10.f();
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
}, {
|
|
2785
|
+
key: "changeAllColorsNeeded",
|
|
2786
|
+
value: function changeAllColorsNeeded() {
|
|
2787
|
+
var _getSelectedDesignAre3 = (0, _Selectors.getSelectedDesignAreaProperties)(_ServiceLocator.Services.store.state),
|
|
2788
|
+
maxColorAmount = _getSelectedDesignAre3.maxColorAmount,
|
|
2789
|
+
hasEngravingBackgroundColors = _getSelectedDesignAre3.hasEngravingBackgroundColors;
|
|
2790
|
+
|
|
2791
|
+
return maxColorAmount === 1 && !hasEngravingBackgroundColors;
|
|
2792
|
+
}
|
|
2793
|
+
}, {
|
|
2794
|
+
key: "setImageAndTextColor",
|
|
2795
|
+
value: function () {
|
|
2796
|
+
var _setImageAndTextColor = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29(color) {
|
|
2797
|
+
var designArea, designData, objects, hasmultipleObjects, canvas, isImageSelected, selectedImageIdentifier, _iterator11, _step11, object, image, operations;
|
|
2798
|
+
|
|
2799
|
+
return regeneratorRuntime.wrap(function _callee29$(_context30) {
|
|
2800
|
+
while (1) {
|
|
2801
|
+
switch (_context30.prev = _context30.next) {
|
|
2802
|
+
case 0:
|
|
2803
|
+
if (this.changeAllColorsNeeded()) {
|
|
2804
|
+
_context30.next = 2;
|
|
2805
|
+
break;
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
return _context30.abrupt("return");
|
|
2809
|
+
|
|
2810
|
+
case 2:
|
|
2811
|
+
designArea = (0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state);
|
|
2812
|
+
designData = (0, _Selectors.getDesignDataByDesignAreaIdentifier)(_ServiceLocator.Services.store.state, designArea.identifier);
|
|
2813
|
+
objects = (0, _get2["default"])(designData, 'canvasData.objects', []);
|
|
2814
|
+
hasmultipleObjects = objects.length > 1;
|
|
2815
|
+
|
|
2816
|
+
if (hasmultipleObjects) {
|
|
2817
|
+
_context30.next = 8;
|
|
2818
|
+
break;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
return _context30.abrupt("return");
|
|
2822
|
+
|
|
2823
|
+
case 8:
|
|
2824
|
+
canvas = this._getCanvas(designArea);
|
|
2825
|
+
isImageSelected = canvas.selectedObject && canvas.selectedObject.type === 'Image';
|
|
2826
|
+
selectedImageIdentifier = isImageSelected ? (0, _get2["default"])(_ServiceLocator.Services.store.state, 'imageGallery.selectedImage.identifier', null) : null;
|
|
2827
|
+
|
|
2828
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions.setDesignAreaTextsColor)(designArea.identifier, color));
|
|
2829
|
+
|
|
2830
|
+
_iterator11 = _createForOfIteratorHelper(objects);
|
|
2831
|
+
_context30.prev = 13;
|
|
2832
|
+
|
|
2833
|
+
_iterator11.s();
|
|
2834
|
+
|
|
2835
|
+
case 15:
|
|
2836
|
+
if ((_step11 = _iterator11.n()).done) {
|
|
2837
|
+
_context30.next = 24;
|
|
2838
|
+
break;
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
object = _step11.value;
|
|
2842
|
+
|
|
2843
|
+
if (!(object.type === 'Image' && object.imageData.identifier !== selectedImageIdentifier)) {
|
|
2844
|
+
_context30.next = 22;
|
|
2845
|
+
break;
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
image = (0, _Selectors2.getUserImage)(_ServiceLocator.Services.store.state, object.imageData.identifier);
|
|
2849
|
+
operations = (0, _Modifiers.setColorOnOperations)(image.operations, color);
|
|
2850
|
+
_context30.next = 22;
|
|
2851
|
+
return _ServiceLocator.Services.designData.editFile(operations, image);
|
|
2852
|
+
|
|
2853
|
+
case 22:
|
|
2854
|
+
_context30.next = 15;
|
|
2855
|
+
break;
|
|
2856
|
+
|
|
2857
|
+
case 24:
|
|
2858
|
+
_context30.next = 29;
|
|
2859
|
+
break;
|
|
2860
|
+
|
|
2861
|
+
case 26:
|
|
2862
|
+
_context30.prev = 26;
|
|
2863
|
+
_context30.t0 = _context30["catch"](13);
|
|
2864
|
+
|
|
2865
|
+
_iterator11.e(_context30.t0);
|
|
2866
|
+
|
|
2867
|
+
case 29:
|
|
2868
|
+
_context30.prev = 29;
|
|
2869
|
+
|
|
2870
|
+
_iterator11.f();
|
|
2871
|
+
|
|
2872
|
+
return _context30.finish(29);
|
|
2873
|
+
|
|
2874
|
+
case 32:
|
|
2875
|
+
_context30.next = 34;
|
|
2876
|
+
return this.updateCanvasDataFromState([designArea]);
|
|
2877
|
+
|
|
2878
|
+
case 34:
|
|
2879
|
+
case "end":
|
|
2880
|
+
return _context30.stop();
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
}, _callee29, this, [[13, 26, 29, 32]]);
|
|
2884
|
+
}));
|
|
2885
|
+
|
|
2886
|
+
function setImageAndTextColor(_x34) {
|
|
2887
|
+
return _setImageAndTextColor.apply(this, arguments);
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
return setImageAndTextColor;
|
|
2891
|
+
}()
|
|
2892
|
+
}, {
|
|
2893
|
+
key: "getGalleryImageColors",
|
|
2894
|
+
value: function () {
|
|
2895
|
+
var _getGalleryImageColors = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30(url) {
|
|
2896
|
+
var svgContent, designProductionMethod;
|
|
2897
|
+
return regeneratorRuntime.wrap(function _callee30$(_context31) {
|
|
2898
|
+
while (1) {
|
|
2899
|
+
switch (_context31.prev = _context31.next) {
|
|
2900
|
+
case 0:
|
|
2901
|
+
_context31.next = 2;
|
|
2902
|
+
return getSvgContent(url);
|
|
2903
|
+
|
|
2904
|
+
case 2:
|
|
2905
|
+
svgContent = _context31.sent;
|
|
2906
|
+
designProductionMethod = (0, _Selectors.getSelectedDesignProductionMethod)(_ServiceLocator.Services.store.state);
|
|
2907
|
+
return _context31.abrupt("return", (0, _Modifiers.createVectorizeColorsMap)({}, getSvgColors(svgContent, designProductionMethod)));
|
|
2908
|
+
|
|
2909
|
+
case 5:
|
|
2910
|
+
case "end":
|
|
2911
|
+
return _context31.stop();
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
}, _callee30);
|
|
2915
|
+
}));
|
|
2916
|
+
|
|
2917
|
+
function getGalleryImageColors(_x35) {
|
|
2918
|
+
return _getGalleryImageColors.apply(this, arguments);
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
return getGalleryImageColors;
|
|
2922
|
+
}()
|
|
2923
|
+
}, {
|
|
2924
|
+
key: "updateDesignAreaImagesWithSelectedImageData",
|
|
2925
|
+
value: function updateDesignAreaImagesWithSelectedImageData() {
|
|
2926
|
+
var originalImageIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
2927
|
+
var imageIdentifier = (0, _get2["default"])(_ServiceLocator.Services.store.state, 'imageGallery.selectedImage.identifier');
|
|
2928
|
+
var newImage = (0, _find["default"])(_ServiceLocator.Services.store.state.imageGallery.userImages, {
|
|
2929
|
+
identifier: imageIdentifier
|
|
2930
|
+
});
|
|
2931
|
+
this.removeDesignAreaPlaceholders(false, true);
|
|
2932
|
+
newImage && _ServiceLocator.Services.store.dispatch((0, _Actions.updateImageData)(newImage, originalImageIdentifier));
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Calls editFile in a queued way to make sure the current image data state is not updated simultaneously
|
|
2936
|
+
* by other editFileQueued calls
|
|
2937
|
+
* Note: it works only with editFileQueued calls (does not guard against calling editFile directly)
|
|
2938
|
+
*/
|
|
2939
|
+
|
|
2940
|
+
}, {
|
|
2941
|
+
key: "editFileQueued",
|
|
2942
|
+
value: function () {
|
|
2943
|
+
var _editFileQueued = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee31(operations, image) {
|
|
2944
|
+
var options,
|
|
2945
|
+
releaseLock,
|
|
2946
|
+
_args32 = arguments;
|
|
2947
|
+
return regeneratorRuntime.wrap(function _callee31$(_context32) {
|
|
2948
|
+
while (1) {
|
|
2949
|
+
switch (_context32.prev = _context32.next) {
|
|
2950
|
+
case 0:
|
|
2951
|
+
options = _args32.length > 2 && _args32[2] !== undefined ? _args32[2] : {};
|
|
2952
|
+
_context32.next = 3;
|
|
2953
|
+
return (0, _ObjectLock.requestLock)(this);
|
|
2954
|
+
|
|
2955
|
+
case 3:
|
|
2956
|
+
releaseLock = _context32.sent;
|
|
2957
|
+
_context32.prev = 4;
|
|
2958
|
+
_context32.next = 7;
|
|
2959
|
+
return this.editFile(operations, image, options);
|
|
2960
|
+
|
|
2961
|
+
case 7:
|
|
2962
|
+
return _context32.abrupt("return", _context32.sent);
|
|
2963
|
+
|
|
2964
|
+
case 8:
|
|
2965
|
+
_context32.prev = 8;
|
|
2966
|
+
releaseLock();
|
|
2967
|
+
return _context32.finish(8);
|
|
2968
|
+
|
|
2969
|
+
case 11:
|
|
2970
|
+
case "end":
|
|
2971
|
+
return _context32.stop();
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
}, _callee31, this, [[4,, 8, 11]]);
|
|
2975
|
+
}));
|
|
2976
|
+
|
|
2977
|
+
function editFileQueued(_x36, _x37) {
|
|
2978
|
+
return _editFileQueued.apply(this, arguments);
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
return editFileQueued;
|
|
2982
|
+
}()
|
|
2983
|
+
}, {
|
|
2984
|
+
key: "editFile",
|
|
2985
|
+
value: function () {
|
|
2986
|
+
var _editFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee32(operations, image) {
|
|
2987
|
+
var options,
|
|
2988
|
+
_options$immediateCom,
|
|
2989
|
+
immediateCommit,
|
|
2990
|
+
_options$designProduc,
|
|
2991
|
+
designProductionMethod,
|
|
2992
|
+
_options$addMode,
|
|
2993
|
+
addMode,
|
|
2994
|
+
displayColorPreview,
|
|
2995
|
+
imageIdentifier,
|
|
2996
|
+
preview,
|
|
2997
|
+
compatibilityInfoHash,
|
|
2998
|
+
imageIsCompatible,
|
|
2999
|
+
operationsMatching,
|
|
3000
|
+
colorPreviewRequired,
|
|
3001
|
+
imageDataPatch,
|
|
3002
|
+
_getImageUsageInfo,
|
|
3003
|
+
designAreas,
|
|
3004
|
+
count,
|
|
3005
|
+
createCopy,
|
|
3006
|
+
editData,
|
|
3007
|
+
currentEditData,
|
|
3008
|
+
isBackendNeeded,
|
|
3009
|
+
selectedImage,
|
|
3010
|
+
_designProductionMethod,
|
|
3011
|
+
svgContent,
|
|
3012
|
+
svgColors,
|
|
3013
|
+
vectorizeColorsMap,
|
|
3014
|
+
thresholdChanged,
|
|
3015
|
+
maxPotentialColorAmount,
|
|
3016
|
+
vectorizeOriginalColorsMap,
|
|
3017
|
+
numberOfAggregatedColors,
|
|
3018
|
+
numberOfColorsToRemove,
|
|
3019
|
+
_args33 = arguments;
|
|
3020
|
+
|
|
3021
|
+
return regeneratorRuntime.wrap(function _callee32$(_context33) {
|
|
3022
|
+
while (1) {
|
|
3023
|
+
switch (_context33.prev = _context33.next) {
|
|
3024
|
+
case 0:
|
|
3025
|
+
options = _args33.length > 2 && _args33[2] !== undefined ? _args33[2] : {};
|
|
3026
|
+
// patch operations to keep other unchanged values
|
|
3027
|
+
operations = _objectSpread(_objectSpread({}, image.operations), operations);
|
|
3028
|
+
_options$immediateCom = options.immediateCommit, immediateCommit = _options$immediateCom === void 0 ? false : _options$immediateCom, _options$designProduc = options.designProductionMethod, designProductionMethod = _options$designProduc === void 0 ? (0, _Selectors.getSelectedDesignProductionMethod)(_ServiceLocator.Services.store.state) : _options$designProduc, _options$addMode = options.addMode, addMode = _options$addMode === void 0 ? false : _options$addMode, displayColorPreview = options.displayColorPreview;
|
|
3029
|
+
imageIdentifier = image.identifier;
|
|
3030
|
+
preview = image.preview;
|
|
3031
|
+
compatibilityInfoHash = (0, _Selectors.getDesignAreaImageCompatibilityInfo)(designProductionMethod);
|
|
3032
|
+
imageIsCompatible = (0, _Selectors.areHashesCompatible)(image.compatibilityInfoHash, compatibilityInfoHash);
|
|
3033
|
+
operationsMatching = (0, _Modifiers.compareOperations)(image.operations, operations);
|
|
3034
|
+
colorPreviewRequired = (0, _Selectors.designProductionMethodHasEmbroideryVisualizationEffect)(designProductionMethod);
|
|
3035
|
+
imageDataPatch = _objectSpread({
|
|
3036
|
+
compatibilityInfoHash: compatibilityInfoHash,
|
|
3037
|
+
colorPreviewRequired: colorPreviewRequired
|
|
3038
|
+
}, displayColorPreview !== undefined && {
|
|
3039
|
+
displayColorPreview: displayColorPreview
|
|
3040
|
+
});
|
|
3041
|
+
|
|
3042
|
+
if (!(!operationsMatching || !imageIsCompatible)) {
|
|
3043
|
+
_context33.next = 29;
|
|
3044
|
+
break;
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
if (!image.operations) {
|
|
3048
|
+
operations.vectorizeThreshold = null;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
operations = makeOperationsCompatible(operations, compatibilityInfoHash, designProductionMethod.colorPalettes);
|
|
3052
|
+
|
|
3053
|
+
if (!image.gallery) {
|
|
3054
|
+
_context33.next = 17;
|
|
3055
|
+
break;
|
|
3056
|
+
}
|
|
3057
|
+
|
|
3058
|
+
operations = _objectSpread(_objectSpread({}, operations || {}), {}, {
|
|
3059
|
+
vectorizeColorsMap: operations.vectorizeColorsMap
|
|
3060
|
+
});
|
|
3061
|
+
_context33.next = 29;
|
|
3062
|
+
break;
|
|
3063
|
+
|
|
3064
|
+
case 17:
|
|
3065
|
+
_getImageUsageInfo = (0, _Selectors2.getImageUsageInfo)(_ServiceLocator.Services.store.state, image.identifier), designAreas = _getImageUsageInfo.designAreas, count = _getImageUsageInfo.count;
|
|
3066
|
+
createCopy = !!(designAreas > 1 && image.compatibilityInfoHash && !imageIsCompatible) || !operationsMatching && count > (addMode ? 0 : 1);
|
|
3067
|
+
editData = (0, _Modifiers.getEditDataFromOperations)(image.fileName, operations, designProductionMethod);
|
|
3068
|
+
currentEditData = (0, _Modifiers.getEditDataFromOperations)(image.fileName, image.operations || {}, designProductionMethod);
|
|
3069
|
+
isBackendNeeded = createCopy || !(0, _isEqual["default"])(editData, currentEditData);
|
|
3070
|
+
_context33.t0 = isBackendNeeded;
|
|
3071
|
+
|
|
3072
|
+
if (!_context33.t0) {
|
|
3073
|
+
_context33.next = 26;
|
|
3074
|
+
break;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
_context33.next = 26;
|
|
3078
|
+
return _ServiceLocator.Services.store.dispatch((0, _Actions2.editImage)(_objectSpread(_objectSpread({}, editData), {}, {
|
|
3079
|
+
createCopy: createCopy
|
|
3080
|
+
}), _objectSpread(_objectSpread({}, imageDataPatch), {}, {
|
|
3081
|
+
operations: operations,
|
|
3082
|
+
identifier: imageIdentifier,
|
|
3083
|
+
incomplete: true
|
|
3084
|
+
}), {
|
|
3085
|
+
immediateCommit: immediateCommit
|
|
3086
|
+
}));
|
|
3087
|
+
|
|
3088
|
+
case 26:
|
|
3089
|
+
selectedImage = _ServiceLocator.Services.store.state.imageGallery.selectedImage;
|
|
3090
|
+
preview = (0, _get2["default"])(selectedImage, 'preview');
|
|
3091
|
+
imageIdentifier = (0, _get2["default"])(selectedImage, 'identifier');
|
|
3092
|
+
|
|
3093
|
+
case 29:
|
|
3094
|
+
if (!(!preview || !preview.url)) {
|
|
3095
|
+
_context33.next = 31;
|
|
3096
|
+
break;
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
throw new Error('Preview image url is not specified!');
|
|
3100
|
+
|
|
3101
|
+
case 31:
|
|
3102
|
+
if (!(0, _Selectors2.isEditableVectorImage)(preview)) {
|
|
3103
|
+
_context33.next = 40;
|
|
3104
|
+
break;
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
_designProductionMethod = (0, _Selectors.getSelectedDesignProductionMethod)(_ServiceLocator.Services.store.state);
|
|
3108
|
+
_context33.next = 35;
|
|
3109
|
+
return getSvgContent(preview.url, false, !operationsMatching);
|
|
3110
|
+
|
|
3111
|
+
case 35:
|
|
3112
|
+
svgContent = _context33.sent;
|
|
3113
|
+
svgColors = getSvgColors(svgContent, _designProductionMethod);
|
|
3114
|
+
vectorizeColorsMap = (0, _Modifiers.createVectorizeColorsMap)(operations.vectorizeColorsMap, svgColors);
|
|
3115
|
+
thresholdChanged = operations.vectorizeThreshold !== (0, _get2["default"])(image, 'operations.vectorizeThreshold', 0); // prepare initial values for the vectorize feature
|
|
3116
|
+
|
|
3117
|
+
if (!operations.vectorizeThreshold) {
|
|
3118
|
+
maxPotentialColorAmount = +(0, _get2["default"])(preview, 'additionalData.maxPotentialColorAmount') || svgColors.length;
|
|
3119
|
+
operations = _objectSpread(_objectSpread({}, operations), {}, {
|
|
3120
|
+
vectorizeMaxColorAmount: maxPotentialColorAmount,
|
|
3121
|
+
vectorizeThreshold: (0, _Selectors5.getAggregatedColorCount)(vectorizeColorsMap)
|
|
3122
|
+
});
|
|
3123
|
+
vectorizeOriginalColorsMap = (0, _Modifiers.createVectorizeColorsMap)({}, svgColors);
|
|
3124
|
+
operations = _objectSpread(_objectSpread({}, operations), {}, {
|
|
3125
|
+
vectorizeOriginalColorsMap: vectorizeOriginalColorsMap,
|
|
3126
|
+
vectorizeColorsMap: vectorizeColorsMap
|
|
3127
|
+
});
|
|
3128
|
+
} else if (thresholdChanged) {
|
|
3129
|
+
operations.vectorizeColorsMap = (0, _ImageEditUtils.expandVectorizeColorsMap)(vectorizeColorsMap, _designProductionMethod.colorPalettes, operations.vectorizeThreshold); // gallery images are not edited by the api, colors have to be reduced programmatically
|
|
3130
|
+
|
|
3131
|
+
if (image.gallery) {
|
|
3132
|
+
numberOfAggregatedColors = (0, _Selectors5.getAggregatedColorCount)(operations.vectorizeColorsMap);
|
|
3133
|
+
numberOfColorsToRemove = numberOfAggregatedColors - operations.vectorizeThreshold;
|
|
3134
|
+
|
|
3135
|
+
if (numberOfColorsToRemove > 0) {
|
|
3136
|
+
operations.vectorizeColorsMap = (0, _Modifiers.reduceNumberOfDistinctColorsBy)(operations.vectorizeColorsMap, numberOfColorsToRemove);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
} else {
|
|
3140
|
+
operations.vectorizeColorsMap = vectorizeColorsMap;
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
case 40:
|
|
3144
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions2.updateImage)(imageIdentifier, _objectSpread(_objectSpread({
|
|
3145
|
+
operations: operations
|
|
3146
|
+
}, imageDataPatch), {}, {
|
|
3147
|
+
incomplete: false
|
|
3148
|
+
}), immediateCommit));
|
|
3149
|
+
|
|
3150
|
+
if (immediateCommit) {
|
|
3151
|
+
this.updateDesignAreaImagesWithSelectedImageData(image.identifier);
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
return _context33.abrupt("return", {
|
|
3155
|
+
vectorizeColorsMap: operations.vectorizeColorsMap,
|
|
3156
|
+
vectorizeThreshold: operations.vectorizeThreshold,
|
|
3157
|
+
vectorizeMaxColorAmount: operations.vectorizeMaxColorAmount,
|
|
3158
|
+
vectorizeOriginalColorsMap: operations.vectorizeOriginalColorsMap
|
|
3159
|
+
});
|
|
3160
|
+
|
|
3161
|
+
case 43:
|
|
3162
|
+
case "end":
|
|
3163
|
+
return _context33.stop();
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
}, _callee32, this);
|
|
3167
|
+
}));
|
|
3168
|
+
|
|
3169
|
+
function editFile(_x38, _x39) {
|
|
3170
|
+
return _editFile.apply(this, arguments);
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
return editFile;
|
|
3174
|
+
}()
|
|
3175
|
+
}, {
|
|
3176
|
+
key: "resetEditedFile",
|
|
3177
|
+
value: function () {
|
|
3178
|
+
var _resetEditedFile = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee33(image) {
|
|
3179
|
+
var state, _image, operations, vectorizeColorsMap, resetOperations, designProductionMethod;
|
|
3180
|
+
|
|
3181
|
+
return regeneratorRuntime.wrap(function _callee33$(_context34) {
|
|
3182
|
+
while (1) {
|
|
3183
|
+
switch (_context34.prev = _context34.next) {
|
|
3184
|
+
case 0:
|
|
3185
|
+
state = _ServiceLocator.Services.store.state;
|
|
3186
|
+
|
|
3187
|
+
if (!image) {
|
|
3188
|
+
image = state.imageGallery.selectedImage;
|
|
3189
|
+
}
|
|
3190
|
+
|
|
3191
|
+
_image = image, operations = _image.operations;
|
|
3192
|
+
vectorizeColorsMap = _extends({}, operations.vectorizeOriginalColorsMap);
|
|
3193
|
+
|
|
3194
|
+
if (image.gallery) {
|
|
3195
|
+
resetOperations = _objectSpread(_objectSpread({}, operations), {}, {
|
|
3196
|
+
vectorizeColorsMap: vectorizeColorsMap
|
|
3197
|
+
});
|
|
3198
|
+
} else {
|
|
3199
|
+
designProductionMethod = (0, _Selectors.getSelectedDesignProductionMethod)(state);
|
|
3200
|
+
resetOperations = _objectSpread(_objectSpread({}, operations), !designProductionMethod.options.vectorsRequired ? (0, _Modifiers.removeVectorizeFromOperations)(operations) : {
|
|
3201
|
+
vectorizeColorsMap: vectorizeColorsMap,
|
|
3202
|
+
vectorizeThreshold: null
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
_context34.next = 7;
|
|
3207
|
+
return this.editFileQueued(resetOperations, image);
|
|
3208
|
+
|
|
3209
|
+
case 7:
|
|
3210
|
+
return _context34.abrupt("return", _context34.sent);
|
|
3211
|
+
|
|
3212
|
+
case 8:
|
|
3213
|
+
case "end":
|
|
3214
|
+
return _context34.stop();
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
}, _callee33, this);
|
|
3218
|
+
}));
|
|
3219
|
+
|
|
3220
|
+
function resetEditedFile(_x40) {
|
|
3221
|
+
return _resetEditedFile.apply(this, arguments);
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
return resetEditedFile;
|
|
3225
|
+
}()
|
|
3226
|
+
}, {
|
|
3227
|
+
key: "commitChanges",
|
|
3228
|
+
value: function commitChanges() {
|
|
3229
|
+
_ServiceLocator.Services.store.dispatch((0, _Actions2.commitChanges)());
|
|
3230
|
+
}
|
|
3231
|
+
}, {
|
|
3232
|
+
key: "clearSelectionOnCurrentDesignArea",
|
|
3233
|
+
value: function clearSelectionOnCurrentDesignArea() {
|
|
3234
|
+
var designArea = (0, _Selectors.getSelectedDesignArea)(_ServiceLocator.Services.store.state);
|
|
3235
|
+
|
|
3236
|
+
var canvas = this._getCanvas(designArea);
|
|
3237
|
+
|
|
3238
|
+
if (canvas) {
|
|
3239
|
+
canvas.clearSelection();
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
}]);
|
|
3243
|
+
|
|
3244
|
+
return DesignDataService;
|
|
3245
|
+
}();
|
|
3246
|
+
|
|
3247
|
+
exports["default"] = DesignDataService;
|
|
3248
|
+
|
|
3249
|
+
_defineProperty(DesignDataService, "serviceName", 'DesignDataService');
|