@atlaskit/editor-plugin-code-block 3.5.11 → 3.5.13

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/editor-commands/index.js +2 -2
  3. package/dist/cjs/nodeviews/code-block.js +24 -3
  4. package/dist/cjs/pm-plugins/codeBlockAutoFullStopTransformPlugin.js +2 -2
  5. package/dist/cjs/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
  6. package/dist/cjs/pm-plugins/ide-ux/bracket-handling.js +4 -0
  7. package/dist/cjs/pm-plugins/ide-ux/line-handling.js +13 -0
  8. package/dist/cjs/pm-plugins/ide-ux/quote-handling.js +8 -0
  9. package/dist/cjs/pm-plugins/ide-ux.js +4 -0
  10. package/dist/cjs/pm-plugins/input-rule.js +16 -1
  11. package/dist/cjs/pm-plugins/main.js +11 -6
  12. package/dist/cjs/pm-plugins/toolbar.js +4 -0
  13. package/dist/cjs/pm-plugins/transform-to-code-block.js +6 -1
  14. package/dist/cjs/pm-plugins/utils.js +3 -19
  15. package/dist/es2019/editor-commands/index.js +4 -4
  16. package/dist/es2019/index.js +3 -0
  17. package/dist/es2019/nodeviews/code-block.js +24 -1
  18. package/dist/es2019/pm-plugins/codeBlockAutoFullStopTransformPlugin.js +1 -1
  19. package/dist/es2019/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
  20. package/dist/es2019/pm-plugins/ide-ux/bracket-handling.js +4 -0
  21. package/dist/es2019/pm-plugins/ide-ux/line-handling.js +13 -0
  22. package/dist/es2019/pm-plugins/ide-ux/quote-handling.js +8 -0
  23. package/dist/es2019/pm-plugins/ide-ux.js +6 -2
  24. package/dist/es2019/pm-plugins/input-rule.js +16 -1
  25. package/dist/es2019/pm-plugins/main.js +6 -1
  26. package/dist/es2019/pm-plugins/toolbar.js +4 -0
  27. package/dist/es2019/pm-plugins/transform-to-code-block.js +7 -1
  28. package/dist/es2019/pm-plugins/utils.js +3 -1
  29. package/dist/esm/editor-commands/index.js +1 -1
  30. package/dist/esm/index.js +3 -0
  31. package/dist/esm/nodeviews/code-block.js +25 -3
  32. package/dist/esm/pm-plugins/codeBlockAutoFullStopTransformPlugin.js +1 -1
  33. package/dist/esm/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
  34. package/dist/esm/pm-plugins/ide-ux/bracket-handling.js +4 -0
  35. package/dist/esm/pm-plugins/ide-ux/line-handling.js +13 -0
  36. package/dist/esm/pm-plugins/ide-ux/quote-handling.js +8 -0
  37. package/dist/esm/pm-plugins/ide-ux.js +4 -0
  38. package/dist/esm/pm-plugins/input-rule.js +16 -1
  39. package/dist/esm/pm-plugins/main.js +6 -1
  40. package/dist/esm/pm-plugins/toolbar.js +4 -0
  41. package/dist/esm/pm-plugins/transform-to-code-block.js +7 -1
  42. package/dist/esm/pm-plugins/utils.js +3 -1
  43. package/dist/types/pm-plugins/main.d.ts +1 -1
  44. package/dist/types/pm-plugins/utils.d.ts +0 -1
  45. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  46. package/dist/types-ts4.5/pm-plugins/utils.d.ts +0 -1
  47. package/package.json +3 -3
@@ -5,16 +5,24 @@ export const QUOTE_MAP = {
5
5
  };
6
6
  export const shouldAutoCloseQuote = (before, after) => {
7
7
  // when directly before a closing bracket
8
+ // Ignored via go/ees005
9
+ // eslint-disable-next-line require-unicode-regexp
8
10
  if (/^[}\])]/.test(after)) {
9
11
  return true;
10
12
  }
11
13
 
12
14
  // exclusion: when directly before a non-whitespace character
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line require-unicode-regexp
13
17
  if (/^[^\s]/.test(after)) {
14
18
  return false;
15
19
  }
16
20
 
17
21
  // exclusion: when directly after a letter or quote
