@atlaskit/editor-plugin-rule 22.0.0 → 24.0.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-rule
2
2
 
3
+ ## 24.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 23.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [`281a2188b8d83`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/281a2188b8d83) -
14
+ [ux] [EDITOR-8348] this change adds a color picker to the divider floating toolbar behind
15
+ `platform_editor_lovability_dividers`. the selected color is applied behind
16
+ `platform_editor_lovability_dividers_attributes`.
17
+ - Updated dependencies
18
+
3
19
  ## 22.0.0
4
20
 
5
21
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateHorizontalRuleWeight = exports.updateHorizontalRuleStyle = exports.removeHorizontalRule = exports.insertHorizontalRule = void 0;
7
+ exports.updateHorizontalRuleWeight = exports.updateHorizontalRuleStyle = exports.updateHorizontalRuleColor = exports.removeHorizontalRule = exports.insertHorizontalRule = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
@@ -109,4 +109,36 @@ var updateHorizontalRuleStyle = exports.updateHorizontalRuleStyle = function upd
109
109
  }
110
110
  return true;
111
111
  };
112
+ };
113
+ var updateHorizontalRuleColor = exports.updateHorizontalRuleColor = function updateHorizontalRuleColor(color, editorAnalyticsAPI) {
114
+ return function (state, dispatch) {
115
+ var rule = state.schema.nodes.rule;
116
+ var selectedRule = (0, _utils.findSelectedNodeOfType)(rule)(state.selection);
117
+ if (!selectedRule) {
118
+ return false;
119
+ }
120
+ var defaultColor = "var(--ds-border, #0B120E24)";
121
+ var previousColor = typeof selectedRule.node.attrs.color === 'string' ? selectedRule.node.attrs.color : null;
122
+ var updatedColor = color === defaultColor ? null : color;
123
+ if (previousColor === updatedColor) {
124
+ return true;
125
+ }
126
+ if (dispatch) {
127
+ var updateTr = state.tr.setNodeMarkup(selectedRule.pos, undefined, _objectSpread(_objectSpread({}, selectedRule.node.attrs), {}, {
128
+ color: updatedColor
129
+ }));
130
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
131
+ action: _analytics.ACTION.UPDATED,
132
+ actionSubject: _analytics.ACTION_SUBJECT.DIVIDER,
133
+ attributes: {
134
+ inputMethod: _analytics.INPUT_METHOD.FLOATING_TB,
135
+ previousColor: previousColor,
136
+ color: updatedColor
137
+ },
138
+ eventType: _analytics.EVENT_TYPE.TRACK
139
+ })(updateTr);
140
+ dispatch(updateTr);
141
+ }
142
+ return true;
143
+ };
112
144
  };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.dividerColorPalette = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _rule = require("@atlaskit/editor-common/messages/rule");
11
+ var _uiColor = require("@atlaskit/editor-common/ui-color");
12
+ 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; }
13
+ 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; }
14
+ /**
15
+ * The dividerColorPalette mirrors the textColorPalette, with the following minor changes –
16
+ */
17
+ var dividerColorPalette = exports.dividerColorPalette = [
18
+ // 1. the textColorPalette does not have the "bold gray" color. it is added separately
19
+ // in `platform/packages/editor/editor-plugin-text-color/src/pm-plugins/utils/constants.ts`
20
+ // by editor-plugin-text-color so we need to do the same for the dividerColorPalette
21
+ {
22
+ border: "var(--ds-border, #0B120E24)",
23
+ label: _rule.ruleMessages.boldGrayDividerColor.defaultMessage,
24
+ message: _rule.ruleMessages.boldGrayDividerColor,
25
+ value: '#172B4D'
26
+ }].concat((0, _toConsumableArray2.default)(_uiColor.textColorPaletteNew.map(function (swatch) {
27
+ return swatch.value.toUpperCase() === '#FFFFFF' ? _objectSpread(_objectSpread({}, swatch), {}, {
28
+ label: _rule.ruleMessages.defaultDividerColor.defaultMessage,
29
+ message: undefined,
30
+ value: "var(--ds-border, #0B120E24)"
31
+ }) : swatch;
32
+ })));
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.dividerPaletteTooltipMessages = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _rule = require("@atlaskit/editor-common/messages/rule");
10
+ var _uiColor = require("@atlaskit/editor-common/ui-color");
11
+ 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; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ // from platform/packages/editor/editor-plugin-text-color/src/pm-plugins/utils/constants.t
14
+ var defaultTextColor = '#172B4D';
15
+
16
+ // The dividerPaletteTooltipMessages mirrors the textPaletteTooltipMessages and overrides the 'Default' text color with the 'Bold gray' tooltip message.
17
+ var dividerPaletteTooltipMessages = exports.dividerPaletteTooltipMessages = {
18
+ light: _objectSpread(_objectSpread({}, _uiColor.textPaletteTooltipMessages.light), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, defaultTextColor, _rule.ruleMessages.boldGrayDividerColor), "var(--ds-border, #0B120E24)".toUpperCase(), _rule.ruleMessages.defaultDividerColor)),
19
+ dark: _objectSpread(_objectSpread({}, _uiColor.textPaletteTooltipMessages.dark), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, defaultTextColor, _rule.ruleMessages.boldGrayDividerColor), "var(--ds-border, #0B120E24)".toUpperCase(), _rule.ruleMessages.defaultDividerColor))
20
+ };
@@ -10,17 +10,20 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
12
12
  var _rule = require("@atlaskit/editor-common/messages/rule");
