@atlaskit/editor-plugin-panel 5.2.4 → 5.2.5
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 +13 -0
- package/dist/cjs/editor-actions/actions.js +11 -3
- package/dist/cjs/panelPlugin.js +16 -4
- package/dist/cjs/pm-plugins/utils/utils.js +3 -1
- package/dist/es2019/editor-actions/actions.js +12 -4
- package/dist/es2019/panelPlugin.js +17 -5
- package/dist/es2019/pm-plugins/utils/utils.js +5 -2
- package/dist/esm/editor-actions/actions.js +12 -4
- package/dist/esm/panelPlugin.js +17 -5
- package/dist/esm/pm-plugins/utils/utils.js +4 -2
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-panel
|
|
2
2
|
|
|
3
|
+
## 5.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#195353](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195353)
|
|
8
|
+
[`dc5e7898ce269`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dc5e7898ce269) -
|
|
9
|
+
EDITOR-1104 Replace panel with panelWithLocalId behind platform_editor_adf_with_localid feature
|
|
10
|
+
gate.
|
|
11
|
+
- [#195649](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195649)
|
|
12
|
+
[`231bb33e06dfe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/231bb33e06dfe) -
|
|
13
|
+
EDITOR-1131 Bump adf-schema version to 50.2.0
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 5.2.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -15,6 +15,7 @@ var _panel = require("@atlaskit/editor-common/panel");
|
|
|
15
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
16
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
17
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
19
|
var _utils3 = require("../pm-plugins/utils/utils");
|
|
19
20
|
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
21
|
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; }
|
|
@@ -51,6 +52,7 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
|
|
|
51
52
|
var panelOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
52
53
|
var allowCustomPanel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
53
54
|
return function (state, dispatch) {
|
|
55
|
+
var _panelNode$node$attrs;
|
|
54
56
|
var nodes = state.schema.nodes,
|
|
55
57
|
tr = state.tr;
|
|
56
58
|
var panelNode = (0, _utils3.findPanel)(state);
|
|
@@ -60,6 +62,7 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
|
|
|
60
62
|
var newType = panelType;
|
|
61
63
|
var previousType = panelNode.node.attrs.panelType;
|
|
62
64
|
var newTr;
|
|
65
|
+
var localId = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? ((_panelNode$node$attrs = panelNode.node.attrs) === null || _panelNode$node$attrs === void 0 ? void 0 : _panelNode$node$attrs.localId) || _adfSchema.uuid.generate() : undefined;
|
|
63
66
|
if (allowCustomPanel) {
|
|
64
67
|
var previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : (0, _panel.getPanelTypeBackgroundNoTokens)(previousType);
|
|
65
68
|
var previousIcon = panelNode.node.attrs.panelIcon;
|
|
@@ -76,11 +79,13 @@ var changePanelType = exports.changePanelType = function changePanelType(editorA
|
|
|
76
79
|
panelIconId: newPanelOptions.emojiId,
|
|
77
80
|
panelIconText: newPanelOptions.emojiText,
|
|
78
81
|
panelColor: newPanelOptions.color,
|
|
79
|
-
panelType: panelType
|
|
82
|
+
panelType: panelType,
|
|
83
|
+
localId: localId
|
|
80
84
|
});
|
|
81
85
|
} else {
|
|
82
86
|
newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
|
|
83
|
-
panelType: panelType
|
|
87
|
+
panelType: panelType,
|
|
88
|
+
localId: localId
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
91
|
var payload = {
|
|
@@ -117,7 +122,10 @@ function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
117
122
|
})(function (state, dispatch) {
|
|
118
123
|
var nodes = state.schema.nodes;
|
|
119
124
|
if (nodes.panel && nodes.paragraph) {
|
|
120
|
-
|
|
125
|
+
var panelAttrs = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? {
|
|
126
|
+
localId: _adfSchema.uuid.generate()
|
|
127
|
+
} : {};
|
|
128
|
+
return (0, _utils.wrapSelectionIn)(nodes.panel, panelAttrs)(state, dispatch);
|
|
121
129
|
}
|
|
122
130
|
return false;
|
|
123
131
|
});
|
package/dist/cjs/panelPlugin.js
CHANGED
|
@@ -5,18 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
13
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
13
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
15
17
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
18
|
var _actions = require("./editor-actions/actions");
|
|
17
19
|
var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
|
|
18
20
|
var _main = require("./pm-plugins/main");
|
|
19
21
|
var _toolbar = require("./ui/toolbar");
|
|
22
|
+
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
|
+
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; }
|
|
20
24
|
var panelPlugin = function panelPlugin(_ref) {
|
|
21
25
|
var _ref$config = _ref.config,
|
|
22
26
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
@@ -24,10 +28,15 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
24
28
|
return {
|
|
25
29
|
name: 'panel',
|
|
26
30
|
nodes: function nodes() {
|
|
27
|
-
|
|
31
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid')) {
|
|
32
|
+
return [{
|
|
33
|
+
name: 'panel',
|
|
34
|
+
node: (0, _adfSchema.extendedPanelWithLocalId)(!!options.allowCustomPanel)
|
|
35
|
+
}];
|
|
36
|
+
}
|
|
28
37
|
return [{
|
|
29
38
|
name: 'panel',
|
|
30
|
-
node:
|
|
39
|
+
node: (0, _adfSchema.extendedPanel)(!!options.allowCustomPanel)
|
|
31
40
|
}];
|
|
32
41
|
},
|
|
33
42
|
pmPlugins: function pmPlugins() {
|
|
@@ -228,6 +237,9 @@ function createPanelAction(_ref4) {
|
|
|
228
237
|
insert = _ref4.insert;
|
|
229
238
|
var panel = state.schema.nodes.panel;
|
|
230
239
|
var tr;
|
|
240
|
+
var panelAttrs = (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _objectSpread(_objectSpread({}, attributes), {}, {
|
|
241
|
+
localId: attributes.localId || _adfSchema.uuid.generate()
|
|
242
|
+
}) : _objectSpread({}, attributes);
|
|
231
243
|
|
|
232
244
|
// Panels should wrap content by default when inserted, the quickInsert `insert` method
|
|
233
245
|
// will insert the node on a newline
|
|
@@ -235,10 +247,10 @@ function createPanelAction(_ref4) {
|
|
|
235
247
|
tr = state.selection.empty && (0, _utils.createWrapSelectionTransaction)({
|
|
236
248
|
state: state,
|
|
237
249
|
type: panel,
|
|
238
|
-
nodeAttributes:
|
|
250
|
+
nodeAttributes: panelAttrs
|
|
239
251
|
});
|
|
240
252
|
} else {
|
|
241
|
-
var node = panel.createAndFill(
|
|
253
|
+
var node = panel.createAndFill(panelAttrs);
|
|
242
254
|
if (!node) {
|
|
243
255
|
return false;
|
|
244
256
|
}
|
|
@@ -69,7 +69,9 @@ var handleCut = exports.handleCut = function handleCut(newState, oldState) {
|
|
|
69
69
|
return node.type.name === 'panel';
|
|
70
70
|
})(oldState.tr.selection);
|
|
71
71
|
var clonedPanelNode = oldPanelNode === null || oldPanelNode === void 0 ? void 0 : oldPanelNode.node.copy();
|
|
72
|
-
var newPanelNode = schema.nodes.panel.create(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs),
|
|
72
|
+
var newPanelNode = schema.nodes.panel.create(_objectSpread(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs), (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') && {
|
|
73
|
+
localId: _adfSchema.uuid.generate()
|
|
74
|
+
}), emptyParagraph);
|
|
73
75
|
var endPos = oldState.tr.selection.$from.pos;
|
|
74
76
|
if (oldPanelNode) {
|
|
75
77
|
newTr.insert(oldPanelNode.pos, newPanelNode).setSelection(new _state.TextSelection(newTr.doc.resolve(endPos)));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { PanelType } from '@atlaskit/adf-schema';
|
|
1
|
+
import { PanelType, uuid } from '@atlaskit/adf-schema';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
4
|
import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
|
|
5
5
|
import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { findPanel } from '../pm-plugins/utils/utils';
|
|
9
10
|
export const removePanel = editorAnalyticsAPI => (state, dispatch) => {
|
|
10
11
|
const {
|
|
@@ -37,6 +38,7 @@ export const removePanel = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
37
38
|
return true;
|
|
38
39
|
};
|
|
39
40
|
export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions = {}, allowCustomPanel = false) => (state, dispatch) => {
|
|
41
|
+
var _panelNode$node$attrs;
|
|
40
42
|
const {
|
|
41
43
|
schema: {
|
|
42
44
|
nodes
|
|
@@ -50,6 +52,7 @@ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions =
|
|
|
50
52
|
const newType = panelType;
|
|
51
53
|
const previousType = panelNode.node.attrs.panelType;
|
|
52
54
|
let newTr;
|
|
55
|
+
const localId = fg('platform_editor_adf_with_localid') ? ((_panelNode$node$attrs = panelNode.node.attrs) === null || _panelNode$node$attrs === void 0 ? void 0 : _panelNode$node$attrs.localId) || uuid.generate() : undefined;
|
|
53
56
|
if (allowCustomPanel) {
|
|
54
57
|
const previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : getPanelTypeBackgroundNoTokens(previousType);
|
|
55
58
|
const previousIcon = panelNode.node.attrs.panelIcon;
|
|
@@ -67,11 +70,13 @@ export const changePanelType = editorAnalyticsAPI => (panelType, panelOptions =
|
|
|
67
70
|
panelIconId: newPanelOptions.emojiId,
|
|
68
71
|
panelIconText: newPanelOptions.emojiText,
|
|
69
72
|
panelColor: newPanelOptions.color,
|
|
70
|
-
panelType
|
|
73
|
+
panelType,
|
|
74
|
+
localId
|
|
71
75
|
});
|
|
72
76
|
} else {
|
|
73
77
|
newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
|
|
74
|
-
panelType
|
|
78
|
+
panelType,
|
|
79
|
+
localId
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
const payload = {
|
|
@@ -108,7 +113,10 @@ export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
108
113
|
nodes
|
|
109
114
|
} = state.schema;
|
|
110
115
|
if (nodes.panel && nodes.paragraph) {
|
|
111
|
-
|
|
116
|
+
const panelAttrs = fg('platform_editor_adf_with_localid') ? {
|
|
117
|
+
localId: uuid.generate()
|
|
118
|
+
} : {};
|
|
119
|
+
return wrapSelectionIn(nodes.panel, panelAttrs)(state, dispatch);
|
|
112
120
|
}
|
|
113
121
|
return false;
|
|
114
122
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { extendedPanel, PanelType } from '@atlaskit/adf-schema';
|
|
2
|
+
import { extendedPanel, extendedPanelWithLocalId, PanelType, uuid } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
5
5
|
import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
|
|
6
6
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { T50 } from '@atlaskit/theme/colors';
|
|
8
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
10
|
import { insertPanelWithAnalytics } from './editor-actions/actions';
|
|
@@ -16,10 +17,15 @@ const panelPlugin = ({
|
|
|
16
17
|
}) => ({
|
|
17
18
|
name: 'panel',
|
|
18
19
|
nodes() {
|
|
19
|
-
|
|
20
|
+
if (fg('platform_editor_adf_with_localid')) {
|
|
21
|
+
return [{
|
|
22
|
+
name: 'panel',
|
|
23
|
+
node: extendedPanelWithLocalId(!!options.allowCustomPanel)
|
|
24
|
+
}];
|
|
25
|
+
}
|
|
20
26
|
return [{
|
|
21
27
|
name: 'panel',
|
|
22
|
-
node:
|
|
28
|
+
node: extendedPanel(!!options.allowCustomPanel)
|
|
23
29
|
}];
|
|
24
30
|
},
|
|
25
31
|
pmPlugins() {
|
|
@@ -204,6 +210,12 @@ function createPanelAction({
|
|
|
204
210
|
panel
|
|
205
211
|
} = state.schema.nodes;
|
|
206
212
|
let tr;
|
|
213
|
+
const panelAttrs = fg('platform_editor_adf_with_localid') ? {
|
|
214
|
+
...attributes,
|
|
215
|
+
localId: attributes.localId || uuid.generate()
|
|
216
|
+
} : {
|
|
217
|
+
...attributes
|
|
218
|
+
};
|
|
207
219
|
|
|
208
220
|
// Panels should wrap content by default when inserted, the quickInsert `insert` method
|
|
209
221
|
// will insert the node on a newline
|
|
@@ -211,10 +223,10 @@ function createPanelAction({
|
|
|
211
223
|
tr = state.selection.empty && createWrapSelectionTransaction({
|
|
212
224
|
state,
|
|
213
225
|
type: panel,
|
|
214
|
-
nodeAttributes:
|
|
226
|
+
nodeAttributes: panelAttrs
|
|
215
227
|
});
|
|
216
228
|
} else {
|
|
217
|
-
const node = panel.createAndFill(
|
|
229
|
+
const node = panel.createAndFill(panelAttrs);
|
|
218
230
|
if (!node) {
|
|
219
231
|
return false;
|
|
220
232
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PanelType } from '@atlaskit/adf-schema';
|
|
1
|
+
import { PanelType, uuid } from '@atlaskit/adf-schema';
|
|
2
2
|
import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
3
3
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
4
4
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -65,7 +65,10 @@ export const handleCut = (newState, oldState) => {
|
|
|
65
65
|
const oldPanelNode = findParentNode(node => node.type.name === 'panel')(oldState.tr.selection);
|
|
66
66
|
const clonedPanelNode = oldPanelNode === null || oldPanelNode === void 0 ? void 0 : oldPanelNode.node.copy();
|
|
67
67
|
const newPanelNode = schema.nodes.panel.create({
|
|
68
|
-
...(clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs)
|
|
68
|
+
...(clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs),
|
|
69
|
+
...(fg('platform_editor_adf_with_localid') && {
|
|
70
|
+
localId: uuid.generate()
|
|
71
|
+
})
|
|
69
72
|
}, emptyParagraph);
|
|
70
73
|
const endPos = oldState.tr.selection.$from.pos;
|
|
71
74
|
if (oldPanelNode) {
|
|
@@ -1,13 +1,14 @@
|
|
|
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 { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import { PanelType, uuid } from '@atlaskit/adf-schema';
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
7
7
|
import { getPanelTypeBackgroundNoTokens } from '@atlaskit/editor-common/panel';
|
|
8
8
|
import { wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { findPanel } from '../pm-plugins/utils/utils';
|
|
12
13
|
export var removePanel = function removePanel(editorAnalyticsAPI) {
|
|
13
14
|
return function (state, dispatch) {
|
|
@@ -42,6 +43,7 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
|
|
|
42
43
|
var panelOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
44
|
var allowCustomPanel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
44
45
|
return function (state, dispatch) {
|
|
46
|
+
var _panelNode$node$attrs;
|
|
45
47
|
var nodes = state.schema.nodes,
|
|
46
48
|
tr = state.tr;
|
|
47
49
|
var panelNode = findPanel(state);
|
|
@@ -51,6 +53,7 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
|
|
|
51
53
|
var newType = panelType;
|
|
52
54
|
var previousType = panelNode.node.attrs.panelType;
|
|
53
55
|
var newTr;
|
|
56
|
+
var localId = fg('platform_editor_adf_with_localid') ? ((_panelNode$node$attrs = panelNode.node.attrs) === null || _panelNode$node$attrs === void 0 ? void 0 : _panelNode$node$attrs.localId) || uuid.generate() : undefined;
|
|
54
57
|
if (allowCustomPanel) {
|
|
55
58
|
var previousColor = panelNode.node.attrs.panelType === 'custom' ? panelNode.node.attrs.panelColor || 'none' : getPanelTypeBackgroundNoTokens(previousType);
|
|
56
59
|
var previousIcon = panelNode.node.attrs.panelIcon;
|
|
@@ -67,11 +70,13 @@ export var changePanelType = function changePanelType(editorAnalyticsAPI) {
|
|
|
67
70
|
panelIconId: newPanelOptions.emojiId,
|
|
68
71
|
panelIconText: newPanelOptions.emojiText,
|
|
69
72
|
panelColor: newPanelOptions.color,
|
|
70
|
-
panelType: panelType
|
|
73
|
+
panelType: panelType,
|
|
74
|
+
localId: localId
|
|
71
75
|
});
|
|
72
76
|
} else {
|
|
73
77
|
newTr = tr.setNodeMarkup(panelNode.pos, nodes.panel, {
|
|
74
|
-
panelType: panelType
|
|
78
|
+
panelType: panelType,
|
|
79
|
+
localId: localId
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
var payload = {
|
|
@@ -108,7 +113,10 @@ export function insertPanelWithAnalytics(inputMethod, analyticsAPI) {
|
|
|
108
113
|
})(function (state, dispatch) {
|
|
109
114
|
var nodes = state.schema.nodes;
|
|
110
115
|
if (nodes.panel && nodes.paragraph) {
|
|
111
|
-
|
|
116
|
+
var panelAttrs = fg('platform_editor_adf_with_localid') ? {
|
|
117
|
+
localId: uuid.generate()
|
|
118
|
+
} : {};
|
|
119
|
+
return wrapSelectionIn(nodes.panel, panelAttrs)(state, dispatch);
|
|
112
120
|
}
|
|
113
121
|
return false;
|
|
114
122
|
});
|
package/dist/esm/panelPlugin.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import React from 'react';
|
|
2
|
-
import { extendedPanel, PanelType } from '@atlaskit/adf-schema';
|
|
5
|
+
import { extendedPanel, extendedPanelWithLocalId, PanelType, uuid } from '@atlaskit/adf-schema';
|
|
3
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
7
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
5
8
|
import { IconCustomPanel, IconPanel, IconPanelError, IconPanelNote, IconPanelSuccess, IconPanelWarning } from '@atlaskit/editor-common/quick-insert';
|
|
6
9
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
11
|
import { T50 } from '@atlaskit/theme/colors';
|
|
8
12
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
13
|
import { insertPanelWithAnalytics } from './editor-actions/actions';
|
|
@@ -17,10 +21,15 @@ var panelPlugin = function panelPlugin(_ref) {
|
|
|
17
21
|
return {
|
|
18
22
|
name: 'panel',
|
|
19
23
|
nodes: function nodes() {
|
|
20
|
-
|
|
24
|
+
if (fg('platform_editor_adf_with_localid')) {
|
|
25
|
+
return [{
|
|
26
|
+
name: 'panel',
|
|
27
|
+
node: extendedPanelWithLocalId(!!options.allowCustomPanel)
|
|
28
|
+
}];
|
|
29
|
+
}
|
|
21
30
|
return [{
|
|
22
31
|
name: 'panel',
|
|
23
|
-
node:
|
|
32
|
+
node: extendedPanel(!!options.allowCustomPanel)
|
|
24
33
|
}];
|
|
25
34
|
},
|
|
26
35
|
pmPlugins: function pmPlugins() {
|
|
@@ -221,6 +230,9 @@ function createPanelAction(_ref4) {
|
|
|
221
230
|
insert = _ref4.insert;
|
|
222
231
|
var panel = state.schema.nodes.panel;
|
|
223
232
|
var tr;
|
|
233
|
+
var panelAttrs = fg('platform_editor_adf_with_localid') ? _objectSpread(_objectSpread({}, attributes), {}, {
|
|
234
|
+
localId: attributes.localId || uuid.generate()
|
|
235
|
+
}) : _objectSpread({}, attributes);
|
|
224
236
|
|
|
225
237
|
// Panels should wrap content by default when inserted, the quickInsert `insert` method
|
|
226
238
|
// will insert the node on a newline
|
|
@@ -228,10 +240,10 @@ function createPanelAction(_ref4) {
|
|
|
228
240
|
tr = state.selection.empty && createWrapSelectionTransaction({
|
|
229
241
|
state: state,
|
|
230
242
|
type: panel,
|
|
231
|
-
nodeAttributes:
|
|
243
|
+
nodeAttributes: panelAttrs
|
|
232
244
|
});
|
|
233
245
|
} else {
|
|
234
|
-
var node = panel.createAndFill(
|
|
246
|
+
var node = panel.createAndFill(panelAttrs);
|
|
235
247
|
if (!node) {
|
|
236
248
|
return false;
|
|
237
249
|
}
|
|
@@ -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 { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import { PanelType, uuid } from '@atlaskit/adf-schema';
|
|
5
5
|
import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
6
6
|
import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
7
7
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -62,7 +62,9 @@ export var handleCut = function handleCut(newState, oldState) {
|
|
|
62
62
|
return node.type.name === 'panel';
|
|
63
63
|
})(oldState.tr.selection);
|
|
64
64
|
var clonedPanelNode = oldPanelNode === null || oldPanelNode === void 0 ? void 0 : oldPanelNode.node.copy();
|
|
65
|
-
var newPanelNode = schema.nodes.panel.create(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs),
|
|
65
|
+
var newPanelNode = schema.nodes.panel.create(_objectSpread(_objectSpread({}, clonedPanelNode === null || clonedPanelNode === void 0 ? void 0 : clonedPanelNode.attrs), fg('platform_editor_adf_with_localid') && {
|
|
66
|
+
localId: uuid.generate()
|
|
67
|
+
}), emptyParagraph);
|
|
66
68
|
var endPos = oldState.tr.selection.$from.pos;
|
|
67
69
|
if (oldPanelNode) {
|
|
68
70
|
newTr.insert(oldPanelNode.pos, newPanelNode).setSelection(new TextSelection(newTr.doc.resolve(endPos)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-panel",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.5",
|
|
4
4
|
"description": "Panel plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
".": "./src/index.ts"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@atlaskit/adf-schema": "^50.0
|
|
33
|
+
"@atlaskit/adf-schema": "^50.2.0",
|
|
34
34
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-decorations": "^3.0.0",
|
|
@@ -94,6 +94,9 @@
|
|
|
94
94
|
"platform-feature-flags": {
|
|
95
95
|
"platform_editor_nested_dnd_styles_changes": {
|
|
96
96
|
"type": "boolean"
|
|
97
|
+
},
|
|
98
|
+
"platform_editor_adf_with_localid": {
|
|
99
|
+
"type": "boolean"
|
|
97
100
|
}
|
|
98
101
|
},
|
|
99
102
|
"stricter": {
|