@atlaskit/editor-plugin-code-block-advanced 2.2.3 → 2.2.4

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
+ ## 2.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#149738](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149738)
8
+ [`3098e65159385`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3098e65159385) -
9
+ Fix selection when the editor is disabled.
10
+
3
11
  ## 2.2.3
4
12
 
5
13
  ### Patch Changes
@@ -76,7 +76,9 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
76
76
  fixed: false
77
77
  }), _view.EditorView.updateListener.of(function (update) {
78
78
  return _this.forwardUpdate(update);
79
- }), this.readOnlyCompartment.of(_view.EditorView.editable.of(this.view.editable)), (0, _autocomplete.closeBrackets)(), _view.EditorView.editorAttributes.of({
79
+ }), this.readOnlyCompartment.of([_state.EditorState.readOnly.of(!this.view.editable), _view.EditorView.contentAttributes.of({
80
+ contentEditable: "".concat(this.view.editable)
81
+ })]), (0, _autocomplete.closeBrackets)(), _view.EditorView.editorAttributes.of({
80
82
  class: 'code-block'
81
83
  }), (0, _manageSelectionMarker.manageSelectionMarker)(config.api), (0, _prosemirrorDecorations.prosemirrorDecorationPlugin)(this.pmFacet, view, getPos)])
82
84
  });
@@ -141,7 +143,9 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
141
143
  value: function updateReadonlyState() {
142
144
  this.updating = true;
143
145
  this.cm.dispatch({
144
- effects: this.readOnlyCompartment.reconfigure(_view.EditorView.editable.of(this.view.editable))
146
+ effects: this.readOnlyCompartment.reconfigure([_state.EditorState.readOnly.of(!this.view.editable), _view.EditorView.contentAttributes.of({
147
+ contentEditable: "".concat(this.view.editable)
148
+ })])
145
149
  });
146
150
  this.updating = false;
147
151
  }
@@ -26,6 +26,9 @@ var cmTheme = exports.cmTheme = _view.EditorView.theme({
26
26
  '&.cm-editor.code-block.danger': {
27
27
  backgroundColor: "var(--ds-background-danger, #FFECEB)"
28
28
  },
29
+ '.cm-content[aria-readonly="true"]': {
30
+ caretColor: 'transparent'
31
+ },
29
32
  '.cm-content': {
30
33
  cursor: 'text',
31
34
  caretColor: "var(--ds-text, #172B4D)",
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { closeBrackets } from '@codemirror/autocomplete';
3
3
  import { syntaxHighlighting, bracketMatching } from '@codemirror/language';
4
- import { Compartment, EditorSelection, Facet } from '@codemirror/state';
4
+ import { Compartment, EditorSelection, Facet, EditorState as CodeMirrorState } from '@codemirror/state';
5
5
  import { EditorView as CodeMirror, lineNumbers, gutters } from '@codemirror/view';
6
6
  import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
7
7
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
@@ -56,7 +56,9 @@ class CodeBlockAdvancedNodeView {
56
56
  // Renderer behaviour
57
57
  gutters({
58
58
  fixed: false
59
- }), CodeMirror.updateListener.of(update => this.forwardUpdate(update)), this.readOnlyCompartment.of(CodeMirror.editable.of(this.view.editable)), closeBrackets(), CodeMirror.editorAttributes.of({
59
+ }), CodeMirror.updateListener.of(update => this.forwardUpdate(update)), this.readOnlyCompartment.of([CodeMirrorState.readOnly.of(!this.view.editable), CodeMirror.contentAttributes.of({
60
+ contentEditable: `${this.view.editable}`
61
+ })]), closeBrackets(), CodeMirror.editorAttributes.of({
60
62
  class: 'code-block'
61
63
  }), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos)]
62
64
  });
@@ -113,7 +115,9 @@ class CodeBlockAdvancedNodeView {
113
115
  updateReadonlyState() {
114
116
  this.updating = true;
115
117
  this.cm.dispatch({
116
- effects: this.readOnlyCompartment.reconfigure(CodeMirror.editable.of(this.view.editable))
118
+ effects: this.readOnlyCompartment.reconfigure([CodeMirrorState.readOnly.of(!this.view.editable), CodeMirror.contentAttributes.of({
119
+ contentEditable: `${this.view.editable}`
120
+ })])
117
121
  });
118
122
  this.updating = false;
119
123
  }
@@ -20,6 +20,9 @@ export const cmTheme = CodeMirror.theme({
20
20
  '&.cm-editor.code-block.danger': {
21
21
  backgroundColor: "var(--ds-background-danger, #FFECEB)"
22
22
  },
23
+ '.cm-content[aria-readonly="true"]': {
24
+ caretColor: 'transparent'
25
+ },
23
26
  '.cm-content': {
24
27
  cursor: 'text',
25
28
  caretColor: "var(--ds-text, #172B4D)",
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  import { closeBrackets } from '@codemirror/autocomplete';
6
6
  import { syntaxHighlighting, bracketMatching } from '@codemirror/language';
7
- import { Compartment, EditorSelection, Facet } from '@codemirror/state';
7
+ import { Compartment, EditorSelection, Facet, EditorState as CodeMirrorState } from '@codemirror/state';
8
8
  import { EditorView as CodeMirror, lineNumbers, gutters } from '@codemirror/view';
9
9
  import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
10
10
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
@@ -69,7 +69,9 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
69
69
  fixed: false
70
70
  }), CodeMirror.updateListener.of(function (update) {
71
71
  return _this.forwardUpdate(update);
72
- }), this.readOnlyCompartment.of(CodeMirror.editable.of(this.view.editable)), closeBrackets(), CodeMirror.editorAttributes.of({
72
+ }), this.readOnlyCompartment.of([CodeMirrorState.readOnly.of(!this.view.editable), CodeMirror.contentAttributes.of({
73
+ contentEditable: "".concat(this.view.editable)
74
+ })]), closeBrackets(), CodeMirror.editorAttributes.of({
73
75
  class: 'code-block'
74
76
  }), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos)])
