@atlaskit/editor-plugin-code-block 8.1.0 → 8.1.2

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-code-block
2
2
 
3
+ ## 8.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a4fbfc862e34f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a4fbfc862e34f) -
8
+ [ux] ED-29557 Clean up plain text quick insert as it's not needed
9
+ - Updated dependencies
10
+
11
+ ## 8.1.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`2a658b46713fb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a658b46713fb) -
16
+ upgrade use of browser util
17
+
3
18
  ## 8.1.0
4
19
 
5
20
  ### Minor Changes
@@ -13,7 +13,6 @@ var _blockMenu = require("@atlaskit/editor-common/block-menu");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
14
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
16
  var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
18
17
  var _editorCommands = require("./editor-commands");
19
18
  var _codeBlockAutoFullStopTransformPlugin = require("./pm-plugins/codeBlockAutoFullStopTransformPlugin");
@@ -116,7 +115,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
116
115
  pluginsOptions: {
117
116
  quickInsert: function quickInsert(_ref5) {
118
117
  var formatMessage = _ref5.formatMessage;
119
- var quickInsertItems = [{
118
+ return [{
120
119
  id: 'codeblock',
121
120
  title: formatMessage(_messages.blockTypeMessages.codeblock),
122
121
  description: formatMessage(_messages.blockTypeMessages.codeblockDescription),
@@ -143,38 +142,6 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
143
142
  return tr;
144
143
  }
145
144
  }];
146
- if ((0, _expValEquals.expValEquals)('platform_editor_plain_text_support', 'isEnabled', true)) {
147
- quickInsertItems.push({
148
- id: 'plainText',
149
- title: formatMessage(_messages.blockTypeMessages.plainTextCodeblock),
150
- description: formatMessage(_messages.blockTypeMessages.plainTextCodeblockDescription),
151
- keywords: ['plain text'],
152
- icon: function icon() {
153
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconCode, null);
154
- },
155
- action: function action(_insert, state, source) {
156
- var _api$analytics4;
157
- var tr = (0, _editorCommands.createInsertCodeBlockTransaction)({
158
- state: state,
159
- attributes: {
160
- language: 'text'
161
- }
162
- });
163
- api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || _api$analytics4.actions.attachAnalyticsEvent({
164
- action: _analytics.ACTION.INSERTED,
165
- actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
166
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.CODE_BLOCK,
167
- attributes: {
168
- inputMethod: source || _analytics.INPUT_METHOD.QUICK_INSERT,
169
- language: 'text'
170
- },
171
- eventType: _analytics.EVENT_TYPE.TRACK
172
- })(tr);
173
- return tr;
174
- }
175
- });
176
- }
177
- return quickInsertItems;
178
145
  },
179
146
  floatingToolbar: (0, _toolbar.getToolbarConfig)(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api, options === null || options === void 0 ? void 0 : options.overrideLanguageName)
180
147
  }
@@ -16,7 +16,6 @@ var _insert = require("@atlaskit/editor-common/insert");
16
16
  var _transforms = require("@atlaskit/editor-common/transforms");
17
17
  var _state = require("@atlaskit/editor-prosemirror/state");
18
18
  var _utils = require("@atlaskit/editor-prosemirror/utils");
19
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
20
19
  var _actions = require("../pm-plugins/actions");
21
20
  var _codeBlockCopySelectionPlugin = require("../pm-plugins/codeBlockCopySelectionPlugin");
22
21
  var _pluginKey = require("../pm-plugins/plugin-key");
@@ -178,8 +177,7 @@ var resetShouldIgnoreFollowingMutations = exports.resetShouldIgnoreFollowingMuta
178
177
  * append the codeblock to the end of the document.
179
178
  */
