@atlaskit/editor-plugin-code-block 3.3.7 → 3.3.9

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,21 @@
1
1
  # @atlaskit/editor-plugin-code-block
2
2
 
3
+ ## 3.3.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#134918](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134918)
8
+ [`89e5820ef3ed5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/89e5820ef3ed5) -
9
+ [ux] ED-24678 adding a11y support for code block
10
+
11
+ ## 3.3.8
12
+
13
+ ### Patch Changes
14
+
15
+ - [#134213](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134213)
16
+ [`93bd7032842ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/93bd7032842ec) -
17
+ [ux] [ED-24636] Bump ADF Schema package
18
+
3
19
  ## 3.3.7
4
20
 
5
21
  ### Patch Changes
@@ -17,7 +17,7 @@ var _actions = require("../actions");
17
17
  var _mainState = require("../pm-plugins/main-state");
18
18
  var _classNames = require("../ui/class-names");
19
19
  var MATCH_NEWLINES = new RegExp('\n', 'g');
20
- var toDOM = function toDOM(node, contentEditable) {
20
+ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
21
21
  return ['div', {
22
22
  class: 'code-block'
23
23
  }, ['div', {
@@ -34,17 +34,19 @@ var toDOM = function toDOM(node, contentEditable) {
34
34
  'data-language': node.attrs.language || '',
35
35
  spellcheck: 'false',
36
36
  contenteditable: (0, _platformFeatureFlags.fg)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
37
- 'data-testid': 'code-block--code'
37
+ 'data-testid': 'code-block--code',
38
+ 'aria-label': formattedAriaLabel
38
39
  }, 0]]], ['div', {
39
40
  class: _classNames.codeBlockClassNames.end,
40
41
  contenteditable: 'false'
41
42
  }]];
42
43
  };
43
44
  var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
44
- function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
45
+ function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
45
46
  var _this = this,
46
47
  _api$editorDisabled;
47
48
  (0, _classCallCheck2.default)(this, CodeBlockView);
49
+ (0, _defineProperty2.default)(this, "formattedAriaLabel", '');
48
50
  (0, _defineProperty2.default)(this, "ensureLineNumbers", (0, _rafSchd.default)(function () {
49
51
  var lines = 1;
50
52
  _this.node.forEach(function (node) {
@@ -75,7 +77,7 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
75
77
  _this.dom.style.setProperty('--lineNumberGutterWidth', "".concat(maxDigits, "ch"));
76
78
  });
77
79
  this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
78
- var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled))),
80
+ var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled), formattedAriaLabel)),
79
81
  dom = _DOMSerializer$render.dom,
80
82
  contentDOM = _DOMSerializer$render.contentDOM;
81
83
  this.getPos = getPos;
@@ -199,6 +201,6 @@ var CodeBlockView = exports.CodeBlockView = /*#__PURE__*/function () {
199
201
  }]);
200
202
  return CodeBlockView;
201
203
  }();
202
- var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
203
- return new CodeBlockView(node, view, getPos, api);
204
+ var codeBlockNodeView = exports.codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
205
+ return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
204
206
  };
@@ -8,6 +8,7 @@ exports.createPlugin = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _codeBlock = require("@atlaskit/editor-common/code-block");
11
+ var _messages = require("@atlaskit/editor-common/messages");
11
12
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
13
  var _selection = require("@atlaskit/editor-common/selection");
13
14
  var _utils = require("@atlaskit/editor-common/utils");
@@ -189,7 +190,10 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
189
190
  },
190
191
  nodeViews: {
191
192
  codeBlock: function codeBlock(node, view, getPos) {
192
- return (0, _codeBlock2.codeBlockNodeView)(node, view, getPos, api);
193
+ var _getIntl = getIntl(),
194
+ formatMessage = _getIntl.formatMessage;
195
+ var formattedAriaLabel = formatMessage(_messages.blockTypeMessages.codeblock);
196
+ return (0, _codeBlock2.codeBlockNodeView)(node, view, getPos, formattedAriaLabel, api);
193
197
  }
194
198
  },
