@atlaskit/editor-plugin-guideline 2.0.6 → 2.0.7

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-guideline
2
2
 
3
+ ## 2.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#148126](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/148126)
8
+ [`2839a051cf613`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2839a051cf613) -
9
+ Migrate to useSharedPluginStateSelector for grid, guideline, help-dialog, highlight and hyperlink
10
+ plugins
11
+
3
12
  ## 2.0.6
4
13
 
5
14
  ### Patch Changes
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _react = require("@emotion/react");
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
11
11
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
12
13
  var _state = require("@atlaskit/editor-prosemirror/state");
13
14
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
14
15
  var _guidelineContainer = require("./ui/guidelineContainer");
@@ -56,14 +57,38 @@ var guidelinePMPlugin = new _safePlugin.SafePlugin({
56
57
  }
57
58
  }
58
59
  });
60
+ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
61
+ var width = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'width.width');
62
+ var lineLength = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'width.lineLength');
63
+ var guidelines = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'guideline.guidelines');
64
+ var rect = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'guideline.rect');
65
+ return {
66
+ width: width,
67
+ lineLength: lineLength,
68
+ guidelines: guidelines,
69
+ rect: rect
70
+ };
71
+ }, function (api) {
72
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'guideline']),
73
+ widthState = _useSharedPluginState.widthState,
74
+ guidelineState = _useSharedPluginState.guidelineState;
75
+ return {
76
+ width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
77
+ lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
78
+ guidelines: guidelineState === null || guidelineState === void 0 ? void 0 : guidelineState.guidelines,
79
+ rect: guidelineState === null || guidelineState === void 0 ? void 0 : guidelineState.rect
80
+ };
81
+ });
59
82
  var ContentComponent = function ContentComponent(_ref) {
60
83
  var api = _ref.api,
61
84
  editorView = _ref.editorView,
62
85
  options = _ref.options;
63
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['width', 'guideline']),
64
- widthState = _useSharedPluginState.widthState,
65
- guidelineState = _useSharedPluginState.guidelineState;
66
- if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
86
+ var _useSharedState = useSharedState(api),
87
+ width = _useSharedState.width,
88
+ lineLength = _useSharedState.lineLength,
89
+ guidelines = _useSharedState.guidelines,
90
+ rect = _useSharedState.rect;
91
+ if (!width || !lineLength || !guidelines || guidelines.length === 0) {
67
92
  return null;
68
93
  }
