@atlaskit/editor-common 74.29.2 → 74.30.0

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.
Files changed (167) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/i18n/cs.js +19 -0
  3. package/dist/cjs/i18n/da.js +19 -0
  4. package/dist/cjs/i18n/de.js +19 -0
  5. package/dist/cjs/i18n/es.js +19 -0
  6. package/dist/cjs/i18n/fi.js +19 -0
  7. package/dist/cjs/i18n/fr.js +19 -0
  8. package/dist/cjs/i18n/hu.js +19 -0
  9. package/dist/cjs/i18n/it.js +19 -0
  10. package/dist/cjs/i18n/ja.js +19 -0
  11. package/dist/cjs/i18n/ko.js +19 -0
  12. package/dist/cjs/i18n/nb.js +19 -0
  13. package/dist/cjs/i18n/nl.js +19 -0
  14. package/dist/cjs/i18n/pl.js +19 -0
  15. package/dist/cjs/i18n/pt_BR.js +19 -0
  16. package/dist/cjs/i18n/ru.js +19 -0
  17. package/dist/cjs/i18n/sv.js +19 -0
  18. package/dist/cjs/i18n/th.js +19 -0
  19. package/dist/cjs/i18n/tr.js +19 -0
  20. package/dist/cjs/i18n/uk.js +19 -0
  21. package/dist/cjs/i18n/vi.js +19 -0
  22. package/dist/cjs/i18n/zh.js +19 -0
  23. package/dist/cjs/i18n/zh_TW.js +19 -0
  24. package/dist/cjs/mark/commands.js +201 -0
  25. package/dist/cjs/mark/index.js +30 -0
  26. package/dist/cjs/messages/full-page.js +25 -0
  27. package/dist/cjs/messages/index.js +7 -0
  28. package/dist/cjs/monitoring/error.js +1 -1
  29. package/dist/cjs/ui/DropList/index.js +1 -1
  30. package/dist/cjs/ui/Toolbar/index.js +8 -0
  31. package/dist/cjs/ui/index.js +7 -0
  32. package/dist/cjs/ui-menu/DropdownMenu/index.js +16 -2
  33. package/dist/cjs/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +219 -0
  34. package/dist/cjs/ui-menu/index.js +23 -4
  35. package/dist/cjs/version.json +1 -1
  36. package/dist/es2019/i18n/cs.js +19 -0
  37. package/dist/es2019/i18n/da.js +19 -0
  38. package/dist/es2019/i18n/de.js +19 -0
  39. package/dist/es2019/i18n/es.js +19 -0
  40. package/dist/es2019/i18n/fi.js +19 -0
  41. package/dist/es2019/i18n/fr.js +19 -0
  42. package/dist/es2019/i18n/hu.js +19 -0
  43. package/dist/es2019/i18n/it.js +19 -0
  44. package/dist/es2019/i18n/ja.js +19 -0
  45. package/dist/es2019/i18n/ko.js +19 -0
  46. package/dist/es2019/i18n/nb.js +19 -0
  47. package/dist/es2019/i18n/nl.js +19 -0
  48. package/dist/es2019/i18n/pl.js +19 -0
  49. package/dist/es2019/i18n/pt_BR.js +19 -0
  50. package/dist/es2019/i18n/ru.js +19 -0
  51. package/dist/es2019/i18n/sv.js +19 -0
  52. package/dist/es2019/i18n/th.js +19 -0
  53. package/dist/es2019/i18n/tr.js +19 -0
  54. package/dist/es2019/i18n/uk.js +19 -0
  55. package/dist/es2019/i18n/vi.js +19 -0
  56. package/dist/es2019/i18n/zh.js +19 -0
  57. package/dist/es2019/i18n/zh_TW.js +19 -0
  58. package/dist/es2019/mark/commands.js +205 -0
  59. package/dist/es2019/mark/index.js +1 -0
  60. package/dist/es2019/messages/full-page.js +18 -0
  61. package/dist/es2019/messages/index.js +1 -0
  62. package/dist/es2019/monitoring/error.js +1 -1
  63. package/dist/es2019/ui/DropList/index.js +1 -1
  64. package/dist/es2019/ui/Toolbar/index.js +1 -0
  65. package/dist/es2019/ui/index.js +2 -1
  66. package/dist/es2019/ui-menu/DropdownMenu/index.js +16 -2
  67. package/dist/es2019/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +209 -0
  68. package/dist/es2019/ui-menu/index.js +5 -4
  69. package/dist/es2019/version.json +1 -1
  70. package/dist/esm/i18n/cs.js +19 -0
  71. package/dist/esm/i18n/da.js +19 -0
  72. package/dist/esm/i18n/de.js +19 -0
  73. package/dist/esm/i18n/es.js +19 -0
  74. package/dist/esm/i18n/fi.js +19 -0
  75. package/dist/esm/i18n/fr.js +19 -0
  76. package/dist/esm/i18n/hu.js +19 -0
  77. package/dist/esm/i18n/it.js +19 -0
  78. package/dist/esm/i18n/ja.js +19 -0
  79. package/dist/esm/i18n/ko.js +19 -0
  80. package/dist/esm/i18n/nb.js +19 -0
  81. package/dist/esm/i18n/nl.js +19 -0
  82. package/dist/esm/i18n/pl.js +19 -0
  83. package/dist/esm/i18n/pt_BR.js +19 -0
  84. package/dist/esm/i18n/ru.js +19 -0
  85. package/dist/esm/i18n/sv.js +19 -0
  86. package/dist/esm/i18n/th.js +19 -0
  87. package/dist/esm/i18n/tr.js +19 -0
  88. package/dist/esm/i18n/uk.js +19 -0
  89. package/dist/esm/i18n/vi.js +19 -0
  90. package/dist/esm/i18n/zh.js +19 -0
  91. package/dist/esm/i18n/zh_TW.js +19 -0
  92. package/dist/esm/mark/commands.js +190 -0
  93. package/dist/esm/mark/index.js +1 -0
  94. package/dist/esm/messages/full-page.js +18 -0
  95. package/dist/esm/messages/index.js +1 -0
  96. package/dist/esm/monitoring/error.js +1 -1
  97. package/dist/esm/ui/DropList/index.js +1 -1
  98. package/dist/esm/ui/Toolbar/index.js +1 -0
  99. package/dist/esm/ui/index.js +2 -1
  100. package/dist/esm/ui-menu/DropdownMenu/index.js +15 -2
  101. package/dist/esm/ui-menu/ToolbarArrowKeyNavigationProvider/index.js +207 -0
  102. package/dist/esm/ui-menu/index.js +5 -4
  103. package/dist/esm/version.json +1 -1
  104. package/dist/types/i18n/cs.d.ts +19 -0
  105. package/dist/types/i18n/da.d.ts +19 -0
  106. package/dist/types/i18n/de.d.ts +19 -0
  107. package/dist/types/i18n/es.d.ts +19 -0
  108. package/dist/types/i18n/fi.d.ts +19 -0
  109. package/dist/types/i18n/fr.d.ts +19 -0
  110. package/dist/types/i18n/hu.d.ts +19 -0
  111. package/dist/types/i18n/it.d.ts +19 -0
  112. package/dist/types/i18n/ja.d.ts +19 -0
  113. package/dist/types/i18n/ko.d.ts +19 -0
  114. package/dist/types/i18n/nb.d.ts +19 -0
  115. package/dist/types/i18n/nl.d.ts +19 -0
  116. package/dist/types/i18n/pl.d.ts +19 -0
  117. package/dist/types/i18n/pt_BR.d.ts +19 -0
  118. package/dist/types/i18n/ru.d.ts +19 -0
  119. package/dist/types/i18n/sv.d.ts +19 -0
  120. package/dist/types/i18n/th.d.ts +19 -0
  121. package/dist/types/i18n/tr.d.ts +19 -0
  122. package/dist/types/i18n/uk.d.ts +19 -0
  123. package/dist/types/i18n/vi.d.ts +19 -0
  124. package/dist/types/i18n/zh.d.ts +19 -0
  125. package/dist/types/i18n/zh_TW.d.ts +19 -0
  126. package/dist/types/mark/commands.d.ts +18 -0
  127. package/dist/types/mark/index.d.ts +1 -0
  128. package/dist/types/messages/full-page.d.ts +17 -0
  129. package/dist/types/messages/index.d.ts +1 -0
  130. package/dist/types/ui/Toolbar/index.d.ts +5 -0
  131. package/dist/types/ui/index.d.ts +2 -0
  132. package/dist/types/ui-menu/DropdownMenu/index.d.ts +2 -1
  133. package/dist/types/ui-menu/ToolbarArrowKeyNavigationProvider/index.d.ts +30 -0
  134. package/dist/types/ui-menu/index.d.ts +7 -6
  135. package/dist/types-ts4.5/i18n/cs.d.ts +19 -0
  136. package/dist/types-ts4.5/i18n/da.d.ts +19 -0
  137. package/dist/types-ts4.5/i18n/de.d.ts +19 -0
  138. package/dist/types-ts4.5/i18n/es.d.ts +19 -0
  139. package/dist/types-ts4.5/i18n/fi.d.ts +19 -0
  140. package/dist/types-ts4.5/i18n/fr.d.ts +19 -0
  141. package/dist/types-ts4.5/i18n/hu.d.ts +19 -0
  142. package/dist/types-ts4.5/i18n/it.d.ts +19 -0
  143. package/dist/types-ts4.5/i18n/ja.d.ts +19 -0
  144. package/dist/types-ts4.5/i18n/ko.d.ts +19 -0
  145. package/dist/types-ts4.5/i18n/nb.d.ts +19 -0
  146. package/dist/types-ts4.5/i18n/nl.d.ts +19 -0
  147. package/dist/types-ts4.5/i18n/pl.d.ts +19 -0
  148. package/dist/types-ts4.5/i18n/pt_BR.d.ts +19 -0
  149. package/dist/types-ts4.5/i18n/ru.d.ts +19 -0
  150. package/dist/types-ts4.5/i18n/sv.d.ts +19 -0
  151. package/dist/types-ts4.5/i18n/th.d.ts +19 -0
  152. package/dist/types-ts4.5/i18n/tr.d.ts +19 -0
  153. package/dist/types-ts4.5/i18n/uk.d.ts +19 -0
  154. package/dist/types-ts4.5/i18n/vi.d.ts +19 -0
  155. package/dist/types-ts4.5/i18n/zh.d.ts +19 -0
  156. package/dist/types-ts4.5/i18n/zh_TW.d.ts +19 -0
  157. package/dist/types-ts4.5/mark/commands.d.ts +18 -0
  158. package/dist/types-ts4.5/mark/index.d.ts +1 -0
  159. package/dist/types-ts4.5/messages/full-page.d.ts +17 -0
  160. package/dist/types-ts4.5/messages/index.d.ts +1 -0
  161. package/dist/types-ts4.5/ui/Toolbar/index.d.ts +5 -0
  162. package/dist/types-ts4.5/ui/index.d.ts +2 -0
  163. package/dist/types-ts4.5/ui-menu/DropdownMenu/index.d.ts +2 -1
  164. package/dist/types-ts4.5/ui-menu/ToolbarArrowKeyNavigationProvider/index.d.ts +30 -0
  165. package/dist/types-ts4.5/ui-menu/index.d.ts +7 -6
  166. package/mark/package.json +15 -0
  167. package/package.json +6 -4