180
179
  function createInsertCodeBlockTransaction(_ref) {
181
- var state = _ref.state,
182
- attributes = _ref.attributes;
180
+ var state = _ref.state;
183
181
  var tr = state.tr;
184
182
  var from = state.selection.from;
185
183
  var codeBlock = state.schema.nodes.codeBlock;
@@ -195,12 +193,12 @@ function createInsertCodeBlockTransaction(_ref) {
195
193
  var canInsertCodeBlock = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
196
194
  parentNodeType: parentNodeType,
197
195
  grandParentNodeType: grandParentNodeType,
198
- content: codeBlock.createAndFill((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined)
196
+ content: codeBlock.createAndFill()
199
197
  }) && (0, _insert.contentAllowedInCodeBlock)(state);
200
198
  if (canInsertCodeBlock) {
201
- tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined);
199
+ tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from, undefined);
202
200
  } else {
203
- (0, _utils.safeInsert)(codeBlock.createAndFill((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined))(tr).scrollIntoView();
201
+ (0, _utils.safeInsert)(codeBlock.createAndFill())(tr).scrollIntoView();
204
202
  }
205
203
  return tr;
206
204
  }
@@ -12,6 +12,7 @@ var _browser = require("@atlaskit/editor-common/browser");
12
12
  var _codeBlock = require("@atlaskit/editor-common/code-block");
13
13
  var _model = require("@atlaskit/editor-prosemirror/model");
14
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
16
  var _editorCommands = require("../editor-commands");
16
17
  var _mainState = require("../pm-plugins/main-state");
17
18
  var _classNames = require("../ui/class-names");
@@ -172,7 +173,8 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
172
173
  }
173
174
  this.node = node;
174
175
  this.maintainDynamicGutterSize();
