@atlaskit/editor-common 111.32.1 → 111.33.0
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 +12 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/document.js +63 -6
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/document.js +40 -6
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/document.js +63 -6
- package/dist/types/utils/document.d.ts +4 -1
- package/dist/types-ts4.5/utils/document.d.ts +4 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 111.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`e7825d1698274`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e7825d1698274) -
|
|
8
|
+
Improve areNodesEqualIgnoreAttrs by adding option ignoreMarkOrder which ensures the order of the
|
|
9
|
+
marks does not result in a "false" which can break some cases of diffs.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 111.32.1
|
|
4
16
|
|
|
5
17
|
### 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 = "
|
|
22
|
+
var packageVersion = "111.32.1";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// 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 = "
|
|
27
|
+
var packageVersion = "111.32.1";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var fadeIn = (0, _react2.keyframes)({
|
|
@@ -15,7 +15,11 @@ exports.isSelectionEndOfParagraph = exports.isReplaceDocOperation = void 0;
|
|
|
15
15
|
exports.nodesBetweenChanged = nodesBetweenChanged;
|
|
16
16
|
var _clamp = _interopRequireDefault(require("lodash/clamp"));
|
|
17
17
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
18
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
19
|
var _editorCoreUtils = require("./editor-core-utils");
|
|
20
|
+
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; } } }; }
|
|
21
|
+
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; } }
|
|
22
|
+
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; }
|
|
19
23
|
var getStepRange = exports.getStepRange = function getStepRange(transaction) {
|
|
20
24
|
var from = -1;
|
|
21
25
|
var to = -1;
|
|
@@ -150,7 +154,44 @@ var isReplaceDocOperation = exports.isReplaceDocOperation = function isReplaceDo
|
|
|
150
154
|
return hasStepReplacingEntireDocument;
|
|
151
155
|
});
|
|
152
156
|
};
|
|
153
|
-
|
|
157
|
+
function marksEqualInOrder(m1, m2) {
|
|
158
|
+
if (m1.length !== m2.length) return false;
|
|
159
|
+
return m1.every(function (m, i) {
|
|
160
|
+
return m.eq(m2[i]);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function marksEqualIgnoringOrder(m1, m2) {
|
|
164
|
+
if (m1.length !== m2.length) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
var m2Used = new Set();
|
|
168
|
+
var _iterator = _createForOfIteratorHelper(m1),
|
|
169
|
+
_step;
|
|
170
|
+
try {
|
|
171
|
+
var _loop = function _loop() {
|
|
172
|
+
var mark1 = _step.value;
|
|
173
|
+
var idx = m2.findIndex(function (mark2, i) {
|
|
174
|
+
return !m2Used.has(i) && mark1.eq(mark2);
|
|
175
|
+
});
|
|
176
|
+
if (idx === -1) {
|
|
177
|
+
return {
|
|
178
|
+
v: false
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
m2Used.add(idx);
|
|
182
|
+
},
|
|
183
|
+
_ret;
|
|
184
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
185
|
+
_ret = _loop();
|
|
186
|
+
if (_ret) return _ret.v;
|
|
187
|
+
}
|
|
188
|
+
} catch (err) {
|
|
189
|
+
_iterator.e(err);
|
|
190
|
+
} finally {
|
|
191
|
+
_iterator.f();
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
154
195
|
/**
|
|
155
196
|
* Compares two ProseMirror documents for equality, ignoring attributes
|
|
156
197
|
* which don't affect the document structure.
|
|
@@ -160,16 +201,28 @@ var isReplaceDocOperation = exports.isReplaceDocOperation = function isReplaceDo
|
|
|
160
201
|
* @param doc1 PMNode
|
|
161
202
|
* @param doc2 PMNode
|
|
162
203
|
* @param attributesToIgnore Specific array of attribute keys to ignore - defaults to ignoring all
|
|
204
|
+
* @param opts.ignoreMarkOrder If mark order should be ignored to still be equal (e.g. reversed annotation marks). When not provided, controlled by platform_editor_are_nodes_equal_ignore_mark_order feature gate (defaults to true when gate is on).
|
|
163
205
|
* @returns boolean
|
|
164
206
|
*/
|
|
165
|
-
|
|
207
|
+
|
|
208
|
+
function areNodesEqualIgnoreAttrs(node1, node2, attributesToIgnore, opts) {
|
|
209
|
+
var _opts$ignoreMarkOrder;
|
|
210
|
+
var ignoreMarkOrder = (_opts$ignoreMarkOrder = opts === null || opts === void 0 ? void 0 : opts.ignoreMarkOrder) !== null && _opts$ignoreMarkOrder !== void 0 ? _opts$ignoreMarkOrder : (0, _expValEquals.expValEquals)('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true);
|
|
166
211
|
if (node1.isText) {
|
|
212
|
+
if (ignoreMarkOrder) {
|
|
213
|
+
return node1.text === node2.text && marksEqualIgnoringOrder(node1.marks, node2.marks);
|
|
214
|
+
}
|
|
167
215
|
return node1.eq(node2);
|
|
168
216
|
}
|
|
217
|
+
var marksEqual = ignoreMarkOrder ? marksEqualIgnoringOrder(node1.marks, node2.marks) : marksEqualInOrder(node1.marks, node2.marks);
|
|
169
218
|
|
|
170
219
|
// If no attributes to ignore, compare all attributes
|
|
171
220
|
if (!attributesToIgnore || attributesToIgnore.length === 0) {
|
|
172
|
-
|
|
221
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
222
|
+
return node1 === node2 || node1.hasMarkup(node2.type, node1.attrs, node1.marks) && marksEqual && areFragmentsEqual(node1.content, node2.content, undefined, opts);
|
|
223
|
+
} else {
|
|
224
|
+
return node1 === node2 || node1.hasMarkup(node2.type, node1.attrs, node2.marks) && areFragmentsEqual(node1.content, node2.content);
|
|
225
|
+
}
|
|
173
226
|
}
|
|
174
227
|
|
|
175
228
|
// Build attrs to compare by excluding ignored attributes
|
|
@@ -180,16 +233,20 @@ function areNodesEqualIgnoreAttrs(node1, node2, attributesToIgnore) {
|
|
|
180
233
|
attrsToCompare[key] = node1.attrs[key];
|
|
181
234
|
}
|
|
182
235
|
}
|
|
183
|
-
|
|
236
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
237
|
+
return node1 === node2 || node1.type === node2.type && node1.hasMarkup(node2.type, attrsToCompare, node1.marks) && marksEqual && areFragmentsEqual(node1.content, node2.content, attributesToIgnore, opts);
|
|
238
|
+
} else {
|
|
239
|
+
return node1 === node2 || node1.hasMarkup(node2.type, attrsToCompare, node2.marks) && areFragmentsEqual(node1.content, node2.content, attributesToIgnore);
|
|
240
|
+
}
|
|
184
241
|
}
|
|
185
|
-
function areFragmentsEqual(frag1, frag2, attributesToIgnore) {
|
|
242
|
+
function areFragmentsEqual(frag1, frag2, attributesToIgnore, opts) {
|
|
186
243
|
if (frag1.content.length !== frag2.content.length) {
|
|
187
244
|
return false;
|
|
188
245
|
}
|
|
189
246
|
var childrenEqual = true;
|
|
190
247
|
frag1.content.forEach(function (child, i) {
|
|
191
248
|
var otherChild = frag2.child(i);
|
|
192
|
-
if (child === otherChild || otherChild && areNodesEqualIgnoreAttrs(child, otherChild, attributesToIgnore)) {
|
|
249
|
+
if (child === otherChild || otherChild && areNodesEqualIgnoreAttrs(child, otherChild, attributesToIgnore, opts)) {
|
|
193
250
|
return;
|
|
194
251
|
}
|
|
195
252
|
childrenEqual = false;
|
|
@@ -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 = "
|
|
7
|
+
const packageVersion = "111.32.1";
|
|
8
8
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
9
9
|
// Remove URL as it has UGC
|
|
10
10
|
// 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 = "
|
|
17
|
+
const packageVersion = "111.32.1";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import clamp from 'lodash/clamp';
|
|
2
2
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
4
|
import { isEmptyParagraph } from './editor-core-utils';
|
|
4
5
|
export const getStepRange = transaction => {
|
|
5
6
|
let from = -1;
|
|
@@ -137,7 +138,24 @@ export const isReplaceDocOperation = (transactions, oldState) => {
|
|
|
137
138
|
return hasStepReplacingEntireDocument;
|
|
138
139
|
});
|
|
139
140
|
};
|
|
140
|
-
|
|
141
|
+
function marksEqualInOrder(m1, m2) {
|
|
142
|
+
if (m1.length !== m2.length) return false;
|
|
143
|
+
return m1.every((m, i) => m.eq(m2[i]));
|
|
144
|
+
}
|
|
145
|
+
function marksEqualIgnoringOrder(m1, m2) {
|
|
146
|
+
if (m1.length !== m2.length) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
const m2Used = new Set();
|
|
150
|
+
for (const mark1 of m1) {
|
|
151
|
+
const idx = m2.findIndex((mark2, i) => !m2Used.has(i) && mark1.eq(mark2));
|
|
152
|
+
if (idx === -1) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
m2Used.add(idx);
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
141
159
|
/**
|
|
142
160
|
* Compares two ProseMirror documents for equality, ignoring attributes
|
|
143
161
|
* which don't affect the document structure.
|
|
@@ -147,16 +165,28 @@ export const isReplaceDocOperation = (transactions, oldState) => {
|
|
|
147
165
|
* @param doc1 PMNode
|
|
148
166
|
* @param doc2 PMNode
|
|
149
167
|
* @param attributesToIgnore Specific array of attribute keys to ignore - defaults to ignoring all
|
|
168
|
+
* @param opts.ignoreMarkOrder If mark order should be ignored to still be equal (e.g. reversed annotation marks). When not provided, controlled by platform_editor_are_nodes_equal_ignore_mark_order feature gate (defaults to true when gate is on).
|
|
150
169
|
* @returns boolean
|
|
151
170
|
*/
|
|
152
|
-
|
|
171
|
+
|
|
172
|
+
export function areNodesEqualIgnoreAttrs(node1, node2, attributesToIgnore, opts) {
|
|
173
|
+
var _opts$ignoreMarkOrder;
|
|
174
|
+
const ignoreMarkOrder = (_opts$ignoreMarkOrder = opts === null || opts === void 0 ? void 0 : opts.ignoreMarkOrder) !== null && _opts$ignoreMarkOrder !== void 0 ? _opts$ignoreMarkOrder : expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true);
|
|
153
175
|
if (node1.isText) {
|
|
176
|
+
if (ignoreMarkOrder) {
|
|
177
|
+
return node1.text === node2.text && marksEqualIgnoringOrder(node1.marks, node2.marks);
|
|
178
|
+
}
|
|
154
179
|
return node1.eq(node2);
|
|
155
180
|
}
|
|
181
|
+
const marksEqual = ignoreMarkOrder ? marksEqualIgnoringOrder(node1.marks, node2.marks) : marksEqualInOrder(node1.marks, node2.marks);
|
|
156
182
|
|
|
157
183
|
// If no attributes to ignore, compare all attributes
|
|
158
184
|
if (!attributesToIgnore || attributesToIgnore.length === 0) {
|
|
159
|
-
|
|
185
|
+
if (expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
186
|
+
return node1 === node2 || node1.hasMarkup(node2.type, node1.attrs, node1.marks) && marksEqual && areFragmentsEqual(node1.content, node2.content, undefined, opts);
|
|
187
|
+
} else {
|
|
188
|
+
return node1 === node2 || node1.hasMarkup(node2.type, node1.attrs, node2.marks) && areFragmentsEqual(node1.content, node2.content);
|
|
189
|
+
}
|
|
160
190
|
}
|
|
161
191
|
|
|
162
192
|
// Build attrs to compare by excluding ignored attributes
|
|
@@ -167,16 +197,20 @@ export function areNodesEqualIgnoreAttrs(node1, node2, attributesToIgnore) {
|
|
|
167
197
|
attrsToCompare[key] = node1.attrs[key];
|
|
168
198
|
}
|
|
169
199
|
}
|
|
170
|
-
|
|
200
|
+
if (expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
201
|
+
return node1 === node2 || node1.type === node2.type && node1.hasMarkup(node2.type, attrsToCompare, node1.marks) && marksEqual && areFragmentsEqual(node1.content, node2.content, attributesToIgnore, opts);
|
|
202
|
+
} else {
|
|
203
|
+
return node1 === node2 || node1.hasMarkup(node2.type, attrsToCompare, node2.marks) && areFragmentsEqual(node1.content, node2.content, attributesToIgnore);
|
|
204
|
+
}
|
|
171
205
|
}
|
|
172
|
-
function areFragmentsEqual(frag1, frag2, attributesToIgnore) {
|
|
206
|
+
function areFragmentsEqual(frag1, frag2, attributesToIgnore, opts) {
|
|
173
207
|
if (frag1.content.length !== frag2.content.length) {
|
|
174
208
|
return false;
|
|
175
209
|
}
|
|
176
210
|
let childrenEqual = true;
|
|
177
211
|
frag1.content.forEach((child, i) => {
|
|
178
212
|
const otherChild = frag2.child(i);
|
|
179
|
-
if (child === otherChild || otherChild && areNodesEqualIgnoreAttrs(child, otherChild, attributesToIgnore)) {
|
|
213
|
+
if (child === otherChild || otherChild && areNodesEqualIgnoreAttrs(child, otherChild, attributesToIgnore, opts)) {
|
|
180
214
|
return;
|
|
181
215
|
}
|
|
182
216
|
childrenEqual = false;
|
|
@@ -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 = "
|
|
13
|
+
var packageVersion = "111.32.1";
|
|
14
14
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
15
15
|
// Remove URL as it has UGC
|
|
16
16
|
// 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 = "
|
|
24
|
+
var packageVersion = "111.32.1";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var fadeIn = keyframes({
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
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; } }
|
|
3
|
+
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; }
|
|
1
4
|
import clamp from 'lodash/clamp';
|
|
2
5
|
import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
7
|
import { isEmptyParagraph } from './editor-core-utils';
|
|
4
8
|
export var getStepRange = function getStepRange(transaction) {
|
|
5
9
|
var from = -1;
|
|
@@ -135,7 +139,44 @@ export var isReplaceDocOperation = function isReplaceDocOperation(transactions,
|
|
|
135
139
|
return hasStepReplacingEntireDocument;
|
|
136
140
|
});
|
|
137
141
|
};
|
|
138
|
-
|
|
142
|
+
function marksEqualInOrder(m1, m2) {
|
|
143
|
+
if (m1.length !== m2.length) return false;
|
|
144
|
+
return m1.every(function (m, i) {
|
|
145
|
+
return m.eq(m2[i]);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function marksEqualIgnoringOrder(m1, m2) {
|
|
149
|
+
if (m1.length !== m2.length) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
var m2Used = new Set();
|
|
153
|
+
var _iterator = _createForOfIteratorHelper(m1),
|
|
154
|
+
_step;
|
|
155
|
+
try {
|
|
156
|
+
var _loop = function _loop() {
|
|
157
|
+
var mark1 = _step.value;
|
|
158
|
+
var idx = m2.findIndex(function (mark2, i) {
|
|
159
|
+
return !m2Used.has(i) && mark1.eq(mark2);
|
|
160
|
+
});
|
|
161
|
+
if (idx === -1) {
|
|
162
|
+
return {
|
|
163
|
+
v: false
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
m2Used.add(idx);
|
|
167
|
+
},
|
|
168
|
+
_ret;
|
|
169
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
170
|
+
_ret = _loop();
|
|
171
|
+
if (_ret) return _ret.v;
|
|
172
|
+
}
|
|
173
|
+
} catch (err) {
|
|
174
|
+
_iterator.e(err);
|
|
175
|
+
} finally {
|
|
176
|
+
_iterator.f();
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
139
180
|
/**
|
|
140
181
|
* Compares two ProseMirror documents for equality, ignoring attributes
|
|
141
182
|
* which don't affect the document structure.
|
|
@@ -145,16 +186,28 @@ export var isReplaceDocOperation = function isReplaceDocOperation(transactions,
|
|
|
145
186
|
* @param doc1 PMNode
|
|
146
187
|
* @param doc2 PMNode
|
|
147
188
|
* @param attributesToIgnore Specific array of attribute keys to ignore - defaults to ignoring all
|
|
189
|
+
* @param opts.ignoreMarkOrder If mark order should be ignored to still be equal (e.g. reversed annotation marks). When not provided, controlled by platform_editor_are_nodes_equal_ignore_mark_order feature gate (defaults to true when gate is on).
|
|
148
190
|
* @returns boolean
|
|
149
191
|
*/
|
|
150
|
-
|
|
192
|
+
|
|
193
|
+
export function areNodesEqualIgnoreAttrs(node1, node2, attributesToIgnore, opts) {
|
|
194
|
+
var _opts$ignoreMarkOrder;
|
|
195
|
+
var ignoreMarkOrder = (_opts$ignoreMarkOrder = opts === null || opts === void 0 ? void 0 : opts.ignoreMarkOrder) !== null && _opts$ignoreMarkOrder !== void 0 ? _opts$ignoreMarkOrder : expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true);
|
|
151
196
|
if (node1.isText) {
|
|
197
|
+
if (ignoreMarkOrder) {
|
|
198
|
+
return node1.text === node2.text && marksEqualIgnoringOrder(node1.marks, node2.marks);
|
|
199
|
+
}
|
|
152
200
|
return node1.eq(node2);
|
|
153
201
|
}
|
|
202
|
+
var marksEqual = ignoreMarkOrder ? marksEqualIgnoringOrder(node1.marks, node2.marks) : marksEqualInOrder(node1.marks, node2.marks);
|
|
154
203
|
|
|
155
204
|
// If no attributes to ignore, compare all attributes
|
|
156
205
|
if (!attributesToIgnore || attributesToIgnore.length === 0) {
|
|
157
|
-
|
|
206
|
+
if (expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
207
|
+
return node1 === node2 || node1.hasMarkup(node2.type, node1.attrs, node1.marks) && marksEqual && areFragmentsEqual(node1.content, node2.content, undefined, opts);
|
|
208
|
+
} else {
|
|
209
|
+
return node1 === node2 || node1.hasMarkup(node2.type, node1.attrs, node2.marks) && areFragmentsEqual(node1.content, node2.content);
|
|
210
|
+
}
|
|
158
211
|
}
|
|
159
212
|
|
|
160
213
|
// Build attrs to compare by excluding ignored attributes
|
|
@@ -165,16 +218,20 @@ export function areNodesEqualIgnoreAttrs(node1, node2, attributesToIgnore) {
|
|
|
165
218
|
attrsToCompare[key] = node1.attrs[key];
|
|
166
219
|
}
|
|
167
220
|
}
|
|
168
|
-
|
|
221
|
+
if (expValEquals('platform_editor_are_nodes_equal_ignore_mark_order', 'isEnabled', true)) {
|
|
222
|
+
return node1 === node2 || node1.type === node2.type && node1.hasMarkup(node2.type, attrsToCompare, node1.marks) && marksEqual && areFragmentsEqual(node1.content, node2.content, attributesToIgnore, opts);
|
|
223
|
+
} else {
|
|
224
|
+
return node1 === node2 || node1.hasMarkup(node2.type, attrsToCompare, node2.marks) && areFragmentsEqual(node1.content, node2.content, attributesToIgnore);
|
|
225
|
+
}
|
|
169
226
|
}
|
|
170
|
-
function areFragmentsEqual(frag1, frag2, attributesToIgnore) {
|
|
227
|
+
function areFragmentsEqual(frag1, frag2, attributesToIgnore, opts) {
|
|
171
228
|
if (frag1.content.length !== frag2.content.length) {
|
|
172
229
|
return false;
|
|
173
230
|
}
|
|
174
231
|
var childrenEqual = true;
|
|
175
232
|
frag1.content.forEach(function (child, i) {
|
|
176
233
|
var otherChild = frag2.child(i);
|
|
177
|
-
if (child === otherChild || otherChild && areNodesEqualIgnoreAttrs(child, otherChild, attributesToIgnore)) {
|
|
234
|
+
if (child === otherChild || otherChild && areNodesEqualIgnoreAttrs(child, otherChild, attributesToIgnore, opts)) {
|
|
178
235
|
return;
|
|
179
236
|
}
|
|
180
237
|
childrenEqual = false;
|
|
@@ -31,7 +31,10 @@ export declare const isReplaceDocOperation: (transactions: readonly Transaction[
|
|
|
31
31
|
* @param doc1 PMNode
|
|
32
32
|
* @param doc2 PMNode
|
|
33
33
|
* @param attributesToIgnore Specific array of attribute keys to ignore - defaults to ignoring all
|
|
34
|
+
* @param opts.ignoreMarkOrder If mark order should be ignored to still be equal (e.g. reversed annotation marks). When not provided, controlled by platform_editor_are_nodes_equal_ignore_mark_order feature gate (defaults to true when gate is on).
|
|
34
35
|
* @returns boolean
|
|
35
36
|
*/
|
|
36
|
-
export declare function areNodesEqualIgnoreAttrs(node1: Node, node2: Node, attributesToIgnore?: string[]
|
|
37
|
+
export declare function areNodesEqualIgnoreAttrs(node1: Node, node2: Node, attributesToIgnore?: string[], opts?: {
|
|
38
|
+
ignoreMarkOrder?: boolean;
|
|
39
|
+
}): boolean;
|
|
37
40
|
export {};
|
|
@@ -31,7 +31,10 @@ export declare const isReplaceDocOperation: (transactions: readonly Transaction[
|
|
|
31
31
|
* @param doc1 PMNode
|
|
32
32
|
* @param doc2 PMNode
|
|
33
33
|
* @param attributesToIgnore Specific array of attribute keys to ignore - defaults to ignoring all
|
|
34
|
+
* @param opts.ignoreMarkOrder If mark order should be ignored to still be equal (e.g. reversed annotation marks). When not provided, controlled by platform_editor_are_nodes_equal_ignore_mark_order feature gate (defaults to true when gate is on).
|
|
34
35
|
* @returns boolean
|
|
35
36
|
*/
|
|
36
|
-
export declare function areNodesEqualIgnoreAttrs(node1: Node, node2: Node, attributesToIgnore?: string[]
|
|
37
|
+
export declare function areNodesEqualIgnoreAttrs(node1: Node, node2: Node, attributesToIgnore?: string[], opts?: {
|
|
38
|
+
ignoreMarkOrder?: boolean;
|
|
39
|
+
}): boolean;
|
|
37
40
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "111.
|
|
3
|
+
"version": "111.33.0",
|
|
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/"
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@atlaskit/task-decision": "^19.3.0",
|
|
83
83
|
"@atlaskit/textfield": "^8.2.0",
|
|
84
84
|
"@atlaskit/theme": "^22.0.0",
|
|
85
|
-
"@atlaskit/tmp-editor-statsig": "^35.
|
|
85
|
+
"@atlaskit/tmp-editor-statsig": "^35.6.0",
|
|
86
86
|
"@atlaskit/tokens": "^11.1.0",
|
|
87
87
|
"@atlaskit/tooltip": "^20.14.0",
|
|
88
88
|
"@atlaskit/width-detector": "^5.0.0",
|