@atlaskit/editor-plugin-code-block-advanced 7.1.0 → 7.1.1

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,13 @@
1
1
  # @atlaskit/editor-plugin-code-block-advanced
2
2
 
3
+ ## 7.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e91ea1cbba89a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e91ea1cbba89a) -
8
+ JRACLOUD-96830: Fix navigating and editing codeblocks with CRLF new lines.
9
+ - Updated dependencies
10
+
3
11
  ## 7.1.0
4
12
 
5
13
  ### Minor Changes
@@ -28,6 +28,7 @@ var _updateCMSelection = require("./codemirrorSync/updateCMSelection");
28
28
  var _firstCodeBlockInDocument = require("./extensions/firstCodeBlockInDocument");
29
29
  var _foldGutter = require("./extensions/foldGutter");
30
30
  var _keymap = require("./extensions/keymap");
31
+ var _lineSeparator = require("./extensions/lineSeparator");
31
32
  var _manageSelectionMarker = require("./extensions/manageSelectionMarker");
32
33
  var _prosemirrorDecorations = require("./extensions/prosemirrorDecorations");
33
34
  var _tripleClickExtension = require("./extensions/tripleClickExtension");
@@ -128,7 +129,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
128
129
  getNode: function getNode() {
129
130
  return _this.node;
130
131
  }
131
- })] : []])
132
+ })] : [], (0, _lineSeparator.lineSeparatorExtension)()])
132
133
  });
133
134
  if (contentFormatSharedState) {
134
135
  this.unsubscribeContentFormat = contentFormatSharedState.onChange(function (_ref) {
@@ -0,0 +1,18 @@
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
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
+ /**
10
+ * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
11
+ * we only consider \n for line separators.
12
+ */
13
+ var lineSeparatorExtension = exports.lineSeparatorExtension = function lineSeparatorExtension() {
14
+ if ((0, _expValEquals.expValEquals)('platform_editor_fix_advanced_codeblocks_crlf', 'isEnabled', true)) {
15
+ return _state.EditorState.lineSeparator.of('\n');
16
+ }
17
+ return [];
18
+ };
@@ -18,6 +18,7 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
18
18
  import { firstCodeBlockInDocument } from './extensions/firstCodeBlockInDocument';
19
19
  import { foldGutterExtension, getCodeBlockFoldStateEffects } from './extensions/foldGutter';
20
20
  import { keymapExtension } from './extensions/keymap';
21
+ import { lineSeparatorExtension } from './extensions/lineSeparator';
21
22
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
22
23
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
23
24
  import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
@@ -100,7 +101,7 @@ class CodeBlockAdvancedNodeView {
100
101
  }), config.allowCodeFolding ? [foldGutterExtension({
101
102
  selectNode,
102
103
  getNode: () => this.node
103
- })] : []]
104
+ })] : [], lineSeparatorExtension()]
104
105
  });
105
106
  if (contentFormatSharedState) {
106
107
  this.unsubscribeContentFormat = contentFormatSharedState.onChange(({
@@ -0,0 +1,13 @@
1
+ import { EditorState as CodeMirrorState } from '@codemirror/state';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
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 = () => {
9
+ if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf', 'isEnabled', true)) {
10
+ return CodeMirrorState.lineSeparator.of('\n');
11
+ }
12
+ return [];
13
+ };
@@ -26,6 +26,7 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
26
26
  import { firstCodeBlockInDocument } from './extensions/firstCodeBlockInDocument';
27
27
  import { foldGutterExtension, getCodeBlockFoldStateEffects } from './extensions/foldGutter';
28
28
  import { keymapExtension } from './extensions/keymap';
29
+ import { lineSeparatorExtension } from './extensions/lineSeparator';
29
30
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
30
31
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
31
32
  import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
@@ -122,7 +123,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
122
123
  getNode: function getNode() {
123
124
  return _this.node;
124
125
  }
125
- })] : []])
126
+ })] : [], lineSeparatorExtension()])
126
127
  });