69
94
  var updateRect = function updateRect(_ref2) {
@@ -71,7 +96,7 @@ var ContentComponent = function ContentComponent(_ref) {
71
96
  left = _ref2.left;
72
97
  var dispatch = editorView.dispatch,
73
98
  state = editorView.state;
74
- var _ref3 = guidelineState.rect || {},
99
+ var _ref3 = rect || {},
75
100
  prevTop = _ref3.top,
76
101
  prevLeft = _ref3.left;
77
102
  if (prevTop !== top || prevLeft !== left) {
@@ -88,13 +113,13 @@ var ContentComponent = function ContentComponent(_ref) {
88
113
  return (0, _react.jsx)("div", {
89
114
  css: guidelineStyles
90
115
  }, (0, _react.jsx)(_guidelineContainer.GuidelineContainer, {
91
- guidelines: guidelineState.guidelines
116
+ guidelines: guidelines
92
117
  // Ignored via go/ees005
93
118
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
94
119
  ,
95
120
  height: editorView.dom.scrollHeight,
96
- width: widthState.width,
97
- editorWidth: widthState.lineLength,
121
+ width: width,
122
+ editorWidth: lineLength,
98
123
  updateRect: updateRect
99
124
  }));
100
125
  };
@@ -4,8 +4,9 @@
4
4
  */
5
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
6
  import { css, jsx } from '@emotion/react';
7
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
8
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
10
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
10
11
  import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
11
12
  import { GuidelineContainer } from './ui/guidelineContainer';
@@ -51,16 +52,41 @@ const guidelinePMPlugin = new SafePlugin({
51
52
  }
52
53
  }
53
54
  });
55
+ const useSharedState = sharedPluginStateHookMigratorFactory(api => {
56
+ const width = useSharedPluginStateSelector(api, 'width.width');
57
+ const lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
58
+ const guidelines = useSharedPluginStateSelector(api, 'guideline.guidelines');
59
+ const rect = useSharedPluginStateSelector(api, 'guideline.rect');
60
+ return {
61
+ width,
62
+ lineLength,
63
+ guidelines,
64
+ rect
65
+ };
66
+ }, api => {
67
+ const {
68
+ widthState,
69
+ guidelineState
70
+ } = useSharedPluginState(api, ['width', 'guideline']);
71
+ return {
72
+ width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
73
+ lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
74
+ guidelines: guidelineState === null || guidelineState === void 0 ? void 0 : guidelineState.guidelines,
75
+ rect: guidelineState === null || guidelineState === void 0 ? void 0 : guidelineState.rect
76
+ };
77
+ });
54
78
  const ContentComponent = ({
55
79
  api,
56
80
  editorView,
57
81
  options
58
82
  }) => {
59
83
  const {
60
- widthState,
61
- guidelineState
62
- } = useSharedPluginState(api, ['width', 'guideline']);
63
- if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
84
+ width,
85
+ lineLength,
86
+ guidelines,
87
+ rect
88
+ } = useSharedState(api);
89
+ if (!width || !lineLength || !guidelines || guidelines.length === 0) {
64
90
  return null;
65
91
  }
66
92
  const updateRect = ({
@@ -74,7 +100,7 @@ const ContentComponent = ({
74
100
  const {
75
101
  top: prevTop,
76
102
  left: prevLeft
77
- } = guidelineState.rect || {};
103
+ } = rect || {};
78
104
  if (prevTop !== top || prevLeft !== left) {
79
105
  const tr = state.tr.setMeta(key, {
80
106
  rect: {
@@ -89,13 +115,13 @@ const ContentComponent = ({
89
115
  return jsx("div", {
90
116
  css: guidelineStyles
91
117
  }, jsx(GuidelineContainer, {
92
- guidelines: guidelineState.guidelines
118
+ guidelines: guidelines
93
119
  // Ignored via go/ees005
94
120
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
95
121
  ,
96
122
  height: editorView.dom.scrollHeight,
97
- width: widthState.width,
98
- editorWidth: widthState.lineLength,
123
+ width: width,
124
+ editorWidth: lineLength,
99
125
  updateRect: updateRect
100
126
  }));
101
127
  };
@@ -7,8 +7,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  */
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { css, jsx } from '@emotion/react';
10
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
+ import { useSharedPluginState, sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
11
11
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
12
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
12
13
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
13
14
  import { akEditorGridLineZIndex } from '@atlaskit/editor-shared-styles';
14
15
  import { GuidelineContainer } from './ui/guidelineContainer';
@@ -51,14 +52,38 @@ var guidelinePMPlugin = new SafePlugin({
51
52
  }
52
53
  }
53
54
  });
55
+ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
56
+ var width = useSharedPluginStateSelector(api, 'width.width');
57
+ var lineLength = useSharedPluginStateSelector(api, 'width.lineLength');
58
+ var guidelines = useSharedPluginStateSelector(api, 'guideline.guidelines');
59
+ var rect = useSharedPluginStateSelector(api, 'guideline.rect');
60
+ return {
61
+ width: width,
62
+ lineLength: lineLength,
63
+ guidelines: guidelines,
64
+ rect: rect
65
+ };
66
+ }, function (api) {
67
+ var _useSharedPluginState = useSharedPluginState(api, ['width', 'guideline']),
68
+ widthState = _useSharedPluginState.widthState,
69
+ guidelineState = _useSharedPluginState.guidelineState;
70
+ return {
71
+ width: widthState === null || widthState === void 0 ? void 0 : widthState.width,
72
+ lineLength: widthState === null || widthState === void 0 ? void 0 : widthState.lineLength,
73
+ guidelines: guidelineState === null || guidelineState === void 0 ? void 0 : guidelineState.guidelines,
74
+ rect: guidelineState === null || guidelineState === void 0 ? void 0 : guidelineState.rect
75
+ };
76
+ });
54
77
  var ContentComponent = function ContentComponent(_ref) {
55
78
  var api = _ref.api,
56
79
  editorView = _ref.editorView,
57
80
  options = _ref.options;
58
- var _useSharedPluginState = useSharedPluginState(api, ['width', 'guideline']),
59
- widthState = _useSharedPluginState.widthState,
60
- guidelineState = _useSharedPluginState.guidelineState;
61
- if (!widthState || !widthState.width || !widthState.lineLength || !guidelineState || !guidelineState.guidelines || guidelineState.guidelines.length === 0) {
81
+ var _useSharedState = useSharedState(api),
82
+ width = _useSharedState.width,
83
+ lineLength = _useSharedState.lineLength,
84
+ guidelines = _useSharedState.guidelines,
85
+ rect = _useSharedState.rect;
86
+ if (!width || !lineLength || !guidelines || guidelines.length === 0) {
62
87
  return null;
63
88
  }
64
89
  var updateRect = function updateRect(_ref2) {
@@ -66,7 +91,7 @@ var ContentComponent = function ContentComponent(_ref) {
66
91
  left = _ref2.left;
67
92
  var dispatch = editorView.dispatch,
68
93
  state = editorView.state;
69
- var _ref3 = guidelineState.rect || {},
94
+ var _ref3 = rect || {},
70
95
  prevTop = _ref3.top,
71
96
  prevLeft = _ref3.left;
72
97
  if (prevTop !== top || prevLeft !== left) {
@@ -83,13 +108,13 @@ var ContentComponent = function ContentComponent(_ref) {
83
108
  return jsx("div", {
84
109
  css: guidelineStyles
85
110
  }, jsx(GuidelineContainer, {
86
- guidelines: guidelineState.guidelines
111
+ guidelines: guidelines
87
112
  // Ignored via go/ees005
88
113
  // eslint-disable-next-line @atlaskit/editor/no-as-casting
89
114
  ,
90
115
  height: editorView.dom.scrollHeight,
91
- width: widthState.width,
92
- editorWidth: widthState.lineLength,
116
+ width: width,
117
+ editorWidth: lineLength,
93
118
  updateRect: updateRect
94
119
  }));
95
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-guideline",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "guideline plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -25,7 +25,7 @@
25
25
  ".": "./src/index.ts"
26
26
  },
27
27
  "dependencies": {
28
- "@atlaskit/editor-common": "^104.0.0",
28
+ "@atlaskit/editor-common": "^104.1.0",
29
29
  "@atlaskit/editor-plugin-width": "^3.0.0",
30
30
  "@atlaskit/editor-prosemirror": "7.0.0",
31
31
  "@atlaskit/editor-shared-styles": "^3.4.0",