@atlaskit/editor-plugin-layout 2.3.0 → 2.3.2

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-layout
2
2
 
3
+ ## 2.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#128309](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/128309)
8
+ [`5668591816f6a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5668591816f6a) -
9
+ Clean up platform_editor_advanced_layouts_dnd_remove_layout
10
+ - Updated dependencies
11
+
12
+ ## 2.3.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#128179](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/128179)
17
+ [`1ce5182d1a35f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1ce5182d1a35f) -
18
+ Clean up feature flag platform_editor_advanced_layouts_post_fix_patch_3
19
+ - Updated dependencies
20
+
3
21
  ## 2.3.0
4
22
 
5
23
  ### Minor Changes
@@ -14,7 +14,6 @@ var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _model = require("@atlaskit/editor-prosemirror/model");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
16
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
17
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
17
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
19
18
  var _consts = require("./consts");
20
19
  var _pluginKey = require("./plugin-key");
@@ -346,21 +345,15 @@ var setPresetLayout = exports.setPresetLayout = function setPresetLayout(editorA
346
345
  var _ref = _pluginKey.pluginKey.getState(state),
347
346
  pos = _ref.pos,
348
347
  selectedLayout = _ref.selectedLayout;
349
- if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
350
- if (pos === null) {
351
- return false;
352
- }
353
- } else if (selectedLayout === layout || pos === null) {
348
+ if (pos === null) {
354
349
  return false;
355
350
  }
356
351
  var node = state.doc.nodeAt(pos);
357
352
  if (!node) {
358
353
  return false;
359
354
  }
360
- if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_post_fix_patch_3')) {
361
- if (selectedLayout === layout && node.childCount > 1) {
362
- return false;
363
- }
355
+ if (selectedLayout === layout && node.childCount > 1) {
356
+ return false;
364
357
  }
365
358
  var tr = forceSectionToPresetLayout(state, node, pos, layout);
366
359
  if (tr) {
@@ -392,15 +385,11 @@ function layoutNeedChanges(node) {
392
385
  var getDefaultPresetLayout = function getDefaultPresetLayout(layoutNode) {
393
386
  var layoutColumnCount = layoutNode.childCount;
394
387
  if (layoutColumnCount <= 1) {
395
- if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_dnd_remove_layout')) {
396
- return 'single';
397
- }
398
-
399
- // This prevents the creation of a single column layout
400
- // once we support single column layout, we can return 'single'
401
- return 'two_equal';
388
+ return 'single';
402
389
  }
403
390
  switch (layoutColumnCount) {
391
+ case 1:
392
+ return 'single';
404
393
  case 2:
405
394
  return 'two_equal';
406
395
  case 3:
@@ -14,7 +14,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
14
14
  var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
16
16
  var _view = require("@atlaskit/editor-prosemirror/view");
17
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
17
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
19
18
  var _actions = require("./actions");
20
19
  var _consts = require("./consts");
@@ -81,24 +80,19 @@ var getInitialPluginState = function getInitialPluginState(options, state) {
81
80
  var handleDeleteLayoutColumn = function handleDeleteLayoutColumn(state, dispatch) {
82
81
  var sel = state.selection;
83
82
  if (sel instanceof _state.NodeSelection && sel.node.type.name === 'layoutColumn' && sel.$from.parent.type.name === 'layoutSection' && sel.$from.parent.childCount === 2 && dispatch && (0, _experiments.editorExperiment)('advanced_layouts', true)) {
84
- if ((0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_dnd_remove_layout')) {
85
- var _sel$$from$parent$las, _sel$$from$parent$fir;
86
- var tr = state.tr;
87
- var layoutContentFragment = sel.$from.parentOffset === 0 ? _model.Fragment.from((_sel$$from$parent$las = sel.$from.parent.lastChild) === null || _sel$$from$parent$las === void 0 ? void 0 : _sel$$from$parent$las.content) : _model.Fragment.from((_sel$$from$parent$fir = sel.$from.parent.firstChild) === null || _sel$$from$parent$fir === void 0 ? void 0 : _sel$$from$parent$fir.content);
88
- var parent = (0, _utils2.findParentNodeClosestToPos)(sel.$from, function (node) {
89
- return node.type.name === 'layoutSection';
90
- });
91
- if (parent) {
92
- var layoutSectionPos = tr.mapping.map(parent.pos);
93
- var layoutSectionNodeSize = parent.node.nodeSize;
94
- dispatch(state.tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment));
95
- return true;
96
- }
97
- return false;
98
- } else {
99
- dispatch(state.tr.deleteRange(sel.from + 1, sel.from + sel.node.content.size));
83
+ var _sel$$from$parent$las, _sel$$from$parent$fir;
84
+ var tr = state.tr;
85
+ var layoutContentFragment = sel.$from.parentOffset === 0 ? _model.Fragment.from((_sel$$from$parent$las = sel.$from.parent.lastChild) === null || _sel$$from$parent$las === void 0 ? void 0 : _sel$$from$parent$las.content) : _model.Fragment.from((_sel$$from$parent$fir = sel.$from.parent.firstChild) === null || _sel$$from$parent$fir === void 0 ? void 0 : _sel$$from$parent$fir.content);
86
+ var parent = (0, _utils2.findParentNodeClosestToPos)(sel.$from, function (node) {
87
+ return node.type.name === 'layoutSection';
88
+ });
89
+ if (parent) {
90
+ var layoutSectionPos = tr.mapping.map(parent.pos);
91
+ var layoutSectionNodeSize = parent.node.nodeSize;
92
+ dispatch(state.tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment));
93
+ return true;
100
94
  }
101
- return true;
95
+ return false;
102
96
  }
103
97
  return false;
104
98
  };
@@ -169,7 +163,7 @@ var _default = exports.default = function _default(options) {
169
163
  changes.push(change);
170
164
  }
171
165
  });
172
- if ((0, _experiments.editorExperiment)('advanced_layouts', true) && changes.length === 1 && (0, _platformFeatureFlags.fg)('platform_editor_advanced_layouts_dnd_remove_layout')) {
166
+ if ((0, _experiments.editorExperiment)('advanced_layouts', true) && changes.length === 1) {
173
167
  var _change$slice$content, _change$slice$content2;
174
168
  var change = changes[0];
175
169
  // when need to update a layoutColumn with width 100
@@ -4,7 +4,6 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
4
4
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
5
5
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
8
  import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
10
9
  import { pluginKey } from './plugin-key';
@@ -323,21 +322,15 @@ export const setPresetLayout = editorAnalyticsAPI => layout => (state, dispatch)
323
322
  pos,
324
323
  selectedLayout
325
324
  } = pluginKey.getState(state);
326
- if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
327
- if (pos === null) {
328
- return false;
329
- }
330
- } else if (selectedLayout === layout || pos === null) {
325
+ if (pos === null) {
331
326
  return false;
332
327
  }
333
328
  const node = state.doc.nodeAt(pos);
334
329
  if (!node) {
335
330
  return false;
336
331
  }
337
- if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
338
- if (selectedLayout === layout && node.childCount > 1) {
339
- return false;
340
- }
332
+ if (selectedLayout === layout && node.childCount > 1) {
333
+ return false;
341
334
  }
342
335
  const tr = forceSectionToPresetLayout(state, node, pos, layout);
343
336
  if (tr) {
@@ -367,15 +360,11 @@ function layoutNeedChanges(node) {
367
360
  const getDefaultPresetLayout = layoutNode => {
368
361
  const layoutColumnCount = layoutNode.childCount;
369
362
  if (layoutColumnCount <= 1) {
370
- if (fg('platform_editor_advanced_layouts_dnd_remove_layout')) {
371
- return 'single';
372
- }
373
-
374
- // This prevents the creation of a single column layout
375
- // once we support single column layout, we can return 'single'
376
- return 'two_equal';
363
+ return 'single';
377
364
  }
378
365
  switch (layoutColumnCount) {
366
+ case 1:
367
+ return 'single';
379
368
  case 2:
380
369
  return 'two_equal';
381
370
  case 3:
@@ -6,7 +6,6 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
6
6
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { findParentNodeClosestToPos, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
8
8
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
9
- import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
10
  import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from './actions';
12
11
  import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
@@ -76,24 +75,19 @@ const getInitialPluginState = (options, state) => {
76
75
  const handleDeleteLayoutColumn = (state, dispatch) => {
77
76
  const sel = state.selection;
78
77
  if (sel instanceof NodeSelection && sel.node.type.name === 'layoutColumn' && sel.$from.parent.type.name === 'layoutSection' && sel.$from.parent.childCount === 2 && dispatch && editorExperiment('advanced_layouts', true)) {
79
- if (fg('platform_editor_advanced_layouts_dnd_remove_layout')) {
80
- var _sel$$from$parent$las, _sel$$from$parent$fir;
81
- const tr = state.tr;
82
- const layoutContentFragment = sel.$from.parentOffset === 0 ? Fragment.from((_sel$$from$parent$las = sel.$from.parent.lastChild) === null || _sel$$from$parent$las === void 0 ? void 0 : _sel$$from$parent$las.content) : Fragment.from((_sel$$from$parent$fir = sel.$from.parent.firstChild) === null || _sel$$from$parent$fir === void 0 ? void 0 : _sel$$from$parent$fir.content);
83
- const parent = findParentNodeClosestToPos(sel.$from, node => {
84
- return node.type.name === 'layoutSection';
85
- });
86
- if (parent) {
87
- const layoutSectionPos = tr.mapping.map(parent.pos);
88
- const layoutSectionNodeSize = parent.node.nodeSize;
89
- dispatch(state.tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment));
90
- return true;
91
- }
92
- return false;
93
- } else {
94
- dispatch(state.tr.deleteRange(sel.from + 1, sel.from + sel.node.content.size));
78
+ var _sel$$from$parent$las, _sel$$from$parent$fir;
79
+ const tr = state.tr;
80
+ const layoutContentFragment = sel.$from.parentOffset === 0 ? Fragment.from((_sel$$from$parent$las = sel.$from.parent.lastChild) === null || _sel$$from$parent$las === void 0 ? void 0 : _sel$$from$parent$las.content) : Fragment.from((_sel$$from$parent$fir = sel.$from.parent.firstChild) === null || _sel$$from$parent$fir === void 0 ? void 0 : _sel$$from$parent$fir.content);
81
+ const parent = findParentNodeClosestToPos(sel.$from, node => {
82
+ return node.type.name === 'layoutSection';
83
+ });
84
+ if (parent) {
85
+ const layoutSectionPos = tr.mapping.map(parent.pos);
86
+ const layoutSectionNodeSize = parent.node.nodeSize;
87
+ dispatch(state.tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment));
88
+ return true;
95
89
  }
96
- return true;
90
+ return false;
97
91
  }
98
92
  return false;
99
93
  };
@@ -158,7 +152,7 @@ export default (options => new SafePlugin({
158
152
  changes.push(change);
159
153
  }
160
154
  });
161
- if (editorExperiment('advanced_layouts', true) && changes.length === 1 && fg('platform_editor_advanced_layouts_dnd_remove_layout')) {
155
+ if (editorExperiment('advanced_layouts', true) && changes.length === 1) {
162
156
  var _change$slice$content, _change$slice$content2;
163
157
  const change = changes[0];
164
158
  // when need to update a layoutColumn with width 100
@@ -7,7 +7,6 @@ import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/e
7
7
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
8
8
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
9
9
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
10
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
12
11
  import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
13
12
  import { pluginKey } from './plugin-key';
@@ -337,21 +336,15 @@ export var setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
337
336
  var _ref = pluginKey.getState(state),
338
337
  pos = _ref.pos,
339
338
  selectedLayout = _ref.selectedLayout;
340
- if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
341
- if (pos === null) {
342
- return false;
343
- }
344
- } else if (selectedLayout === layout || pos === null) {
339
+ if (pos === null) {
345
340
  return false;
346
341
  }
347
342
  var node = state.doc.nodeAt(pos);
348
343
  if (!node) {
349
344
  return false;
350
345
  }
351
- if (fg('platform_editor_advanced_layouts_post_fix_patch_3')) {
352
- if (selectedLayout === layout && node.childCount > 1) {
353
- return false;
354
- }
346
+ if (selectedLayout === layout && node.childCount > 1) {
347
+ return false;
355
348
  }
356
349
  var tr = forceSectionToPresetLayout(state, node, pos, layout);
357
350
  if (tr) {
@@ -383,15 +376,11 @@ function layoutNeedChanges(node) {
383
376
  var getDefaultPresetLayout = function getDefaultPresetLayout(layoutNode) {
384
377
  var layoutColumnCount = layoutNode.childCount;
385
378
  if (layoutColumnCount <= 1) {
386
- if (fg('platform_editor_advanced_layouts_dnd_remove_layout')) {
387
- return 'single';
388
- }
389
-
390
- // This prevents the creation of a single column layout
391
- // once we support single column layout, we can return 'single'
392
- return 'two_equal';
379
+ return 'single';
393
380
  }
394
381
  switch (layoutColumnCount) {
382
+ case 1:
383
+ return 'single';
395
384
  case 2:
396
385
  return 'two_equal';
397
386
  case 3:
@@ -9,7 +9,6 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
9
9
  import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { findParentNodeClosestToPos, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
13
  import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from './actions';
15
14
  import { EVEN_DISTRIBUTED_COL_WIDTHS } from './consts';
@@ -74,24 +73,19 @@ var getInitialPluginState = function getInitialPluginState(options, state) {
74
73
  var handleDeleteLayoutColumn = function handleDeleteLayoutColumn(state, dispatch) {
75
74
  var sel = state.selection;
76
75
  if (sel instanceof NodeSelection && sel.node.type.name === 'layoutColumn' && sel.$from.parent.type.name === 'layoutSection' && sel.$from.parent.childCount === 2 && dispatch && editorExperiment('advanced_layouts', true)) {
77
- if (fg('platform_editor_advanced_layouts_dnd_remove_layout')) {
78
- var _sel$$from$parent$las, _sel$$from$parent$fir;
79
- var tr = state.tr;
80
- var layoutContentFragment = sel.$from.parentOffset === 0 ? Fragment.from((_sel$$from$parent$las = sel.$from.parent.lastChild) === null || _sel$$from$parent$las === void 0 ? void 0 : _sel$$from$parent$las.content) : Fragment.from((_sel$$from$parent$fir = sel.$from.parent.firstChild) === null || _sel$$from$parent$fir === void 0 ? void 0 : _sel$$from$parent$fir.content);
81
- var parent = findParentNodeClosestToPos(sel.$from, function (node) {
82
- return node.type.name === 'layoutSection';
83
- });
84
- if (parent) {
85
- var layoutSectionPos = tr.mapping.map(parent.pos);
86
- var layoutSectionNodeSize = parent.node.nodeSize;
87
- dispatch(state.tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment));
88
- return true;
89
- }
90
- return false;
91
- } else {
92
- dispatch(state.tr.deleteRange(sel.from + 1, sel.from + sel.node.content.size));
76
+ var _sel$$from$parent$las, _sel$$from$parent$fir;
77
+ var tr = state.tr;
78
+ var layoutContentFragment = sel.$from.parentOffset === 0 ? Fragment.from((_sel$$from$parent$las = sel.$from.parent.lastChild) === null || _sel$$from$parent$las === void 0 ? void 0 : _sel$$from$parent$las.content) : Fragment.from((_sel$$from$parent$fir = sel.$from.parent.firstChild) === null || _sel$$from$parent$fir === void 0 ? void 0 : _sel$$from$parent$fir.content);
79
+ var parent = findParentNodeClosestToPos(sel.$from, function (node) {
80
+ return node.type.name === 'layoutSection';
81
+ });
82
+ if (parent) {
83
+ var layoutSectionPos = tr.mapping.map(parent.pos);
84
+ var layoutSectionNodeSize = parent.node.nodeSize;
85
+ dispatch(state.tr.replaceWith(layoutSectionPos, layoutSectionPos + layoutSectionNodeSize, layoutContentFragment));
86
+ return true;
93
87
  }
94
- return true;
88
+ return false;
95
89
  }
96
90
  return false;
97
91
  };
@@ -162,7 +156,7 @@ export default (function (options) {
162
156
  changes.push(change);
163
157
  }
164
158
  });
165
- if (editorExperiment('advanced_layouts', true) && changes.length === 1 && fg('platform_editor_advanced_layouts_dnd_remove_layout')) {
159
+ if (editorExperiment('advanced_layouts', true) && changes.length === 1) {
166
160
  var _change$slice$content, _change$slice$content2;
167
161
  var change = changes[0];
168
162
  // when need to update a layoutColumn with width 100
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-layout",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "Layout plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
- "@atlaskit/editor-common": "^102.11.0",
37
+ "@atlaskit/editor-common": "^102.13.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
39
  "@atlaskit/editor-plugin-decorations": "^2.0.0",
40
40
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/icon": "^25.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^1.1.0",
46
- "@atlaskit/tmp-editor-statsig": "^4.1.0",
46
+ "@atlaskit/tmp-editor-statsig": "^4.4.0",
47
47
  "@atlaskit/tokens": "^4.5.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "@emotion/react": "^11.7.1"
@@ -99,12 +99,6 @@
99
99
  "platform-feature-flags": {
100
100
  "platform-visual-refresh-icons": {
101
101
  "type": "boolean"
102
- },
103
- "platform_editor_advanced_layouts_post_fix_patch_3": {
104
- "type": "boolean"
105
- },
106
- "platform_editor_advanced_layouts_dnd_remove_layout": {
107
- "type": "boolean"
108
102
  }
109
103
  }
110
104
  }