@atlaskit/editor-toolbar 0.0.2 → 0.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-toolbar
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#192343](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/192343)
8
+ [`9cb0878241016`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9cb0878241016) -
9
+ ED-28736 more extensible selection extensions API
10
+
11
+ ## 0.0.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [#192616](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/192616)
16
+ [`b97ca8e19b601`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b97ca8e19b601) -
17
+ [ED-28595] add aria-attributes to toolbar button and toolbar dropdown item
18
+ - Updated dependencies
19
+
3
20
  ## 0.0.2
4
21
 
5
22
  ### Patch Changes
@@ -153,7 +153,7 @@ export const ExampleManuallyComposedToolbar = () => {
153
153
  <ToolbarNestedDropdownMenu
154
154
  elemBefore={<AIAdjustLengthIcon label="Adjust length" />}
155
155
  text="Adjust length"
156
- elemAfter={<NestedDropdownRightIcon label={'Choose desired tone'}/>}
156
+ elemAfter={<NestedDropdownRightIcon label={'Choose desired tone'} />}
157
157
  isDisabled={isAdjustLengthDisabled}
158
158
  >
159
159
  <ToolbarDropdownItemSection>
@@ -174,7 +174,7 @@ export const ExampleManuallyComposedToolbar = () => {
174
174
  <ToolbarNestedDropdownMenu
175
175
  elemBefore={<AIChangeToneIcon label="Change tone" />}
176
176
  text="Change tone"
177
- elemAfter={<NestedDropdownRightIcon label={'Choose desired tone'}/>}
177
+ elemAfter={<NestedDropdownRightIcon label={'Choose desired tone'} />}
178
178
  >
179
179
  <ToolbarDropdownItemSection>
180
180
  <ToolbarDropdownItem
@@ -206,7 +206,7 @@ export const ExampleManuallyComposedToolbar = () => {
206
206
  <ToolbarNestedDropdownMenu
207
207
  elemBefore={<AITranslateIcon label="Translate" />}
208
208
  text="Translate"
209
- elemAfter={<NestedDropdownRightIcon label={'Choose language option'}/>}
209
+ elemAfter={<NestedDropdownRightIcon label={'Choose language option'} />}
210
210
  >
211
211
  <ToolbarDropdownItemSection>
212
212
  <ToolbarDropdownItem
@@ -275,6 +275,7 @@ export const ExampleManuallyComposedToolbar = () => {
275
275
  onClick={onClick('Normal text', onSetTextStyle('normal'))}
276
276
  isSelected={textStyle === 'normal'}
277
277
  textStyle="normal"
278
+ ariaKeyshortcuts="⌘⌥0"
278
279
  >
279
280
  Normal text
280
281
  </ToolbarDropdownItem>
@@ -284,6 +285,7 @@ export const ExampleManuallyComposedToolbar = () => {
284
285
  onClick={onClick('Heading one', onSetTextStyle('heading1'))}
285
286
  isSelected={textStyle === 'heading1'}
286
287
  textStyle="heading1"
288
+ ariaKeyshortcuts="⌘⌥1"
287
289
  >
288
290
  Heading 1
289
291
  </ToolbarDropdownItem>
@@ -293,6 +295,7 @@ export const ExampleManuallyComposedToolbar = () => {
293
295
  onClick={onClick('Heading two', onSetTextStyle('heading2'))}
294
296
  isSelected={textStyle === 'heading2'}
295
297
  textStyle="heading2"
298
+ ariaKeyshortcuts="⌘⌥2"
296
299
  >
297
300
  Heading 2
298
301
  </ToolbarDropdownItem>
@@ -302,6 +305,7 @@ export const ExampleManuallyComposedToolbar = () => {
302
305
  onClick={onClick('Heading three', onSetTextStyle('heading3'))}
303
306
  isSelected={textStyle === 'heading3'}
304
307
  textStyle="heading3"
308
+ ariaKeyshortcuts="⌘⌥3"
305
309
  >
306
310
  Heading 3
307
311
  </ToolbarDropdownItem>
@@ -311,6 +315,7 @@ export const ExampleManuallyComposedToolbar = () => {
311
315
  onClick={onClick('Heading four', onSetTextStyle('heading4'))}
312
316
  isSelected={textStyle === 'heading4'}
313
317
  textStyle="heading4"
318
+ ariaKeyshortcuts="⌘⌥4"
314
319
  >
315
320
  Heading 4
316
321
  </ToolbarDropdownItem>
@@ -320,6 +325,7 @@ export const ExampleManuallyComposedToolbar = () => {
320
325
  onClick={onClick('Heading five', onSetTextStyle('heading5'))}
321
326
  isSelected={textStyle === 'heading5'}
322
327
  textStyle="heading5"
328
+ ariaKeyshortcuts="⌘⌥5"
323
329
  >
324
330
  Heading 5
325
331
  </ToolbarDropdownItem>
@@ -329,6 +335,7 @@ export const ExampleManuallyComposedToolbar = () => {
329
335
  onClick={onClick('Heading six', onSetTextStyle('heading6'))}
330
336
  isSelected={textStyle === 'heading6'}
331
337
  textStyle="heading6"
338
+ ariaKeyshortcuts="⌘⌥6"
332
339
  >
333
340
  Heading 6
334
341
  </ToolbarDropdownItem>
@@ -338,6 +345,7 @@ export const ExampleManuallyComposedToolbar = () => {
338
345
  onClick={onClick('Quote', onSetTextStyle('quote'))}
339
346
  isSelected={textStyle === 'quote'}
340
347
  textStyle="normal"
348
+ ariaKeyshortcuts="⌘⌥9"
341
349
  >
342
350
  Quote
343
351
  </ToolbarDropdownItem>
@@ -358,16 +366,18 @@ export const ExampleManuallyComposedToolbar = () => {
358
366
  groupLocation="start"
359
367
  isSelected={formatting.bold || formatting.italic}
360
368
  isDisabled={formatting.italic ? isItalicDisabled : isBoldDisabled}
369
+ ariaKeyshortcuts={formatting.italic && !formatting.bold ? '⌘I' : '⌘B'}
361
370
  />
362
371
  </ToolbarTooltip>
363
372
  <ToolbarDropdownMenu icon={MoreItemsIcon} label="More formatting" groupLocation="end">
364
373
  <ToolbarDropdownItemSection>
365
374
  <ToolbarDropdownItem
366
- elemBefore={<BoldIcon label="Bold" />}
367
- elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘B" />}
368
- onClick={onClick('Bold', onToggleFormatting('bold'))}
369
- isSelected={formatting.bold}
370
- isDisabled={isBoldDisabled}
375
+ elemBefore={<BoldIcon label="Bold" />}
376
+ elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘B" />}
377
+ onClick={onClick('Bold', onToggleFormatting('bold'))}
378
+ isSelected={formatting.bold}
379
+ isDisabled={isBoldDisabled}
380
+ ariaKeyshortcuts="⌘B"
371
381
  >
372
382
  Bold
373
383
  </ToolbarDropdownItem>
@@ -377,16 +387,18 @@ export const ExampleManuallyComposedToolbar = () => {
377
387
  onClick={onClick('Italic', onToggleFormatting('italic'))}
378
388
  isSelected={formatting.italic}
379
389
  isDisabled={isItalicDisabled}
390
+ ariaKeyshortcuts="⌘I"
380
391
  >
381
392
  Italic
382
393
  </ToolbarDropdownItem>
383
394
  </ToolbarDropdownItemSection>
384
- <ToolbarDropdownDivider/>
395
+ <ToolbarDropdownDivider />
385
396
  <ToolbarDropdownItemSection>
386
397
  <ToolbarDropdownItem
387
398
  elemBefore={<ClearFormattingIcon label="Clear formatting" />}
388
399
  elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘\" />}
389
400
  onClick={onClick('Clear formatting')}
401
+ ariaKeyshortcuts="⌘\"
390
402
  >
391
403
  Clear formatting
392
404
  </ToolbarDropdownItem>
@@ -449,11 +461,12 @@ export const ExampleManuallyComposedToolbar = () => {
449
461
  >
450
462
  <ToolbarDropdownItemSection>
451
463
  <ToolbarDropdownItem
452
- elemBefore={<ListBulletedIcon label="Bulleted list" />}
453
- elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⇧8" />}
454
- onClick={onClick('Bulleted list', onToggleListOrAlignment('bulleted'))}
455
- isSelected={listOrAlignment === 'bulleted'}
456
- isDisabled={isBulletedListDisabled}
464
+ elemBefore={<ListBulletedIcon label="Bulleted list" />}
465
+ elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⇧8" />}
466
+ onClick={onClick('Bulleted list', onToggleListOrAlignment('bulleted'))}
467
+ isSelected={listOrAlignment === 'bulleted'}
468
+ isDisabled={isBulletedListDisabled}
469
+ ariaKeyshortcuts="⌘⇧8"
457
470
  >
458
471
  Bulleted list
459
472
  </ToolbarDropdownItem>
@@ -463,6 +476,7 @@ export const ExampleManuallyComposedToolbar = () => {
463
476
  onClick={onClick('Numbered list', onToggleListOrAlignment('numbered'))}
464
477
  isSelected={listOrAlignment === 'numbered'}
465
478
  isDisabled={isNumberedListDisabled}
479
+ ariaKeyshortcuts="⌘⇧7"
466
480
  >
467
481
  Numbered list
468
482
  </ToolbarDropdownItem>
@@ -513,9 +527,9 @@ export const ExampleManuallyComposedToolbar = () => {
513
527
  >
514
528
  <ToolbarDropdownItemSection>
515
529
  <ToolbarDropdownItem
516
- elemBefore={<AddIcon label="Create Jira work item" />}
517
- onClick={onClick('Create Jira work item')}
518
- isDisabled={isCreateJiraWorkItemDisabled}
530
+ elemBefore={<AddIcon label="Create Jira work item" />}
531
+ onClick={onClick('Create Jira work item')}
532
+ isDisabled={isCreateJiraWorkItemDisabled}
519
533
  >
520
534
  Create Jira work item
521
535
  </ToolbarDropdownItem>
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://registry.npmjs.org/"
5
5
  },
6
- "version": "0.0.2",
6
+ "version": "0.0.4",
7
7
  "description": "Common UI for Toolbars across the platform",
8
8
  "atlassian": {
9
9
  "team": "Editor"
@@ -24,16 +24,16 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@atlaskit/badge": "^18.1.0",
27
- "@atlaskit/button": "^23.2.0",
27
+ "@atlaskit/button": "^23.3.0",
28
28
  "@atlaskit/css": "^0.12.0",
29
29
  "@atlaskit/dropdown-menu": "^16.3.0",
30
- "@atlaskit/icon": "^27.7.0",
30
+ "@atlaskit/icon": "^27.8.0",
31
31
  "@atlaskit/icon-lab": "^5.2.0",
32
- "@atlaskit/logo": "^19.5.0",
32
+ "@atlaskit/logo": "^19.6.0",
33
33
  "@atlaskit/popup": "^4.3.0",
34
- "@atlaskit/primitives": "^14.10.0",
34
+ "@atlaskit/primitives": "^14.11.0",
35
35
  "@atlaskit/tokens": "^5.6.0",
36
- "@atlaskit/tooltip": "^20.3.0",
36
+ "@atlaskit/tooltip": "^20.4.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "@compiled/react": "^0.18.3"
39
39
  },
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export { ToolbarDropdownItem } from './ui/ToolbarDropdownItem';
5
5
  export { ToolbarDropdownMenu } from './ui/ToolbarDropdownMenu';
6
6
  export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
7
7
  export { ToolbarSection } from './ui/ToolbarSection';
8
+ export { ToolbarTooltip } from './ui/ToolbarTooltip';
8
9
 
9
10
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
10
11
  export { AIChatIcon } from './ui/icons/AIChatIcon';
@@ -30,4 +31,4 @@ export { QuoteIcon } from './ui/icons/QuoteIcon';
30
31
  export { TextColorIcon } from './ui/icons/TextColorIcon';
31
32
  export { TextIcon } from './ui/icons/TextIcon';
32
33
 
33
- export type { ToolbarButtonGroupLocation } from './types';
34
+ export type { IconComponent, ToolbarButtonGroupLocation } from './types';
@@ -89,6 +89,7 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
89
89
  icon: IconComponent;
90
90
  groupLocation?: ToolbarButtonGroupLocation;
91
91
  isDisabled?: boolean;
92
+ ariaKeyshortcuts?: string;
92
93
  };
93
94
 
94
95
  export const ToolbarButton = forwardRef(
@@ -108,6 +109,7 @@ export const ToolbarButton = forwardRef(
108
109
  testId,
109
110
  groupLocation,
110
111
  isDisabled,
112
+ ariaKeyshortcuts,
111
113
  }: ToolbarButtonProps,
112
114
  ref: Ref<HTMLButtonElement>,
113
115
  ) => {
@@ -126,9 +128,11 @@ export const ToolbarButton = forwardRef(
126
128
  groupLocation === 'middle' && styles.groupMiddle,
127
129
  groupLocation === 'end' && styles.groupEnd,
128
130
  )}
131
+ aria-pressed={isSelected}
129
132
  aria-expanded={ariaExpanded}
130
133
  aria-haspopup={ariaHasPopup}
131
134
  aria-controls={ariaControls}
135
+ aria-keyshortcuts={ariaKeyshortcuts}
132
136
  data-ds--level={dataDsLevel}
133
137
  onClick={onClick}
134
138
  onBlur={onBlur}
@@ -77,32 +77,45 @@ export type CustomDropdownMenuItemButtonProps = CustomItemComponentProps & {
77
77
  'aria-haspopup'?: boolean;
78
78
  'aria-disabled'?: boolean;
79
79
  'aria-pressed'?: boolean;
80
+ 'aria-keyshortcuts'?: string;
80
81
  };
81
82
 
82
- const CustomDropdownMenuItemButton = forwardRef<HTMLButtonElement, CustomDropdownMenuItemButtonProps>(({
83
- children,
84
- 'data-testid': testId,
85
- 'aria-haspopup': ariaHasPopup,
86
- 'aria-disabled': ariaDisabled,
87
- 'aria-pressed': ariaPressed,
88
- onClick,
89
- tabIndex,
90
- }, ref) =>
91
- <Pressable
92
- testId={testId}
93
- xcss={cx(styles.toolbarDropdownItem, ariaDisabled ? styles.disabled : ariaPressed ? styles.selected : styles.enabled)}
94
- onClick={onClick}
95
- tabIndex={tabIndex}
96
- aria-haspopup={ariaHasPopup}
97
- aria-expanded={ariaHasPopup ? ariaPressed ? true : false : undefined}
98
- aria-pressed={ariaPressed}
99
- aria-disabled={ariaDisabled}
100
- ref={ref}
101
- >
102
- {children}
103
- </Pressable>
104
- )
105
-
83
+ const CustomDropdownMenuItemButton = forwardRef<
84
+ HTMLButtonElement,
85
+ CustomDropdownMenuItemButtonProps
86
+ >(
87
+ (
88
+ {
89
+ children,
90
+ 'data-testid': testId,
91
+ 'aria-haspopup': ariaHasPopup,
92
+ 'aria-disabled': ariaDisabled,
93
+ 'aria-pressed': ariaPressed,
94
+ 'aria-keyshortcuts': ariaKeyshortcuts,
95
+ onClick,
96
+ tabIndex,
97
+ },
98
+ ref,
99
+ ) => (
100
+ <Pressable
101
+ testId={testId}
102
+ xcss={cx(
103
+ styles.toolbarDropdownItem,
104
+ ariaDisabled ? styles.disabled : ariaPressed ? styles.selected : styles.enabled,
105
+ )}
106
+ onClick={onClick}
107
+ tabIndex={tabIndex}
108
+ aria-haspopup={ariaHasPopup}
109
+ aria-expanded={ariaHasPopup ? (ariaPressed ? true : false) : undefined}
110
+ aria-pressed={ariaPressed}
111
+ aria-disabled={ariaDisabled}
112
+ aria-keyshortcuts={ariaKeyshortcuts}
113
+ ref={ref}
114
+ >
115
+ {children}
116
+ </Pressable>
117
+ ),
118
+ );
106
119
 
107
120
  type ToolbarDropdownItemProps = {
108
121
  onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
@@ -113,8 +126,9 @@ type ToolbarDropdownItemProps = {
113
126
  textStyle?: TextStyle;
114
127
  isDisabled?: boolean;
115
128
  hasNestedDropdownMenu?: boolean;
116
- triggerRef?: Ref<HTMLButtonElement>
129
+ triggerRef?: Ref<HTMLButtonElement>;
117
130
  testId?: string;
131
+ ariaKeyshortcuts?: string;
118
132
  };
119
133
 
120
134
  export const ToolbarDropdownItem = ({
@@ -128,7 +142,8 @@ export const ToolbarDropdownItem = ({
128
142
  hasNestedDropdownMenu,
129
143
  triggerRef,
130
144
  testId,
131
- }: ToolbarDropdownItemProps) =>
145
+ ariaKeyshortcuts,
146
+ }: ToolbarDropdownItemProps) => (
132
147
  <DropdownItem
133
148
  onClick={onClick}
134
149
  elemBefore={elemBefore}
@@ -137,9 +152,11 @@ export const ToolbarDropdownItem = ({
137
152
  isDisabled={isDisabled}
138
153
  aria-haspopup={hasNestedDropdownMenu}
139
154
  aria-pressed={isSelected}
155
+ aria-keyshortcuts={ariaKeyshortcuts}
140
156
  ref={triggerRef}
141
157
  component={CustomDropdownMenuItemButton}
142
158
  testId={testId}
143
159
  >
144
160
  <Box xcss={styles[textStyle]}>{children}</Box>
145
161
  </DropdownItem>
162
+ );
package/tsconfig.app.json CHANGED
@@ -49,6 +49,9 @@
49
49
  {
50
50
  "path": "../../design-system/logo/tsconfig.app.json"
51
51
  },
52
+ {
53
+ "path": "../../design-system/menu/tsconfig.app.json"
54
+ },
52
55
  {
53
56
  "path": "../../design-system/popup/tsconfig.app.json"
54
57
  },