@atlaskit/editor-plugin-find-replace 29.0.2 → 29.0.4
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-find-replace
|
|
2
2
|
|
|
3
|
+
## 29.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7d0f2c4f8ded7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7d0f2c4f8ded7) -
|
|
8
|
+
Cache Smart Card lookups by URL during Find and Replace behind
|
|
9
|
+
`platform_editor_reduce_forced_layout_2`.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 29.0.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`f268dee2526f7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f268dee2526f7) -
|
|
17
|
+
Migrate Smart Card registration and removal from transactions to editor actions behind
|
|
18
|
+
`platform_editor_reduce_forced_layout_2`. Remove unused card overlay registration behind
|
|
19
|
+
`platform_editor_reduce_forced_layout_2`.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 29.0.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -21,6 +21,7 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
21
21
|
var _isPromise = require("@atlaskit/mention/is-promise");
|
|
22
22
|
var _isResolvingMentionProvider = require("@atlaskit/mention/is-resolving-mention-provider");
|
|
23
23
|
var _types = require("@atlaskit/mention/types");
|
|
24
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
24
25
|
var _getGlobalTheme2 = require("@atlaskit/tokens/get-global-theme");
|
|
25
26
|
var _styles = require("../../ui/styles");
|
|
26
27
|
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; } } }; }
|
|
@@ -95,21 +96,21 @@ var createDecoration = exports.createDecoration = function createDecoration(matc
|
|
|
95
96
|
var _getGlobalTheme = (0, _getGlobalTheme2.getGlobalTheme)(),
|
|
96
97
|
colorMode = _getGlobalTheme.colorMode;
|
|
97
98
|
if (isElement(nodeType)) {
|
|
98
|
-
var
|
|
99
|
-
return _view.Decoration.node(start, end, {
|
|
100
|
-
class: className
|
|
101
|
-
});
|
|
102
|
-
} else if (isExpandTitle(match)) {
|
|
103
|
-
var _className = (0, _classnames4.default)(_styles.searchMatchExpandTitleClass, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _styles.selectedSearchMatchClass, isSelected), _styles.darkModeSearchMatchClass, colorMode === 'dark'));
|
|
99
|
+
var _className = (0, _classnames4.default)(_styles.blockSearchMatchClass, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _styles.selectedBlockSearchMatchClass, isSelected), _styles.darkModeSearchMatchClass, colorMode === 'dark'));
|
|
104
100
|
return _view.Decoration.node(start, end, {
|
|
105
101
|
class: _className
|
|
106
102
|
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
}
|
|
104
|
+
if (isExpandTitle(match)) {
|
|
105
|
+
var _className2 = (0, _classnames4.default)(_styles.searchMatchExpandTitleClass, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _styles.selectedSearchMatchClass, isSelected), _styles.darkModeSearchMatchClass, colorMode === 'dark'));
|
|
106
|
+
return _view.Decoration.node(start, end, {
|
|
110
107
|
class: _className2
|
|
111
108
|
});
|
|
112
109
|
}
|
|
110
|
+
var className = (0, _classnames4.default)(_styles.searchMatchTextClass, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _styles.selectedSearchMatchClass, isSelected), _styles.darkModeSearchMatchClass, colorMode === 'dark'));
|
|
111
|
+
return _view.Decoration.inline(start, end, {
|
|
112
|
+
class: className
|
|
113
|
+
});
|
|
113
114
|
};
|
|
114
115
|
function findMatches(_ref2) {
|
|
115
116
|
var content = _ref2.content,
|
|
@@ -169,32 +170,40 @@ function findMatches(_ref2) {
|
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
};
|
|
173
|
+
|
|
174
|
+
// Cache to avoid repeated O(n) url lookups
|
|
175
|
+
var registeredCardsByUrl = null;
|
|
172
176
|
var collectCardTitleMatch = function collectCardTitleMatch(node, pos) {
|
|
173
|
-
var _api$
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
collectNodeMatch({
|
|
183
|
-
text: title,
|
|
184
|
-
pos: pos
|
|
185
|
-
}, node);
|
|
186
|
-
} else {
|
|
187
|
-
// when there is no title, e.g. in an error case like unauthorized
|
|
188
|
-
// the link card just shows the entire url as the title in inline card
|
|
189
|
-
if (node.type.name === 'inlineCard') {
|
|
190
|
-
collectNodeMatch({
|
|
191
|
-
text: node.attrs.url,
|
|
192
|
-
pos: pos
|
|
193
|
-
}, node);
|
|
194
|
-
}
|
|
177
|
+
var _registeredCardsByUrl, _api$card2;
|
|
178
|
+
// Populate cache
|
|
179
|
+
if (!registeredCardsByUrl && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2')) {
|
|
180
|
+
registeredCardsByUrl = new Map();
|
|
181
|
+
for (var _i = 0, _Object$values = Object.values((_api$card$actions$get = api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 || (_api$card = _api$card.actions) === null || _api$card === void 0 || (_api$card$getCardRegi = _api$card.getCardRegistrations) === null || _api$card$getCardRegi === void 0 ? void 0 : _api$card$getCardRegi.call(_api$card)) !== null && _api$card$actions$get !== void 0 ? _api$card$actions$get : {}); _i < _Object$values.length; _i++) {
|
|
182
|
+
var _api$card$actions$get, _api$card, _api$card$getCardRegi;
|
|
183
|
+
var card = _Object$values[_i];
|
|
184
|
+
if (card.getPos() !== undefined) {
|
|
185
|
+
registeredCardsByUrl.set(card.url, card);
|
|
195
186
|
}
|
|
196
187
|
}
|
|
197
188
|
}
|
|
189
|
+
var relevantCard = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout_2') ? (_registeredCardsByUrl = registeredCardsByUrl) === null || _registeredCardsByUrl === void 0 ? void 0 : _registeredCardsByUrl.get(node.attrs.url) : api === null || api === void 0 || (_api$card2 = api.card) === null || _api$card2 === void 0 || (_api$card2 = _api$card2.sharedState.currentState()) === null || _api$card2 === void 0 || (_api$card2 = _api$card2.cards) === null || _api$card2 === void 0 ? void 0 : _api$card2.find(function (card) {
|
|
190
|
+
return card.url === node.attrs.url;
|
|
191
|
+
});
|
|
192
|
+
if (relevantCard) {
|
|
193
|
+
if (relevantCard.title) {
|
|
194
|
+
collectNodeMatch({
|
|
195
|
+
text: relevantCard.title,
|
|
196
|
+
pos: pos
|
|
197
|
+
}, node);
|
|
198
|
+
} else if (node.type.name === 'inlineCard') {
|
|
199
|
+
// when there is no title, e.g. in an error case like unauthorized
|
|
200
|
+
// the link card just shows the entire url as the title in inline card
|
|
201
|
+
collectNodeMatch({
|
|
202
|
+
text: node.attrs.url,
|
|
203
|
+
pos: pos
|
|
204
|
+
}, node);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
198
207
|
};
|
|
199
208
|
if (searchTextLength > 0) {
|
|
200
209
|
content.descendants(function (node, pos) {
|
|
@@ -205,7 +214,7 @@ function findMatches(_ref2) {
|
|
|
205
214
|
pos: pos
|
|
206
215
|
};
|
|
207
216
|
} else {
|
|
208
|
-
textGrouping.text
|
|
217
|
+
textGrouping.text += node.text;
|
|
209
218
|
}
|
|
210
219
|
} else {
|
|
211
220
|
collectTextMatch(textGrouping);
|
|
@@ -300,7 +309,8 @@ function findClosestMatch(selectionPos, matches) {
|
|
|
300
309
|
if (forwardMatchIndex === -1) {
|
|
301
310
|
// if there are no forward matches, it must be the last match
|
|
302
311
|
return matches.length > 0 ? matches.length - 1 : 0;
|
|
303
|
-
}
|
|
312
|
+
}
|
|
313
|
+
if (forwardMatchIndex === 0) {
|
|
304
314
|
return forwardMatchIndex;
|
|
305
315
|
}
|
|
306
316
|
var backwardMatchIndex = forwardMatchIndex - 1;
|
|
@@ -308,9 +318,8 @@ function findClosestMatch(selectionPos, matches) {
|
|
|
308
318
|
var backwardMatchPos = matches[backwardMatchIndex].start;
|
|
309
319
|
if (forwardMatchPos - selectionPos < selectionPos - backwardMatchPos) {
|
|
310
320
|
return forwardMatchIndex;
|
|
311
|
-
} else {
|
|
312
|
-
return backwardMatchIndex;
|
|
313
321
|
}
|
|
322
|
+
return backwardMatchIndex;
|
|
314
323
|
}
|
|
315
324
|
|
|
316
325
|
/**
|
|
@@ -5,6 +5,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
5
5
|
import { isPromise } from '@atlaskit/mention/is-promise';
|
|
6
6
|
import { isResolvingMentionProvider } from '@atlaskit/mention/is-resolving-mention-provider';
|
|
7
7
|
import { MentionNameStatus } from '@atlaskit/mention/types';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
8
9
|
import { getGlobalTheme } from '@atlaskit/tokens/get-global-theme';
|
|
9
10
|
import { selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass, selectedBlockSearchMatchClass, searchMatchExpandTitleClass, searchMatchTextClass } from '../../ui/styles';
|
|
10
11
|
|
|
@@ -71,7 +72,8 @@ export const createDecoration = (match, isSelected) => {
|
|
|
71
72
|
return Decoration.node(start, end, {
|
|
72
73
|
class: className
|
|
73
74
|
});
|
|
74
|
-
}
|
|
75
|
+
}
|
|
76
|
+
if (isExpandTitle(match)) {
|
|
75
77
|
const className = classnames(searchMatchExpandTitleClass, {
|
|
76
78
|
[selectedSearchMatchClass]: isSelected,
|
|
77
79
|
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
@@ -79,15 +81,14 @@ export const createDecoration = (match, isSelected) => {
|
|
|
79
81
|
return Decoration.node(start, end, {
|
|
80
82
|
class: className
|
|
81
83
|
});
|
|
82
|
-
} else {
|
|
83
|
-
const className = classnames(searchMatchTextClass, {
|
|
84
|
-
[selectedSearchMatchClass]: isSelected,
|
|
85
|
-
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
86
|
-
});
|
|
87
|
-
return Decoration.inline(start, end, {
|
|
88
|
-
class: className
|
|
89
|
-
});
|
|
90
84
|
}
|
|
85
|
+
const className = classnames(searchMatchTextClass, {
|
|
86
|
+
[selectedSearchMatchClass]: isSelected,
|
|
87
|
+
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
88
|
+
});
|
|
89
|
+
return Decoration.inline(start, end, {
|
|
90
|
+
class: className
|
|
91
|
+
});
|
|
91
92
|
};
|
|
92
93
|
export function findMatches({
|
|
93
94
|
content,
|
|
@@ -155,30 +156,37 @@ export function findMatches({
|
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
};
|
|
159
|
+
|
|
160
|
+
// Cache to avoid repeated O(n) url lookups
|
|
161
|
+
let registeredCardsByUrl = null;
|
|
158
162
|
const collectCardTitleMatch = (node, pos) => {
|
|
159
|
-
var _api$
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
text: title,
|
|
168
|
-
pos
|
|
169
|
-
}, node);
|
|
170
|
-
} else {
|
|
171
|
-
// when there is no title, e.g. in an error case like unauthorized
|
|
172
|
-
// the link card just shows the entire url as the title in inline card
|
|
173
|
-
if (node.type.name === 'inlineCard') {
|
|
174
|
-
collectNodeMatch({
|
|
175
|
-
text: node.attrs.url,
|
|
176
|
-
pos
|
|
177
|
-
}, node);
|
|
178
|
-
}
|
|
163
|
+
var _registeredCardsByUrl, _api$card2, _api$card2$sharedStat, _api$card2$sharedStat2;
|
|
164
|
+
// Populate cache
|
|
165
|
+
if (!registeredCardsByUrl && isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
166
|
+
registeredCardsByUrl = new Map();
|
|
167
|
+
for (const card of Object.values((_api$card$actions$get = api === null || api === void 0 ? void 0 : (_api$card = api.card) === null || _api$card === void 0 ? void 0 : (_api$card$actions = _api$card.actions) === null || _api$card$actions === void 0 ? void 0 : (_api$card$actions$get2 = _api$card$actions.getCardRegistrations) === null || _api$card$actions$get2 === void 0 ? void 0 : _api$card$actions$get2.call(_api$card$actions)) !== null && _api$card$actions$get !== void 0 ? _api$card$actions$get : {})) {
|
|
168
|
+
var _api$card$actions$get, _api$card, _api$card$actions, _api$card$actions$get2;
|
|
169
|
+
if (card.getPos() !== undefined) {
|
|
170
|
+
registeredCardsByUrl.set(card.url, card);
|
|
179
171
|
}
|
|
180
172
|
}
|
|
181
173
|
}
|
|
174
|
+
const relevantCard = isExperimentEnabled('platform_editor_reduce_forced_layout_2') ? (_registeredCardsByUrl = registeredCardsByUrl) === null || _registeredCardsByUrl === void 0 ? void 0 : _registeredCardsByUrl.get(node.attrs.url) : api === null || api === void 0 ? void 0 : (_api$card2 = api.card) === null || _api$card2 === void 0 ? void 0 : (_api$card2$sharedStat = _api$card2.sharedState.currentState()) === null || _api$card2$sharedStat === void 0 ? void 0 : (_api$card2$sharedStat2 = _api$card2$sharedStat.cards) === null || _api$card2$sharedStat2 === void 0 ? void 0 : _api$card2$sharedStat2.find(card => card.url === node.attrs.url);
|
|
175
|
+
if (relevantCard) {
|
|
176
|
+
if (relevantCard.title) {
|
|
177
|
+
collectNodeMatch({
|
|
178
|
+
text: relevantCard.title,
|
|
179
|
+
pos
|
|
180
|
+
}, node);
|
|
181
|
+
} else if (node.type.name === 'inlineCard') {
|
|
182
|
+
// when there is no title, e.g. in an error case like unauthorized
|
|
183
|
+
// the link card just shows the entire url as the title in inline card
|
|
184
|
+
collectNodeMatch({
|
|
185
|
+
text: node.attrs.url,
|
|
186
|
+
pos
|
|
187
|
+
}, node);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
182
190
|
};
|
|
183
191
|
if (searchTextLength > 0) {
|
|
184
192
|
content.descendants((node, pos) => {
|
|
@@ -189,7 +197,7 @@ export function findMatches({
|
|
|
189
197
|
pos
|
|
190
198
|
};
|
|
191
199
|
} else {
|
|
192
|
-
textGrouping.text
|
|
200
|
+
textGrouping.text += node.text;
|
|
193
201
|
}
|
|
194
202
|
} else {
|
|
195
203
|
collectTextMatch(textGrouping);
|
|
@@ -282,7 +290,8 @@ export function findClosestMatch(selectionPos, matches) {
|
|
|
282
290
|
if (forwardMatchIndex === -1) {
|
|
283
291
|
// if there are no forward matches, it must be the last match
|
|
284
292
|
return matches.length > 0 ? matches.length - 1 : 0;
|
|
285
|
-
}
|
|
293
|
+
}
|
|
294
|
+
if (forwardMatchIndex === 0) {
|
|
286
295
|
return forwardMatchIndex;
|
|
287
296
|
}
|
|
288
297
|
const backwardMatchIndex = forwardMatchIndex - 1;
|
|
@@ -290,9 +299,8 @@ export function findClosestMatch(selectionPos, matches) {
|
|
|
290
299
|
const backwardMatchPos = matches[backwardMatchIndex].start;
|
|
291
300
|
if (forwardMatchPos - selectionPos < selectionPos - backwardMatchPos) {
|
|
292
301
|
return forwardMatchIndex;
|
|
293
|
-
} else {
|
|
294
|
-
return backwardMatchIndex;
|
|
295
302
|
}
|
|
303
|
+
return backwardMatchIndex;
|
|
296
304
|
}
|
|
297
305
|
|
|
298
306
|
/**
|
|
@@ -9,6 +9,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
9
9
|
import { isPromise } from '@atlaskit/mention/is-promise';
|
|
10
10
|
import { isResolvingMentionProvider } from '@atlaskit/mention/is-resolving-mention-provider';
|
|
11
11
|
import { MentionNameStatus } from '@atlaskit/mention/types';
|
|
12
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
12
13
|
import { getGlobalTheme } from '@atlaskit/tokens/get-global-theme';
|
|
13
14
|
import { selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass, selectedBlockSearchMatchClass, searchMatchExpandTitleClass, searchMatchTextClass } from '../../ui/styles';
|
|
14
15
|
|
|
@@ -81,21 +82,21 @@ export var createDecoration = function createDecoration(match, isSelected) {
|
|
|
81
82
|
var _getGlobalTheme = getGlobalTheme(),
|
|
82
83
|
colorMode = _getGlobalTheme.colorMode;
|
|
83
84
|
if (isElement(nodeType)) {
|
|
84
|
-
var
|
|
85
|
-
return Decoration.node(start, end, {
|
|
86
|
-
class: className
|
|
87
|
-
});
|
|
88
|
-
} else if (isExpandTitle(match)) {
|
|
89
|
-
var _className = classnames(searchMatchExpandTitleClass, _defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
85
|
+
var _className = classnames(blockSearchMatchClass, _defineProperty(_defineProperty({}, selectedBlockSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
90
86
|
return Decoration.node(start, end, {
|
|
91
87
|
class: _className
|
|
92
88
|
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
}
|
|
90
|
+
if (isExpandTitle(match)) {
|
|
91
|
+
var _className2 = classnames(searchMatchExpandTitleClass, _defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
92
|
+
return Decoration.node(start, end, {
|
|
96
93
|
class: _className2
|
|
97
94
|
});
|
|
98
95
|
}
|
|
96
|
+
var className = classnames(searchMatchTextClass, _defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
97
|
+
return Decoration.inline(start, end, {
|
|
98
|
+
class: className
|
|
99
|
+
});
|
|
99
100
|
};
|
|
100
101
|
export function findMatches(_ref2) {
|
|
101
102
|
var content = _ref2.content,
|
|
@@ -155,32 +156,40 @@ export function findMatches(_ref2) {
|
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
};
|
|
159
|
+
|
|
160
|
+
// Cache to avoid repeated O(n) url lookups
|
|
161
|
+
var registeredCardsByUrl = null;
|
|
158
162
|
var collectCardTitleMatch = function collectCardTitleMatch(node, pos) {
|
|
159
|
-
var _api$
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
collectNodeMatch({
|
|
169
|
-
text: title,
|
|
170
|
-
pos: pos
|
|
171
|
-
}, node);
|
|
172
|
-
} else {
|
|
173
|
-
// when there is no title, e.g. in an error case like unauthorized
|
|
174
|
-
// the link card just shows the entire url as the title in inline card
|
|
175
|
-
if (node.type.name === 'inlineCard') {
|
|
176
|
-
collectNodeMatch({
|
|
177
|
-
text: node.attrs.url,
|
|
178
|
-
pos: pos
|
|
179
|
-
}, node);
|
|
180
|
-
}
|
|
163
|
+
var _registeredCardsByUrl, _api$card2;
|
|
164
|
+
// Populate cache
|
|
165
|
+
if (!registeredCardsByUrl && isExperimentEnabled('platform_editor_reduce_forced_layout_2')) {
|
|
166
|
+
registeredCardsByUrl = new Map();
|
|
167
|
+
for (var _i = 0, _Object$values = Object.values((_api$card$actions$get = api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 || (_api$card = _api$card.actions) === null || _api$card === void 0 || (_api$card$getCardRegi = _api$card.getCardRegistrations) === null || _api$card$getCardRegi === void 0 ? void 0 : _api$card$getCardRegi.call(_api$card)) !== null && _api$card$actions$get !== void 0 ? _api$card$actions$get : {}); _i < _Object$values.length; _i++) {
|
|
168
|
+
var _api$card$actions$get, _api$card, _api$card$getCardRegi;
|
|
169
|
+
var card = _Object$values[_i];
|
|
170
|
+
if (card.getPos() !== undefined) {
|
|
171
|
+
registeredCardsByUrl.set(card.url, card);
|
|
181
172
|
}
|
|
182
173
|
}
|
|
183
174
|
}
|
|
175
|
+
var relevantCard = isExperimentEnabled('platform_editor_reduce_forced_layout_2') ? (_registeredCardsByUrl = registeredCardsByUrl) === null || _registeredCardsByUrl === void 0 ? void 0 : _registeredCardsByUrl.get(node.attrs.url) : api === null || api === void 0 || (_api$card2 = api.card) === null || _api$card2 === void 0 || (_api$card2 = _api$card2.sharedState.currentState()) === null || _api$card2 === void 0 || (_api$card2 = _api$card2.cards) === null || _api$card2 === void 0 ? void 0 : _api$card2.find(function (card) {
|
|
176
|
+
return card.url === node.attrs.url;
|
|
177
|
+
});
|
|
178
|
+
if (relevantCard) {
|
|
179
|
+
if (relevantCard.title) {
|
|
180
|
+
collectNodeMatch({
|
|
181
|
+
text: relevantCard.title,
|
|
182
|
+
pos: pos
|
|
183
|
+
}, node);
|
|
184
|
+
} else if (node.type.name === 'inlineCard') {
|
|
185
|
+
// when there is no title, e.g. in an error case like unauthorized
|
|
186
|
+
// the link card just shows the entire url as the title in inline card
|
|
187
|
+
collectNodeMatch({
|
|
188
|
+
text: node.attrs.url,
|
|
189
|
+
pos: pos
|
|
190
|
+
}, node);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
184
193
|
};
|
|
185
194
|
if (searchTextLength > 0) {
|
|
186
195
|
content.descendants(function (node, pos) {
|
|
@@ -191,7 +200,7 @@ export function findMatches(_ref2) {
|
|
|
191
200
|
pos: pos
|
|
192
201
|
};
|
|
193
202
|
} else {
|
|
194
|
-
textGrouping.text
|
|
203
|
+
textGrouping.text += node.text;
|
|
195
204
|
}
|
|
196
205
|
} else {
|
|
197
206
|
collectTextMatch(textGrouping);
|
|
@@ -286,7 +295,8 @@ export function findClosestMatch(selectionPos, matches) {
|
|
|
286
295
|
if (forwardMatchIndex === -1) {
|
|
287
296
|
// if there are no forward matches, it must be the last match
|
|
288
297
|
return matches.length > 0 ? matches.length - 1 : 0;
|
|
289
|
-
}
|
|
298
|
+
}
|
|
299
|
+
if (forwardMatchIndex === 0) {
|
|
290
300
|
return forwardMatchIndex;
|
|
291
301
|
}
|
|
292
302
|
var backwardMatchIndex = forwardMatchIndex - 1;
|
|
@@ -294,9 +304,8 @@ export function findClosestMatch(selectionPos, matches) {
|
|
|
294
304
|
var backwardMatchPos = matches[backwardMatchIndex].start;
|
|
295
305
|
if (forwardMatchPos - selectionPos < selectionPos - backwardMatchPos) {
|
|
296
306
|
return forwardMatchIndex;
|
|
297
|
-
} else {
|
|
298
|
-
return backwardMatchIndex;
|
|
299
307
|
}
|
|
308
|
+
return backwardMatchIndex;
|
|
300
309
|
}
|
|
301
310
|
|
|
302
311
|
/**
|
|
@@ -23,7 +23,7 @@ type SimpleADFNode = {
|
|
|
23
23
|
export declare function extractTextFromADFContent(nodes: SimpleADFNode[]): string;
|
|
24
24
|
export declare function getSelectedText(selection: TextSelection): string;
|
|
25
25
|
export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
|
|
26
|
-
export declare const createDecoration: (match: Match, isSelected?:
|
|
26
|
+
export declare const createDecoration: (match: Match, isSelected?: boolean) => Decoration;
|
|
27
27
|
type FindMatchesType = {
|
|
28
28
|
api?: ExtractInjectionAPI<FindReplacePlugin>;
|
|
29
29
|
content: PmNode | Fragment;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "29.0.
|
|
3
|
+
"version": "29.0.4",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,28 +20,28 @@
|
|
|
20
20
|
],
|
|
21
21
|
"atlaskit:src": "src/index.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/button": "^25.
|
|
23
|
+
"@atlaskit/button": "^25.6.0",
|
|
24
24
|
"@atlaskit/editor-plugin-analytics": "^29.0.0",
|
|
25
25
|
"@atlaskit/editor-plugin-block-collapse": "^15.0.0",
|
|
26
|
-
"@atlaskit/editor-plugin-card": "^35.
|
|
26
|
+
"@atlaskit/editor-plugin-card": "^35.1.0",
|
|
27
27
|
"@atlaskit/editor-plugin-editor-viewmode": "^31.0.0",
|
|
28
28
|
"@atlaskit/editor-plugin-expand": "^30.0.0",
|
|
29
29
|
"@atlaskit/editor-plugin-mentions": "^31.0.0",
|
|
30
30
|
"@atlaskit/editor-plugin-primary-toolbar": "^30.0.0",
|
|
31
31
|
"@atlaskit/editor-plugin-synced-block": "^27.0.0",
|
|
32
32
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
33
|
-
"@atlaskit/editor-shared-styles": "^4.
|
|
33
|
+
"@atlaskit/editor-shared-styles": "^4.6.0",
|
|
34
34
|
"@atlaskit/form": "^18.2.0",
|
|
35
35
|
"@atlaskit/icon": "^38.0.0",
|
|
36
36
|
"@atlaskit/icon-lab": "^7.11.0",
|
|
37
|
-
"@atlaskit/mention": "^30.
|
|
37
|
+
"@atlaskit/mention": "^30.4.0",
|
|
38
38
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags-react": "^1.2.0",
|
|
41
41
|
"@atlaskit/primitives": "^22.6.0",
|
|
42
42
|
"@atlaskit/textfield": "^10.2.0",
|
|
43
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
44
|
-
"@atlaskit/tokens": "^20.
|
|
43
|
+
"@atlaskit/tmp-editor-statsig": "^245.0.0",
|
|
44
|
+
"@atlaskit/tokens": "^20.7.0",
|
|
45
45
|
"@atlaskit/tooltip": "^24.4.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@emotion/react": "^11.7.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"react-intl": "^7.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@atlaskit/editor-common": "^133.
|
|
63
|
+
"@atlaskit/editor-common": "^133.5.0",
|
|
64
64
|
"react": "^18.2.0 || ^19.2.0",
|
|
65
65
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
66
66
|
}
|