@atlaskit/editor-plugin-insert-block 3.1.1 → 3.1.3
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,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 3.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#132166](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/132166)
|
|
14
|
+
[`e1c6dcf47a8a2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e1c6dcf47a8a2) -
|
|
15
|
+
ED-24538 Clean up platform_editor_basic_text_transformations
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.1.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -10,21 +10,16 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _elementBrowser = require("@atlaskit/editor-common/element-browser");
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
|
-
var _insert = require("@atlaskit/editor-common/insert");
|
|
14
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
13
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
16
14
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
17
15
|
var _types = require("@atlaskit/editor-common/types");
|
|
18
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
16
|
var _consts = require("@atlaskit/editor-plugin-block-type/consts");
|
|
20
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
22
19
|
var _elementBrowser2 = require("./pm-plugins/elementBrowser");
|
|
23
20
|
var _toggleInsertBlock = require("./pm-plugins/toggleInsertBlock");
|
|
24
|
-
var _switch = _interopRequireDefault(require("./ui/assets/switch"));
|
|
25
21
|
var _ElementRail = require("./ui/ElementRail");
|
|
26
22
|
var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
|
|
27
|
-
var _transformOptions = require("./ui/transformOptions");
|
|
28
23
|
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); }
|
|
29
24
|
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; }
|
|
30
25
|
// Ignored via go/ees005
|
|
@@ -229,65 +224,7 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
|
|
|
229
224
|
});
|
|
230
225
|
return plugins;
|
|
231
226
|
},
|
|
232
|
-
pluginsOptions: {
|
|
233
|
-
// This is added for basic text transformations experiment.
|
|
234
|
-
// This may not be the most ideal plugin to add this to, but it is suitable for experiment purpose
|
|
235
|
-
// as relevant plugin dependencies are already set up.
|
|
236
|
-
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
237
|
-
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3931754727/Experiment+Elements+Basic+Text+Transformations
|
|
238
|
-
selectionToolbar: function selectionToolbar(state, intl) {
|
|
239
|
-
var _api$featureFlags;
|
|
240
|
-
var isEligible = // basicTextTransformations is used to present AI enablement status to avoid adding editor props
|
|
241
|
-
api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.basicTextTransformations;
|
|
242
|
-
if (!isEligible) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if ((0, _experiments.editorExperiment)('basic-text-transformations', true, {
|
|
246
|
-
exposure: true
|
|
247
|
-
})) {
|
|
248
|
-
var formatMessage = intl.formatMessage;
|
|
249
|
-
var _options = (0, _transformOptions.transformationOptions)(api, state.schema).map(function (option) {
|
|
250
|
-
var canWrap;
|
|
251
|
-
if (option.type.name === 'codeBlock') {
|
|
252
|
-
var _$from$node;
|
|
253
|
-
var $from = state.selection.$from;
|
|
254
|
-
var grandParentNodeType = (_$from$node = $from.node(-1)) === null || _$from$node === void 0 ? void 0 : _$from$node.type;
|
|
255
|
-
var parentNodeType = $from.parent.type;
|
|
256
|
-
canWrap = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
|
|
257
|
-
parentNodeType: parentNodeType,
|
|
258
|
-
grandParentNodeType: grandParentNodeType,
|
|
259
|
-
content: option.type.createAndFill()
|
|
260
|
-
}) && (0, _insert.contentAllowedInCodeBlock)(state);
|
|
261
|
-
} else {
|
|
262
|
-
canWrap = !!(0, _utils.getWrappingOptions)(state, option.type).wrapping;
|
|
263
|
-
}
|
|
264
|
-
var IconBefore = option.icon;
|
|
265
|
-
return {
|
|
266
|
-
title: formatMessage(option.title),
|
|
267
|
-
icon: /*#__PURE__*/_react.default.createElement(IconBefore, {
|
|
268
|
-
label: "",
|
|
269
|
-
disabled: !canWrap
|
|
270
|
-
}),
|
|
271
|
-
disabled: !canWrap,
|
|
272
|
-
onClick: function onClick(state, dispatch) {
|
|
273
|
-
var _option$command;
|
|
274
|
-
(_option$command = option.command) === null || _option$command === void 0 || _option$command.call(option, _analytics.INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
});
|
|
279
|
-
return {
|
|
280
|
-
items: [{
|
|
281
|
-
type: 'dropdown',
|
|
282
|
-
title: formatMessage(_messages.toolbarInsertBlockMessages.turnInto),
|
|
283
|
-
iconBefore: _switch.default,
|
|
284
|
-
options: _options
|
|
285
|
-
}],
|
|
286
|
-
rank: -9
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
},
|
|
227
|
+
pluginsOptions: {},
|
|
291
228
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
292
229
|
};
|
|
293
230
|
if (
|
|
@@ -2,23 +2,18 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
-
import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
6
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
8
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
7
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
10
|
-
import { getWrappingOptions } from '@atlaskit/editor-common/utils';
|
|
11
8
|
import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
|
|
12
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
11
|
import { elementBrowserPmKey, elementBrowserPmPlugin } from './pm-plugins/elementBrowser';
|
|
15
12
|
import { toggleInsertBlockPmKey, toggleInsertBlockPmPlugin } from './pm-plugins/toggleInsertBlock';
|
|
16
|
-
import SwitchIcon from './ui/assets/switch';
|
|
17
13
|
import { InsertMenuRail } from './ui/ElementRail';
|
|
18
14
|
// Ignored via go/ees005
|
|
19
15
|
// eslint-disable-next-line import/no-named-as-default
|
|
20
16
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
21
|
-
import { transformationOptions } from './ui/transformOptions';
|
|
22
17
|
export const toolbarSizeToButtons = (toolbarSize, appearance) => {
|
|
23
18
|
// Different button numbers for full-page to better match full page toolbar breakpoints
|
|
24
19
|
if (appearance === 'full-page' && fg('platform_editor_toolbar_responsive_fixes')) {
|
|
@@ -210,69 +205,7 @@ export const insertBlockPlugin = ({
|
|
|
210
205
|
});
|
|
211
206
|
return plugins;
|
|
212
207
|
},
|
|
213
|
-
pluginsOptions: {
|
|
214
|
-
// This is added for basic text transformations experiment.
|
|
215
|
-
// This may not be the most ideal plugin to add this to, but it is suitable for experiment purpose
|
|
216
|
-
// as relevant plugin dependencies are already set up.
|
|
217
|
-
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
218
|
-
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3931754727/Experiment+Elements+Basic+Text+Transformations
|
|
219
|
-
selectionToolbar: (state, intl) => {
|
|
220
|
-
var _api$featureFlags, _api$featureFlags$sha;
|
|
221
|
-
const isEligible = // basicTextTransformations is used to present AI enablement status to avoid adding editor props
|
|
222
|
-
api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : (_api$featureFlags$sha = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags$sha === void 0 ? void 0 : _api$featureFlags$sha.basicTextTransformations;
|
|
223
|
-
if (!isEligible) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (editorExperiment('basic-text-transformations', true, {
|
|
227
|
-
exposure: true
|
|
228
|
-
})) {
|
|
229
|
-
const {
|
|
230
|
-
formatMessage
|
|
231
|
-
} = intl;
|
|
232
|
-
const options = transformationOptions(api, state.schema).map(option => {
|
|
233
|
-
let canWrap;
|
|
234
|
-
if (option.type.name === 'codeBlock') {
|
|
235
|
-
var _$from$node;
|
|
236
|
-
const {
|
|
237
|
-
$from
|
|
238
|
-
} = state.selection;
|
|
239
|
-
const grandParentNodeType = (_$from$node = $from.node(-1)) === null || _$from$node === void 0 ? void 0 : _$from$node.type;
|
|
240
|
-
const parentNodeType = $from.parent.type;
|
|
241
|
-
canWrap = shouldSplitSelectedNodeOnNodeInsertion({
|
|
242
|
-
parentNodeType,
|
|
243
|
-
grandParentNodeType,
|
|
244
|
-
content: option.type.createAndFill()
|
|
245
|
-
}) && contentAllowedInCodeBlock(state);
|
|
246
|
-
} else {
|
|
247
|
-
canWrap = !!getWrappingOptions(state, option.type).wrapping;
|
|
248
|
-
}
|
|
249
|
-
const IconBefore = option.icon;
|
|
250
|
-
return {
|
|
251
|
-
title: formatMessage(option.title),
|
|
252
|
-
icon: /*#__PURE__*/React.createElement(IconBefore, {
|
|
253
|
-
label: "",
|
|
254
|
-
disabled: !canWrap
|
|
255
|
-
}),
|
|
256
|
-
disabled: !canWrap,
|
|
257
|
-
onClick: (state, dispatch) => {
|
|
258
|
-
var _option$command;
|
|
259
|
-
(_option$command = option.command) === null || _option$command === void 0 ? void 0 : _option$command.call(option, INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
260
|
-
return true;
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
});
|
|
264
|
-
return {
|
|
265
|
-
items: [{
|
|
266
|
-
type: 'dropdown',
|
|
267
|
-
title: formatMessage(messages.turnInto),
|
|
268
|
-
iconBefore: SwitchIcon,
|
|
269
|
-
options
|
|
270
|
-
}],
|
|
271
|
-
rank: -9
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
},
|
|
208
|
+
pluginsOptions: {},
|
|
276
209
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
277
210
|
};
|
|
278
211
|
if (
|
|
@@ -2,23 +2,18 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ElementBrowser } from '@atlaskit/editor-common/element-browser';
|
|
4
4
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
-
import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
6
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
8
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
7
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
10
|
-
import { getWrappingOptions } from '@atlaskit/editor-common/utils';
|
|
11
8
|
import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
|
|
12
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
10
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
11
|
import { elementBrowserPmKey, elementBrowserPmPlugin } from './pm-plugins/elementBrowser';
|
|
15
12
|
import { toggleInsertBlockPmKey, toggleInsertBlockPmPlugin } from './pm-plugins/toggleInsertBlock';
|
|
16
|
-
import SwitchIcon from './ui/assets/switch';
|
|
17
13
|
import { InsertMenuRail } from './ui/ElementRail';
|
|
18
14
|
// Ignored via go/ees005
|
|
19
15
|
// eslint-disable-next-line import/no-named-as-default
|
|
20
16
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
21
|
-
import { transformationOptions } from './ui/transformOptions';
|
|
22
17
|
export var toolbarSizeToButtons = function toolbarSizeToButtons(toolbarSize, appearance) {
|
|
23
18
|
// Different button numbers for full-page to better match full page toolbar breakpoints
|
|
24
19
|
if (appearance === 'full-page' && fg('platform_editor_toolbar_responsive_fixes')) {
|
|
@@ -218,65 +213,7 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
218
213
|
});
|
|
219
214
|
return plugins;
|
|
220
215
|
},
|
|
221
|
-
pluginsOptions: {
|
|
222
|
-
// This is added for basic text transformations experiment.
|
|
223
|
-
// This may not be the most ideal plugin to add this to, but it is suitable for experiment purpose
|
|
224
|
-
// as relevant plugin dependencies are already set up.
|
|
225
|
-
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
226
|
-
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3931754727/Experiment+Elements+Basic+Text+Transformations
|
|
227
|
-
selectionToolbar: function selectionToolbar(state, intl) {
|
|
228
|
-
var _api$featureFlags;
|
|
229
|
-
var isEligible = // basicTextTransformations is used to present AI enablement status to avoid adding editor props
|
|
230
|
-
api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 || (_api$featureFlags = _api$featureFlags.sharedState.currentState()) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.basicTextTransformations;
|
|
231
|
-
if (!isEligible) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
if (editorExperiment('basic-text-transformations', true, {
|
|
235
|
-
exposure: true
|
|
236
|
-
})) {
|
|
237
|
-
var formatMessage = intl.formatMessage;
|
|
238
|
-
var _options = transformationOptions(api, state.schema).map(function (option) {
|
|
239
|
-
var canWrap;
|
|
240
|
-
if (option.type.name === 'codeBlock') {
|
|
241
|
-
var _$from$node;
|
|
242
|
-
var $from = state.selection.$from;
|
|
243
|
-
var grandParentNodeType = (_$from$node = $from.node(-1)) === null || _$from$node === void 0 ? void 0 : _$from$node.type;
|
|
244
|
-
var parentNodeType = $from.parent.type;
|
|
245
|
-
canWrap = shouldSplitSelectedNodeOnNodeInsertion({
|
|
246
|
-
parentNodeType: parentNodeType,
|
|
247
|
-
grandParentNodeType: grandParentNodeType,
|
|
248
|
-
content: option.type.createAndFill()
|
|
249
|
-
}) && contentAllowedInCodeBlock(state);
|
|
250
|
-
} else {
|
|
251
|
-
canWrap = !!getWrappingOptions(state, option.type).wrapping;
|
|
252
|
-
}
|
|
253
|
-
var IconBefore = option.icon;
|
|
254
|
-
return {
|
|
255
|
-
title: formatMessage(option.title),
|
|
256
|
-
icon: /*#__PURE__*/React.createElement(IconBefore, {
|
|
257
|
-
label: "",
|
|
258
|
-
disabled: !canWrap
|
|
259
|
-
}),
|
|
260
|
-
disabled: !canWrap,
|
|
261
|
-
onClick: function onClick(state, dispatch) {
|
|
262
|
-
var _option$command;
|
|
263
|
-
(_option$command = option.command) === null || _option$command === void 0 || _option$command.call(option, INPUT_METHOD.FLOATING_TB)(state, dispatch);
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
});
|
|
268
|
-
return {
|
|
269
|
-
items: [{
|
|
270
|
-
type: 'dropdown',
|
|
271
|
-
title: formatMessage(messages.turnInto),
|
|
272
|
-
iconBefore: SwitchIcon,
|
|
273
|
-
options: _options
|
|
274
|
-
}],
|
|
275
|
-
rank: -9
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
},
|
|
216
|
+
pluginsOptions: {},
|
|
280
217
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
281
218
|
};
|
|
282
219
|
if (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/button": "^
|
|
36
|
+
"@atlaskit/button": "^22.0.0",
|
|
37
37
|
"@atlaskit/editor-common": "^102.13.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-block-type": "^5.1.0",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
65
65
|
"@atlaskit/emoji": "^69.0.0",
|
|
66
66
|
"@atlaskit/heading": "^5.1.0",
|
|
67
|
-
"@atlaskit/icon": "^25.
|
|
68
|
-
"@atlaskit/icon-lab": "^4.
|
|
67
|
+
"@atlaskit/icon": "^25.2.0",
|
|
68
|
+
"@atlaskit/icon-lab": "^4.5.0",
|
|
69
69
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
70
70
|
"@atlaskit/primitives": "^14.2.0",
|
|
71
71
|
"@atlaskit/theme": "^18.0.0",
|
|
72
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
72
|
+
"@atlaskit/tmp-editor-statsig": "^4.4.0",
|
|
73
73
|
"@atlaskit/tokens": "^4.5.0",
|
|
74
74
|
"@atlaskit/tooltip": "^20.0.0",
|
|
75
75
|
"@babel/runtime": "^7.0.0",
|