@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,46 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
2
|
+
const safeError = message => {
|
|
3
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4
|
+
throw new Error(message);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
console.error(message);
|
|
9
|
+
};
|
|
10
|
+
const createAbortController = () => {
|
|
11
|
+
if (typeof AbortController === 'undefined') {
|
|
12
|
+
safeError('Missing AbortController');
|
|
13
|
+
}
|
|
14
|
+
return new AbortController();
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Similar to useEffect but integrated with the AbortController to make it useful for async operations.
|
|
18
|
+
* On unmount, the abort function will be called and the signal will be passed down to the function so
|
|
19
|
+
* we get the chance to cancel any operation we want.
|
|
20
|
+
*
|
|
21
|
+
* Note: This hook follows the signature of useEffect so it can be linted if enabled through the
|
|
22
|
+
* `additionalHooks` config.
|
|
23
|
+
*
|
|
24
|
+
* @param callback
|
|
25
|
+
* @param deps
|
|
26
|
+
*/
|
|
27
|
+
export function useAbortableEffect(callback, deps) {
|
|
28
|
+
const abortController = useMemo(() => createAbortController(),
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
deps);
|
|
31
|
+
const abort = useCallback(() => abortController.abort(), [abortController]);
|
|
32
|
+
// AFP-2511 TODO: Fix automatic suppressions below
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
const fn = useCallback(callback, deps);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const teardown = fn(abortController.signal);
|
|
37
|
+
return () => {
|
|
38
|
+
if (typeof teardown === 'function') {
|
|
39
|
+
teardown();
|
|
40
|
+
}
|
|
41
|
+
abort();
|
|
42
|
+
};
|
|
43
|
+
}, [abortController, abort, fn,
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
...deps]);
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useAbortableEffect } from '../use-abortable-effect';
|
|
3
|
+
/**
|
|
4
|
+
* Similar to useState but deals with async values.
|
|
5
|
+
* Simply pass a promise and it will set the state when it resolves. It won't try to set if
|
|
6
|
+
* the component unmounts
|
|
7
|
+
*
|
|
8
|
+
* Note: This hook follows the signature of useEffect so it can be linted if enabled through the
|
|
9
|
+
* `additionalHooks` config.
|
|
10
|
+
*
|
|
11
|
+
* @param callback
|
|
12
|
+
* @param deps
|
|
13
|
+
*/
|
|
14
|
+
export function useStateFromPromise(callback, deps, initialValue) {
|
|
15
|
+
// AFP-2511 TODO: Fix automatic suppressions below
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
const fn = useCallback(callback, deps);
|
|
18
|
+
const [value, setValue] = useState(initialValue);
|
|
19
|
+
useAbortableEffect(signal => {
|
|
20
|
+
Promise.resolve(fn()).then(result => {
|
|
21
|
+
if (signal.aborted) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
setValue(result);
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
[...deps]);
|
|
29
|
+
return [value, setValue];
|
|
30
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { isOptionsGrouped } from '@atlaskit/select';
|
|
2
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS, ALLOWED_PARAM_TYPES } from './constants';
|
|
3
|
+
import { ValidationError } from './types';
|
|
4
|
+
export const validate = (field, value) => {
|
|
5
|
+
return validateRequired(field, value);
|
|
6
|
+
};
|
|
7
|
+
const isEmptyString = value => typeof value === 'string' && value === '';
|
|
8
|
+
const isEmptyArray = value => Array.isArray(value) && value.length === 0;
|
|
9
|
+
const getUngroupedOptions = groupedOptions => {
|
|
10
|
+
return groupedOptions.flatMap(option => option.options);
|
|
11
|
+
};
|
|
12
|
+
export const validateRequired = ({
|
|
13
|
+
isRequired,
|
|
14
|
+
isMultiple
|
|
15
|
+
}, value) => {
|
|
16
|
+
if (isRequired) {
|
|
17
|
+
const isUndefined = typeof value === 'undefined';
|
|
18
|
+
const isEmpty = isEmptyString(value) || isMultiple && isEmptyArray(value) || false;
|
|
19
|
+
return isUndefined || isEmpty ? ValidationError.Required : undefined;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
export const getOptionFromValue = (options, value) => {
|
|
24
|
+
if (!Array.isArray(options) || options.length === 0) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
if (isOptionsGrouped(options)) {
|
|
29
|
+
return getUngroupedOptions(options).filter(option => value.includes(option.value));
|
|
30
|
+
}
|
|
31
|
+
return options.filter(option => value.includes(option.value));
|
|
32
|
+
}
|
|
33
|
+
if (isOptionsGrouped(options)) {
|
|
34
|
+
return getUngroupedOptions(options).find(option => value === option.value);
|
|
35
|
+
}
|
|
36
|
+
return options.find(option => value === option.value);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Atlaskit uses final-form to power the form.
|
|
40
|
+
// Final-form will create nesting in the tree if a dot (.) is used in the name of the field.
|
|
41
|
+
// A parent is provided from a <Fieldset /> and is appended to the name here for simplicity
|
|
42
|
+
export const getSafeParentedName = (name, parentName) => {
|
|
43
|
+
if (parentName && name.indexOf(`${parentName}.`) === -1) {
|
|
44
|
+
return `${parentName}.${name}`;
|
|
45
|
+
}
|
|
46
|
+
return name;
|
|
47
|
+
};
|
|
48
|
+
const duplicateFieldRegex = /:[0-9]+$/;
|
|
49
|
+
export const isDuplicateField = key => duplicateFieldRegex.test(key);
|
|
50
|
+
export const getNameFromDuplicateField = key => key.replace(duplicateFieldRegex, '');
|
|
51
|
+
|
|
52
|
+
// An overly cautious parser for sanitizing configuration parameters of UGC
|
|
53
|
+
export const parseParamType = (paramValue, paramField) => {
|
|
54
|
+
if (paramValue && paramField) {
|
|
55
|
+
if (paramField.type === 'string') {
|
|
56
|
+
if (paramField.name === 'types') {
|
|
57
|
+
// Parse types field as an array of valid content types
|
|
58
|
+
const contentTypes = ['page', 'blogpost', 'comment', 'attachment'];
|
|
59
|
+
return paramValue && paramValue.split(',').map(type => type.trim()).filter(type => contentTypes.includes(type));
|
|
60
|
+
}
|
|
61
|
+
if (paramField.name === 'width') {
|
|
62
|
+
return parseFloat(paramValue);
|
|
63
|
+
}
|
|
64
|
+
// Strings are very risky - return empty string in case anything slips through
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
if (ALLOWED_PARAM_TYPES.includes(paramField.type)) {
|
|
68
|
+
// The param types defined here are already parsed and safe to log
|
|
69
|
+
return paramValue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Safety net
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
export const getLoggedParameters = (macroKey, currentParams, macroFields) => {
|
|
76
|
+
// Get the parameters only defined in the allowlist of logged macro/parameter keys
|
|
77
|
+
return Object.keys(currentParams).filter(paramKey => {
|
|
78
|
+
var _ALLOWED_LOGGED_MACRO;
|
|
79
|
+
return (_ALLOWED_LOGGED_MACRO = ALLOWED_LOGGED_MACRO_PARAMS[macroKey]) === null || _ALLOWED_LOGGED_MACRO === void 0 ? void 0 : _ALLOWED_LOGGED_MACRO.includes(paramKey);
|
|
80
|
+
}).reduce((obj, param) => {
|
|
81
|
+
return {
|
|
82
|
+
...obj,
|
|
83
|
+
[param]: parseParamType(currentParams[param], macroFields === null || macroFields === void 0 ? void 0 : macroFields.find(field => field.name === param))
|
|
84
|
+
};
|
|
85
|
+
}, {});
|
|
86
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
|
|
3
|
+
import { Fragment, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
6
|
+
import CheckCircleIcon from '@atlaskit/icon/glyph/check-circle';
|
|
7
|
+
import { G300, N0 } from '@atlaskit/theme/colors';
|
|
8
|
+
import { messages } from './messages';
|
|
9
|
+
const noop = () => {};
|
|
10
|
+
const saveIndicatorWrapperStyles = css({
|
|
11
|
+
display: 'flex',
|
|
12
|
+
justifyContent: 'center'
|
|
13
|
+
});
|
|
14
|
+
const saveIndicatorContentStyles = css({
|
|
15
|
+
position: 'fixed',
|
|
16
|
+
width: '256px',
|
|
17
|
+
bottom: "var(--ds-space-250, 20px)",
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'row',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
padding: `${"var(--ds-space-075, 6px)"} ${"var(--ds-space-150, 12px)"}`,
|
|
22
|
+
background: `var(--ds-surface-overlay, ${N0})`,
|
|
23
|
+
/* E300 */
|
|
24
|
+
boxShadow: `var(--ds-shadow-overlay, ${`0px 8px 12px rgba(9, 30, 66, 0.15), 0px 0px 1px rgba(9, 30, 66, 0.31)`})`,
|
|
25
|
+
borderRadius: '16px'
|
|
26
|
+
});
|
|
27
|
+
const saveIndicatorTextStyles = css({
|
|
28
|
+
paddingLeft: "var(--ds-space-075, 6px)"
|
|
29
|
+
});
|
|
30
|
+
export const SaveIndicator = ({
|
|
31
|
+
children,
|
|
32
|
+
duration,
|
|
33
|
+
visible = true
|
|
34
|
+
}) => {
|
|
35
|
+
const [saving, setSaving] = useState(false);
|
|
36
|
+
const shown = useRef(false);
|
|
37
|
+
const onSaveStarted = useCallback(() => {
|
|
38
|
+
if (!shown.current) {
|
|
39
|
+
setSaving(true);
|
|
40
|
+
shown.current = true;
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (saving) {
|
|
45
|
+
const handleId = setTimeout(() => {
|
|
46
|
+
setSaving(false);
|
|
47
|
+
}, duration);
|
|
48
|
+
return () => clearTimeout(handleId);
|
|
49
|
+
}
|
|
50
|
+
}, [saving, duration]);
|
|
51
|
+
return jsx(Fragment, null, jsx("div", null, children({
|
|
52
|
+
onSaveStarted,
|
|
53
|
+
onSaveEnded: noop
|
|
54
|
+
})), visible && saving && jsx("div", {
|
|
55
|
+
css: saveIndicatorWrapperStyles
|
|
56
|
+
}, jsx("div", {
|
|
57
|
+
css: saveIndicatorContentStyles,
|
|
58
|
+
"data-testid": "save-indicator-content"
|
|
59
|
+
}, jsx(CheckCircleIcon, {
|
|
60
|
+
label: "Saving",
|
|
61
|
+
primaryColor: `var(--ds-icon-success, ${G300})`,
|
|
62
|
+
size: "small"
|
|
63
|
+
}), jsx("span", {
|
|
64
|
+
css: saveIndicatorTextStyles
|
|
65
|
+
}, jsx(FormattedMessage, messages.saveIndicator)))));
|
|
66
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
saveIndicator: {
|
|
4
|
+
id: 'fabric.editor.extensions.config-panel.save-indicator',
|
|
5
|
+
defaultMessage: 'All changes are always autosaved',
|
|
6
|
+
description: 'Message shown to the user to notify to them that we save the changes automatically.'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { closestElement, findNodePosByLocalIds } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
export const getSelectedExtension = (state, searchParent = false) => {
|
|
4
|
+
const {
|
|
5
|
+
inlineExtension,
|
|
6
|
+
extension,
|
|
7
|
+
bodiedExtension,
|
|
8
|
+
multiBodiedExtension
|
|
9
|
+
} = state.schema.nodes;
|
|
10
|
+
const nodeTypes = [extension, bodiedExtension, inlineExtension, multiBodiedExtension];
|
|
11
|
+
return findSelectedNodeOfType(nodeTypes)(state.selection) || searchParent && findParentNodeOfType(nodeTypes)(state.selection) || undefined;
|
|
12
|
+
};
|
|
13
|
+
export const findExtensionWithLocalId = (state, localId) => {
|
|
14
|
+
const selectedExtension = getSelectedExtension(state, true);
|
|
15
|
+
if (!localId) {
|
|
16
|
+
return selectedExtension;
|
|
17
|
+
}
|
|
18
|
+
if (selectedExtension && selectedExtension.node.attrs.localId === localId) {
|
|
19
|
+
return selectedExtension;
|
|
20
|
+
}
|
|
21
|
+
const {
|
|
22
|
+
inlineExtension,
|
|
23
|
+
extension,
|
|
24
|
+
bodiedExtension,
|
|
25
|
+
multiBodiedExtension
|
|
26
|
+
} = state.schema.nodes;
|
|
27
|
+
const nodeTypes = [extension, bodiedExtension, inlineExtension, multiBodiedExtension];
|
|
28
|
+
let matched;
|
|
29
|
+
state.doc.descendants((node, pos) => {
|
|
30
|
+
if (nodeTypes.includes(node.type) && node.attrs.localId === localId) {
|
|
31
|
+
matched = {
|
|
32
|
+
node,
|
|
33
|
+
pos
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return matched;
|
|
38
|
+
};
|
|
39
|
+
export const getSelectedDomElement = (schema, domAtPos, selectedExtensionNode) => {
|
|
40
|
+
const selectedExtensionDomNode = findDomRefAtPos(selectedExtensionNode.pos, domAtPos);
|
|
41
|
+
const isContentExtension = selectedExtensionNode.node.type !== schema.nodes.bodiedExtension;
|
|
42
|
+
return (
|
|
43
|
+
// Content extension can be nested in bodied-extension, the following check is necessary for that case
|
|
44
|
+
(isContentExtension ?
|
|
45
|
+
// Search down
|
|
46
|
+
selectedExtensionDomNode.querySelector('.extension-container') :
|
|
47
|
+
// Try searching up and then down
|
|
48
|
+
closestElement(selectedExtensionDomNode, '.extension-container') || selectedExtensionDomNode.querySelector('.extension-container')) || selectedExtensionDomNode
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
export const getDataConsumerMark = newNode => {
|
|
52
|
+
var _newNode$marks;
|
|
53
|
+
return (_newNode$marks = newNode.marks) === null || _newNode$marks === void 0 ? void 0 : _newNode$marks.find(mark => mark.type.name === 'dataConsumer');
|
|
54
|
+
};
|
|
55
|
+
export const getNodeTypesReferenced = (ids, state) => {
|
|
56
|
+
return findNodePosByLocalIds(state, ids, {
|
|
57
|
+
includeDocNode: true
|
|
58
|
+
}).map(({
|
|
59
|
+
node
|
|
60
|
+
}) => node.type.name);
|
|
61
|
+
};
|
|
62
|
+
export const findNodePosWithLocalId = (state, localId) => {
|
|
63
|
+
const nodes = findNodePosByLocalIds(state, [localId]);
|
|
64
|
+
return nodes.length >= 1 ? nodes[0] : undefined;
|
|
65
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TARGET_SELECTION_SOURCE } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
export { transformSliceToRemoveOpenBodiedExtension } from '@atlaskit/editor-common/transforms';
|
|
8
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { findSelectedNodeOfType, replaceParentNodeOfType, replaceSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
+
import { createExtensionAPI, getEditInLegacyMacroBrowser } from './extension-api';
|
|
11
|
+
import { getPluginState } from './pm-plugins/main';
|
|
12
|
+
import { findExtensionWithLocalId } from './utils';
|
|
13
|
+
export var buildExtensionNode = function buildExtensionNode(type, schema, attrs, content, marks) {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case 'extension':
|
|
16
|
+
return schema.nodes.extension.createChecked(attrs, content, marks);
|
|
17
|
+
case 'inlineExtension':
|
|
18
|
+
return schema.nodes.inlineExtension.createChecked(attrs, content, marks);
|
|
19
|
+
case 'bodiedExtension':
|
|
20
|
+
return schema.nodes.bodiedExtension.create(attrs, content, marks);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export var performNodeUpdate = function performNodeUpdate(editorAnalyticsAPI) {
|
|
24
|
+
return function (type, newAttrs, content, marks, shouldScrollIntoView) {
|
|
25
|
+
return function (_state, _dispatch, view) {
|
|
26
|
+
if (!view) {
|
|
27
|
+
throw Error('EditorView is required to perform node update!');
|
|
28
|
+
}
|
|
29
|
+
// NOTE: `state` and `dispatch` are stale at this point so we need to grab
|
|
30
|
+
// the latest one from `view` @see HOT-93986
|
|
31
|
+
var state = view.state,
|
|
32
|
+
dispatch = view.dispatch;
|
|
33
|
+
var newNode = buildExtensionNode(type, state.schema, newAttrs, content, marks);
|
|
34
|
+
if (!newNode) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
var selection = state.selection,
|
|
38
|
+
schema = state.schema;
|
|
39
|
+
var _schema$nodes = schema.nodes,
|
|
40
|
+
extension = _schema$nodes.extension,
|
|
41
|
+
inlineExtension = _schema$nodes.inlineExtension,
|
|
42
|
+
bodiedExtension = _schema$nodes.bodiedExtension;
|
|
43
|
+
var isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
44
|
+
var extensionState = getPluginState(state);
|
|
45
|
+
var targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
46
|
+
var action = ACTION.UPDATED;
|
|
47
|
+
var tr = state.tr;
|
|
48
|
+
|
|
49
|
+
// When it's a bodiedExtension but not selected
|
|
50
|
+
if (newNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
51
|
+
// Bodied extensions can trigger an update when the cursor is inside which means that there is no node selected.
|
|
52
|
+
// To work around that we replace the parent and create a text selection instead of new node selection
|
|
53
|
+
tr = replaceParentNodeOfType(state.schema.nodes.bodiedExtension, newNode)(tr);
|
|
54
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
55
|
+
tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
|
|
56
|
+
}
|
|
57
|
+
// If any extension is currently selected
|
|
58
|
+
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
59
|
+
tr = replaceSelectedNode(newNode)(tr);
|
|
60
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
61
|
+
tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
62
|
+
}
|
|
63
|
+
// When we loose the selection. This usually happens when Synchrony resets or changes
|
|
64
|
+
// the selection when user is in the middle of updating an extension.
|
|
65
|
+
else if (extensionState.element) {
|
|
66
|
+
var pos = view.posAtDOM(extensionState.element, -1);
|
|
67
|
+
if (pos > -1) {
|
|
68
|
+
tr = tr.replaceWith(pos, pos + (content.size || 0) + 1, newNode);
|
|
69
|
+
tr.setSelection(Selection.near(tr.doc.resolve(pos)));
|
|
70
|
+
targetSelectionSource = TARGET_SELECTION_SOURCE.HTML_ELEMENT;
|
|
71
|
+
} else {
|
|
72
|
+
action = ACTION.ERRORED;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Only scroll if we have anything to update, best to avoid surprise scroll
|
|
77
|
+
if (dispatch && tr.docChanged) {
|
|
78
|
+
var _newNode$attrs = newNode.attrs,
|
|
79
|
+
extensionType = _newNode$attrs.extensionType,
|
|
80
|
+
extensionKey = _newNode$attrs.extensionKey,
|
|
81
|
+
layout = _newNode$attrs.layout,
|
|
82
|
+
localId = _newNode$attrs.localId;
|
|
83
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
84
|
+
action: action,
|
|
85
|
+
actionSubject: ACTION_SUBJECT.EXTENSION,
|
|
86
|
+
actionSubjectId: newNode.type.name,
|
|
87
|
+
eventType: EVENT_TYPE.TRACK,
|
|
88
|
+
attributes: {
|
|
89
|
+
inputMethod: INPUT_METHOD.CONFIG_PANEL,
|
|
90
|
+
extensionType: extensionType,
|
|
91
|
+
extensionKey: extensionKey,
|
|
92
|
+
layout: layout,
|
|
93
|
+
localId: localId,
|
|
94
|
+
selection: tr.selection.toJSON(),
|
|
95
|
+
targetSelectionSource: targetSelectionSource
|
|
96
|
+
}
|
|
97
|
+
})(tr);
|
|
98
|
+
dispatch(shouldScrollIntoView ? tr.scrollIntoView() : tr);
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
var updateExtensionParams = function updateExtensionParams(editorAnalyticsAPI) {
|
|
105
|
+
return function (updateExtension, node, actions) {
|
|
106
|
+
return /*#__PURE__*/function () {
|
|
107
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(state, dispatch, view) {
|
|
108
|
+
var _node$node, attrs, type, content, marks, parameters, newParameters, newAttrs;
|
|
109
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
110
|
+
while (1) switch (_context.prev = _context.next) {
|
|
111
|
+
case 0:
|
|
112
|
+
_node$node = node.node, attrs = _node$node.attrs, type = _node$node.type, content = _node$node.content, marks = _node$node.marks;
|
|
113
|
+
if (state.schema.nodes[type.name]) {
|
|
114
|
+
_context.next = 3;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return _context.abrupt("return", false);
|
|
118
|
+
case 3:
|
|
119
|
+
parameters = attrs.parameters;
|
|
120
|
+
_context.prev = 4;
|
|
121
|
+
_context.next = 7;
|
|
122
|
+
return updateExtension(parameters, actions);
|
|
123
|
+
case 7:
|
|
124
|
+
newParameters = _context.sent;
|
|
125
|
+
if (!newParameters) {
|
|
126
|
+
_context.next = 11;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
newAttrs = _objectSpread(_objectSpread({}, attrs), {}, {
|
|
130
|
+
parameters: _objectSpread(_objectSpread({}, parameters), newParameters)
|
|
131
|
+
});
|
|
132
|
+
return _context.abrupt("return", performNodeUpdate(editorAnalyticsAPI)(type.name, newAttrs, content, marks, true)(state, dispatch, view));
|
|
133
|
+
case 11:
|
|
134
|
+
_context.next = 15;
|
|
135
|
+
break;
|
|
136
|
+
case 13:
|
|
137
|
+
_context.prev = 13;
|
|
138
|
+
_context.t0 = _context["catch"](4);
|
|
139
|
+
case 15:
|
|
140
|
+
return _context.abrupt("return", true);
|
|
141
|
+
case 16:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context.stop();
|
|
144
|
+
}
|
|
145
|
+
}, _callee, null, [[4, 13]]);
|
|
146
|
+
}));
|
|
147
|
+
return function (_x, _x2, _x3) {
|
|
148
|
+
return _ref.apply(this, arguments);
|
|
149
|
+
};
|
|
150
|
+
}();
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// This is to decouple extensions from editor core
|
|
155
|
+
// Ideally in the future we completely deprecate `EditorActions`
|
|
156
|
+
export var editSelectedExtension = function editSelectedExtension(editorActions) {
|
|
157
|
+
var editorView = editorActions._privateGetEditorView();
|
|
158
|
+
var _getPluginState = getPluginState(editorView.state),
|
|
159
|
+
updateExtension = _getPluginState.updateExtension,
|
|
160
|
+
applyChangeToContextPanel = _getPluginState.applyChangeToContextPanel;
|
|
161
|
+
// The analytics API cannot be accessed in this case because
|
|
162
|
+
// we do not have access to the plugin injection API. Rather
|
|
163
|
+
// than change the way this works - we just won't use analytics
|
|
164
|
+
// here for now.
|
|
165
|
+
var editorAnalyticsAPI = undefined;
|
|
166
|
+
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(editorView.state, editorView.dispatch, editorView);
|
|
167
|
+
};
|
|
168
|
+
export var editExtension = function editExtension(macroProvider, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension) {
|
|
169
|
+
return function (state, dispatch, view) {
|
|
170
|
+
if (!view) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
var _getPluginState2 = getPluginState(state),
|
|
174
|
+
localId = _getPluginState2.localId;
|
|
175
|
+
var nodeWithPos = findExtensionWithLocalId(state, localId);
|
|
176
|
+
if (!nodeWithPos) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
var editInLegacyMacroBrowser = getEditInLegacyMacroBrowser({
|
|
180
|
+
view: view,
|
|
181
|
+
macroProvider: macroProvider || undefined,
|
|
182
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
183
|
+
});
|
|
184
|
+
if (updateExtension) {
|
|
185
|
+
updateExtension.then(function (updateMethod) {
|
|
186
|
+
if (updateMethod && view) {
|
|
187
|
+
var actions = createExtensionAPI({
|
|
188
|
+
editorView: view,
|
|
189
|
+
editInLegacyMacroBrowser: editInLegacyMacroBrowser,
|
|
190
|
+
applyChange: applyChangeToContextPanel,
|
|
191
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
192
|
+
});
|
|
193
|
+
updateExtensionParams(editorAnalyticsAPI)(updateMethod, nodeWithPos, actions)(state, dispatch, view);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (!updateMethod && macroProvider) {
|
|
197
|
+
editInLegacyMacroBrowser();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
} else {
|
|
202
|
+
if (!macroProvider) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
editInLegacyMacroBrowser();
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
export var createEditSelectedExtensionAction = function createEditSelectedExtensionAction(_ref2) {
|
|
211
|
+
var editorViewRef = _ref2.editorViewRef,
|
|
212
|
+
editorAnalyticsAPI = _ref2.editorAnalyticsAPI;
|
|
213
|
+
return function () {
|
|
214
|
+
var view = editorViewRef.current;
|
|
215
|
+
if (!view) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
var _getPluginState3 = getPluginState(view.state),
|
|
219
|
+
updateExtension = _getPluginState3.updateExtension,
|
|
220
|
+
applyChangeToContextPanel = _getPluginState3.applyChangeToContextPanel;
|
|
221
|
+
return editExtension(null, applyChangeToContextPanel, editorAnalyticsAPI, updateExtension)(view.state, view.dispatch, view);
|
|
222
|
+
};
|
|
223
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { removeConnectedNodes } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { createCommand } from './plugin-factory';
|
|
8
|
+
import { getSelectedExtension } from './utils';
|
|
9
|
+
|
|
10
|
+
// AFP-2532 TODO: Fix automatic suppressions below
|
|
11
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
12
|
+
|
|
13
|
+
export function updateState(state) {
|
|
14
|
+
return createCommand({
|
|
15
|
+
type: 'UPDATE_STATE',
|
|
16
|
+
data: state
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function setEditingContextToContextPanel(processParametersBefore, processParametersAfter, applyChangeToContextPanel) {
|
|
20
|
+
return createCommand({
|
|
21
|
+
type: 'UPDATE_STATE',
|
|
22
|
+
data: {
|
|
23
|
+
showContextPanel: true,
|
|
24
|
+
processParametersBefore: processParametersBefore,
|
|
25
|
+
processParametersAfter: processParametersAfter
|
|
26
|
+
}
|
|
27
|
+
}, applyChangeToContextPanel);
|
|
28
|
+
}
|
|
29
|
+
export var clearEditingContext = function clearEditingContext(applyChangeToContextPanel) {
|
|
30
|
+
return createCommand({
|
|
31
|
+
type: 'UPDATE_STATE',
|
|
32
|
+
data: {
|
|
33
|
+
showContextPanel: false,
|
|
34
|
+
processParametersBefore: undefined,
|
|
35
|
+
processParametersAfter: undefined
|
|
36
|
+
}
|
|
37
|
+
}, applyChangeToContextPanel);
|
|
38
|
+
};
|
|
39
|
+
export var forceAutoSave = function forceAutoSave(applyChangeToContextPanel) {
|
|
40
|
+
return function (resolve, reject) {
|
|
41
|
+
return createCommand({
|
|
42
|
+
type: 'UPDATE_STATE',
|
|
43
|
+
data: {
|
|
44
|
+
autoSaveResolve: resolve,
|
|
45
|
+
autoSaveReject: reject
|
|
46
|
+
}
|
|
47
|
+
}, applyChangeToContextPanel);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export var updateExtensionLayout = function updateExtensionLayout(layout) {
|
|
51
|
+
return createCommand({
|
|
52
|
+
type: 'UPDATE_STATE',
|
|
53
|
+
data: {
|
|
54
|
+
layout: layout
|
|
55
|
+
}
|
|
56
|
+
}, function (tr, state) {
|
|
57
|
+
var selectedExtension = getSelectedExtension(state, true);
|
|
58
|
+
if (selectedExtension) {
|
|
59
|
+
var trWithNewNodeMarkup = tr.setNodeMarkup(selectedExtension.pos, undefined, _objectSpread(_objectSpread({}, selectedExtension.node.attrs), {}, {
|
|
60
|
+
layout: layout
|
|
61
|
+
}));
|
|
62
|
+
trWithNewNodeMarkup.setMeta('scrollIntoView', false);
|
|
63
|
+
return trWithNewNodeMarkup;
|
|
64
|
+
}
|
|
65
|
+
return tr;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
export var removeExtension = function removeExtension(editorAnalyticsAPI) {
|
|
69
|
+
return createCommand({
|
|
70
|
+
type: 'UPDATE_STATE',
|
|
71
|
+
data: {
|
|
72
|
+
element: undefined
|
|
73
|
+
}
|
|
74
|
+
}, function (tr, state) {
|
|
75
|
+
if (getSelectedExtension(state)) {
|
|
76
|
+
return removeSelectedNode(tr);
|
|
77
|
+
} else {
|
|
78
|
+
return checkAndRemoveExtensionNode(state, tr, editorAnalyticsAPI);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
export var removeDescendantNodes = function removeDescendantNodes(sourceNode) {
|
|
83
|
+
return createCommand({
|
|
84
|
+
type: 'UPDATE_STATE',
|
|
85
|
+
data: {
|
|
86
|
+
element: undefined
|
|
87
|
+
}
|
|
88
|
+
}, function (tr, state) {
|
|
89
|
+
return sourceNode ? removeConnectedNodes(state, sourceNode) : tr;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
export var checkAndRemoveExtensionNode = function checkAndRemoveExtensionNode(state, tr, analyticsApi) {
|
|
93
|
+
var nodeType = state.schema.nodes.bodiedExtension;
|
|
94
|
+
var maybeMBENode = findParentNodeOfType(state.schema.nodes.multiBodiedExtension)(state.selection);
|
|
95
|
+
if (maybeMBENode) {
|
|
96
|
+
nodeType = state.schema.nodes.multiBodiedExtension;
|
|
97
|
+
if (analyticsApi) {
|
|
98
|
+
analyticsApi.attachAnalyticsEvent({
|
|
99
|
+
action: ACTION.DELETED,
|
|
100
|
+
actionSubject: ACTION_SUBJECT.MULTI_BODIED_EXTENSION,
|
|
101
|
+
eventType: EVENT_TYPE.TRACK,
|
|
102
|
+
attributes: {
|
|
103
|
+
extensionType: maybeMBENode.node.attrs.extensionType,
|
|
104
|
+
extensionKey: maybeMBENode.node.attrs.extensionKey,
|
|
105
|
+
localId: maybeMBENode.node.attrs.localId,
|
|
106
|
+
maxFramesCount: maybeMBENode.node.attrs.maxFrames,
|
|
107
|
+
currentFramesCount: maybeMBENode.node.content.childCount
|
|
108
|
+
}
|
|
109
|
+
})(tr);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return removeParentNodeOfType(nodeType)(tr);
|
|
113
|
+
};
|