@atlaskit/editor-plugin-code-block 8.0.9 → 8.0.11

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.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`76178d0e6e20d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/76178d0e6e20d) -
8
+ [ux] ED-29503 Update createInsertCodeBlockTransaction to pass in attributes when creating a new
9
+ node
10
+ - Updated dependencies
11
+
12
+ ## 8.0.10
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 8.0.9
4
19
 
5
20
  ### Patch Changes
@@ -154,7 +154,10 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
154
154
  },
155
155
  action: function action(_insert, state) {
156
156
  var tr = (0, _editorCommands.createInsertCodeBlockTransaction)({
157
- state: state
157
+ state: state,
158
+ attributes: {
159
+ language: 'text'
160
+ }
158
161
  });
159
162
  return tr;
160
163
  }
@@ -16,6 +16,7 @@ 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");
19
20
  var _actions = require("../pm-plugins/actions");
20
21
  var _codeBlockCopySelectionPlugin = require("../pm-plugins/codeBlockCopySelectionPlugin");
21
22
  var _pluginKey = require("../pm-plugins/plugin-key");
@@ -177,7 +178,8 @@ var resetShouldIgnoreFollowingMutations = exports.resetShouldIgnoreFollowingMuta
177
178
  * append the codeblock to the end of the document.
178
179
  */
179
180
  function createInsertCodeBlockTransaction(_ref) {
180
- var state = _ref.state;
181
+ var state = _ref.state,
182
+ attributes = _ref.attributes;
181
183
  var tr = state.tr;
182
184
  var from = state.selection.from;
183
185
  var codeBlock = state.schema.nodes.codeBlock;
@@ -193,12 +195,12 @@ function createInsertCodeBlockTransaction(_ref) {
193
195
  var canInsertCodeBlock = (0, _insert.shouldSplitSelectedNodeOnNodeInsertion)({
194
196
  parentNodeType: parentNodeType,
195
197
  grandParentNodeType: grandParentNodeType,
196
- content: codeBlock.createAndFill()
198
+ content: codeBlock.createAndFill((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined)
197
199
  }) && (0, _insert.contentAllowedInCodeBlock)(state);
198
200
  if (canInsertCodeBlock) {
199
- tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from, undefined);
201
+ tr = (0, _transformToCodeBlock.transformToCodeBlockAction)(state, from, (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined);
200
202
  } else {
201
- (0, _utils.safeInsert)(codeBlock.createAndFill())(tr).scrollIntoView();
203
+ (0, _utils.safeInsert)(codeBlock.createAndFill((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined))(tr).scrollIntoView();
202
204
  }
203
205
  return tr;
204
206
  }
@@ -136,7 +136,10 @@ const codeBlockPlugin = ({
136
136
  icon: () => /*#__PURE__*/React.createElement(IconCode, null),
137
137
  action(_insert, state) {
138
138
  const tr = createInsertCodeBlockTransaction({
139
- state
139
+ state,
140
+ attributes: {
141
+ language: 'text'
142
+ }
140
143
  });
141
144
  return tr;
142
145
  }
@@ -6,6 +6,7 @@ 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';
9
10
  import { ACTIONS } from '../pm-plugins/actions';
10
11
  import { copySelectionPluginKey } from '../pm-plugins/codeBlockCopySelectionPlugin';
11
12
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -181,7 +182,8 @@ export const resetShouldIgnoreFollowingMutations = (state, dispatch) => {
181
182
  * append the codeblock to the end of the document.
182
183
  */
183
184
  export function createInsertCodeBlockTransaction({
184
- state
185
+ state,
186
+ attributes
185
187
  }) {
186
188
  let {
187
189
  tr
@@ -204,12 +206,12 @@ export function createInsertCodeBlockTransaction({
204
206
  const canInsertCodeBlock = shouldSplitSelectedNodeOnNodeInsertion({
205
207
  parentNodeType,
206
208
  grandParentNodeType,
207
- content: codeBlock.createAndFill()
209
+ content: codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined)
208
210
  }) && contentAllowedInCodeBlock(state);
209
211
  if (canInsertCodeBlock) {
210
- tr = transformToCodeBlockAction(state, from, undefined);
212
+ tr = transformToCodeBlockAction(state, from, expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined);
211
213
  } else {
212
- safeInsert(codeBlock.createAndFill())(tr).scrollIntoView();
214
+ safeInsert(codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined))(tr).scrollIntoView();
213
215
  }
214
216
  return tr;
215
217
  }
@@ -147,7 +147,10 @@ var codeBlockPlugin = function codeBlockPlugin(_ref) {
147
147
  },
148
148
  action: function action(_insert, state) {
149
149
  var tr = createInsertCodeBlockTransaction({
150
- state: state
150
+ state: state,
151
+ attributes: {
152
+ language: 'text'
153
+ }
151
154
  });
152
155
  return tr;
153
156
  }
@@ -6,6 +6,7 @@ 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';
9
10
  import { ACTIONS } from '../pm-plugins/actions';
10
11
  import { copySelectionPluginKey } from '../pm-plugins/codeBlockCopySelectionPlugin';
11
12
  import { pluginKey } from '../pm-plugins/plugin-key';
@@ -167,7 +168,8 @@ export var resetShouldIgnoreFollowingMutations = function resetShouldIgnoreFollo
167
168
  * append the codeblock to the end of the document.
168
169
  */
169
170
  export function createInsertCodeBlockTransaction(_ref) {
170
- var state = _ref.state;
171
+ var state = _ref.state,
172
+ attributes = _ref.attributes;
171
173
  var tr = state.tr;
172
174
  var from = state.selection.from;
173
175
  var codeBlock = state.schema.nodes.codeBlock;
@@ -183,12 +185,12 @@ export function createInsertCodeBlockTransaction(_ref) {
183
185
  var canInsertCodeBlock = shouldSplitSelectedNodeOnNodeInsertion({
184
186
  parentNodeType: parentNodeType,
185
187
  grandParentNodeType: grandParentNodeType,
186
- content: codeBlock.createAndFill()
188
+ content: codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined)
187
189
  }) && contentAllowedInCodeBlock(state);
188
190
  if (canInsertCodeBlock) {
189
- tr = transformToCodeBlockAction(state, from, undefined);
191
+ tr = transformToCodeBlockAction(state, from, expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined);
190
192
  } else {
191
- safeInsert(codeBlock.createAndFill())(tr).scrollIntoView();
193
+ safeInsert(codeBlock.createAndFill(expValEqualsNoExposure('platform_editor_plain_text_support', 'isEnabled', true) ? attributes : undefined))(tr).scrollIntoView();
192
194
  }
193
195
  return tr;
194
196
  }
@@ -1,3 +1,4 @@
1
+ import type { CodeBlockAttrs } from '@atlaskit/adf-schema';
1
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
4
  import type { Command } from '@atlaskit/editor-common/types';
@@ -15,7 +16,8 @@ export declare const resetShouldIgnoreFollowingMutations: Command;
15
16
  * if there is text selected it will wrap the current selection if not it will
16
17
  * append the codeblock to the end of the document.
17
18
  */
18
- export declare function createInsertCodeBlockTransaction({ state }: {
19
+ export declare function createInsertCodeBlockTransaction({ state, attributes, }: {
20
+ attributes?: CodeBlockAttrs;
19
21
  state: EditorState;
20
22
  }): import("prosemirror-state").Transaction;
21
23
  export declare function insertCodeBlockWithAnalytics(inputMethod: INPUT_METHOD, analyticsAPI?: EditorAnalyticsAPI): Command;
@@ -1,3 +1,4 @@
1
+ import type { CodeBlockAttrs } from '@atlaskit/adf-schema';
1
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
4
  import type { Command } from '@atlaskit/editor-common/types';
@@ -15,7 +16,8 @@ export declare const resetShouldIgnoreFollowingMutations: Command;
15
16
  * if there is text selected it will wrap the current selection if not it will
16
17
  * append the codeblock to the end of the document.
17
18
  */
18
- export declare function createInsertCodeBlockTransaction({ state }: {
19
+ export declare function createInsertCodeBlockTransaction({ state, attributes, }: {
20
+ attributes?: CodeBlockAttrs;
19
21
  state: EditorState;
20
22
  }): import("prosemirror-state").Transaction;
21
23
  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.0.9",
3
+ "version": "8.0.11",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,13 +37,13 @@
37
37
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
38
38
  "@atlaskit/editor-plugin-interaction": "^8.0.0",
39
39
  "@atlaskit/editor-plugin-selection": "^6.1.0",
40
- "@atlaskit/editor-plugin-toolbar": "^3.1.0",
40
+ "@atlaskit/editor-plugin-toolbar": "^3.2.0",
41
41
  "@atlaskit/editor-prosemirror": "7.0.0",
42
- "@atlaskit/editor-toolbar": "^0.14.0",
42
+ "@atlaskit/editor-toolbar": "^0.15.0",
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.7.0",
46
+ "@atlaskit/tmp-editor-statsig": "^13.9.0",
47
47
  "@babel/runtime": "^7.0.0"
48
48
  },
49
49
  "peerDependencies": {