@atlaskit/editor-plugin-highlight 1.7.2 → 1.7.3

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,14 @@
1
1
  # @atlaskit/editor-plugin-highlight
2
2
 
3
+ ## 1.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#108804](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108804)
8
+ [`3d5378c261364`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3d5378c261364) -
9
+ [ED-23517] Changed initial state of highlight plugin to avoid inactive toolbar button in examples
10
+ - Updated dependencies
11
+
3
12
  ## 1.7.2
4
13
 
5
14
  ### Patch Changes
@@ -19,16 +19,16 @@ var changeColor = exports.changeColor = function changeColor(editorAnalyticsAPI)
19
19
  return null;
20
20
  }
21
21
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(createAnalyticsEvent(color, tr))(tr);
22
- tr.setMeta(_pmPlugin.highlightPluginKey, {
23
- type: _pmPlugin.HighlightPluginAction.CHANGE_COLOR,
24
- color: color
25
- });
26
22
  tr.scrollIntoView();
27
23
  if (color === _uiColor.REMOVE_HIGHLIGHT_COLOR) {
28
24
  (0, _mark.removeMark)(backgroundColor)({
29
25
  tr: tr
30
26
  });
31
27
  } else {
28
+ tr.setMeta(_pmPlugin.highlightPluginKey, {
29
+ type: _pmPlugin.HighlightPluginAction.CHANGE_COLOR,
30
+ color: color
31
+ });
32
32
  (0, _mark.toggleMark)(backgroundColor, {
33
33
  color: color
34
34
  })({
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.highlightPluginKey = exports.createPlugin = exports.HighlightPluginAction = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
- var _uiColor = require("@atlaskit/editor-common/ui-color");
11
10
  var _state = require("@atlaskit/editor-prosemirror/state");
12
11
  var _color = require("./utils/color");
13
12
  var _disabled = require("./utils/disabled");
@@ -23,10 +22,10 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
23
22
  return new _safePlugin.SafePlugin({
24
23
  key: highlightPluginKey,
25
24
  state: {
26
- init: function init() {
25
+ init: function init(_, editorState) {
27
26
  return {
28
- activeColor: _uiColor.REMOVE_HIGHLIGHT_COLOR,
29
- disabled: true
27
+ activeColor: null,
28
+ disabled: (0, _disabled.getDisabledState)(editorState)
30
29
  };
31
30
  },
32
31
  apply: function apply(tr, pluginState, _oldState, newState) {
@@ -99,7 +99,7 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
99
99
 
100
100
  // Get the design token for the active color (if it exists) to modify the toolbar
101
101
  // icon, but show the nice rainbow if none is selected
102
- var activeColorToken = highlightState.activeColor === _uiColor.REMOVE_HIGHLIGHT_COLOR || highlightState.activeColor === null ? null : (0, _editorPalette.hexToEditorTextBackgroundPaletteColor)(highlightState.activeColor);
102
+ var activeColorToken = highlightState.activeColor === null ? null : (0, _editorPalette.hexToEditorTextBackgroundPaletteColor)(highlightState.activeColor);
103
103
 
104
104
  // pixels, used to determine where to horizontally position the dropdown when space is limited
105
105
  // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
@@ -15,16 +15,16 @@ export const changeColor = editorAnalyticsAPI => ({
15
15
  return null;
16
16
  }
17
17
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(createAnalyticsEvent(color, tr))(tr);
18
- tr.setMeta(highlightPluginKey, {
19
- type: HighlightPluginAction.CHANGE_COLOR,
20
- color
21
- });
22
18
  tr.scrollIntoView();
23
19
  if (color === REMOVE_HIGHLIGHT_COLOR) {
24
20
  removeMark(backgroundColor)({
25
21
  tr
26
22
  });
27
23
  } else {
24
+ tr.setMeta(highlightPluginKey, {
25
+ type: HighlightPluginAction.CHANGE_COLOR,
26
+ color
27
+ });
28
28
  toggleMark(backgroundColor, {
29
29
  color
30
30
  })({
@@ -1,5 +1,4 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
3
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
3
  import { getActiveColor } from './utils/color';
5
4
  import { getDisabledState } from './utils/disabled';
@@ -14,9 +13,9 @@ export const createPlugin = ({
14
13
  return new SafePlugin({
15
14
  key: highlightPluginKey,
16
15
  state: {
17
- init: () => ({
18
- activeColor: REMOVE_HIGHLIGHT_COLOR,
19
- disabled: true
16
+ init: (_, editorState) => ({
17
+ activeColor: null,
18
+ disabled: getDisabledState(editorState)
20
19
  }),
21
20
  apply: (tr, pluginState, _oldState, newState) => {
22
21
  var _tr$getMeta;
@@ -6,7 +6,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
6
6
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
7
  import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
8
8
  import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
9
- import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette, REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
9
+ import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette } from '@atlaskit/editor-common/ui-color';
10
10
  import { ArrowKeyNavigationType, DropdownContainer as Dropdown, TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
11
11
  import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
12
12
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
@@ -83,7 +83,7 @@ const ToolbarHighlightColor = ({
83
83
 
84
84
  // Get the design token for the active color (if it exists) to modify the toolbar
85
85
  // icon, but show the nice rainbow if none is selected
86
- const activeColorToken = highlightState.activeColor === REMOVE_HIGHLIGHT_COLOR || highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
86
+ const activeColorToken = highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
87
87
 
88
88
  // pixels, used to determine where to horizontally position the dropdown when space is limited
89
89
  // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
@@ -13,16 +13,16 @@ export var changeColor = function changeColor(editorAnalyticsAPI) {
13
13
  return null;
14
14
  }
15
15
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(createAnalyticsEvent(color, tr))(tr);
16
- tr.setMeta(highlightPluginKey, {
17
- type: HighlightPluginAction.CHANGE_COLOR,
18
- color: color
19
- });
20
16
  tr.scrollIntoView();
21
17
  if (color === REMOVE_HIGHLIGHT_COLOR) {
22
18
  removeMark(backgroundColor)({
23
19
  tr: tr
24
20
  });
25
21
  } else {
22
+ tr.setMeta(highlightPluginKey, {
23
+ type: HighlightPluginAction.CHANGE_COLOR,
24
+ color: color
25
+ });
26
26
  toggleMark(backgroundColor, {
27
27
  color: color
28
28
  })({
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
6
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
6
  import { getActiveColor } from './utils/color';
8
7
  import { getDisabledState } from './utils/disabled';
@@ -16,10 +15,10 @@ export var createPlugin = function createPlugin(_ref) {
16
15
  return new SafePlugin({
17
16
  key: highlightPluginKey,
18
17
  state: {
19
- init: function init() {
18
+ init: function init(_, editorState) {
20
19
  return {
21
- activeColor: REMOVE_HIGHLIGHT_COLOR,
22
- disabled: true
20
+ activeColor: null,
21
+ disabled: getDisabledState(editorState)
23
22
  };
24
23
  },
25
24
  apply: function apply(tr, pluginState, _oldState, newState) {
@@ -7,7 +7,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
7
7
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
8
  import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
9
9
  import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
10
- import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette, REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
10
+ import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette } from '@atlaskit/editor-common/ui-color';
11
11
  import { ArrowKeyNavigationType, DropdownContainer as Dropdown, TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
12
12
  import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
13
13
  import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
@@ -88,7 +88,7 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
88
88
 
89
89
  // Get the design token for the active color (if it exists) to modify the toolbar
90
90
  // icon, but show the nice rainbow if none is selected
91
- var activeColorToken = highlightState.activeColor === REMOVE_HIGHLIGHT_COLOR || highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
91
+ var activeColorToken = highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
92
92
 
93
93
  // pixels, used to determine where to horizontally position the dropdown when space is limited
94
94
  // this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-highlight",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Highlight plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,7 +38,7 @@
38
38
  ".": "./src/index.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@atlaskit/editor-common": "^82.1.0",
41
+ "@atlaskit/editor-common": "^82.2.0",
42
42
  "@atlaskit/editor-palette": "1.6.0",
43
43
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
44
44
  "@atlaskit/editor-plugin-background-color": "^1.1.0",