@atlaskit/editor-plugin-code-block-advanced 12.1.1 → 12.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/editor-plugin-code-block-advanced
2
2
 
3
+ ## 12.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d19e8a0a9bc84`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d19e8a0a9bc84) -
8
+ Clean up experiment `platform_editor_fix_advanced_codeblocks_crlf_patch`
9
+ - Updated dependencies
10
+
11
+ ## 12.1.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 12.1.1
4
18
 
5
19
  ### Patch Changes
@@ -32,7 +32,6 @@ var _updateCMSelection = require("./codemirrorSync/updateCMSelection");
32
32
  var _firstCodeBlockInDocument = require("./extensions/firstCodeBlockInDocument");
33
33
  var _foldGutter = require("./extensions/foldGutter");
34
34
  var _keymap = require("./extensions/keymap");
35
- var _lineSeparator = require("./extensions/lineSeparator");
36
35
  var _manageSelectionMarker = require("./extensions/manageSelectionMarker");
37
36
  var _prosemirrorDecorations = require("./extensions/prosemirrorDecorations");
38
37
  var _tripleClickExtension = require("./extensions/tripleClickExtension");
@@ -164,9 +163,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
164
163
  return _this.node;
165
164
  },
166
165
  onFoldToggled: this.fireCodeFoldingAnalytics
167
- })] : [],
168
- // With platform_editor_fix_advanced_codeblocks_crlf_patch the lineSeparatorExtension is not needed
169
- (0, _expValEquals.expValEquals)('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true) ? [] : [(0, _lineSeparator.lineSeparatorExtension)()]])
166
+ })] : []])
170
167
  });