22
+ // Ignored via go/ees005
23
+ // eslint-disable-next-line require-unicode-regexp
24
+ // Ignored via go/ees005
25
+ // eslint-disable-next-line require-unicode-regexp
18
26
  if (/[A-Za-z0-9]$/.test(before) || /[\'\"\`]$/.test(before)) {
19
27
  return false;
20
28
  }
@@ -14,6 +14,8 @@ const ideUX = pluginInjectionApi => {
14
14
  const editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
15
15
  return new SafePlugin({
16
16
  props: {
17
+ // Ignored via go/ees005
18
+ // eslint-disable-next-line @typescript-eslint/max-params
17
19
  handleTextInput(view, from, to, text) {
18
20
  var _pluginInjectionApi$c;
19
21
  const {
@@ -39,7 +41,7 @@ const ideUX = pluginInjectionApi => {
39
41
  } = getAutoClosingBracketInfo(beforeText + text, afterText);
40
42
  if (left && right) {
41
43
  const bracketPair = state.schema.text(text + right);
42
- let tr = state.tr.replaceWith(from, to, bracketPair);
44
+ const tr = state.tr.replaceWith(from, to, bracketPair);
43
45
  dispatch(setTextSelection(from + text.length)(tr));
44
46
  return true;
45
47
  }
@@ -53,7 +55,7 @@ const ideUX = pluginInjectionApi => {
53
55
  } = getAutoClosingQuoteInfo(beforeText + text, afterText);
54
56
  if (leftQuote && rightQuote) {
55
57
  const quotePair = state.schema.text(text + rightQuote);
56
- let tr = state.tr.replaceWith(from, to, quotePair);
58
+ const tr = state.tr.replaceWith(from, to, quotePair);
57
59
  dispatch(setTextSelection(from + text.length)(tr));
58
60
  return true;
59
61
  }
@@ -64,6 +66,8 @@ const ideUX = pluginInjectionApi => {
64
66
  handleKeyDown: keydownHandler({
65
67
  Backspace: (state, dispatch) => {
66
68
  if (isCursorInsideCodeBlock(state)) {
69
+ // Ignored via go/ees005
70
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67
71
  const $cursor = getCursor(state.selection);
68
72
  const beforeText = getStartOfCurrentLine(state).text;
69
73
  const afterText = getEndOfCurrentLine(state).text;
@@ -29,10 +29,16 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
29
29
  eventType: EVENT_TYPE.TRACK
30
30
  }, editorAnalyticsAPI);
31
31
  const validMatchLength = match => match.length > 0 && match[0].length === 3;
32
+
33
+ // Ignored via go/ees005
34
+ // eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
32
35
  const threeTildeRule = createRule(/(?!\s)(`{3,})$/, (state, match, start, end) => {
33
36
  if (!validMatchLength(match)) {
34
37
  return null;
35
38
  }
39
+
40
+ // Ignored via go/ees005
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
42
  const attributes = {};
37
43
  if (match[4]) {
38
44
  attributes.language = match[4];
@@ -46,10 +52,19 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
46
52
  safeInsert(codeBlock)(tr);
47
53
  return tr;
48
54
  });
49
- const leftNodeReplacementThreeTildeRule = createRule(new RegExp(`((${leafNodeReplacementCharacter}\`{3,})|^\\s(\`{3,}))(\\S*)$`), (state, match, start, end) => {
55
+ const leftNodeReplacementThreeTildeRule = createRule(
56
+ // Ignored via go/ees005
57
+ // eslint-disable-next-line require-unicode-regexp
58
+ new RegExp(`((${leafNodeReplacementCharacter}\`{3,})|^\\s(\`{3,}))(\\S*)$`),
59
+ // Ignored via go/ees005
60
+ // eslint-disable-next-line @typescript-eslint/max-params
61
+ (state, match, start, end) => {
50
62
  if (!validMatchLength(match)) {
51
63
  return null;
52
64
  }
65
+
66
+ // Ignored via go/ees005
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
68
  const attributes = {};
54
69
  if (match[4]) {
55
70
  attributes.language = match[4];
@@ -5,6 +5,7 @@ import { updateCodeBlockWrappedStateNodeKeys } from '@atlaskit/editor-common/cod
5
5
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
8
+ import { findCodeBlock } from '@atlaskit/editor-common/transforms';
8
9
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -14,7 +15,7 @@ import { codeBlockClassNames } from '../ui/class-names';
14
15
  import { ACTIONS } from './actions';
15
16
  import { generateInitialDecorations, updateCodeBlockDecorations, updateDecorationSetWithWordWrappedDecorator } from './decorators';
16
17
  import { pluginKey } from './plugin-key';
17
- import { findCodeBlock, getAllChangedCodeBlocksInTransaction, getAllCodeBlockNodesInDoc } from './utils';
18
+ import { getAllChangedCodeBlocksInTransaction, getAllCodeBlockNodesInDoc } from './utils';
18
19
  export const createPlugin = ({
19
20
  useLongPressSelection = false,
20
21
  getIntl,
@@ -36,6 +37,8 @@ export const createPlugin = ({
36
37
  event.preventDefault();
37
38
  return true;
38
39
  } else if (browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && findCodeBlock(view.state, view.state.selection)) {
40
+ // Ignored via go/ees005
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
42
  const resultingText = event.target.outerText + '\n';
40
43
  if (resultingText.endsWith(eventText)) {
41
44
  // End of paragraph
@@ -72,6 +75,8 @@ export const createPlugin = ({
72
75
  decorations: DecorationSet.create(state.doc, initialDecorations)
73
76
  };
74
77
  },
78
+ // Ignored via go/ees005
79
+ // eslint-disable-next-line @typescript-eslint/max-params
75
80
  apply(tr, pluginState, _oldState, newState) {
76
81
  const meta = tr.getMeta(pluginKey);
77
82
  if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
@@ -99,6 +99,8 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
99
99
  };
100
100
  return {
101
101
  title: 'CodeBlock floating controls',
102
+ // Ignored via go/ees005
103
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
102
104
  getDomRef: view => findDomRefAtPos(pos, view.domAtPos.bind(view)),
103
105
  nodeType,
104
106
  items: [languageSelect, separator, codeBlockWrapButton, separator, ...copyToClipboardItems, deleteButton],
@@ -110,6 +112,8 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
110
112
  * Filters language list based on both name and alias properties.
111
113
  */
112
114
  export const languageListFilter = (option, rawInput) => {
115
+ // Ignored via go/ees005
116
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
117
  const {
114
118
  data
115
119
  } = option;
@@ -3,7 +3,13 @@ import { mapSlice, timestampToString } from '@atlaskit/editor-common/utils';
3
3
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
6
- export function transformToCodeBlockAction(state, start, attrs, isNestingInQuoteSupported) {
6
+
7
+ // Ignored via go/ees005
8
+ // eslint-disable-next-line @typescript-eslint/max-params
9
+ export function transformToCodeBlockAction(state, start,
10
+ // Ignored via go/ees005
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ attrs, isNestingInQuoteSupported) {
7
13
  const startOfCodeBlockText = state.selection.$from;
8
14
  const endPosition = state.selection.empty && !(state.selection instanceof GapCursorSelection) ? startOfCodeBlockText.end() : state.selection.$to.pos;
9
15
  const startLinePosition = startOfCodeBlockText.start();
@@ -1,4 +1,3 @@
1
- export { findCodeBlock, transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '@atlaskit/editor-common/transforms';
2
1
  export function getCursor(selection) {
3
2
  return selection.$cursor || undefined;
4
3
  }
@@ -23,6 +22,9 @@ export function getAllChangedCodeBlocksInTransaction(tr) {
23
22
  const nodePositions = new Set();
24
23
  tr.steps.forEach(step => {
25
24
  const mapResult = step.getMap();
25
+
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line @typescript-eslint/max-params
26
28
  mapResult.forEach((oldStart, oldEnd, newStart, newEnd) => {
27
29
  tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), (node, pos) => {
28
30
  if (node.type.name === 'codeBlock') {
@@ -3,13 +3,13 @@ import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
3
3
  import { codeBlockWrappedStates, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
4
4
  import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
5
5
  import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
6
+ import { findCodeBlock } from '@atlaskit/editor-common/transforms';
6
7
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
8
  import { findParentNodeOfType, findSelectedNodeOfType, isNodeSelection, removeParentNodeOfType, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
8
9
  import { ACTIONS } from '../pm-plugins/actions';
9
10
  import { copySelectionPluginKey } from '../pm-plugins/codeBlockCopySelectionPlugin';
10
11
  import { pluginKey } from '../pm-plugins/plugin-key';
11
12
  import { transformToCodeBlockAction } from '../pm-plugins/transform-to-code-block';
12
- import { findCodeBlock } from '../pm-plugins/utils';
13
13
  export var removeCodeBlock = function removeCodeBlock(state, dispatch) {
14
14
  var nodes = state.schema.nodes,
15
15
  tr = state.tr;
package/dist/esm/index.js CHANGED
@@ -1 +1,4 @@
1
+ /* eslint-disable @atlaskit/editor/no-re-export */
2
+ // Entry file in package.json
3
+
1
4
  export { default as codeBlockPlugin } from './codeBlockPlugin';
@@ -8,6 +8,9 @@ import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
9
9
  import { getPluginState } from '../pm-plugins/main-state';
10
10
  import { codeBlockClassNames } from '../ui/class-names';
11
+
12
+ // Ignored via go/ees005
13
+ // eslint-disable-next-line require-unicode-regexp
11
14
  var MATCH_NEWLINES = new RegExp('\n', 'g');
12
15
  var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
13
16
  return ['div', {
@@ -34,6 +37,8 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
34
37
  }]];
35
38
  };
36
39
  export var CodeBlockView = /*#__PURE__*/function () {
40
+ // Ignored via go/ees005
41
+ // eslint-disable-next-line @typescript-eslint/max-params
37
42
  function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
38
43
  var _this = this,
39
44
  _api$editorDisabled;
@@ -47,6 +52,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
47
52
  _this.node.forEach(function (node) {
48
53
  var text = node.text;
49
54
  if (text) {
55
+ // Ignored via go/ees005
56
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
50
57
  totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
51
58
  }
52
59
  });
@@ -60,8 +67,14 @@ export var CodeBlockView = /*#__PURE__*/function () {
60
67
  this.getPos = getPos;
61
68
  this.view = view;
62
69
  this.node = _node;
70
+ // Ignored via go/ees005
71
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
63
72
  this.dom = dom;
73
+ // Ignored via go/ees005
74
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
64
75
  this.contentDOM = contentDOM;
76
+ // Ignored via go/ees005
77
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
65
78
  this.lineNumberGutter = this.dom.querySelector(".".concat(codeBlockClassNames.gutter));
66
79
  this.api = api;
67
80
  this.maintainDynamicGutterSize();
@@ -73,7 +86,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
73
86
  }
74
87
  this.handleEditorDisabledChanged();
75
88
  }
76
- _createClass(CodeBlockView, [{
89
+ return _createClass(CodeBlockView, [{
77
90
  key: "handleEditorDisabledChanged",
78
91
  value: function handleEditorDisabledChanged() {
79
92
  var _this$api,
@@ -95,6 +108,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
95
108
  var contentWrapper = this.dom.childNodes[1];
96
109
  var contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
97
110
  if ((contentView === null || contentView === void 0 || (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
111
+ // Ignored via go/ees005
112
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
98
113
  var codeElement = contentView.firstChild;
99
114
  codeElement.innerHTML = savedInnerHTML;
100
115
 
@@ -121,10 +136,15 @@ export var CodeBlockView = /*#__PURE__*/function () {
121
136
  if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
122
137
  var savedInnerHTML = '';
123
138
  while (contentView.childNodes.length > 1) {
139
+ // Ignored via go/ees005
140
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
124
141
  var lastChild = contentView.lastChild;
125
142
  savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
126
143
  contentView.removeChild(lastChild);
127
144
  }
145
+
146
+ // Ignored via go/ees005
147
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
128
148
  var firstChild = contentView.firstChild;
129
149
  savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
130
150
  var newCursorPosition = firstChild.innerHTML.length + 1;
@@ -174,8 +194,10 @@ export var CodeBlockView = /*#__PURE__*/function () {
174
194
  this.cleanupEditorDisabledListener = undefined;
175
195
  }
176
196
  }]);
177
- return CodeBlockView;
178
197
  }();
179
- export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
198
+ export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
199
+ // Ignored via go/ees005
200
+ // eslint-disable-next-line @typescript-eslint/max-params
201
+ ) {
180
202
  return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
181
203
  };
@@ -1,8 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { findCodeBlock } from '@atlaskit/editor-common/transforms';
2
3
  import { browser } from '@atlaskit/editor-common/utils';
3
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
5
- import { findCodeBlock } from './utils';
6
6
  export var codeBlockAutoFullStopTransformPluginKey = new PluginKey('codeBlockAutoFullStopTransformPluginKey');
7
7
  export function codeBlockAutoFullStopTransformPlugin() {
8
8
  return new SafePlugin({
@@ -30,6 +30,8 @@ export function codeBlockCopySelectionPlugin() {
30
30
  decorationStartAndEnd: undefined
31
31
  };
32
32
  },
33
+ // Ignored via go/ees005
34
+ // eslint-disable-next-line @typescript-eslint/max-params
33
35
  apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
34
36
  switch (transaction.getMeta(copySelectionPluginKey)) {
35
37
  case 'show-selection':
@@ -5,11 +5,15 @@ export var BRACKET_MAP = {
5
5
  };
6
6
  export var shouldAutoCloseBracket = function shouldAutoCloseBracket(before, after) {
7
7
  // when directly before a closing bracket
8
+ // Ignored via go/ees005
9
+ // eslint-disable-next-line require-unicode-regexp
8
10
  if (/^[}\])]/.test(after)) {
9
11
  return true;
10
12
  }
11
13
 
12
14
  // exclusion: when directly before a non-whitespace character
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line require-unicode-regexp
13
17
  if (/^[^\s]/.test(after)) {
14
18
  return false;
15
19
  }
@@ -8,8 +8,12 @@ export var isCursorInsideCodeBlock = function isCursorInsideCodeBlock(state) {
8
8
  export var getStartOfCurrentLine = function getStartOfCurrentLine(state) {
9
9
  var $from = state.selection.$from;
10
10
  if ($from.nodeBefore && $from.nodeBefore.isText) {
11
+ // Ignored via go/ees005
12
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
13
  var prevNewLineIndex = $from.nodeBefore.text.lastIndexOf('\n');
12
14
  return {
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13
17
  text: $from.nodeBefore.text.substring(prevNewLineIndex + 1),
14
18
  pos: $from.start() + prevNewLineIndex + 1
15
19
  };
@@ -22,8 +26,12 @@ export var getStartOfCurrentLine = function getStartOfCurrentLine(state) {
22
26
  export var getEndOfCurrentLine = function getEndOfCurrentLine(state) {
23
27
  var $to = state.selection.$to;
24
28
  if ($to.nodeAfter && $to.nodeAfter.isText) {
29
+ // Ignored via go/ees005
30
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
25
31
  var nextNewLineIndex = $to.nodeAfter.text.indexOf('\n');
26
32
  return {
33
+ // Ignored via go/ees005
34
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
27
35
  text: $to.nodeAfter.text.substring(0, nextNewLineIndex >= 0 ? nextNewLineIndex : undefined),
28
36
  pos: nextNewLineIndex >= 0 ? $to.pos + nextNewLineIndex : $to.end()
29
37
  };
@@ -52,11 +60,16 @@ export var forEachLine = function forEachLine(text, callback) {
52
60
  offset += line.length + 1;
53
61
  });
54
62
  };
63
+
64
+ // Ignored via go/ees005
65
+ // eslint-disable-next-line require-unicode-regexp
55
66
  var SPACE = {
56
67
  token: ' ',
57
68
  size: 2,
58
69
  regex: /[^ ]/
59
70
  };
71
+ // Ignored via go/ees005
72
+ // eslint-disable-next-line require-unicode-regexp
60
73
  var TAB = {
61
74
  token: '\t',
62
75
  size: 1,
@@ -5,16 +5,24 @@ export var QUOTE_MAP = {
5
5
  };
6
6
  export var shouldAutoCloseQuote = function shouldAutoCloseQuote(before, after) {
7
7
  // when directly before a closing bracket
8
+ // Ignored via go/ees005
9
+ // eslint-disable-next-line require-unicode-regexp
8
10
  if (/^[}\])]/.test(after)) {
9
11
  return true;
10
12
  }
11
13
 
12
14
  // exclusion: when directly before a non-whitespace character
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line require-unicode-regexp
13
17
  if (/^[^\s]/.test(after)) {
14
18
  return false;
15
19
  }
16
20
 
17
21
  // exclusion: when directly after a letter or quote
22
+ // Ignored via go/ees005
23
+ // eslint-disable-next-line require-unicode-regexp
24
+ // Ignored via go/ees005
25
+ // eslint-disable-next-line require-unicode-regexp
18
26
  if (/[A-Za-z0-9]$/.test(before) || /[\'\"\`]$/.test(before)) {
19
27
  return false;
20
28
  }
@@ -14,6 +14,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
14
14
  var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
15
15
  return new SafePlugin({
16
16
  props: {
17
+ // Ignored via go/ees005
18
+ // eslint-disable-next-line @typescript-eslint/max-params
17
19
  handleTextInput: function handleTextInput(view, from, to, text) {
18
20
  var _pluginInjectionApi$c;
19
21
  var state = view.state,
@@ -60,6 +62,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
60
62
  handleKeyDown: keydownHandler({
61
63
  Backspace: function Backspace(state, dispatch) {
62
64
  if (isCursorInsideCodeBlock(state)) {
65
+ // Ignored via go/ees005
66
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
63
67
  var $cursor = getCursor(state.selection);
64
68
  var beforeText = getStartOfCurrentLine(state).text;
65
69
  var afterText = getEndOfCurrentLine(state).text;
@@ -31,10 +31,16 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
31
31
  var validMatchLength = function validMatchLength(match) {
32
32
  return match.length > 0 && match[0].length === 3;
33
33
  };
34
+
35
+ // Ignored via go/ees005
36
+ // eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
34
37
  var threeTildeRule = createRule(/(?!\s)(`{3,})$/, function (state, match, start, end) {
35
38
  if (!validMatchLength(match)) {
36
39
  return null;
37
40
  }
41
+
42
+ // Ignored via go/ees005
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
44
  var attributes = {};
39
45
  if (match[4]) {
40
46
  attributes.language = match[4];
@@ -48,10 +54,19 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
48
54
  safeInsert(codeBlock)(tr);
49
55
  return tr;
50
56
  });
51
- var leftNodeReplacementThreeTildeRule = createRule(new RegExp("((".concat(leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")), function (state, match, start, end) {
57
+ var leftNodeReplacementThreeTildeRule = createRule(
58
+ // Ignored via go/ees005
59
+ // eslint-disable-next-line require-unicode-regexp
60
+ new RegExp("((".concat(leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")),
61
+ // Ignored via go/ees005
62
+ // eslint-disable-next-line @typescript-eslint/max-params
63
+ function (state, match, start, end) {
52
64
  if (!validMatchLength(match)) {
53
65
  return null;
54
66
  }
67
+
68
+ // Ignored via go/ees005
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
70
  var attributes = {};
56
71
  if (match[4]) {
57
72
  attributes.language = match[4];
@@ -8,6 +8,7 @@ import { updateCodeBlockWrappedStateNodeKeys } from '@atlaskit/editor-common/cod
8
8
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
9
9
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
10
10
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
11
+ import { findCodeBlock } from '@atlaskit/editor-common/transforms';
11
12
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
13
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
13
14
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -17,7 +18,7 @@ import { codeBlockClassNames } from '../ui/class-names';
17
18
  import { ACTIONS } from './actions';
18
19
  import { generateInitialDecorations, updateCodeBlockDecorations, updateDecorationSetWithWordWrappedDecorator } from './decorators';
19
20
  import { pluginKey } from './plugin-key';
20
- import { findCodeBlock, getAllChangedCodeBlocksInTransaction, getAllCodeBlockNodesInDoc } from './utils';
21
+ import { getAllChangedCodeBlocksInTransaction, getAllCodeBlockNodesInDoc } from './utils';
21
22
  export var createPlugin = function createPlugin(_ref) {
22
23
  var _ref$useLongPressSele = _ref.useLongPressSelection,
23
24
  useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele,
@@ -40,6 +41,8 @@ export var createPlugin = function createPlugin(_ref) {
40
41
  event.preventDefault();
41
42
  return true;
42
43
  } else if (browser.android && event.composed && eventInputType === 'insertCompositionText' && eventText[(eventText === null || eventText === void 0 ? void 0 : eventText.length) - 1] === '\n' && findCodeBlock(view.state, view.state.selection)) {
44
+ // Ignored via go/ees005
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
46
  var resultingText = event.target.outerText + '\n';
44
47
  if (resultingText.endsWith(eventText)) {
45
48
  // End of paragraph
@@ -78,6 +81,8 @@ export var createPlugin = function createPlugin(_ref) {
78
81
  decorations: DecorationSet.create(state.doc, initialDecorations)
79
82
  };
80
83
  },
84
+ // Ignored via go/ees005
85
+ // eslint-disable-next-line @typescript-eslint/max-params
81
86
  apply: function apply(tr, pluginState, _oldState, newState) {
82
87
  var meta = tr.getMeta(pluginKey);
83
88
  if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
@@ -108,6 +108,8 @@ export var getToolbarConfig = function getToolbarConfig() {
108
108
  };
109
109
  return {
110
110
  title: 'CodeBlock floating controls',
111
+ // Ignored via go/ees005
112
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
111
113
  getDomRef: function getDomRef(view) {
112
114
  return findDomRefAtPos(pos, view.domAtPos.bind(view));
113
115
  },
@@ -122,6 +124,8 @@ export var getToolbarConfig = function getToolbarConfig() {
122
124
  * Filters language list based on both name and alias properties.
123
125
  */
124
126
  export var languageListFilter = function languageListFilter(option, rawInput) {
127
+ // Ignored via go/ees005
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
129
  var _ref3 = option,
126
130
  data = _ref3.data;
127
131
  var searchString = rawInput.toLowerCase();
@@ -3,7 +3,13 @@ import { mapSlice, timestampToString } from '@atlaskit/editor-common/utils';
3
3
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
6
- export function transformToCodeBlockAction(state, start, attrs, isNestingInQuoteSupported) {
6
+
7
+ // Ignored via go/ees005
8
+ // eslint-disable-next-line @typescript-eslint/max-params
9
+ export function transformToCodeBlockAction(state, start,
10
+ // Ignored via go/ees005
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ attrs, isNestingInQuoteSupported) {
7
13
  var startOfCodeBlockText = state.selection.$from;
8
14
  var endPosition = state.selection.empty && !(state.selection instanceof GapCursorSelection) ? startOfCodeBlockText.end() : state.selection.$to.pos;
9
15
  var startLinePosition = startOfCodeBlockText.start();
@@ -1,4 +1,3 @@
1
- export { findCodeBlock, transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '@atlaskit/editor-common/transforms';
2
1
  export function getCursor(selection) {
3
2
  return selection.$cursor || undefined;
4
3
  }
@@ -23,6 +22,9 @@ export function getAllChangedCodeBlocksInTransaction(tr) {
23
22
  var nodePositions = new Set();
24
23
  tr.steps.forEach(function (step) {
25
24
  var mapResult = step.getMap();
25
+
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line @typescript-eslint/max-params
26
28
  mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
27
29
  tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
28
30
  if (node.type.name === 'codeBlock') {
@@ -21,7 +21,7 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
21
21
  }, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
22
22
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
23
23
  sharedState: {
24
- createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
24
+ createAnalyticsEvent: import("packages/analytics/analytics-next/dist/types").CreateUIAnalyticsEvent | null;
25
25
  attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
26
26
  performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
27
27
  };
@@ -1,4 +1,3 @@
1
- export { findCodeBlock, transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark, } from '@atlaskit/editor-common/transforms';
2
1
  import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
3
2
  import type { EditorState, ReadonlyTransaction, Selection } from '@atlaskit/editor-prosemirror/state';
4
3
  import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
@@ -24,7 +24,7 @@ export declare const createPlugin: ({ useLongPressSelection, getIntl, allowCompo
24
24
  import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
25
25
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
26
26
  sharedState: {
27
- createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
27
+ createAnalyticsEvent: import("packages/analytics/analytics-next/dist/types").CreateUIAnalyticsEvent | null;
28
28
  attachAnalyticsEvent: import("@atlaskit/editor-plugin-analytics").CreateAttachPayloadIntoTransaction | null;
29
29
  performanceTracking: import("@atlaskit/editor-common/types").PerformanceTracking | undefined;
30
30
  };
@@ -1,4 +1,3 @@
1
- export { findCodeBlock, transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark, } from '@atlaskit/editor-common/transforms';
2
1
  import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
3
2
  import type { EditorState, ReadonlyTransaction, Selection } from '@atlaskit/editor-prosemirror/state';
4
3
  import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "3.5.11",
3
+ "version": "3.5.13",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,13 +33,13 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^46.1.0",
35
35
  "@atlaskit/code": "^15.6.0",
36
- "@atlaskit/editor-common": "^96.0.0",
36
+ "@atlaskit/editor-common": "^98.0.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
38
38
  "@atlaskit/editor-plugin-composition": "^1.2.0",
39
39
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
40
40
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
41
41
  "@atlaskit/editor-prosemirror": "6.2.1",
42
- "@atlaskit/icon": "^23.0.0",
42
+ "@atlaskit/icon": "^23.1.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.3.0",
44
44
  "@atlaskit/prosemirror-input-rules": "^3.2.0",
45
45
  "@babel/runtime": "^7.0.0"