@atlaskit/editor-plugin-layout 10.0.15 → 10.1.0
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 +12 -0
- package/dist/cjs/layoutPlugin.js +15 -1
- package/dist/cjs/pm-plugins/actions.js +12 -1
- package/dist/cjs/pm-plugins/main.js +9 -4
- package/dist/cjs/ui/LayoutColumnMenu/index.js +24 -0
- package/dist/es2019/layoutPlugin.js +17 -4
- package/dist/es2019/pm-plugins/actions.js +12 -1
- package/dist/es2019/pm-plugins/main.js +10 -4
- package/dist/es2019/ui/LayoutColumnMenu/index.js +19 -0
- package/dist/esm/layoutPlugin.js +17 -4
- package/dist/esm/pm-plugins/actions.js +12 -1
- package/dist/esm/pm-plugins/main.js +9 -4
- package/dist/esm/ui/LayoutColumnMenu/index.js +17 -0
- package/dist/types/layoutPluginType.d.ts +6 -1
- package/dist/types/pm-plugins/actions.d.ts +4 -1
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types/ui/LayoutColumnMenu/index.d.ts +8 -0
- package/dist/types-ts4.5/layoutPluginType.d.ts +6 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +4 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/LayoutColumnMenu/index.d.ts +8 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-layout
|
|
2
2
|
|
|
3
|
+
## 10.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`2023cac0fd36f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2023cac0fd36f) -
|
|
8
|
+
Add column drag handle context menu placeholder, gated behind the
|
|
9
|
+
platform_editor_layout_column_menu experiment flag.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 10.0.15
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/layoutPlugin.js
CHANGED
|
@@ -15,6 +15,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
17
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
18
19
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
19
20
|
var _actions = require("./pm-plugins/actions");
|
|
20
21
|
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
@@ -22,8 +23,10 @@ var _pluginKey = require("./pm-plugins/plugin-key");
|
|
|
22
23
|
var _resizing = _interopRequireDefault(require("./pm-plugins/resizing"));
|
|
23
24
|
var _globalStyles = require("./ui/global-styles");
|
|
24
25
|
var _LayoutBlockMenuItem = require("./ui/LayoutBlockMenuItem");
|
|
26
|
+
var _LayoutColumnMenu = require("./ui/LayoutColumnMenu");
|
|
25
27
|
var _toolbar = require("./ui/toolbar");
|
|
26
28
|
var LAYOUT_SECTION_NODE_NAME = 'layoutSection';
|
|
29
|
+
|
|
27
30
|
/**
|
|
28
31
|
* This function is used to set the selection into
|
|
29
32
|
* the first paragraph of the first column of a layout section.
|
|
@@ -274,7 +277,18 @@ var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
|
274
277
|
}
|
|
275
278
|
},
|
|
276
279
|
contentComponent: function contentComponent() {
|
|
277
|
-
return (0, _experiments.editorExperiment)('advanced_layouts', true) ? /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, null) : null
|
|
280
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _experiments.editorExperiment)('advanced_layouts', true) ? /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, null) : null, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_layout_column_menu', 'isEnabled', true) ? /*#__PURE__*/_react.default.createElement(_LayoutColumnMenu.LayoutColumnMenu, {
|
|
281
|
+
api: api
|
|
282
|
+
}) : null);
|
|
283
|
+
},
|
|
284
|
+
getSharedState: function getSharedState(editorState) {
|
|
285
|
+
if (!editorState) {
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
return _pluginKey.pluginKey.getState(editorState);
|
|
289
|
+
},
|
|
290
|
+
commands: {
|
|
291
|
+
toggleLayoutColumnMenu: _actions.toggleLayoutColumnMenu
|
|
278
292
|
}
|
|
279
293
|
};
|
|
280
294
|
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.fixColumnStructure = exports.fixColumnSizes = exports.deleteActiveLayoutNode = exports.createMultiColumnLayoutSection = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = void 0;
|
|
8
8
|
exports.forceSectionToPresetLayout = forceSectionToPresetLayout;
|
|
9
|
-
exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
9
|
+
exports.toggleLayoutColumnMenu = exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
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");
|
|
@@ -547,4 +547,15 @@ var formatLayoutName = function formatLayoutName(layout) {
|
|
|
547
547
|
case 'three_with_sidebars':
|
|
548
548
|
return _analytics.LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
549
549
|
}
|
|
550
|
+
};
|
|
551
|
+
var toggleLayoutColumnMenu = exports.toggleLayoutColumnMenu = function toggleLayoutColumnMenu(_ref4) {
|
|
552
|
+
var isOpen = _ref4.isOpen;
|
|
553
|
+
return function (_ref5) {
|
|
554
|
+
var tr = _ref5.tr;
|
|
555
|
+
tr.setMeta('toggleLayoutColumnMenu', {
|
|
556
|
+
isOpen: isOpen
|
|
557
|
+
});
|
|
558
|
+
tr.setMeta('scrollIntoView', false);
|
|
559
|
+
return tr;
|
|
560
|
+
};
|
|
550
561
|
};
|
|
@@ -72,7 +72,8 @@ var getInitialPluginState = function getInitialPluginState(options, state) {
|
|
|
72
72
|
addSidebarLayouts: addSidebarLayouts,
|
|
73
73
|
selectedLayout: selectedLayout,
|
|
74
74
|
allowSingleColumnLayout: allowSingleColumnLayout,
|
|
75
|
-
isResizing: false
|
|
75
|
+
isResizing: false,
|
|
76
|
+
isLayoutColumnMenuOpen: false
|
|
76
77
|
};
|
|
77
78
|
};
|
|
78
79
|
|
|
@@ -121,11 +122,15 @@ var _default = exports.default = function _default(options) {
|
|
|
121
122
|
return getInitialPluginState(options, state);
|
|
122
123
|
},
|
|
123
124
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
124
|
-
var _tr$getMeta, _pluginKey$getState;
|
|
125
|
+
var _columnMenuMeta$isOpe, _tr$getMeta, _pluginKey$getState;
|
|
126
|
+
var columnMenuMeta = tr.getMeta('toggleLayoutColumnMenu');
|
|
127
|
+
var nextPluginState = columnMenuMeta ? _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
128
|
+
isLayoutColumnMenuOpen: (_columnMenuMeta$isOpe = columnMenuMeta.isOpen) !== null && _columnMenuMeta$isOpe !== void 0 ? _columnMenuMeta$isOpe : !pluginState.isLayoutColumnMenuOpen
|
|
129
|
+
}) : pluginState;
|
|
125
130
|
var isResizing = (0, _experiments.editorExperiment)('single_column_layouts', true) ? (_tr$getMeta = tr.getMeta('is-resizer-resizing')) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : (_pluginKey$getState = _pluginKey.pluginKey.getState(oldState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.isResizing : false;
|
|
126
131
|
if (tr.docChanged || tr.selectionSet) {
|
|
127
132
|
var maybeLayoutSection = (0, _utils3.getMaybeLayoutSection)(newState);
|
|
128
|
-
var newPluginState = _objectSpread(_objectSpread({},
|
|
133
|
+
var newPluginState = _objectSpread(_objectSpread({}, nextPluginState), {}, {
|
|
129
134
|
pos: maybeLayoutSection ? maybeLayoutSection.pos : null,
|
|
130
135
|
isResizing: isResizing,
|
|
131
136
|
selectedLayout: (0, _actions.getSelectedLayout)(maybeLayoutSection && maybeLayoutSection.node,
|
|
@@ -135,7 +140,7 @@ var _default = exports.default = function _default(options) {
|
|
|
135
140
|
});
|
|
136
141
|
return newPluginState;
|
|
137
142
|
}
|
|
138
|
-
return _objectSpread(_objectSpread({},
|
|
143
|
+
return _objectSpread(_objectSpread({}, nextPluginState), {}, {
|
|
139
144
|
isResizing: isResizing
|
|
140
145
|
});
|
|
141
146
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LayoutColumnMenu = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var LayoutColumnMenu = exports.LayoutColumnMenu = function LayoutColumnMenu(_ref) {
|
|
11
|
+
var api = _ref.api;
|
|
12
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['layout'], function (states) {
|
|
13
|
+
var _states$layoutState$i, _states$layoutState;
|
|
14
|
+
return {
|
|
15
|
+
isLayoutColumnMenuOpen: (_states$layoutState$i = (_states$layoutState = states.layoutState) === null || _states$layoutState === void 0 ? void 0 : _states$layoutState.isLayoutColumnMenuOpen) !== null && _states$layoutState$i !== void 0 ? _states$layoutState$i : false
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
isLayoutColumnMenuOpen = _useSharedPluginState.isLayoutColumnMenuOpen;
|
|
19
|
+
if (!isLayoutColumnMenuOpen) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
var placeholder = 'Mock Layout Column Menu';
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement("div", null, placeholder);
|
|
24
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { layoutColumn,
|
|
2
|
+
import { layoutColumn, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId } from '@atlaskit/adf-schema';
|
|
3
3
|
import { layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from '@atlaskit/adf-schema/schema';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
@@ -8,15 +8,17 @@ import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLa
|
|
|
8
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
11
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
-
|
|
13
|
-
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
13
|
+
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
14
14
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
15
15
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
16
16
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
17
17
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
18
18
|
import { createLayoutBlockMenuItem } from './ui/LayoutBlockMenuItem';
|
|
19
|
+
import { LayoutColumnMenu } from './ui/LayoutColumnMenu';
|
|
19
20
|
import { buildToolbar } from './ui/toolbar';
|
|
21
|
+
const LAYOUT_SECTION_NODE_NAME = 'layoutSection';
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* This function is used to set the selection into
|
|
@@ -254,7 +256,18 @@ export const layoutPlugin = ({
|
|
|
254
256
|
}
|
|
255
257
|
},
|
|
256
258
|
contentComponent() {
|
|
257
|
-
return editorExperiment('advanced_layouts', true) ? /*#__PURE__*/React.createElement(GlobalStylesWrapper, null) : null
|
|
259
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, editorExperiment('advanced_layouts', true) ? /*#__PURE__*/React.createElement(GlobalStylesWrapper, null) : null, expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true) ? /*#__PURE__*/React.createElement(LayoutColumnMenu, {
|
|
260
|
+
api: api
|
|
261
|
+
}) : null);
|
|
262
|
+
},
|
|
263
|
+
getSharedState(editorState) {
|
|
264
|
+
if (!editorState) {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
return pluginKey.getState(editorState);
|
|
268
|
+
},
|
|
269
|
+
commands: {
|
|
270
|
+
toggleLayoutColumnMenu
|
|
258
271
|
}
|
|
259
272
|
};
|
|
260
273
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE,
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, LAYOUT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
3
|
import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -524,4 +524,15 @@ const formatLayoutName = layout => {
|
|
|
524
524
|
case 'three_with_sidebars':
|
|
525
525
|
return LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
526
526
|
}
|
|
527
|
+
};
|
|
528
|
+
export const toggleLayoutColumnMenu = ({
|
|
529
|
+
isOpen
|
|
530
|
+
}) => ({
|
|
531
|
+
tr
|
|
532
|
+
}) => {
|
|
533
|
+
tr.setMeta('toggleLayoutColumnMenu', {
|
|
534
|
+
isOpen
|
|
535
|
+
});
|
|
536
|
+
tr.setMeta('scrollIntoView', false);
|
|
537
|
+
return tr;
|
|
527
538
|
};
|
|
@@ -66,7 +66,8 @@ const getInitialPluginState = (options, state) => {
|
|
|
66
66
|
addSidebarLayouts,
|
|
67
67
|
selectedLayout,
|
|
68
68
|
allowSingleColumnLayout,
|
|
69
|
-
isResizing: false
|
|
69
|
+
isResizing: false,
|
|
70
|
+
isLayoutColumnMenuOpen: false
|
|
70
71
|
};
|
|
71
72
|
};
|
|
72
73
|
|
|
@@ -113,12 +114,17 @@ export default (options => {
|
|
|
113
114
|
state: {
|
|
114
115
|
init: (_, state) => getInitialPluginState(options, state),
|
|
115
116
|
apply: (tr, pluginState, oldState, newState) => {
|
|
116
|
-
var _tr$getMeta, _pluginKey$getState;
|
|
117
|
+
var _columnMenuMeta$isOpe, _tr$getMeta, _pluginKey$getState;
|
|
118
|
+
const columnMenuMeta = tr.getMeta('toggleLayoutColumnMenu');
|
|
119
|
+
const nextPluginState = columnMenuMeta ? {
|
|
120
|
+
...pluginState,
|
|
121
|
+
isLayoutColumnMenuOpen: (_columnMenuMeta$isOpe = columnMenuMeta.isOpen) !== null && _columnMenuMeta$isOpe !== void 0 ? _columnMenuMeta$isOpe : !pluginState.isLayoutColumnMenuOpen
|
|
122
|
+
} : pluginState;
|
|
117
123
|
const isResizing = editorExperiment('single_column_layouts', true) ? (_tr$getMeta = tr.getMeta('is-resizer-resizing')) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : (_pluginKey$getState = pluginKey.getState(oldState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.isResizing : false;
|
|
118
124
|
if (tr.docChanged || tr.selectionSet) {
|
|
119
125
|
const maybeLayoutSection = getMaybeLayoutSection(newState);
|
|
120
126
|
const newPluginState = {
|
|
121
|
-
...
|
|
127
|
+
...nextPluginState,
|
|
122
128
|
pos: maybeLayoutSection ? maybeLayoutSection.pos : null,
|
|
123
129
|
isResizing,
|
|
124
130
|
selectedLayout: getSelectedLayout(maybeLayoutSection && maybeLayoutSection.node,
|
|
@@ -129,7 +135,7 @@ export default (options => {
|
|
|
129
135
|
return newPluginState;
|
|
130
136
|
}
|
|
131
137
|
return {
|
|
132
|
-
...
|
|
138
|
+
...nextPluginState,
|
|
133
139
|
isResizing
|
|
134
140
|
};
|
|
135
141
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
export const LayoutColumnMenu = ({
|
|
4
|
+
api
|
|
5
|
+
}) => {
|
|
6
|
+
const {
|
|
7
|
+
isLayoutColumnMenuOpen
|
|
8
|
+
} = useSharedPluginStateWithSelector(api, ['layout'], states => {
|
|
9
|
+
var _states$layoutState$i, _states$layoutState;
|
|
10
|
+
return {
|
|
11
|
+
isLayoutColumnMenuOpen: (_states$layoutState$i = (_states$layoutState = states.layoutState) === null || _states$layoutState === void 0 ? void 0 : _states$layoutState.isLayoutColumnMenuOpen) !== null && _states$layoutState$i !== void 0 ? _states$layoutState$i : false
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
if (!isLayoutColumnMenuOpen) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const placeholder = 'Mock Layout Column Menu';
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", null, placeholder);
|
|
19
|
+
};
|
package/dist/esm/layoutPlugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { layoutColumn,
|
|
2
|
+
import { layoutColumn, layoutColumnWithLocalId, layoutSection, layoutSectionWithLocalId } from '@atlaskit/adf-schema';
|
|
3
3
|
import { layoutSectionWithSingleColumn, layoutSectionWithSingleColumnLocalId } from '@atlaskit/adf-schema/schema';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { TRANSFORM_STRUCTURE_LAYOUT_MENU_ITEM, TRANSFORM_STRUCTURE_MENU_SECTION, TRANSFORM_STRUCTURE_MENU_SECTION_RANK } from '@atlaskit/editor-common/block-menu';
|
|
@@ -8,15 +8,17 @@ import { IconFiveColumnLayout, IconFourColumnLayout, IconLayout, IconOneColumnLa
|
|
|
8
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
10
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
11
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
-
|
|
13
|
-
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
13
|
+
import { createDefaultLayoutSection, createMultiColumnLayoutSection, insertLayoutColumnsWithAnalytics, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
14
14
|
import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
15
15
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
16
16
|
import { default as createLayoutResizingPlugin } from './pm-plugins/resizing';
|
|
17
17
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
18
18
|
import { createLayoutBlockMenuItem } from './ui/LayoutBlockMenuItem';
|
|
19
|
+
import { LayoutColumnMenu } from './ui/LayoutColumnMenu';
|
|
19
20
|
import { buildToolbar } from './ui/toolbar';
|
|
21
|
+
var LAYOUT_SECTION_NODE_NAME = 'layoutSection';
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* This function is used to set the selection into
|
|
@@ -268,7 +270,18 @@ export var layoutPlugin = function layoutPlugin(_ref) {
|
|
|
268
270
|
}
|
|
269
271
|
},
|
|
270
272
|
contentComponent: function contentComponent() {
|
|
271
|
-
return editorExperiment('advanced_layouts', true) ? /*#__PURE__*/React.createElement(GlobalStylesWrapper, null) : null
|
|
273
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, editorExperiment('advanced_layouts', true) ? /*#__PURE__*/React.createElement(GlobalStylesWrapper, null) : null, expValEqualsNoExposure('platform_editor_layout_column_menu', 'isEnabled', true) ? /*#__PURE__*/React.createElement(LayoutColumnMenu, {
|
|
274
|
+
api: api
|
|
275
|
+
}) : null);
|
|
276
|
+
},
|
|
277
|
+
getSharedState: function getSharedState(editorState) {
|
|
278
|
+
if (!editorState) {
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
return pluginKey.getState(editorState);
|
|
282
|
+
},
|
|
283
|
+
commands: {
|
|
284
|
+
toggleLayoutColumnMenu: toggleLayoutColumnMenu
|
|
272
285
|
}
|
|
273
286
|
};
|
|
274
287
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
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
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE,
|
|
4
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, LAYOUT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
6
6
|
import { flatmap, getStepRange, isEmptyDocument, mapChildren } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -538,4 +538,15 @@ var formatLayoutName = function formatLayoutName(layout) {
|
|
|
538
538
|
case 'three_with_sidebars':
|
|
539
539
|
return LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
540
540
|
}
|
|
541
|
+
};
|
|
542
|
+
export var toggleLayoutColumnMenu = function toggleLayoutColumnMenu(_ref4) {
|
|
543
|
+
var isOpen = _ref4.isOpen;
|
|
544
|
+
return function (_ref5) {
|
|
545
|
+
var tr = _ref5.tr;
|
|
546
|
+
tr.setMeta('toggleLayoutColumnMenu', {
|
|
547
|
+
isOpen: isOpen
|
|
548
|
+
});
|
|
549
|
+
tr.setMeta('scrollIntoView', false);
|
|
550
|
+
return tr;
|
|
551
|
+
};
|
|
541
552
|
};
|
|
@@ -65,7 +65,8 @@ var getInitialPluginState = function getInitialPluginState(options, state) {
|
|
|
65
65
|
addSidebarLayouts: addSidebarLayouts,
|
|
66
66
|
selectedLayout: selectedLayout,
|
|
67
67
|
allowSingleColumnLayout: allowSingleColumnLayout,
|
|
68
|
-
isResizing: false
|
|
68
|
+
isResizing: false,
|
|
69
|
+
isLayoutColumnMenuOpen: false
|
|
69
70
|
};
|
|
70
71
|
};
|
|
71
72
|
|
|
@@ -114,11 +115,15 @@ export default (function (options) {
|
|
|
114
115
|
return getInitialPluginState(options, state);
|
|
115
116
|
},
|
|
116
117
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
117
|
-
var _tr$getMeta, _pluginKey$getState;
|
|
118
|
+
var _columnMenuMeta$isOpe, _tr$getMeta, _pluginKey$getState;
|
|
119
|
+
var columnMenuMeta = tr.getMeta('toggleLayoutColumnMenu');
|
|
120
|
+
var nextPluginState = columnMenuMeta ? _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
121
|
+
isLayoutColumnMenuOpen: (_columnMenuMeta$isOpe = columnMenuMeta.isOpen) !== null && _columnMenuMeta$isOpe !== void 0 ? _columnMenuMeta$isOpe : !pluginState.isLayoutColumnMenuOpen
|
|
122
|
+
}) : pluginState;
|
|
118
123
|
var isResizing = editorExperiment('single_column_layouts', true) ? (_tr$getMeta = tr.getMeta('is-resizer-resizing')) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : (_pluginKey$getState = pluginKey.getState(oldState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.isResizing : false;
|
|
119
124
|
if (tr.docChanged || tr.selectionSet) {
|
|
120
125
|
var maybeLayoutSection = getMaybeLayoutSection(newState);
|
|
121
|
-
var newPluginState = _objectSpread(_objectSpread({},
|
|
126
|
+
var newPluginState = _objectSpread(_objectSpread({}, nextPluginState), {}, {
|
|
122
127
|
pos: maybeLayoutSection ? maybeLayoutSection.pos : null,
|
|
123
128
|
isResizing: isResizing,
|
|
124
129
|
selectedLayout: getSelectedLayout(maybeLayoutSection && maybeLayoutSection.node,
|
|
@@ -128,7 +133,7 @@ export default (function (options) {
|
|
|
128
133
|
});
|
|
129
134
|
return newPluginState;
|
|
130
135
|
}
|
|
131
|
-
return _objectSpread(_objectSpread({},
|
|
136
|
+
return _objectSpread(_objectSpread({}, nextPluginState), {}, {
|
|
132
137
|
isResizing: isResizing
|
|
133
138
|
});
|
|
134
139
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
export var LayoutColumnMenu = function LayoutColumnMenu(_ref) {
|
|
4
|
+
var api = _ref.api;
|
|
5
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['layout'], function (states) {
|
|
6
|
+
var _states$layoutState$i, _states$layoutState;
|
|
7
|
+
return {
|
|
8
|
+
isLayoutColumnMenuOpen: (_states$layoutState$i = (_states$layoutState = states.layoutState) === null || _states$layoutState === void 0 ? void 0 : _states$layoutState.isLayoutColumnMenuOpen) !== null && _states$layoutState$i !== void 0 ? _states$layoutState$i : false
|
|
9
|
+
};
|
|
10
|
+
}),
|
|
11
|
+
isLayoutColumnMenuOpen = _useSharedPluginState.isLayoutColumnMenuOpen;
|
|
12
|
+
if (!isLayoutColumnMenuOpen) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
var placeholder = 'Mock Layout Column Menu';
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", null, placeholder);
|
|
17
|
+
};
|
|
@@ -8,7 +8,8 @@ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
|
|
|
8
8
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
11
|
-
import type { insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
11
|
+
import type { insertLayoutColumnsWithAnalytics, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
12
|
+
import type { LayoutState } from './pm-plugins/types';
|
|
12
13
|
import type { LayoutPluginOptions } from './types';
|
|
13
14
|
export type LayoutPluginDependencies = [
|
|
14
15
|
DecorationsPlugin,
|
|
@@ -25,6 +26,10 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
25
26
|
actions: {
|
|
26
27
|
insertLayoutColumns: ReturnType<typeof insertLayoutColumnsWithAnalytics>;
|
|
27
28
|
};
|
|
29
|
+
commands: {
|
|
30
|
+
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
31
|
+
};
|
|
28
32
|
dependencies: LayoutPluginDependencies;
|
|
29
33
|
pluginConfiguration: LayoutPluginOptions | undefined;
|
|
34
|
+
sharedState: LayoutState | undefined;
|
|
30
35
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Command, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Command, EditorCommand, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import type { Change, PresetLayout } from '../types';
|
|
@@ -26,3 +26,6 @@ export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI |
|
|
|
26
26
|
export declare const fixColumnSizes: (changedTr: Transaction, state: EditorState) => Change | undefined;
|
|
27
27
|
export declare const fixColumnStructure: (state: EditorState) => Transaction | undefined;
|
|
28
28
|
export declare const deleteActiveLayoutNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, inputMethod?: INPUT_METHOD.FLOATING_TB) => Command;
|
|
29
|
+
export declare const toggleLayoutColumnMenu: ({ isOpen }: {
|
|
30
|
+
isOpen?: boolean;
|
|
31
|
+
}) => EditorCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
+
type LayoutColumnMenuProps = {
|
|
5
|
+
api: ExtractInjectionAPI<LayoutPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const LayoutColumnMenu: ({ api }: LayoutColumnMenuProps) => React.JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -8,7 +8,8 @@ import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
|
|
|
8
8
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
9
9
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
10
10
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
11
|
-
import type { insertLayoutColumnsWithAnalytics } from './pm-plugins/actions';
|
|
11
|
+
import type { insertLayoutColumnsWithAnalytics, toggleLayoutColumnMenu } from './pm-plugins/actions';
|
|
12
|
+
import type { LayoutState } from './pm-plugins/types';
|
|
12
13
|
import type { LayoutPluginOptions } from './types';
|
|
13
14
|
export type LayoutPluginDependencies = [
|
|
14
15
|
DecorationsPlugin,
|
|
@@ -25,6 +26,10 @@ export type LayoutPlugin = NextEditorPlugin<'layout', {
|
|
|
25
26
|
actions: {
|
|
26
27
|
insertLayoutColumns: ReturnType<typeof insertLayoutColumnsWithAnalytics>;
|
|
27
28
|
};
|
|
29
|
+
commands: {
|
|
30
|
+
toggleLayoutColumnMenu: typeof toggleLayoutColumnMenu;
|
|
31
|
+
};
|
|
28
32
|
dependencies: LayoutPluginDependencies;
|
|
29
33
|
pluginConfiguration: LayoutPluginOptions | undefined;
|
|
34
|
+
sharedState: LayoutState | undefined;
|
|
30
35
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import type { Command, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { Command, EditorCommand, TOOLBAR_MENU_TYPE } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import type { Change, PresetLayout } from '../types';
|
|
@@ -26,3 +26,6 @@ export declare const setPresetLayout: (editorAnalyticsAPI: EditorAnalyticsAPI |
|
|
|
26
26
|
export declare const fixColumnSizes: (changedTr: Transaction, state: EditorState) => Change | undefined;
|
|
27
27
|
export declare const fixColumnStructure: (state: EditorState) => Transaction | undefined;
|
|
28
28
|
export declare const deleteActiveLayoutNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, inputMethod?: INPUT_METHOD.FLOATING_TB) => Command;
|
|
29
|
+
export declare const toggleLayoutColumnMenu: ({ isOpen }: {
|
|
30
|
+
isOpen?: boolean;
|
|
31
|
+
}) => EditorCommand;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { LayoutPlugin } from '../../layoutPluginType';
|
|
4
|
+
type LayoutColumnMenuProps = {
|
|
5
|
+
api: ExtractInjectionAPI<LayoutPlugin> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const LayoutColumnMenu: ({ api }: LayoutColumnMenuProps) => React.JSX.Element | null;
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-layout",
|
|
3
|
-
"version": "10.0
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Layout plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"@atlaskit/icon": "^34.4.0",
|
|
47
47
|
"@atlaskit/icon-lab": "^6.7.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^77.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^77.3.0",
|
|
50
50
|
"@atlaskit/tokens": "^13.0.0",
|
|
51
51
|
"@babel/runtime": "^7.0.0",
|
|
52
52
|
"@emotion/react": "^11.7.1",
|
|
53
53
|
"bind-event-listener": "^3.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^114.
|
|
56
|
+
"@atlaskit/editor-common": "^114.26.0",
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
59
59
|
},
|