@atlaskit/editor-common 74.36.4 → 74.38.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 (79) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/guideline/constants.js +4 -2
  3. package/dist/cjs/guideline/defaultGuideline.js +4 -3
  4. package/dist/cjs/guideline/index.js +10 -4
  5. package/dist/cjs/guideline/snapping.js +42 -30
  6. package/dist/cjs/keymaps/index.js +11 -7
  7. package/dist/cjs/monitoring/error.js +1 -1
  8. package/dist/cjs/preset/index.js +8 -1
  9. package/dist/cjs/preset/plugin-commands.js +19 -0
  10. package/dist/cjs/preset/plugin-injection-api.js +28 -1
  11. package/dist/cjs/types/layout.js +5 -0
  12. package/dist/cjs/types/plugin-command.js +5 -0
  13. package/dist/cjs/types/selection.js +5 -0
  14. package/dist/cjs/ui/DropList/index.js +1 -1
  15. package/dist/cjs/ui/MediaSingle/styled.js +1 -1
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/guideline/constants.js +2 -1
  18. package/dist/es2019/guideline/defaultGuideline.js +4 -3
  19. package/dist/es2019/guideline/index.js +2 -2
  20. package/dist/es2019/guideline/snapping.js +35 -27
  21. package/dist/es2019/keymaps/index.js +10 -7
  22. package/dist/es2019/monitoring/error.js +1 -1
  23. package/dist/es2019/preset/index.js +2 -1
  24. package/dist/es2019/preset/plugin-commands.js +14 -0
  25. package/dist/es2019/preset/plugin-injection-api.js +21 -1
  26. package/dist/es2019/types/layout.js +1 -0
  27. package/dist/es2019/types/plugin-command.js +1 -0
  28. package/dist/es2019/types/selection.js +1 -0
  29. package/dist/es2019/ui/DropList/index.js +1 -1
  30. package/dist/es2019/ui/MediaSingle/styled.js +8 -7
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/guideline/constants.js +2 -1
  33. package/dist/esm/guideline/defaultGuideline.js +4 -3
  34. package/dist/esm/guideline/index.js +2 -2
  35. package/dist/esm/guideline/snapping.js +40 -28
  36. package/dist/esm/keymaps/index.js +10 -7
  37. package/dist/esm/monitoring/error.js +1 -1
  38. package/dist/esm/preset/index.js +2 -1
  39. package/dist/esm/preset/plugin-commands.js +13 -0
  40. package/dist/esm/preset/plugin-injection-api.js +28 -1
  41. package/dist/esm/types/layout.js +1 -0
  42. package/dist/esm/types/plugin-command.js +1 -0
  43. package/dist/esm/types/selection.js +1 -0
  44. package/dist/esm/ui/DropList/index.js +1 -1
  45. package/dist/esm/ui/MediaSingle/styled.js +2 -1
  46. package/dist/esm/version.json +1 -1
  47. package/dist/types/collab/index.d.ts +25 -0
  48. package/dist/types/guideline/constants.d.ts +1 -0
  49. package/dist/types/guideline/dynamicGuideline.d.ts +1 -1
  50. package/dist/types/guideline/index.d.ts +3 -3
  51. package/dist/types/guideline/snapping.d.ts +12 -11
  52. package/dist/types/guideline/types.d.ts +13 -2
  53. package/dist/types/keymaps/index.d.ts +5 -1
  54. package/dist/types/preset/index.d.ts +1 -0
  55. package/dist/types/preset/plugin-commands.d.ts +3 -0
  56. package/dist/types/preset/plugin-injection-api.d.ts +1 -0
  57. package/dist/types/types/index.d.ts +4 -1
  58. package/dist/types/types/layout.d.ts +6 -0
  59. package/dist/types/types/next-editor-plugin.d.ts +10 -1
  60. package/dist/types/types/plugin-command.d.ts +7 -0
  61. package/dist/types/types/selection.d.ts +3 -0
  62. package/dist/types/ui/MediaSingle/styled.d.ts +3 -2
  63. package/dist/types-ts4.5/collab/index.d.ts +25 -0
  64. package/dist/types-ts4.5/guideline/constants.d.ts +1 -0
  65. package/dist/types-ts4.5/guideline/dynamicGuideline.d.ts +1 -1
  66. package/dist/types-ts4.5/guideline/index.d.ts +3 -3
  67. package/dist/types-ts4.5/guideline/snapping.d.ts +12 -11
  68. package/dist/types-ts4.5/guideline/types.d.ts +13 -2
  69. package/dist/types-ts4.5/keymaps/index.d.ts +5 -1
  70. package/dist/types-ts4.5/preset/index.d.ts +1 -0
  71. package/dist/types-ts4.5/preset/plugin-commands.d.ts +3 -0
  72. package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +1 -0
  73. package/dist/types-ts4.5/types/index.d.ts +4 -1
  74. package/dist/types-ts4.5/types/layout.d.ts +6 -0
  75. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +10 -1
  76. package/dist/types-ts4.5/types/plugin-command.d.ts +7 -0
  77. package/dist/types-ts4.5/types/selection.d.ts +3 -0
  78. package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +3 -2
  79. package/package.json +1 -1
