@atlaskit/editor-plugin-layout 1.12.9 → 1.12.11
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 +24 -0
- package/dist/cjs/layoutPlugin.js +5 -6
- package/dist/cjs/nodeviews/index.js +3 -1
- package/dist/cjs/pm-plugins/actions.js +16 -11
- package/dist/cjs/pm-plugins/main.js +20 -1
- package/dist/cjs/ui/toolbar.js +2 -2
- package/dist/es2019/layoutPlugin.js +5 -6
- package/dist/es2019/nodeviews/index.js +3 -1
- package/dist/es2019/pm-plugins/actions.js +16 -11
- package/dist/es2019/pm-plugins/main.js +21 -2
- package/dist/es2019/ui/toolbar.js +2 -2
- package/dist/esm/layoutPlugin.js +5 -6
- package/dist/esm/nodeviews/index.js +3 -1
- package/dist/esm/pm-plugins/actions.js +16 -11
- package/dist/esm/pm-plugins/main.js +21 -2
- package/dist/esm/ui/toolbar.js +2 -2
- package/package.json +3 -9
- package/dist/cjs/pm-plugins/utils/preRelease.js +0 -11
- package/dist/es2019/pm-plugins/utils/preRelease.js +0 -3
- package/dist/esm/pm-plugins/utils/preRelease.js +0 -5
- package/dist/types/pm-plugins/utils/preRelease.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/utils/preRelease.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 1.12.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#171974](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171974)
|
|
8
|
+
[`bc888f2b9c449`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bc888f2b9c449) -
|
|
9
|
+
Fire analytics event from BreakoutResizer component when breakout is resized
|
|
10
|
+
- [#171077](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171077)
|
|
11
|
+
[`0a92cf56671ac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0a92cf56671ac) -
|
|
12
|
+
ED-25867 always show drag handler for layout columns
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 1.12.10
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#171014](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171014)
|
|
20
|
+
[`6163248356c63`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6163248356c63) -
|
|
21
|
+
[ED-25833] Replace the following FGs with experiment `platform_editor_advanced_layouts`
|
|
22
|
+
|
|
23
|
+
- platform_editor_advanced_layouts_breakout_resizing
|
|
24
|
+
- platform_editor_advanced_layouts_pre_release_1
|
|
25
|
+
- platform_editor_advanced_layouts_pre_release_2
|
|
26
|
+
|
|
3
27
|
## 1.12.9
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/cjs/layoutPlugin.js
CHANGED
|
@@ -17,12 +17,11 @@ var _schema = require("@atlaskit/adf-schema/schema");
|
|
|
17
17
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
18
18
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
19
19
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
20
|
-
var
|
|
20
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
21
21
|
var _actions = require("./pm-plugins/actions");
|
|
22
22
|
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
23
23
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
24
24
|
var _resizing = _interopRequireDefault(require("./pm-plugins/resizing"));
|
|
25
|
-
var _preRelease = require("./pm-plugins/utils/preRelease");
|
|
26
25
|
var _globalStyles = require("./ui/global-styles");
|
|
27
26
|
var _toolbar = require("./ui/toolbar");
|
|
28
27
|
var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
@@ -35,7 +34,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
35
34
|
nodes: function nodes() {
|
|
36
35
|
return [{
|
|
37
36
|
name: 'layoutSection',
|
|
38
|
-
node: (0,
|
|
37
|
+
node: (0, _experiments.editorExperiment)('advanced_layouts', true) ? _schema.layoutSectionWithSingleColumn : _adfSchema.layoutSection
|
|
39
38
|
}, {
|
|
40
39
|
name: 'layoutColumn',
|
|
41
40
|
node: _adfSchema.layoutColumn
|
|
@@ -48,7 +47,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
48
47
|
return (0, _main.default)(options);
|
|
49
48
|
}
|
|
50
49
|
}];
|
|
51
|
-
if ((options.editorAppearance === 'full-page' || options.editorAppearance === 'full-width') && api && (0,
|
|
50
|
+
if ((options.editorAppearance === 'full-page' || options.editorAppearance === 'full-width') && api && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
52
51
|
plugins.push({
|
|
53
52
|
name: 'layoutResizing',
|
|
54
53
|
plugin: function plugin(_ref2) {
|
|
@@ -77,7 +76,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
77
76
|
},
|
|
78
77
|
quickInsert: function quickInsert(_ref4) {
|
|
79
78
|
var formatMessage = _ref4.formatMessage;
|
|
80
|
-
return (0,
|
|
79
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) ? [{
|
|
81
80
|
id: 'twocolumnslayout',
|
|
82
81
|
title: formatMessage(_messages.layoutMessages.twoColumns),
|
|
83
82
|
description: formatMessage(_messages.toolbarInsertBlockMessages.columnsDescription),
|
|
@@ -156,7 +155,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
156
155
|
}
|
|
157
156
|
},
|
|
158
157
|
contentComponent: function contentComponent() {
|
|
159
|
-
return (0,
|
|
158
|
+
return (0, _experiments.editorExperiment)('advanced_layouts', true) ? /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, null) : null;
|
|
160
159
|
}
|
|
161
160
|
};
|
|
162
161
|
};
|
|
@@ -18,6 +18,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
18
18
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
19
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
20
|
var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
|
|
21
|
+
var _pluginInjectionApi$a;
|
|
21
22
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
22
23
|
forwardRef = _ref.forwardRef,
|
|
23
24
|
getPos = _ref.getPos,
|
|
@@ -36,7 +37,8 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
|
|
|
36
37
|
nodeType: "layoutSection",
|
|
37
38
|
getEditorWidth: getEditorWidth,
|
|
38
39
|
disabled: (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) === true,
|
|
39
|
-
parentRef: parentRef
|
|
40
|
+
parentRef: parentRef,
|
|
41
|
+
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions
|
|
40
42
|
});
|
|
41
43
|
};
|
|
42
44
|
var toDOM = function toDOM() {
|
|
@@ -17,14 +17,13 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
|
17
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
18
|
var _consts = require("./consts");
|
|
19
19
|
var _pluginKey = require("./plugin-key");
|
|
20
|
-
var _preRelease = require("./utils/preRelease");
|
|
21
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
22
|
var ONE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = ['single'];
|
|
24
23
|
var TWO_COL_LAYOUTS = exports.TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
25
24
|
var THREE_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
26
25
|
var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
27
|
-
if ((0,
|
|
26
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
28
27
|
switch (presetLayout) {
|
|
29
28
|
case 'single':
|
|
30
29
|
return [100];
|
|
@@ -66,17 +65,17 @@ var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
|
66
65
|
};
|
|
67
66
|
var isValidLayoutWidthDistributions = function isValidLayoutWidthDistributions(layoutSection) {
|
|
68
67
|
var totalWidth = 0;
|
|
68
|
+
var hasInvalidWidth = false;
|
|
69
69
|
(0, _utils.mapChildren)(layoutSection, function (column) {
|
|
70
70
|
return column.attrs.width;
|
|
71
71
|
}).forEach(function (width) {
|
|
72
72
|
if (typeof width === 'number' && isFinite(width) && width > 0 && width <= 100) {
|
|
73
73
|
totalWidth += width;
|
|
74
|
+
} else {
|
|
75
|
+
hasInvalidWidth = true;
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
// not a valid width, e.g. 0, 100, undefined
|
|
77
|
-
return false;
|
|
78
77
|
});
|
|
79
|
-
return Math.round(totalWidth) === 100;
|
|
78
|
+
return !hasInvalidWidth && Math.round(totalWidth) === 100;
|
|
80
79
|
};
|
|
81
80
|
|
|
82
81
|
/**
|
|
@@ -87,7 +86,7 @@ var getPresetLayout = exports.getPresetLayout = function getPresetLayout(section
|
|
|
87
86
|
var widths = (0, _utils.mapChildren)(section, function (column) {
|
|
88
87
|
return column.attrs.width;
|
|
89
88
|
}).join(',');
|
|
90
|
-
if ((0,
|
|
89
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
91
90
|
switch (widths) {
|
|
92
91
|
case '100':
|
|
93
92
|
return 'single';
|
|
@@ -128,7 +127,13 @@ var getPresetLayout = exports.getPresetLayout = function getPresetLayout(section
|
|
|
128
127
|
}
|
|
129
128
|
return;
|
|
130
129
|
};
|
|
130
|
+
var isLayoutOutOfSync = function isLayoutOutOfSync(node, presetLayout) {
|
|
131
|
+
return node.childCount !== getWidthsForPreset(presetLayout).length;
|
|
132
|
+
};
|
|
131
133
|
var getSelectedLayout = exports.getSelectedLayout = function getSelectedLayout(maybeLayoutSection, current) {
|
|
134
|
+
if (maybeLayoutSection && isLayoutOutOfSync(maybeLayoutSection, current) && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
135
|
+
return getDefaultPresetLayout(maybeLayoutSection);
|
|
136
|
+
}
|
|
132
137
|
if (maybeLayoutSection && getPresetLayout(maybeLayoutSection)) {
|
|
133
138
|
return getPresetLayout(maybeLayoutSection) || current;
|
|
134
139
|
}
|
|
@@ -190,7 +195,7 @@ var insertLayoutColumnsWithAnalytics = exports.insertLayoutColumnsWithAnalytics
|
|
|
190
195
|
* Add a column to the right of existing layout
|
|
191
196
|
*/
|
|
192
197
|
function addColumn(schema, pos) {
|
|
193
|
-
if (
|
|
198
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', false)) {
|
|
194
199
|
return function (tr) {
|
|
195
200
|
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
196
201
|
};
|
|
@@ -323,7 +328,7 @@ function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
|
323
328
|
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
324
329
|
}
|
|
325
330
|
function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
326
|
-
var forceColumnStructureFn = (0,
|
|
331
|
+
var forceColumnStructureFn = (0, _experiments.editorExperiment)('advanced_layouts', true) ? forceColumnStructureNew : forceColumnStructure;
|
|
327
332
|
var tr = forceColumnStructureFn(state, node, pos, presetLayout);
|
|
328
333
|
|
|
329
334
|
// save the selection here, since forcing column widths causes a change over the
|
|
@@ -369,7 +374,7 @@ var setPresetLayout = exports.setPresetLayout = function setPresetLayout(editorA
|
|
|
369
374
|
};
|
|
370
375
|
};
|
|
371
376
|
function layoutNeedChanges(node) {
|
|
372
|
-
if ((0,
|
|
377
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
373
378
|
return !getPresetLayout(node) || !isValidLayoutWidthDistributions(node);
|
|
374
379
|
}
|
|
375
380
|
return !getPresetLayout(node);
|
|
@@ -482,7 +487,7 @@ var deleteActiveLayoutNode = exports.deleteActiveLayoutNode = function deleteAct
|
|
|
482
487
|
};
|
|
483
488
|
};
|
|
484
489
|
var formatLayoutName = function formatLayoutName(layout) {
|
|
485
|
-
if ((0,
|
|
490
|
+
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
486
491
|
switch (layout) {
|
|
487
492
|
case 'single':
|
|
488
493
|
return _analytics.LAYOUT_TYPE.SINGLE_COL;
|
|
@@ -13,6 +13,7 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
15
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
16
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
17
|
var _actions = require("./actions");
|
|
17
18
|
var _pluginKey = require("./plugin-key");
|
|
18
19
|
var _utils3 = require("./utils");
|
|
@@ -66,6 +67,20 @@ var getInitialPluginState = function getInitialPluginState(options, state) {
|
|
|
66
67
|
allowSingleColumnLayout: allowSingleColumnLayout
|
|
67
68
|
};
|
|
68
69
|
};
|
|
70
|
+
|
|
71
|
+
// To prevent a single-column layout,
|
|
72
|
+
// if a user attempts to delete a layout column and
|
|
73
|
+
// we will force remove the content instead.
|
|
74
|
+
// There are some edge cases where user can delete a layout column
|
|
75
|
+
// see packages/editor/editor-plugin-layout-tests/src/__tests__/unit/delete.ts
|
|
76
|
+
var handleDeleteLayoutColumn = function handleDeleteLayoutColumn(state, dispatch) {
|
|
77
|
+
var sel = state.selection;
|
|
78
|
+
if (sel instanceof _state.NodeSelection && sel.node.type.name === 'layoutColumn' && sel.$from.parent.type.name === 'layoutSection' && sel.$from.parent.childCount === 2 && dispatch && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
79
|
+
dispatch(state.tr.deleteRange(sel.from + 1, sel.from + sel.node.content.size));
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
};
|
|
69
84
|
var _default = exports.default = function _default(options) {
|
|
70
85
|
return new _safePlugin.SafePlugin({
|
|
71
86
|
key: _pluginKey.pluginKey,
|
|
@@ -94,7 +109,11 @@ var _default = exports.default = function _default(options) {
|
|
|
94
109
|
return undefined;
|
|
95
110
|
},
|
|
96
111
|
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
97
|
-
Tab: (0, _utils.filterCommand)(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn)
|
|
112
|
+
Tab: (0, _utils.filterCommand)(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn),
|
|
113
|
+
'Mod-Backspace': handleDeleteLayoutColumn,
|
|
114
|
+
'Mod-Delete': handleDeleteLayoutColumn,
|
|
115
|
+
Backspace: handleDeleteLayoutColumn,
|
|
116
|
+
Delete: handleDeleteLayoutColumn
|
|
98
117
|
}),
|
|
99
118
|
handleClickOn: (0, _selection.createSelectionClickHandler)(['layoutColumn'], function (target) {
|
|
100
119
|
return target.hasAttribute('data-layout-section') || target.hasAttribute('data-layout-column');
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -24,8 +24,8 @@ var _layoutTwoLeftSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph
|
|
|
24
24
|
var _layoutTwoRightSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-right-sidebar"));
|
|
25
25
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
26
26
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
27
28
|
var _actions = require("../pm-plugins/actions");
|
|
28
|
-
var _preRelease = require("../pm-plugins/utils/preRelease");
|
|
29
29
|
var _LayoutThreeWithLeftSidebars = require("./icons/LayoutThreeWithLeftSidebars");
|
|
30
30
|
var _LayoutThreeWithRightSidebars = require("./icons/LayoutThreeWithRightSidebars");
|
|
31
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); }
|
|
@@ -233,7 +233,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos
|
|
|
233
233
|
},
|
|
234
234
|
nodeType: nodeType,
|
|
235
235
|
groupLabel: intl.formatMessage(_messages.layoutMessages.floatingToolbarRadioGroupAriaLabel),
|
|
236
|
-
items: (0,
|
|
236
|
+
items: (0, _experiments.editorExperiment)('advanced_layouts', true) ? getAdvancedLayoutItems({
|
|
237
237
|
addSidebarLayouts: addSidebarLayouts,
|
|
238
238
|
intl: intl,
|
|
239
239
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
@@ -4,12 +4,11 @@ import { layoutSectionWithSingleColumn } from '@atlaskit/adf-schema/schema';
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
-
import {
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
8
|
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
9
9
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
10
10
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
11
11
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
12
|
-
import { isPreRelease2 } from './pm-plugins/utils/preRelease';
|
|
13
12
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
14
13
|
import { buildToolbar } from './ui/toolbar';
|
|
15
14
|
export { pluginKey };
|
|
@@ -23,7 +22,7 @@ export const layoutPlugin = ({
|
|
|
23
22
|
nodes() {
|
|
24
23
|
return [{
|
|
25
24
|
name: 'layoutSection',
|
|
26
|
-
node:
|
|
25
|
+
node: editorExperiment('advanced_layouts', true) ? layoutSectionWithSingleColumn : layoutSection
|
|
27
26
|
}, {
|
|
28
27
|
name: 'layoutColumn',
|
|
29
28
|
node: layoutColumn
|
|
@@ -34,7 +33,7 @@ export const layoutPlugin = ({
|
|
|
34
33
|
name: 'layout',
|
|
35
34
|
plugin: () => createLayoutPlugin(options)
|
|
36
35
|
}];
|
|
37
|
-
if ((options.editorAppearance === 'full-page' || options.editorAppearance === 'full-width') && api &&
|
|
36
|
+
if ((options.editorAppearance === 'full-page' || options.editorAppearance === 'full-width') && api && editorExperiment('advanced_layouts', true)) {
|
|
38
37
|
plugins.push({
|
|
39
38
|
name: 'layoutResizing',
|
|
40
39
|
plugin: ({
|
|
@@ -63,7 +62,7 @@ export const layoutPlugin = ({
|
|
|
63
62
|
},
|
|
64
63
|
quickInsert: ({
|
|
65
64
|
formatMessage
|
|
66
|
-
}) =>
|
|
65
|
+
}) => editorExperiment('advanced_layouts', true) ? [{
|
|
67
66
|
id: 'twocolumnslayout',
|
|
68
67
|
title: formatMessage(layoutMessages.twoColumns),
|
|
69
68
|
description: formatMessage(messages.columnsDescription),
|
|
@@ -131,7 +130,7 @@ export const layoutPlugin = ({
|
|
|
131
130
|
}]
|
|
132
131
|
},
|
|
133
132
|
contentComponent() {
|
|
134
|
-
return
|
|
133
|
+
return editorExperiment('advanced_layouts', true) ? /*#__PURE__*/React.createElement(GlobalStylesWrapper, null) : null;
|
|
135
134
|
}
|
|
136
135
|
};
|
|
137
136
|
};
|
|
@@ -10,6 +10,7 @@ const LayoutBreakoutResizer = ({
|
|
|
10
10
|
view,
|
|
11
11
|
parentRef
|
|
12
12
|
}) => {
|
|
13
|
+
var _pluginInjectionApi$a;
|
|
13
14
|
const {
|
|
14
15
|
editorDisabledState
|
|
15
16
|
} = useSharedPluginState(pluginInjectionApi, ['editorDisabled']);
|
|
@@ -24,7 +25,8 @@ const LayoutBreakoutResizer = ({
|
|
|
24
25
|
nodeType: "layoutSection",
|
|
25
26
|
getEditorWidth: getEditorWidth,
|
|
26
27
|
disabled: (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) === true,
|
|
27
|
-
parentRef: parentRef
|
|
28
|
+
parentRef: parentRef,
|
|
29
|
+
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions
|
|
28
30
|
});
|
|
29
31
|
};
|
|
30
32
|
const toDOM = () => ['div', {
|
|
@@ -7,12 +7,11 @@ import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
|
7
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
8
|
import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
|
|
9
9
|
import { pluginKey } from './plugin-key';
|
|
10
|
-
import { isPreRelease2 } from './utils/preRelease';
|
|
11
10
|
export const ONE_COL_LAYOUTS = ['single'];
|
|
12
11
|
export const TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
13
12
|
export const THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
14
13
|
const getWidthsForPreset = presetLayout => {
|
|
15
|
-
if (
|
|
14
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
16
15
|
switch (presetLayout) {
|
|
17
16
|
case 'single':
|
|
18
17
|
return [100];
|
|
@@ -54,15 +53,15 @@ const getWidthsForPreset = presetLayout => {
|
|
|
54
53
|
};
|
|
55
54
|
const isValidLayoutWidthDistributions = layoutSection => {
|
|
56
55
|
let totalWidth = 0;
|
|
56
|
+
let hasInvalidWidth = false;
|
|
57
57
|
mapChildren(layoutSection, column => column.attrs.width).forEach(width => {
|
|
58
58
|
if (typeof width === 'number' && isFinite(width) && width > 0 && width <= 100) {
|
|
59
59
|
totalWidth += width;
|
|
60
|
+
} else {
|
|
61
|
+
hasInvalidWidth = true;
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
// not a valid width, e.g. 0, 100, undefined
|
|
63
|
-
return false;
|
|
64
63
|
});
|
|
65
|
-
return Math.round(totalWidth) === 100;
|
|
64
|
+
return !hasInvalidWidth && Math.round(totalWidth) === 100;
|
|
66
65
|
};
|
|
67
66
|
|
|
68
67
|
/**
|
|
@@ -71,7 +70,7 @@ const isValidLayoutWidthDistributions = layoutSection => {
|
|
|
71
70
|
*/
|
|
72
71
|
export const getPresetLayout = section => {
|
|
73
72
|
const widths = mapChildren(section, column => column.attrs.width).join(',');
|
|
74
|
-
if (
|
|
73
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
75
74
|
switch (widths) {
|
|
76
75
|
case '100':
|
|
77
76
|
return 'single';
|
|
@@ -112,7 +111,13 @@ export const getPresetLayout = section => {
|
|
|
112
111
|
}
|
|
113
112
|
return;
|
|
114
113
|
};
|
|
114
|
+
const isLayoutOutOfSync = (node, presetLayout) => {
|
|
115
|
+
return node.childCount !== getWidthsForPreset(presetLayout).length;
|
|
116
|
+
};
|
|
115
117
|
export const getSelectedLayout = (maybeLayoutSection, current) => {
|
|
118
|
+
if (maybeLayoutSection && isLayoutOutOfSync(maybeLayoutSection, current) && editorExperiment('advanced_layouts', true)) {
|
|
119
|
+
return getDefaultPresetLayout(maybeLayoutSection);
|
|
120
|
+
}
|
|
116
121
|
if (maybeLayoutSection && getPresetLayout(maybeLayoutSection)) {
|
|
117
122
|
return getPresetLayout(maybeLayoutSection) || current;
|
|
118
123
|
}
|
|
@@ -169,7 +174,7 @@ export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => inputMetho
|
|
|
169
174
|
* Add a column to the right of existing layout
|
|
170
175
|
*/
|
|
171
176
|
function addColumn(schema, pos) {
|
|
172
|
-
if (
|
|
177
|
+
if (editorExperiment('advanced_layouts', false)) {
|
|
173
178
|
return tr => {
|
|
174
179
|
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
175
180
|
};
|
|
@@ -301,7 +306,7 @@ function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
|
301
306
|
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
302
307
|
}
|
|
303
308
|
export function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
304
|
-
const forceColumnStructureFn =
|
|
309
|
+
const forceColumnStructureFn = editorExperiment('advanced_layouts', true) ? forceColumnStructureNew : forceColumnStructure;
|
|
305
310
|
let tr = forceColumnStructureFn(state, node, pos, presetLayout);
|
|
306
311
|
|
|
307
312
|
// save the selection here, since forcing column widths causes a change over the
|
|
@@ -344,7 +349,7 @@ export const setPresetLayout = editorAnalyticsAPI => layout => (state, dispatch)
|
|
|
344
349
|
return false;
|
|
345
350
|
};
|
|
346
351
|
function layoutNeedChanges(node) {
|
|
347
|
-
if (
|
|
352
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
348
353
|
return !getPresetLayout(node) || !isValidLayoutWidthDistributions(node);
|
|
349
354
|
}
|
|
350
355
|
return !getPresetLayout(node);
|
|
@@ -459,7 +464,7 @@ export const deleteActiveLayoutNode = editorAnalyticsAPI => (state, dispatch) =>
|
|
|
459
464
|
return false;
|
|
460
465
|
};
|
|
461
466
|
const formatLayoutName = layout => {
|
|
462
|
-
if (
|
|
467
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
463
468
|
switch (layout) {
|
|
464
469
|
case 'single':
|
|
465
470
|
return LAYOUT_TYPE.SINGLE_COL;
|
|
@@ -2,9 +2,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import { filterCommand as filter } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
5
|
-
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from './actions';
|
|
9
10
|
import { pluginKey } from './plugin-key';
|
|
10
11
|
import { getMaybeLayoutSection } from './utils';
|
|
@@ -61,6 +62,20 @@ const getInitialPluginState = (options, state) => {
|
|
|
61
62
|
allowSingleColumnLayout
|
|
62
63
|
};
|
|
63
64
|
};
|
|
65
|
+
|
|
66
|
+
// To prevent a single-column layout,
|
|
67
|
+
// if a user attempts to delete a layout column and
|
|
68
|
+
// we will force remove the content instead.
|
|
69
|
+
// There are some edge cases where user can delete a layout column
|
|
70
|
+
// see packages/editor/editor-plugin-layout-tests/src/__tests__/unit/delete.ts
|
|
71
|
+
const handleDeleteLayoutColumn = (state, dispatch) => {
|
|
72
|
+
const sel = state.selection;
|
|
73
|
+
if (sel instanceof NodeSelection && sel.node.type.name === 'layoutColumn' && sel.$from.parent.type.name === 'layoutSection' && sel.$from.parent.childCount === 2 && dispatch && editorExperiment('advanced_layouts', true)) {
|
|
74
|
+
dispatch(state.tr.deleteRange(sel.from + 1, sel.from + sel.node.content.size));
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
64
79
|
export default (options => new SafePlugin({
|
|
65
80
|
key: pluginKey,
|
|
66
81
|
state: {
|
|
@@ -87,7 +102,11 @@ export default (options => new SafePlugin({
|
|
|
87
102
|
return undefined;
|
|
88
103
|
},
|
|
89
104
|
handleKeyDown: keydownHandler({
|
|
90
|
-
Tab: filter(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn)
|
|
105
|
+
Tab: filter(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn),
|
|
106
|
+
'Mod-Backspace': handleDeleteLayoutColumn,
|
|
107
|
+
'Mod-Delete': handleDeleteLayoutColumn,
|
|
108
|
+
Backspace: handleDeleteLayoutColumn,
|
|
109
|
+
Delete: handleDeleteLayoutColumn
|
|
91
110
|
}),
|
|
92
111
|
handleClickOn: createSelectionClickHandler(['layoutColumn'], target => target.hasAttribute('data-layout-section') || target.hasAttribute('data-layout-column'), {
|
|
93
112
|
useLongPressSelection: options.useLongPressSelection || false,
|
|
@@ -15,8 +15,8 @@ import LayoutTwoLeftSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-lef
|
|
|
15
15
|
import LayoutTwoRightSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-right-sidebar';
|
|
16
16
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
19
|
import { deleteActiveLayoutNode, getPresetLayout, setPresetLayout } from '../pm-plugins/actions';
|
|
19
|
-
import { isPreRelease2 } from '../pm-plugins/utils/preRelease';
|
|
20
20
|
import { LayoutThreeWithLeftSidebarsIcon } from './icons/LayoutThreeWithLeftSidebars';
|
|
21
21
|
import { LayoutThreeWithRightSidebarsIcon } from './icons/LayoutThreeWithRightSidebars';
|
|
22
22
|
const LAYOUT_TYPES = [{
|
|
@@ -218,7 +218,7 @@ export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts
|
|
|
218
218
|
getDomRef: view => findDomRefAtPos(pos, view.domAtPos.bind(view)),
|
|
219
219
|
nodeType,
|
|
220
220
|
groupLabel: intl.formatMessage(toolbarMessages.floatingToolbarRadioGroupAriaLabel),
|
|
221
|
-
items:
|
|
221
|
+
items: editorExperiment('advanced_layouts', true) ? getAdvancedLayoutItems({
|
|
222
222
|
addSidebarLayouts,
|
|
223
223
|
intl,
|
|
224
224
|
editorAnalyticsAPI,
|
package/dist/esm/layoutPlugin.js
CHANGED
|
@@ -4,12 +4,11 @@ import { layoutSectionWithSingleColumn } from '@atlaskit/adf-schema/schema';
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
-
import {
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
8
|
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
9
9
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
10
10
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
11
11
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
12
|
-
import { isPreRelease2 } from './pm-plugins/utils/preRelease';
|
|
13
12
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
14
13
|
import { buildToolbar } from './ui/toolbar';
|
|
15
14
|
export { pluginKey };
|
|
@@ -23,7 +22,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
23
22
|
nodes: function nodes() {
|
|
24
23
|
return [{
|
|
25
24
|
name: 'layoutSection',
|
|
26
|
-
node:
|
|
25
|
+
node: editorExperiment('advanced_layouts', true) ? layoutSectionWithSingleColumn : layoutSection
|
|
27
26
|
}, {
|
|
28
27
|
name: 'layoutColumn',
|
|
29
28
|
node: layoutColumn
|
|
@@ -36,7 +35,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
36
35
|
return createLayoutPlugin(options);
|
|
37
36
|
}
|
|
38
37
|
}];
|
|
39
|
-
if ((options.editorAppearance === 'full-page' || options.editorAppearance === 'full-width') && api &&
|
|
38
|
+
if ((options.editorAppearance === 'full-page' || options.editorAppearance === 'full-width') && api && editorExperiment('advanced_layouts', true)) {
|
|
40
39
|
plugins.push({
|
|
41
40
|
name: 'layoutResizing',
|
|
42
41
|
plugin: function plugin(_ref2) {
|
|
@@ -65,7 +64,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
65
64
|
},
|
|
66
65
|
quickInsert: function quickInsert(_ref4) {
|
|
67
66
|
var formatMessage = _ref4.formatMessage;
|
|
68
|
-
return
|
|
67
|
+
return editorExperiment('advanced_layouts', true) ? [{
|
|
69
68
|
id: 'twocolumnslayout',
|
|
70
69
|
title: formatMessage(layoutMessages.twoColumns),
|
|
71
70
|
description: formatMessage(messages.columnsDescription),
|
|
@@ -144,7 +143,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
144
143
|
}
|
|
145
144
|
},
|
|
146
145
|
contentComponent: function contentComponent() {
|
|
147
|
-
return
|
|
146
|
+
return editorExperiment('advanced_layouts', true) ? /*#__PURE__*/React.createElement(GlobalStylesWrapper, null) : null;
|
|
148
147
|
}
|
|
149
148
|
};
|
|
150
149
|
};
|
|
@@ -11,6 +11,7 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
11
11
|
import { BreakoutResizer, ignoreResizerMutations } from '@atlaskit/editor-common/resizer';
|
|
12
12
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
13
13
|
var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
|
|
14
|
+
var _pluginInjectionApi$a;
|
|
14
15
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
15
16
|
forwardRef = _ref.forwardRef,
|
|
16
17
|
getPos = _ref.getPos,
|
|
@@ -29,7 +30,8 @@ var LayoutBreakoutResizer = function LayoutBreakoutResizer(_ref) {
|
|
|
29
30
|
nodeType: "layoutSection",
|
|
30
31
|
getEditorWidth: getEditorWidth,
|
|
31
32
|
disabled: (editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) === true,
|
|
32
|
-
parentRef: parentRef
|
|
33
|
+
parentRef: parentRef,
|
|
34
|
+
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions
|
|
33
35
|
});
|
|
34
36
|
};
|
|
35
37
|
var toDOM = function toDOM() {
|
|
@@ -10,12 +10,11 @@ import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
|
10
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
11
|
import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
|
|
12
12
|
import { pluginKey } from './plugin-key';
|
|
13
|
-
import { isPreRelease2 } from './utils/preRelease';
|
|
14
13
|
export var ONE_COL_LAYOUTS = ['single'];
|
|
15
14
|
export var TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
16
15
|
export var THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
17
16
|
var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
18
|
-
if (
|
|
17
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
19
18
|
switch (presetLayout) {
|
|
20
19
|
case 'single':
|
|
21
20
|
return [100];
|
|
@@ -57,17 +56,17 @@ var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
|
57
56
|
};
|
|
58
57
|
var isValidLayoutWidthDistributions = function isValidLayoutWidthDistributions(layoutSection) {
|
|
59
58
|
var totalWidth = 0;
|
|
59
|
+
var hasInvalidWidth = false;
|
|
60
60
|
mapChildren(layoutSection, function (column) {
|
|
61
61
|
return column.attrs.width;
|
|
62
62
|
}).forEach(function (width) {
|
|
63
63
|
if (typeof width === 'number' && isFinite(width) && width > 0 && width <= 100) {
|
|
64
64
|
totalWidth += width;
|
|
65
|
+
} else {
|
|
66
|
+
hasInvalidWidth = true;
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
// not a valid width, e.g. 0, 100, undefined
|
|
68
|
-
return false;
|
|
69
68
|
});
|
|
70
|
-
return Math.round(totalWidth) === 100;
|
|
69
|
+
return !hasInvalidWidth && Math.round(totalWidth) === 100;
|
|
71
70
|
};
|
|
72
71
|
|
|
73
72
|
/**
|
|
@@ -78,7 +77,7 @@ export var getPresetLayout = function getPresetLayout(section) {
|
|
|
78
77
|
var widths = mapChildren(section, function (column) {
|
|
79
78
|
return column.attrs.width;
|
|
80
79
|
}).join(',');
|
|
81
|
-
if (
|
|
80
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
82
81
|
switch (widths) {
|
|
83
82
|
case '100':
|
|
84
83
|
return 'single';
|
|
@@ -119,7 +118,13 @@ export var getPresetLayout = function getPresetLayout(section) {
|
|
|
119
118
|
}
|
|
120
119
|
return;
|
|
121
120
|
};
|
|
121
|
+
var isLayoutOutOfSync = function isLayoutOutOfSync(node, presetLayout) {
|
|
122
|
+
return node.childCount !== getWidthsForPreset(presetLayout).length;
|
|
123
|
+
};
|
|
122
124
|
export var getSelectedLayout = function getSelectedLayout(maybeLayoutSection, current) {
|
|
125
|
+
if (maybeLayoutSection && isLayoutOutOfSync(maybeLayoutSection, current) && editorExperiment('advanced_layouts', true)) {
|
|
126
|
+
return getDefaultPresetLayout(maybeLayoutSection);
|
|
127
|
+
}
|
|
123
128
|
if (maybeLayoutSection && getPresetLayout(maybeLayoutSection)) {
|
|
124
129
|
return getPresetLayout(maybeLayoutSection) || current;
|
|
125
130
|
}
|
|
@@ -181,7 +186,7 @@ export var insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAn
|
|
|
181
186
|
* Add a column to the right of existing layout
|
|
182
187
|
*/
|
|
183
188
|
function addColumn(schema, pos) {
|
|
184
|
-
if (
|
|
189
|
+
if (editorExperiment('advanced_layouts', false)) {
|
|
185
190
|
return function (tr) {
|
|
186
191
|
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
187
192
|
};
|
|
@@ -314,7 +319,7 @@ function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
|
314
319
|
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
315
320
|
}
|
|
316
321
|
export function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
317
|
-
var forceColumnStructureFn =
|
|
322
|
+
var forceColumnStructureFn = editorExperiment('advanced_layouts', true) ? forceColumnStructureNew : forceColumnStructure;
|
|
318
323
|
var tr = forceColumnStructureFn(state, node, pos, presetLayout);
|
|
319
324
|
|
|
320
325
|
// save the selection here, since forcing column widths causes a change over the
|
|
@@ -360,7 +365,7 @@ export var setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
|
|
|
360
365
|
};
|
|
361
366
|
};
|
|
362
367
|
function layoutNeedChanges(node) {
|
|
363
|
-
if (
|
|
368
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
364
369
|
return !getPresetLayout(node) || !isValidLayoutWidthDistributions(node);
|
|
365
370
|
}
|
|
366
371
|
return !getPresetLayout(node);
|
|
@@ -473,7 +478,7 @@ export var deleteActiveLayoutNode = function deleteActiveLayoutNode(editorAnalyt
|
|
|
473
478
|
};
|
|
474
479
|
};
|
|
475
480
|
var formatLayoutName = function formatLayoutName(layout) {
|
|
476
|
-
if (
|
|
481
|
+
if (editorExperiment('advanced_layouts', true)) {
|
|
477
482
|
switch (layout) {
|
|
478
483
|
case 'single':
|
|
479
484
|
return LAYOUT_TYPE.SINGLE_COL;
|
|
@@ -5,9 +5,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
5
5
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
6
6
|
import { filterCommand as filter } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
8
|
-
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
12
|
import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from './actions';
|
|
12
13
|
import { pluginKey } from './plugin-key';
|
|
13
14
|
import { getMaybeLayoutSection } from './utils';
|
|
@@ -59,6 +60,20 @@ var getInitialPluginState = function getInitialPluginState(options, state) {
|
|
|
59
60
|
allowSingleColumnLayout: allowSingleColumnLayout
|
|
60
61
|
};
|
|
61
62
|
};
|
|
63
|
+
|
|
64
|
+
// To prevent a single-column layout,
|
|
65
|
+
// if a user attempts to delete a layout column and
|
|
66
|
+
// we will force remove the content instead.
|
|
67
|
+
// There are some edge cases where user can delete a layout column
|
|
68
|
+
// see packages/editor/editor-plugin-layout-tests/src/__tests__/unit/delete.ts
|
|
69
|
+
var handleDeleteLayoutColumn = function handleDeleteLayoutColumn(state, dispatch) {
|
|
70
|
+
var sel = state.selection;
|
|
71
|
+
if (sel instanceof NodeSelection && sel.node.type.name === 'layoutColumn' && sel.$from.parent.type.name === 'layoutSection' && sel.$from.parent.childCount === 2 && dispatch && editorExperiment('advanced_layouts', true)) {
|
|
72
|
+
dispatch(state.tr.deleteRange(sel.from + 1, sel.from + sel.node.content.size));
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
};
|
|
62
77
|
export default (function (options) {
|
|
63
78
|
return new SafePlugin({
|
|
64
79
|
key: pluginKey,
|
|
@@ -87,7 +102,11 @@ export default (function (options) {
|
|
|
87
102
|
return undefined;
|
|
88
103
|
},
|
|
89
104
|
handleKeyDown: keydownHandler({
|
|
90
|
-
Tab: filter(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn)
|
|
105
|
+
Tab: filter(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn),
|
|
106
|
+
'Mod-Backspace': handleDeleteLayoutColumn,
|
|
107
|
+
'Mod-Delete': handleDeleteLayoutColumn,
|
|
108
|
+
Backspace: handleDeleteLayoutColumn,
|
|
109
|
+
Delete: handleDeleteLayoutColumn
|
|
91
110
|
}),
|
|
92
111
|
handleClickOn: createSelectionClickHandler(['layoutColumn'], function (target) {
|
|
93
112
|
return target.hasAttribute('data-layout-section') || target.hasAttribute('data-layout-column');
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -16,8 +16,8 @@ import LayoutTwoLeftSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-lef
|
|
|
16
16
|
import LayoutTwoRightSidebarIcon from '@atlaskit/icon/glyph/editor/layout-two-right-sidebar';
|
|
17
17
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
18
18
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
19
20
|
import { deleteActiveLayoutNode, getPresetLayout, setPresetLayout } from '../pm-plugins/actions';
|
|
20
|
-
import { isPreRelease2 } from '../pm-plugins/utils/preRelease';
|
|
21
21
|
import { LayoutThreeWithLeftSidebarsIcon } from './icons/LayoutThreeWithLeftSidebars';
|
|
22
22
|
import { LayoutThreeWithRightSidebarsIcon } from './icons/LayoutThreeWithRightSidebars';
|
|
23
23
|
var LAYOUT_TYPES = [{
|
|
@@ -223,7 +223,7 @@ export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout
|
|
|
223
223
|
},
|
|
224
224
|
nodeType: nodeType,
|
|
225
225
|
groupLabel: intl.formatMessage(toolbarMessages.floatingToolbarRadioGroupAriaLabel),
|
|
226
|
-
items:
|
|
226
|
+
items: editorExperiment('advanced_layouts', true) ? getAdvancedLayoutItems({
|
|
227
227
|
addSidebarLayouts: addSidebarLayouts,
|
|
228
228
|
intl: intl,
|
|
229
229
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.11",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-width": "^1.3.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
41
|
-
"@atlaskit/icon": "^
|
|
41
|
+
"@atlaskit/icon": "^23.0.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
43
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
43
|
+
"@atlaskit/tmp-editor-statsig": "^2.22.0",
|
|
44
44
|
"@atlaskit/tokens": "^2.4.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"@emotion/react": "^11.7.1"
|
|
@@ -94,15 +94,9 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"platform-feature-flags": {
|
|
97
|
-
"platform_editor_advanced_layouts_pre_release_2": {
|
|
98
|
-
"type": "boolean"
|
|
99
|
-
},
|
|
100
97
|
"platform_editor_remove_copy_button_from_view_mode": {
|
|
101
98
|
"type": "boolean"
|
|
102
99
|
},
|
|
103
|
-
"platform_editor_advanced_layouts_breakout_resizing": {
|
|
104
|
-
"type": "boolean"
|
|
105
|
-
},
|
|
106
100
|
"platform-visual-refresh-icons": {
|
|
107
101
|
"type": "boolean"
|
|
108
102
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isPreRelease2 = void 0;
|
|
7
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
9
|
-
var isPreRelease2 = exports.isPreRelease2 = function isPreRelease2() {
|
|
10
|
-
return (0, _experiments.editorExperiment)('advanced_layouts', true) || (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_pre_release_2');
|
|
11
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
3
|
-
export var isPreRelease2 = function isPreRelease2() {
|
|
4
|
-
return editorExperiment('advanced_layouts', true) || fg('platform_editor_advanced_layouts_pre_release_2');
|
|
5
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isPreRelease2: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isPreRelease2: () => boolean;
|