127
128
  if (contentFormatSharedState) {
128
129
  this.unsubscribeContentFormat = contentFormatSharedState.onChange(function (_ref) {
@@ -0,0 +1,13 @@
1
+ import { EditorState as CodeMirrorState } from '@codemirror/state';
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
+
4
+ /**
5
+ * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
6
+ * we only consider \n for line separators.
7
+ */
8
+ export var lineSeparatorExtension = function lineSeparatorExtension() {
9
+ if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf', 'isEnabled', true)) {
10
+ return CodeMirrorState.lineSeparator.of('\n');
11
+ }
12
+ return [];
13
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
3
+ * we only consider \n for line separators.
4
+ */
5
+ export declare const lineSeparatorExtension: () => import("@codemirror/state").Extension;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
3
+ * we only consider \n for line separators.
4
+ */
5
+ export declare const lineSeparatorExtension: () => import("@codemirror/state").Extension;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-prosemirror": "^7.2.0",
38
38
  "@atlaskit/platform-feature-flags": "^1.1.0",
39
39
  "@atlaskit/prosemirror-history": "^0.2.0",
40
- "@atlaskit/tmp-editor-statsig": "^16.18.0",
40
+ "@atlaskit/tmp-editor-statsig": "^16.23.0",
41
41
  "@atlaskit/tokens": "^9.1.0",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "@codemirror/autocomplete": "6.18.4",
@@ -54,7 +54,7 @@
54
54
  "codemirror-lang-elixir": "4.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@atlaskit/editor-common": "^111.7.0",
57
+ "@atlaskit/editor-common": "^111.8.0",
58
58
  "react": "^18.2.0",
59
59
  "react-intl-next": "npm:react-intl@^5.18.1"
60
60
  },
@@ -43,6 +43,7 @@ import { getCMSelectionChanges } from './codemirrorSync/updateCMSelection';
43
43
  import { firstCodeBlockInDocument } from './extensions/firstCodeBlockInDocument';
44
44
  import { foldGutterExtension, getCodeBlockFoldStateEffects } from './extensions/foldGutter';
45
45
  import { keymapExtension } from './extensions/keymap';
46
+ import { lineSeparatorExtension } from './extensions/lineSeparator';
46
47
  import { manageSelectionMarker } from './extensions/manageSelectionMarker';
47
48
  import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
48
49
  import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
@@ -182,6 +183,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
182
183
  config.allowCodeFolding
183
184
  ? [foldGutterExtension({ selectNode, getNode: () => this.node })]
184
185
  : [],
186
+ lineSeparatorExtension(),
185
187
  ],
186
188
  });
187
189
 
@@ -366,7 +368,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
366
368
  this.updating = false;
367
369
  }
368
370
 
369
- update(node: PMNode, _: readonly Decoration[], innerDecorations: DecorationSource) {
371
+ update(node: PMNode, _: readonly Decoration[], innerDecorations: DecorationSource): boolean {
370
372
  this.maybeTryingToReachNodeSelection = false;
371
373
 
372
374
  if (node.type !== this.node.type) {
@@ -419,7 +421,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
419
421
  this.updating = false;
420
422
  }
421
423
 
422
- stopEvent(e: Event) {
424
+ stopEvent(e: Event): boolean {
423
425
  // If we have selected the node we should not stop these events
424
426
  if (
425
427
  (e instanceof KeyboardEvent || e instanceof ClipboardEvent) &&
@@ -12,7 +12,7 @@ interface BackspaceProps {
12
12
  view: EditorView;
13
13
  }
14
14
 
15
- export const backspaceKeymap = ({ cm, view, getPos, getNode }: BackspaceProps) => {
15
+ export const backspaceKeymap = ({ cm, view, getPos, getNode }: BackspaceProps): boolean => {
16
16
  const ranges = cm.state.selection.ranges;
17
17
 
18
18
  if (ranges.length > 1) {
@@ -0,0 +1,14 @@
1
+ import { EditorState as CodeMirrorState } from '@codemirror/state';
2
+
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
+
5
+ /**
6
+ * To avoid issues with CRLF (\r\n) syncing with ProseMirror,
7
+ * we only consider \n for line separators.
8
+ */
9
+ export const lineSeparatorExtension = () => {
10
+ if (expValEquals('platform_editor_fix_advanced_codeblocks_crlf', 'isEnabled', true)) {
11
+ return CodeMirrorState.lineSeparator.of('\n');
12
+ }
13
+ return [];
14
+ };
@@ -1,7 +1,7 @@
1
1
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
3
 
4
- export const shiftArrowUpWorkaround = (view: EditorView, event: KeyboardEvent) => {
4
+ export const shiftArrowUpWorkaround = (view: EditorView, event: KeyboardEvent): boolean => {
5
5
  const {
6
6
  doc,
7
7
  selection: { $head, $anchor },
@@ -28,7 +28,7 @@ export const shiftArrowUpWorkaround = (view: EditorView, event: KeyboardEvent) =
28
28
  return false;
29
29
  };
30
30
 
31
- export const shiftArrowDownWorkaround = (view: EditorView, event: KeyboardEvent) => {
31
+ export const shiftArrowDownWorkaround = (view: EditorView, event: KeyboardEvent): boolean => {
32
32
  const {
33
33
  doc,
34
34
  selection: { $head, $anchor },
package/tsconfig.app.json CHANGED
@@ -43,6 +43,9 @@
43
43
  {
44
44
  "path": "../editor-plugin-code-block/tsconfig.app.json"
45
45
  },
46
+ {
47
+ "path": "../editor-plugin-content-format/tsconfig.app.json"
48
+ },
46
49
  {
47
50
  "path": "../editor-plugin-editor-disabled/tsconfig.app.json"
48
51
  },
@@ -1,22 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "paths": {}
6
- },
7
- "include": [
8
- "../src/**/*.ts",
9
- "../src/**/*.tsx"
10
- ],
11
- "exclude": [
12
- "../src/**/__tests__/*",
13
- "../src/**/*.test.*",
14
- "../src/**/test.*",
15
- "../src/**/examples.*",
16
- "../src/**/examples/*",
17
- "../src/**/examples/**/*",
18
- "../src/**/*.stories.*",
19
- "../src/**/stories/*",
20
- "../src/**/stories/**/*"
21
- ]
22
- }