@atlaskit/editor-common 74.41.2 → 74.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/analytics/types/table-events.js +1 -0
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/preset/plugin-commands.js +10 -0
  5. package/dist/cjs/preset/plugin-injection-api.js +17 -2
  6. package/dist/cjs/quick-insert/assets/action.js +23 -6
  7. package/dist/cjs/quick-insert/assets/code.js +31 -8
  8. package/dist/cjs/quick-insert/assets/decision.js +19 -5
  9. package/dist/cjs/quick-insert/assets/divider.js +35 -9
  10. package/dist/cjs/quick-insert/use-icon-themed.js +20 -0
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/es2019/analytics/types/table-events.js +1 -0
  14. package/dist/es2019/monitoring/error.js +1 -1
  15. package/dist/es2019/preset/plugin-commands.js +10 -0
  16. package/dist/es2019/preset/plugin-injection-api.js +17 -2
  17. package/dist/es2019/quick-insert/assets/action.js +24 -6
  18. package/dist/es2019/quick-insert/assets/code.js +32 -8
  19. package/dist/es2019/quick-insert/assets/decision.js +20 -5
  20. package/dist/es2019/quick-insert/assets/divider.js +36 -9
  21. package/dist/es2019/quick-insert/use-icon-themed.js +14 -0
  22. package/dist/es2019/ui/DropList/index.js +1 -1
  23. package/dist/es2019/version.json +1 -1
  24. package/dist/esm/analytics/types/table-events.js +1 -0
  25. package/dist/esm/monitoring/error.js +1 -1
  26. package/dist/esm/preset/plugin-commands.js +10 -0
  27. package/dist/esm/preset/plugin-injection-api.js +17 -2
  28. package/dist/esm/quick-insert/assets/action.js +23 -6
  29. package/dist/esm/quick-insert/assets/code.js +31 -8
  30. package/dist/esm/quick-insert/assets/decision.js +19 -5
  31. package/dist/esm/quick-insert/assets/divider.js +35 -9
  32. package/dist/esm/quick-insert/use-icon-themed.js +13 -0
  33. package/dist/esm/ui/DropList/index.js +1 -1
  34. package/dist/esm/version.json +1 -1
  35. package/dist/types/analytics/types/table-events.d.ts +11 -3
  36. package/dist/types/hooks/useSharedPluginState.d.ts +5 -5
  37. package/dist/types/preset/plugin-commands.d.ts +10 -0
  38. package/dist/types/preset/plugin-injection-api.d.ts +9 -1
  39. package/dist/types/quick-insert/use-icon-themed.d.ts +9 -0
  40. package/dist/types/types/next-editor-plugin.d.ts +8 -0
  41. package/dist/types-ts4.5/analytics/types/table-events.d.ts +11 -3
  42. package/dist/types-ts4.5/hooks/useSharedPluginState.d.ts +5 -5
  43. package/dist/types-ts4.5/preset/plugin-commands.d.ts +10 -0
  44. package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +9 -1
  45. package/dist/types-ts4.5/quick-insert/use-icon-themed.d.ts +9 -0
  46. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +8 -0
  47. package/package.json +1 -1
