@atlaskit/editor-plugin-selection 5.0.0 → 5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-selection
2
2
 
3
+ ## 5.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c69b58dc48801`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c69b58dc48801) -
8
+ Expose getSliceFromSelection
9
+
3
10
  ## 5.0.0
4
11
 
5
12
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getSelectionLocalIds = exports.getSelectionFragment = void 0;
7
+ exports.getSliceFromSelection = exports.getSelectionLocalIds = exports.getSelectionFragment = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
10
10
  var _model = require("@atlaskit/editor-prosemirror/model");
@@ -20,7 +20,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
20
20
  * @param selection The selection to get the slice for.
21
21
  * @returns The slice of the document corresponding to the selection.
22
22
  */
23
- var getSlice = function getSlice(selection) {
23
+ var getSliceFromSelection = exports.getSliceFromSelection = function getSliceFromSelection(selection) {
24
24
  var from = selection.from,
25
25
  to = selection.to;
26
26
  if (from === to) {
@@ -62,7 +62,7 @@ var getSelectionFragment = exports.getSelectionFragment = function getSelectionF
62
62
  if (!selection || !schema || selection.empty) {
63
63
  return null;
64
64
  }
65
- var slice = getSlice(selection);
65
+ var slice = getSliceFromSelection(selection);
66
66
  var content = slice.content;
67
67
  var fragment = [];
68
68
  content.forEach(function (node) {
@@ -92,7 +92,7 @@ var getSelectionLocalIds = exports.getSelectionLocalIds = function getSelectionL
92
92
  } else if (selection.empty) {
93
93
  return [selection.$from.parent.attrs.localId];
94
94
  }
95
- var content = getSlice(selection).content;
95
+ var content = getSliceFromSelection(selection).content;
96
96
  var ids = [];
97
97
  content.forEach(function (node) {
98
98
  var _node$attrs;
@@ -9,7 +9,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
9
9
  * @param selection The selection to get the slice for.
10
10
  * @returns The slice of the document corresponding to the selection.
11
11
  */
12
- const getSlice = selection => {
12
+ export const getSliceFromSelection = selection => {
13
13
  const {
14
14
  from,
15
15
  to
@@ -43,7 +43,7 @@ export const getSelectionFragment = api => () => {
43
43
  if (!selection || !schema || selection.empty) {
44
44
  return null;
45
45
  }
46
- const slice = getSlice(selection);
46
+ const slice = getSliceFromSelection(selection);
47
47
  const content = slice.content;
48
48
  const fragment = [];
49
49
  content.forEach(node => {
@@ -72,7 +72,7 @@ export const getSelectionLocalIds = api => () => {
72
72
  } else if (selection.empty) {
73
73
  return [selection.$from.parent.attrs.localId];
74
74
  }
75
- const content = getSlice(selection).content;
75
+ const content = getSliceFromSelection(selection).content;
76
76
  const ids = [];
77
77
  content.forEach(node => {
78
78
  var _node$attrs;
@@ -13,7 +13,7 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
13
13
  * @param selection The selection to get the slice for.
14
14
  * @returns The slice of the document corresponding to the selection.
15
15
  */
16
- var getSlice = function getSlice(selection) {
16
+ export var getSliceFromSelection = function getSliceFromSelection(selection) {
17
17
  var from = selection.from,
18
18
  to = selection.to;
19
19
  if (from === to) {
@@ -55,7 +55,7 @@ export var getSelectionFragment = function getSelectionFragment(api) {
55
55
  if (!selection || !schema || selection.empty) {
56
56
  return null;
57
57
  }
58
- var slice = getSlice(selection);
58
+ var slice = getSliceFromSelection(selection);
59
59
  var content = slice.content;
60
60
  var fragment = [];
61
61
  content.forEach(function (node) {
@@ -85,7 +85,7 @@ export var getSelectionLocalIds = function getSelectionLocalIds(api) {
85
85
  } else if (selection.empty) {
86
86
  return [selection.$from.parent.attrs.localId];
87
87
  }
88
- var content = getSlice(selection).content;
88
+ var content = getSliceFromSelection(selection).content;
89
89
  var ids = [];
90
90
  content.forEach(function (node) {
91
91
  var _node$attrs;
@@ -1,5 +1,16 @@
1
1
  import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { type JSONNode } from '@atlaskit/editor-json-transformer';
3
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
+ import { type Selection } from '@atlaskit/editor-prosemirror/state';
3
5
  import type { SelectionPlugin } from '../selectionPluginType';
6
+ /**
7
+ * Get the slice of the document corresponding to the selection.
8
+ * This is similar to the prosemirror `selection.content()` - but
9
+ * does not include the parents (unless the result is inline)
10
+ *
11
+ * @param selection The selection to get the slice for.
12
+ * @returns The slice of the document corresponding to the selection.
13
+ */
14
+ export declare const getSliceFromSelection: (selection: Selection) => Fragment;
4
15
  export declare const getSelectionFragment: (api: ExtractInjectionAPI<SelectionPlugin> | undefined) => () => JSONNode[] | null;
5
16
  export declare const getSelectionLocalIds: (api: ExtractInjectionAPI<SelectionPlugin> | undefined) => () => any[] | null;
@@ -1,5 +1,16 @@
1
1
  import { type ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
2
  import { type JSONNode } from '@atlaskit/editor-json-transformer';
3
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
4
+ import { type Selection } from '@atlaskit/editor-prosemirror/state';
3
5
  import type { SelectionPlugin } from '../selectionPluginType';
6
+ /**
7
+ * Get the slice of the document corresponding to the selection.
8
+ * This is similar to the prosemirror `selection.content()` - but
9
+ * does not include the parents (unless the result is inline)
10
+ *
11
+ * @param selection The selection to get the slice for.
12
+ * @returns The slice of the document corresponding to the selection.
13
+ */
14
+ export declare const getSliceFromSelection: (selection: Selection) => Fragment;
4
15
  export declare const getSelectionFragment: (api: ExtractInjectionAPI<SelectionPlugin> | undefined) => () => JSONNode[] | null;
5
16
  export declare const getSelectionLocalIds: (api: ExtractInjectionAPI<SelectionPlugin> | undefined) => () => any[] | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Selection plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -19,18 +19,18 @@
19
19
  "singleton": true
20
20
  },
21
21
  "dependencies": {
22
- "@atlaskit/editor-json-transformer": "^8.27.0",
22
+ "@atlaskit/editor-json-transformer": "^8.29.0",
23
23
  "@atlaskit/editor-plugin-interaction": "^7.0.0",
24
24
  "@atlaskit/editor-prosemirror": "7.0.0",
25
25
  "@atlaskit/editor-shared-styles": "^3.6.0",
26
26
  "@atlaskit/editor-tables": "^2.9.0",
27
27
  "@atlaskit/platform-feature-flags": "^1.1.0",
28
- "@atlaskit/tmp-editor-statsig": "^12.9.0",
28
+ "@atlaskit/tmp-editor-statsig": "^12.22.0",
29
29
  "@atlaskit/tokens": "^6.3.0",
30
30
  "@babel/runtime": "^7.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@atlaskit/editor-common": "^109.0.0",
33
+ "@atlaskit/editor-common": "^109.7.0",
34
34
  "react": "^18.2.0"
35
35
  },
36
36
  "techstack": {