@atlaskit/editor-common 74.37.0 → 74.38.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.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/guideline/constants.js +4 -2
- package/dist/cjs/guideline/defaultGuideline.js +4 -3
- package/dist/cjs/guideline/index.js +10 -4
- package/dist/cjs/guideline/snapping.js +42 -30
- package/dist/cjs/keymaps/index.js +11 -7
- package/dist/cjs/media-single/utils.js +1 -1
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/preset/index.js +8 -1
- package/dist/cjs/preset/plugin-commands.js +19 -0
- package/dist/cjs/preset/plugin-injection-api.js +28 -1
- package/dist/cjs/types/plugin-command.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/MediaSingle/styled.js +1 -11
- package/dist/cjs/utils/rich-media-utils.js +6 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/guideline/constants.js +2 -1
- package/dist/es2019/guideline/defaultGuideline.js +4 -3
- package/dist/es2019/guideline/index.js +2 -2
- package/dist/es2019/guideline/snapping.js +35 -27
- package/dist/es2019/keymaps/index.js +10 -7
- package/dist/es2019/media-single/utils.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/preset/index.js +2 -1
- package/dist/es2019/preset/plugin-commands.js +14 -0
- package/dist/es2019/preset/plugin-injection-api.js +21 -1
- package/dist/es2019/types/plugin-command.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/MediaSingle/styled.js +11 -24
- package/dist/es2019/utils/rich-media-utils.js +6 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/guideline/constants.js +2 -1
- package/dist/esm/guideline/defaultGuideline.js +4 -3
- package/dist/esm/guideline/index.js +2 -2
- package/dist/esm/guideline/snapping.js +40 -28
- package/dist/esm/keymaps/index.js +10 -7
- package/dist/esm/media-single/utils.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/preset/index.js +2 -1
- package/dist/esm/preset/plugin-commands.js +13 -0
- package/dist/esm/preset/plugin-injection-api.js +28 -1
- package/dist/esm/types/plugin-command.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/MediaSingle/styled.js +3 -12
- package/dist/esm/utils/rich-media-utils.js +6 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/guideline/constants.d.ts +1 -0
- package/dist/types/guideline/dynamicGuideline.d.ts +1 -1
- package/dist/types/guideline/index.d.ts +3 -3
- package/dist/types/guideline/snapping.d.ts +12 -11
- package/dist/types/guideline/types.d.ts +13 -2
- package/dist/types/keymaps/index.d.ts +5 -1
- package/dist/types/media-single/utils.d.ts +1 -1
- package/dist/types/preset/index.d.ts +1 -0
- package/dist/types/preset/plugin-commands.d.ts +3 -0
- package/dist/types/preset/plugin-injection-api.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/next-editor-plugin.d.ts +10 -1
- package/dist/types/types/plugin-command.d.ts +7 -0
- package/dist/types/ui/MediaSingle/styled.d.ts +3 -2
- package/dist/types/utils/rich-media-utils.d.ts +1 -1
- package/dist/types-ts4.5/guideline/constants.d.ts +1 -0
- package/dist/types-ts4.5/guideline/dynamicGuideline.d.ts +1 -1
- package/dist/types-ts4.5/guideline/index.d.ts +3 -3
- package/dist/types-ts4.5/guideline/snapping.d.ts +12 -11
- package/dist/types-ts4.5/guideline/types.d.ts +13 -2
- package/dist/types-ts4.5/keymaps/index.d.ts +5 -1
- package/dist/types-ts4.5/media-single/utils.d.ts +1 -1
- package/dist/types-ts4.5/preset/index.d.ts +1 -0
- package/dist/types-ts4.5/preset/plugin-commands.d.ts +3 -0
- package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -0
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +10 -1
- package/dist/types-ts4.5/types/plugin-command.d.ts +7 -0
- package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +3 -2
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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]:
|
|
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';
|
|
@@ -34,7 +34,7 @@ export interface calcMediaSinglePixelWidthProps {
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const calcMediaSinglePixelWidth: ({ width, widthType, origWidth, layout, contentWidth, containerWidth, gutterOffset, }: calcMediaSinglePixelWidthProps) => number;
|
|
36
36
|
/**
|
|
37
|
-
* Calculate maximum width allowed for media single in new experience
|
|
37
|
+
* Calculate maximum width allowed for media single node in fix-width editor in new experience
|
|
38
38
|
* @param containerWidth width of editor container
|
|
39
39
|
*/
|
|
40
40
|
export declare const calcMediaSingleMaxWidth: (containerWidth: number) => number;
|
|
@@ -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>>(): {
|
|
@@ -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
|
};
|
|
@@ -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
|
-
|
|
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 {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import
|
|
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
|
*
|
|
@@ -4,6 +4,6 @@ import { SnapPointsProps } from '../types';
|
|
|
4
4
|
export declare const shouldAddDefaultWrappedWidth: (layout: RichMediaLayout, width?: number, lineLength?: number) => boolean | 0 | undefined;
|
|
5
5
|
export declare const nonWrappedLayouts: RichMediaLayout[];
|
|
6
6
|
export declare const floatingLayouts: string[];
|
|
7
|
-
export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean) => boolean;
|
|
7
|
+
export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean, includeMoreParentNodeTypes?: boolean) => boolean;
|
|
8
8
|
export declare const alignAttributes: (layout: RichMediaLayout, oldAttrs: RichMediaAttributes, gridSize: number | undefined, originalWidth: number, lineLength?: number) => RichMediaAttributes;
|
|
9
9
|
export declare function calculateSnapPoints({ $pos, akEditorWideLayoutWidth, allowBreakoutSnapPoints, containerWidth, gridSize, gridWidth, insideInlineLike, insideLayout, isVideoFile, lineLength, offsetLeft, wrappedLayout, }: SnapPointsProps): number[];
|
|
@@ -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 {
|
|
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[],
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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]:
|
|
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';
|
|
@@ -34,7 +34,7 @@ export interface calcMediaSinglePixelWidthProps {
|
|
|
34
34
|
*/
|
|
35
35
|
export declare const calcMediaSinglePixelWidth: ({ width, widthType, origWidth, layout, contentWidth, containerWidth, gutterOffset, }: calcMediaSinglePixelWidthProps) => number;
|
|
36
36
|
/**
|
|
37
|
-
* Calculate maximum width allowed for media single in new experience
|
|
37
|
+
* Calculate maximum width allowed for media single node in fix-width editor in new experience
|
|
38
38
|
* @param containerWidth width of editor container
|
|
39
39
|
*/
|
|
40
40
|
export declare const calcMediaSingleMaxWidth: (containerWidth: number) => number;
|
|
@@ -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>>(): {
|
|
@@ -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
|
};
|
|
@@ -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
|
-
|
|
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 {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import
|
|
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
|
*
|
|
@@ -4,6 +4,6 @@ import { SnapPointsProps } from '../types';
|
|
|
4
4
|
export declare const shouldAddDefaultWrappedWidth: (layout: RichMediaLayout, width?: number, lineLength?: number) => boolean | 0 | undefined;
|
|
5
5
|
export declare const nonWrappedLayouts: RichMediaLayout[];
|
|
6
6
|
export declare const floatingLayouts: string[];
|
|
7
|
-
export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean) => boolean;
|
|
7
|
+
export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean, includeMoreParentNodeTypes?: boolean) => boolean;
|
|
8
8
|
export declare const alignAttributes: (layout: RichMediaLayout, oldAttrs: RichMediaAttributes, gridSize: number | undefined, originalWidth: number, lineLength?: number) => RichMediaAttributes;
|
|
9
9
|
export declare function calculateSnapPoints({ $pos, akEditorWideLayoutWidth, allowBreakoutSnapPoints, containerWidth, gridSize, gridWidth, insideInlineLike, insideLayout, isVideoFile, lineLength, offsetLeft, wrappedLayout, }: SnapPointsProps): number[];
|
package/package.json
CHANGED