@atlaskit/editor-plugin-layout 10.8.0 → 10.9.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.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/layoutPlugin.js +2 -5
- package/dist/cjs/pm-plugins/actions.js +91 -82
- package/dist/cjs/pm-plugins/utils/{redistribute-proportionally.js → layout-column-distribution.js} +39 -3
- package/dist/cjs/pm-plugins/utils/layout-column-selection.js +56 -98
- package/dist/cjs/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +1 -1
- package/dist/cjs/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.js +14 -19
- package/dist/cjs/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +2 -2
- package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +1 -1
- package/dist/cjs/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +1 -1
- package/dist/cjs/ui/LayoutColumnMenu/index.js +1 -1
- package/dist/cjs/ui/LayoutColumnMenu/useSelectedLayoutColumns.js +4 -3
- package/dist/cjs/ui/toolbar.js +70 -11
- package/dist/es2019/layoutPlugin.js +3 -6
- package/dist/es2019/pm-plugins/actions.js +74 -63
- package/dist/es2019/pm-plugins/utils/{redistribute-proportionally.js → layout-column-distribution.js} +34 -1
- package/dist/es2019/pm-plugins/utils/layout-column-selection.js +54 -94
- package/dist/es2019/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +1 -1
- package/dist/es2019/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.js +15 -15
- package/dist/es2019/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +2 -2
- package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +1 -1
- package/dist/es2019/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +1 -1
- package/dist/es2019/ui/LayoutColumnMenu/index.js +1 -1
- package/dist/es2019/ui/LayoutColumnMenu/useSelectedLayoutColumns.js +6 -4
- package/dist/es2019/ui/toolbar.js +68 -11
- package/dist/esm/layoutPlugin.js +3 -6
- package/dist/esm/pm-plugins/actions.js +89 -80
- package/dist/esm/pm-plugins/utils/{redistribute-proportionally.js → layout-column-distribution.js} +37 -3
- package/dist/esm/pm-plugins/utils/layout-column-selection.js +55 -97
- package/dist/esm/ui/LayoutColumnMenu/DeleteColumnDropdownItem.js +1 -1
- package/dist/esm/ui/LayoutColumnMenu/DistributeColumnsDropdownItem.js +14 -19
- package/dist/esm/ui/LayoutColumnMenu/InsertColumnDropdownItem.js +2 -2
- package/dist/esm/ui/LayoutColumnMenu/VerticalAlignDropdownItem.js +1 -1
- package/dist/esm/ui/LayoutColumnMenu/VerticalAlignNestedMenu.js +1 -1
- package/dist/esm/ui/LayoutColumnMenu/index.js +1 -1
- package/dist/esm/ui/LayoutColumnMenu/useSelectedLayoutColumns.js +5 -4
- package/dist/esm/ui/toolbar.js +71 -12
- package/dist/types/layoutPluginType.d.ts +2 -2
- package/dist/types/pm-plugins/actions.d.ts +12 -2
- package/dist/types/pm-plugins/utils/layout-column-distribution.d.ts +16 -0
- package/dist/types/pm-plugins/utils/layout-column-selection.d.ts +8 -7
- package/dist/types-ts4.5/layoutPluginType.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +12 -2
- package/dist/types-ts4.5/pm-plugins/utils/layout-column-distribution.d.ts +16 -0
- package/dist/types-ts4.5/pm-plugins/utils/layout-column-selection.d.ts +8 -7
- package/package.json +5 -5
- package/dist/types/pm-plugins/utils/redistribute-proportionally.d.ts +0 -2
- package/dist/types-ts4.5/pm-plugins/utils/redistribute-proportionally.d.ts +0 -2
|
@@ -12,7 +12,7 @@ export var VerticalAlignNestedMenu = function VerticalAlignNestedMenu(_ref) {
|
|
|
12
12
|
formatMessage = _useIntl.formatMessage;
|
|
13
13
|
var selectedLayoutColumns = useSelectedLayoutColumns(api);
|
|
14
14
|
var currentValign = useMemo(function () {
|
|
15
|
-
var selectedColumns = selectedLayoutColumns === null || selectedLayoutColumns === void 0 ? void 0 : selectedLayoutColumns.
|
|
15
|
+
var selectedColumns = selectedLayoutColumns === null || selectedLayoutColumns === void 0 ? void 0 : selectedLayoutColumns.selectedLayoutColumns;
|
|
16
16
|
var firstColumn = selectedColumns === null || selectedColumns === void 0 ? void 0 : selectedColumns[0];
|
|
17
17
|
var firstValign = getLayoutColumnValign(firstColumn === null || firstColumn === void 0 ? void 0 : firstColumn.node);
|
|
18
18
|
if (!firstValign || !(selectedColumns !== null && selectedColumns !== void 0 && selectedColumns.every(function (_ref2) {
|
|
@@ -18,7 +18,7 @@ var TOOLBAR_MENU_SELECTOR = '[data-toolbar-component="menu"]';
|
|
|
18
18
|
*/
|
|
19
19
|
var getLayoutColumnMenuTarget = function getLayoutColumnMenuTarget(editorView, selection, anchorPosFromHandle) {
|
|
20
20
|
var _columnDomRef$parentE;
|
|
21
|
-
var anchorPos = getLayoutColumnMenuAnchorPos(selection, anchorPosFromHandle);
|
|
21
|
+
var anchorPos = selection && getLayoutColumnMenuAnchorPos(selection, anchorPosFromHandle);
|
|
22
22
|
if (anchorPos === undefined) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
2
|
-
import {
|
|
2
|
+
import { getSelectedLayoutColumnsFromSelection } from '../../pm-plugins/utils/layout-column-selection';
|
|
3
3
|
export var useSelectedLayoutColumns = function useSelectedLayoutColumns(api) {
|
|
4
|
-
return useSharedPluginStateWithSelector(api, ['selection'], function (
|
|
5
|
-
var
|
|
6
|
-
|
|
4
|
+
return useSharedPluginStateWithSelector(api, ['selection'], function (_ref) {
|
|
5
|
+
var selectionState = _ref.selectionState;
|
|
6
|
+
var selectedLayoutColumns = (selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection) && getSelectedLayoutColumnsFromSelection(selectionState.selection);
|
|
7
|
+
return selectedLayoutColumns !== null && selectedLayoutColumns !== void 0 && selectedLayoutColumns.selectedLayoutColumns.length ? selectedLayoutColumns : undefined;
|
|
7
8
|
});
|
|
8
9
|
};
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -16,8 +16,11 @@ import LayoutThreeColumnsSidebarsIcon from '@atlaskit/icon/core/layout-three-col
|
|
|
16
16
|
import LayoutTwoColumnsIcon from '@atlaskit/icon/core/layout-two-columns';
|
|
17
17
|
import LayoutTwoColumnsSidebarLeftIcon from '@atlaskit/icon/core/layout-two-columns-sidebar-left';
|
|
18
18
|
import LayoutTwoColumnsSidebarRightIcon from '@atlaskit/icon/core/layout-two-columns-sidebar-right';
|
|
19
|
+
import TableColumnsDistributeIcon from '@atlaskit/icon/core/table-columns-distribute';
|
|
20
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
19
21
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
20
|
-
import { deleteActiveLayoutNode, getPresetLayout, setPresetLayout } from '../pm-plugins/actions';
|
|
22
|
+
import { deleteActiveLayoutNode, distributeLayoutColumns, getPresetLayout, setPresetLayout } from '../pm-plugins/actions';
|
|
23
|
+
import { isDistributedUniformly } from '../pm-plugins/utils/layout-column-distribution';
|
|
21
24
|
import { EditorLayoutFiveColumnsIcon, EditorLayoutFourColumnsIcon } from './icons/LayoutColumnsIcon';
|
|
22
25
|
import { LayoutThreeWithLeftSidebarsIcon } from './icons/LayoutThreeWithLeftSidebars';
|
|
23
26
|
import { LayoutThreeWithRightSidebarsIcon } from './icons/LayoutThreeWithRightSidebars';
|
|
@@ -56,7 +59,7 @@ var SIDEBAR_LAYOUT_TYPES = [{
|
|
|
56
59
|
}];
|
|
57
60
|
|
|
58
61
|
// These are used for advanced layout options
|
|
59
|
-
var
|
|
62
|
+
var LAYOUT_WITH_TWO_COL_DISTRIBUTION_OLD = [{
|
|
60
63
|
id: 'editor.layout.twoEquals',
|
|
61
64
|
type: 'two_equal',
|
|
62
65
|
title: toolbarMessages.twoColumns,
|
|
@@ -72,7 +75,7 @@ var LAYOUT_WITH_TWO_COL_DISTRIBUTION = [{
|
|
|
72
75
|
title: toolbarMessages.leftSidebar,
|
|
73
76
|
icon: LayoutTwoColumnsSidebarLeftIcon
|
|
74
77
|
}];
|
|
75
|
-
var
|
|
78
|
+
var LAYOUT_WITH_THREE_COL_DISTRIBUTION_OLD = [{
|
|
76
79
|
id: 'editor.layout.threeEquals',
|
|
77
80
|
type: 'three_equal',
|
|
78
81
|
title: toolbarMessages.threeColumns,
|
|
@@ -95,6 +98,35 @@ var LAYOUT_WITH_THREE_COL_DISTRIBUTION = [{
|
|
|
95
98
|
icon: LayoutThreeWithLeftSidebarsIcon,
|
|
96
99
|
iconFallback: LayoutThreeWithLeftSidebarsIcon
|
|
97
100
|
}];
|
|
101
|
+
var LAYOUT_WITH_TWO_COL_DISTRIBUTION = [{
|
|
102
|
+
id: 'editor.layout.twoRightSidebar',
|
|
103
|
+
type: 'two_right_sidebar',
|
|
104
|
+
title: toolbarMessages.rightSidebar,
|
|
105
|
+
icon: LayoutTwoColumnsSidebarRightIcon
|
|
106
|
+
}, {
|
|
107
|
+
id: 'editor.layout.twoLeftSidebar',
|
|
108
|
+
type: 'two_left_sidebar',
|
|
109
|
+
title: toolbarMessages.leftSidebar,
|
|
110
|
+
icon: LayoutTwoColumnsSidebarLeftIcon
|
|
111
|
+
}];
|
|
112
|
+
var LAYOUT_WITH_THREE_COL_DISTRIBUTION = [{
|
|
113
|
+
id: 'editor.layout.threeWithSidebars',
|
|
114
|
+
type: 'three_with_sidebars',
|
|
115
|
+
title: toolbarMessages.threeColumnsWithSidebars,
|
|
116
|
+
icon: LayoutThreeColumnsSidebarsIcon
|
|
117
|
+
}, {
|
|
118
|
+
id: 'editor.layout.threeRightSidebars',
|
|
119
|
+
type: 'three_right_sidebars',
|
|
120
|
+
title: toolbarMessages.threeColumnsWithRightSidebars,
|
|
121
|
+
icon: LayoutThreeWithRightSidebarsIcon,
|
|
122
|
+
iconFallback: LayoutThreeWithRightSidebarsIcon
|
|
123
|
+
}, {
|
|
124
|
+
id: 'editor.layout.threeLeftSidebars',
|
|
125
|
+
type: 'three_left_sidebars',
|
|
126
|
+
title: toolbarMessages.threeColumnsWithLeftSidebars,
|
|
127
|
+
icon: LayoutThreeWithLeftSidebarsIcon,
|
|
128
|
+
iconFallback: LayoutThreeWithLeftSidebarsIcon
|
|
129
|
+
}];
|
|
98
130
|
var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, editorAnalyticsAPI) {
|
|
99
131
|
return {
|
|
100
132
|
id: item.id,
|
|
@@ -109,7 +141,9 @@ var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, ed
|
|
|
109
141
|
};
|
|
110
142
|
};
|
|
111
143
|
export var layoutToolbarTitle = 'Layout floating controls';
|
|
112
|
-
var iconPlaceholder = LayoutTwoColumnsIcon
|
|
144
|
+
var iconPlaceholder = /*#__PURE__*/React.createElement(LayoutTwoColumnsIcon, {
|
|
145
|
+
label: ""
|
|
146
|
+
}); // TODO: ED-25466 - Replace with proper icon
|
|
113
147
|
|
|
114
148
|
var getLayoutColumnsIcons = function getLayoutColumnsIcons(colCount) {
|
|
115
149
|
if (!editorExperiment('single_column_layouts', true) && !editorExperiment('platform_editor_controls', 'variant1')) {
|
|
@@ -136,11 +170,15 @@ var getLayoutColumnsIcons = function getLayoutColumnsIcons(colCount) {
|
|
|
136
170
|
return undefined;
|
|
137
171
|
}
|
|
138
172
|
};
|
|
173
|
+
var getLayoutColumnWidths = function getLayoutColumnWidths(node) {
|
|
174
|
+
return node.children.map(function (child) {
|
|
175
|
+
return child.attrs.width;
|
|
176
|
+
});
|
|
177
|
+
};
|
|
139
178
|
var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
140
179
|
var addSidebarLayouts = _ref.addSidebarLayouts,
|
|
141
180
|
intl = _ref.intl,
|
|
142
181
|
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
143
|
-
state = _ref.state,
|
|
144
182
|
node = _ref.node,
|
|
145
183
|
nodeType = _ref.nodeType,
|
|
146
184
|
separator = _ref.separator,
|
|
@@ -148,7 +186,8 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
148
186
|
currentLayout = _ref.currentLayout,
|
|
149
187
|
allowAdvancedSingleColumnLayout = _ref.allowAdvancedSingleColumnLayout;
|
|
150
188
|
var numberOfColumns = node.content.childCount || 2;
|
|
151
|
-
var
|
|
189
|
+
var isLayoutColumnMenuEnabled = expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true);
|
|
190
|
+
var distributionOptions = isLayoutColumnMenuEnabled ? numberOfColumns === 2 ? LAYOUT_WITH_TWO_COL_DISTRIBUTION : numberOfColumns === 3 ? LAYOUT_WITH_THREE_COL_DISTRIBUTION : [] : numberOfColumns === 2 ? LAYOUT_WITH_TWO_COL_DISTRIBUTION_OLD : numberOfColumns === 3 ? LAYOUT_WITH_THREE_COL_DISTRIBUTION_OLD : [];
|
|
152
191
|
var columnOptions = [{
|
|
153
192
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
154
193
|
count: 2
|
|
@@ -182,7 +221,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
182
221
|
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'),
|
|
183
222
|
selected: numberOfColumns === 5
|
|
184
223
|
}];
|
|
185
|
-
var
|
|
224
|
+
var dropdownOptions = [].concat(_toConsumableArray(allowAdvancedSingleColumnLayout ? [{
|
|
186
225
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
187
226
|
count: 1
|
|
188
227
|
}),
|
|
@@ -190,19 +229,40 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
190
229
|
icon: getLayoutColumnsIcons(1) || iconPlaceholder,
|
|
191
230
|
onClick: setPresetLayout(editorAnalyticsAPI)('single'),
|
|
192
231
|
selected: numberOfColumns === 1
|
|
193
|
-
} : [];
|
|
232
|
+
}] : []), columnOptions);
|
|
233
|
+
var distributeColumnsButton = isLayoutColumnMenuEnabled && numberOfColumns > 1 ? {
|
|
234
|
+
disabled: isDistributedUniformly(getLayoutColumnWidths(node)),
|
|
235
|
+
icon: TableColumnsDistributeIcon,
|
|
236
|
+
onClick: function onClick(editorState, dispatch) {
|
|
237
|
+
var tr = distributeLayoutColumns({
|
|
238
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
239
|
+
inputMethod: INPUT_METHOD.FLOATING_TB,
|
|
240
|
+
target: 'allColumns'
|
|
241
|
+
})({
|
|
242
|
+
tr: editorState.tr
|
|
243
|
+
});
|
|
244
|
+
if (!tr) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
dispatch === null || dispatch === void 0 || dispatch(tr);
|
|
248
|
+
return true;
|
|
249
|
+
},
|
|
250
|
+
testId: 'layout-distribute-columns',
|
|
251
|
+
title: intl.formatMessage(layoutMessages.distributeColumns),
|
|
252
|
+
type: 'button'
|
|
253
|
+
} : undefined;
|
|
194
254
|
return [{
|
|
195
255
|
type: 'dropdown',
|
|
196
256
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
197
257
|
count: numberOfColumns
|
|
198
258
|
}),
|
|
199
259
|
//`${numberOfColumns}-columns`,
|
|
200
|
-
options:
|
|
260
|
+
options: dropdownOptions,
|
|
201
261
|
showSelected: true,
|
|
202
262
|
testId: 'column-options-button'
|
|
203
|
-
}].concat(_toConsumableArray(distributionOptions.length > 0 ? [separator] : []), _toConsumableArray(addSidebarLayouts ? distributionOptions.map(function (i) {
|
|
263
|
+
}].concat(_toConsumableArray(distributionOptions.length > 0 || distributeColumnsButton ? [separator] : []), _toConsumableArray(addSidebarLayouts ? distributionOptions.map(function (i) {
|
|
204
264
|
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
205
|
-
}) : []));
|
|
265
|
+
}) : []), _toConsumableArray(distributeColumnsButton ? [distributeColumnsButton] : []));
|
|
206
266
|
};
|
|
207
267
|
var fullHeightSeparator = {
|
|
208
268
|
type: 'separator',
|
|
@@ -291,7 +351,6 @@ export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout
|
|
|
291
351
|
addSidebarLayouts: addSidebarLayouts,
|
|
292
352
|
intl: intl,
|
|
293
353
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
294
|
-
state: state,
|
|
295
354
|
nodeType: nodeType,
|
|
296
355
|
node: node,
|
|
297
356
|
separator: separator,
|
|
@@ -9,7 +9,7 @@ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
|
|
11
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
12
|
-
import type { deleteLayoutColumn,
|
|
12
|
+
import type { deleteLayoutColumn, createDistributeLayoutColumnsCommand, InsertLayoutColumnSide, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
13
13
|
import type { LayoutState } from './pm-plugins/types';
|
|
14
14
|
import type { LayoutPluginOptions } from './types';
|
|
15
15
|
export type LayoutPluginDependencies = [
|
|
@@ -30,7 +30,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
30
30
|
};
|
|
31
31
|
commands: {
|
|
32
32
|
deleteLayoutColumn: ReturnType<typeof deleteLayoutColumn>;
|
|
33
|
-
distributeLayoutColumns: ReturnType<typeof
|
|
33
|
+
distributeLayoutColumns: ReturnType<typeof createDistributeLayoutColumnsCommand>;
|
|
34
34
|
insertLayoutColumn: (side: InsertLayoutColumnSide) => EditorCommand;
|
|
35
35
|
setLayoutColumnValign: (valign: Parameters<typeof setLayoutColumnValign>[0]) => EditorCommand;
|
|
36
36
|
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
@@ -5,6 +5,13 @@ import type { Command, EditorCommand, TOOLBAR_MENU_TYPE } from '@atlaskit/editor
|
|
|
5
5
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { Change, PresetLayout } from '../types';
|
|
8
|
+
export type DistributeLayoutColumnsOptions = {
|
|
9
|
+
inputMethod?: INPUT_METHOD.LAYOUT_COLUMN_MENU | INPUT_METHOD.FLOATING_TB;
|
|
10
|
+
target?: 'selectedColumns' | 'allColumns';
|
|
11
|
+
};
|
|
12
|
+
type DistributeLayoutColumnsActionOptions = DistributeLayoutColumnsOptions & {
|
|
13
|
+
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
14
|
+
};
|
|
8
15
|
export declare const ONE_COL_LAYOUTS: PresetLayout[];
|
|
9
16
|
export declare const TWO_COL_LAYOUTS: PresetLayout[];
|
|
10
17
|
export declare const THREE_COL_LAYOUTS: PresetLayout[];
|
|
@@ -17,7 +24,8 @@ export declare const getSelectedLayout: (maybeLayoutSection: Node | undefined, c
|
|
|
17
24
|
export declare const createMultiColumnLayoutSection: (state: EditorState, numberOfColumns?: number) => Node;
|
|
18
25
|
export declare const createDefaultLayoutSection: (state: EditorState) => Node;
|
|
19
26
|
export declare const insertLayoutColumns: Command;
|
|
20
|
-
|
|
27
|
+
type InsertLayoutColumnsInputMethod = TOOLBAR_MENU_TYPE | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.ELEMENT_BROWSER;
|
|
28
|
+
export declare const insertLayoutColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertLayoutColumnsInputMethod) => Command;
|
|
21
29
|
/**
|
|
22
30
|
* Forces a layout section node to match the given preset layout by adjusting
|
|
23
31
|
* its column structure and widths, then restoring the original selection.
|
|
@@ -34,9 +42,11 @@ export type InsertLayoutColumnSide = 'left' | 'right';
|
|
|
34
42
|
export declare function getEffectiveMaxLayoutColumns(): number;
|
|
35
43
|
export declare const insertLayoutColumn: (side: InsertLayoutColumnSide, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
36
44
|
export declare const setLayoutColumnValign: (valign: Valign, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
37
|
-
export declare const distributeLayoutColumns: (editorAnalyticsAPI
|
|
45
|
+
export declare const distributeLayoutColumns: ({ editorAnalyticsAPI, inputMethod, target, }?: DistributeLayoutColumnsActionOptions) => EditorCommand;
|
|
46
|
+
export declare const createDistributeLayoutColumnsCommand: (editorAnalyticsAPI?: EditorAnalyticsAPI) => (options?: DistributeLayoutColumnsOptions) => EditorCommand;
|
|
38
47
|
export declare const toggleLayoutColumnMenu: ({ anchorPos, isOpen }: {
|
|
39
48
|
anchorPos?: number;
|
|
40
49
|
isOpen?: boolean;
|
|
41
50
|
}) => EditorCommand;
|
|
42
51
|
export declare const deleteLayoutColumn: (editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when the given selected columns already reflect the distribution that
|
|
3
|
+
* `distributeLayoutColumns` would produce — i.e. the first N-1 cols each hold
|
|
4
|
+
* `equalWidth` (rounded to 2 dp) and the last col absorbs the rounding remainder.
|
|
5
|
+
*
|
|
6
|
+
* This mirrors the action's "last col absorbs remainder" logic so that the UI can
|
|
7
|
+
* disable the option when it would be a no-op, avoiding spurious undo entries.
|
|
8
|
+
*/
|
|
9
|
+
export type Distribution = {
|
|
10
|
+
equalWidth: number;
|
|
11
|
+
selectedTotal: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const calculateDistribution: (selectedWidths: number[]) => Distribution | undefined;
|
|
14
|
+
export declare function isDistributedUniformly(selectedWidths: number[], distribution?: Distribution | undefined): boolean;
|
|
15
|
+
export declare const redistributeAfterDeletion: (currentWidths: number[], removeIndex: number, minWidth: number) => number[];
|
|
16
|
+
export declare const redistributeProportionally: (currentWidths: number[], insertIndex: number, maxColumns: number, minWidth: number) => number[];
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { Valign } from '@atlaskit/adf-schema/layout-column';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
|
|
5
|
-
index: number;
|
|
4
|
+
type FoundNode = {
|
|
6
5
|
node: PMNode;
|
|
7
6
|
pos: number;
|
|
8
7
|
};
|
|
9
8
|
export type SelectedLayoutColumns = {
|
|
9
|
+
endIndex: number;
|
|
10
10
|
layoutSectionNode: PMNode;
|
|
11
11
|
layoutSectionPos: number;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
selectedLayoutColumns: FoundNode[];
|
|
13
|
+
startIndex: number;
|
|
14
14
|
};
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
15
|
+
export declare const getSelectedLayoutColumnsFromSelection: (selection: Selection) => SelectedLayoutColumns | undefined;
|
|
16
|
+
export declare const getAllLayoutColumnsFromSelection: (selection: Selection) => SelectedLayoutColumns | undefined;
|
|
17
17
|
export declare const getLayoutColumnValign: (layoutColumn: PMNode | undefined) => Valign | undefined;
|
|
18
|
-
export declare const getLayoutColumnMenuAnchorPos: (selection: Selection
|
|
18
|
+
export declare const getLayoutColumnMenuAnchorPos: (selection: Selection, anchorPosFromHandle?: number) => number | undefined;
|
|
19
|
+
export {};
|
|
@@ -9,7 +9,7 @@ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
|
|
11
11
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
12
|
-
import type { deleteLayoutColumn,
|
|
12
|
+
import type { deleteLayoutColumn, createDistributeLayoutColumnsCommand, InsertLayoutColumnSide, insertLayoutColumnsWithAnalytics, setLayoutColumnValign, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
13
13
|
import type { LayoutState } from './pm-plugins/types';
|
|
14
14
|
import type { LayoutPluginOptions } from './types';
|
|
15
15
|
export type LayoutPluginDependencies = [
|
|
@@ -30,7 +30,7 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
30
30
|
};
|
|
31
31
|
commands: {
|
|
32
32
|
deleteLayoutColumn: ReturnType<typeof deleteLayoutColumn>;
|
|
33
|
-
distributeLayoutColumns: ReturnType<typeof
|
|
33
|
+
distributeLayoutColumns: ReturnType<typeof createDistributeLayoutColumnsCommand>;
|
|
34
34
|
insertLayoutColumn: (side: InsertLayoutColumnSide) => EditorCommand;
|
|
35
35
|
setLayoutColumnValign: (valign: Parameters<typeof setLayoutColumnValign>[0]) => EditorCommand;
|
|
36
36
|
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
@@ -5,6 +5,13 @@ import type { Command, EditorCommand, TOOLBAR_MENU_TYPE } from '@atlaskit/editor
|
|
|
5
5
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { Change, PresetLayout } from '../types';
|
|
8
|
+
export type DistributeLayoutColumnsOptions = {
|
|
9
|
+
inputMethod?: INPUT_METHOD.LAYOUT_COLUMN_MENU | INPUT_METHOD.FLOATING_TB;
|
|
10
|
+
target?: 'selectedColumns' | 'allColumns';
|
|
11
|
+
};
|
|
12
|
+
type DistributeLayoutColumnsActionOptions = DistributeLayoutColumnsOptions & {
|
|
13
|
+
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
14
|
+
};
|
|
8
15
|
export declare const ONE_COL_LAYOUTS: PresetLayout[];
|
|
9
16
|
export declare const TWO_COL_LAYOUTS: PresetLayout[];
|
|
10
17
|
export declare const THREE_COL_LAYOUTS: PresetLayout[];
|
|
@@ -17,7 +24,8 @@ export declare const getSelectedLayout: (maybeLayoutSection: Node | undefined, c
|
|
|
17
24
|
export declare const createMultiColumnLayoutSection: (state: EditorState, numberOfColumns?: number) => Node;
|
|
18
25
|
export declare const createDefaultLayoutSection: (state: EditorState) => Node;
|
|
19
26
|
export declare const insertLayoutColumns: Command;
|
|
20
|
-
|
|
27
|
+
type InsertLayoutColumnsInputMethod = TOOLBAR_MENU_TYPE | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.ELEMENT_BROWSER;
|
|
28
|
+
export declare const insertLayoutColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: InsertLayoutColumnsInputMethod) => Command;
|
|
21
29
|
/**
|
|
22
30
|
* Forces a layout section node to match the given preset layout by adjusting
|
|
23
31
|
* its column structure and widths, then restoring the original selection.
|
|
@@ -34,9 +42,11 @@ export type InsertLayoutColumnSide = 'left' | 'right';
|
|
|
34
42
|
export declare function getEffectiveMaxLayoutColumns(): number;
|
|
35
43
|
export declare const insertLayoutColumn: (side: InsertLayoutColumnSide, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
36
44
|
export declare const setLayoutColumnValign: (valign: Valign, editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
37
|
-
export declare const distributeLayoutColumns: (editorAnalyticsAPI
|
|
45
|
+
export declare const distributeLayoutColumns: ({ editorAnalyticsAPI, inputMethod, target, }?: DistributeLayoutColumnsActionOptions) => EditorCommand;
|
|
46
|
+
export declare const createDistributeLayoutColumnsCommand: (editorAnalyticsAPI?: EditorAnalyticsAPI) => (options?: DistributeLayoutColumnsOptions) => EditorCommand;
|
|
38
47
|
export declare const toggleLayoutColumnMenu: ({ anchorPos, isOpen }: {
|
|
39
48
|
anchorPos?: number;
|
|
40
49
|
isOpen?: boolean;
|
|
41
50
|
}) => EditorCommand;
|
|
42
51
|
export declare const deleteLayoutColumn: (editorAnalyticsAPI?: EditorAnalyticsAPI) => EditorCommand;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when the given selected columns already reflect the distribution that
|
|
3
|
+
* `distributeLayoutColumns` would produce — i.e. the first N-1 cols each hold
|
|
4
|
+
* `equalWidth` (rounded to 2 dp) and the last col absorbs the rounding remainder.
|
|
5
|
+
*
|
|
6
|
+
* This mirrors the action's "last col absorbs remainder" logic so that the UI can
|
|
7
|
+
* disable the option when it would be a no-op, avoiding spurious undo entries.
|
|
8
|
+
*/
|
|
9
|
+
export type Distribution = {
|
|
10
|
+
equalWidth: number;
|
|
11
|
+
selectedTotal: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const calculateDistribution: (selectedWidths: number[]) => Distribution | undefined;
|
|
14
|
+
export declare function isDistributedUniformly(selectedWidths: number[], distribution?: Distribution | undefined): boolean;
|
|
15
|
+
export declare const redistributeAfterDeletion: (currentWidths: number[], removeIndex: number, minWidth: number) => number[];
|
|
16
|
+
export declare const redistributeProportionally: (currentWidths: number[], insertIndex: number, maxColumns: number, minWidth: number) => number[];
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { Valign } from '@atlaskit/adf-schema/layout-column';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
|
|
5
|
-
index: number;
|
|
4
|
+
type FoundNode = {
|
|
6
5
|
node: PMNode;
|
|
7
6
|
pos: number;
|
|
8
7
|
};
|
|
9
8
|
export type SelectedLayoutColumns = {
|
|
9
|
+
endIndex: number;
|
|
10
10
|
layoutSectionNode: PMNode;
|
|
11
11
|
layoutSectionPos: number;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
selectedLayoutColumns: FoundNode[];
|
|
13
|
+
startIndex: number;
|
|
14
14
|
};
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
15
|
+
export declare const getSelectedLayoutColumnsFromSelection: (selection: Selection) => SelectedLayoutColumns | undefined;
|
|
16
|
+
export declare const getAllLayoutColumnsFromSelection: (selection: Selection) => SelectedLayoutColumns | undefined;
|
|
17
17
|
export declare const getLayoutColumnValign: (layoutColumn: PMNode | undefined) => Valign | undefined;
|
|
18
|
-
export declare const getLayoutColumnMenuAnchorPos: (selection: Selection
|
|
18
|
+
export declare const getLayoutColumnMenuAnchorPos: (selection: Selection, anchorPosFromHandle?: number) => number | undefined;
|
|
19
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.9.0",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"@atlaskit/editor-plugin-width": "^11.1.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.11.0",
|
|
46
|
-
"@atlaskit/editor-toolbar": "^1.
|
|
46
|
+
"@atlaskit/editor-toolbar": "^1.9.0",
|
|
47
47
|
"@atlaskit/editor-ui-control-model": "^1.2.0",
|
|
48
48
|
"@atlaskit/icon": "^35.3.0",
|
|
49
49
|
"@atlaskit/icon-lab": "^6.12.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
52
|
-
"@atlaskit/tokens": "^13.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^85.0.0",
|
|
52
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@emotion/react": "^11.7.1",
|
|
55
55
|
"bind-event-listener": "^3.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@atlaskit/editor-common": "^114.
|
|
58
|
+
"@atlaskit/editor-common": "^114.51.0",
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
61
61
|
},
|