@atlaskit/editor-plugin-layout 10.5.0 → 10.6.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 (52) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/layoutPlugin.js +4 -1
  3. package/dist/cjs/pm-plugins/actions.js +87 -64
  4. package/dist/cjs/pm-plugins/main.js +4 -2
  5. package/dist/cjs/pm-plugins/utils/layout-column-selection.js +128 -0
  6. package/dist/cjs/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +7 -4
  7. package/dist/cjs/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +5 -6
  8. package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +9 -7
  9. package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +15 -6
  10. package/dist/cjs/ui/LayoutColumnMenu/index.js +17 -7
  11. package/dist/cjs/ui/LayoutColumnMenu/useSelectedLayoutColumns.js +14 -0
  12. package/dist/es2019/layoutPlugin.js +4 -1
  13. package/dist/es2019/pm-plugins/actions.js +73 -58
  14. package/dist/es2019/pm-plugins/main.js +4 -2
  15. package/dist/es2019/pm-plugins/utils/layout-column-selection.js +118 -0
  16. package/dist/es2019/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +7 -4
  17. package/dist/es2019/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +5 -6
  18. package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +9 -6
  19. package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +15 -5
  20. package/dist/es2019/ui/LayoutColumnMenu/index.js +16 -6
  21. package/dist/es2019/ui/LayoutColumnMenu/useSelectedLayoutColumns.js +6 -0
  22. package/dist/esm/layoutPlugin.js +5 -2
  23. package/dist/esm/pm-plugins/actions.js +87 -64
  24. package/dist/esm/pm-plugins/main.js +4 -2
  25. package/dist/esm/pm-plugins/utils/layout-column-selection.js +122 -0
  26. package/dist/esm/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +7 -4
  27. package/dist/esm/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +5 -6
  28. package/dist/esm/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +10 -8
  29. package/dist/esm/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +15 -6
  30. package/dist/esm/ui/LayoutColumnMenu/index.js +17 -7
  31. package/dist/esm/ui/LayoutColumnMenu/useSelectedLayoutColumns.js +8 -0
  32. package/dist/types/layoutPluginType.d.ts +1 -1
  33. package/dist/types/pm-plugins/actions.d.ts +3 -2
  34. package/dist/types/pm-plugins/types.d.ts +1 -0
  35. package/dist/types/pm-plugins/utils/layout-column-selection.d.ts +18 -0
  36. package/dist/types/ui/LayoutColumnMenu/useSelectedLayoutColumns.d.ts +4 -0
  37. package/dist/types-ts4.5/layoutPluginType.d.ts +1 -1
  38. package/dist/types-ts4.5/pm-plugins/actions.d.ts +3 -2
  39. package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
  40. package/dist/types-ts4.5/pm-plugins/utils/layout-column-selection.d.ts +18 -0
  41. package/dist/types-ts4.5/ui/LayoutColumnMenu/useSelectedLayoutColumns.d.ts +4 -0
  42. package/package.json +3 -3
  43. package/dist/cjs/ui/LayoutColumnMenu/layoutColumnSelection.js +0 -21
  44. package/dist/cjs/ui/LayoutColumnMenu/useCurrentLayoutColumn.js +0 -20
  45. package/dist/es2019/ui/LayoutColumnMenu/layoutColumnSelection.js +0 -9
  46. package/dist/es2019/ui/LayoutColumnMenu/useCurrentLayoutColumn.js +0 -10
  47. package/dist/esm/ui/LayoutColumnMenu/layoutColumnSelection.js +0 -15
  48. package/dist/esm/ui/LayoutColumnMenu/useCurrentLayoutColumn.js +0 -14
  49. package/dist/types/ui/LayoutColumnMenu/layoutColumnSelection.d.ts +0 -7
  50. package/dist/types/ui/LayoutColumnMenu/useCurrentLayoutColumn.d.ts +0 -5
  51. package/dist/types-ts4.5/ui/LayoutColumnMenu/layoutColumnSelection.d.ts +0 -7
  52. package/dist/types-ts4.5/ui/LayoutColumnMenu/useCurrentLayoutColumn.d.ts +0 -5