13
+ var _text = require("@atlaskit/editor-palette/text");
13
14
  var _utils = require("@atlaskit/editor-prosemirror/utils");
14
15
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
15
16
  var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
16
17
  var _customize = _interopRequireDefault(require("@atlaskit/icon/core/customize"));
17
18
  var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
18
19
  var _commands = require("../pm-plugins/commands");
20
+ var _dividerColorPalette = require("./dividerColorPalette");
21
+ var _dividerColorPaletteMessages = require("./dividerColorPaletteMessages");
19
22
  var _DividerOptions = require("./DividerOptions");
20
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; }
21
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; }
22
25
  var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, ruleAttrs, api) {
23
- var _api$decorations, _api$analytics3;
26
+ var _api$decorations, _api$analytics4;
24
27
  var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
25
28
  var hoverDecorationProps = function hoverDecorationProps(className) {
26
29
  return {
@@ -30,6 +33,7 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, rule
30
33
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(ruleNodeType, false, className)
31
34
  };
32
35
  };
36
+ var currentColor = ruleAttrs.color || "var(--ds-border, #0B120E24)";
33
37
  var items = [{
34
38
  id: 'divider-options',
35
39
  type: 'dropdown',
@@ -55,6 +59,30 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, rule
55
59
  });
56
60
  }
57
61
  }
62
+ }, {
63
+ id: 'divider-color-picker',
64
+ type: 'select',
65
+ selectType: 'color',
66
+ title: formatMessage(_rule.ruleMessages.dividerColors),
67
+ isAriaExpanded: true,
68
+ hideExpandIcon: true,
69
+ defaultValue: _dividerColorPalette.dividerColorPalette.find(function (color) {
70
+ return color.value === currentColor;
71
+ }) || {
72
+ label: formatMessage(_rule.ruleMessages.customDividerColor),
73
+ value: currentColor,
74
+ border: _dividerColorPalette.dividerColorPalette[0].border
75
+ },
76
+ options: _dividerColorPalette.dividerColorPalette,
77
+ cols: 10,
78
+ hexToPaletteColor: function hexToPaletteColor(color) {
79
+ return color === "var(--ds-border, #0B120E24)" ? color : (0, _text.hexToEditorTextPaletteColor)(color);
80
+ },
81
+ paletteColorTooltipMessages: _dividerColorPaletteMessages.dividerPaletteTooltipMessages,
82
+ onChange: function onChange(option) {
83
+ var _api$analytics3;
84
+ return (0, _commands.updateHorizontalRuleColor)(option.value, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
85
+ }
58
86
  }, {
59
87
  type: 'separator',
60
88
  fullHeight: true
@@ -76,7 +104,7 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, rule
76
104
  icon: /*#__PURE__*/_react.default.createElement(_delete.default, {
77
105
  label: ""
78
106
  }),
79
- onClick: (0, _commands.removeHorizontalRule)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
107
+ onClick: (0, _commands.removeHorizontalRule)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)
80
108
  }, hoverDecorationProps())]
81
109
  }];
82
110
  items.push.apply(items, overflowMenuItems);
@@ -97,4 +97,37 @@ export const updateHorizontalRuleStyle = (style, editorAnalyticsAPI) => (state,
97
97
  dispatch(updateTr);
98
98
  }
99
99
  return true;
