@atlaskit/editor-plugin-layout 1.12.7 → 1.12.8
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 +9 -0
- package/dist/cjs/actions.js +22 -44
- package/dist/cjs/plugin.js +4 -4
- package/dist/cjs/toolbar.js +5 -5
- package/dist/cjs/ui/global-styles.js +29 -14
- package/dist/es2019/actions.js +22 -45
- package/dist/es2019/plugin.js +4 -4
- package/dist/es2019/toolbar.js +5 -5
- package/dist/es2019/ui/global-styles.js +20 -6
- package/dist/esm/actions.js +22 -44
- package/dist/esm/plugin.js +4 -4
- package/dist/esm/toolbar.js +5 -5
- package/dist/esm/ui/global-styles.js +27 -12
- package/dist/types/actions.d.ts +5 -6
- package/dist/types/ui/global-styles.d.ts +0 -4
- package/dist/types-ts4.5/actions.d.ts +5 -6
- package/dist/types-ts4.5/ui/global-styles.d.ts +0 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 1.12.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#169277](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169277)
|
|
8
|
+
[`4d8433c0b731a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4d8433c0b731a) -
|
|
9
|
+
ED-25872 improve placeholder usability for layout
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 1.12.7
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/cjs/actions.js
CHANGED
|
@@ -10,7 +10,6 @@ exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.ins
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
13
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
14
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
16
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -135,46 +134,31 @@ var getSelectedLayout = exports.getSelectedLayout = function getSelectedLayout(m
|
|
|
135
134
|
}
|
|
136
135
|
return current;
|
|
137
136
|
};
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
var _schema$nodes = schema.nodes,
|
|
143
|
-
paragraph = _schema$nodes.paragraph,
|
|
144
|
-
placeholder = _schema$nodes.placeholder;
|
|
145
|
-
//create a paragraph node with content of placeholder node
|
|
146
|
-
var placeholderNode = placeholder.createChecked({
|
|
147
|
-
text: formatMessage(_messages.layoutMessages.layoutPlaceholder)
|
|
148
|
-
});
|
|
149
|
-
return paragraph.createAndFill(undefined, placeholderNode);
|
|
150
|
-
};
|
|
151
|
-
var createMultiColumnLayoutSection = exports.createMultiColumnLayoutSection = function createMultiColumnLayoutSection(state, numberOfColumns, formatMessage) {
|
|
137
|
+
var createMultiColumnLayoutSection = exports.createMultiColumnLayoutSection = function createMultiColumnLayoutSection(state) {
|
|
138
|
+
var numberOfColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
152
139
|
var _state$schema$nodes = state.schema.nodes,
|
|
153
140
|
layoutSection = _state$schema$nodes.layoutSection,
|
|
154
141
|
layoutColumn = _state$schema$nodes.layoutColumn;
|
|
155
|
-
var placeholder = createPlaceholderNode(state.schema, formatMessage);
|
|
156
|
-
var layoutColumnNode = layoutColumn.createAndFill({
|
|
157
|
-
width: _consts.EVEN_DISTRIBUTED_COL_WIDTHS[numberOfColumns]
|
|
158
|
-
}, placeholder);
|
|
159
142
|
var columns = _model.Fragment.fromArray(Array.from({
|
|
160
143
|
length: numberOfColumns
|
|
161
144
|
}, function () {
|
|
162
|
-
return
|
|
145
|
+
return layoutColumn.createAndFill({
|
|
146
|
+
width: _consts.EVEN_DISTRIBUTED_COL_WIDTHS[numberOfColumns]
|
|
147
|
+
});
|
|
163
148
|
}));
|
|
164
149
|
return layoutSection.createAndFill(undefined, columns);
|
|
165
150
|
};
|
|
166
|
-
var createDefaultLayoutSection = exports.createDefaultLayoutSection = function createDefaultLayoutSection(state
|
|
151
|
+
var createDefaultLayoutSection = exports.createDefaultLayoutSection = function createDefaultLayoutSection(state) {
|
|
167
152
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
168
153
|
layoutSection = _state$schema$nodes2.layoutSection,
|
|
169
154
|
layoutColumn = _state$schema$nodes2.layoutColumn;
|
|
170
|
-
var placeholder = (0, _preRelease.isPreRelease2)() ? createPlaceholderNode(state.schema, formatMessage) : undefined;
|
|
171
155
|
|
|
172
156
|
// create a 50-50 layout by default
|
|
173
157
|
var columns = _model.Fragment.fromArray([layoutColumn.createAndFill({
|
|
174
158
|
width: 50
|
|
175
|
-
}
|
|
159
|
+
}), layoutColumn.createAndFill({
|
|
176
160
|
width: 50
|
|
177
|
-
}
|
|
161
|
+
})]);
|
|
178
162
|
return layoutSection.createAndFill(undefined, columns);
|
|
179
163
|
};
|
|
180
164
|
var insertLayoutColumns = exports.insertLayoutColumns = function insertLayoutColumns(state, dispatch) {
|
|
@@ -184,7 +168,7 @@ var insertLayoutColumns = exports.insertLayoutColumns = function insertLayoutCol
|
|
|
184
168
|
return true;
|
|
185
169
|
};
|
|
186
170
|
var insertLayoutColumnsWithAnalytics = exports.insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAnalytics(editorAnalyticsAPI) {
|
|
187
|
-
return function (inputMethod
|
|
171
|
+
return function (inputMethod) {
|
|
188
172
|
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
189
173
|
action: _analytics.ACTION.INSERTED,
|
|
190
174
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
@@ -195,7 +179,7 @@ var insertLayoutColumnsWithAnalytics = exports.insertLayoutColumnsWithAnalytics
|
|
|
195
179
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
196
180
|
})(function (state, dispatch) {
|
|
197
181
|
if (dispatch) {
|
|
198
|
-
dispatch((0, _utils2.safeInsert)(createDefaultLayoutSection(state
|
|
182
|
+
dispatch((0, _utils2.safeInsert)(createDefaultLayoutSection(state))(state.tr));
|
|
199
183
|
}
|
|
200
184
|
return true;
|
|
201
185
|
});
|
|
@@ -205,26 +189,21 @@ var insertLayoutColumnsWithAnalytics = exports.insertLayoutColumnsWithAnalytics
|
|
|
205
189
|
/**
|
|
206
190
|
* Add a column to the right of existing layout
|
|
207
191
|
*/
|
|
208
|
-
function addColumn(schema, pos
|
|
192
|
+
function addColumn(schema, pos) {
|
|
209
193
|
if (!(0, _preRelease.isPreRelease2)()) {
|
|
210
194
|
return function (tr) {
|
|
211
195
|
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
212
196
|
};
|
|
213
197
|
}
|
|
214
|
-
var placeholder = createPlaceholderNode(schema, formatMessage);
|
|
215
198
|
return function (tr) {
|
|
216
|
-
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill(undefined
|
|
199
|
+
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill(undefined));
|
|
217
200
|
};
|
|
218
201
|
}
|
|
219
|
-
var containPlaceholderOnly = function containPlaceholderOnly(node, schema) {
|
|
220
|
-
var _node$firstChild, _node$firstChild2;
|
|
221
|
-
return node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.childCount) === 1 && ((_node$firstChild2 = node.firstChild) === null || _node$firstChild2 === void 0 || (_node$firstChild2 = _node$firstChild2.firstChild) === null || _node$firstChild2 === void 0 ? void 0 : _node$firstChild2.type) === schema.nodes.placeholder;
|
|
222
|
-
};
|
|
223
202
|
function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
224
203
|
return function (tr) {
|
|
225
204
|
// check if the column only contains a paragraph with a placeholder text
|
|
226
205
|
// if so, remove the whole column, otherwise just remove the paragraph
|
|
227
|
-
if ((0, _utils.isEmptyDocument)(column)
|
|
206
|
+
if ((0, _utils.isEmptyDocument)(column)) {
|
|
228
207
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(insideRightEdgePos), _model.Slice.empty);
|
|
229
208
|
} else {
|
|
230
209
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), _model.Slice.empty);
|
|
@@ -249,10 +228,9 @@ var fromThreeColstoOne = function fromThreeColstoOne(node, tr, insideRightEdgePo
|
|
|
249
228
|
};
|
|
250
229
|
var increaseColumns = function increaseColumns(schema, pos) {
|
|
251
230
|
var newColumnsNumber = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
252
|
-
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
253
231
|
return function (tr) {
|
|
254
232
|
for (var i = 0; i < newColumnsNumber; i++) {
|
|
255
|
-
addColumn(schema, pos
|
|
233
|
+
addColumn(schema, pos)(tr);
|
|
256
234
|
}
|
|
257
235
|
};
|
|
258
236
|
};
|
|
@@ -276,7 +254,7 @@ var decreaseColumns = function decreaseColumns(node, insideRightEdgePos) {
|
|
|
276
254
|
* Switching from 3 -> 2 moves all the content of the third col inside the second before
|
|
277
255
|
* removing it
|
|
278
256
|
*/
|
|
279
|
-
function forceColumnStructure(state, node, pos, presetLayout
|
|
257
|
+
function forceColumnStructure(state, node, pos, presetLayout) {
|
|
280
258
|
var tr = state.tr;
|
|
281
259
|
var insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
282
260
|
var numCols = node.childCount;
|
|
@@ -289,7 +267,7 @@ function forceColumnStructure(state, node, pos, presetLayout, formatMessage) {
|
|
|
289
267
|
|
|
290
268
|
// 2 columns -> 3 columns
|
|
291
269
|
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
292
|
-
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection
|
|
270
|
+
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
293
271
|
|
|
294
272
|
// 2 columns -> 1 column
|
|
295
273
|
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
@@ -310,13 +288,13 @@ function forceColumnStructure(state, node, pos, presetLayout, formatMessage) {
|
|
|
310
288
|
}
|
|
311
289
|
return tr;
|
|
312
290
|
}
|
|
313
|
-
function forceColumnStructureNew(state, node, pos, presetLayout
|
|
291
|
+
function forceColumnStructureNew(state, node, pos, presetLayout) {
|
|
314
292
|
var tr = state.tr;
|
|
315
293
|
var insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
316
294
|
var numCols = node.childCount;
|
|
317
295
|
var columnChange = getWidthsForPreset(presetLayout).length - numCols;
|
|
318
296
|
if (columnChange > 0) {
|
|
319
|
-
increaseColumns(state.schema, insideRightEdgeOfLayoutSection, columnChange
|
|
297
|
+
increaseColumns(state.schema, insideRightEdgeOfLayoutSection, columnChange)(tr);
|
|
320
298
|
} else if (columnChange < 0) {
|
|
321
299
|
decreaseColumns(node, insideRightEdgeOfLayoutSection, -columnChange)(tr);
|
|
322
300
|
}
|
|
@@ -344,9 +322,9 @@ function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
|
344
322
|
}
|
|
345
323
|
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
346
324
|
}
|
|
347
|
-
function forceSectionToPresetLayout(state, node, pos, presetLayout
|
|
325
|
+
function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
348
326
|
var forceColumnStructureFn = (0, _preRelease.isPreRelease2)() ? forceColumnStructureNew : forceColumnStructure;
|
|
349
|
-
var tr = forceColumnStructureFn(state, node, pos, presetLayout
|
|
327
|
+
var tr = forceColumnStructureFn(state, node, pos, presetLayout);
|
|
350
328
|
|
|
351
329
|
// save the selection here, since forcing column widths causes a change over the
|
|
352
330
|
// entire layoutSection, which remaps selection to the end. not remapping here
|
|
@@ -357,7 +335,7 @@ function forceSectionToPresetLayout(state, node, pos, presetLayout, formatMessag
|
|
|
357
335
|
return tr.setSelection(state.selection instanceof _state.NodeSelection ? new _state.NodeSelection(selectionPos$) : new _state.TextSelection(selectionPos$));
|
|
358
336
|
}
|
|
359
337
|
var setPresetLayout = exports.setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
|
|
360
|
-
return function (layout
|
|
338
|
+
return function (layout) {
|
|
361
339
|
return function (state, dispatch) {
|
|
362
340
|
var _ref = _pluginKey.pluginKey.getState(state),
|
|
363
341
|
pos = _ref.pos,
|
|
@@ -369,7 +347,7 @@ var setPresetLayout = exports.setPresetLayout = function setPresetLayout(editorA
|
|
|
369
347
|
if (!node) {
|
|
370
348
|
return false;
|
|
371
349
|
}
|
|
372
|
-
var tr = forceSectionToPresetLayout(state, node, pos, layout
|
|
350
|
+
var tr = forceSectionToPresetLayout(state, node, pos, layout);
|
|
373
351
|
if (tr) {
|
|
374
352
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
375
353
|
action: _analytics.ACTION.CHANGED_LAYOUT,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -87,7 +87,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
87
87
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconTwoColumnLayout, null);
|
|
88
88
|
},
|
|
89
89
|
action: function action(insert, state) {
|
|
90
|
-
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 2
|
|
90
|
+
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 2));
|
|
91
91
|
return tr;
|
|
92
92
|
}
|
|
93
93
|
}, {
|
|
@@ -100,7 +100,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
100
100
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconThreeColumnLayout, null);
|
|
101
101
|
},
|
|
102
102
|
action: function action(insert, state) {
|
|
103
|
-
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 3
|
|
103
|
+
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 3));
|
|
104
104
|
return tr;
|
|
105
105
|
}
|
|
106
106
|
}, {
|
|
@@ -113,7 +113,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
113
113
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconFourColumnLayout, null);
|
|
114
114
|
},
|
|
115
115
|
action: function action(insert, state) {
|
|
116
|
-
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 4
|
|
116
|
+
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 4));
|
|
117
117
|
return tr;
|
|
118
118
|
}
|
|
119
119
|
}, {
|
|
@@ -126,7 +126,7 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
126
126
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconFiveColumnLayout, null);
|
|
127
127
|
},
|
|
128
128
|
action: function action(insert, state) {
|
|
129
|
-
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 5
|
|
129
|
+
var tr = insert((0, _actions.createMultiColumnLayoutSection)(state, 5));
|
|
130
130
|
return tr;
|
|
131
131
|
}
|
|
132
132
|
}] : [{
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -123,7 +123,7 @@ var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, ed
|
|
|
123
123
|
iconFallback: item.iconFallback,
|
|
124
124
|
testId: item.title.id ? "".concat(item.title.id) : undefined,
|
|
125
125
|
title: intl.formatMessage(item.title),
|
|
126
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)(item.type
|
|
126
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)(item.type),
|
|
127
127
|
selected: !!currentLayout && currentLayout === item.type,
|
|
128
128
|
tabIndex: null
|
|
129
129
|
};
|
|
@@ -149,7 +149,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
149
149
|
}),
|
|
150
150
|
//'2-columns',
|
|
151
151
|
icon: iconPlaceholder,
|
|
152
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('two_equal'
|
|
152
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('two_equal'),
|
|
153
153
|
selected: numberOfColumns === 2
|
|
154
154
|
}, {
|
|
155
155
|
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
@@ -157,7 +157,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
157
157
|
}),
|
|
158
158
|
//'3-columns'
|
|
159
159
|
icon: iconPlaceholder,
|
|
160
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('three_equal'
|
|
160
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('three_equal'),
|
|
161
161
|
selected: numberOfColumns === 3
|
|
162
162
|
}, {
|
|
163
163
|
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
@@ -165,7 +165,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
165
165
|
}),
|
|
166
166
|
//'4-columns'
|
|
167
167
|
icon: iconPlaceholder,
|
|
168
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('four_equal'
|
|
168
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('four_equal'),
|
|
169
169
|
selected: numberOfColumns === 4
|
|
170
170
|
}, {
|
|
171
171
|
title: intl.formatMessage(_messages.layoutMessages.columnOption, {
|
|
@@ -173,7 +173,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
173
173
|
}),
|
|
174
174
|
//'5-columns'
|
|
175
175
|
icon: iconPlaceholder,
|
|
176
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('five_equal'
|
|
176
|
+
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)('five_equal'),
|
|
177
177
|
selected: numberOfColumns === 5
|
|
178
178
|
}];
|
|
179
179
|
return [{
|
|
@@ -4,26 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GlobalStylesWrapper = void 0;
|
|
7
|
-
var _react = require("
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _react2 = require("@emotion/react");
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
8
11
|
/**
|
|
9
12
|
* @jsxRuntime classic
|
|
10
13
|
* @jsx jsx
|
|
11
14
|
*/
|
|
12
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled
|
|
17
|
+
|
|
18
|
+
var getPlaceholderStyle = function getPlaceholderStyle(message) {
|
|
19
|
+
return (0, _react2.css)({
|
|
20
|
+
// when paragraph is the only child, and it only has a trailingBreak.
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
22
|
+
'.ProseMirror [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
|
|
23
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
24
|
+
'&::before': {
|
|
25
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
26
|
+
content: "\"".concat(message, "\""),
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
color: "var(--ds-text-disabled, #A5ADBA)",
|
|
29
|
+
font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
30
|
+
marginTop: "var(--ds-space-050, 4px)"
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
25
35
|
var GlobalStylesWrapper = exports.GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
37
|
+
formatMessage = _useIntl.formatMessage;
|
|
38
|
+
var placeholderStyle = (0, _react.useMemo)(function () {
|
|
39
|
+
return getPlaceholderStyle(formatMessage(_messages.layoutMessages.layoutPlaceholder));
|
|
40
|
+
}, [formatMessage]);
|
|
41
|
+
return (0, _react2.jsx)(_react2.Global, {
|
|
42
|
+
styles: placeholderStyle
|
|
28
43
|
});
|
|
29
44
|
};
|
package/dist/es2019/actions.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, LAYOUT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
|
-
import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
|
|
4
3
|
import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/editor-common/utils';
|
|
5
4
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
6
5
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -119,47 +118,30 @@ export const getSelectedLayout = (maybeLayoutSection, current) => {
|
|
|
119
118
|
}
|
|
120
119
|
return current;
|
|
121
120
|
};
|
|
122
|
-
const
|
|
123
|
-
if (!formatMessage) {
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
const {
|
|
127
|
-
paragraph,
|
|
128
|
-
placeholder
|
|
129
|
-
} = schema.nodes;
|
|
130
|
-
//create a paragraph node with content of placeholder node
|
|
131
|
-
const placeholderNode = placeholder.createChecked({
|
|
132
|
-
text: formatMessage(messages.layoutPlaceholder)
|
|
133
|
-
});
|
|
134
|
-
return paragraph.createAndFill(undefined, placeholderNode);
|
|
135
|
-
};
|
|
136
|
-
export const createMultiColumnLayoutSection = (state, numberOfColumns, formatMessage) => {
|
|
121
|
+
export const createMultiColumnLayoutSection = (state, numberOfColumns = 2) => {
|
|
137
122
|
const {
|
|
138
123
|
layoutSection,
|
|
139
124
|
layoutColumn
|
|
140
125
|
} = state.schema.nodes;
|
|
141
|
-
const placeholder = createPlaceholderNode(state.schema, formatMessage);
|
|
142
|
-
const layoutColumnNode = layoutColumn.createAndFill({
|
|
143
|
-
width: EVEN_DISTRIBUTED_COL_WIDTHS[numberOfColumns]
|
|
144
|
-
}, placeholder);
|
|
145
126
|
const columns = Fragment.fromArray(Array.from({
|
|
146
127
|
length: numberOfColumns
|
|
147
|
-
}, () =>
|
|
128
|
+
}, () => layoutColumn.createAndFill({
|
|
129
|
+
width: EVEN_DISTRIBUTED_COL_WIDTHS[numberOfColumns]
|
|
130
|
+
})));
|
|
148
131
|
return layoutSection.createAndFill(undefined, columns);
|
|
149
132
|
};
|
|
150
|
-
export const createDefaultLayoutSection =
|
|
133
|
+
export const createDefaultLayoutSection = state => {
|
|
151
134
|
const {
|
|
152
135
|
layoutSection,
|
|
153
136
|
layoutColumn
|
|
154
137
|
} = state.schema.nodes;
|
|
155
|
-
const placeholder = isPreRelease2() ? createPlaceholderNode(state.schema, formatMessage) : undefined;
|
|
156
138
|
|
|
157
139
|
// create a 50-50 layout by default
|
|
158
140
|
const columns = Fragment.fromArray([layoutColumn.createAndFill({
|
|
159
141
|
width: 50
|
|
160
|
-
}
|
|
142
|
+
}), layoutColumn.createAndFill({
|
|
161
143
|
width: 50
|
|
162
|
-
}
|
|
144
|
+
})]);
|
|
163
145
|
return layoutSection.createAndFill(undefined, columns);
|
|
164
146
|
};
|
|
165
147
|
export const insertLayoutColumns = (state, dispatch) => {
|
|
@@ -168,7 +150,7 @@ export const insertLayoutColumns = (state, dispatch) => {
|
|
|
168
150
|
}
|
|
169
151
|
return true;
|
|
170
152
|
};
|
|
171
|
-
export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI =>
|
|
153
|
+
export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => inputMethod => withAnalytics(editorAnalyticsAPI, {
|
|
172
154
|
action: ACTION.INSERTED,
|
|
173
155
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
174
156
|
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
|
|
@@ -178,7 +160,7 @@ export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => (inputMeth
|
|
|
178
160
|
eventType: EVENT_TYPE.TRACK
|
|
179
161
|
})((state, dispatch) => {
|
|
180
162
|
if (dispatch) {
|
|
181
|
-
dispatch(safeInsert(createDefaultLayoutSection(state
|
|
163
|
+
dispatch(safeInsert(createDefaultLayoutSection(state))(state.tr));
|
|
182
164
|
}
|
|
183
165
|
return true;
|
|
184
166
|
});
|
|
@@ -186,26 +168,21 @@ export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => (inputMeth
|
|
|
186
168
|
/**
|
|
187
169
|
* Add a column to the right of existing layout
|
|
188
170
|
*/
|
|
189
|
-
function addColumn(schema, pos
|
|
171
|
+
function addColumn(schema, pos) {
|
|
190
172
|
if (!isPreRelease2()) {
|
|
191
173
|
return tr => {
|
|
192
174
|
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
193
175
|
};
|
|
194
176
|
}
|
|
195
|
-
const placeholder = createPlaceholderNode(schema, formatMessage);
|
|
196
177
|
return tr => {
|
|
197
|
-
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill(undefined
|
|
178
|
+
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill(undefined));
|
|
198
179
|
};
|
|
199
180
|
}
|
|
200
|
-
const containPlaceholderOnly = (node, schema) => {
|
|
201
|
-
var _node$firstChild, _node$firstChild2, _node$firstChild2$fir;
|
|
202
|
-
return node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.childCount) === 1 && ((_node$firstChild2 = node.firstChild) === null || _node$firstChild2 === void 0 ? void 0 : (_node$firstChild2$fir = _node$firstChild2.firstChild) === null || _node$firstChild2$fir === void 0 ? void 0 : _node$firstChild2$fir.type) === schema.nodes.placeholder;
|
|
203
|
-
};
|
|
204
181
|
function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
205
182
|
return tr => {
|
|
206
183
|
// check if the column only contains a paragraph with a placeholder text
|
|
207
184
|
// if so, remove the whole column, otherwise just remove the paragraph
|
|
208
|
-
if (isEmptyDocument(column)
|
|
185
|
+
if (isEmptyDocument(column)) {
|
|
209
186
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(insideRightEdgePos), Slice.empty);
|
|
210
187
|
} else {
|
|
211
188
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), Slice.empty);
|
|
@@ -228,10 +205,10 @@ const fromThreeColstoOne = (node, tr, insideRightEdgePos) => {
|
|
|
228
205
|
const secondColumn = node.content.child(1);
|
|
229
206
|
fromTwoColsToOne(secondColumn, insideRightEdgePos - thirdColumn.nodeSize - secondColumn.nodeSize, insideRightEdgePos)(tr);
|
|
230
207
|
};
|
|
231
|
-
const increaseColumns = (schema, pos, newColumnsNumber = 1
|
|
208
|
+
const increaseColumns = (schema, pos, newColumnsNumber = 1) => {
|
|
232
209
|
return tr => {
|
|
233
210
|
for (let i = 0; i < newColumnsNumber; i++) {
|
|
234
|
-
addColumn(schema, pos
|
|
211
|
+
addColumn(schema, pos)(tr);
|
|
235
212
|
}
|
|
236
213
|
};
|
|
237
214
|
};
|
|
@@ -254,7 +231,7 @@ const decreaseColumns = (node, insideRightEdgePos, columnsNumberToRemove = 1) =>
|
|
|
254
231
|
* Switching from 3 -> 2 moves all the content of the third col inside the second before
|
|
255
232
|
* removing it
|
|
256
233
|
*/
|
|
257
|
-
function forceColumnStructure(state, node, pos, presetLayout
|
|
234
|
+
function forceColumnStructure(state, node, pos, presetLayout) {
|
|
258
235
|
const tr = state.tr;
|
|
259
236
|
const insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
260
237
|
const numCols = node.childCount;
|
|
@@ -267,7 +244,7 @@ function forceColumnStructure(state, node, pos, presetLayout, formatMessage) {
|
|
|
267
244
|
|
|
268
245
|
// 2 columns -> 3 columns
|
|
269
246
|
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
270
|
-
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection
|
|
247
|
+
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
271
248
|
|
|
272
249
|
// 2 columns -> 1 column
|
|
273
250
|
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
@@ -288,13 +265,13 @@ function forceColumnStructure(state, node, pos, presetLayout, formatMessage) {
|
|
|
288
265
|
}
|
|
289
266
|
return tr;
|
|
290
267
|
}
|
|
291
|
-
function forceColumnStructureNew(state, node, pos, presetLayout
|
|
268
|
+
function forceColumnStructureNew(state, node, pos, presetLayout) {
|
|
292
269
|
const tr = state.tr;
|
|
293
270
|
const insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
294
271
|
const numCols = node.childCount;
|
|
295
272
|
const columnChange = getWidthsForPreset(presetLayout).length - numCols;
|
|
296
273
|
if (columnChange > 0) {
|
|
297
|
-
increaseColumns(state.schema, insideRightEdgeOfLayoutSection, columnChange
|
|
274
|
+
increaseColumns(state.schema, insideRightEdgeOfLayoutSection, columnChange)(tr);
|
|
298
275
|
} else if (columnChange < 0) {
|
|
299
276
|
decreaseColumns(node, insideRightEdgeOfLayoutSection, -columnChange)(tr);
|
|
300
277
|
}
|
|
@@ -323,9 +300,9 @@ function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
|
323
300
|
}
|
|
324
301
|
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
325
302
|
}
|
|
326
|
-
export function forceSectionToPresetLayout(state, node, pos, presetLayout
|
|
303
|
+
export function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
327
304
|
const forceColumnStructureFn = isPreRelease2() ? forceColumnStructureNew : forceColumnStructure;
|
|
328
|
-
let tr = forceColumnStructureFn(state, node, pos, presetLayout
|
|
305
|
+
let tr = forceColumnStructureFn(state, node, pos, presetLayout);
|
|
329
306
|
|
|
330
307
|
// save the selection here, since forcing column widths causes a change over the
|
|
331
308
|
// entire layoutSection, which remaps selection to the end. not remapping here
|
|
@@ -335,7 +312,7 @@ export function forceSectionToPresetLayout(state, node, pos, presetLayout, forma
|
|
|
335
312
|
const selectionPos$ = tr.doc.resolve(selection.$from.pos);
|
|
336
313
|
return tr.setSelection(state.selection instanceof NodeSelection ? new NodeSelection(selectionPos$) : new TextSelection(selectionPos$));
|
|
337
314
|
}
|
|
338
|
-
export const setPresetLayout = editorAnalyticsAPI =>
|
|
315
|
+
export const setPresetLayout = editorAnalyticsAPI => layout => (state, dispatch) => {
|
|
339
316
|
const {
|
|
340
317
|
pos,
|
|
341
318
|
selectedLayout
|
|
@@ -347,7 +324,7 @@ export const setPresetLayout = editorAnalyticsAPI => (layout, formatMessage) =>
|
|
|
347
324
|
if (!node) {
|
|
348
325
|
return false;
|
|
349
326
|
}
|
|
350
|
-
let tr = forceSectionToPresetLayout(state, node, pos, layout
|
|
327
|
+
let tr = forceSectionToPresetLayout(state, node, pos, layout);
|
|
351
328
|
if (tr) {
|
|
352
329
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
353
330
|
action: ACTION.CHANGED_LAYOUT,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -71,7 +71,7 @@ export const layoutPlugin = ({
|
|
|
71
71
|
priority: 1100,
|
|
72
72
|
icon: () => /*#__PURE__*/React.createElement(IconTwoColumnLayout, null),
|
|
73
73
|
action(insert, state) {
|
|
74
|
-
const tr = insert(createMultiColumnLayoutSection(state, 2
|
|
74
|
+
const tr = insert(createMultiColumnLayoutSection(state, 2));
|
|
75
75
|
return tr;
|
|
76
76
|
}
|
|
77
77
|
}, {
|
|
@@ -82,7 +82,7 @@ export const layoutPlugin = ({
|
|
|
82
82
|
priority: 1100,
|
|
83
83
|
icon: () => /*#__PURE__*/React.createElement(IconThreeColumnLayout, null),
|
|
84
84
|
action(insert, state) {
|
|
85
|
-
const tr = insert(createMultiColumnLayoutSection(state, 3
|
|
85
|
+
const tr = insert(createMultiColumnLayoutSection(state, 3));
|
|
86
86
|
return tr;
|
|
87
87
|
}
|
|
88
88
|
}, {
|
|
@@ -93,7 +93,7 @@ export const layoutPlugin = ({
|
|
|
93
93
|
priority: 1100,
|
|
94
94
|
icon: () => /*#__PURE__*/React.createElement(IconFourColumnLayout, null),
|
|
95
95
|
action(insert, state) {
|
|
96
|
-
const tr = insert(createMultiColumnLayoutSection(state, 4
|
|
96
|
+
const tr = insert(createMultiColumnLayoutSection(state, 4));
|
|
97
97
|
return tr;
|
|
98
98
|
}
|
|
99
99
|
}, {
|
|
@@ -104,7 +104,7 @@ export const layoutPlugin = ({
|
|
|
104
104
|
priority: 1100,
|
|
105
105
|
icon: () => /*#__PURE__*/React.createElement(IconFiveColumnLayout, null),
|
|
106
106
|
action(insert, state) {
|
|
107
|
-
const tr = insert(createMultiColumnLayoutSection(state, 5
|
|
107
|
+
const tr = insert(createMultiColumnLayoutSection(state, 5));
|
|
108
108
|
return tr;
|
|
109
109
|
}
|
|
110
110
|
}] : [{
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -111,7 +111,7 @@ const buildLayoutButton = (intl, item, currentLayout, editorAnalyticsAPI) => ({
|
|
|
111
111
|
iconFallback: item.iconFallback,
|
|
112
112
|
testId: item.title.id ? `${item.title.id}` : undefined,
|
|
113
113
|
title: intl.formatMessage(item.title),
|
|
114
|
-
onClick: setPresetLayout(editorAnalyticsAPI)(item.type
|
|
114
|
+
onClick: setPresetLayout(editorAnalyticsAPI)(item.type),
|
|
115
115
|
selected: !!currentLayout && currentLayout === item.type,
|
|
116
116
|
tabIndex: null
|
|
117
117
|
});
|
|
@@ -137,7 +137,7 @@ const getAdvancedLayoutItems = ({
|
|
|
137
137
|
}),
|
|
138
138
|
//'2-columns',
|
|
139
139
|
icon: iconPlaceholder,
|
|
140
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('two_equal'
|
|
140
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('two_equal'),
|
|
141
141
|
selected: numberOfColumns === 2
|
|
142
142
|
}, {
|
|
143
143
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
@@ -145,7 +145,7 @@ const getAdvancedLayoutItems = ({
|
|
|
145
145
|
}),
|
|
146
146
|
//'3-columns'
|
|
147
147
|
icon: iconPlaceholder,
|
|
148
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('three_equal'
|
|
148
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('three_equal'),
|
|
149
149
|
selected: numberOfColumns === 3
|
|
150
150
|
}, {
|
|
151
151
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
@@ -153,7 +153,7 @@ const getAdvancedLayoutItems = ({
|
|
|
153
153
|
}),
|
|
154
154
|
//'4-columns'
|
|
155
155
|
icon: iconPlaceholder,
|
|
156
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('four_equal'
|
|
156
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('four_equal'),
|
|
157
157
|
selected: numberOfColumns === 4
|
|
158
158
|
}, {
|
|
159
159
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
@@ -161,7 +161,7 @@ const getAdvancedLayoutItems = ({
|
|
|
161
161
|
}),
|
|
162
162
|
//'5-columns'
|
|
163
163
|
icon: iconPlaceholder,
|
|
164
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'
|
|
164
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'),
|
|
165
165
|
selected: numberOfColumns === 5
|
|
166
166
|
}];
|
|
167
167
|
return [{
|
|
@@ -2,21 +2,35 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled
|
|
6
8
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
|
-
|
|
9
|
+
import { useIntl } from 'react-intl-next';
|
|
10
|
+
import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
|
+
const getPlaceholderStyle = message => css({
|
|
12
|
+
// when paragraph is the only child, and it only has a trailingBreak.
|
|
8
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
9
|
-
'.ProseMirror [data-layout-column]
|
|
14
|
+
'.ProseMirror [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
|
|
10
15
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
11
|
-
'&::
|
|
16
|
+
'&::before': {
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
18
|
+
content: `"${message}"`,
|
|
19
|
+
position: 'absolute',
|
|
12
20
|
color: "var(--ds-text-disabled, #A5ADBA)",
|
|
13
21
|
font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
14
|
-
|
|
22
|
+
marginTop: "var(--ds-space-050, 4px)"
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
});
|
|
18
26
|
export const GlobalStylesWrapper = () => {
|
|
27
|
+
const {
|
|
28
|
+
formatMessage
|
|
29
|
+
} = useIntl();
|
|
30
|
+
const placeholderStyle = useMemo(() => {
|
|
31
|
+
return getPlaceholderStyle(formatMessage(messages.layoutPlaceholder));
|
|
32
|
+
}, [formatMessage]);
|
|
19
33
|
return jsx(Global, {
|
|
20
|
-
styles:
|
|
34
|
+
styles: placeholderStyle
|
|
21
35
|
});
|
|
22
36
|
};
|
package/dist/esm/actions.js
CHANGED
|
@@ -3,7 +3,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, LAYOUT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
6
|
-
import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
6
|
import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/editor-common/utils';
|
|
8
7
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
8
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -126,46 +125,31 @@ export var getSelectedLayout = function getSelectedLayout(maybeLayoutSection, cu
|
|
|
126
125
|
}
|
|
127
126
|
return current;
|
|
128
127
|
};
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
var _schema$nodes = schema.nodes,
|
|
134
|
-
paragraph = _schema$nodes.paragraph,
|
|
135
|
-
placeholder = _schema$nodes.placeholder;
|
|
136
|
-
//create a paragraph node with content of placeholder node
|
|
137
|
-
var placeholderNode = placeholder.createChecked({
|
|
138
|
-
text: formatMessage(messages.layoutPlaceholder)
|
|
139
|
-
});
|
|
140
|
-
return paragraph.createAndFill(undefined, placeholderNode);
|
|
141
|
-
};
|
|
142
|
-
export var createMultiColumnLayoutSection = function createMultiColumnLayoutSection(state, numberOfColumns, formatMessage) {
|
|
128
|
+
export var createMultiColumnLayoutSection = function createMultiColumnLayoutSection(state) {
|
|
129
|
+
var numberOfColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
143
130
|
var _state$schema$nodes = state.schema.nodes,
|
|
144
131
|
layoutSection = _state$schema$nodes.layoutSection,
|
|
145
132
|
layoutColumn = _state$schema$nodes.layoutColumn;
|
|
146
|
-
var placeholder = createPlaceholderNode(state.schema, formatMessage);
|
|
147
|
-
var layoutColumnNode = layoutColumn.createAndFill({
|
|
148
|
-
width: EVEN_DISTRIBUTED_COL_WIDTHS[numberOfColumns]
|
|
149
|
-
}, placeholder);
|
|
150
133
|
var columns = Fragment.fromArray(Array.from({
|
|
151
134
|
length: numberOfColumns
|
|
152
135
|
}, function () {
|
|
153
|
-
return
|
|
136
|
+
return layoutColumn.createAndFill({
|
|
137
|
+
width: EVEN_DISTRIBUTED_COL_WIDTHS[numberOfColumns]
|
|
138
|
+
});
|
|
154
139
|
}));
|
|
155
140
|
return layoutSection.createAndFill(undefined, columns);
|
|
156
141
|
};
|
|
157
|
-
export var createDefaultLayoutSection = function createDefaultLayoutSection(state
|
|
142
|
+
export var createDefaultLayoutSection = function createDefaultLayoutSection(state) {
|
|
158
143
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
159
144
|
layoutSection = _state$schema$nodes2.layoutSection,
|
|
160
145
|
layoutColumn = _state$schema$nodes2.layoutColumn;
|
|
161
|
-
var placeholder = isPreRelease2() ? createPlaceholderNode(state.schema, formatMessage) : undefined;
|
|
162
146
|
|
|
163
147
|
// create a 50-50 layout by default
|
|
164
148
|
var columns = Fragment.fromArray([layoutColumn.createAndFill({
|
|
165
149
|
width: 50
|
|
166
|
-
}
|
|
150
|
+
}), layoutColumn.createAndFill({
|
|
167
151
|
width: 50
|
|
168
|
-
}
|
|
152
|
+
})]);
|
|
169
153
|
return layoutSection.createAndFill(undefined, columns);
|
|
170
154
|
};
|
|
171
155
|
export var insertLayoutColumns = function insertLayoutColumns(state, dispatch) {
|
|
@@ -175,7 +159,7 @@ export var insertLayoutColumns = function insertLayoutColumns(state, dispatch) {
|
|
|
175
159
|
return true;
|
|
176
160
|
};
|
|
177
161
|
export var insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAnalytics(editorAnalyticsAPI) {
|
|
178
|
-
return function (inputMethod
|
|
162
|
+
return function (inputMethod) {
|
|
179
163
|
return withAnalytics(editorAnalyticsAPI, {
|
|
180
164
|
action: ACTION.INSERTED,
|
|
181
165
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -186,7 +170,7 @@ export var insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAn
|
|
|
186
170
|
eventType: EVENT_TYPE.TRACK
|
|
187
171
|
})(function (state, dispatch) {
|
|
188
172
|
if (dispatch) {
|
|
189
|
-
dispatch(safeInsert(createDefaultLayoutSection(state
|
|
173
|
+
dispatch(safeInsert(createDefaultLayoutSection(state))(state.tr));
|
|
190
174
|
}
|
|
191
175
|
return true;
|
|
192
176
|
});
|
|
@@ -196,26 +180,21 @@ export var insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAn
|
|
|
196
180
|
/**
|
|
197
181
|
* Add a column to the right of existing layout
|
|
198
182
|
*/
|
|
199
|
-
function addColumn(schema, pos
|
|
183
|
+
function addColumn(schema, pos) {
|
|
200
184
|
if (!isPreRelease2()) {
|
|
201
185
|
return function (tr) {
|
|
202
186
|
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
203
187
|
};
|
|
204
188
|
}
|
|
205
|
-
var placeholder = createPlaceholderNode(schema, formatMessage);
|
|
206
189
|
return function (tr) {
|
|
207
|
-
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill(undefined
|
|
190
|
+
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill(undefined));
|
|
208
191
|
};
|
|
209
192
|
}
|
|
210
|
-
var containPlaceholderOnly = function containPlaceholderOnly(node, schema) {
|
|
211
|
-
var _node$firstChild, _node$firstChild2;
|
|
212
|
-
return node.childCount === 1 && ((_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.childCount) === 1 && ((_node$firstChild2 = node.firstChild) === null || _node$firstChild2 === void 0 || (_node$firstChild2 = _node$firstChild2.firstChild) === null || _node$firstChild2 === void 0 ? void 0 : _node$firstChild2.type) === schema.nodes.placeholder;
|
|
213
|
-
};
|
|
214
193
|
function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
215
194
|
return function (tr) {
|
|
216
195
|
// check if the column only contains a paragraph with a placeholder text
|
|
217
196
|
// if so, remove the whole column, otherwise just remove the paragraph
|
|
218
|
-
if (isEmptyDocument(column)
|
|
197
|
+
if (isEmptyDocument(column)) {
|
|
219
198
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(insideRightEdgePos), Slice.empty);
|
|
220
199
|
} else {
|
|
221
200
|
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), Slice.empty);
|
|
@@ -240,10 +219,9 @@ var fromThreeColstoOne = function fromThreeColstoOne(node, tr, insideRightEdgePo
|
|
|
240
219
|
};
|
|
241
220
|
var increaseColumns = function increaseColumns(schema, pos) {
|
|
242
221
|
var newColumnsNumber = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
243
|
-
var formatMessage = arguments.length > 3 ? arguments[3] : undefined;
|
|
244
222
|
return function (tr) {
|
|
245
223
|
for (var i = 0; i < newColumnsNumber; i++) {
|
|
246
|
-
addColumn(schema, pos
|
|
224
|
+
addColumn(schema, pos)(tr);
|
|
247
225
|
}
|
|
248
226
|
};
|
|
249
227
|
};
|
|
@@ -267,7 +245,7 @@ var decreaseColumns = function decreaseColumns(node, insideRightEdgePos) {
|
|
|
267
245
|
* Switching from 3 -> 2 moves all the content of the third col inside the second before
|
|
268
246
|
* removing it
|
|
269
247
|
*/
|
|
270
|
-
function forceColumnStructure(state, node, pos, presetLayout
|
|
248
|
+
function forceColumnStructure(state, node, pos, presetLayout) {
|
|
271
249
|
var tr = state.tr;
|
|
272
250
|
var insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
273
251
|
var numCols = node.childCount;
|
|
@@ -280,7 +258,7 @@ function forceColumnStructure(state, node, pos, presetLayout, formatMessage) {
|
|
|
280
258
|
|
|
281
259
|
// 2 columns -> 3 columns
|
|
282
260
|
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
283
|
-
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection
|
|
261
|
+
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
284
262
|
|
|
285
263
|
// 2 columns -> 1 column
|
|
286
264
|
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
@@ -301,13 +279,13 @@ function forceColumnStructure(state, node, pos, presetLayout, formatMessage) {
|
|
|
301
279
|
}
|
|
302
280
|
return tr;
|
|
303
281
|
}
|
|
304
|
-
function forceColumnStructureNew(state, node, pos, presetLayout
|
|
282
|
+
function forceColumnStructureNew(state, node, pos, presetLayout) {
|
|
305
283
|
var tr = state.tr;
|
|
306
284
|
var insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
307
285
|
var numCols = node.childCount;
|
|
308
286
|
var columnChange = getWidthsForPreset(presetLayout).length - numCols;
|
|
309
287
|
if (columnChange > 0) {
|
|
310
|
-
increaseColumns(state.schema, insideRightEdgeOfLayoutSection, columnChange
|
|
288
|
+
increaseColumns(state.schema, insideRightEdgeOfLayoutSection, columnChange)(tr);
|
|
311
289
|
} else if (columnChange < 0) {
|
|
312
290
|
decreaseColumns(node, insideRightEdgeOfLayoutSection, -columnChange)(tr);
|
|
313
291
|
}
|
|
@@ -335,9 +313,9 @@ function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
|
335
313
|
}
|
|
336
314
|
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
337
315
|
}
|
|
338
|
-
export function forceSectionToPresetLayout(state, node, pos, presetLayout
|
|
316
|
+
export function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
339
317
|
var forceColumnStructureFn = isPreRelease2() ? forceColumnStructureNew : forceColumnStructure;
|
|
340
|
-
var tr = forceColumnStructureFn(state, node, pos, presetLayout
|
|
318
|
+
var tr = forceColumnStructureFn(state, node, pos, presetLayout);
|
|
341
319
|
|
|
342
320
|
// save the selection here, since forcing column widths causes a change over the
|
|
343
321
|
// entire layoutSection, which remaps selection to the end. not remapping here
|
|
@@ -348,7 +326,7 @@ export function forceSectionToPresetLayout(state, node, pos, presetLayout, forma
|
|
|
348
326
|
return tr.setSelection(state.selection instanceof NodeSelection ? new NodeSelection(selectionPos$) : new TextSelection(selectionPos$));
|
|
349
327
|
}
|
|
350
328
|
export var setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
|
|
351
|
-
return function (layout
|
|
329
|
+
return function (layout) {
|
|
352
330
|
return function (state, dispatch) {
|
|
353
331
|
var _ref = pluginKey.getState(state),
|
|
354
332
|
pos = _ref.pos,
|
|
@@ -360,7 +338,7 @@ export var setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
|
|
|
360
338
|
if (!node) {
|
|
361
339
|
return false;
|
|
362
340
|
}
|
|
363
|
-
var tr = forceSectionToPresetLayout(state, node, pos, layout
|
|
341
|
+
var tr = forceSectionToPresetLayout(state, node, pos, layout);
|
|
364
342
|
if (tr) {
|
|
365
343
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
366
344
|
action: ACTION.CHANGED_LAYOUT,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -75,7 +75,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
75
75
|
return /*#__PURE__*/React.createElement(IconTwoColumnLayout, null);
|
|
76
76
|
},
|
|
77
77
|
action: function action(insert, state) {
|
|
78
|
-
var tr = insert(createMultiColumnLayoutSection(state, 2
|
|
78
|
+
var tr = insert(createMultiColumnLayoutSection(state, 2));
|
|
79
79
|
return tr;
|
|
80
80
|
}
|
|
81
81
|
}, {
|
|
@@ -88,7 +88,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
88
88
|
return /*#__PURE__*/React.createElement(IconThreeColumnLayout, null);
|
|
89
89
|
},
|
|
90
90
|
action: function action(insert, state) {
|
|
91
|
-
var tr = insert(createMultiColumnLayoutSection(state, 3
|
|
91
|
+
var tr = insert(createMultiColumnLayoutSection(state, 3));
|
|
92
92
|
return tr;
|
|
93
93
|
}
|
|
94
94
|
}, {
|
|
@@ -101,7 +101,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
101
101
|
return /*#__PURE__*/React.createElement(IconFourColumnLayout, null);
|
|
102
102
|
},
|
|
103
103
|
action: function action(insert, state) {
|
|
104
|
-
var tr = insert(createMultiColumnLayoutSection(state, 4
|
|
104
|
+
var tr = insert(createMultiColumnLayoutSection(state, 4));
|
|
105
105
|
return tr;
|
|
106
106
|
}
|
|
107
107
|
}, {
|
|
@@ -114,7 +114,7 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
114
114
|
return /*#__PURE__*/React.createElement(IconFiveColumnLayout, null);
|
|
115
115
|
},
|
|
116
116
|
action: function action(insert, state) {
|
|
117
|
-
var tr = insert(createMultiColumnLayoutSection(state, 5
|
|
117
|
+
var tr = insert(createMultiColumnLayoutSection(state, 5));
|
|
118
118
|
return tr;
|
|
119
119
|
}
|
|
120
120
|
}] : [{
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -113,7 +113,7 @@ var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, ed
|
|
|
113
113
|
iconFallback: item.iconFallback,
|
|
114
114
|
testId: item.title.id ? "".concat(item.title.id) : undefined,
|
|
115
115
|
title: intl.formatMessage(item.title),
|
|
116
|
-
onClick: setPresetLayout(editorAnalyticsAPI)(item.type
|
|
116
|
+
onClick: setPresetLayout(editorAnalyticsAPI)(item.type),
|
|
117
117
|
selected: !!currentLayout && currentLayout === item.type,
|
|
118
118
|
tabIndex: null
|
|
119
119
|
};
|
|
@@ -139,7 +139,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
139
139
|
}),
|
|
140
140
|
//'2-columns',
|
|
141
141
|
icon: iconPlaceholder,
|
|
142
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('two_equal'
|
|
142
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('two_equal'),
|
|
143
143
|
selected: numberOfColumns === 2
|
|
144
144
|
}, {
|
|
145
145
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
@@ -147,7 +147,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
147
147
|
}),
|
|
148
148
|
//'3-columns'
|
|
149
149
|
icon: iconPlaceholder,
|
|
150
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('three_equal'
|
|
150
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('three_equal'),
|
|
151
151
|
selected: numberOfColumns === 3
|
|
152
152
|
}, {
|
|
153
153
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
@@ -155,7 +155,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
155
155
|
}),
|
|
156
156
|
//'4-columns'
|
|
157
157
|
icon: iconPlaceholder,
|
|
158
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('four_equal'
|
|
158
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('four_equal'),
|
|
159
159
|
selected: numberOfColumns === 4
|
|
160
160
|
}, {
|
|
161
161
|
title: intl.formatMessage(layoutMessages.columnOption, {
|
|
@@ -163,7 +163,7 @@ var getAdvancedLayoutItems = function getAdvancedLayoutItems(_ref) {
|
|
|
163
163
|
}),
|
|
164
164
|
//'5-columns'
|
|
165
165
|
icon: iconPlaceholder,
|
|
166
|
-
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'
|
|
166
|
+
onClick: setPresetLayout(editorAnalyticsAPI)('five_equal'),
|
|
167
167
|
selected: numberOfColumns === 5
|
|
168
168
|
}];
|
|
169
169
|
return [{
|
|
@@ -2,21 +2,36 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled
|
|
6
8
|
import { css, Global, jsx } from '@emotion/react';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
import { useIntl } from 'react-intl-next';
|
|
10
|
+
import { layoutMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
|
+
var getPlaceholderStyle = function getPlaceholderStyle(message) {
|
|
12
|
+
return css({
|
|
13
|
+
// when paragraph is the only child, and it only has a trailingBreak.
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
15
|
+
'.ProseMirror [data-layout-column] > [data-layout-content] > p:only-child:has(.ProseMirror-trailingBreak:only-child)': {
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles -- Ignored via go/DSP-18766
|
|
17
|
+
'&::before': {
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values
|
|
19
|
+
content: "\"".concat(message, "\""),
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
color: "var(--ds-text-disabled, #A5ADBA)",
|
|
22
|
+
font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
23
|
+
marginTop: "var(--ds-space-050, 4px)"
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
18
28
|
export var GlobalStylesWrapper = function GlobalStylesWrapper() {
|
|
29
|
+
var _useIntl = useIntl(),
|
|
30
|
+
formatMessage = _useIntl.formatMessage;
|
|
31
|
+
var placeholderStyle = useMemo(function () {
|
|
32
|
+
return getPlaceholderStyle(formatMessage(messages.layoutPlaceholder));
|
|
33
|
+
}, [formatMessage]);
|
|
19
34
|
return jsx(Global, {
|
|
20
|
-
styles:
|
|
35
|
+
styles: placeholderStyle
|
|
21
36
|
});
|
|
22
37
|
};
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type IntlShape } from 'react-intl-next';
|
|
2
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import type { Command, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -13,12 +12,12 @@ export declare const THREE_COL_LAYOUTS: PresetLayout[];
|
|
|
13
12
|
*/
|
|
14
13
|
export declare const getPresetLayout: (section: Node) => PresetLayout | undefined;
|
|
15
14
|
export declare const getSelectedLayout: (maybeLayoutSection: Node | undefined, current: PresetLayout) => PresetLayout;
|
|
16
|
-
export declare const createMultiColumnLayoutSection: (state: EditorState, numberOfColumns
|
|
17
|
-
export declare const createDefaultLayoutSection: (state: EditorState
|
|
15
|
+
export declare const createMultiColumnLayoutSection: (state: EditorState, numberOfColumns?: number) => Node;
|
|
16
|
+
export declare const createDefaultLayoutSection: (state: EditorState) => Node;
|
|
18
17
|
export declare const insertLayoutColumns: Command;
|
|
19
|
-
export declare const insertLayoutColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: TOOLBAR_MENU_TYPE
|
|
20
|
-
export declare function forceSectionToPresetLayout(state: EditorState, node: Node, pos: number, presetLayout: PresetLayout
|
|
21
|
-
export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (layout: PresetLayout
|
|
18
|
+
export declare const insertLayoutColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: TOOLBAR_MENU_TYPE) => Command;
|
|
19
|
+
export declare function forceSectionToPresetLayout(state: EditorState, node: Node, pos: number, presetLayout: PresetLayout): Transaction;
|
|
20
|
+
export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (layout: PresetLayout) => Command;
|
|
22
21
|
export declare const fixColumnSizes: (changedTr: Transaction, state: EditorState) => Change | undefined;
|
|
23
22
|
export declare const fixColumnStructure: (state: EditorState) => Transaction | undefined;
|
|
24
23
|
export declare const deleteActiveLayoutNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type IntlShape } from 'react-intl-next';
|
|
2
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import type { Command, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -13,12 +12,12 @@ export declare const THREE_COL_LAYOUTS: PresetLayout[];
|
|
|
13
12
|
*/
|
|
14
13
|
export declare const getPresetLayout: (section: Node) => PresetLayout | undefined;
|
|
15
14
|
export declare const getSelectedLayout: (maybeLayoutSection: Node | undefined, current: PresetLayout) => PresetLayout;
|
|
16
|
-
export declare const createMultiColumnLayoutSection: (state: EditorState, numberOfColumns
|
|
17
|
-
export declare const createDefaultLayoutSection: (state: EditorState
|
|
15
|
+
export declare const createMultiColumnLayoutSection: (state: EditorState, numberOfColumns?: number) => Node;
|
|
16
|
+
export declare const createDefaultLayoutSection: (state: EditorState) => Node;
|
|
18
17
|
export declare const insertLayoutColumns: Command;
|
|
19
|
-
export declare const insertLayoutColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: TOOLBAR_MENU_TYPE
|
|
20
|
-
export declare function forceSectionToPresetLayout(state: EditorState, node: Node, pos: number, presetLayout: PresetLayout
|
|
21
|
-
export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (layout: PresetLayout
|
|
18
|
+
export declare const insertLayoutColumnsWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod: TOOLBAR_MENU_TYPE) => Command;
|
|
19
|
+
export declare function forceSectionToPresetLayout(state: EditorState, node: Node, pos: number, presetLayout: PresetLayout): Transaction;
|
|
20
|
+
export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (layout: PresetLayout) => Command;
|
|
22
21
|
export declare const fixColumnSizes: (changedTr: Transaction, state: EditorState) => Change | undefined;
|
|
23
22
|
export declare const fixColumnStructure: (state: EditorState) => Transaction | undefined;
|
|
24
23
|
export declare const deleteActiveLayoutNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
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.8",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^95.
|
|
35
|
+
"@atlaskit/editor-common": "^95.8.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|