@atlaskit/editor-plugin-editor-disabled 0.2.1 → 0.2.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,17 @@
1
1
  # @atlaskit/editor-plugin-editor-disabled
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#41429](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41429) [`86a2ac5bc4f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/86a2ac5bc4f) - Fix race condition with editor disabled being set in the prosemirror update cycle ausing a specific case where the floating toolbar did not appear.
8
+
9
+ ## 0.2.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 0.2.1
4
16
 
5
17
  ### Patch Changes
@@ -10,13 +22,13 @@
10
22
 
11
23
  ### Minor Changes
12
24
 
13
- - [`ad3c5c21079`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ad3c5c21079) - Updating all plugins with minor version to correct issue with semver.
25
+ - [#39325](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39325) [`ad3c5c21079`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ad3c5c21079) - Updating all plugins with minor version to correct issue with semver.
14
26
 
15
27
  ## 0.1.2
16
28
 
17
29
  ### Patch Changes
18
30
 
19
- - [`24e27147cbd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/24e27147cbd) - Added atlaskit docs to all existing plugins.
31
+ - [#39177](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39177) [`24e27147cbd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/24e27147cbd) - Added atlaskit docs to all existing plugins.
20
32
 
21
33
  ## 0.1.1
22
34
 
package/README.md CHANGED
@@ -27,4 +27,4 @@ Please see [Atlaskit - Editor plugin editor disabled](https://atlaskit.atlassian
27
27
  For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
28
28
  ## License
29
29
  ---
30
- Please see [Atlassian Frontend - License](https://developer.atlassian.com/cloud/framework/atlassian-frontend/#license) for more licensing information.
30
+ Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.editorDisabledPlugin = void 0;
8
+ var _rafSchd = _interopRequireDefault(require("raf-schd"));
7
9
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
10
  var _utils = require("@atlaskit/editor-common/utils");
9
11
  var _state = require("@atlaskit/editor-prosemirror/state");
@@ -14,6 +16,15 @@ function reducer(_pluginState, meta) {
14
16
  var _pluginFactory = (0, _utils.pluginFactory)(pluginKey, reducer),
15
17
  createPluginState = _pluginFactory.createPluginState,
16
18
  getPluginState = _pluginFactory.getPluginState;
19
+ var scheduleEditorDisabledUpdate = (0, _rafSchd.default)(function (view) {
20
+ if (getPluginState(view.state).editorDisabled !== !view.editable) {
21
+ var tr = view.state.tr.setMeta(pluginKey, {
22
+ editorDisabled: !view.editable
23
+ });
24
+ tr.setMeta('isLocal', true);
25
+ view.dispatch(tr);
26
+ }
27
+ });
17
28
 
18
29
  /*
19
30
  Stores the state of the editor enabled/disabled for panel and floating
@@ -29,13 +40,10 @@ function createPlugin(dispatch) {
29
40
  view: function view() {
30
41
  return {
31
42
  update: function update(view) {
32
- if (getPluginState(view.state).editorDisabled !== !view.editable) {
33
- var tr = view.state.tr.setMeta(pluginKey, {
34
- editorDisabled: !view.editable
35
- });
36
- tr.setMeta('isLocal', true);
37
- view.dispatch(tr);
38
- }
43
+ scheduleEditorDisabledUpdate(view);
44
+ },
45
+ destroy: function destroy() {
46
+ scheduleEditorDisabledUpdate.cancel();
39
47
  }
40
48
  };
41
49
  }
@@ -45,7 +53,7 @@ function createPlugin(dispatch) {
45
53
  * Editor disabled plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
46
54
  * from `@atlaskit/editor-core`.
47
55
  */
48
- var editorDisabledPlugin = function editorDisabledPlugin() {
56
+ var editorDisabledPlugin = exports.editorDisabledPlugin = function editorDisabledPlugin() {
49
57
  return {
50
58
  name: 'editorDisabled',
51
59
  getSharedState: function getSharedState(editorState) {
@@ -72,5 +80,4 @@ var editorDisabledPlugin = function editorDisabledPlugin() {
72
80
  }];
73
81
  }
74
82
  };
75
- };
76
- exports.editorDisabledPlugin = editorDisabledPlugin;
83
+ };
@@ -1,3 +1,4 @@
1
+ import rafSchedule from 'raf-schd';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { pluginFactory } from '@atlaskit/editor-common/utils';
3
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
@@ -9,6 +10,15 @@ const {
9
10
  createPluginState,
10
11
  getPluginState
11
12
  } = pluginFactory(pluginKey, reducer);
13
+ const scheduleEditorDisabledUpdate = rafSchedule(view => {
14
+ if (getPluginState(view.state).editorDisabled !== !view.editable) {
15
+ const tr = view.state.tr.setMeta(pluginKey, {
16
+ editorDisabled: !view.editable
17
+ });
18
+ tr.setMeta('isLocal', true);
19
+ view.dispatch(tr);
20
+ }
21
+ });
12
22
 
13
23
  /*
14
24
  Stores the state of the editor enabled/disabled for panel and floating
@@ -24,13 +34,10 @@ function createPlugin(dispatch) {
24
34
  view: () => {
25
35
  return {
26
36
  update(view) {
27
- if (getPluginState(view.state).editorDisabled !== !view.editable) {
28
- const tr = view.state.tr.setMeta(pluginKey, {
29
- editorDisabled: !view.editable
30
- });
31
- tr.setMeta('isLocal', true);
32
- view.dispatch(tr);
33
- }
37
+ scheduleEditorDisabledUpdate(view);
38
+ },
39
+ destroy() {
40
+ scheduleEditorDisabledUpdate.cancel();
34
41
  }
35
42
  };
36
43
  }
@@ -1,3 +1,4 @@
1
+ import rafSchedule from 'raf-schd';
1
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { pluginFactory } from '@atlaskit/editor-common/utils';
3
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
@@ -8,6 +9,15 @@ function reducer(_pluginState, meta) {
8
9
  var _pluginFactory = pluginFactory(pluginKey, reducer),
9
10
  createPluginState = _pluginFactory.createPluginState,
10
11
  getPluginState = _pluginFactory.getPluginState;
12
+ var scheduleEditorDisabledUpdate = rafSchedule(function (view) {
13
+ if (getPluginState(view.state).editorDisabled !== !view.editable) {
14
+ var tr = view.state.tr.setMeta(pluginKey, {
15
+ editorDisabled: !view.editable
16
+ });
17
+ tr.setMeta('isLocal', true);
18
+ view.dispatch(tr);
19
+ }
20
+ });
11
21
 
12
22
  /*
13
23
  Stores the state of the editor enabled/disabled for panel and floating
@@ -23,13 +33,10 @@ function createPlugin(dispatch) {
23
33
  view: function view() {
24
34
  return {
25
35
  update: function update(view) {
26
- if (getPluginState(view.state).editorDisabled !== !view.editable) {
27
- var tr = view.state.tr.setMeta(pluginKey, {
28
- editorDisabled: !view.editable
29
- });
30
- tr.setMeta('isLocal', true);
31
- view.dispatch(tr);
32
- }
36
+ scheduleEditorDisabledUpdate(view);
37
+ },
38
+ destroy: function destroy() {
39
+ scheduleEditorDisabledUpdate.cancel();
33
40
  }
34
41
  };
35
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-editor-disabled",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Editor disabled plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -23,9 +23,10 @@
23
23
  ".": "./src/index.ts"
24
24
  },
25
25
  "dependencies": {
26
- "@atlaskit/editor-common": "^75.0.0",
26
+ "@atlaskit/editor-common": "^76.9.0",
27
27
  "@atlaskit/editor-prosemirror": "1.1.0",
28
- "@babel/runtime": "^7.0.0"
28
+ "@babel/runtime": "^7.0.0",
29
+ "raf-schd": "^4.0.3"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "react": "^16.8.0"
@@ -33,6 +34,7 @@
33
34
  "devDependencies": {
34
35
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
35
36
  "@testing-library/react": "^12.1.5",
37
+ "raf-stub": "^2.0.1",
36
38
  "react-dom": "^16.8.0",
37
39
  "typescript": "~4.9.5",
38
40
  "wait-for-expect": "^1.2.0"