195
199
  handleClickOn: (0, _selection.createSelectionClickHandler)(['codeBlock'], function (target) {
@@ -8,7 +8,7 @@ import { resetShouldIgnoreFollowingMutations } from '../actions';
8
8
  import { getPluginState } from '../pm-plugins/main-state';
9
9
  import { codeBlockClassNames } from '../ui/class-names';
10
10
  const MATCH_NEWLINES = new RegExp('\n', 'g');
11
- const toDOM = (node, contentEditable) => ['div', {
11
+ const toDOM = (node, contentEditable, formattedAriaLabel) => ['div', {
12
12
  class: 'code-block'
13
13
  }, ['div', {
14
14
  class: codeBlockClassNames.start,
@@ -24,14 +24,16 @@ const toDOM = (node, contentEditable) => ['div', {
24
24
  'data-language': node.attrs.language || '',
25
25
  spellcheck: 'false',
26
26
  contenteditable: fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
27
- 'data-testid': 'code-block--code'
27
+ 'data-testid': 'code-block--code',
28
+ 'aria-label': formattedAriaLabel
28
29
  }, 0]]], ['div', {
29
30
  class: codeBlockClassNames.end,
30
31
  contenteditable: 'false'
31
32
  }]];
32
33
  export class CodeBlockView {
33
- constructor(_node, view, getPos, api, cleanupEditorDisabledListener) {
34
+ constructor(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
34
35
  var _api$editorDisabled, _api$editorDisabled$s;
36
+ _defineProperty(this, "formattedAriaLabel", '');
35
37
  _defineProperty(this, "ensureLineNumbers", rafSchedule(() => {
36
38
  let lines = 1;
37
39
  this.node.forEach(node => {
@@ -65,7 +67,7 @@ export class CodeBlockView {
65
67
  const {
66
68
  dom,
67
69
  contentDOM
68
- } = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled$s !== void 0 && _api$editorDisabled$s.editorDisabled)));
70
+ } = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled$s !== void 0 && _api$editorDisabled$s.editorDisabled), formattedAriaLabel));
69
71
  this.getPos = getPos;
70
72
  this.view = view;
71
73
  this.node = _node;
@@ -170,4 +172,4 @@ export class CodeBlockView {
170
172
  this.cleanupEditorDisabledListener = undefined;
171
173
  }
172
174
  }
173
- export const codeBlockNodeView = (node, view, getPos, api) => new CodeBlockView(node, view, getPos, api);
175
+ export const codeBlockNodeView = (node, view, getPos, formattedAriaLabel, api) => new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
@@ -1,4 +1,5 @@
1
1
  import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
2
+ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
2
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
4
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
4
5
  import { browser } from '@atlaskit/editor-common/utils';
@@ -177,7 +178,13 @@ export const createPlugin = ({
177
178
  return undefined;
178
179
  },
179
180
  nodeViews: {
180
- codeBlock: (node, view, getPos) => codeBlockNodeView(node, view, getPos, api)
181
+ codeBlock: (node, view, getPos) => {
182
+ const {
183
+ formatMessage
184
+ } = getIntl();
185
+ const formattedAriaLabel = formatMessage(blockTypeMessages.codeblock);
186
+ return codeBlockNodeView(node, view, getPos, formattedAriaLabel, api);
187
+ }
181
188
  },
182
189
  handleClickOn: createSelectionClickHandler(['codeBlock'], target => fg('editor_support_code_block_wrapping') ? !!(target.classList.contains(codeBlockClassNames.lineNumberWidget) || target.classList.contains(codeBlockClassNames.gutterFg)) : !!(target.closest(`.${codeBlockClassNames.gutter}`) || target.classList.contains(codeBlockClassNames.content)), {
183
190
  useLongPressSelection
@@ -10,7 +10,7 @@ import { resetShouldIgnoreFollowingMutations } from '../actions';
10
10
  import { getPluginState } from '../pm-plugins/main-state';
11
11
  import { codeBlockClassNames } from '../ui/class-names';
12
12
  var MATCH_NEWLINES = new RegExp('\n', 'g');
13
- var toDOM = function toDOM(node, contentEditable) {
13
+ var toDOM = function toDOM(node, contentEditable, formattedAriaLabel) {
14
14
  return ['div', {
15
15
  class: 'code-block'
16
16
  }, ['div', {
@@ -27,17 +27,19 @@ var toDOM = function toDOM(node, contentEditable) {
27
27
  'data-language': node.attrs.language || '',
28
28
  spellcheck: 'false',
29
29
  contenteditable: fg('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') ? contentEditable ? 'true' : 'false' : 'true',
30
- 'data-testid': 'code-block--code'
30
+ 'data-testid': 'code-block--code',
31
+ 'aria-label': formattedAriaLabel
31
32
  }, 0]]], ['div', {
32
33
  class: codeBlockClassNames.end,
33
34
  contenteditable: 'false'
34
35
  }]];
35
36
  };
36
37
  export var CodeBlockView = /*#__PURE__*/function () {
37
- function CodeBlockView(_node, view, getPos, api, cleanupEditorDisabledListener) {
38
+ function CodeBlockView(_node, view, getPos, formattedAriaLabel, api, cleanupEditorDisabledListener) {
38
39
  var _this = this,
39
40
  _api$editorDisabled;
40
41
  _classCallCheck(this, CodeBlockView);
42
+ _defineProperty(this, "formattedAriaLabel", '');
41
43
  _defineProperty(this, "ensureLineNumbers", rafSchedule(function () {
42
44
  var lines = 1;
43
45
  _this.node.forEach(function (node) {
@@ -68,7 +70,7 @@ export var CodeBlockView = /*#__PURE__*/function () {
68
70
  _this.dom.style.setProperty('--lineNumberGutterWidth', "".concat(maxDigits, "ch"));
69
71
  });
70
72
  this.cleanupEditorDisabledListener = cleanupEditorDisabledListener;
71
- var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled))),
73
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node, !(api !== null && api !== void 0 && (_api$editorDisabled = api.editorDisabled) !== null && _api$editorDisabled !== void 0 && (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) !== null && _api$editorDisabled !== void 0 && _api$editorDisabled.editorDisabled), formattedAriaLabel)),
72
74
  dom = _DOMSerializer$render.dom,
73
75
  contentDOM = _DOMSerializer$render.contentDOM;
74
76
  this.getPos = getPos;
@@ -192,6 +194,6 @@ export var CodeBlockView = /*#__PURE__*/function () {
192
194
  }]);
193
195
  return CodeBlockView;
194
196
  }();
195
- export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, api) {
196
- return new CodeBlockView(node, view, getPos, api);
197
+ export var codeBlockNodeView = function codeBlockNodeView(node, view, getPos, formattedAriaLabel, api) {
198
+ return new CodeBlockView(node, view, getPos, formattedAriaLabel, api);
197
199
  };
@@ -3,6 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  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; }
4
4
  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
5
  import { isCodeBlockWordWrapEnabled } from '@atlaskit/editor-common/code-block';
6
+ import { blockTypeMessages } from '@atlaskit/editor-common/messages';
6
7
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
8
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
8
9
  import { browser } from '@atlaskit/editor-common/utils';
@@ -182,7 +183,10 @@ export var createPlugin = function createPlugin(_ref) {
182
183
  },
183
184
  nodeViews: {
184
185
  codeBlock: function codeBlock(node, view, getPos) {
185
- return codeBlockNodeView(node, view, getPos, api);
186
+ var _getIntl = getIntl(),
187
+ formatMessage = _getIntl.formatMessage;
188
+ var formattedAriaLabel = formatMessage(blockTypeMessages.codeblock);
189
+ return codeBlockNodeView(node, view, getPos, formattedAriaLabel, api);
186
190
  }
187
191
  },
188
192
  handleClickOn: createSelectionClickHandler(['codeBlock'], function (target) {
@@ -10,8 +10,9 @@ export declare class CodeBlockView {
10
10
  lineNumberGutter: HTMLElement;
11
11
  getPos: getPosHandlerNode;
12
12
  view: EditorView;
13
+ formattedAriaLabel: string;
13
14
  api?: ExtractInjectionAPI<CodeBlockPlugin>;
14
- constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, api?: ExtractInjectionAPI<CodeBlockPlugin>, cleanupEditorDisabledListener?: (() => void) | undefined);
15
+ constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, formattedAriaLabel: string, api?: ExtractInjectionAPI<CodeBlockPlugin>, cleanupEditorDisabledListener?: (() => void) | undefined);
15
16
  handleEditorDisabledChanged(): void;
16
17
  updateDOMAndSelection(savedInnerHTML: string, newCursorPosition: number): void;
17
18
  coalesceDOMElements(): void;
@@ -27,4 +28,4 @@ export declare class CodeBlockView {
27
28
  }): boolean;
28
29
  destroy(): void;
29
30
  }
30
- export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
31
+ export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, formattedAriaLabel: string, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
@@ -10,8 +10,9 @@ export declare class CodeBlockView {
10
10
  lineNumberGutter: HTMLElement;
11
11
  getPos: getPosHandlerNode;
12
12
  view: EditorView;
13
+ formattedAriaLabel: string;
13
14
  api?: ExtractInjectionAPI<CodeBlockPlugin>;
14
- constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, api?: ExtractInjectionAPI<CodeBlockPlugin>, cleanupEditorDisabledListener?: (() => void) | undefined);
15
+ constructor(node: Node, view: EditorView, getPos: getPosHandlerNode, formattedAriaLabel: string, api?: ExtractInjectionAPI<CodeBlockPlugin>, cleanupEditorDisabledListener?: (() => void) | undefined);
15
16
  handleEditorDisabledChanged(): void;
16
17
  updateDOMAndSelection(savedInnerHTML: string, newCursorPosition: number): void;
17
18
  coalesceDOMElements(): void;
@@ -27,4 +28,4 @@ export declare class CodeBlockView {
27
28
  }): boolean;
28
29
  destroy(): void;
29
30
  }
30
- export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
31
+ export declare const codeBlockNodeView: (node: Node, view: EditorView, getPos: getPosHandler, formattedAriaLabel: string, api: ExtractInjectionAPI<CodeBlockPlugin> | undefined) => CodeBlockView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "3.3.7",
3
+ "version": "3.3.9",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,15 +33,15 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/adf-schema": "^40.8.1",
37
- "@atlaskit/code": "^15.5.0",
38
- "@atlaskit/editor-common": "^88.1.0",
36
+ "@atlaskit/adf-schema": "^40.9.0",
37
+ "@atlaskit/code": "^15.6.0",
38
+ "@atlaskit/editor-common": "^88.4.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^1.8.0",
40
40
  "@atlaskit/editor-plugin-composition": "^1.2.0",
41
41
  "@atlaskit/editor-plugin-decorations": "^1.3.0",
42
42
  "@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
43
43
  "@atlaskit/editor-prosemirror": "5.0.1",
44
- "@atlaskit/icon": "^22.14.0",
44
+ "@atlaskit/icon": "^22.15.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/prosemirror-input-rules": "^3.2.0",
47
47
  "@babel/runtime": "^7.0.0",