@atlaskit/editor-plugin-highlight 12.1.36 → 12.1.38
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 +14 -0
- package/dist/cjs/editor-commands/color.js +1 -23
- package/dist/cjs/highlightPlugin.js +1 -3
- package/dist/cjs/pm-plugins/main.js +4 -34
- package/dist/es2019/editor-commands/color.js +0 -25
- package/dist/es2019/highlightPlugin.js +1 -3
- package/dist/es2019/pm-plugins/main.js +5 -39
- package/dist/esm/editor-commands/color.js +0 -22
- package/dist/esm/highlightPlugin.js +1 -3
- package/dist/esm/pm-plugins/main.js +5 -35
- package/dist/types/editor-commands/color.d.ts +1 -6
- package/dist/types/pm-plugins/main.d.ts +1 -11
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-highlight
|
|
2
2
|
|
|
3
|
+
## 12.1.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 12.1.37
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`e74b3e9fc5c95`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e74b3e9fc5c95) -
|
|
14
|
+
Account for container backgrounds in text color contrast warnings
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 12.1.36
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
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");
|
|
@@ -109,26 +109,4 @@ var getActiveColor = exports.getActiveColor = function getActiveColor(tr) {
|
|
|
109
109
|
color = getColorFromRange(selection.from, selection.to, tr);
|
|
110
110
|
}
|
|
111
111
|
return color;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Returns true when the selection contains two or more distinct highlight colors,
|
|
116
|
-
* counting unmarked text as the default transparent highlight.
|
|
117
|
-
*/
|
|
118
|
-
var isMultiHighlightColorSelection = exports.isMultiHighlightColorSelection = function isMultiHighlightColorSelection(_ref) {
|
|
119
|
-
var selection = _ref.selection,
|
|
120
|
-
doc = _ref.doc;
|
|
121
|
-
if (!(selection instanceof _state.TextSelection)) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
var backgroundColor = doc.type.schema.marks.backgroundColor;
|
|
125
|
-
var colors = new Set();
|
|
126
|
-
doc.nodesBetween(selection.from, selection.to, function (node) {
|
|
127
|
-
if (node.isText) {
|
|
128
|
-
var _mark$attrs$color2;
|
|
129
|
-
var mark = backgroundColor.isInSet(node.marks);
|
|
130
|
-
colors.add((_mark$attrs$color2 = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color2 !== void 0 ? _mark$attrs$color2 : 'default');
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return colors.size > 1;
|
|
134
112
|
};
|
|
@@ -79,9 +79,7 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
79
79
|
var plugins = [{
|
|
80
80
|
name: 'highlight',
|
|
81
81
|
plugin: function plugin() {
|
|
82
|
-
return (0, _main.createPlugin)(
|
|
83
|
-
api: api
|
|
84
|
-
});
|
|
82
|
+
return (0, _main.createPlugin)();
|
|
85
83
|
}
|
|
86
84
|
}, {
|
|
87
85
|
name: 'highlightKeymap',
|
|
@@ -7,10 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.highlightPluginKey = exports.createPlugin = exports.HighlightPluginAction = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
-
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
11
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
14
11
|
var _color = require("../editor-commands/color");
|
|
15
12
|
var _disabled = require("../editor-commands/disabled");
|
|
16
13
|
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; }
|
|
@@ -21,37 +18,16 @@ var HighlightPluginAction = exports.HighlightPluginAction = /*#__PURE__*/functio
|
|
|
21
18
|
HighlightPluginAction[HighlightPluginAction["SET_PALETTE"] = 1] = "SET_PALETTE";
|
|
22
19
|
return HighlightPluginAction;
|
|
23
20
|
}({});
|
|
24
|
-
var
|
|
25
|
-
var getActiveColorInNonActiveTheme = function getActiveColorInNonActiveTheme(color) {
|
|
26
|
-
return (0, _uiColor.getHighlightColorInNonActiveTheme)(color, {
|
|
27
|
-
defaultBackgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var getColorAccessibilityState = function getColorAccessibilityState(activeColor, tr) {
|
|
31
|
-
var isMultiHighlightColor = activeColor === _color.MULTIPLE_HIGHLIGHT_COLORS_SELECTED || (0, _color.isMultiHighlightColorSelection)(tr);
|
|
32
|
-
return {
|
|
33
|
-
// When the selection spans multiple highlight colors, `activeColor` is the
|
|
34
|
-
// `MULTIPLE_HIGHLIGHT_COLORS_SELECTED` sentinel rather than a real hex value.
|
|
35
|
-
// Passing it through would resolve the literal sentinel as a color, so fall
|
|
36
|
-
// back to the neutral default instead.
|
|
37
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(isMultiHighlightColor ? null : activeColor),
|
|
38
|
-
isMultiHighlightColor: isMultiHighlightColor
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
42
|
-
var api = _ref.api;
|
|
21
|
+
var createPlugin = exports.createPlugin = function createPlugin() {
|
|
43
22
|
return new _safePlugin.SafePlugin({
|
|
44
23
|
key: highlightPluginKey,
|
|
45
24
|
state: {
|
|
46
25
|
init: function init(_, editorState) {
|
|
47
|
-
return
|
|
26
|
+
return {
|
|
48
27
|
activeColor: null,
|
|
49
28
|
disabled: (0, _disabled.getDisabledState)(editorState),
|
|
50
29
|
isPaletteOpen: false
|
|
51
|
-
}
|
|
52
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null),
|
|
53
|
-
isMultiHighlightColor: (0, _color.isMultiHighlightColorSelection)(editorState)
|
|
54
|
-
});
|
|
30
|
+
};
|
|
55
31
|
},
|
|
56
32
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
57
33
|
var _tr$getMeta;
|
|
@@ -62,9 +38,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
62
38
|
color = _tr$getMeta2.color;
|
|
63
39
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
64
40
|
activeColor: color
|
|
65
|
-
}, (0, _platformFeatureFlags.fg)('platform_editor_lovability_text_bg_color_patch_1') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
66
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color),
|
|
67
|
-
isMultiHighlightColor: false
|
|
68
41
|
});
|
|
69
42
|
case HighlightPluginAction.SET_PALETTE:
|
|
70
43
|
var _tr$getMeta3 = tr.getMeta(highlightPluginKey),
|
|
@@ -74,13 +47,10 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
74
47
|
});
|
|
75
48
|
default:
|
|
76
49
|
var activeColor = (0, _color.getActiveColor)(tr);
|
|
77
|
-
var colorAccessibilityState =
|
|
78
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
79
|
-
(0, _platformFeatureFlags.fg)('platform_editor_lovability_text_bg_color_patch_1') && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_lovability_text_bg_color', 'isEnabled', true) && (activeColor !== pluginState.activeColor || tr.selectionSet || !tr.selection.empty && tr.docChanged) ? getColorAccessibilityState(activeColor, tr) : {};
|
|
80
50
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
81
51
|
activeColor: activeColor,
|
|
82
52
|
disabled: (0, _disabled.getDisabledState)(newState)
|
|
83
|
-
}
|
|
53
|
+
});
|
|
84
54
|
}
|
|
85
55
|
}
|
|
86
56
|
}
|
|
@@ -108,29 +108,4 @@ export const getActiveColor = tr => {
|
|
|
108
108
|
color = getColorFromRange(selection.from, selection.to, tr);
|
|
109
109
|
}
|
|
110
110
|
return color;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Returns true when the selection contains two or more distinct highlight colors,
|
|
115
|
-
* counting unmarked text as the default transparent highlight.
|
|
116
|
-
*/
|
|
117
|
-
export const isMultiHighlightColorSelection = ({
|
|
118
|
-
selection,
|
|
119
|
-
doc
|
|
120
|
-
}) => {
|
|
121
|
-
if (!(selection instanceof TextSelection)) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
const {
|
|
125
|
-
backgroundColor
|
|
126
|
-
} = doc.type.schema.marks;
|
|
127
|
-
const colors = new Set();
|
|
128
|
-
doc.nodesBetween(selection.from, selection.to, node => {
|
|
129
|
-
if (node.isText) {
|
|
130
|
-
var _mark$attrs$color2;
|
|
131
|
-
const mark = backgroundColor.isInSet(node.marks);
|
|
132
|
-
colors.add((_mark$attrs$color2 = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color2 !== void 0 ? _mark$attrs$color2 : 'default');
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
return colors.size > 1;
|
|
136
111
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { getHighlightColorInNonActiveTheme } from '@atlaskit/editor-common/ui-color';
|
|
3
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import {
|
|
5
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
6
|
-
import { getActiveColor, isMultiHighlightColorSelection, MULTIPLE_HIGHLIGHT_COLORS_SELECTED } from '../editor-commands/color';
|
|
3
|
+
import { getActiveColor } from '../editor-commands/color';
|
|
7
4
|
import { getDisabledState } from '../editor-commands/disabled';
|
|
8
5
|
export const highlightPluginKey = new PluginKey('highlight');
|
|
9
6
|
export let HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
@@ -11,36 +8,14 @@ export let HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction)
|
|
|
11
8
|
HighlightPluginAction[HighlightPluginAction["SET_PALETTE"] = 1] = "SET_PALETTE";
|
|
12
9
|
return HighlightPluginAction;
|
|
13
10
|
}({});
|
|
14
|
-
const
|
|
15
|
-
const getActiveColorInNonActiveTheme = color => getHighlightColorInNonActiveTheme(color, {
|
|
16
|
-
defaultBackgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
17
|
-
});
|
|
18
|
-
const getColorAccessibilityState = (activeColor, tr) => {
|
|
19
|
-
const isMultiHighlightColor = activeColor === MULTIPLE_HIGHLIGHT_COLORS_SELECTED || isMultiHighlightColorSelection(tr);
|
|
20
|
-
return {
|
|
21
|
-
// When the selection spans multiple highlight colors, `activeColor` is the
|
|
22
|
-
// `MULTIPLE_HIGHLIGHT_COLORS_SELECTED` sentinel rather than a real hex value.
|
|
23
|
-
// Passing it through would resolve the literal sentinel as a color, so fall
|
|
24
|
-
// back to the neutral default instead.
|
|
25
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(isMultiHighlightColor ? null : activeColor),
|
|
26
|
-
isMultiHighlightColor
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export const createPlugin = ({
|
|
30
|
-
api
|
|
31
|
-
}) => {
|
|
11
|
+
export const createPlugin = () => {
|
|
32
12
|
return new SafePlugin({
|
|
33
13
|
key: highlightPluginKey,
|
|
34
14
|
state: {
|
|
35
15
|
init: (_, editorState) => ({
|
|
36
16
|
activeColor: null,
|
|
37
17
|
disabled: getDisabledState(editorState),
|
|
38
|
-
isPaletteOpen: false
|
|
39
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
40
|
-
...(fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
41
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null),
|
|
42
|
-
isMultiHighlightColor: isMultiHighlightColorSelection(editorState)
|
|
43
|
-
})
|
|
18
|
+
isPaletteOpen: false
|
|
44
19
|
}),
|
|
45
20
|
apply: (tr, pluginState, _oldState, newState) => {
|
|
46
21
|
var _tr$getMeta;
|
|
@@ -52,12 +27,7 @@ export const createPlugin = ({
|
|
|
52
27
|
} = tr.getMeta(highlightPluginKey);
|
|
53
28
|
return {
|
|
54
29
|
...pluginState,
|
|
55
|
-
activeColor: color
|
|
56
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
57
|
-
...(fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
58
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color),
|
|
59
|
-
isMultiHighlightColor: false
|
|
60
|
-
})
|
|
30
|
+
activeColor: color
|
|
61
31
|
};
|
|
62
32
|
case HighlightPluginAction.SET_PALETTE:
|
|
63
33
|
const {
|
|
@@ -69,14 +39,10 @@ export const createPlugin = ({
|
|
|
69
39
|
};
|
|
70
40
|
default:
|
|
71
41
|
const activeColor = getActiveColor(tr);
|
|
72
|
-
const colorAccessibilityState =
|
|
73
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
74
|
-
fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && (activeColor !== pluginState.activeColor || tr.selectionSet || !tr.selection.empty && tr.docChanged) ? getColorAccessibilityState(activeColor, tr) : {};
|
|
75
42
|
return {
|
|
76
43
|
...pluginState,
|
|
77
44
|
activeColor,
|
|
78
|
-
disabled: getDisabledState(newState)
|
|
79
|
-
...colorAccessibilityState
|
|
45
|
+
disabled: getDisabledState(newState)
|
|
80
46
|
};
|
|
81
47
|
}
|
|
82
48
|
}
|
|
@@ -103,26 +103,4 @@ export var getActiveColor = function getActiveColor(tr) {
|
|
|
103
103
|
color = getColorFromRange(selection.from, selection.to, tr);
|
|
104
104
|
}
|
|
105
105
|
return color;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Returns true when the selection contains two or more distinct highlight colors,
|
|
110
|
-
* counting unmarked text as the default transparent highlight.
|
|
111
|
-
*/
|
|
112
|
-
export var isMultiHighlightColorSelection = function isMultiHighlightColorSelection(_ref) {
|
|
113
|
-
var selection = _ref.selection,
|
|
114
|
-
doc = _ref.doc;
|
|
115
|
-
if (!(selection instanceof TextSelection)) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
var backgroundColor = doc.type.schema.marks.backgroundColor;
|
|
119
|
-
var colors = new Set();
|
|
120
|
-
doc.nodesBetween(selection.from, selection.to, function (node) {
|
|
121
|
-
if (node.isText) {
|
|
122
|
-
var _mark$attrs$color2;
|
|
123
|
-
var mark = backgroundColor.isInSet(node.marks);
|
|
124
|
-
colors.add((_mark$attrs$color2 = mark === null || mark === void 0 ? void 0 : mark.attrs.color) !== null && _mark$attrs$color2 !== void 0 ? _mark$attrs$color2 : 'default');
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return colors.size > 1;
|
|
128
106
|
};
|
|
@@ -2,11 +2,8 @@ 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 { getHighlightColorInNonActiveTheme } from '@atlaskit/editor-common/ui-color';
|
|
6
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import {
|
|
8
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
9
|
-
import { getActiveColor, isMultiHighlightColorSelection, MULTIPLE_HIGHLIGHT_COLORS_SELECTED } from '../editor-commands/color';
|
|
6
|
+
import { getActiveColor } from '../editor-commands/color';
|
|
10
7
|
import { getDisabledState } from '../editor-commands/disabled';
|
|
11
8
|
export var highlightPluginKey = new PluginKey('highlight');
|
|
12
9
|
export var HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
@@ -14,37 +11,16 @@ export var HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction)
|
|
|
14
11
|
HighlightPluginAction[HighlightPluginAction["SET_PALETTE"] = 1] = "SET_PALETTE";
|
|
15
12
|
return HighlightPluginAction;
|
|
16
13
|
}({});
|
|
17
|
-
var
|
|
18
|
-
var getActiveColorInNonActiveTheme = function getActiveColorInNonActiveTheme(color) {
|
|
19
|
-
return getHighlightColorInNonActiveTheme(color, {
|
|
20
|
-
defaultBackgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var getColorAccessibilityState = function getColorAccessibilityState(activeColor, tr) {
|
|
24
|
-
var isMultiHighlightColor = activeColor === MULTIPLE_HIGHLIGHT_COLORS_SELECTED || isMultiHighlightColorSelection(tr);
|
|
25
|
-
return {
|
|
26
|
-
// When the selection spans multiple highlight colors, `activeColor` is the
|
|
27
|
-
// `MULTIPLE_HIGHLIGHT_COLORS_SELECTED` sentinel rather than a real hex value.
|
|
28
|
-
// Passing it through would resolve the literal sentinel as a color, so fall
|
|
29
|
-
// back to the neutral default instead.
|
|
30
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(isMultiHighlightColor ? null : activeColor),
|
|
31
|
-
isMultiHighlightColor: isMultiHighlightColor
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
export var createPlugin = function createPlugin(_ref) {
|
|
35
|
-
var api = _ref.api;
|
|
14
|
+
export var createPlugin = function createPlugin() {
|
|
36
15
|
return new SafePlugin({
|
|
37
16
|
key: highlightPluginKey,
|
|
38
17
|
state: {
|
|
39
18
|
init: function init(_, editorState) {
|
|
40
|
-
return
|
|
19
|
+
return {
|
|
41
20
|
activeColor: null,
|
|
42
21
|
disabled: getDisabledState(editorState),
|
|
43
22
|
isPaletteOpen: false
|
|
44
|
-
}
|
|
45
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(null),
|
|
46
|
-
isMultiHighlightColor: isMultiHighlightColorSelection(editorState)
|
|
47
|
-
});
|
|
23
|
+
};
|
|
48
24
|
},
|
|
49
25
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
50
26
|
var _tr$getMeta;
|
|
@@ -55,9 +31,6 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
55
31
|
color = _tr$getMeta2.color;
|
|
56
32
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
57
33
|
activeColor: color
|
|
58
|
-
}, fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && {
|
|
59
|
-
activeColorInNonActiveTheme: getActiveColorInNonActiveTheme(color),
|
|
60
|
-
isMultiHighlightColor: false
|
|
61
34
|
});
|
|
62
35
|
case HighlightPluginAction.SET_PALETTE:
|
|
63
36
|
var _tr$getMeta3 = tr.getMeta(highlightPluginKey),
|
|
@@ -67,13 +40,10 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
67
40
|
});
|
|
68
41
|
default:
|
|
69
42
|
var activeColor = getActiveColor(tr);
|
|
70
|
-
var colorAccessibilityState =
|
|
71
|
-
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
72
|
-
fg('platform_editor_lovability_text_bg_color_patch_1') && expValEqualsNoExposure('platform_editor_lovability_text_bg_color', 'isEnabled', true) && (activeColor !== pluginState.activeColor || tr.selectionSet || !tr.selection.empty && tr.docChanged) ? getColorAccessibilityState(activeColor, tr) : {};
|
|
73
43
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
74
44
|
activeColor: activeColor,
|
|
75
45
|
disabled: getDisabledState(newState)
|
|
76
|
-
}
|
|
46
|
+
});
|
|
77
47
|
}
|
|
78
48
|
}
|
|
79
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
/**
|
|
3
3
|
* Value returned by `getActiveColor` when the selection spans more than one
|
|
4
4
|
* distinct highlight (background) color. Callers can compare against this to
|
|
@@ -6,8 +6,3 @@ import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/ed
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const MULTIPLE_HIGHLIGHT_COLORS_SELECTED = "multiple";
|
|
8
8
|
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string | null;
|
|
9
|
-
/**
|
|
10
|
-
* Returns true when the selection contains two or more distinct highlight colors,
|
|
11
|
-
* counting unmarked text as the default transparent highlight.
|
|
12
|
-
*/
|
|
13
|
-
export declare const isMultiHighlightColorSelection: ({ selection, doc, }: EditorState | Transaction | ReadonlyTransaction) => boolean;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { HighlightPlugin } from '../highlightPluginType';
|
|
5
3
|
export declare const highlightPluginKey: PluginKey<HighlightPluginState>;
|
|
6
4
|
export type HighlightPluginState = {
|
|
7
5
|
activeColor: string | null;
|
|
8
|
-
activeColorInNonActiveTheme?: string;
|
|
9
6
|
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;
|
|
15
7
|
isPaletteOpen: boolean;
|
|
16
8
|
};
|
|
17
9
|
export declare enum HighlightPluginAction {
|
|
18
10
|
CHANGE_COLOR = 0,
|
|
19
11
|
SET_PALETTE = 1
|
|
20
12
|
}
|
|
21
|
-
export declare const createPlugin: (
|
|
22
|
-
api: ExtractInjectionAPI<HighlightPlugin> | undefined;
|
|
23
|
-
}) => SafePlugin<HighlightPluginState>;
|
|
13
|
+
export declare const createPlugin: () => SafePlugin<HighlightPluginState>;
|
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.38",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"@atlaskit/editor-toolbar-model": "^1.1.0",
|
|
40
40
|
"@atlaskit/heading": "^6.2.0",
|
|
41
41
|
"@atlaskit/icon": "^37.1.0",
|
|
42
|
-
"@atlaskit/platform-feature-flags": "^2.
|
|
43
|
-
"@atlaskit/primitives": "^22.
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
-
"@atlaskit/tokens": "^16.
|
|
42
|
+
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
43
|
+
"@atlaskit/primitives": "^22.1.0",
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^131.0.0",
|
|
45
|
+
"@atlaskit/tokens": "^16.2.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.35.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
53
53
|
},
|