100
+ };
101
+ export const updateHorizontalRuleColor = (color, editorAnalyticsAPI) => (state, dispatch) => {
102
+ const {
103
+ rule
104
+ } = state.schema.nodes;
105
+ const selectedRule = findSelectedNodeOfType(rule)(state.selection);
106
+ if (!selectedRule) {
107
+ return false;
108
+ }
109
+ const defaultColor = "var(--ds-border, #0B120E24)";
110
+ const previousColor = typeof selectedRule.node.attrs.color === 'string' ? selectedRule.node.attrs.color : null;
111
+ const updatedColor = color === defaultColor ? null : color;
112
+ if (previousColor === updatedColor) {
113
+ return true;
114
+ }
115
+ if (dispatch) {
116
+ const updateTr = state.tr.setNodeMarkup(selectedRule.pos, undefined, {
117
+ ...selectedRule.node.attrs,
118
+ color: updatedColor
119
+ });
120
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
121
+ action: ACTION.UPDATED,
122
+ actionSubject: ACTION_SUBJECT.DIVIDER,
123
+ attributes: {
124
+ inputMethod: INPUT_METHOD.FLOATING_TB,
125
+ previousColor,
126
+ color: updatedColor
127
+ },
128
+ eventType: EVENT_TYPE.TRACK
129
+ })(updateTr);
130
+ dispatch(updateTr);
131
+ }
132
+ return true;
100
133
  };
