@atlaskit/editor-plugin-code-block 21.0.0 → 21.0.1
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 +10 -0
- package/dist/cjs/codeBlockPlugin.js +15 -18
- package/dist/cjs/pm-plugins/toolbar.js +3 -2
- package/dist/es2019/codeBlockPlugin.js +15 -18
- package/dist/es2019/pm-plugins/toolbar.js +3 -2
- package/dist/esm/codeBlockPlugin.js +15 -18
- package/dist/esm/pm-plugins/toolbar.js +3 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 21.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8d37dc7e55d62`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8d37dc7e55d62) -
|
|
8
|
+
Clean up shipped experiment `platform_editor_block_menu`
|
|
9
|
+
- [`8864ef7070f02`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8864ef7070f02) -
|
|
10
|
+
Use the precise code-block copy accessible name behind platform_editor_a11y_codeblock_copy_name.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 21.0.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -16,7 +16,6 @@ var _assets = require("@atlaskit/editor-common/assets");
|
|
|
16
16
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
17
17
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
18
18
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
19
|
-
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
20
19
|
var _editorCommands = require("./editor-commands");
|
|
21
20
|
var _autoDetect = require("./pm-plugins/auto-detect");
|
|
22
21
|
var _codeBlockAutoFullStopTransformPlugin = require("./pm-plugins/codeBlockAutoFullStopTransformPlugin");
|
|
@@ -35,26 +34,24 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
35
34
|
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; }
|
|
36
35
|
var CODE_BLOCK_NODE_NAME = 'codeBlock';
|
|
37
36
|
var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
37
|
+
var _api$blockMenu;
|
|
38
38
|
var options = _ref.config,
|
|
39
39
|
api = _ref.api;
|
|
40
40
|
var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}]);
|
|
57
|
-
}
|
|
41
|
+
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
|
|
42
|
+
type: 'block-menu-item',
|
|
43
|
+
key: _blockMenu.TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key,
|
|
44
|
+
parent: {
|
|
45
|
+
type: 'block-menu-section',
|
|
46
|
+
key: _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
47
|
+
rank: _blockMenu.TRANSFORM_STRUCTURE_MENU_SECTION_RANK[_blockMenu.TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key]
|
|
48
|
+
},
|
|
49
|
+
component: (0, _CodeBlockMenuItem.createCodeBlockMenuItem)(api),
|
|
50
|
+
isHidden: function isHidden() {
|
|
51
|
+
var _api$blockMenu2;
|
|
52
|
+
return Boolean(api === null || api === void 0 || (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(CODE_BLOCK_NODE_NAME));
|
|
53
|
+
}
|
|
54
|
+
}]);
|
|
58
55
|
if (isRegisteredSlashCommandEnabled) {
|
|
59
56
|
var _api$uiControlRegistr;
|
|
60
57
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getCodeBlockQuickInsertComponents.getCodeBlockQuickInsertComponents)({
|
|
@@ -19,6 +19,7 @@ var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
|
19
19
|
var _listNumbered = _interopRequireDefault(require("@atlaskit/icon/core/list-numbered"));
|
|
20
20
|
var _textWrap = _interopRequireDefault(require("@atlaskit/icon/core/text-wrap"));
|
|
21
21
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
22
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
22
23
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
24
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
24
25
|
var _editorCommands = require("../editor-commands");
|
|
@@ -188,7 +189,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
188
189
|
// note: copyContentToClipboardWithAnalytics contains logic that also removes the
|
|
189
190
|
// visual feedback for the copy button
|
|
190
191
|
onClick: (0, _editorCommands.copyContentToClipboardWithAnalytics)(editorAnalyticsAPI),
|
|
191
|
-
title: formatMessage(codeBlockState.contentCopied ? _messages.codeBlockButtonMessages.copiedCodeToClipboard : _messages.codeBlockButtonMessages.copyCodeToClipboard),
|
|
192
|
+
title: formatMessage(codeBlockState.contentCopied ? _messages.codeBlockButtonMessages.copiedCodeToClipboard : (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_a11y_codeblock_copy_name') ? _messages.codeBlockButtonMessages.copyCodeSnippetToClipboard : _messages.codeBlockButtonMessages.copyCodeToClipboard),
|
|
192
193
|
onMouseEnter: _codeBlockCopySelectionPlugin.provideVisualFeedbackForCopyButton,
|
|
193
194
|
// note: resetCopiedState contains logic that also removes the
|
|
194
195
|
// visual feedback for the copy button
|
|
@@ -214,7 +215,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
214
215
|
}];
|
|
215
216
|
if (allowCopyToClipboard) {
|
|
216
217
|
overflowMenuOptions.unshift({
|
|
217
|
-
title: formatMessage(_messages.default.copyToClipboard),
|
|
218
|
+
title: formatMessage((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_a11y_codeblock_copy_name') ? _messages.codeBlockButtonMessages.copyCodeSnippetToClipboard : _messages.default.copyToClipboard),
|
|
218
219
|
onClick: (0, _editorCommands.copyContentToClipboardWithAnalytics)(editorAnalyticsAPI),
|
|
219
220
|
icon: (0, _copy.default)({
|
|
220
221
|
label: ''
|
|
@@ -7,7 +7,6 @@ import { IconCode } from '@atlaskit/editor-common/assets';
|
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
9
9
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
10
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
11
10
|
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
|
|
12
11
|
import { createAutoDetectPlugin } from './pm-plugins/auto-detect';
|
|
13
12
|
import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
|
|
@@ -27,24 +26,22 @@ const codeBlockPlugin = ({
|
|
|
27
26
|
config: options,
|
|
28
27
|
api
|
|
29
28
|
}) => {
|
|
29
|
+
var _api$blockMenu;
|
|
30
30
|
const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}]);
|
|
47
|
-
}
|
|
31
|
+
api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents([{
|
|
32
|
+
type: 'block-menu-item',
|
|
33
|
+
key: TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key,
|
|
34
|
+
parent: {
|
|
35
|
+
type: 'block-menu-section',
|
|
36
|
+
key: TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
37
|
+
rank: TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key]
|
|
38
|
+
},
|
|
39
|
+
component: createCodeBlockMenuItem(api),
|
|
40
|
+
isHidden: () => {
|
|
41
|
+
var _api$blockMenu2;
|
|
42
|
+
return Boolean(api === null || api === void 0 ? void 0 : (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(CODE_BLOCK_NODE_NAME));
|
|
43
|
+
}
|
|
44
|
+
}]);
|
|
48
45
|
if (isRegisteredSlashCommandEnabled) {
|
|
49
46
|
var _api$uiControlRegistr;
|
|
50
47
|
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getCodeBlockQuickInsertComponents({
|
|
@@ -9,6 +9,7 @@ import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
|
9
9
|
import ListNumberedIcon from '@atlaskit/icon/core/list-numbered';
|
|
10
10
|
import TextWrapIcon from '@atlaskit/icon/core/text-wrap';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
12
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
12
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
14
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
14
15
|
import { changeLanguage, copyContentToClipboardWithAnalytics, createFormatCodeOnClick, removeCodeBlockWithAnalytics, resetCopiedState, toggleLineNumbersForCodeBlockNode, toggleWordWrapStateForCodeBlockNode } from '../editor-commands';
|
|
@@ -158,7 +159,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api, overrideLang
|
|
|
158
159
|
// note: copyContentToClipboardWithAnalytics contains logic that also removes the
|
|
159
160
|
// visual feedback for the copy button
|
|
160
161
|
onClick: copyContentToClipboardWithAnalytics(editorAnalyticsAPI),
|
|
161
|
-
title: formatMessage(codeBlockState.contentCopied ? codeBlockButtonMessages.copiedCodeToClipboard : codeBlockButtonMessages.copyCodeToClipboard),
|
|
162
|
+
title: formatMessage(codeBlockState.contentCopied ? codeBlockButtonMessages.copiedCodeToClipboard : isExperimentEnabled('platform_editor_a11y_codeblock_copy_name') ? codeBlockButtonMessages.copyCodeSnippetToClipboard : codeBlockButtonMessages.copyCodeToClipboard),
|
|
162
163
|
onMouseEnter: provideVisualFeedbackForCopyButton,
|
|
163
164
|
// note: resetCopiedState contains logic that also removes the
|
|
164
165
|
// visual feedback for the copy button
|
|
@@ -184,7 +185,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api, overrideLang
|
|
|
184
185
|
}];
|
|
185
186
|
if (allowCopyToClipboard) {
|
|
186
187
|
overflowMenuOptions.unshift({
|
|
187
|
-
title: formatMessage(commonMessages.copyToClipboard),
|
|
188
|
+
title: formatMessage(isExperimentEnabled('platform_editor_a11y_codeblock_copy_name') ? codeBlockButtonMessages.copyCodeSnippetToClipboard : commonMessages.copyToClipboard),
|
|
188
189
|
onClick: copyContentToClipboardWithAnalytics(editorAnalyticsAPI),
|
|
189
190
|
icon: CopyIcon({
|
|
190
191
|
label: ''
|
|
@@ -11,7 +11,6 @@ import { IconCode } from '@atlaskit/editor-common/assets';
|
|
|
11
11
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
13
13
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
14
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/editor-experiment';
|
|
15
14
|
import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
|
|
16
15
|
import { createAutoDetectPlugin } from './pm-plugins/auto-detect';
|
|
17
16
|
import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
|
|
@@ -28,26 +27,24 @@ import { FormatCodeErrorFlag } from './ui/FormatCodeErrorFlag';
|
|
|
28
27
|
import { getCodeBlockQuickInsertComponents } from './ui/quick-insert/getCodeBlockQuickInsertComponents';
|
|
29
28
|
var CODE_BLOCK_NODE_NAME = 'codeBlock';
|
|
30
29
|
var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
30
|
+
var _api$blockMenu;
|
|
31
31
|
var options = _ref.config,
|
|
32
32
|
api = _ref.api;
|
|
33
33
|
var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}]);
|
|
50
|
-
}
|
|
34
|
+
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
|
|
35
|
+
type: 'block-menu-item',
|
|
36
|
+
key: TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key,
|
|
37
|
+
parent: {
|
|
38
|
+
type: 'block-menu-section',
|
|
39
|
+
key: TRANSFORM_STRUCTURE_MENU_SECTION.key,
|
|
40
|
+
rank: TRANSFORM_STRUCTURE_MENU_SECTION_RANK[TRANSFORM_STRUCTURE_CODE_BLOCK_MENU_ITEM.key]
|
|
41
|
+
},
|
|
42
|
+
component: createCodeBlockMenuItem(api),
|
|
43
|
+
isHidden: function isHidden() {
|
|
44
|
+
var _api$blockMenu2;
|
|
45
|
+
return Boolean(api === null || api === void 0 || (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(CODE_BLOCK_NODE_NAME));
|
|
46
|
+
}
|
|
47
|
+
}]);
|
|
51
48
|
if (isRegisteredSlashCommandEnabled) {
|
|
52
49
|
var _api$uiControlRegistr;
|
|
53
50
|
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getCodeBlockQuickInsertComponents({
|
|
@@ -13,6 +13,7 @@ import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
|
13
13
|
import ListNumberedIcon from '@atlaskit/icon/core/list-numbered';
|
|
14
14
|
import TextWrapIcon from '@atlaskit/icon/core/text-wrap';
|
|
15
15
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
16
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
17
18
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
18
19
|
import { changeLanguage, copyContentToClipboardWithAnalytics, createFormatCodeOnClick, removeCodeBlockWithAnalytics, resetCopiedState, toggleLineNumbersForCodeBlockNode, toggleWordWrapStateForCodeBlockNode } from '../editor-commands';
|
|
@@ -179,7 +180,7 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
179
180
|
// note: copyContentToClipboardWithAnalytics contains logic that also removes the
|
|
180
181
|
// visual feedback for the copy button
|
|
181
182
|
onClick: copyContentToClipboardWithAnalytics(editorAnalyticsAPI),
|
|
182
|
-
title: formatMessage(codeBlockState.contentCopied ? codeBlockButtonMessages.copiedCodeToClipboard : codeBlockButtonMessages.copyCodeToClipboard),
|
|
183
|
+
title: formatMessage(codeBlockState.contentCopied ? codeBlockButtonMessages.copiedCodeToClipboard : isExperimentEnabled('platform_editor_a11y_codeblock_copy_name') ? codeBlockButtonMessages.copyCodeSnippetToClipboard : codeBlockButtonMessages.copyCodeToClipboard),
|
|
183
184
|
onMouseEnter: provideVisualFeedbackForCopyButton,
|
|
184
185
|
// note: resetCopiedState contains logic that also removes the
|
|
185
186
|
// visual feedback for the copy button
|
|
@@ -205,7 +206,7 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
205
206
|
}];
|
|
206
207
|
if (allowCopyToClipboard) {
|
|
207
208
|
overflowMenuOptions.unshift({
|
|
208
|
-
title: formatMessage(commonMessages.copyToClipboard),
|
|
209
|
+
title: formatMessage(isExperimentEnabled('platform_editor_a11y_codeblock_copy_name') ? codeBlockButtonMessages.copyCodeSnippetToClipboard : commonMessages.copyToClipboard),
|
|
209
210
|
onClick: copyContentToClipboardWithAnalytics(editorAnalyticsAPI),
|
|
210
211
|
icon: CopyIcon({
|
|
211
212
|
label: ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.1",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/prosemirror-input-rules": "^4.1.0",
|
|
46
46
|
"@atlaskit/react-select": "^4.9.0",
|
|
47
47
|
"@atlaskit/select": "^22.11.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^200.0.0",
|
|
49
49
|
"@atlaskit/tokens": "^18.2.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@compiled/react": "^1.0.2"
|