@atlaskit/editor-plugin-text-color 16.1.10 → 17.0.1
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 +16 -0
- package/dist/cjs/editor-commands/change-color.js +15 -5
- package/dist/cjs/pm-plugins/commands/change-color.js +15 -5
- package/dist/es2019/editor-commands/change-color.js +10 -5
- package/dist/es2019/pm-plugins/commands/change-color.js +10 -5
- package/dist/esm/editor-commands/change-color.js +14 -5
- package/dist/esm/pm-plugins/commands/change-color.js +14 -5
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 17.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 17.0.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`fb891566dfac2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fb891566dfac2) -
|
|
14
|
+
Add anyMarksActiveFromTr and getHadMarkAttributes so mark-active checks can run from a
|
|
15
|
+
transaction. Color, highlight, toolbar/Cmd+K link apply, and paste events include had-mark
|
|
16
|
+
attributes behind kill switch platform_editor_add_text_color_tracking.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 16.1.10
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.changeColor = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
9
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
13
|
var _color = require("../pm-plugins/utils/color");
|
|
11
14
|
var _removeColor = require("./remove-color");
|
|
12
15
|
var _toggleColor = require("./toggle-color");
|
|
16
|
+
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; }
|
|
17
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
13
18
|
var maybeSyncSelectionAfterFormat = function maybeSyncSelectionAfterFormat(tr) {
|
|
14
19
|
if (tr.docChanged && (0, _expValEquals.expValEquals)('platform_editor_fix_selection_text_color_change', 'isEnabled', true)) {
|
|
15
20
|
tr.setMeta(_selection.FORMAT_SELECTION_SYNC_META, true);
|
|
@@ -24,6 +29,7 @@ var maybeSyncSelectionAfterFormat = function maybeSyncSelectionAfterFormat(tr) {
|
|
|
24
29
|
* @returns Higher order command with analytics logic inside.
|
|
25
30
|
*/
|
|
26
31
|
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod) {
|
|
32
|
+
var hadMarkAttributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
27
33
|
var newColorFromPalette = palette.find(function (_ref) {
|
|
28
34
|
var value = _ref.value;
|
|
29
35
|
return value === newColor;
|
|
@@ -39,28 +45,32 @@ function createColorAnalyticsPayload(newColor, previousColor, palette, inputMeth
|
|
|
39
45
|
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
40
46
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
41
47
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
42
|
-
attributes: {
|
|
48
|
+
attributes: _objectSpread({
|
|
43
49
|
newColor: newColorLabel.toLowerCase(),
|
|
44
50
|
previousColor: previousColorLabel.toLowerCase(),
|
|
45
51
|
inputMethod: inputMethod
|
|
46
|
-
}
|
|
52
|
+
}, hadMarkAttributes)
|
|
47
53
|
};
|
|
48
54
|
}
|
|
49
55
|
var changeColor = exports.changeColor = function changeColor(color, api, inputMethod) {
|
|
50
56
|
return function (_ref3) {
|
|
51
57
|
var _api$analytics2;
|
|
52
58
|
var tr = _ref3.tr;
|
|
53
|
-
var
|
|
59
|
+
var _tr$doc$type$schema$m = tr.doc.type.schema.marks,
|
|
60
|
+
textColor = _tr$doc$type$schema$m.textColor,
|
|
61
|
+
backgroundColor = _tr$doc$type$schema$m.backgroundColor;
|
|
54
62
|
var pluginState = api === null || api === void 0 ? void 0 : api.textColor.sharedState.currentState();
|
|
55
63
|
if (!textColor || !pluginState) {
|
|
56
64
|
return tr;
|
|
57
65
|
}
|
|
58
66
|
var activeColor = (0, _color.getActiveColorNew)(tr);
|
|
59
|
-
var
|
|
67
|
+
var isRemovingColor = color === pluginState.defaultColor;
|
|
68
|
+
var hadMarkAttributes = isRemovingColor ? {} : (0, _mark.getHadMarkAttributes)(tr, [backgroundColor]);
|
|
69
|
+
var colorAnalyticsPayload = createColorAnalyticsPayload(color, activeColor, pluginState.palette, inputMethod, hadMarkAttributes);
|
|
60
70
|
if (pluginState.disabled) {
|
|
61
71
|
return tr;
|
|
62
72
|
}
|
|
63
|
-
if (
|
|
73
|
+
if (isRemovingColor) {
|
|
64
74
|
var _api$analytics;
|
|
65
75
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
66
76
|
(0, _removeColor.removeColor)({
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.changeColor = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
10
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
11
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
9
12
|
var _main = require("../main");
|
|
10
13
|
var _color = require("../utils/color");
|
|
11
14
|
var _removeColor = require("./remove-color");
|
|
12
15
|
var _toggleColor = require("./toggle-color");
|
|
16
|
+
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; }
|
|
17
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
13
18
|
/**
|
|
14
19
|
* Helper to create a higher order analytics command
|
|
15
20
|
* @param newColor - Color to be change in hex code
|
|
@@ -18,6 +23,7 @@ var _toggleColor = require("./toggle-color");
|
|
|
18
23
|
* @return Higher order command with analytics logic inside.
|
|
19
24
|
*/
|
|
20
25
|
function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyticsApi, inputMethod) {
|
|
26
|
+
var hadMarkAttributes = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
21
27
|
var newColorFromPalette = palette.find(function (_ref) {
|
|
22
28
|
var value = _ref.value;
|
|
23
29
|
return value === newColor;
|
|
@@ -33,24 +39,28 @@ function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyt
|
|
|
33
39
|
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
34
40
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
35
41
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
36
|
-
attributes: {
|
|
42
|
+
attributes: _objectSpread({
|
|
37
43
|
newColor: newColorLabel.toLowerCase(),
|
|
38
44
|
previousColor: previousColorLabel.toLowerCase(),
|
|
39
45
|
inputMethod: inputMethod
|
|
40
|
-
}
|
|
46
|
+
}, hadMarkAttributes)
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
49
|
var changeColor = exports.changeColor = function changeColor(color, editorAnalyticsApi, inputMethod) {
|
|
44
50
|
return function (state, dispatch) {
|
|
45
|
-
var
|
|
51
|
+
var _state$schema$marks = state.schema.marks,
|
|
52
|
+
textColor = _state$schema$marks.textColor,
|
|
53
|
+
backgroundColor = _state$schema$marks.backgroundColor;
|
|
46
54
|
if (textColor) {
|
|
47
55
|
var pluginState = _main.pluginKey.getState(state);
|
|
48
56
|
var activeColor = (0, _color.getActiveColor)(state);
|
|
49
|
-
var
|
|
57
|
+
var isRemovingColor = color === (pluginState === null || pluginState === void 0 ? void 0 : pluginState.defaultColor);
|
|
58
|
+
var hadMarkAttributes = isRemovingColor ? {} : (0, _mark.getHadMarkAttributes)(state.tr, [backgroundColor]);
|
|
59
|
+
var withColorAnalytics = createWithColorAnalytics(color, activeColor, (pluginState === null || pluginState === void 0 ? void 0 : pluginState.palette) || [], editorAnalyticsApi, inputMethod, hadMarkAttributes);
|
|
50
60
|
if (pluginState !== null && pluginState !== void 0 && pluginState.disabled) {
|
|
51
61
|
return false;
|
|
52
62
|
}
|
|
53
|
-
if (
|
|
63
|
+
if (isRemovingColor) {
|
|
54
64
|
withColorAnalytics((0, _removeColor.removeColor)())(state, dispatch);
|
|
55
65
|
return true;
|
|
56
66
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { getHadMarkAttributes } from '@atlaskit/editor-common/mark';
|
|
2
3
|
import { FORMAT_SELECTION_SYNC_META } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { getActiveColorNew } from '../pm-plugins/utils/color';
|
|
@@ -17,7 +18,7 @@ const maybeSyncSelectionAfterFormat = tr => {
|
|
|
17
18
|
* @param palette - Current palette of colors
|
|
18
19
|
* @returns Higher order command with analytics logic inside.
|
|
19
20
|
*/
|
|
20
|
-
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod) {
|
|
21
|
+
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod, hadMarkAttributes = {}) {
|
|
21
22
|
const newColorFromPalette = palette.find(({
|
|
22
23
|
value
|
|
23
24
|
}) => value === newColor);
|
|
@@ -34,7 +35,8 @@ function createColorAnalyticsPayload(newColor, previousColor, palette, inputMeth
|
|
|
34
35
|
attributes: {
|
|
35
36
|
newColor: newColorLabel.toLowerCase(),
|
|
36
37
|
previousColor: previousColorLabel.toLowerCase(),
|
|
37
|
-
inputMethod
|
|
38
|
+
inputMethod,
|
|
39
|
+
...hadMarkAttributes
|
|
38
40
|
}
|
|
39
41
|
};
|
|
40
42
|
}
|
|
@@ -43,18 +45,21 @@ export const changeColor = (color, api, inputMethod) => ({
|
|
|
43
45
|
}) => {
|
|
44
46
|
var _api$analytics2;
|
|
45
47
|
const {
|
|
46
|
-
textColor
|
|
48
|
+
textColor,
|
|
49
|
+
backgroundColor
|
|
47
50
|
} = tr.doc.type.schema.marks;
|
|
48
51
|
const pluginState = api === null || api === void 0 ? void 0 : api.textColor.sharedState.currentState();
|
|
49
52
|
if (!textColor || !pluginState) {
|
|
50
53
|
return tr;
|
|
51
54
|
}
|
|
52
55
|
const activeColor = getActiveColorNew(tr);
|
|
53
|
-
const
|
|
56
|
+
const isRemovingColor = color === pluginState.defaultColor;
|
|
57
|
+
const hadMarkAttributes = isRemovingColor ? {} : getHadMarkAttributes(tr, [backgroundColor]);
|
|
58
|
+
const colorAnalyticsPayload = createColorAnalyticsPayload(color, activeColor, pluginState.palette, inputMethod, hadMarkAttributes);
|
|
54
59
|
if (pluginState.disabled) {
|
|
55
60
|
return tr;
|
|
56
61
|
}
|
|
57
|
-
if (
|
|
62
|
+
if (isRemovingColor) {
|
|
58
63
|
var _api$analytics;
|
|
59
64
|
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
60
65
|
removeColor({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
|
+
import { getHadMarkAttributes } from '@atlaskit/editor-common/mark';
|
|
3
4
|
import { pluginKey } from '../main';
|
|
4
5
|
import { getActiveColor } from '../utils/color';
|
|
5
6
|
import { removeColor } from './remove-color';
|
|
@@ -12,7 +13,7 @@ import { toggleColor } from './toggle-color';
|
|
|
12
13
|
* @param palette - Current palette of colors
|
|
13
14
|
* @return Higher order command with analytics logic inside.
|
|
14
15
|
*/
|
|
15
|
-
function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyticsApi, inputMethod) {
|
|
16
|
+
function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyticsApi, inputMethod, hadMarkAttributes = {}) {
|
|
16
17
|
const newColorFromPalette = palette.find(({
|
|
17
18
|
value
|
|
18
19
|
}) => value === newColor);
|
|
@@ -29,22 +30,26 @@ function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyt
|
|
|
29
30
|
attributes: {
|
|
30
31
|
newColor: newColorLabel.toLowerCase(),
|
|
31
32
|
previousColor: previousColorLabel.toLowerCase(),
|
|
32
|
-
inputMethod
|
|
33
|
+
inputMethod,
|
|
34
|
+
...hadMarkAttributes
|
|
33
35
|
}
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
export const changeColor = (color, editorAnalyticsApi, inputMethod) => (state, dispatch) => {
|
|
37
39
|
const {
|
|
38
|
-
textColor
|
|
40
|
+
textColor,
|
|
41
|
+
backgroundColor
|
|
39
42
|
} = state.schema.marks;
|
|
40
43
|
if (textColor) {
|
|
41
44
|
const pluginState = pluginKey.getState(state);
|
|
42
45
|
const activeColor = getActiveColor(state);
|
|
43
|
-
const
|
|
46
|
+
const isRemovingColor = color === (pluginState === null || pluginState === void 0 ? void 0 : pluginState.defaultColor);
|
|
47
|
+
const hadMarkAttributes = isRemovingColor ? {} : getHadMarkAttributes(state.tr, [backgroundColor]);
|
|
48
|
+
const withColorAnalytics = createWithColorAnalytics(color, activeColor, (pluginState === null || pluginState === void 0 ? void 0 : pluginState.palette) || [], editorAnalyticsApi, inputMethod, hadMarkAttributes);
|
|
44
49
|
if (pluginState !== null && pluginState !== void 0 && pluginState.disabled) {
|
|
45
50
|
return false;
|
|
46
51
|
}
|
|
47
|
-
if (
|
|
52
|
+
if (isRemovingColor) {
|
|
48
53
|
withColorAnalytics(removeColor())(state, dispatch);
|
|
49
54
|
return true;
|
|
50
55
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { getHadMarkAttributes } from '@atlaskit/editor-common/mark';
|
|
2
6
|
import { FORMAT_SELECTION_SYNC_META } from '@atlaskit/editor-common/selection';
|
|
3
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
8
|
import { getActiveColorNew } from '../pm-plugins/utils/color';
|
|
@@ -18,6 +22,7 @@ var maybeSyncSelectionAfterFormat = function maybeSyncSelectionAfterFormat(tr) {
|
|
|
18
22
|
* @returns Higher order command with analytics logic inside.
|
|
19
23
|
*/
|
|
20
24
|
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod) {
|
|
25
|
+
var hadMarkAttributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
21
26
|
var newColorFromPalette = palette.find(function (_ref) {
|
|
22
27
|
var value = _ref.value;
|
|
23
28
|
return value === newColor;
|
|
@@ -33,28 +38,32 @@ function createColorAnalyticsPayload(newColor, previousColor, palette, inputMeth
|
|
|
33
38
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
34
39
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
35
40
|
eventType: EVENT_TYPE.TRACK,
|
|
36
|
-
attributes: {
|
|
41
|
+
attributes: _objectSpread({
|
|
37
42
|
newColor: newColorLabel.toLowerCase(),
|
|
38
43
|
previousColor: previousColorLabel.toLowerCase(),
|
|
39
44
|
inputMethod: inputMethod
|
|
40
|
-
}
|
|
45
|
+
}, hadMarkAttributes)
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
export var changeColor = function changeColor(color, api, inputMethod) {
|
|
44
49
|
return function (_ref3) {
|
|
45
50
|
var _api$analytics2;
|
|
46
51
|
var tr = _ref3.tr;
|
|
47
|
-
var
|
|
52
|
+
var _tr$doc$type$schema$m = tr.doc.type.schema.marks,
|
|
53
|
+
textColor = _tr$doc$type$schema$m.textColor,
|
|
54
|
+
backgroundColor = _tr$doc$type$schema$m.backgroundColor;
|
|
48
55
|
var pluginState = api === null || api === void 0 ? void 0 : api.textColor.sharedState.currentState();
|
|
49
56
|
if (!textColor || !pluginState) {
|
|
50
57
|
return tr;
|
|
51
58
|
}
|
|
52
59
|
var activeColor = getActiveColorNew(tr);
|
|
53
|
-
var
|
|
60
|
+
var isRemovingColor = color === pluginState.defaultColor;
|
|
61
|
+
var hadMarkAttributes = isRemovingColor ? {} : getHadMarkAttributes(tr, [backgroundColor]);
|
|
62
|
+
var colorAnalyticsPayload = createColorAnalyticsPayload(color, activeColor, pluginState.palette, inputMethod, hadMarkAttributes);
|
|
54
63
|
if (pluginState.disabled) {
|
|
55
64
|
return tr;
|
|
56
65
|
}
|
|
57
|
-
if (
|
|
66
|
+
if (isRemovingColor) {
|
|
58
67
|
var _api$analytics;
|
|
59
68
|
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
60
69
|
removeColor({
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
5
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
6
|
+
import { getHadMarkAttributes } from '@atlaskit/editor-common/mark';
|
|
3
7
|
import { pluginKey } from '../main';
|
|
4
8
|
import { getActiveColor } from '../utils/color';
|
|
5
9
|
import { removeColor } from './remove-color';
|
|
@@ -13,6 +17,7 @@ import { toggleColor } from './toggle-color';
|
|
|
13
17
|
* @return Higher order command with analytics logic inside.
|
|
14
18
|
*/
|
|
15
19
|
function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyticsApi, inputMethod) {
|
|
20
|
+
var hadMarkAttributes = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
16
21
|
var newColorFromPalette = palette.find(function (_ref) {
|
|
17
22
|
var value = _ref.value;
|
|
18
23
|
return value === newColor;
|
|
@@ -28,24 +33,28 @@ function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyt
|
|
|
28
33
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
29
34
|
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
30
35
|
eventType: EVENT_TYPE.TRACK,
|
|
31
|
-
attributes: {
|
|
36
|
+
attributes: _objectSpread({
|
|
32
37
|
newColor: newColorLabel.toLowerCase(),
|
|
33
38
|
previousColor: previousColorLabel.toLowerCase(),
|
|
34
39
|
inputMethod: inputMethod
|
|
35
|
-
}
|
|
40
|
+
}, hadMarkAttributes)
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
export var changeColor = function changeColor(color, editorAnalyticsApi, inputMethod) {
|
|
39
44
|
return function (state, dispatch) {
|
|
40
|
-
var
|
|
45
|
+
var _state$schema$marks = state.schema.marks,
|
|
46
|
+
textColor = _state$schema$marks.textColor,
|
|
47
|
+
backgroundColor = _state$schema$marks.backgroundColor;
|
|
41
48
|
if (textColor) {
|
|
42
49
|
var pluginState = pluginKey.getState(state);
|
|
43
50
|
var activeColor = getActiveColor(state);
|
|
44
|
-
var
|
|
51
|
+
var isRemovingColor = color === (pluginState === null || pluginState === void 0 ? void 0 : pluginState.defaultColor);
|
|
52
|
+
var hadMarkAttributes = isRemovingColor ? {} : getHadMarkAttributes(state.tr, [backgroundColor]);
|
|
53
|
+
var withColorAnalytics = createWithColorAnalytics(color, activeColor, (pluginState === null || pluginState === void 0 ? void 0 : pluginState.palette) || [], editorAnalyticsApi, inputMethod, hadMarkAttributes);
|
|
45
54
|
if (pluginState !== null && pluginState !== void 0 && pluginState.disabled) {
|
|
46
55
|
return false;
|
|
47
56
|
}
|
|
48
|
-
if (
|
|
57
|
+
if (isRemovingColor) {
|
|
49
58
|
withColorAnalytics(removeColor())(state, dispatch);
|
|
50
59
|
return true;
|
|
51
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.1",
|
|
4
4
|
"description": "Text color plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
],
|
|
22
22
|
"atlaskit:src": "src/index.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/adf-schema": "^57.
|
|
24
|
+
"@atlaskit/adf-schema": "^57.4.0",
|
|
25
25
|
"@atlaskit/button": "^25.3.0",
|
|
26
26
|
"@atlaskit/css": "^1.1.0",
|
|
27
27
|
"@atlaskit/editor-palette": "^3.5.0",
|
|
28
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
29
|
-
"@atlaskit/editor-plugin-highlight": "^
|
|
30
|
-
"@atlaskit/editor-plugin-interaction": "^
|
|
31
|
-
"@atlaskit/editor-plugin-primary-toolbar": "^
|
|
32
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^
|
|
33
|
-
"@atlaskit/editor-plugin-toolbar": "^
|
|
28
|
+
"@atlaskit/editor-plugin-analytics": "^17.0.0",
|
|
29
|
+
"@atlaskit/editor-plugin-highlight": "^17.0.0",
|
|
30
|
+
"@atlaskit/editor-plugin-interaction": "^28.0.0",
|
|
31
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^18.0.0",
|
|
32
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^18.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-toolbar": "^14.0.0",
|
|
34
34
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
35
35
|
"@atlaskit/editor-shared-styles": "^4.1.0",
|
|
36
36
|
"@atlaskit/editor-toolbar": "^2.6.0",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags-react": "^1.2.0",
|
|
44
44
|
"@atlaskit/primitives": "^22.5.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^180.0.0",
|
|
46
46
|
"@atlaskit/tokens": "^16.11.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0",
|
|
48
48
|
"@emotion/react": "^11.7.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@atlaskit/editor-common": "^
|
|
51
|
+
"@atlaskit/editor-common": "^121.1.0",
|
|
52
52
|
"react": "^18.2.0 || ^19.2.0",
|
|
53
53
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
54
54
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|