@atlaskit/editor-common 111.0.4 → 111.0.5

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-common
2
2
 
3
+ ## 111.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4bf196f8645a7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4bf196f8645a7) -
8
+ Editor-4011: Added util function isMultiNodeSelection
9
+
3
10
  ## 111.0.4
4
11
 
5
12
  ### Patch Changes
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "0.0.0-development";
22
+ var packageVersion = "111.0.4";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -110,6 +110,18 @@ Object.defineProperty(exports, "isIgnored", {
110
110
  return _isIgnored.isIgnored;
111
111
  }
112
112
  });
113
+ Object.defineProperty(exports, "isMultiBlockRange", {
114
+ enumerable: true,
115
+ get: function get() {
116
+ return _utils2.isMultiBlockRange;
117
+ }
118
+ });
119
+ Object.defineProperty(exports, "isMultiBlockSelection", {
120
+ enumerable: true,
121
+ get: function get() {
122
+ return _utils2.isMultiBlockSelection;
123
+ }
124
+ });
113
125
  Object.defineProperty(exports, "isSelectionAtEndOfNode", {
114
126
  enumerable: true,
115
127
  get: function get() {
@@ -9,7 +9,9 @@ exports.atTheEndOfBlock = atTheEndOfBlock;
9
9
  exports.atTheEndOfDoc = atTheEndOfDoc;
10
10
  exports.deleteSelectedRange = void 0;
11
11
  exports.endPositionOfParent = endPositionOfParent;
12
- exports.isSelectionAtStartOfNode = exports.isSelectionAtEndOfNode = exports.expandToBlockRange = exports.expandSelectionToBlockRange = exports.expandSelectionBounds = void 0;
12
+ exports.isMultiBlockRange = exports.expandToBlockRange = exports.expandSelectionToBlockRange = exports.expandSelectionBounds = void 0;
13
+ exports.isMultiBlockSelection = isMultiBlockSelection;
14
+ exports.isSelectionAtStartOfNode = exports.isSelectionAtEndOfNode = void 0;
13
15
  exports.startPositionOfParent = startPositionOfParent;
14
16
  var _state = require("@atlaskit/editor-prosemirror/state");
15
17
  var _utils = require("@atlaskit/editor-tables/utils");
@@ -206,4 +208,33 @@ var expandSelectionToBlockRange = exports.expandSelectionToBlockRange = function
206
208
  var $from = _ref2.$from,
207
209
  $to = _ref2.$to;
208
210
  return expandToBlockRange($from, $to);
209
- };
211
+ };
212
+ var isMultiBlockRange = exports.isMultiBlockRange = function isMultiBlockRange(range) {
213
+ if (range.endIndex - range.startIndex <= 1) {
214
+ return false; // At most one child
215
+ }
216
+
217
+ // Count block nodes in the range, return true if more than one
218
+ var blockCount = 0;
219
+ for (var i = range.startIndex; i < range.endIndex; i++) {
220
+ if (range.parent.child(i).isBlock) {
221
+ blockCount++;
222
+ }
223
+ if (blockCount > 1) {
224
+ return true;
225
+ }
226
+ }
227
+ return false;
228
+ };
229
+
230
+ /**
231
+ * Determines if a selection contains multiple block nodes.
232
+ */
233
+ function isMultiBlockSelection(selection) {
234
+ var _expandSelectionToBlo = expandSelectionToBlockRange(selection),
235
+ range = _expandSelectionToBlo.range;
236
+ if (!range) {
237
+ return false;
238
+ }
239
+ return isMultiBlockRange(range);
240
+ }
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "0.0.0-development";
27
+ var packageVersion = "111.0.4";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -4,7 +4,7 @@ import { isFedRamp } from './environment';
4
4
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
5
5
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
6
6
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
7
- const packageVersion = "0.0.0-development";
7
+ const packageVersion = "111.0.4";
8
8
  const sanitiseSentryEvents = (data, _hint) => {
9
9
  // Remove URL as it has UGC
10
10
  // Ignored via go/ees007
@@ -12,7 +12,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
12
12
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
13
13
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
14
14
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
15
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
15
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isMultiBlockRange, isMultiBlockSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
16
16
  export function getNodeSelectionAnalyticsPayload(selection) {
17
17
  if (selection instanceof NodeSelection) {
18
18
  return {
@@ -204,4 +204,34 @@ export const expandSelectionToBlockRange = ({
204
204
  $to
205
205
  }) => {
206
206
  return expandToBlockRange($from, $to);
207
- };
207
+ };
208
+ export const isMultiBlockRange = range => {
209
+ if (range.endIndex - range.startIndex <= 1) {
210
+ return false; // At most one child
211
+ }
212
+
213
+ // Count block nodes in the range, return true if more than one
214
+ let blockCount = 0;
215
+ for (let i = range.startIndex; i < range.endIndex; i++) {
216
+ if (range.parent.child(i).isBlock) {
217
+ blockCount++;
218
+ }
219
+ if (blockCount > 1) {
220
+ return true;
221
+ }
222
+ }
223
+ return false;
224
+ };
225
+
226
+ /**
227
+ * Determines if a selection contains multiple block nodes.
228
+ */
229
+ export function isMultiBlockSelection(selection) {
230
+ const {
231
+ range
232
+ } = expandSelectionToBlockRange(selection);
233
+ if (!range) {
234
+ return false;
235
+ }
236
+ return isMultiBlockRange(range);
237
+ }
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "0.0.0-development";
17
+ const packageVersion = "111.0.4";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -10,7 +10,7 @@ import { isFedRamp } from './environment';
10
10
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
11
11
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
12
12
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
13
- var packageVersion = "0.0.0-development";
13
+ var packageVersion = "111.0.4";
14
14
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
15
15
  // Remove URL as it has UGC
16
16
  // Ignored via go/ees007
@@ -12,7 +12,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
12
12
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
13
13
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
14
14
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
15
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
15
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isMultiBlockRange, isMultiBlockSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
16
16
  export function getNodeSelectionAnalyticsPayload(selection) {
17
17
  if (selection instanceof NodeSelection) {
18
18
  return {
@@ -193,4 +193,33 @@ export var expandSelectionToBlockRange = function expandSelectionToBlockRange(_r
193
193
  var $from = _ref2.$from,
194
194
  $to = _ref2.$to;
195
195
  return expandToBlockRange($from, $to);
196
- };
196
+ };
197
+ export var isMultiBlockRange = function isMultiBlockRange(range) {
198
+ if (range.endIndex - range.startIndex <= 1) {
199
+ return false; // At most one child
200
+ }
201
+
202
+ // Count block nodes in the range, return true if more than one
203
+ var blockCount = 0;
204
+ for (var i = range.startIndex; i < range.endIndex; i++) {
205
+ if (range.parent.child(i).isBlock) {
206
+ blockCount++;
207
+ }
208
+ if (blockCount > 1) {
209
+ return true;
210
+ }
211
+ }
212
+ return false;
213
+ };
214
+
215
+ /**
216
+ * Determines if a selection contains multiple block nodes.
217
+ */
218
+ export function isMultiBlockSelection(selection) {
219
+ var _expandSelectionToBlo = expandSelectionToBlockRange(selection),
220
+ range = _expandSelectionToBlo.range;
221
+ if (!range) {
222
+ return false;
223
+ }
224
+ return isMultiBlockRange(range);
225
+ }
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "0.0.0-development";
24
+ var packageVersion = "111.0.4";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -11,7 +11,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
11
11
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
12
12
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
13
13
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
14
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
14
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isMultiBlockRange, isMultiBlockSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
15
15
  export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
16
16
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
17
17
  export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
@@ -1,4 +1,4 @@
1
- import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import type { NodeRange, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import { type Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare const isSelectionAtStartOfNode: ($pos: ResolvedPos, parentNode?: PMNode) => boolean;
@@ -46,7 +46,7 @@ export declare const expandToBlockRange: ($from: ResolvedPos, $to: ResolvedPos,
46
46
  } | {
47
47
  $from: ResolvedPos;
48
48
  $to: ResolvedPos;
49
- range: import("prosemirror-model").NodeRange;
49
+ range: NodeRange;
50
50
  };
51
51
  /**
52
52
  * Expands a given selection to a block range, considering specific node types that require expansion.
@@ -67,5 +67,10 @@ export declare const expandSelectionToBlockRange: ({ $from, $to }: Selection) =>
67
67
  } | {
68
68
  $from: ResolvedPos;
69
69
  $to: ResolvedPos;
70
- range: import("prosemirror-model").NodeRange;
70
+ range: NodeRange;
71
71
  };
72
+ export declare const isMultiBlockRange: (range: NodeRange) => boolean;
73
+ /**
74
+ * Determines if a selection contains multiple block nodes.
75
+ */
76
+ export declare function isMultiBlockSelection(selection: Selection): boolean;
@@ -11,7 +11,7 @@ export { isIgnored } from './gap-cursor/utils/is-ignored';
11
11
  export { isValidTargetNode } from './gap-cursor/utils/is-valid-target-node';
12
12
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
13
13
  export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
14
- export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
14
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, deleteSelectedRange, endPositionOfParent, expandSelectionBounds, expandSelectionToBlockRange, expandToBlockRange, isMultiBlockRange, isMultiBlockSelection, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
15
15
  export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
16
16
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
17
17
  export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined;
@@ -1,4 +1,4 @@
1
- import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import type { NodeRange, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import { type Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare const isSelectionAtStartOfNode: ($pos: ResolvedPos, parentNode?: PMNode) => boolean;
@@ -46,7 +46,7 @@ export declare const expandToBlockRange: ($from: ResolvedPos, $to: ResolvedPos,
46
46
  } | {
47
47
  $from: ResolvedPos;
48
48
  $to: ResolvedPos;
49
- range: import("prosemirror-model").NodeRange;
49
+ range: NodeRange;
50
50
  };
51
51
  /**
52
52
  * Expands a given selection to a block range, considering specific node types that require expansion.
@@ -67,5 +67,10 @@ export declare const expandSelectionToBlockRange: ({ $from, $to }: Selection) =>
67
67
  } | {
68
68
  $from: ResolvedPos;
69
69
  $to: ResolvedPos;
70
- range: import("prosemirror-model").NodeRange;
70
+ range: NodeRange;
71
71
  };
72
+ export declare const isMultiBlockRange: (range: NodeRange) => boolean;
73
+ /**
74
+ * Determines if a selection contains multiple block nodes.
75
+ */
76
+ export declare function isMultiBlockSelection(selection: Selection): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "111.0.4",
3
+ "version": "111.0.5",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"