@atlaskit/editor-plugin-layout 2.1.5 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/layoutPlugin.js +19 -3
- package/dist/cjs/ui/global-styles.js +12 -13
- package/dist/cjs/ui/toolbar.js +15 -4
- package/dist/es2019/layoutPlugin.js +17 -3
- package/dist/es2019/ui/global-styles.js +3 -2
- package/dist/es2019/ui/toolbar.js +15 -4
- package/dist/esm/layoutPlugin.js +20 -4
- package/dist/esm/ui/global-styles.js +11 -13
- package/dist/esm/ui/toolbar.js +15 -4
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/ui/toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/toolbar.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 2.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#127914](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/127914)
|
|
8
|
+
[`1240912e13dd0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1240912e13dd0) -
|
|
9
|
+
[ux] ED-27097 Hide layout placeholder when editor is not focussed
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.2.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#115815](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/115815)
|
|
17
|
+
[`ad7c517ed3b47`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ad7c517ed3b47) -
|
|
18
|
+
ED-26661 add option enables single column layout
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 2.1.5
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/cjs/layoutPlugin.js
CHANGED
|
@@ -23,6 +23,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
23
23
|
var _ref$config = _ref.config,
|
|
24
24
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
25
25
|
api = _ref.api;
|
|
26
|
+
var allowAdvancedSingleColumnLayout = (0, _experiments.editorExperiment)('advanced_layouts', true) && (0, _experiments.editorExperiment)('single_column_layouts', true);
|
|
26
27
|
return {
|
|
27
28
|
name: 'layout',
|
|
28
29
|
nodes: function nodes() {
|
|
@@ -64,7 +65,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
64
65
|
addSidebarLayouts = _ref3.addSidebarLayouts,
|
|
65
66
|
allowSingleColumnLayout = _ref3.allowSingleColumnLayout;
|
|
66
67
|
if (pos !== null) {
|
|
67
|
-
return (0, _toolbar.buildToolbar)(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api);
|
|
68
|
+
return (0, _toolbar.buildToolbar)(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, allowAdvancedSingleColumnLayout, api);
|
|
68
69
|
}
|
|
69
70
|
return undefined;
|
|
70
71
|
},
|
|
@@ -83,6 +84,21 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
83
84
|
})(tr);
|
|
84
85
|
return tr;
|
|
85
86
|
};
|
|
87
|
+
var advancedSingleColumnOption = allowAdvancedSingleColumnLayout ? [{
|
|
88
|
+
id: 'onecolumnlayout',
|
|
89
|
+
title: formatMessage(_messages.layoutMessages.singleColumnAdvancedLayout),
|
|
90
|
+
description: formatMessage(_messages.toolbarInsertBlockMessages.singleColumnsDescriptionAdvancedLayout),
|
|
91
|
+
keywords: ['layout', 'column', 'section', 'single column'],
|
|
92
|
+
priority: 1100,
|
|
93
|
+
icon: function icon() {
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconOneColumnLayout, null);
|
|
95
|
+
},
|
|
96
|
+
action: function action(insert, state, _source) {
|
|
97
|
+
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 1));
|
|
98
|
+
withInsertLayoutAnalytics(tr);
|
|
99
|
+
return tr;
|
|
100
|
+
}
|
|
101
|
+
}] : [];
|
|
86
102
|
if ((0, _experiments.editorExperiment)('advanced_layouts', true)) {
|
|
87
103
|
if ((0, _experiments.editorExperiment)('platform_editor_insertion', 'variant1')) {
|
|
88
104
|
return [{
|
|
@@ -103,7 +119,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
103
119
|
}
|
|
104
120
|
}];
|
|
105
121
|
} else {
|
|
106
|
-
return [{
|
|
122
|
+
return [].concat(advancedSingleColumnOption, [{
|
|
107
123
|
id: 'twocolumnslayout',
|
|
108
124
|
title: formatMessage(_messages.layoutMessages.twoColumnsAdvancedLayout),
|
|
109
125
|
description: formatMessage(_messages.toolbarInsertBlockMessages.columnsDescriptionAdvancedLayout, {
|
|
@@ -167,7 +183,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
167
183
|
withInsertLayoutAnalytics(tr);
|
|
168
184
|
return tr;
|
|
169
185
|
}
|
|
170
|
-
}];
|
|
186
|
+
}]);
|
|
171
187
|
}
|
|
172
188
|
} else {
|
|
173
189
|
return [{
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.GlobalStylesWrapper = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _react = require("react");
|
|
8
10
|
var _react2 = require("@emotion/react");
|
|
9
11
|
var _reactIntlNext = require("react-intl-next");
|
|
@@ -16,22 +18,19 @@ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
|
16
18
|
|
|
17
19
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled
|
|
18
20
|
|
|
21
|
+
var PLACEHOLDER_SELECTOR = '.ProseMirror-focused .layoutSectionView-content-wrap.selected [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)';
|
|
19
22
|
var getPlaceholderStyle = function getPlaceholderStyle(message) {
|
|
20
23
|
if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
21
|
-
return (0, _react2.css)({
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
position: 'absolute',
|
|
30
|
-
color: "var(--ds-text-subtlest, #626F86)",
|
|
31
|
-
pointerEvents: 'none'
|
|
32
|
-
}
|
|
24
|
+
return (0, _react2.css)((0, _defineProperty2.default)({}, "".concat(PLACEHOLDER_SELECTOR), {
|
|
25
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
26
|
+
'&::before': {
|
|
27
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
28
|
+
content: "\"".concat(message, "\""),
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
color: "var(--ds-text-subtlest, #626F86)",
|
|
31
|
+
pointerEvents: 'none'
|
|
33
32
|
}
|
|
34
|
-
});
|
|
33
|
+
}));
|
|
35
34
|
}
|
|
36
35
|
return (0, _react2.css)({
|
|
37
36
|
// when paragraph is the only child, and it only has a trailingBreak.
|
package/dist/cjs/ui/toolbar.js
CHANGED
|
@@ -141,7 +141,8 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
141
141
|
nodeType = _ref.nodeType,
|
|
142
142
|
separator = _ref.separator,
|
|
143
143
|
deleteButton = _ref.deleteButton,
|
|
144
|
-
currentLayout = _ref.currentLayout
|
|
144
|
+
currentLayout = _ref.currentLayout,
|
|
145
|
+
allowAdvancedSingleColumnLayout = _ref.allowAdvancedSingleColumnLayout;
|
|
145
146
|
var numberOfColumns = node.content.childCount || 2;
|
|
146
147
|
var distributionOptions = numberOfColumns === 2 ? LAYOUT_WITH_TWO_COL_DISTRIBUTION : numberOfColumns === 3 ? LAYOUT_WITH_THREE_COL_DISTRIBUTION : [];
|
|
147
148
|
var columnOptions = [{
|
|
@@ -177,13 +178,22 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
177
178
|
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('five_equal'),
|
|
178
179
|
selected: numberOfColumns === 5
|
|
179
180
|
}];
|
|
181
|
+
var singleColumnOption = allowAdvancedSingleColumnLayout ? {
|
|
182
|
+
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
183
|
+
count: 1
|
|
184
|
+
}),
|
|
185
|
+
//'1-columns',
|
|
186
|
+
icon: iconPlaceholder,
|
|
187
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('single'),
|
|
188
|
+
selected: numberOfColumns === 1
|
|
189
|
+
} : [];
|
|
180
190
|
return [{
|
|
181
191
|
type: 'dropdown',
|
|
182
192
|
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
183
193
|
count: numberOfColumns
|
|
184
194
|
}),
|
|
185
195
|
//`${numberOfColumns}-columns`,
|
|
186
|
-
options: columnOptions,
|
|
196
|
+
options: [singleColumnOption, columnOptions].flat(),
|
|
187
197
|
showSelected: true,
|
|
188
198
|
testId: 'column-options-button'
|
|
189
199
|
}].concat((0, _toConsumableArray2.default)(distributionOptions.length > 0 ? [separator] : []), (0, _toConsumableArray2.default)(addSidebarLayouts ? distributionOptions.map(function (i) {
|
|
@@ -194,7 +204,7 @@ var fullHeightSeparator = {
|
|
|
194
204
|
type: 'separator',
|
|
195
205
|
fullHeight: true
|
|
196
206
|
};
|
|
197
|
-
var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) {
|
|
207
|
+
var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, allowAdvancedSingleColumnLayout, api) {
|
|
198
208
|
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
199
209
|
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 : {},
|
|
200
210
|
hoverDecoration = _ref2.hoverDecoration;
|
|
@@ -270,7 +280,8 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos
|
|
|
270
280
|
node: node,
|
|
271
281
|
separator: separator,
|
|
272
282
|
deleteButton: deleteButton,
|
|
273
|
-
currentLayout: currentLayout
|
|
283
|
+
currentLayout: currentLayout,
|
|
284
|
+
allowAdvancedSingleColumnLayout: allowAdvancedSingleColumnLayout
|
|
274
285
|
}) : [].concat((0, _toConsumableArray2.default)(layoutTypes.map(function (i) {
|
|
275
286
|
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
276
287
|
})), (0, _toConsumableArray2.default)(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(function (i) {
|
|
@@ -3,7 +3,7 @@ import { layoutColumn, layoutSection } from '@atlaskit/adf-schema';
|
|
|
3
3
|
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
|
-
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
+
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
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';
|
|
@@ -16,6 +16,7 @@ export const layoutPlugin = ({
|
|
|
16
16
|
api
|
|
17
17
|
}) => {
|
|
18
18
|
var _api$analytics;
|
|
19
|
+
const allowAdvancedSingleColumnLayout = editorExperiment('advanced_layouts', true) && editorExperiment('single_column_layouts', true);
|
|
19
20
|
return {
|
|
20
21
|
name: 'layout',
|
|
21
22
|
nodes() {
|
|
@@ -55,7 +56,7 @@ export const layoutPlugin = ({
|
|
|
55
56
|
allowSingleColumnLayout
|
|
56
57
|
} = pluginKey.getState(state);
|
|
57
58
|
if (pos !== null) {
|
|
58
|
-
return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api);
|
|
59
|
+
return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, allowAdvancedSingleColumnLayout, api);
|
|
59
60
|
}
|
|
60
61
|
return undefined;
|
|
61
62
|
},
|
|
@@ -75,6 +76,19 @@ export const layoutPlugin = ({
|
|
|
75
76
|
})(tr);
|
|
76
77
|
return tr;
|
|
77
78
|
};
|
|
79
|
+
const advancedSingleColumnOption = allowAdvancedSingleColumnLayout ? [{
|
|
80
|
+
id: 'onecolumnlayout',
|
|
81
|
+
title: formatMessage(layoutMessages.singleColumnAdvancedLayout),
|
|
82
|
+
description: formatMessage(messages.singleColumnsDescriptionAdvancedLayout),
|
|
83
|
+
keywords: ['layout', 'column', 'section', 'single column'],
|
|
84
|
+
priority: 1100,
|
|
85
|
+
icon: () => /*#__PURE__*/React.createElement(IconOneColumnLayout, null),
|
|
86
|
+
action(insert, state, _source) {
|
|
87
|
+
const tr = insert(createMultiColumnLayoutSection(state, 1));
|
|
88
|
+
withInsertLayoutAnalytics(tr);
|
|
89
|
+
return tr;
|
|
90
|
+
}
|
|
91
|
+
}] : [];
|
|
78
92
|
if (editorExperiment('advanced_layouts', true)) {
|
|
79
93
|
if (editorExperiment('platform_editor_insertion', 'variant1')) {
|
|
80
94
|
return [{
|
|
@@ -93,7 +107,7 @@ export const layoutPlugin = ({
|
|
|
93
107
|
}
|
|
94
108
|
}];
|
|
95
109
|
} else {
|
|
96
|
-
return [{
|
|
110
|
+
return [...advancedSingleColumnOption, {
|
|
97
111
|
id: 'twocolumnslayout',
|
|
98
112
|
title: formatMessage(layoutMessages.twoColumnsAdvancedLayout),
|
|
99
113
|
description: formatMessage(messages.columnsDescriptionAdvancedLayout, {
|
|
@@ -9,12 +9,13 @@ import { css, Global, jsx } from '@emotion/react';
|
|
|
9
9
|
import { useIntl } from 'react-intl-next';
|
|
10
10
|
import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
+
const PLACEHOLDER_SELECTOR = '.ProseMirror-focused .layoutSectionView-content-wrap.selected [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)';
|
|
12
13
|
const getPlaceholderStyle = message => {
|
|
13
14
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
14
15
|
return css({
|
|
15
16
|
// when paragraph is the only child, and it only has a trailingBreak.
|
|
16
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
17
|
-
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
18
|
+
[`${PLACEHOLDER_SELECTOR}`]: {
|
|
18
19
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
19
20
|
'&::before': {
|
|
20
21
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
@@ -128,7 +128,8 @@ const getAdvancedLayoutItems = ({
|
|
|
128
128
|
nodeType,
|
|
129
129
|
separator,
|
|
130
130
|
deleteButton,
|
|
131
|
-
currentLayout
|
|
131
|
+
currentLayout,
|
|
132
|
+
allowAdvancedSingleColumnLayout
|
|
132
133
|
}) => {
|
|
133
134
|
const numberOfColumns = node.content.childCount || 2;
|
|
134
135
|
const distributionOptions = numberOfColumns === 2 ? LAYOUT_WITH_TWO_COL_DISTRIBUTION : numberOfColumns === 3 ? LAYOUT_WITH_THREE_COL_DISTRIBUTION : [];
|
|
@@ -165,13 +166,22 @@ const getAdvancedLayoutItems = ({
|
|
|
165
166
|
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'),
|
|
166
167
|
selected: numberOfColumns === 5
|
|
167
168
|
}];
|
|
169
|
+
const singleColumnOption = allowAdvancedSingleColumnLayout ? {
|
|
170
|
+
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
171
|
+
count: 1
|
|
172
|
+
}),
|
|
173
|
+
//'1-columns',
|
|
174
|
+
icon: iconPlaceholder,
|
|
175
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('single'),
|
|
176
|
+
selected: numberOfColumns === 1
|
|
177
|
+
} : [];
|
|
168
178
|
return [{
|
|
169
179
|
type: 'dropdown',
|
|
170
180
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
171
181
|
count: numberOfColumns
|
|
172
182
|
}),
|
|
173
183
|
//`${numberOfColumns}-columns`,
|
|
174
|
-
options: columnOptions,
|
|
184
|
+
options: [singleColumnOption, columnOptions].flat(),
|
|
175
185
|
showSelected: true,
|
|
176
186
|
testId: 'column-options-button'
|
|
177
187
|
}, ...(distributionOptions.length > 0 ? [separator] : []), ...(addSidebarLayouts ? distributionOptions.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)) : [])];
|
|
@@ -180,7 +190,7 @@ const fullHeightSeparator = {
|
|
|
180
190
|
type: 'separator',
|
|
181
191
|
fullHeight: true
|
|
182
192
|
};
|
|
183
|
-
export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) => {
|
|
193
|
+
export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, allowAdvancedSingleColumnLayout, api) => {
|
|
184
194
|
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
185
195
|
const {
|
|
186
196
|
hoverDecoration
|
|
@@ -255,7 +265,8 @@ export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts
|
|
|
255
265
|
node,
|
|
256
266
|
separator,
|
|
257
267
|
deleteButton,
|
|
258
|
-
currentLayout
|
|
268
|
+
currentLayout,
|
|
269
|
+
allowAdvancedSingleColumnLayout
|
|
259
270
|
}) : [...layoutTypes.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)), ...(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(i => buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI)) : [])]), ...(editorExperiment('platform_editor_controls', 'variant1') ? [fullHeightSeparator, overflowMenu] : [separator, copyButton, separator, deleteButton])],
|
|
260
271
|
scrollable: true
|
|
261
272
|
};
|
package/dist/esm/layoutPlugin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { layoutColumn, layoutSection } from '@atlaskit/adf-schema';
|
|
|
3
3
|
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
|
-
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
6
|
+
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
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';
|
|
@@ -16,6 +16,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
16
16
|
var _ref$config = _ref.config,
|
|
17
17
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
18
18
|
api = _ref.api;
|
|
19
|
+
var allowAdvancedSingleColumnLayout = editorExperiment('advanced_layouts', true) && editorExperiment('single_column_layouts', true);
|
|
19
20
|
return {
|
|
20
21
|
name: 'layout',
|
|
21
22
|
nodes: function nodes() {
|
|
@@ -57,7 +58,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
57
58
|
addSidebarLayouts = _ref3.addSidebarLayouts,
|
|
58
59
|
allowSingleColumnLayout = _ref3.allowSingleColumnLayout;
|
|
59
60
|
if (pos !== null) {
|
|
60
|
-
return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api);
|
|
61
|
+
return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, allowAdvancedSingleColumnLayout, api);
|
|
61
62
|
}
|
|
62
63
|
return undefined;
|
|
63
64
|
},
|
|
@@ -76,6 +77,21 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
76
77
|
})(tr);
|
|
77
78
|
return tr;
|
|
78
79
|
};
|
|
80
|
+
var advancedSingleColumnOption = allowAdvancedSingleColumnLayout ? [{
|
|
81
|
+
id: 'onecolumnlayout',
|
|
82
|
+
title: formatMessage(layoutMessages.singleColumnAdvancedLayout),
|
|
83
|
+
description: formatMessage(messages.singleColumnsDescriptionAdvancedLayout),
|
|
84
|
+
keywords: ['layout', 'column', 'section', 'single column'],
|
|
85
|
+
priority: 1100,
|
|
86
|
+
icon: function icon() {
|
|
87
|
+
return /*#__PURE__*/React.createElement(IconOneColumnLayout, null);
|
|
88
|
+
},
|
|
89
|
+
action: function action(insert, state, _source) {
|
|
90
|
+
var tr = insert(createMultiColumnLayoutSection(state, 1));
|
|
91
|
+
withInsertLayoutAnalytics(tr);
|
|
92
|
+
return tr;
|
|
93
|
+
}
|
|
94
|
+
}] : [];
|
|
79
95
|
if (editorExperiment('advanced_layouts', true)) {
|
|
80
96
|
if (editorExperiment('platform_editor_insertion', 'variant1')) {
|
|
81
97
|
return [{
|
|
@@ -96,7 +112,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
96
112
|
}
|
|
97
113
|
}];
|
|
98
114
|
} else {
|
|
99
|
-
return [{
|
|
115
|
+
return [].concat(advancedSingleColumnOption, [{
|
|
100
116
|
id: 'twocolumnslayout',
|
|
101
117
|
title: formatMessage(layoutMessages.twoColumnsAdvancedLayout),
|
|
102
118
|
description: formatMessage(messages.columnsDescriptionAdvancedLayout, {
|
|
@@ -160,7 +176,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
160
176
|
withInsertLayoutAnalytics(tr);
|
|
161
177
|
return tr;
|
|
162
178
|
}
|
|
163
|
-
}];
|
|
179
|
+
}]);
|
|
164
180
|
}
|
|
165
181
|
} else {
|
|
166
182
|
return [{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
/**
|
|
2
3
|
* @jsxRuntime classic
|
|
3
4
|
* @jsx jsx
|
|
@@ -9,22 +10,19 @@ import { css, Global, jsx } from '@emotion/react';
|
|
|
9
10
|
import { useIntl } from 'react-intl-next';
|
|
10
11
|
import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
|
+
var PLACEHOLDER_SELECTOR = '.ProseMirror-focused .layoutSectionView-content-wrap.selected [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)';
|
|
12
14
|
var getPlaceholderStyle = function getPlaceholderStyle(message) {
|
|
13
15
|
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
14
|
-
return css({
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
color: "var(--ds-text-subtlest, #626F86)",
|
|
24
|
-
pointerEvents: 'none'
|
|
25
|
-
}
|
|
16
|
+
return css(_defineProperty({}, "".concat(PLACEHOLDER_SELECTOR), {
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
18
|
+
'&::before': {
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
20
|
+
content: "\"".concat(message, "\""),
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
color: "var(--ds-text-subtlest, #626F86)",
|
|
23
|
+
pointerEvents: 'none'
|
|
26
24
|
}
|
|
27
|
-
});
|
|
25
|
+
}));
|
|
28
26
|
}
|
|
29
27
|
return css({
|
|
30
28
|
// when paragraph is the only child, and it only has a trailingBreak.
|
package/dist/esm/ui/toolbar.js
CHANGED
|
@@ -131,7 +131,8 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
131
131
|
nodeType = _ref.nodeType,
|
|
132
132
|
separator = _ref.separator,
|
|
133
133
|
deleteButton = _ref.deleteButton,
|
|
134
|
-
currentLayout = _ref.currentLayout
|
|
134
|
+
currentLayout = _ref.currentLayout,
|
|
135
|
+
allowAdvancedSingleColumnLayout = _ref.allowAdvancedSingleColumnLayout;
|
|
135
136
|
var numberOfColumns = node.content.childCount || 2;
|
|
136
137
|
var distributionOptions = numberOfColumns === 2 ? LAYOUT_WITH_TWO_COL_DISTRIBUTION : numberOfColumns === 3 ? LAYOUT_WITH_THREE_COL_DISTRIBUTION : [];
|
|
137
138
|
var columnOptions = [{
|
|
@@ -167,13 +168,22 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
167
168
|
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'),
|
|
168
169
|
selected: numberOfColumns === 5
|
|
169
170
|
}];
|
|
171
|
+
var singleColumnOption = allowAdvancedSingleColumnLayout ? {
|
|
172
|
+
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
173
|
+
count: 1
|
|
174
|
+
}),
|
|
175
|
+
//'1-columns',
|
|
176
|
+
icon: iconPlaceholder,
|
|
177
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('single'),
|
|
178
|
+
selected: numberOfColumns === 1
|
|
179
|
+
} : [];
|
|
170
180
|
return [{
|
|
171
181
|
type: 'dropdown',
|
|
172
182
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
173
183
|
count: numberOfColumns
|
|
174
184
|
}),
|
|
175
185
|
//`${numberOfColumns}-columns`,
|
|
176
|
-
options: columnOptions,
|
|
186
|
+
options: [singleColumnOption, columnOptions].flat(),
|
|
177
187
|
showSelected: true,
|
|
178
188
|
testId: 'column-options-button'
|
|
179
189
|
}].concat(_toConsumableArray(distributionOptions.length > 0 ? [separator] : []), _toConsumableArray(addSidebarLayouts ? distributionOptions.map(function (i) {
|
|
@@ -184,7 +194,7 @@ var fullHeightSeparator = {
|
|
|
184
194
|
type: 'separator',
|
|
185
195
|
fullHeight: true
|
|
186
196
|
};
|
|
187
|
-
export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) {
|
|
197
|
+
export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, allowAdvancedSingleColumnLayout, api) {
|
|
188
198
|
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
189
199
|
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 : {},
|
|
190
200
|
hoverDecoration = _ref2.hoverDecoration;
|
|
@@ -260,7 +270,8 @@ export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout
|
|
|
260
270
|
node: node,
|
|
261
271
|
separator: separator,
|
|
262
272
|
deleteButton: deleteButton,
|
|
263
|
-
currentLayout: currentLayout
|
|
273
|
+
currentLayout: currentLayout,
|
|
274
|
+
allowAdvancedSingleColumnLayout: allowAdvancedSingleColumnLayout
|
|
264
275
|
}) : [].concat(_toConsumableArray(layoutTypes.map(function (i) {
|
|
265
276
|
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
266
277
|
})), _toConsumableArray(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(function (i) {
|
|
@@ -3,6 +3,11 @@ import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
export interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
|
|
4
4
|
allowBreakout?: boolean;
|
|
5
5
|
UNSAFE_addSidebarLayouts?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated
|
|
9
|
+
* @see https://product-fabric.atlassian.net/browse/ED-26662
|
|
10
|
+
*/
|
|
6
11
|
UNSAFE_allowSingleColumnLayout?: boolean;
|
|
7
12
|
editorAppearance?: EditorAppearance;
|
|
8
13
|
}
|
|
@@ -3,4 +3,4 @@ import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/edito
|
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { LayoutPlugin } from '../index';
|
|
5
5
|
export declare const layoutToolbarTitle = "Layout floating controls";
|
|
6
|
-
export declare const buildToolbar: (state: EditorState, intl: IntlShape, pos: number, _allowBreakout: boolean, addSidebarLayouts: boolean, allowSingleColumnLayout: boolean, api: ExtractInjectionAPI<LayoutPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
|
6
|
+
export declare const buildToolbar: (state: EditorState, intl: IntlShape, pos: number, _allowBreakout: boolean, addSidebarLayouts: boolean, allowSingleColumnLayout: boolean, allowAdvancedSingleColumnLayout: boolean, api: ExtractInjectionAPI<LayoutPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
|
@@ -3,6 +3,11 @@ import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
export interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
|
|
4
4
|
allowBreakout?: boolean;
|
|
5
5
|
UNSAFE_addSidebarLayouts?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* @private
|
|
8
|
+
* @deprecated
|
|
9
|
+
* @see https://product-fabric.atlassian.net/browse/ED-26662
|
|
10
|
+
*/
|
|
6
11
|
UNSAFE_allowSingleColumnLayout?: boolean;
|
|
7
12
|
editorAppearance?: EditorAppearance;
|
|
8
13
|
}
|
|
@@ -3,4 +3,4 @@ import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/edito
|
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import type { LayoutPlugin } from '../index';
|
|
5
5
|
export declare const layoutToolbarTitle = "Layout floating controls";
|
|
6
|
-
export declare const buildToolbar: (state: EditorState, intl: IntlShape, pos: number, _allowBreakout: boolean, addSidebarLayouts: boolean, allowSingleColumnLayout: boolean, api: ExtractInjectionAPI<LayoutPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
|
6
|
+
export declare const buildToolbar: (state: EditorState, intl: IntlShape, pos: number, _allowBreakout: boolean, addSidebarLayouts: boolean, allowSingleColumnLayout: boolean, allowAdvancedSingleColumnLayout: boolean, api: ExtractInjectionAPI<LayoutPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^102.
|
|
37
|
+
"@atlaskit/editor-common": "^102.10.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
44
44
|
"@atlaskit/icon": "^25.0.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^4.1.0",
|
|
47
47
|
"@atlaskit/tokens": "^4.5.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
49
49
|
"@emotion/react": "^11.7.1"
|