@@ -0,0 +1,190 @@
1
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ // eslint-disable-next-line no-duplicate-imports
3
+
4
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
5
+ var SMART_TO_ASCII = {
6
+ '…': '...',
7
+ '→': '->',
8
+ '←': '<-',
9
+ '–': '--',
10
+ '“': '"',
11
+ '”': '"',
12
+ '‘': "'",
13
+ '’': "'"
14
+ };
15
+ var FIND_SMART_CHAR = new RegExp("[".concat(Object.keys(SMART_TO_ASCII).join(''), "]"), 'g');
16
+ var isNodeTextBlock = function isNodeTextBlock(schema) {
17
+ var _schema$nodes = schema.nodes,
18
+ mention = _schema$nodes.mention,
19
+ text = _schema$nodes.text,
20
+ emoji = _schema$nodes.emoji;
21
+ return function (node, _, parent) {
22
+ if (node.type === mention || node.type === emoji || node.type === text) {
23
+ return parent === null || parent === void 0 ? void 0 : parent.isTextblock;
24
+ }
25
+ return;
26
+ };
27
+ };
28
+ var replaceSmartCharsToAscii = function replaceSmartCharsToAscii(position, textContent, tr) {
29
+ var schema = tr.doc.type.schema;
30
+ var match;
31
+ while (match = FIND_SMART_CHAR.exec(textContent)) {
32
+ var _match = match,
33
+ smartChar = _match[0],
34
+ offset = _match.index;
35
+ var replacePos = tr.mapping.map(position + offset);
36
+ var replacementText = schema.text(SMART_TO_ASCII[smartChar]);
37
+ tr.replaceWith(replacePos, replacePos + smartChar.length, replacementText);
38
+ }
39
+ };
40
+ var replaceMentionOrEmojiForTextContent = function replaceMentionOrEmojiForTextContent(position, nodeSize, textContent, tr) {
41
+ var currentPos = tr.mapping.map(position);
42
+ var schema = tr.doc.type.schema;
43
+ tr.replaceWith(currentPos, currentPos + nodeSize, schema.text(textContent));
44
+ };
45
+ export function filterChildrenBetween(doc, from, to, predicate) {
46
+ var results = [];
47
+ doc.nodesBetween(from, to, function (node, pos, parent) {
48
+ if (predicate(node, pos, parent)) {
49
+ results.push({
50
+ node: node,
51
+ pos: pos
52
+ });
53
+ }
54
+ });
55
+ return results;
56
+ }
57
+ export var transformSmartCharsMentionsAndEmojis = function transformSmartCharsMentionsAndEmojis(from, to, tr) {
58
+ var schema = tr.doc.type.schema;
59
+ var _schema$nodes2 = schema.nodes,
60
+ mention = _schema$nodes2.mention,
61
+ text = _schema$nodes2.text,
62
+ emoji = _schema$nodes2.emoji;
63
+ // Traverse through all the nodes within the range and replace them with their plaintext counterpart
64
+ var children = filterChildrenBetween(tr.doc, from, to, isNodeTextBlock(schema));
65
+ children.forEach(function (_ref) {
66
+ var node = _ref.node,
67
+ pos = _ref.pos;
68
+ if (node.type === mention || node.type === emoji) {
69
+ // Convert gracefully when no text found, ProseMirror will blow up if you try to create a node with an empty string or undefined
70
+ var replacementText = node.attrs.text;
71
+ if (typeof replacementText === 'undefined' || replacementText === '') {
72
+ replacementText = "".concat(node.type.name, " text missing");
73
+ }
74
+ replaceMentionOrEmojiForTextContent(pos, node.nodeSize, replacementText, tr);
75
+ } else if (node.type === text && node.text) {
76
+ var replacePosition = pos > from ? pos : from;
77
+ var textToReplace = pos > from ? node.text : node.text.substr(from - pos);
78
+ replaceSmartCharsToAscii(replacePosition, textToReplace, tr);
79
+ }
80
+ });
81
+ };
82
+ export var applyMarkOnRange = function applyMarkOnRange(from, to, removeMark, mark, tr) {
83
+ var schema = tr.doc.type.schema;
84
+ var code = schema.marks.code;
85
+ if (mark.type === code) {
86
+ transformSmartCharsMentionsAndEmojis(from, to, tr);
87
+ }
88
+ tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
89
+ if (!node.isText) {
90
+ return true;
91
+ }
92
+
93
+ // This is an issue when the user selects some text.
94
+ // We need to check if the current node position is less than the range selection from.
95
+ // If it’s true, that means we should apply the mark using the range selection,
96
+ // not the current node position.
97
+ var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
98
+ var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
99
+ if (removeMark) {
100
+ tr.removeMark(nodeBetweenFrom, nodeBetweenTo, mark);
101
+ } else {
102
+ tr.addMark(nodeBetweenFrom, nodeBetweenTo, mark);
103
+ }
104
+ return true;
105
+ });
106
+ return tr;
107
+ };
108
+ var entireSelectionContainsMark = function entireSelectionContainsMark(mark, doc, fromPos, toPos) {
109
+ var onlyContainsMark = true;
110
+ doc.nodesBetween(fromPos, toPos, function (node) {
111
+ // Skip recursion once we've found text which doesn't include the mark
112
+ if (!onlyContainsMark) {
113
+ return false;
114
+ }
115
+ if (node.isText) {
116
+ onlyContainsMark && (onlyContainsMark = mark.isInSet(node.marks));
117
+ }
118
+ });
119
+ return onlyContainsMark;
120
+ };
121
+ var toggleMarkInRange = function toggleMarkInRange(mark) {
122
+ return function (state, dispatch) {
123
+ var tr = state.tr;
124
+ if (state.selection instanceof CellSelection) {
125
+ var removeMark = true;
126
+ var cells = [];
127
+ state.selection.forEachCell(function (cell, cellPos) {
128
+ cells.push({
129
+ node: cell,
130
+ pos: cellPos
131
+ });
132
+ var from = cellPos;
133
+ var to = cellPos + cell.nodeSize;
134
+ removeMark && (removeMark = entireSelectionContainsMark(mark, state.doc, from, to));
135
+ });
136
+ for (var i = cells.length - 1; i >= 0; i--) {
137
+ var cell = cells[i];
138
+ var from = cell.pos;
139
+ var to = from + cell.node.nodeSize;
140
+ applyMarkOnRange(from, to, removeMark, mark, tr);
141
+ }
142
+ } else {
143
+ var _state$selection = state.selection,
144
+ $from = _state$selection.$from,
145
+ $to = _state$selection.$to;
146
+ // We decide to remove the mark only if the entire selection contains the mark
147
+ // Examples with *bold* text
148
+ // Scenario 1: Selection contains both bold and non-bold text -> bold entire selection
149
+ // Scenario 2: Selection contains only bold text -> un-bold entire selection
150
+ // Scenario 3: Selection contains no bold text -> bold entire selection
151
+ var _removeMark = entireSelectionContainsMark(mark, state.doc, $from.pos, $to.pos);
152
+ applyMarkOnRange($from.pos, $to.pos, _removeMark, mark, tr);
153
+ }
154
+ if (tr.docChanged) {
155
+ if (dispatch) {
156
+ dispatch(tr);
157
+ }
158
+ return true;
159
+ }
160
+ return false;
161
+ };
162
+ };
163
+
164
+ /**
165
+ * A wrapper over the default toggleMark, except when we have a selection
166
+ * we only toggle marks on text nodes rather than inline nodes.
167
+ * @param markType
168
+ * @param attrs
169
+ */
170
+ export var toggleMark = function toggleMark(markType, attrs) {
171
+ return function (state, dispatch) {
172
+ var mark = markType.create(attrs);
173
+
174
+ // For cursor selections we can use the default behaviour.
175
+ if (state.selection instanceof TextSelection && state.selection.$cursor) {
176
+ var tr = state.tr;
177
+ if (mark.isInSet(state.storedMarks || state.selection.$cursor.marks())) {
178
+ tr.removeStoredMark(mark);
179
+ } else {
180
+ tr.addStoredMark(mark);
181
+ }
182
+ if (dispatch) {
183
+ dispatch(tr);
184
+ return true;
185
+ }
186
+ return false;
187
+ }
188
+ return toggleMarkInRange(mark)(state, dispatch);
189
+ };
190
+ };
@@ -0,0 +1 @@
1
+ export { transformSmartCharsMentionsAndEmojis, applyMarkOnRange, toggleMark, filterChildrenBetween } from './commands';
@@ -0,0 +1,18 @@
1
+ import { defineMessages } from 'react-intl-next';
2
+ export var messages = defineMessages({
3
+ toolbarLabel: {
4
+ id: 'fabric.editor.toolbarLabel',
5
+ defaultMessage: 'Editor toolbar',
6
+ description: 'Label for the ARIA region landmark'
7
+ },
8
+ pageActionsLabel: {
9
+ id: 'fabric.editor.pageActionsLabel',
10
+ defaultMessage: 'Page actions',
11
+ description: 'Label for the ARIA region landmark'
12
+ },
13
+ editableContentLabel: {
14
+ id: 'fabric.editor.editableContentLabel',
15
+ defaultMessage: 'Editable content',
16
+ description: 'Label for the ARIA region landmark'
17
+ }
18
+ });
@@ -7,6 +7,7 @@ export { codeBlockButtonMessages } from './codeBlockButton';
7
7
  export { toolbarInsertBlockMessages } from './insert-block';
