@atlaskit/editor-common 74.45.5 → 74.46.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 (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/guideline/dynamicGuideline.js +76 -48
  3. package/dist/cjs/guideline/index.js +20 -1
  4. package/dist/cjs/guideline/relativeGuideline.js +145 -0
  5. package/dist/cjs/keymaps/index.js +4 -4
  6. package/dist/cjs/monitoring/error.js +1 -1
  7. package/dist/cjs/preset/{plugin-commands.js → editor-commands.js} +4 -4
  8. package/dist/cjs/preset/index.js +3 -3
  9. package/dist/cjs/preset/plugin-injection-api.js +8 -8
  10. package/dist/cjs/ui/DropList/index.js +1 -1
  11. package/dist/es2019/guideline/dynamicGuideline.js +87 -54
  12. package/dist/es2019/guideline/index.js +2 -1
  13. package/dist/es2019/guideline/relativeGuideline.js +143 -0
  14. package/dist/es2019/keymaps/index.js +3 -3
  15. package/dist/es2019/monitoring/error.js +1 -1
  16. package/dist/es2019/preset/{plugin-commands.js → editor-commands.js} +3 -3
  17. package/dist/es2019/preset/index.js +1 -1
  18. package/dist/es2019/preset/plugin-injection-api.js +4 -4
  19. package/dist/es2019/ui/DropList/index.js +1 -1
  20. package/dist/esm/guideline/dynamicGuideline.js +76 -48
  21. package/dist/esm/guideline/index.js +2 -1
  22. package/dist/esm/guideline/relativeGuideline.js +136 -0
  23. package/dist/esm/keymaps/index.js +3 -3
  24. package/dist/esm/monitoring/error.js +1 -1
  25. package/dist/esm/preset/{plugin-commands.js → editor-commands.js} +3 -3
  26. package/dist/esm/preset/index.js +1 -1
  27. package/dist/esm/preset/plugin-injection-api.js +8 -8
  28. package/dist/esm/ui/DropList/index.js +1 -1
  29. package/dist/types/guideline/dynamicGuideline.d.ts +5 -26
  30. package/dist/types/guideline/index.d.ts +3 -2
  31. package/dist/types/guideline/relativeGuideline.d.ts +8 -0
  32. package/dist/types/guideline/types.d.ts +14 -3
  33. package/dist/types/keymaps/index.d.ts +2 -2
  34. package/dist/types/mark/commands.d.ts +2 -2
  35. package/dist/{types-ts4.5/preset/plugin-commands.d.ts → types/preset/editor-commands.d.ts} +4 -4
  36. package/dist/types/preset/index.d.ts +1 -1
  37. package/dist/types/preset/plugin-injection-api.d.ts +2 -2
  38. package/dist/types/types/editor-command.d.ts +5 -0
  39. package/dist/types/types/index.d.ts +2 -2
  40. package/dist/types/types/next-editor-plugin.d.ts +17 -6
  41. package/dist/types-ts4.5/guideline/dynamicGuideline.d.ts +5 -26
  42. package/dist/types-ts4.5/guideline/index.d.ts +3 -2
  43. package/dist/types-ts4.5/guideline/relativeGuideline.d.ts +8 -0
  44. package/dist/types-ts4.5/guideline/types.d.ts +14 -3
  45. package/dist/types-ts4.5/keymaps/index.d.ts +2 -2
  46. package/dist/types-ts4.5/mark/commands.d.ts +2 -2
  47. package/dist/{types/preset/plugin-commands.d.ts → types-ts4.5/preset/editor-commands.d.ts} +4 -4
  48. package/dist/types-ts4.5/preset/index.d.ts +1 -1
  49. package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +2 -2
  50. package/dist/types-ts4.5/types/editor-command.d.ts +5 -0
  51. package/dist/types-ts4.5/types/index.d.ts +2 -2
  52. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +17 -6
  53. package/package.json +1 -1
  54. package/dist/cjs/version.json +0 -5
  55. package/dist/es2019/version.json +0 -5
  56. package/dist/esm/version.json +0 -5
  57. package/dist/types/types/plugin-command.d.ts +0 -7
  58. package/dist/types-ts4.5/types/plugin-command.d.ts +0 -7
  59. /package/dist/cjs/types/{plugin-command.js → editor-command.js} +0 -0
  60. /package/dist/es2019/types/{plugin-command.js → editor-command.js} +0 -0
  61. /package/dist/esm/types/{plugin-command.js → editor-command.js} +0 -0
@@ -1,27 +1,6 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import type { GuidelineConfig } from './types';
3
- export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
4
- styles?: {
5
- capStyle?: "line" | undefined;
6
- lineStyle?: "dashed" | "solid" | undefined;
7
- color?: import("@atlaskit/tokens").CSSToken | undefined;
8
- } | undefined;
9
- show?: boolean | undefined;
10
- active?: boolean | undefined;
11
- position: {
12
- x: number;
13
- };
14
- key: string;
15
- } | {
16
- styles?: {
17
- capStyle?: "line" | undefined;
18
- lineStyle?: "dashed" | "solid" | undefined;
19
- color?: import("@atlaskit/tokens").CSSToken | undefined;
20
- } | undefined;
21
- show?: boolean | undefined;
22
- active?: boolean | undefined;
23
- position: {
24
- x: number;
25
- };
26
- key: string;
27
- })[];
2
+ import type { GuidelineConfig, GuidelineStyles, RelativeGuides } from './types';
3
+ export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: GuidelineStyles) => {
4
+ dynamicGuides: GuidelineConfig[];
5
+ relativeGuides: RelativeGuides;
6
+ };
@@ -3,6 +3,7 @@ export { createFixedGuidelinesFromLengths, createGuidesFromLengths, } from './fi
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
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, GuidelineTypes, } from './types';
6
+ export type { WidthTypes, Position, GuidelineStyles, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, RelativeGuides, GuidelineSnap, GuidelineSnapsReference, GuidelineTypes, } from './types';
7
7
  export { getGuidelineSnaps, findClosestSnap } from './snapping';