@@ -6,25 +6,32 @@
6
6
  */
7
7
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { EditorPlugin } from './editor-plugin';
9
+ import type { PluginCommand, PluginCommandWithMetadata } from './plugin-command';
9
10
  type IsAny<T> = 0 extends 1 & T ? true : false;
10
11
  type PickSharedStatePropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractSharedStateFromMetadata<Metadata> extends never ? never : 'getSharedState';
11
12
  type WithSharedState<Metadata extends NextEditorPluginMetadata> = {
12
13
  [Property in keyof Pick<Metadata, 'sharedState'> as PickSharedStatePropertyName<Metadata>]: (editorState: EditorState | undefined) => ExtractSharedStateFromMetadata<Metadata>;
13
14
  };
14
15
  type PickActionsPropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractActionsFromMetadata<Metadata> extends never ? never : 'actions';
16
+ type PickCommandsPropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractCommandsFromMetadata<Metadata> extends never ? never : 'commands';
15
17
  type WithActions<Metadata extends NextEditorPluginMetadata> = {
16
18
  [Property in keyof Pick<Metadata, 'actions'> as PickActionsPropertyName<Metadata>]: ExtractActionsFromMetadata<Metadata>;
17
19
  };
18
- export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata> = EditorPlugin & WithSharedState<Metadata> & WithActions<Metadata> & {
20
+ type WithCommands<Metadata extends NextEditorPluginMetadata> = {
21
+ [Property in keyof Pick<Metadata, 'commands'> as PickCommandsPropertyName<Metadata>]: ExtractCommandsFromMetadata<Metadata>;
22
+ };
23
+ export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata> = EditorPlugin & WithSharedState<Metadata> & WithActions<Metadata> & WithCommands<Metadata> & {
19
24
  name: Name;
20
25
  };
21
26
  type MaybeAction = ((...agrs: any) => any) | ((...agrs: any) => void);
22
27
  type NextEditorPluginActions = Record<string, MaybeAction>;
28
+ type NextEditorPluginCommands = Record<string, PluginCommandWithMetadata | PluginCommand>;
23
29
  export interface NextEditorPluginMetadata {
24
30
  readonly sharedState?: any;
25
31
  readonly pluginConfiguration?: any;
26
32
  readonly dependencies?: DependencyPlugin[];
27
33
  readonly actions?: NextEditorPluginActions;
34
+ readonly commands?: NextEditorPluginCommands;
28
35
  }
29
36
  export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
30
37
  dependencies: CreatePluginDependenciesAPI<[
@@ -56,6 +63,7 @@ type ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata extends Next
56
63
  type ExtractPluginDependenciesFromMetadata<Metadata> = 'dependencies' extends keyof Metadata ? Metadata['dependencies'] extends DependencyPlugin[] ? Exclude<Metadata['dependencies'], undefined> : [] : [];
57
64
  type ExtractSharedStateFromMetadata<Metadata> = 'sharedState' extends keyof Metadata ? Metadata['sharedState'] : never;
58
65
  type ExtractActionsFromMetadata<Metadata> = 'actions' extends keyof Metadata ? Metadata['actions'] : never;
66
+ type ExtractCommandsFromMetadata<Metadata> = 'commands' extends keyof Metadata ? Metadata['commands'] : never;
59
67
  type ExtractPluginConfigurationFromMetadata<Metadata> = 'pluginConfiguration' extends keyof Metadata ? Metadata['pluginConfiguration'] : never;
60
68
  export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
61
69
  type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
@@ -72,6 +80,7 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
72
80
  }) => void) => Unsubscribe;
73
81
  };
74
82
  actions: ExtractPluginActions<Plugin>;
83
+ commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
75
84
  };
76
85
  export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