75
77
  });
@@ -134,7 +136,9 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
134
136
  value: function updateReadonlyState() {
135
137
  this.updating = true;
136
138
  this.cm.dispatch({
137
- effects: this.readOnlyCompartment.reconfigure(CodeMirror.editable.of(this.view.editable))
139
+ effects: this.readOnlyCompartment.reconfigure([CodeMirrorState.readOnly.of(!this.view.editable), CodeMirror.contentAttributes.of({
140
+ contentEditable: "".concat(this.view.editable)
141
+ })])
138
142
  });
139
143
  this.updating = false;
140
144
  }
@@ -20,6 +20,9 @@ export var cmTheme = CodeMirror.theme({
20
20
  '&.cm-editor.code-block.danger': {
21
21
  backgroundColor: "var(--ds-background-danger, #FFECEB)"
22
22
  },
23
+ '.cm-content[aria-readonly="true"]': {
24
+ caretColor: 'transparent'
25
+ },
23
26
  '.cm-content': {
24
27
  cursor: 'text',
25
28
  caretColor: "var(--ds-text, #172B4D)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,11 +33,11 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^47.6.0",
36
- "@atlaskit/editor-common": "^103.9.0",
36
+ "@atlaskit/editor-common": "^103.22.0",
37
37
  "@atlaskit/editor-plugin-code-block": "^4.4.0",
38
38
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
39
39
  "@atlaskit/editor-plugin-find-replace": "^2.2.0",
40
- "@atlaskit/editor-plugin-selection": "^2.1.0",
40
+ "@atlaskit/editor-plugin-selection": "^2.2.0",
41
41
  "@atlaskit/editor-plugin-selection-marker": "^2.2.0",
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
43
  "@atlaskit/tokens": "^4.8.0",
@@ -57,7 +57,7 @@
57
57
  "react": "^18.2.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@atlaskit/code": "^17.0.0",
60
+ "@atlaskit/code": "^17.1.0",
61
61
  "typescript": "~5.4.2"
62
62
  },
63
63
  "techstack": {
@@ -1,6 +1,12 @@
1
1
  import { closeBrackets } from '@codemirror/autocomplete';
2
2
  import { syntaxHighlighting, bracketMatching } from '@codemirror/language';
3
- import { Compartment, Extension, EditorSelection, Facet } from '@codemirror/state';
3
+ import {
4
+ Compartment,
5
+ Extension,
6
+ EditorSelection,
7
+ Facet,
8
+ EditorState as CodeMirrorState,
9
+ } from '@codemirror/state';
4
10
  import { EditorView as CodeMirror, lineNumbers, ViewUpdate, gutters } from '@codemirror/view';
5
11
 
6
12
  import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
@@ -103,7 +109,10 @@ class CodeBlockAdvancedNodeView implements NodeView {
103
109
  // Renderer behaviour
104
110
  gutters({ fixed: false }),
105
111
  CodeMirror.updateListener.of((update) => this.forwardUpdate(update)),
106
- this.readOnlyCompartment.of(CodeMirror.editable.of(this.view.editable)),
112
+ this.readOnlyCompartment.of([
113
+ CodeMirrorState.readOnly.of(!this.view.editable),
114
+ CodeMirror.contentAttributes.of({ contentEditable: `${this.view.editable}` }),
115
+ ]),
107
116
  closeBrackets(),
108
117
  CodeMirror.editorAttributes.of({ class: 'code-block' }),
109
118
  manageSelectionMarker(config.api),
@@ -161,7 +170,10 @@ class CodeBlockAdvancedNodeView implements NodeView {
161
170
  private updateReadonlyState() {
162
171
  this.updating = true;
163
172
  this.cm.dispatch({
164
- effects: this.readOnlyCompartment.reconfigure(CodeMirror.editable.of(this.view.editable)),
173
+ effects: this.readOnlyCompartment.reconfigure([
174
+ CodeMirrorState.readOnly.of(!this.view.editable),
175
+ CodeMirror.contentAttributes.of({ contentEditable: `${this.view.editable}` }),
176
+ ]),
165
177
  });
166
178
  this.updating = false;
167
179
  }
package/src/ui/theme.ts CHANGED
@@ -23,6 +23,9 @@ export const cmTheme = CodeMirror.theme({
23
23
  '&.cm-editor.code-block.danger': {
24
24
  backgroundColor: token('color.background.danger'),
25
25
  },
26
+ '.cm-content[aria-readonly="true"]': {
27
+ caretColor: 'transparent',
28
+ },
26
29
  '.cm-content': {
27
30
  cursor: 'text',
28
31
  caretColor: token('color.text'),