@atlaskit/editor-common 72.4.0 → 72.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/cjs/analytics/analytics-queue.js +79 -0
  3. package/dist/cjs/analytics/fire-analytics-event.js +36 -0
  4. package/dist/cjs/analytics/index.js +15 -1
  5. package/dist/cjs/analytics/types/enums.js +4 -0
  6. package/dist/cjs/analytics/utils.js +16 -0
  7. package/dist/cjs/hooks/index.js +20 -0
  8. package/dist/cjs/hooks/useConstructor.js +22 -0
  9. package/dist/cjs/hooks/usePreviousState.js +23 -0
  10. package/dist/cjs/keymaps/index.js +1 -1
  11. package/dist/cjs/styles/index.js +6 -0
  12. package/dist/cjs/styles/shared/table.js +3 -1
  13. package/dist/cjs/ui/DropList/index.js +1 -1
  14. package/dist/cjs/ui/index.js +6 -0
  15. package/dist/cjs/ui-color/ColorPalette/Color/index.js +2 -3
  16. package/dist/cjs/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -1
  17. package/dist/cjs/ui-color/ColorPalette/index.js +9 -11
  18. package/dist/cjs/ui-color/ColorPalette/utils.js +42 -0
  19. package/dist/cjs/ui-color/index.js +25 -0
  20. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +141 -0
  21. package/dist/cjs/ui-menu/{MenuArrowKeyNavigationProvider → ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider}/index.js +15 -0
  22. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/index.js +29 -0
  23. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/types.js +12 -0
  24. package/dist/cjs/ui-menu/Dropdown/index.js +5 -7
  25. package/dist/cjs/ui-menu/DropdownMenu/index.js +50 -24
  26. package/dist/cjs/ui-menu/ToolbarButton/index.js +3 -1
  27. package/dist/cjs/ui-menu/index.js +21 -0
  28. package/dist/cjs/utils/analytics.js +5 -1
  29. package/dist/cjs/utils/index.js +6 -0
  30. package/dist/cjs/utils/referentiality.js +29 -15
  31. package/dist/cjs/version.json +1 -1
  32. package/dist/es2019/analytics/analytics-queue.js +53 -0
  33. package/dist/es2019/analytics/fire-analytics-event.js +27 -0
  34. package/dist/es2019/analytics/index.js +3 -1
  35. package/dist/es2019/analytics/types/enums.js +4 -0
  36. package/dist/es2019/analytics/utils.js +4 -0
  37. package/dist/es2019/hooks/index.js +2 -0
  38. package/dist/es2019/hooks/useConstructor.js +17 -0
  39. package/dist/es2019/hooks/usePreviousState.js +18 -0
  40. package/dist/es2019/keymaps/index.js +1 -1
  41. package/dist/es2019/styles/index.js +1 -1
  42. package/dist/es2019/styles/shared/table.js +1 -0
  43. package/dist/es2019/ui/DropList/index.js +1 -1
  44. package/dist/es2019/ui/index.js +1 -1
  45. package/dist/es2019/ui-color/ColorPalette/Color/index.js +7 -4
  46. package/dist/es2019/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -1
  47. package/dist/es2019/ui-color/ColorPalette/index.js +9 -11
  48. package/dist/es2019/ui-color/ColorPalette/utils.js +31 -0
  49. package/dist/es2019/ui-color/index.js +1 -0
  50. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +132 -0
  51. package/dist/es2019/ui-menu/{MenuArrowKeyNavigationProvider → ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider}/index.js +16 -1
  52. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/index.js +21 -0
  53. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/types.js +5 -0
  54. package/dist/es2019/ui-menu/Dropdown/index.js +5 -7
  55. package/dist/es2019/ui-menu/DropdownMenu/index.js +46 -23
  56. package/dist/es2019/ui-menu/ToolbarButton/index.js +3 -1
  57. package/dist/es2019/ui-menu/index.js +3 -0
  58. package/dist/es2019/utils/analytics.js +1 -0
  59. package/dist/es2019/utils/index.js +1 -1
  60. package/dist/es2019/utils/referentiality.js +19 -15
  61. package/dist/es2019/version.json +1 -1
  62. package/dist/esm/analytics/analytics-queue.js +71 -0
  63. package/dist/esm/analytics/fire-analytics-event.js +29 -0
  64. package/dist/esm/analytics/index.js +3 -1
  65. package/dist/esm/analytics/types/enums.js +4 -0
  66. package/dist/esm/analytics/utils.js +9 -0
  67. package/dist/esm/hooks/index.js +2 -0
  68. package/dist/esm/hooks/useConstructor.js +17 -0
  69. package/dist/esm/hooks/usePreviousState.js +18 -0
  70. package/dist/esm/keymaps/index.js +1 -1
  71. package/dist/esm/styles/index.js +1 -1
  72. package/dist/esm/styles/shared/table.js +1 -0
  73. package/dist/esm/ui/DropList/index.js +1 -1
  74. package/dist/esm/ui/index.js +1 -1
  75. package/dist/esm/ui-color/ColorPalette/Color/index.js +2 -3
  76. package/dist/esm/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -1
  77. package/dist/esm/ui-color/ColorPalette/index.js +9 -11
  78. package/dist/esm/ui-color/ColorPalette/utils.js +32 -0
  79. package/dist/esm/ui-color/index.js +1 -0
  80. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.js +131 -0
  81. package/dist/esm/ui-menu/{MenuArrowKeyNavigationProvider → ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider}/index.js +16 -1
  82. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/index.js +21 -0
  83. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/types.js +5 -0
  84. package/dist/esm/ui-menu/Dropdown/index.js +5 -7
  85. package/dist/esm/ui-menu/DropdownMenu/index.js +50 -24
  86. package/dist/esm/ui-menu/ToolbarButton/index.js +3 -1
  87. package/dist/esm/ui-menu/index.js +3 -0
  88. package/dist/esm/utils/analytics.js +3 -0
  89. package/dist/esm/utils/index.js +1 -1
  90. package/dist/esm/utils/referentiality.js +28 -15
  91. package/dist/esm/version.json +1 -1
  92. package/dist/types/analytics/analytics-queue.d.ts +10 -0
  93. package/dist/types/analytics/fire-analytics-event.d.ts +2 -0
  94. package/dist/types/analytics/index.d.ts +3 -1
  95. package/dist/types/analytics/types/enums.d.ts +4 -0
  96. package/dist/types/analytics/types/events.d.ts +2 -1
  97. package/dist/types/analytics/types/general-events.d.ts +2 -2
  98. package/dist/types/analytics/types/index.d.ts +1 -1
  99. package/dist/types/analytics/utils.d.ts +3 -0
  100. package/dist/types/extensions/types/extension-manifest.d.ts +1 -1
  101. package/dist/types/hooks/index.d.ts +2 -0
  102. package/dist/types/hooks/useConstructor.d.ts +9 -0
  103. package/dist/types/hooks/usePreviousState.d.ts +11 -0
  104. package/dist/types/styles/index.d.ts +1 -1
  105. package/dist/types/styles/shared/table.d.ts +1 -0
  106. package/dist/types/types/editor-actions.d.ts +2 -1
  107. package/dist/types/types/feature-flags.d.ts +11 -0
  108. package/dist/types/types/floating-toolbar.d.ts +1 -1
  109. package/dist/types/types/index.d.ts +2 -2
  110. package/dist/types/types/next-editor-plugin.d.ts +37 -32
  111. package/dist/types/ui/index.d.ts +1 -1
  112. package/dist/types/ui-color/ColorPalette/Color/index.d.ts +1 -5
  113. package/dist/types/ui-color/ColorPalette/index.d.ts +1 -0
  114. package/dist/types/ui-color/ColorPalette/utils.d.ts +11 -0
  115. package/dist/types/ui-color/index.d.ts +1 -0
  116. package/dist/types/ui-menu/ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider/index.d.ts +7 -0
  117. package/dist/types/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.d.ts +7 -0
  118. package/dist/types/ui-menu/ArrowKeyNavigationProvider/index.d.ts +3 -0
  119. package/dist/types/ui-menu/ArrowKeyNavigationProvider/types.d.ts +33 -0
  120. package/dist/types/ui-menu/Dropdown/index.d.ts +2 -3
  121. package/dist/types/ui-menu/DropdownMenu/index.d.ts +2 -0
  122. package/dist/types/ui-menu/DropdownMenu/types.d.ts +3 -6
  123. package/dist/types/ui-menu/ToolbarButton/index.d.ts +2 -0
  124. package/dist/types/ui-menu/index.d.ts +3 -0
  125. package/dist/types/utils/analytics.d.ts +1 -0
  126. package/dist/types/utils/index.d.ts +1 -1
  127. package/dist/types/utils/referentiality.d.ts +11 -0
  128. package/hooks/package.json +15 -0
  129. package/package.json +18 -14
  130. package/dist/types/ui-menu/MenuArrowKeyNavigationProvider/index.d.ts +0 -16