175
- if (_browser.browser.android) {
176
+ var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
177
+ if (browser.android) {
176
178
  this.coalesceDOMElements();
177
179
  (0, _editorCommands.resetShouldIgnoreFollowingMutations)(this.view.state, this.view.dispatch);
178
180
  }
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.codeBlockAutoFullStopTransformPlugin = codeBlockAutoFullStopTransformPlugin;
7
7
  exports.codeBlockAutoFullStopTransformPluginKey = void 0;
8
+ var _browser = require("@atlaskit/editor-common/browser");
8
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
9
10
  var _transforms = require("@atlaskit/editor-common/transforms");
10
- var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var codeBlockAutoFullStopTransformPluginKey = exports.codeBlockAutoFullStopTransformPluginKey = new _state.PluginKey('codeBlockAutoFullStopTransformPluginKey');
14
15
  function codeBlockAutoFullStopTransformPlugin() {
15
16
  return new _safePlugin.SafePlugin({
@@ -27,7 +28,7 @@ function codeBlockAutoFullStopTransformPlugin() {
27
28
  fromNew = _trNew$selection.from,
28
29
  toNew = _trNew$selection.to;
29
30
  var isCodeBlock = !!(0, _transforms.findCodeBlock)(oldState, trOld.selection) && !!(0, _transforms.findCodeBlock)(newState, trNew.selection);
30
-
31
+ var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
31
32
  /**
32
33
  * Mac will auto insert a fullstop when the user double taps the space key after some content.
33
34
  * Line number decorators are assumed content so on new lines the fullstop is inserted.
@@ -43,7 +44,7 @@ function codeBlockAutoFullStopTransformPlugin() {
43
44
  */
44
45
 
45
46
  // both selections must be of code block early exit
46
- if (_utils.browser.mac && fromNew === toNew && fromNew === fromOld + 1 && isCodeBlock) {
47
+ if (browser.mac && fromNew === toNew && fromNew === fromOld + 1 && isCodeBlock) {
47
48
  // detect when '.' is inserted when the previous state was a space ' '
48
49
  try {
49
50
  var textBetweenBefore = trOld.doc.textBetween(fromOld - 1, fromOld); // ' '
@@ -47,12 +47,13 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
47
47
  var keyEvent = event;
48
48
  var eventInputType = keyEvent.inputType;
49
49
  var eventText = keyEvent.data;
50
- if (_browser.browser.ios && event.composed &&
50
+ var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
51
+ if (browser.ios && event.composed &&
51
52
  // insertParagraph will be the input type when the enter key is pressed.
52
53
  eventInputType === 'insertParagraph' && (0, _transforms.findCodeBlock)(view.state, view.state.selection)) {
53
54
  event.preventDefault();
54
55
  return true;
55
- } else if (_browser.browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && (0, _transforms.findCodeBlock)(view.state, view.state.selection)) {
56
+ } else if (browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && (0, _transforms.findCodeBlock)(view.state, view.state.selection)) {
56
57
  // Ignored via go/ees005
57
58
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
59
  var resultingText = event.target.outerText + '\n';
@@ -74,7 +75,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
74
75
  }
75
76
  return true;
76
77
  }
77
- if (_browser.browser.android) {
78
+ if (browser.android) {
78
79
  (0, _editorCommands.resetShouldIgnoreFollowingMutations)(view.state, view.dispatch);
79
80
  }
80
81
  return false;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.refreshBrowserSelection = exports.default = void 0;
7
7
  var _browser = require("@atlaskit/editor-common/browser");
8
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
9
  var _pluginKey = require("./plugin-key");
9
10
  // Workaround for a firefox issue where dom selection is off sync
10
11
  // https://product-fabric.atlassian.net/browse/ED-12442
@@ -20,7 +21,8 @@ var refreshBrowserSelection = exports.refreshBrowserSelection = function refresh
20
21
  };
21
22
  var refreshBrowserSelectionOnChange = function refreshBrowserSelectionOnChange(transaction, editorState) {
22
23
  var _pluginKey$getState;
23
- if (_browser.browser.gecko && transaction.docChanged &&
24
+ var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
25
+ if (browser.gecko && transaction.docChanged &&
24
26
  // codeblockState.pos should be set if current selection is in a codeblock.
25
27
  typeof ((_pluginKey$getState = _pluginKey.pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.pos) === 'number') {
26
28
  refreshBrowserSelection();
@@ -5,7 +5,6 @@ import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK,
5
5
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
6
6
  import { IconCode } from '@atlaskit/editor-common/quick-insert';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
8
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
9
  import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
11
10
  import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
@@ -101,63 +100,31 @@ const codeBlockPlugin = ({
101
100
  pluginsOptions: {
102
101
  quickInsert: ({
103
102
  formatMessage
104
- }) => {
105
- const quickInsertItems = [{
106
- id: 'codeblock',
107
- title: formatMessage(blockTypeMessages.codeblock),
108
- description: formatMessage(blockTypeMessages.codeblockDescription),
109
- keywords: ['code block'],
110
- priority: 700,
111
- keyshortcut: '```',
112
- icon: () => /*#__PURE__*/React.createElement(IconCode, null),
113
- action(_insert, state, source) {
114
- var _api$analytics3;
115
- const tr = createInsertCodeBlockTransaction({
116
- state
117
- });
118
- api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
119
- action: ACTION.INSERTED,
120
- actionSubject: ACTION_SUBJECT.DOCUMENT,
121
- actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
122
- attributes: {
123
- inputMethod: expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? source || INPUT_METHOD.QUICK_INSERT : INPUT_METHOD.QUICK_INSERT
124
- },
125
- eventType: EVENT_TYPE.TRACK
126
- })(tr);
127
- return tr;
128
- }
129
- }];
130
- if (expValEquals('platform_editor_plain_text_support', 'isEnabled', true)) {
131
- quickInsertItems.push({
132
- id: 'plainText',
133
- title: formatMessage(blockTypeMessages.plainTextCodeblock),
134
- description: formatMessage(blockTypeMessages.plainTextCodeblockDescription),
135
- keywords: ['plain text'],
136
- icon: () => /*#__PURE__*/React.createElement(IconCode, null),
137
- action(_insert, state, source) {
138
- var _api$analytics4;
139
- const tr = createInsertCodeBlockTransaction({
140
- state,
141
- attributes: {
142
- language: 'text'
143
- }
144
- });
145
- api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.attachAnalyticsEvent({
146
- action: ACTION.INSERTED,
147
- actionSubject: ACTION_SUBJECT.DOCUMENT,
148
- actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
149
- attributes: {
150
- inputMethod: source || INPUT_METHOD.QUICK_INSERT,
151
- language: 'text'
152
- },
153
- eventType: EVENT_TYPE.TRACK
154
- })(tr);
155
- return tr;
156
- }
103
+ }) => [{
104
+ id: 'codeblock',
105
+ title: formatMessage(blockTypeMessages.codeblock),
106
+ description: formatMessage(blockTypeMessages.codeblockDescription),
107
+ keywords: ['code block'],
108
+ priority: 700,
109
+ keyshortcut: '```',
110
+ icon: () => /*#__PURE__*/React.createElement(IconCode, null),
111
+ action(_insert, state, source) {
112
+ var _api$analytics3;
113
+ const tr = createInsertCodeBlockTransaction({
114
+ state
157
115
  });
116
+ api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
117
+ action: ACTION.INSERTED,
118
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
119
+ actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
120
+ attributes: {
121
+ inputMethod: expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? source || INPUT_METHOD.QUICK_INSERT : INPUT_METHOD.QUICK_INSERT
122
+ },
123
+ eventType: EVENT_TYPE.TRACK
124
+ })(tr);
125
+ return tr;
158
126
  }
159
- return quickInsertItems;
160
- },
127
+ }],
161
128
  floatingToolbar: getToolbarConfig(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api, options === null || options === void 0 ? void 0 : options.overrideLanguageName)
162
129
  }
163
130
  };
@@ -6,7 +6,6 @@ import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } fro
6
6
  import { findCodeBlock } from '@atlaskit/editor-common/transforms';
7
7
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
9
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
9
  import { ACTIONS } from '../pm-plugins/actions';
11
10
  import { copySelectionPluginKey } from '../pm-plugins/codeBlockCopySelectionPlugin';
12
11
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -182,8 +181,7 @@ export const resetShouldIgnoreFollowingMutations = (state, dispatch) => {
182
181
  * append the codeblock to the end of the document.
183
182
  */
184
183
  export function createInsertCodeBlockTransaction({
185
- state,
186
- attributes
184
+ state
187
185
  }) {
188
186
  let {
189
187
  tr
@@ -206,12 +204,12 @@ export function createInsertCodeBlockTransaction({
206
204
  const canInsertCodeBlock = shouldSplitSelectedNodeOnNodeInsertion({
207
205
  parentNodeType,
208
206
  grandParentNodeType,
209
- content: codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined)
207
+ content: codeBlock.createAndFill()
210
208
  }) && contentAllowedInCodeBlock(state);
211
209
  if (canInsertCodeBlock) {
212
- tr = transformToCodeBlockAction(state, from, expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined);
210
+ tr = transformToCodeBlockAction(state, from, undefined);
213
211
  } else {
214
- safeInsert(codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined))(tr).scrollIntoView();
212
+ safeInsert(codeBlock.createAndFill())(tr).scrollIntoView();
215
213
  }
216
214
  return tr;
217
215
  }
@@ -1,8 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import { browser } from '@atlaskit/editor-common/browser';
2
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
3
3
  import { codeBlockWrappedStates, defaultWordWrapState } from '@atlaskit/editor-common/code-block';
4
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
7
8
  import { getPluginState } from '../pm-plugins/main-state';
8
9
  import { codeBlockClassNames } from '../ui/class-names';
@@ -149,6 +150,7 @@ export class CodeBlockView {
149
150
  }
150
151
  this.node = node;
151
152
  this.maintainDynamicGutterSize();
153
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
152
154
  if (browser.android) {
153
155
  this.coalesceDOMElements();
154
156
  resetShouldIgnoreFollowingMutations(this.view.state, this.view.dispatch);
@@ -1,8 +1,9 @@
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { findCodeBlock } from '@atlaskit/editor-common/transforms';
3
- import { browser } from '@atlaskit/editor-common/utils';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  export const codeBlockAutoFullStopTransformPluginKey = new PluginKey('codeBlockAutoFullStopTransformPluginKey');
7
8
  export function codeBlockAutoFullStopTransformPlugin() {
8
9
  return new SafePlugin({
@@ -27,7 +28,7 @@ export function codeBlockAutoFullStopTransformPlugin() {
27
28
  to: toNew
28
29
  } = trNew.selection;
29
30
  const isCodeBlock = !!findCodeBlock(oldState, trOld.selection) && !!findCodeBlock(newState, trNew.selection);
30
-
31
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
31
32
  /**
32
33
  * Mac will auto insert a fullstop when the user double taps the space key after some content.
33
34
  * Line number decorators are assumed content so on new lines the fullstop is inserted.
@@ -1,4 +1,4 @@
1
- import { browser } from '@atlaskit/editor-common/browser';
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
2
2
  import { updateCodeBlockWrappedStateNodeKeys } from '@atlaskit/editor-common/code-block';
3
3
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -36,6 +36,7 @@ export const createPlugin = ({
36
36
  const keyEvent = event;
37
37
  const eventInputType = keyEvent.inputType;
38
38
  const eventText = keyEvent.data;
39
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
39
40
  if (browser.ios && event.composed &&
40
41
  // insertParagraph will be the input type when the enter key is pressed.
41
42
  eventInputType === 'insertParagraph' && findCodeBlock(view.state, view.state.selection)) {
@@ -1,4 +1,5 @@
1
- import { browser } from '@atlaskit/editor-common/browser';
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { pluginKey } from './plugin-key';
3
4
 
4
5
  // Workaround for a firefox issue where dom selection is off sync
@@ -15,6 +16,7 @@ const refreshBrowserSelection = () => {
15
16
  };
16
17
  const refreshBrowserSelectionOnChange = (transaction, editorState) => {
17
18
  var _pluginKey$getState;
19
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
18
20
  if (browser.gecko && transaction.docChanged &&
19
21
  // codeblockState.pos should be set if current selection is in a codeblock.
20
22
  typeof ((_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.pos) === 'number') {
@@ -8,7 +8,6 @@ import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK,
8
8
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
9
9
  import { IconCode } from '@atlaskit/editor-common/quick-insert';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
11
  import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
13
12
  import { createInsertCodeBlockTransaction, insertCodeBlockWithAnalytics } from './editor-commands';
14
13
  import { codeBlockAutoFullStopTransformPlugin } from './pm-plugins/codeBlockAutoFullStopTransformPlugin';
@@ -109,7 +108,7 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
109
108
  pluginsOptions: {
110
109
  quickInsert: function quickInsert(_ref5) {
111
110
  var formatMessage = _ref5.formatMessage;
112
- var quickInsertItems = [{
111
+ return [{
113
112
  id: 'codeblock',
114
113
  title: formatMessage(blockTypeMessages.codeblock),
115
114
  description: formatMessage(blockTypeMessages.codeblockDescription),
@@ -136,38 +135,6 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
136
135
  return tr;
137
136
  }
138
137
  }];
139
- if (expValEquals('platform_editor_plain_text_support', 'isEnabled', true)) {
140
- quickInsertItems.push({
141
- id: 'plainText',
142
- title: formatMessage(blockTypeMessages.plainTextCodeblock),
143
- description: formatMessage(blockTypeMessages.plainTextCodeblockDescription),
144
- keywords: ['plain text'],
145
- icon: function icon() {
146
- return /*#__PURE__*/React.createElement(IconCode, null);
147
- },
148
- action: function action(_insert, state, source) {
149
- var _api$analytics4;
150
- var tr = createInsertCodeBlockTransaction({
151
- state: state,
152
- attributes: {
153
- language: 'text'
154
- }
155
- });
156
- api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || _api$analytics4.actions.attachAnalyticsEvent({
157
- action: ACTION.INSERTED,
158
- actionSubject: ACTION_SUBJECT.DOCUMENT,
159
- actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
160
- attributes: {
161
- inputMethod: source || INPUT_METHOD.QUICK_INSERT,
162
- language: 'text'
163
- },
164
- eventType: EVENT_TYPE.TRACK
165
- })(tr);
166
- return tr;
167
- }
168
- });
169
- }
170
- return quickInsertItems;
171
138
  },
172
139
  floatingToolbar: getToolbarConfig(options === null || options === void 0 ? void 0 : options.allowCopyToClipboard, api, options === null || options === void 0 ? void 0 : options.overrideLanguageName)
173
140
  }
@@ -6,7 +6,6 @@ import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } fro
6
6
  import { findCodeBlock } from '@atlaskit/editor-common/transforms';
7
7
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
9
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
10
9
  import { ACTIONS } from '../pm-plugins/actions';
11
10
  import { copySelectionPluginKey } from '../pm-plugins/codeBlockCopySelectionPlugin';
12
11
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -168,8 +167,7 @@ export var resetShouldIgnoreFollowingMutations = function resetShouldIgnoreFollo
168
167
  * append the codeblock to the end of the document.
169
168
  */
170
169
  export function createInsertCodeBlockTransaction(_ref) {
171
- var state = _ref.state,
172
- attributes = _ref.attributes;
170
+ var state = _ref.state;
173
171
  var tr = state.tr;
174
172
  var from = state.selection.from;
175
173
  var codeBlock = state.schema.nodes.codeBlock;
@@ -185,12 +183,12 @@ export function createInsertCodeBlockTransaction(_ref) {
185
183
  var canInsertCodeBlock = shouldSplitSelectedNodeOnNodeInsertion({
186
184
  parentNodeType: parentNodeType,
187
185
  grandParentNodeType: grandParentNodeType,
188
- content: codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined)
186
+ content: codeBlock.createAndFill()
189
187
  }) && contentAllowedInCodeBlock(state);
190
188
  if (canInsertCodeBlock) {
191
- tr = transformToCodeBlockAction(state, from, expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined);
189
+ tr = transformToCodeBlockAction(state, from, undefined);
192
190
  } else {
193
- safeInsert(codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined))(tr).scrollIntoView();
191
+ safeInsert(codeBlock.createAndFill())(tr).scrollIntoView();
194
192
  }
195
193
  return tr;
196
194
  }
@@ -3,10 +3,11 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  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; }
5
5
  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; }
6
- import { browser } from '@atlaskit/editor-common/browser';
6
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
7
7
  import { codeBlockWrappedStates, defaultWordWrapState } from '@atlaskit/editor-common/code-block';
8
8
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
11
  import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
11
12
  import { getPluginState } from '../pm-plugins/main-state';
12
13
  import { codeBlockClassNames } from '../ui/class-names';
@@ -166,6 +167,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
166
167
  }
167
168
  this.node = node;
168
169
  this.maintainDynamicGutterSize();
170
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
169
171
  if (browser.android) {
170
172
  this.coalesceDOMElements();
171
173
  resetShouldIgnoreFollowingMutations(this.view.state, this.view.dispatch);
@@ -1,8 +1,9 @@
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { findCodeBlock } from '@atlaskit/editor-common/transforms';
3
- import { browser } from '@atlaskit/editor-common/utils';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  export var codeBlockAutoFullStopTransformPluginKey = new PluginKey('codeBlockAutoFullStopTransformPluginKey');
7
8
  export function codeBlockAutoFullStopTransformPlugin() {
8
9
  return new SafePlugin({
@@ -20,7 +21,7 @@ export function codeBlockAutoFullStopTransformPlugin() {
20
21
  fromNew = _trNew$selection.from,
21
22
  toNew = _trNew$selection.to;
22
23
  var isCodeBlock = !!findCodeBlock(oldState, trOld.selection) && !!findCodeBlock(newState, trNew.selection);
23
-
24
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
24
25
  /**
25
26
  * Mac will auto insert a fullstop when the user double taps the space key after some content.
26
27
  * Line number decorators are assumed content so on new lines the fullstop is inserted.
@@ -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 { browser } from '@atlaskit/editor-common/browser';
4
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
5
5
  import { updateCodeBlockWrappedStateNodeKeys } from '@atlaskit/editor-common/code-block';
6
6
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
7
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -40,6 +40,7 @@ export var createPlugin = function createPlugin(_ref) {
40
40
  var keyEvent = event;
41
41
  var eventInputType = keyEvent.inputType;
42
42
  var eventText = keyEvent.data;
43
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
43
44
  if (browser.ios && event.composed &&
44
45
  // insertParagraph will be the input type when the enter key is pressed.
45
46
  eventInputType === 'insertParagraph' && findCodeBlock(view.state, view.state.selection)) {
@@ -1,4 +1,5 @@
1
- import { browser } from '@atlaskit/editor-common/browser';
1
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { pluginKey } from './plugin-key';
3
4
 
4
5
  // Workaround for a firefox issue where dom selection is off sync
@@ -15,6 +16,7 @@ var refreshBrowserSelection = function refreshBrowserSelection() {
15
16
  };
16
17
  var refreshBrowserSelectionOnChange = function refreshBrowserSelectionOnChange(transaction, editorState) {
17
18
  var _pluginKey$getState;
19
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
18
20
  if (browser.gecko && transaction.docChanged &&
19
21
  // codeblockState.pos should be set if current selection is in a codeblock.
20
22
  typeof ((_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.pos) === 'number') {
@@ -1,4 +1,3 @@
1
- import type { CodeBlockAttrs } from '@atlaskit/adf-schema';
2
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import type { Command } from '@atlaskit/editor-common/types';
@@ -16,8 +15,7 @@ export declare const resetShouldIgnoreFollowingMutations: Command;
16
15
  * if there is text selected it will wrap the current selection if not it will
17
16
  * append the codeblock to the end of the document.
18
17
  */
19
- export declare function createInsertCodeBlockTransaction({ state, attributes, }: {
20
- attributes?: CodeBlockAttrs;
18
+ export declare function createInsertCodeBlockTransaction({ state }: {
21
19
  state: EditorState;
22
20
  }): import("prosemirror-state").Transaction;
23
21
  export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
@@ -1,4 +1,3 @@
1
- import type { CodeBlockAttrs } from '@atlaskit/adf-schema';
2
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
2
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
4
3
  import type { Command } from '@atlaskit/editor-common/types';
@@ -16,8 +15,7 @@ export declare const resetShouldIgnoreFollowingMutations: Command;
16
15
  * if there is text selected it will wrap the current selection if not it will
17
16
  * append the codeblock to the end of the document.
18
17
  */
19
- export declare function createInsertCodeBlockTransaction({ state, attributes, }: {
20
- attributes?: CodeBlockAttrs;
18
+ export declare function createInsertCodeBlockTransaction({ state }: {
21
19
  state: EditorState;
22
20
  }): import("prosemirror-state").Transaction;
23
21
  export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "8.1.0",
3
+ "version": "8.1.2",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -43,11 +43,11 @@
43
43
  "@atlaskit/icon": "^28.5.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
45
  "@atlaskit/prosemirror-input-rules": "^3.5.0",
46
- "@atlaskit/tmp-editor-statsig": "^13.13.0",
46
+ "@atlaskit/tmp-editor-statsig": "^13.14.0",
47
47
  "@babel/runtime": "^7.0.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@atlaskit/editor-common": "^110.14.0",
50
+ "@atlaskit/editor-common": "^110.15.0",
51
51
  "react": "^18.2.0",
52
52
  "react-intl-next": "npm:react-intl@^5.18.1"
53
53
  },