@@ -0,0 +1,22 @@
1
+ import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
2
+ import { textColorPaletteNew } from '@atlaskit/editor-common/ui-color';
3
+ /**
4
+ * The dividerColorPalette mirrors the textColorPalette, with the following minor changes –
5
+ */
6
+ export const dividerColorPalette = [
7
+ // 1. the textColorPalette does not have the "bold gray" color. it is added separately
8
+ // in `platform/packages/editor/editor-plugin-text-color/src/pm-plugins/utils/constants.ts`
9
+ // by editor-plugin-text-color so we need to do the same for the dividerColorPalette
10
+ {
11
+ border: "var(--ds-border, #0B120E24)",
12
+ label: ruleMessages.boldGrayDividerColor.defaultMessage,
13
+ message: ruleMessages.boldGrayDividerColor,
14
+ value: '#172B4D'
15
+ },
16
+ // 2. the dividerColorPalette replaces textColorPalette's white with the divider's default color.
17
+ ...textColorPaletteNew.map(swatch => swatch.value.toUpperCase() === '#FFFFFF' ? {
18
+ ...swatch,
19
+ label: ruleMessages.defaultDividerColor.defaultMessage,
20
+ message: undefined,
21
+ value: "var(--ds-border, #0B120E24)"
22
+ } : swatch)];
@@ -0,0 +1,18 @@
1
+ import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
2
+ import { textPaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
3
+ // from platform/packages/editor/editor-plugin-text-color/src/pm-plugins/utils/constants.t
4
+ const defaultTextColor = '#172B4D';
5
+
6
+ // The dividerPaletteTooltipMessages mirrors the textPaletteTooltipMessages and overrides the 'Default' text color with the 'Bold gray' tooltip message.
7
+ export const dividerPaletteTooltipMessages = {
8
+ light: {
9
+ ...textPaletteTooltipMessages.light,
10
+ [defaultTextColor]: ruleMessages.boldGrayDividerColor,
11
+ ["var(--ds-border, #0B120E24)".toUpperCase()]: ruleMessages.defaultDividerColor
12
+ },
13
+ dark: {
14
+ ...textPaletteTooltipMessages.dark,
15
+ [defaultTextColor]: ruleMessages.boldGrayDividerColor,
16
+ ["var(--ds-border, #0B120E24)".toUpperCase()]: ruleMessages.defaultDividerColor
17
+ }
18
+ };
@@ -2,15 +2,18 @@ import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import commonMessages from '@atlaskit/editor-common/messages';
4
4
  import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
5
+ import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette/text';
5
6
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
7
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
7
8
  import CopyIcon from '@atlaskit/icon/core/copy';
8
9
  import CustomizeIcon from '@atlaskit/icon/core/customize';
9
10
  import DeleteIcon from '@atlaskit/icon/core/delete';
10
- import { removeHorizontalRule, updateHorizontalRuleStyle, updateHorizontalRuleWeight } from '../pm-plugins/commands';
11
+ import { removeHorizontalRule, updateHorizontalRuleColor, updateHorizontalRuleStyle, updateHorizontalRuleWeight } from '../pm-plugins/commands';
12
+ import { dividerColorPalette } from './dividerColorPalette';
13
+ import { dividerPaletteTooltipMessages } from './dividerColorPaletteMessages';
11
14
  import { DividerOptions } from './DividerOptions';
12
15
  const getToolbarItems = (formatMessage, ruleNodeType, ruleAttrs, api) => {
13
- var _api$decorations, _api$analytics3;
16
+ var _api$decorations, _api$analytics4;
14
17
  const hoverDecoration = api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
15
18
  const hoverDecorationProps = className => ({
16
19
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(ruleNodeType, true, className),
@@ -18,6 +21,7 @@ const getToolbarItems = (formatMessage, ruleNodeType, ruleAttrs, api) => {
18
21
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(ruleNodeType, true, className),
19
22
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(ruleNodeType, false, className)
20
23
  });
24
+ const currentColor = ruleAttrs.color || "var(--ds-border, #0B120E24)";
21
25
  const items = [{
22
26
  id: 'divider-options',
23
27
  type: 'dropdown',
@@ -42,6 +46,26 @@ const getToolbarItems = (formatMessage, ruleNodeType, ruleAttrs, api) => {
42
46
  }
43
47
  })
44
48
  }
49
+ }, {
50
+ id: 'divider-color-picker',
51
+ type: 'select',
52
+ selectType: 'color',
53
+ title: formatMessage(ruleMessages.dividerColors),
54
+ isAriaExpanded: true,
55
+ hideExpandIcon: true,
56
+ defaultValue: dividerColorPalette.find(color => color.value === currentColor) || {
57
+ label: formatMessage(ruleMessages.customDividerColor),
58
+ value: currentColor,
59
+ border: dividerColorPalette[0].border
60
+ },
61
+ options: dividerColorPalette,
62
+ cols: 10,
63
+ hexToPaletteColor: color => color === "var(--ds-border, #0B120E24)" ? color : hexToEditorTextPaletteColor(color),
64
+ paletteColorTooltipMessages: dividerPaletteTooltipMessages,
65
+ onChange: option => {
66
+ var _api$analytics3;
67
+ return updateHorizontalRuleColor(option.value, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
68
+ }
45
69
  }, {
46
70
  type: 'separator',
47
71
  fullHeight: true
@@ -64,7 +88,7 @@ const getToolbarItems = (formatMessage, ruleNodeType, ruleAttrs, api) => {
64
88
  icon: /*#__PURE__*/React.createElement(DeleteIcon, {
65
89
  label: ""
66
90
  }),
67
- onClick: removeHorizontalRule(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
91
+ onClick: removeHorizontalRule(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
68
92
  ...hoverDecorationProps()
69
93
  }]
70
94
  }];
@@ -102,4 +102,36 @@ export var updateHorizontalRuleStyle = function updateHorizontalRuleStyle(style,
102
102
  }
103
103
  return true;
104
104
  };
105
+ };
106
+ export var updateHorizontalRuleColor = function updateHorizontalRuleColor(color, editorAnalyticsAPI) {
107
+ return function (state, dispatch) {
108
+ var rule = state.schema.nodes.rule;
109
+ var selectedRule = findSelectedNodeOfType(rule)(state.selection);
110
+ if (!selectedRule) {
111
+ return false;
112
+ }
113
+ var defaultColor = "var(--ds-border, #0B120E24)";
114
+ var previousColor = typeof selectedRule.node.attrs.color === 'string' ? selectedRule.node.attrs.color : null;
115
+ var updatedColor = color === defaultColor ? null : color;
116
+ if (previousColor === updatedColor) {
117
+ return true;
118
+ }
119
+ if (dispatch) {
120
+ var updateTr = state.tr.setNodeMarkup(selectedRule.pos, undefined, _objectSpread(_objectSpread({}, selectedRule.node.attrs), {}, {
121
+ color: updatedColor
122
+ }));
123
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
124
+ action: ACTION.UPDATED,
125
+ actionSubject: ACTION_SUBJECT.DIVIDER,
126
+ attributes: {
127
+ inputMethod: INPUT_METHOD.FLOATING_TB,
128
+ previousColor: previousColor,
129
+ color: updatedColor
130
+ },
131
+ eventType: EVENT_TYPE.TRACK
132
+ })(updateTr);
133
+ dispatch(updateTr);
134
+ }
135
+ return true;
136
+ };
105
137
  };
