@atlaskit/editor-plugin-highlight 12.1.23 → 12.1.24
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 +9 -0
- package/dist/cjs/editor-commands/color.js +9 -3
- package/dist/cjs/pm-plugins/main.js +14 -9
- package/dist/es2019/editor-commands/color.js +9 -2
- package/dist/es2019/pm-plugins/main.js +16 -13
- package/dist/esm/editor-commands/color.js +9 -2
- package/dist/esm/pm-plugins/main.js +16 -11
- package/dist/types/editor-commands/color.d.ts +6 -0
- package/dist/types/pm-plugins/main.d.ts +5 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-highlight
|
|
2
2
|
|
|
3
|
+
## 12.1.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4821d5874a821`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4821d5874a821) -
|
|
8
|
+
EDITOR-7869: Show worst accessibility status when selection spans multiple text or highlight
|
|
9
|
+
colors
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 12.1.23
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -4,11 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getActiveColor = void 0;
|
|
7
|
+
exports.getActiveColor = exports.MULTIPLE_HIGHLIGHT_COLORS_SELECTED = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _mark = require("@atlaskit/editor-common/mark");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
12
|
+
/**
|
|
13
|
+
* Value returned by `getActiveColor` when the selection spans more than one
|
|
14
|
+
* distinct highlight (background) color. Callers can compare against this to
|
|
15
|
+
* detect a multi-color selection.
|
|
16
|
+
*/
|
|
17
|
+
var MULTIPLE_HIGHLIGHT_COLORS_SELECTED = exports.MULTIPLE_HIGHLIGHT_COLORS_SELECTED = 'multiple';
|
|
12
18
|
var getAllUniqueBackgroundColorMarksInRange = function getAllUniqueBackgroundColorMarksInRange(from, to, tr) {
|
|
13
19
|
var doc = tr.doc;
|
|
14
20
|
var backgroundColor = doc.type.schema.marks.backgroundColor;
|
|
@@ -48,7 +54,7 @@ var getAllUniqueBackgroundColorMarksInCellSelection = function getAllUniqueBackg
|
|
|
48
54
|
var getColorFromCellSelection = function getColorFromCellSelection(selection, tr) {
|
|
49
55
|
var marks = getAllUniqueBackgroundColorMarksInCellSelection(selection, tr);
|
|
50
56
|
if (marks.length > 1) {
|
|
51
|
-
return
|
|
57
|
+
return MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
52
58
|
}
|
|
53
59
|
var firstColorMark = marks.at(0);
|
|
54
60
|
if (!firstColorMark) {
|
|
@@ -74,7 +80,7 @@ var getColorFromCellSelection = function getColorFromCellSelection(selection, tr
|
|
|
74
80
|
var getColorFromRange = function getColorFromRange(from, to, tr) {
|
|
75
81
|
var marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
76
82
|
if (marks.length > 1) {
|
|
77
|
-
return
|
|
83
|
+
return MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
78
84
|
}
|
|
79
85
|
var firstColorMark = marks.at(0);
|
|
80
86
|
if (firstColorMark && (0, _mark.entireSelectionContainsMark)(firstColorMark, tr.doc, from, to)) {
|
|
@@ -8,7 +8,6 @@ exports.highlightPluginKey = exports.createPlugin = exports.HighlightPluginActio
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
11
|
-
var _textBackgroundColor = require("@atlaskit/editor-palette/text-background-color");
|
|
12
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
13
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
@@ -24,11 +23,9 @@ var HighlightPluginAction = exports.HighlightPluginAction = /*#__PURE__*/functio
|
|
|
24
23
|
}({});
|
|
25
24
|
var DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
|
|
26
25
|
var getActiveColorInNonActiveTheme = function getActiveColorInNonActiveTheme(color) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
var colorValue = (0, _textBackgroundColor.hexToEditorTextBackgroundPaletteColor)(color) || color;
|
|
31
|
-
return (0, _uiColor.getTokenCSSVariableValueForNonActiveTheme)(colorValue, color);
|
|
26
|
+
return (0, _uiColor.getHighlightColorInNonActiveTheme)(color, {
|
|
27
|
+
defaultBackgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
28
|
+
});
|
|
32
29
|
};
|
|
33
30
|
var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
34
31
|
var api = _ref.api;
|
|
@@ -41,7 +38,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
41
38
|
disabled: (0, _disabled.getDisabledState)(editorState),
|
|
42
39
|
isPaletteOpen: false
|
|
43
40
|
}, (0, _platformFeatureFlags.fg)('platform_editor_lovability_text_bg_color_patch_1') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
44
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null)
|
|
41
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null),
|
|
42
|
+
isMultiHighlightColor: false
|
|
45
43
|
});
|
|
46
44
|
},
|
|
47
45
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
@@ -54,7 +52,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
54
52
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
55
53
|
activeColor: color
|
|
56
54
|
}, (0, _platformFeatureFlags.fg)('platform_editor_lovability_text_bg_color_patch_1') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
57
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color)
|
|
55
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color),
|
|
56
|
+
isMultiHighlightColor: false
|
|
58
57
|
});
|
|
59
58
|
case HighlightPluginAction.SET_PALETTE:
|
|
60
59
|
var _tr$getMeta3 = tr.getMeta(highlightPluginKey),
|
|
@@ -64,11 +63,17 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
64
63
|
});
|
|
65
64
|
default:
|
|
66
65
|
var activeColor = (0, _color.getActiveColor)(tr);
|
|
66
|
+
var isMultiHighlightColor = activeColor === _color.MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
67
67
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
68
68
|
activeColor: activeColor,
|
|
69
69
|
disabled: (0, _disabled.getDisabledState)(newState)
|
|
70
70
|
}, activeColor !== pluginState.activeColor && (0, _platformFeatureFlags.fg)('platform_editor_lovability_text_bg_color_patch_1') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
71
|
-
|
|
71
|
+
// When the selection spans multiple highlight colors, `activeColor` is the
|
|
72
|
+
// `MULTIPLE_HIGHLIGHT_COLORS_SELECTED` sentinel rather than a real hex value.
|
|
73
|
+
// Passing it through would resolve the literal sentinel as a color, so fall
|
|
74
|
+
// back to the neutral default instead.
|
|
75
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(isMultiHighlightColor ? null : activeColor),
|
|
76
|
+
isMultiHighlightColor: isMultiHighlightColor
|
|
72
77
|
});
|
|
73
78
|
}
|
|
74
79
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { entireSelectionContainsMark } from '@atlaskit/editor-common/mark';
|
|
2
2
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Value returned by `getActiveColor` when the selection spans more than one
|
|
7
|
+
* distinct highlight (background) color. Callers can compare against this to
|
|
8
|
+
* detect a multi-color selection.
|
|
9
|
+
*/
|
|
10
|
+
export const MULTIPLE_HIGHLIGHT_COLORS_SELECTED = 'multiple';
|
|
4
11
|
const getAllUniqueBackgroundColorMarksInRange = (from, to, tr) => {
|
|
5
12
|
const {
|
|
6
13
|
doc
|
|
@@ -44,7 +51,7 @@ const getAllUniqueBackgroundColorMarksInCellSelection = (selection, tr) => {
|
|
|
44
51
|
const getColorFromCellSelection = (selection, tr) => {
|
|
45
52
|
const marks = getAllUniqueBackgroundColorMarksInCellSelection(selection, tr);
|
|
46
53
|
if (marks.length > 1) {
|
|
47
|
-
return
|
|
54
|
+
return MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
48
55
|
}
|
|
49
56
|
const firstColorMark = marks.at(0);
|
|
50
57
|
if (!firstColorMark) {
|
|
@@ -70,7 +77,7 @@ const getColorFromCellSelection = (selection, tr) => {
|
|
|
70
77
|
const getColorFromRange = (from, to, tr) => {
|
|
71
78
|
const marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
72
79
|
if (marks.length > 1) {
|
|
73
|
-
return
|
|
80
|
+
return MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
74
81
|
}
|
|
75
82
|
const firstColorMark = marks.at(0);
|
|
76
83
|
if (firstColorMark && entireSelectionContainsMark(firstColorMark, tr.doc, from, to)) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import {
|
|
3
|
-
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette/text-background-color';
|
|
2
|
+
import { getHighlightColorInNonActiveTheme } from '@atlaskit/editor-common/ui-color';
|
|
4
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
|
-
import { getActiveColor } from '../editor-commands/color';
|
|
6
|
+
import { getActiveColor, MULTIPLE_HIGHLIGHT_COLORS_SELECTED } from '../editor-commands/color';
|
|
8
7
|
import { getDisabledState } from '../editor-commands/disabled';
|
|
9
8
|
export const highlightPluginKey = new PluginKey('highlight');
|
|
10
9
|
export let HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
@@ -13,13 +12,9 @@ export let HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction)
|
|
|
13
12
|
return HighlightPluginAction;
|
|
14
13
|
}({});
|
|
15
14
|
const DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
|
|
16
|
-
const getActiveColorInNonActiveTheme = color => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const colorValue = hexToEditorTextBackgroundPaletteColor(color) || color;
|
|
21
|
-
return getTokenCSSVariableValueForNonActiveTheme(colorValue, color);
|
|
22
|
-
};
|
|
15
|
+
const getActiveColorInNonActiveTheme = color => getHighlightColorInNonActiveTheme(color, {
|
|
16
|
+
defaultBackgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
17
|
+
});
|
|
23
18
|
export const createPlugin = ({
|
|
24
19
|
api
|
|
25
20
|
}) => {
|
|
@@ -32,7 +27,8 @@ export const createPlugin = ({
|
|
|
32
27
|
isPaletteOpen: false,
|
|
33
28
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
34
29
|
...(fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
35
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null)
|
|
30
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null),
|
|
31
|
+
isMultiHighlightColor: false
|
|
36
32
|
})
|
|
37
33
|
}),
|
|
38
34
|
apply: (tr, pluginState, _oldState, newState) => {
|
|
@@ -48,7 +44,8 @@ export const createPlugin = ({
|
|
|
48
44
|
activeColor: color,
|
|
49
45
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
50
46
|
...(fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
51
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color)
|
|
47
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color),
|
|
48
|
+
isMultiHighlightColor: false
|
|
52
49
|
})
|
|
53
50
|
};
|
|
54
51
|
case HighlightPluginAction.SET_PALETTE:
|
|
@@ -61,13 +58,19 @@ export const createPlugin = ({
|
|
|
61
58
|
};
|
|
62
59
|
default:
|
|
63
60
|
const activeColor = getActiveColor(tr);
|
|
61
|
+
const isMultiHighlightColor = activeColor === MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
64
62
|
return {
|
|
65
63
|
...pluginState,
|
|
66
64
|
activeColor,
|
|
67
65
|
disabled: getDisabledState(newState),
|
|
68
66
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
69
67
|
...(activeColor !== pluginState.activeColor && fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
70
|
-
|
|
68
|
+
// When the selection spans multiple highlight colors, `activeColor` is the
|
|
69
|
+
// `MULTIPLE_HIGHLIGHT_COLORS_SELECTED` sentinel rather than a real hex value.
|
|
70
|
+
// Passing it through would resolve the literal sentinel as a color, so fall
|
|
71
|
+
// back to the neutral default instead.
|
|
72
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(isMultiHighlightColor ? null : activeColor),
|
|
73
|
+
isMultiHighlightColor
|
|
71
74
|
})
|
|
72
75
|
};
|
|
73
76
|
}
|
|
@@ -2,6 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import { entireSelectionContainsMark } from '@atlaskit/editor-common/mark';
|
|
3
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Value returned by `getActiveColor` when the selection spans more than one
|
|
8
|
+
* distinct highlight (background) color. Callers can compare against this to
|
|
9
|
+
* detect a multi-color selection.
|
|
10
|
+
*/
|
|
11
|
+
export var MULTIPLE_HIGHLIGHT_COLORS_SELECTED = 'multiple';
|
|
5
12
|
var getAllUniqueBackgroundColorMarksInRange = function getAllUniqueBackgroundColorMarksInRange(from, to, tr) {
|
|
6
13
|
var doc = tr.doc;
|
|
7
14
|
var backgroundColor = doc.type.schema.marks.backgroundColor;
|
|
@@ -41,7 +48,7 @@ var getAllUniqueBackgroundColorMarksInCellSelection = function getAllUniqueBackg
|
|
|
41
48
|
var getColorFromCellSelection = function getColorFromCellSelection(selection, tr) {
|
|
42
49
|
var marks = getAllUniqueBackgroundColorMarksInCellSelection(selection, tr);
|
|
43
50
|
if (marks.length > 1) {
|
|
44
|
-
return
|
|
51
|
+
return MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
45
52
|
}
|
|
46
53
|
var firstColorMark = marks.at(0);
|
|
47
54
|
if (!firstColorMark) {
|
|
@@ -67,7 +74,7 @@ var getColorFromCellSelection = function getColorFromCellSelection(selection, tr
|
|
|
67
74
|
var getColorFromRange = function getColorFromRange(from, to, tr) {
|
|
68
75
|
var marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
69
76
|
if (marks.length > 1) {
|
|
70
|
-
return
|
|
77
|
+
return MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
71
78
|
}
|
|
72
79
|
var firstColorMark = marks.at(0);
|
|
73
80
|
if (firstColorMark && entireSelectionContainsMark(firstColorMark, tr.doc, from, to)) {
|
|
@@ -2,12 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import {
|
|
6
|
-
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette/text-background-color';
|
|
5
|
+
import { getHighlightColorInNonActiveTheme } from '@atlaskit/editor-common/ui-color';
|
|
7
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
8
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
10
|
-
import { getActiveColor } from '../editor-commands/color';
|
|
9
|
+
import { getActiveColor, MULTIPLE_HIGHLIGHT_COLORS_SELECTED } from '../editor-commands/color';
|
|
11
10
|
import { getDisabledState } from '../editor-commands/disabled';
|
|
12
11
|
export var highlightPluginKey = new PluginKey('highlight');
|
|
13
12
|
export var HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
@@ -17,11 +16,9 @@ export var HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction)
|
|
|
17
16
|
}({});
|
|
18
17
|
var DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
|
|
19
18
|
var getActiveColorInNonActiveTheme = function getActiveColorInNonActiveTheme(color) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
var colorValue = hexToEditorTextBackgroundPaletteColor(color) || color;
|
|
24
|
-
return getTokenCSSVariableValueForNonActiveTheme(colorValue, color);
|
|
19
|
+
return getHighlightColorInNonActiveTheme(color, {
|
|
20
|
+
defaultBackgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
21
|
+
});
|
|
25
22
|
};
|
|
26
23
|
export var createPlugin = function createPlugin(_ref) {
|
|
27
24
|
var api = _ref.api;
|
|
@@ -34,7 +31,8 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
34
31
|
disabled: getDisabledState(editorState),
|
|
35
32
|
isPaletteOpen: false
|
|
36
33
|
}, fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
37
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null)
|
|
34
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null),
|
|
35
|
+
isMultiHighlightColor: false
|
|
38
36
|
});
|
|
39
37
|
},
|
|
40
38
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
@@ -47,7 +45,8 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
47
45
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
48
46
|
activeColor: color
|
|
49
47
|
}, fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
50
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color)
|
|
48
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color),
|
|
49
|
+
isMultiHighlightColor: false
|
|
51
50
|
});
|
|
52
51
|
case HighlightPluginAction.SET_PALETTE:
|
|
53
52
|
var _tr$getMeta3 = tr.getMeta(highlightPluginKey),
|
|
@@ -57,11 +56,17 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
57
56
|
});
|
|
58
57
|
default:
|
|
59
58
|
var activeColor = getActiveColor(tr);
|
|
59
|
+
var isMultiHighlightColor = activeColor === MULTIPLE_HIGHLIGHT_COLORS_SELECTED;
|
|
60
60
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
61
61
|
activeColor: activeColor,
|
|
62
62
|
disabled: getDisabledState(newState)
|
|
63
63
|
}, activeColor !== pluginState.activeColor && fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
64
|
-
|
|
64
|
+
// When the selection spans multiple highlight colors, `activeColor` is the
|
|
65
|
+
// `MULTIPLE_HIGHLIGHT_COLORS_SELECTED` sentinel rather than a real hex value.
|
|
66
|
+
// Passing it through would resolve the literal sentinel as a color, so fall
|
|
67
|
+
// back to the neutral default instead.
|
|
68
|
+
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(isMultiHighlightColor ? null : activeColor),
|
|
69
|
+
isMultiHighlightColor: isMultiHighlightColor
|
|
65
70
|
});
|
|
66
71
|
}
|
|
67
72
|
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* Value returned by `getActiveColor` when the selection spans more than one
|
|
4
|
+
* distinct highlight (background) color. Callers can compare against this to
|
|
5
|
+
* detect a multi-color selection.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MULTIPLE_HIGHLIGHT_COLORS_SELECTED = "multiple";
|
|
2
8
|
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string | null;
|
|
@@ -7,6 +7,11 @@ export type HighlightPluginState = {
|
|
|
7
7
|
activeColor: string | null;
|
|
8
8
|
activeColorInNonActiveTheme?: string;
|
|
9
9
|
disabled: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* True when the current selection spans more than one highlight color. Only
|
|
12
|
+
* populated behind the lovability text/bg color patch gate + experiment.
|
|
13
|
+
*/
|
|
14
|
+
isMultiHighlightColor?: boolean;
|
|
10
15
|
isPaletteOpen: boolean;
|
|
11
16
|
};
|
|
12
17
|
export declare enum HighlightPluginAction {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-highlight",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.24",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
36
36
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
37
37
|
"@atlaskit/editor-tables": "^3.0.0",
|
|
38
|
-
"@atlaskit/editor-toolbar": "^2.
|
|
38
|
+
"@atlaskit/editor-toolbar": "^2.2.0",
|
|
39
39
|
"@atlaskit/editor-toolbar-model": "^1.1.0",
|
|
40
40
|
"@atlaskit/heading": "^6.2.0",
|
|
41
41
|
"@atlaskit/icon": "^37.0.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
43
|
-
"@atlaskit/primitives": "^20.
|
|
43
|
+
"@atlaskit/primitives": "^20.6.0",
|
|
44
44
|
"@atlaskit/tmp-editor-statsig": "^124.1.0",
|
|
45
|
-
"@atlaskit/tokens": "^15.
|
|
45
|
+
"@atlaskit/tokens": "^15.6.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.26.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
53
53
|
},
|