@@ -6,56 +6,61 @@
6
6
  */
7
7
  import type { EditorState } from 'prosemirror-state';
8
8
  import type { EditorPlugin } from './editor-plugin';
9
- interface DefaultEditorPlugin<Name extends string> extends EditorPlugin {
9
+ interface DefaultEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata> extends EditorPlugin {
10
10
  name: Name;
11
11
  }
12
- interface DefaultEditorPluginWithSharedPluginState<Name, PublicState> {
12
+ interface DefaultEditorPluginWithSharedPluginState<Name, Metadata extends NextEditorPluginMetadata> {
13
13
  name: Name;
14
- getSharedState: (editorState: EditorState) => PublicState;
14
+ getSharedState: (editorState: EditorState) => ExtractSharedStateFromMetadata<Metadata>;
15
15
  }
16
- declare type CheckSharedState<Name extends string, PublicState = never> = Exclude<PublicState, never> extends never ? DefaultEditorPlugin<Name> : DefaultEditorPluginWithSharedPluginState<Name, PublicState>;
17
- export declare type NextEditorPlugin<Name extends string, PublicState = never, PluginConfiguration extends unknown | undefined = unknown> = any extends Function ? Exclude<unknown, PluginConfiguration> extends never ? (optionalConfig?: PluginConfiguration) => CheckSharedState<Name, PublicState> : Exclude<PluginConfiguration, Exclude<PluginConfiguration, undefined>> extends never ? (mandatoryConfig: PluginConfiguration) => CheckSharedState<Name, PublicState> : (optionalKnownConfig?: PluginConfiguration) => CheckSharedState<Name, PublicState> : never;
18
- declare type getNextEditorPluginStateType<T> = T extends NextEditorPlugin<any, infer U, any> ? U : never;
19
- declare type getNextEditorPluginNameType<T> = T extends NextEditorPlugin<infer U, any, any> ? U : never;
20
- declare type ExternalPluginAPIProps<T extends NextEditorPlugin<any, any, any>> = {
16
+ declare type CheckSharedState<Name extends string, Metadata extends NextEditorPluginMetadata> = Exclude<ExtractSharedStateFromMetadata<Metadata>, never> extends never ? DefaultEditorPlugin<Name, Metadata> : DefaultEditorPluginWithSharedPluginState<Name, Metadata>;
17
+ interface NextEditorPluginMetadata {
18
+ readonly sharedState?: any;
19
+ readonly pluginConfiguration?: any;
20
+ readonly dependencies?: NextEditorPlugin<any, any>[];
21
+ }
22
+ declare type NextEditorPluginProps<Metadata extends NextEditorPluginMetadata> = {
23
+ externalPlugins: ExternalPluginAPI<ExtractPluginDependenciesFromMetadata<Metadata>>;
24
+ };
25
+ declare type NextEditorPluginFunctionDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration> = (config: Configuration, api?: NextEditorPluginProps<Metadata>) => CheckSharedState<Name, Metadata>;
26
+ declare type NextEditorPluginFunctionOptionalConfigDefinition<Name extends string, Metadata extends NextEditorPluginMetadata, Configuration = undefined> = (config?: Configuration, api?: NextEditorPluginProps<Metadata>) => CheckSharedState<Name, Metadata>;
27
+ export declare type NextEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata = {}> = Metadata extends NextEditorPluginMetadata ? 'pluginConfiguration' extends keyof Metadata ? undefined extends Metadata['pluginConfiguration'] ? NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionDefinition<Name, Metadata, Metadata['pluginConfiguration']> : NextEditorPluginFunctionOptionalConfigDefinition<Name, Metadata> : never;
28
+ declare type ExtractPluginDependenciesFromMetadata<Metadata> = 'dependencies' extends keyof Metadata ? Metadata['dependencies'] extends NextEditorPlugin<any, any>[] ? Exclude<Metadata['dependencies'], undefined> : [] : [];
29
+ declare type ExtractSharedStateFromMetadata<Metadata> = 'sharedState' extends keyof Metadata ? Metadata['sharedState'] : never;
30
+ declare type ExtractPluginConfigurationFromMetadata<Metadata> = 'pluginConfiguration' extends keyof Metadata ? Metadata['pluginConfiguration'] : never;
31
+ declare type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => CheckSharedState<any, infer Metadata> ? ExtractPluginDependenciesFromMetadata<Metadata> : never : never;
32
+ declare type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => CheckSharedState<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
33
+ declare type ExtractPluginSharedState<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => CheckSharedState<any, infer Metadata> ? ExtractSharedStateFromMetadata<Metadata> : never : never;
34
+ declare type ExtractPluginName<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (...args: any) => CheckSharedState<infer PluginName, any> ? PluginName : never : never;
35
+ declare type ExternalPluginAPIProps<Plugin extends NextEditorPlugin<any, any>> = {
21
36
  sharedPluginState: {
22
- currentState: () => getNextEditorPluginStateType<T>;
23
- onChange: (sub: (props: getNextEditorPluginStateType<T>) => void) => void;
37
+ currentState: () => ExtractPluginSharedState<Plugin>;
38
+ onChange: (sub: (props: ExtractPluginSharedState<Plugin>) => void) => void;
24
39
  };
25
40
  };
26
- declare type ExternalPluginAPI<PluginList extends AllBuilderPlugins[]> = {
27
- [Plugin in PluginList[number] extends NextEditorPluginWithDependencies<any, any, any, any> ? ReturnType<PluginList[number]> : PluginList[number] as getNextEditorPluginNameType<Plugin>]: Plugin extends NextEditorPlugin<any, any, any> ? ExternalPluginAPIProps<Plugin> : never;
41
+ declare type ExternalPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
42
+ [Plugin in PluginList[number] as ExtractPluginName<Plugin>]: Plugin extends NextEditorPlugin<any, any> ? ExternalPluginAPIProps<Plugin> : never;
28
43
  };
29
- export declare type NextEditorPluginWithDependencies<NextEditorPluginKey extends string, NextEditorPluginPublicState, D extends AllBuilderPlugins[], NextEditorPluginConfiguration extends unknown | undefined = unknown> = (props: {
30
- externalPlugins: ExternalPluginAPI<D>;
31
- }) => NextEditorPlugin<NextEditorPluginKey, NextEditorPluginPublicState, NextEditorPluginConfiguration>;
32
- export declare type PluginAsArray<A extends string, B = never, C = unknown> = C extends C & undefined ? [NextEditorPlugin<A, B, C>, C?] : [NextEditorPlugin<A, B, C>, C];
33
- export declare type PluginWithDependenciesAsArray<A extends string, B, C extends AllBuilderPlugins[], D extends unknown = unknown> = D extends D & undefined ? [NextEditorPluginWithDependencies<A, B, C, D>, D?] : [NextEditorPluginWithDependencies<A, B, C, D>, D];
34
- declare type AllPluginsAsArray = PluginAsArray<string, any, any> | PluginWithDependenciesAsArray<string, any, any, any>;
35
- export declare type AllNextEditorPlugins = NextEditorPlugin<string, any, any> | NextEditorPluginWithDependencies<string, any, any, any>;
36
- export declare type AllBuilderPlugins = AllPluginsAsArray | AllNextEditorPlugins;
37
- declare type ExtractNextEditorPlugin<T> = T extends PluginAsArray<string, any, any> | PluginWithDependenciesAsArray<string, any, any, any> ? T[0] : never;
38
- export declare type VerifyPluginDependencies<T, Plugins extends AllBuilderPlugins[]> = T extends NextEditorPluginWithDependencies<string, any, infer D, any> | PluginWithDependenciesAsArray<string, any, infer D, any> ?
44
+ export declare type PluginAsArray<Plugin> = undefined extends ExtractPluginConfiguration<Plugin> ? [Plugin, ExtractPluginConfiguration<Plugin>?] : [Plugin, ExtractPluginConfiguration<Plugin>];
45
+ export declare type AllBuilderPlugins = PluginAsArray<any> | NextEditorPlugin<any, any>;
46
+ declare type ExtractNextEditorPlugin<Plugin> = Plugin extends PluginAsArray<any> ? Plugin[0] : never;
47
+ export declare type VerifyPluginDependencies<Plugin, PluginsStack extends AllBuilderPlugins[]> = ExtractPluginDependencies<Plugin> extends [] ? Plugin extends PluginAsArray<any> | NextEditorPlugin<any, any> ? Plugin : never :
39
48
  /**
40
49
  * case 1: We're looking for its dependent plugins indexed on `AllBuilderPlugins`
41
50
  */
42
- D[number] extends (D[number] & Plugins[number])
51
+ ExtractPluginDependencies<Plugin>[number] extends (ExtractPluginDependencies<Plugin>[number] & PluginsStack[number])
43
52
  /**
44
53
  * case 2:
45
54
  * Otherwise check whether the dependent-plugin, is hidden inside a tuple,
46
55
  * unwrapping `Plugins` via `ExtractNextEditorPlugin`
47
56
  */
48
- | (D[number] & ExtractNextEditorPlugin<Plugins[number]>) ? T : never : T extends PluginAsArray<any, any, any> | NextEditorPlugin<any, any, any> ? T : never;
57
+ | (ExtractPluginDependencies<Plugin>[number] & ExtractNextEditorPlugin<PluginsStack[number]>) ? Plugin : never;
49
58
  /**
50
59
  * Used to check if a plugin being added can be added to a Preset/builder
51
60
  */
52
- export declare type SafePresetCheck<Plugin, StackPlugins extends AllBuilderPlugins[]> = Plugin extends Plugin & VerifyPluginDependencies<Plugin, StackPlugins> ? Plugin extends NextEditorPluginWithDependencies<string, any, any, infer Config> ? CheckPluginWithDependency<Plugin, Config, StackPlugins> : Plugin extends NextEditorPlugin<any, any, infer Config> ? CheckBasicPlugin<Plugin, Config> : never : Plugin extends (config: infer Config) => EditorPlugin ?
53
- /** Checks whether config has any mandatory fields - if so, config cannot be optional */
54
- Exclude<unknown, Config> extends never ? Plugin | [Plugin] : Exclude<unknown, Config> extends never ? Plugin | [Plugin] | [Plugin, Config] : [
55
- Plugin,
61
+ export declare type SafePresetCheck<Plugin, StackPlugins extends AllBuilderPlugins[]> = Plugin extends Plugin & VerifyPluginDependencies<Plugin, StackPlugins> ? Plugin extends NextEditorPlugin<any, any> ? CheckBasicPlugin<Plugin> : never : never;
62
+ declare type CheckTupleRequirements<Plugin, Config, ArrayType> = unknown extends Config ? Plugin | ArrayType : undefined extends Config ? Plugin | ArrayType : [
56
63
  Config
57
- ] : never;
58
- declare type CheckTupleRequirements<Plugin, Config, ArrayType> = Plugin extends Plugin ? Exclude<unknown, Config> extends never ? Plugin | ArrayType : Exclude<Config, Exclude<Config, undefined>> extends never ? Plugin | ArrayType : ArrayType : never;
59
- declare type CheckPluginWithDependency<Plugin, Config, StackPlugins extends AllBuilderPlugins[]> = Plugin extends (...args: any) => (...args: any) => EditorPlugin ? CheckTupleRequirements<Plugin, Config, PluginWithDependenciesAsArray<any, any, StackPlugins, Config | undefined>> : never;
60
- declare type CheckBasicPlugin<Plugin, Config> = Plugin extends (...args: any) => EditorPlugin ? CheckTupleRequirements<Plugin, Config, PluginAsArray<any, any, Config | undefined>> : never;
64
+ ] extends [never] ? Plugin : ArrayType;
65
+ declare type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>, PluginAsArray<Plugin>> : never;
61
66
  export {};
@@ -13,7 +13,7 @@ export { BaseTheme, mapBreakpointToLayoutMaxWidth } from './BaseTheme';
13
13
  export { default as withOuterListeners } from './with-outer-listeners';
14
14
  export type { WithOutsideClickProps } from './with-outer-listeners';
15
15
  export type { CardEventClickHandler, CardSurroundings, EventHandlers, LinkEventClickHandler, MentionEventHandler, MentionEventHandlers, SmartCardEventClickHandler, } from './EventHandlers';
16
- export { WidthConsumer, WidthProvider, getBreakpoint } from './WidthProvider';
16
+ export { WidthContext, WidthConsumer, WidthProvider, getBreakpoint, } from './WidthProvider';
17
17
  export type { WidthConsumerContext, Breakpoints } from './WidthProvider';
18
18
  export { default as overflowShadow, shadowClassNames } from './OverflowShadow';
19
19
  export type { OverflowShadowOptions, OverflowShadowProps, OverflowShadowState, } from './OverflowShadow';
@@ -10,11 +10,7 @@ export interface Props {
10
10
  borderColor: string;
11
11
  checkMarkColor?: string;
12
12
  autoFocus?: boolean;
13
- /**
14
- * When set to true -- the presentation of colors in the
15
- * palette will use design tokens when available.
16
- */
17
- useDesignTokens: boolean;
13
+ hexToPaletteColor?: (hexColor: string) => string | undefined;
18
14
  }
19
15
  declare class Color extends PureComponent<Props> {
20
16
  render(): jsx.JSX.Element;
@@ -16,6 +16,7 @@ interface Props {
16
16
  * @default false
17
17
  */
18
18
  textPalette?: boolean;
19
+ hexToPaletteColor?: (hexColor: string) => string | undefined;
19
20
  /**
20
21
  * Used to detect if the useSomewhatSemanticTextColorNames feature flag
21
22
  * is true. If so, text color tooltips in the color picker will
@@ -0,0 +1,11 @@
1
+ import { PaletteColor } from './Palettes/type';
2
+ export declare const DEFAULT_COLOR_PICKER_COLUMNS = 7;
3
+ export declare function getColorsPerRowFromPalette(palette: PaletteColor[], cols?: number): PaletteColor[][];
4
+ export declare function getSelectedRowAndColumn(colorsPerRow: PaletteColor[][], selectedColor: string | null): {
5
+ selectedRowIndex: number;
6
+ selectedColumnIndex: number;
7
+ };
8
+ export declare function getSelectedRowAndColumnFromPalette(palette: PaletteColor[], selectedColor: string | null, cols?: number): {
9
+ selectedRowIndex: number;
10
+ selectedColumnIndex: number;
11
+ };
@@ -1,5 +1,6 @@
1
1
  export { default as ColorPalette } from './ColorPalette';
2
2
  export { default as Color } from './ColorPalette/Color';
3
+ export { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette, getSelectedRowAndColumn, getSelectedRowAndColumnFromPalette, } from './ColorPalette/utils';
3
4
  export { default as cellBackgroundColorPalette } from './ColorPalette/Palettes/cellBackgroundColorPalette';
4
5
  export { default as colorPaletteMessages } from './ColorPalette/Palettes/paletteMessages';
5
6
  export { panelBackgroundPalette, panelDarkModeBackgroundPalette, } from './ColorPalette/Palettes/panelBackgroundPalette';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { ColorPaletteArrowKeyNavigationProps } from '../types';
3
+ /**
4
+ * This component is a wrapper for color picker which listens to keydown events of children
5
+ * and handles arrow key navigation
6
+ */
7
+ export declare const ColorPaletteArrowKeyNavigationProvider: React.FC<Omit<ColorPaletteArrowKeyNavigationProps, 'type'>>;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { MenuArrowKeyNavigationProviderProps } from '../types';
3
+ /**
4
+ * This component is a wrapper of vertical menus which listens to keydown events of children
5
+ * and handles up/down arrow key navigation
6
+ */
7
+ export declare const MenuArrowKeyNavigationProvider: React.FC<Omit<MenuArrowKeyNavigationProviderProps, 'type'>>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { ArrowKeyNavigationProviderProps } from './types';
3
+ export declare const ArrowKeyNavigationProvider: React.FC<ArrowKeyNavigationProviderProps>;
@@ -0,0 +1,33 @@
1
+ export interface KeyDownHandlerContext {
2
+ handleArrowRight: () => void;
3
+ handleArrowLeft: () => void;
4
+ handleTab: () => void;
5
+ }
6
+ export declare type SimpleEventHandler<T> = (event: T) => void;
7
+ export declare enum ArrowKeyNavigationType {
8
+ COLOR = "color",
9
+ MENU = "menu"
10
+ }
11
+ export declare type ColorPaletteArrowKeyNavigationOptions = {
12
+ type: ArrowKeyNavigationType.COLOR;
13
+ selectedRowIndex: number;
14
+ selectedColumnIndex: number;
15
+ isOpenedByKeyboard: boolean;
16
+ isPopupPositioned: boolean;
17
+ };
18
+ export declare type ColorPaletteArrowKeyNavigationProps = ColorPaletteArrowKeyNavigationOptions & {
19
+ handleClose?: SimpleEventHandler<KeyboardEvent>;
20
+ closeOnTab?: boolean;
21
+ };
22
+ export declare type MenuArrowKeyNavigationOptions = {
23
+ type: ArrowKeyNavigationType.MENU;
24
+ disableArrowKeyNavigation?: boolean;
25
+ keyDownHandlerContext?: KeyDownHandlerContext;
26
+ };
27
+ export declare type MenuArrowKeyNavigationProviderProps = MenuArrowKeyNavigationOptions & {
28
+ handleClose?: SimpleEventHandler<KeyboardEvent>;
29
+ onSelection?: (index: number) => void;
30
+ closeOnTab?: boolean;
31
+ };
32
+ export declare type ArrowKeyNavigationProviderOptions = ColorPaletteArrowKeyNavigationOptions | MenuArrowKeyNavigationOptions;
33
+ export declare type ArrowKeyNavigationProviderProps = ColorPaletteArrowKeyNavigationProps | MenuArrowKeyNavigationProviderProps;
@@ -1,6 +1,6 @@
1
1
  import React, { PureComponent } from 'react';
2
2
  import { OpenChangedEvent } from '../../ui/DropList';
3
- import { KeyDownHandlerContext } from '../DropdownMenu/types';
3
+ import { ArrowKeyNavigationProviderOptions } from '../ArrowKeyNavigationProvider/types';
4
4
  export interface Props {
5
5
  mountTo?: HTMLElement;
6
6
  boundariesElement?: HTMLElement;
@@ -11,8 +11,7 @@ export interface Props {
11
11
  fitWidth?: number;
12
12
  fitHeight?: number;
13
13
  zIndex?: number;
14
- disableArrowKeyNavigation?: boolean;
15
- keyDownHandlerContext?: KeyDownHandlerContext;
14
+ arrowKeyNavigationProviderOptions: ArrowKeyNavigationProviderOptions;
16
15
  }
17
16
  export interface State {
18
17
  target?: HTMLElement;
@@ -11,10 +11,12 @@ export type { MenuItem } from './types';
11
11
  */
12
12
  export default class DropdownMenuWrapper extends PureComponent<Props, State> {
13
13
  state: State;
14
+ private popupRef;
14
15
  private handleRef;
15
16
  private updatePopupPlacement;
16
17
  private handleCloseAndFocus;
17
18
  private handleClose;
18
19
  private renderDropdownMenu;
19
20
  render(): jsx.JSX.Element;
21
+ componentDidUpdate(previousProps: Props): void;
20
22
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { EditorActionsOptions as EditorActions } from '../../types';
3
+ import { ArrowKeyNavigationProviderOptions } from '../ArrowKeyNavigationProvider/types';
3
4
  export interface Props {
4
5
  mountTo?: HTMLElement;
5
6
  boundariesElement?: HTMLElement;
@@ -9,7 +10,6 @@ export interface Props {
9
10
  onItemActivated?: (attrs: any) => void;
10
11
  onMouseEnter?: (attrs: any) => void;
11
12
  onMouseLeave?: (attrs: any) => void;
12
- keyDownHandlerContext?: KeyDownHandlerContext;
13
13
  fitWidth?: number;
14
14
  fitHeight?: number;
15
15
  offset?: Array<number>;
@@ -19,11 +19,8 @@ export interface Props {
19
19
  }>;
20
20
  shouldUseDefaultRole?: boolean;
21
21
  disableArrowKeyNavigation?: boolean;
22
- }
23
- export interface KeyDownHandlerContext {
24
- handleArrowRight: () => void;
25
- handleArrowLeft: () => void;
26
- handleTab: () => void;
22
+ shouldFocusFirstItem?: () => boolean;
23
+ arrowKeyNavigationProviderOptions: ArrowKeyNavigationProviderOptions;
27
24
  }
28
25
  export interface MenuItem {
29
26
  key?: string;
@@ -15,6 +15,7 @@ export declare type Props = {
15
15
  iconBefore?: React.ReactElement<any>;
16
16
  onClick?: (event: React.MouseEvent<HTMLElement>) => void;
17
17
  onItemClick?: (item: MenuItem) => void;
18
+ onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void;
18
19
  selected?: boolean;
19
20
  spacing?: 'default' | 'compact' | 'none';
20
21
  target?: string;
@@ -39,6 +40,7 @@ declare const ToolbarButton: React.ForwardRefExoticComponent<{
39
40
  iconBefore?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
40
41
  onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | undefined;
41
42
  onItemClick?: ((item: MenuItem) => void) | undefined;
43
+ onKeyDown?: ((event: React.KeyboardEvent<HTMLElement>) => void) | undefined;
42
44
  selected?: boolean | undefined;
43
45
  spacing?: "none" | "default" | "compact" | undefined;
44
46
  target?: string | undefined;
@@ -2,4 +2,7 @@ export { default as DropdownMenu } from '../ui-menu/DropdownMenu';
2
2
  export type { MenuItem } from '../ui-menu/DropdownMenu';
3
3
  export { default as ToolbarButton, TOOLBAR_BUTTON, } from '../ui-menu/ToolbarButton';
4
4
  export type { ToolbarButtonRef } from '../ui-menu/ToolbarButton';
5
+ export { ArrowKeyNavigationProvider } from '../ui-menu/ArrowKeyNavigationProvider';
6
+ export { ArrowKeyNavigationType } from '../ui-menu/ArrowKeyNavigationProvider/types';
7
+ export { ColorPaletteArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider';
5
8
  export { default as Dropdown } from './Dropdown';
@@ -1,6 +1,7 @@
1
1
  import { EDITOR_APPEARANCE_CONTEXT } from '@atlaskit/analytics-namespaced-context';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
3
3
  export declare const getAnalyticsAppearance: (appearance?: string | undefined) => EDITOR_APPEARANCE_CONTEXT | undefined;
4
+ export declare const getAnalyticsEditorAppearance: (editorAppearance?: string | undefined) => string;
4
5
  export declare const getAnalyticsEventSeverity: (duration: number, normalThreshold: number, degradedThreshold: number) => SEVERITY;
5
6
  export declare enum SEVERITY {
6
7
  NORMAL = "normal",
@@ -18,7 +18,7 @@ export type { FlatMapCallback, MapWithCallback } from './slice';
18
18
  export { walkUpTreeUntil, unwrap, removeNestedEmptyEls, containsClassName, closest, closestElement, parsePx, mapElem, maphElem, } from './dom';
19
19
  export type { MapCallback } from './dom';
20
20
  export { default as ADFTraversor } from './traversor';
21
- export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEventSeverity, SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS, } from './analytics';
21
+ export { analyticsEventKey, getAnalyticsAppearance, getAnalyticsEditorAppearance, getAnalyticsEventSeverity, SEVERITY, getUnsupportedContentLevelData, UNSUPPORTED_CONTENT_LEVEL_SEVERITY, UNSUPPORTED_CONTENT_LEVEL_SEVERITY_THRESHOLD_DEFAULTS, } from './analytics';
22
22
  export type { UnsupportedContentTooltipPayload, UnsupportedContentPayload, UnsupportedContentLevelsTracking, } from './analytics';
23
23
  export { findAndTrackUnsupportedContentNodes } from './track-unsupported-content';
24
24
  export { getDistortedDurationMonitor, measureRender, } from './performance/measure-render';
@@ -1,7 +1,18 @@
1
1
  import { Node as PMNode } from 'prosemirror-model';
2
2
  import { EditorState } from 'prosemirror-state';
3
+ import type { FragmentAttributes } from '@atlaskit/adf-schema/schema';
3
4
  import { ConfirmDialogChildInfo } from '../types';
5
+ declare type LocalId = FragmentAttributes['localId'];
6
+ declare type NodeAndTargetLinkages = {
7
+ readonly localId: LocalId;
8
+ readonly name: string;
9
+ readonly node: PMNode;
10
+ readonly pos: number;
11
+ readonly targets: LocalId[];
12
+ };
4
13
  export declare const isReferencedSource: (state: EditorState, node?: PMNode<any> | undefined) => boolean;
14
+ export declare const getConnections: (state: EditorState) => Record<string, NodeAndTargetLinkages>;
5
15
  export declare const removeConnectedNodes: (state: EditorState, node?: PMNode<any> | undefined) => import("prosemirror-state").Transaction<any>;
6
16
  export declare const getChildrenInfo: (state: EditorState, node?: PMNode<any> | undefined) => ConfirmDialogChildInfo[];
7
17
  export declare const getNodeName: (state: EditorState, node?: PMNode<any> | undefined) => string;
18
+ export {};
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/hooks",
3
+ "main": "../dist/cjs/hooks/index.js",
4
+ "module": "../dist/esm/hooks/index.js",
5
+ "module:es2019": "../dist/es2019/hooks/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/hooks/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.0 <4.5": {
10
+ "*": [
11
+ "../dist/types-ts4.0/hooks/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "72.4.0",
3
+ "version": "72.5.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -53,37 +53,38 @@
53
53
  "./ui-color": "./src/ui-color/index.ts",
54
54
  "./transforms": "./src/transforms/index.ts",
55
55
  "./core-utils": "./src/core-utils/index.ts",
56
- "./selection": "./src/selection/index.ts"
56
+ "./selection": "./src/selection/index.ts",
57
+ "./hooks": "./src/hooks/index.ts"
57
58
  },
58
59
  "dependencies": {
59
60
  "@atlaskit/activity-provider": "^2.3.0",
60
- "@atlaskit/adf-schema": "^25.2.0",
61
+ "@atlaskit/adf-schema": "^25.3.0",
61
62
  "@atlaskit/adf-utils": "^18.0.0",
62
63
  "@atlaskit/analytics-listeners": "^8.5.0",
63
64
  "@atlaskit/analytics-namespaced-context": "^6.6.0",
64
65
  "@atlaskit/analytics-next": "^9.0.0",
65
66
  "@atlaskit/analytics-next-stable-react-context": "1.0.1",
66
67
  "@atlaskit/button": "^16.5.0",
67
- "@atlaskit/code": "^14.4.0",
68
+ "@atlaskit/code": "^14.5.0",
68
69
  "@atlaskit/codemod-utils": "^4.1.0",
69
70
  "@atlaskit/editor-json-transformer": "^8.8.0",
70
71
  "@atlaskit/editor-palette": "1.0.0",
71
72
  "@atlaskit/editor-shared-styles": "^2.3.0",
72
- "@atlaskit/emoji": "^67.0.0",
73
+ "@atlaskit/emoji": "^67.1.0",
73
74
  "@atlaskit/icon": "^21.11.0",
74
75
  "@atlaskit/in-product-testing": "^0.1.0",
75
- "@atlaskit/media-card": "^74.6.0",
76
- "@atlaskit/media-client": "^20.0.0",
76
+ "@atlaskit/media-card": "^74.7.0",
77
+ "@atlaskit/media-client": "^20.1.0",
77
78
  "@atlaskit/media-picker": "^64.2.0",
78
79
  "@atlaskit/mention": "^21.0.0",
79
- "@atlaskit/menu": "^1.4.0",
80
- "@atlaskit/profilecard": "^18.2.0",
81
- "@atlaskit/smart-card": "^24.1.0",
80
+ "@atlaskit/menu": "^1.5.0",
81
+ "@atlaskit/profilecard": "^18.4.0",
82
+ "@atlaskit/smart-card": "^25.0.0",
82
83
  "@atlaskit/smart-user-picker": "^6.0.0",
83
84
  "@atlaskit/task-decision": "^17.5.0",
84
85
  "@atlaskit/theme": "^12.2.0",
85
86
  "@atlaskit/tokens": "^1.2.0",
86
- "@atlaskit/tooltip": "^17.6.0",
87
+ "@atlaskit/tooltip": "^17.7.0",
87
88
  "@atlaskit/ufo": "^0.1.0",
88
89
  "@atlaskit/width-detector": "^4.0.0",
89
90
  "@babel/runtime": "^7.0.0",
@@ -97,6 +98,7 @@
97
98
  "date-fns": "^2.17.0",
98
99
  "focus-trap": "^2.4.5",
99
100
  "lodash": "^4.17.21",
101
+ "memoize-one": "^6.0.0",
100
102
  "popper.js": "^1.14.1",
101
103
  "prop-types": "^15.5.10",
102
104
  "prosemirror-model": "1.14.3",
@@ -108,22 +110,24 @@
108
110
  "react-loadable": "^5.1.0"
109
111
  },
110
112
  "peerDependencies": {
111
- "@atlaskit/media-core": "^34.0.1",
113
+ "@atlaskit/media-core": "^34.0.2",
112
114
  "react": "^16.8.0",
113
115
  "react-dom": "^16.8.0",
114
116
  "react-intl-next": "npm:react-intl@^5.18.1"
115
117
  },
116
118
  "devDependencies": {
117
- "@atlaskit/editor-core": "^179.1.0",
119
+ "@atlaskit/editor-core": "^180.1.0",
118
120
  "@atlaskit/editor-json-transformer": "^8.8.0",
119
- "@atlaskit/editor-plugin-table": "^1.1.0",
121
+ "@atlaskit/editor-plugin-table": "^1.2.0",
120
122
  "@atlaskit/editor-test-helpers": "^18.0.0",
121
123
  "@atlaskit/media-core": "^34.0.0",
122
124
  "@atlaskit/util-data-test": "^17.6.0",
123
125
  "@atlaskit/visual-regression": "*",
124
126
  "@atlaskit/webdriver-runner": "*",
125
127
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
128
+ "@testing-library/jest-dom": "^5.16.5",
126
129
  "@testing-library/react": "^12.1.5",
130
+ "@testing-library/react-hooks": "^8.0.1",
127
131
  "@types/raf-schd": "^4.0.1",
128
132
  "enzyme": "^3.10.0",
129
133
  "raf-stub": "^2.0.1",
@@ -1,16 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { KeyDownHandlerContext } from '../DropdownMenu/types';
3
- declare type SimpleEventHandler<T> = (event: T) => void;
4
- /**
5
- * This component is a wrapper of vertical menus which listens to keydown events of children
6
- * and handles up/down arrow key navigation
7
- */
8
- export declare const MenuArrowKeyNavigationProvider: ({ children, handleClose, disableArrowKeyNavigation, keyDownHandlerContext, closeOnTab, onSelection, }: {
9
- children: ReactNode;
10
- handleClose?: SimpleEventHandler<KeyboardEvent> | undefined;
11
- disableArrowKeyNavigation?: boolean | undefined;
12
- keyDownHandlerContext?: KeyDownHandlerContext | undefined;
13
- onSelection?: ((index: number) => void) | undefined;
14
- closeOnTab?: boolean | undefined;
15
- }) => JSX.Element;
16
- export {};