@atlaskit/editor-plugin-text-color 5.0.1 → 5.2.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 +23 -0
- package/dist/cjs/editor-commands/change-color.js +69 -0
- package/dist/cjs/editor-commands/remove-color.js +19 -0
- package/dist/cjs/editor-commands/toggle-color.js +37 -0
- package/dist/cjs/pm-plugins/utils/color.js +45 -1
- package/dist/cjs/pm-plugins/utils/disabled.js +29 -1
- package/dist/cjs/textColorPlugin.js +8 -2
- package/dist/cjs/ui/RemoveColorMenuItem.compiled.css +6 -0
- package/dist/cjs/ui/RemoveColorMenuItem.js +65 -0
- package/dist/cjs/ui/toolbar-components.js +14 -2
- package/dist/es2019/editor-commands/change-color.js +63 -0
- package/dist/es2019/editor-commands/remove-color.js +16 -0
- package/dist/es2019/editor-commands/toggle-color.js +34 -0
- package/dist/es2019/pm-plugins/utils/color.js +45 -0
- package/dist/es2019/pm-plugins/utils/disabled.js +31 -0
- package/dist/es2019/textColorPlugin.js +6 -0
- package/dist/es2019/ui/RemoveColorMenuItem.compiled.css +6 -0
- package/dist/es2019/ui/RemoveColorMenuItem.js +59 -0
- package/dist/es2019/ui/toolbar-components.js +17 -2
- package/dist/esm/editor-commands/change-color.js +64 -0
- package/dist/esm/editor-commands/remove-color.js +13 -0
- package/dist/esm/editor-commands/toggle-color.js +31 -0
- package/dist/esm/pm-plugins/utils/color.js +45 -0
- package/dist/esm/pm-plugins/utils/disabled.js +28 -0
- package/dist/esm/textColorPlugin.js +6 -0
- package/dist/esm/ui/RemoveColorMenuItem.compiled.css +6 -0
- package/dist/esm/ui/RemoveColorMenuItem.js +56 -0
- package/dist/esm/ui/toolbar-components.js +15 -3
- package/dist/types/editor-commands/change-color.d.ts +4 -0
- package/dist/types/editor-commands/remove-color.d.ts +2 -0
- package/dist/types/editor-commands/toggle-color.d.ts +2 -0
- package/dist/types/pm-plugins/utils/color.d.ts +5 -1
- package/dist/types/pm-plugins/utils/disabled.d.ts +5 -1
- package/dist/types/textColorPluginType.d.ts +4 -1
- package/dist/types/ui/RemoveColorMenuItem.d.ts +9 -0
- package/dist/types-ts4.5/editor-commands/change-color.d.ts +4 -0
- package/dist/types-ts4.5/editor-commands/remove-color.d.ts +2 -0
- package/dist/types-ts4.5/editor-commands/toggle-color.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/utils/color.d.ts +5 -1
- package/dist/types-ts4.5/pm-plugins/utils/disabled.d.ts +5 -1
- package/dist/types-ts4.5/textColorPluginType.d.ts +4 -1
- package/dist/types-ts4.5/ui/RemoveColorMenuItem.d.ts +9 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`64ec65231b4cf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/64ec65231b4cf) -
|
|
8
|
+
EDITOR-1568 bump adf-schema for afm
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 5.1.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`52e588636f4d0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/52e588636f4d0) -
|
|
19
|
+
Add new 'changeColor' Editor Command to editor-plugin-text-color, add new keys for clear color
|
|
20
|
+
menu item, add new clear color menu item, add new platform_editor_toolbar_aifc_patch_4 experiment
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 5.0.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.changeColor = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _color = require("../pm-plugins/utils/color");
|
|
9
|
+
var _removeColor = require("./remove-color");
|
|
10
|
+
var _toggleColor = require("./toggle-color");
|
|
11
|
+
/**
|
|
12
|
+
* Helper to create an analytics payload
|
|
13
|
+
* @param newColor - Color to be change in hex code
|
|
14
|
+
* @param previousColor - Active color in hex code
|
|
15
|
+
* @param palette - Current palette of colors
|
|
16
|
+
* @returns Higher order command with analytics logic inside.
|
|
17
|
+
*/
|
|
18
|
+
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod) {
|
|
19
|
+
var newColorFromPalette = palette.find(function (_ref) {
|
|
20
|
+
var value = _ref.value;
|
|
21
|
+
return value === newColor;
|
|
22
|
+
});
|
|
23
|
+
var previousColorFromPalette = palette.find(function (_ref2) {
|
|
24
|
+
var value = _ref2.value;
|
|
25
|
+
return value === previousColor;
|
|
26
|
+
});
|
|
27
|
+
var newColorLabel = newColorFromPalette ? newColorFromPalette.label : newColor;
|
|
28
|
+
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor || '';
|
|
29
|
+
return {
|
|
30
|
+
action: _analytics.ACTION.FORMATTED,
|
|
31
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
32
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
33
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
34
|
+
attributes: {
|
|
35
|
+
newColor: newColorLabel.toLowerCase(),
|
|
36
|
+
previousColor: previousColorLabel.toLowerCase(),
|
|
37
|
+
inputMethod: inputMethod
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
var changeColor = exports.changeColor = function changeColor(color, api, inputMethod) {
|
|
42
|
+
return function (_ref3) {
|
|
43
|
+
var _api$analytics2;
|
|
44
|
+
var tr = _ref3.tr;
|
|
45
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
46
|
+
var pluginState = api === null || api === void 0 ? void 0 : api.textColor.sharedState.currentState();
|
|
47
|
+
if (!textColor || !pluginState) {
|
|
48
|
+
return tr;
|
|
49
|
+
}
|
|
50
|
+
var activeColor = (0, _color.getActiveColorNew)(tr);
|
|
51
|
+
var colorAnalyticsPayload = createColorAnalyticsPayload(color, activeColor, pluginState.palette, inputMethod);
|
|
52
|
+
if (pluginState.disabled) {
|
|
53
|
+
return tr;
|
|
54
|
+
}
|
|
55
|
+
if (color === pluginState.defaultColor) {
|
|
56
|
+
var _api$analytics;
|
|
57
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
58
|
+
(0, _removeColor.removeColor)({
|
|
59
|
+
tr: tr
|
|
60
|
+
});
|
|
61
|
+
return tr;
|
|
62
|
+
}
|
|
63
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
64
|
+
(0, _toggleColor.toggleColor)(color)({
|
|
65
|
+
tr: tr
|
|
66
|
+
});
|
|
67
|
+
return tr;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeColor = void 0;
|
|
7
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
|
+
var _main = require("../pm-plugins/main");
|
|
9
|
+
var removeColor = exports.removeColor = function removeColor(_ref) {
|
|
10
|
+
var tr = _ref.tr;
|
|
11
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
12
|
+
(0, _mark.removeMark)(textColor)({
|
|
13
|
+
tr: tr
|
|
14
|
+
});
|
|
15
|
+
tr.setMeta(_main.pluginKey, {
|
|
16
|
+
action: _main.ACTIONS.RESET_COLOR
|
|
17
|
+
});
|
|
18
|
+
return tr;
|
|
19
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toggleColor = void 0;
|
|
7
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
|
+
var _main = require("../pm-plugins/main");
|
|
9
|
+
var _constants = require("../pm-plugins/utils/constants");
|
|
10
|
+
var _disabled = require("../pm-plugins/utils/disabled");
|
|
11
|
+
var toggleColor = exports.toggleColor = function toggleColor(color) {
|
|
12
|
+
return function (_ref) {
|
|
13
|
+
var tr = _ref.tr;
|
|
14
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
15
|
+
var disabledState = (0, _disabled.getDisabledStateNew)(tr);
|
|
16
|
+
if (disabledState) {
|
|
17
|
+
tr.setMeta(_main.pluginKey, {
|
|
18
|
+
action: _main.ACTIONS.DISABLE
|
|
19
|
+
});
|
|
20
|
+
return tr;
|
|
21
|
+
}
|
|
22
|
+
_constants.overrideMarks.forEach(function (mark) {
|
|
23
|
+
var marks = tr.doc.type.schema.marks;
|
|
24
|
+
if (marks[mark]) {
|
|
25
|
+
(0, _mark.removeMark)(marks[mark])({
|
|
26
|
+
tr: tr
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
(0, _mark.toggleMark)(textColor, {
|
|
31
|
+
color: color
|
|
32
|
+
})({
|
|
33
|
+
tr: tr
|
|
34
|
+
});
|
|
35
|
+
return tr;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getActiveColor = void 0;
|
|
6
|
+
exports.getActiveColorNew = exports.getActiveColor = void 0;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
|
+
/**
|
|
9
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
10
|
+
*/
|
|
8
11
|
var getActiveColor = exports.getActiveColor = function getActiveColor(state) {
|
|
9
12
|
var _ref = state.selection,
|
|
10
13
|
$from = _ref.$from,
|
|
@@ -28,6 +31,47 @@ var getActiveColor = exports.getActiveColor = function getActiveColor(state) {
|
|
|
28
31
|
});
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
// Merge consecutive same color marks
|
|
35
|
+
var prevMark;
|
|
36
|
+
marks = marks.filter(function (mark) {
|
|
37
|
+
if (mark && prevMark && mark.attrs.color === prevMark.attrs.color) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
prevMark = mark;
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
43
|
+
var marksWithColor = marks.filter(function (mark) {
|
|
44
|
+
return !!mark;
|
|
45
|
+
});
|
|
46
|
+
// When multiple colors are selected revert back to default color
|
|
47
|
+
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return marksWithColor.length ? marksWithColor[0].attrs.color : _constants.DEFAULT_COLOR.color;
|
|
51
|
+
};
|
|
52
|
+
var getActiveColorNew = exports.getActiveColorNew = function getActiveColorNew(tr) {
|
|
53
|
+
var _ref3 = tr.selection,
|
|
54
|
+
$from = _ref3.$from,
|
|
55
|
+
$to = _ref3.$to,
|
|
56
|
+
$cursor = _ref3.$cursor;
|
|
57
|
+
var _ref4 = tr.doc.type.schema.marks,
|
|
58
|
+
textColor = _ref4.textColor;
|
|
59
|
+
|
|
60
|
+
// Filter out other marks
|
|
61
|
+
var marks = [];
|
|
62
|
+
if ($cursor) {
|
|
63
|
+
marks.push(textColor.isInSet(tr.storedMarks || $cursor.marks()) || undefined);
|
|
64
|
+
} else {
|
|
65
|
+
tr.doc.nodesBetween($from.pos, $to.pos, function (currentNode) {
|
|
66
|
+
if (currentNode.isLeaf) {
|
|
67
|
+
var mark = textColor.isInSet(currentNode.marks) || undefined;
|
|
68
|
+
marks.push(mark);
|
|
69
|
+
return !mark;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
31
75
|
// Merge consecutive same color marks
|
|
32
76
|
var prevMark;
|
|
33
77
|
marks = marks.filter(function (mark) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getDisabledState = void 0;
|
|
6
|
+
exports.getDisabledStateNew = exports.getDisabledState = void 0;
|
|
7
7
|
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
8
|
var _constants = require("./constants");
|
|
9
9
|
var hasLinkMark = function hasLinkMark($pos) {
|
|
@@ -14,6 +14,10 @@ var hasLinkMark = function hasLinkMark($pos) {
|
|
|
14
14
|
}
|
|
15
15
|
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
20
|
+
*/
|
|
17
21
|
var getDisabledState = exports.getDisabledState = function getDisabledState(state) {
|
|
18
22
|
var textColor = state.schema.marks.textColor;
|
|
19
23
|
if (textColor) {
|
|
@@ -37,4 +41,28 @@ var getDisabledState = exports.getDisabledState = function getDisabledState(stat
|
|
|
37
41
|
return false;
|
|
38
42
|
}
|
|
39
43
|
return true;
|
|
44
|
+
};
|
|
45
|
+
var getDisabledStateNew = exports.getDisabledStateNew = function getDisabledStateNew(tr) {
|
|
46
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
47
|
+
if (textColor) {
|
|
48
|
+
var _tr$storedMarks;
|
|
49
|
+
var _ref2 = tr.selection,
|
|
50
|
+
empty = _ref2.empty,
|
|
51
|
+
ranges = _ref2.ranges,
|
|
52
|
+
$cursor = _ref2.$cursor;
|
|
53
|
+
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || (0, _mark.isMarkAllowedInRange)(tr.doc, ranges, textColor) === false) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Allow "excluded" marks that can be overridden
|
|
58
|
+
// These marks are explicitly removed before applying the new mark (see toggleColor command)
|
|
59
|
+
var omitOverrides = function omitOverrides(mark) {
|
|
60
|
+
return !_constants.overrideMarks.includes(mark.type.name);
|
|
61
|
+
};
|
|
62
|
+
if ((0, _mark.isMarkExcluded)(textColor, ((_tr$storedMarks = tr.storedMarks) === null || _tr$storedMarks === void 0 ? void 0 : _tr$storedMarks.filter(omitOverrides)) || $cursor && $cursor.marks().filter(omitOverrides))) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
40
68
|
};
|
|
@@ -9,7 +9,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
|
-
var _changeColor2 = require("./
|
|
12
|
+
var _changeColor2 = require("./editor-commands/change-color");
|
|
13
|
+
var _changeColor3 = require("./pm-plugins/commands/change-color");
|
|
13
14
|
var _main = require("./pm-plugins/main");
|
|
14
15
|
var _FloatingToolbarComponent = require("./ui/FloatingToolbarComponent");
|
|
15
16
|
var _PrimaryToolbarComponent = require("./ui/PrimaryToolbarComponent");
|
|
@@ -83,7 +84,12 @@ var textColorPlugin = exports.textColorPlugin = function textColorPlugin(_ref) {
|
|
|
83
84
|
actions: {
|
|
84
85
|
changeColor: function changeColor(color, inputMethod) {
|
|
85
86
|
var _api$analytics;
|
|
86
|
-
return (0,
|
|
87
|
+
return (0, _changeColor3.changeColor)(color, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, inputMethod);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
commands: {
|
|
91
|
+
changeColor: function changeColor(color, inputMethod) {
|
|
92
|
+
return (0, _changeColor2.changeColor)(color, api, inputMethod);
|
|
87
93
|
}
|
|
88
94
|
},
|
|
89
95
|
pluginsOptions: !isToolbarAIFCEnabled ? {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
3
|
+
._195gv77o{margin-inline:var(--ds-space-025,2px)}
|
|
4
|
+
._1dqonqa1{border-style:solid}
|
|
5
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
6
|
+
._19pk12x7{margin-top:var(--ds-space-075,6px)}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* RemoveColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.RemoveColorMenuItem = void 0;
|
|
10
|
+
require("./RemoveColorMenuItem.compiled.css");
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _reactIntlNext = require("react-intl-next");
|
|
14
|
+
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
15
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
16
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
17
|
+
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
18
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
19
|
+
var _compiled = require("@atlaskit/primitives/compiled");
|
|
20
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
21
|
+
var styles = {
|
|
22
|
+
removeColorButton: "_2rko12b0 _195gv77o _189ee4h9 _1dqonqa1 _1h6dmuej _19pk12x7"
|
|
23
|
+
};
|
|
24
|
+
var RemoveColorMenuItem = exports.RemoveColorMenuItem = function RemoveColorMenuItem(_ref) {
|
|
25
|
+
var api = _ref.api,
|
|
26
|
+
parents = _ref.parents;
|
|
27
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
28
|
+
formatMessage = _useIntl.formatMessage;
|
|
29
|
+
var context = (0, _editorToolbar.useToolbarDropdownMenu)();
|
|
30
|
+
var closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
|
|
31
|
+
var onClick = function onClick() {
|
|
32
|
+
var _api$textColor$shared;
|
|
33
|
+
if (!api) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var defaultColor = (_api$textColor$shared = api.textColor.sharedState.currentState()) === null || _api$textColor$shared === void 0 ? void 0 : _api$textColor$shared.defaultColor;
|
|
37
|
+
if (!defaultColor) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
api.core.actions.execute(function (_ref2) {
|
|
41
|
+
var _api$highlight;
|
|
42
|
+
var tr = _ref2.tr;
|
|
43
|
+
api.textColor.commands.changeColor(defaultColor, (0, _toolbar.getInputMethodFromParentKeys)(parents))({
|
|
44
|
+
tr: tr
|
|
45
|
+
});
|
|
46
|
+
(_api$highlight = api.highlight) === null || _api$highlight === void 0 || _api$highlight.commands.changeColor({
|
|
47
|
+
color: _uiColor.REMOVE_HIGHLIGHT_COLOR,
|
|
48
|
+
inputMethod: (0, _toolbar.getInputMethodFromParentKeys)(parents)
|
|
49
|
+
})({
|
|
50
|
+
tr: tr
|
|
51
|
+
});
|
|
52
|
+
return tr;
|
|
53
|
+
});
|
|
54
|
+
closeMenu === null || closeMenu === void 0 || closeMenu();
|
|
55
|
+
};
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: (0, _runtime.ax)([styles.removeColorButton])
|
|
58
|
+
}, /*#__PURE__*/React.createElement(_new.default, {
|
|
59
|
+
shouldFitContainer: true,
|
|
60
|
+
appearance: "subtle",
|
|
61
|
+
onClick: onClick
|
|
62
|
+
}, /*#__PURE__*/React.createElement(_compiled.Text, {
|
|
63
|
+
weight: "medium"
|
|
64
|
+
}, formatMessage(_messages.highlightMessages.removeColor))));
|
|
65
|
+
};
|
|
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getToolbarComponents = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
12
12
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
|
+
var _RemoveColorMenuItem = require("./RemoveColorMenuItem");
|
|
13
14
|
var _TextColorHighlightMenu = require("./TextColorHighlightMenu");
|
|
14
15
|
var _TextColorMenuItem = require("./TextColorMenuItem");
|
|
15
16
|
var _TextMenuSection = require("./TextMenuSection");
|
|
@@ -50,5 +51,16 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
50
51
|
parents: parents
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
})]
|
|
54
|
+
})].concat((0, _toConsumableArray2.default)((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_4', 'isEnabled', true) ? [_objectSpread(_objectSpread({}, _toolbar.CLEAR_COLOR_MENU_ITEM), {}, {
|
|
55
|
+
parents: [_objectSpread(_objectSpread({}, _toolbar.TEXT_COLOR_HIGHLIGHT_MENU_SECTION), {}, {
|
|
56
|
+
rank: _toolbar.TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[_toolbar.CLEAR_COLOR_MENU_ITEM.key]
|
|
57
|
+
})],
|
|
58
|
+
component: function component(_ref3) {
|
|
59
|
+
var parents = _ref3.parents;
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_RemoveColorMenuItem.RemoveColorMenuItem, {
|
|
61
|
+
api: api,
|
|
62
|
+
parents: parents
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
})] : []));
|
|
54
66
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { getActiveColorNew } from '../pm-plugins/utils/color';
|
|
3
|
+
import { removeColor } from './remove-color';
|
|
4
|
+
import { toggleColor } from './toggle-color';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper to create an analytics payload
|
|
8
|
+
* @param newColor - Color to be change in hex code
|
|
9
|
+
* @param previousColor - Active color in hex code
|
|
10
|
+
* @param palette - Current palette of colors
|
|
11
|
+
* @returns Higher order command with analytics logic inside.
|
|
12
|
+
*/
|
|
13
|
+
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod) {
|
|
14
|
+
const newColorFromPalette = palette.find(({
|
|
15
|
+
value
|
|
16
|
+
}) => value === newColor);
|
|
17
|
+
const previousColorFromPalette = palette.find(({
|
|
18
|
+
value
|
|
19
|
+
}) => value === previousColor);
|
|
20
|
+
const newColorLabel = newColorFromPalette ? newColorFromPalette.label : newColor;
|
|
21
|
+
const previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor || '';
|
|
22
|
+
return {
|
|
23
|
+
action: ACTION.FORMATTED,
|
|
24
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
25
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
26
|
+
eventType: EVENT_TYPE.TRACK,
|
|
27
|
+
attributes: {
|
|
28
|
+
newColor: newColorLabel.toLowerCase(),
|
|
29
|
+
previousColor: previousColorLabel.toLowerCase(),
|
|
30
|
+
inputMethod
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export const changeColor = (color, api, inputMethod) => ({
|
|
35
|
+
tr
|
|
36
|
+
}) => {
|
|
37
|
+
var _api$analytics2;
|
|
38
|
+
const {
|
|
39
|
+
textColor
|
|
40
|
+
} = tr.doc.type.schema.marks;
|
|
41
|
+
const pluginState = api === null || api === void 0 ? void 0 : api.textColor.sharedState.currentState();
|
|
42
|
+
if (!textColor || !pluginState) {
|
|
43
|
+
return tr;
|
|
44
|
+
}
|
|
45
|
+
const activeColor = getActiveColorNew(tr);
|
|
46
|
+
const colorAnalyticsPayload = createColorAnalyticsPayload(color, activeColor, pluginState.palette, inputMethod);
|
|
47
|
+
if (pluginState.disabled) {
|
|
48
|
+
return tr;
|
|
49
|
+
}
|
|
50
|
+
if (color === pluginState.defaultColor) {
|
|
51
|
+
var _api$analytics;
|
|
52
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
53
|
+
removeColor({
|
|
54
|
+
tr
|
|
55
|
+
});
|
|
56
|
+
return tr;
|
|
57
|
+
}
|
|
58
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
59
|
+
toggleColor(color)({
|
|
60
|
+
tr
|
|
61
|
+
});
|
|
62
|
+
return tr;
|
|
63
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { removeMark } from '@atlaskit/editor-common/mark';
|
|
2
|
+
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
|
+
export const removeColor = ({
|
|
4
|
+
tr
|
|
5
|
+
}) => {
|
|
6
|
+
const {
|
|
7
|
+
textColor
|
|
8
|
+
} = tr.doc.type.schema.marks;
|
|
9
|
+
removeMark(textColor)({
|
|
10
|
+
tr
|
|
11
|
+
});
|
|
12
|
+
tr.setMeta(pluginKey, {
|
|
13
|
+
action: ACTIONS.RESET_COLOR
|
|
14
|
+
});
|
|
15
|
+
return tr;
|
|
16
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { removeMark, toggleMark } from '@atlaskit/editor-common/mark';
|
|
2
|
+
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
|
+
import { overrideMarks } from '../pm-plugins/utils/constants';
|
|
4
|
+
import { getDisabledStateNew } from '../pm-plugins/utils/disabled';
|
|
5
|
+
export const toggleColor = color => ({
|
|
6
|
+
tr
|
|
7
|
+
}) => {
|
|
8
|
+
const {
|
|
9
|
+
textColor
|
|
10
|
+
} = tr.doc.type.schema.marks;
|
|
11
|
+
const disabledState = getDisabledStateNew(tr);
|
|
12
|
+
if (disabledState) {
|
|
13
|
+
tr.setMeta(pluginKey, {
|
|
14
|
+
action: ACTIONS.DISABLE
|
|
15
|
+
});
|
|
16
|
+
return tr;
|
|
17
|
+
}
|
|
18
|
+
overrideMarks.forEach(mark => {
|
|
19
|
+
const {
|
|
20
|
+
marks
|
|
21
|
+
} = tr.doc.type.schema;
|
|
22
|
+
if (marks[mark]) {
|
|
23
|
+
removeMark(marks[mark])({
|
|
24
|
+
tr
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
toggleMark(textColor, {
|
|
29
|
+
color
|
|
30
|
+
})({
|
|
31
|
+
tr
|
|
32
|
+
});
|
|
33
|
+
return tr;
|
|
34
|
+
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_COLOR } from './constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
5
|
+
*/
|
|
2
6
|
export const getActiveColor = state => {
|
|
3
7
|
const {
|
|
4
8
|
$from,
|
|
@@ -24,6 +28,47 @@ export const getActiveColor = state => {
|
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
// Merge consecutive same color marks
|
|
32
|
+
let prevMark;
|
|
33
|
+
marks = marks.filter(mark => {
|
|
34
|
+
if (mark && prevMark && mark.attrs.color === prevMark.attrs.color) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
prevMark = mark;
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
|
+
const marksWithColor = marks.filter(mark => !!mark);
|
|
41
|
+
// When multiple colors are selected revert back to default color
|
|
42
|
+
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return marksWithColor.length ? marksWithColor[0].attrs.color : DEFAULT_COLOR.color;
|
|
46
|
+
};
|
|
47
|
+
export const getActiveColorNew = tr => {
|
|
48
|
+
const {
|
|
49
|
+
$from,
|
|
50
|
+
$to,
|
|
51
|
+
$cursor
|
|
52
|
+
} = tr.selection;
|
|
53
|
+
const {
|
|
54
|
+
textColor
|
|
55
|
+
} = tr.doc.type.schema.marks;
|
|
56
|
+
|
|
57
|
+
// Filter out other marks
|
|
58
|
+
let marks = [];
|
|
59
|
+
if ($cursor) {
|
|
60
|
+
marks.push(textColor.isInSet(tr.storedMarks || $cursor.marks()) || undefined);
|
|
61
|
+
} else {
|
|
62
|
+
tr.doc.nodesBetween($from.pos, $to.pos, currentNode => {
|
|
63
|
+
if (currentNode.isLeaf) {
|
|
64
|
+
const mark = textColor.isInSet(currentNode.marks) || undefined;
|
|
65
|
+
marks.push(mark);
|
|
66
|
+
return !mark;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
27
72
|
// Merge consecutive same color marks
|
|
28
73
|
let prevMark;
|
|
29
74
|
marks = marks.filter(mark => {
|
|
@@ -18,6 +18,10 @@ const hasLinkMark = $pos => {
|
|
|
18
18
|
}
|
|
19
19
|
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
24
|
+
*/
|
|
21
25
|
export const getDisabledState = state => {
|
|
22
26
|
const {
|
|
23
27
|
textColor
|
|
@@ -44,4 +48,31 @@ export const getDisabledState = state => {
|
|
|
44
48
|
return false;
|
|
45
49
|
}
|
|
46
50
|
return true;
|
|
51
|
+
};
|
|
52
|
+
export const getDisabledStateNew = tr => {
|
|
53
|
+
const {
|
|
54
|
+
textColor
|
|
55
|
+
} = tr.doc.type.schema.marks;
|
|
56
|
+
if (textColor) {
|
|
57
|
+
var _tr$storedMarks;
|
|
58
|
+
const {
|
|
59
|
+
empty,
|
|
60
|
+
ranges,
|
|
61
|
+
$cursor
|
|
62
|
+
} = tr.selection;
|
|
63
|
+
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || isMarkAllowedInRange(tr.doc, ranges, textColor) === false) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Allow "excluded" marks that can be overridden
|
|
68
|
+
// These marks are explicitly removed before applying the new mark (see toggleColor command)
|
|
69
|
+
const omitOverrides = mark => {
|
|
70
|
+
return !overrideMarks.includes(mark.type.name);
|
|
71
|
+
};
|
|
72
|
+
if (isMarkExcluded(textColor, ((_tr$storedMarks = tr.storedMarks) === null || _tr$storedMarks === void 0 ? void 0 : _tr$storedMarks.filter(omitOverrides)) || $cursor && $cursor.marks().filter(omitOverrides))) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
47
78
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { textColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
+
import { changeColor as changeColorCommand } from './editor-commands/change-color';
|
|
5
6
|
import { changeColor } from './pm-plugins/commands/change-color';
|
|
6
7
|
import { createPlugin, pluginKey as textColorPluginKey } from './pm-plugins/main';
|
|
7
8
|
import { FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
|
|
@@ -80,6 +81,11 @@ export const textColorPlugin = ({
|
|
|
80
81
|
return changeColor(color, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, inputMethod);
|
|
81
82
|
}
|
|
82
83
|
},
|
|
84
|
+
commands: {
|
|
85
|
+
changeColor: (color, inputMethod) => {
|
|
86
|
+
return changeColorCommand(color, api, inputMethod);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
83
89
|
pluginsOptions: !isToolbarAIFCEnabled ? {
|
|
84
90
|
selectionToolbar: () => {
|
|
85
91
|
var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2, _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
3
|
+
._195gv77o{margin-inline:var(--ds-space-025,2px)}
|
|
4
|
+
._1dqonqa1{border-style:solid}
|
|
5
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
6
|
+
._19pk12x7{margin-top:var(--ds-space-075,6px)}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* RemoveColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./RemoveColorMenuItem.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { useIntl } from 'react-intl-next';
|
|
6
|
+
import Button from '@atlaskit/button/new';
|
|
7
|
+
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
8
|
+
import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
|
|
9
|
+
import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
10
|
+
import { useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
11
|
+
import { Text } from '@atlaskit/primitives/compiled';
|
|
12
|
+
const styles = {
|
|
13
|
+
removeColorButton: "_2rko12b0 _195gv77o _189ee4h9 _1dqonqa1 _1h6dmuej _19pk12x7"
|
|
14
|
+
};
|
|
15
|
+
export const RemoveColorMenuItem = ({
|
|
16
|
+
api,
|
|
17
|
+
parents
|
|
18
|
+
}) => {
|
|
19
|
+
const {
|
|
20
|
+
formatMessage
|
|
21
|
+
} = useIntl();
|
|
22
|
+
const context = useToolbarDropdownMenu();
|
|
23
|
+
const closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
|
|
24
|
+
const onClick = () => {
|
|
25
|
+
var _api$textColor$shared;
|
|
26
|
+
if (!api) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const defaultColor = (_api$textColor$shared = api.textColor.sharedState.currentState()) === null || _api$textColor$shared === void 0 ? void 0 : _api$textColor$shared.defaultColor;
|
|
30
|
+
if (!defaultColor) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
api.core.actions.execute(({
|
|
34
|
+
tr
|
|
35
|
+
}) => {
|
|
36
|
+
var _api$highlight;
|
|
37
|
+
api.textColor.commands.changeColor(defaultColor, getInputMethodFromParentKeys(parents))({
|
|
38
|
+
tr
|
|
39
|
+
});
|
|
40
|
+
(_api$highlight = api.highlight) === null || _api$highlight === void 0 ? void 0 : _api$highlight.commands.changeColor({
|
|
41
|
+
color: REMOVE_HIGHLIGHT_COLOR,
|
|
42
|
+
inputMethod: getInputMethodFromParentKeys(parents)
|
|
43
|
+
})({
|
|
44
|
+
tr
|
|
45
|
+
});
|
|
46
|
+
return tr;
|
|
47
|
+
});
|
|
48
|
+
closeMenu === null || closeMenu === void 0 ? void 0 : closeMenu();
|
|
49
|
+
};
|
|
50
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: ax([styles.removeColorButton])
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
53
|
+
shouldFitContainer: true,
|
|
54
|
+
appearance: "subtle",
|
|
55
|
+
onClick: onClick
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
57
|
+
weight: "medium"
|
|
58
|
+
}, formatMessage(messages.removeColor))));
|
|
59
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
2
|
+
import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, CLEAR_COLOR_MENU_ITEM } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
|
+
import { RemoveColorMenuItem } from './RemoveColorMenuItem';
|
|
4
5
|
import { TextColorHighlightMenu } from './TextColorHighlightMenu';
|
|
5
6
|
import { TextColorMenuItem } from './TextColorMenuItem';
|
|
6
7
|
import { TextMenuSection } from './TextMenuSection';
|
|
@@ -45,5 +46,19 @@ export const getToolbarComponents = api => {
|
|
|
45
46
|
api: api,
|
|
46
47
|
parents: parents
|
|
47
48
|
})
|
|
48
|
-
}
|
|
49
|
+
}, ...(expValEquals('platform_editor_toolbar_aifc_patch_4', 'isEnabled', true) ? [{
|
|
50
|
+
...CLEAR_COLOR_MENU_ITEM,
|
|
51
|
+
parents: [{
|
|
52
|
+
...TEXT_COLOR_HIGHLIGHT_MENU_SECTION,
|
|
53
|
+
rank: TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[CLEAR_COLOR_MENU_ITEM.key]
|
|
54
|
+
}],
|
|
55
|
+
component: ({
|
|
56
|
+
parents
|
|
57
|
+
}) => {
|
|
58
|
+
return /*#__PURE__*/React.createElement(RemoveColorMenuItem, {
|
|
59
|
+
api: api,
|
|
60
|
+
parents: parents
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}] : [])];
|
|
49
64
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { getActiveColorNew } from '../pm-plugins/utils/color';
|
|
3
|
+
import { removeColor } from './remove-color';
|
|
4
|
+
import { toggleColor } from './toggle-color';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper to create an analytics payload
|
|
8
|
+
* @param newColor - Color to be change in hex code
|
|
9
|
+
* @param previousColor - Active color in hex code
|
|
10
|
+
* @param palette - Current palette of colors
|
|
11
|
+
* @returns Higher order command with analytics logic inside.
|
|
12
|
+
*/
|
|
13
|
+
function createColorAnalyticsPayload(newColor, previousColor, palette, inputMethod) {
|
|
14
|
+
var newColorFromPalette = palette.find(function (_ref) {
|
|
15
|
+
var value = _ref.value;
|
|
16
|
+
return value === newColor;
|
|
17
|
+
});
|
|
18
|
+
var previousColorFromPalette = palette.find(function (_ref2) {
|
|
19
|
+
var value = _ref2.value;
|
|
20
|
+
return value === previousColor;
|
|
21
|
+
});
|
|
22
|
+
var newColorLabel = newColorFromPalette ? newColorFromPalette.label : newColor;
|
|
23
|
+
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor || '';
|
|
24
|
+
return {
|
|
25
|
+
action: ACTION.FORMATTED,
|
|
26
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
27
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
28
|
+
eventType: EVENT_TYPE.TRACK,
|
|
29
|
+
attributes: {
|
|
30
|
+
newColor: newColorLabel.toLowerCase(),
|
|
31
|
+
previousColor: previousColorLabel.toLowerCase(),
|
|
32
|
+
inputMethod: inputMethod
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export var changeColor = function changeColor(color, api, inputMethod) {
|
|
37
|
+
return function (_ref3) {
|
|
38
|
+
var _api$analytics2;
|
|
39
|
+
var tr = _ref3.tr;
|
|
40
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
41
|
+
var pluginState = api === null || api === void 0 ? void 0 : api.textColor.sharedState.currentState();
|
|
42
|
+
if (!textColor || !pluginState) {
|
|
43
|
+
return tr;
|
|
44
|
+
}
|
|
45
|
+
var activeColor = getActiveColorNew(tr);
|
|
46
|
+
var colorAnalyticsPayload = createColorAnalyticsPayload(color, activeColor, pluginState.palette, inputMethod);
|
|
47
|
+
if (pluginState.disabled) {
|
|
48
|
+
return tr;
|
|
49
|
+
}
|
|
50
|
+
if (color === pluginState.defaultColor) {
|
|
51
|
+
var _api$analytics;
|
|
52
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
53
|
+
removeColor({
|
|
54
|
+
tr: tr
|
|
55
|
+
});
|
|
56
|
+
return tr;
|
|
57
|
+
}
|
|
58
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent(colorAnalyticsPayload)(tr);
|
|
59
|
+
toggleColor(color)({
|
|
60
|
+
tr: tr
|
|
61
|
+
});
|
|
62
|
+
return tr;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { removeMark } from '@atlaskit/editor-common/mark';
|
|
2
|
+
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
|
+
export var removeColor = function removeColor(_ref) {
|
|
4
|
+
var tr = _ref.tr;
|
|
5
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
6
|
+
removeMark(textColor)({
|
|
7
|
+
tr: tr
|
|
8
|
+
});
|
|
9
|
+
tr.setMeta(pluginKey, {
|
|
10
|
+
action: ACTIONS.RESET_COLOR
|
|
11
|
+
});
|
|
12
|
+
return tr;
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { removeMark, toggleMark } from '@atlaskit/editor-common/mark';
|
|
2
|
+
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
|
+
import { overrideMarks } from '../pm-plugins/utils/constants';
|
|
4
|
+
import { getDisabledStateNew } from '../pm-plugins/utils/disabled';
|
|
5
|
+
export var toggleColor = function toggleColor(color) {
|
|
6
|
+
return function (_ref) {
|
|
7
|
+
var tr = _ref.tr;
|
|
8
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
9
|
+
var disabledState = getDisabledStateNew(tr);
|
|
10
|
+
if (disabledState) {
|
|
11
|
+
tr.setMeta(pluginKey, {
|
|
12
|
+
action: ACTIONS.DISABLE
|
|
13
|
+
});
|
|
14
|
+
return tr;
|
|
15
|
+
}
|
|
16
|
+
overrideMarks.forEach(function (mark) {
|
|
17
|
+
var marks = tr.doc.type.schema.marks;
|
|
18
|
+
if (marks[mark]) {
|
|
19
|
+
removeMark(marks[mark])({
|
|
20
|
+
tr: tr
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
toggleMark(textColor, {
|
|
25
|
+
color: color
|
|
26
|
+
})({
|
|
27
|
+
tr: tr
|
|
28
|
+
});
|
|
29
|
+
return tr;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_COLOR } from './constants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
5
|
+
*/
|
|
2
6
|
export var getActiveColor = function getActiveColor(state) {
|
|
3
7
|
var _ref = state.selection,
|
|
4
8
|
$from = _ref.$from,
|
|
@@ -22,6 +26,47 @@ export var getActiveColor = function getActiveColor(state) {
|
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
// Merge consecutive same color marks
|
|
30
|
+
var prevMark;
|
|
31
|
+
marks = marks.filter(function (mark) {
|
|
32
|
+
if (mark && prevMark && mark.attrs.color === prevMark.attrs.color) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
prevMark = mark;
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
var marksWithColor = marks.filter(function (mark) {
|
|
39
|
+
return !!mark;
|
|
40
|
+
});
|
|
41
|
+
// When multiple colors are selected revert back to default color
|
|
42
|
+
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return marksWithColor.length ? marksWithColor[0].attrs.color : DEFAULT_COLOR.color;
|
|
46
|
+
};
|
|
47
|
+
export var getActiveColorNew = function getActiveColorNew(tr) {
|
|
48
|
+
var _ref3 = tr.selection,
|
|
49
|
+
$from = _ref3.$from,
|
|
50
|
+
$to = _ref3.$to,
|
|
51
|
+
$cursor = _ref3.$cursor;
|
|
52
|
+
var _ref4 = tr.doc.type.schema.marks,
|
|
53
|
+
textColor = _ref4.textColor;
|
|
54
|
+
|
|
55
|
+
// Filter out other marks
|
|
56
|
+
var marks = [];
|
|
57
|
+
if ($cursor) {
|
|
58
|
+
marks.push(textColor.isInSet(tr.storedMarks || $cursor.marks()) || undefined);
|
|
59
|
+
} else {
|
|
60
|
+
tr.doc.nodesBetween($from.pos, $to.pos, function (currentNode) {
|
|
61
|
+
if (currentNode.isLeaf) {
|
|
62
|
+
var mark = textColor.isInSet(currentNode.marks) || undefined;
|
|
63
|
+
marks.push(mark);
|
|
64
|
+
return !mark;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
25
70
|
// Merge consecutive same color marks
|
|
26
71
|
var prevMark;
|
|
27
72
|
marks = marks.filter(function (mark) {
|
|
@@ -8,6 +8,10 @@ var hasLinkMark = function hasLinkMark($pos) {
|
|
|
8
8
|
}
|
|
9
9
|
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
10
10
|
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
14
|
+
*/
|
|
11
15
|
export var getDisabledState = function getDisabledState(state) {
|
|
12
16
|
var textColor = state.schema.marks.textColor;
|
|
13
17
|
if (textColor) {
|
|
@@ -31,4 +35,28 @@ export var getDisabledState = function getDisabledState(state) {
|
|
|
31
35
|
return false;
|
|
32
36
|
}
|
|
33
37
|
return true;
|
|
38
|
+
};
|
|
39
|
+
export var getDisabledStateNew = function getDisabledStateNew(tr) {
|
|
40
|
+
var textColor = tr.doc.type.schema.marks.textColor;
|
|
41
|
+
if (textColor) {
|
|
42
|
+
var _tr$storedMarks;
|
|
43
|
+
var _ref2 = tr.selection,
|
|
44
|
+
empty = _ref2.empty,
|
|
45
|
+
ranges = _ref2.ranges,
|
|
46
|
+
$cursor = _ref2.$cursor;
|
|
47
|
+
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || isMarkAllowedInRange(tr.doc, ranges, textColor) === false) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Allow "excluded" marks that can be overridden
|
|
52
|
+
// These marks are explicitly removed before applying the new mark (see toggleColor command)
|
|
53
|
+
var omitOverrides = function omitOverrides(mark) {
|
|
54
|
+
return !overrideMarks.includes(mark.type.name);
|
|
55
|
+
};
|
|
56
|
+
if (isMarkExcluded(textColor, ((_tr$storedMarks = tr.storedMarks) === null || _tr$storedMarks === void 0 ? void 0 : _tr$storedMarks.filter(omitOverrides)) || $cursor && $cursor.marks().filter(omitOverrides))) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
34
62
|
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { textColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
+
import { changeColor as changeColorCommand } from './editor-commands/change-color';
|
|
5
6
|
import { changeColor as _changeColor } from './pm-plugins/commands/change-color';
|
|
6
7
|
import { createPlugin, pluginKey as textColorPluginKey } from './pm-plugins/main';
|
|
7
8
|
import { FloatingToolbarComponent } from './ui/FloatingToolbarComponent';
|
|
@@ -79,6 +80,11 @@ export var textColorPlugin = function textColorPlugin(_ref) {
|
|
|
79
80
|
return _changeColor(color, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, inputMethod);
|
|
80
81
|
}
|
|
81
82
|
},
|
|
83
|
+
commands: {
|
|
84
|
+
changeColor: function changeColor(color, inputMethod) {
|
|
85
|
+
return changeColorCommand(color, api, inputMethod);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
82
88
|
pluginsOptions: !isToolbarAIFCEnabled ? {
|
|
83
89
|
selectionToolbar: function selectionToolbar() {
|
|
84
90
|
var _api$userPreferences, _api$selectionToolbar;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
3
|
+
._195gv77o{margin-inline:var(--ds-space-025,2px)}
|
|
4
|
+
._1dqonqa1{border-style:solid}
|
|
5
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
6
|
+
._19pk12x7{margin-top:var(--ds-space-075,6px)}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* RemoveColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./RemoveColorMenuItem.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { useIntl } from 'react-intl-next';
|
|
6
|
+
import Button from '@atlaskit/button/new';
|
|
7
|
+
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
8
|
+
import { getInputMethodFromParentKeys } from '@atlaskit/editor-common/toolbar';
|
|
9
|
+
import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
10
|
+
import { useToolbarDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
11
|
+
import { Text } from '@atlaskit/primitives/compiled';
|
|
12
|
+
var styles = {
|
|
13
|
+
removeColorButton: "_2rko12b0 _195gv77o _189ee4h9 _1dqonqa1 _1h6dmuej _19pk12x7"
|
|
14
|
+
};
|
|
15
|
+
export var RemoveColorMenuItem = function RemoveColorMenuItem(_ref) {
|
|
16
|
+
var api = _ref.api,
|
|
17
|
+
parents = _ref.parents;
|
|
18
|
+
var _useIntl = useIntl(),
|
|
19
|
+
formatMessage = _useIntl.formatMessage;
|
|
20
|
+
var context = useToolbarDropdownMenu();
|
|
21
|
+
var closeMenu = context === null || context === void 0 ? void 0 : context.closeMenu;
|
|
22
|
+
var onClick = function onClick() {
|
|
23
|
+
var _api$textColor$shared;
|
|
24
|
+
if (!api) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
var defaultColor = (_api$textColor$shared = api.textColor.sharedState.currentState()) === null || _api$textColor$shared === void 0 ? void 0 : _api$textColor$shared.defaultColor;
|
|
28
|
+
if (!defaultColor) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
api.core.actions.execute(function (_ref2) {
|
|
32
|
+
var _api$highlight;
|
|
33
|
+
var tr = _ref2.tr;
|
|
34
|
+
api.textColor.commands.changeColor(defaultColor, getInputMethodFromParentKeys(parents))({
|
|
35
|
+
tr: tr
|
|
36
|
+
});
|
|
37
|
+
(_api$highlight = api.highlight) === null || _api$highlight === void 0 || _api$highlight.commands.changeColor({
|
|
38
|
+
color: REMOVE_HIGHLIGHT_COLOR,
|
|
39
|
+
inputMethod: getInputMethodFromParentKeys(parents)
|
|
40
|
+
})({
|
|
41
|
+
tr: tr
|
|
42
|
+
});
|
|
43
|
+
return tr;
|
|
44
|
+
});
|
|
45
|
+
closeMenu === null || closeMenu === void 0 || closeMenu();
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: ax([styles.removeColorButton])
|
|
49
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
50
|
+
shouldFitContainer: true,
|
|
51
|
+
appearance: "subtle",
|
|
52
|
+
onClick: onClick
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
54
|
+
weight: "medium"
|
|
55
|
+
}, formatMessage(messages.removeColor))));
|
|
56
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU } from '@atlaskit/editor-common/toolbar';
|
|
6
|
+
import { TEXT_SECTION, TEXT_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP, TEXT_COLOR_HIGHLIGHT_MENU, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK, TEXT_COLOR_HIGHLIGHT_GROUP_RANK, TEXT_COLOR_HIGHLIGHT_MENU_RANK, TEXT_COLLAPSED_MENU_RANK, TEXT_COLLAPSED_MENU, CLEAR_COLOR_MENU_ITEM } from '@atlaskit/editor-common/toolbar';
|
|
7
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { RemoveColorMenuItem } from './RemoveColorMenuItem';
|
|
8
9
|
import { TextColorHighlightMenu } from './TextColorHighlightMenu';
|
|
9
10
|
import { TextColorMenuItem } from './TextColorMenuItem';
|
|
10
11
|
import { TextMenuSection } from './TextMenuSection';
|
|
@@ -43,5 +44,16 @@ export var getToolbarComponents = function getToolbarComponents(api) {
|
|
|
43
44
|
parents: parents
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
|
-
})]
|
|
47
|
+
})].concat(_toConsumableArray(expValEquals('platform_editor_toolbar_aifc_patch_4', 'isEnabled', true) ? [_objectSpread(_objectSpread({}, CLEAR_COLOR_MENU_ITEM), {}, {
|
|
48
|
+
parents: [_objectSpread(_objectSpread({}, TEXT_COLOR_HIGHLIGHT_MENU_SECTION), {}, {
|
|
49
|
+
rank: TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[CLEAR_COLOR_MENU_ITEM.key]
|
|
50
|
+
})],
|
|
51
|
+
component: function component(_ref3) {
|
|
52
|
+
var parents = _ref3.parents;
|
|
53
|
+
return /*#__PURE__*/React.createElement(RemoveColorMenuItem, {
|
|
54
|
+
api: api,
|
|
55
|
+
parents: parents
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
})] : []));
|
|
47
59
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { TextColorPlugin } from '../textColorPluginType';
|
|
3
|
+
import type { TextColorInputMethod } from '../types';
|
|
4
|
+
export declare const changeColor: (color: string, api: ExtractInjectionAPI<TextColorPlugin> | undefined, inputMethod?: TextColorInputMethod) => EditorCommand;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
4
|
+
*/
|
|
2
5
|
export declare const getActiveColor: (state: EditorState) => string | null;
|
|
6
|
+
export declare const getActiveColorNew: (tr: Transaction) => string | null;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
4
|
+
*/
|
|
2
5
|
export declare const getDisabledState: (state: EditorState) => boolean;
|
|
6
|
+
export declare const getDisabledStateNew: (tr: Transaction) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { HighlightPlugin } from '@atlaskit/editor-plugin-highlight';
|
|
4
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
@@ -20,6 +20,9 @@ export type TextColorPlugin = NextEditorPlugin<'textColor', {
|
|
|
20
20
|
actions: {
|
|
21
21
|
changeColor: (color: string, inputMethod?: TextColorInputMethod) => Command;
|
|
22
22
|
};
|
|
23
|
+
commands: {
|
|
24
|
+
changeColor: (color: string, inputMethod?: TextColorInputMethod) => EditorCommand;
|
|
25
|
+
};
|
|
23
26
|
dependencies: Dependencies;
|
|
24
27
|
pluginConfiguration: TextColorPluginOptions | undefined;
|
|
25
28
|
sharedState: TextColorPluginState | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { TextColorPlugin } from '../textColorPluginType';
|
|
4
|
+
type RemoveColorMenuItemButtonProps = {
|
|
5
|
+
api?: ExtractInjectionAPI<TextColorPlugin>;
|
|
6
|
+
parents: ToolbarComponentTypes;
|
|
7
|
+
};
|
|
8
|
+
export declare const RemoveColorMenuItem: ({ api, parents }: RemoveColorMenuItemButtonProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { TextColorPlugin } from '../textColorPluginType';
|
|
3
|
+
import type { TextColorInputMethod } from '../types';
|
|
4
|
+
export declare const changeColor: (color: string, api: ExtractInjectionAPI<TextColorPlugin> | undefined, inputMethod?: TextColorInputMethod) => EditorCommand;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
4
|
+
*/
|
|
2
5
|
export declare const getActiveColor: (state: EditorState) => string | null;
|
|
6
|
+
export declare const getActiveColorNew: (tr: Transaction) => string | null;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
/**
|
|
3
|
+
* Use getDisabledStateNew instead and pass in `tr`
|
|
4
|
+
*/
|
|
2
5
|
export declare const getDisabledState: (state: EditorState) => boolean;
|
|
6
|
+
export declare const getDisabledStateNew: (tr: Transaction) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { HighlightPlugin } from '@atlaskit/editor-plugin-highlight';
|
|
4
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
@@ -20,6 +20,9 @@ export type TextColorPlugin = NextEditorPlugin<'textColor', {
|
|
|
20
20
|
actions: {
|
|
21
21
|
changeColor: (color: string, inputMethod?: TextColorInputMethod) => Command;
|
|
22
22
|
};
|
|
23
|
+
commands: {
|
|
24
|
+
changeColor: (color: string, inputMethod?: TextColorInputMethod) => EditorCommand;
|
|
25
|
+
};
|
|
23
26
|
dependencies: Dependencies;
|
|
24
27
|
pluginConfiguration: TextColorPluginOptions | undefined;
|
|
25
28
|
sharedState: TextColorPluginState | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { TextColorPlugin } from '../textColorPluginType';
|
|
4
|
+
type RemoveColorMenuItemButtonProps = {
|
|
5
|
+
api?: ExtractInjectionAPI<TextColorPlugin>;
|
|
6
|
+
parents: ToolbarComponentTypes;
|
|
7
|
+
};
|
|
8
|
+
export declare const RemoveColorMenuItem: ({ api, parents }: RemoveColorMenuItemButtonProps) => JSX.Element;
|
|
9
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Text color plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^51.
|
|
32
|
+
"@atlaskit/adf-schema": "^51.1.1",
|
|
33
|
+
"@atlaskit/button": "^23.4.0",
|
|
33
34
|
"@atlaskit/css": "^0.14.0",
|
|
34
35
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
35
|
-
"@atlaskit/editor-plugin-analytics": "^5.
|
|
36
|
-
"@atlaskit/editor-plugin-highlight": "^5.
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^5.1.0",
|
|
37
|
+
"@atlaskit/editor-plugin-highlight": "^5.2.0",
|
|
37
38
|
"@atlaskit/editor-plugin-primary-toolbar": "^6.0.0",
|
|
38
39
|
"@atlaskit/editor-plugin-selection-toolbar": "^6.1.0",
|
|
39
40
|
"@atlaskit/editor-plugin-toolbar": "^2.1.0",
|
|
@@ -47,13 +48,13 @@
|
|
|
47
48
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
49
|
"@atlaskit/primitives": "^14.14.0",
|
|
49
50
|
"@atlaskit/theme": "^21.0.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^12.14.0",
|
|
51
52
|
"@atlaskit/tokens": "^6.3.0",
|
|
52
53
|
"@babel/runtime": "^7.0.0",
|
|
53
54
|
"@emotion/react": "^11.7.1"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^109.
|
|
57
|
+
"@atlaskit/editor-common": "^109.3.0",
|
|
57
58
|
"react": "^18.2.0",
|
|
58
59
|
"react-dom": "^18.2.0",
|
|
59
60
|
"react-intl-next": "npm:react-intl@^5.18.1"
|