@@ -31,7 +31,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
31
31
  commands: {
32
32
  deleteLayoutColumn: ReturnType<typeof deleteLayoutColumn>;
33
33
  insertLayoutColumn: (side: InsertLayoutColumnSide) => EditorCommand;
34
- setLayoutColumnValign: typeof setLayoutColumnValign;
34
+ setLayoutColumnValign: (valign: Parameters<typeof setLayoutColumnValign>[0]) => EditorCommand;
35
35
  toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
36
36
  };
37
37
  dependencies: LayoutPluginDependencies;
@@ -33,8 +33,9 @@ export type InsertLayoutColumnSide = 'left' | 'right';
33
33
  */
34
34
  export declare function getEffectiveMaxLayoutColumns(): number;
35
35
  export declare const insertLayoutColumn: (side: InsertLayoutColumnSide, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
36
- export declare const setLayoutColumnValign: (valign: Valign) => EditorCommand;
37
- export declare const toggleLayoutColumnMenu: ({ isOpen }: {
36
+ export declare const setLayoutColumnValign: (valign: Valign, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
37
+ export declare const toggleLayoutColumnMenu: ({ anchorPos, isOpen }: {
38
+ anchorPos?: number;
38
39
  isOpen?: boolean;
39
40
  }) => EditorCommand;
40
41
  export declare const deleteLayoutColumn: (editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
@@ -6,6 +6,7 @@ export type LayoutState = {
6
6
  allowSingleColumnLayout: boolean;
7
7
  isLayoutColumnMenuOpen: boolean;
8
8
  isResizing: boolean;
9
+ layoutColumnMenuAnchorPos: number | undefined;
9
10
  pos: number | null;
10
11
  selectedLayout: PresetLayout | undefined;
11
12
  };
@@ -0,0 +1,18 @@
1
+ import type { Valign } from '@atlaskit/editor-common/types/valign';
2
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
+ export type SelectedLayoutColumn = {
5
+ index: number;
6
+ node: PMNode;
7
+ pos: number;
8
+ };
9
+ export type SelectedLayoutColumns = {
10
+ layoutSectionNode: PMNode;
11
+ layoutSectionPos: number;
12
+ selectedColumnIndices: number[];
13
+ selectedColumns: SelectedLayoutColumn[];
14
+ };
15
+ export declare const getSelectedLayoutColumns: (selection: Selection | undefined) => SelectedLayoutColumns | undefined;
16
+ export declare const getLayoutSectionColumnCount: (layoutSection: PMNode | undefined) => number;
17
+ export declare const getLayoutColumnValign: (layoutColumn: PMNode | undefined) => Valign | undefined;
18
+ export declare const getLayoutColumnMenuAnchorPos: (selection: Selection | undefined, anchorPosFromHandle?: number) => number | undefined;
@@ -0,0 +1,4 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { LayoutPlugin } from '../../layoutPluginType';
3
+ import { type SelectedLayoutColumns } from '../../pm-plugins/utils/layout-column-selection';
4
+ export declare const useSelectedLayoutColumns: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => SelectedLayoutColumns | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-layout",
3
- "version": "10.5.0",
3
+ "version": "10.6.0",
4
4
  "description": "Layout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
- "@atlaskit/adf-schema": "^52.13.0",
32
+ "@atlaskit/adf-schema": "^52.14.0",
33
33
  "@atlaskit/css": "^0.19.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^10.1.0",
35
35
  "@atlaskit/editor-plugin-block-menu": "^9.2.0",
@@ -55,7 +55,7 @@
55
55
  "bind-event-listener": "^3.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@atlaskit/editor-common": "^114.42.0",
58
+ "@atlaskit/editor-common": "^114.45.0",
59
59
  "react": "^18.2.0",
60
60
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
61
61
  },
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getLayoutSectionColumnCount = exports.getLayoutSectionAtSelection = exports.getLayoutColumnValign = exports.getLayoutColumnAtSelection = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var getLayoutColumnAtSelection = exports.getLayoutColumnAtSelection = function getLayoutColumnAtSelection(selection) {
9
- return selection instanceof _state.NodeSelection && selection.node.type.name === 'layoutColumn' ? selection.node : undefined;
10
- };
11
- var getLayoutSectionAtSelection = exports.getLayoutSectionAtSelection = function getLayoutSectionAtSelection(selection) {
12
- var selectedColumn = getLayoutColumnAtSelection(selection);
13
- var parent = selectedColumn ? selection === null || selection === void 0 ? void 0 : selection.$from.parent : undefined;
14
- return (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' ? parent : undefined;
15
- };
16
- var getLayoutSectionColumnCount = exports.getLayoutSectionColumnCount = function getLayoutSectionColumnCount(layoutSection) {
17
- return (layoutSection === null || layoutSection === void 0 ? void 0 : layoutSection.type.name) === 'layoutSection' ? layoutSection.childCount : 0;
18
- };
19
- var getLayoutColumnValign = exports.getLayoutColumnValign = function getLayoutColumnValign(layoutColumn) {
20
- return layoutColumn === null || layoutColumn === void 0 ? void 0 : layoutColumn.attrs.valign;
21
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useCurrentLayoutSection = exports.useCurrentLayoutColumn = void 0;
7
- var _hooks = require("@atlaskit/editor-common/hooks");
8
- var _layoutColumnSelection = require("./layoutColumnSelection");
9
- var useCurrentLayoutColumn = exports.useCurrentLayoutColumn = function useCurrentLayoutColumn(api) {
10
- return (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
11
- var _states$selectionStat;
12
- return (0, _layoutColumnSelection.getLayoutColumnAtSelection)((_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection);
13
- });
14
- };
15
- var useCurrentLayoutSection = exports.useCurrentLayoutSection = function useCurrentLayoutSection(api) {
16
- return (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection'], function (states) {
17
- var _states$selectionStat2;
18
- return (0, _layoutColumnSelection.getLayoutSectionAtSelection)((_states$selectionStat2 = states.selectionState) === null || _states$selectionStat2 === void 0 ? void 0 : _states$selectionStat2.selection);
19
- });
20
- };
@@ -1,9 +0,0 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
- export const getLayoutColumnAtSelection = selection => selection instanceof NodeSelection && selection.node.type.name === 'layoutColumn' ? selection.node : undefined;
3
- export const getLayoutSectionAtSelection = selection => {
4
- const selectedColumn = getLayoutColumnAtSelection(selection);
5
- const parent = selectedColumn ? selection === null || selection === void 0 ? void 0 : selection.$from.parent : undefined;
6
- return (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' ? parent : undefined;
7
- };
8
- export const getLayoutSectionColumnCount = layoutSection => (layoutSection === null || layoutSection === void 0 ? void 0 : layoutSection.type.name) === 'layoutSection' ? layoutSection.childCount : 0;
9
- export const getLayoutColumnValign = layoutColumn => layoutColumn === null || layoutColumn === void 0 ? void 0 : layoutColumn.attrs.valign;
@@ -1,10 +0,0 @@
1
- import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
2
- import { getLayoutColumnAtSelection, getLayoutSectionAtSelection } from './layoutColumnSelection';
3
- export const useCurrentLayoutColumn = api => useSharedPluginStateWithSelector(api, ['selection'], states => {
4
- var _states$selectionStat;
5
- return getLayoutColumnAtSelection((_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection);
6
- });
7
- export const useCurrentLayoutSection = api => useSharedPluginStateWithSelector(api, ['selection'], states => {
8
- var _states$selectionStat2;
9
- return getLayoutSectionAtSelection((_states$selectionStat2 = states.selectionState) === null || _states$selectionStat2 === void 0 ? void 0 : _states$selectionStat2.selection);
10
- });
@@ -1,15 +0,0 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
- export var getLayoutColumnAtSelection = function getLayoutColumnAtSelection(selection) {
3
- return selection instanceof NodeSelection && selection.node.type.name === 'layoutColumn' ? selection.node : undefined;
4
- };
5
- export var getLayoutSectionAtSelection = function getLayoutSectionAtSelection(selection) {
6
- var selectedColumn = getLayoutColumnAtSelection(selection);
7
- var parent = selectedColumn ? selection === null || selection === void 0 ? void 0 : selection.$from.parent : undefined;
8
- return (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' ? parent : undefined;
9
- };
10
- export var getLayoutSectionColumnCount = function getLayoutSectionColumnCount(layoutSection) {
11
- return (layoutSection === null || layoutSection === void 0 ? void 0 : layoutSection.type.name) === 'layoutSection' ? layoutSection.childCount : 0;
12
- };
13
- export var getLayoutColumnValign = function getLayoutColumnValign(layoutColumn) {
14
- return layoutColumn === null || layoutColumn === void 0 ? void 0 : layoutColumn.attrs.valign;
15
- };
@@ -1,14 +0,0 @@
1
- import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
2
- import { getLayoutColumnAtSelection, getLayoutSectionAtSelection } from './layoutColumnSelection';
3
- export var useCurrentLayoutColumn = function useCurrentLayoutColumn(api) {
4
- return useSharedPluginStateWithSelector(api, ['selection'], function (states) {
5
- var _states$selectionStat;
6
- return getLayoutColumnAtSelection((_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection);
7
- });
8
- };
9
- export var useCurrentLayoutSection = function useCurrentLayoutSection(api) {
10
- return useSharedPluginStateWithSelector(api, ['selection'], function (states) {
11
- var _states$selectionStat2;
12
- return getLayoutSectionAtSelection((_states$selectionStat2 = states.selectionState) === null || _states$selectionStat2 === void 0 ? void 0 : _states$selectionStat2.selection);
13
- });
14
- };
@@ -1,7 +0,0 @@
1
- import type { Valign } from '@atlaskit/editor-common/types/valign';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
- export declare const getLayoutColumnAtSelection: (selection: Selection | undefined) => PMNode | undefined;
5
- export declare const getLayoutSectionAtSelection: (selection: Selection | undefined) => PMNode | undefined;
6
- export declare const getLayoutSectionColumnCount: (layoutSection: PMNode | undefined) => number;
7
- export declare const getLayoutColumnValign: (layoutColumn: PMNode | undefined) => Valign | undefined;
@@ -1,5 +0,0 @@
1
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { LayoutPlugin } from '../../layoutPluginType';
4
- export declare const useCurrentLayoutColumn: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => PMNode | undefined;
5
- export declare const useCurrentLayoutSection: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => PMNode | undefined;
@@ -1,7 +0,0 @@
1
- import type { Valign } from '@atlaskit/editor-common/types/valign';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { Selection } from '@atlaskit/editor-prosemirror/state';
4
- export declare const getLayoutColumnAtSelection: (selection: Selection | undefined) => PMNode | undefined;
5
- export declare const getLayoutSectionAtSelection: (selection: Selection | undefined) => PMNode | undefined;
6
- export declare const getLayoutSectionColumnCount: (layoutSection: PMNode | undefined) => number;
7
- export declare const getLayoutColumnValign: (layoutColumn: PMNode | undefined) => Valign | undefined;
@@ -1,5 +0,0 @@
1
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
- import type { LayoutPlugin } from '../../layoutPluginType';
4
- export declare const useCurrentLayoutColumn: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => PMNode | undefined;
5
- export declare const useCurrentLayoutSection: (api: ExtractInjectionAPI<LayoutPlugin> | undefined) => PMNode | undefined;