@atlaskit/editor-core 189.0.9 → 189.0.11

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/index.js +0 -7
  3. package/dist/cjs/plugins/tasks-and-decisions/index.js +15 -5
  4. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
  5. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +40 -0
  6. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -31
  7. package/dist/cjs/presets/universal.js +2 -1
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/plugins/index.js +0 -1
  10. package/dist/es2019/plugins/tasks-and-decisions/index.js +11 -1
  11. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -6
  12. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +36 -0
  13. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +29 -30
  14. package/dist/es2019/presets/universal.js +2 -1
  15. package/dist/es2019/version-wrapper.js +1 -1
  16. package/dist/esm/plugins/index.js +0 -1
  17. package/dist/esm/plugins/tasks-and-decisions/index.js +11 -1
  18. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
  19. package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +34 -0
  20. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -32
  21. package/dist/esm/presets/universal.js +2 -1
  22. package/dist/esm/version-wrapper.js +1 -1
  23. package/dist/types/plugins/index.d.ts +0 -1
  24. package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
  25. package/dist/types/plugins/tasks-and-decisions/types.d.ts +4 -0
  26. package/dist/types/types/editor-props.d.ts +1 -1
  27. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  28. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
  29. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +4 -0
  30. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  31. package/package.json +3 -2
  32. package/report.api.md +1 -12
  33. package/tmp/api-report-tmp.d.ts +1 -12
  34. package/dist/cjs/plugins/text-color/commands/change-color.js +0 -61
  35. package/dist/cjs/plugins/text-color/commands/remove-color.js +0 -59
  36. package/dist/cjs/plugins/text-color/commands/toggle-color.js +0 -36
  37. package/dist/cjs/plugins/text-color/index.js +0 -75
  38. package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -88
  39. package/dist/cjs/plugins/text-color/types.js +0 -5
  40. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -29
  41. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +0 -285
  42. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -38
  43. package/dist/cjs/plugins/text-color/utils/color.js +0 -54
  44. package/dist/cjs/plugins/text-color/utils/disabled.js +0 -32
  45. package/dist/es2019/plugins/text-color/commands/change-color.js +0 -54
  46. package/dist/es2019/plugins/text-color/commands/remove-color.js +0 -57
  47. package/dist/es2019/plugins/text-color/commands/toggle-color.js +0 -30
  48. package/dist/es2019/plugins/text-color/index.js +0 -63
  49. package/dist/es2019/plugins/text-color/pm-plugins/main.js +0 -75
  50. package/dist/es2019/plugins/text-color/types.js +0 -1
  51. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -20
  52. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +0 -265
  53. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -48
  54. package/dist/es2019/plugins/text-color/utils/color.js +0 -48
  55. package/dist/es2019/plugins/text-color/utils/disabled.js +0 -39
  56. package/dist/esm/plugins/text-color/commands/change-color.js +0 -56
  57. package/dist/esm/plugins/text-color/commands/remove-color.js +0 -53
  58. package/dist/esm/plugins/text-color/commands/toggle-color.js +0 -30
  59. package/dist/esm/plugins/text-color/index.js +0 -63
  60. package/dist/esm/plugins/text-color/pm-plugins/main.js +0 -75
  61. package/dist/esm/plugins/text-color/types.js +0 -1
  62. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -22
  63. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +0 -282
  64. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -28
  65. package/dist/esm/plugins/text-color/utils/color.js +0 -48
  66. package/dist/esm/plugins/text-color/utils/disabled.js +0 -26
  67. package/dist/types/plugins/text-color/commands/change-color.d.ts +0 -3
  68. package/dist/types/plugins/text-color/commands/remove-color.d.ts +0 -2
  69. package/dist/types/plugins/text-color/commands/toggle-color.d.ts +0 -2
  70. package/dist/types/plugins/text-color/index.d.ts +0 -7
  71. package/dist/types/plugins/text-color/pm-plugins/main.d.ts +0 -25
  72. package/dist/types/plugins/text-color/types.d.ts +0 -10
  73. package/dist/types/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
  74. package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
  75. package/dist/types/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
  76. package/dist/types/plugins/text-color/utils/color.d.ts +0 -6
  77. package/dist/types/plugins/text-color/utils/disabled.d.ts +0 -2
  78. package/dist/types-ts4.5/plugins/text-color/commands/change-color.d.ts +0 -3
  79. package/dist/types-ts4.5/plugins/text-color/commands/remove-color.d.ts +0 -2
  80. package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +0 -2
  81. package/dist/types-ts4.5/plugins/text-color/index.d.ts +0 -7
  82. package/dist/types-ts4.5/plugins/text-color/pm-plugins/main.d.ts +0 -25
  83. package/dist/types-ts4.5/plugins/text-color/types.d.ts +0 -12
  84. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
  85. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
  86. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
  87. package/dist/types-ts4.5/plugins/text-color/utils/color.d.ts +0 -6
  88. package/dist/types-ts4.5/plugins/text-color/utils/disabled.d.ts +0 -2
