@atlaskit/editor-plugin-code-block 8.1.1 → 8.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,19 @@
1
1
  # @atlaskit/editor-plugin-code-block
2
2
 
3
+ ## 8.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 8.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`a4fbfc862e34f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a4fbfc862e34f) -
14
+ [ux] ED-29557 Clean up plain text quick insert as it's not needed
15
+ - Updated dependencies
16
+
3
17
  ## 8.1.1
4
18
 
5
19
  ### Patch 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
  }
@@ -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
  }
@@ -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
  }
@@ -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.1",
3
+ "version": "8.1.3",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,7 +30,7 @@
30
30
  "@atlaskit/adf-schema": "^51.3.0",
31
31
  "@atlaskit/code": "^17.2.0",
32
32
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
33
- "@atlaskit/editor-plugin-block-menu": "^4.0.0",
33
+ "@atlaskit/editor-plugin-block-menu": "^5.0.0",
34
34
  "@atlaskit/editor-plugin-composition": "^5.0.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
36
36
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.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.16.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
  },