77
86
  [Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> : never;
@@ -0,0 +1,7 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ type PluginCommandProps = {
3
+ tr: Transaction;
4
+ };
5
+ export type PluginCommand = (props: PluginCommandProps) => Transaction | null;
6
+ export type PluginCommandWithMetadata = (args: any) => PluginCommand;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface LongPressSelectionPluginOptions {
2
+ useLongPressSelection?: boolean;
3
+ }
@@ -1,7 +1,8 @@
1
1
  /** @jsx jsx */
2
- import React, { RefObject } from 'react';
2
+ import type { RefObject } from 'react';
3
+ import React from 'react';
3
4
  import { jsx } from '@emotion/react';
4
- import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
5
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
5
6
  /**
6
7
  * Calculates the image width for non-resized images.
7
8
  *
@@ -1,6 +1,8 @@
1
+ import type { ReactElement } from 'react';
1
2
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  import type { Step } from '@atlaskit/editor-prosemirror/transform';
5
+ import type { Providers } from '../provider-factory';
4
6
  export type NewCollabSyncUpErrorAttributes = {
5
7
  lengthOfUnconfirmedSteps?: number;
6
8
  tries: number;
@@ -348,4 +350,27 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
348
350
  } & Events[K]): void;
349
351
  getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
350
352
  }
353
+ export type CollabEditOptions = {
354
+ provider?: Providers['collabEditProvider'];
355
+ userId?: string;
356
+ useNativePlugin?: boolean;
357
+ } & CollabInviteToEditProps & CollabAnalyticsProps;
358
+ export type InviteToEditButtonProps = {
359
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
360
+ selected: boolean;
361
+ };
362
+ export type InviteToEditComponentProps = {
363
+ children: ReactElement<InviteToEditButtonProps>;
364
+ };
365
+ export interface CollabInviteToEditProps {
366
+ inviteToEditHandler?: (event: React.MouseEvent<HTMLElement>) => void;
367
+ isInviteToEditButtonSelected?: boolean;
368
+ inviteToEditComponent?: React.ComponentType<InviteToEditComponentProps>;
369
+ }
370
+ export interface CollabAnalyticsProps {
371
+ /**
372
+ * @description Control wether Synchrony entity error events are tracked
373
+ */
374
+ EXPERIMENTAL_allowInternalErrorAnalytics?: boolean;
375
+ }
351
376
  export {};
@@ -1 +1,2 @@
1
1
  export declare const MEDIA_DYNAMIC_GUIDELINE_PREFIX = "media_";
2
+ export declare const INNER_GRID_GUIDELINE_PREFIX = "grid_";
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@atlaskit/editor-prosemirror/state';
1
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { GuidelineConfig } from './types';
3
3
  export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
4
4
  styles?: {
@@ -2,7 +2,7 @@ export { generateDynamicGuidelines } from './dynamicGuideline';
2
2
  export { createFixedGuidelinesFromLengths, createGuidesFromLengths, } from './fixedGuideline';
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
- export { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
6
- export type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, } from './types';
7
- export { getSnapWidth, findClosestSnap } from './snapping';
5
+ export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX, } from './constants';
6
+ export type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, GuidelineSnap, GuidelineSnapsReference, } from './types';
7
+ export { getGuidelineSnaps, findClosestSnap } from './snapping';
8
8
  export { isVerticalPosition, getContainerWidthOrFullEditorWidth, } from './utils';
@@ -1,18 +1,19 @@
1
- import { RichMediaLayout } from '@atlaskit/adf-schema';
2
- import type { GuidelineConfig } from './types';
3
- export type SnapTo = {
4
- guidelineKey: string;
5
- width: number;
6
- };
1
+ import type { RichMediaLayout } from '@atlaskit/adf-schema';
2
+ import type { GuidelineConfig, GuidelineSnap } from './types';
7
3
  /**
8
4
  * Returns keys of guidelines that are closest to the image and withthin the snapGap.
9
5
  * If both default and dynamic guidelines present, only returns default guidelines
10
6
  */
