@atlaskit/editor-plugin-selection-toolbar 0.1.5 → 0.2.1

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-selection-toolbar
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#68572](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68572) [`15d407fe5143`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/15d407fe5143) - Upgrading @atlaskit/editor-prosemirror dependency
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#68277](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68277) [`fe0abf4abc01`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fe0abf4abc01) - Enable the selection toolbar to work with live pages view mode
14
+
3
15
  ## 0.1.5
4
16
 
5
17
  ### Patch Changes
@@ -45,11 +45,15 @@ var selectionToolbarPlugin = exports.selectionToolbarPlugin = function selection
45
45
  var unbind = (0, _bindEventListener.bind)(_view.root, {
46
46
  type: 'mouseup',
47
47
  listener: function listener() {
48
+ var _options$api;
48
49
  // We only want to set selectionStable to true if the editor has focus
49
50
  // to prevent the toolbar from showing when the editor is blurred
50
51
  // due to a click outside the editor.
52
+
53
+ var editorViewModePlugin = (_options$api = options.api) === null || _options$api === void 0 || (_options$api = _options$api.editorViewMode) === null || _options$api === void 0 ? void 0 : _options$api.sharedState.currentState();
54
+ var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
51
55
  _view.dispatch(_view.state.tr.setMeta(_pluginKey.selectionToolbarPluginKey, {
52
- selectionStable: _view.hasFocus()
56
+ selectionStable: !isViewModeEnabled ? _view.hasFocus() : true
53
57
  }));
54
58
  }
55
59
  });
@@ -37,11 +37,15 @@ export const selectionToolbarPlugin = options => {
37
37
  const unbind = bind(view.root, {
38
38
  type: 'mouseup',
39
39
  listener: () => {
40
+ var _options$api, _options$api$editorVi;
40
41
  // We only want to set selectionStable to true if the editor has focus
41
42
  // to prevent the toolbar from showing when the editor is blurred
42
43
  // due to a click outside the editor.
44
+
45
+ const editorViewModePlugin = (_options$api = options.api) === null || _options$api === void 0 ? void 0 : (_options$api$editorVi = _options$api.editorViewMode) === null || _options$api$editorVi === void 0 ? void 0 : _options$api$editorVi.sharedState.currentState();
46
+ const isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
43
47
  view.dispatch(view.state.tr.setMeta(selectionToolbarPluginKey, {
44
- selectionStable: view.hasFocus()
48
+ selectionStable: !isViewModeEnabled ? view.hasFocus() : true
45
49
  }));
46
50
  }
47
51
  });
@@ -38,11 +38,15 @@ export var selectionToolbarPlugin = function selectionToolbarPlugin(options) {
38
38
  var unbind = bind(_view.root, {
39
39
  type: 'mouseup',
40
40
  listener: function listener() {
41
+ var _options$api;
41
42
  // We only want to set selectionStable to true if the editor has focus
42
43
  // to prevent the toolbar from showing when the editor is blurred
43
44
  // due to a click outside the editor.
45
+
46
+ var editorViewModePlugin = (_options$api = options.api) === null || _options$api === void 0 || (_options$api = _options$api.editorViewMode) === null || _options$api === void 0 ? void 0 : _options$api.sharedState.currentState();
47
+ var isViewModeEnabled = (editorViewModePlugin === null || editorViewModePlugin === void 0 ? void 0 : editorViewModePlugin.mode) === 'view';
44
48
  _view.dispatch(_view.state.tr.setMeta(selectionToolbarPluginKey, {
45
- selectionStable: _view.hasFocus()
49
+ selectionStable: !isViewModeEnabled ? _view.hasFocus() : true
46
50
  }));
47
51
  }
48
52
  });
@@ -1,4 +1,5 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
2
3
  export declare const selectionToolbarPlugin: NextEditorPlugin<'selectionToolbar', {
3
4
  pluginConfiguration: {
4
5
  /**
@@ -6,5 +7,6 @@ export declare const selectionToolbarPlugin: NextEditorPlugin<'selectionToolbar'
6
7
  */
7
8
  preferenceToolbarAboveSelection?: boolean;
8
9
  };
10
+ dependencies: [OptionalPlugin<EditorViewModePlugin>];
9
11
  }>;
10
12
  export type SelectionToolbarPlugin = typeof selectionToolbarPlugin;
@@ -1,4 +1,5 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
2
3
  export declare const selectionToolbarPlugin: NextEditorPlugin<'selectionToolbar', {
3
4
  pluginConfiguration: {
4
5
  /**
@@ -6,5 +7,8 @@ export declare const selectionToolbarPlugin: NextEditorPlugin<'selectionToolbar'
6
7
  */
7
8
  preferenceToolbarAboveSelection?: boolean;
8
9
  };
10
+ dependencies: [
11
+ OptionalPlugin<EditorViewModePlugin>
12
+ ];
9
13
  }>;
10
14
  export type SelectionToolbarPlugin = typeof selectionToolbarPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-toolbar",
3
- "version": "0.1.5",
3
+ "version": "0.2.1",
4
4
  "description": "@atlaskit/editor-plugin-selection-toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,8 +33,9 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/editor-common": "^77.0.0",
37
- "@atlaskit/editor-prosemirror": "1.1.0",
36
+ "@atlaskit/editor-common": "^77.3.0",
37
+ "@atlaskit/editor-plugin-editor-viewmode": "^0.1.0",
38
+ "@atlaskit/editor-prosemirror": "3.0.0",
38
39
  "@babel/runtime": "^7.0.0",
39
40
  "bind-event-listener": "^2.1.1"
40
41
  },