@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.
- package/CHANGELOG.md +114 -0
- package/build/tsconfig.json +17 -0
- package/consts/package.json +7 -0
- package/dist/cjs/consts/consts.js +277 -0
- package/dist/cjs/consts/consts.test.js +25 -0
- package/dist/cjs/consts/index.js +541 -0
- package/dist/cjs/consts/types.js +5 -0
- package/dist/cjs/index.js +563 -0
- package/dist/cjs/overflow-shadow/index.js +13 -0
- package/dist/cjs/overflow-shadow/overflow-shadow.js +22 -0
- package/dist/cjs/selection/index.js +27 -0
- package/dist/cjs/selection/types.js +21 -0
- package/dist/cjs/selection/utils.js +49 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/consts/consts.js +152 -0
- package/dist/es2019/consts/consts.test.js +20 -0
- package/dist/es2019/consts/index.js +1 -0
- package/dist/es2019/consts/types.js +1 -0
- package/dist/es2019/index.js +3 -0
- package/dist/es2019/overflow-shadow/index.js +1 -0
- package/dist/es2019/overflow-shadow/overflow-shadow.js +23 -0
- package/dist/es2019/selection/index.js +2 -0
- package/dist/es2019/selection/types.js +13 -0
- package/dist/es2019/selection/utils.js +61 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/consts/consts.js +162 -0
- package/dist/esm/consts/consts.test.js +22 -0
- package/dist/esm/consts/index.js +1 -0
- package/dist/esm/consts/types.js +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/overflow-shadow/index.js +1 -0
- package/dist/esm/overflow-shadow/overflow-shadow.js +10 -0
- package/dist/esm/selection/index.js +2 -0
- package/dist/esm/selection/types.js +13 -0
- package/dist/esm/selection/utils.js +38 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/consts/consts.d.ts +124 -0
- package/dist/types/consts/index.d.ts +2 -0
- package/dist/types/consts/types.d.ts +3 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/overflow-shadow/index.d.ts +1 -0
- package/dist/types/overflow-shadow/overflow-shadow.d.ts +5 -0
- package/dist/types/selection/index.d.ts +2 -0
- package/dist/types/selection/types.d.ts +11 -0
- package/dist/types/selection/utils.d.ts +13 -0
- package/package.json +46 -0
- package/selection/package.json +7 -0
- package/src/consts/consts.test.ts +21 -0
- package/src/consts/consts.ts +204 -0
- package/src/consts/index.ts +92 -0
- package/src/consts/types.ts +3 -0
- package/src/index.ts +99 -0
- package/src/overflow-shadow/index.ts +1 -0
- package/src/overflow-shadow/overflow-shadow.ts +29 -0
- package/src/selection/__tests__/unit/utils.ts +43 -0
- package/src/selection/index.ts +5 -0
- package/src/selection/types.ts +11 -0
- package/src/selection/utils.ts +71 -0
- 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,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
|
+
};
|