11
- export declare const findClosestSnap: (mediaSingleWidth: number, snapArray: number[], snapTo: SnapTo[], snapGap?: number) => {
7
+ export declare const findClosestSnap: (mediaSingleWidth: number, snapArray: number[], guidelineSnaps: GuidelineSnap[], snapGap?: number) => {
12
8
  gap: number;
13
9
  keys: string[];
14
10
  };
15
- /**
16
- * Get snapping widths and respective guideline keys
17
- */
18
- export declare const getSnapWidth: (guidelines: GuidelineConfig[], mediaSingleWidth: number, snap: number, layout: RichMediaLayout | null) => SnapTo[];
11
+ export declare const getGuidelineSnaps: import("memoize-one").MemoizedFn<(guidelines: GuidelineConfig[], editorWidth: number, layout?: RichMediaLayout) => {
12
+ guidelineReference: {
13
+ guidelineKey: string;
14
+ width: number;
15
+ }[];
16
+ snaps: {
17
+ x: number[] | undefined;
18
+ };
19
+ }>;
@@ -1,5 +1,5 @@
1
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
2
- import { CSSToken } from '@atlaskit/tokens';
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { CSSToken } from '@atlaskit/tokens';
3
3
  export declare enum WidthTypes {
4
4
  PERCENTAGE = "percentage",
5
5
  PIXEL = "pixel"
@@ -40,3 +40,14 @@ export interface GuidelinePluginOptions {
40
40
  }
41
41
  export type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
42
42
  export type DisplayGuideline = (view: EditorView) => DisplayGrid;
43
+ export type GuidelineSnap = {
44
+ guidelineKey: string;
45
+ width: number;
46
+ };
47
+ export type GuidelineSnapsReference = {
48
+ snaps: {
49
+ x?: number[];
50
+ y?: number[];
51
+ };
52
+ guidelineReference: GuidelineSnap[];
53
+ };
@@ -2,6 +2,7 @@
2
2
  import React from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import type { Command } from '../types/command';
5
+ import type { PluginCommand } from '../types/plugin-command';
5
6
  export declare const addAltText: Keymap;
6
7
  export declare const navToEditorToolbar: Keymap;
7
8
  export declare const navToFloatingToolbar: Keymap;
@@ -85,7 +86,10 @@ export interface Keymap {
85
86
  common?: string;
86
87
  }
87
88
  export declare function bindKeymapWithCommand(shortcut: string, cmd: Command, keymap: {
88
- [key: string]: Function;
89
+ [key: string]: Command;
90
+ }): void;
91
+ export declare function bindKeymapWithPluginCommand(shortcut: string, cmd: PluginCommand, keymap: {
92
+ [key: string]: Command;
89
93
  }): void;
90
94
  export declare function findKeyMapForBrowser(keyMap: Keymap): string | undefined;
91
95
  export { DOWN, HEADING_KEYS, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, LEFT, RIGHT, UP, } from './consts';
@@ -1,2 +1,3 @@
1
1
  export { EditorPresetBuilder } from './builder';
2
2
  export { EditorPluginInjectionAPI } from './plugin-injection-api';
3
+ export { pluginCommandToPMCommand } from './plugin-commands';
@@ -0,0 +1,3 @@
1
+ import type { Command } from '../types/command';
2
+ import type { PluginCommand } from '../types/plugin-command';
3
+ export declare function pluginCommandToPMCommand(command: PluginCommand | undefined): Command;
@@ -32,6 +32,7 @@ interface PluginInjectionAPIDefinition {
32
32
  export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefinition {
33
33
  private sharedStateAPI;
34
34
  private actionsAPI;
35
+ private commandsAPI;
35
36
  private plugins;
36
37
  constructor({ getEditorState }: SharedStateAPIProps);
37
38
  api<T extends NextEditorPlugin<any, any>>(): {
@@ -1,4 +1,4 @@
1
- import { Node } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node } from '@atlaskit/editor-prosemirror/model';
2
2
  export interface Transformer<T> {
3
3
  encode(node: Node): T;
4
4
  parse(content: T): Node;
@@ -29,6 +29,7 @@ export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin
29
29
  export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
30
30
  export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
31
31
  export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, } from './next-editor-plugin';
32
+ export type { PluginCommand, PluginCommandWithMetadata, } from './plugin-command';
32
33
  export type IconProps = {
33
34
  label?: string;
34
35
  };
@@ -43,3 +44,5 @@ export type { AllowedBlockTypes, HeadingLevels, NormalTextLevel, HeadingLevelsAn
43
44
  export type { ColumnResizingPluginState } from './tables';
44
45
  export type { InputRuleHandler, OnHandlerApply, InputRuleWrapper, } from './input-rules';
45
46
  export type { TextFormattingOptions, TextFormattingState, InputMethodToolbar, InputMethodBasic, } from './text-formatting';
47
+ export type { LayoutPluginOptions } from './layout';
48
+ export type { LongPressSelectionPluginOptions } from './selection';
@@ -0,0 +1,6 @@
1
+ import type { LongPressSelectionPluginOptions } from './selection';
2
+ export interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
3
+ allowBreakout?: boolean;
4
+ UNSAFE_addSidebarLayouts?: boolean;
5
+ UNSAFE_allowSingleColumnLayout?: boolean;
6
+ }
@@ -6,25 +6,32 @@
6
6
  */
7
7
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
8
  import type { EditorPlugin } from './editor-plugin';
9
+ import type { PluginCommand, PluginCommandWithMetadata } from './plugin-command';
9
10
  type IsAny<T> = 0 extends 1 & T ? true : false;
10
11
  type PickSharedStatePropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractSharedStateFromMetadata<Metadata> extends never ? never : 'getSharedState';
11
12
  type WithSharedState<Metadata extends NextEditorPluginMetadata> = {
12
13
  [Property in keyof Pick<Metadata, 'sharedState'> as PickSharedStatePropertyName<Metadata>]: (editorState: EditorState | undefined) => ExtractSharedStateFromMetadata<Metadata>;
13
14
  };
14
15
  type PickActionsPropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractActionsFromMetadata<Metadata> extends never ? never : 'actions';
16
+ type PickCommandsPropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractCommandsFromMetadata<Metadata> extends never ? never : 'commands';
15
17
  type WithActions<Metadata extends NextEditorPluginMetadata> = {
16
18
  [Property in keyof Pick<Metadata, 'actions'> as PickActionsPropertyName<Metadata>]: ExtractActionsFromMetadata<Metadata>;
17
19
  };
18
- export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata> = EditorPlugin & WithSharedState<Metadata> & WithActions<Metadata> & {
20
+ type WithCommands<Metadata extends NextEditorPluginMetadata> = {
21
+ [Property in keyof Pick<Metadata, 'commands'> as PickCommandsPropertyName<Metadata>]: ExtractCommandsFromMetadata<Metadata>;
22
+ };
23
+ export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata> = EditorPlugin & WithSharedState<Metadata> & WithActions<Metadata> & WithCommands<Metadata> & {
19
24
  name: Name;
20
25
  };
21
26
  type MaybeAction = ((...agrs: any) => any) | ((...agrs: any) => void);
22
27
  type NextEditorPluginActions = Record<string, MaybeAction>;
28
+ type NextEditorPluginCommands = Record<string, PluginCommandWithMetadata | PluginCommand>;
23
29
  export interface NextEditorPluginMetadata {
24
30
  readonly sharedState?: any;
25
31
  readonly pluginConfiguration?: any;
26
32
  readonly dependencies?: DependencyPlugin[];
27
33
  readonly actions?: NextEditorPluginActions;
34
+ readonly commands?: NextEditorPluginCommands;
28
35
  }
29
36
  export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
30
37
  dependencies: CreatePluginDependenciesAPI<[
@@ -62,6 +69,7 @@ type ExtractPluginDependenciesFromMetadata<Metadata> = 'dependencies' extends ke
62
69
  ];
63
70
  type ExtractSharedStateFromMetadata<Metadata> = 'sharedState' extends keyof Metadata ? Metadata['sharedState'] : never;
64
71
  type ExtractActionsFromMetadata<Metadata> = 'actions' extends keyof Metadata ? Metadata['actions'] : never;
72
+ type ExtractCommandsFromMetadata<Metadata> = 'commands' extends keyof Metadata ? Metadata['commands'] : never;
65
73
  type ExtractPluginConfigurationFromMetadata<Metadata> = 'pluginConfiguration' extends keyof Metadata ? Metadata['pluginConfiguration'] : never;
66
74
  export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
67
75
  type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
@@ -78,6 +86,7 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
78
86
  }) => void) => Unsubscribe;
79
87
  };
80
88
  actions: ExtractPluginActions<Plugin>;
89
+ commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
81
90
  };
82
91
  export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
83
92
  [Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> : never;
@@ -0,0 +1,7 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ type PluginCommandProps = {
3
+ tr: Transaction;
4
+ };
5
+ export type PluginCommand = (props: PluginCommandProps) => Transaction | null;
6
+ export type PluginCommandWithMetadata = (args: any) => PluginCommand;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface LongPressSelectionPluginOptions {
2
+ useLongPressSelection?: boolean;
3
+ }
@@ -1,7 +1,8 @@
1
1
  /** @jsx jsx */
2
- import React, { RefObject } from 'react';
2
+ import type { RefObject } from 'react';
3
+ import React from 'react';
3
4
  import { jsx } from '@emotion/react';
4
- import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
5
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
5
6
  /**
6
7
  * Calculates the image width for non-resized images.
7
8
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.36.4",
3
+ "version": "74.38.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/"