@atlaskit/editor-plugin-code-block-advanced 16.0.6 → 16.0.8
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 +2 -43
- package/dist/es2019/nodeviews/codeBlockAdvanced.js +2 -46
- package/dist/esm/nodeviews/codeBlockAdvanced.js +3 -44
- package/dist/types/nodeviews/codeBlockAdvanced.d.ts +0 -2
- package/package.json +4 -4
- package/src/nodeviews/codeBlockAdvanced.ts +2 -67
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block-advanced
|
|
2
2
|
|
|
3
|
+
## 16.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`c4385174a8662`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c4385174a8662) -
|
|
8
|
+
Clean up experiment `editor_a11y_role_textbox`.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 16.0.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 16.0.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -14,9 +14,7 @@ var _language = require("@codemirror/language");
|
|
|
14
14
|
var _state = require("@codemirror/state");
|
|
15
15
|
var _view = require("@codemirror/view");
|
|
16
16
|
var _bindEventListener = require("bind-event-listener");
|
|
17
|
-
var _browser = require("@atlaskit/editor-common/browser");
|
|
18
17
|
var _codeBlock = require("@atlaskit/editor-common/code-block");
|
|
19
|
-
var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
20
18
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
21
19
|
var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
22
20
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -35,7 +33,6 @@ var _keymap = require("./extensions/keymap");
|
|
|
35
33
|
var _manageSelectionMarker = require("./extensions/manageSelectionMarker");
|
|
36
34
|
var _prosemirrorDecorations = require("./extensions/prosemirrorDecorations");
|
|
37
35
|
var _tripleClickExtension = require("./extensions/tripleClickExtension");
|
|
38
|
-
var _getLanguageName = _interopRequireDefault(require("./languages/getLanguageName"));
|
|
39
36
|
var _loader = require("./languages/loader");
|
|
40
37
|
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; }
|
|
41
38
|
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; }
|
|
@@ -114,7 +111,6 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
114
111
|
var _config$getIntl = config.getIntl(),
|
|
115
112
|
formatMessage = _config$getIntl.formatMessage;
|
|
116
113
|
var formattedAriaLabel = formatMessage(_messages.blockTypeMessages.codeblock);
|
|
117
|
-
var isMacOS = (0, _browser.getBrowserInfo)().mac;
|
|
118
114
|
this.cm = new _view.EditorView({
|
|
119
115
|
doc: this.node.textContent,
|
|
120
116
|
extensions: [].concat((0, _toConsumableArray2.default)(config.extensions), [this.lineWrappingCompartment.of((0, _codeBlock.isCodeBlockWordWrapEnabled)(node) ? _view.EditorView.lineWrapping : []), this.languageCompartment.of([]), this.pmDecorationsCompartment.of(this.pmFacet.compute([], function () {
|
|
@@ -143,18 +139,9 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
143
139
|
class: 'code-block'
|
|
144
140
|
}, (0, _fg.fg)('platform_editor_adf_with_localid') && {
|
|
145
141
|
'data-local-id': this.node.attrs.localId
|
|
146
|
-
})), (0, _manageSelectionMarker.manageSelectionMarker)(config.api), (0, _prosemirrorDecorations.prosemirrorDecorationPlugin)(this.pmFacet, view, getPos), (0, _tripleClickExtension.tripleClickSelectAllExtension)(), (0, _firstCodeBlockInDocument.firstCodeBlockInDocument)(getPos), _view.EditorView.contentAttributes.of(
|
|
142
|
+
})), (0, _manageSelectionMarker.manageSelectionMarker)(config.api), (0, _prosemirrorDecorations.prosemirrorDecorationPlugin)(this.pmFacet, view, getPos), (0, _tripleClickExtension.tripleClickSelectAllExtension)(), (0, _firstCodeBlockInDocument.firstCodeBlockInDocument)(getPos), _view.EditorView.contentAttributes.of({
|
|
147
143
|
'aria-label': "".concat(formattedAriaLabel)
|
|
148
|
-
}),
|
|
149
|
-
role: 'textbox',
|
|
150
|
-
'aria-roledescription': formatMessage(_messages.roleDescriptionMessages.codeSnippetTextBox),
|
|
151
|
-
'aria-describedby': "codesnippet-".concat(this.node.attrs.localId),
|
|
152
|
-
'aria-multiline': 'true',
|
|
153
|
-
'aria-label': formattedAriaLabel
|
|
154
|
-
}), !isMacOS && (0, _expValEquals.expValEquals)('editor_a11y_role_textbox', 'isEnabled', true) && {
|
|
155
|
-
'aria-label': formattedAriaLabel,
|
|
156
|
-
'aria-describedby': "codesnippet-".concat(this.node.attrs.localId)
|
|
157
|
-
})), config.allowCodeFolding ? [(0, _foldGutter.foldGutterExtension)({
|
|
144
|
+
}), config.allowCodeFolding ? [(0, _foldGutter.foldGutterExtension)({
|
|
158
145
|
selectNode: this.selectCodeBlockNodeAndFocus,
|
|
159
146
|
getNode: function getNode() {
|
|
160
147
|
return _this.node;
|
|
@@ -197,13 +184,6 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
197
184
|
// The editor's outer node is our DOM representation
|
|
198
185
|
this.dom = this.cm.dom;
|
|
199
186
|
this.dom.appendChild(spaceContainer);
|
|
200
|
-
if ((0, _expValEquals.expValEquals)('editor_a11y_role_textbox', 'isEnabled', true) && (0, _fg.fg)('platform_editor_adf_with_localid')) {
|
|
201
|
-
this.invisibleAriaDescription = document.createElement('span');
|
|
202
|
-
this.invisibleAriaDescription.hidden = true;
|
|
203
|
-
this.invisibleAriaDescription.id = "codesnippet-".concat(this.node.attrs.localId);
|
|
204
|
-
this.updateAriaDescription();
|
|
205
|
-
this.dom.appendChild(this.invisibleAriaDescription);
|
|
206
|
-
}
|
|
207
187
|
|
|
208
188
|
// This flag is used to avoid an update loop between the outer and
|
|
209
189
|
// inner editor
|
|
@@ -275,27 +255,6 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
275
255
|
key: "updateLanguage",
|
|
276
256
|
value: function updateLanguage() {
|
|
277
257
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
278
|
-
if ((0, _expValEquals.expValEquals)('editor_a11y_role_textbox', 'isEnabled', true) && (0, _fg.fg)('platform_editor_adf_with_localid')) {
|
|
279
|
-
this.updateAriaDescription();
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}, {
|
|
283
|
-
key: "updateAriaDescription",
|
|
284
|
-
value: function updateAriaDescription() {
|
|
285
|
-
if (!this.invisibleAriaDescription) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
var _this$config$getIntl = this.config.getIntl(),
|
|
289
|
-
formatMessage = _this$config$getIntl.formatMessage;
|
|
290
|
-
var languageName = (0, _getLanguageName.default)(this.node.attrs.language);
|
|
291
|
-
if (languageName) {
|
|
292
|
-
this.invisibleAriaDescription.textContent = "".concat(formatMessage(_messages.codeBlockMessages.codeblockLanguageAriaDescription, {
|
|
293
|
-
language: languageName
|
|
294
|
-
}), " ").concat(formatMessage(_floatingToolbar.messages.floatingToolbarAnnouncer));
|
|
295
|
-
} else {
|
|
296
|
-
// If the lanuage is undefined provide a more human readable message
|
|
297
|
-
this.invisibleAriaDescription.textContent = "".concat(formatMessage(_messages.codeBlockMessages.codeBlockLanguageNotSet), " ").concat(formatMessage(_floatingToolbar.messages.floatingToolbarAnnouncer));
|
|
298
|
-
}
|
|
299
258
|
}
|
|
300
259
|
}, {
|
|
301
260
|
key: "updateLocalIdAttribute",
|
|
@@ -4,10 +4,8 @@ import { syntaxHighlighting, bracketMatching } from '@codemirror/language';
|
|
|
4
4
|
import { Compartment, Facet, EditorState as CodeMirrorState } from '@codemirror/state';
|
|
5
5
|
import { EditorView as CodeMirror, lineNumbers, gutters } from '@codemirror/view';
|
|
6
6
|
import { bind } from 'bind-event-listener';
|
|
7
|
-
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
8
7
|
import { areCodeBlockLineNumbersHidden, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
9
|
-
import {
|
|
10
|
-
import { blockTypeMessages, codeBlockMessages, roleDescriptionMessages } from '@atlaskit/editor-common/messages';
|
|
8
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
11
9
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
12
10
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
11
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -25,7 +23,6 @@ import { keymapExtension } from './extensions/keymap';
|
|
|
25
23
|
import { manageSelectionMarker } from './extensions/manageSelectionMarker';
|
|
26
24
|
import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
|
|
27
25
|
import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
|
|
28
|
-
import getLanguageName from './languages/getLanguageName';
|
|
29
26
|
import { LanguageLoader } from './languages/loader';
|
|
30
27
|
// Based on: https://prosemirror.net/examples/codemirror/
|
|
31
28
|
class CodeBlockAdvancedNodeView {
|
|
@@ -93,7 +90,6 @@ class CodeBlockAdvancedNodeView {
|
|
|
93
90
|
formatMessage
|
|
94
91
|
} = config.getIntl();
|
|
95
92
|
const formattedAriaLabel = formatMessage(blockTypeMessages.codeblock);
|
|
96
|
-
const isMacOS = getBrowserInfo().mac;
|
|
97
93
|
this.cm = new CodeMirror({
|
|
98
94
|
doc: this.node.textContent,
|
|
99
95
|
extensions: [...config.extensions, this.lineWrappingCompartment.of(isCodeBlockWordWrapEnabled(node) ? CodeMirror.lineWrapping : []), this.languageCompartment.of([]), this.pmDecorationsCompartment.of(this.pmFacet.compute([], () => innerDecorations)), keymapExtension({
|
|
@@ -120,20 +116,7 @@ class CodeBlockAdvancedNodeView {
|
|
|
120
116
|
'data-local-id': this.node.attrs.localId
|
|
121
117
|
})
|
|
122
118
|
}), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension(), firstCodeBlockInDocument(getPos), CodeMirror.contentAttributes.of({
|
|
123
|
-
|
|
124
|
-
'aria-label': `${formattedAriaLabel}`
|
|
125
|
-
}),
|
|
126
|
-
...(isMacOS && expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && {
|
|
127
|
-
role: 'textbox',
|
|
128
|
-
'aria-roledescription': formatMessage(roleDescriptionMessages.codeSnippetTextBox),
|
|
129
|
-
'aria-describedby': `codesnippet-${this.node.attrs.localId}`,
|
|
130
|
-
'aria-multiline': 'true',
|
|
131
|
-
'aria-label': formattedAriaLabel
|
|
132
|
-
}),
|
|
133
|
-
...(!isMacOS && expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && {
|
|
134
|
-
'aria-label': formattedAriaLabel,
|
|
135
|
-
'aria-describedby': `codesnippet-${this.node.attrs.localId}`
|
|
136
|
-
})
|
|
119
|
+
'aria-label': `${formattedAriaLabel}`
|
|
137
120
|
}), config.allowCodeFolding ? [foldGutterExtension({
|
|
138
121
|
selectNode: this.selectCodeBlockNodeAndFocus,
|
|
139
122
|
getNode: () => this.node,
|
|
@@ -176,13 +159,6 @@ class CodeBlockAdvancedNodeView {
|
|
|
176
159
|
// The editor's outer node is our DOM representation
|
|
177
160
|
this.dom = this.cm.dom;
|
|
178
161
|
this.dom.appendChild(spaceContainer);
|
|
179
|
-
if (expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && fg('platform_editor_adf_with_localid')) {
|
|
180
|
-
this.invisibleAriaDescription = document.createElement('span');
|
|
181
|
-
this.invisibleAriaDescription.hidden = true;
|
|
182
|
-
this.invisibleAriaDescription.id = `codesnippet-${this.node.attrs.localId}`;
|
|
183
|
-
this.updateAriaDescription();
|
|
184
|
-
this.dom.appendChild(this.invisibleAriaDescription);
|
|
185
|
-
}
|
|
186
162
|
|
|
187
163
|
// This flag is used to avoid an update loop between the outer and
|
|
188
164
|
// inner editor
|
|
@@ -244,26 +220,6 @@ class CodeBlockAdvancedNodeView {
|
|
|
244
220
|
}
|
|
245
221
|
updateLanguage() {
|
|
246
222
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
247
|
-
if (expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && fg('platform_editor_adf_with_localid')) {
|
|
248
|
-
this.updateAriaDescription();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
updateAriaDescription() {
|
|
252
|
-
if (!this.invisibleAriaDescription) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const {
|
|
256
|
-
formatMessage
|
|
257
|
-
} = this.config.getIntl();
|
|
258
|
-
const languageName = getLanguageName(this.node.attrs.language);
|
|
259
|
-
if (languageName) {
|
|
260
|
-
this.invisibleAriaDescription.textContent = `${formatMessage(codeBlockMessages.codeblockLanguageAriaDescription, {
|
|
261
|
-
language: languageName
|
|
262
|
-
})} ${formatMessage(floatingToolbarMessages.floatingToolbarAnnouncer)}`;
|
|
263
|
-
} else {
|
|
264
|
-
// If the lanuage is undefined provide a more human readable message
|
|
265
|
-
this.invisibleAriaDescription.textContent = `${formatMessage(codeBlockMessages.codeBlockLanguageNotSet)} ${formatMessage(floatingToolbarMessages.floatingToolbarAnnouncer)}`;
|
|
266
|
-
}
|
|
267
223
|
}
|
|
268
224
|
updateLocalIdAttribute() {
|
|
269
225
|
if (fg('platform_editor_adf_with_localid')) {
|
|
@@ -9,10 +9,8 @@ import { syntaxHighlighting, bracketMatching } from '@codemirror/language';
|
|
|
9
9
|
import { Compartment, Facet, EditorState as CodeMirrorState } from '@codemirror/state';
|
|
10
10
|
import { EditorView as CodeMirror, lineNumbers, gutters } from '@codemirror/view';
|
|
11
11
|
import { bind } from 'bind-event-listener';
|
|
12
|
-
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
13
12
|
import { areCodeBlockLineNumbersHidden, isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
|
|
14
|
-
import {
|
|
15
|
-
import { blockTypeMessages, codeBlockMessages, roleDescriptionMessages } from '@atlaskit/editor-common/messages';
|
|
13
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
16
14
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/whitespace';
|
|
17
15
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
18
16
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -30,7 +28,6 @@ import { keymapExtension } from './extensions/keymap';
|
|
|
30
28
|
import { manageSelectionMarker } from './extensions/manageSelectionMarker';
|
|
31
29
|
import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
|
|
32
30
|
import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
|
|
33
|
-
import getLanguageName from './languages/getLanguageName';
|
|
34
31
|
import { LanguageLoader } from './languages/loader';
|
|
35
32
|
// Based on: https://prosemirror.net/examples/codemirror/
|
|
36
33
|
var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
@@ -107,7 +104,6 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
107
104
|
var _config$getIntl = config.getIntl(),
|
|
108
105
|
formatMessage = _config$getIntl.formatMessage;
|
|
109
106
|
var formattedAriaLabel = formatMessage(blockTypeMessages.codeblock);
|
|
110
|
-
var isMacOS = getBrowserInfo().mac;
|
|
111
107
|
this.cm = new CodeMirror({
|
|
112
108
|
doc: this.node.textContent,
|
|
113
109
|
extensions: [].concat(_toConsumableArray(config.extensions), [this.lineWrappingCompartment.of(isCodeBlockWordWrapEnabled(node) ? CodeMirror.lineWrapping : []), this.languageCompartment.of([]), this.pmDecorationsCompartment.of(this.pmFacet.compute([], function () {
|
|
@@ -136,18 +132,9 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
136
132
|
class: 'code-block'
|
|
137
133
|
}, fg('platform_editor_adf_with_localid') && {
|
|
138
134
|
'data-local-id': this.node.attrs.localId
|
|
139
|
-
})), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension(), firstCodeBlockInDocument(getPos), CodeMirror.contentAttributes.of(
|
|
135
|
+
})), manageSelectionMarker(config.api), prosemirrorDecorationPlugin(this.pmFacet, view, getPos), tripleClickSelectAllExtension(), firstCodeBlockInDocument(getPos), CodeMirror.contentAttributes.of({
|
|
140
136
|
'aria-label': "".concat(formattedAriaLabel)
|
|
141
|
-
}),
|
|
142
|
-
role: 'textbox',
|
|
143
|
-
'aria-roledescription': formatMessage(roleDescriptionMessages.codeSnippetTextBox),
|
|
144
|
-
'aria-describedby': "codesnippet-".concat(this.node.attrs.localId),
|
|
145
|
-
'aria-multiline': 'true',
|
|
146
|
-
'aria-label': formattedAriaLabel
|
|
147
|
-
}), !isMacOS && expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && {
|
|
148
|
-
'aria-label': formattedAriaLabel,
|
|
149
|
-
'aria-describedby': "codesnippet-".concat(this.node.attrs.localId)
|
|
150
|
-
})), config.allowCodeFolding ? [foldGutterExtension({
|
|
137
|
+
}), config.allowCodeFolding ? [foldGutterExtension({
|
|
151
138
|
selectNode: this.selectCodeBlockNodeAndFocus,
|
|
152
139
|
getNode: function getNode() {
|
|
153
140
|
return _this.node;
|
|
@@ -190,13 +177,6 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
190
177
|
// The editor's outer node is our DOM representation
|
|
191
178
|
this.dom = this.cm.dom;
|
|
192
179
|
this.dom.appendChild(spaceContainer);
|
|
193
|
-
if (expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && fg('platform_editor_adf_with_localid')) {
|
|
194
|
-
this.invisibleAriaDescription = document.createElement('span');
|
|
195
|
-
this.invisibleAriaDescription.hidden = true;
|
|
196
|
-
this.invisibleAriaDescription.id = "codesnippet-".concat(this.node.attrs.localId);
|
|
197
|
-
this.updateAriaDescription();
|
|
198
|
-
this.dom.appendChild(this.invisibleAriaDescription);
|
|
199
|
-
}
|
|
200
180
|
|
|
201
181
|
// This flag is used to avoid an update loop between the outer and
|
|
202
182
|
// inner editor
|
|
@@ -268,27 +248,6 @@ var CodeBlockAdvancedNodeView = /*#__PURE__*/function () {
|
|
|
268
248
|
key: "updateLanguage",
|
|
269
249
|
value: function updateLanguage() {
|
|
270
250
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
271
|
-
if (expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && fg('platform_editor_adf_with_localid')) {
|
|
272
|
-
this.updateAriaDescription();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}, {
|
|
276
|
-
key: "updateAriaDescription",
|
|
277
|
-
value: function updateAriaDescription() {
|
|
278
|
-
if (!this.invisibleAriaDescription) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
var _this$config$getIntl = this.config.getIntl(),
|
|
282
|
-
formatMessage = _this$config$getIntl.formatMessage;
|
|
283
|
-
var languageName = getLanguageName(this.node.attrs.language);
|
|
284
|
-
if (languageName) {
|
|
285
|
-
this.invisibleAriaDescription.textContent = "".concat(formatMessage(codeBlockMessages.codeblockLanguageAriaDescription, {
|
|
286
|
-
language: languageName
|
|
287
|
-
}), " ").concat(formatMessage(floatingToolbarMessages.floatingToolbarAnnouncer));
|
|
288
|
-
} else {
|
|
289
|
-
// If the lanuage is undefined provide a more human readable message
|
|
290
|
-
this.invisibleAriaDescription.textContent = "".concat(formatMessage(codeBlockMessages.codeBlockLanguageNotSet), " ").concat(formatMessage(floatingToolbarMessages.floatingToolbarAnnouncer));
|
|
291
|
-
}
|
|
292
251
|
}
|
|
293
252
|
}, {
|
|
294
253
|
key: "updateLocalIdAttribute",
|
|
@@ -32,7 +32,6 @@ declare class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
32
32
|
private languageLoader;
|
|
33
33
|
private pmFacet;
|
|
34
34
|
private unsubscribeContentFormat;
|
|
35
|
-
private invisibleAriaDescription?;
|
|
36
35
|
private config;
|
|
37
36
|
private cleanupBorderAreaClick;
|
|
38
37
|
private cleanupBorderAreaMouseDown;
|
|
@@ -42,7 +41,6 @@ declare class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
42
41
|
setSelection(anchor: number, head: number): void;
|
|
43
42
|
private updateReadonlyState;
|
|
44
43
|
private updateLanguage;
|
|
45
|
-
private updateAriaDescription;
|
|
46
44
|
private updateLocalIdAttribute;
|
|
47
45
|
private selectCodeBlockNode;
|
|
48
46
|
private wordWrappingEnabled;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block-advanced",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.8",
|
|
4
4
|
"description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
32
32
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
33
33
|
"@atlaskit/prosemirror-history": "^1.2.0",
|
|
34
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
35
|
-
"@atlaskit/tokens": "^16.
|
|
34
|
+
"@atlaskit/tmp-editor-statsig": "^168.0.0",
|
|
35
|
+
"@atlaskit/tokens": "^16.9.0",
|
|
36
36
|
"@babel/runtime": "^7.0.0",
|
|
37
37
|
"@codemirror/autocomplete": "6.18.4",
|
|
38
38
|
"@codemirror/commands": "6.7.1",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"codemirror-lang-mermaid": "0.4.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^120.
|
|
53
|
+
"@atlaskit/editor-common": "^120.7.0",
|
|
54
54
|
"react": "^18.2.0 || ^19.2.0",
|
|
55
55
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
56
56
|
},
|
|
@@ -7,17 +7,11 @@ import type { ViewUpdate } from '@codemirror/view';
|
|
|
7
7
|
import { bind } from 'bind-event-listener';
|
|
8
8
|
import type { IntlShape } from 'react-intl';
|
|
9
9
|
|
|
10
|
-
import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
11
10
|
import {
|
|
12
11
|
areCodeBlockLineNumbersHidden,
|
|
13
12
|
isCodeBlockWordWrapEnabled,
|
|
14
13
|
} from '@atlaskit/editor-common/code-block';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
blockTypeMessages,
|
|
18
|
-
codeBlockMessages,
|
|
19
|
-
roleDescriptionMessages,
|
|
20
|
-
} from '@atlaskit/editor-common/messages';
|
|
14
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
21
15
|
import type { RelativeSelectionPos } from '@atlaskit/editor-common/selection';
|
|
22
16
|
import type {
|
|
23
17
|
getPosHandler,
|
|
@@ -53,7 +47,6 @@ import { keymapExtension } from './extensions/keymap';
|
|
|
53
47
|
import { manageSelectionMarker } from './extensions/manageSelectionMarker';
|
|
54
48
|
import { prosemirrorDecorationPlugin } from './extensions/prosemirrorDecorations';
|
|
55
49
|
import { tripleClickSelectAllExtension } from './extensions/tripleClickExtension';
|
|
56
|
-
import getLanguageName from './languages/getLanguageName';
|
|
57
50
|
import { LanguageLoader } from './languages/loader';
|
|
58
51
|
|
|
59
52
|
export interface ConfigProps {
|
|
@@ -85,7 +78,6 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
85
78
|
private languageLoader: LanguageLoader;
|
|
86
79
|
private pmFacet = Facet.define<DecorationSource>();
|
|
87
80
|
private unsubscribeContentFormat: (() => void) | undefined;
|
|
88
|
-
private invisibleAriaDescription?: HTMLSpanElement;
|
|
89
81
|
private config: ConfigProps;
|
|
90
82
|
private cleanupBorderAreaClick: (() => void) | undefined;
|
|
91
83
|
private cleanupBorderAreaMouseDown: (() => void) | undefined;
|
|
@@ -122,8 +114,6 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
122
114
|
const { formatMessage } = config.getIntl();
|
|
123
115
|
const formattedAriaLabel = formatMessage(blockTypeMessages.codeblock);
|
|
124
116
|
|
|
125
|
-
const isMacOS = getBrowserInfo().mac;
|
|
126
|
-
|
|
127
117
|
this.cm = new CodeMirror({
|
|
128
118
|
doc: this.node.textContent,
|
|
129
119
|
extensions: [
|
|
@@ -173,22 +163,7 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
173
163
|
tripleClickSelectAllExtension(),
|
|
174
164
|
firstCodeBlockInDocument(getPos),
|
|
175
165
|
CodeMirror.contentAttributes.of({
|
|
176
|
-
|
|
177
|
-
'aria-label': `${formattedAriaLabel}`,
|
|
178
|
-
}),
|
|
179
|
-
...(isMacOS &&
|
|
180
|
-
expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && {
|
|
181
|
-
role: 'textbox',
|
|
182
|
-
'aria-roledescription': formatMessage(roleDescriptionMessages.codeSnippetTextBox),
|
|
183
|
-
'aria-describedby': `codesnippet-${this.node.attrs.localId}`,
|
|
184
|
-
'aria-multiline': 'true',
|
|
185
|
-
'aria-label': formattedAriaLabel,
|
|
186
|
-
}),
|
|
187
|
-
...(!isMacOS &&
|
|
188
|
-
expValEquals('editor_a11y_role_textbox', 'isEnabled', true) && {
|
|
189
|
-
'aria-label': formattedAriaLabel,
|
|
190
|
-
'aria-describedby': `codesnippet-${this.node.attrs.localId}`,
|
|
191
|
-
}),
|
|
166
|
+
'aria-label': `${formattedAriaLabel}`,
|
|
192
167
|
}),
|
|
193
168
|
config.allowCodeFolding
|
|
194
169
|
? [
|
|
@@ -242,18 +217,6 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
242
217
|
this.dom = this.cm.dom;
|
|
243
218
|
this.dom.appendChild(spaceContainer);
|
|
244
219
|
|
|
245
|
-
if (
|
|
246
|
-
expValEquals('editor_a11y_role_textbox', 'isEnabled', true) &&
|
|
247
|
-
fg('platform_editor_adf_with_localid')
|
|
248
|
-
) {
|
|
249
|
-
this.invisibleAriaDescription = document.createElement('span');
|
|
250
|
-
this.invisibleAriaDescription.hidden = true;
|
|
251
|
-
this.invisibleAriaDescription.id = `codesnippet-${this.node.attrs.localId}`;
|
|
252
|
-
this.updateAriaDescription();
|
|
253
|
-
|
|
254
|
-
this.dom.appendChild(this.invisibleAriaDescription);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
220
|
// This flag is used to avoid an update loop between the outer and
|
|
258
221
|
// inner editor
|
|
259
222
|
this.updating = false;
|
|
@@ -314,34 +277,6 @@ class CodeBlockAdvancedNodeView implements NodeView {
|
|
|
314
277
|
|
|
315
278
|
private updateLanguage() {
|
|
316
279
|
this.languageLoader.updateLanguage(this.node.attrs.language);
|
|
317
|
-
if (
|
|
318
|
-
expValEquals('editor_a11y_role_textbox', 'isEnabled', true) &&
|
|
319
|
-
fg('platform_editor_adf_with_localid')
|
|
320
|
-
) {
|
|
321
|
-
this.updateAriaDescription();
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
private updateAriaDescription() {
|
|
326
|
-
if (!this.invisibleAriaDescription) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const { formatMessage } = this.config.getIntl();
|
|
331
|
-
const languageName = getLanguageName(this.node.attrs.language);
|
|
332
|
-
if (languageName) {
|
|
333
|
-
this.invisibleAriaDescription.textContent = `${formatMessage(
|
|
334
|
-
codeBlockMessages.codeblockLanguageAriaDescription,
|
|
335
|
-
{
|
|
336
|
-
language: languageName,
|
|
337
|
-
},
|
|
338
|
-
)} ${formatMessage(floatingToolbarMessages.floatingToolbarAnnouncer)}`;
|
|
339
|
-
} else {
|
|
340
|
-
// If the lanuage is undefined provide a more human readable message
|
|
341
|
-
this.invisibleAriaDescription.textContent = `${formatMessage(
|
|
342
|
-
codeBlockMessages.codeBlockLanguageNotSet,
|
|
343
|
-
)} ${formatMessage(floatingToolbarMessages.floatingToolbarAnnouncer)}`;
|
|
344
|
-
}
|
|
345
280
|
}
|
|
346
281
|
|
|
347
282
|
private updateLocalIdAttribute() {
|