@atlaskit/editor-plugin-annotation 1.22.0 → 1.23.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,24 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 1.23.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#152319](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/152319)
14
+ [`bfa9c49e1928b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bfa9c49e1928b) -
15
+ [ux] Added a check to handle the case where a single non-breaking space is selected and the user
16
+ attempts to leave a comment on it.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 1.22.0
4
23
 
5
24
  ### Minor Changes
package/dist/cjs/utils.js CHANGED
@@ -342,7 +342,7 @@ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(stat
342
342
  if (disallowOnWhitespace && hasInvalidWhitespaceNode(selection, state.schema)) {
343
343
  return _types.AnnotationSelectionType.INVALID;
344
344
  }
345
- if (isEmptyTextSelection(selection, state.schema)) {
345
+ if ((0, _utils.isEmptyTextSelection)(selection, state.schema)) {
346
346
  return _types.AnnotationSelectionType.INVALID;
347
347
  }
348
348
  return _types.AnnotationSelectionType.VALID;
@@ -356,29 +356,6 @@ var hasInvalidNodes = exports.hasInvalidNodes = function hasInvalidNodes(state)
356
356
  to: selection.to
357
357
  }, doc, schema);
358
358
  };
359
-
360
- /**
361
- * Checks if selection contains only empty text
362
- * e.g. when you select across multiple empty paragraphs
363
- */
364
- function isEmptyTextSelection(selection, schema) {
365
- var _schema$nodes = schema.nodes,
366
- text = _schema$nodes.text,
367
- paragraph = _schema$nodes.paragraph;
368
- var hasContent = false;
369
- selection.content().content.descendants(function (node) {
370
- // for empty paragraph - consider empty (nothing to comment on)
371
- if (node.type === paragraph && !node.content.size) {
372
- return false;
373
- }
374
- // for not a text or nonempty text - consider nonempty (can comment if the node is supported for annotations)
375
- if (node.type !== text || !node.textContent) {
376
- hasContent = true;
377
- }
378
- return !hasContent;
379
- });
380
- return !hasContent;
381
- }
382
359
  var isSupportedBlockNode = exports.isSupportedBlockNode = function isSupportedBlockNode(node) {
383
360
  var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
384
361
  return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
@@ -2,7 +2,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
4
4
  import { AnnotationSharedClassNames, BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
5
- import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getRangeInlineNodeNames, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
5
+ import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getRangeInlineNodeNames, hasAnnotationMark, isEmptyTextSelection, isParagraph, isText } from '@atlaskit/editor-common/utils';
6
6
  import { AllSelection, NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -323,30 +323,6 @@ export const hasInvalidNodes = state => {
323
323
  to: selection.to
324
324
  }, doc, schema);
325
325
  };
326
-
327
- /**
328
- * Checks if selection contains only empty text
329
- * e.g. when you select across multiple empty paragraphs
330
- */
331
- function isEmptyTextSelection(selection, schema) {
332
- const {
333
- text,
334
- paragraph
335
- } = schema.nodes;
336
- let hasContent = false;
337
- selection.content().content.descendants(node => {
338
- // for empty paragraph - consider empty (nothing to comment on)
339
- if (node.type === paragraph && !node.content.size) {
340
- return false;
341
- }
342
- // for not a text or nonempty text - consider nonempty (can comment if the node is supported for annotations)
343
- if (node.type !== text || !node.textContent) {
344
- hasContent = true;
345
- }
346
- return !hasContent;
347
- });
348
- return !hasContent;
349
- }
350
326
  export const isSupportedBlockNode = (node, supportedBlockNodes = []) => {
351
327
  return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
352
328
  };
package/dist/esm/utils.js CHANGED
@@ -2,7 +2,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
4
4
  import { AnnotationSharedClassNames, BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
5
- import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getRangeInlineNodeNames, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
5
+ import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getRangeInlineNodeNames, hasAnnotationMark, isEmptyTextSelection, isParagraph, isText } from '@atlaskit/editor-common/utils';
6
6
  import { AllSelection, NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -329,29 +329,6 @@ export var hasInvalidNodes = function hasInvalidNodes(state) {
329
329
  to: selection.to
330
330
  }, doc, schema);
331
331
  };
332
-
333
- /**
334
- * Checks if selection contains only empty text
335
- * e.g. when you select across multiple empty paragraphs
336
- */
337
- function isEmptyTextSelection(selection, schema) {
338
- var _schema$nodes = schema.nodes,
339
- text = _schema$nodes.text,
340
- paragraph = _schema$nodes.paragraph;
341
- var hasContent = false;
342
- selection.content().content.descendants(function (node) {
343
- // for empty paragraph - consider empty (nothing to comment on)
344
- if (node.type === paragraph && !node.content.size) {
345
- return false;
346
- }
347
- // for not a text or nonempty text - consider nonempty (can comment if the node is supported for annotations)
348
- if (node.type !== text || !node.textContent) {
349
- hasContent = true;
350
- }
351
- return !hasContent;
352
- });
353
- return !hasContent;
354
- }
355
332
  export var isSupportedBlockNode = function isSupportedBlockNode(node) {
356
333
  var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
357
334
  return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.22.0",
3
+ "version": "1.23.1",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,14 +32,14 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^42.3.1",
35
- "@atlaskit/editor-common": "^94.8.0",
35
+ "@atlaskit/editor-common": "^94.9.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^1.1.0",
38
38
  "@atlaskit/editor-plugin-engagement-platform": "^2.1.0",
39
39
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
40
40
  "@atlaskit/editor-prosemirror": "6.0.0",
41
41
  "@atlaskit/icon": "^22.24.0",
42
- "@atlaskit/onboarding": "^11.2.0",
42
+ "@atlaskit/onboarding": "^12.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.3.0",
44
44
  "@atlaskit/tmp-editor-statsig": "^2.10.0",
45
45
  "@babel/runtime": "^7.0.0"