@atlaskit/editor-plugin-layout 2.5.1 → 2.6.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 +17 -0
- package/dist/cjs/layoutPlugin.js +36 -1
- package/dist/cjs/pm-plugins/actions.js +3 -1
- package/dist/cjs/pm-plugins/utils/index.js +0 -1
- package/dist/es2019/layoutPlugin.js +35 -0
- package/dist/es2019/pm-plugins/actions.js +3 -1
- package/dist/es2019/pm-plugins/utils/index.js +0 -1
- package/dist/esm/layoutPlugin.js +36 -0
- package/dist/esm/pm-plugins/actions.js +3 -1
- package/dist/esm/pm-plugins/utils/index.js +0 -1
- package/dist/types/layoutPlugin.d.ts +9 -0
- package/dist/types-ts4.5/layoutPlugin.d.ts +9 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 2.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#145340](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145340)
|
|
8
|
+
[`21717a29553b2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21717a29553b2) -
|
|
9
|
+
Switching from 5, 4, 3 empty columns layout to 1 column should work
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 2.6.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#144082](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/144082)
|
|
17
|
+
[`583a67e0b8ee7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/583a67e0b8ee7) -
|
|
18
|
+
ED-27146 improve layout insertion behaivour, now will select into the layout after insertion.
|
|
19
|
+
|
|
3
20
|
## 2.5.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/cjs/layoutPlugin.js
CHANGED
|
@@ -4,13 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.layoutPlugin = void 0;
|
|
7
|
+
exports.selectIntoLayoutSection = exports.layoutPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _schema = require("@atlaskit/adf-schema/schema");
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
13
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
14
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
14
16
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
17
|
var _actions = require("./pm-plugins/actions");
|
|
16
18
|
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
@@ -18,6 +20,33 @@ var _pluginKey = require("./pm-plugins/plugin-key");
|
|
|
18
20
|
var _resizing = _interopRequireDefault(require("./pm-plugins/resizing"));
|
|
19
21
|
var _globalStyles = require("./ui/global-styles");
|
|
20
22
|
var _toolbar = require("./ui/toolbar");
|
|
23
|
+
/**
|
|
24
|
+
* This function is used to set the selection into
|
|
25
|
+
* the first paragraph of the first column of a layout section.
|
|
26
|
+
* This function is only intended to be used after inserting a new layout section.
|
|
27
|
+
* @param tr - transaction
|
|
28
|
+
* @returns - transaction with the selection set to the first paragraph of the first column
|
|
29
|
+
*/
|
|
30
|
+
var selectIntoLayoutSection = exports.selectIntoLayoutSection = function selectIntoLayoutSection(tr) {
|
|
31
|
+
var _nodeWithPos$node$fir;
|
|
32
|
+
if (!(0, _experiments.editorExperiment)('single_column_layouts', true)) {
|
|
33
|
+
return tr;
|
|
34
|
+
}
|
|
35
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
36
|
+
layoutSection = _tr$doc$type$schema$n.layoutSection,
|
|
37
|
+
paragraph = _tr$doc$type$schema$n.paragraph;
|
|
38
|
+
var nodeWithPos = (0, _utils.findParentNode)(function (node) {
|
|
39
|
+
return node.type === layoutSection;
|
|
40
|
+
})(tr.selection);
|
|
41
|
+
if (!nodeWithPos || !nodeWithPos.node || nodeWithPos.node.type.name !== 'layoutSection' || ((_nodeWithPos$node$fir = nodeWithPos.node.firstChild) === null || _nodeWithPos$node$fir === void 0 || (_nodeWithPos$node$fir = _nodeWithPos$node$fir.firstChild) === null || _nodeWithPos$node$fir === void 0 ? void 0 : _nodeWithPos$node$fir.type) !== paragraph) {
|
|
42
|
+
return tr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// set text selection at the beginning of the layout section
|
|
46
|
+
// will set the selection to the first column
|
|
47
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, nodeWithPos.pos));
|
|
48
|
+
return tr;
|
|
49
|
+
};
|
|
21
50
|
var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
22
51
|
var _api$analytics;
|
|
23
52
|
var _ref$config = _ref.config,
|
|
@@ -98,6 +127,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
98
127
|
action: function action(insert, state, _source) {
|
|
99
128
|
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 1));
|
|
100
129
|
withInsertLayoutAnalytics(tr);
|
|
130
|
+
selectIntoLayoutSection(tr);
|
|
101
131
|
return tr;
|
|
102
132
|
}
|
|
103
133
|
}] : [];
|
|
@@ -117,6 +147,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
117
147
|
action: function action(insert, state) {
|
|
118
148
|
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 3));
|
|
119
149
|
withInsertLayoutAnalytics(tr);
|
|
150
|
+
selectIntoLayoutSection(tr);
|
|
120
151
|
return tr;
|
|
121
152
|
}
|
|
122
153
|
}];
|
|
@@ -135,6 +166,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
135
166
|
action: function action(insert, state) {
|
|
136
167
|
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 2));
|
|
137
168
|
withInsertLayoutAnalytics(tr);
|
|
169
|
+
selectIntoLayoutSection(tr);
|
|
138
170
|
return tr;
|
|
139
171
|
}
|
|
140
172
|
}, {
|
|
@@ -151,6 +183,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
151
183
|
action: function action(insert, state) {
|
|
152
184
|
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 3));
|
|
153
185
|
withInsertLayoutAnalytics(tr);
|
|
186
|
+
selectIntoLayoutSection(tr);
|
|
154
187
|
return tr;
|
|
155
188
|
}
|
|
156
189
|
}, {
|
|
@@ -167,6 +200,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
167
200
|
action: function action(insert, state) {
|
|
168
201
|
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 4));
|
|
169
202
|
withInsertLayoutAnalytics(tr);
|
|
203
|
+
selectIntoLayoutSection(tr);
|
|
170
204
|
return tr;
|
|
171
205
|
}
|
|
172
206
|
}, {
|
|
@@ -183,6 +217,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
183
217
|
action: function action(insert, state) {
|
|
184
218
|
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 5));
|
|
185
219
|
withInsertLayoutAnalytics(tr);
|
|
220
|
+
selectIntoLayoutSection(tr);
|
|
186
221
|
return tr;
|
|
187
222
|
}
|
|
188
223
|
}]);
|
|
@@ -14,6 +14,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
14
14
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
19
|
var _consts = require("./consts");
|
|
19
20
|
var _pluginKey = require("./plugin-key");
|
|
@@ -209,7 +210,8 @@ function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
|
209
210
|
// check if the column only contains a paragraph with a placeholder text
|
|
210
211
|
// if so, remove the whole column, otherwise just remove the paragraph
|
|
211
212
|
if ((0, _utils.isEmptyDocument)(column)) {
|
|
212
|
-
|
|
213
|
+
var fromPos = (0, _platformFeatureFlags.fg)('platform_editor_convert_multiple_columns_to_single') ? columnPos : columnPos - 1;
|
|
214
|
+
tr.replaceRange(tr.mapping.map(fromPos), tr.mapping.map(insideRightEdgePos), _model.Slice.empty);
|
|
213
215
|
} else {
|
|
214
216
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), _model.Slice.empty);
|
|
215
217
|
}
|
|
@@ -38,7 +38,6 @@ var selectIntoLayout = exports.selectIntoLayout = function selectIntoLayout(view
|
|
|
38
38
|
var $maybeLayoutSection = view.state.doc.resolve(posOfLayout);
|
|
39
39
|
if (((_$maybeLayoutSection$ = $maybeLayoutSection.nodeAfter) === null || _$maybeLayoutSection$ === void 0 ? void 0 : _$maybeLayoutSection$.type.name) === 'layoutSection') {
|
|
40
40
|
var _layoutSectionNode$fi;
|
|
41
|
-
// $maybeLayoutSection.posAtIndex(1, 1);
|
|
42
41
|
var layoutSectionNode = $maybeLayoutSection.nodeAfter;
|
|
43
42
|
|
|
44
43
|
// check if the childIndex is valid
|
|
@@ -4,6 +4,8 @@ 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, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
10
|
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
9
11
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
@@ -11,6 +13,33 @@ import { pluginKey } from './pm-plugins/plugin-key';
|
|
|
11
13
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
12
14
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
13
15
|
import { buildToolbar } from './ui/toolbar';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function is used to set the selection into
|
|
19
|
+
* the first paragraph of the first column of a layout section.
|
|
20
|
+
* This function is only intended to be used after inserting a new layout section.
|
|
21
|
+
* @param tr - transaction
|
|
22
|
+
* @returns - transaction with the selection set to the first paragraph of the first column
|
|
23
|
+
*/
|
|
24
|
+
export const selectIntoLayoutSection = tr => {
|
|
25
|
+
var _nodeWithPos$node$fir, _nodeWithPos$node$fir2;
|
|
26
|
+
if (!editorExperiment('single_column_layouts', true)) {
|
|
27
|
+
return tr;
|
|
28
|
+
}
|
|
29
|
+
const {
|
|
30
|
+
layoutSection,
|
|
31
|
+
paragraph
|
|
32
|
+
} = tr.doc.type.schema.nodes;
|
|
33
|
+
const nodeWithPos = findParentNode(node => node.type === layoutSection)(tr.selection);
|
|
34
|
+
if (!nodeWithPos || !nodeWithPos.node || nodeWithPos.node.type.name !== 'layoutSection' || ((_nodeWithPos$node$fir = nodeWithPos.node.firstChild) === null || _nodeWithPos$node$fir === void 0 ? void 0 : (_nodeWithPos$node$fir2 = _nodeWithPos$node$fir.firstChild) === null || _nodeWithPos$node$fir2 === void 0 ? void 0 : _nodeWithPos$node$fir2.type) !== paragraph) {
|
|
35
|
+
return tr;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// set text selection at the beginning of the layout section
|
|
39
|
+
// will set the selection to the first column
|
|
40
|
+
tr.setSelection(TextSelection.create(tr.doc, nodeWithPos.pos));
|
|
41
|
+
return tr;
|
|
42
|
+
};
|
|
14
43
|
export const layoutPlugin = ({
|
|
15
44
|
config: options = {},
|
|
16
45
|
api
|
|
@@ -88,6 +117,7 @@ export const layoutPlugin = ({
|
|
|
88
117
|
action(insert, state, _source) {
|
|
89
118
|
const tr = insert(createMultiColumnLayoutSection(state, 1));
|
|
90
119
|
withInsertLayoutAnalytics(tr);
|
|
120
|
+
selectIntoLayoutSection(tr);
|
|
91
121
|
return tr;
|
|
92
122
|
}
|
|
93
123
|
}] : [];
|
|
@@ -105,6 +135,7 @@ export const layoutPlugin = ({
|
|
|
105
135
|
action(insert, state) {
|
|
106
136
|
const tr = insert(createMultiColumnLayoutSection(state, 3));
|
|
107
137
|
withInsertLayoutAnalytics(tr);
|
|
138
|
+
selectIntoLayoutSection(tr);
|
|
108
139
|
return tr;
|
|
109
140
|
}
|
|
110
141
|
}];
|
|
@@ -121,6 +152,7 @@ export const layoutPlugin = ({
|
|
|
121
152
|
action(insert, state) {
|
|
122
153
|
const tr = insert(createMultiColumnLayoutSection(state, 2));
|
|
123
154
|
withInsertLayoutAnalytics(tr);
|
|
155
|
+
selectIntoLayoutSection(tr);
|
|
124
156
|
return tr;
|
|
125
157
|
}
|
|
126
158
|
}, {
|
|
@@ -135,6 +167,7 @@ export const layoutPlugin = ({
|
|
|
135
167
|
action(insert, state) {
|
|
136
168
|
const tr = insert(createMultiColumnLayoutSection(state, 3));
|
|
137
169
|
withInsertLayoutAnalytics(tr);
|
|
170
|
+
selectIntoLayoutSection(tr);
|
|
138
171
|
return tr;
|
|
139
172
|
}
|
|
140
173
|
}, {
|
|
@@ -149,6 +182,7 @@ export const layoutPlugin = ({
|
|
|
149
182
|
action(insert, state) {
|
|
150
183
|
const tr = insert(createMultiColumnLayoutSection(state, 4));
|
|
151
184
|
withInsertLayoutAnalytics(tr);
|
|
185
|
+
selectIntoLayoutSection(tr);
|
|
152
186
|
return tr;
|
|
153
187
|
}
|
|
154
188
|
}, {
|
|
@@ -163,6 +197,7 @@ export const layoutPlugin = ({
|
|
|
163
197
|
action(insert, state) {
|
|
164
198
|
const tr = insert(createMultiColumnLayoutSection(state, 5));
|
|
165
199
|
withInsertLayoutAnalytics(tr);
|
|
200
|
+
selectIntoLayoutSection(tr);
|
|
166
201
|
return tr;
|
|
167
202
|
}
|
|
168
203
|
}];
|
|
@@ -4,6 +4,7 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
|
|
|
4
4
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
9
|
import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
|
|
9
10
|
import { pluginKey } from './plugin-key';
|
|
@@ -188,7 +189,8 @@ function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
|
188
189
|
// check if the column only contains a paragraph with a placeholder text
|
|
189
190
|
// if so, remove the whole column, otherwise just remove the paragraph
|
|
190
191
|
if (isEmptyDocument(column)) {
|
|
191
|
-
|
|
192
|
+
const fromPos = fg('platform_editor_convert_multiple_columns_to_single') ? columnPos : columnPos - 1;
|
|
193
|
+
tr.replaceRange(tr.mapping.map(fromPos), tr.mapping.map(insideRightEdgePos), Slice.empty);
|
|
192
194
|
} else {
|
|
193
195
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), Slice.empty);
|
|
194
196
|
}
|
|
@@ -36,7 +36,6 @@ export const selectIntoLayout = (view, posOfLayout, childIndex = 0) => {
|
|
|
36
36
|
const $maybeLayoutSection = view.state.doc.resolve(posOfLayout);
|
|
37
37
|
if (((_$maybeLayoutSection$ = $maybeLayoutSection.nodeAfter) === null || _$maybeLayoutSection$ === void 0 ? void 0 : _$maybeLayoutSection$.type.name) === 'layoutSection') {
|
|
38
38
|
var _layoutSectionNode$fi;
|
|
39
|
-
// $maybeLayoutSection.posAtIndex(1, 1);
|
|
40
39
|
const layoutSectionNode = $maybeLayoutSection.nodeAfter;
|
|
41
40
|
|
|
42
41
|
// check if the childIndex is valid
|
package/dist/esm/layoutPlugin.js
CHANGED
|
@@ -4,6 +4,8 @@ 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, IconOneColumnLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
10
|
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
9
11
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
@@ -11,6 +13,34 @@ import { pluginKey } from './pm-plugins/plugin-key';
|
|
|
11
13
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
12
14
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
13
15
|
import { buildToolbar } from './ui/toolbar';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function is used to set the selection into
|
|
19
|
+
* the first paragraph of the first column of a layout section.
|
|
20
|
+
* This function is only intended to be used after inserting a new layout section.
|
|
21
|
+
* @param tr - transaction
|
|
22
|
+
* @returns - transaction with the selection set to the first paragraph of the first column
|
|
23
|
+
*/
|
|
24
|
+
export var selectIntoLayoutSection = function selectIntoLayoutSection(tr) {
|
|
25
|
+
var _nodeWithPos$node$fir;
|
|
26
|
+
if (!editorExperiment('single_column_layouts', true)) {
|
|
27
|
+
return tr;
|
|
28
|
+
}
|
|
29
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
30
|
+
layoutSection = _tr$doc$type$schema$n.layoutSection,
|
|
31
|
+
paragraph = _tr$doc$type$schema$n.paragraph;
|
|
32
|
+
var nodeWithPos = findParentNode(function (node) {
|
|
33
|
+
return node.type === layoutSection;
|
|
34
|
+
})(tr.selection);
|
|
35
|
+
if (!nodeWithPos || !nodeWithPos.node || nodeWithPos.node.type.name !== 'layoutSection' || ((_nodeWithPos$node$fir = nodeWithPos.node.firstChild) === null || _nodeWithPos$node$fir === void 0 || (_nodeWithPos$node$fir = _nodeWithPos$node$fir.firstChild) === null || _nodeWithPos$node$fir === void 0 ? void 0 : _nodeWithPos$node$fir.type) !== paragraph) {
|
|
36
|
+
return tr;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// set text selection at the beginning of the layout section
|
|
40
|
+
// will set the selection to the first column
|
|
41
|
+
tr.setSelection(TextSelection.create(tr.doc, nodeWithPos.pos));
|
|
42
|
+
return tr;
|
|
43
|
+
};
|
|
14
44
|
export var layoutPlugin = function layoutPlugin(_ref) {
|
|
15
45
|
var _api$analytics;
|
|
16
46
|
var _ref$config = _ref.config,
|
|
@@ -91,6 +121,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
91
121
|
action: function action(insert, state, _source) {
|
|
92
122
|
var tr = insert(createMultiColumnLayoutSection(state, 1));
|
|
93
123
|
withInsertLayoutAnalytics(tr);
|
|
124
|
+
selectIntoLayoutSection(tr);
|
|
94
125
|
return tr;
|
|
95
126
|
}
|
|
96
127
|
}] : [];
|
|
@@ -110,6 +141,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
110
141
|
action: function action(insert, state) {
|
|
111
142
|
var tr = insert(createMultiColumnLayoutSection(state, 3));
|
|
112
143
|
withInsertLayoutAnalytics(tr);
|
|
144
|
+
selectIntoLayoutSection(tr);
|
|
113
145
|
return tr;
|
|
114
146
|
}
|
|
115
147
|
}];
|
|
@@ -128,6 +160,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
128
160
|
action: function action(insert, state) {
|
|
129
161
|
var tr = insert(createMultiColumnLayoutSection(state, 2));
|
|
130
162
|
withInsertLayoutAnalytics(tr);
|
|
163
|
+
selectIntoLayoutSection(tr);
|
|
131
164
|
return tr;
|
|
132
165
|
}
|
|
133
166
|
}, {
|
|
@@ -144,6 +177,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
144
177
|
action: function action(insert, state) {
|
|
145
178
|
var tr = insert(createMultiColumnLayoutSection(state, 3));
|
|
146
179
|
withInsertLayoutAnalytics(tr);
|
|
180
|
+
selectIntoLayoutSection(tr);
|
|
147
181
|
return tr;
|
|
148
182
|
}
|
|
149
183
|
}, {
|
|
@@ -160,6 +194,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
160
194
|
action: function action(insert, state) {
|
|
161
195
|
var tr = insert(createMultiColumnLayoutSection(state, 4));
|
|
162
196
|
withInsertLayoutAnalytics(tr);
|
|
197
|
+
selectIntoLayoutSection(tr);
|
|
163
198
|
return tr;
|
|
164
199
|
}
|
|
165
200
|
}, {
|
|
@@ -176,6 +211,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
176
211
|
action: function action(insert, state) {
|
|
177
212
|
var tr = insert(createMultiColumnLayoutSection(state, 5));
|
|
178
213
|
withInsertLayoutAnalytics(tr);
|
|
214
|
+
selectIntoLayoutSection(tr);
|
|
179
215
|
return tr;
|
|
180
216
|
}
|
|
181
217
|
}]);
|
|
@@ -7,6 +7,7 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
|
|
|
7
7
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
12
|
import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
|
|
12
13
|
import { pluginKey } from './plugin-key';
|
|
@@ -200,7 +201,8 @@ function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
|
200
201
|
// check if the column only contains a paragraph with a placeholder text
|
|
201
202
|
// if so, remove the whole column, otherwise just remove the paragraph
|
|
202
203
|
if (isEmptyDocument(column)) {
|
|
203
|
-
|
|
204
|
+
var fromPos = fg('platform_editor_convert_multiple_columns_to_single') ? columnPos : columnPos - 1;
|
|
205
|
+
tr.replaceRange(tr.mapping.map(fromPos), tr.mapping.map(insideRightEdgePos), Slice.empty);
|
|
204
206
|
} else {
|
|
205
207
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), Slice.empty);
|
|
206
208
|
}
|
|
@@ -32,7 +32,6 @@ export var selectIntoLayout = function selectIntoLayout(view, posOfLayout) {
|
|
|
32
32
|
var $maybeLayoutSection = view.state.doc.resolve(posOfLayout);
|
|
33
33
|
if (((_$maybeLayoutSection$ = $maybeLayoutSection.nodeAfter) === null || _$maybeLayoutSection$ === void 0 ? void 0 : _$maybeLayoutSection$.type.name) === 'layoutSection') {
|
|
34
34
|
var _layoutSectionNode$fi;
|
|
35
|
-
// $maybeLayoutSection.posAtIndex(1, 1);
|
|
36
35
|
var layoutSectionNode = $maybeLayoutSection.nodeAfter;
|
|
37
36
|
|
|
38
37
|
// check if the childIndex is valid
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
1
2
|
import type { LayoutPlugin } from './layoutPluginType';
|
|
3
|
+
/**
|
|
4
|
+
* This function is used to set the selection into
|
|
5
|
+
* the first paragraph of the first column of a layout section.
|
|
6
|
+
* This function is only intended to be used after inserting a new layout section.
|
|
7
|
+
* @param tr - transaction
|
|
8
|
+
* @returns - transaction with the selection set to the first paragraph of the first column
|
|
9
|
+
*/
|
|
10
|
+
export declare const selectIntoLayoutSection: (tr: Transaction) => Transaction;
|
|
2
11
|
export declare const layoutPlugin: LayoutPlugin;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
1
2
|
import type { LayoutPlugin } from './layoutPluginType';
|
|
3
|
+
/**
|
|
4
|
+
* This function is used to set the selection into
|
|
5
|
+
* the first paragraph of the first column of a layout section.
|
|
6
|
+
* This function is only intended to be used after inserting a new layout section.
|
|
7
|
+
* @param tr - transaction
|
|
8
|
+
* @returns - transaction with the selection set to the first paragraph of the first column
|
|
9
|
+
*/
|
|
10
|
+
export declare const selectIntoLayoutSection: (tr: Transaction) => Transaction;
|
|
2
11
|
export declare const layoutPlugin: LayoutPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.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": "^103.
|
|
37
|
+
"@atlaskit/editor-common": "^103.17.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",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
46
46
|
"@atlaskit/icon": "^25.6.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^4.14.0",
|
|
49
49
|
"@atlaskit/tokens": "^4.8.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1"
|
|
@@ -101,6 +101,9 @@
|
|
|
101
101
|
"platform-feature-flags": {
|
|
102
102
|
"platform-visual-refresh-icons": {
|
|
103
103
|
"type": "boolean"
|
|
104
|
+
},
|
|
105
|
+
"platform_editor_convert_multiple_columns_to_single": {
|
|
106
|
+
"type": "boolean"
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
}
|