@atlaskit/editor-plugin-selection 7.1.0 → 8.0.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.
Files changed (24) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/pm-plugins/gap-cursor-main.js +3 -1
  3. package/dist/cjs/pm-plugins/plugin-factory.js +7 -7
  4. package/dist/es2019/pm-plugins/gap-cursor-main.js +3 -1
  5. package/dist/es2019/pm-plugins/plugin-factory.js +5 -6
  6. package/dist/esm/pm-plugins/gap-cursor-main.js +3 -1
  7. package/dist/esm/pm-plugins/plugin-factory.js +7 -8
  8. package/dist/types/pm-plugins/auto-expand-selection-range-on-inline-node-key.d.ts +1 -1
  9. package/dist/types/pm-plugins/auto-expand-selection-range-on-inline-node-main.d.ts +1 -1
  10. package/dist/types/pm-plugins/events/keydown.d.ts +1 -1
  11. package/dist/types/pm-plugins/gap-cursor-main.d.ts +3 -2
  12. package/dist/types/pm-plugins/gap-cursor-plugin-key.d.ts +1 -1
  13. package/dist/types/pm-plugins/mark-boundary-cursor-plugin-key.d.ts +1 -1
  14. package/dist/types/pm-plugins/plugin-factory.d.ts +7 -1
  15. package/dist/types/types/index.d.ts +1 -1
  16. package/dist/types-ts4.5/pm-plugins/auto-expand-selection-range-on-inline-node-key.d.ts +1 -1
  17. package/dist/types-ts4.5/pm-plugins/auto-expand-selection-range-on-inline-node-main.d.ts +1 -1
  18. package/dist/types-ts4.5/pm-plugins/events/keydown.d.ts +1 -1
  19. package/dist/types-ts4.5/pm-plugins/gap-cursor-main.d.ts +3 -2
  20. package/dist/types-ts4.5/pm-plugins/gap-cursor-plugin-key.d.ts +1 -1
  21. package/dist/types-ts4.5/pm-plugins/mark-boundary-cursor-plugin-key.d.ts +1 -1
  22. package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +7 -1
  23. package/dist/types-ts4.5/types/index.d.ts +1 -1
  24. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 8.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 8.0.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [`8184c046099e5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8184c046099e5) -
14
+ Fixed bug where it wasn't possible to paste before a block node when the block node was the first
15
+ node in an editor document.
16
+ - Updated dependencies
17
+
3
18
  ## 7.1.0
4
19
 
5
20
  ### Minor Changes
@@ -10,6 +10,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
11
  var _view2 = require("@atlaskit/editor-prosemirror/view");
12
12
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
14
15
  var _types = require("../types");
15
16
  var _gapCursorPluginKey = require("./gap-cursor-plugin-key");
@@ -101,7 +102,8 @@ var plugin = new _safePlugin.SafePlugin({
101
102
  var layoutMode = node && (0, _utils2.getLayoutModeFromTargetNode)(node);
102
103
  return _view2.DecorationSet.create(doc, [_view2.Decoration.widget(position, _placeGapCursor.toDOM, {
103
104
  key: "".concat(_selection.JSON_ID, "-").concat(side, "-").concat(layoutMode),
104
- side: layoutMode ? -1 : 0
105
+ // position === 0: if gap cursor at start of document, render it on the left side of the selection to enable pasting (otherwise Chrome doesn't pick up the paste event)
106
+ side: layoutMode || position === 0 && (0, _expValEquals.expValEquals)('platform_editor_paste_before_first_block_node', 'isEnabled', true) ? -1 : 0
105
107
  })]);
106
108
  }
107
109
  return null;
@@ -40,10 +40,10 @@ var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
40
40
  }
41
41
  return pluginState;
42
42
  };
43
- var _pluginFactory = (0, _utils.pluginFactory)(_types.selectionPluginKey, _reducer.reducer, {
44
- onDocChanged: handleDocChanged,
45
- onSelectionChanged: handleSelectionChanged
46
- }),
47
- createCommand = exports.createCommand = _pluginFactory.createCommand,
48
- getPluginState = exports.getPluginState = _pluginFactory.getPluginState,
49
- createPluginState = exports.createPluginState = _pluginFactory.createPluginState;
43
+ var dest = (0, _utils.pluginFactory)(_types.selectionPluginKey, _reducer.reducer, {
44
+ onDocChanged: handleDocChanged,
45
+ onSelectionChanged: handleSelectionChanged
46
+ });
47
+ var createCommand = exports.createCommand = dest.createCommand;
48
+ var getPluginState = exports.getPluginState = dest.getPluginState;
49
+ var createPluginState = exports.createPluginState = dest.createPluginState;
@@ -4,6 +4,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { selectionPluginKey } from '../types';
9
10
  import { gapCursorPluginKey } from './gap-cursor-plugin-key';
@@ -99,7 +100,8 @@ const plugin = new SafePlugin({
99
100
  const layoutMode = node && getLayoutModeFromTargetNode(node);
100
101
  return DecorationSet.create(doc, [Decoration.widget(position, toDOM, {
101
102
  key: `${JSON_ID}-${side}-${layoutMode}`,
102
- side: layoutMode ? -1 : 0
103
+ // position === 0: if gap cursor at start of document, render it on the left side of the selection to enable pasting (otherwise Chrome doesn't pick up the paste event)
104
+ side: layoutMode || position === 0 && expValEquals('platform_editor_paste_before_first_block_node', 'isEnabled', true) ? -1 : 0
103
105
  })]);
104
106
  }
105
107
  return null;
@@ -33,11 +33,10 @@ const handleSelectionChanged = (tr, pluginState) => {
33
33
  }
34
34
  return pluginState;
35
35
  };
36
- export const {
37
- createCommand,
38
- getPluginState,
39
- createPluginState
40
- } = pluginFactory(selectionPluginKey, reducer, {
36
+ const dest = pluginFactory(selectionPluginKey, reducer, {
41
37
  onDocChanged: handleDocChanged,
42
38
  onSelectionChanged: handleSelectionChanged
43
- });
39
+ });
40
+ export const createCommand = dest.createCommand;
41
+ export const getPluginState = dest.getPluginState;
42
+ export const createPluginState = dest.createPluginState;
@@ -4,6 +4,7 @@ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { selectionPluginKey } from '../types';
9
10
  import { gapCursorPluginKey } from './gap-cursor-plugin-key';
@@ -95,7 +96,8 @@ var plugin = new SafePlugin({
95
96
  var layoutMode = node && getLayoutModeFromTargetNode(node);
96
97
  return DecorationSet.create(doc, [Decoration.widget(position, toDOM, {
97
98
  key: "".concat(JSON_ID, "-").concat(side, "-").concat(layoutMode),
98
- side: layoutMode ? -1 : 0
99
+ // position === 0: if gap cursor at start of document, render it on the left side of the selection to enable pasting (otherwise Chrome doesn't pick up the paste event)
100
+ side: layoutMode || position === 0 && expValEquals('platform_editor_paste_before_first_block_node', 'isEnabled', true) ? -1 : 0
99
101
  })]);
100
102
  }
101
103
  return null;
@@ -33,11 +33,10 @@ var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
33
33
  }
34
34
  return pluginState;
35
35
  };
36
- var _pluginFactory = pluginFactory(selectionPluginKey, reducer, {
37
- onDocChanged: handleDocChanged,
38
- onSelectionChanged: handleSelectionChanged
39
- }),
40
- createCommand = _pluginFactory.createCommand,
41
- getPluginState = _pluginFactory.getPluginState,
42
- createPluginState = _pluginFactory.createPluginState;
43
- export { createCommand, getPluginState, createPluginState };
36
+ var dest = pluginFactory(selectionPluginKey, reducer, {
37
+ onDocChanged: handleDocChanged,
38
+ onSelectionChanged: handleSelectionChanged
39
+ });
40
+ export var createCommand = dest.createCommand;
41
+ export var getPluginState = dest.getPluginState;
42
+ export var createPluginState = dest.createPluginState;
@@ -1,2 +1,2 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const autoExpandSelectionRangeOnInlineNodePluginKey: PluginKey<any>;
2
+ export declare const autoExpandSelectionRangeOnInlineNodePluginKey: PluginKey;
@@ -1,2 +1,2 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare const createAutoExpandSelectionRangeOnInlineNodePlugin: () => SafePlugin<any>;
2
+ export declare const createAutoExpandSelectionRangeOnInlineNodePlugin: () => SafePlugin;
@@ -1,4 +1,4 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
- export declare function createOnKeydown({ __livePage }: {
2
+ export declare function createOnKeydown({ __livePage, }: {
3
3
  __livePage?: boolean;
4
4
  }): (view: EditorView, event: Event) => boolean;
@@ -1,7 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- declare const plugin: SafePlugin<{
2
+ type GapCursorPluginState = {
3
3
  selectionIsGapCursor: boolean;
4
4
  displayGapCursor: boolean;
5
5
  hideCursor: boolean;
6
- }>;
6
+ };
7
+ declare const plugin: SafePlugin<GapCursorPluginState>;
7
8
  export default plugin;
@@ -1,2 +1,2 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const gapCursorPluginKey: PluginKey<any>;
2
+ export declare const gapCursorPluginKey: PluginKey;
@@ -1,2 +1,2 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const markBoundaryCursorPluginKey: PluginKey<any>;
2
+ export declare const markBoundaryCursorPluginKey: PluginKey;
@@ -1,2 +1,8 @@
1
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
1
2
  import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
2
- export declare const createCommand: <A = import("./actions").SelectionAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => SelectionPluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: SelectionPluginState | ((state: import("prosemirror-state").EditorState) => SelectionPluginState)) => import("prosemirror-state").SafeStateField<SelectionPluginState>;
3
+ import type { Command } from '@atlaskit/editor-common/types';
4
+ import type { EditorState, SafeStateField, Transaction } from '@atlaskit/editor-prosemirror/state';
5
+ import type { SelectionAction } from './actions';
6
+ export declare const createCommand: <A = SelectionAction>(action: A | ((state: Readonly<EditorState>) => false | A), transform?: (tr: Transaction, state: EditorState) => Transaction) => Command;
7
+ export declare const getPluginState: (state: EditorState) => SelectionPluginState;
8
+ export declare const createPluginState: (dispatch: Dispatch, initialState: SelectionPluginState | ((state: EditorState) => SelectionPluginState)) => SafeStateField<SelectionPluginState>;
@@ -4,7 +4,7 @@ import type { LongPressSelectionPluginOptions } from '@atlaskit/editor-common/ty
4
4
  import type { JSONNode } from '@atlaskit/editor-json-transformer';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
7
- export declare const selectionPluginKey: PluginKey<any>;
7
+ export declare const selectionPluginKey: PluginKey;
8
8
  export { RelativeSelectionPos };
9
9
  export declare enum SelectionDirection {
10
10
  Before = -1,
@@ -1,2 +1,2 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const autoExpandSelectionRangeOnInlineNodePluginKey: PluginKey<any>;
2
+ export declare const autoExpandSelectionRangeOnInlineNodePluginKey: PluginKey;
@@ -1,2 +1,2 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare const createAutoExpandSelectionRangeOnInlineNodePlugin: () => SafePlugin<any>;
2
+ export declare const createAutoExpandSelectionRangeOnInlineNodePlugin: () => SafePlugin;
@@ -1,4 +1,4 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
- export declare function createOnKeydown({ __livePage }: {
2
+ export declare function createOnKeydown({ __livePage, }: {
3
3
  __livePage?: boolean;
4
4
  }): (view: EditorView, event: Event) => boolean;
@@ -1,7 +1,8 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- declare const plugin: SafePlugin<{
2
+ type GapCursorPluginState = {
3
3
  selectionIsGapCursor: boolean;
4
4
  displayGapCursor: boolean;
5
5
  hideCursor: boolean;
6
- }>;
6
+ };
7
+ declare const plugin: SafePlugin<GapCursorPluginState>;
7
8
  export default plugin;
@@ -1,2 +1,2 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const gapCursorPluginKey: PluginKey<any>;
2
+ export declare const gapCursorPluginKey: PluginKey;
@@ -1,2 +1,2 @@
1
1
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const markBoundaryCursorPluginKey: PluginKey<any>;
2
+ export declare const markBoundaryCursorPluginKey: PluginKey;
@@ -1,2 +1,8 @@
1
+ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
1
2
  import type { SelectionPluginState } from '@atlaskit/editor-common/selection';
2
- export declare const createCommand: <A = import("./actions").SelectionAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => SelectionPluginState, createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: SelectionPluginState | ((state: import("prosemirror-state").EditorState) => SelectionPluginState)) => import("prosemirror-state").SafeStateField<SelectionPluginState>;
3
+ import type { Command } from '@atlaskit/editor-common/types';
4
+ import type { EditorState, SafeStateField, Transaction } from '@atlaskit/editor-prosemirror/state';
5
+ import type { SelectionAction } from './actions';
6
+ export declare const createCommand: <A = SelectionAction>(action: A | ((state: Readonly<EditorState>) => false | A), transform?: (tr: Transaction, state: EditorState) => Transaction) => Command;
7
+ export declare const getPluginState: (state: EditorState) => SelectionPluginState;
8
+ export declare const createPluginState: (dispatch: Dispatch, initialState: SelectionPluginState | ((state: EditorState) => SelectionPluginState)) => SafeStateField<SelectionPluginState>;
@@ -4,7 +4,7 @@ import type { LongPressSelectionPluginOptions } from '@atlaskit/editor-common/ty
4
4
  import type { JSONNode } from '@atlaskit/editor-json-transformer';
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
7
- export declare const selectionPluginKey: PluginKey<any>;
7
+ export declare const selectionPluginKey: PluginKey;
8
8
  export { RelativeSelectionPos };
9
9
  export declare enum SelectionDirection {
10
10
  Before = -1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "7.1.0",
3
+ "version": "8.0.1",
4
4
  "description": "Selection plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -20,17 +20,17 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@atlaskit/editor-json-transformer": "^8.31.0",
23
- "@atlaskit/editor-plugin-interaction": "^14.0.0",
23
+ "@atlaskit/editor-plugin-interaction": "^15.0.0",
24
24
  "@atlaskit/editor-prosemirror": "^7.3.0",
25
25
  "@atlaskit/editor-shared-styles": "^3.10.0",
26
26
  "@atlaskit/editor-tables": "^2.9.0",
27
27
  "@atlaskit/platform-feature-flags": "^1.1.0",
28
- "@atlaskit/tmp-editor-statsig": "^35.5.0",
28
+ "@atlaskit/tmp-editor-statsig": "^36.0.0",
29
29
  "@atlaskit/tokens": "^11.1.0",
30
30
  "@babel/runtime": "^7.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@atlaskit/editor-common": "^111.32.0",
33
+ "@atlaskit/editor-common": "^112.0.0",
34
34
  "react": "^18.2.0"
35
35
  },
36
36
  "techstack": {