@atlaskit/editor-plugin-code-block 3.5.12 → 3.5.14

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 (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/nodeviews/code-block.js +23 -5
  3. package/dist/cjs/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
  4. package/dist/cjs/pm-plugins/decorators.js +2 -8
  5. package/dist/cjs/pm-plugins/ide-ux/bracket-handling.js +4 -0
  6. package/dist/cjs/pm-plugins/ide-ux/line-handling.js +13 -0
  7. package/dist/cjs/pm-plugins/ide-ux/quote-handling.js +8 -0
  8. package/dist/cjs/pm-plugins/ide-ux.js +4 -0
  9. package/dist/cjs/pm-plugins/input-rule.js +16 -1
  10. package/dist/cjs/pm-plugins/main.js +5 -3
  11. package/dist/cjs/pm-plugins/toolbar.js +4 -0
  12. package/dist/cjs/pm-plugins/transform-to-code-block.js +6 -1
  13. package/dist/cjs/pm-plugins/utils.js +3 -0
  14. package/dist/es2019/editor-commands/index.js +3 -3
  15. package/dist/es2019/nodeviews/code-block.js +25 -6
  16. package/dist/es2019/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
  17. package/dist/es2019/pm-plugins/decorators.js +2 -8
  18. package/dist/es2019/pm-plugins/ide-ux/bracket-handling.js +4 -0
  19. package/dist/es2019/pm-plugins/ide-ux/line-handling.js +13 -0
  20. package/dist/es2019/pm-plugins/ide-ux/quote-handling.js +8 -0
  21. package/dist/es2019/pm-plugins/ide-ux.js +6 -2
  22. package/dist/es2019/pm-plugins/input-rule.js +16 -1
  23. package/dist/es2019/pm-plugins/main.js +5 -3
  24. package/dist/es2019/pm-plugins/toolbar.js +4 -0
  25. package/dist/es2019/pm-plugins/transform-to-code-block.js +7 -1
  26. package/dist/es2019/pm-plugins/utils.js +3 -0
  27. package/dist/esm/nodeviews/code-block.js +25 -6
  28. package/dist/esm/pm-plugins/codeBlockCopySelectionPlugin.js +2 -0
  29. package/dist/esm/pm-plugins/decorators.js +2 -8
  30. package/dist/esm/pm-plugins/ide-ux/bracket-handling.js +4 -0
  31. package/dist/esm/pm-plugins/ide-ux/line-handling.js +13 -0
  32. package/dist/esm/pm-plugins/ide-ux/quote-handling.js +8 -0
  33. package/dist/esm/pm-plugins/ide-ux.js +4 -0
  34. package/dist/esm/pm-plugins/input-rule.js +16 -1
  35. package/dist/esm/pm-plugins/main.js +5 -3
  36. package/dist/esm/pm-plugins/toolbar.js +4 -0
  37. package/dist/esm/pm-plugins/transform-to-code-block.js +7 -1
  38. package/dist/esm/pm-plugins/utils.js +3 -0
  39. package/dist/types/pm-plugins/main.d.ts +1 -1
  40. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  41. package/package.json +2 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-code-block
2
2
 
3
+ ## 3.5.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [#98963](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98963)
8
+ [`3638dcf79b6c7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3638dcf79b6c7) -
9
+ ED-26126 Cleanup code wrapping language bug fg
10
+
11
+ ## 3.5.13
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 3.5.12
4
18
 
5
19
  ### Patch Changes
@@ -11,10 +11,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
  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
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
14
  var _editorCommands = require("../editor-commands");
16
15
  var _mainState = require("../pm-plugins/main-state");
17
16
  var _classNames = require("../ui/class-names");
17
+ // Ignored via go/ees005
18
+ // eslint-disable-next-line require-unicode-regexp
18
19
  var MATCH_NEWLINES = new RegExp('\n', 'g');
19
20
  var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
20
21
  return ['div', {
@@ -41,6 +42,8 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
41
42
  }]];
42
43
  };
43
44
  var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
45
+ // Ignored via go/ees005
46
+ // eslint-disable-next-line @typescript-eslint/max-params
44
47
  function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
45
48
  var _this = this,
46
49
  _api$editorDisabled;
@@ -54,6 +57,8 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
54
57
  _this.node.forEach(function (node) {
55
58
  var text = node.text;
56
59
  if (text) {
60
+ // Ignored via go/ees005
61
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
62
  totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
58
63
  }
59
64
  });
@@ -67,8 +72,14 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
67
72
  this.getPos = getPos;
68
73
  this.view = view;
69
74
  this.node = _node;
75
+ // Ignored via go/ees005
76
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
70
77
  this.dom = dom;
78
+ // Ignored via go/ees005
79
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
71
80
  this.contentDOM = contentDOM;
81
+ // Ignored via go/ees005
82
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
72
83
  this.lineNumberGutter = this.dom.querySelector(".".concat(_classNames.codeBlockClassNames.gutter));
73
84
  this.api = api;
74
85
  this.maintainDynamicGutterSize();
@@ -102,6 +113,8 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
102
113
  var contentWrapper = this.dom.childNodes[1];
103
114
  var contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
104
115
  if ((contentView === null || contentView === void 0 || (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
116
+ // Ignored via go/ees005
117
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
105
118
  var codeElement = contentView.firstChild;
106
119
  codeElement.innerHTML = savedInnerHTML;
107
120
 
@@ -128,10 +141,15 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
128
141
  if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
129
142
  var savedInnerHTML = '';
130
143
  while (contentView.childNodes.length > 1) {
144
+ // Ignored via go/ees005
145
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
131
146
  var lastChild = contentView.lastChild;
132
147
  savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
133
148
  contentView.removeChild(lastChild);
134
149
  }
150
+
151
+ // Ignored via go/ees005
152
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
135
153
  var firstChild = contentView.firstChild;
136
154
  savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
137
155
  var newCursorPosition = firstChild.innerHTML.length + 1;
@@ -146,9 +164,6 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
146
164
  return false;
147
165
  }
148
166
  if (node !== this.node) {
149
- if (!(0, _platformFeatureFlags.fg)('editor_code_block_wrapping_language_change_bug')) {
150
- (0, _codeBlock.transferCodeBlockWrappedValue)(this.node, node);
151
- }
152
167
  if (node.attrs.language !== this.node.attrs.language) {
153
168
  this.contentDOM.setAttribute('data-language', node.attrs.language || '');
154
169
  }
@@ -182,6 +197,9 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
182
197
  }
183
198
  }]);
184
199
  }();
185
- var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
200
+ var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
201
+ // Ignored via go/ees005
202
+ // eslint-disable-next-line @typescript-eslint/max-params
203
+ ) {
186
204
  return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
187
205
  };
@@ -40,6 +40,8 @@ function codeBlockCopySelectionPlugin() {
40
40
  decorationStartAndEnd: undefined
41
41
  };
42
42
  },
43
+ // Ignored via go/ees005
44
+ // eslint-disable-next-line @typescript-eslint/max-params
43
45
  apply: function apply(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
44
46
  switch (transaction.getMeta(copySelectionPluginKey)) {
45
47
  case 'show-selection':
@@ -142,14 +142,8 @@ var validateWordWrappedDecorators = exports.validateWordWrappedDecorators = func
142
142
  codeBlockNodes.forEach(function (node) {
143
143
  var isCodeBlockWrappedInState = (0, _codeBlock.isCodeBlockWordWrapEnabled)(node.node);
144
144
  var isCodeBlockWrappedByDecorator = getWordWrapDecoratorsFromNodePos(node.pos, decorationSet).length !== 0;
145
- if ((0, _platformFeatureFlags.fg)('editor_code_block_wrapping_language_change_bug')) {
146
- if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
147
- updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
148
- }
149
- } else {
150
- if (isCodeBlockWrappedInState && !isCodeBlockWrappedByDecorator) {
151
- updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
152
- }
145
+ if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
146
+ updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
153
147
  }
154
148
  });
155
149
  return updatedDecorationSet;
@@ -11,11 +11,15 @@ var BRACKET_MAP = exports.BRACKET_MAP = {
11
11
  };
12
12
  var shouldAutoCloseBracket = exports.shouldAutoCloseBracket = function shouldAutoCloseBracket(before, after) {
13
13
  // when directly before a closing bracket
14
+ // Ignored via go/ees005
15
+ // eslint-disable-next-line require-unicode-regexp
14
16
  if (/^[}\])]/.test(after)) {
15
17
  return true;
16
18
  }
17
19
 
18
20
  // exclusion: when directly before a non-whitespace character
21
+ // Ignored via go/ees005
22
+ // eslint-disable-next-line require-unicode-regexp
19
23
  if (/^[^\s]/.test(after)) {
20
24
  return false;
21
25
  }
@@ -16,8 +16,12 @@ var isCursorInsideCodeBlock = exports.isCursorInsideCodeBlock = function isCurso
16
16
  var getStartOfCurrentLine = exports.getStartOfCurrentLine = function getStartOfCurrentLine(state) {
17
17
  var $from = state.selection.$from;
18
18
  if ($from.nodeBefore && $from.nodeBefore.isText) {
19
+ // Ignored via go/ees005
20
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
21
  var prevNewLineIndex = $from.nodeBefore.text.lastIndexOf('\n');
20
22
  return {
23
+ // Ignored via go/ees005
24
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
21
25
  text: $from.nodeBefore.text.substring(prevNewLineIndex + 1),
22
26
  pos: $from.start() + prevNewLineIndex + 1
23
27
  };
@@ -30,8 +34,12 @@ var getStartOfCurrentLine = exports.getStartOfCurrentLine = function getStartOfC
30
34
  var getEndOfCurrentLine = exports.getEndOfCurrentLine = function getEndOfCurrentLine(state) {
31
35
  var $to = state.selection.$to;
32
36
  if ($to.nodeAfter && $to.nodeAfter.isText) {
37
+ // Ignored via go/ees005
38
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
39
  var nextNewLineIndex = $to.nodeAfter.text.indexOf('\n');
34
40
  return {
41
+ // Ignored via go/ees005
42
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
35
43
  text: $to.nodeAfter.text.substring(0, nextNewLineIndex >= 0 ? nextNewLineIndex : undefined),
36
44
  pos: nextNewLineIndex >= 0 ? $to.pos + nextNewLineIndex : $to.end()
37
45
  };
@@ -60,11 +68,16 @@ var forEachLine = exports.forEachLine = function forEachLine(text, callback) {
60
68
  offset += line.length + 1;
61
69
  });
62
70
  };
71
+
72
+ // Ignored via go/ees005
73
+ // eslint-disable-next-line require-unicode-regexp
63
74
  var SPACE = {
64
75
  token: ' ',
65
76
  size: 2,
66
77
  regex: /[^ ]/
67
78
  };
79
+ // Ignored via go/ees005
80
+ // eslint-disable-next-line require-unicode-regexp
68
81
  var TAB = {
69
82
  token: '\t',
70
83
  size: 1,
@@ -11,16 +11,24 @@ var QUOTE_MAP = exports.QUOTE_MAP = {
11
11
  };
12
12
  var shouldAutoCloseQuote = exports.shouldAutoCloseQuote = function shouldAutoCloseQuote(before, after) {
13
13
  // when directly before a closing bracket
14
+ // Ignored via go/ees005
15
+ // eslint-disable-next-line require-unicode-regexp
14
16
  if (/^[}\])]/.test(after)) {
15
17
  return true;
16
18
  }
17
19
 
18
20
  // exclusion: when directly before a non-whitespace character
21
+ // Ignored via go/ees005
22
+ // eslint-disable-next-line require-unicode-regexp
19
23
  if (/^[^\s]/.test(after)) {
20
24
  return false;
21
25
  }
22
26
 
23
27
  // exclusion: when directly after a letter or quote
28
+ // Ignored via go/ees005
29
+ // eslint-disable-next-line require-unicode-regexp
30
+ // Ignored via go/ees005
31
+ // eslint-disable-next-line require-unicode-regexp
24
32
  if (/[A-Za-z0-9]$/.test(before) || /[\'\"\`]$/.test(before)) {
25
33
  return false;
26
34
  }
@@ -20,6 +20,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
20
20
  var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
21
21
  return new _safePlugin.SafePlugin({
22
22
  props: {
23
+ // Ignored via go/ees005
24
+ // eslint-disable-next-line @typescript-eslint/max-params
23
25
  handleTextInput: function handleTextInput(view, from, to, text) {
24
26
  var _pluginInjectionApi$c;
25
27
  var state = view.state,
@@ -66,6 +68,8 @@ var ideUX = function ideUX(pluginInjectionApi) {
66
68
  handleKeyDown: (0, _keymap.keydownHandler)({
67
69
  Backspace: function Backspace(state, dispatch) {
68
70
  if ((0, _lineHandling.isCursorInsideCodeBlock)(state)) {
71
+ // Ignored via go/ees005
72
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
69
73
  var $cursor = (0, _utils3.getCursor)(state.selection);
70
74
  var beforeText = (0, _lineHandling.getStartOfCurrentLine)(state).text;
71
75
  var afterText = (0, _lineHandling.getEndOfCurrentLine)(state).text;
@@ -37,10 +37,16 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
37
37
  var validMatchLength = function validMatchLength(match) {
38
38
  return match.length > 0 && match[0].length === 3;
39
39
  };
40
+
41
+ // Ignored via go/ees005
42
+ // eslint-disable-next-line require-unicode-regexp, @typescript-eslint/max-params
40
43
  var threeTildeRule = (0, _utils.createRule)(/(?!\s)(`{3,})$/, function (state, match, start, end) {
41
44
  if (!validMatchLength(match)) {
42
45
  return null;
43
46
  }
47
+
48
+ // Ignored via go/ees005
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
50
  var attributes = {};
45
51
  if (match[4]) {
46
52
  attributes.language = match[4];
@@ -54,10 +60,19 @@ function getCodeBlockRules(editorAnalyticsAPI, schema, isNestingInQuoteSupported
54
60
  (0, _utils2.safeInsert)(codeBlock)(tr);
55
61
  return tr;
56
62
  });
57
- var leftNodeReplacementThreeTildeRule = (0, _utils.createRule)(new RegExp("((".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")), function (state, match, start, end) {
63
+ var leftNodeReplacementThreeTildeRule = (0, _utils.createRule)(
64
+ // Ignored via go/ees005
65
+ // eslint-disable-next-line require-unicode-regexp
66
+ new RegExp("((".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, "`{3,})|^\\s(`{3,}))(\\S*)$")),
67
+ // Ignored via go/ees005
68
+ // eslint-disable-next-line @typescript-eslint/max-params
69
+ function (state, match, start, end) {
58
70
  if (!validMatchLength(match)) {
59
71
  return null;
60
72
  }
73
+
74
+ // Ignored via go/ees005
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
76
  var attributes = {};
62
77
  if (match[4]) {
63
78
  attributes.language = match[4];
@@ -46,6 +46,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
46
46
  event.preventDefault();
47
47
  return true;
48
48
  } 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)) {
49
+ // Ignored via go/ees005
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
51
  var resultingText = event.target.outerText + '\n';
50
52
  if (resultingText.endsWith(eventText)) {
51
53
  // End of paragraph
@@ -84,6 +86,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
84
86
  decorations: _view.DecorationSet.create(state.doc, initialDecorations)
85
87
  };
86
88
  },
89
+ // Ignored via go/ees005
90
+ // eslint-disable-next-line @typescript-eslint/max-params
87
91
  apply: function apply(tr, pluginState, _oldState, newState) {
88
92
  var meta = tr.getMeta(_pluginKey.pluginKey);
89
93
  if ((meta === null || meta === void 0 ? void 0 : meta.type) === _actions.ACTIONS.SET_IS_WRAPPED) {
@@ -100,9 +104,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
100
104
  var updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
101
105
  var codeBlockNodes = (0, _platformFeatureFlags.fg)('editor_code_wrapping_perf_improvement_ed-25141') ? (0, _utils.getAllChangedCodeBlocksInTransaction)(tr) : (0, _utils.getAllCodeBlockNodesInDoc)(newState);
102
106
  if (codeBlockNodes) {
103
- if ((0, _platformFeatureFlags.fg)('editor_code_block_wrapping_language_change_bug')) {
104
- (0, _codeBlock.updateCodeBlockWrappedStateNodeKeys)(codeBlockNodes, _oldState);
105
- }
107
+ (0, _codeBlock.updateCodeBlockWrappedStateNodeKeys)(codeBlockNodes, _oldState);
106
108
  updatedDecorationSet = (0, _decorators.updateCodeBlockDecorations)(tr, codeBlockNodes, updatedDecorationSet);
107
109
  }
108
110
  var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -118,6 +118,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
118
118
  };
119
119
  return {
120
120
  title: 'CodeBlock floating controls',
121
+ // Ignored via go/ees005
122
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
121
123
  getDomRef: function getDomRef(view) {
122
124
  return (0, _utils.findDomRefAtPos)(pos, view.domAtPos.bind(view));
123
125
  },
@@ -132,6 +134,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
132
134
  * Filters language list based on both name and alias properties.
133
135
  */
134
136
  var languageListFilter = exports.languageListFilter = function languageListFilter(option, rawInput) {
137
+ // Ignored via go/ees005
138
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
139
  var _ref3 = option,
136
140
  data = _ref3.data;
137
141
  var searchString = rawInput.toLowerCase();
@@ -10,7 +10,12 @@ var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _model = require("@atlaskit/editor-prosemirror/model");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
13
- function transformToCodeBlockAction(state, start, attrs, isNestingInQuoteSupported) {
13
+ // Ignored via go/ees005
14
+ // eslint-disable-next-line @typescript-eslint/max-params
15
+ function transformToCodeBlockAction(state, start,
16
+ // Ignored via go/ees005
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ attrs, isNestingInQuoteSupported) {
14
19
  var startOfCodeBlockText = state.selection.$from;
15
20
  var endPosition = state.selection.empty && !(state.selection instanceof _selection.GapCursorSelection) ? startOfCodeBlockText.end() : state.selection.$to.pos;
16
21
  var startLinePosition = startOfCodeBlockText.start();
@@ -30,6 +30,9 @@ function getAllChangedCodeBlocksInTransaction(tr) {
30
30
  var nodePositions = new Set();
31
31
  tr.steps.forEach(function (step) {
32
32
  var mapResult = step.getMap();
33
+
34
+ // Ignored via go/ees005
35
+ // eslint-disable-next-line @typescript-eslint/max-params
33
36
  mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
34
37
  tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
35
38
  if (node.type.name === 'codeBlock') {
@@ -66,7 +66,7 @@ export const copyContentToClipboard = (state, dispatch) => {
66
66
  const textContent = codeBlock && codeBlock.node.textContent;
67
67
  if (textContent) {
68
68
  copyToClipboard(textContent);
69
- let copyToClipboardTr = tr;
69
+ const copyToClipboardTr = tr;
70
70
  copyToClipboardTr.setMeta(pluginKey, {
71
71
  type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
72
72
  data: true
@@ -83,7 +83,7 @@ export const resetCopiedState = (state, dispatch) => {
83
83
  tr
84
84
  } = state;
85
85
  const codeBlockState = pluginKey.getState(state);
86
- let resetCopiedStateTr = tr;
86
+ const resetCopiedStateTr = tr;
87
87
  if (codeBlockState && codeBlockState.contentCopied) {
88
88
  resetCopiedStateTr.setMeta(pluginKey, {
89
89
  type: ACTIONS.SET_COPIED_TO_CLIPBOARD,
@@ -188,7 +188,7 @@ export function insertCodeBlockWithAnalytics(inputMethod, analyticsAPI, isNestin
188
188
  },
189
189
  eventType: EVENT_TYPE.TRACK
190
190
  })(function (state, dispatch) {
191
- let tr = createInsertCodeBlockTransaction({
191
+ const tr = createInsertCodeBlockTransaction({
192
192
  state,
193
193
  isNestingInQuoteSupported
194
194
  });
@@ -1,11 +1,13 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { browser } from '@atlaskit/editor-common/browser';
3
- import { codeBlockWrappedStates, defaultWordWrapState, transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
3
+ import { codeBlockWrappedStates, defaultWordWrapState } from '@atlaskit/editor-common/code-block';
4
4
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
7
6
  import { getPluginState } from '../pm-plugins/main-state';
8
7
  import { codeBlockClassNames } from '../ui/class-names';
8
+
9
+ // Ignored via go/ees005
10
+ // eslint-disable-next-line require-unicode-regexp
9
11
  const MATCH_NEWLINES = new RegExp('\n', 'g');
10
12
  const toDOM = (node, contentEditable, formattedAriaLabel) => ['div', {
11
13
  class: codeBlockClassNames.container
@@ -30,6 +32,8 @@ const toDOM = (node, contentEditable, formattedAriaLabel) => ['div', {
30
32
  contenteditable: 'false'
31
33
  }]];
32
34
  export class CodeBlockView {
35
+ // Ignored via go/ees005
36
+ // eslint-disable-next-line @typescript-eslint/max-params
33
37
  constructor(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
34
38
  var _api$editorDisabled, _api$editorDisabled$s;
35
39
  _defineProperty(this, "formattedAriaLabel", '');
@@ -41,6 +45,8 @@ export class CodeBlockView {
41
45
  this.node.forEach(node => {
42
46
  const text = node.text;
43
47
  if (text) {
48
+ // Ignored via go/ees005
49
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
44
50
  totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
45
51
  }
46
52
  });
@@ -55,8 +61,14 @@ export class CodeBlockView {
55
61
  this.getPos = getPos;
56
62
  this.view = view;
57
63
  this.node = _node;
64
+ // Ignored via go/ees005
65
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
58
66
  this.dom = dom;
67
+ // Ignored via go/ees005
68
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
59
69
  this.contentDOM = contentDOM;
70
+ // Ignored via go/ees005
71
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
60
72
  this.lineNumberGutter = this.dom.querySelector(`.${codeBlockClassNames.gutter}`);
61
73
  this.api = api;
62
74
  this.maintainDynamicGutterSize();
@@ -85,6 +97,8 @@ export class CodeBlockView {
85
97
  const contentWrapper = this.dom.childNodes[1];
86
98
  const contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
87
99
  if ((contentView === null || contentView === void 0 ? void 0 : (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
100
+ // Ignored via go/ees005
101
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
88
102
  const codeElement = contentView.firstChild;
89
103
  codeElement.innerHTML = savedInnerHTML;
90
104
 
@@ -107,10 +121,15 @@ export class CodeBlockView {
107
121
  if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
108
122
  let savedInnerHTML = '';
109
123
  while (contentView.childNodes.length > 1) {
124
+ // Ignored via go/ees005
125
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
110
126
  const lastChild = contentView.lastChild;
111
127
  savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
112
128
  contentView.removeChild(lastChild);
113
129
  }
130
+
131
+ // Ignored via go/ees005
132
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
114
133
  const firstChild = contentView.firstChild;
115
134
  savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
116
135
  const newCursorPosition = firstChild.innerHTML.length + 1;
@@ -123,9 +142,6 @@ export class CodeBlockView {
123
142
  return false;
124
143
  }
125
144
  if (node !== this.node) {
126
- if (!fg('editor_code_block_wrapping_language_change_bug')) {
127
- transferCodeBlockWrappedValue(this.node, node);
128
- }
129
145
  if (node.attrs.language !== this.node.attrs.language) {
130
146
  this.contentDOM.setAttribute('data-language', node.attrs.language || '');
131
147
  }
@@ -154,4 +170,7 @@ export class CodeBlockView {
154
170
  this.cleanupEditorDisabledListener = undefined;
155
171
  }
156
172
  }
157
- export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api) => new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
173
+ export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api
174
+ // Ignored via go/ees005
175
+ // eslint-disable-next-line @typescript-eslint/max-params
176
+ ) => new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
@@ -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(transaction, currentCodeBlockCopySelectionPluginState, _oldState, newState) {
34
36
  switch (transaction.getMeta(copySelectionPluginKey)) {
35
37
  case 'show-selection':
@@ -132,14 +132,8 @@ export const validateWordWrappedDecorators = (tr, codeBlockNodes, decorationSet)
132
132
  codeBlockNodes.forEach(node => {
133
133
  const isCodeBlockWrappedInState = isCodeBlockWordWrapEnabled(node.node);
134
134
  const isCodeBlockWrappedByDecorator = getWordWrapDecoratorsFromNodePos(node.pos, decorationSet).length !== 0;
135
- if (fg('editor_code_block_wrapping_language_change_bug')) {
136
- if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
137
- updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
138
- }
139
- } else {
140
- if (isCodeBlockWrappedInState && !isCodeBlockWrappedByDecorator) {
141
- updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
142
- }
135
+ if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
136
+ updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
143
137
  }
144
138
  });
145
139
  return updatedDecorationSet;
@@ -5,11 +5,15 @@ export const BRACKET_MAP = {
5
5
  };
6
6
  export const 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
  }
@@ -6,8 +6,12 @@ export const getStartOfCurrentLine = state => {
6
6
  $from
7
7
  } = state.selection;
8
8
  if ($from.nodeBefore && $from.nodeBefore.isText) {
9
+ // Ignored via go/ees005
10
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9
11
  const prevNewLineIndex = $from.nodeBefore.text.lastIndexOf('\n');
10
12
  return {
13
+ // Ignored via go/ees005
14
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
15
  text: $from.nodeBefore.text.substring(prevNewLineIndex + 1),
12
16
  pos: $from.start() + prevNewLineIndex + 1
13
17
  };
@@ -22,8 +26,12 @@ export const getEndOfCurrentLine = state => {
22
26
  $to
23
27
  } = state.selection;
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
  const 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
  };
@@ -54,11 +62,16 @@ export const forEachLine = (text, callback) => {
54
62
  offset += line.length + 1;
55
63
  });
56
64
  };
65
+
66
+ // Ignored via go/ees005
67
+ // eslint-disable-next-line require-unicode-regexp
57
68
  const SPACE = {
58
69
  token: ' ',
59
70
  size: 2,
60
71
  regex: /[^ ]/
61
72
  };
73
+ // Ignored via go/ees005
74
+ // eslint-disable-next-line require-unicode-regexp
62
75
  const TAB = {
63
76
  token: '\t',
64
77
  size: 1,
@@ -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];
@@ -37,6 +37,8 @@ export const createPlugin = ({
37
37
  event.preventDefault();
38
38
  return true;
39
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
40
42
  const resultingText = event.target.outerText + '\n';
41
43
  if (resultingText.endsWith(eventText)) {
42
44
  // End of paragraph
@@ -73,6 +75,8 @@ export const createPlugin = ({
73
75
  decorations: DecorationSet.create(state.doc, initialDecorations)
74
76
  };
75
77
  },
78
+ // Ignored via go/ees005
79
+ // eslint-disable-next-line @typescript-eslint/max-params
76
80
  apply(tr, pluginState, _oldState, newState) {
77
81
  const meta = tr.getMeta(pluginKey);
78
82
  if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
@@ -90,9 +94,7 @@ export const createPlugin = ({
90
94
  let updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
91
95
  const codeBlockNodes = fg('editor_code_wrapping_perf_improvement_ed-25141') ? getAllChangedCodeBlocksInTransaction(tr) : getAllCodeBlockNodesInDoc(newState);
92
96
  if (codeBlockNodes) {
93
- if (fg('editor_code_block_wrapping_language_change_bug')) {
94
- updateCodeBlockWrappedStateNodeKeys(codeBlockNodes, _oldState);
95
- }
97
+ updateCodeBlockWrappedStateNodeKeys(codeBlockNodes, _oldState);
96
98
  updatedDecorationSet = updateCodeBlockDecorations(tr, codeBlockNodes, updatedDecorationSet);
97
99
  }
98
100
  const newPluginState = {
@@ -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();
@@ -22,6 +22,9 @@ export function getAllChangedCodeBlocksInTransaction(tr) {
22
22
  const nodePositions = new Set();
23
23
  tr.steps.forEach(step => {
24
24
  const mapResult = step.getMap();
25
+
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line @typescript-eslint/max-params
25
28
  mapResult.forEach((oldStart, oldEnd, newStart, newEnd) => {
26
29
  tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), (node, pos) => {
27
30
  if (node.type.name === 'codeBlock') {
@@ -2,12 +2,14 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { browser } from '@atlaskit/editor-common/browser';
5
- import { codeBlockWrappedStates, defaultWordWrapState, transferCodeBlockWrappedValue } from '@atlaskit/editor-common/code-block';
5
+ import { codeBlockWrappedStates, defaultWordWrapState } from '@atlaskit/editor-common/code-block';
6
6
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
7
  import { resetShouldIgnoreFollowingMutations } from '../editor-commands';
9
8
  import { getPluginState } from '../pm-plugins/main-state';
10
9
  import { codeBlockClassNames } from '../ui/class-names';
10
+
11
+ // Ignored via go/ees005
12
+ // eslint-disable-next-line require-unicode-regexp
11
13
  var MATCH_NEWLINES = new RegExp('\n', 'g');
12
14
  var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
13
15
  return ['div', {
@@ -34,6 +36,8 @@ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
34
36
  }]];
35
37
  };
36
38
  export var CodeBlockView = /*#__PURE__*/function () {
39
+ // Ignored via go/ees005
40
+ // eslint-disable-next-line @typescript-eslint/max-params
37
41
  function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
38
42
  var _this = this,
39
43
  _api$editorDisabled;
@@ -47,6 +51,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
47
51
  _this.node.forEach(function (node) {
48
52
  var text = node.text;
49
53
  if (text) {
54
+ // Ignored via go/ees005
55
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
50
56
  totalLineCount += (node.text.match(MATCH_NEWLINES) || []).length;
51
57
  }
52
58
  });
@@ -60,8 +66,14 @@ export var CodeBlockView = /*#__PURE__*/function () {
60
66
  this.getPos = getPos;
61
67
  this.view = view;
62
68
  this.node = _node;
69
+ // Ignored via go/ees005
70
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
63
71
  this.dom = dom;
72
+ // Ignored via go/ees005
73
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
64
74
  this.contentDOM = contentDOM;
75
+ // Ignored via go/ees005
76
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
65
77
  this.lineNumberGutter = this.dom.querySelector(".".concat(codeBlockClassNames.gutter));
66
78
  this.api = api;
67
79
  this.maintainDynamicGutterSize();
@@ -95,6 +107,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
95
107
  var contentWrapper = this.dom.childNodes[1];
96
108
  var contentView = contentWrapper === null || contentWrapper === void 0 ? void 0 : contentWrapper.childNodes[1];
97
109
  if ((contentView === null || contentView === void 0 || (_contentView$childNod = contentView.childNodes) === null || _contentView$childNod === void 0 ? void 0 : _contentView$childNod.length) > 0) {
110
+ // Ignored via go/ees005
111
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
98
112
  var codeElement = contentView.firstChild;
99
113
  codeElement.innerHTML = savedInnerHTML;
100
114
 
@@ -121,10 +135,15 @@ export var CodeBlockView = /*#__PURE__*/function () {
121
135
  if (contentView !== null && contentView !== void 0 && contentView.childNodes && contentView.childNodes.length > 1) {
122
136
  var savedInnerHTML = '';
123
137
  while (contentView.childNodes.length > 1) {
138
+ // Ignored via go/ees005
139
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
124
140
  var lastChild = contentView.lastChild;
125
141
  savedInnerHTML = lastChild.innerHTML + savedInnerHTML;
126
142
  contentView.removeChild(lastChild);
127
143
  }
144
+
145
+ // Ignored via go/ees005
146
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
128
147
  var firstChild = contentView.firstChild;
129
148
  savedInnerHTML = firstChild.innerHTML + '\n' + savedInnerHTML;
130
149
  var newCursorPosition = firstChild.innerHTML.length + 1;
@@ -139,9 +158,6 @@ export var CodeBlockView = /*#__PURE__*/function () {
139
158
  return false;
140
159
  }
141
160
  if (node !== this.node) {
142
- if (!fg('editor_code_block_wrapping_language_change_bug')) {
143
- transferCodeBlockWrappedValue(this.node, node);
144
- }
145
161
  if (node.attrs.language !== this.node.attrs.language) {
146
162
  this.contentDOM.setAttribute('data-language', node.attrs.language || '');
147
163
  }
@@ -175,6 +191,9 @@ export var CodeBlockView = /*#__PURE__*/function () {
175
191
  }
176
192
  }]);
177
193
  }();
178
- export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
194
+ export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api
195
+ // Ignored via go/ees005
196
+ // eslint-disable-next-line @typescript-eslint/max-params
197
+ ) {
179
198
  return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
180
199
  };
@@ -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':
@@ -135,14 +135,8 @@ export var validateWordWrappedDecorators = function validateWordWrappedDecorator
135
135
  codeBlockNodes.forEach(function (node) {
136
136
  var isCodeBlockWrappedInState = isCodeBlockWordWrapEnabled(node.node);
137
137
  var isCodeBlockWrappedByDecorator = getWordWrapDecoratorsFromNodePos(node.pos, decorationSet).length !== 0;
138
- if (fg('editor_code_block_wrapping_language_change_bug')) {
139
- if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
140
- updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
141
- }
142
- } else {
143
- if (isCodeBlockWrappedInState && !isCodeBlockWrappedByDecorator) {
144
- updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
145
- }
138
+ if (isCodeBlockWrappedInState !== isCodeBlockWrappedByDecorator) {
139
+ updatedDecorationSet = updateDecorationSetWithWordWrappedDecorator(decorationSet, tr, node);
146
140
  }
147
141
  });
148
142
  return updatedDecorationSet;
@@ -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];
@@ -41,6 +41,8 @@ export var createPlugin = function createPlugin(_ref) {
41
41
  event.preventDefault();
42
42
  return true;
43
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
44
46
  var resultingText = event.target.outerText + '\n';
45
47
  if (resultingText.endsWith(eventText)) {
46
48
  // End of paragraph
@@ -79,6 +81,8 @@ export var createPlugin = function createPlugin(_ref) {
79
81
  decorations: DecorationSet.create(state.doc, initialDecorations)
80
82
  };
81
83
  },
84
+ // Ignored via go/ees005
85
+ // eslint-disable-next-line @typescript-eslint/max-params
82
86
  apply: function apply(tr, pluginState, _oldState, newState) {
83
87
  var meta = tr.getMeta(pluginKey);
84
88
  if ((meta === null || meta === void 0 ? void 0 : meta.type) === ACTIONS.SET_IS_WRAPPED) {
@@ -95,9 +99,7 @@ export var createPlugin = function createPlugin(_ref) {
95
99
  var updatedDecorationSet = pluginState.decorations.map(tr.mapping, tr.doc);
96
100
  var codeBlockNodes = fg('editor_code_wrapping_perf_improvement_ed-25141') ? getAllChangedCodeBlocksInTransaction(tr) : getAllCodeBlockNodesInDoc(newState);
97
101
  if (codeBlockNodes) {
98
- if (fg('editor_code_block_wrapping_language_change_bug')) {
99
- updateCodeBlockWrappedStateNodeKeys(codeBlockNodes, _oldState);
100
- }
102
+ updateCodeBlockWrappedStateNodeKeys(codeBlockNodes, _oldState);
101
103
  updatedDecorationSet = updateCodeBlockDecorations(tr, codeBlockNodes, updatedDecorationSet);
102
104
  }
103
105
  var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -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();
@@ -22,6 +22,9 @@ export function getAllChangedCodeBlocksInTransaction(tr) {
22
22
  var nodePositions = new Set();
23
23
  tr.steps.forEach(function (step) {
24
24
  var mapResult = step.getMap();
25
+
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line @typescript-eslint/max-params
25
28
  mapResult.forEach(function (oldStart, oldEnd, newStart, newEnd) {
26
29
  tr.doc.nodesBetween(newStart, Math.min(newEnd, tr.doc.content.size), function (node, pos) {
27
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
  };
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "3.5.12",
3
+ "version": "3.5.14",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^46.1.0",
35
35
  "@atlaskit/code": "^15.6.0",
36
- "@atlaskit/editor-common": "^97.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",
@@ -96,9 +96,6 @@
96
96
  "code_block_auto_insertion_bug_fix": {
97
97
  "type": "boolean"
98
98
  },
99
- "editor_code_block_wrapping_language_change_bug": {
100
- "type": "boolean"
101
- },
102
99
  "editor_nest_media_and_codeblock_in_quotes_jira": {
103
100
  "type": "boolean"
104
101
  },