@atlaskit/editor-plugin-code-block-advanced 4.0.2 → 4.0.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 +14 -0
- package/dist/cjs/nodeviews/codeBlockAdvanced.js +21 -2
- package/dist/cjs/nodeviews/codeBlockNodeWithToDOMFixed.js +1 -1
- package/dist/es2019/nodeviews/codeBlockAdvanced.js +17 -1
- package/dist/es2019/nodeviews/codeBlockNodeWithToDOMFixed.js +2 -2
- package/dist/esm/nodeviews/codeBlockAdvanced.js +21 -2
- package/dist/esm/nodeviews/codeBlockNodeWithToDOMFixed.js +2 -2
- package/dist/types/nodeviews/codeBlockAdvanced.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/codeBlockAdvanced.d.ts +1 -0
- package/package.json +5 -5
- package/src/nodeviews/codeBlockAdvanced.ts +20 -1
- package/src/nodeviews/codeBlockNodeWithToDOMFixed.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block-advanced
|
|
2
2
|
|
|
3
|
+
## 4.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e239c0974b8dc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e239c0974b8dc) -
|
|
8
|
+
EDITOR-1464 Use codeBlockWithLocalId and add local-id attribute to dom output.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.0.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 4.0.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -18,6 +18,7 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
18
18
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
19
19
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
20
20
|
var _view2 = require("@atlaskit/editor-prosemirror/view");
|
|
21
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
22
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
22
23
|
var _syntaxHighlightingTheme = require("../ui/syntaxHighlightingTheme");
|
|
23
24
|
var _theme = require("../ui/theme");
|
|
@@ -30,6 +31,8 @@ var _manageSelectionMarker = require("./extensions/manageSelectionMarker");
|
|
|
30
31
|
var _prosemirrorDecorations = require("./extensions/prosemirrorDecorations");
|
|
31
32
|
var _tripleClickExtension = require("./extensions/tripleClickExtension");
|
|
32
33
|
var _loader = require("./languages/loader");
|
|
34
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
35
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
36
|
// Based on: https://prosemirror.net/examples/codemirror/
|
|
34
37
|
var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
35
38
|
function CodeBlockAdvancedNodeView(node, view, getPos, innerDecorations, config) {
|
|
@@ -101,9 +104,11 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
101
104
|
return _this.forwardUpdate(update);
|
|
102
105
|
}), this.readOnlyCompartment.of([_state.EditorState.readOnly.of(!this.view.editable), _view.EditorView.contentAttributes.of({
|
|
103
106
|
contentEditable: "".concat(this.view.editable)
|
|
104
|
-
})]), (0, _autocomplete.closeBrackets)(), _view.EditorView.editorAttributes.of({
|
|
107
|
+
})]), (0, _autocomplete.closeBrackets)(), _view.EditorView.editorAttributes.of(_objectSpread({
|
|
105
108
|
class: 'code-block'
|
|
106
|
-
}
|
|
109
|
+
}, (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') && {
|
|
110
|
+
'data-local-id': this.node.attrs.localId
|
|
111
|
+
})), (0, _manageSelectionMarker.manageSelectionMarker)(config.api), (0, _prosemirrorDecorations.prosemirrorDecorationPlugin)(this.pmFacet, view, getPos), (0, _tripleClickExtension.tripleClickSelectAllExtension)(), (0, _firstCodeBlockInDocument.firstCodeBlockInDocument)(getPos), _view.EditorView.contentAttributes.of({
|
|
107
112
|
'aria-label': formattedAriaLabel
|
|
108
113
|
}), config.allowCodeFolding ? [(0, _foldGutter.foldGutterExtension)({
|
|
109
114
|
selectNode: selectNode,
|
|
@@ -126,6 +131,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
126
131
|
// inner editor
|
|
127
132
|
this.updating = false;
|
|
128
133
|
this.updateLanguage();
|
|
134
|
+
this.updateLocalIdAttribute();
|
|
129
135
|
this.wordWrappingEnabled = (0, _codeBlock.isCodeBlockWordWrapEnabled)(node);
|
|
130
136
|
|
|
131
137
|
// Restore fold state after initialization
|
|
@@ -188,6 +194,18 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
188
194
|
value: function updateLanguage() {
|
|
189
195
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
190
196
|
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "updateLocalIdAttribute",
|
|
199
|
+
value: function updateLocalIdAttribute() {
|
|
200
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid')) {
|
|
201
|
+
var localId = this.node.attrs.localId;
|
|
202
|
+
if (localId) {
|
|
203
|
+
this.cm.dom.setAttribute('data-local-id', localId);
|
|
204
|
+
} else {
|
|
205
|
+
this.cm.dom.removeAttribute('data-local-id');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
191
209
|
}, {
|
|
192
210
|
key: "selectCodeBlockNode",
|
|
193
211
|
value: function selectCodeBlockNode(relativeSelectionPos) {
|
|
@@ -236,6 +254,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
236
254
|
return true;
|
|
237
255
|
}
|
|
238
256
|
this.updateLanguage();
|
|
257
|
+
this.updateLocalIdAttribute();
|
|
239
258
|
var newText = node.textContent,
|
|
240
259
|
curText = this.cm.state.doc.toString();
|
|
241
260
|
|
|
@@ -81,7 +81,7 @@ var _toDOM = function toDOM(node, formattedAriaLabel, config) {
|
|
|
81
81
|
}]];
|
|
82
82
|
};
|
|
83
83
|
var codeBlockNodeWithFixedToDOM = exports.codeBlockNodeWithFixedToDOM = function codeBlockNodeWithFixedToDOM(config) {
|
|
84
|
-
return _objectSpread(_objectSpread({}, _adfSchema.codeBlock), {}, {
|
|
84
|
+
return _objectSpread(_objectSpread({}, (0, _platformFeatureFlags.fg)('platform_editor_adf_with_localid') ? _adfSchema.codeBlockWithLocalId : _adfSchema.codeBlock), {}, {
|
|
85
85
|
toDOM: function toDOM(node) {
|
|
86
86
|
return _toDOM(node, '', config);
|
|
87
87
|
}
|
|
@@ -8,6 +8,7 @@ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
|
8
8
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
9
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
12
13
|
import { highlightStyle } from '../ui/syntaxHighlightingTheme';
|
|
13
14
|
import { cmTheme, codeFoldingTheme } from '../ui/theme';
|
|
@@ -81,7 +82,10 @@ class CodeBlockAdvancedNodeView {
|
|
|
81
82
|
}), CodeMirror.updateListener.of(update => this.forwardUpdate(update)), this.readOnlyCompartment.of([CodeMirrorState.readOnly.of(!this.view.editable), CodeMirror.contentAttributes.of({
|
|
82
83
|
contentEditable: `${this.view.editable}`
|
|
83
84
|
})]), closeBrackets(), CodeMirror.editorAttributes.of({
|
|
84
|
-
class: 'code-block'
|
|
85
|
+
class: 'code-block',
|
|
86
|
+
...(fg('platform_editor_adf_with_localid') && {
|
|
87
|
+
'data-local-id': this.node.attrs.localId
|
|
88
|
+
})
|
|
85
89
|
}), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension(), firstCodeBlockInDocument(getPos), CodeMirror.contentAttributes.of({
|
|
86
90
|
'aria-label': formattedAriaLabel
|
|
87
91
|
}), config.allowCodeFolding ? [foldGutterExtension({
|
|
@@ -103,6 +107,7 @@ class CodeBlockAdvancedNodeView {
|
|
|
103
107
|
// inner editor
|
|
104
108
|
this.updating = false;
|
|
105
109
|
this.updateLanguage();
|
|
110
|
+
this.updateLocalIdAttribute();
|
|
106
111
|
this.wordWrappingEnabled = isCodeBlockWordWrapEnabled(node);
|
|
107
112
|
|
|
108
113
|
// Restore fold state after initialization
|
|
@@ -155,6 +160,16 @@ class CodeBlockAdvancedNodeView {
|
|
|
155
160
|
updateLanguage() {
|
|
156
161
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
157
162
|
}
|
|
163
|
+
updateLocalIdAttribute() {
|
|
164
|
+
if (fg('platform_editor_adf_with_localid')) {
|
|
165
|
+
const localId = this.node.attrs.localId;
|
|
166
|
+
if (localId) {
|
|
167
|
+
this.cm.dom.setAttribute('data-local-id', localId);
|
|
168
|
+
} else {
|
|
169
|
+
this.cm.dom.removeAttribute('data-local-id');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
158
173
|
selectCodeBlockNode(relativeSelectionPos) {
|
|
159
174
|
var _this$selectionAPI, _this$getPos3, _this$getPos4;
|
|
160
175
|
const tr = (_this$selectionAPI = this.selectionAPI) === null || _this$selectionAPI === void 0 ? void 0 : _this$selectionAPI.selectNearNode({
|
|
@@ -195,6 +210,7 @@ class CodeBlockAdvancedNodeView {
|
|
|
195
210
|
return true;
|
|
196
211
|
}
|
|
197
212
|
this.updateLanguage();
|
|
213
|
+
this.updateLocalIdAttribute();
|
|
198
214
|
const newText = node.textContent,
|
|
199
215
|
curText = this.cm.state.doc.toString();
|
|
200
216
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { codeBlock } from '@atlaskit/adf-schema';
|
|
1
|
+
import { codeBlock, codeBlockWithLocalId } from '@atlaskit/adf-schema';
|
|
2
2
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
3
3
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -71,7 +71,7 @@ const toDOM = (node, formattedAriaLabel, config) => {
|
|
|
71
71
|
};
|
|
72
72
|
export const codeBlockNodeWithFixedToDOM = config => {
|
|
73
73
|
return {
|
|
74
|
-
...codeBlock,
|
|
74
|
+
...(fg('platform_editor_adf_with_localid') ? codeBlockWithLocalId : codeBlock),
|
|
75
75
|
toDOM: node => toDOM(node, '', config)
|
|
76
76
|
};
|
|
77
77
|
};
|
|
@@ -2,6 +2,8 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
7
|
import { closeBrackets } from '@codemirror/autocomplete';
|
|
6
8
|
import { syntaxHighlighting, bracketMatching } from '@codemirror/language';
|
|
7
9
|
import { Compartment, Facet, EditorState as CodeMirrorState } from '@codemirror/state';
|
|
@@ -11,6 +13,7 @@ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
|
11
13
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
12
14
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
15
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
17
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
15
18
|
import { highlightStyle } from '../ui/syntaxHighlightingTheme';
|
|
16
19
|
import { cmTheme, codeFoldingTheme } from '../ui/theme';
|
|
@@ -94,9 +97,11 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
94
97
|
return _this.forwardUpdate(update);
|
|
95
98
|
}), this.readOnlyCompartment.of([CodeMirrorState.readOnly.of(!this.view.editable), CodeMirror.contentAttributes.of({
|
|
96
99
|
contentEditable: "".concat(this.view.editable)
|
|
97
|
-
})]), closeBrackets(), CodeMirror.editorAttributes.of({
|
|
100
|
+
})]), closeBrackets(), CodeMirror.editorAttributes.of(_objectSpread({
|
|
98
101
|
class: 'code-block'
|
|
99
|
-
}
|
|
102
|
+
}, fg('platform_editor_adf_with_localid') && {
|
|
103
|
+
'data-local-id': this.node.attrs.localId
|
|
104
|
+
})), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension(), firstCodeBlockInDocument(getPos), CodeMirror.contentAttributes.of({
|
|
100
105
|
'aria-label': formattedAriaLabel
|
|
101
106
|
}), config.allowCodeFolding ? [foldGutterExtension({
|
|
102
107
|
selectNode: selectNode,
|
|
@@ -119,6 +124,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
119
124
|
// inner editor
|
|
120
125
|
this.updating = false;
|
|
121
126
|
this.updateLanguage();
|
|
127
|
+
this.updateLocalIdAttribute();
|
|
122
128
|
this.wordWrappingEnabled = isCodeBlockWordWrapEnabled(node);
|
|
123
129
|
|
|
124
130
|
// Restore fold state after initialization
|
|
@@ -181,6 +187,18 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
181
187
|
value: function updateLanguage() {
|
|
182
188
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
183
189
|
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "updateLocalIdAttribute",
|
|
192
|
+
value: function updateLocalIdAttribute() {
|
|
193
|
+
if (fg('platform_editor_adf_with_localid')) {
|
|
194
|
+
var localId = this.node.attrs.localId;
|
|
195
|
+
if (localId) {
|
|
196
|
+
this.cm.dom.setAttribute('data-local-id', localId);
|
|
197
|
+
} else {
|
|
198
|
+
this.cm.dom.removeAttribute('data-local-id');
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
184
202
|
}, {
|
|
185
203
|
key: "selectCodeBlockNode",
|
|
186
204
|
value: function selectCodeBlockNode(relativeSelectionPos) {
|
|
@@ -229,6 +247,7 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
229
247
|
return true;
|
|
230
248
|
}
|
|
231
249
|
this.updateLanguage();
|
|
250
|
+
this.updateLocalIdAttribute();
|
|
232
251
|
var newText = node.textContent,
|
|
233
252
|
curText = this.cm.state.doc.toString();
|
|
234
253
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import { codeBlock } from '@atlaskit/adf-schema';
|
|
4
|
+
import { codeBlock, codeBlockWithLocalId } from '@atlaskit/adf-schema';
|
|
5
5
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
6
6
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -74,7 +74,7 @@ var _toDOM = function toDOM(node, formattedAriaLabel, config) {
|
|
|
74
74
|
}]];
|
|
75
75
|
};
|
|
76
76
|
export var codeBlockNodeWithFixedToDOM = function codeBlockNodeWithFixedToDOM(config) {
|
|
77
|
-
return _objectSpread(_objectSpread({}, codeBlock), {}, {
|
|
77
|
+
return _objectSpread(_objectSpread({}, fg('platform_editor_adf_with_localid') ? codeBlockWithLocalId : codeBlock), {}, {
|
|
78
78
|
toDOM: function toDOM(node) {
|
|
79
79
|
return _toDOM(node, '', config);
|
|
80
80
|
}
|
|
@@ -33,6 +33,7 @@ declare class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
33
33
|
setSelection(anchor: number, head: number): void;
|
|
34
34
|
private updateReadonlyState;
|
|
35
35
|
private updateLanguage;
|
|
36
|
+
private updateLocalIdAttribute;
|
|
36
37
|
private selectCodeBlockNode;
|
|
37
38
|
private wordWrappingEnabled;
|
|
38
39
|
private getWordWrapEffects;
|
|
@@ -33,6 +33,7 @@ declare class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
33
33
|
setSelection(anchor: number, head: number): void;
|
|
34
34
|
private updateReadonlyState;
|
|
35
35
|
private updateLanguage;
|
|
36
|
+
private updateLocalIdAttribute;
|
|
36
37
|
private selectCodeBlockNode;
|
|
37
38
|
private wordWrappingEnabled;
|
|
38
39
|
private getWordWrapEffects;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block-advanced",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"@atlaskit/editor-plugin-selection": "^4.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-selection-marker": "^4.0.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
39
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
39
|
+
"@atlaskit/editor-toolbar": "^0.8.0",
|
|
40
40
|
"@atlaskit/icon": "^28.1.0",
|
|
41
41
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
42
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
43
|
-
"@atlaskit/tokens": "^6.
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^12.5.0",
|
|
43
|
+
"@atlaskit/tokens": "^6.2.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@codemirror/autocomplete": "6.18.4",
|
|
46
46
|
"@codemirror/commands": "6.7.1",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"codemirror-lang-elixir": "4.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@atlaskit/editor-common": "^108.
|
|
58
|
+
"@atlaskit/editor-common": "^108.3.0",
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
61
61
|
},
|
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
NodeView,
|
|
30
30
|
} from '@atlaskit/editor-prosemirror/view';
|
|
31
31
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
32
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
32
33
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
33
34
|
|
|
34
35
|
import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
|
|
@@ -140,7 +141,12 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
140
141
|
CodeMirror.contentAttributes.of({ contentEditable: `${this.view.editable}` }),
|
|
141
142
|
]),
|
|
142
143
|
closeBrackets(),
|
|
143
|
-
CodeMirror.editorAttributes.of({
|
|
144
|
+
CodeMirror.editorAttributes.of({
|
|
145
|
+
class: 'code-block',
|
|
146
|
+
...(fg('platform_editor_adf_with_localid') && {
|
|
147
|
+
'data-local-id': this.node.attrs.localId,
|
|
148
|
+
}),
|
|
149
|
+
}),
|
|
144
150
|
manageSelectionMarker(config.api),
|
|
145
151
|
prosemirrorDecorationPlugin(this.pmFacet, view, getPos),
|
|
146
152
|
tripleClickSelectAllExtension(),
|
|
@@ -165,6 +171,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
165
171
|
// inner editor
|
|
166
172
|
this.updating = false;
|
|
167
173
|
this.updateLanguage();
|
|
174
|
+
this.updateLocalIdAttribute();
|
|
168
175
|
this.wordWrappingEnabled = isCodeBlockWordWrapEnabled(node);
|
|
169
176
|
|
|
170
177
|
// Restore fold state after initialization
|
|
@@ -218,6 +225,17 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
218
225
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
219
226
|
}
|
|
220
227
|
|
|
228
|
+
private updateLocalIdAttribute() {
|
|
229
|
+
if (fg('platform_editor_adf_with_localid')) {
|
|
230
|
+
const localId = this.node.attrs.localId;
|
|
231
|
+
if (localId) {
|
|
232
|
+
this.cm.dom.setAttribute('data-local-id', localId);
|
|
233
|
+
} else {
|
|
234
|
+
this.cm.dom.removeAttribute('data-local-id');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
221
239
|
private selectCodeBlockNode(relativeSelectionPos: RelativeSelectionPos | undefined) {
|
|
222
240
|
const tr = this.selectionAPI?.selectNearNode({
|
|
223
241
|
selectionRelativeToNode: relativeSelectionPos,
|
|
@@ -260,6 +278,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
260
278
|
return true;
|
|
261
279
|
}
|
|
262
280
|
this.updateLanguage();
|
|
281
|
+
this.updateLocalIdAttribute();
|
|
263
282
|
const newText = node.textContent,
|
|
264
283
|
curText = this.cm.state.doc.toString();
|
|
265
284
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { codeBlock } from '@atlaskit/adf-schema';
|
|
1
|
+
import { codeBlock, codeBlockWithLocalId } from '@atlaskit/adf-schema';
|
|
2
2
|
import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
3
3
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
4
4
|
import type { NodeSpec, DOMOutputSpec, Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -107,7 +107,7 @@ const toDOM = (node: Node, formattedAriaLabel: string, config: Config): DOMOutpu
|
|
|
107
107
|
|
|
108
108
|
export const codeBlockNodeWithFixedToDOM = (config: Config): NodeSpec => {
|
|
109
109
|
return {
|
|
110
|
-
...codeBlock,
|
|
110
|
+
...(fg('platform_editor_adf_with_localid') ? codeBlockWithLocalId : codeBlock),
|
|
111
111
|
toDOM: (node) => toDOM(node, '', config),
|
|
112
112
|
};
|
|
113
113
|
};
|