@atlaskit/editor-plugin-extension 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +26 -0
- package/CHANGELOG.md +10 -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 +48 -6
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { bodiedExtension, extension, extensionFrame, inlineExtension, multiBodiedExtension } from '@atlaskit/adf-schema';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { createEditSelectedExtensionAction } from './actions';
|
|
5
|
+
import { forceAutoSave } from './commands';
|
|
6
|
+
import { getContextPanel } from './context-panel';
|
|
7
|
+
import { createExtensionAPI } from './extension-api';
|
|
8
|
+
import keymapPlugin from './pm-plugins/keymap';
|
|
9
|
+
import { createPlugin as createMacroPlugin } from './pm-plugins/macro';
|
|
10
|
+
import { insertMacroFromMacroBrowser, runMacroAutoConvert } from './pm-plugins/macro/actions';
|
|
11
|
+
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
12
|
+
import { createPlugin as createUniqueIdPlugin } from './pm-plugins/unique-id';
|
|
13
|
+
import { getToolbarConfig } from './toolbar';
|
|
14
|
+
export const extensionPlugin = ({
|
|
15
|
+
config: options = {},
|
|
16
|
+
api
|
|
17
|
+
}) => {
|
|
18
|
+
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$contextPanel3, _api$analytics4, _api$contextPanel4;
|
|
19
|
+
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
20
|
+
//Note: This is a hack to get the editor view reference in the plugin. Copied from table plugin.
|
|
21
|
+
//This is needed to get the current selection in the editor
|
|
22
|
+
const editorViewRef = {
|
|
23
|
+
current: null
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
name: 'extension',
|
|
27
|
+
nodes() {
|
|
28
|
+
const extensionNodes = [{
|
|
29
|
+
name: 'extension',
|
|
30
|
+
node: extension
|
|
31
|
+
}, {
|
|
32
|
+
name: 'bodiedExtension',
|
|
33
|
+
node: bodiedExtension
|
|
34
|
+
}, {
|
|
35
|
+
name: 'inlineExtension',
|
|
36
|
+
node: inlineExtension
|
|
37
|
+
}];
|
|
38
|
+
|
|
39
|
+
// Revert to returning all nodes without local variable, once FF is removed
|
|
40
|
+
if (getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
|
|
41
|
+
extensionNodes.push({
|
|
42
|
+
name: 'extensionFrame',
|
|
43
|
+
node: extensionFrame
|
|
44
|
+
});
|
|
45
|
+
extensionNodes.push({
|
|
46
|
+
name: 'multiBodiedExtension',
|
|
47
|
+
node: multiBodiedExtension
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return extensionNodes;
|
|
51
|
+
},
|
|
52
|
+
getSharedState(state) {
|
|
53
|
+
if (!state) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const pluginState = pluginKey.getState(state);
|
|
57
|
+
return {
|
|
58
|
+
showContextPanel: pluginState === null || pluginState === void 0 ? void 0 : pluginState.showContextPanel
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
pmPlugins() {
|
|
62
|
+
return [{
|
|
63
|
+
name: 'extension',
|
|
64
|
+
plugin: ({
|
|
65
|
+
dispatch,
|
|
66
|
+
providerFactory,
|
|
67
|
+
portalProviderAPI,
|
|
68
|
+
eventDispatcher
|
|
69
|
+
}) => {
|
|
70
|
+
const extensionHandlers = options.extensionHandlers || {};
|
|
71
|
+
return createPlugin(dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, api, options.useLongPressSelection, {
|
|
72
|
+
appearance: options.appearance
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
name: 'extensionKeymap',
|
|
77
|
+
plugin: () => {
|
|
78
|
+
var _api$contextPanel;
|
|
79
|
+
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange);
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
name: 'extensionUniqueId',
|
|
83
|
+
plugin: () => createUniqueIdPlugin()
|
|
84
|
+
}, {
|
|
85
|
+
name: 'extensionEditorViewRef',
|
|
86
|
+
plugin: () => {
|
|
87
|
+
return new SafePlugin({
|
|
88
|
+
view: editorView => {
|
|
89
|
+
// Do not cleanup the editorViewRef on destroy
|
|
90
|
+
// because some functions may point to a stale
|
|
91
|
+
// reference and this means we will return null.
|
|
92
|
+
// EditorView is assumed to be stable so we do not need to
|
|
93
|
+
// cleanup.
|
|
94
|
+
// See: #hot-106316
|
|
95
|
+
editorViewRef.current = editorView;
|
|
96
|
+
return {};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
name: 'macro',
|
|
102
|
+
plugin: ({
|
|
103
|
+
dispatch,
|
|
104
|
+
providerFactory
|
|
105
|
+
}) => createMacroPlugin(dispatch, providerFactory)
|
|
106
|
+
}];
|
|
107
|
+
},
|
|
108
|
+
actions: {
|
|
109
|
+
api: () => {
|
|
110
|
+
var _api$contextPanel2, _api$analytics;
|
|
111
|
+
return createExtensionAPI({
|
|
112
|
+
editorView: editorViewRef.current,
|
|
113
|
+
applyChange: api === null || api === void 0 ? void 0 : (_api$contextPanel2 = api.contextPanel) === null || _api$contextPanel2 === void 0 ? void 0 : _api$contextPanel2.actions.applyChange,
|
|
114
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
insertMacroFromMacroBrowser: insertMacroFromMacroBrowser(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
118
|
+
editSelectedExtension: createEditSelectedExtensionAction({
|
|
119
|
+
editorViewRef,
|
|
120
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions
|
|
121
|
+
}),
|
|
122
|
+
runMacroAutoConvert,
|
|
123
|
+
forceAutoSave
|
|
124
|
+
},
|
|
125
|
+
pluginsOptions: {
|
|
126
|
+
floatingToolbar: getToolbarConfig({
|
|
127
|
+
breakoutEnabled: options.breakoutEnabled,
|
|
128
|
+
hoverDecoration: api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration,
|
|
129
|
+
applyChangeToContextPanel: api === null || api === void 0 ? void 0 : (_api$contextPanel3 = api.contextPanel) === null || _api$contextPanel3 === void 0 ? void 0 : _api$contextPanel3.actions.applyChange,
|
|
130
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions
|
|
131
|
+
}),
|
|
132
|
+
contextPanel: getContextPanel(() => {
|
|
133
|
+
var _editorViewRef$curren;
|
|
134
|
+
return (_editorViewRef$curren = editorViewRef.current) !== null && _editorViewRef$curren !== void 0 ? _editorViewRef$curren : undefined;
|
|
135
|
+
})(options.allowAutoSave, featureFlags, api === null || api === void 0 ? void 0 : (_api$contextPanel4 = api.contextPanel) === null || _api$contextPanel4 === void 0 ? void 0 : _api$contextPanel4.actions.applyChange)
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { bindKeymapWithCommand, escape } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
+
import { clearEditingContext } from '../commands';
|
|
4
|
+
import { getPluginState } from './main';
|
|
5
|
+
export default function keymapPlugin(applyChange) {
|
|
6
|
+
const list = {};
|
|
7
|
+
bindKeymapWithCommand(escape.common, (state, dispatch) => {
|
|
8
|
+
const extensionState = getPluginState(state);
|
|
9
|
+
if (!extensionState.showContextPanel) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return clearEditingContext(applyChange)(state, dispatch);
|
|
13
|
+
}, list);
|
|
14
|
+
return keymap(list);
|
|
15
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TARGET_SELECTION_SOURCE } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { normaliseNestedLayout } from '@atlaskit/editor-common/insert';
|
|
4
|
+
import { getValidNode } from '@atlaskit/editor-common/validator';
|
|
5
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { findSelectedNodeOfType, replaceParentNodeOfType, replaceSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { getPluginState as getExtensionPluginState } from '../../plugin-factory';
|
|
8
|
+
import { pluginKey } from './plugin-key';
|
|
9
|
+
export const insertMacroFromMacroBrowser = editorAnalyticsAPI => (macroProvider, macroNode, isEditing) => async view => {
|
|
10
|
+
if (!macroProvider) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// opens MacroBrowser for editing "macroNode" if passed in
|
|
15
|
+
const newMacro = await macroProvider.openMacroBrowser(macroNode);
|
|
16
|
+
if (newMacro && macroNode) {
|
|
17
|
+
const {
|
|
18
|
+
state,
|
|
19
|
+
dispatch
|
|
20
|
+
} = view;
|
|
21
|
+
const currentLayout = macroNode && macroNode.attrs.layout || 'default';
|
|
22
|
+
const node = resolveMacro(newMacro, state, {
|
|
23
|
+
layout: currentLayout
|
|
24
|
+
});
|
|
25
|
+
if (!node) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
selection,
|
|
30
|
+
schema
|
|
31
|
+
} = state;
|
|
32
|
+
const {
|
|
33
|
+
extension,
|
|
34
|
+
inlineExtension,
|
|
35
|
+
bodiedExtension
|
|
36
|
+
} = schema.nodes;
|
|
37
|
+
const extensionState = getExtensionPluginState(state);
|
|
38
|
+
let targetSelectionSource = TARGET_SELECTION_SOURCE.CURRENT_SELECTION;
|
|
39
|
+
let {
|
|
40
|
+
tr
|
|
41
|
+
} = state;
|
|
42
|
+
const isBodiedExtensionSelected = !!findSelectedNodeOfType([bodiedExtension])(selection);
|
|
43
|
+
|
|
44
|
+
// When it's a bodiedExtension but not selected
|
|
45
|
+
if (macroNode.type === bodiedExtension && !isBodiedExtensionSelected) {
|
|
46
|
+
// `isEditing` is `false` when we are inserting from insert-block toolbar
|
|
47
|
+
tr = isEditing ? replaceParentNodeOfType(bodiedExtension, node)(tr) : safeInsert(node)(tr);
|
|
48
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
49
|
+
tr.setSelection(TextSelection.create(tr.doc, state.selection.anchor));
|
|
50
|
+
}
|
|
51
|
+
// If any extension is currently selected
|
|
52
|
+
else if (findSelectedNodeOfType([extension, bodiedExtension, inlineExtension])(selection)) {
|
|
53
|
+
tr = replaceSelectedNode(node)(tr);
|
|
54
|
+
// Replacing selected node doesn't update the selection. `selection.node` still returns the old node
|
|
55
|
+
tr.setSelection(NodeSelection.create(tr.doc, tr.mapping.map(state.selection.anchor)));
|
|
56
|
+
}
|
|
57
|
+
// When we loose the selection. This usually happens when Synchrony resets or changes
|
|
58
|
+
// the selection when user is in the middle of updating an extension.
|
|
59
|
+
else if (extensionState.element) {
|
|
60
|
+
const pos = view.posAtDOM(extensionState.element, -1);
|
|
61
|
+
if (pos > -1) {
|
|
62
|
+
tr = tr.replaceWith(pos, pos + macroNode.nodeSize, node);
|
|
63
|
+
tr.setSelection(Selection.near(tr.doc.resolve(pos)));
|
|
64
|
+
targetSelectionSource = TARGET_SELECTION_SOURCE.HTML_ELEMENT;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Only scroll if we have anything to update, best to avoid surprise scroll
|
|
69
|
+
if (dispatch && tr.docChanged) {
|
|
70
|
+
const {
|
|
71
|
+
extensionType,
|
|
72
|
+
extensionKey,
|
|
73
|
+
layout,
|
|
74
|
+
localId
|
|
75
|
+
} = macroNode.attrs;
|
|
76
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
77
|
+
action: ACTION.UPDATED,
|
|
78
|
+
actionSubject: ACTION_SUBJECT.EXTENSION,
|
|
79
|
+
actionSubjectId: macroNode.type.name,
|
|
80
|
+
eventType: EVENT_TYPE.TRACK,
|
|
81
|
+
attributes: {
|
|
82
|
+
inputMethod: isEditing ? INPUT_METHOD.MACRO_BROWSER : INPUT_METHOD.TOOLBAR,
|
|
83
|
+
extensionType,
|
|
84
|
+
extensionKey,
|
|
85
|
+
layout,
|
|
86
|
+
localId,
|
|
87
|
+
selection: tr.selection.toJSON(),
|
|
88
|
+
targetSelectionSource
|
|
89
|
+
}
|
|
90
|
+
})(tr);
|
|
91
|
+
dispatch(tr.scrollIntoView());
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
export const resolveMacro = (macro, state, optionalAttrs) => {
|
|
98
|
+
if (!macro || !state) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const {
|
|
102
|
+
schema
|
|
103
|
+
} = state;
|
|
104
|
+
const {
|
|
105
|
+
type,
|
|
106
|
+
attrs
|
|
107
|
+
} = getValidNode(macro, schema);
|
|
108
|
+
let node = null;
|
|
109
|
+
if (type === 'extension') {
|
|
110
|
+
node = schema.nodes.extension.create({
|
|
111
|
+
...attrs,
|
|
112
|
+
...optionalAttrs
|
|
113
|
+
});
|
|
114
|
+
} else if (type === 'bodiedExtension') {
|
|
115
|
+
node = schema.nodes.bodiedExtension.create({
|
|
116
|
+
...attrs,
|
|
117
|
+
...optionalAttrs
|
|
118
|
+
}, schema.nodeFromJSON(macro).content);
|
|
119
|
+
} else if (type === 'inlineExtension') {
|
|
120
|
+
node = schema.nodes.inlineExtension.create(attrs);
|
|
121
|
+
}
|
|
122
|
+
return node && normaliseNestedLayout(state, node);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// gets the macroProvider from the state and tries to autoConvert a given text
|
|
126
|
+
export const runMacroAutoConvert = (state, text) => {
|
|
127
|
+
const macroPluginState = pluginKey.getState(state);
|
|
128
|
+
const macroProvider = macroPluginState && macroPluginState.macroProvider;
|
|
129
|
+
if (!macroProvider || !macroProvider.autoConvert) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const macroAttributes = macroProvider.autoConvert(text);
|
|
133
|
+
if (!macroAttributes) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// decides which kind of macro to render (inline|bodied|bodyless)
|
|
138
|
+
return resolveMacro(macroAttributes, state);
|
|
139
|
+
};
|
|
140
|
+
export const setMacroProvider = provider => async view => {
|
|
141
|
+
let resolvedProvider;
|
|
142
|
+
try {
|
|
143
|
+
resolvedProvider = await provider;
|
|
144
|
+
assert(resolvedProvider && resolvedProvider.openMacroBrowser, `MacroProvider promise did not resolve to a valid instance of MacroProvider - ${resolvedProvider}`);
|
|
145
|
+
} catch (err) {
|
|
146
|
+
resolvedProvider = null;
|
|
147
|
+
}
|
|
148
|
+
view.dispatch(view.state.tr.setMeta(pluginKey, {
|
|
149
|
+
macroProvider: resolvedProvider
|
|
150
|
+
}));
|
|
151
|
+
return true;
|
|
152
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { setMacroProvider } from './actions';
|
|
3
|
+
import { pluginKey } from './plugin-key';
|
|
4
|
+
export { insertMacroFromMacroBrowser, resolveMacro, runMacroAutoConvert, setMacroProvider } from './actions';
|
|
5
|
+
export const createPlugin = (dispatch, providerFactory) => new SafePlugin({
|
|
6
|
+
state: {
|
|
7
|
+
init: () => ({
|
|
8
|
+
macroProvider: null
|
|
9
|
+
}),
|
|
10
|
+
apply(tr, state) {
|
|
11
|
+
const meta = tr.getMeta(pluginKey);
|
|
12
|
+
if (meta) {
|
|
13
|
+
const newState = {
|
|
14
|
+
...state,
|
|
15
|
+
...meta
|
|
16
|
+
};
|
|
17
|
+
dispatch(pluginKey, newState);
|
|
18
|
+
return newState;
|
|
19
|
+
}
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
key: pluginKey,
|
|
24
|
+
view: view => {
|
|
25
|
+
const handleProvider = (_name, provider) => provider && setMacroProvider(provider)(view);
|
|
26
|
+
// make sure editable DOM node is mounted
|
|
27
|
+
if (view.dom.parentNode) {
|
|
28
|
+
providerFactory.subscribe('macroProvider', handleProvider);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
destroy() {
|
|
32
|
+
providerFactory.unsubscribe('macroProvider', handleProvider);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ExtensionNodeView } from '@atlaskit/editor-common/extensibility';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { createSelectionClickHandler, isSelectionAtEndOfNode, isSelectionAtStartOfNode } from '@atlaskit/editor-common/selection';
|
|
4
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { clearEditingContext, updateState } from '../commands';
|
|
7
|
+
import { createCommand, createPluginState, getPluginState } from '../plugin-factory';
|
|
8
|
+
import { pluginKey } from '../plugin-key';
|
|
9
|
+
import { getSelectedDomElement, getSelectedExtension } from '../utils';
|
|
10
|
+
import { updateEditButton } from './utils';
|
|
11
|
+
const shouldShowEditButton = (extensionHandler, extensionProvider) => {
|
|
12
|
+
const usesLegacyMacroBrowser = !extensionHandler && !extensionProvider || typeof extensionHandler === 'function';
|
|
13
|
+
const usesModernUpdateMethod = typeof extensionHandler === 'object' && typeof extensionHandler.update === 'function';
|
|
14
|
+
if (usesLegacyMacroBrowser || usesModernUpdateMethod) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
const getUpdateExtensionPromise = async (view, extensionHandler, extensionProvider) => {
|
|
20
|
+
if (extensionHandler && typeof extensionHandler === 'object') {
|
|
21
|
+
// Old API with the `update` function
|
|
22
|
+
return extensionHandler.update;
|
|
23
|
+
} else if (extensionProvider) {
|
|
24
|
+
// New API with or without the `update` function, we don't know at this point
|
|
25
|
+
const updateMethod = await updateEditButton(view, extensionProvider);
|
|
26
|
+
if (updateMethod) {
|
|
27
|
+
return updateMethod;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
throw new Error('No update method available');
|
|
31
|
+
};
|
|
32
|
+
export const createExtensionProviderHandler = view => async (name, provider) => {
|
|
33
|
+
if (name === 'extensionProvider' && provider) {
|
|
34
|
+
try {
|
|
35
|
+
const extensionProvider = await provider;
|
|
36
|
+
updateState({
|
|
37
|
+
extensionProvider
|
|
38
|
+
})(view.state, view.dispatch);
|
|
39
|
+
await updateEditButton(view, extensionProvider);
|
|
40
|
+
} catch {
|
|
41
|
+
updateState({
|
|
42
|
+
extensionProvider: undefined
|
|
43
|
+
})(view.state, view.dispatch);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const createContextIdentifierProviderHandler = view => async (name, provider) => {
|
|
48
|
+
if (name === 'contextIdentifierProvider' && provider) {
|
|
49
|
+
try {
|
|
50
|
+
const contextIdentifierProvider = await provider;
|
|
51
|
+
updateState({
|
|
52
|
+
contextIdentifierProvider
|
|
53
|
+
})(view.state, view.dispatch);
|
|
54
|
+
} catch {
|
|
55
|
+
updateState({
|
|
56
|
+
contextIdentifierProvider: undefined
|
|
57
|
+
})(view.state, view.dispatch);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export const handleUpdate = ({
|
|
62
|
+
view,
|
|
63
|
+
prevState,
|
|
64
|
+
domAtPos,
|
|
65
|
+
extensionHandlers,
|
|
66
|
+
applyChange
|
|
67
|
+
}) => {
|
|
68
|
+
const {
|
|
69
|
+
state,
|
|
70
|
+
dispatch
|
|
71
|
+
} = view;
|
|
72
|
+
const {
|
|
73
|
+
element,
|
|
74
|
+
localId,
|
|
75
|
+
extensionProvider,
|
|
76
|
+
showContextPanel,
|
|
77
|
+
showEditButton
|
|
78
|
+
} = getPluginState(state);
|
|
79
|
+
|
|
80
|
+
// This fetches the selected extension node, either by keyboard selection or click for all types of extensions
|
|
81
|
+
const selectedExtension = getSelectedExtension(state, true);
|
|
82
|
+
if (!selectedExtension) {
|
|
83
|
+
if (showContextPanel) {
|
|
84
|
+
clearEditingContext(applyChange)(state, dispatch);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const {
|
|
89
|
+
node
|
|
90
|
+
} = selectedExtension;
|
|
91
|
+
const newElement = getSelectedDomElement(state.schema, domAtPos, selectedExtension);
|
|
92
|
+
|
|
93
|
+
// In some cases, showEditButton can be stale and the edit button doesn't show - @see ED-15285
|
|
94
|
+
// To be safe, we update the showEditButton state here
|
|
95
|
+
const shouldUpdateEditButton = !showEditButton && extensionProvider && element === newElement && !getSelectedExtension(prevState, true);
|
|
96
|
+
const isNewNodeSelected = node.attrs.localId ? localId !== node.attrs.localId :
|
|
97
|
+
// This is the current assumption and it's wrong but we are keeping it
|
|
98
|
+
// as fallback in case we need to turn off `allowLocalIdGeneration`
|
|
99
|
+
element !== newElement;
|
|
100
|
+
if (isNewNodeSelected || shouldUpdateEditButton) {
|
|
101
|
+
if (showContextPanel) {
|
|
102
|
+
clearEditingContext(applyChange)(state, dispatch);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const {
|
|
106
|
+
extensionType
|
|
107
|
+
} = node.attrs;
|
|
108
|
+
const extensionHandler = extensionHandlers[extensionType];
|
|
109
|
+
|
|
110
|
+
// showEditButton might change async based on results from extension providers
|
|
111
|
+
const showEditButton = shouldShowEditButton(extensionHandler, extensionProvider);
|
|
112
|
+
const updateExtension = getUpdateExtensionPromise(view, extensionHandler, extensionProvider).catch(() => {
|
|
113
|
+
// do nothing;
|
|
114
|
+
});
|
|
115
|
+
updateState({
|
|
116
|
+
localId: node.attrs.localId,
|
|
117
|
+
showContextPanel: false,
|
|
118
|
+
element: newElement,
|
|
119
|
+
showEditButton,
|
|
120
|
+
updateExtension
|
|
121
|
+
})(state, dispatch);
|
|
122
|
+
}
|
|
123
|
+
// New DOM element doesn't necessarily mean it's a new Node
|
|
124
|
+
else if (element !== newElement) {
|
|
125
|
+
updateState({
|
|
126
|
+
element: newElement
|
|
127
|
+
})(state, dispatch);
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
const createPlugin = (dispatch, providerFactory, extensionHandlers, portalProviderAPI, eventDispatcher, pluginInjectionApi, useLongPressSelection = false, options = {}) => {
|
|
132
|
+
var _pluginInjectionApi$c, _pluginInjectionApi$c2;
|
|
133
|
+
const state = createPluginState(dispatch, {
|
|
134
|
+
showEditButton: false,
|
|
135
|
+
showContextPanel: false,
|
|
136
|
+
applyChangeToContextPanel: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.applyChange
|
|
137
|
+
});
|
|
138
|
+
const extensionNodeViewOptions = {
|
|
139
|
+
appearance: options.appearance
|
|
140
|
+
};
|
|
141
|
+
return new SafePlugin({
|
|
142
|
+
state,
|
|
143
|
+
view: editorView => {
|
|
144
|
+
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
145
|
+
const extensionProviderHandler = createExtensionProviderHandler(editorView);
|
|
146
|
+
const contextIdentificationProviderHandler = createContextIdentifierProviderHandler(editorView);
|
|
147
|
+
providerFactory.subscribe('extensionProvider', extensionProviderHandler);
|
|
148
|
+
providerFactory.subscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
|
|
149
|
+
return {
|
|
150
|
+
update: (view, prevState) => {
|
|
151
|
+
var _pluginInjectionApi$c3;
|
|
152
|
+
handleUpdate({
|
|
153
|
+
view,
|
|
154
|
+
prevState,
|
|
155
|
+
domAtPos,
|
|
156
|
+
extensionHandlers,
|
|
157
|
+
applyChange: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c3 = pluginInjectionApi.contextPanel) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.actions.applyChange
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
destroy: () => {
|
|
161
|
+
providerFactory.unsubscribe('extensionProvider', extensionProviderHandler);
|
|
162
|
+
providerFactory.unsubscribe('contextIdentificationProvider', contextIdentificationProviderHandler);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
key: pluginKey,
|
|
167
|
+
props: {
|
|
168
|
+
handleDOMEvents: {
|
|
169
|
+
/**
|
|
170
|
+
* ED-18072 - Cannot shift + arrow past bodied extension if it is not empty.
|
|
171
|
+
* This code is to handle the case where the selection starts inside or on the node and the user is trying to shift + arrow.
|
|
172
|
+
* For other part of the solution see code in: packages/editor/editor-core/src/plugins/selection/pm-plugins/events/keydown.ts
|
|
173
|
+
*/
|
|
174
|
+
keydown: (view, event) => {
|
|
175
|
+
if (event instanceof KeyboardEvent && event.shiftKey && ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
176
|
+
const {
|
|
177
|
+
schema,
|
|
178
|
+
selection,
|
|
179
|
+
selection: {
|
|
180
|
+
$head
|
|
181
|
+
},
|
|
182
|
+
doc,
|
|
183
|
+
tr
|
|
184
|
+
} = view.state;
|
|
185
|
+
const {
|
|
186
|
+
bodiedExtension
|
|
187
|
+
} = schema.nodes;
|
|
188
|
+
if (selection instanceof TextSelection || selection instanceof NodeSelection) {
|
|
189
|
+
const maybeBodiedExtension = selection instanceof TextSelection ? findParentNodeOfTypeClosestToPos($head, bodiedExtension) : findSelectedNodeOfType(bodiedExtension)(selection);
|
|
190
|
+
if (maybeBodiedExtension) {
|
|
191
|
+
const end = maybeBodiedExtension.pos + maybeBodiedExtension.node.nodeSize;
|
|
192
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowLeft' && isSelectionAtStartOfNode($head, maybeBodiedExtension)) {
|
|
193
|
+
const anchor = end + 1;
|
|
194
|
+
|
|
195
|
+
// an offset is used here so that left arrow selects the first character before the node (consistent with arrow right)
|
|
196
|
+
const headOffset = event.key === 'ArrowLeft' ? -1 : 0;
|
|
197
|
+
const head = maybeBodiedExtension.pos + headOffset;
|
|
198
|
+
const newSelection = TextSelection.create(doc, Math.max(anchor, selection.anchor), head);
|
|
199
|
+
view.dispatch(tr.setSelection(newSelection));
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowRight' && isSelectionAtEndOfNode($head, maybeBodiedExtension)) {
|
|
203
|
+
const anchor = maybeBodiedExtension.pos - 1;
|
|
204
|
+
const head = end + 1;
|
|
205
|
+
const newSelection = TextSelection.create(doc, Math.min(anchor, selection.anchor), head);
|
|
206
|
+
view.dispatch(tr.setSelection(newSelection));
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
nodeViews: {
|
|
216
|
+
// WARNING: referentiality-plugin also creates these nodeviews
|
|
217
|
+
extension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
218
|
+
// WARNING: referentiality-plugin also creates these nodeviews
|
|
219
|
+
bodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
220
|
+
// WARNING: referentiality-plugin also creates these nodeviews
|
|
221
|
+
inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
222
|
+
multiBodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
|
|
223
|
+
},
|
|
224
|
+
handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], target => !target.closest('.extension-content'), {
|
|
225
|
+
useLongPressSelection
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
export { pluginKey, createPlugin, createCommand, getPluginState };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { uuid } from '@atlaskit/adf-schema';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
|
|
4
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
const pluginKey = new PluginKey('extensionUniqueIdPlugin');
|
|
6
|
+
const createPlugin = () => new SafePlugin({
|
|
7
|
+
// TODO: @see ED-8839
|
|
8
|
+
appendTransaction: (transactions, _oldState, newState) => {
|
|
9
|
+
const tr = newState.tr;
|
|
10
|
+
const selectionBookmark = tr.selection.getBookmark();
|
|
11
|
+
let modified = false;
|
|
12
|
+
const {
|
|
13
|
+
extension,
|
|
14
|
+
bodiedExtension,
|
|
15
|
+
inlineExtension,
|
|
16
|
+
multiBodiedExtension
|
|
17
|
+
} = newState.schema.nodes;
|
|
18
|
+
const extensionTypes = new Set([extension, bodiedExtension, inlineExtension, multiBodiedExtension]);
|
|
19
|
+
const idsObserved = new Set();
|
|
20
|
+
transactions.forEach(transaction => {
|
|
21
|
+
if (!transaction.docChanged) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const isAddingExtension = transaction.steps.some(step => stepAddsOneOf(step, extensionTypes));
|
|
25
|
+
if (isAddingExtension) {
|
|
26
|
+
// Can't simply look at changed nodes, as we could be adding an extension
|
|
27
|
+
newState.doc.descendants((node, pos) => {
|
|
28
|
+
const localId = node.attrs.localId;
|
|
29
|
+
|
|
30
|
+
// Dealing with an extension - make sure it's a unique ID
|
|
31
|
+
if (!!node.type && extensionTypes.has(node.type)) {
|
|
32
|
+
if (localId && !idsObserved.has(localId)) {
|
|
33
|
+
idsObserved.add(localId);
|
|
34
|
+
// Also add a localId if it happens to not have one,
|
|
35
|
+
} else if (!localId || idsObserved.has(localId)) {
|
|
36
|
+
modified = true;
|
|
37
|
+
tr.setNodeMarkup(pos, undefined, {
|
|
38
|
+
...node.attrs,
|
|
39
|
+
localId: uuid.generate()
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* If it's a multiBodiedExtension or bodiedExtension, we'll need to keep digging;
|
|
44
|
+
* since we can have more extension nodes within the contents of that
|
|
45
|
+
*/
|
|
46
|
+
if ([multiBodiedExtension, bodiedExtension].includes(node.type)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Otherwise continue traversing, we can encounter extensions nested in
|
|
54
|
+
* expands/bodiedExtensions
|
|
55
|
+
*/
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (modified) {
|
|
61
|
+
// We want to restore to the original selection but w/o applying the mapping
|
|
62
|
+
// @see https://github.com/ProseMirror/prosemirror/issues/645
|
|
63
|
+
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
},
|
|
67
|
+
key: pluginKey
|
|
68
|
+
});
|
|
69
|
+
export { createPlugin };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getExtensionModuleNode } from '@atlaskit/editor-common/extensions';
|
|
2
|
+
import { updateState } from '../commands';
|
|
3
|
+
import { getSelectedExtension } from '../utils';
|
|
4
|
+
const maybeGetUpdateMethodFromExtensionProvider = async (view, extensionProvider) => {
|
|
5
|
+
const nodeWithPos = getSelectedExtension(view.state, true);
|
|
6
|
+
if (!nodeWithPos) {
|
|
7
|
+
throw new Error('There is no selection');
|
|
8
|
+
}
|
|
9
|
+
const {
|
|
10
|
+
extensionType,
|
|
11
|
+
extensionKey
|
|
12
|
+
} = nodeWithPos.node.attrs;
|
|
13
|
+
const extensionModuleNode = await getExtensionModuleNode(extensionProvider, extensionType, extensionKey);
|
|
14
|
+
const newNodeWithPos = getSelectedExtension(view.state, true);
|
|
15
|
+
if (newNodeWithPos && newNodeWithPos.node.attrs.extensionType === extensionType && newNodeWithPos.node.attrs.extensionKey === extensionKey && newNodeWithPos.pos === nodeWithPos.pos && extensionModuleNode) {
|
|
16
|
+
return extensionModuleNode.update;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const updateEditButton = async (view, extensionProvider) => {
|
|
20
|
+
try {
|
|
21
|
+
const updateMethod = await maybeGetUpdateMethodFromExtensionProvider(view, extensionProvider);
|
|
22
|
+
updateState({
|
|
23
|
+
showEditButton: !!updateMethod,
|
|
24
|
+
updateExtension: updateMethod && Promise.resolve(updateMethod) || undefined
|
|
25
|
+
})(view.state, view.dispatch);
|
|
26
|
+
return updateMethod;
|
|
27
|
+
} catch {
|
|
28
|
+
// this exception is not important for this case, fail silently
|
|
29
|
+
}
|
|
30
|
+
};
|