@webiny/app-admin 0.0.0-mt-1
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/LICENSE +21 -0
- package/README.md +21 -0
- package/assets/icons/add-18px.svg +3 -0
- package/assets/icons/arrow_drop_down-24px.svg +4 -0
- package/assets/icons/attach_file_black_24dp.svg +1 -0
- package/assets/icons/baseline-menu-24px.svg +4 -0
- package/assets/icons/baseline-notification_important-24px.svg +4 -0
- package/assets/icons/baseline-security-24px.svg +4 -0
- package/assets/icons/filter-24px.svg +8 -0
- package/assets/icons/github-brands.svg +1 -0
- package/assets/icons/highlight-24px.svg +1 -0
- package/assets/icons/icon-community.svg +16 -0
- package/assets/icons/icon-documentation.svg +16 -0
- package/assets/icons/info.svg +1 -0
- package/assets/icons/insert_drive_file-24px.svg +1 -0
- package/assets/icons/insert_photo-24px.svg +1 -0
- package/assets/icons/label-24px.svg +1 -0
- package/assets/icons/round-account_circle-24px.svg +1 -0
- package/assets/icons/round-add-24px.svg +16 -0
- package/assets/icons/round-arrow_drop_down-24px.svg +1 -0
- package/assets/icons/round-chevron_right-24px.svg +12 -0
- package/assets/icons/round-feedback-24px.svg +54 -0
- package/assets/icons/round-help-24px.svg +1 -0
- package/assets/icons/round-invert_colors-24px.svg +52 -0
- package/assets/icons/round-keyboard_arrow_down-24px.svg +16 -0
- package/assets/icons/round-keyboard_arrow_up-24px.svg +16 -0
- package/assets/icons/round-lock_open-24px.svg +60 -0
- package/assets/icons/round-more_vert-24px.svg +12 -0
- package/assets/icons/round-open_in_new-24px.svg +44 -0
- package/assets/icons/round-settings-24px.svg +4 -0
- package/assets/icons/search-24px.svg +20 -0
- package/assets/icons/slack-logo.svg +1 -0
- package/assets/icons/today-24px.svg +1 -0
- package/assets/icons/touch_app.svg +1 -0
- package/assets/images/arr.png +0 -0
- package/assets/images/arr_2.png +0 -0
- package/assets/images/header_bg.jpg +0 -0
- package/assets/images/icons.png +0 -0
- package/assets/images/icons_retina.png +0 -0
- package/assets/images/logo.png +0 -0
- package/assets/images/logo_orange.png +0 -0
- package/assets/images/public/bg-login.png +0 -0
- package/assets/images/public/favicon.ico +0 -0
- package/assets/images/public/logo_orange.png +0 -0
- package/assets/images/public/preloader_2.png +0 -0
- package/assets/images/swich.png +0 -0
- package/assets/images/table_img.jpg +0 -0
- package/assets/images/webiny-logo.svg +20 -0
- package/assets/images/webiny-orange-logo.svg +20 -0
- package/components/AdminLayout.d.ts +7 -0
- package/components/AdminLayout.js +35 -0
- package/components/AppInstaller/Sidebar.d.ts +7 -0
- package/components/AppInstaller/Sidebar.js +158 -0
- package/components/AppInstaller/assets/sign-in-divider.svg +19 -0
- package/components/AppInstaller/index.d.ts +5 -0
- package/components/AppInstaller/index.js +134 -0
- package/components/AppInstaller/styled.d.ts +7 -0
- package/components/AppInstaller/styled.js +73 -0
- package/components/AppInstaller/useInstaller.d.ts +11 -0
- package/components/AppInstaller/useInstaller.js +279 -0
- package/components/EmptyView.d.ts +8 -0
- package/components/EmptyView.js +56 -0
- package/components/FileManager/BottomInfoBar/SupportedFileTypes.d.ts +5 -0
- package/components/FileManager/BottomInfoBar/SupportedFileTypes.js +35 -0
- package/components/FileManager/BottomInfoBar/UploadStatus.d.ts +5 -0
- package/components/FileManager/BottomInfoBar/UploadStatus.js +47 -0
- package/components/FileManager/BottomInfoBar.d.ts +3 -0
- package/components/FileManager/BottomInfoBar.js +42 -0
- package/components/FileManager/DropFilesHere.d.ts +8 -0
- package/components/FileManager/DropFilesHere.js +58 -0
- package/components/FileManager/File.d.ts +18 -0
- package/components/FileManager/File.js +129 -0
- package/components/FileManager/FileDetails/Name.d.ts +6 -0
- package/components/FileManager/FileDetails/Name.js +113 -0
- package/components/FileManager/FileDetails/Tags.d.ts +6 -0
- package/components/FileManager/FileDetails/Tags.js +241 -0
- package/components/FileManager/FileDetails.d.ts +23 -0
- package/components/FileManager/FileDetails.js +392 -0
- package/components/FileManager/FileManagerContext.d.ts +23 -0
- package/components/FileManager/FileManagerContext.js +174 -0
- package/components/FileManager/FileManagerView.d.ts +23 -0
- package/components/FileManager/FileManagerView.js +632 -0
- package/components/FileManager/LeftSidebar.d.ts +8 -0
- package/components/FileManager/LeftSidebar.js +95 -0
- package/components/FileManager/NoPermissionView.d.ts +3 -0
- package/components/FileManager/NoPermissionView.js +70 -0
- package/components/FileManager/NoResults.d.ts +2 -0
- package/components/FileManager/NoResults.js +13 -0
- package/components/FileManager/getFileTypePlugin.d.ts +1 -0
- package/components/FileManager/getFileTypePlugin.js +27 -0
- package/components/FileManager/getFileUploader.d.ts +2 -0
- package/components/FileManager/getFileUploader.js +10 -0
- package/components/FileManager/graphql.d.ts +6 -0
- package/components/FileManager/graphql.js +17 -0
- package/components/FileManager/icons/content_copy-black-24px.svg +1 -0
- package/components/FileManager/icons/delete.svg +12 -0
- package/components/FileManager/icons/privacy_tip-24px.svg +10 -0
- package/components/FileManager/icons/round-check_box-24px.svg +4 -0
- package/components/FileManager/icons/round-check_box_outline_blank-24px.svg +4 -0
- package/components/FileManager/icons/round-cloud_download-24px.svg +4 -0
- package/components/FileManager/icons/round-cloud_upload-24px.svg +4 -0
- package/components/FileManager/icons/round-description-24px.svg +4 -0
- package/components/FileManager/icons/round-edit-24px.svg +4 -0
- package/components/FileManager/icons/round-info-24px.svg +4 -0
- package/components/FileManager/icons/round-label-24px.svg +4 -0
- package/components/FileManager/icons/round-more_vert-24px.svg +4 -0
- package/components/FileManager/icons/round-search-24px.svg +20 -0
- package/components/FileManager/outputFileSelectionError.d.ts +2 -0
- package/components/FileManager/outputFileSelectionError.js +39 -0
- package/components/FileManager.d.ts +18 -0
- package/components/FileManager.js +133 -0
- package/components/FloatingActionButton.d.ts +3 -0
- package/components/FloatingActionButton.js +17 -0
- package/components/MultiImageUpload.d.ts +4 -0
- package/components/MultiImageUpload.js +20 -0
- package/components/OverlayLayout/OverlayLayout.d.ts +25 -0
- package/components/OverlayLayout/OverlayLayout.js +159 -0
- package/components/OverlayLayout/icons/close.svg +13 -0
- package/components/OverlayLayout/icons/navigate_before.svg +16 -0
- package/components/OverlayLayout/index.d.ts +1 -0
- package/components/OverlayLayout/index.js +1 -0
- package/components/Permissions/Permissions.d.ts +7 -0
- package/components/Permissions/Permissions.js +37 -0
- package/components/Permissions/StyledComponents.d.ts +6 -0
- package/components/Permissions/StyledComponents.js +19 -0
- package/components/Permissions/index.d.ts +2 -0
- package/components/Permissions/index.js +2 -0
- package/components/RichTextEditor/RichTextEditor.d.ts +3 -0
- package/components/RichTextEditor/RichTextEditor.js +15 -0
- package/components/RichTextEditor/index.d.ts +2 -0
- package/components/RichTextEditor/index.js +2 -0
- package/components/RichTextEditor/styles.scss +64 -0
- package/components/RichTextEditor/tools/header/index.d.ts +228 -0
- package/components/RichTextEditor/tools/header/index.js +731 -0
- package/components/RichTextEditor/tools/header/styles.scss +48 -0
- package/components/RichTextEditor/tools/image/index.d.ts +97 -0
- package/components/RichTextEditor/tools/image/index.js +257 -0
- package/components/RichTextEditor/tools/image/styles.scss +90 -0
- package/components/RichTextEditor/tools/image/svgs.d.ts +6 -0
- package/components/RichTextEditor/tools/image/svgs.js +5 -0
- package/components/RichTextEditor/tools/image/tunes.d.ts +58 -0
- package/components/RichTextEditor/tools/image/tunes.js +134 -0
- package/components/RichTextEditor/tools/image/ui.d.ts +111 -0
- package/components/RichTextEditor/tools/image/ui.js +281 -0
- package/components/RichTextEditor/tools/paragraph/index.d.ts +211 -0
- package/components/RichTextEditor/tools/paragraph/index.js +520 -0
- package/components/RichTextEditor/tools/paragraph/styles.scss +29 -0
- package/components/RichTextEditor/tools/textColor/index.d.ts +58 -0
- package/components/RichTextEditor/tools/textColor/index.js +232 -0
- package/components/RichTextEditor/tools/textColor/styles.scss +21 -0
- package/components/RichTextEditor/tools/utils.d.ts +19 -0
- package/components/RichTextEditor/tools/utils.js +24 -0
- package/components/SearchUI.d.ts +8 -0
- package/components/SearchUI.js +59 -0
- package/components/SimpleForm/SimpleForm.d.ts +21 -0
- package/components/SimpleForm/SimpleForm.js +75 -0
- package/components/SimpleForm/index.d.ts +1 -0
- package/components/SimpleForm/index.js +1 -0
- package/components/SimpleUI/InputField.d.ts +9 -0
- package/components/SimpleUI/InputField.js +97 -0
- package/components/SingleImageUpload.d.ts +25 -0
- package/components/SingleImageUpload.js +102 -0
- package/components/SplitView/SplitView.d.ts +10 -0
- package/components/SplitView/SplitView.js +76 -0
- package/components/SplitView/index.d.ts +1 -0
- package/components/SplitView/index.js +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/hooks/useConfirmationDialog.d.ts +10 -0
- package/hooks/useConfirmationDialog.js +47 -0
- package/hooks/useDialog.d.ts +5 -0
- package/hooks/useDialog.js +27 -0
- package/hooks/useSnackbar.d.ts +4 -0
- package/hooks/useSnackbar.js +25 -0
- package/package.json +101 -0
- package/plugins/FileManagerFileTypePlugin.d.ts +33 -0
- package/plugins/FileManagerFileTypePlugin.js +46 -0
- package/plugins/MenuPlugin.d.ts +20 -0
- package/plugins/MenuPlugin.js +41 -0
- package/plugins/PermissionRendererPlugin.d.ts +22 -0
- package/plugins/PermissionRendererPlugin.js +41 -0
- package/plugins/fileManager/fileDefault.d.ts +3 -0
- package/plugins/fileManager/fileDefault.js +20 -0
- package/plugins/fileManager/fileImage/DeleteAction.d.ts +3 -0
- package/plugins/fileManager/fileImage/DeleteAction.js +62 -0
- package/plugins/fileManager/fileImage/EditAction.d.ts +9 -0
- package/plugins/fileManager/fileImage/EditAction.js +143 -0
- package/plugins/fileManager/fileImage/index.d.ts +3 -0
- package/plugins/fileManager/fileImage/index.js +29 -0
- package/plugins/fileManager/icons/edit.svg +17 -0
- package/plugins/fileManager/icons/round-description-24px.svg +1 -0
- package/plugins/fileManager/index.d.ts +2 -0
- package/plugins/fileManager/index.js +3 -0
- package/plugins/globalSearch/SearchBar.d.ts +3 -0
- package/plugins/globalSearch/SearchBar.js +241 -0
- package/plugins/globalSearch/SearchBarDropdown.d.ts +5 -0
- package/plugins/globalSearch/SearchBarDropdown.js +82 -0
- package/plugins/globalSearch/icons/round-search-24px.svg +20 -0
- package/plugins/globalSearch/index.d.ts +8 -0
- package/plugins/globalSearch/index.js +30 -0
- package/plugins/globalSearch/styled.d.ts +9 -0
- package/plugins/globalSearch/styled.js +115 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +8 -0
- package/plugins/logo/Logo.d.ts +22 -0
- package/plugins/logo/Logo.js +108 -0
- package/plugins/logo/index.d.ts +5 -0
- package/plugins/logo/index.js +32 -0
- package/plugins/menu/documentation.d.ts +4 -0
- package/plugins/menu/documentation.js +16 -0
- package/plugins/menu/fileManager.d.ts +4 -0
- package/plugins/menu/fileManager.js +64 -0
- package/plugins/menu/index.d.ts +6 -0
- package/plugins/menu/index.js +24 -0
- package/plugins/menu/renderers/MenuGroupRenderer.d.ts +7 -0
- package/plugins/menu/renderers/MenuGroupRenderer.js +126 -0
- package/plugins/menu/renderers/MenuLinkRenderer.d.ts +7 -0
- package/plugins/menu/renderers/MenuLinkRenderer.js +52 -0
- package/plugins/menu/renderers/MenuSectionItemRenderer.d.ts +7 -0
- package/plugins/menu/renderers/MenuSectionItemRenderer.js +77 -0
- package/plugins/menu/renderers/MenuSectionRenderer.d.ts +7 -0
- package/plugins/menu/renderers/MenuSectionRenderer.js +51 -0
- package/plugins/menu/slack.d.ts +4 -0
- package/plugins/menu/slack.js +16 -0
- package/plugins/menu/source.d.ts +4 -0
- package/plugins/menu/source.js +16 -0
- package/plugins/uiLayoutRenderer/index.d.ts +3 -0
- package/plugins/uiLayoutRenderer/index.js +63 -0
- package/plugins/userMenu/UserMenuElement.d.ts +7 -0
- package/plugins/userMenu/UserMenuElement.js +43 -0
- package/plugins/userMenu/UserMenuRenderer.d.ts +6 -0
- package/plugins/userMenu/UserMenuRenderer.js +47 -0
- package/plugins/userMenu/index.d.ts +4 -0
- package/plugins/userMenu/index.js +16 -0
- package/styles/material-theme-assignments.scss +333 -0
- package/styles/material.scss +74 -0
- package/styles/theme.scss +43 -0
- package/styles.scss +2 -0
- package/types.d.ts +100 -0
- package/types.js +1 -0
- package/ui/UIElement.d.ts +2 -0
- package/ui/UIElement.js +1 -0
- package/ui/UILayout.d.ts +1 -0
- package/ui/UILayout.js +1 -0
- package/ui/UIRenderer.d.ts +2 -0
- package/ui/UIRenderer.js +1 -0
- package/ui/UIView.d.ts +2 -0
- package/ui/UIView.js +1 -0
- package/ui/elements/AccordionElement.d.ts +27 -0
- package/ui/elements/AccordionElement.js +86 -0
- package/ui/elements/ButtonElement.d.ts +24 -0
- package/ui/elements/ButtonElement.js +78 -0
- package/ui/elements/ButtonGroupElement.d.ts +6 -0
- package/ui/elements/ButtonGroupElement.js +48 -0
- package/ui/elements/GenericElement.d.ts +1 -0
- package/ui/elements/GenericElement.js +1 -0
- package/ui/elements/LabelElement.d.ts +16 -0
- package/ui/elements/LabelElement.js +47 -0
- package/ui/elements/NavigationMenuElement.d.ts +32 -0
- package/ui/elements/NavigationMenuElement.js +158 -0
- package/ui/elements/PanelElement.d.ts +3 -0
- package/ui/elements/PanelElement.js +17 -0
- package/ui/elements/PlaceholderElement.d.ts +5 -0
- package/ui/elements/PlaceholderElement.js +30 -0
- package/ui/elements/SmallButtonElement.d.ts +6 -0
- package/ui/elements/SmallButtonElement.js +47 -0
- package/ui/elements/TypographyElement.d.ts +13 -0
- package/ui/elements/TypographyElement.js +49 -0
- package/ui/elements/ViewElement.d.ts +1 -0
- package/ui/elements/ViewElement.js +1 -0
- package/ui/elements/form/DynamicFieldsetElement/DynamicFieldsetRowElement.d.ts +6 -0
- package/ui/elements/form/DynamicFieldsetElement/DynamicFieldsetRowElement.js +44 -0
- package/ui/elements/form/DynamicFieldsetElement.d.ts +42 -0
- package/ui/elements/form/DynamicFieldsetElement.js +127 -0
- package/ui/elements/form/FileManagerElement/EmptyStateElement.d.ts +4 -0
- package/ui/elements/form/FileManagerElement/EmptyStateElement.js +24 -0
- package/ui/elements/form/FileManagerElement/EmptyStateElementRenderer.d.ts +7 -0
- package/ui/elements/form/FileManagerElement/EmptyStateElementRenderer.js +72 -0
- package/ui/elements/form/FileManagerElement/FileManagerElementRenderer.d.ts +13 -0
- package/ui/elements/form/FileManagerElement/FileManagerElementRenderer.js +95 -0
- package/ui/elements/form/FileManagerElement/styled.d.ts +14 -0
- package/ui/elements/form/FileManagerElement/styled.js +106 -0
- package/ui/elements/form/FileManagerElement.d.ts +24 -0
- package/ui/elements/form/FileManagerElement.js +91 -0
- package/ui/elements/form/FormElement.d.ts +21 -0
- package/ui/elements/form/FormElement.js +45 -0
- package/ui/elements/form/FormFieldElement.d.ts +55 -0
- package/ui/elements/form/FormFieldElement.js +183 -0
- package/ui/elements/form/HiddenElement.d.ts +6 -0
- package/ui/elements/form/HiddenElement.js +49 -0
- package/ui/elements/form/InputElement.d.ts +6 -0
- package/ui/elements/form/InputElement.js +55 -0
- package/ui/elements/form/PasswordElement.d.ts +6 -0
- package/ui/elements/form/PasswordElement.js +50 -0
- package/ui/elements/form/README.md +2 -0
- package/ui/elements/form/SelectElement.d.ts +15 -0
- package/ui/elements/form/SelectElement.js +71 -0
- package/ui/elements/form/TextareaElement.d.ts +15 -0
- package/ui/elements/form/TextareaElement.js +56 -0
- package/ui/views/AdminView/ContentElement.d.ts +4 -0
- package/ui/views/AdminView/ContentElement.js +62 -0
- package/ui/views/AdminView/HeaderElement.d.ts +13 -0
- package/ui/views/AdminView/HeaderElement.js +111 -0
- package/ui/views/AdminView/HeaderSectionCenterElement.d.ts +6 -0
- package/ui/views/AdminView/HeaderSectionCenterElement.js +42 -0
- package/ui/views/AdminView/HeaderSectionLeftElement.d.ts +6 -0
- package/ui/views/AdminView/HeaderSectionLeftElement.js +42 -0
- package/ui/views/AdminView/HeaderSectionRightElement.d.ts +6 -0
- package/ui/views/AdminView/HeaderSectionRightElement.js +42 -0
- package/ui/views/AdminView/components/Dialog.d.ts +2 -0
- package/ui/views/AdminView/components/Dialog.js +40 -0
- package/ui/views/AdminView/components/Hamburger.d.ts +3 -0
- package/ui/views/AdminView/components/Hamburger.js +25 -0
- package/ui/views/AdminView/components/Snackbar.d.ts +3 -0
- package/ui/views/AdminView/components/Snackbar.js +28 -0
- package/ui/views/AdminView.d.ts +12 -0
- package/ui/views/AdminView.js +90 -0
- package/ui/views/FormView/FormContainerElement.d.ts +12 -0
- package/ui/views/FormView/FormContainerElement.js +51 -0
- package/ui/views/FormView/FormContentElement.d.ts +3 -0
- package/ui/views/FormView/FormContentElement.js +17 -0
- package/ui/views/FormView/FormFooterElement.d.ts +6 -0
- package/ui/views/FormView/FormFooterElement.js +49 -0
- package/ui/views/FormView/FormHeaderElement.d.ts +14 -0
- package/ui/views/FormView/FormHeaderElement.js +81 -0
- package/ui/views/FormView.d.ts +40 -0
- package/ui/views/FormView.js +160 -0
- package/ui/views/NavigationView/ContentElement.d.ts +10 -0
- package/ui/views/NavigationView/ContentElement.js +86 -0
- package/ui/views/NavigationView/FooterElement.d.ts +13 -0
- package/ui/views/NavigationView/FooterElement.js +57 -0
- package/ui/views/NavigationView/HeaderElement.d.ts +16 -0
- package/ui/views/NavigationView/HeaderElement.js +66 -0
- package/ui/views/NavigationView/NavigationViewRenderer.d.ts +6 -0
- package/ui/views/NavigationView/NavigationViewRenderer.js +38 -0
- package/ui/views/NavigationView/Styled.d.ts +7 -0
- package/ui/views/NavigationView/Styled.js +47 -0
- package/ui/views/NavigationView/legacyMenu.d.ts +22 -0
- package/ui/views/NavigationView/legacyMenu.js +1 -0
- package/ui/views/NavigationView/useNavigation.d.ts +6 -0
- package/ui/views/NavigationView/useNavigation.js +22 -0
- package/ui/views/NavigationView.d.ts +26 -0
- package/ui/views/NavigationView.js +204 -0
- package/ui/views/OverlayView/ContentElement.d.ts +6 -0
- package/ui/views/OverlayView/ContentElement.js +42 -0
- package/ui/views/OverlayView/HeaderElement.d.ts +24 -0
- package/ui/views/OverlayView/HeaderElement.js +115 -0
- package/ui/views/OverlayView/HeaderTitleElement.d.ts +13 -0
- package/ui/views/OverlayView/HeaderTitleElement.js +54 -0
- package/ui/views/OverlayView/useOverlayView.d.ts +6 -0
- package/ui/views/OverlayView/useOverlayView.js +38 -0
- package/ui/views/OverlayView.d.ts +31 -0
- package/ui/views/OverlayView.js +176 -0
- package/ui/views/SplitView/SplitViewPanelElement.d.ts +11 -0
- package/ui/views/SplitView/SplitViewPanelElement.js +72 -0
- package/ui/views/SplitView.d.ts +21 -0
- package/ui/views/SplitView.js +142 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin styles
|
|
3
|
+
*/
|
|
4
|
+
.ce-header {
|
|
5
|
+
padding: 1em 0;
|
|
6
|
+
margin: 0 0 -0.9em;
|
|
7
|
+
line-height: 1.5em;
|
|
8
|
+
outline: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ce-header p,
|
|
12
|
+
.ce-header div {
|
|
13
|
+
padding: 0 !important;
|
|
14
|
+
margin: 0 !important;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Styles for Plugin icon in Toolbar
|
|
19
|
+
*/
|
|
20
|
+
.ce-header__icon {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ce-header[contentEditable="true"][data-placeholder]::before {
|
|
24
|
+
position: absolute;
|
|
25
|
+
content: attr(data-placeholder);
|
|
26
|
+
color: #707684;
|
|
27
|
+
font-weight: normal;
|
|
28
|
+
display: none;
|
|
29
|
+
cursor: text;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ce-header[contentEditable="true"][data-placeholder]:empty::before {
|
|
33
|
+
display: block;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ce-header[contentEditable="true"][data-placeholder]:empty:focus::before {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ce-header-text--start {
|
|
41
|
+
text-align: start;
|
|
42
|
+
}
|
|
43
|
+
.ce-header-text--center {
|
|
44
|
+
text-align: center;
|
|
45
|
+
}
|
|
46
|
+
.ce-header-text--end {
|
|
47
|
+
text-align: end;
|
|
48
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export default class ImageTool {
|
|
2
|
+
private readonly api;
|
|
3
|
+
private readonly readOnly;
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly tunes;
|
|
6
|
+
private readonly ui;
|
|
7
|
+
private readonly _data;
|
|
8
|
+
/**
|
|
9
|
+
* Notify core that read-only mode is supported
|
|
10
|
+
*
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
static get isReadOnlySupported(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Get Tool toolbox settings
|
|
16
|
+
* icon - Tool icon's SVG
|
|
17
|
+
* title - title to show in toolbox
|
|
18
|
+
*
|
|
19
|
+
* @returns {{icon: string, title: string}}
|
|
20
|
+
*/
|
|
21
|
+
static get toolbox(): {
|
|
22
|
+
icon: string;
|
|
23
|
+
title: string;
|
|
24
|
+
};
|
|
25
|
+
constructor({ data, config, api, readOnly }: {
|
|
26
|
+
data: any;
|
|
27
|
+
config: any;
|
|
28
|
+
api: any;
|
|
29
|
+
readOnly: any;
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Renders Block content
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*
|
|
36
|
+
* @returns {HTMLDivElement}
|
|
37
|
+
*/
|
|
38
|
+
render(): HTMLElement;
|
|
39
|
+
/**
|
|
40
|
+
* Return Block data
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*
|
|
44
|
+
* @returns {ImageToolData}
|
|
45
|
+
*/
|
|
46
|
+
save(): any;
|
|
47
|
+
/**
|
|
48
|
+
* Makes buttons with tunes: stretch image
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*
|
|
52
|
+
* @returns {Element}
|
|
53
|
+
*/
|
|
54
|
+
renderSettings(): any;
|
|
55
|
+
/**
|
|
56
|
+
* Stores all Tool's data
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
*
|
|
60
|
+
* @param {ImageToolData} data - data in Image Tool format
|
|
61
|
+
*/
|
|
62
|
+
set data(data: any);
|
|
63
|
+
/**
|
|
64
|
+
* Return Tool data
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
*
|
|
68
|
+
* @returns {ImageToolData}
|
|
69
|
+
*/
|
|
70
|
+
get data(): any;
|
|
71
|
+
/**
|
|
72
|
+
* Set new image file
|
|
73
|
+
*
|
|
74
|
+
* @private
|
|
75
|
+
*
|
|
76
|
+
* @param {object} file - uploaded file data
|
|
77
|
+
*/
|
|
78
|
+
set image(file: any);
|
|
79
|
+
/**
|
|
80
|
+
* Callback fired when Block Tune is activated
|
|
81
|
+
*
|
|
82
|
+
* @private
|
|
83
|
+
*
|
|
84
|
+
* @param {string} tuneName - tune that has been clicked
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
tuneToggled(tuneName: any): void;
|
|
88
|
+
/**
|
|
89
|
+
* Set one tune
|
|
90
|
+
*
|
|
91
|
+
* @param {string} tuneName - {@link Tunes.tunes}
|
|
92
|
+
* @param {boolean} value - tune state
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
95
|
+
setTune(tuneName: any, value: any): void;
|
|
96
|
+
isReadOnly(): boolean;
|
|
97
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import Ui from "./ui";
|
|
5
|
+
import Tunes from "./tunes";
|
|
6
|
+
import svgs from "./svgs";
|
|
7
|
+
|
|
8
|
+
var defaultGetFileSrc = function defaultGetFileSrc(file) {
|
|
9
|
+
if (typeof file === "string") {
|
|
10
|
+
return file;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return file.src;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var defaultOnSelectFile = function defaultOnSelectFile(file) {
|
|
17
|
+
return file.src;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var ImageTool = /*#__PURE__*/function () {
|
|
21
|
+
function ImageTool(_ref) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
var data = _ref.data,
|
|
25
|
+
config = _ref.config,
|
|
26
|
+
api = _ref.api,
|
|
27
|
+
readOnly = _ref.readOnly;
|
|
28
|
+
|
|
29
|
+
_classCallCheck(this, ImageTool);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "api", void 0);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "readOnly", void 0);
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "config", void 0);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "tunes", void 0);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "ui", void 0);
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "_data", void 0);
|
|
42
|
+
|
|
43
|
+
this.api = api;
|
|
44
|
+
this.readOnly = readOnly;
|
|
45
|
+
this.config = {
|
|
46
|
+
getFileSrc: config.getFileSrc || defaultGetFileSrc,
|
|
47
|
+
onSelectFile: config.onSelectFile || defaultOnSelectFile,
|
|
48
|
+
actions: config.actions || [],
|
|
49
|
+
context: config.context
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Module for working with UI
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
this.ui = new Ui({
|
|
56
|
+
api: api,
|
|
57
|
+
config: this.config,
|
|
58
|
+
onSelectFile: function onSelectFile() {
|
|
59
|
+
_this.config.context.showFileManager(function (file) {
|
|
60
|
+
_this.image = _this.config.onSelectFile(file);
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
readOnly: readOnly
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Module for working with tunes
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
this.tunes = new Tunes({
|
|
70
|
+
api: api,
|
|
71
|
+
actions: this.config.actions,
|
|
72
|
+
onChange: function onChange(tuneName) {
|
|
73
|
+
return _this.tuneToggled(tuneName);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Set saved state
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
this._data = {};
|
|
81
|
+
this.data = data;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Renders Block content
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*
|
|
88
|
+
* @returns {HTMLDivElement}
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
_createClass(ImageTool, [{
|
|
93
|
+
key: "render",
|
|
94
|
+
value: function render() {
|
|
95
|
+
return this.ui.render(this.data);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Return Block data
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*
|
|
102
|
+
* @returns {ImageToolData}
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
}, {
|
|
106
|
+
key: "save",
|
|
107
|
+
value: function save() {
|
|
108
|
+
var caption = this.ui.nodes.caption;
|
|
109
|
+
this._data.caption = caption.innerHTML;
|
|
110
|
+
return this.data;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Makes buttons with tunes: stretch image
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*
|
|
117
|
+
* @returns {Element}
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
}, {
|
|
121
|
+
key: "renderSettings",
|
|
122
|
+
value: function renderSettings() {
|
|
123
|
+
return this.tunes.render(this.data);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Stores all Tool's data
|
|
127
|
+
*
|
|
128
|
+
* @private
|
|
129
|
+
*
|
|
130
|
+
* @param {ImageToolData} data - data in Image Tool format
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
}, {
|
|
134
|
+
key: "data",
|
|
135
|
+
get:
|
|
136
|
+
/**
|
|
137
|
+
* Return Tool data
|
|
138
|
+
*
|
|
139
|
+
* @private
|
|
140
|
+
*
|
|
141
|
+
* @returns {ImageToolData}
|
|
142
|
+
*/
|
|
143
|
+
function get() {
|
|
144
|
+
return this._data;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Set new image file
|
|
148
|
+
*
|
|
149
|
+
* @private
|
|
150
|
+
*
|
|
151
|
+
* @param {object} file - uploaded file data
|
|
152
|
+
*/
|
|
153
|
+
,
|
|
154
|
+
set: function set(data) {
|
|
155
|
+
var _this2 = this;
|
|
156
|
+
|
|
157
|
+
this.image = data.file;
|
|
158
|
+
this._data.caption = data.caption || "";
|
|
159
|
+
this.ui.fillCaption(this._data.caption);
|
|
160
|
+
Tunes.tunes.forEach(function (_ref2) {
|
|
161
|
+
var tune = _ref2.name;
|
|
162
|
+
var value = typeof data[tune] !== "undefined" ? data[tune] === true || data[tune] === "true" : false;
|
|
163
|
+
|
|
164
|
+
_this2.setTune(tune, value);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "image",
|
|
169
|
+
set: function set(file) {
|
|
170
|
+
this._data.file = file || {};
|
|
171
|
+
|
|
172
|
+
if (file) {
|
|
173
|
+
this.ui.fillImage(this.config.getFileSrc(file));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Callback fired when Block Tune is activated
|
|
178
|
+
*
|
|
179
|
+
* @private
|
|
180
|
+
*
|
|
181
|
+
* @param {string} tuneName - tune that has been clicked
|
|
182
|
+
* @returns {void}
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
}, {
|
|
186
|
+
key: "tuneToggled",
|
|
187
|
+
value: function tuneToggled(tuneName) {
|
|
188
|
+
// inverse tune state
|
|
189
|
+
this.setTune(tuneName, !this._data[tuneName]);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Set one tune
|
|
193
|
+
*
|
|
194
|
+
* @param {string} tuneName - {@link Tunes.tunes}
|
|
195
|
+
* @param {boolean} value - tune state
|
|
196
|
+
* @returns {void}
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
}, {
|
|
200
|
+
key: "setTune",
|
|
201
|
+
value: function setTune(tuneName, value) {
|
|
202
|
+
var _this3 = this;
|
|
203
|
+
|
|
204
|
+
this._data[tuneName] = value;
|
|
205
|
+
this.ui.applyTune(tuneName, value);
|
|
206
|
+
|
|
207
|
+
if (tuneName === "stretched") {
|
|
208
|
+
/**
|
|
209
|
+
* Wait until the API is ready
|
|
210
|
+
*/
|
|
211
|
+
Promise.resolve().then(function () {
|
|
212
|
+
var blockId = _this3.api.blocks.getCurrentBlockIndex();
|
|
213
|
+
|
|
214
|
+
_this3.api.blocks.stretchBlock(blockId, value);
|
|
215
|
+
}).catch(function (err) {
|
|
216
|
+
console.error(err);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "isReadOnly",
|
|
222
|
+
value: function isReadOnly() {
|
|
223
|
+
return this.readOnly;
|
|
224
|
+
}
|
|
225
|
+
}], [{
|
|
226
|
+
key: "isReadOnlySupported",
|
|
227
|
+
get:
|
|
228
|
+
/**
|
|
229
|
+
* Notify core that read-only mode is supported
|
|
230
|
+
*
|
|
231
|
+
* @returns {boolean}
|
|
232
|
+
*/
|
|
233
|
+
function get() {
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get Tool toolbox settings
|
|
238
|
+
* icon - Tool icon's SVG
|
|
239
|
+
* title - title to show in toolbox
|
|
240
|
+
*
|
|
241
|
+
* @returns {{icon: string, title: string}}
|
|
242
|
+
*/
|
|
243
|
+
|
|
244
|
+
}, {
|
|
245
|
+
key: "toolbox",
|
|
246
|
+
get: function get() {
|
|
247
|
+
return {
|
|
248
|
+
icon: svgs.toolbox,
|
|
249
|
+
title: "Image"
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}]);
|
|
253
|
+
|
|
254
|
+
return ImageTool;
|
|
255
|
+
}();
|
|
256
|
+
|
|
257
|
+
export { ImageTool as default };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
.image-tool {
|
|
2
|
+
--bg-color: #cdd1e0;
|
|
3
|
+
--front-color: #388ae5;
|
|
4
|
+
--border-color: #e8e8eb;
|
|
5
|
+
|
|
6
|
+
&--stretched {
|
|
7
|
+
.image-tool__image {
|
|
8
|
+
max-width: 1032px;
|
|
9
|
+
margin: 0 auto 10px;
|
|
10
|
+
|
|
11
|
+
img {
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cdx-input {
|
|
18
|
+
box-shadow: none;
|
|
19
|
+
border: none;
|
|
20
|
+
text-align: center;
|
|
21
|
+
|
|
22
|
+
&:before {
|
|
23
|
+
text-align: center;
|
|
24
|
+
width: inherit;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__image {
|
|
29
|
+
border-radius: 3px;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
margin-bottom: 10px;
|
|
32
|
+
|
|
33
|
+
&-picture {
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
vertical-align: bottom;
|
|
36
|
+
display: block;
|
|
37
|
+
margin: 0 auto;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__caption {
|
|
42
|
+
&[contentEditable="true"][data-placeholder]::before {
|
|
43
|
+
position: absolute !important;
|
|
44
|
+
content: "Add caption for image (optional)";
|
|
45
|
+
color: #707684;
|
|
46
|
+
font-weight: normal;
|
|
47
|
+
display: none;
|
|
48
|
+
text-align: center;
|
|
49
|
+
width: inherit;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&[contentEditable="true"][data-placeholder]:empty {
|
|
53
|
+
&::before {
|
|
54
|
+
display: block;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus::before {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&--empty {
|
|
64
|
+
.image-tool__caption {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.image-tool__image {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&--filled {
|
|
74
|
+
.cdx-button {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Tunes
|
|
81
|
+
* ----------------
|
|
82
|
+
*/
|
|
83
|
+
&--stretched {
|
|
84
|
+
&__image {
|
|
85
|
+
&-picture {
|
|
86
|
+
width: 100%;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
buttonIcon: "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M3.15 13.628A7.749 7.749 0 0 0 10 17.75a7.74 7.74 0 0 0 6.305-3.242l-2.387-2.127-2.765 2.244-4.389-4.496-3.614 3.5zm-.787-2.303l4.446-4.371 4.52 4.63 2.534-2.057 3.533 2.797c.23-.734.354-1.514.354-2.324a7.75 7.75 0 1 0-15.387 1.325zM10 20C4.477 20 0 15.523 0 10S4.477 0 10 0s10 4.477 10 10-4.477 10-10 10z\"/>",
|
|
3
|
+
stretched: "<svg width=\"17\" height=\"10\" viewBox=\"0 0 17 10\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13.568 5.925H4.056l1.703 1.703a1.125 1.125 0 0 1-1.59 1.591L.962 6.014A1.069 1.069 0 0 1 .588 4.26L4.38.469a1.069 1.069 0 0 1 1.512 1.511L4.084 3.787h9.606l-1.85-1.85a1.069 1.069 0 1 1 1.512-1.51l3.792 3.791a1.069 1.069 0 0 1-.475 1.788L13.514 9.16a1.125 1.125 0 0 1-1.59-1.591l1.644-1.644z\"/></svg>",
|
|
4
|
+
toolbox: "<svg width=\"17\" height=\"15\" viewBox=\"0 0 336 276\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M291 150.242V79c0-18.778-15.222-34-34-34H79c-18.778 0-34 15.222-34 34v42.264l67.179-44.192 80.398 71.614 56.686-29.14L291 150.242zm-.345 51.622l-42.3-30.246-56.3 29.884-80.773-66.925L45 174.187V197c0 18.778 15.222 34 34 34h178c17.126 0 31.295-12.663 33.655-29.136zM79 0h178c43.63 0 79 35.37 79 79v118c0 43.63-35.37 79-79 79H79c-43.63 0-79-35.37-79-79V79C0 35.37 35.37 0 79 0z\"/></svg>"
|
|
5
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
declare type Tune = {
|
|
2
|
+
name: string;
|
|
3
|
+
icon: string;
|
|
4
|
+
title: string;
|
|
5
|
+
action?: Function;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Working with Block Tunes
|
|
9
|
+
*/
|
|
10
|
+
export default class Tunes {
|
|
11
|
+
private api;
|
|
12
|
+
private actions;
|
|
13
|
+
private onChange;
|
|
14
|
+
private buttons;
|
|
15
|
+
/**
|
|
16
|
+
* @param {object} tune - image tool Tunes managers
|
|
17
|
+
* @param {object} tune.api - Editor API
|
|
18
|
+
* @param {object} tune.actions - list of user defined tunes
|
|
19
|
+
* @param {Function} tune.onChange - tune toggling callback
|
|
20
|
+
*/
|
|
21
|
+
constructor({ api, actions, onChange }: {
|
|
22
|
+
api: any;
|
|
23
|
+
actions: any;
|
|
24
|
+
onChange: any;
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Available Image tunes
|
|
28
|
+
*
|
|
29
|
+
* @returns {{name: string, icon: string, title: string}[]}
|
|
30
|
+
*/
|
|
31
|
+
static get tunes(): Tune[];
|
|
32
|
+
/**
|
|
33
|
+
* Styles
|
|
34
|
+
*
|
|
35
|
+
* @returns {{wrapper: string, buttonBase: *, button: string, buttonActive: *}}
|
|
36
|
+
*/
|
|
37
|
+
get CSS(): {
|
|
38
|
+
wrapper: string;
|
|
39
|
+
buttonBase: string;
|
|
40
|
+
button: string;
|
|
41
|
+
buttonActive: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Makes buttons with tunes: stretch image
|
|
45
|
+
*
|
|
46
|
+
* @param {ImageToolData} toolData - generate Elements of tunes
|
|
47
|
+
* @returns {Element}
|
|
48
|
+
*/
|
|
49
|
+
render(toolData: any): any;
|
|
50
|
+
/**
|
|
51
|
+
* Clicks to one of the tunes
|
|
52
|
+
*
|
|
53
|
+
* @param {string} tuneName - clicked tune name
|
|
54
|
+
* @param {Function} customFunction - function to execute on click
|
|
55
|
+
*/
|
|
56
|
+
tuneClicked(tuneName: any, customFunction: any): boolean;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import { make } from "./ui";
|
|
5
|
+
import svgs from "./svgs";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Working with Block Tunes
|
|
9
|
+
*/
|
|
10
|
+
var Tunes = /*#__PURE__*/function () {
|
|
11
|
+
/**
|
|
12
|
+
* @param {object} tune - image tool Tunes managers
|
|
13
|
+
* @param {object} tune.api - Editor API
|
|
14
|
+
* @param {object} tune.actions - list of user defined tunes
|
|
15
|
+
* @param {Function} tune.onChange - tune toggling callback
|
|
16
|
+
*/
|
|
17
|
+
function Tunes(_ref) {
|
|
18
|
+
var api = _ref.api,
|
|
19
|
+
actions = _ref.actions,
|
|
20
|
+
onChange = _ref.onChange;
|
|
21
|
+
|
|
22
|
+
_classCallCheck(this, Tunes);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "api", void 0);
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "actions", void 0);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "onChange", void 0);
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "buttons", void 0);
|
|
31
|
+
|
|
32
|
+
this.api = api;
|
|
33
|
+
this.actions = actions;
|
|
34
|
+
this.onChange = onChange;
|
|
35
|
+
this.buttons = [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Available Image tunes
|
|
39
|
+
*
|
|
40
|
+
* @returns {{name: string, icon: string, title: string}[]}
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
_createClass(Tunes, [{
|
|
45
|
+
key: "CSS",
|
|
46
|
+
get:
|
|
47
|
+
/**
|
|
48
|
+
* Styles
|
|
49
|
+
*
|
|
50
|
+
* @returns {{wrapper: string, buttonBase: *, button: string, buttonActive: *}}
|
|
51
|
+
*/
|
|
52
|
+
function get() {
|
|
53
|
+
return {
|
|
54
|
+
wrapper: "",
|
|
55
|
+
buttonBase: this.api.styles.settingsButton,
|
|
56
|
+
button: "image-tool__tune",
|
|
57
|
+
buttonActive: this.api.styles.settingsButtonActive
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Makes buttons with tunes: stretch image
|
|
62
|
+
*
|
|
63
|
+
* @param {ImageToolData} toolData - generate Elements of tunes
|
|
64
|
+
* @returns {Element}
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
}, {
|
|
68
|
+
key: "render",
|
|
69
|
+
value: function render(toolData) {
|
|
70
|
+
var _this = this;
|
|
71
|
+
|
|
72
|
+
var wrapper = make("div", this.CSS.wrapper);
|
|
73
|
+
this.buttons = [];
|
|
74
|
+
var tunes = Tunes.tunes.concat(this.actions);
|
|
75
|
+
tunes.forEach(function (tune) {
|
|
76
|
+
var title = _this.api.i18n.t(tune.title);
|
|
77
|
+
|
|
78
|
+
var el = make("div", [_this.CSS.buttonBase, _this.CSS.button], {
|
|
79
|
+
innerHTML: tune.icon,
|
|
80
|
+
title: title
|
|
81
|
+
});
|
|
82
|
+
el.addEventListener("click", function () {
|
|
83
|
+
_this.tuneClicked(tune.name, tune.action);
|
|
84
|
+
});
|
|
85
|
+
el.dataset.tune = tune.name;
|
|
86
|
+
el.classList.toggle(_this.CSS.buttonActive, toolData[tune.name]);
|
|
87
|
+
|
|
88
|
+
_this.buttons.push(el);
|
|
89
|
+
|
|
90
|
+
_this.api.tooltip.onHover(el, title, {
|
|
91
|
+
placement: "top"
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
wrapper.appendChild(el);
|
|
95
|
+
});
|
|
96
|
+
return wrapper;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Clicks to one of the tunes
|
|
100
|
+
*
|
|
101
|
+
* @param {string} tuneName - clicked tune name
|
|
102
|
+
* @param {Function} customFunction - function to execute on click
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
}, {
|
|
106
|
+
key: "tuneClicked",
|
|
107
|
+
value: function tuneClicked(tuneName, customFunction) {
|
|
108
|
+
if (typeof customFunction === "function") {
|
|
109
|
+
if (!customFunction(tuneName)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var button = this.buttons.find(function (el) {
|
|
115
|
+
return el.dataset.tune === tuneName;
|
|
116
|
+
});
|
|
117
|
+
button.classList.toggle(this.CSS.buttonActive, !button.classList.contains(this.CSS.buttonActive));
|
|
118
|
+
this.onChange(tuneName);
|
|
119
|
+
}
|
|
120
|
+
}], [{
|
|
121
|
+
key: "tunes",
|
|
122
|
+
get: function get() {
|
|
123
|
+
return [{
|
|
124
|
+
name: "stretched",
|
|
125
|
+
icon: svgs.stretched,
|
|
126
|
+
title: "Stretch image"
|
|
127
|
+
}];
|
|
128
|
+
}
|
|
129
|
+
}]);
|
|
130
|
+
|
|
131
|
+
return Tunes;
|
|
132
|
+
}();
|
|
133
|
+
|
|
134
|
+
export { Tunes as default };
|