@@ -0,0 +1,25 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
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
+ 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
+ import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
6
+ import { textColorPaletteNew } from '@atlaskit/editor-common/ui-color';
7
+ /**
8
+ * The dividerColorPalette mirrors the textColorPalette, with the following minor changes –
9
+ */
10
+ export var dividerColorPalette = [
11
+ // 1. the textColorPalette does not have the "bold gray" color. it is added separately
12
+ // in `platform/packages/editor/editor-plugin-text-color/src/pm-plugins/utils/constants.ts`
13
+ // by editor-plugin-text-color so we need to do the same for the dividerColorPalette
14
+ {
15
+ border: "var(--ds-border, #0B120E24)",
16
+ label: ruleMessages.boldGrayDividerColor.defaultMessage,
17
+ message: ruleMessages.boldGrayDividerColor,
18
+ value: '#172B4D'
19
+ }].concat(_toConsumableArray(textColorPaletteNew.map(function (swatch) {
20
+ return swatch.value.toUpperCase() === '#FFFFFF' ? _objectSpread(_objectSpread({}, swatch), {}, {
21
+ label: ruleMessages.defaultDividerColor.defaultMessage,
22
+ message: undefined,
23
+ value: "var(--ds-border, #0B120E24)"
24
+ }) : swatch;
25
+ })));
@@ -0,0 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
5
+ import { textPaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
6
+ // from platform/packages/editor/editor-plugin-text-color/src/pm-plugins/utils/constants.t
7
+ var defaultTextColor = '#172B4D';
8
+
9
+ // The dividerPaletteTooltipMessages mirrors the textPaletteTooltipMessages and overrides the 'Default' text color with the 'Bold gray' tooltip message.
10
+ export var dividerPaletteTooltipMessages = {
11
+ light: _objectSpread(_objectSpread({}, textPaletteTooltipMessages.light), {}, _defineProperty(_defineProperty({}, defaultTextColor, ruleMessages.boldGrayDividerColor), "var(--ds-border, #0B120E24)".toUpperCase(), ruleMessages.defaultDividerColor)),
12
+ dark: _objectSpread(_objectSpread({}, textPaletteTooltipMessages.dark), {}, _defineProperty(_defineProperty({}, defaultTextColor, ruleMessages.boldGrayDividerColor), "var(--ds-border, #0B120E24)".toUpperCase(), ruleMessages.defaultDividerColor))
13
+ };
@@ -5,15 +5,18 @@ import React from 'react';
5
5
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import commonMessages from '@atlaskit/editor-common/messages';
7
7
  import { ruleMessages } from '@atlaskit/editor-common/messages/rule';
8
+ import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette/text';
8
9
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
10
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
10
11
  import CopyIcon from '@atlaskit/icon/core/copy';
11
12
  import CustomizeIcon from '@atlaskit/icon/core/customize';
12
13
  import DeleteIcon from '@atlaskit/icon/core/delete';
13
- import { removeHorizontalRule, updateHorizontalRuleStyle, updateHorizontalRuleWeight } from '../pm-plugins/commands';
14
+ import { removeHorizontalRule, updateHorizontalRuleColor, updateHorizontalRuleStyle, updateHorizontalRuleWeight } from '../pm-plugins/commands';
15
+ import { dividerColorPalette } from './dividerColorPalette';
16
+ import { dividerPaletteTooltipMessages } from './dividerColorPaletteMessages';
14
17
  import { DividerOptions } from './DividerOptions';
15
18
  var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, ruleAttrs, api) {
16
- var _api$decorations, _api$analytics3;
19
+ var _api$decorations, _api$analytics4;
17
20
  var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
18
21
  var hoverDecorationProps = function hoverDecorationProps(className) {
19
22
  return {
@@ -23,6 +26,7 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, rule
23
26
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(ruleNodeType, false, className)
24
27
  };
25
28
  };
29
+ var currentColor = ruleAttrs.color || "var(--ds-border, #0B120E24)";
26
30
  var items = [{
27
31
  id: 'divider-options',
28
32
  type: 'dropdown',
@@ -48,6 +52,30 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, rule
48
52
  });
49
53
  }
50
54
  }