8
8
  export { toolbarMessages as mediaAndEmbedToolbarMessages } from './media-and-embed-toolbar';
9
9
  export { messages as cardMessages } from './card';
10
+ export { messages as fullPageMessages } from './full-page';
10
11
  export default defineMessages({
11
12
  layoutFixedWidth: {
12
13
  id: 'fabric.editor.layoutFixedWidth',
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.29.2";
9
+ var packageVersion = "74.30.0";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.29.2";
21
+ var packageVersion = "74.30.0";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -0,0 +1 @@
1
+ export var EDIT_AREA_ID = 'ak-editor-textarea';
@@ -25,4 +25,5 @@ export { snapTo, handleSides, imageAlignmentMap } from './ResizerLegacy/utils';
25
25
  export { wrapperStyle } from './ResizerLegacy/styled';
26
26
  export { panelTextInput } from './PanelTextInput/styles';
27
27
  export { default as PanelTextInput } from './PanelTextInput';
28
- export { default as Announcer } from './Announcer/announcer';
28
+ export { default as Announcer } from './Announcer/announcer';
29
+ export { EDIT_AREA_ID } from './Toolbar';
@@ -1,3 +1,4 @@
1
+ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import _extends from "@babel/runtime/helpers/extends";
@@ -16,7 +17,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
17
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
17
18
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
19
  /** @jsx jsx */
19
- import React, { PureComponent } from 'react';
20
+ import React, { PureComponent, useContext } from 'react';
20
21
  import { css, jsx } from '@emotion/react';
21
22
  import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
22
23
  import { CustomItem, MenuGroup } from '@atlaskit/menu';
@@ -25,6 +26,7 @@ import { B100, DN600, DN80, N70, N900 } from '@atlaskit/theme/colors';
25
26
  import { themed } from '@atlaskit/theme/components';
26
27
  import Tooltip from '@atlaskit/tooltip';
27
28
  import { DropdownMenuSharedCssClassName } from '../../styles';
29
+ import { KeyDownHandlerContext } from '../../ui-menu/ToolbarArrowKeyNavigationProvider';
28
30
  import { withReactEditorViewOuterListeners } from '../../ui-react';
29
31
  import DropList from '../../ui/DropList';
30
32
  import Popup from '../../ui/Popup';
@@ -317,4 +319,15 @@ function DropdownMenuItem(_ref) {
317
319
  }, dropListItem);
318
320
  }
319
321
  return dropListItem;
320
- }
322
+ }
323
+ export var DropdownMenuWithKeyboardNavigation = /*#__PURE__*/React.memo(function (_ref2) {
324
+ var props = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
325
+ var keyDownHandlerContext = useContext(KeyDownHandlerContext);
326
+ //This context is to handle the tab, Arrow Right/Left key events for dropdown.
327
+ //Default context has the void callbacks for above key events
328
+ return jsx(DropdownMenuWrapper, _extends({
329
+ arrowKeyNavigationProviderOptions: _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
330
+ keyDownHandlerContext: keyDownHandlerContext
331
+ })
332
+ }, props));
333
+ });
@@ -0,0 +1,207 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ /** @jsx jsx */
4
+ /* eslint-disable no-console */
5
+ import React, { useCallback, useLayoutEffect, useRef } from 'react';
6
+ import { css, jsx } from '@emotion/react';
7
+ import { fullPageMessages as messages } from '../../messages';
8
+ import { EDIT_AREA_ID } from '../../ui';
9
+ /*
10
+ ** The context is used to handle the keydown events of submenus.
11
+ ** Because the keyboard navigation is explicitly managed for main toolbar items
12
+ ** Few key presses such as Tab,Arrow Right/Left need ot be handled here via context
13
+ */
14
+ export var KeyDownHandlerContext = /*#__PURE__*/React.createContext({
15
+ handleArrowLeft: function handleArrowLeft() {},
16
+ handleArrowRight: function handleArrowRight() {},
17
+ handleTab: function handleTab() {}
18
+ });
19
+ var centeredToolbarContainer = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n width: 100%;\n align-items: center;\n"])));
20
+
21
+ /**
22
+ * This component is a wrapper of main toolbar which listens to keydown events of children
23
+ * and handles left/right arrow key navigation for all focusable elements
24
+ * @param
25
+ * @returns
26
+ */
27
+ export var ToolbarArrowKeyNavigationProvider = function ToolbarArrowKeyNavigationProvider(_ref) {
28
+ var children = _ref.children,
29
+ editorView = _ref.editorView,
30
+ childComponentSelector = _ref.childComponentSelector,
31
+ handleEscape = _ref.handleEscape,
32
+ disableArrowKeyNavigation = _ref.disableArrowKeyNavigation,
33
+ isShortcutToFocusToolbar = _ref.isShortcutToFocusToolbar,
34
+ editorAppearance = _ref.editorAppearance,
35
+ useStickyToolbar = _ref.useStickyToolbar,
36
+ intl = _ref.intl;
37
+ var wrapperRef = useRef(null);
38
+ var selectedItemIndex = useRef(0);
39
+ var incrementIndex = useCallback(function (list) {
40
+ var index = 0;
41
+ if (document.activeElement) {
42
+ index = list.indexOf(document.activeElement);
43
+ index = (index + 1) % list.length;
44
+ }
45
+ selectedItemIndex.current = index;
46
+ }, []);
47
+ var decrementIndex = useCallback(function (list) {
48
+ var index = 0;
49
+ if (document.activeElement) {
50
+ index = list.indexOf(document.activeElement);
51
+ index = (list.length + index - 1) % list.length;
52
+ }
53
+ selectedItemIndex.current = index;
54
+ }, []);
55
+ var handleArrowRight = function handleArrowRight() {
56
+ var _filteredFocusableEle;
57
+ var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
58
+ incrementIndex(filteredFocusableElements);
59
+ (_filteredFocusableEle = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle === void 0 ? void 0 : _filteredFocusableEle.focus();
60
+ };
61
+ var handleArrowLeft = function handleArrowLeft() {
62
+ var _filteredFocusableEle2;
63
+ var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
64
+ decrementIndex(filteredFocusableElements);
65
+ (_filteredFocusableEle2 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle2 === void 0 ? void 0 : _filteredFocusableEle2.focus();
66
+ };
67
+ var handleTab = function handleTab() {
68
+ var _filteredFocusableEle3;
69
+ var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
70
+ (_filteredFocusableEle3 = filteredFocusableElements[selectedItemIndex.current]) === null || _filteredFocusableEle3 === void 0 ? void 0 : _filteredFocusableEle3.focus();
71
+ };
72
+ var handleTabLocal = function handleTabLocal() {
73
+ var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
74
+ filteredFocusableElements.forEach(function (element) {
75
+ element.setAttribute('tabindex', '-1');
76
+ });
77
+ filteredFocusableElements[selectedItemIndex.current].setAttribute('tabindex', '0');
78
+ };
79
+ var focusAndScrollToElement = function focusAndScrollToElement(element) {
80
+ var scrollToElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
81
+ if (scrollToElement) {
82
+ element === null || element === void 0 ? void 0 : element.scrollIntoView({
83
+ behavior: 'smooth',
84
+ block: 'center',
85
+ inline: 'nearest'
86
+ });
87
+ }
88
+ element.focus();
89
+ };
90
+ var submenuKeydownHandleContext = {
91
+ handleArrowLeft: handleArrowLeft,
92
+ handleArrowRight: handleArrowRight,
93
+ handleTab: handleTab
94
+ };
95
+ useLayoutEffect(function () {
96
+ if (!wrapperRef.current || disableArrowKeyNavigation) {
97
+ return;
98
+ }
99
+ var element = wrapperRef.current;
100
+
101
+ /**
102
+ * To handle the key events on the list
103
+ * @param event
104
+ */
105
+ var handleKeyDown = function handleKeyDown(event) {
106
+ var _document$querySelect, _document$querySelect2, _wrapperRef$current;
107
+ //To trap the focus inside the horizontal toolbar for left and right arrow keys
108
+ var targetElement = event.target;
109
+
110
+ //To filter out the events outside the child component
111
+ if (!targetElement.closest("".concat(childComponentSelector))) {
112
+ return;
113
+ }
114
+
115
+ //The key events are from child components such as dropdown menus / popups are ignored
116
+ if ((_document$querySelect = document.querySelector('[data-role="droplistContent"], [data-test-id="color-picker-menu"], [data-emoji-picker-container="true"]')) !== null && _document$querySelect !== void 0 && _document$querySelect.contains(targetElement) || (_document$querySelect2 = document.querySelector('[data-test-id="color-picker-menu"]')) !== null && _document$querySelect2 !== void 0 && _document$querySelect2.contains(targetElement) || event.key === 'ArrowUp' || event.key === 'ArrowDown' || disableArrowKeyNavigation) {
117
+ return;
118
+ }
119
+ var menuWrapper = document.querySelector('.menu-key-handler-wrapper');
120
+ if (menuWrapper) {
121
+ // if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
122
+ return;
123
+ }
124
+ var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
125
+ if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
126
+ return;
127
+ }
128
+
129
+ //This is kind of hack to reset the current focused toolbar item
130
+ //to handle some use cases such as Tab in/out of main toolbar
131
+ if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
132
+ selectedItemIndex.current = -1;
133
+ } else {
134
+ selectedItemIndex.current = filteredFocusableElements.indexOf(targetElement) > -1 ? filteredFocusableElements.indexOf(targetElement) : selectedItemIndex.current;
135
+ }
136
+
137
+ //do not scroll to focused element for sticky toolbar when navigating with arrows to avoid unnesessary scroll jump
138
+ var allowScrollToElement = !(editorAppearance === 'comment' && !!useStickyToolbar);
139
+ switch (event.key) {
140
+ case 'ArrowRight':
141
+ incrementIndex(filteredFocusableElements);
142
+ focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
143
+ event.preventDefault();
144
+ break;
145
+ case 'ArrowLeft':
146
+ decrementIndex(filteredFocusableElements);
147
+ focusAndScrollToElement(filteredFocusableElements[selectedItemIndex.current], allowScrollToElement);
148
+ event.preventDefault();
149
+ break;
150
+ case 'Tab':
151
+ handleTabLocal();
152
+ break;
153
+ case 'Escape':
154
+ handleEscape(event);
155
+ break;
156
+ default:
157
+ }
158
+ };
159
+ var globalKeyDownHandler = function globalKeyDownHandler(event) {
160
+ //To focus the first element in the toolbar
161
+ if (isShortcutToFocusToolbar(event)) {
162
+ var _filteredFocusableEle4, _filteredFocusableEle5;
163
+ var filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
164
+ (_filteredFocusableEle4 = filteredFocusableElements[0]) === null || _filteredFocusableEle4 === void 0 ? void 0 : _filteredFocusableEle4.focus();
165
+ (_filteredFocusableEle5 = filteredFocusableElements[0]) === null || _filteredFocusableEle5 === void 0 ? void 0 : _filteredFocusableEle5.scrollIntoView({
166
+ behavior: 'smooth',
167
+ block: 'center',
168
+ inline: 'nearest'
169
+ });
170
+ }
171
+ };
172
+ element === null || element === void 0 ? void 0 : element.addEventListener('keydown', handleKeyDown);
173
+ var editorViewDom = editorView === null || editorView === void 0 ? void 0 : editorView.dom;
174
+ if (isShortcutToFocusToolbar) {
175
+ editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.addEventListener('keydown', globalKeyDownHandler);
176
+ }
177
+ return function () {
178
+ element === null || element === void 0 ? void 0 : element.removeEventListener('keydown', handleKeyDown);
179
+ if (isShortcutToFocusToolbar) {
180
+ editorViewDom === null || editorViewDom === void 0 ? void 0 : editorViewDom.removeEventListener('keydown', globalKeyDownHandler);
181
+ }
182
+ };
183
+ }, [selectedItemIndex, wrapperRef, editorView, disableArrowKeyNavigation, handleEscape, childComponentSelector, incrementIndex, decrementIndex, isShortcutToFocusToolbar, editorAppearance, useStickyToolbar]);
184
+ return jsx("div", {
185
+ css: editorAppearance === 'comment' && centeredToolbarContainer,
186
+ className: "custom-key-handler-wrapper",
187
+ ref: wrapperRef,
188
+ role: "toolbar",
189
+ "aria-label": intl.formatMessage(messages.toolbarLabel),
190
+ "aria-controls": EDIT_AREA_ID
191
+ }, jsx(KeyDownHandlerContext.Provider, {
192
+ value: submenuKeydownHandleContext
193
+ }, children));
194
+ };
195
+ function getFocusableElements(rootNode) {
196
+ if (!rootNode) {
197
+ return [];
198
+ }
199
+ var focusableModalElements = rootNode.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, div[tabindex="-1"], div[tabindex="0"]') || [];
200
+ return Array.from(focusableModalElements);
201
+ }
202
+ function getFilteredFocusableElements(rootNode) {
203
+ //The focusable elements from child components such as dropdown menus / popups are ignored
204
+ return getFocusableElements(rootNode).filter(function (elm) {
205
+ return !elm.closest('[data-role="droplistContent"]') && !elm.closest('[data-emoji-picker-container="true"]') && !elm.closest('[data-test-id="color-picker-menu"]') && !elm.closest('.scroll-buttons');
206
+ });
207
+ }
@@ -1,6 +1,7 @@
1
- export { default as DropdownMenu } from '../ui-menu/DropdownMenu';
2
- export { default as ToolbarButton, TOOLBAR_BUTTON } from '../ui-menu/ToolbarButton';
3
- export { ArrowKeyNavigationProvider } from '../ui-menu/ArrowKeyNavigationProvider';
4
- export { ArrowKeyNavigationType } from '../ui-menu/ArrowKeyNavigationProvider/types';
1
+ export { default as DropdownMenu, DropdownMenuWithKeyboardNavigation } from './DropdownMenu';
2
+ export { default as ToolbarButton, TOOLBAR_BUTTON } from './ToolbarButton';
3
+ export { ArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider';
4
+ export { ToolbarArrowKeyNavigationProvider, KeyDownHandlerContext } from './ToolbarArrowKeyNavigationProvider';
5
+ export { ArrowKeyNavigationType } from './ArrowKeyNavigationProvider/types';
5
6
  export { ColorPaletteArrowKeyNavigationProvider } from './ArrowKeyNavigationProvider/ColorPaletteArrowKeyNavigationProvider';
6
7
  export { default as Dropdown } from './Dropdown';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.29.2",
3
+ "version": "74.30.0",
4
4
  "sideEffects": false
5
5
  }