171
168
  if (contentFormatSharedState) {
172
169
  this.unsubscribeContentFormat = contentFormatSharedState.onChange(function (_ref) {
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.syncCMWithPM = void 0;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
8
  /**
10
9
  * Returns the extra offset to add when mapping a CodeMirror position to ProseMirror
11
10
  * when the content may contain \r\n (CRLF). Each \r\n in the text before the given
@@ -45,23 +44,15 @@ var syncCMWithPM = exports.syncCMWithPM = function syncCMWithPM(_ref) {
45
44
  if (update.docChanged || pmSel.from !== selFrom || pmSel.to !== selTo) {
46
45
  var tr = view.state.tr;
47
46
  update.changes.iterChanges(function (fromA, toA, fromB, toB, text) {
48
- if ((0, _expValEquals.expValEquals)('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
49
- var adjFrom = crlfAdjustment(codeBlockText, fromA);
50
- // If the from and to are the same, we don't need to run adjustment again
51
- var adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
52
- var pmFrom = offset + fromA + adjFrom;
53
- var pmTo = offset + toA + adjTo;
54
- if (text.length) {
55
- tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
56
- } else {
57
- tr.delete(pmFrom, pmTo);
58
- }
47
+ var adjFrom = crlfAdjustment(codeBlockText, fromA);
48
+ // If the from and to are the same, we don't need to run adjustment again
49
+ var adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
50
+ var pmFrom = offset + fromA + adjFrom;
51
+ var pmTo = offset + toA + adjTo;
52
+ if (text.length) {
53
+ tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
59
54
  } else {
60
- if (text.length) {
61
- tr.replaceWith(offset + fromA, offset + toA, view.state.schema.text(text.toString()));
62
- } else {
63
- tr.delete(offset + fromA, offset + toA);
64
- }
55
+ tr.delete(pmFrom, pmTo);
65
56
  }
66
57
  offset += toB - fromB - (toA - fromA);
67
58
  });
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getCMSelectionChanges = void 0;
7
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
8
7
  /**
9
8
  *
10
9
  * Compares the updated text with the current to determine the transaction to fire
@@ -27,42 +26,26 @@ var getCMSelectionChanges = exports.getCMSelectionChanges = function getCMSelect
27
26
  if (newText !== curText) {
28
27
  var curStart = 0,
29
28
  newStart = 0;
30
- var start = 0,
31
- curEnd = curText.length,
29
+ var curEnd = curText.length,
32
30
  newEnd = newText.length;
33
- if ((0, _expValEquals.expValEquals)('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
34
- while (curStart < curEnd && (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) || newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED)) {
35
- if (newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED && newText.charCodeAt(newStart + 1) === N_LINE_FEED) {
36
- newStart++;
37
- }
38
- curStart++;
31
+ while (curStart < curEnd && (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) || newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED)) {
32
+ if (newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED && newText.charCodeAt(newStart + 1) === N_LINE_FEED) {
39
33
  newStart++;
40
34
  }
41
- while (curEnd > curStart && newEnd > newStart && (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) || newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED)) {
42
- if (newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED && newText.charCodeAt(newEnd - 2) === R_LINE_FEED) {
43
- newEnd--;
44
- }
45
- curEnd--;
46
- newEnd--;
47
- }
48
- return {
49
- from: curStart,
50
- to: curEnd,
51
- insert: newText.slice(newStart, newEnd)
52
- };
53
- } else {
54
- while (start < curEnd && curText.charCodeAt(start) === newText.charCodeAt(start)) {
55
- ++start;
56
- }
57
- while (curEnd > start && newEnd > start && curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1)) {
58
- curEnd--;
35
+ curStart++;
36
+ newStart++;
37
+ }
38
+ while (curEnd > curStart && newEnd > newStart && (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) || newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED)) {
39
+ if (newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED && newText.charCodeAt(newEnd - 2) === R_LINE_FEED) {
59
40
  newEnd--;
60
41
  }
61
- return {
62
- from: start,
63
- to: curEnd,
64
- insert: newText.slice(start, newEnd)
65
- };
42
+ curEnd--;
43
+ newEnd--;
66
44
  }
45
+ return {
46
+ from: curStart,
47
+ to: curEnd,
48
+ insert: newText.slice(newStart, newEnd)
49
+ };
67
50
  }
68
51
  };
@@ -22,7 +22,6 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
22
22
  import { firstCodeBlockInDocument } from './extensions/firstCodeBlockInDocument';
23
23
  import { foldGutterExtension, getCodeBlockFoldStateEffects } from './extensions/foldGutter';
24
24
  import { keymapExtension } from './extensions/keymap';
25
- import { lineSeparatorExtension } from './extensions/lineSeparator';
26
25
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
27
26
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
28
27
  import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
@@ -142,9 +141,7 @@ class CodeBlockAdvancedNodeView {
142
141
  selectNode: this.selectCodeBlockNodeAndFocus,
143
142
  getNode: () => this.node,
144
143
  onFoldToggled: this.fireCodeFoldingAnalytics
145
- })] : [],
146
- // With platform_editor_fix_advanced_codeblocks_crlf_patch the lineSeparatorExtension is not needed
147
- expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true) ? [] : [lineSeparatorExtension()]]
144
+ })] : []]
148
145
  });
149
146
  if (contentFormatSharedState) {
150
147
  this.unsubscribeContentFormat = contentFormatSharedState.onChange(({
@@ -1,5 +1,4 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
2
  /**
4
3
  * Returns the extra offset to add when mapping a CodeMirror position to ProseMirror
5
4
  * when the content may contain \r\n (CRLF). Each \r\n in the text before the given
@@ -42,23 +41,15 @@ export const syncCMWithPM = ({
42
41
  if (update.docChanged || pmSel.from !== selFrom || pmSel.to !== selTo) {
43
42
  const tr = view.state.tr;
44
43
  update.changes.iterChanges((fromA, toA, fromB, toB, text) => {
45
- if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
46
- const adjFrom = crlfAdjustment(codeBlockText, fromA);
47
- // If the from and to are the same, we don't need to run adjustment again
48
- const adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
49
- const pmFrom = offset + fromA + adjFrom;
50
- const pmTo = offset + toA + adjTo;
51
- if (text.length) {
52
- tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
53
- } else {
54
- tr.delete(pmFrom, pmTo);
55
- }
44
+ const adjFrom = crlfAdjustment(codeBlockText, fromA);
45
+ // If the from and to are the same, we don't need to run adjustment again
46
+ const adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
47
+ const pmFrom = offset + fromA + adjFrom;
48
+ const pmTo = offset + toA + adjTo;
49
+ if (text.length) {
50
+ tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
56
51
  } else {
57
- if (text.length) {
58
- tr.replaceWith(offset + fromA, offset + toA, view.state.schema.text(text.toString()));
59
- } else {
60
- tr.delete(offset + fromA, offset + toA);
61
- }
52
+ tr.delete(pmFrom, pmTo);
62
53
  }
63
54
  offset += toB - fromB - (toA - fromA);
64
55
  });
@@ -1,4 +1,3 @@
1
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
1
  /**
3
2
  *
4
3
  * Compares the updated text with the current to determine the transaction to fire
@@ -21,42 +20,26 @@ export const getCMSelectionChanges = (curText, newText) => {
21
20
  if (newText !== curText) {
22
21
  let curStart = 0,
23
22
  newStart = 0;
24
- let start = 0,
25
- curEnd = curText.length,
23
+ let curEnd = curText.length,
26
24
  newEnd = newText.length;
27
- if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
28
- while (curStart < curEnd && (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) || newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED)) {
29
- if (newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED && newText.charCodeAt(newStart + 1) === N_LINE_FEED) {
30
- newStart++;
31
- }
32
- curStart++;
25
+ while (curStart < curEnd && (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) || newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED)) {
26
+ if (newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED && newText.charCodeAt(newStart + 1) === N_LINE_FEED) {
33
27
  newStart++;
34
28
  }
35
- while (curEnd > curStart && newEnd > newStart && (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) || newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED)) {
36
- if (newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED && newText.charCodeAt(newEnd - 2) === R_LINE_FEED) {
37
- newEnd--;
38
- }
39
- curEnd--;
40
- newEnd--;
41
- }
42
- return {
43
- from: curStart,
44
- to: curEnd,
45
- insert: newText.slice(newStart, newEnd)
46
- };
47
- } else {
48
- while (start < curEnd && curText.charCodeAt(start) === newText.charCodeAt(start)) {
49
- ++start;
50
- }
51
- while (curEnd > start && newEnd > start && curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1)) {
52
- curEnd--;
29
+ curStart++;
30
+ newStart++;
31
+ }
32
+ while (curEnd > curStart && newEnd > newStart && (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) || newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED)) {
33
+ if (newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED && newText.charCodeAt(newEnd - 2) === R_LINE_FEED) {
53
34
  newEnd--;
54
35
  }
55
- return {
56
- from: start,
57
- to: curEnd,
58
- insert: newText.slice(start, newEnd)
59
- };
36
+ curEnd--;
37
+ newEnd--;
60
38
  }
39
+ return {
40
+ from: curStart,
41
+ to: curEnd,
42
+ insert: newText.slice(newStart, newEnd)
43
+ };
61
44
  }
62
45
  };
@@ -27,7 +27,6 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
27
27
  import { firstCodeBlockInDocument } from './extensions/firstCodeBlockInDocument';
28
28
  import { foldGutterExtension, getCodeBlockFoldStateEffects } from './extensions/foldGutter';
29
29
  import { keymapExtension } from './extensions/keymap';
30
- import { lineSeparatorExtension } from './extensions/lineSeparator';
31
30
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
32
31
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
33
32
  import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
@@ -157,9 +156,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
157
156
  return _this.node;
158
157
  },
159
158
  onFoldToggled: this.fireCodeFoldingAnalytics
160
- })] : [],
161
- // With platform_editor_fix_advanced_codeblocks_crlf_patch the lineSeparatorExtension is not needed
162
- expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true) ? [] : [lineSeparatorExtension()]])
159
+ })] : []])
163
160
  });
164
161
  if (contentFormatSharedState) {
165
162
  this.unsubscribeContentFormat = contentFormatSharedState.onChange(function (_ref) {
@@ -1,5 +1,4 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
2
  /**
4
3
  * Returns the extra offset to add when mapping a CodeMirror position to ProseMirror
5
4
  * when the content may contain \r\n (CRLF). Each \r\n in the text before the given
@@ -39,23 +38,15 @@ export var syncCMWithPM = function syncCMWithPM(_ref) {
39
38
  if (update.docChanged || pmSel.from !== selFrom || pmSel.to !== selTo) {
40
39
  var tr = view.state.tr;
41
40
  update.changes.iterChanges(function (fromA, toA, fromB, toB, text) {
42
- if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
43
- var adjFrom = crlfAdjustment(codeBlockText, fromA);
44
- // If the from and to are the same, we don't need to run adjustment again
45
- var adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
46
- var pmFrom = offset + fromA + adjFrom;
47
- var pmTo = offset + toA + adjTo;
48
- if (text.length) {
49
- tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
50
- } else {
51
- tr.delete(pmFrom, pmTo);
52
- }
41
+ var adjFrom = crlfAdjustment(codeBlockText, fromA);
42
+ // If the from and to are the same, we don't need to run adjustment again
43
+ var adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
44
+ var pmFrom = offset + fromA + adjFrom;
45
+ var pmTo = offset + toA + adjTo;
46
+ if (text.length) {
47
+ tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
53
48
  } else {
54
- if (text.length) {
55
- tr.replaceWith(offset + fromA, offset + toA, view.state.schema.text(text.toString()));
56
- } else {
57
- tr.delete(offset + fromA, offset + toA);
58
- }
49
+ tr.delete(pmFrom, pmTo);
59
50
  }
60
51
  offset += toB - fromB - (toA - fromA);
61
52
  });
@@ -1,4 +1,3 @@
1
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
1
  /**
3
2
  *
4
3
  * Compares the updated text with the current to determine the transaction to fire
@@ -21,42 +20,26 @@ export var getCMSelectionChanges = function getCMSelectionChanges(curText, newTe
21
20
  if (newText !== curText) {
22
21
  var curStart = 0,
23
22
  newStart = 0;
24
- var start = 0,
25
- curEnd = curText.length,
23
+ var curEnd = curText.length,
26
24
  newEnd = newText.length;
27
- if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
28
- while (curStart < curEnd && (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) || newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED)) {
29
- if (newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED && newText.charCodeAt(newStart + 1) === N_LINE_FEED) {
30
- newStart++;
31
- }
32
- curStart++;
25
+ while (curStart < curEnd && (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) || newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED)) {
26
+ if (newText.charCodeAt(newStart) === R_LINE_FEED && curText.charCodeAt(curStart) === N_LINE_FEED && newText.charCodeAt(newStart + 1) === N_LINE_FEED) {
33
27
  newStart++;
34
28
  }
35
- while (curEnd > curStart && newEnd > newStart && (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) || newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED)) {
36
- if (newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED && newText.charCodeAt(newEnd - 2) === R_LINE_FEED) {
37
- newEnd--;
38
- }
39
- curEnd--;
40
- newEnd--;
41
- }
42
- return {
43
- from: curStart,
44
- to: curEnd,
45
- insert: newText.slice(newStart, newEnd)
46
- };
47
- } else {
48
- while (start < curEnd && curText.charCodeAt(start) === newText.charCodeAt(start)) {
49
- ++start;
50
- }
51
- while (curEnd > start && newEnd > start && curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1)) {
52
- curEnd--;
29
+ curStart++;
30
+ newStart++;
31
+ }
32
+ while (curEnd > curStart && newEnd > newStart && (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) || newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED)) {
33
+ if (newText.charCodeAt(newEnd - 1) === N_LINE_FEED && curText.charCodeAt(curEnd - 1) === N_LINE_FEED && newText.charCodeAt(newEnd - 2) === R_LINE_FEED) {
53
34
  newEnd--;
54
35
  }
55
- return {
56
- from: start,
57
- to: curEnd,
58
- insert: newText.slice(start, newEnd)
59
- };
36
+ curEnd--;
37
+ newEnd--;
60
38
  }
39
+ return {
40
+ from: curStart,
41
+ to: curEnd,
42
+ insert: newText.slice(newStart, newEnd)
43
+ };
61
44
  }
62
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "12.1.1",
3
+ "version": "12.1.3",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/editor-prosemirror": "^8.0.0",
32
32
  "@atlaskit/platform-feature-flags": "^2.1.0",
33
33
  "@atlaskit/prosemirror-history": "^1.0.0",
34
- "@atlaskit/tmp-editor-statsig": "^133.0.0",
34
+ "@atlaskit/tmp-editor-statsig": "^135.0.0",
35
35
  "@atlaskit/tokens": "^16.3.0",
36
36
  "@babel/runtime": "^7.0.0",
37
37
  "@codemirror/autocomplete": "6.18.4",
@@ -50,7 +50,7 @@
50
50
  "codemirror-lang-mermaid": "0.4.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@atlaskit/editor-common": "^116.39.0",
53
+ "@atlaskit/editor-common": "^116.41.0",
54
54
  "react": "^18.2.0",
55
55
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
56
56
  },
@@ -50,7 +50,6 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
50
50
  import { firstCodeBlockInDocument } from './extensions/firstCodeBlockInDocument';
51
51
  import { foldGutterExtension, getCodeBlockFoldStateEffects } from './extensions/foldGutter';
52
52
  import { keymapExtension } from './extensions/keymap';
53
- import { lineSeparatorExtension } from './extensions/lineSeparator';
54
53
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
55
54
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
56
55
  import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
@@ -200,10 +199,6 @@ class CodeBlockAdvancedNodeView implements NodeView {
200
199
  }),
201
200
  ]
202
201
  : [],
203
- // With platform_editor_fix_advanced_codeblocks_crlf_patch the lineSeparatorExtension is not needed
204
- expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)
205
- ? []
206
- : [lineSeparatorExtension()],
207
202
  ],
208
203
  });
209
204
 
@@ -2,7 +2,6 @@ import type { ViewUpdate } from '@codemirror/view';
2
2
 
3
3
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
5
 
7
6
  interface Props {
8
7
  offset: number;
@@ -46,23 +45,15 @@ export const syncCMWithPM = ({ view, update, offset }: Props): void => {
46
45
  if (update.docChanged || pmSel.from !== selFrom || pmSel.to !== selTo) {
47
46
  const tr = view.state.tr;
48
47
  update.changes.iterChanges((fromA, toA, fromB, toB, text) => {
49
- if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
50
- const adjFrom = crlfAdjustment(codeBlockText, fromA);
51
- // If the from and to are the same, we don't need to run adjustment again
52
- const adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
53
- const pmFrom = offset + fromA + adjFrom;
54
- const pmTo = offset + toA + adjTo;
55
- if (text.length) {
56
- tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
57
- } else {
58
- tr.delete(pmFrom, pmTo);
59
- }
48
+ const adjFrom = crlfAdjustment(codeBlockText, fromA);
49
+ // If the from and to are the same, we don't need to run adjustment again
50
+ const adjTo = fromA === toA ? adjFrom : crlfAdjustment(codeBlockText, toA);
51
+ const pmFrom = offset + fromA + adjFrom;
52
+ const pmTo = offset + toA + adjTo;
53
+ if (text.length) {
54
+ tr.replaceWith(pmFrom, pmTo, view.state.schema.text(text.toString()));
60
55
  } else {
61
- if (text.length) {
62
- tr.replaceWith(offset + fromA, offset + toA, view.state.schema.text(text.toString()));
63
- } else {
64
- tr.delete(offset + fromA, offset + toA);
65
- }
56
+ tr.delete(pmFrom, pmTo);
66
57
  }
67
58
  offset += toB - fromB - (toA - fromA);
68
59
  });
@@ -1,6 +1,5 @@
1
1
  import type { ChangeSpec } from '@codemirror/state';
2
2
 
3
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
3
  /**
5
4
  *
6
5
  * Compares the updated text with the current to determine the transaction to fire
@@ -23,66 +22,46 @@ export const getCMSelectionChanges = (curText: string, newText: string): ChangeS
23
22
  if (newText !== curText) {
24
23
  let curStart = 0,
25
24
  newStart = 0;
26
- let start = 0,
27
- curEnd = curText.length,
25
+ let curEnd = curText.length,
28
26
  newEnd = newText.length;
29
27
 
30
- if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf_patch', 'isEnabled', true)) {
31
- while (
32
- curStart < curEnd &&
33
- (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) ||
34
- (newText.charCodeAt(newStart) === R_LINE_FEED &&
35
- curText.charCodeAt(curStart) === N_LINE_FEED))
28
+ while (
29
+ curStart < curEnd &&
30
+ (curText.charCodeAt(curStart) === newText.charCodeAt(newStart) ||
31
+ (newText.charCodeAt(newStart) === R_LINE_FEED &&
32
+ curText.charCodeAt(curStart) === N_LINE_FEED))
33
+ ) {
34
+ if (
35
+ newText.charCodeAt(newStart) === R_LINE_FEED &&
36
+ curText.charCodeAt(curStart) === N_LINE_FEED &&
37
+ newText.charCodeAt(newStart + 1) === N_LINE_FEED
36
38
  ) {
37
- if (
38
- newText.charCodeAt(newStart) === R_LINE_FEED &&
39
- curText.charCodeAt(curStart) === N_LINE_FEED &&
40
- newText.charCodeAt(newStart + 1) === N_LINE_FEED
41
- ) {
42
- newStart++;
43
- }
44
- curStart++;
45
39
  newStart++;
46
40
  }
47
- while (
48
- curEnd > curStart &&
49
- newEnd > newStart &&
50
- (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) ||
51
- (newText.charCodeAt(newEnd - 1) === N_LINE_FEED &&
52
- curText.charCodeAt(curEnd - 1) === N_LINE_FEED))
53
- ) {
54
- if (
55
- newText.charCodeAt(newEnd - 1) === N_LINE_FEED &&
56
- curText.charCodeAt(curEnd - 1) === N_LINE_FEED &&
57
- newText.charCodeAt(newEnd - 2) === R_LINE_FEED
58
- ) {
59
- newEnd--;
60
- }
61
- curEnd--;
62
- newEnd--;
63
- }
64
- return {
65
- from: curStart,
66
- to: curEnd,
67
- insert: newText.slice(newStart, newEnd),
68
- };
69
- } else {
70
- while (start < curEnd && curText.charCodeAt(start) === newText.charCodeAt(start)) {
71
- ++start;
72
- }
73
- while (
74
- curEnd > start &&
75
- newEnd > start &&
76
- curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1)
41
+ curStart++;
42
+ newStart++;
43
+ }
44
+ while (
45
+ curEnd > curStart &&
46
+ newEnd > newStart &&
47
+ (curText.charCodeAt(curEnd - 1) === newText.charCodeAt(newEnd - 1) ||
48
+ (newText.charCodeAt(newEnd - 1) === N_LINE_FEED &&
49
+ curText.charCodeAt(curEnd - 1) === N_LINE_FEED))
50
+ ) {
51
+ if (
52
+ newText.charCodeAt(newEnd - 1) === N_LINE_FEED &&
53
+ curText.charCodeAt(curEnd - 1) === N_LINE_FEED &&
54
+ newText.charCodeAt(newEnd - 2) === R_LINE_FEED
77
55
  ) {
78
- curEnd--;
79
56
  newEnd--;
80
57
  }
81
- return {
82
- from: start,
83
- to: curEnd,
84
- insert: newText.slice(start, newEnd),
85
- };
58
+ curEnd--;
59
+ newEnd--;
86
60
  }
61
+ return {
62
+ from: curStart,
63
+ to: curEnd,
64
+ insert: newText.slice(newStart, newEnd),
65
+ };
87
66
  }
88
67
  };
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.lineSeparatorExtension = void 0;
7
- var _state = require("@codemirror/state");
8
- /**
9
- * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
10
- * we only consider \n for line separators.
11
- */
12
- var lineSeparatorExtension = exports.lineSeparatorExtension = function lineSeparatorExtension() {
13
- return _state.EditorState.lineSeparator.of('\n');
14
- };
@@ -1,8 +0,0 @@
1
- import { EditorState as CodeMirrorState } from '@codemirror/state';
2
- /**
3
- * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
4
- * we only consider \n for line separators.
5
- */
6
- export const lineSeparatorExtension = () => {
7
- return CodeMirrorState.lineSeparator.of('\n');
8
- };
@@ -1,8 +0,0 @@
1
- import { EditorState as CodeMirrorState } from '@codemirror/state';
2
- /**
3
- * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
4
- * we only consider \n for line separators.
5
- */
6
- export var lineSeparatorExtension = function lineSeparatorExtension() {
7
- return CodeMirrorState.lineSeparator.of('\n');
8
- };
@@ -1,6 +0,0 @@
1
- import type { Extension } from '@codemirror/state';
2
- /**
3
- * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
4
- * we only consider \n for line separators.
5
- */
6
- export declare const lineSeparatorExtension: () => Extension;
@@ -1,10 +0,0 @@
1
- import { EditorState as CodeMirrorState } from '@codemirror/state';
2
- import type { Extension } from '@codemirror/state';
3
-
4
- /**
5
- * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
6
- * we only consider \n for line separators.
7
- */
8
- export const lineSeparatorExtension = (): Extension => {
9
- return CodeMirrorState.lineSeparator.of('\n');
10
- };