@@ -1,88 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ACTIONS = void 0;
8
- Object.defineProperty(exports, "DEFAULT_COLOR", {
9
- enumerable: true,
10
- get: function get() {
11
- return _color.DEFAULT_COLOR;
12
- }
13
- });
14
- exports.createPlugin = createPlugin;
15
- exports.pluginKey = void 0;
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
18
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
19
- var _state = require("@atlaskit/editor-prosemirror/state");
20
- var _uiColor = require("@atlaskit/editor-common/ui-color");
21
- var _color = require("../utils/color");
22
- var _disabled = require("../utils/disabled");
23
- 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; }
24
- 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; }
25
- function createInitialPluginState(editorState, pluginConfig) {
26
- var defaultColor = (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.defaultColor) || _color.DEFAULT_COLOR;
27
- var palette = [{
28
- value: defaultColor.color,
29
- label: defaultColor.label,
30
- border: _uiColor.DEFAULT_BORDER_COLOR
31
- }].concat((0, _toConsumableArray2.default)(_uiColor.textColorPalette));
32
- var state = {
33
- color: (0, _color.getActiveColor)(editorState),
34
- disabled: (0, _disabled.getDisabledState)(editorState),
35
- palette: palette,
36
- defaultColor: defaultColor.color
37
- };
38
- return state;
39
- }
40
- var ACTIONS = exports.ACTIONS = /*#__PURE__*/function (ACTIONS) {
41
- ACTIONS[ACTIONS["RESET_COLOR"] = 0] = "RESET_COLOR";
42
- ACTIONS[ACTIONS["SET_COLOR"] = 1] = "SET_COLOR";
43
- ACTIONS[ACTIONS["DISABLE"] = 2] = "DISABLE";
44
- return ACTIONS;
45
- }({});
46
- var pluginKey = exports.pluginKey = new _state.PluginKey('textColorPlugin');
47
- function createPlugin(dispatch, pluginConfig) {
48
- return new _safePlugin.SafePlugin({
49
- key: pluginKey,
50
- state: {
51
- init: function init(_config, editorState) {
52
- return createInitialPluginState(editorState, pluginConfig);
53
- },
54
- apply: function apply(tr, pluginState, _, newState) {
55
- var meta = tr.getMeta(pluginKey) || {};
56
- var nextState;
57
- switch (meta.action) {
58
- case ACTIONS.RESET_COLOR:
59
- nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
60
- color: pluginState.defaultColor
61
- });
62
- break;
63
- case ACTIONS.SET_COLOR:
64
- nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
65
- color: meta.color,
66
- disabled: false
67
- });
68
- break;
69
- case ACTIONS.DISABLE:
70
- nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
71
- disabled: true
72
- });
73
- break;
74
- default:
75
- nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
76
- color: (0, _color.getActiveColor)(newState),
77
- disabled: (0, _disabled.getDisabledState)(newState)
78
- });
79
- }
80
- if (pluginState && pluginState.color !== nextState.color || pluginState && pluginState.disabled !== nextState.disabled) {
81
- dispatch(pluginKey, nextState);
82
- return nextState;
83
- }
84
- return pluginState;
85
- }
86
- }
87
- });
88
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.EditorTextColorIcon = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _base = _interopRequireDefault(require("@atlaskit/icon/base"));
11
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
12
-
13
- var textColorGlyph = function textColorGlyph(props) {
14
- return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({}, props, {
15
- width: "24",
16
- height: "24",
17
- xmlns: "http://www.w3.org/2000/svg"
18
- }), /*#__PURE__*/_react.default.createElement("path", {
19
- d: "M14 12.5h-4l-.874 2.186A.5.5 0 0 1 8.66 15H7.273a.5.5 0 0 1-.456-.705l4.05-9A.5.5 0 0 1 11.323 5h1.354a.5.5 0 0 1 .456.295l4.05 9a.5.5 0 0 1-.456.705h-1.388a.5.5 0 0 1-.465-.314L14 12.5zm-.6-1.5L12 7.5 10.6 11h2.8z",
20
- fill: "currentColor",
21
- fillRule: "evenodd"
22
- }));
23
- };
24
- var EditorTextColorIcon = exports.EditorTextColorIcon = function EditorTextColorIcon() {
25
- return /*#__PURE__*/_react.default.createElement(_base.default, {
26
- glyph: textColorGlyph,
27
- label: ""
28
- });
29
- };
@@ -1,285 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.messages = exports.default = exports.ToolbarTextColor = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _react = _interopRequireDefault(require("react"));
16
- var _react2 = require("@emotion/react");
17
- var _reactIntlNext = require("react-intl-next");
18
- var _uiColor = require("@atlaskit/editor-common/ui-color");
19
- var _uiMenu = require("@atlaskit/editor-common/ui-menu");
20
- var _styles = require("@atlaskit/editor-common/styles");
21
- var _analytics = require("@atlaskit/editor-common/analytics");
22
- var _editorPalette = require("@atlaskit/editor-palette");
23
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
24
- var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
25
- var _changeColor = require("../../commands/change-color");
26
- var _icon = require("./icon");
27
- var _styles2 = require("./styles");
28
- 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; }
29
- 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; }
30
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
31
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
32
- var EXPERIMENT_NAME = 'editor.toolbarTextColor.moreColors';
33
- var EXPERIMENT_GROUP_CONTROL = 'control';
34
- var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
35
- textColor: {
36
- id: 'fabric.editor.textColor',
37
- defaultMessage: 'Text color',
38
- description: ''
39
- }
40
- });
41
- var ToolbarTextColor = exports.ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
42
- (0, _inherits2.default)(ToolbarTextColor, _React$Component);
43
- var _super = _createSuper(ToolbarTextColor);
44
- function ToolbarTextColor() {
45
- var _this;
46
- (0, _classCallCheck2.default)(this, ToolbarTextColor);
47
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
48
- args[_key] = arguments[_key];
49
- }
50
- _this = _super.call.apply(_super, [this].concat(args));
51
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
52
- isOpen: false,
53
- isOpenedByKeyboard: false
54
- });
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toolbarItemRef", /*#__PURE__*/_react.default.createRef());
56
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "changeColor", function (color, editorAnalyticsApi) {
57
- return (0, _changeColor.changeColor)(color, editorAnalyticsApi)(_this.props.editorView.state, _this.props.editorView.dispatch);
58
- });
59
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onOpenChange", function (attrs) {
60
- _this.handleOpenChange({
61
- isOpen: attrs.isOpen,
62
- logCloseEvent: true,
63
- event: attrs.event
64
- });
65
- });
66
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "changeTextColor", function (color, editorAnalyticsApi, disabled) {
67
- if (!disabled) {
68
- var _this$props$editorVie;
69
- var palette = _this.props.pluginState.palette;
70
-
71
- // we store color names in analytics
72
- var swatch = palette.find(function (sw) {
73
- return sw.value === color;
74
- });
75
- _this.dispatchAnalyticsEvent(_this.buildAnalyticsSelectColor({
76
- color: (swatch ? swatch.label : color).toLowerCase()
77
- }));
78
- _this.handleOpenChange({
79
- isOpen: false,
80
- logCloseEvent: false
81
- });
82
- _this.changeColor(color, editorAnalyticsApi);
83
- //To set the focus on the textcolor button when the menu is closed by 'Esc' only to meet aria guidelines
84
- (_this$props$editorVie = _this.props.editorView) === null || _this$props$editorVie === void 0 || _this$props$editorVie.focus();
85
- }
86
- return false;
87
- });
88
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toggleOpen", function () {
89
- _this.handleOpenChange({
90
- isOpen: !_this.state.isOpen,
91
- logCloseEvent: true
92
- });
93
- });
94
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyDown", function (event) {
95
- if (event.key === 'Enter' || event.key === ' ') {
96
- event.preventDefault();
97
- _this.setState({
98
- isOpenedByKeyboard: true
99
- });
100
- _this.toggleOpen();
101
- }
102
- });
103
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleOpenChange", function (_ref) {
104
- var isOpen = _ref.isOpen,
105
- logCloseEvent = _ref.logCloseEvent,
106
- event = _ref.event;
107
- _this.setState({
108
- isOpen: isOpen
109
- });
110
- if (!isOpen) {
111
- _this.setState({
112
- isOpenedByKeyboard: false
113
- });
114
- }
115
- if (logCloseEvent) {
116
- _this.dispatchAnalyticsEvent(_this.buildAnalyticsPalette(isOpen ? _analytics.ACTION.OPENED : _analytics.ACTION.CLOSED, {
117
- noSelect: isOpen === false
118
- }));
119
- }
120
- if (!isOpen && event instanceof KeyboardEvent && (event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
121
- var _this$toolbarItemRef;
122
- (_this$toolbarItemRef = _this.toolbarItemRef) === null || _this$toolbarItemRef === void 0 || (_this$toolbarItemRef = _this$toolbarItemRef.current) === null || _this$toolbarItemRef === void 0 || _this$toolbarItemRef.focus();
123
- }
124
- });
125
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hide", function (e) {
126
- var isOpen = _this.state.isOpen;
127
- if (isOpen === true) {
128
- _this.dispatchAnalyticsEvent(_this.buildAnalyticsPalette(_analytics.ACTION.CLOSED, {
129
- noSelect: true
130
- }));
131
- _this.setState({
132
- isOpen: false
133
- });
134
- if (e instanceof KeyboardEvent && e.key === 'Escape') {
135
- var _this$toolbarItemRef2;
136
- (_this$toolbarItemRef2 = _this.toolbarItemRef) === null || _this$toolbarItemRef2 === void 0 || (_this$toolbarItemRef2 = _this$toolbarItemRef2.current) === null || _this$toolbarItemRef2 === void 0 || _this$toolbarItemRef2.focus();
137
- }
138
- }
139
- });
140
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hideonEsc", function (e) {
141
- var _this$toolbarItemRef3;
142
- _this.hide(e);
143
- (_this$toolbarItemRef3 = _this.toolbarItemRef) === null || _this$toolbarItemRef3 === void 0 || (_this$toolbarItemRef3 = _this$toolbarItemRef3.current) === null || _this$toolbarItemRef3 === void 0 || _this$toolbarItemRef3.focus();
144
- });
145
- return _this;
146
- }
147
- (0, _createClass2.default)(ToolbarTextColor, [{
148
- key: "render",
149
- value: function render() {
150
- var _this2 = this;
151
- var _this$state = this.state,
152
- isOpen = _this$state.isOpen,
153
- isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
154
- var _this$props = this.props,
155
- popupsMountPoint = _this$props.popupsMountPoint,
156
- popupsBoundariesElement = _this$props.popupsBoundariesElement,
157
- popupsScrollableElement = _this$props.popupsScrollableElement,
158
- isReducedSpacing = _this$props.isReducedSpacing,
159
- pluginState = _this$props.pluginState,
160
- formatMessage = _this$props.intl.formatMessage,
161
- disabled = _this$props.disabled,
162
- pluginInjectionApi = _this$props.pluginInjectionApi;
163
- var labelTextColor = formatMessage(messages.textColor);
164
- var palette = pluginState.palette;
165
- var fitWidth;
166
- if (document.body.clientWidth <= 740) {
167
- // This was originally hard-coded, but moved here to a const
168
- // My guess is it's based off (width of button * columns) + left/right padding
169
- // 240 = (32 * 7) + (8 + 8)
170
- // Not sure where the extra 2px comes from
171
- fitWidth = 242;
172
- }
173
- var selectedColor = this.getSelectedColor(pluginState);
174
- var _getSelectedRowAndCol = (0, _uiColor.getSelectedRowAndColumnFromPalette)(palette, pluginState.color),
175
- selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
176
- selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
177
- return (0, _react2.jsx)("span", {
178
- css: _styles.wrapperStyle
179
- }, (0, _react2.jsx)(_uiMenu.DropdownContainer, {
180
- mountTo: popupsMountPoint,
181
- boundariesElement: popupsBoundariesElement,
182
- scrollableElement: popupsScrollableElement,
183
- isOpen: isOpen && !pluginState.disabled,
184
- handleClickOutside: this.hide,
185
- handleEscapeKeydown: this.hideonEsc,
186
- zIndex: _editorSharedStyles.akEditorMenuZIndex,
187
- fitWidth: fitWidth,
188
- onOpenChange: this.onOpenChange,
189
- closeOnTab: true,
190
- arrowKeyNavigationProviderOptions: {
191
- type: _uiMenu.ArrowKeyNavigationType.COLOR,
192
- selectedRowIndex: selectedRowIndex,
193
- selectedColumnIndex: selectedColumnIndex,
194
- isOpenedByKeyboard: isOpenedByKeyboard,
195
- isPopupPositioned: true
196
- },
197
- trigger: (0, _react2.jsx)(_uiMenu.ToolbarButton, {
198
- buttonId: _uiMenu.TOOLBAR_BUTTON.TEXT_COLOR,
199
- spacing: isReducedSpacing ? 'none' : 'default',
200
- disabled: disabled || pluginState.disabled,
201
- selected: isOpen,
202
- "aria-label": labelTextColor,
203
- "aria-expanded": isOpen,
204
- "aria-haspopup": true,
205
- title: labelTextColor,
206
- onClick: this.toggleOpen,
207
- onKeyDown: this.onKeyDown,
208
- ref: this.toolbarItemRef,
209
- iconBefore: (0, _react2.jsx)("div", {
210
- css: _styles.triggerWrapperStyles
211
- }, (0, _react2.jsx)("div", {
212
- css: _styles2.textColorIconWrapper
213
- }, (0, _react2.jsx)(_icon.EditorTextColorIcon, null), (0, _react2.jsx)("div", {
214
- css: [_styles2.textColorIconBar, selectedColor ? "background: ".concat(selectedColor, ";") : pluginState.disabled && _styles2.backgroundDisabled]
215
- })), (0, _react2.jsx)("span", {
216
- css: _styles.expandIconWrapperStyle
217
- }, (0, _react2.jsx)(_chevronDown.default, {
218
- label: ""
219
- })))
220
- })
221
- }, (0, _react2.jsx)("div", {
222
- "data-testid": "text-color-palette"
223
- }, (0, _react2.jsx)(_uiColor.ColorPalette, {
224
- onClick: function onClick(color) {
225
- var _pluginInjectionApi$a;
226
- return _this2.changeTextColor(color, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, pluginState.disabled);
227
- },
228
- selectedColor: pluginState.color,
229
- paletteOptions: {
230
- palette: palette,
231
- hexToPaletteColor: _editorPalette.hexToEditorTextPaletteColor,
232
- paletteColorTooltipMessages: _uiColor.textPaletteTooltipMessages
233
- }
234
- }))), (0, _react2.jsx)("span", {
235
- css: _styles.separatorStyles
236
- }));
237
- }
238
- }, {
239
- key: "getSelectedColor",
240
- value: function getSelectedColor(pluginState) {
241
- var selectedColor = pluginState.color !== pluginState.defaultColor && (pluginState.color ? (0, _editorPalette.hexToEditorTextPaletteColor)(pluginState.color) : pluginState.color);
242
- return selectedColor;
243
- }
244
- }, {
245
- key: "getCommonAnalyticsAttributes",
246
- value: function getCommonAnalyticsAttributes() {
247
- return {
248
- experiment: EXPERIMENT_NAME,
249
- experimentGroup: EXPERIMENT_GROUP_CONTROL
250
- };
251
- }
252
- }, {
253
- key: "buildAnalyticsPalette",
254
- value: function buildAnalyticsPalette(action, data) {
255
- return {
256
- action: action,
257
- actionSubject: _analytics.ACTION_SUBJECT.TOOLBAR,
258
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
259
- eventType: _analytics.EVENT_TYPE.TRACK,
260
- attributes: _objectSpread(_objectSpread({}, this.getCommonAnalyticsAttributes()), data)
261
- };
262
- }
263
- }, {
264
- key: "buildAnalyticsSelectColor",
265
- value: function buildAnalyticsSelectColor(data) {
266
- return {
267
- action: _analytics.ACTION.FORMATTED,
268
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
269
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
270
- eventType: _analytics.EVENT_TYPE.TRACK,
271
- attributes: _objectSpread(_objectSpread({}, this.getCommonAnalyticsAttributes()), data)
272
- };
273
- }
274
- }, {
275
- key: "dispatchAnalyticsEvent",
276
- value: function dispatchAnalyticsEvent(payload) {
277
- var dispatchAnalyticsEvent = this.props.dispatchAnalyticsEvent;
278
- if (dispatchAnalyticsEvent) {
279
- dispatchAnalyticsEvent(payload);
280
- }
281
- }
282
- }]);
283
- return ToolbarTextColor;
284
- }(_react.default.Component);
285
- var _default = exports.default = (0, _reactIntlNext.injectIntl)(ToolbarTextColor);
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.textColorIconWrapper = exports.textColorIconBar = exports.backgroundDisabled = void 0;
9
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
- var _react = require("@emotion/react");
11
- var _constants = require("@atlaskit/theme/constants");
12
- var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
13
- var _templateObject, _templateObject2, _templateObject3;
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
- var createSteppedRainbow = function createSteppedRainbow(colors) {
17
- return "\n linear-gradient(\n to right,\n ".concat(colors.map(function (color, i) {
18
- var inc = 100 / colors.length;
19
- var pos = i + 1;
20
- if (i === 0) {
21
- return "".concat(color, " ").concat(pos * inc, "%,");
22
- }
23
- if (i === colors.length - 1) {
24
- return "".concat(color, " ").concat((pos - 1) * inc, "%");
25
- }
26
- return "\n ".concat(color, " ").concat((pos - 1) * inc, "%,\n ").concat(color, " ").concat(pos * inc, "%,\n ");
27
- }).join('\n'), "\n );\n ");
28
- };
29
-
30
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4137
31
- /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
32
- var rainbow = createSteppedRainbow([colors.P300, colors.T300, colors.Y400, colors.R400]);
33
- var disabledRainbow = createSteppedRainbow([colors.N80, colors.N60, colors.N40, colors.N60]);
34
- /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
35
-
36
- var textColorIconWrapper = exports.textColorIconWrapper = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n"])));
37
- var textColorIconBar = exports.textColorIconBar = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n left: 0;\n right: 0;\n top: 16px;\n margin: auto;\n width: 12px;\n height: 3px;\n border-radius: ", ";\n background: ", ";\n"])), (0, _constants.borderRadius)() + 'px', rainbow);
38
- var backgroundDisabled = exports.backgroundDisabled = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n"])), disabledRainbow);
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getActiveColor = exports.DEFAULT_COLOR = void 0;
7
- var _colors = require("@atlaskit/theme/colors");
8
- var DEFAULT_COLOR = exports.DEFAULT_COLOR = {
9
- // TODO: https://product-fabric.atlassian.net/browse/DSP-4137
10
- /* eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage */
11
- color: _colors.N800.toLowerCase(),
12
- label: 'Dark gray'
13
- };
14
- var getActiveColor = exports.getActiveColor = function getActiveColor(state) {
15
- var _ref = state.selection,
16
- $from = _ref.$from,
17
- $to = _ref.$to,
18
- $cursor = _ref.$cursor;
19
- var _ref2 = state.schema.marks,
20
- textColor = _ref2.textColor;
21
-
22
- // Filter out other marks
23
- var marks = [];
24
- if ($cursor) {
25
- marks.push(textColor.isInSet(state.storedMarks || $cursor.marks()) || undefined);
26
- } else {
27
- state.doc.nodesBetween($from.pos, $to.pos, function (currentNode) {
28
- if (currentNode.isLeaf) {
29
- var mark = textColor.isInSet(currentNode.marks) || undefined;
30
- marks.push(mark);
31
- return !mark;
32
- }
33
- return true;
34
- });
35
- }
36
-
37
- // Merge consecutive same color marks
38
- var prevMark;
39
- marks = marks.filter(function (mark) {
40
- if (mark && prevMark && mark.attrs.color === prevMark.attrs.color) {
41
- return false;
42
- }
43
- prevMark = mark;
44
- return true;
45
- });
46
- var marksWithColor = marks.filter(function (mark) {
47
- return !!mark;
48
- });
49
- // When multiple colors are selected revert back to default color
50
- if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
51
- return null;
52
- }
53
- return marksWithColor.length ? marksWithColor[0].attrs.color : DEFAULT_COLOR.color;
54
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDisabledState = void 0;
7
- var _mark = require("@atlaskit/editor-common/mark");
8
- var hasLinkMark = function hasLinkMark($pos) {
9
- var linkMarkType = $pos.doc.type.schema.marks.link,
10
- pos = $pos.pos;
11
- if (!linkMarkType) {
12
- return false;
13
- }
14
- return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
15
- };
16
- var getDisabledState = exports.getDisabledState = function getDisabledState(state) {
17
- var textColor = state.schema.marks.textColor;
18
- if (textColor) {
19
- var _ref = state.selection,
20
- empty = _ref.empty,
21
- ranges = _ref.ranges,
22
- $cursor = _ref.$cursor;
23
- if (empty && !$cursor || $cursor && hasLinkMark($cursor) || (0, _mark.isMarkAllowedInRange)(state.doc, ranges, textColor) === false) {
24
- return true;
25
- }
26
- if ((0, _mark.isMarkExcluded)(textColor, state.storedMarks || $cursor && $cursor.marks())) {
27
- return true;
28
- }
29
- return false;
30
- }
31
- return true;
32
- };
@@ -1,54 +0,0 @@
1
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
- import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
3
- import { pluginKey } from '../pm-plugins/main';
4
- import { getActiveColor } from '../utils/color';
5
- import { removeColor } from './remove-color';
6
- import { toggleColor } from './toggle-color';
7
-
8
- /**
9
- * Helper to create a higher order analytics command
10
- * @param newColor - Color to be change in hex code
11
- * @param previousColor - Active color in hex code
12
- * @param palette - Current palette of colors
13
- * @return Higher order command with analytics logic inside.
14
- */
15
- function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyticsApi) {
16
- const newColorFromPalette = palette.find(({
17
- value
18
- }) => value === newColor);
19
- const previousColorFromPalette = palette.find(({
20
- value
21
- }) => value === previousColor);
22
- const newColorLabel = newColorFromPalette ? newColorFromPalette.label : newColor;
23
- const previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor || '';
24
- return withAnalytics(editorAnalyticsApi, {
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
- }
33
- });
34
- }
35
- export const changeColor = (color, editorAnalyticsApi) => (state, dispatch) => {
36
- const {
37
- textColor
38
- } = state.schema.marks;
39
- if (textColor) {
40
- const pluginState = pluginKey.getState(state);
41
- const activeColor = getActiveColor(state);
42
- const withColorAnalytics = createWithColorAnalytics(color, activeColor, (pluginState === null || pluginState === void 0 ? void 0 : pluginState.palette) || [], editorAnalyticsApi);
43
- if (pluginState !== null && pluginState !== void 0 && pluginState.disabled) {
44
- return false;
45
- }
46
- if (color === (pluginState === null || pluginState === void 0 ? void 0 : pluginState.defaultColor)) {
47
- withColorAnalytics(removeColor())(state, dispatch);
48
- return true;
49
- }
50
- withColorAnalytics(toggleColor(color))(state, dispatch);
51
- return true;
52
- }
53
- return false;
54
- };
@@ -1,57 +0,0 @@
1
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
- import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
- import { ACTIONS, pluginKey } from '../pm-plugins/main';
4
- export const removeColor = () => (state, dispatch) => {
5
- const {
6
- schema,
7
- selection
8
- } = state;
9
- const {
10
- textColor
11
- } = schema.marks;
12
- let tr = state.tr;
13
- if (selection instanceof TextSelection) {
14
- const {
15
- from,
16
- to,
17
- $cursor
18
- } = selection;
19
- if ($cursor) {
20
- tr = state.tr.removeStoredMark(textColor);
21
- } else {
22
- tr = state.tr.removeMark(from, to, textColor);
23
- }
24
- }
25
- if (selection instanceof CellSelection) {
26
- /**
27
- * This is a slight abstraction from `src/utils/commands.ts`
28
- * The main difference is we can't toggle the default from another (since they are different marks),
29
- * we want to remove all text color marks on the selection, so we slightly modify the cell selection
30
- * part here.
31
- */
32
- selection.forEachCell((cell, cellPos) => {
33
- const from = cellPos;
34
- const to = cellPos + cell.nodeSize;
35
- tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), (node, pos) => {
36
- if (!node.isText) {
37
- return true;
38
- }
39
-
40
- // This is an issue when the user selects some text.
41
- // We need to check if the current node position is less than the range selection from.
42
- // If it’s true, that means we should apply the mark using the range selection,
43
- // not the current node position.
44
- const nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
45
- const nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
46
- tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
47
- return true;
48
- });
49
- });
50
- }
51
- if (dispatch) {
52
- dispatch(tr.setMeta(pluginKey, {
53
- action: ACTIONS.RESET_COLOR
54
- }));
55
- }
56
- return true;
57
- };