@atlaskit/editor-plugin-layout 1.12.4 → 1.12.6
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 +20 -0
- package/dist/cjs/actions.js +46 -10
- package/dist/cjs/toolbar.js +101 -59
- package/dist/cjs/ui/icons/LayoutThreeWithLeftSidebars.js +56 -0
- package/dist/cjs/ui/icons/LayoutThreeWithRightSidebars.js +56 -0
- package/dist/es2019/actions.js +44 -8
- package/dist/es2019/toolbar.js +97 -54
- package/dist/es2019/ui/icons/LayoutThreeWithLeftSidebars.js +46 -0
- package/dist/es2019/ui/icons/LayoutThreeWithRightSidebars.js +46 -0
- package/dist/esm/actions.js +45 -9
- package/dist/esm/toolbar.js +101 -59
- package/dist/esm/ui/icons/LayoutThreeWithLeftSidebars.js +48 -0
- package/dist/esm/ui/icons/LayoutThreeWithRightSidebars.js +48 -0
- package/dist/types/actions.d.ts +0 -2
- package/dist/types/types.d.ts +1 -1
- package/dist/types/ui/icons/LayoutThreeWithLeftSidebars.d.ts +7 -0
- package/dist/types/ui/icons/LayoutThreeWithRightSidebars.d.ts +7 -0
- package/dist/types-ts4.5/actions.d.ts +0 -2
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/LayoutThreeWithLeftSidebars.d.ts +7 -0
- package/dist/types-ts4.5/ui/icons/LayoutThreeWithRightSidebars.d.ts +7 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 1.12.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#169290](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169290)
|
|
8
|
+
[`128ec4e2667bc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/128ec4e2667bc) -
|
|
9
|
+
ED-25824 fix invalid layout after undo or other operations.
|
|
10
|
+
|
|
11
|
+
## 1.12.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#165765](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165765)
|
|
16
|
+
[`3f441f30e6507`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3f441f30e6507) -
|
|
17
|
+
Bump adf-schema to 46.0.0
|
|
18
|
+
- [#168790](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168790)
|
|
19
|
+
[`e08e221fb797c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e08e221fb797c) -
|
|
20
|
+
Add new distributions for 3 column layouts for advanced layouts
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 1.12.4
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.fixColumnStructure = exports.fixColumnSizes = exports.deleteActiveLayoutNode = exports.createMultiColumnLayoutSection = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS =
|
|
7
|
+
exports.fixColumnStructure = exports.fixColumnSizes = exports.deleteActiveLayoutNode = exports.createMultiColumnLayoutSection = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = void 0;
|
|
8
8
|
exports.forceSectionToPresetLayout = forceSectionToPresetLayout;
|
|
9
9
|
exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -15,6 +15,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
15
15
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
17
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
19
|
var _consts = require("./consts");
|
|
19
20
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
20
21
|
var _preRelease = require("./utils/preRelease");
|
|
@@ -23,8 +24,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
23
24
|
var ONE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = ['single'];
|
|
24
25
|
var TWO_COL_LAYOUTS = exports.TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
25
26
|
var THREE_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
26
|
-
var FOUR_COL_LAYOUTS = exports.FOUR_COL_LAYOUTS = ['four_equal'];
|
|
27
|
-
var FIVE_COL_LAYOUTS = exports.FIVE_COL_LAYOUTS = ['five_equal'];
|
|
28
27
|
var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
29
28
|
if ((0, _preRelease.isPreRelease2)()) {
|
|
30
29
|
switch (presetLayout) {
|
|
@@ -40,6 +39,10 @@ var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
|
40
39
|
return [66.66, 33.33];
|
|
41
40
|
case 'three_with_sidebars':
|
|
42
41
|
return [25, 50, 25];
|
|
42
|
+
case 'three_left_sidebars':
|
|
43
|
+
return [25, 25, 50];
|
|
44
|
+
case 'three_right_sidebars':
|
|
45
|
+
return [50, 25, 25];
|
|
43
46
|
case 'four_equal':
|
|
44
47
|
return [25, 25, 25, 25];
|
|
45
48
|
case 'five_equal':
|
|
@@ -63,11 +66,17 @@ var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
|
63
66
|
return [];
|
|
64
67
|
};
|
|
65
68
|
var isValidLayoutWidthDistributions = function isValidLayoutWidthDistributions(layoutSection) {
|
|
66
|
-
var totalWidth =
|
|
69
|
+
var totalWidth = 0;
|
|
70
|
+
(0, _utils.mapChildren)(layoutSection, function (column) {
|
|
67
71
|
return column.attrs.width;
|
|
68
|
-
}).
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
}).forEach(function (width) {
|
|
73
|
+
if (typeof width === 'number' && isFinite(width) && width > 0 && width <= 100) {
|
|
74
|
+
totalWidth += width;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// not a valid width, e.g. 0, 100, undefined
|
|
78
|
+
return false;
|
|
79
|
+
});
|
|
71
80
|
return Math.round(totalWidth) === 100;
|
|
72
81
|
};
|
|
73
82
|
|
|
@@ -87,6 +96,10 @@ var getPresetLayout = exports.getPresetLayout = function getPresetLayout(section
|
|
|
87
96
|
return 'three_equal';
|
|
88
97
|
case '25,50,25':
|
|
89
98
|
return 'three_with_sidebars';
|
|
99
|
+
case '50,25,25':
|
|
100
|
+
return 'three_right_sidebars';
|
|
101
|
+
case '25,25,50':
|
|
102
|
+
return 'three_left_sidebars';
|
|
90
103
|
case '50,50':
|
|
91
104
|
return 'two_equal';
|
|
92
105
|
case '33.33,66.66':
|
|
@@ -383,12 +396,30 @@ function layoutNeedChanges(node) {
|
|
|
383
396
|
}
|
|
384
397
|
return !getPresetLayout(node);
|
|
385
398
|
}
|
|
399
|
+
var getDefaultPresetLayout = function getDefaultPresetLayout(layoutNode) {
|
|
400
|
+
var layoutColumnCount = layoutNode.childCount;
|
|
401
|
+
if (layoutColumnCount <= 1) {
|
|
402
|
+
return 'single';
|
|
403
|
+
}
|
|
404
|
+
switch (layoutColumnCount) {
|
|
405
|
+
case 2:
|
|
406
|
+
return 'two_equal';
|
|
407
|
+
case 3:
|
|
408
|
+
return 'three_equal';
|
|
409
|
+
case 4:
|
|
410
|
+
return 'four_equal';
|
|
411
|
+
case 5:
|
|
412
|
+
return 'five_equal';
|
|
413
|
+
default:
|
|
414
|
+
return 'five_equal';
|
|
415
|
+
}
|
|
416
|
+
};
|
|
386
417
|
function getLayoutChange(node, pos, schema) {
|
|
387
418
|
if (node.type === schema.nodes.layoutSection) {
|
|
388
419
|
if (!layoutNeedChanges(node)) {
|
|
389
420
|
return;
|
|
390
421
|
}
|
|
391
|
-
var presetLayout = node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
422
|
+
var presetLayout = (0, _experiments.editorExperiment)('advanced_layouts', true) ? getDefaultPresetLayout(node) : node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
392
423
|
var fixedColumns = columnWidth(node, schema, getWidthsForPreset(presetLayout));
|
|
393
424
|
return {
|
|
394
425
|
from: pos + 1,
|
|
@@ -437,8 +468,13 @@ var fixColumnStructure = exports.fixColumnStructure = function fixColumnStructur
|
|
|
437
468
|
selectedLayout = _ref2.selectedLayout;
|
|
438
469
|
if (pos !== null && selectedLayout) {
|
|
439
470
|
var node = state.doc.nodeAt(pos);
|
|
440
|
-
if (node
|
|
441
|
-
|
|
471
|
+
if (node) {
|
|
472
|
+
if (node.childCount !== getWidthsForPreset(selectedLayout).length) {
|
|
473
|
+
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
474
|
+
}
|
|
475
|
+
if (!isValidLayoutWidthDistributions(node) && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
476
|
+
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
477
|
+
}
|
|
442
478
|
}
|
|
443
479
|
}
|
|
444
480
|
return;
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -25,6 +25,8 @@ var _layoutTwoRightSidebar = _interopRequireDefault(require("@atlaskit/icon/glyp
|
|
|
25
25
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
26
26
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
27
|
var _actions = require("./actions");
|
|
28
|
+
var _LayoutThreeWithLeftSidebars = require("./ui/icons/LayoutThreeWithLeftSidebars");
|
|
29
|
+
var _LayoutThreeWithRightSidebars = require("./ui/icons/LayoutThreeWithRightSidebars");
|
|
28
30
|
var _preRelease = require("./utils/preRelease");
|
|
29
31
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
30
32
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -67,7 +69,9 @@ var SIDEBAR_LAYOUT_TYPES = [{
|
|
|
67
69
|
icon: _layoutThreeColumnsSidebars.default,
|
|
68
70
|
iconFallback: _layoutThreeWithSidebars.default
|
|
69
71
|
}];
|
|
70
|
-
|
|
72
|
+
|
|
73
|
+
// These are used for advanced layout options
|
|
74
|
+
var LAYOUT_WITH_TWO_COL_DISTRIBUTION = [{
|
|
71
75
|
id: 'editor.layout.twoEquals',
|
|
72
76
|
type: 'two_equal',
|
|
73
77
|
title: _messages.layoutMessages.twoColumns,
|
|
@@ -85,7 +89,8 @@ var LAYOUT_DISTRIBUTION_TYPES = [{
|
|
|
85
89
|
title: _messages.layoutMessages.leftSidebar,
|
|
86
90
|
icon: _layoutTwoColumnsSidebarLeft.default,
|
|
87
91
|
iconFallback: _layoutTwoLeftSidebar.default
|
|
88
|
-
}
|
|
92
|
+
}];
|
|
93
|
+
var LAYOUT_WITH_THREE_COL_DISTRIBUTION = [{
|
|
89
94
|
id: 'editor.layout.threeEquals',
|
|
90
95
|
type: 'three_equal',
|
|
91
96
|
title: _messages.layoutMessages.threeColumns,
|
|
@@ -97,13 +102,19 @@ var LAYOUT_DISTRIBUTION_TYPES = [{
|
|
|
97
102
|
title: _messages.layoutMessages.threeColumnsWithSidebars,
|
|
98
103
|
icon: _layoutThreeColumnsSidebars.default,
|
|
99
104
|
iconFallback: _layoutThreeWithSidebars.default
|
|
105
|
+
}, {
|
|
106
|
+
id: 'editor.layout.threeRightSidebars',
|
|
107
|
+
type: 'three_right_sidebars',
|
|
108
|
+
title: _messages.layoutMessages.threeColumnsWithRightSidebars,
|
|
109
|
+
icon: _LayoutThreeWithRightSidebars.LayoutThreeWithRightSidebarsIcon,
|
|
110
|
+
iconFallback: _LayoutThreeWithRightSidebars.LayoutThreeWithRightSidebarsIcon
|
|
111
|
+
}, {
|
|
112
|
+
id: 'editor.layout.threeLeftSidebars',
|
|
113
|
+
type: 'three_left_sidebars',
|
|
114
|
+
title: _messages.layoutMessages.threeColumnsWithLeftSidebars,
|
|
115
|
+
icon: _LayoutThreeWithLeftSidebars.LayoutThreeWithLeftSidebarsIcon,
|
|
116
|
+
iconFallback: _LayoutThreeWithLeftSidebars.LayoutThreeWithLeftSidebarsIcon
|
|
100
117
|
}];
|
|
101
|
-
var SIDEBAR_LAYOUT_TYPES_BY_COLUMNS = {
|
|
102
|
-
2: [LAYOUT_DISTRIBUTION_TYPES[0], LAYOUT_DISTRIBUTION_TYPES[1], LAYOUT_DISTRIBUTION_TYPES[2]],
|
|
103
|
-
3: [LAYOUT_DISTRIBUTION_TYPES[3], LAYOUT_DISTRIBUTION_TYPES[4]],
|
|
104
|
-
4: [],
|
|
105
|
-
5: []
|
|
106
|
-
};
|
|
107
118
|
var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, editorAnalyticsAPI) {
|
|
108
119
|
return {
|
|
109
120
|
id: item.id,
|
|
@@ -119,15 +130,81 @@ var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, ed
|
|
|
119
130
|
};
|
|
120
131
|
var layoutToolbarTitle = exports.layoutToolbarTitle = 'Layout floating controls';
|
|
121
132
|
var iconPlaceholder = _layoutTwoColumns.default; // TODO: Replace with proper icon ED-25466
|
|
133
|
+
|
|
134
|
+
var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
135
|
+
var addSidebarLayouts = _ref.addSidebarLayouts,
|
|
136
|
+
intl = _ref.intl,
|
|
137
|
+
editorAnalyticsAPI = _ref.editorAnalyticsAPI,
|
|
138
|
+
state = _ref.state,
|
|
139
|
+
node = _ref.node,
|
|
140
|
+
nodeType = _ref.nodeType,
|
|
141
|
+
separator = _ref.separator,
|
|
142
|
+
deleteButton = _ref.deleteButton,
|
|
143
|
+
currentLayout = _ref.currentLayout;
|
|
144
|
+
var numberOfColumns = node.content.childCount || 2;
|
|
145
|
+
var distributionOptions = numberOfColumns === 2 ? LAYOUT_WITH_TWO_COL_DISTRIBUTION : numberOfColumns === 3 ? LAYOUT_WITH_THREE_COL_DISTRIBUTION : [];
|
|
146
|
+
var columnOptions = [{
|
|
147
|
+
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
148
|
+
count: 2
|
|
149
|
+
}),
|
|
150
|
+
//'2-columns',
|
|
151
|
+
icon: iconPlaceholder,
|
|
152
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('two_equal', intl.formatMessage),
|
|
153
|
+
selected: numberOfColumns === 2
|
|
154
|
+
}, {
|
|
155
|
+
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
156
|
+
count: 3
|
|
157
|
+
}),
|
|
158
|
+
//'3-columns'
|
|
159
|
+
icon: iconPlaceholder,
|
|
160
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('three_equal', intl.formatMessage),
|
|
161
|
+
selected: numberOfColumns === 3
|
|
162
|
+
}, {
|
|
163
|
+
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
164
|
+
count: 4
|
|
165
|
+
}),
|
|
166
|
+
//'4-columns'
|
|
167
|
+
icon: iconPlaceholder,
|
|
168
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('four_equal', intl.formatMessage),
|
|
169
|
+
selected: numberOfColumns === 4
|
|
170
|
+
}, {
|
|
171
|
+
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
172
|
+
count: 5
|
|
173
|
+
}),
|
|
174
|
+
//'5-columns'
|
|
175
|
+
icon: iconPlaceholder,
|
|
176
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('five_equal', intl.formatMessage),
|
|
177
|
+
selected: numberOfColumns === 5
|
|
178
|
+
}];
|
|
179
|
+
return [{
|
|
180
|
+
type: 'dropdown',
|
|
181
|
+
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
182
|
+
count: numberOfColumns
|
|
183
|
+
}),
|
|
184
|
+
//`${numberOfColumns}-columns`,
|
|
185
|
+
options: columnOptions,
|
|
186
|
+
showSelected: true,
|
|
187
|
+
testId: 'column-options-button'
|
|
188
|
+
}].concat((0, _toConsumableArray2.default)(distributionOptions.length > 0 ? [separator] : []), (0, _toConsumableArray2.default)(addSidebarLayouts ? distributionOptions.map(function (i) {
|
|
189
|
+
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
190
|
+
}) : []), [separator, {
|
|
191
|
+
type: 'copy-button',
|
|
192
|
+
supportsViewMode: !(0, _platformFeatureFlags.fg)('platform_editor_remove_copy_button_from_view_mode'),
|
|
193
|
+
items: [{
|
|
194
|
+
state: state,
|
|
195
|
+
formatMessage: intl.formatMessage,
|
|
196
|
+
nodeType: nodeType
|
|
197
|
+
}]
|
|
198
|
+
}, separator, deleteButton]);
|
|
199
|
+
};
|
|
122
200
|
var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) {
|
|
123
201
|
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
124
|
-
var
|
|
125
|
-
hoverDecoration =
|
|
202
|
+
var _ref2 = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
|
|
203
|
+
hoverDecoration = _ref2.hoverDecoration;
|
|
126
204
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
127
205
|
var node = state.doc.nodeAt(pos);
|
|
128
206
|
if (node) {
|
|
129
207
|
var currentLayout = (0, _actions.getPresetLayout)(node);
|
|
130
|
-
var numberOfColumns = node.content.childCount || 2;
|
|
131
208
|
var separator = {
|
|
132
209
|
type: 'separator'
|
|
133
210
|
};
|
|
@@ -148,41 +225,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos
|
|
|
148
225
|
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
149
226
|
tabIndex: null
|
|
150
227
|
};
|
|
151
|
-
var layoutTypes =
|
|
152
|
-
var columnOptions = [{
|
|
153
|
-
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
154
|
-
count: 2
|
|
155
|
-
}),
|
|
156
|
-
//'2-columns',
|
|
157
|
-
icon: iconPlaceholder,
|
|
158
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('two_equal', intl.formatMessage),
|
|
159
|
-
selected: numberOfColumns === 2
|
|
160
|
-
}, {
|
|
161
|
-
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
162
|
-
count: 3
|
|
163
|
-
}),
|
|
164
|
-
//'3-columns'
|
|
165
|
-
icon: iconPlaceholder,
|
|
166
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('three_equal', intl.formatMessage),
|
|
167
|
-
selected: numberOfColumns === 3
|
|
168
|
-
}, {
|
|
169
|
-
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
170
|
-
count: 4
|
|
171
|
-
}),
|
|
172
|
-
//'4-columns'
|
|
173
|
-
icon: iconPlaceholder,
|
|
174
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('four_equal', intl.formatMessage),
|
|
175
|
-
selected: numberOfColumns === 4
|
|
176
|
-
}, {
|
|
177
|
-
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
178
|
-
count: 5
|
|
179
|
-
}),
|
|
180
|
-
//'5-columns'
|
|
181
|
-
icon: iconPlaceholder,
|
|
182
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('five_equal', intl.formatMessage),
|
|
183
|
-
selected: numberOfColumns === 5
|
|
184
|
-
}];
|
|
185
|
-
var sidebarTypesByColumns = SIDEBAR_LAYOUT_TYPES_BY_COLUMNS[numberOfColumns] || [];
|
|
228
|
+
var layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
|
|
186
229
|
return {
|
|
187
230
|
title: layoutToolbarTitle,
|
|
188
231
|
getDomRef: function getDomRef(view) {
|
|
@@ -190,20 +233,19 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos
|
|
|
190
233
|
},
|
|
191
234
|
nodeType: nodeType,
|
|
192
235
|
groupLabel: intl.formatMessage(_messages.layoutMessages.floatingToolbarRadioGroupAriaLabel),
|
|
193
|
-
items:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
})), (0, _toConsumableArray2.default)(addSidebarLayouts ? (0, _preRelease.isPreRelease2)() ? sidebarTypesByColumns.map(function (i) {
|
|
236
|
+
items: (0, _preRelease.isPreRelease2)() ? getAdvancedLayoutItems({
|
|
237
|
+
addSidebarLayouts: addSidebarLayouts,
|
|
238
|
+
intl: intl,
|
|
239
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
240
|
+
state: state,
|
|
241
|
+
nodeType: nodeType,
|
|
242
|
+
node: node,
|
|
243
|
+
separator: separator,
|
|
244
|
+
deleteButton: deleteButton,
|
|
245
|
+
currentLayout: currentLayout
|
|
246
|
+
}) : [].concat((0, _toConsumableArray2.default)(layoutTypes.map(function (i) {
|
|
205
247
|
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
206
|
-
})
|
|
248
|
+
})), (0, _toConsumableArray2.default)(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(function (i) {
|
|
207
249
|
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
208
250
|
}) : []), [separator, {
|
|
209
251
|
type: 'copy-button',
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LayoutThreeWithLeftSidebarsIcon = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = require("@emotion/react");
|
|
10
|
+
var _icon = _interopRequireDefault(require("@atlaskit/icon"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
/**
|
|
13
|
+
* @jsxRuntime classic
|
|
14
|
+
* @jsx jsx
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
17
|
+
|
|
18
|
+
var LayoutThreeWithLeftSidebarsGlyph = function LayoutThreeWithLeftSidebarsGlyph(props) {
|
|
19
|
+
if ((0, _platformFeatureFlags.fg)('platform-visual-refresh-icons')) {
|
|
20
|
+
return (0, _react.jsx)("svg", (0, _extends2.default)({
|
|
21
|
+
width: "16",
|
|
22
|
+
height: "14",
|
|
23
|
+
viewBox: "0 0 16 14",
|
|
24
|
+
fill: "none",
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
26
|
+
}, props), (0, _react.jsx)("path", {
|
|
27
|
+
fillRule: "evenodd",
|
|
28
|
+
clipRule: "evenodd",
|
|
29
|
+
d: "M7.5 1.375C7.5 0.615609 8.11561 0 8.875 0H9.625C10.3844 0 11 0.615608 11 1.375V12.625C11 13.3844 10.3844 14 9.625 14H8.875C8.11561 14 7.5 13.3844 7.5 12.625V1.375ZM9 1.5V12.5H9.5V1.5H9ZM0 1.37505C0 0.615655 0.615608 4.66853e-05 1.375 4.66853e-05H4.625C5.38439 4.66853e-05 6 0.615655 6 1.37505V12.625C6 13.3844 5.38439 14 4.625 14H1.375C0.615608 14 0 13.3844 0 12.625V1.37505ZM1.5 1.50005V12.5H4.5V1.50005H1.5ZM12.5 1.37505C12.5 0.615655 13.1156 4.66853e-05 13.875 4.66853e-05H14.625C15.3844 4.66853e-05 16 0.615655 16 1.37505V12.625C16 13.3844 15.3844 14 14.625 14H13.875C13.1156 14 12.5 13.3844 12.5 12.625V1.37505ZM14 1.50005V12.5H14.5V1.50005H14Z",
|
|
30
|
+
fill: "currentcolor"
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return (0, _react.jsx)("svg", (0, _extends2.default)({
|
|
34
|
+
width: "16",
|
|
35
|
+
height: "14",
|
|
36
|
+
viewBox: "0 0 16 14",
|
|
37
|
+
fill: "none",
|
|
38
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
39
|
+
}, props), (0, _react.jsx)("path", {
|
|
40
|
+
fillRule: "evenodd",
|
|
41
|
+
clipRule: "evenodd",
|
|
42
|
+
d: "M1 0C1.26522 0 1.51957 0.105357 1.70711 0.292893C1.89464 0.48043 2 0.734784 2 1V13C2 13.2652 1.89464 13.5196 1.70711 13.7071C1.51957 13.8946 1.26522 14 1 14C0.734784 14 0.48043 13.8946 0.292893 13.7071C0.105357 13.5196 0 13.2652 0 13V1C0 0.734784 0.105357 0.48043 0.292893 0.292893C0.48043 0.105357 0.734784 0 1 0ZM9 0H15C15.2652 0 15.5196 0.105357 15.7071 0.292893C15.8946 0.48043 16 0.734784 16 1V13C16 13.2652 15.8946 13.5196 15.7071 13.7071C15.5196 13.8946 15.2652 14 15 14H9C8.73478 14 8.48043 13.8946 8.29289 13.7071C8.10536 13.5196 8 13.2652 8 13V1C8 0.734784 8.10536 0.48043 8.29289 0.292893C8.48043 0.105357 8.73478 0 9 0ZM5 0C5.26522 0 5.51957 0.105356 5.70711 0.292892C5.89464 0.480429 6 0.734784 6 1V13C6 13.2652 5.89464 13.5196 5.70711 13.7071C5.51957 13.8946 5.26522 14 5 14C4.73478 14 4.48043 13.8946 4.29289 13.7071C4.10536 13.5196 4 13.2652 4 13V1C4 0.734784 4.10536 0.480429 4.29289 0.292892C4.48043 0.105356 4.73478 0 5 0Z",
|
|
43
|
+
fill: "currentcolor"
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
var floatingToolbarPadding = (0, _react.css)({
|
|
47
|
+
paddingRight: "var(--ds-space-050, 4px)",
|
|
48
|
+
paddingLeft: "var(--ds-space-050, 4px)"
|
|
49
|
+
});
|
|
50
|
+
var LayoutThreeWithLeftSidebarsIcon = exports.LayoutThreeWithLeftSidebarsIcon = function LayoutThreeWithLeftSidebarsIcon(props) {
|
|
51
|
+
return (0, _react.jsx)("span", {
|
|
52
|
+
css: floatingToolbarPadding
|
|
53
|
+
}, (0, _react.jsx)(_icon.default, (0, _extends2.default)({
|
|
54
|
+
glyph: LayoutThreeWithLeftSidebarsGlyph
|
|
55
|
+
}, props)));
|
|
56
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LayoutThreeWithRightSidebarsIcon = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = require("@emotion/react");
|
|
10
|
+
var _icon = _interopRequireDefault(require("@atlaskit/icon"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
/**
|
|
13
|
+
* @jsxRuntime classic
|
|
14
|
+
* @jsx jsx
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
17
|
+
|
|
18
|
+
var LayoutThreeWithRightSidebarsGlyph = function LayoutThreeWithRightSidebarsGlyph(props) {
|
|
19
|
+
if ((0, _platformFeatureFlags.fg)('platform-visual-refresh-icons')) {
|
|
20
|
+
return (0, _react.jsx)("svg", (0, _extends2.default)({
|
|
21
|
+
width: "16",
|
|
22
|
+
height: "14",
|
|
23
|
+
viewBox: "0 0 16 14",
|
|
24
|
+
fill: "none",
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
26
|
+
}, props), (0, _react.jsx)("path", {
|
|
27
|
+
fillRule: "evenodd",
|
|
28
|
+
clipRule: "evenodd",
|
|
29
|
+
d: "M8.5 1.375C8.5 0.615609 7.88439 0 7.125 0H6.375C5.61561 0 5 0.615608 5 1.375V12.625C5 13.3844 5.61561 14 6.375 14H7.125C7.88439 14 8.5 13.3844 8.5 12.625V1.375ZM7 1.5V12.5H6.5V1.5H7ZM16 1.37505C16 0.615655 15.3844 4.66853e-05 14.625 4.66853e-05H11.375C10.6156 4.66853e-05 10 0.615655 10 1.37505V12.625C10 13.3844 10.6156 14 11.375 14H14.625C15.3844 14 16 13.3844 16 12.625V1.37505ZM14.5 1.50005V12.5H11.5V1.50005H14.5ZM3.5 1.37505C3.5 0.615655 2.88439 4.66853e-05 2.125 4.66853e-05H1.375C0.615608 4.66853e-05 0 0.615655 0 1.37505V12.625C0 13.3844 0.615608 14 1.375 14H2.125C2.88439 14 3.5 13.3844 3.5 12.625V1.37505ZM2 1.50005V12.5H1.5V1.50005H2Z",
|
|
30
|
+
fill: "currentcolor"
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return (0, _react.jsx)("svg", (0, _extends2.default)({
|
|
34
|
+
width: "16",
|
|
35
|
+
height: "14",
|
|
36
|
+
viewBox: "0 0 16 14",
|
|
37
|
+
fill: "none",
|
|
38
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
39
|
+
}, props), (0, _react.jsx)("path", {
|
|
40
|
+
fillRule: "evenodd",
|
|
41
|
+
clipRule: "evenodd",
|
|
42
|
+
d: "M11 0C11.2652 0 11.5196 0.105357 11.7071 0.292893C11.8946 0.48043 12 0.734784 12 1V13C12 13.2652 11.8946 13.5196 11.7071 13.7071C11.5196 13.8946 11.2652 14 11 14C10.7348 14 10.4804 13.8946 10.2929 13.7071C10.1054 13.5196 10 13.2652 10 13V1C10 0.734784 10.1054 0.48043 10.2929 0.292893C10.4804 0.105357 10.7348 0 11 0ZM1 0H7C7.26522 0 7.51957 0.105357 7.70711 0.292893C7.89464 0.48043 8 0.734784 8 1V13C8 13.2652 7.89464 13.5196 7.70711 13.7071C7.51957 13.8946 7.26522 14 7 14H1C0.734784 14 0.48043 13.8946 0.292893 13.7071C0.105357 13.5196 0 13.2652 0 13V1C0 0.734784 0.105357 0.48043 0.292893 0.292893C0.48043 0.105357 0.734784 0 1 0ZM15 0C15.2652 0 15.5196 0.105357 15.7071 0.292893C15.8946 0.48043 16 0.734784 16 1V13C16 13.2652 15.8946 13.5196 15.7071 13.7071C15.5196 13.8946 15.2652 14 15 14C14.7348 14 14.4804 13.8946 14.2929 13.7071C14.1054 13.5196 14 13.2652 14 13V1C14 0.734784 14.1054 0.48043 14.2929 0.292893C14.4804 0.105357 14.7348 0 15 0Z",
|
|
43
|
+
fill: "currentcolor"
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
var floatingToolbarPadding = (0, _react.css)({
|
|
47
|
+
paddingRight: "var(--ds-space-050, 4px)",
|
|
48
|
+
paddingLeft: "var(--ds-space-050, 4px)"
|
|
49
|
+
});
|
|
50
|
+
var LayoutThreeWithRightSidebarsIcon = exports.LayoutThreeWithRightSidebarsIcon = function LayoutThreeWithRightSidebarsIcon(props) {
|
|
51
|
+
return (0, _react.jsx)("span", {
|
|
52
|
+
css: floatingToolbarPadding
|
|
53
|
+
}, (0, _react.jsx)(_icon.default, (0, _extends2.default)({
|
|
54
|
+
glyph: LayoutThreeWithRightSidebarsGlyph
|
|
55
|
+
}, props)));
|
|
56
|
+
};
|
package/dist/es2019/actions.js
CHANGED
|
@@ -5,14 +5,13 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
|
|
|
5
5
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
|
|
9
10
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
11
|
import { isPreRelease2 } from './utils/preRelease';
|
|
11
12
|
export const ONE_COL_LAYOUTS = ['single'];
|
|
12
13
|
export const TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
13
14
|
export const THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
14
|
-
export const FOUR_COL_LAYOUTS = ['four_equal'];
|
|
15
|
-
export const FIVE_COL_LAYOUTS = ['five_equal'];
|
|
16
15
|
const getWidthsForPreset = presetLayout => {
|
|
17
16
|
if (isPreRelease2()) {
|
|
18
17
|
switch (presetLayout) {
|
|
@@ -28,6 +27,10 @@ const getWidthsForPreset = presetLayout => {
|
|
|
28
27
|
return [66.66, 33.33];
|
|
29
28
|
case 'three_with_sidebars':
|
|
30
29
|
return [25, 50, 25];
|
|
30
|
+
case 'three_left_sidebars':
|
|
31
|
+
return [25, 25, 50];
|
|
32
|
+
case 'three_right_sidebars':
|
|
33
|
+
return [50, 25, 25];
|
|
31
34
|
case 'four_equal':
|
|
32
35
|
return [25, 25, 25, 25];
|
|
33
36
|
case 'five_equal':
|
|
@@ -51,9 +54,15 @@ const getWidthsForPreset = presetLayout => {
|
|
|
51
54
|
return [];
|
|
52
55
|
};
|
|
53
56
|
const isValidLayoutWidthDistributions = layoutSection => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
let totalWidth = 0;
|
|
58
|
+
mapChildren(layoutSection, column => column.attrs.width).forEach(width => {
|
|
59
|
+
if (typeof width === 'number' && isFinite(width) && width > 0 && width <= 100) {
|
|
60
|
+
totalWidth += width;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// not a valid width, e.g. 0, 100, undefined
|
|
64
|
+
return false;
|
|
65
|
+
});
|
|
57
66
|
return Math.round(totalWidth) === 100;
|
|
58
67
|
};
|
|
59
68
|
|
|
@@ -71,6 +80,10 @@ export const getPresetLayout = section => {
|
|
|
71
80
|
return 'three_equal';
|
|
72
81
|
case '25,50,25':
|
|
73
82
|
return 'three_with_sidebars';
|
|
83
|
+
case '50,25,25':
|
|
84
|
+
return 'three_right_sidebars';
|
|
85
|
+
case '25,25,50':
|
|
86
|
+
return 'three_left_sidebars';
|
|
74
87
|
case '50,50':
|
|
75
88
|
return 'two_equal';
|
|
76
89
|
case '33.33,66.66':
|
|
@@ -359,12 +372,30 @@ function layoutNeedChanges(node) {
|
|
|
359
372
|
}
|
|
360
373
|
return !getPresetLayout(node);
|
|
361
374
|
}
|
|
375
|
+
const getDefaultPresetLayout = layoutNode => {
|
|
376
|
+
const layoutColumnCount = layoutNode.childCount;
|
|
377
|
+
if (layoutColumnCount <= 1) {
|
|
378
|
+
return 'single';
|
|
379
|
+
}
|
|
380
|
+
switch (layoutColumnCount) {
|
|
381
|
+
case 2:
|
|
382
|
+
return 'two_equal';
|
|
383
|
+
case 3:
|
|
384
|
+
return 'three_equal';
|
|
385
|
+
case 4:
|
|
386
|
+
return 'four_equal';
|
|
387
|
+
case 5:
|
|
388
|
+
return 'five_equal';
|
|
389
|
+
default:
|
|
390
|
+
return 'five_equal';
|
|
391
|
+
}
|
|
392
|
+
};
|
|
362
393
|
function getLayoutChange(node, pos, schema) {
|
|
363
394
|
if (node.type === schema.nodes.layoutSection) {
|
|
364
395
|
if (!layoutNeedChanges(node)) {
|
|
365
396
|
return;
|
|
366
397
|
}
|
|
367
|
-
const presetLayout = node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
398
|
+
const presetLayout = editorExperiment('advanced_layouts', true) ? getDefaultPresetLayout(node) : node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
368
399
|
const fixedColumns = columnWidth(node, schema, getWidthsForPreset(presetLayout));
|
|
369
400
|
return {
|
|
370
401
|
from: pos + 1,
|
|
@@ -416,8 +447,13 @@ export const fixColumnStructure = state => {
|
|
|
416
447
|
} = pluginKey.getState(state);
|
|
417
448
|
if (pos !== null && selectedLayout) {
|
|
418
449
|
const node = state.doc.nodeAt(pos);
|
|
419
|
-
if (node
|
|
420
|
-
|
|
450
|
+
if (node) {
|
|
451
|
+
if (node.childCount !== getWidthsForPreset(selectedLayout).length) {
|
|
452
|
+
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
453
|
+
}
|
|
454
|
+
if (!isValidLayoutWidthDistributions(node) && editorExperiment('advanced_layouts', true)) {
|
|
455
|
+
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
456
|
+
}
|
|
421
457
|
}
|
|
422
458
|
}
|
|
423
459
|
return;
|