@atlaskit/editor-common 109.1.0 → 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,22 @@
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
+
11
+ ## 109.1.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`360b8c9d0b280`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/360b8c9d0b280) -
16
+ [ux] [ED-29055] selections with no text nodes will always return text formatting marks as active.
17
+ this is behind the aifc experiment and patch 3 experiment
18
+ - Updated dependencies
19
+
3
20
  ## 109.1.0
4
21
 
5
22
  ### Minor Changes
@@ -8,6 +8,7 @@ exports.wholeSelectionHasMarks = exports.isMarkExcluded = exports.isMarkAllowedI
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _model = require("@atlaskit/editor-prosemirror/model");
10
10
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
11
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
12
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
12
13
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
14
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -136,6 +137,10 @@ var wholeRangeHasMarks = function wholeRangeHasMarks(from, to, doc, markTypes) {
136
137
  var hasMarks = new Map(markTypes.map(function (markType) {
137
138
  return [markType, true];
138
139
  }));
140
+ var hasNoMarks = new Map(markTypes.map(function (markType) {
141
+ return [markType, false];
142
+ }));
143
+ var isTextContent = false;
139
144
  doc.nodesBetween(from, to, function (node) {
140
145
  if (allMarksAreRuledOut(hasMarks)) {
141
146
  // This won't be a true early exit, but will prevent diving into nodes and
@@ -145,6 +150,7 @@ var wholeRangeHasMarks = function wholeRangeHasMarks(from, to, doc, markTypes) {
145
150
  if (!node.type.isText) {
146
151
  return true; // continue traversing
147
152
  }
153
+ isTextContent = true;
148
154
  var _iterator3 = _createForOfIteratorHelper(hasMarks),
149
155
  _step3;
150
156
  try {
@@ -170,6 +176,9 @@ var wholeRangeHasMarks = function wholeRangeHasMarks(from, to, doc, markTypes) {
170
176
  _iterator3.f();
171
177
  }
172
178
  });
179
+ if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true)) {
180
+ return isTextContent ? hasMarks : hasNoMarks;
181
+ }
173
182
  return hasMarks;
174
183
  };
175
184
  var isMarkAllowedInRange = exports.isMarkAllowedInRange = function isMarkAllowedInRange(doc, ranges, type) {
@@ -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.0.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.0.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,5 +1,6 @@
1
1
  import { Mark } from '@atlaskit/editor-prosemirror/model';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
 
4
5
  /**
5
6
  * Determine if a mark of a specific type exists anywhere in the selection.
@@ -96,6 +97,8 @@ const cellSelectionHasMarks = (doc, selection, markTypes) => {
96
97
  };
97
98
  const wholeRangeHasMarks = (from, to, doc, markTypes) => {
98
99
  const hasMarks = new Map(markTypes.map(markType => [markType, true]));
100
+ const hasNoMarks = new Map(markTypes.map(markType => [markType, false]));
101
+ let isTextContent = false;
99
102
  doc.nodesBetween(from, to, node => {
100
103
  if (allMarksAreRuledOut(hasMarks)) {
101
104
  // This won't be a true early exit, but will prevent diving into nodes and
@@ -105,6 +108,7 @@ const wholeRangeHasMarks = (from, to, doc, markTypes) => {
105
108
  if (!node.type.isText) {
106
109
  return true; // continue traversing
107
110
  }
111
+ isTextContent = true;
108
112
  for (const [markType, hasMark] of hasMarks) {
109
113
  if (!hasMark) {
110
114
  continue; // already ruled out the mark, skip further checks
@@ -113,6 +117,9 @@ const wholeRangeHasMarks = (from, to, doc, markTypes) => {
113
117
  hasMarks.set(markType, value);
114
118
  }
115
119
  });
120
+ if (expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true)) {
121
+ return isTextContent ? hasMarks : hasNoMarks;
122
+ }
116
123
  return hasMarks;
117
124
  };
118
125
  export const isMarkAllowedInRange = (doc, ranges, type) => {
@@ -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.0.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.0.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 => {
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
4
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
5
  import { Mark } from '@atlaskit/editor-prosemirror/model';
6
6
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
7
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
8
 
8
9
  /**
9
10
  * Determine if a mark of a specific type exists anywhere in the selection.
@@ -130,6 +131,10 @@ var wholeRangeHasMarks = function wholeRangeHasMarks(from, to, doc, markTypes) {
130
131
  var hasMarks = new Map(markTypes.map(function (markType) {
131
132
  return [markType, true];
132
133
  }));
134
+ var hasNoMarks = new Map(markTypes.map(function (markType) {
135
+ return [markType, false];
136
+ }));
137
+ var isTextContent = false;
133
138
  doc.nodesBetween(from, to, function (node) {
134
139
  if (allMarksAreRuledOut(hasMarks)) {
135
140
  // This won't be a true early exit, but will prevent diving into nodes and
@@ -139,6 +144,7 @@ var wholeRangeHasMarks = function wholeRangeHasMarks(from, to, doc, markTypes) {
139
144
  if (!node.type.isText) {
140
145
  return true; // continue traversing
141
146
  }
147
+ isTextContent = true;
142
148
  var _iterator3 = _createForOfIteratorHelper(hasMarks),
143
149
  _step3;
144
150
  try {
@@ -164,6 +170,9 @@ var wholeRangeHasMarks = function wholeRangeHasMarks(from, to, doc, markTypes) {
164
170
  _iterator3.f();
165
171
  }
166
172
  });
173
+ if (expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true)) {
174
+ return isTextContent ? hasMarks : hasNoMarks;
175
+ }
167
176
  return hasMarks;
168
177
  };
169
178
  export var isMarkAllowedInRange = function isMarkAllowedInRange(doc, ranges, type) {
@@ -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.0.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.0.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.0",
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/"
@@ -151,7 +151,7 @@
151
151
  "@atlaskit/icon-object": "^7.2.0",
152
152
  "@atlaskit/link": "^3.2.0",
153
153
  "@atlaskit/link-datasource": "^4.21.0",
154
- "@atlaskit/link-picker": "^3.9.0",
154
+ "@atlaskit/link-picker": "^3.10.0",
155
155
  "@atlaskit/media-card": "^79.5.0",
156
156
  "@atlaskit/media-client": "^35.3.0",
157
157
  "@atlaskit/media-client-react": "^4.1.0",
@@ -167,7 +167,7 @@
167
167
  "@atlaskit/platform-feature-flags-react": "^0.3.0",
168
168
  "@atlaskit/popper": "^7.1.0",
169
169
  "@atlaskit/primitives": "^14.14.0",
170
- "@atlaskit/profilecard": "^24.11.0",
170
+ "@atlaskit/profilecard": "^24.12.0",
171
171
  "@atlaskit/react-ufo": "^4.6.0",
172
172
  "@atlaskit/section-message": "^8.7.0",
173
173
  "@atlaskit/smart-card": "^40.22.0",
@@ -177,7 +177,7 @@
177
177
  "@atlaskit/task-decision": "^19.2.0",
178
178
  "@atlaskit/textfield": "^8.0.0",
179
179
  "@atlaskit/theme": "^21.0.0",
180
- "@atlaskit/tmp-editor-statsig": "^12.10.0",
180
+ "@atlaskit/tmp-editor-statsig": "^12.12.0",
181
181
  "@atlaskit/tokens": "^6.3.0",
182
182
  "@atlaskit/tooltip": "^20.4.0",
183
183
  "@atlaskit/width-detector": "^5.0.0",
@@ -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",