@atlaskit/editor-plugin-layout 1.12.7 → 1.12.9
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 +18 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/{plugin.js → layoutPlugin.js} +7 -7
- package/dist/cjs/layoutPluginType.js +12 -0
- package/dist/cjs/{actions.js → pm-plugins/actions.js} +23 -45
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/resizing.js +2 -2
- package/dist/cjs/ui/global-styles.js +29 -14
- package/dist/cjs/{toolbar.js → ui/toolbar.js} +9 -9
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/{plugin.js → layoutPlugin.js} +7 -7
- package/dist/es2019/layoutPluginType.js +2 -0
- package/dist/es2019/{actions.js → pm-plugins/actions.js} +23 -46
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/resizing.js +1 -1
- package/dist/es2019/ui/global-styles.js +20 -6
- package/dist/es2019/{toolbar.js → ui/toolbar.js} +9 -9
- package/dist/esm/index.js +1 -1
- package/dist/esm/{plugin.js → layoutPlugin.js} +7 -7
- package/dist/esm/layoutPluginType.js +2 -0
- package/dist/esm/{actions.js → pm-plugins/actions.js} +23 -45
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/resizing.js +1 -1
- package/dist/esm/ui/global-styles.js +27 -12
- package/dist/esm/{toolbar.js → ui/toolbar.js} +9 -9
- package/dist/types/index.d.ts +2 -2
- package/dist/types/layoutPlugin.d.ts +4 -0
- package/dist/types/{plugin.d.ts → layoutPluginType.d.ts} +1 -2
- package/dist/types/{node-views → nodeviews}/index.d.ts +1 -1
- package/dist/types/{actions.d.ts → pm-plugins/actions.d.ts} +6 -7
- package/dist/types/pm-plugins/resizing.d.ts +1 -1
- package/dist/types/ui/global-styles.d.ts +0 -4
- package/dist/types/{toolbar.d.ts → ui/toolbar.d.ts} +1 -1
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/layoutPlugin.d.ts +4 -0
- package/dist/types-ts4.5/{plugin.d.ts → layoutPluginType.d.ts} +1 -2
- package/dist/types-ts4.5/{node-views → nodeviews}/index.d.ts +1 -1
- package/dist/types-ts4.5/{actions.d.ts → pm-plugins/actions.d.ts} +6 -7
- package/dist/types-ts4.5/pm-plugins/resizing.d.ts +1 -1
- package/dist/types-ts4.5/ui/global-styles.d.ts +0 -4
- package/dist/types-ts4.5/{toolbar.d.ts → ui/toolbar.d.ts} +1 -1
- package/package.json +8 -5
- /package/dist/cjs/{node-views → nodeviews}/index.js +0 -0
- /package/dist/cjs/{consts.js → pm-plugins/consts.js} +0 -0
- /package/dist/cjs/{utils → pm-plugins/utils}/index.js +0 -0
- /package/dist/cjs/{utils → pm-plugins/utils}/preRelease.js +0 -0
- /package/dist/cjs/{types.js → types/index.js} +0 -0
- /package/dist/es2019/{node-views → nodeviews}/index.js +0 -0
- /package/dist/es2019/{consts.js → pm-plugins/consts.js} +0 -0
- /package/dist/es2019/{utils → pm-plugins/utils}/index.js +0 -0
- /package/dist/es2019/{utils → pm-plugins/utils}/preRelease.js +0 -0
- /package/dist/es2019/{types.js → types/index.js} +0 -0
- /package/dist/esm/{node-views → nodeviews}/index.js +0 -0
- /package/dist/esm/{consts.js → pm-plugins/consts.js} +0 -0
- /package/dist/esm/{utils → pm-plugins/utils}/index.js +0 -0
- /package/dist/esm/{utils → pm-plugins/utils}/preRelease.js +0 -0
- /package/dist/esm/{types.js → types/index.js} +0 -0
- /package/dist/types/{consts.d.ts → pm-plugins/consts.d.ts} +0 -0
- /package/dist/types/{utils → pm-plugins/utils}/index.d.ts +0 -0
- /package/dist/types/{utils → pm-plugins/utils}/preRelease.d.ts +0 -0
- /package/dist/types/{types.d.ts → types/index.d.ts} +0 -0
- /package/dist/types-ts4.5/{consts.d.ts → pm-plugins/consts.d.ts} +0 -0
- /package/dist/types-ts4.5/{utils → pm-plugins/utils}/index.d.ts +0 -0
- /package/dist/types-ts4.5/{utils → pm-plugins/utils}/preRelease.d.ts +0 -0
- /package/dist/types-ts4.5/{types.d.ts → types/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 1.12.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#170473](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170473)
|
|
8
|
+
[`2c463f9682286`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2c463f9682286) -
|
|
9
|
+
ED-25813: refactors plugins to meet folder standards
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 1.12.8
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#169277](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169277)
|
|
17
|
+
[`4d8433c0b731a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4d8433c0b731a) -
|
|
18
|
+
ED-25872 improve placeholder usability for layout
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 1.12.7
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "layoutPlugin", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function get() {
|
|
9
|
-
return
|
|
9
|
+
return _layoutPlugin.layoutPlugin;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
var
|
|
12
|
+
var _layoutPlugin = require("./layoutPlugin");
|
|
@@ -18,13 +18,13 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
18
18
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
19
19
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
-
var _actions = require("./actions");
|
|
21
|
+
var _actions = require("./pm-plugins/actions");
|
|
22
22
|
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
23
23
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
24
24
|
var _resizing = _interopRequireDefault(require("./pm-plugins/resizing"));
|
|
25
|
-
var
|
|
25
|
+
var _preRelease = require("./pm-plugins/utils/preRelease");
|
|
26
26
|
var _globalStyles = require("./ui/global-styles");
|
|
27
|
-
var
|
|
27
|
+
var _toolbar = require("./ui/toolbar");
|
|
28
28
|
var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
29
29
|
var _api$analytics;
|
|
30
30
|
var _ref$config = _ref.config,
|
|
@@ -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
|
}] : [{
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "pluginKey", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _pluginKey.pluginKey;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
@@ -10,14 +10,13 @@ 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");
|
|
17
16
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
19
18
|
var _consts = require("./consts");
|
|
20
|
-
var _pluginKey = require("./
|
|
19
|
+
var _pluginKey = require("./plugin-key");
|
|
21
20
|
var _preRelease = require("./utils/preRelease");
|
|
22
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -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,
|
|
@@ -13,9 +13,9 @@ var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
15
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
16
|
-
var _actions = require("
|
|
17
|
-
var _utils3 = require("../utils");
|
|
16
|
+
var _actions = require("./actions");
|
|
18
17
|
var _pluginKey = require("./plugin-key");
|
|
18
|
+
var _utils3 = require("./utils");
|
|
19
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
21
|
var DEFAULT_LAYOUT = exports.DEFAULT_LAYOUT = 'two_equal';
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.pluginKey = exports.default = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var
|
|
9
|
+
var _nodeviews = require("../nodeviews");
|
|
10
10
|
var pluginKey = exports.pluginKey = new _state.PluginKey('layoutResizingPlugin');
|
|
11
11
|
var _default = exports.default = function _default(options, pluginInjectionApi, portalProviderAPI, eventDispatcher) {
|
|
12
12
|
return new _safePlugin.SafePlugin({
|
|
@@ -14,7 +14,7 @@ var _default = exports.default = function _default(options, pluginInjectionApi,
|
|
|
14
14
|
props: {
|
|
15
15
|
nodeViews: {
|
|
16
16
|
layoutSection: function layoutSection(node, view, getPos) {
|
|
17
|
-
return new
|
|
17
|
+
return new _nodeviews.LayoutSectionView({
|
|
18
18
|
node: node,
|
|
19
19
|
view: view,
|
|
20
20
|
getPos: getPos,
|
|
@@ -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
|
};
|
|
@@ -24,10 +24,10 @@ var _layoutTwoLeftSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph
|
|
|
24
24
|
var _layoutTwoRightSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-right-sidebar"));
|
|
25
25
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
26
26
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
|
-
var _actions = require("
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
27
|
+
var _actions = require("../pm-plugins/actions");
|
|
28
|
+
var _preRelease = require("../pm-plugins/utils/preRelease");
|
|
29
|
+
var _LayoutThreeWithLeftSidebars = require("./icons/LayoutThreeWithLeftSidebars");
|
|
30
|
+
var _LayoutThreeWithRightSidebars = require("./icons/LayoutThreeWithRightSidebars");
|
|
31
31
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
32
32
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
33
33
|
var LAYOUT_TYPES = [{
|
|
@@ -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 [{
|
package/dist/es2019/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { layoutPlugin } from './
|
|
1
|
+
export { layoutPlugin } from './layoutPlugin';
|
|
@@ -5,13 +5,13 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
5
5
|
import { layoutMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconThreeColumnLayout, IconTwoColumnLayout } from '@atlaskit/editor-common/quick-insert';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './actions';
|
|
8
|
+
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
9
9
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
10
10
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
11
11
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
12
|
-
import {
|
|
12
|
+
import { isPreRelease2 } from './pm-plugins/utils/preRelease';
|
|
13
13
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
14
|
-
import {
|
|
14
|
+
import { buildToolbar } from './ui/toolbar';
|
|
15
15
|
export { pluginKey };
|
|
16
16
|
export const layoutPlugin = ({
|
|
17
17
|
config: options = {},
|
|
@@ -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
|
}] : [{
|