@atlaskit/editor-plugin-code-block 12.1.11 → 13.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 +15 -0
- package/dist/cjs/codeBlockPlugin.js +1 -1
- package/dist/cjs/editor-commands/index.js +3 -2
- package/dist/cjs/pm-plugins/toolbar.js +1 -1
- package/dist/cjs/ui/CodeBlockLanguagePicker.js +2 -2
- package/dist/cjs/ui/language-picker-options.js +2 -2
- package/dist/es2019/codeBlockPlugin.js +1 -1
- package/dist/es2019/editor-commands/index.js +3 -2
- package/dist/es2019/pm-plugins/toolbar.js +1 -1
- package/dist/es2019/ui/CodeBlockLanguagePicker.js +2 -2
- package/dist/es2019/ui/language-picker-options.js +2 -2
- package/dist/esm/codeBlockPlugin.js +1 -1
- package/dist/esm/editor-commands/index.js +3 -2
- package/dist/esm/pm-plugins/toolbar.js +1 -1
- package/dist/esm/ui/CodeBlockLanguagePicker.js +2 -2
- package/dist/esm/ui/language-picker-options.js +2 -2
- package/package.json +19 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 13.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3e2877f105afc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3e2877f105afc) -
|
|
8
|
+
Gate code block auto-detection behind the q4 lovability experiment and
|
|
9
|
+
platform_editor_code_block_language_detection_flow kill switch.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 13.0.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 12.1.11
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -83,7 +83,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
83
83
|
var schema = _ref3.schema;
|
|
84
84
|
return (0, _inputRule.createCodeBlockInputRule)(schema, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
85
85
|
}
|
|
86
|
-
}].concat((0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('
|
|
86
|
+
}].concat((0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('platform_editor_code_block_q4_lovability', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_code_block_language_detection_flow') ? [{
|
|
87
87
|
name: 'codeBlockAutoDetect',
|
|
88
88
|
plugin: function plugin() {
|
|
89
89
|
return (0, _autoDetect.createAutoDetectPlugin)(api);
|
|
@@ -19,6 +19,7 @@ var _preset = require("@atlaskit/editor-common/preset");
|
|
|
19
19
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
20
20
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
21
21
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
22
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
23
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
23
24
|
var _actions = require("../pm-plugins/actions");
|
|
24
25
|
var _autoDetectState = require("../pm-plugins/auto-detect-state");
|
|
@@ -63,11 +64,11 @@ var changeLanguage = exports.changeLanguage = function changeLanguage(editorAnal
|
|
|
63
64
|
}
|
|
64
65
|
var node = state.doc.nodeAt(pos);
|
|
65
66
|
var localId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
66
|
-
var previousAutoDetectEntry = (0, _expValEquals.expValEquals)('
|
|
67
|
+
var previousAutoDetectEntry = (0, _expValEquals.expValEquals)('platform_editor_code_block_q4_lovability', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_code_block_language_detection_flow') ? (_autoDetectPluginKey$ = _autoDetectState.autoDetectPluginKey.getState(state)) === null || _autoDetectPluginKey$ === void 0 ? void 0 : _autoDetectPluginKey$.languageDetectionMap[localId] : undefined;
|
|
67
68
|
var tr = state.tr.setNodeMarkup(pos, codeBlock, _objectSpread(_objectSpread({}, node === null || node === void 0 ? void 0 : node.attrs), {}, {
|
|
68
69
|
language: language
|
|
69
70
|
})).setMeta('scrollIntoView', false);
|
|
70
|
-
if ((0, _expValEquals.expValEquals)('
|
|
71
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_code_block_q4_lovability', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_code_block_language_detection_flow')) {
|
|
71
72
|
tr.setMeta(_autoDetectState.autoDetectPluginKey, {
|
|
72
73
|
type: _actions.ACTIONS.REMOVE_AUTO_DETECT_ENTRY,
|
|
73
74
|
data: {
|
|
@@ -96,7 +96,6 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
96
96
|
var language = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.language;
|
|
97
97
|
var localId = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId;
|
|
98
98
|
var autoDetectState = _autoDetectState.autoDetectPluginKey.getState(state);
|
|
99
|
-
var autoDetectEntry = (0, _expValEquals.expValEquals)('platform_editor_code_block_auto_detection', 'isEnabled', true) && typeof localId === 'string' ? autoDetectState === null || autoDetectState === void 0 ? void 0 : autoDetectState.languageDetectionMap[localId] : undefined;
|
|
100
99
|
|
|
101
100
|
// Keep fresh option objects for the legacy toolbar select so reopening it
|
|
102
101
|
// continues to start from the top rather than preserving the previously
|
|
@@ -123,6 +122,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
|
|
|
123
122
|
};
|
|
124
123
|
var languagePicker;
|
|
125
124
|
if ((0, _expValEquals.expValEquals)('platform_editor_code_block_q4_lovability', 'isEnabled', true) && (0, _platformFeatureFlags.fg)('platform_editor_code_block_add_line_number_button')) {
|
|
125
|
+
var autoDetectEntry = typeof localId === 'string' && (0, _platformFeatureFlags.fg)('platform_editor_code_block_language_detection_flow') ? autoDetectState === null || autoDetectState === void 0 ? void 0 : autoDetectState.languageDetectionMap[localId] : undefined;
|
|
126
126
|
var autoDetectPickerValue = getAutoDetectPickerValue({
|
|
127
127
|
autoDetectEntry: autoDetectEntry,
|
|
128
128
|
formatMessage: formatMessage,
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.CodeBlockLanguagePicker = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
12
|
var _editorCommands = require("../editor-commands");
|
|
13
13
|
var _languagePickerOptions = require("./language-picker-options");
|
|
14
14
|
var _LanguagePicker = require("./LanguagePicker");
|
|
@@ -33,7 +33,7 @@ var CodeBlockLanguagePicker = exports.CodeBlockLanguagePicker = function CodeBlo
|
|
|
33
33
|
}, []);
|
|
34
34
|
var handleSelection = (0, _react.useCallback)(function (option, selectionSource) {
|
|
35
35
|
var _api$analytics;
|
|
36
|
-
var command = option.value === _languagePickerOptions.DETECT_LANGUAGE_VALUE && (0,
|
|
36
|
+
var command = option.value === _languagePickerOptions.DETECT_LANGUAGE_VALUE && (0, _platformFeatureFlags.fg)('platform_editor_code_block_language_detection_flow') ? (0, _editorCommands.detectLanguage)() : (0, _editorCommands.changeLanguage)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(option.value, selectionSource);
|
|
37
37
|
var commandSucceeded = command(editorView.state, editorView.dispatch);
|
|
38
38
|
if (commandSucceeded && option.value !== _languagePickerOptions.DETECT_LANGUAGE_VALUE) {
|
|
39
39
|
(0, _recentLanguages.saveRecentLanguage)(option.value);
|
|
@@ -8,7 +8,7 @@ exports.getDetectLanguageOption = exports.createGroupedLanguageOptions = exports
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
-
var
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
12
|
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; }
|
|
13
13
|
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; }
|
|
14
14
|
var NONE_LANGUAGE_VALUE = exports.NONE_LANGUAGE_VALUE = 'none';
|
|
@@ -36,7 +36,7 @@ var createGroupedLanguageOptions = exports.createGroupedLanguageOptions = functi
|
|
|
36
36
|
var plainTextOption = languages.find(function (language) {
|
|
37
37
|
return language.value === PLAIN_TEXT_LANGUAGE_VALUE;
|
|
38
38
|
});
|
|
39
|
-
var pinnedOptions = (0,
|
|
39
|
+
var pinnedOptions = (0, _platformFeatureFlags.fg)('platform_editor_code_block_language_detection_flow') ? [getDetectLanguageOption(formatMessage)] : [];
|
|
40
40
|
if (plainTextOption) {
|
|
41
41
|
pinnedOptions.push(_objectSpread(_objectSpread({}, plainTextOption), {}, {
|
|
42
42
|
selectionSource: 'pinned'
|
|
@@ -74,7 +74,7 @@ const codeBlockPlugin = ({
|
|
|
74
74
|
var _api$analytics;
|
|
75
75
|
return createCodeBlockInputRule(schema, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
76
76
|
}
|
|
77
|
-
}, ...(expValEquals('
|
|
77
|
+
}, ...(expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_language_detection_flow') ? [{
|
|
78
78
|
name: 'codeBlockAutoDetect',
|
|
79
79
|
plugin: () => createAutoDetectPlugin(api)
|
|
80
80
|
}] : []), {
|
|
@@ -7,6 +7,7 @@ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
|
7
7
|
import { findCodeBlock } from '@atlaskit/editor-common/transforms';
|
|
8
8
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { ACTIONS } from '../pm-plugins/actions';
|
|
12
13
|
import { autoDetectPluginKey } from '../pm-plugins/auto-detect-state';
|
|
@@ -53,12 +54,12 @@ export const changeLanguage = editorAnalyticsAPI => (language, selectionSource)
|
|
|
53
54
|
}
|
|
54
55
|
const node = state.doc.nodeAt(pos);
|
|
55
56
|
const localId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
56
|
-
const previousAutoDetectEntry = expValEquals('
|
|
57
|
+
const previousAutoDetectEntry = expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_language_detection_flow') ? (_autoDetectPluginKey$ = autoDetectPluginKey.getState(state)) === null || _autoDetectPluginKey$ === void 0 ? void 0 : _autoDetectPluginKey$.languageDetectionMap[localId] : undefined;
|
|
57
58
|
const tr = state.tr.setNodeMarkup(pos, codeBlock, {
|
|
58
59
|
...(node === null || node === void 0 ? void 0 : node.attrs),
|
|
59
60
|
language
|
|
60
61
|
}).setMeta('scrollIntoView', false);
|
|
61
|
-
if (expValEquals('
|
|
62
|
+
if (expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_language_detection_flow')) {
|
|
62
63
|
tr.setMeta(autoDetectPluginKey, {
|
|
63
64
|
type: ACTIONS.REMOVE_AUTO_DETECT_ENTRY,
|
|
64
65
|
data: {
|
|
@@ -79,7 +79,6 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api, overrideLang
|
|
|
79
79
|
const language = node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.language;
|
|
80
80
|
const localId = node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId;
|
|
81
81
|
const autoDetectState = autoDetectPluginKey.getState(state);
|
|
82
|
-
const autoDetectEntry = expValEquals('platform_editor_code_block_auto_detection', 'isEnabled', true) && typeof localId === 'string' ? autoDetectState === null || autoDetectState === void 0 ? void 0 : autoDetectState.languageDetectionMap[localId] : undefined;
|
|
83
82
|
|
|
84
83
|
// Keep fresh option objects for the legacy toolbar select so reopening it
|
|
85
84
|
// continues to start from the top rather than preserving the previously
|
|
@@ -100,6 +99,7 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api, overrideLang
|
|
|
100
99
|
};
|
|
101
100
|
let languagePicker;
|
|
102
101
|
if (expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_add_line_number_button')) {
|
|
102
|
+
const autoDetectEntry = typeof localId === 'string' && fg('platform_editor_code_block_language_detection_flow') ? autoDetectState === null || autoDetectState === void 0 ? void 0 : autoDetectState.languageDetectionMap[localId] : undefined;
|
|
103
103
|
const autoDetectPickerValue = getAutoDetectPickerValue({
|
|
104
104
|
autoDetectEntry,
|
|
105
105
|
formatMessage,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { changeLanguage, detectLanguage } from '../editor-commands';
|
|
4
4
|
import { DETECT_LANGUAGE_VALUE } from './language-picker-options';
|
|
5
5
|
import { LanguagePicker } from './LanguagePicker';
|
|
@@ -19,7 +19,7 @@ export const CodeBlockLanguagePicker = ({
|
|
|
19
19
|
}, []);
|
|
20
20
|
const handleSelection = useCallback((option, selectionSource) => {
|
|
21
21
|
var _api$analytics;
|
|
22
|
-
const command = option.value === DETECT_LANGUAGE_VALUE &&
|
|
22
|
+
const command = option.value === DETECT_LANGUAGE_VALUE && fg('platform_editor_code_block_language_detection_flow') ? detectLanguage() : changeLanguage(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(option.value, selectionSource);
|
|
23
23
|
const commandSucceeded = command(editorView.state, editorView.dispatch);
|
|
24
24
|
if (commandSucceeded && option.value !== DETECT_LANGUAGE_VALUE) {
|
|
25
25
|
saveRecentLanguage(option.value);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { codeBlockButtonMessages } from '@atlaskit/editor-common/messages';
|
|
2
|
-
import {
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
export const NONE_LANGUAGE_VALUE = 'none';
|
|
4
4
|
export const DETECT_LANGUAGE_VALUE = 'autodetect';
|
|
5
5
|
export const PLAIN_TEXT_LANGUAGE_VALUE = 'text';
|
|
@@ -17,7 +17,7 @@ export const createGroupedLanguageOptions = ({
|
|
|
17
17
|
const recentlyUsedLanguageValues = new Set(recentlyUsedLanguages.map(language => language.value));
|
|
18
18
|
const allLanguages = languages.filter(language => language.value !== NONE_LANGUAGE_VALUE && language.value !== PLAIN_TEXT_LANGUAGE_VALUE && !recentlyUsedLanguageValues.has(language.value));
|
|
19
19
|
const plainTextOption = languages.find(language => language.value === PLAIN_TEXT_LANGUAGE_VALUE);
|
|
20
|
-
const pinnedOptions =
|
|
20
|
+
const pinnedOptions = fg('platform_editor_code_block_language_detection_flow') ? [getDetectLanguageOption(formatMessage)] : [];
|
|
21
21
|
if (plainTextOption) {
|
|
22
22
|
pinnedOptions.push({
|
|
23
23
|
...plainTextOption,
|
|
@@ -76,7 +76,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
|
|
|
76
76
|
var schema = _ref3.schema;
|
|
77
77
|
return createCodeBlockInputRule(schema, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
78
78
|
}
|
|
79
|
-
}].concat(_toConsumableArray(expValEquals('
|
|
79
|
+
}].concat(_toConsumableArray(expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_language_detection_flow') ? [{
|
|
80
80
|
name: 'codeBlockAutoDetect',
|
|
81
81
|
plugin: function plugin() {
|
|
82
82
|
return createAutoDetectPlugin(api);
|
|
@@ -10,6 +10,7 @@ import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
|
10
10
|
import { findCodeBlock } from '@atlaskit/editor-common/transforms';
|
|
11
11
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
15
|
import { ACTIONS } from '../pm-plugins/actions';
|
|
15
16
|
import { autoDetectPluginKey } from '../pm-plugins/auto-detect-state';
|
|
@@ -52,11 +53,11 @@ export var changeLanguage = function changeLanguage(editorAnalyticsAPI) {
|
|
|
52
53
|
}
|
|
53
54
|
var node = state.doc.nodeAt(pos);
|
|
54
55
|
var localId = node === null || node === void 0 ? void 0 : node.attrs.localId;
|
|
55
|
-
var previousAutoDetectEntry = expValEquals('
|
|
56
|
+
var previousAutoDetectEntry = expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_language_detection_flow') ? (_autoDetectPluginKey$ = autoDetectPluginKey.getState(state)) === null || _autoDetectPluginKey$ === void 0 ? void 0 : _autoDetectPluginKey$.languageDetectionMap[localId] : undefined;
|
|
56
57
|
var tr = state.tr.setNodeMarkup(pos, codeBlock, _objectSpread(_objectSpread({}, node === null || node === void 0 ? void 0 : node.attrs), {}, {
|
|
57
58
|
language: language
|
|
58
59
|
})).setMeta('scrollIntoView', false);
|
|
59
|
-
if (expValEquals('
|
|
60
|
+
if (expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_language_detection_flow')) {
|
|
60
61
|
tr.setMeta(autoDetectPluginKey, {
|
|
61
62
|
type: ACTIONS.REMOVE_AUTO_DETECT_ENTRY,
|
|
62
63
|
data: {
|
|
@@ -87,7 +87,6 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
87
87
|
var language = node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.language;
|
|
88
88
|
var localId = node === null || node === void 0 || (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId;
|
|
89
89
|
var autoDetectState = autoDetectPluginKey.getState(state);
|
|
90
|
-
var autoDetectEntry = expValEquals('platform_editor_code_block_auto_detection', 'isEnabled', true) && typeof localId === 'string' ? autoDetectState === null || autoDetectState === void 0 ? void 0 : autoDetectState.languageDetectionMap[localId] : undefined;
|
|
91
90
|
|
|
92
91
|
// Keep fresh option objects for the legacy toolbar select so reopening it
|
|
93
92
|
// continues to start from the top rather than preserving the previously
|
|
@@ -114,6 +113,7 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
114
113
|
};
|
|
115
114
|
var languagePicker;
|
|
116
115
|
if (expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true) && fg('platform_editor_code_block_add_line_number_button')) {
|
|
116
|
+
var autoDetectEntry = typeof localId === 'string' && fg('platform_editor_code_block_language_detection_flow') ? autoDetectState === null || autoDetectState === void 0 ? void 0 : autoDetectState.languageDetectionMap[localId] : undefined;
|
|
117
117
|
var autoDetectPickerValue = getAutoDetectPickerValue({
|
|
118
118
|
autoDetectEntry: autoDetectEntry,
|
|
119
119
|
formatMessage: formatMessage,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { changeLanguage, detectLanguage } from '../editor-commands';
|
|
5
5
|
import { DETECT_LANGUAGE_VALUE } from './language-picker-options';
|
|
6
6
|
import { LanguagePicker } from './LanguagePicker';
|
|
@@ -24,7 +24,7 @@ export var CodeBlockLanguagePicker = function CodeBlockLanguagePicker(_ref) {
|
|
|
24
24
|
}, []);
|
|
25
25
|
var handleSelection = useCallback(function (option, selectionSource) {
|
|
26
26
|
var _api$analytics;
|
|
27
|
-
var command = option.value === DETECT_LANGUAGE_VALUE &&
|
|
27
|
+
var command = option.value === DETECT_LANGUAGE_VALUE && fg('platform_editor_code_block_language_detection_flow') ? detectLanguage() : changeLanguage(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(option.value, selectionSource);
|
|
28
28
|
var commandSucceeded = command(editorView.state, editorView.dispatch);
|
|
29
29
|
if (commandSucceeded && option.value !== DETECT_LANGUAGE_VALUE) {
|
|
30
30
|
saveRecentLanguage(option.value);
|
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
import { codeBlockButtonMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
-
import {
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
export var NONE_LANGUAGE_VALUE = 'none';
|
|
8
8
|
export var DETECT_LANGUAGE_VALUE = 'autodetect';
|
|
9
9
|
export var PLAIN_TEXT_LANGUAGE_VALUE = 'text';
|
|
@@ -29,7 +29,7 @@ export var createGroupedLanguageOptions = function createGroupedLanguageOptions(
|
|
|
29
29
|
var plainTextOption = languages.find(function (language) {
|
|
30
30
|
return language.value === PLAIN_TEXT_LANGUAGE_VALUE;
|
|
31
31
|
});
|
|
32
|
-
var pinnedOptions =
|
|
32
|
+
var pinnedOptions = fg('platform_editor_code_block_language_detection_flow') ? [getDetectLanguageOption(formatMessage)] : [];
|
|
33
33
|
if (plainTextOption) {
|
|
34
34
|
pinnedOptions.push(_objectSpread(_objectSpread({}, plainTextOption), {}, {
|
|
35
35
|
selectionSource: 'pinned'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,35 +27,35 @@
|
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"atlaskit:src": "src/index.ts",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^52.
|
|
30
|
+
"@atlaskit/adf-schema": "^52.16.0",
|
|
31
31
|
"@atlaskit/button": "^23.11.0",
|
|
32
32
|
"@atlaskit/code": "^17.5.0",
|
|
33
33
|
"@atlaskit/css": "^0.19.0",
|
|
34
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
35
|
-
"@atlaskit/editor-plugin-block-menu": "^
|
|
36
|
-
"@atlaskit/editor-plugin-composition": "^
|
|
37
|
-
"@atlaskit/editor-plugin-decorations": "^
|
|
38
|
-
"@atlaskit/editor-plugin-editor-disabled": "^
|
|
39
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
40
|
-
"@atlaskit/editor-plugin-interaction": "^
|
|
41
|
-
"@atlaskit/editor-plugin-selection": "^
|
|
42
|
-
"@atlaskit/editor-plugin-toolbar": "^
|
|
34
|
+
"@atlaskit/editor-plugin-analytics": "^11.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-block-menu": "^10.1.0",
|
|
36
|
+
"@atlaskit/editor-plugin-composition": "^10.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-decorations": "^11.0.0",
|
|
38
|
+
"@atlaskit/editor-plugin-editor-disabled": "^11.0.0",
|
|
39
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^13.0.0",
|
|
40
|
+
"@atlaskit/editor-plugin-interaction": "^20.0.0",
|
|
41
|
+
"@atlaskit/editor-plugin-selection": "^11.0.0",
|
|
42
|
+
"@atlaskit/editor-plugin-toolbar": "^8.0.0",
|
|
43
43
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
44
44
|
"@atlaskit/editor-shared-styles": "^3.11.0",
|
|
45
|
-
"@atlaskit/editor-toolbar": "^1.
|
|
46
|
-
"@atlaskit/frontend-utilities": "^3.
|
|
47
|
-
"@atlaskit/icon": "^35.
|
|
45
|
+
"@atlaskit/editor-toolbar": "^1.10.0",
|
|
46
|
+
"@atlaskit/frontend-utilities": "^3.4.0",
|
|
47
|
+
"@atlaskit/icon": "^35.4.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
49
49
|
"@atlaskit/primitives": "^19.0.0",
|
|
50
50
|
"@atlaskit/prosemirror-input-rules": "^3.7.0",
|
|
51
51
|
"@atlaskit/select": "^21.12.0",
|
|
52
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
52
|
+
"@atlaskit/tmp-editor-statsig": "^89.0.0",
|
|
53
53
|
"@atlaskit/tokens": "^13.1.0",
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@compiled/react": "^0.20.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@atlaskit/editor-common": "^
|
|
58
|
+
"@atlaskit/editor-common": "^115.2.0",
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
61
61
|
},
|
|
@@ -109,6 +109,9 @@
|
|
|
109
109
|
},
|
|
110
110
|
"platform_editor_code_block_add_line_number_button": {
|
|
111
111
|
"type": "boolean"
|
|
112
|
+
},
|
|
113
|
+
"platform_editor_code_block_language_detection_flow": {
|
|
114
|
+
"type": "boolean"
|
|
112
115
|
}
|
|
113
116
|
},
|
|
114
117
|
"devDependencies": {
|