@@ -15,9 +15,12 @@ declare const _default: {
15
15
  'fabric.editor.blockDescription': string;
16
16
  'fabric.editor.blockTitle': string;
17
17
  'fabric.editor.blockquote': string;
18
+ 'fabric.editor.bug': string;
18
19
  'fabric.editor.cancelButton': string;
19
20
  'fabric.editor.captionPlaceholder': string;
20
21
  'fabric.editor.cardFloatingControls': string;
22
+ 'fabric.editor.clearLink': string;
23
+ 'fabric.editor.clearLinkText': string;
21
24
  'fabric.editor.codeBidiWarningLabel': string;
22
25
  'fabric.editor.codeBlockCopyButton.copiedToClipboard': string;
23
26
  'fabric.editor.codeBlockCopyButton.copyToClipboard': string;
@@ -32,11 +35,13 @@ declare const _default: {
32
35
  'fabric.editor.date.description': string;
33
36
  'fabric.editor.decision': string;
34
37
  'fabric.editor.decision.description': string;
38
+ 'fabric.editor.defaultAltText': string;
35
39
  'fabric.editor.displayBlock': string;
36
40
  'fabric.editor.displayEmbed': string;
37
41
  'fabric.editor.displayInline': string;
38
42
  'fabric.editor.displayLink': string;
39
43
  'fabric.editor.displayOptionUnavailableInParentNode': string;
44
+ 'fabric.editor.displayText': string;
40
45
  'fabric.editor.ecombedDescription': string;
41
46
  'fabric.editor.edit.datasource': string;
42
47
  'fabric.editor.editLink': string;
@@ -45,6 +50,7 @@ declare const _default: {
45
50
  'fabric.editor.emoji': string;
46
51
  'fabric.editor.emoji.description': string;
47
52
  'fabric.editor.emptyLink': string;
53
+ 'fabric.editor.epic': string;
48
54
  'fabric.editor.expand': string;
49
55
  'fabric.editor.expand.description': string;
50
56
  'fabric.editor.expandDefaultTitle': string;
@@ -52,12 +58,22 @@ declare const _default: {
52
58
  'fabric.editor.expandPlaceholder': string;
53
59
  'fabric.editor.feedbackDialog': string;
54
60
  'fabric.editor.feedbackDialog.description': string;
61
+ 'fabric.editor.headingLink.hyperlinkIconBlogLabel': string;
62
+ 'fabric.editor.headingLink.hyperlinkIconBugLabel': string;
63
+ 'fabric.editor.headingLink.hyperlinkIconIssueLabel': string;
64
+ 'fabric.editor.headingLink.hyperlinkIconPageLabel': string;
65
+ 'fabric.editor.headingLink.hyperlinkIconStoryLabel': string;
66
+ 'fabric.editor.headingLink.hyperlinkIconTaskLabel': string;
55
67
  'fabric.editor.help': string;
56
68
  'fabric.editor.help.description': string;
57
69
  'fabric.editor.horizontalRule': string;
58
70
  'fabric.editor.horizontalRule.description': string;
71
+ 'fabric.editor.hyperlink.linkAriaLabel': string;
72
+ 'fabric.editor.hyperlink.searchLinkAriaDescription': string;
73
+ 'fabric.editor.hyperlink.searchLinkResults': string;
59
74
  'fabric.editor.hyperlinkToolbarPlaceholder': string;
60
75
  'fabric.editor.image': string;
76
+ 'fabric.editor.improvement': string;
61
77
  'fabric.editor.inlineDescription': string;
62
78
  'fabric.editor.inlineTitle': string;
63
79
  'fabric.editor.insertMenu': string;
@@ -83,8 +99,11 @@ declare const _default: {
83
99
  'fabric.editor.settingsLinks': string;
84
100
  'fabric.editor.status': string;
85
101
  'fabric.editor.status.description': string;
102
+ 'fabric.editor.story': string;
103
+ 'fabric.editor.subTask': string;
86
104
  'fabric.editor.table': string;
87
105
  'fabric.editor.table.description': string;
106
+ 'fabric.editor.task': string;
88
107
  'fabric.editor.time.ago': string;
89
108
  'fabric.editor.time.updated': string;
90
109
  'fabric.editor.time.viewed': string;
@@ -15,9 +15,12 @@ declare const _default: {
15
15
  'fabric.editor.blockDescription': string;
16
16
  'fabric.editor.blockTitle': string;
17
17
  'fabric.editor.blockquote': string;
18
+ 'fabric.editor.bug': string;
18
19
  'fabric.editor.cancelButton': string;
19
20
  'fabric.editor.captionPlaceholder': string;
20
21
  'fabric.editor.cardFloatingControls': string;
22
+ 'fabric.editor.clearLink': string;
23
+ 'fabric.editor.clearLinkText': string;
21
24
  'fabric.editor.codeBidiWarningLabel': string;
22
25
  'fabric.editor.codeBlockCopyButton.copiedToClipboard': string;
23
26
  'fabric.editor.codeBlockCopyButton.copyToClipboard': string;
@@ -32,11 +35,13 @@ declare const _default: {
32
35
  'fabric.editor.date.description': string;
33
36
  'fabric.editor.decision': string;
34
37
  'fabric.editor.decision.description': string;
38
+ 'fabric.editor.defaultAltText': string;
35
39
  'fabric.editor.displayBlock': string;
36
40
  'fabric.editor.displayEmbed': string;
37
41
  'fabric.editor.displayInline': string;
38
42
  'fabric.editor.displayLink': string;
39
43
  'fabric.editor.displayOptionUnavailableInParentNode': string;
44
+ 'fabric.editor.displayText': string;
40
45
  'fabric.editor.ecombedDescription': string;
41
46
  'fabric.editor.edit.datasource': string;
42
47
  'fabric.editor.editLink': string;
@@ -45,6 +50,7 @@ declare const _default: {
45
50
  'fabric.editor.emoji': string;
46
51
  'fabric.editor.emoji.description': string;
47
52
  'fabric.editor.emptyLink': string;
53
+ 'fabric.editor.epic': string;
48
54
  'fabric.editor.expand': string;
49
55
  'fabric.editor.expand.description': string;
50
56
  'fabric.editor.expandDefaultTitle': string;
@@ -52,12 +58,22 @@ declare const _default: {
52
58
  'fabric.editor.expandPlaceholder': string;
53
59
  'fabric.editor.feedbackDialog': string;
54
60
  'fabric.editor.feedbackDialog.description': string;
61
+ 'fabric.editor.headingLink.hyperlinkIconBlogLabel': string;
62
+ 'fabric.editor.headingLink.hyperlinkIconBugLabel': string;
63
+ 'fabric.editor.headingLink.hyperlinkIconIssueLabel': string;
64
+ 'fabric.editor.headingLink.hyperlinkIconPageLabel': string;
65
+ 'fabric.editor.headingLink.hyperlinkIconStoryLabel': string;
66
+ 'fabric.editor.headingLink.hyperlinkIconTaskLabel': string;
55
67
  'fabric.editor.help': string;
56
68
  'fabric.editor.help.description': string;
57
69
  'fabric.editor.horizontalRule': string;
58
70
  'fabric.editor.horizontalRule.description': string;
71
+ 'fabric.editor.hyperlink.linkAriaLabel': string;
72
+ 'fabric.editor.hyperlink.searchLinkAriaDescription': string;
73
+ 'fabric.editor.hyperlink.searchLinkResults': string;
59
74
  'fabric.editor.hyperlinkToolbarPlaceholder': string;
60
75
  'fabric.editor.image': string;
76
+ 'fabric.editor.improvement': string;
61
77
  'fabric.editor.inlineDescription': string;
62
78
  'fabric.editor.inlineTitle': string;
63
79
  'fabric.editor.insertMenu': string;
@@ -83,8 +99,11 @@ declare const _default: {
83
99
  'fabric.editor.settingsLinks': string;
84
100
  'fabric.editor.status': string;
85
101
  'fabric.editor.status.description': string;
102
+ 'fabric.editor.story': string;
103
+ 'fabric.editor.subTask': string;
86
104
  'fabric.editor.table': string;
87
105
  'fabric.editor.table.description': string;
106
+ 'fabric.editor.task': string;
88
107
  'fabric.editor.time.ago': string;
89
108
  'fabric.editor.time.updated': string;
90
109
  'fabric.editor.time.viewed': string;