@akemona-org/strapi-plugin-content-manager 3.7.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/LICENSE +22 -0
- package/README.md +27 -0
- package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +78 -0
- package/admin/src/assets/images/background_input.svg +1 -0
- package/admin/src/assets/images/icon-cross-blue.svg +1 -0
- package/admin/src/assets/images/icon_remove.svg +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AddDropdown/components.js +113 -0
- package/admin/src/components/AddDropdown/index.js +76 -0
- package/admin/src/components/Block/components.js +28 -0
- package/admin/src/components/Block/index.js +45 -0
- package/admin/src/components/ComponentInitializer/P.js +9 -0
- package/admin/src/components/ComponentInitializer/index.js +43 -0
- package/admin/src/components/Container/index.js +7 -0
- package/admin/src/components/CustomInputCheckbox/components.js +77 -0
- package/admin/src/components/CustomInputCheckbox/index.js +53 -0
- package/admin/src/components/CustomTable/ActionCollapse/Delete.js +14 -0
- package/admin/src/components/CustomTable/ActionCollapse/DeleteAll.js +18 -0
- package/admin/src/components/CustomTable/ActionCollapse/Wrapper.js +20 -0
- package/admin/src/components/CustomTable/ActionCollapse/index.js +38 -0
- package/admin/src/components/CustomTable/Headers/Header.js +59 -0
- package/admin/src/components/CustomTable/Headers/Thead.js +35 -0
- package/admin/src/components/CustomTable/Headers/index.js +46 -0
- package/admin/src/components/CustomTable/Row/ActionContainer.js +19 -0
- package/admin/src/components/CustomTable/Row/Cell.js +55 -0
- package/admin/src/components/CustomTable/Row/index.js +112 -0
- package/admin/src/components/CustomTable/index.js +162 -0
- package/admin/src/components/CustomTable/styledComponents.js +85 -0
- package/admin/src/components/DragLayer/index.js +102 -0
- package/admin/src/components/DraggedField/Close/index.js +10 -0
- package/admin/src/components/DraggedField/GrabWrapper.js +38 -0
- package/admin/src/components/DraggedField/Link.js +17 -0
- package/admin/src/components/DraggedField/NameWrapper.js +29 -0
- package/admin/src/components/DraggedField/RemoveWrapper.js +32 -0
- package/admin/src/components/DraggedField/SubWrapper.js +36 -0
- package/admin/src/components/DraggedField/Wrapper.js +134 -0
- package/admin/src/components/DraggedField/index.js +196 -0
- package/admin/src/components/DraggedField/utils/getColor.js +12 -0
- package/admin/src/components/DraggedField/utils/getHeight.js +3 -0
- package/admin/src/components/DraggedFieldWithPreview/Carret.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +70 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicZoneWrapper.js +10 -0
- package/admin/src/components/DraggedFieldWithPreview/Tooltip.js +19 -0
- package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/index.js +194 -0
- package/admin/src/components/DynamicComponentCard/Wrapper.js +63 -0
- package/admin/src/components/DynamicComponentCard/index.js +49 -0
- package/admin/src/components/DynamicZone/BaselineAlignement.js +11 -0
- package/admin/src/components/DynamicZone/Button.js +31 -0
- package/admin/src/components/DynamicZone/Component/RoundCTA.js +45 -0
- package/admin/src/components/DynamicZone/Component/index.js +79 -0
- package/admin/src/components/DynamicZone/ComponentWrapper.js +44 -0
- package/admin/src/components/DynamicZone/DynamicZoneWrapper.js +12 -0
- package/admin/src/components/DynamicZone/Label.js +42 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/Wrapper.js +78 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/index.js +33 -0
- package/admin/src/components/DynamicZone/Picker/Category/index.js +53 -0
- package/admin/src/components/DynamicZone/Picker/Wrapper.js +32 -0
- package/admin/src/components/DynamicZone/Picker/index.js +88 -0
- package/admin/src/components/DynamicZone/Wrapper.js +34 -0
- package/admin/src/components/DynamicZone/index.js +238 -0
- package/admin/src/components/DynamicZone/utils/connect.js +12 -0
- package/admin/src/components/DynamicZone/utils/select.js +49 -0
- package/admin/src/components/FieldComponent/ComponentIcon.js +44 -0
- package/admin/src/components/FieldComponent/EmptyComponent.js +19 -0
- package/admin/src/components/FieldComponent/Label.js +10 -0
- package/admin/src/components/FieldComponent/ResetComponent.js +41 -0
- package/admin/src/components/FieldComponent/Wrapper.js +18 -0
- package/admin/src/components/FieldComponent/index.js +171 -0
- package/admin/src/components/FieldComponent/utils/connect.js +12 -0
- package/admin/src/components/FieldComponent/utils/select.js +123 -0
- package/admin/src/components/FieldsReorder/Item.js +249 -0
- package/admin/src/components/FieldsReorder/components.js +8 -0
- package/admin/src/components/FieldsReorder/index.js +102 -0
- package/admin/src/components/FilterOptionsCTA/index.js +14 -0
- package/admin/src/components/FilterPicker/components.js +56 -0
- package/admin/src/components/FilterPicker/index.js +258 -0
- package/admin/src/components/FilterPicker/init.js +25 -0
- package/admin/src/components/FilterPicker/reducer.js +58 -0
- package/admin/src/components/FilterPickerOption/Input.js +58 -0
- package/admin/src/components/FilterPickerOption/Option.js +18 -0
- package/admin/src/components/FilterPickerOption/components.js +60 -0
- package/admin/src/components/FilterPickerOption/index.js +101 -0
- package/admin/src/components/FormTitle/index.js +26 -0
- package/admin/src/components/FormWrapper/index.js +20 -0
- package/admin/src/components/InputJSON/components.js +30 -0
- package/admin/src/components/InputJSON/index.js +184 -0
- package/admin/src/components/InputJSON/jsonlint.js +424 -0
- package/admin/src/components/InputJSONWithErrors/Wrapper.js +32 -0
- package/admin/src/components/InputJSONWithErrors/index.js +168 -0
- package/admin/src/components/InputUID/InputUID.js +26 -0
- package/admin/src/components/InputUID/Options/Option.js +22 -0
- package/admin/src/components/InputUID/Options/OptionsTitle.js +12 -0
- package/admin/src/components/InputUID/Options/RightOptionLabel.js +10 -0
- package/admin/src/components/InputUID/Options/index.js +34 -0
- package/admin/src/components/InputUID/Options/wrapper.js +13 -0
- package/admin/src/components/InputUID/RegenerateButton.js +18 -0
- package/admin/src/components/InputUID/RightContent.js +14 -0
- package/admin/src/components/InputUID/RightContentLabel.js +10 -0
- package/admin/src/components/InputUID/RightLabel.js +42 -0
- package/admin/src/components/InputUID/SubLabel.js +9 -0
- package/admin/src/components/InputUID/Wrapper.js +8 -0
- package/admin/src/components/InputUID/index.js +325 -0
- package/admin/src/components/InputUID/regex.js +3 -0
- package/admin/src/components/Inputs/index.js +283 -0
- package/admin/src/components/Inputs/utils/VALIDATIONS_TO_OMIT.js +12 -0
- package/admin/src/components/Inputs/utils/connect.js +12 -0
- package/admin/src/components/Inputs/utils/generateOptions.js +19 -0
- package/admin/src/components/Inputs/utils/getInputType.js +44 -0
- package/admin/src/components/Inputs/utils/getStep.js +15 -0
- package/admin/src/components/Inputs/utils/index.js +6 -0
- package/admin/src/components/Inputs/utils/select.js +38 -0
- package/admin/src/components/LayoutTitle/index.js +19 -0
- package/admin/src/components/MediaPreviewList/StyledMediaPreviewList.js +171 -0
- package/admin/src/components/MediaPreviewList/index.js +110 -0
- package/admin/src/components/NonRepeatableComponent/index.js +73 -0
- package/admin/src/components/NonRepeatableWrapper/index.js +73 -0
- package/admin/src/components/PlusButton/index.js +52 -0
- package/admin/src/components/PopupForm/index.js +93 -0
- package/admin/src/components/PreviewCarret/components.js +27 -0
- package/admin/src/components/PreviewCarret/index.js +22 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +133 -0
- package/admin/src/components/PreviewWysiwyg/index.js +34 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +72 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +16 -0
- package/admin/src/components/RelationPreviewList/CountWrapper.js +7 -0
- package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +117 -0
- package/admin/src/components/RelationPreviewList/index.js +111 -0
- package/admin/src/components/RepeatableComponent/AddFieldButton.js +64 -0
- package/admin/src/components/RepeatableComponent/Banner.js +112 -0
- package/admin/src/components/RepeatableComponent/BannerWrapper.js +194 -0
- package/admin/src/components/RepeatableComponent/CarretTop.js +14 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/index.js +245 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/index.js +2 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js +30 -0
- package/admin/src/components/RepeatableComponent/EmptyComponent.js +27 -0
- package/admin/src/components/RepeatableComponent/FormWrapper.js +27 -0
- package/admin/src/components/RepeatableComponent/index.js +187 -0
- package/admin/src/components/RepeatableComponent/reducer.js +73 -0
- package/admin/src/components/RepeatableComponent/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/utils/select.js +12 -0
- package/admin/src/components/Search/index.js +88 -0
- package/admin/src/components/SectionTitle/Title.js +11 -0
- package/admin/src/components/SectionTitle/index.js +29 -0
- package/admin/src/components/SelectMany/ListItem.js +107 -0
- package/admin/src/components/SelectMany/Relation.js +106 -0
- package/admin/src/components/SelectMany/components.js +153 -0
- package/admin/src/components/SelectMany/index.js +159 -0
- package/admin/src/components/SelectOne/SingleValue.js +58 -0
- package/admin/src/components/SelectOne/index.js +71 -0
- package/admin/src/components/SelectWrapper/ClearIndicator.js +15 -0
- package/admin/src/components/SelectWrapper/IndicatorSeparator.js +3 -0
- package/admin/src/components/SelectWrapper/Option.js +76 -0
- package/admin/src/components/SelectWrapper/components.js +14 -0
- package/admin/src/components/SelectWrapper/index.js +393 -0
- package/admin/src/components/SelectWrapper/utils/connect.js +12 -0
- package/admin/src/components/SelectWrapper/utils/index.js +3 -0
- package/admin/src/components/SelectWrapper/utils/select.js +45 -0
- package/admin/src/components/SelectWrapper/utils/styles.js +105 -0
- package/admin/src/components/Separator/index.js +9 -0
- package/admin/src/components/SettingFormWrapper/index.js +9 -0
- package/admin/src/components/SettingsViewWrapper/index.js +283 -0
- package/admin/src/components/SortWrapper/index.js +9 -0
- package/admin/src/components/SortableList/Item.js +126 -0
- package/admin/src/components/SortableList/index.js +60 -0
- package/admin/src/components/State/Wrapper.js +30 -0
- package/admin/src/components/State/index.js +26 -0
- package/admin/src/components/Truncate/index.js +5 -0
- package/admin/src/components/Truncated/index.js +10 -0
- package/admin/src/components/Wysiwyg/EditorWrapper.js +122 -0
- package/admin/src/components/Wysiwyg/MediaLib.js +71 -0
- package/admin/src/components/Wysiwyg/PreviewControlWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/SelectWrapper.js +24 -0
- package/admin/src/components/Wysiwyg/ToggleModeWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/constants.js +98 -0
- package/admin/src/components/Wysiwyg/customSelect.js +39 -0
- package/admin/src/components/Wysiwyg/helpers.js +116 -0
- package/admin/src/components/Wysiwyg/index.js +819 -0
- package/admin/src/components/Wysiwyg/previewControl.js +29 -0
- package/admin/src/components/Wysiwyg/toggleMode.js +44 -0
- package/admin/src/components/Wysiwyg/utils.js +70 -0
- package/admin/src/components/WysiwygBottomControls/components.js +44 -0
- package/admin/src/components/WysiwygBottomControls/index.js +33 -0
- package/admin/src/components/WysiwygDropUpload/Label.js +16 -0
- package/admin/src/components/WysiwygDropUpload/index.js +18 -0
- package/admin/src/components/WysiwygEditor/index.js +26 -0
- package/admin/src/components/WysiwygInlineControls/Button.js +77 -0
- package/admin/src/components/WysiwygInlineControls/StyledButton.js +54 -0
- package/admin/src/components/WysiwygInlineControls/Wrapper.js +25 -0
- package/admin/src/components/WysiwygInlineControls/index.js +66 -0
- package/admin/src/components/WysiwygWithErrors/Wrapper.js +38 -0
- package/admin/src/components/WysiwygWithErrors/index.js +158 -0
- package/admin/src/containers/CollectionTypeFormWrapper/index.js +376 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/CollectionTypeRecursivePath/index.js +125 -0
- package/admin/src/containers/ComponentSetttingsView/index.js +55 -0
- package/admin/src/containers/EditSettingsView/index.js +408 -0
- package/admin/src/containers/EditSettingsView/init.js +18 -0
- package/admin/src/containers/EditSettingsView/reducer.js +126 -0
- package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +26 -0
- package/admin/src/containers/EditSettingsView/utils/getInputProps.js +30 -0
- package/admin/src/containers/EditSettingsView/utils/index.js +2 -0
- package/admin/src/containers/EditSettingsView/utils/layout.js +98 -0
- package/admin/src/containers/EditView/DeleteLink/index.js +94 -0
- package/admin/src/containers/EditView/DeleteLink/utils/connect.js +12 -0
- package/admin/src/containers/EditView/DeleteLink/utils/index.js +2 -0
- package/admin/src/containers/EditView/DeleteLink/utils/select.js +21 -0
- package/admin/src/containers/EditView/Header/index.js +258 -0
- package/admin/src/containers/EditView/Header/utils/connect.js +12 -0
- package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +62 -0
- package/admin/src/containers/EditView/Header/utils/index.js +3 -0
- package/admin/src/containers/EditView/Header/utils/select.js +31 -0
- package/admin/src/containers/EditView/InformationCard.js +100 -0
- package/admin/src/containers/EditView/components.js +74 -0
- package/admin/src/containers/EditView/index.js +297 -0
- package/admin/src/containers/EditView/utils/createAttributesLayout.js +39 -0
- package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +23 -0
- package/admin/src/containers/EditView/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/index.js +519 -0
- package/admin/src/containers/EditViewDataManagerProvider/reducer.js +218 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +88 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +17 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +368 -0
- package/admin/src/containers/EditViewLayoutManager/Permissions.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/actions.js +9 -0
- package/admin/src/containers/EditViewLayoutManager/constants.js +2 -0
- package/admin/src/containers/EditViewLayoutManager/index.js +44 -0
- package/admin/src/containers/EditViewLayoutManager/reducer.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/selectors.js +5 -0
- package/admin/src/containers/LayoutDndProvider/index.js +75 -0
- package/admin/src/containers/ListSettingsView/DragWrapper.js +21 -0
- package/admin/src/containers/ListSettingsView/DropdownButton.js +8 -0
- package/admin/src/containers/ListSettingsView/Label.js +91 -0
- package/admin/src/containers/ListSettingsView/MenuDropdown.js +41 -0
- package/admin/src/containers/ListSettingsView/Toggle.js +51 -0
- package/admin/src/containers/ListSettingsView/forms.json +64 -0
- package/admin/src/containers/ListSettingsView/index.js +298 -0
- package/admin/src/containers/ListSettingsView/init.js +11 -0
- package/admin/src/containers/ListSettingsView/reducer.js +77 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/StyledLink.js +28 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/Wrapper.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/index.js +29 -0
- package/admin/src/containers/ListView/FieldPicker/Field/Wrapper.js +15 -0
- package/admin/src/containers/ListView/FieldPicker/Field/index.js +24 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +18 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/index.js +27 -0
- package/admin/src/containers/ListView/FieldPicker/Header/Reset.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/Header/index.js +42 -0
- package/admin/src/containers/ListView/FieldPicker/Wrapper.js +9 -0
- package/admin/src/containers/ListView/FieldPicker/index.js +46 -0
- package/admin/src/containers/ListView/Filter.js +83 -0
- package/admin/src/containers/ListView/Footer.js +60 -0
- package/admin/src/containers/ListView/actions.js +91 -0
- package/admin/src/containers/ListView/components.js +138 -0
- package/admin/src/containers/ListView/constants.js +16 -0
- package/admin/src/containers/ListView/index.js +573 -0
- package/admin/src/containers/ListView/reducer.js +182 -0
- package/admin/src/containers/ListView/selectors.js +24 -0
- package/admin/src/containers/ListView/utils/buildQueryString.js +26 -0
- package/admin/src/containers/ListView/utils/createPluginsFilter.js +13 -0
- package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +17 -0
- package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +14 -0
- package/admin/src/containers/ListView/utils/index.js +3 -0
- package/admin/src/containers/ListViewLayoutManager/Permissions.js +29 -0
- package/admin/src/containers/ListViewLayoutManager/index.js +60 -0
- package/admin/src/containers/ListViewProvider/index.js +16 -0
- package/admin/src/containers/Main/actions.js +13 -0
- package/admin/src/containers/Main/constants.js +3 -0
- package/admin/src/containers/Main/index.js +100 -0
- package/admin/src/containers/Main/reducer.js +37 -0
- package/admin/src/containers/Main/selectors.js +20 -0
- package/admin/src/containers/RBACManager/actions.js +14 -0
- package/admin/src/containers/RBACManager/constants.js +2 -0
- package/admin/src/containers/RBACManager/reducer.js +32 -0
- package/admin/src/containers/RBACManager/useSyncRbac.js +28 -0
- package/admin/src/containers/SingleTypeFormWrapper/index.js +317 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/SingleTypeRecursivePath/index.js +84 -0
- package/admin/src/containers/WysiwygProvider/index.js +16 -0
- package/admin/src/contexts/ContentTypeLayout.js +5 -0
- package/admin/src/contexts/LayoutDnd.js +5 -0
- package/admin/src/contexts/ListView.js +5 -0
- package/admin/src/contexts/Wysiwyg.js +5 -0
- package/admin/src/contexts/index.js +4 -0
- package/admin/src/hooks/index.js +6 -0
- package/admin/src/hooks/useContentTypeLayout/index.js +19 -0
- package/admin/src/hooks/useFetchContentTypeLayout/index.js +83 -0
- package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +56 -0
- package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +235 -0
- package/admin/src/hooks/useFindRedirectionLink/index.js +14 -0
- package/admin/src/hooks/useFindRedirectionLink/selectors.js +7 -0
- package/admin/src/hooks/useFindRedirectionLink/utils/getRedirectionLink.js +45 -0
- package/admin/src/hooks/useLayoutDnd.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/hooks/useWysiwyg.js +6 -0
- package/admin/src/icons/Bold/index.js +22 -0
- package/admin/src/icons/Code/index.js +13 -0
- package/admin/src/icons/Cross/index.js +33 -0
- package/admin/src/icons/Italic/index.js +23 -0
- package/admin/src/icons/Link/index.js +21 -0
- package/admin/src/icons/Media/index.js +14 -0
- package/admin/src/icons/Na/index.js +58 -0
- package/admin/src/icons/Ol/index.js +13 -0
- package/admin/src/icons/Quote/index.js +13 -0
- package/admin/src/icons/Striked/index.js +24 -0
- package/admin/src/icons/Ul/index.js +15 -0
- package/admin/src/icons/Underline/index.js +22 -0
- package/admin/src/index.js +52 -0
- package/admin/src/lifecycles.js +19 -0
- package/admin/src/permissions.js +27 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +16 -0
- package/admin/src/selectors.js +6 -0
- package/admin/src/sharedReducers/crudReducer/actions.js +44 -0
- package/admin/src/sharedReducers/crudReducer/constants.js +7 -0
- package/admin/src/sharedReducers/crudReducer/reducer.js +75 -0
- package/admin/src/sharedReducers/crudReducer/selectors.js +5 -0
- package/admin/src/testUtils/data.js +305 -0
- package/admin/src/testUtils/index.js +4 -0
- package/admin/src/translations/ar.json +94 -0
- package/admin/src/translations/cs.json +130 -0
- package/admin/src/translations/de.json +177 -0
- package/admin/src/translations/dk.json +180 -0
- package/admin/src/translations/en.json +177 -0
- package/admin/src/translations/es.json +177 -0
- package/admin/src/translations/fr.json +162 -0
- package/admin/src/translations/id.json +175 -0
- package/admin/src/translations/index.js +53 -0
- package/admin/src/translations/it.json +177 -0
- package/admin/src/translations/ja.json +94 -0
- package/admin/src/translations/ko.json +110 -0
- package/admin/src/translations/ms.json +148 -0
- package/admin/src/translations/nl.json +94 -0
- package/admin/src/translations/pl.json +142 -0
- package/admin/src/translations/pt-BR.json +94 -0
- package/admin/src/translations/pt.json +94 -0
- package/admin/src/translations/ru.json +177 -0
- package/admin/src/translations/sk.json +172 -0
- package/admin/src/translations/th.json +155 -0
- package/admin/src/translations/tr.json +177 -0
- package/admin/src/translations/uk.json +148 -0
- package/admin/src/translations/vi.json +110 -0
- package/admin/src/translations/zh-Hans.json +177 -0
- package/admin/src/translations/zh.json +94 -0
- package/admin/src/utils/ItemTypes.js +7 -0
- package/admin/src/utils/checkIfAttributeIsDisplayable.js +13 -0
- package/admin/src/utils/createDefaultForm.js +50 -0
- package/admin/src/utils/dateFormats.js +18 -0
- package/admin/src/utils/formatFiltersFromQuery.js +55 -0
- package/admin/src/utils/formatFiltersToQuery.js +27 -0
- package/admin/src/utils/formatLayoutToApi.js +44 -0
- package/admin/src/utils/generatePermissionsObject.js +20 -0
- package/admin/src/utils/getComponents.js +50 -0
- package/admin/src/utils/getDisplayedValue.js +61 -0
- package/admin/src/utils/getFieldName.js +6 -0
- package/admin/src/utils/getMaxTempKey.js +12 -0
- package/admin/src/utils/getRequestUrl.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +17 -0
- package/admin/src/utils/mergeMetasWithSchema.js +20 -0
- package/admin/src/utils/removeKeyInObject.js +45 -0
- package/admin/src/utils/removePasswordFieldsFromData.js +54 -0
- package/config/admin.json +5 -0
- package/config/functions/bootstrap.js +9 -0
- package/config/policies/has-draft-and-publish.js +19 -0
- package/config/policies/hasPermissions.js +34 -0
- package/config/policies/routing.js +27 -0
- package/config/routes.json +275 -0
- package/controllers/collection-types.js +282 -0
- package/controllers/components.js +66 -0
- package/controllers/content-types.js +112 -0
- package/controllers/relations.js +63 -0
- package/controllers/single-types.js +170 -0
- package/controllers/uid.js +41 -0
- package/controllers/validation/index.js +104 -0
- package/controllers/validation/model-configuration.js +114 -0
- package/oas.yml +757 -0
- package/package.json +77 -0
- package/services/components.js +92 -0
- package/services/configuration.js +79 -0
- package/services/content-types.js +73 -0
- package/services/data-mapper.js +98 -0
- package/services/entity-manager.js +140 -0
- package/services/metrics.js +34 -0
- package/services/permission-checker.js +69 -0
- package/services/permission.js +95 -0
- package/services/uid.js +63 -0
- package/services/utils/configuration/attributes.js +175 -0
- package/services/utils/configuration/index.js +43 -0
- package/services/utils/configuration/layouts.js +185 -0
- package/services/utils/configuration/metadatas.js +142 -0
- package/services/utils/configuration/settings.js +52 -0
- package/services/utils/store.js +93 -0
- package/utils/index.js +16 -0
- package/utils/pick-writable-attributes.js +6 -0
- package/utils/wrap-bad-request.js +15 -0
- package/validation/policies/hasPermissions.js +17 -0
|
@@ -0,0 +1,819 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Wysiwyg
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import {
|
|
8
|
+
ContentState,
|
|
9
|
+
EditorState,
|
|
10
|
+
getDefaultKeyBinding,
|
|
11
|
+
genKey,
|
|
12
|
+
Modifier,
|
|
13
|
+
RichUtils,
|
|
14
|
+
SelectionState,
|
|
15
|
+
} from 'draft-js';
|
|
16
|
+
import PropTypes from 'prop-types';
|
|
17
|
+
import { isEmpty, isNaN, replace, words } from 'lodash';
|
|
18
|
+
import cn from 'classnames';
|
|
19
|
+
import WysiwygProvider from '../../containers/WysiwygProvider';
|
|
20
|
+
import Controls from '../WysiwygInlineControls';
|
|
21
|
+
import PreviewWysiwyg from '../PreviewWysiwyg';
|
|
22
|
+
import WysiwygBottomControls from '../WysiwygBottomControls';
|
|
23
|
+
import WysiwygEditor from '../WysiwygEditor';
|
|
24
|
+
import MediaLib from './MediaLib';
|
|
25
|
+
import CustomSelect from './customSelect';
|
|
26
|
+
import PreviewControl from './previewControl';
|
|
27
|
+
import ToggleMode from './toggleMode';
|
|
28
|
+
import { CONTROLS } from './constants';
|
|
29
|
+
import {
|
|
30
|
+
getBlockContent,
|
|
31
|
+
getBlockStyle,
|
|
32
|
+
getDefaultSelectionOffsets,
|
|
33
|
+
getKeyCommandData,
|
|
34
|
+
getOffSets,
|
|
35
|
+
} from './helpers';
|
|
36
|
+
import {
|
|
37
|
+
createNewBlock,
|
|
38
|
+
getNextBlocksList,
|
|
39
|
+
getSelectedBlocksList,
|
|
40
|
+
onTab,
|
|
41
|
+
updateSelection,
|
|
42
|
+
} from './utils';
|
|
43
|
+
import EditorWrapper from './EditorWrapper';
|
|
44
|
+
|
|
45
|
+
/* eslint-disable */
|
|
46
|
+
|
|
47
|
+
class Wysiwyg extends React.Component {
|
|
48
|
+
constructor(props) {
|
|
49
|
+
super(props);
|
|
50
|
+
this.state = {
|
|
51
|
+
editorState: EditorState.createEmpty(),
|
|
52
|
+
isFocused: false,
|
|
53
|
+
isFullscreen: false,
|
|
54
|
+
isMediaLibraryOpened: false,
|
|
55
|
+
isPreviewMode: false,
|
|
56
|
+
headerValue: '',
|
|
57
|
+
selection: null,
|
|
58
|
+
};
|
|
59
|
+
this.focus = () => {
|
|
60
|
+
this.setState({ isFocused: true });
|
|
61
|
+
|
|
62
|
+
return this.domEditor.focus();
|
|
63
|
+
};
|
|
64
|
+
this.blur = () => {
|
|
65
|
+
this.setState({ isFocused: false });
|
|
66
|
+
|
|
67
|
+
return this.domEditor.blur();
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
componentDidMount() {
|
|
72
|
+
if (this.props.autoFocus) {
|
|
73
|
+
this.focus();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!isEmpty(this.props.value)) {
|
|
77
|
+
this.setInitialValue(this.props);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
82
|
+
if (nextProps.value !== this.props.value && !this.state.isFocused) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (nextState.editorState !== this.state.editorState) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (nextProps.resetProps !== this.props.resetProps) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (nextState.isFocused !== this.state.isFocused) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (nextState.isFullscreen !== this.state.isFullscreen) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (nextState.isPreviewMode !== this.state.isPreviewMode) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (nextState.headerValue !== this.state.headerValue) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (nextProps.error !== this.props.error) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (nextState.isMediaLibraryOpened !== this.state.isMediaLibraryOpened) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
componentDidUpdate(prevProps) {
|
|
122
|
+
// Handle resetProps
|
|
123
|
+
if (prevProps.resetProps !== this.props.resetProps) {
|
|
124
|
+
this.setInitialValue(this.props);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Update the content when used in a dynamiczone
|
|
128
|
+
// We cannot update the value of the component each time there is a onChange event
|
|
129
|
+
// fired otherwise the component gets very slow
|
|
130
|
+
if (prevProps.value !== this.props.value && !this.state.isFocused) {
|
|
131
|
+
this.setInitialValue(this.props);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Here we need to update the content of editorState for the edition case
|
|
135
|
+
// With the current architecture of the EditView we cannot rely on the componentDidMount lifecycle
|
|
136
|
+
// Since we need to perform some operations in the reducer the loading phase stops before all the operations
|
|
137
|
+
// are computed which in some case causes the inputs component to be initialised with a null value.
|
|
138
|
+
if (!prevProps.value && this.props.value) {
|
|
139
|
+
// This is also called if the first thing you add in the editor is
|
|
140
|
+
// a markdown formatting block (b, i, u, etc.) which results in
|
|
141
|
+
// the selection being pushed to the end after the first character is added.
|
|
142
|
+
// Basically, setInitialValue is always called whenever
|
|
143
|
+
// you start typing in an empty editor (even after the initial load)
|
|
144
|
+
this.setInitialValue(this.props);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Init the editor with data from
|
|
150
|
+
* @param {[type]} props [description]
|
|
151
|
+
*/
|
|
152
|
+
setInitialValue = props => {
|
|
153
|
+
if (isEmpty(props.value)) {
|
|
154
|
+
return this.setState({ editorState: EditorState.createEmpty() });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const contentState = ContentState.createFromText(props.value);
|
|
158
|
+
const newEditorState = EditorState.createWithContent(contentState);
|
|
159
|
+
const editorState = this.state.isFocused
|
|
160
|
+
? EditorState.moveFocusToEnd(newEditorState)
|
|
161
|
+
: newEditorState;
|
|
162
|
+
|
|
163
|
+
return this.setState({ editorState });
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Handler to add B, I, Strike, U, link
|
|
168
|
+
* @param {String} content usually something like **textToReplace**
|
|
169
|
+
* @param {String} style
|
|
170
|
+
*/
|
|
171
|
+
addContent = (content, style) => {
|
|
172
|
+
const selectedText = this.getSelectedText();
|
|
173
|
+
// Retrieve the associated data for the type to add
|
|
174
|
+
const { innerContent, endReplacer, startReplacer } = getBlockContent(style);
|
|
175
|
+
// Replace the selected text by the markdown command or insert default text
|
|
176
|
+
const defaultContent =
|
|
177
|
+
selectedText === ''
|
|
178
|
+
? replace(content, 'textToReplace', innerContent)
|
|
179
|
+
: replace(content, 'textToReplace', selectedText);
|
|
180
|
+
// Get the current cursor position
|
|
181
|
+
const cursorPosition = getOffSets(this.getSelection()).start;
|
|
182
|
+
const textWithEntity = this.modifyBlockContent(defaultContent);
|
|
183
|
+
// Highlight the text
|
|
184
|
+
const { anchorOffset, focusOffset } = getDefaultSelectionOffsets(
|
|
185
|
+
defaultContent,
|
|
186
|
+
startReplacer,
|
|
187
|
+
endReplacer,
|
|
188
|
+
cursorPosition
|
|
189
|
+
);
|
|
190
|
+
// Merge the current selection with the new one
|
|
191
|
+
const updatedSelection = this.getSelection().merge({
|
|
192
|
+
anchorOffset,
|
|
193
|
+
focusOffset,
|
|
194
|
+
});
|
|
195
|
+
const newEditorState = EditorState.push(
|
|
196
|
+
this.getEditorState(),
|
|
197
|
+
textWithEntity,
|
|
198
|
+
'insert-character'
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
if (selectedText.length === 0) {
|
|
202
|
+
this.setState(
|
|
203
|
+
{
|
|
204
|
+
// Highlight the text if the selection was empty
|
|
205
|
+
editorState: EditorState.forceSelection(newEditorState, updatedSelection),
|
|
206
|
+
},
|
|
207
|
+
() => {
|
|
208
|
+
this.focus();
|
|
209
|
+
// Update the parent reducer
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
this.sendData(newEditorState);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Don't handle selection: the user has selected some text to be changed with the appropriate markdown
|
|
217
|
+
this.setState(
|
|
218
|
+
{
|
|
219
|
+
editorState: newEditorState,
|
|
220
|
+
},
|
|
221
|
+
() => {
|
|
222
|
+
this.focus();
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
this.sendData(newEditorState);
|
|
226
|
+
return;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Create an ordered list block
|
|
231
|
+
* @return ContentBlock
|
|
232
|
+
*/
|
|
233
|
+
addOlBlock = () => {
|
|
234
|
+
// Get all the selected blocks
|
|
235
|
+
const selectedBlocksList = getSelectedBlocksList(this.getEditorState());
|
|
236
|
+
let newEditorState = this.getEditorState();
|
|
237
|
+
|
|
238
|
+
// Check if the cursor is NOT at the beginning of a new line
|
|
239
|
+
// So we need to move all the next blocks
|
|
240
|
+
if (getOffSets(this.getSelection()).start !== 0) {
|
|
241
|
+
// Retrieve all the blocks after the current position
|
|
242
|
+
const nextBlocks = getNextBlocksList(newEditorState, this.getSelection().getStartKey());
|
|
243
|
+
let liNumber = 1;
|
|
244
|
+
|
|
245
|
+
// Loop to update each block after the inserted li
|
|
246
|
+
nextBlocks.map((block, index) => {
|
|
247
|
+
const previousContent =
|
|
248
|
+
index === 0
|
|
249
|
+
? this.getEditorState()
|
|
250
|
+
.getCurrentContent()
|
|
251
|
+
.getBlockForKey(this.getCurrentAnchorKey())
|
|
252
|
+
: newEditorState.getCurrentContent().getBlockBefore(block.getKey());
|
|
253
|
+
// Check if there was an li before the position so we update the entire list bullets
|
|
254
|
+
const number = previousContent ? parseInt(previousContent.getText().split('.')[0], 10) : 0;
|
|
255
|
+
liNumber = isNaN(number) ? 1 : number + 1;
|
|
256
|
+
const nextBlockText = index === 0 ? `${liNumber}. ` : nextBlocks.get(index - 1).getText();
|
|
257
|
+
// Update the current block
|
|
258
|
+
const newBlock = createNewBlock(nextBlockText, 'block-list', block.getKey());
|
|
259
|
+
// Update the contentState
|
|
260
|
+
const newContentState = this.createNewContentStateFromBlock(
|
|
261
|
+
newBlock,
|
|
262
|
+
newEditorState.getCurrentContent()
|
|
263
|
+
);
|
|
264
|
+
newEditorState = EditorState.push(newEditorState, newContentState);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Move the cursor to the correct position and add a space after '.'
|
|
268
|
+
// 2 for the dot and the space after, we add the number length (10 = offset of 2)
|
|
269
|
+
const offset = 2 + liNumber.toString().length;
|
|
270
|
+
const updatedSelection = updateSelection(this.getSelection(), nextBlocks, offset);
|
|
271
|
+
|
|
272
|
+
return this.setState({
|
|
273
|
+
editorState: EditorState.acceptSelection(newEditorState, updatedSelection),
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// If the cursor is at the beginning we need to move all the content after the cursor so we don't loose the data
|
|
278
|
+
selectedBlocksList.map((block, i) => {
|
|
279
|
+
const selectedText = block.getText();
|
|
280
|
+
const li = selectedText === '' ? `${i + 1}. ` : `${i + 1}. ${selectedText}`;
|
|
281
|
+
const newBlock = createNewBlock(li, 'block-list', block.getKey());
|
|
282
|
+
const newContentState = this.createNewContentStateFromBlock(
|
|
283
|
+
newBlock,
|
|
284
|
+
newEditorState.getCurrentContent()
|
|
285
|
+
);
|
|
286
|
+
newEditorState = EditorState.push(newEditorState, newContentState);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Update the parent reducer
|
|
290
|
+
this.sendData(newEditorState);
|
|
291
|
+
|
|
292
|
+
return this.setState({
|
|
293
|
+
editorState: EditorState.moveFocusToEnd(newEditorState),
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Create an unordered list
|
|
299
|
+
* @return ContentBlock
|
|
300
|
+
*/
|
|
301
|
+
// NOTE: it's pretty much the same dynamic as above
|
|
302
|
+
// We don't use the same handler because it needs less logic than a ordered list
|
|
303
|
+
// so it's easier to maintain the code
|
|
304
|
+
addUlBlock = () => {
|
|
305
|
+
const selectedBlocksList = getSelectedBlocksList(this.getEditorState());
|
|
306
|
+
let newEditorState = this.getEditorState();
|
|
307
|
+
|
|
308
|
+
if (getOffSets(this.getSelection()).start !== 0) {
|
|
309
|
+
const nextBlocks = getNextBlocksList(newEditorState, this.getSelection().getStartKey());
|
|
310
|
+
|
|
311
|
+
nextBlocks.map((block, index) => {
|
|
312
|
+
const nextBlockText = index === 0 ? '- ' : nextBlocks.get(index - 1).getText();
|
|
313
|
+
const newBlock = createNewBlock(nextBlockText, 'block-list', block.getKey());
|
|
314
|
+
const newContentState = this.createNewContentStateFromBlock(
|
|
315
|
+
newBlock,
|
|
316
|
+
newEditorState.getCurrentContent()
|
|
317
|
+
);
|
|
318
|
+
newEditorState = EditorState.push(newEditorState, newContentState);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const updatedSelection = updateSelection(this.getSelection(), nextBlocks, 2);
|
|
322
|
+
|
|
323
|
+
return this.setState({
|
|
324
|
+
editorState: EditorState.acceptSelection(newEditorState, updatedSelection),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
selectedBlocksList.map(block => {
|
|
329
|
+
const selectedText = block.getText();
|
|
330
|
+
const li = selectedText === '' ? '- ' : `- ${selectedText}`;
|
|
331
|
+
const newBlock = createNewBlock(li, 'block-list', block.getKey());
|
|
332
|
+
const newContentState = this.createNewContentStateFromBlock(
|
|
333
|
+
newBlock,
|
|
334
|
+
newEditorState.getCurrentContent()
|
|
335
|
+
);
|
|
336
|
+
newEditorState = EditorState.push(newEditorState, newContentState);
|
|
337
|
+
});
|
|
338
|
+
this.sendData(newEditorState);
|
|
339
|
+
return this.setState({
|
|
340
|
+
editorState: EditorState.moveFocusToEnd(newEditorState),
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Handler to create header
|
|
346
|
+
* @param {String} text header content
|
|
347
|
+
*/
|
|
348
|
+
addBlock = text => {
|
|
349
|
+
const nextBlockKey = this.getNextBlockKey(this.getCurrentAnchorKey()) || genKey();
|
|
350
|
+
const newBlock = createNewBlock(text, 'header', nextBlockKey);
|
|
351
|
+
const newContentState = this.createNewContentStateFromBlock(newBlock);
|
|
352
|
+
const newEditorState = this.createNewEditorState(newContentState, text);
|
|
353
|
+
|
|
354
|
+
this.sendData(newEditorState);
|
|
355
|
+
|
|
356
|
+
return this.setState(
|
|
357
|
+
{
|
|
358
|
+
editorState: newEditorState,
|
|
359
|
+
},
|
|
360
|
+
() => {
|
|
361
|
+
this.focus();
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
addLinks = data => {
|
|
367
|
+
const links = data.reduce((acc, { alt, url }) => `${acc}\n`, '');
|
|
368
|
+
const { selection } = this.state;
|
|
369
|
+
const newBlock = createNewBlock(links);
|
|
370
|
+
const newContentState = this.createNewContentStateFromBlock(newBlock);
|
|
371
|
+
const anchorOffset = links.length;
|
|
372
|
+
const focusOffset = links.length;
|
|
373
|
+
let newEditorState = this.createNewEditorState(newContentState, links);
|
|
374
|
+
|
|
375
|
+
const updatedSelection =
|
|
376
|
+
getOffSets(selection).start === 0
|
|
377
|
+
? this.getSelection().merge({ anchorOffset, focusOffset })
|
|
378
|
+
: new SelectionState({
|
|
379
|
+
anchorKey: newBlock.getKey(),
|
|
380
|
+
anchorOffset,
|
|
381
|
+
focusOffset,
|
|
382
|
+
focusKey: newBlock.getKey(),
|
|
383
|
+
isBackward: false,
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
newEditorState = EditorState.forceSelection(newEditorState, updatedSelection);
|
|
387
|
+
|
|
388
|
+
this.setState({ isFocused: true });
|
|
389
|
+
this.sendData(newEditorState);
|
|
390
|
+
|
|
391
|
+
return this.setState({
|
|
392
|
+
editorState: newEditorState,
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Handler used for code block and Img controls
|
|
398
|
+
* @param {String} content the text that will be added
|
|
399
|
+
* @param {String} style the type
|
|
400
|
+
*/
|
|
401
|
+
addSimpleBlockWithSelection = (content, style) => {
|
|
402
|
+
// Retrieve the selected text by the user
|
|
403
|
+
const selectedText = this.getSelectedText();
|
|
404
|
+
const { innerContent, endReplacer, startReplacer } = getBlockContent(style);
|
|
405
|
+
const defaultContent =
|
|
406
|
+
selectedText === ''
|
|
407
|
+
? replace(content, 'textToReplace', innerContent)
|
|
408
|
+
: replace(content, 'textToReplace', selectedText);
|
|
409
|
+
const newBlock = createNewBlock(defaultContent);
|
|
410
|
+
const newContentState = this.createNewContentStateFromBlock(newBlock);
|
|
411
|
+
const { anchorOffset, focusOffset } = getDefaultSelectionOffsets(
|
|
412
|
+
defaultContent,
|
|
413
|
+
startReplacer,
|
|
414
|
+
endReplacer
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
let newEditorState = this.createNewEditorState(newContentState, defaultContent);
|
|
418
|
+
const updatedSelection =
|
|
419
|
+
getOffSets(this.getSelection()).start === 0
|
|
420
|
+
? this.getSelection().merge({ anchorOffset, focusOffset })
|
|
421
|
+
: new SelectionState({
|
|
422
|
+
anchorKey: newBlock.getKey(),
|
|
423
|
+
anchorOffset,
|
|
424
|
+
focusOffset,
|
|
425
|
+
focusKey: newBlock.getKey(),
|
|
426
|
+
isBackward: false,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
newEditorState = EditorState.acceptSelection(newEditorState, updatedSelection);
|
|
430
|
+
|
|
431
|
+
return this.setState(
|
|
432
|
+
{
|
|
433
|
+
editorState: EditorState.forceSelection(newEditorState, newEditorState.getSelection()),
|
|
434
|
+
},
|
|
435
|
+
() => {
|
|
436
|
+
this.focus();
|
|
437
|
+
// Update the parent reducer
|
|
438
|
+
this.sendData(newEditorState);
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Update the current editorState
|
|
445
|
+
* @param {Map} newContentState
|
|
446
|
+
* @param {String} text The text to add
|
|
447
|
+
* @return {Map} EditorState
|
|
448
|
+
*/
|
|
449
|
+
createNewEditorState = (newContentState, text) => {
|
|
450
|
+
let newEditorState;
|
|
451
|
+
|
|
452
|
+
if (getOffSets(this.getSelection()).start !== 0) {
|
|
453
|
+
newEditorState = EditorState.push(this.getEditorState(), newContentState);
|
|
454
|
+
} else {
|
|
455
|
+
const textWithEntity = this.modifyBlockContent(text);
|
|
456
|
+
newEditorState = EditorState.push(this.getEditorState(), textWithEntity, 'insert-characters');
|
|
457
|
+
}
|
|
458
|
+
return newEditorState;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Update the content of a block
|
|
463
|
+
* @param {Map} newBlock The new block
|
|
464
|
+
* @param {Map} contentState The ContentState
|
|
465
|
+
* @return {Map} The updated block
|
|
466
|
+
*/
|
|
467
|
+
createNewBlockMap = (newBlock, contentState) =>
|
|
468
|
+
contentState.getBlockMap().set(newBlock.key, newBlock);
|
|
469
|
+
|
|
470
|
+
createNewContentStateFromBlock = (
|
|
471
|
+
newBlock,
|
|
472
|
+
contentState = this.getEditorState().getCurrentContent()
|
|
473
|
+
) =>
|
|
474
|
+
ContentState.createFromBlockArray(this.createNewBlockMap(newBlock, contentState).toArray())
|
|
475
|
+
.set('selectionBefore', contentState.getSelectionBefore())
|
|
476
|
+
.set('selectionAfter', contentState.getSelectionAfter());
|
|
477
|
+
|
|
478
|
+
getCharactersNumber = (editorState = this.getEditorState()) => {
|
|
479
|
+
const plainText = editorState.getCurrentContent().getPlainText();
|
|
480
|
+
const spacesNumber = plainText.split(' ').length;
|
|
481
|
+
|
|
482
|
+
return words(plainText).join('').length + spacesNumber - 1;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
getEditorState = () => this.state.editorState;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Retrieve the selected text
|
|
489
|
+
* @return {Map}
|
|
490
|
+
*/
|
|
491
|
+
getSelection = () => this.getEditorState().getSelection();
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Retrieve the cursor anchor key
|
|
495
|
+
* @return {String}
|
|
496
|
+
*/
|
|
497
|
+
getCurrentAnchorKey = () => this.getSelection().getAnchorKey();
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Retrieve the current content block
|
|
501
|
+
* @return {Map} ContentBlock
|
|
502
|
+
*/
|
|
503
|
+
getCurrentContentBlock = () =>
|
|
504
|
+
this.getEditorState()
|
|
505
|
+
.getCurrentContent()
|
|
506
|
+
.getBlockForKey(this.getSelection().getAnchorKey());
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Retrieve the block key after a specific one
|
|
510
|
+
* @param {String} currentBlockKey
|
|
511
|
+
* @param {Map} [editorState=this.getEditorState()] The current EditorState or the updated one
|
|
512
|
+
* @return {String} The next block key
|
|
513
|
+
*/
|
|
514
|
+
getNextBlockKey = (currentBlockKey, editorState = this.getEditorState()) =>
|
|
515
|
+
editorState.getCurrentContent().getKeyAfter(currentBlockKey);
|
|
516
|
+
|
|
517
|
+
getSelectedText = ({ start, end } = getOffSets(this.getSelection())) =>
|
|
518
|
+
this.getCurrentContentBlock()
|
|
519
|
+
.getText()
|
|
520
|
+
.slice(start, end);
|
|
521
|
+
|
|
522
|
+
handleBlur = () => {
|
|
523
|
+
const target = {
|
|
524
|
+
name: this.props.name,
|
|
525
|
+
type: 'textarea',
|
|
526
|
+
value: this.getEditorState()
|
|
527
|
+
.getCurrentContent()
|
|
528
|
+
.getPlainText(),
|
|
529
|
+
};
|
|
530
|
+
this.props.onBlur({ target });
|
|
531
|
+
this.blur();
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
handleChangeSelect = ({ target }) => {
|
|
535
|
+
this.setState({ headerValue: target.value });
|
|
536
|
+
const selectedText = this.getSelectedText();
|
|
537
|
+
const title = selectedText === '' ? `${target.value} ` : `${target.value} ${selectedText}`;
|
|
538
|
+
this.addBlock(title);
|
|
539
|
+
|
|
540
|
+
return this.setState({ headerValue: '' });
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
handleClickPreview = () => this.setState({ isPreviewMode: !this.state.isPreviewMode });
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Handler that listens for specific key commands
|
|
547
|
+
* @param {String} command
|
|
548
|
+
* @param {Map} editorState
|
|
549
|
+
* @return {Bool}
|
|
550
|
+
*/
|
|
551
|
+
handleKeyCommand = (command, editorState) => {
|
|
552
|
+
const newState = RichUtils.handleKeyCommand(editorState, command);
|
|
553
|
+
|
|
554
|
+
if (command === 'bold' || command === 'italic' || command === 'underline') {
|
|
555
|
+
const { content, style } = getKeyCommandData(command);
|
|
556
|
+
this.addContent(content, style);
|
|
557
|
+
return false;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (newState && command !== 'backspace') {
|
|
561
|
+
this.onChange(newState);
|
|
562
|
+
return true;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
return false;
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
handleOpenMediaLibrary = () => {
|
|
569
|
+
return this.setState({
|
|
570
|
+
isMediaLibraryOpened: true,
|
|
571
|
+
isFullscreen: false,
|
|
572
|
+
selection: this.getSelection(),
|
|
573
|
+
});
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
handleReturn = (e, editorState) => {
|
|
577
|
+
const selection = editorState.getSelection();
|
|
578
|
+
const currentBlock = editorState.getCurrentContent().getBlockForKey(selection.getStartKey());
|
|
579
|
+
|
|
580
|
+
if (currentBlock.getText().split('')[0] === '-') {
|
|
581
|
+
this.addUlBlock();
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (
|
|
586
|
+
currentBlock.getText().split('.').length > 1 &&
|
|
587
|
+
!isNaN(parseInt(currentBlock.getText().split('.')[0], 10))
|
|
588
|
+
) {
|
|
589
|
+
this.addOlBlock();
|
|
590
|
+
return true;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return false;
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
mapKeyToEditorCommand = e => {
|
|
597
|
+
if (e.keyCode === 9 /* TAB */) {
|
|
598
|
+
const newEditorState = RichUtils.onTab(e, this.state.editorState, 4 /* maxDepth */);
|
|
599
|
+
if (newEditorState !== this.state.editorState) {
|
|
600
|
+
this.onChange(newEditorState);
|
|
601
|
+
}
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return getDefaultKeyBinding(e);
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Change the content of a block
|
|
610
|
+
* @param {String]} text
|
|
611
|
+
* @param {Map} [contentState=this.getEditorState().getCurrentContent()]
|
|
612
|
+
* @return {Map}
|
|
613
|
+
*/
|
|
614
|
+
modifyBlockContent = (text, contentState = this.getEditorState().getCurrentContent()) =>
|
|
615
|
+
Modifier.replaceText(contentState, this.getSelection(), text);
|
|
616
|
+
|
|
617
|
+
onChange = editorState => {
|
|
618
|
+
const { disabled } = this.props;
|
|
619
|
+
|
|
620
|
+
if (!disabled) {
|
|
621
|
+
this.sendData(editorState);
|
|
622
|
+
this.setState({ editorState });
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
handleTab = e => {
|
|
627
|
+
e.preventDefault();
|
|
628
|
+
const newEditorState = onTab(this.getEditorState());
|
|
629
|
+
|
|
630
|
+
return this.onChange(newEditorState);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Toggle the medialibrary modal
|
|
635
|
+
*/
|
|
636
|
+
|
|
637
|
+
handleToggle = () => {
|
|
638
|
+
this.setState(prevState => ({
|
|
639
|
+
...prevState,
|
|
640
|
+
isMediaLibraryOpened: !prevState.isMediaLibraryOpened,
|
|
641
|
+
}));
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Update the parent reducer
|
|
646
|
+
* @param {Map} editorState [description]
|
|
647
|
+
*/
|
|
648
|
+
sendData = editorState => {
|
|
649
|
+
if (
|
|
650
|
+
this.getEditorState().getCurrentContent() !== editorState.getCurrentContent() ||
|
|
651
|
+
editorState.getLastChangeType() === 'remove-range'
|
|
652
|
+
) {
|
|
653
|
+
this.props.onChange({
|
|
654
|
+
target: {
|
|
655
|
+
value: editorState.getCurrentContent().getPlainText(),
|
|
656
|
+
name: this.props.name,
|
|
657
|
+
type: 'textarea',
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
} else return;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
toggleFullScreen = e => {
|
|
664
|
+
e.preventDefault();
|
|
665
|
+
this.setState({
|
|
666
|
+
isFullscreen: !this.state.isFullscreen,
|
|
667
|
+
isPreviewMode: false,
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
render() {
|
|
672
|
+
const { editorState, isMediaLibraryOpened, isPreviewMode, isFullscreen } = this.state;
|
|
673
|
+
const editorStyle = isFullscreen ? { marginTop: '0' } : this.props.style;
|
|
674
|
+
const { disabled } = this.props;
|
|
675
|
+
|
|
676
|
+
return (
|
|
677
|
+
<WysiwygProvider
|
|
678
|
+
handleChangeSelect={this.handleChangeSelect}
|
|
679
|
+
headerValue={this.state.headerValue}
|
|
680
|
+
html={this.props.value}
|
|
681
|
+
isPreviewMode={this.state.isPreviewMode}
|
|
682
|
+
isFullscreen={this.state.isFullscreen}
|
|
683
|
+
placeholder={this.props.placeholder}
|
|
684
|
+
>
|
|
685
|
+
<EditorWrapper isFullscreen={isFullscreen} disabled={disabled}>
|
|
686
|
+
{/* FIRST EDITOR WITH CONTROLS} */}
|
|
687
|
+
<div
|
|
688
|
+
className={cn(
|
|
689
|
+
'editorWrapper',
|
|
690
|
+
!this.props.deactivateErrorHighlight && this.props.error && 'editorError',
|
|
691
|
+
!isEmpty(this.props.className) && this.props.className
|
|
692
|
+
)}
|
|
693
|
+
onClick={e => {
|
|
694
|
+
if (isFullscreen) {
|
|
695
|
+
e.preventDefault();
|
|
696
|
+
e.stopPropagation();
|
|
697
|
+
}
|
|
698
|
+
}}
|
|
699
|
+
style={editorStyle}
|
|
700
|
+
>
|
|
701
|
+
<div className="controlsContainer">
|
|
702
|
+
<CustomSelect disabled={isPreviewMode || disabled} />
|
|
703
|
+
{CONTROLS.map((value, key) => (
|
|
704
|
+
<Controls
|
|
705
|
+
key={key}
|
|
706
|
+
buttons={value}
|
|
707
|
+
disabled={isPreviewMode || disabled}
|
|
708
|
+
editorState={editorState}
|
|
709
|
+
handlers={{
|
|
710
|
+
addContent: this.addContent,
|
|
711
|
+
addOlBlock: this.addOlBlock,
|
|
712
|
+
addSimpleBlockWithSelection: this.addSimpleBlockWithSelection,
|
|
713
|
+
addUlBlock: this.addUlBlock,
|
|
714
|
+
handleOpenMediaLibrary: this.handleOpenMediaLibrary,
|
|
715
|
+
}}
|
|
716
|
+
onToggle={this.toggleInlineStyle}
|
|
717
|
+
onToggleBlock={this.toggleBlockType}
|
|
718
|
+
/>
|
|
719
|
+
))}
|
|
720
|
+
{!isFullscreen ? (
|
|
721
|
+
<ToggleMode isPreviewMode={isPreviewMode} onClick={this.handleClickPreview} />
|
|
722
|
+
) : (
|
|
723
|
+
<div style={{ marginRight: '10px' }} />
|
|
724
|
+
)}
|
|
725
|
+
</div>
|
|
726
|
+
{/* WYSIWYG PREVIEW NOT FULLSCREEN */}
|
|
727
|
+
{isPreviewMode ? (
|
|
728
|
+
<PreviewWysiwyg data={this.props.value} />
|
|
729
|
+
) : (
|
|
730
|
+
<div
|
|
731
|
+
className={cn('editor', isFullscreen && 'editorFullScreen')}
|
|
732
|
+
onClick={this.focus}
|
|
733
|
+
>
|
|
734
|
+
<WysiwygEditor
|
|
735
|
+
blockStyleFn={getBlockStyle}
|
|
736
|
+
editorState={editorState}
|
|
737
|
+
handleKeyCommand={this.handleKeyCommand}
|
|
738
|
+
handleReturn={this.handleReturn}
|
|
739
|
+
keyBindingFn={this.mapKeyToEditorCommand}
|
|
740
|
+
onBlur={this.handleBlur}
|
|
741
|
+
onChange={this.onChange}
|
|
742
|
+
onTab={this.handleTab}
|
|
743
|
+
placeholder={this.props.placeholder}
|
|
744
|
+
setRef={editor => (this.domEditor = editor)}
|
|
745
|
+
stripPastedStyles
|
|
746
|
+
tabIndex={this.props.tabIndex}
|
|
747
|
+
spellCheck
|
|
748
|
+
/>
|
|
749
|
+
<input className="editorInput" tabIndex="-1" />
|
|
750
|
+
</div>
|
|
751
|
+
)}
|
|
752
|
+
{!isFullscreen && (
|
|
753
|
+
<WysiwygBottomControls
|
|
754
|
+
isPreviewMode={isPreviewMode}
|
|
755
|
+
onClick={this.toggleFullScreen}
|
|
756
|
+
onChange={this.handleDrop}
|
|
757
|
+
/>
|
|
758
|
+
)}
|
|
759
|
+
</div>
|
|
760
|
+
{/* PREVIEW WYSIWYG FULLSCREEN */}
|
|
761
|
+
{isFullscreen && (
|
|
762
|
+
<div
|
|
763
|
+
className={cn('editorWrapper')}
|
|
764
|
+
onClick={e => {
|
|
765
|
+
e.preventDefault();
|
|
766
|
+
e.stopPropagation();
|
|
767
|
+
}}
|
|
768
|
+
style={{ marginTop: '0' }}
|
|
769
|
+
>
|
|
770
|
+
<PreviewControl
|
|
771
|
+
onClick={this.toggleFullScreen}
|
|
772
|
+
characters={this.getCharactersNumber()}
|
|
773
|
+
/>
|
|
774
|
+
<PreviewWysiwyg data={this.props.value} />
|
|
775
|
+
</div>
|
|
776
|
+
)}
|
|
777
|
+
</EditorWrapper>
|
|
778
|
+
<MediaLib
|
|
779
|
+
onToggle={this.handleToggle}
|
|
780
|
+
isOpen={isMediaLibraryOpened}
|
|
781
|
+
onChange={this.addLinks}
|
|
782
|
+
/>
|
|
783
|
+
</WysiwygProvider>
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
Wysiwyg.defaultProps = {
|
|
789
|
+
autoFocus: false,
|
|
790
|
+
className: '',
|
|
791
|
+
deactivateErrorHighlight: false,
|
|
792
|
+
disabled: false,
|
|
793
|
+
error: false,
|
|
794
|
+
onBlur: () => {},
|
|
795
|
+
onChange: () => {},
|
|
796
|
+
placeholder: '',
|
|
797
|
+
resetProps: false,
|
|
798
|
+
style: {},
|
|
799
|
+
tabIndex: '0',
|
|
800
|
+
value: '',
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
Wysiwyg.propTypes = {
|
|
804
|
+
autoFocus: PropTypes.bool,
|
|
805
|
+
className: PropTypes.string,
|
|
806
|
+
deactivateErrorHighlight: PropTypes.bool,
|
|
807
|
+
disabled: PropTypes.bool,
|
|
808
|
+
error: PropTypes.bool,
|
|
809
|
+
name: PropTypes.string.isRequired,
|
|
810
|
+
onBlur: PropTypes.func,
|
|
811
|
+
onChange: PropTypes.func,
|
|
812
|
+
placeholder: PropTypes.string,
|
|
813
|
+
resetProps: PropTypes.bool,
|
|
814
|
+
style: PropTypes.object,
|
|
815
|
+
tabIndex: PropTypes.string,
|
|
816
|
+
value: PropTypes.string,
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
export default Wysiwyg;
|