@@ -1,9 +1,14 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { DefaultEditorPlugin, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
4
+ import type { PluginCommand } from '../types/plugin-command';
3
5
  type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
4
6
  type SharedStateAPIProps = {
5
7
  getEditorState: () => EditorState | undefined;
6
8
  };
9
+ interface PluginInjectionAPIProps extends SharedStateAPIProps {
10
+ getEditorView: () => EditorView | undefined;
11
+ }
7
12
  type EditorStateDiff = {
8
13
  readonly newEditorState: EditorState;
9
14
  readonly oldEditorState: EditorState | undefined;
@@ -34,10 +39,13 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
34
39
  private actionsAPI;
35
40
  private commandsAPI;
36
41
  private plugins;
37
- constructor({ getEditorState }: SharedStateAPIProps);
42
+ private getEditorView;
43
+ constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
38
44
  api<T extends NextEditorPlugin<any, any>>(): {
39
45
  dependencies: import("../types/next-editor-plugin").CreatePluginDependenciesAPI<[NextEditorPlugin<T extends (config?: any, api?: PluginInjectionAPI<infer Name extends string, any> | undefined) => DefaultEditorPlugin<infer Name extends string, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>, ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (((config?: any, api?: PluginInjectionAPI<any, any> | undefined) => DefaultEditorPlugin<any, any>) | import("../types/next-editor-plugin").OptionalPlugin<(config?: any, api?: PluginInjectionAPI<any, any> | undefined) => DefaultEditorPlugin<any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [] : []]>;
46
+ executeCommand: (command: PluginCommand | undefined) => boolean;
40
47
  };
48
+ private executeCommand;
41
49
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
42
50
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
43
51
  private addPlugin;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Warning -- if additional color modes beyond light and dark are added in future -- this will have unexpected behaviour
3
+ */
4
+ export declare const useIconThemed: () => {
5
+ iconThemed: (colors: {
6
+ light: string;
7
+ dark: string;
8
+ }) => string;
9
+ };
@@ -38,6 +38,14 @@ export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorP
38
38
  NextEditorPlugin<Name, Metadata>,
39
39
  ...ExtractPluginDependenciesFromMetadata<Metadata>
40
40
  ]>;
41
+ /**
42
+ * Dispatches a PluginCommand to ProseMirror
43
+ *
44
+ * @param action A function (PluginCommand | undefined) that takes a `Transaction` and returns a `Transaction` if it
45
+ * is successful or `null` if it shouldn't be dispatched.
46
+ * @returns (boolean) if the command was successful in dispatching
47
+ */
48
+ executeCommand: (action: PluginCommand | undefined) => boolean;
41
49
  };
42
50
  export type PluginInjectionAPIWithDependency<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? {
43
51
  dependencies: CreatePluginDependenciesAPI<[
@@ -1,6 +1,6 @@
1
1
  import type { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
2
2
  import type { ACTION_SUBJECT, INPUT_METHOD } from './enums';
3
- import type { TableAEP, UIAEP } from './utils';
3
+ import type { OperationalAEP, TableAEP, UIAEP } from './utils';
4
4
  export declare enum TABLE_ACTION {
5
5
  DELETED = "deleted",
6
6
  CLEARED = "cleared",
@@ -23,7 +23,8 @@ export declare enum TABLE_ACTION {
23
23
  ATTEMPTED_TABLE_WIDTH_CHANGE = "attemptedTableWidthChange",
24
24
  DISTRIBUTED_COLUMNS_WIDTHS = "distributedColumnsWidths",
25
25
  FIXED = "fixed",
26
- RESIZED = "resized"
26
+ RESIZED = "resized",
27
+ RESIZE_PERF_SAMPLING = "resizePerfSampling"
27
28
  }
28
29
  export declare enum TABLE_BREAKOUT {
29
30
  WIDE = "wide",
@@ -57,6 +58,12 @@ type ResizedInfo = {
57
58
  totalTableWidth: number | null;
58
59
  nodeSize: number;
59
60
  } & TotalRowAndColCount;
61
+ type ResizePreviewInfo = {
62
+ frameRate: number;
63
+ isInitialSample: boolean;
64
+ docSize: number;
65
+ nodeSize: number;
66
+ };
60
67
  type TableDeleteAEP = TableAEP<TABLE_ACTION.DELETED, {
61
68
  inputMethod: INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB;
62
69
  } & TotalRowAndColCount, undefined>;
@@ -106,5 +113,6 @@ type TableFixedAEP = TableAEP<TABLE_ACTION.FIXED, {
106
113
  reason: string;
107
114
  }, undefined>;
108
115
  type TableResizedAEP = TableAEP<TABLE_ACTION.RESIZED, ResizedInfo, undefined>;
109
- export type TableEventPayload = TableDeleteAEP | TableClearAEP | TableMergeSplitAEP | TableColorAEP | TableToggleHeaderAEP | TableChangeBreakoutAEP | TableCopyAndCutAEP | TableAddRowOrColumnAEP | TableSortColumnAEP | TableDeleteRowOrColumnAEP | TableReplaceAEP | TableAttemptedResizeAEP | TableDistributeColumnsWidthsAEP | TableCollapsedAEP | TableFixedAEP | TableResizedAEP;
116
+ type TableResizePerfSamplingAEP = OperationalAEP<TABLE_ACTION.RESIZE_PERF_SAMPLING, ACTION_SUBJECT.TABLE, undefined, ResizePreviewInfo, undefined>;
117
+ export type TableEventPayload = TableDeleteAEP | TableClearAEP | TableMergeSplitAEP | TableColorAEP | TableToggleHeaderAEP | TableChangeBreakoutAEP | TableCopyAndCutAEP | TableAddRowOrColumnAEP | TableSortColumnAEP | TableDeleteRowOrColumnAEP | TableReplaceAEP | TableAttemptedResizeAEP | TableDistributeColumnsWidthsAEP | TableCollapsedAEP | TableFixedAEP | TableResizedAEP | TableResizePerfSamplingAEP;
110
118
  export {};
@@ -1,8 +1,8 @@
1
- import type { ExtractPluginSharedState, NextEditorPluginMetadata, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
2
- type NamedPluginStatesFromInjectionAPI<API extends PluginInjectionAPI<any, any> | undefined, PluginList extends string[]> = Readonly<{
3
- [K in PluginList[number] as `${K}State`]: API extends PluginInjectionAPI<any, any> ? API['dependencies'][K] extends PluginDependenciesAPI<infer Plugin> | undefined ? ExtractPluginSharedState<Plugin> | undefined : never : never;
1
+ import type { ExtractPluginSharedState, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPIWithDependencies } from '../types/next-editor-plugin';
2
+ type NamedPluginStatesFromInjectionAPI<API extends PluginInjectionAPIWithDependencies<any> | undefined, PluginList extends string[]> = Readonly<{
3
+ [K in PluginList[number] as `${K}State`]: API extends PluginInjectionAPIWithDependencies<any> ? API['dependencies'][K] extends PluginDependenciesAPI<infer Plugin> | undefined ? ExtractPluginSharedState<Plugin> | undefined : never : never;
4
4
  }>;
5
- type ExtractPluginNames<Name extends string, Metadata extends NextEditorPluginMetadata> = keyof PluginInjectionAPI<Name, Metadata>['dependencies'];
5
+ type ExtractPluginNames<API extends PluginInjectionAPIWithDependencies<any>> = API extends PluginInjectionAPIWithDependencies<any> ? keyof API['dependencies'] : never;
6
6
  /**
7
7
  *
8
8
  * Used to return the current plugin state of
@@ -35,5 +35,5 @@ type ExtractPluginNames<Name extends string, Metadata extends NextEditorPluginMe
35
35
  * @returns A corresponding object, the keys are names of the plugin with `State` appended,
36
36
  * the values are the shared state exposed by that plugin.
37
37
  */
38
- export declare function useSharedPluginState<Name extends string, Metadata extends NextEditorPluginMetadata, PluginNames extends ExtractPluginNames<Name, Metadata>[]>(injectionApi: PluginInjectionAPI<Name, Metadata> | undefined, plugins: PluginNames): NamedPluginStatesFromInjectionAPI<typeof injectionApi, PluginNames>;
38
+ export declare function useSharedPluginState<Plugins extends NextEditorPlugin<any, any>[], PluginNames extends ExtractPluginNames<PluginInjectionAPIWithDependencies<Plugins>>[]>(injectionApi: PluginInjectionAPIWithDependencies<Plugins> | undefined, plugins: PluginNames): NamedPluginStatesFromInjectionAPI<typeof injectionApi, PluginNames>;
39
39
  export {};
@@ -1,3 +1,13 @@
1
1
  import type { Command } from '../types/command';
2
2
  import type { PluginCommand } from '../types/plugin-command';
3
+ /**
4
+ * Convert a PluginCommand to a standard Prosemirror Command.
5
+ * The preferred approach to dispatching a `PluginCommand` is via the
6
+ * `executeCommand` on `pluginInjectionAPI`. In some cases
7
+ * the type may require a Command until we refactor this out and this
8
+ * function is suitable for those cases.
9
+ *
10
+ * @param command A plugin command (a function that modifies and returns a `Transaction`)
11
+ * @returns Command
12
+ */
3
13
  export declare function pluginCommandToPMCommand(command: PluginCommand | undefined): Command;
@@ -1,9 +1,14 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { DefaultEditorPlugin, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
4
+ import type { PluginCommand } from '../types/plugin-command';
3
5
  type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
4
6
  type SharedStateAPIProps = {
5
7
  getEditorState: () => EditorState | undefined;
6
8
  };
9
+ interface PluginInjectionAPIProps extends SharedStateAPIProps {
10
+ getEditorView: () => EditorView | undefined;
11
+ }
7
12
  type EditorStateDiff = {
8
13
  readonly newEditorState: EditorState;
9
14
  readonly oldEditorState: EditorState | undefined;
@@ -34,7 +39,8 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
34
39
  private actionsAPI;
35
40
  private commandsAPI;
36
41
  private plugins;
37
- constructor({ getEditorState }: SharedStateAPIProps);
42
+ private getEditorView;
43
+ constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
38
44
  api<T extends NextEditorPlugin<any, any>>(): {
39
45
  dependencies: import("../types/next-editor-plugin").CreatePluginDependenciesAPI<[
40
46
  NextEditorPlugin<T extends (config?: any, api?: PluginInjectionAPI<infer Name extends string, any> | undefined) => DefaultEditorPlugin<infer Name extends string, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>,
@@ -42,7 +48,9 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
42
48
  ] : [
43
49
  ]
44
50
  ]>;
51
+ executeCommand: (command: PluginCommand | undefined) => boolean;
45
52
  };
53
+ private executeCommand;
46
54
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
47
55
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
48
56
  private addPlugin;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Warning -- if additional color modes beyond light and dark are added in future -- this will have unexpected behaviour
3
+ */
4
+ export declare const useIconThemed: () => {
5
+ iconThemed: (colors: {
6
+ light: string;
7
+ dark: string;
8
+ }) => string;
9
+ };
@@ -38,6 +38,14 @@ export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorP
38
38
  NextEditorPlugin<Name, Metadata>,
39
39
  ...ExtractPluginDependenciesFromMetadata<Metadata>
40
40
  ]>;
41
+ /**
42
+ * Dispatches a PluginCommand to ProseMirror
43
+ *
44
+ * @param action A function (PluginCommand | undefined) that takes a `Transaction` and returns a `Transaction` if it
45
+ * is successful or `null` if it shouldn't be dispatched.
46
+ * @returns (boolean) if the command was successful in dispatching
47
+ */
48
+ executeCommand: (action: PluginCommand | undefined) => boolean;
41
49
  };
42
50
  export type PluginInjectionAPIWithDependency<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? {
43
51
  dependencies: CreatePluginDependenciesAPI<[
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.41.2",
3
+ "version": "74.42.1",
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/"