8
- export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
8
+ export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
9
+ export { getRelativeGuideSnaps, getRelativeGuidelines, } from './relativeGuideline';
@@ -0,0 +1,8 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { GuidelineConfig, RelativeGuides } from './types';
4
+ export declare const getRelativeGuideSnaps: (relativeGuides: RelativeGuides, aspectRatio: number) => number[];
5
+ export declare const getRelativeGuidelines: (relativeGuides: RelativeGuides, nodeWithPos: NodeWithPos, view: EditorView, editorWidth: number, size: {
6
+ width: number;
7
+ height: number;
8
+ }) => GuidelineConfig[];
@@ -1,3 +1,4 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
1
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { CSSToken } from '@atlaskit/tokens';
3
4
  export type WidthTypes = 'percentage' | 'pixel';
@@ -19,9 +20,7 @@ export type HorizontalPosition = {
19
20
  y: number;
20
21
  };
21
22
  export type Position = VerticalPosition | HorizontalPosition;
22
- export type GuidelineConfig = {
23
- key: string;
24
- position: Position;
23
+ export type GuidelineStyles = {
25
24
  active?: boolean;
26
25
  show?: boolean;
27
26
  styles?: {
@@ -30,6 +29,10 @@ export type GuidelineConfig = {
30
29
  color?: CSSToken;
31
30
  };
32
31
  };
32
+ export type GuidelineConfig = {
33
+ key: string;
34
+ position: Position;
35
+ } & GuidelineStyles;
33
36
  export type GuidelinePluginState = {
34
37
  guidelines: GuidelineConfig[];
35
38
  };
@@ -49,3 +52,11 @@ export type GuidelineSnapsReference = {
49
52
  guidelineReference: GuidelineSnap[];
50
53
  };
51
54
  export type GuidelineTypes = 'default' | 'temporary' | 'relative' | 'none';
55
+ export type RelativeGuides = {
56
+ width?: {
57
+ [key: number]: NodeWithPos[];
58
+ };
59
+ height?: {
60
+ [key: number]: NodeWithPos[];
61
+ };
62
+ };
@@ -2,7 +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
+ import type { EditorCommand } from '../types/editor-command';
6
6
  export declare const addAltText: Keymap;
7
7
  export declare const navToEditorToolbar: Keymap;
8
8
  export declare const navToFloatingToolbar: Keymap;
@@ -88,7 +88,7 @@ export interface Keymap {
88
88
  export declare function bindKeymapWithCommand(shortcut: string, cmd: Command, keymap: {
89
89
  [key: string]: Command;
90
90
  }): void;
91
- export declare function bindKeymapWithPluginCommand(shortcut: string, cmd: PluginCommand, keymap: {
91
+ export declare function bindKeymapWithEditorCommand(shortcut: string, cmd: EditorCommand, keymap: {
92
92
  [key: string]: Command;
93
93
  }): void;
94
94
  export declare function findKeyMapForBrowser(keyMap: Keymap): string | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { Mark, MarkType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { PluginCommand } from '../types';
3
+ import type { EditorCommand } from '../types';
4
4
  export declare function filterChildrenBetween(doc: PMNode, from: number, to: number, predicate: (node: PMNode, pos: number, parent: PMNode | null) => boolean | undefined): {
5
5
  node: PMNode;
6
6
  pos: number;
@@ -15,4 +15,4 @@ export declare const applyMarkOnRange: (from: number, to: number, removeMark: bo
15
15
  */
16
16
  export declare const toggleMark: (markType: MarkType, attrs?: {
17
17
  [key: string]: any;
18
- } | undefined) => PluginCommand;
18
+ } | undefined) => EditorCommand;
@@ -1,8 +1,8 @@
1
1
  import type { Command } from '../types/command';
2
- import type { PluginCommand } from '../types/plugin-command';
2
+ import type { EditorCommand } from '../types/editor-command';
3
3
  /**
4
- * Convert a PluginCommand to a standard Prosemirror Command.
5
- * The preferred approach to dispatching a `PluginCommand` is via the
4
+ * Convert a EditorCommand to a standard Prosemirror Command.
5
+ * The preferred approach to dispatching a `EditorCommand` is via the
6
6
  * `executeCommand` on `pluginInjectionAPI`. In some cases
7
7
  * the type may require a Command until we refactor this out and this
8
8
  * function is suitable for those cases.
@@ -10,4 +10,4 @@ import type { PluginCommand } from '../types/plugin-command';
10
10
  * @param command A plugin command (a function that modifies and returns a `Transaction`)
11
11
  * @returns Command
12
12
  */
13
- export declare function pluginCommandToPMCommand(command: PluginCommand | undefined): Command;
13
+ export declare function editorCommandToPMCommand(command: EditorCommand | undefined): Command;
@@ -1,3 +1,3 @@
1
1
  export { EditorPresetBuilder } from './builder';
2
2
  export { EditorPluginInjectionAPI } from './plugin-injection-api';
3
- export { pluginCommandToPMCommand } from './plugin-commands';
3
+ export { editorCommandToPMCommand } from './editor-commands';
@@ -1,7 +1,7 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorCommand } from '../types/editor-command';
3
4
  import type { DefaultEditorPlugin, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
4
- import type { PluginCommand } from '../types/plugin-command';
5
5
  type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
6
6
  type SharedStateAPIProps = {
7
7
  getEditorState: () => EditorState | undefined;
@@ -43,7 +43,7 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
43
43
  constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
44
44
  api<T extends NextEditorPlugin<any, any>>(): {
45
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;
46
+ executeCommand: (command: EditorCommand | undefined) => boolean;
47
47
  };
48
48
  private executeCommand;
49
49
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
@@ -0,0 +1,5 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export type EditorCommand = (props: {
3
+ tr: Transaction;
4
+ }) => Transaction | null;
5
+ export type EditorCommandWithMetadata = (args: any) => EditorCommand;
@@ -28,8 +28,8 @@ export type { EditorReactContext } from './editor-react-context';
28
28
  export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
29
29
  export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
30
30
  export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
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';
31
+ export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, PublicPluginAPI, } from './next-editor-plugin';
32
+ export type { EditorCommand, EditorCommandWithMetadata, } from './editor-command';
33
33
  export type IconProps = {
34
34
  label?: string;
35
35
  };
@@ -5,8 +5,8 @@
5
5
  * are put together - but for now `Builder` & `Preset` aim to beinterchangeable.
6
6
  */
7
7
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
+ import type { EditorCommand, EditorCommandWithMetadata } from './editor-command';
8
9
  import type { EditorPlugin } from './editor-plugin';
9
- import type { PluginCommand, PluginCommandWithMetadata } from './plugin-command';
10
10
  type IsAny<T> = 0 extends 1 & T ? true : false;
11
11
  type PickSharedStatePropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractSharedStateFromMetadata<Metadata> extends never ? never : 'getSharedState';
12
12
  type WithSharedState<Metadata extends NextEditorPluginMetadata> = {
@@ -25,13 +25,13 @@ export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditor
25
25
  };
26
26
  type MaybeAction = ((...agrs: any) => any) | ((...agrs: any) => void);
27
27
  type NextEditorPluginActions = Record<string, MaybeAction>;
28
- type NextEditorPluginCommands = Record<string, PluginCommandWithMetadata | PluginCommand>;
28
+ type NextEditorEditorCommands = Record<string, EditorCommandWithMetadata | EditorCommand>;
29
29
  export interface NextEditorPluginMetadata {
30
30
  readonly sharedState?: any;
31
31
  readonly pluginConfiguration?: any;
32
32
  readonly dependencies?: DependencyPlugin[];
33
33
  readonly actions?: NextEditorPluginActions;
34
- readonly commands?: NextEditorPluginCommands;
34
+ readonly commands?: NextEditorEditorCommands;
35
35
  }
36
36
  export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
37
37
  dependencies: CreatePluginDependenciesAPI<[
@@ -39,13 +39,13 @@ export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorP
39
39
  ...ExtractPluginDependenciesFromMetadata<Metadata>
40
40
  ]>;
41
41
  /**
42
- * Dispatches a PluginCommand to ProseMirror
42
+ * Dispatches an EditorCommand to ProseMirror
43
43
  *
44
- * @param action A function (PluginCommand | undefined) that takes a `Transaction` and returns a `Transaction` if it
44
+ * @param command A function (EditorCommand | undefined) that takes an object containing a `Transaction` and returns a `Transaction` if it
45
45
  * is successful or `null` if it shouldn't be dispatched.
46
46
  * @returns (boolean) if the command was successful in dispatching
47
47
  */
48
- executeCommand: (action: PluginCommand | undefined) => boolean;
48
+ executeCommand: (command: EditorCommand | undefined) => boolean;
49
49
  };
50
50
  export type PluginInjectionAPIWithDependency<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? {
51
51
  dependencies: CreatePluginDependenciesAPI<[
@@ -117,4 +117,15 @@ type CheckTupleRequirements<Plugin, Config, ArrayType> = unknown extends Config
117
117
  type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>, PluginAsArray<Plugin>> : never;
118
118
  export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends AllEditorPresetPluginTypes> = Plugin extends Array<any> ? Plugin extends [infer MaybePlugin, ...any] ? MaybePlugin extends NextEditorPlugin<any, any> ? ExtractPluginName<MaybePlugin> : never : never : Plugin extends NextEditorPlugin<any, any> ? ExtractPluginName<Plugin> : never;
119
119
  export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata> : never;
120
+ export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
121
+ dependencies: CreatePluginDependenciesAPI<PluginList>;
122
+ /**
123
+ * Dispatches an EditorCommand to ProseMirror
124
+ *
125
+ * @param command A function (EditorCommand | undefined) that takes an object containing a `Transaction` and returns a `Transaction` if it
126
+ * is successful or `null` if it shouldn't be dispatched.
127
+ * @returns (boolean) if the command was successful in dispatching
128
+ */
129
+ executeCommand: (command: EditorCommand | undefined) => boolean;
130
+ };
120
131
  export {};
@@ -1,27 +1,6 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import type { GuidelineConfig } from './types';
3
- export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
4
- styles?: {
5
- capStyle?: "line" | undefined;
6
- lineStyle?: "dashed" | "solid" | undefined;
7
- color?: import("@atlaskit/tokens").CSSToken | undefined;
8
- } | undefined;
9
- show?: boolean | undefined;
10
- active?: boolean | undefined;
11
- position: {
12
- x: number;
13
- };
14
- key: string;
15
- } | {
16
- styles?: {
17
- capStyle?: "line" | undefined;
18
- lineStyle?: "dashed" | "solid" | undefined;
19
- color?: import("@atlaskit/tokens").CSSToken | undefined;
20
- } | undefined;
21
- show?: boolean | undefined;
22
- active?: boolean | undefined;
23
- position: {
24
- x: number;
25
- };
26
- key: string;
27
- })[];
2
+ import type { GuidelineConfig, GuidelineStyles, RelativeGuides } from './types';
3
+ export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: GuidelineStyles) => {
4
+ dynamicGuides: GuidelineConfig[];
5
+ relativeGuides: RelativeGuides;
6
+ };
@@ -3,6 +3,7 @@ export { createFixedGuidelinesFromLengths, createGuidesFromLengths, } from './fi
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
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, GuidelineTypes, } from './types';
6
+ export type { WidthTypes, Position, GuidelineStyles, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, RelativeGuides, GuidelineSnap, GuidelineSnapsReference, GuidelineTypes, } from './types';
7
7
  export { getGuidelineSnaps, findClosestSnap } from './snapping';
8
- export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
8
+ export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
9
+ export { getRelativeGuideSnaps, getRelativeGuidelines, } from './relativeGuideline';
@@ -0,0 +1,8 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { GuidelineConfig, RelativeGuides } from './types';
4
+ export declare const getRelativeGuideSnaps: (relativeGuides: RelativeGuides, aspectRatio: number) => number[];
5
+ export declare const getRelativeGuidelines: (relativeGuides: RelativeGuides, nodeWithPos: NodeWithPos, view: EditorView, editorWidth: number, size: {
6
+ width: number;
7
+ height: number;
8
+ }) => GuidelineConfig[];
@@ -1,3 +1,4 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
1
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { CSSToken } from '@atlaskit/tokens';
3
4
  export type WidthTypes = 'percentage' | 'pixel';
@@ -19,9 +20,7 @@ export type HorizontalPosition = {
19
20
  y: number;
20
21
  };
21
22
  export type Position = VerticalPosition | HorizontalPosition;
22
- export type GuidelineConfig = {
23
- key: string;
24
- position: Position;
23
+ export type GuidelineStyles = {
25
24
  active?: boolean;
26
25
  show?: boolean;
27
26
  styles?: {
@@ -30,6 +29,10 @@ export type GuidelineConfig = {
30
29
  color?: CSSToken;
31
30
  };
32
31
  };
32
+ export type GuidelineConfig = {
33
+ key: string;
34
+ position: Position;
35
+ } & GuidelineStyles;
33
36
  export type GuidelinePluginState = {
34
37
  guidelines: GuidelineConfig[];
35
38
  };
@@ -49,3 +52,11 @@ export type GuidelineSnapsReference = {
49
52
  guidelineReference: GuidelineSnap[];
50
53
  };
51
54
  export type GuidelineTypes = 'default' | 'temporary' | 'relative' | 'none';
55
+ export type RelativeGuides = {
56
+ width?: {
57
+ [key: number]: NodeWithPos[];
58
+ };
59
+ height?: {
60
+ [key: number]: NodeWithPos[];
61
+ };
62
+ };
@@ -2,7 +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
+ import type { EditorCommand } from '../types/editor-command';
6
6
  export declare const addAltText: Keymap;
7
7
  export declare const navToEditorToolbar: Keymap;
8
8
  export declare const navToFloatingToolbar: Keymap;
@@ -88,7 +88,7 @@ export interface Keymap {
88
88
  export declare function bindKeymapWithCommand(shortcut: string, cmd: Command, keymap: {
89
89
  [key: string]: Command;
90
90
  }): void;
91
- export declare function bindKeymapWithPluginCommand(shortcut: string, cmd: PluginCommand, keymap: {
91
+ export declare function bindKeymapWithEditorCommand(shortcut: string, cmd: EditorCommand, keymap: {
92
92
  [key: string]: Command;
93
93
  }): void;
94
94
  export declare function findKeyMapForBrowser(keyMap: Keymap): string | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { Mark, MarkType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import type { PluginCommand } from '../types';
3
+ import type { EditorCommand } from '../types';
4
4
  export declare function filterChildrenBetween(doc: PMNode, from: number, to: number, predicate: (node: PMNode, pos: number, parent: PMNode | null) => boolean | undefined): {
5
5
  node: PMNode;
6
6
  pos: number;
@@ -15,4 +15,4 @@ export declare const applyMarkOnRange: (from: number, to: number, removeMark: bo
15
15
  */
16
16
  export declare const toggleMark: (markType: MarkType, attrs?: {
17
17
  [key: string]: any;
18
- } | undefined) => PluginCommand;
18
+ } | undefined) => EditorCommand;
@@ -1,8 +1,8 @@
1
1
  import type { Command } from '../types/command';
2
- import type { PluginCommand } from '../types/plugin-command';
2
+ import type { EditorCommand } from '../types/editor-command';
3
3
  /**
4
- * Convert a PluginCommand to a standard Prosemirror Command.
5
- * The preferred approach to dispatching a `PluginCommand` is via the
4
+ * Convert a EditorCommand to a standard Prosemirror Command.
5
+ * The preferred approach to dispatching a `EditorCommand` is via the
6
6
  * `executeCommand` on `pluginInjectionAPI`. In some cases
7
7
  * the type may require a Command until we refactor this out and this
8
8
  * function is suitable for those cases.
@@ -10,4 +10,4 @@ import type { PluginCommand } from '../types/plugin-command';
10
10
  * @param command A plugin command (a function that modifies and returns a `Transaction`)
11
11
  * @returns Command
12
12
  */
13
- export declare function pluginCommandToPMCommand(command: PluginCommand | undefined): Command;
13
+ export declare function editorCommandToPMCommand(command: EditorCommand | undefined): Command;
@@ -1,3 +1,3 @@
1
1
  export { EditorPresetBuilder } from './builder';
2
2
  export { EditorPluginInjectionAPI } from './plugin-injection-api';
3
- export { pluginCommandToPMCommand } from './plugin-commands';
3
+ export { editorCommandToPMCommand } from './editor-commands';
@@ -1,7 +1,7 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { EditorCommand } from '../types/editor-command';
3
4
  import type { DefaultEditorPlugin, NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin';
4
- import type { PluginCommand } from '../types/plugin-command';
5
5
  type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
6
6
  type SharedStateAPIProps = {
7
7
  getEditorState: () => EditorState | undefined;
@@ -48,7 +48,7 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
48
48
  ] : [
49
49
  ]
50
50
  ]>;
51
- executeCommand: (command: PluginCommand | undefined) => boolean;
51
+ executeCommand: (command: EditorCommand | undefined) => boolean;
52
52
  };
53
53
  private executeCommand;
54
54
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
@@ -0,0 +1,5 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ export type EditorCommand = (props: {
3
+ tr: Transaction;
4
+ }) => Transaction | null;
5
+ export type EditorCommandWithMetadata = (args: any) => EditorCommand;
@@ -28,8 +28,8 @@ export type { EditorReactContext } from './editor-react-context';
28
28
  export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
29
29
  export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
30
30
  export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
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';
31
+ export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, PublicPluginAPI, } from './next-editor-plugin';
32
+ export type { EditorCommand, EditorCommandWithMetadata, } from './editor-command';
33
33
  export type IconProps = {
34
34
  label?: string;
35
35
  };
@@ -5,8 +5,8 @@
5
5
  * are put together - but for now `Builder` & `Preset` aim to beinterchangeable.
6
6
  */
7
7
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
+ import type { EditorCommand, EditorCommandWithMetadata } from './editor-command';
8
9
  import type { EditorPlugin } from './editor-plugin';
9
- import type { PluginCommand, PluginCommandWithMetadata } from './plugin-command';
10
10
  type IsAny<T> = 0 extends 1 & T ? true : false;
11
11
  type PickSharedStatePropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractSharedStateFromMetadata<Metadata> extends never ? never : 'getSharedState';
12
12
  type WithSharedState<Metadata extends NextEditorPluginMetadata> = {
@@ -25,13 +25,13 @@ export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditor
25
25
  };
26
26
  type MaybeAction = ((...agrs: any) => any) | ((...agrs: any) => void);
27
27
  type NextEditorPluginActions = Record<string, MaybeAction>;
28
- type NextEditorPluginCommands = Record<string, PluginCommandWithMetadata | PluginCommand>;
28
+ type NextEditorEditorCommands = Record<string, EditorCommandWithMetadata | EditorCommand>;
29
29
  export interface NextEditorPluginMetadata {
30
30
  readonly sharedState?: any;
31
31
  readonly pluginConfiguration?: any;
32
32
  readonly dependencies?: DependencyPlugin[];
33
33
  readonly actions?: NextEditorPluginActions;
34
- readonly commands?: NextEditorPluginCommands;
34
+ readonly commands?: NextEditorEditorCommands;
35
35
  }
36
36
  export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
37
37
  dependencies: CreatePluginDependenciesAPI<[
@@ -39,13 +39,13 @@ export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorP
39
39
  ...ExtractPluginDependenciesFromMetadata<Metadata>
40
40
  ]>;
41
41
  /**
42
- * Dispatches a PluginCommand to ProseMirror
42
+ * Dispatches an EditorCommand to ProseMirror
43
43
  *
44
- * @param action A function (PluginCommand | undefined) that takes a `Transaction` and returns a `Transaction` if it
44
+ * @param command A function (EditorCommand | undefined) that takes an object containing a `Transaction` and returns a `Transaction` if it
45
45
  * is successful or `null` if it shouldn't be dispatched.
46
46
  * @returns (boolean) if the command was successful in dispatching
47
47
  */
48
- executeCommand: (action: PluginCommand | undefined) => boolean;
48
+ executeCommand: (command: EditorCommand | undefined) => boolean;
49
49
  };
50
50
  export type PluginInjectionAPIWithDependency<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? {
51
51
  dependencies: CreatePluginDependenciesAPI<[
@@ -135,4 +135,15 @@ export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends AllEditorPrese
135
135
  ...any
136
136
  ] ? MaybePlugin extends NextEditorPlugin<any, any> ? ExtractPluginName<MaybePlugin> : never : never : Plugin extends NextEditorPlugin<any, any> ? ExtractPluginName<Plugin> : never;
137
137
  export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata> : never;
138
+ export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
139
+ dependencies: CreatePluginDependenciesAPI<PluginList>;
140
+ /**
141
+ * Dispatches an EditorCommand to ProseMirror
142
+ *
143
+ * @param command A function (EditorCommand | undefined) that takes an object containing a `Transaction` and returns a `Transaction` if it
144
+ * is successful or `null` if it shouldn't be dispatched.
145
+ * @returns (boolean) if the command was successful in dispatching
146
+ */
147
+ executeCommand: (command: EditorCommand | undefined) => boolean;
148
+ };
138
149
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.45.5",
3
+ "version": "74.46.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/"
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/editor-common",
3
- "version": "74.45.5",
4
- "sideEffects": false
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/editor-common",
3
- "version": "74.45.5",
4
- "sideEffects": false
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/editor-common",
3
- "version": "74.45.5",
4
- "sideEffects": false
5
- }
@@ -1,7 +0,0 @@
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 {};
@@ -1,7 +0,0 @@
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 {};