@atlaskit/editor-shared-styles 1.6.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 (59) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/build/tsconfig.json +17 -0
  3. package/consts/package.json +7 -0
  4. package/dist/cjs/consts/consts.js +277 -0
  5. package/dist/cjs/consts/consts.test.js +25 -0
  6. package/dist/cjs/consts/index.js +541 -0
  7. package/dist/cjs/consts/types.js +5 -0
  8. package/dist/cjs/index.js +563 -0
  9. package/dist/cjs/overflow-shadow/index.js +13 -0
  10. package/dist/cjs/overflow-shadow/overflow-shadow.js +22 -0
  11. package/dist/cjs/selection/index.js +27 -0
  12. package/dist/cjs/selection/types.js +21 -0
  13. package/dist/cjs/selection/utils.js +49 -0
  14. package/dist/cjs/version.json +5 -0
  15. package/dist/es2019/consts/consts.js +152 -0
  16. package/dist/es2019/consts/consts.test.js +20 -0
  17. package/dist/es2019/consts/index.js +1 -0
  18. package/dist/es2019/consts/types.js +1 -0
  19. package/dist/es2019/index.js +3 -0
  20. package/dist/es2019/overflow-shadow/index.js +1 -0
  21. package/dist/es2019/overflow-shadow/overflow-shadow.js +23 -0
  22. package/dist/es2019/selection/index.js +2 -0
  23. package/dist/es2019/selection/types.js +13 -0
  24. package/dist/es2019/selection/utils.js +61 -0
  25. package/dist/es2019/version.json +5 -0
  26. package/dist/esm/consts/consts.js +162 -0
  27. package/dist/esm/consts/consts.test.js +22 -0
  28. package/dist/esm/consts/index.js +1 -0
  29. package/dist/esm/consts/types.js +1 -0
  30. package/dist/esm/index.js +3 -0
  31. package/dist/esm/overflow-shadow/index.js +1 -0
  32. package/dist/esm/overflow-shadow/overflow-shadow.js +10 -0
  33. package/dist/esm/selection/index.js +2 -0
  34. package/dist/esm/selection/types.js +13 -0
  35. package/dist/esm/selection/utils.js +38 -0
  36. package/dist/esm/version.json +5 -0
  37. package/dist/types/consts/consts.d.ts +124 -0
  38. package/dist/types/consts/index.d.ts +2 -0
  39. package/dist/types/consts/types.d.ts +3 -0
  40. package/dist/types/index.d.ts +4 -0
  41. package/dist/types/overflow-shadow/index.d.ts +1 -0
  42. package/dist/types/overflow-shadow/overflow-shadow.d.ts +5 -0
  43. package/dist/types/selection/index.d.ts +2 -0
  44. package/dist/types/selection/types.d.ts +11 -0
  45. package/dist/types/selection/utils.d.ts +13 -0
  46. package/package.json +46 -0
  47. package/selection/package.json +7 -0
  48. package/src/consts/consts.test.ts +21 -0
  49. package/src/consts/consts.ts +204 -0
  50. package/src/consts/index.ts +92 -0
  51. package/src/consts/types.ts +3 -0
  52. package/src/index.ts +99 -0
  53. package/src/overflow-shadow/index.ts +1 -0
  54. package/src/overflow-shadow/overflow-shadow.ts +29 -0
  55. package/src/selection/__tests__/unit/utils.ts +43 -0
  56. package/src/selection/index.ts +5 -0
  57. package/src/selection/types.ts +11 -0
  58. package/src/selection/utils.ts +71 -0
  59. package/tsconfig.json +11 -0