55
+ }, {
56
+ id: 'divider-color-picker',
57
+ type: 'select',
58
+ selectType: 'color',
59
+ title: formatMessage(ruleMessages.dividerColors),
60
+ isAriaExpanded: true,
61
+ hideExpandIcon: true,
62
+ defaultValue: dividerColorPalette.find(function (color) {
63
+ return color.value === currentColor;
64
+ }) || {
65
+ label: formatMessage(ruleMessages.customDividerColor),
66
+ value: currentColor,
67
+ border: dividerColorPalette[0].border
68
+ },
69
+ options: dividerColorPalette,
70
+ cols: 10,
71
+ hexToPaletteColor: function hexToPaletteColor(color) {
72
+ return color === "var(--ds-border, #0B120E24)" ? color : hexToEditorTextPaletteColor(color);
73
+ },
74
+ paletteColorTooltipMessages: dividerPaletteTooltipMessages,
75
+ onChange: function onChange(option) {
76
+ var _api$analytics3;
77
+ return updateHorizontalRuleColor(option.value, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
78
+ }
51
79
  }, {
52
80
  type: 'separator',
53
81
  fullHeight: true
@@ -69,7 +97,7 @@ var getToolbarItems = function getToolbarItems(formatMessage, ruleNodeType, rule
69
97
  icon: /*#__PURE__*/React.createElement(DeleteIcon, {
70
98
  label: ""
71
99
  }),
72
- onClick: removeHorizontalRule(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
100
+ onClick: removeHorizontalRule(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)
73
101
  }, hoverDecorationProps())]
74
102
  }];
75
103
  items.push.apply(items, overflowMenuItems);
@@ -6,3 +6,4 @@ export declare const insertHorizontalRule: (editorAnalyticsAPI: EditorAnalyticsA
6
6
  export declare const removeHorizontalRule: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
7
7
  export declare const updateHorizontalRuleWeight: (weight: DividerWeight, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
8
8
  export declare const updateHorizontalRuleStyle: (style: DividerStyle, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
9
+ export declare const updateHorizontalRuleColor: (color: string, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
@@ -0,0 +1,5 @@
1
+ import type { PaletteColor } from '@atlaskit/editor-common/ui-color';
2
+ /**
3
+ * The dividerColorPalette mirrors the textColorPalette, with the following minor changes –
4
+ */
5
+ export declare const dividerColorPalette: Array<PaletteColor>;
@@ -0,0 +1,2 @@
1
+ import type { PaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
2
+ export declare const dividerPaletteTooltipMessages: PaletteTooltipMessages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-rule",
3
- "version": "22.0.0",
3
+ "version": "24.0.0",
4
4
  "description": "Rule plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -22,9 +22,10 @@
22
22
  "@atlaskit/adf-schema": "^57.6.0",
23
23
  "@atlaskit/button": "^25.4.0",
24
24
  "@atlaskit/css": "^1.1.0",
25
- "@atlaskit/editor-plugin-analytics": "^22.0.0",
26
- "@atlaskit/editor-plugin-floating-toolbar": "^24.0.0",
27
- "@atlaskit/editor-plugin-ui-control-registry": "^16.0.0",
25
+ "@atlaskit/editor-palette": "^3.5.0",
26
+ "@atlaskit/editor-plugin-analytics": "^24.0.0",
27
+ "@atlaskit/editor-plugin-floating-toolbar": "^26.0.0",
28
+ "@atlaskit/editor-plugin-ui-control-registry": "^18.0.0",
28
29
  "@atlaskit/editor-prosemirror": "^9.0.0",
29
30
  "@atlaskit/editor-shared-styles": "^4.3.0",
30
31
  "@atlaskit/icon": "^38.0.0",
@@ -32,13 +33,13 @@
32
33
  "@atlaskit/platform-feature-flags": "^2.2.0",
33
34
  "@atlaskit/primitives": "^22.5.0",
34
35
  "@atlaskit/prosemirror-input-rules": "^4.1.0",
35
- "@atlaskit/tokens": "^20.0.0",
36
+ "@atlaskit/tokens": "^20.1.0",
36
37
  "@babel/runtime": "^7.0.0",
37
38
  "@compiled/react": "^1.0.2",
38
39
  "react-intl": "^7.0.0"
39
40
  },
40
41
  "peerDependencies": {
41
- "@atlaskit/editor-common": "^126.0.0",
42
+ "@atlaskit/editor-common": "^128.0.0",
42
43
  "react": "^18.2.0 || ^19.2.0",
43
44
  "react-dom": "^18.2.0 || ^19.2.0"
44
45
  },