@atlaskit/editor-plugin-show-diff 16.0.13 → 16.0.14
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 +8 -0
- package/dist/cjs/pm-plugins/decorations/createInlineChangedDecoration.js +4 -6
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +6 -7
- package/dist/cjs/pm-plugins/utils/isEmptyParagraphSlice.js +11 -0
- package/dist/es2019/pm-plugins/decorations/createInlineChangedDecoration.js +4 -6
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +6 -7
- package/dist/es2019/pm-plugins/utils/isEmptyParagraphSlice.js +5 -0
- package/dist/esm/pm-plugins/decorations/createInlineChangedDecoration.js +4 -6
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +6 -7
- package/dist/esm/pm-plugins/utils/isEmptyParagraphSlice.js +5 -0
- package/dist/types/pm-plugins/utils/isEmptyParagraphSlice.d.ts +3 -0
- package/package.json +1 -1
- package/dist/cjs/pm-plugins/utils/hasVisibleContent.js +0 -37
- package/dist/es2019/pm-plugins/utils/hasVisibleContent.js +0 -28
- package/dist/esm/pm-plugins/utils/hasVisibleContent.js +0 -32
- package/dist/types/pm-plugins/utils/hasVisibleContent.d.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 16.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6667b6ae8e77c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6667b6ae8e77c) -
|
|
8
|
+
Ensure contributor tags are rendered for shown attributed diff content, including whitespace-only
|
|
9
|
+
changes and deletion widgets, without tagging structurally empty paragraphs.
|
|
10
|
+
|
|
3
11
|
## 16.0.13
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -12,7 +12,7 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
12
12
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
13
13
|
var _buildContributorTagDom = require("../../ui/ContributorTag/buildContributorTagDom");
|
|
14
14
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
15
|
-
var
|
|
15
|
+
var _isEmptyParagraphSlice = require("../utils/isEmptyParagraphSlice");
|
|
16
16
|
var _factory = require("./colorSchemes/factory");
|
|
17
17
|
var _schemes = require("./colorSchemes/schemes");
|
|
18
18
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
@@ -163,11 +163,9 @@ var createInlineChangedDecoration = exports.createInlineChangedDecoration = func
|
|
|
163
163
|
// tag host's key, remounting every tag mid-step. Random ids are kept when tags are off.
|
|
164
164
|
var diffId = showContributorTags ? "inline-".concat(change.fromB, "-").concat(change.toB) : crypto.randomUUID();
|
|
165
165
|
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
// a host that is never emitted (EDITOR-8855).
|
|
170
|
-
var canTagChange = showContributorTags && !!doc && (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && (0, _createContributorTagWidget.isContributorTagWidgetEnabled)() && (0, _hasVisibleContent.hasVisibleContent)(doc.slice(change.fromB, change.toB).content);
|
|
166
|
+
// Match the rendered shape: whitespace text is eligible, while an empty paragraph is structural
|
|
167
|
+
// content with no tag host.
|
|
168
|
+
var canTagChange = showContributorTags && !!doc && (0, _isExtendedEnabled.isExtendedEnabled)(diffType) && (0, _createContributorTagWidget.isContributorTagWidgetEnabled)() && !(0, _isEmptyParagraphSlice.isEmptyParagraphSlice)(doc.slice(change.fromB, change.toB));
|
|
171
169
|
if (shouldHideDeleted) {
|
|
172
170
|
return [_view.Decoration.inline(change.fromB, change.toB, {
|
|
173
171
|
style: displayNoneStyle
|
|
@@ -9,7 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
10
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
11
11
|
var _isExtendedEnabled = require("../isExtendedEnabled");
|
|
12
|
-
var
|
|
12
|
+
var _isEmptyParagraphSlice = require("../utils/isEmptyParagraphSlice");
|
|
13
13
|
var _createAnchorDecorationWidgets = require("./createAnchorDecorationWidgets");
|
|
14
14
|
var _createChangedRowDecorationWidgets = require("./createChangedRowDecorationWidgets");
|
|
15
15
|
var _createContributorTagWidget = require("./createContributorTagWidget");
|
|
@@ -101,7 +101,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
101
101
|
* that is not in the current document.
|
|
102
102
|
*/
|
|
103
103
|
var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
104
|
-
var
|
|
104
|
+
var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
105
105
|
var attributionKey = _ref2.attributionKey,
|
|
106
106
|
change = _ref2.change,
|
|
107
107
|
doc = _ref2.doc,
|
|
@@ -124,7 +124,7 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
124
124
|
reveal = _ref2.reveal,
|
|
125
125
|
tagMountContext = _ref2.tagMountContext;
|
|
126
126
|
var slice = doc.slice(change.fromA, change.toA);
|
|
127
|
-
var shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (
|
|
127
|
+
var shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (0, _isEmptyParagraphSlice.isEmptyParagraphSlice)(slice);
|
|
128
128
|
// Widget decoration used for deletions as the content is not in the document
|
|
129
129
|
// and we want to display the deleted content with a style.
|
|
130
130
|
// For `placeBelow`, anchor at the END of the new content (change.toB) so the deleted
|
|
@@ -226,10 +226,9 @@ var createNodeChangedDecorationWidget = exports.createNodeChangedDecorationWidge
|
|
|
226
226
|
// Derived from the deleted range so it survives a recalculation — see the same reasoning in
|
|
227
227
|
// `createInlineChangedDecoration`.
|
|
228
228
|
var diffId = showContributorTags ? "widget-".concat(change.fromA, "-").concat(change.toA) : crypto.randomUUID();
|
|
229
|
-
//
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
var canTagWidget = showContributorTags && (0, _hasVisibleContent.hasVisibleContent)(slice.content);
|
|
229
|
+
// Match the rendering predicate above: an empty paragraph has no widget to tag, while whitespace
|
|
230
|
+
// text in a rendered widget remains eligible.
|
|
231
|
+
var canTagWidget = showContributorTags && !shouldSkipDeletedEmptyParagraphDecoration;
|
|
233
232
|
var decorations = [];
|
|
234
233
|
var replacementNode = newDoc.nodeAt(change.fromB);
|
|
235
234
|
var firstReplacedNode = slice.content.firstChild;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isEmptyParagraphSlice = void 0;
|
|
7
|
+
/** Whether a slice contains exactly one structurally empty paragraph. */
|
|
8
|
+
var isEmptyParagraphSlice = exports.isEmptyParagraphSlice = function isEmptyParagraphSlice(slice) {
|
|
9
|
+
var _slice$content$firstC;
|
|
10
|
+
return (slice === null || slice === void 0 ? void 0 : slice.content.childCount) === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'paragraph' && slice.content.firstChild.content.size === 0;
|
|
11
|
+
};
|
|
@@ -3,7 +3,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
3
3
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
4
4
|
import { CONTRIBUTOR_TAG_Z_INDEX } from '../../ui/ContributorTag/buildContributorTagDom';
|
|
5
5
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
6
|
-
import {
|
|
6
|
+
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
7
7
|
import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
|
|
8
8
|
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
9
9
|
import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
@@ -138,11 +138,9 @@ export const createInlineChangedDecoration = ({
|
|
|
138
138
|
// tag host's key, remounting every tag mid-step. Random ids are kept when tags are off.
|
|
139
139
|
const diffId = showContributorTags ? `inline-${change.fromB}-${change.toB}` : crypto.randomUUID();
|
|
140
140
|
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
// a host that is never emitted (EDITOR-8855).
|
|
145
|
-
const canTagChange = showContributorTags && !!doc && isExtendedEnabled(diffType) && isContributorTagWidgetEnabled() && hasVisibleContent(doc.slice(change.fromB, change.toB).content);
|
|
141
|
+
// Match the rendered shape: whitespace text is eligible, while an empty paragraph is structural
|
|
142
|
+
// content with no tag host.
|
|
143
|
+
const canTagChange = showContributorTags && !!doc && isExtendedEnabled(diffType) && isContributorTagWidgetEnabled() && !isEmptyParagraphSlice(doc.slice(change.fromB, change.toB));
|
|
146
144
|
if (shouldHideDeleted) {
|
|
147
145
|
return [Decoration.inline(change.fromB, change.toB, {
|
|
148
146
|
style: displayNoneStyle
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
3
3
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
4
|
-
import {
|
|
4
|
+
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
5
5
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
6
6
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
7
7
|
import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
|
|
@@ -114,9 +114,9 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
114
114
|
reveal,
|
|
115
115
|
tagMountContext
|
|
116
116
|
}) => {
|
|
117
|
-
var
|
|
117
|
+
var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
118
118
|
const slice = doc.slice(change.fromA, change.toA);
|
|
119
|
-
const shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice
|
|
119
|
+
const shouldSkipDeletedEmptyParagraphDecoration = !isInserted && isEmptyParagraphSlice(slice);
|
|
120
120
|
// Widget decoration used for deletions as the content is not in the document
|
|
121
121
|
// and we want to display the deleted content with a style.
|
|
122
122
|
// For `placeBelow`, anchor at the END of the new content (change.toB) so the deleted
|
|
@@ -210,10 +210,9 @@ export const createNodeChangedDecorationWidget = ({
|
|
|
210
210
|
// Derived from the deleted range so it survives a recalculation — see the same reasoning in
|
|
211
211
|
// `createInlineChangedDecoration`.
|
|
212
212
|
const diffId = showContributorTags ? `widget-${change.fromA}-${change.toA}` : crypto.randomUUID();
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
const canTagWidget = showContributorTags && hasVisibleContent(slice.content);
|
|
213
|
+
// Match the rendering predicate above: an empty paragraph has no widget to tag, while whitespace
|
|
214
|
+
// text in a rendered widget remains eligible.
|
|
215
|
+
const canTagWidget = showContributorTags && !shouldSkipDeletedEmptyParagraphDecoration;
|
|
217
216
|
const decorations = [];
|
|
218
217
|
const replacementNode = newDoc.nodeAt(change.fromB);
|
|
219
218
|
const firstReplacedNode = slice.content.firstChild;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Whether a slice contains exactly one structurally empty paragraph. */
|
|
2
|
+
export const isEmptyParagraphSlice = slice => {
|
|
3
|
+
var _slice$content$firstC;
|
|
4
|
+
return (slice === null || slice === void 0 ? void 0 : slice.content.childCount) === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'paragraph' && slice.content.firstChild.content.size === 0;
|
|
5
|
+
};
|
|
@@ -7,7 +7,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
7
7
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
8
|
import { CONTRIBUTOR_TAG_Z_INDEX } from '../../ui/ContributorTag/buildContributorTagDom';
|
|
9
9
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
10
|
-
import {
|
|
10
|
+
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
11
11
|
import { buildAtomicInlineChangedCSSVariables, buildDeletedInlineContentStyleExtended, buildDeletedInlineStyle, buildDeletedInlineStyleStandard, buildInsertStyle, buildInsertStyleActive, buildInsertStyleExtended, buildInsertStyleExtendedActive, buildInsertStyleExtendedNoUnderline, buildInsertStyleExtendedNoUnderlineActive } from './colorSchemes/factory';
|
|
12
12
|
import { colorSchemeRegistry, getLegacyColorScheme } from './colorSchemes/schemes';
|
|
13
13
|
import { createInlineIndicatorAnchorWidgets } from './createAnchorDecorationWidgets';
|
|
@@ -156,11 +156,9 @@ export var createInlineChangedDecoration = function createInlineChangedDecoratio
|
|
|
156
156
|
// tag host's key, remounting every tag mid-step. Random ids are kept when tags are off.
|
|
157
157
|
var diffId = showContributorTags ? "inline-".concat(change.fromB, "-").concat(change.toB) : crypto.randomUUID();
|
|
158
158
|
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
// a host that is never emitted (EDITOR-8855).
|
|
163
|
-
var canTagChange = showContributorTags && !!doc && isExtendedEnabled(diffType) && isContributorTagWidgetEnabled() && hasVisibleContent(doc.slice(change.fromB, change.toB).content);
|
|
159
|
+
// Match the rendered shape: whitespace text is eligible, while an empty paragraph is structural
|
|
160
|
+
// content with no tag host.
|
|
161
|
+
var canTagChange = showContributorTags && !!doc && isExtendedEnabled(diffType) && isContributorTagWidgetEnabled() && !isEmptyParagraphSlice(doc.slice(change.fromB, change.toB));
|
|
164
162
|
if (shouldHideDeleted) {
|
|
165
163
|
return [Decoration.inline(change.fromB, change.toB, {
|
|
166
164
|
style: displayNoneStyle
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { isExtendedEnabled } from '../isExtendedEnabled';
|
|
7
|
-
import {
|
|
7
|
+
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
8
8
|
import { createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
9
9
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
10
10
|
import { createContributorTagHost, unmountContributorTag } from './createContributorTagWidget';
|
|
@@ -94,7 +94,7 @@ var createTableCellContentWidgets = function createTableCellContentWidgets(_ref)
|
|
|
94
94
|
* that is not in the current document.
|
|
95
95
|
*/
|
|
96
96
|
export var createNodeChangedDecorationWidget = function createNodeChangedDecorationWidget(_ref2) {
|
|
97
|
-
var
|
|
97
|
+
var _$safeInsertPos$nodeB, _slice$content$firstC, _newDoc$firstChild, _slice$content$firstC2;
|
|
98
98
|
var attributionKey = _ref2.attributionKey,
|
|
99
99
|
change = _ref2.change,
|
|
100
100
|
doc = _ref2.doc,
|
|
@@ -117,7 +117,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
117
117
|
reveal = _ref2.reveal,
|
|
118
118
|
tagMountContext = _ref2.tagMountContext;
|
|
119
119
|
var slice = doc.slice(change.fromA, change.toA);
|
|
120
|
-
var shouldSkipDeletedEmptyParagraphDecoration = !isInserted && (slice
|
|
120
|
+
var shouldSkipDeletedEmptyParagraphDecoration = !isInserted && isEmptyParagraphSlice(slice);
|
|
121
121
|
// Widget decoration used for deletions as the content is not in the document
|
|
122
122
|
// and we want to display the deleted content with a style.
|
|
123
123
|
// For `placeBelow`, anchor at the END of the new content (change.toB) so the deleted
|
|
@@ -219,10 +219,9 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
219
219
|
// Derived from the deleted range so it survives a recalculation — see the same reasoning in
|
|
220
220
|
// `createInlineChangedDecoration`.
|
|
221
221
|
var diffId = showContributorTags ? "widget-".concat(change.fromA, "-").concat(change.toA) : crypto.randomUUID();
|
|
222
|
-
//
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
var canTagWidget = showContributorTags && hasVisibleContent(slice.content);
|
|
222
|
+
// Match the rendering predicate above: an empty paragraph has no widget to tag, while whitespace
|
|
223
|
+
// text in a rendered widget remains eligible.
|
|
224
|
+
var canTagWidget = showContributorTags && !shouldSkipDeletedEmptyParagraphDecoration;
|
|
226
225
|
var decorations = [];
|
|
227
226
|
var replacementNode = newDoc.nodeAt(change.fromB);
|
|
228
227
|
var firstReplacedNode = slice.content.firstChild;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Whether a slice contains exactly one structurally empty paragraph. */
|
|
2
|
+
export var isEmptyParagraphSlice = function isEmptyParagraphSlice(slice) {
|
|
3
|
+
var _slice$content$firstC;
|
|
4
|
+
return (slice === null || slice === void 0 ? void 0 : slice.content.childCount) === 1 && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type.name) === 'paragraph' && slice.content.firstChild.content.size === 0;
|
|
5
|
+
};
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.hasVisibleContent = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _charsByOffset = require("./charsByOffset");
|
|
10
|
-
/**
|
|
11
|
-
* Whether `fragment` holds anything a reader can see.
|
|
12
|
-
*
|
|
13
|
-
* Text counts once it carries a single non-whitespace character; a leaf node (mention, emoji, date,
|
|
14
|
-
* media, rule, hardBreak, …) counts in its own right, exactly as `resolveTagAnchorPos` treats one.
|
|
15
|
-
* Everything else is descended into, so a paragraph is visible when its content is.
|
|
16
|
-
*
|
|
17
|
-
* A change whose content is nothing but whitespace — a space typed between two words, a run of
|
|
18
|
-
* trailing spaces, an added blank paragraph — has no visible content for a contributor tag to
|
|
19
|
-
* caption, so it carries no tag (EDITOR-8855).
|
|
20
|
-
*/
|
|
21
|
-
var _hasVisibleContent = exports.hasVisibleContent = function hasVisibleContent(fragment) {
|
|
22
|
-
var visible = false;
|
|
23
|
-
fragment.forEach(function (node) {
|
|
24
|
-
if (visible) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (node.isText) {
|
|
28
|
-
var _node$text;
|
|
29
|
-
visible = (0, _toConsumableArray2.default)((_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '').some(function (char) {
|
|
30
|
-
return !(0, _charsByOffset.isWhitespaceChar)(char);
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
visible = node.isLeaf || _hasVisibleContent(node.content);
|
|
35
|
-
});
|
|
36
|
-
return visible;
|
|
37
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { isWhitespaceChar } from './charsByOffset';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Whether `fragment` holds anything a reader can see.
|
|
5
|
-
*
|
|
6
|
-
* Text counts once it carries a single non-whitespace character; a leaf node (mention, emoji, date,
|
|
7
|
-
* media, rule, hardBreak, …) counts in its own right, exactly as `resolveTagAnchorPos` treats one.
|
|
8
|
-
* Everything else is descended into, so a paragraph is visible when its content is.
|
|
9
|
-
*
|
|
10
|
-
* A change whose content is nothing but whitespace — a space typed between two words, a run of
|
|
11
|
-
* trailing spaces, an added blank paragraph — has no visible content for a contributor tag to
|
|
12
|
-
* caption, so it carries no tag (EDITOR-8855).
|
|
13
|
-
*/
|
|
14
|
-
export const hasVisibleContent = fragment => {
|
|
15
|
-
let visible = false;
|
|
16
|
-
fragment.forEach(node => {
|
|
17
|
-
if (visible) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (node.isText) {
|
|
21
|
-
var _node$text;
|
|
22
|
-
visible = [...((_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '')].some(char => !isWhitespaceChar(char));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
visible = node.isLeaf || hasVisibleContent(node.content);
|
|
26
|
-
});
|
|
27
|
-
return visible;
|
|
28
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { isWhitespaceChar } from './charsByOffset';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Whether `fragment` holds anything a reader can see.
|
|
6
|
-
*
|
|
7
|
-
* Text counts once it carries a single non-whitespace character; a leaf node (mention, emoji, date,
|
|
8
|
-
* media, rule, hardBreak, …) counts in its own right, exactly as `resolveTagAnchorPos` treats one.
|
|
9
|
-
* Everything else is descended into, so a paragraph is visible when its content is.
|
|
10
|
-
*
|
|
11
|
-
* A change whose content is nothing but whitespace — a space typed between two words, a run of
|
|
12
|
-
* trailing spaces, an added blank paragraph — has no visible content for a contributor tag to
|
|
13
|
-
* caption, so it carries no tag (EDITOR-8855).
|
|
14
|
-
*/
|
|
15
|
-
var _hasVisibleContent = function hasVisibleContent(fragment) {
|
|
16
|
-
var visible = false;
|
|
17
|
-
fragment.forEach(function (node) {
|
|
18
|
-
if (visible) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (node.isText) {
|
|
22
|
-
var _node$text;
|
|
23
|
-
visible = _toConsumableArray((_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : '').some(function (char) {
|
|
24
|
-
return !isWhitespaceChar(char);
|
|
25
|
-
});
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
visible = node.isLeaf || _hasVisibleContent(node.content);
|
|
29
|
-
});
|
|
30
|
-
return visible;
|
|
31
|
-
};
|
|
32
|
-
export { _hasVisibleContent as hasVisibleContent };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
/**
|
|
3
|
-
* Whether `fragment` holds anything a reader can see.
|
|
4
|
-
*
|
|
5
|
-
* Text counts once it carries a single non-whitespace character; a leaf node (mention, emoji, date,
|
|
6
|
-
* media, rule, hardBreak, …) counts in its own right, exactly as `resolveTagAnchorPos` treats one.
|
|
7
|
-
* Everything else is descended into, so a paragraph is visible when its content is.
|
|
8
|
-
*
|
|
9
|
-
* A change whose content is nothing but whitespace — a space typed between two words, a run of
|
|
10
|
-
* trailing spaces, an added blank paragraph — has no visible content for a contributor tag to
|
|
11
|
-
* caption, so it carries no tag (EDITOR-8855).
|
|
12
|
-
*/
|
|
13
|
-
export declare const hasVisibleContent: (fragment: Fragment) => boolean;
|