@@ -0,0 +1 @@
1
+ export { overflowShadow } from './overflow-shadow';
@@ -0,0 +1,29 @@
1
+ import { css } from 'styled-components';
2
+
3
+ import { ThemedValue } from '@atlaskit/theme/types';
4
+
5
+ export const overflowShadow = ({
6
+ background,
7
+ width,
8
+ }: {
9
+ background: ThemedValue<string> | string;
10
+ width: string;
11
+ }) => css`
12
+ /* shadow cover right */ linear-gradient(
13
+ to left,
14
+ ${background} ${width},
15
+ transparent ${width}
16
+ ),
17
+ /* overflow shadow right */
18
+ linear-gradient(
19
+ to left,
20
+ rgba(9, 30, 66, 0.13) 0,
21
+ rgba(99, 114, 130, 0) ${width}
22
+ ),
23
+ /* overflow shadow left */
24
+ linear-gradient(
25
+ to right,
26
+ rgba(9, 30, 66, 0.13) 0,
27
+ rgba(99, 114, 130, 0) ${width}
28
+ )
29
+ `;
@@ -0,0 +1,43 @@
1
+ import { SelectionStyle } from '../../types';
2
+ import { getSelectionStyles } from '../../utils';
3
+
4
+ describe('selection plugin: utils', () => {
5
+ describe('getSelectionStyles', () => {
6
+ const selectionStyles = [
7
+ { name: 'border', style: SelectionStyle.Border, regex: /border\:/ },
8
+ {
9
+ name: 'box-shadow',
10
+ style: SelectionStyle.BoxShadow,
11
+ regex: /box\-shadow\:/,
12
+ },
13
+ {
14
+ name: 'background',
15
+ style: SelectionStyle.Background,
16
+ regex: /background\-color\:/,
17
+ },
18
+ { name: 'blanket', style: SelectionStyle.Blanket, regex: /\:\:after/ },
19
+ ];
20
+
21
+ for (const selectionStyle of selectionStyles) {
22
+ it(`gets styles for ${selectionStyle.name}`, () => {
23
+ const css = getSelectionStyles([selectionStyle.style]);
24
+ expect(css).toMatch(selectionStyle.regex);
25
+ });
26
+ }
27
+
28
+ it('combines multiple styles', () => {
29
+ const allStyles = selectionStyles.map(
30
+ (selectionStyle) => selectionStyle.style,
31
+ );
32
+ const allRegex = selectionStyles.map(
33
+ (selectionStyle) => selectionStyle.regex,
34
+ );
35
+
36
+ const css = getSelectionStyles(allStyles);
37
+
38
+ for (const regex of allRegex) {
39
+ expect(css).toMatch(regex);
40
+ }
41
+ });
42
+ });
43
+ });
@@ -0,0 +1,5 @@
1
+ export { SelectionStyle } from './types';
2
+ export {
3
+ getSelectionStyles,
4
+ hideNativeBrowserTextSelectionStyles,
5
+ } from './utils';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * These are generic selection styles for all nodes
3
+ * If you have custom behaviour needed for a node, add that in the plugin's styles
4
+ * file in editor-core
5
+ */
6
+ export enum SelectionStyle {
7
+ Border,
8
+ BoxShadow,
9
+ Background,
10
+ Blanket,
11
+ }
@@ -0,0 +1,71 @@
1
+ import {
2
+ akEditorSelectedBgColor,
3
+ akEditorSelectedBlanketColor,
4
+ akEditorSelectedBlanketOpacity,
5
+ akEditorSelectedBorder,
6
+ akEditorSelectedBoxShadow,
7
+ } from '../consts';
8
+
9
+ import { SelectionStyle } from './types';
10
+
11
+ /**
12
+ * Adds correct selection styling for a node
13
+ * Pass in which selection style properties you want and it will return css string of necessary styles
14
+ *
15
+ * eg.
16
+ * .expand.ak-editor-selected-node {
17
+ * ${getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket])}
18
+ * }
19
+ *
20
+ */
21
+ export const getSelectionStyles = (
22
+ selectionStyles: Array<SelectionStyle>,
23
+ ): string =>
24
+ selectionStyles
25
+ .map((selectionStyle) => getSelectionStyle(selectionStyle))
26
+ .concat(hideNativeBrowserTextSelectionStyles)
27
+ .join('\n');
28
+
29
+ export const hideNativeBrowserTextSelectionStyles = `
30
+ ::selection,*::selection {
31
+ background-color: transparent;
32
+ }
33
+ ::-moz-selection,*::-moz-selection {
34
+ background-color: transparent;
35
+ }
36
+ `;
37
+
38
+ const getSelectionStyle = (style: SelectionStyle): string => {
39
+ switch (style) {
40
+ case SelectionStyle.Border:
41
+ return `border: ${akEditorSelectedBorder};`;
42
+ case SelectionStyle.BoxShadow:
43
+ return `
44
+ box-shadow: ${akEditorSelectedBoxShadow};
45
+ border-color: transparent;
46
+ `;
47
+ case SelectionStyle.Background:
48
+ return `background-color: ${akEditorSelectedBgColor};`;
49
+ case SelectionStyle.Blanket:
50
+ return `
51
+ position: relative;
52
+
53
+ // Fixes ED-9263, where emoji or inline card in panel makes selection go outside the panel
54
+ // in Safari. Looks like it's caused by user-select: all in the emoji element
55
+ -webkit-user-select: text;
56
+
57
+ ::after {
58
+ position: absolute;
59
+ content: '';
60
+ left: 0;
61
+ right: 0;
62
+ top: 0;
63
+ bottom: 0;
64
+ opacity: ${akEditorSelectedBlanketOpacity};
65
+ pointer-events: none;
66
+ background-color: ${akEditorSelectedBlanketColor}
67
+ }`;
68
+ default:
69
+ return '';
70
+ }
71
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "./",
5
+ "noImplicitAny": true
6
+ },
7
+ "include": [
8
+ "./src/**/*.ts",
9
+ "./src/**/*.tsx",
10
+ ]
11
+ }