@atlaskit/editor-plugin-text-color 12.3.19 → 12.3.20
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 +8 -0
- package/dist/cjs/pm-plugins/utils/color.js +5 -13
- package/dist/cjs/ui/ColorAccessibilityMenuItem.js +3 -3
- package/dist/es2019/pm-plugins/utils/color.js +5 -13
- package/dist/es2019/ui/ColorAccessibilityMenuItem.js +1 -1
- package/dist/esm/pm-plugins/utils/color.js +5 -13
- package/dist/esm/ui/ColorAccessibilityMenuItem.js +1 -1
- package/dist/types/pm-plugins/utils/color.d.ts +2 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 12.3.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1a6b32ef3760e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1a6b32ef3760e) -
|
|
8
|
+
Treat default text and highlight colors as mixed selection colors
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 12.3.19
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -52,15 +52,8 @@ var getActiveColor = exports.getActiveColor = function getActiveColor(state) {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Returns true
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* This is deliberately narrower than `getActiveColor() === null`: `getActiveColor`
|
|
59
|
-
* also returns `null` for a mixed selection where a single colored region sits
|
|
60
|
-
* alongside uncolored text (`marksWithColor.length === 1 && marks.length > 1`).
|
|
61
|
-
* That mixed case is not a multi-color selection and must not trigger the
|
|
62
|
-
* expensive worst-status selection walk, so we key the `isMultiTextColor` flag
|
|
63
|
-
* off this predicate instead.
|
|
55
|
+
* Returns true when the selection contains two or more distinct text colors,
|
|
56
|
+
* counting unmarked text as the default color.
|
|
64
57
|
*/
|
|
65
58
|
var isMultiTextColorSelection = exports.isMultiTextColorSelection = function isMultiTextColorSelection(state) {
|
|
66
59
|
var selection = state.selection,
|
|
@@ -71,11 +64,10 @@ var isMultiTextColorSelection = exports.isMultiTextColorSelection = function isM
|
|
|
71
64
|
var textColor = doc.type.schema.marks.textColor;
|
|
72
65
|
var colors = new Set();
|
|
73
66
|
doc.nodesBetween(selection.from, selection.to, function (node) {
|
|
74
|
-
if (node.
|
|
67
|
+
if (node.isText) {
|
|
68
|
+
var _mark$attrs$color;
|
|
75
69
|
var mark = textColor.isInSet(node.marks);
|
|
76
|
-
|
|
77
|
-
colors.add(mark.attrs.color);
|
|
78
|
-
}
|
|
70
|
+
colors.add((_mark$attrs$color = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color !== void 0 ? _mark$attrs$color : _constants.DEFAULT_COLOR.color);
|
|
79
71
|
}
|
|
80
72
|
});
|
|
81
73
|
return colors.size > 1;
|
|
@@ -20,7 +20,7 @@ var _accessibility = _interopRequireDefault(require("@atlaskit/icon/core/accessi
|
|
|
20
20
|
var _questionCircle = _interopRequireDefault(require("@atlaskit/icon/core/question-circle"));
|
|
21
21
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
22
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
23
|
-
var
|
|
23
|
+
var _getTokenValue = require("@atlaskit/tokens/get-token-value");
|
|
24
24
|
var _colorContrast = require("../pm-plugins/utils/color-contrast");
|
|
25
25
|
var _constants = require("../pm-plugins/utils/constants");
|
|
26
26
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
@@ -31,14 +31,14 @@ var resolveColorValue = function resolveColorValue(color, fallback) {
|
|
|
31
31
|
};
|
|
32
32
|
var getForegroundColor = function getForegroundColor(textColor, defaultColor) {
|
|
33
33
|
if (!textColor || defaultColor && textColor === defaultColor) {
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, _getTokenValue.getTokenValue)('color.text', defaultColor || _constants.DEFAULT_COLOR.color);
|
|
35
35
|
}
|
|
36
36
|
var colorValue = (0, _editorPalette.hexToEditorTextPaletteColor)(textColor) || textColor;
|
|
37
37
|
return resolveColorValue(colorValue, textColor);
|
|
38
38
|
};
|
|
39
39
|
var getBackgroundColor = function getBackgroundColor(highlightColor) {
|
|
40
40
|
if (!highlightColor || highlightColor === _constants.TRANSPARENT_HIGHLIGHT_COLOR) {
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, _getTokenValue.getTokenValue)('elevation.surface', _constants.DEFAULT_BACKGROUND_COLOR);
|
|
42
42
|
}
|
|
43
43
|
var colorValue = (0, _editorPalette.hexToEditorTextBackgroundPaletteColor)(highlightColor) || highlightColor;
|
|
44
44
|
return resolveColorValue(colorValue, highlightColor);
|
|
@@ -47,15 +47,8 @@ export const getActiveColor = state => {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Returns true
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* This is deliberately narrower than `getActiveColor() === null`: `getActiveColor`
|
|
54
|
-
* also returns `null` for a mixed selection where a single colored region sits
|
|
55
|
-
* alongside uncolored text (`marksWithColor.length === 1 && marks.length > 1`).
|
|
56
|
-
* That mixed case is not a multi-color selection and must not trigger the
|
|
57
|
-
* expensive worst-status selection walk, so we key the `isMultiTextColor` flag
|
|
58
|
-
* off this predicate instead.
|
|
50
|
+
* Returns true when the selection contains two or more distinct text colors,
|
|
51
|
+
* counting unmarked text as the default color.
|
|
59
52
|
*/
|
|
60
53
|
export const isMultiTextColorSelection = state => {
|
|
61
54
|
const {
|
|
@@ -70,11 +63,10 @@ export const isMultiTextColorSelection = state => {
|
|
|
70
63
|
} = doc.type.schema.marks;
|
|
71
64
|
const colors = new Set();
|
|
72
65
|
doc.nodesBetween(selection.from, selection.to, node => {
|
|
73
|
-
if (node.
|
|
66
|
+
if (node.isText) {
|
|
67
|
+
var _mark$attrs$color;
|
|
74
68
|
const mark = textColor.isInSet(node.marks);
|
|
75
|
-
|
|
76
|
-
colors.add(mark.attrs.color);
|
|
77
|
-
}
|
|
69
|
+
colors.add((_mark$attrs$color = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color !== void 0 ? _mark$attrs$color : DEFAULT_COLOR.color);
|
|
78
70
|
}
|
|
79
71
|
});
|
|
80
72
|
return colors.size > 1;
|
|
@@ -13,7 +13,7 @@ import AccessibilityIcon from '@atlaskit/icon/core/accessibility';
|
|
|
13
13
|
import QuestionCircleIcon from '@atlaskit/icon/core/question-circle';
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
|
|
16
|
-
import { getTokenValue } from '@atlaskit/tokens';
|
|
16
|
+
import { getTokenValue } from '@atlaskit/tokens/get-token-value';
|
|
17
17
|
import { getContrastRatio as calcContrastRatio } from '../pm-plugins/utils/color-contrast';
|
|
18
18
|
import { DEFAULT_COLOR, DEFAULT_BACKGROUND_COLOR, TRANSPARENT_HIGHLIGHT_COLOR, ACCESSIBLE_CONTRAST_RATIO, DIFFICULT_CONTRAST_RATIO } from '../pm-plugins/utils/constants';
|
|
19
19
|
const resolveColorValue = (color, fallback) => {
|
|
@@ -47,15 +47,8 @@ export var getActiveColor = function getActiveColor(state) {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Returns true
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* This is deliberately narrower than `getActiveColor() === null`: `getActiveColor`
|
|
54
|
-
* also returns `null` for a mixed selection where a single colored region sits
|
|
55
|
-
* alongside uncolored text (`marksWithColor.length === 1 && marks.length > 1`).
|
|
56
|
-
* That mixed case is not a multi-color selection and must not trigger the
|
|
57
|
-
* expensive worst-status selection walk, so we key the `isMultiTextColor` flag
|
|
58
|
-
* off this predicate instead.
|
|
50
|
+
* Returns true when the selection contains two or more distinct text colors,
|
|
51
|
+
* counting unmarked text as the default color.
|
|
59
52
|
*/
|
|
60
53
|
export var isMultiTextColorSelection = function isMultiTextColorSelection(state) {
|
|
61
54
|
var selection = state.selection,
|
|
@@ -66,11 +59,10 @@ export var isMultiTextColorSelection = function isMultiTextColorSelection(state)
|
|
|
66
59
|
var textColor = doc.type.schema.marks.textColor;
|
|
67
60
|
var colors = new Set();
|
|
68
61
|
doc.nodesBetween(selection.from, selection.to, function (node) {
|
|
69
|
-
if (node.
|
|
62
|
+
if (node.isText) {
|
|
63
|
+
var _mark$attrs$color;
|
|
70
64
|
var mark = textColor.isInSet(node.marks);
|
|
71
|
-
|
|
72
|
-
colors.add(mark.attrs.color);
|
|
73
|
-
}
|
|
65
|
+
colors.add((_mark$attrs$color = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color !== void 0 ? _mark$attrs$color : DEFAULT_COLOR.color);
|
|
74
66
|
}
|
|
75
67
|
});
|
|
76
68
|
return colors.size > 1;
|
|
@@ -16,7 +16,7 @@ import AccessibilityIcon from '@atlaskit/icon/core/accessibility';
|
|
|
16
16
|
import QuestionCircleIcon from '@atlaskit/icon/core/question-circle';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
18
|
import { Box, Inline, Text } from '@atlaskit/primitives/compiled';
|
|
19
|
-
import { getTokenValue } from '@atlaskit/tokens';
|
|
19
|
+
import { getTokenValue } from '@atlaskit/tokens/get-token-value';
|
|
20
20
|
import { getContrastRatio as calcContrastRatio } from '../pm-plugins/utils/color-contrast';
|
|
21
21
|
import { DEFAULT_COLOR, DEFAULT_BACKGROUND_COLOR, TRANSPARENT_HIGHLIGHT_COLOR, ACCESSIBLE_CONTRAST_RATIO, DIFFICULT_CONTRAST_RATIO } from '../pm-plugins/utils/constants';
|
|
22
22
|
var resolveColorValue = function resolveColorValue(color, fallback) {
|
|
@@ -4,15 +4,8 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const getActiveColor: (state: EditorState) => string | null;
|
|
6
6
|
/**
|
|
7
|
-
* Returns true
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* This is deliberately narrower than `getActiveColor() === null`: `getActiveColor`
|
|
11
|
-
* also returns `null` for a mixed selection where a single colored region sits
|
|
12
|
-
* alongside uncolored text (`marksWithColor.length === 1 && marks.length > 1`).
|
|
13
|
-
* That mixed case is not a multi-color selection and must not trigger the
|
|
14
|
-
* expensive worst-status selection walk, so we key the `isMultiTextColor` flag
|
|
15
|
-
* off this predicate instead.
|
|
7
|
+
* Returns true when the selection contains two or more distinct text colors,
|
|
8
|
+
* counting unmarked text as the default color.
|
|
16
9
|
*/
|
|
17
10
|
export declare const isMultiTextColorSelection: (state: EditorState) => boolean;
|
|
18
11
|
export declare const getActiveColorNew: (tr: Transaction) => string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.20",
|
|
4
4
|
"description": "Text color plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags-react": "^1.1.0",
|
|
43
43
|
"@atlaskit/primitives": "^20.6.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^124.
|
|
45
|
-
"@atlaskit/tokens": "^15.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^124.9.0",
|
|
45
|
+
"@atlaskit/tokens": "^15.8.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@emotion/react": "^11.7.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^116.
|
|
50
|
+
"@atlaskit/editor-common": "^116.30.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-dom": "^18.2.0",
|
|
53
53
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|