@atlaskit/editor-common 109.1.1 → 109.1.2

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,13 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 109.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6cbab7879c7ac`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6cbab7879c7ac) -
8
+ [EDITOR-1433] Make sure isEmptySelectionAtStart can handle blockTaskItems
9
+ - Updated dependencies
10
+
3
11
  ## 109.1.1
4
12
 
5
13
  ### Patch Changes
@@ -16,7 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
16
  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); }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "109.1.0";
19
+ var packageVersion = "109.1.1";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // Ignored via go/ees007
@@ -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 = "109.1.0";
27
+ var packageVersion = "109.1.1";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -269,10 +269,26 @@ var insertContentDeleteRange = exports.insertContentDeleteRange = function inser
269
269
  });
270
270
  tr.setSelection(new _state.TextSelection(getSelectionResolvedPos(tr)));
271
271
  };
272
+
273
+ /**
274
+ * Check if the selection is empty and at the start of a task or list item
275
+ * @param state Editor state
276
+ * @returns true if selection is empty and at the start of a task or list item
277
+ */
272
278
  var isEmptySelectionAtStart = exports.isEmptySelectionAtStart = function isEmptySelectionAtStart(state) {
279
+ var blockTaskItem = state.schema.nodes.blockTaskItem;
273
280
  var _state$selection4 = state.selection,
274
281
  empty = _state$selection4.empty,
275
282
  $from = _state$selection4.$from;
283
+
284
+ // If blockTaskItem is in the schema & the selection is empty
285
+ if (blockTaskItem && empty && $from.parent.type === blockTaskItem) {
286
+ var blockTaskItemDepth = $from.depth - 1;
287
+ var firstPosInBlockTaskItem = $from.start(blockTaskItemDepth) + 1;
288
+
289
+ // Is the selection at the first possible position inside the blockTaskItem
290
+ return $from.pos === firstPosInBlockTaskItem;
291
+ }
276
292
  return empty && ($from.parentOffset === 0 || state.selection instanceof _selection.GapCursorSelection);
277
293
  };
278
294
  var isEmptySelectionAtEnd = exports.isEmptySelectionAtEnd = function isEmptySelectionAtEnd(state) {
@@ -1,7 +1,7 @@
1
1
  import { isFedRamp } from './environment';
2
2
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
3
3
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
4
- const packageVersion = "109.1.0";
4
+ const packageVersion = "109.1.1";
5
5
  const sanitiseSentryEvents = (data, _hint) => {
6
6
  // Remove URL as it has UGC
7
7
  // Ignored via go/ees007
@@ -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 = "109.1.0";
17
+ const packageVersion = "109.1.1";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -269,11 +269,29 @@ export const insertContentDeleteRange = (tr, getSelectionResolvedPos, insertions
269
269
  });
270
270
  tr.setSelection(new TextSelection(getSelectionResolvedPos(tr)));
271
271
  };
272
+
273
+ /**
274
+ * Check if the selection is empty and at the start of a task or list item
275
+ * @param state Editor state
276
+ * @returns true if selection is empty and at the start of a task or list item
277
+ */
272
278
  export const isEmptySelectionAtStart = state => {
279
+ const {
280
+ blockTaskItem
281
+ } = state.schema.nodes;
273
282
  const {
274
283
  empty,
275
284
  $from
276
285
  } = state.selection;
286
+
287
+ // If blockTaskItem is in the schema & the selection is empty
288
+ if (blockTaskItem && empty && $from.parent.type === blockTaskItem) {
289
+ const blockTaskItemDepth = $from.depth - 1;
290
+ const firstPosInBlockTaskItem = $from.start(blockTaskItemDepth) + 1;
291
+
292
+ // Is the selection at the first possible position inside the blockTaskItem
293
+ return $from.pos === firstPosInBlockTaskItem;
294
+ }
277
295
  return empty && ($from.parentOffset === 0 || state.selection instanceof GapCursorSelection);
278
296
  };
279
297
  export const isEmptySelectionAtEnd = state => {
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { isFedRamp } from './environment';
8
8
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
9
9
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
10
- var packageVersion = "109.1.0";
10
+ var packageVersion = "109.1.1";
11
11
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
12
12
  // Remove URL as it has UGC
13
13
  // Ignored via go/ees007
@@ -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 = "109.1.0";
24
+ var packageVersion = "109.1.1";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -256,10 +256,26 @@ export var insertContentDeleteRange = function insertContentDeleteRange(tr, getS
256
256
  });
257
257
  tr.setSelection(new TextSelection(getSelectionResolvedPos(tr)));
258
258
  };
259
+
260
+ /**
261
+ * Check if the selection is empty and at the start of a task or list item
262
+ * @param state Editor state
263
+ * @returns true if selection is empty and at the start of a task or list item
264
+ */
259
265
  export var isEmptySelectionAtStart = function isEmptySelectionAtStart(state) {
266
+ var blockTaskItem = state.schema.nodes.blockTaskItem;
260
267
  var _state$selection4 = state.selection,
261
268
  empty = _state$selection4.empty,
262
269
  $from = _state$selection4.$from;
270
+
271
+ // If blockTaskItem is in the schema & the selection is empty
272
+ if (blockTaskItem && empty && $from.parent.type === blockTaskItem) {
273
+ var blockTaskItemDepth = $from.depth - 1;
274
+ var firstPosInBlockTaskItem = $from.start(blockTaskItemDepth) + 1;
275
+
276
+ // Is the selection at the first possible position inside the blockTaskItem
277
+ return $from.pos === firstPosInBlockTaskItem;
278
+ }
263
279
  return empty && ($from.parentOffset === 0 || state.selection instanceof GapCursorSelection);
264
280
  };
265
281
  export var isEmptySelectionAtEnd = function isEmptySelectionAtEnd(state) {
@@ -37,6 +37,11 @@ export declare function atTheBeginningOfDoc(state: EditorState): boolean;
37
37
  */
38
38
  export declare const deleteEmptyParagraphAndMoveBlockUp: (canNextNodeMoveUp: (nextNode: PMNode) => boolean) => Command;
39
39
  export declare const insertContentDeleteRange: (tr: Transaction, getSelectionResolvedPos: (tr: Transaction) => ResolvedPos, insertions: [Fragment, number][], deletions: [number, number][]) => void;
40
+ /**
41
+ * Check if the selection is empty and at the start of a task or list item
42
+ * @param state Editor state
43
+ * @returns true if selection is empty and at the start of a task or list item
44
+ */
40
45
  export declare const isEmptySelectionAtStart: (state: EditorState) => boolean;
41
46
  export declare const isEmptySelectionAtEnd: (state: EditorState) => boolean;
42
47
  export { filter as filterCommand };
@@ -43,6 +43,11 @@ export declare const insertContentDeleteRange: (tr: Transaction, getSelectionRes
43
43
  number,
44
44
  number
45
45
  ][]) => void;
46
+ /**
47
+ * Check if the selection is empty and at the start of a task or list item
48
+ * @param state Editor state
49
+ * @returns true if selection is empty and at the start of a task or list item
50
+ */
46
51
  export declare const isEmptySelectionAtStart: (state: EditorState) => boolean;
47
52
  export declare const isEmptySelectionAtEnd: (state: EditorState) => boolean;
48
53
  export { filter as filterCommand };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "109.1.1",
3
+ "version": "109.1.2",
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/"
@@ -218,7 +218,7 @@
218
218
  "@af/visual-regression": "workspace:^",
219
219
  "@atlaskit/media-core": "^37.0.0",
220
220
  "@atlaskit/media-test-helpers": "^39.0.0",
221
- "@atlaskit/util-data-test": "^18.1.0",
221
+ "@atlaskit/util-data-test": "^18.2.0",
222
222
  "@testing-library/dom": "^10.1.0",
223
223
  "@testing-library/jest-dom": "^6.4.5",
224
224
  "@testing-library/react": "^13.4.0",