@atlaskit/editor-plugin-code-block-advanced 2.4.0 → 3.0.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 +49 -0
- package/afm-cc/tsconfig.json +3 -3
- package/afm-jira/tsconfig.json +3 -3
- package/afm-post-office/tsconfig.json +3 -3
- package/dist/cjs/nodeviews/codeBlockAdvanced.js +29 -18
- package/dist/cjs/ui/theme.js +4 -1
- package/dist/es2019/nodeviews/codeBlockAdvanced.js +29 -18
- package/dist/es2019/ui/theme.js +4 -1
- package/dist/esm/nodeviews/codeBlockAdvanced.js +29 -18
- package/dist/esm/ui/theme.js +4 -1
- package/dist/types/nodeviews/codeBlockAdvanced.d.ts +2 -2
- package/dist/types/nodeviews/codemirrorSync/syncCMWithPM.d.ts +2 -2
- package/dist/types/nodeviews/extensions/keymap/backspace.d.ts +2 -2
- package/dist/types/nodeviews/extensions/keymap/index.d.ts +2 -2
- package/dist/types/nodeviews/extensions/keymap/maybeEscape.d.ts +2 -2
- package/dist/types/nodeviews/extensions/prosemirrorDecorations.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/codeBlockAdvanced.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/codemirrorSync/syncCMWithPM.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/extensions/keymap/backspace.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/extensions/keymap/index.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/extensions/keymap/maybeEscape.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/extensions/prosemirrorDecorations.d.ts +2 -2
- package/package.json +12 -10
- package/src/nodeviews/codeBlockAdvanced.ts +35 -22
- package/src/nodeviews/codemirrorSync/syncCMWithPM.ts +2 -2
- package/src/nodeviews/extensions/keymap/backspace.ts +2 -2
- package/src/nodeviews/extensions/keymap/index.ts +2 -2
- package/src/nodeviews/extensions/keymap/maybeEscape.ts +2 -2
- package/src/nodeviews/extensions/prosemirrorDecorations.ts +3 -3
- package/src/ui/theme.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block-advanced
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#182587](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/182587)
|
|
8
|
+
[`ab1ee31f25e9c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ab1ee31f25e9c) -
|
|
9
|
+
Fixes issue where right click menu would select entire code block.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.0.0
|
|
13
|
+
|
|
14
|
+
### Major Changes
|
|
15
|
+
|
|
16
|
+
- [#181024](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/181024)
|
|
17
|
+
[`8e80c487ca307`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e80c487ca307) - ##
|
|
18
|
+
Make `@atlaskit/editor-common` a peer dependency
|
|
19
|
+
|
|
20
|
+
**WHAT:** `@atlaskit/editor-common` has been moved from `dependencies` to `peerDependencies` in
|
|
21
|
+
all editor plugin packages.
|
|
22
|
+
|
|
23
|
+
**WHY:** This change ensures that only a single version of `@atlaskit/editor-common` is used in
|
|
24
|
+
consuming applications, preventing issues caused by multiple versions of singleton libraries (such
|
|
25
|
+
as context mismatches or duplicated state). This is especially important for packages that rely on
|
|
26
|
+
shared context or singletons.
|
|
27
|
+
|
|
28
|
+
**HOW TO ADJUST:**
|
|
29
|
+
|
|
30
|
+
- Consumers must now explicitly install `@atlaskit/editor-common` in their own project if they use
|
|
31
|
+
any of these editor plugins.
|
|
32
|
+
- Ensure the version you install matches the version required by the plugins.
|
|
33
|
+
- You can use the
|
|
34
|
+
[`check-peer-dependencies`](https://www.npmjs.com/package/check-peer-dependencies) package to
|
|
35
|
+
verify that all required peer dependencies are installed and compatible.
|
|
36
|
+
- Example install command:
|
|
37
|
+
```
|
|
38
|
+
npm install @atlaskit/editor-common
|
|
39
|
+
```
|
|
40
|
+
or
|
|
41
|
+
```
|
|
42
|
+
yarn add @atlaskit/editor-common
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Note:** This is a breaking change. If `@atlaskit/editor-common` is not installed at the
|
|
46
|
+
application level, you may see errors or unexpected behavior.
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies
|
|
51
|
+
|
|
3
52
|
## 2.4.0
|
|
4
53
|
|
|
5
54
|
### Minor Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"../src/**/examples.*"
|
|
18
18
|
],
|
|
19
19
|
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../editor-common/afm-cc/tsconfig.json"
|
|
22
|
-
},
|
|
23
20
|
{
|
|
24
21
|
"path": "../../editor-plugin-code-block/afm-cc/tsconfig.json"
|
|
25
22
|
},
|
|
@@ -43,6 +40,9 @@
|
|
|
43
40
|
},
|
|
44
41
|
{
|
|
45
42
|
"path": "../../../design-system/tokens/afm-cc/tsconfig.json"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../editor-common/afm-cc/tsconfig.json"
|
|
46
46
|
}
|
|
47
47
|
]
|
|
48
48
|
}
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"../src/**/examples.*"
|
|
18
18
|
],
|
|
19
19
|
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../editor-common/afm-jira/tsconfig.json"
|
|
22
|
-
},
|
|
23
20
|
{
|
|
24
21
|
"path": "../../editor-plugin-code-block/afm-jira/tsconfig.json"
|
|
25
22
|
},
|
|
@@ -43,6 +40,9 @@
|
|
|
43
40
|
},
|
|
44
41
|
{
|
|
45
42
|
"path": "../../../design-system/tokens/afm-jira/tsconfig.json"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../editor-common/afm-jira/tsconfig.json"
|
|
46
46
|
}
|
|
47
47
|
]
|
|
48
48
|
}
|
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"../src/**/examples.*"
|
|
18
18
|
],
|
|
19
19
|
"references": [
|
|
20
|
-
{
|
|
21
|
-
"path": "../../editor-common/afm-post-office/tsconfig.json"
|
|
22
|
-
},
|
|
23
20
|
{
|
|
24
21
|
"path": "../../editor-plugin-code-block/afm-post-office/tsconfig.json"
|
|
25
22
|
},
|
|
@@ -43,6 +40,9 @@
|
|
|
43
40
|
},
|
|
44
41
|
{
|
|
45
42
|
"path": "../../../design-system/tokens/afm-post-office/tsconfig.json"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../editor-common/afm-post-office/tsconfig.json"
|
|
46
46
|
}
|
|
47
47
|
]
|
|
48
48
|
}
|
|
@@ -17,6 +17,7 @@ var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
|
17
17
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
18
18
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
19
19
|
var _view2 = require("@atlaskit/editor-prosemirror/view");
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
21
22
|
var _syntaxHighlightingTheme = require("../ui/syntaxHighlightingTheme");
|
|
22
23
|
var _theme = require("../ui/theme");
|
|
@@ -74,7 +75,15 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
74
75
|
selectCodeBlockNode: this.selectCodeBlockNode.bind(this),
|
|
75
76
|
onMaybeNodeSelection: onMaybeNodeSelection,
|
|
76
77
|
customFindReplace: Boolean((_config$api3 = config.api) === null || _config$api3 === void 0 ? void 0 : _config$api3.findReplace)
|
|
77
|
-
}), _theme.cmTheme, (0, _language.syntaxHighlighting)(_syntaxHighlightingTheme.highlightStyle), (0, _language.bracketMatching)(), (0, _view.lineNumbers)(
|
|
78
|
+
}), _theme.cmTheme, (0, _language.syntaxHighlighting)(_syntaxHighlightingTheme.highlightStyle), (0, _language.bracketMatching)(), (0, _view.lineNumbers)({
|
|
79
|
+
domEventHandlers: (0, _platformFeatureFlags.fg)('platform_editor_fix_right_click_paste') ? {
|
|
80
|
+
click: function click() {
|
|
81
|
+
_this.selectCodeBlockNode(undefined);
|
|
82
|
+
_this.view.focus();
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
} : undefined
|
|
86
|
+
}),
|
|
78
87
|
// Explicitly disable "sticky" positioning on line numbers to match
|
|
79
88
|
// Renderer behaviour
|
|
80
89
|
(0, _view.gutters)({
|
|
@@ -243,23 +252,25 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
243
252
|
value: function stopEvent(e) {
|
|
244
253
|
var _this2 = this,
|
|
245
254
|
_this$getPos5;
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
255
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_fix_right_click_paste')) {
|
|
256
|
+
if (e instanceof MouseEvent && e.type === 'mousedown') {
|
|
257
|
+
// !Warning: Side effect!
|
|
258
|
+
// CodeMirror on blur updates the dom observer with a `setTimeout(..., 10);`
|
|
259
|
+
// We need to select the nodeview after this has taken place to ensure
|
|
260
|
+
// ProseMirror takes over
|
|
261
|
+
// https://github.com/codemirror/view/commit/70a9a253df04a57004247b9463198c17832f92f4#diff-cb8cbffa623ff0975389e7e8c315e69d5e10345239ffe2c9b4b7986a56ad95efR720
|
|
262
|
+
setTimeout(function () {
|
|
263
|
+
// Ensure the CM selection is reset - if we have a ranged selection when we do node selection can
|
|
264
|
+
// cause funky behaviour
|
|
265
|
+
_this2.updating = true;
|
|
266
|
+
_this2.cm.dispatch({
|
|
267
|
+
selection: _state.EditorSelection.create([_state.EditorSelection.cursor(0)], 0)
|
|
268
|
+
});
|
|
269
|
+
_this2.updating = false;
|
|
270
|
+
_this2.selectCodeBlockNode(undefined);
|
|
271
|
+
_this2.view.focus();
|
|
272
|
+
}, 20);
|
|
273
|
+
}
|
|
263
274
|
}
|
|
264
275
|
// If we have selected the node we should not stop these events
|
|
265
276
|
if ((e instanceof KeyboardEvent || e instanceof ClipboardEvent) && this.view.state.selection instanceof _state2.NodeSelection && this.view.state.selection.from === ((_this$getPos5 = this.getPos) === null || _this$getPos5 === void 0 ? void 0 : _this$getPos5.call(this))) {
|
package/dist/cjs/ui/theme.js
CHANGED
|
@@ -51,10 +51,13 @@ var cmTheme = exports.cmTheme = _view.EditorView.theme({
|
|
|
51
51
|
'&.cm-focused .cm-cursor': {
|
|
52
52
|
borderLeftColor: "var(--ds-text, #172B4D)"
|
|
53
53
|
},
|
|
54
|
+
'.cm-gutter': {
|
|
55
|
+
padding: "var(--ds-space-100, 8px)"
|
|
56
|
+
},
|
|
54
57
|
'.cm-gutters': {
|
|
55
58
|
backgroundColor: "var(--ds-background-neutral, #091E420F)",
|
|
56
59
|
border: 'none',
|
|
57
|
-
padding: "var(--ds-space-
|
|
60
|
+
padding: "var(--ds-space-0, 0px)",
|
|
58
61
|
color: "var(--ds-text-subtlest, #626F86)"
|
|
59
62
|
},
|
|
60
63
|
'.cm-lineNumbers .cm-gutterElement': {
|
|
@@ -7,6 +7,7 @@ import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
|
7
7
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
8
8
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
11
12
|
import { highlightStyle } from '../ui/syntaxHighlightingTheme';
|
|
12
13
|
import { cmTheme } from '../ui/theme';
|
|
@@ -54,7 +55,15 @@ class CodeBlockAdvancedNodeView {
|
|
|
54
55
|
selectCodeBlockNode: this.selectCodeBlockNode.bind(this),
|
|
55
56
|
onMaybeNodeSelection,
|
|
56
57
|
customFindReplace: Boolean((_config$api3 = config.api) === null || _config$api3 === void 0 ? void 0 : _config$api3.findReplace)
|
|
57
|
-
}), cmTheme, syntaxHighlighting(highlightStyle), bracketMatching(), lineNumbers(
|
|
58
|
+
}), cmTheme, syntaxHighlighting(highlightStyle), bracketMatching(), lineNumbers({
|
|
59
|
+
domEventHandlers: fg('platform_editor_fix_right_click_paste') ? {
|
|
60
|
+
click: () => {
|
|
61
|
+
this.selectCodeBlockNode(undefined);
|
|
62
|
+
this.view.focus();
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
} : undefined
|
|
66
|
+
}),
|
|
58
67
|
// Explicitly disable "sticky" positioning on line numbers to match
|
|
59
68
|
// Renderer behaviour
|
|
60
69
|
gutters({
|
|
@@ -192,23 +201,25 @@ class CodeBlockAdvancedNodeView {
|
|
|
192
201
|
}
|
|
193
202
|
stopEvent(e) {
|
|
194
203
|
var _this$getPos5;
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
if (!fg('platform_editor_fix_right_click_paste')) {
|
|
205
|
+
if (e instanceof MouseEvent && e.type === 'mousedown') {
|
|
206
|
+
// !Warning: Side effect!
|
|
207
|
+
// CodeMirror on blur updates the dom observer with a `setTimeout(..., 10);`
|
|
208
|
+
// We need to select the nodeview after this has taken place to ensure
|
|
209
|
+
// ProseMirror takes over
|
|
210
|
+
// https://github.com/codemirror/view/commit/70a9a253df04a57004247b9463198c17832f92f4#diff-cb8cbffa623ff0975389e7e8c315e69d5e10345239ffe2c9b4b7986a56ad95efR720
|
|
211
|
+
setTimeout(() => {
|
|
212
|
+
// Ensure the CM selection is reset - if we have a ranged selection when we do node selection can
|
|
213
|
+
// cause funky behaviour
|
|
214
|
+
this.updating = true;
|
|
215
|
+
this.cm.dispatch({
|
|
216
|
+
selection: EditorSelection.create([EditorSelection.cursor(0)], 0)
|
|
217
|
+
});
|
|
218
|
+
this.updating = false;
|
|
219
|
+
this.selectCodeBlockNode(undefined);
|
|
220
|
+
this.view.focus();
|
|
221
|
+
}, 20);
|
|
222
|
+
}
|
|
212
223
|
}
|
|
213
224
|
// If we have selected the node we should not stop these events
|
|
214
225
|
if ((e instanceof KeyboardEvent || e instanceof ClipboardEvent) && this.view.state.selection instanceof NodeSelection && this.view.state.selection.from === ((_this$getPos5 = this.getPos) === null || _this$getPos5 === void 0 ? void 0 : _this$getPos5.call(this))) {
|
package/dist/es2019/ui/theme.js
CHANGED
|
@@ -45,10 +45,13 @@ export const cmTheme = CodeMirror.theme({
|
|
|
45
45
|
'&.cm-focused .cm-cursor': {
|
|
46
46
|
borderLeftColor: "var(--ds-text, #172B4D)"
|
|
47
47
|
},
|
|
48
|
+
'.cm-gutter': {
|
|
49
|
+
padding: "var(--ds-space-100, 8px)"
|
|
50
|
+
},
|
|
48
51
|
'.cm-gutters': {
|
|
49
52
|
backgroundColor: "var(--ds-background-neutral, #091E420F)",
|
|
50
53
|
border: 'none',
|
|
51
|
-
padding: "var(--ds-space-
|
|
54
|
+
padding: "var(--ds-space-0, 0px)",
|
|
52
55
|
color: "var(--ds-text-subtlest, #626F86)"
|
|
53
56
|
},
|
|
54
57
|
'.cm-lineNumbers .cm-gutterElement': {
|
|
@@ -10,6 +10,7 @@ import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
|
10
10
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
11
11
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
14
15
|
import { highlightStyle } from '../ui/syntaxHighlightingTheme';
|
|
15
16
|
import { cmTheme } from '../ui/theme';
|
|
@@ -67,7 +68,15 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
67
68
|
selectCodeBlockNode: this.selectCodeBlockNode.bind(this),
|
|
68
69
|
onMaybeNodeSelection: onMaybeNodeSelection,
|
|
69
70
|
customFindReplace: Boolean((_config$api3 = config.api) === null || _config$api3 === void 0 ? void 0 : _config$api3.findReplace)
|
|
70
|
-
}), cmTheme, syntaxHighlighting(highlightStyle), bracketMatching(), lineNumbers(
|
|
71
|
+
}), cmTheme, syntaxHighlighting(highlightStyle), bracketMatching(), lineNumbers({
|
|
72
|
+
domEventHandlers: fg('platform_editor_fix_right_click_paste') ? {
|
|
73
|
+
click: function click() {
|
|
74
|
+
_this.selectCodeBlockNode(undefined);
|
|
75
|
+
_this.view.focus();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
} : undefined
|
|
79
|
+
}),
|
|
71
80
|
// Explicitly disable "sticky" positioning on line numbers to match
|
|
72
81
|
// Renderer behaviour
|
|
73
82
|
gutters({
|
|
@@ -236,23 +245,25 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
236
245
|
value: function stopEvent(e) {
|
|
237
246
|
var _this2 = this,
|
|
238
247
|
_this$getPos5;
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
248
|
+
if (!fg('platform_editor_fix_right_click_paste')) {
|
|
249
|
+
if (e instanceof MouseEvent && e.type === 'mousedown') {
|
|
250
|
+
// !Warning: Side effect!
|
|
251
|
+
// CodeMirror on blur updates the dom observer with a `setTimeout(..., 10);`
|
|
252
|
+
// We need to select the nodeview after this has taken place to ensure
|
|
253
|
+
// ProseMirror takes over
|
|
254
|
+
// https://github.com/codemirror/view/commit/70a9a253df04a57004247b9463198c17832f92f4#diff-cb8cbffa623ff0975389e7e8c315e69d5e10345239ffe2c9b4b7986a56ad95efR720
|
|
255
|
+
setTimeout(function () {
|
|
256
|
+
// Ensure the CM selection is reset - if we have a ranged selection when we do node selection can
|
|
257
|
+
// cause funky behaviour
|
|
258
|
+
_this2.updating = true;
|
|
259
|
+
_this2.cm.dispatch({
|
|
260
|
+
selection: EditorSelection.create([EditorSelection.cursor(0)], 0)
|
|
261
|
+
});
|
|
262
|
+
_this2.updating = false;
|
|
263
|
+
_this2.selectCodeBlockNode(undefined);
|
|
264
|
+
_this2.view.focus();
|
|
265
|
+
}, 20);
|
|
266
|
+
}
|
|
256
267
|
}
|
|
257
268
|
// If we have selected the node we should not stop these events
|
|
258
269
|
if ((e instanceof KeyboardEvent || e instanceof ClipboardEvent) && this.view.state.selection instanceof NodeSelection && this.view.state.selection.from === ((_this$getPos5 = this.getPos) === null || _this$getPos5 === void 0 ? void 0 : _this$getPos5.call(this))) {
|
package/dist/esm/ui/theme.js
CHANGED
|
@@ -45,10 +45,13 @@ export var cmTheme = CodeMirror.theme({
|
|
|
45
45
|
'&.cm-focused .cm-cursor': {
|
|
46
46
|
borderLeftColor: "var(--ds-text, #172B4D)"
|
|
47
47
|
},
|
|
48
|
+
'.cm-gutter': {
|
|
49
|
+
padding: "var(--ds-space-100, 8px)"
|
|
50
|
+
},
|
|
48
51
|
'.cm-gutters': {
|
|
49
52
|
backgroundColor: "var(--ds-background-neutral, #091E420F)",
|
|
50
53
|
border: 'none',
|
|
51
|
-
padding: "var(--ds-space-
|
|
54
|
+
padding: "var(--ds-space-0, 0px)",
|
|
52
55
|
color: "var(--ds-text-subtlest, #626F86)"
|
|
53
56
|
},
|
|
54
57
|
'.cm-lineNumbers .cm-gutterElement': {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Extension } from '@codemirror/state';
|
|
2
|
-
import { ViewUpdate } from '@codemirror/view';
|
|
2
|
+
import { type ViewUpdate } from '@codemirror/view';
|
|
3
3
|
import type { getPosHandler, getPosHandlerNode, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
|
|
7
7
|
interface ConfigProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ViewUpdate } from '@codemirror/view';
|
|
2
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import { type ViewUpdate } from '@codemirror/view';
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
interface Props {
|
|
4
4
|
view: EditorView;
|
|
5
5
|
update: ViewUpdate;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EditorView as CodeMirror } from '@codemirror/view';
|
|
1
|
+
import { type EditorView as CodeMirror } from '@codemirror/view';
|
|
2
2
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
interface BackspaceProps {
|
|
6
6
|
view: EditorView;
|
|
7
7
|
cm: CodeMirror;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Extension } from '@codemirror/state';
|
|
2
|
-
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
2
|
+
import { type RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
interface KeymapProps {
|
|
7
7
|
view: EditorView;
|
|
8
8
|
getNode: () => PMNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EditorView as CodeMirror } from '@codemirror/view';
|
|
1
|
+
import { type EditorView as CodeMirror } from '@codemirror/view';
|
|
2
2
|
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
interface MaybeEscapeProps {
|
|
7
7
|
unit: 'line' | 'char';
|
|
8
8
|
dir: -1 | 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Facet } from '@codemirror/state';
|
|
2
|
-
import { ViewPlugin, EditorView as CodeMirror, type DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
1
|
+
import { type Facet } from '@codemirror/state';
|
|
2
|
+
import { ViewPlugin, type EditorView as CodeMirror, type DecorationSet, type ViewUpdate } from '@codemirror/view';
|
|
3
3
|
import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
/**
|
|
5
5
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Extension } from '@codemirror/state';
|
|
2
|
-
import { ViewUpdate } from '@codemirror/view';
|
|
2
|
+
import { type ViewUpdate } from '@codemirror/view';
|
|
3
3
|
import type { getPosHandler, getPosHandlerNode, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
|
|
7
7
|
interface ConfigProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ViewUpdate } from '@codemirror/view';
|
|
2
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
1
|
+
import { type ViewUpdate } from '@codemirror/view';
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
3
|
interface Props {
|
|
4
4
|
view: EditorView;
|
|
5
5
|
update: ViewUpdate;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EditorView as CodeMirror } from '@codemirror/view';
|
|
1
|
+
import { type EditorView as CodeMirror } from '@codemirror/view';
|
|
2
2
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
interface BackspaceProps {
|
|
6
6
|
view: EditorView;
|
|
7
7
|
cm: CodeMirror;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Extension } from '@codemirror/state';
|
|
2
|
-
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
2
|
+
import { type RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
interface KeymapProps {
|
|
7
7
|
view: EditorView;
|
|
8
8
|
getNode: () => PMNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EditorView as CodeMirror } from '@codemirror/view';
|
|
1
|
+
import { type EditorView as CodeMirror } from '@codemirror/view';
|
|
2
2
|
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
3
3
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
interface MaybeEscapeProps {
|
|
7
7
|
unit: 'line' | 'char';
|
|
8
8
|
dir: -1 | 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Facet } from '@codemirror/state';
|
|
2
|
-
import { ViewPlugin, EditorView as CodeMirror, type DecorationSet, ViewUpdate } from '@codemirror/view';
|
|
1
|
+
import { type Facet } from '@codemirror/state';
|
|
2
|
+
import { ViewPlugin, type EditorView as CodeMirror, type DecorationSet, type ViewUpdate } from '@codemirror/view';
|
|
3
3
|
import type { EditorView, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
/**
|
|
5
5
|
* Creates CodeMirror versions of the decorations provided by ProseMirror.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block-advanced",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor: Lego",
|
|
12
12
|
"releaseModel": "continuous",
|
|
13
|
-
"singleton": true
|
|
14
|
-
"runReact18": true
|
|
13
|
+
"singleton": true
|
|
15
14
|
},
|
|
16
15
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
17
16
|
"main": "dist/cjs/index.js",
|
|
@@ -33,15 +32,14 @@
|
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
36
|
-
"@atlaskit/editor-
|
|
37
|
-
"@atlaskit/editor-plugin-
|
|
38
|
-
"@atlaskit/editor-plugin-
|
|
39
|
-
"@atlaskit/editor-plugin-
|
|
40
|
-
"@atlaskit/editor-plugin-selection": "^
|
|
41
|
-
"@atlaskit/editor-plugin-selection-marker": "^2.5.0",
|
|
35
|
+
"@atlaskit/editor-plugin-code-block": "^5.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-editor-disabled": "^3.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-find-replace": "^3.0.0",
|
|
38
|
+
"@atlaskit/editor-plugin-selection": "^3.0.0",
|
|
39
|
+
"@atlaskit/editor-plugin-selection-marker": "^3.0.0",
|
|
42
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
41
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^8.
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^8.8.0",
|
|
45
43
|
"@atlaskit/tokens": "^5.4.0",
|
|
46
44
|
"@babel/runtime": "^7.0.0",
|
|
47
45
|
"@codemirror/autocomplete": "6.18.4",
|
|
@@ -56,6 +54,7 @@
|
|
|
56
54
|
"codemirror-lang-elixir": "4.0.0"
|
|
57
55
|
},
|
|
58
56
|
"peerDependencies": {
|
|
57
|
+
"@atlaskit/editor-common": "^107.7.0",
|
|
59
58
|
"react": "^18.2.0"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
@@ -101,6 +100,9 @@
|
|
|
101
100
|
"platform-feature-flags": {
|
|
102
101
|
"platform_editor_breakout_resizing_hello_release": {
|
|
103
102
|
"type": "boolean"
|
|
103
|
+
},
|
|
104
|
+
"platform_editor_fix_right_click_paste": {
|
|
105
|
+
"type": "boolean"
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
EditorSelection,
|
|
7
7
|
Facet,
|
|
8
8
|
EditorState as CodeMirrorState,
|
|
9
|
-
StateEffect,
|
|
9
|
+
type StateEffect,
|
|
10
10
|
} from '@codemirror/state';
|
|
11
|
-
import { EditorView as CodeMirror, lineNumbers, ViewUpdate, gutters } from '@codemirror/view';
|
|
11
|
+
import { EditorView as CodeMirror, lineNumbers, type ViewUpdate, gutters } from '@codemirror/view';
|
|
12
12
|
|
|
13
13
|
import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
14
|
-
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
14
|
+
import { type RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
15
15
|
import type {
|
|
16
16
|
getPosHandler,
|
|
17
17
|
getPosHandlerNode,
|
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
} from '@atlaskit/editor-common/types';
|
|
20
20
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
21
21
|
import { type EditorSelectionAPI } from '@atlaskit/editor-plugin-selection';
|
|
22
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
22
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
23
23
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
24
24
|
import type {
|
|
25
25
|
Decoration,
|
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
NodeView,
|
|
29
29
|
} from '@atlaskit/editor-prosemirror/view';
|
|
30
30
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
31
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
31
32
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
32
33
|
|
|
33
34
|
import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
|
|
@@ -110,7 +111,17 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
110
111
|
cmTheme,
|
|
111
112
|
syntaxHighlighting(highlightStyle),
|
|
112
113
|
bracketMatching(),
|
|
113
|
-
lineNumbers(
|
|
114
|
+
lineNumbers({
|
|
115
|
+
domEventHandlers: fg('platform_editor_fix_right_click_paste')
|
|
116
|
+
? {
|
|
117
|
+
click: () => {
|
|
118
|
+
this.selectCodeBlockNode(undefined);
|
|
119
|
+
this.view.focus();
|
|
120
|
+
return true;
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
: undefined,
|
|
124
|
+
}),
|
|
114
125
|
// Explicitly disable "sticky" positioning on line numbers to match
|
|
115
126
|
// Renderer behaviour
|
|
116
127
|
gutters({ fixed: false }),
|
|
@@ -264,23 +275,25 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
264
275
|
}
|
|
265
276
|
|
|
266
277
|
stopEvent(e: Event) {
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
278
|
+
if (!fg('platform_editor_fix_right_click_paste')) {
|
|
279
|
+
if (e instanceof MouseEvent && e.type === 'mousedown') {
|
|
280
|
+
// !Warning: Side effect!
|
|
281
|
+
// CodeMirror on blur updates the dom observer with a `setTimeout(..., 10);`
|
|
282
|
+
// We need to select the nodeview after this has taken place to ensure
|
|
283
|
+
// ProseMirror takes over
|
|
284
|
+
// https://github.com/codemirror/view/commit/70a9a253df04a57004247b9463198c17832f92f4#diff-cb8cbffa623ff0975389e7e8c315e69d5e10345239ffe2c9b4b7986a56ad95efR720
|
|
285
|
+
setTimeout(() => {
|
|
286
|
+
// Ensure the CM selection is reset - if we have a ranged selection when we do node selection can
|
|
287
|
+
// cause funky behaviour
|
|
288
|
+
this.updating = true;
|
|
289
|
+
this.cm.dispatch({
|
|
290
|
+
selection: EditorSelection.create([EditorSelection.cursor(0)], 0),
|
|
291
|
+
});
|
|
292
|
+
this.updating = false;
|
|
293
|
+
this.selectCodeBlockNode(undefined);
|
|
294
|
+
this.view.focus();
|
|
295
|
+
}, 20);
|
|
296
|
+
}
|
|
284
297
|
}
|
|
285
298
|
// If we have selected the node we should not stop these events
|
|
286
299
|
if (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ViewUpdate } from '@codemirror/view';
|
|
1
|
+
import { type ViewUpdate } from '@codemirror/view';
|
|
2
2
|
|
|
3
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
view: EditorView;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EditorView as CodeMirror } from '@codemirror/view';
|
|
1
|
+
import { type EditorView as CodeMirror } from '@codemirror/view';
|
|
2
2
|
|
|
3
3
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
|
|
8
8
|
interface BackspaceProps {
|
|
9
9
|
view: EditorView;
|
|
@@ -3,12 +3,12 @@ import { type Extension } from '@codemirror/state';
|
|
|
3
3
|
import { type KeyBinding, keymap as cmKeymap } from '@codemirror/view';
|
|
4
4
|
|
|
5
5
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
6
|
-
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
6
|
+
import { type RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
7
7
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
8
8
|
import { exitCode, selectAll } from '@atlaskit/editor-prosemirror/commands';
|
|
9
9
|
import { undo, redo } from '@atlaskit/editor-prosemirror/history';
|
|
10
10
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
11
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
14
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EditorView as CodeMirror } from '@codemirror/view';
|
|
1
|
+
import { type EditorView as CodeMirror } from '@codemirror/view';
|
|
2
2
|
|
|
3
3
|
import { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
4
4
|
import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
|
|
9
9
|
interface MaybeEscapeProps {
|
|
10
10
|
unit: 'line' | 'char';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Facet } from '@codemirror/state';
|
|
1
|
+
import { type Facet } from '@codemirror/state';
|
|
2
2
|
import {
|
|
3
3
|
ViewPlugin,
|
|
4
4
|
WidgetType,
|
|
5
5
|
Decoration as CodeMirrorDecoration,
|
|
6
|
-
EditorView as CodeMirror,
|
|
6
|
+
type EditorView as CodeMirror,
|
|
7
7
|
type DecorationSet,
|
|
8
|
-
ViewUpdate,
|
|
8
|
+
type ViewUpdate,
|
|
9
9
|
} from '@codemirror/view';
|
|
10
10
|
|
|
11
11
|
import type { EditorView, Decoration, DecorationSource } from '@atlaskit/editor-prosemirror/view';
|
package/src/ui/theme.ts
CHANGED
|
@@ -49,10 +49,13 @@ export const cmTheme = CodeMirror.theme({
|
|
|
49
49
|
'&.cm-focused .cm-cursor': {
|
|
50
50
|
borderLeftColor: token('color.text'),
|
|
51
51
|
},
|
|
52
|
+
'.cm-gutter': {
|
|
53
|
+
padding: token('space.100'),
|
|
54
|
+
},
|
|
52
55
|
'.cm-gutters': {
|
|
53
56
|
backgroundColor: token('color.background.neutral'),
|
|
54
57
|
border: 'none',
|
|
55
|
-
padding: token('space.
|
|
58
|
+
padding: token('space.0'),
|
|
56
59
|
color: token('color.text.subtlest'),
|
|
57
60
|
},
|
|
58
61
|
'.cm-lineNumbers .cm-gutterElement': {
|