@atlaskit/editor-plugin-extension 0.4.2 → 0.5.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/.eslintrc.js +26 -0
- package/CHANGELOG.md +16 -0
- package/dist/cjs/actions.js +236 -0
- package/dist/cjs/commands.js +122 -0
- package/dist/cjs/context-panel.js +269 -0
- package/dist/cjs/extension-api.js +266 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/plugin-factory.js +32 -0
- package/dist/cjs/plugin-key.js +8 -0
- package/dist/cjs/plugin.js +147 -0
- package/dist/cjs/pm-plugins/keymap.js +21 -0
- package/dist/cjs/pm-plugins/macro/actions.js +186 -0
- package/dist/cjs/pm-plugins/macro/index.js +72 -0
- package/dist/cjs/pm-plugins/macro/plugin-key.js +8 -0
- package/dist/cjs/pm-plugins/macro/types.js +5 -0
- package/dist/cjs/pm-plugins/main.js +323 -0
- package/dist/cjs/pm-plugins/unique-id.js +80 -0
- package/dist/cjs/pm-plugins/utils.js +75 -0
- package/dist/cjs/reducer.js +18 -0
- package/dist/cjs/toolbar.js +242 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +475 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +122 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanelLoader.js +23 -0
- package/dist/cjs/ui/ConfigPanel/ErrorMessage/ErrorImage.js +76 -0
- package/dist/cjs/ui/ConfigPanel/ErrorMessage/index.js +33 -0
- package/dist/cjs/ui/ConfigPanel/FieldMessages.js +105 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Boolean.js +150 -0
- package/dist/cjs/ui/ConfigPanel/Fields/CheckboxGroup.js +101 -0
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +420 -0
- package/dist/cjs/ui/ConfigPanel/Fields/CustomSelect.js +192 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Date.js +55 -0
- package/dist/cjs/ui/ConfigPanel/Fields/DateRange.js +160 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Enum.js +41 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Expand.js +88 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Fieldset.js +270 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Number.js +64 -0
- package/dist/cjs/ui/ConfigPanel/Fields/RadioGroup.js +56 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Select.js +60 -0
- package/dist/cjs/ui/ConfigPanel/Fields/SelectItem.js +53 -0
- package/dist/cjs/ui/ConfigPanel/Fields/String.js +75 -0
- package/dist/cjs/ui/ConfigPanel/Fields/TabGroup.js +73 -0
- package/dist/cjs/ui/ConfigPanel/Fields/UnhandledType.js +19 -0
- package/dist/cjs/ui/ConfigPanel/Fields/UserSelect.js +268 -0
- package/dist/cjs/ui/ConfigPanel/Fields/common/RequiredIndicator.js +12 -0
- package/dist/cjs/ui/ConfigPanel/FormContent.js +231 -0
- package/dist/cjs/ui/ConfigPanel/FormErrorBoundary.js +140 -0
- package/dist/cjs/ui/ConfigPanel/Header.js +148 -0
- package/dist/cjs/ui/ConfigPanel/LoadingState.js +25 -0
- package/dist/cjs/ui/ConfigPanel/NestedForms/RemovableField.js +61 -0
- package/dist/cjs/ui/ConfigPanel/constants.js +13 -0
- package/dist/cjs/ui/ConfigPanel/index.js +9 -0
- package/dist/cjs/ui/ConfigPanel/messages.js +99 -0
- package/dist/cjs/ui/ConfigPanel/transformers.js +631 -0
- package/dist/cjs/ui/ConfigPanel/types.js +15 -0
- package/dist/cjs/ui/ConfigPanel/use-abortable-effect/index.js +56 -0
- package/dist/cjs/ui/ConfigPanel/use-state-from-promise/index.js +41 -0
- package/dist/cjs/ui/ConfigPanel/utils.js +116 -0
- package/dist/cjs/ui/SaveIndicator/SaveIndicator.js +79 -0
- package/dist/cjs/ui/SaveIndicator/messages.js +14 -0
- package/dist/cjs/ui/SaveIndicator/types.js +5 -0
- package/dist/cjs/utils.js +73 -0
- package/dist/es2019/actions.js +203 -0
- package/dist/es2019/commands.js +99 -0
- package/dist/es2019/context-panel.js +181 -0
- package/dist/es2019/extension-api.js +284 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugin-factory.js +26 -0
- package/dist/es2019/plugin-key.js +2 -0
- package/dist/es2019/plugin.js +138 -0
- package/dist/es2019/pm-plugins/keymap.js +15 -0
- package/dist/es2019/pm-plugins/macro/actions.js +152 -0
- package/dist/es2019/pm-plugins/macro/index.js +36 -0
- package/dist/es2019/pm-plugins/macro/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/macro/types.js +1 -0
- package/dist/es2019/pm-plugins/main.js +230 -0
- package/dist/es2019/pm-plugins/unique-id.js +69 -0
- package/dist/es2019/pm-plugins/utils.js +30 -0
- package/dist/es2019/reducer.js +11 -0
- package/dist/es2019/toolbar.js +236 -0
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +415 -0
- package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +100 -0
- package/dist/es2019/ui/ConfigPanel/ConfigPanelLoader.js +7 -0
- package/dist/es2019/ui/ConfigPanel/ErrorMessage/ErrorImage.js +66 -0
- package/dist/es2019/ui/ConfigPanel/ErrorMessage/index.js +25 -0
- package/dist/es2019/ui/ConfigPanel/FieldMessages.js +101 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Boolean.js +138 -0
- package/dist/es2019/ui/ConfigPanel/Fields/CheckboxGroup.js +96 -0
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +411 -0
- package/dist/es2019/ui/ConfigPanel/Fields/CustomSelect.js +132 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Date.js +50 -0
- package/dist/es2019/ui/ConfigPanel/Fields/DateRange.js +139 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Enum.js +35 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Expand.js +73 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Fieldset.js +227 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Number.js +61 -0
- package/dist/es2019/ui/ConfigPanel/Fields/RadioGroup.js +40 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Select.js +50 -0
- package/dist/es2019/ui/ConfigPanel/Fields/SelectItem.js +47 -0
- package/dist/es2019/ui/ConfigPanel/Fields/String.js +67 -0
- package/dist/es2019/ui/ConfigPanel/Fields/TabGroup.js +57 -0
- package/dist/es2019/ui/ConfigPanel/Fields/UnhandledType.js +11 -0
- package/dist/es2019/ui/ConfigPanel/Fields/UserSelect.js +194 -0
- package/dist/es2019/ui/ConfigPanel/Fields/common/RequiredIndicator.js +5 -0
- package/dist/es2019/ui/ConfigPanel/FormContent.js +225 -0
- package/dist/es2019/ui/ConfigPanel/FormErrorBoundary.js +100 -0
- package/dist/es2019/ui/ConfigPanel/Header.js +140 -0
- package/dist/es2019/ui/ConfigPanel/LoadingState.js +15 -0
- package/dist/es2019/ui/ConfigPanel/NestedForms/RemovableField.js +52 -0
- package/dist/es2019/ui/ConfigPanel/constants.js +7 -0
- package/dist/es2019/ui/ConfigPanel/index.js +2 -0
- package/dist/es2019/ui/ConfigPanel/messages.js +93 -0
- package/dist/es2019/ui/ConfigPanel/transformers.js +367 -0
- package/dist/es2019/ui/ConfigPanel/types.js +9 -0
- package/dist/es2019/ui/ConfigPanel/use-abortable-effect/index.js +46 -0
- package/dist/es2019/ui/ConfigPanel/use-state-from-promise/index.js +30 -0
- package/dist/es2019/ui/ConfigPanel/utils.js +86 -0
- package/dist/es2019/ui/SaveIndicator/SaveIndicator.js +66 -0
- package/dist/es2019/ui/SaveIndicator/messages.js +8 -0
- package/dist/es2019/ui/SaveIndicator/types.js +1 -0
- package/dist/es2019/utils.js +65 -0
- package/dist/esm/actions.js +223 -0
- package/dist/esm/commands.js +113 -0
- package/dist/esm/context-panel.js +261 -0
- package/dist/esm/extension-api.js +259 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugin-factory.js +25 -0
- package/dist/esm/plugin-key.js +2 -0
- package/dist/esm/plugin.js +140 -0
- package/dist/esm/pm-plugins/keymap.js +15 -0
- package/dist/esm/pm-plugins/macro/actions.js +179 -0
- package/dist/esm/pm-plugins/macro/index.js +42 -0
- package/dist/esm/pm-plugins/macro/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/macro/types.js +1 -0
- package/dist/esm/pm-plugins/main.js +298 -0
- package/dist/esm/pm-plugins/unique-id.js +74 -0
- package/dist/esm/pm-plugins/utils.js +68 -0
- package/dist/esm/reducer.js +11 -0
- package/dist/esm/toolbar.js +235 -0
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +465 -0
- package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +112 -0
- package/dist/esm/ui/ConfigPanel/ConfigPanelLoader.js +11 -0
- package/dist/esm/ui/ConfigPanel/ErrorMessage/ErrorImage.js +68 -0
- package/dist/esm/ui/ConfigPanel/ErrorMessage/index.js +26 -0
- package/dist/esm/ui/ConfigPanel/FieldMessages.js +97 -0
- package/dist/esm/ui/ConfigPanel/Fields/Boolean.js +140 -0
- package/dist/esm/ui/ConfigPanel/Fields/CheckboxGroup.js +95 -0
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +414 -0
- package/dist/esm/ui/ConfigPanel/Fields/CustomSelect.js +182 -0
- package/dist/esm/ui/ConfigPanel/Fields/Date.js +48 -0
- package/dist/esm/ui/ConfigPanel/Fields/DateRange.js +154 -0
- package/dist/esm/ui/ConfigPanel/Fields/Enum.js +34 -0
- package/dist/esm/ui/ConfigPanel/Fields/Expand.js +77 -0
- package/dist/esm/ui/ConfigPanel/Fields/Fieldset.js +261 -0
- package/dist/esm/ui/ConfigPanel/Fields/Number.js +57 -0
- package/dist/esm/ui/ConfigPanel/Fields/RadioGroup.js +46 -0
- package/dist/esm/ui/ConfigPanel/Fields/Select.js +50 -0
- package/dist/esm/ui/ConfigPanel/Fields/SelectItem.js +45 -0
- package/dist/esm/ui/ConfigPanel/Fields/String.js +65 -0
- package/dist/esm/ui/ConfigPanel/Fields/TabGroup.js +62 -0
- package/dist/esm/ui/ConfigPanel/Fields/UnhandledType.js +10 -0
- package/dist/esm/ui/ConfigPanel/Fields/UserSelect.js +258 -0
- package/dist/esm/ui/ConfigPanel/Fields/common/RequiredIndicator.js +5 -0
- package/dist/esm/ui/ConfigPanel/FormContent.js +223 -0
- package/dist/esm/ui/ConfigPanel/FormErrorBoundary.js +133 -0
- package/dist/esm/ui/ConfigPanel/Header.js +140 -0
- package/dist/esm/ui/ConfigPanel/LoadingState.js +17 -0
- package/dist/esm/ui/ConfigPanel/NestedForms/RemovableField.js +53 -0
- package/dist/esm/ui/ConfigPanel/constants.js +7 -0
- package/dist/esm/ui/ConfigPanel/index.js +2 -0
- package/dist/esm/ui/ConfigPanel/messages.js +93 -0
- package/dist/esm/ui/ConfigPanel/transformers.js +624 -0
- package/dist/esm/ui/ConfigPanel/types.js +9 -0
- package/dist/esm/ui/ConfigPanel/use-abortable-effect/index.js +49 -0
- package/dist/esm/ui/ConfigPanel/use-state-from-promise/index.js +34 -0
- package/dist/esm/ui/ConfigPanel/utils.js +109 -0
- package/dist/esm/ui/SaveIndicator/SaveIndicator.js +72 -0
- package/dist/esm/ui/SaveIndicator/messages.js +8 -0
- package/dist/esm/ui/SaveIndicator/types.js +1 -0
- package/dist/esm/utils.js +67 -0
- package/dist/types/actions.d.ts +20 -0
- package/dist/types/commands.d.ts +15 -0
- package/dist/types/context-panel.d.ts +10 -0
- package/dist/types/extension-api.d.ts +12 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/plugin-factory.d.ts +4 -0
- package/dist/types/plugin-key.d.ts +3 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/pm-plugins/keymap.d.ts +3 -0
- package/dist/types/pm-plugins/macro/actions.d.ts +9 -0
- package/dist/types/pm-plugins/macro/index.d.ts +8 -0
- package/dist/types/pm-plugins/macro/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/macro/types.d.ts +4 -0
- package/dist/types/pm-plugins/main.d.ts +25 -0
- package/dist/types/pm-plugins/unique-id.d.ts +3 -0
- package/dist/types/pm-plugins/utils.d.ts +3 -0
- package/dist/types/reducer.d.ts +2 -0
- package/dist/types/toolbar.d.ts +44 -0
- package/dist/types/types.d.ts +27 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +22 -0
- package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +21 -0
- package/dist/types/ui/ConfigPanel/ConfigPanelLoader.d.ts +5 -0
- package/dist/types/ui/ConfigPanel/ErrorMessage/ErrorImage.d.ts +4 -0
- package/dist/types/ui/ConfigPanel/ErrorMessage/index.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/FieldMessages.d.ts +12 -0
- package/dist/types/ui/ConfigPanel/Fields/Boolean.d.ts +8 -0
- package/dist/types/ui/ConfigPanel/Fields/CheckboxGroup.d.ts +8 -0
- package/dist/types/ui/ConfigPanel/Fields/ColorPicker.d.ts +20 -0
- package/dist/types/ui/ConfigPanel/Fields/CustomSelect.d.ts +24 -0
- package/dist/types/ui/ConfigPanel/Fields/Date.d.ts +20 -0
- package/dist/types/ui/ConfigPanel/Fields/DateRange.d.ts +20 -0
- package/dist/types/ui/ConfigPanel/Fields/Enum.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/Expand.d.ts +16 -0
- package/dist/types/ui/ConfigPanel/Fields/Fieldset.d.ts +19 -0
- package/dist/types/ui/ConfigPanel/Fields/Number.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/RadioGroup.d.ts +8 -0
- package/dist/types/ui/ConfigPanel/Fields/Select.d.ts +11 -0
- package/dist/types/ui/ConfigPanel/Fields/SelectItem.d.ts +5 -0
- package/dist/types/ui/ConfigPanel/Fields/String.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/TabGroup.d.ts +14 -0
- package/dist/types/ui/ConfigPanel/Fields/UnhandledType.d.ts +6 -0
- package/dist/types/ui/ConfigPanel/Fields/UserSelect.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/common/RequiredIndicator.d.ts +1 -0
- package/dist/types/ui/ConfigPanel/FormContent.d.ts +4 -0
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +16 -0
- package/dist/types/ui/ConfigPanel/Header.d.ts +23 -0
- package/dist/types/ui/ConfigPanel/LoadingState.d.ts +4 -0
- package/dist/types/ui/ConfigPanel/NestedForms/RemovableField.d.ts +19 -0
- package/dist/types/ui/ConfigPanel/constants.d.ts +2 -0
- package/dist/types/ui/ConfigPanel/index.d.ts +2 -0
- package/dist/types/ui/ConfigPanel/messages.d.ts +92 -0
- package/dist/types/ui/ConfigPanel/transformers.d.ts +9 -0
- package/dist/types/ui/ConfigPanel/types.d.ts +36 -0
- package/dist/types/ui/ConfigPanel/use-abortable-effect/index.d.ts +16 -0
- package/dist/types/ui/ConfigPanel/use-state-from-promise/index.d.ts +15 -0
- package/dist/types/ui/ConfigPanel/utils.d.ts +16 -0
- package/dist/types/ui/SaveIndicator/SaveIndicator.d.ts +4 -0
- package/dist/types/ui/SaveIndicator/messages.d.ts +7 -0
- package/dist/types/ui/SaveIndicator/types.d.ts +11 -0
- package/dist/types/utils.d.ts +15 -0
- package/dist/types-ts4.5/actions.d.ts +20 -0
- package/dist/types-ts4.5/commands.d.ts +15 -0
- package/dist/types-ts4.5/context-panel.d.ts +10 -0
- package/dist/types-ts4.5/extension-api.d.ts +12 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/plugin-factory.d.ts +4 -0
- package/dist/types-ts4.5/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/macro/actions.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/macro/index.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/macro/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/macro/types.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +25 -0
- package/dist/types-ts4.5/pm-plugins/unique-id.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +3 -0
- package/dist/types-ts4.5/reducer.d.ts +2 -0
- package/dist/types-ts4.5/toolbar.d.ts +44 -0
- package/dist/types-ts4.5/types.d.ts +27 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +22 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +21 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelLoader.d.ts +5 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ErrorMessage/ErrorImage.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ErrorMessage/index.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/FieldMessages.d.ts +12 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Boolean.d.ts +8 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/CheckboxGroup.d.ts +8 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/ColorPicker.d.ts +20 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/CustomSelect.d.ts +24 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Date.d.ts +20 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/DateRange.d.ts +20 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Enum.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Expand.d.ts +16 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Fieldset.d.ts +19 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Number.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/RadioGroup.d.ts +8 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Select.d.ts +11 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/SelectItem.d.ts +5 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/String.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/TabGroup.d.ts +14 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/UnhandledType.d.ts +6 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/UserSelect.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/common/RequiredIndicator.d.ts +1 -0
- package/dist/types-ts4.5/ui/ConfigPanel/FormContent.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +16 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Header.d.ts +23 -0
- package/dist/types-ts4.5/ui/ConfigPanel/LoadingState.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfigPanel/NestedForms/RemovableField.d.ts +19 -0
- package/dist/types-ts4.5/ui/ConfigPanel/constants.d.ts +2 -0
- package/dist/types-ts4.5/ui/ConfigPanel/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/ConfigPanel/messages.d.ts +92 -0
- package/dist/types-ts4.5/ui/ConfigPanel/transformers.d.ts +9 -0
- package/dist/types-ts4.5/ui/ConfigPanel/types.d.ts +39 -0
- package/dist/types-ts4.5/ui/ConfigPanel/use-abortable-effect/index.d.ts +16 -0
- package/dist/types-ts4.5/ui/ConfigPanel/use-state-from-promise/index.d.ts +18 -0
- package/dist/types-ts4.5/ui/ConfigPanel/utils.d.ts +16 -0
- package/dist/types-ts4.5/ui/SaveIndicator/SaveIndicator.d.ts +4 -0
- package/dist/types-ts4.5/ui/SaveIndicator/messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/SaveIndicator/types.d.ts +11 -0
- package/dist/types-ts4.5/utils.d.ts +15 -0
- package/example-utils/config-panel/ConfigPanelWithExtensionPicker.tsx +217 -0
- package/example-utils/config-panel/ConfigPanelWithProviders.tsx +51 -0
- package/example-utils/config-panel/ExtensionNodePicker.tsx +141 -0
- package/example-utils/config-panel/FieldTypePicker.tsx +63 -0
- package/example-utils/config-panel/example-manifest-all-fields.ts +86 -0
- package/example-utils/config-panel/example-manifest-individual-fields.ts +85 -0
- package/example-utils/config-panel/fields.ts +611 -0
- package/package.json +49 -7
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
import commonMessages from '@atlaskit/editor-common/messages';
|
|
3
|
+
import { getChildrenInfo, getNodeName, isReferencedSource } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import EditIcon from '@atlaskit/icon/glyph/editor/edit';
|
|
6
|
+
import CenterIcon from '@atlaskit/icon/glyph/editor/media-center';
|
|
7
|
+
import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
8
|
+
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
9
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
10
|
+
import { editExtension } from './actions';
|
|
11
|
+
import { removeDescendantNodes, removeExtension, updateExtensionLayout } from './commands';
|
|
12
|
+
import { pluginKey as macroPluginKey } from './pm-plugins/macro/plugin-key';
|
|
13
|
+
import { getPluginState } from './pm-plugins/main';
|
|
14
|
+
import { getSelectedExtension } from './utils';
|
|
15
|
+
export const messages = defineMessages({
|
|
16
|
+
edit: {
|
|
17
|
+
id: 'fabric.editor.edit',
|
|
18
|
+
defaultMessage: 'Edit',
|
|
19
|
+
description: 'Edit the properties for this extension.'
|
|
20
|
+
},
|
|
21
|
+
deleteElementTitle: {
|
|
22
|
+
id: 'fabric.editor.extension.deleteElementTitle',
|
|
23
|
+
defaultMessage: 'Delete element',
|
|
24
|
+
description: 'Title text for confirm modal when deleting an extension linked to a data consumer.'
|
|
25
|
+
},
|
|
26
|
+
unnamedSource: {
|
|
27
|
+
id: 'fabric.editor.extension.sourceNoTitledName',
|
|
28
|
+
defaultMessage: 'this element',
|
|
29
|
+
description: 'The current element without preset name been selected'
|
|
30
|
+
},
|
|
31
|
+
confirmDeleteLinkedModalOKButton: {
|
|
32
|
+
id: 'fabric.editor.extension.confirmDeleteLinkedModalOKButton',
|
|
33
|
+
defaultMessage: 'Delete',
|
|
34
|
+
description: 'Action button label for confirm modal when deleting an extension linked to a data consumer.'
|
|
35
|
+
},
|
|
36
|
+
confirmDeleteLinkedModalMessage: {
|
|
37
|
+
id: 'fabric.editor.extension.confirmDeleteLinkedModalMessage',
|
|
38
|
+
defaultMessage: 'Deleting {nodeName} will break anything connected to it.',
|
|
39
|
+
description: 'Message for confirm modal when deleting a extension linked to an data consumer.'
|
|
40
|
+
},
|
|
41
|
+
confirmModalCheckboxLabel: {
|
|
42
|
+
id: 'fabric.editor.floatingToolbar.confirmModalCheckboxLabel',
|
|
43
|
+
defaultMessage: 'Also delete connected elements',
|
|
44
|
+
description: 'checkbox label text'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const isLayoutSupported = (state, selectedExtNode) => {
|
|
48
|
+
const {
|
|
49
|
+
schema: {
|
|
50
|
+
nodes: {
|
|
51
|
+
bodiedExtension,
|
|
52
|
+
extension,
|
|
53
|
+
layoutSection,
|
|
54
|
+
table,
|
|
55
|
+
expand,
|
|
56
|
+
multiBodiedExtension
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
selection
|
|
60
|
+
} = state;
|
|
61
|
+
if (!selectedExtNode) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return !!((selectedExtNode.node.type === bodiedExtension || selectedExtNode.node.type === multiBodiedExtension || selectedExtNode.node.type === extension && !hasParentNodeOfType([bodiedExtension, table, expand].filter(Boolean))(selection)) && !hasParentNodeOfType([layoutSection])(selection));
|
|
65
|
+
};
|
|
66
|
+
const breakoutOptions = (state, formatMessage, extensionState, breakoutEnabled) => {
|
|
67
|
+
const nodeWithPos = getSelectedExtension(state, true);
|
|
68
|
+
|
|
69
|
+
// we should only return breakout options when breakouts are enabled and the node supports them
|
|
70
|
+
if (nodeWithPos && breakoutEnabled && isLayoutSupported(state, nodeWithPos)) {
|
|
71
|
+
const {
|
|
72
|
+
layout
|
|
73
|
+
} = nodeWithPos.node.attrs;
|
|
74
|
+
return [{
|
|
75
|
+
type: 'button',
|
|
76
|
+
icon: CenterIcon,
|
|
77
|
+
onClick: updateExtensionLayout('default'),
|
|
78
|
+
selected: layout === 'default',
|
|
79
|
+
title: formatMessage(commonMessages.layoutFixedWidth),
|
|
80
|
+
tabIndex: null
|
|
81
|
+
}, {
|
|
82
|
+
type: 'button',
|
|
83
|
+
icon: WideIcon,
|
|
84
|
+
onClick: updateExtensionLayout('wide'),
|
|
85
|
+
selected: layout === 'wide',
|
|
86
|
+
title: formatMessage(commonMessages.layoutWide),
|
|
87
|
+
tabIndex: null
|
|
88
|
+
}, {
|
|
89
|
+
type: 'button',
|
|
90
|
+
icon: FullWidthIcon,
|
|
91
|
+
onClick: updateExtensionLayout('full-width'),
|
|
92
|
+
selected: layout === 'full-width',
|
|
93
|
+
title: formatMessage(commonMessages.layoutFullWidth),
|
|
94
|
+
tabIndex: null
|
|
95
|
+
}];
|
|
96
|
+
}
|
|
97
|
+
return [];
|
|
98
|
+
};
|
|
99
|
+
const editButton = (formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI) => {
|
|
100
|
+
if (!extensionState.showEditButton) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
return [{
|
|
104
|
+
id: 'editor.extension.edit',
|
|
105
|
+
type: 'button',
|
|
106
|
+
icon: EditIcon,
|
|
107
|
+
testId: 'extension-toolbar-edit-button',
|
|
108
|
+
// Taking the latest `updateExtension` from plugin state to avoid race condition @see ED-8501
|
|
109
|
+
onClick: (state, dispatch, view) => {
|
|
110
|
+
const macroState = macroPluginKey.getState(state);
|
|
111
|
+
const {
|
|
112
|
+
updateExtension
|
|
113
|
+
} = getPluginState(state);
|
|
114
|
+
editExtension(macroState && macroState.macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(state, dispatch, view);
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
117
|
+
title: formatMessage(messages.edit),
|
|
118
|
+
tabIndex: null,
|
|
119
|
+
focusEditoronEnter: true
|
|
120
|
+
}];
|
|
121
|
+
};
|
|
122
|
+
export const getToolbarConfig = ({
|
|
123
|
+
breakoutEnabled = true,
|
|
124
|
+
hoverDecoration,
|
|
125
|
+
applyChangeToContextPanel,
|
|
126
|
+
editorAnalyticsAPI
|
|
127
|
+
}) => (state, intl) => {
|
|
128
|
+
const {
|
|
129
|
+
formatMessage
|
|
130
|
+
} = intl;
|
|
131
|
+
const extensionState = getPluginState(state);
|
|
132
|
+
if (extensionState && !extensionState.showContextPanel && extensionState.element) {
|
|
133
|
+
const nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension, state.schema.nodes.multiBodiedExtension];
|
|
134
|
+
const editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI);
|
|
135
|
+
const breakoutButtonArray = breakoutOptions(state, formatMessage, extensionState, breakoutEnabled);
|
|
136
|
+
const extensionObj = getSelectedExtension(state, true);
|
|
137
|
+
|
|
138
|
+
// Check if we need to show confirm dialog for delete button
|
|
139
|
+
let confirmDialog;
|
|
140
|
+
if (isReferencedSource(state, extensionObj === null || extensionObj === void 0 ? void 0 : extensionObj.node)) {
|
|
141
|
+
confirmDialog = () => {
|
|
142
|
+
const localSourceName = formatMessage(messages.unnamedSource);
|
|
143
|
+
return {
|
|
144
|
+
title: formatMessage(messages.deleteElementTitle),
|
|
145
|
+
okButtonLabel: formatMessage(messages.confirmDeleteLinkedModalOKButton),
|
|
146
|
+
message: formatMessage(messages.confirmDeleteLinkedModalMessage, {
|
|
147
|
+
nodeName: getNodeName(state, extensionObj === null || extensionObj === void 0 ? void 0 : extensionObj.node) || localSourceName
|
|
148
|
+
}),
|
|
149
|
+
isReferentialityDialog: true,
|
|
150
|
+
getChildrenInfo: () => getChildrenInfo(state, extensionObj === null || extensionObj === void 0 ? void 0 : extensionObj.node),
|
|
151
|
+
checkboxLabel: formatMessage(messages.confirmModalCheckboxLabel),
|
|
152
|
+
onConfirm: (isChecked = false) => clickWithCheckboxHandler(isChecked, extensionObj === null || extensionObj === void 0 ? void 0 : extensionObj.node)
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
title: 'Extension floating controls',
|
|
158
|
+
getDomRef: () => extensionState.element.parentElement || undefined,
|
|
159
|
+
nodeType,
|
|
160
|
+
onPositionCalculated: (editorView, nextPos) => {
|
|
161
|
+
const {
|
|
162
|
+
state: {
|
|
163
|
+
schema,
|
|
164
|
+
selection
|
|
165
|
+
}
|
|
166
|
+
} = editorView;
|
|
167
|
+
const mbeNode = getSelectedExtension(state, true);
|
|
168
|
+
const mbeFrame = findParentNodeOfType(schema.nodes.extensionFrame)(selection);
|
|
169
|
+
if (!mbeNode || !mbeFrame) {
|
|
170
|
+
return nextPos;
|
|
171
|
+
}
|
|
172
|
+
const mbeDomElement = editorView.nodeDOM(mbeNode.pos);
|
|
173
|
+
const mbeFrameElement = editorView.nodeDOM(mbeFrame.pos);
|
|
174
|
+
const mbeNodeRect = mbeDomElement === null || mbeDomElement === void 0 ? void 0 : mbeDomElement.getBoundingClientRect();
|
|
175
|
+
const mbeFrameRect = mbeFrameElement.getBoundingClientRect();
|
|
176
|
+
const scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* MbeNodeRect height will include mbeFrameRect height and the navigation toolbar of the MBE
|
|
180
|
+
* excluding nav toolbar height from the floaing extention toolbar position calculated.
|
|
181
|
+
* In case of new tabs, MBE does not update the frame to the new tab so height comes as 0,
|
|
182
|
+
* so we add the min height (100px) + borders (2px) as the default minimum frame height for toolbar to appear
|
|
183
|
+
*
|
|
184
|
+
*/
|
|
185
|
+
const frameheight = mbeFrameRect.height > 0 ? mbeFrameRect.height : 102;
|
|
186
|
+
return {
|
|
187
|
+
top: mbeNodeRect.top + frameheight + scrollWrapper.scrollTop,
|
|
188
|
+
left: nextPos.left
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
items: [...editButtonArray, ...breakoutButtonArray, {
|
|
192
|
+
type: 'separator',
|
|
193
|
+
hidden: editButtonArray.length === 0 && breakoutButtonArray.length === 0
|
|
194
|
+
}, {
|
|
195
|
+
type: 'extensions-placeholder',
|
|
196
|
+
separator: 'end'
|
|
197
|
+
}, {
|
|
198
|
+
type: 'copy-button',
|
|
199
|
+
items: [{
|
|
200
|
+
state,
|
|
201
|
+
formatMessage: intl.formatMessage,
|
|
202
|
+
nodeType
|
|
203
|
+
}, {
|
|
204
|
+
type: 'separator'
|
|
205
|
+
}]
|
|
206
|
+
}, {
|
|
207
|
+
id: 'editor.extension.delete',
|
|
208
|
+
type: 'button',
|
|
209
|
+
icon: RemoveIcon,
|
|
210
|
+
appearance: 'danger',
|
|
211
|
+
onClick: removeExtension(editorAnalyticsAPI),
|
|
212
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
213
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
214
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
215
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
216
|
+
focusEditoronEnter: true,
|
|
217
|
+
title: formatMessage(commonMessages.remove),
|
|
218
|
+
tabIndex: null,
|
|
219
|
+
confirmDialog
|
|
220
|
+
}],
|
|
221
|
+
scrollable: true
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
};
|
|
226
|
+
const clickWithCheckboxHandler = (isChecked, node) => (state, dispatch) => {
|
|
227
|
+
if (!node) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
if (!isChecked) {
|
|
231
|
+
removeExtension()(state, dispatch);
|
|
232
|
+
} else {
|
|
233
|
+
removeDescendantNodes(node)(state, dispatch);
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
};
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import _isEqual from 'lodash/isEqual';
|
|
5
|
+
import _mergeRecursive from 'lodash/merge';
|
|
6
|
+
import memoizeOne from 'memoize-one';
|
|
7
|
+
import { injectIntl } from 'react-intl-next';
|
|
8
|
+
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
|
+
import ButtonGroup from '@atlaskit/button/button-group';
|
|
10
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
12
|
+
import { isTabGroup } from '@atlaskit/editor-common/extensions';
|
|
13
|
+
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
14
|
+
import Form, { FormFooter } from '@atlaskit/form';
|
|
15
|
+
import { pluginKey as extensionPluginKey } from '../../plugin-key';
|
|
16
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
|
|
17
|
+
import ErrorMessage from './ErrorMessage';
|
|
18
|
+
import FormContent from './FormContent';
|
|
19
|
+
import { FormErrorBoundary } from './FormErrorBoundary';
|
|
20
|
+
import Header from './Header';
|
|
21
|
+
import LoadingState from './LoadingState';
|
|
22
|
+
import { messages } from './messages';
|
|
23
|
+
import { deserialize, findDuplicateFields, serialize } from './transformers';
|
|
24
|
+
import { getLoggedParameters } from './utils';
|
|
25
|
+
function ConfigForm({
|
|
26
|
+
canSave,
|
|
27
|
+
errorMessage,
|
|
28
|
+
extensionManifest,
|
|
29
|
+
fields,
|
|
30
|
+
firstVisibleFieldName,
|
|
31
|
+
hasParsedParameters,
|
|
32
|
+
intl,
|
|
33
|
+
isLoading,
|
|
34
|
+
onCancel,
|
|
35
|
+
onFieldChange,
|
|
36
|
+
parameters,
|
|
37
|
+
submitting,
|
|
38
|
+
contextIdentifierProvider,
|
|
39
|
+
featureFlags
|
|
40
|
+
}) {
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (fields) {
|
|
43
|
+
const firstDuplicateField = findDuplicateFields(fields);
|
|
44
|
+
if (firstDuplicateField) {
|
|
45
|
+
throw new Error(`Possible duplicate field name: \`${firstDuplicateField.name}\`.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, [fields]);
|
|
49
|
+
if (isLoading || !hasParsedParameters && errorMessage === null) {
|
|
50
|
+
return /*#__PURE__*/React.createElement(LoadingState, null);
|
|
51
|
+
}
|
|
52
|
+
if (errorMessage || !fields) {
|
|
53
|
+
return /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
54
|
+
errorMessage: errorMessage || ''
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormContent, {
|
|
58
|
+
fields: fields,
|
|
59
|
+
parameters: parameters,
|
|
60
|
+
extensionManifest: extensionManifest,
|
|
61
|
+
onFieldChange: onFieldChange,
|
|
62
|
+
firstVisibleFieldName: firstVisibleFieldName,
|
|
63
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
64
|
+
featureFlags: featureFlags
|
|
65
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
style: canSave ? {} : {
|
|
67
|
+
display: 'none'
|
|
68
|
+
}
|
|
69
|
+
}, /*#__PURE__*/React.createElement(FormFooter, {
|
|
70
|
+
align: "start"
|
|
71
|
+
}, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
72
|
+
type: "submit",
|
|
73
|
+
appearance: "primary"
|
|
74
|
+
}, intl.formatMessage(messages.submit)), /*#__PURE__*/React.createElement(Button, {
|
|
75
|
+
appearance: "default",
|
|
76
|
+
isDisabled: submitting,
|
|
77
|
+
onClick: onCancel
|
|
78
|
+
}, intl.formatMessage(messages.cancel))))));
|
|
79
|
+
}
|
|
80
|
+
const ConfigFormIntl = injectIntl(ConfigForm);
|
|
81
|
+
const WithOnFieldChange = ({
|
|
82
|
+
getState,
|
|
83
|
+
autoSave,
|
|
84
|
+
handleSubmit,
|
|
85
|
+
children
|
|
86
|
+
}) => {
|
|
87
|
+
const getStateRef = useRef(getState);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
getStateRef.current = getState;
|
|
90
|
+
}, [getState]);
|
|
91
|
+
const handleFieldChange = useCallback((name, isDirty) => {
|
|
92
|
+
if (!autoSave) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Don't trigger submit if nothing actually changed
|
|
97
|
+
if (!isDirty) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const {
|
|
101
|
+
errors,
|
|
102
|
+
values
|
|
103
|
+
} = getStateRef.current();
|
|
104
|
+
|
|
105
|
+
// Get only values that does not contain errors
|
|
106
|
+
const validValues = {};
|
|
107
|
+
for (const key of Object.keys(values)) {
|
|
108
|
+
if (!errors[key]) {
|
|
109
|
+
// not has error
|
|
110
|
+
validValues[key] = values[key];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
handleSubmit(validValues);
|
|
114
|
+
}, [autoSave, handleSubmit]);
|
|
115
|
+
return children(handleFieldChange);
|
|
116
|
+
};
|
|
117
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
118
|
+
class ConfigPanel extends React.Component {
|
|
119
|
+
constructor(props) {
|
|
120
|
+
super(props);
|
|
121
|
+
_defineProperty(this, "handleKeyDown", e => {
|
|
122
|
+
if ((e.key === 'Esc' || e.key === 'Escape') && this.props.closeOnEsc) {
|
|
123
|
+
this.props.onCancel();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// https://product-fabric.atlassian.net/browse/DST-2697
|
|
127
|
+
// workaround for DST-2697, remove this function once fix.
|
|
128
|
+
_defineProperty(this, "backfillTabFormData", (fields, formData, currentParameters) => {
|
|
129
|
+
const getRelevantData = (field, formParams, currentParams, backfill) => {
|
|
130
|
+
if (field.hasGroupedValues && !(field.name in backfill)) {
|
|
131
|
+
backfill[field.name] = {};
|
|
132
|
+
}
|
|
133
|
+
const actualFormParams = field.hasGroupedValues ? formParams[field.name] || {} : formParams;
|
|
134
|
+
const actualCurrentParams = field.hasGroupedValues ? currentParams[field.name] || {} : currentParams;
|
|
135
|
+
const actualBackfillParams = field.hasGroupedValues ? backfill[field.name] : backfill;
|
|
136
|
+
return {
|
|
137
|
+
formParams: actualFormParams,
|
|
138
|
+
currentParams: actualCurrentParams,
|
|
139
|
+
backfillParams: actualBackfillParams
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Traverse any tab structures and backfill field values on tabs
|
|
144
|
+
// which aren't shown. This filter should be ok because tabs are
|
|
145
|
+
// currently only allowed on top level
|
|
146
|
+
const mergedTabGroups = fields.filter(isTabGroup).reduce((missingBackfill, tabGroup) => {
|
|
147
|
+
const {
|
|
148
|
+
formParams: tabGroupFormData,
|
|
149
|
+
currentParams: tabGroupCurrentData,
|
|
150
|
+
backfillParams: tabGroupParams
|
|
151
|
+
} = getRelevantData(tabGroup, formData, currentParameters, missingBackfill);
|
|
152
|
+
|
|
153
|
+
// Loop through tabs and see what fields are missing from current data
|
|
154
|
+
tabGroup.fields.forEach(tabField => {
|
|
155
|
+
const {
|
|
156
|
+
formParams: tabFormData,
|
|
157
|
+
currentParams: tabCurrentData,
|
|
158
|
+
backfillParams: tabParams
|
|
159
|
+
} = getRelevantData(tabField, tabGroupFormData, tabGroupCurrentData, tabGroupParams);
|
|
160
|
+
tabField.fields.forEach(field => {
|
|
161
|
+
if (field.name in tabFormData || !(field.name in tabCurrentData)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
tabParams[field.name] = tabCurrentData[field.name];
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
return missingBackfill;
|
|
168
|
+
}, {});
|
|
169
|
+
return _mergeRecursive({}, mergedTabGroups, formData);
|
|
170
|
+
});
|
|
171
|
+
_defineProperty(this, "handleSubmit", async formData => {
|
|
172
|
+
const {
|
|
173
|
+
fields,
|
|
174
|
+
extensionManifest,
|
|
175
|
+
onChange,
|
|
176
|
+
autoSaveReject
|
|
177
|
+
} = this.props;
|
|
178
|
+
if (!extensionManifest || !fields) {
|
|
179
|
+
if (!extensionManifest) {
|
|
180
|
+
autoSaveReject === null || autoSaveReject === void 0 ? void 0 : autoSaveReject(new Error('Extension manifest not loaded'));
|
|
181
|
+
} else if (!fields) {
|
|
182
|
+
autoSaveReject === null || autoSaveReject === void 0 ? void 0 : autoSaveReject(new Error('Config fields not loaded'));
|
|
183
|
+
}
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const serializedData = await serialize(extensionManifest, this.backfillTabFormData(fields, formData, this.state.currentParameters), fields);
|
|
188
|
+
onChange(serializedData);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
autoSaveReject === null || autoSaveReject === void 0 ? void 0 : autoSaveReject(error);
|
|
191
|
+
// eslint-disable-next-line no-console
|
|
192
|
+
console.error(`Error serializing parameters`, error);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
_defineProperty(this, "parseParameters", async (fields, parameters) => {
|
|
196
|
+
const {
|
|
197
|
+
extensionManifest
|
|
198
|
+
} = this.props;
|
|
199
|
+
if (!extensionManifest || !fields || fields.length === 0) {
|
|
200
|
+
// do not parse while fields are not returned
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (typeof parameters === 'undefined') {
|
|
204
|
+
this.setState({
|
|
205
|
+
currentParameters: {},
|
|
206
|
+
hasParsedParameters: true
|
|
207
|
+
});
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const currentParameters = await deserialize(extensionManifest, parameters, fields);
|
|
211
|
+
this.setState({
|
|
212
|
+
currentParameters,
|
|
213
|
+
hasParsedParameters: true
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
// memoized to prevent rerender on new parameters
|
|
217
|
+
_defineProperty(this, "renderHeader", memoizeOne(extensionManifest => {
|
|
218
|
+
const {
|
|
219
|
+
onCancel,
|
|
220
|
+
showHeader
|
|
221
|
+
} = this.props;
|
|
222
|
+
|
|
223
|
+
// Use a temporary allowlist of top 3 macros to test out a new "Documentation" CTA ("Need help?")
|
|
224
|
+
// This will be removed when Top 5 Modernized Macros updates are rolled out
|
|
225
|
+
const modernizedMacrosList = ['children', 'recently-updated', 'excerpt'];
|
|
226
|
+
const enableHelpCTA = modernizedMacrosList.includes(extensionManifest.key);
|
|
227
|
+
if (!showHeader) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return /*#__PURE__*/React.createElement(Header, {
|
|
231
|
+
icon: extensionManifest.icons['48'],
|
|
232
|
+
title: extensionManifest.title,
|
|
233
|
+
description: extensionManifest.description,
|
|
234
|
+
summary: extensionManifest.summary,
|
|
235
|
+
documentationUrl: extensionManifest.documentationUrl,
|
|
236
|
+
onClose: onCancel,
|
|
237
|
+
enableHelpCTA: enableHelpCTA
|
|
238
|
+
});
|
|
239
|
+
}));
|
|
240
|
+
_defineProperty(this, "getFirstVisibleFieldName", memoizeOne(fields => {
|
|
241
|
+
function nonHidden(field) {
|
|
242
|
+
if ('isHidden' in field) {
|
|
243
|
+
return !field.isHidden;
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// finds the first visible field, true for FieldSets too
|
|
249
|
+
const firstVisibleField = fields.find(nonHidden);
|
|
250
|
+
let newFirstVisibleFieldName;
|
|
251
|
+
if (firstVisibleField) {
|
|
252
|
+
// if it was a fieldset, go deeper trying to locate the field
|
|
253
|
+
if (firstVisibleField.type === 'fieldset') {
|
|
254
|
+
const firstVisibleFieldWithinFieldset = firstVisibleField.fields.find(nonHidden);
|
|
255
|
+
newFirstVisibleFieldName = firstVisibleFieldWithinFieldset && firstVisibleFieldWithinFieldset.name;
|
|
256
|
+
} else {
|
|
257
|
+
newFirstVisibleFieldName = firstVisibleField.name;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return newFirstVisibleFieldName;
|
|
261
|
+
}));
|
|
262
|
+
_defineProperty(this, "setFirstVisibleFieldName", fields => {
|
|
263
|
+
const newFirstVisibleFieldName = this.getFirstVisibleFieldName(fields);
|
|
264
|
+
if (newFirstVisibleFieldName !== this.state.firstVisibleFieldName) {
|
|
265
|
+
this.setState({
|
|
266
|
+
firstVisibleFieldName: newFirstVisibleFieldName
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
this.state = {
|
|
271
|
+
hasParsedParameters: false,
|
|
272
|
+
currentParameters: {},
|
|
273
|
+
firstVisibleFieldName: props.fields ? this.getFirstVisibleFieldName(props.fields) : undefined
|
|
274
|
+
};
|
|
275
|
+
this.onFieldChange = null;
|
|
276
|
+
}
|
|
277
|
+
componentDidMount() {
|
|
278
|
+
const {
|
|
279
|
+
fields,
|
|
280
|
+
parameters
|
|
281
|
+
} = this.props;
|
|
282
|
+
this.parseParameters(fields, parameters);
|
|
283
|
+
}
|
|
284
|
+
componentWillUnmount() {
|
|
285
|
+
const {
|
|
286
|
+
createAnalyticsEvent,
|
|
287
|
+
extensionManifest,
|
|
288
|
+
fields
|
|
289
|
+
} = this.props;
|
|
290
|
+
const {
|
|
291
|
+
currentParameters
|
|
292
|
+
} = this.state;
|
|
293
|
+
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
294
|
+
payload: {
|
|
295
|
+
action: ACTION.CLOSED,
|
|
296
|
+
actionSubject: ACTION_SUBJECT.CONFIG_PANEL,
|
|
297
|
+
eventType: EVENT_TYPE.UI,
|
|
298
|
+
attributes: {
|
|
299
|
+
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
300
|
+
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type,
|
|
301
|
+
...(extensionManifest !== null && extensionManifest !== void 0 && extensionManifest.key && ALLOWED_LOGGED_MACRO_PARAMS[extensionManifest.key] ? {
|
|
302
|
+
parameters: getLoggedParameters(extensionManifest.key, currentParameters, fields)
|
|
303
|
+
} : {})
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
componentDidUpdate(prevProps) {
|
|
309
|
+
const {
|
|
310
|
+
parameters,
|
|
311
|
+
fields,
|
|
312
|
+
autoSaveTrigger,
|
|
313
|
+
extensionManifest
|
|
314
|
+
} = this.props;
|
|
315
|
+
if (parameters && parameters !== prevProps.parameters || fields && (!prevProps.fields || !_isEqual(fields, prevProps.fields))) {
|
|
316
|
+
this.parseParameters(fields, parameters);
|
|
317
|
+
}
|
|
318
|
+
if (fields && (!prevProps.fields || !_isEqual(fields, prevProps.fields))) {
|
|
319
|
+
this.setFirstVisibleFieldName(fields);
|
|
320
|
+
}
|
|
321
|
+
if (prevProps.autoSaveTrigger !== autoSaveTrigger) {
|
|
322
|
+
if (this.onFieldChange) {
|
|
323
|
+
this.onFieldChange('', true);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (prevProps.extensionManifest === undefined && prevProps.extensionManifest !== extensionManifest) {
|
|
327
|
+
// This will only be fired once when extensionManifest is loaded initially
|
|
328
|
+
// Can't do this in componentDidMount because extensionManifest is still undefined at that point
|
|
329
|
+
fireAnalyticsEvent(this.props.createAnalyticsEvent)({
|
|
330
|
+
payload: {
|
|
331
|
+
action: ACTION.OPENED,
|
|
332
|
+
actionSubject: ACTION_SUBJECT.CONFIG_PANEL,
|
|
333
|
+
eventType: EVENT_TYPE.UI,
|
|
334
|
+
attributes: {
|
|
335
|
+
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
336
|
+
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
render() {
|
|
343
|
+
const {
|
|
344
|
+
extensionManifest,
|
|
345
|
+
featureFlags
|
|
346
|
+
} = this.props;
|
|
347
|
+
if (!extensionManifest) {
|
|
348
|
+
return /*#__PURE__*/React.createElement(LoadingState, null);
|
|
349
|
+
}
|
|
350
|
+
const {
|
|
351
|
+
autoSave,
|
|
352
|
+
errorMessage,
|
|
353
|
+
fields,
|
|
354
|
+
isLoading,
|
|
355
|
+
onCancel
|
|
356
|
+
} = this.props;
|
|
357
|
+
const {
|
|
358
|
+
currentParameters,
|
|
359
|
+
hasParsedParameters,
|
|
360
|
+
firstVisibleFieldName
|
|
361
|
+
} = this.state;
|
|
362
|
+
const {
|
|
363
|
+
handleSubmit,
|
|
364
|
+
handleKeyDown
|
|
365
|
+
} = this;
|
|
366
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
367
|
+
onSubmit: handleSubmit
|
|
368
|
+
}, ({
|
|
369
|
+
formProps,
|
|
370
|
+
getState,
|
|
371
|
+
submitting
|
|
372
|
+
}) => {
|
|
373
|
+
return /*#__PURE__*/React.createElement(WithOnFieldChange, {
|
|
374
|
+
autoSave: !!autoSave,
|
|
375
|
+
getState: getState,
|
|
376
|
+
handleSubmit: handleSubmit
|
|
377
|
+
}, onFieldChange => {
|
|
378
|
+
this.onFieldChange = onFieldChange;
|
|
379
|
+
return /*#__PURE__*/React.createElement("form", _extends({}, formProps, {
|
|
380
|
+
noValidate: true,
|
|
381
|
+
onKeyDown: handleKeyDown,
|
|
382
|
+
"data-testid": "extension-config-panel"
|
|
383
|
+
}), this.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(WithPluginState, {
|
|
384
|
+
plugins: {
|
|
385
|
+
extension: extensionPluginKey
|
|
386
|
+
},
|
|
387
|
+
render: ({
|
|
388
|
+
extension
|
|
389
|
+
}) => /*#__PURE__*/React.createElement(FormErrorBoundary, {
|
|
390
|
+
contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
|
|
391
|
+
extensionKey: extensionManifest.key,
|
|
392
|
+
fields: fields || []
|
|
393
|
+
}, /*#__PURE__*/React.createElement(ConfigFormIntl, {
|
|
394
|
+
canSave: !autoSave,
|
|
395
|
+
errorMessage: errorMessage,
|
|
396
|
+
extensionManifest: extensionManifest,
|
|
397
|
+
fields: fields,
|
|
398
|
+
firstVisibleFieldName: firstVisibleFieldName,
|
|
399
|
+
hasParsedParameters: hasParsedParameters,
|
|
400
|
+
isLoading: isLoading || false,
|
|
401
|
+
onCancel: onCancel,
|
|
402
|
+
onFieldChange: onFieldChange,
|
|
403
|
+
parameters: currentParameters,
|
|
404
|
+
submitting: submitting,
|
|
405
|
+
contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
|
|
406
|
+
featureFlags: featureFlags
|
|
407
|
+
}))
|
|
408
|
+
}));
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
export default withAnalyticsContext({
|
|
414
|
+
source: 'ConfigPanel'
|
|
415
|
+
})(withAnalyticsEvents()(ConfigPanel));
|