@atlaskit/editor-plugin-find-replace 10.0.17 → 10.1.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 +17 -0
- package/dist/cjs/pm-plugins/utils/index.js +64 -2
- package/dist/es2019/pm-plugins/utils/index.js +50 -2
- package/dist/esm/pm-plugins/utils/index.js +64 -2
- package/dist/types/findReplacePluginType.d.ts +3 -1
- package/dist/types/pm-plugins/utils/index.d.ts +13 -0
- package/dist/types-ts4.5/findReplacePluginType.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +13 -0
- package/package.json +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-find-replace
|
|
2
2
|
|
|
3
|
+
## 10.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 10.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`55ad279a5e823`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55ad279a5e823) -
|
|
14
|
+
[ux] Support reference sync blocks by find and replace.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 10.0.17
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createDecorations = exports.createDecoration = void 0;
|
|
8
|
+
exports.extractTextFromADFContent = extractTextFromADFContent;
|
|
8
9
|
exports.findClosestMatch = findClosestMatch;
|
|
9
10
|
exports.findLostAdjacentDecorations = exports.findIndexBeforePosition = exports.findDecorationFromMatch = void 0;
|
|
10
11
|
exports.findMatches = findMatches;
|
|
@@ -19,9 +20,48 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
19
20
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
20
21
|
var _resource = require("@atlaskit/mention/resource");
|
|
21
22
|
var _types = require("@atlaskit/mention/types");
|
|
23
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
24
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
25
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
23
26
|
var _tokens = require("@atlaskit/tokens");
|
|
24
27
|
var _styles = require("../../ui/styles");
|
|
28
|
+
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; } } }; }
|
|
29
|
+
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; } }
|
|
30
|
+
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; }
|
|
31
|
+
/**
|
|
32
|
+
* Recursively extracts all text content from an ADF entity tree.
|
|
33
|
+
* Used to search inside reference sync blocks whose content lives outside the PM document.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
function extractTextFromADFContent(nodes) {
|
|
37
|
+
var result = '';
|
|
38
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
|
39
|
+
_step;
|
|
40
|
+
try {
|
|
41
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
42
|
+
var _node$attrs;
|
|
43
|
+
var node = _step.value;
|
|
44
|
+
if ((node.type === 'expand' || node.type === 'nestedExpand') && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.title) {
|
|
45
|
+
result += node.attrs.title;
|
|
46
|
+
}
|
|
47
|
+
if (node.text != null) {
|
|
48
|
+
// Inline text node — concatenate directly (text already carries its own whitespace)
|
|
49
|
+
result += node.text;
|
|
50
|
+
} else if (node.content) {
|
|
51
|
+
// Block-level node — add a space separator to prevent false matches across block boundaries
|
|
52
|
+
if (result.length > 0) {
|
|
53
|
+
result += ' ';
|
|
54
|
+
}
|
|
55
|
+
result += extractTextFromADFContent(node.content);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
_iterator.e(err);
|
|
60
|
+
} finally {
|
|
61
|
+
_iterator.f();
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
25
65
|
function getSelectedText(selection) {
|
|
26
66
|
var text = '';
|
|
27
67
|
var selectedContent = selection.content().content;
|
|
@@ -45,7 +85,7 @@ var createDecorations = exports.createDecorations = function createDecorations(s
|
|
|
45
85
|
});
|
|
46
86
|
};
|
|
47
87
|
var isElement = function isElement(nodeType) {
|
|
48
|
-
return ['blockCard', 'embedCard', 'inlineCard', 'status', 'mention', 'date'].includes(nodeType || '');
|
|
88
|
+
return ['blockCard', 'embedCard', 'inlineCard', 'status', 'mention', 'date'].includes(nodeType || '') || nodeType === 'syncBlock' && (0, _experiments.editorExperiment)('platform_synced_block', true) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11');
|
|
49
89
|
};
|
|
50
90
|
var isExpandTitle = function isExpandTitle(match) {
|
|
51
91
|
return ['expand', 'nestedExpand'].includes(match.nodeType || '') && !match.canReplace;
|
|
@@ -237,6 +277,25 @@ function findMatches(_ref2) {
|
|
|
237
277
|
case 'embedCard':
|
|
238
278
|
collectCardTitleMatch(node, pos);
|
|
239
279
|
break;
|
|
280
|
+
case 'syncBlock':
|
|
281
|
+
{
|
|
282
|
+
if ((0, _experiments.editorExperiment)('platform_synced_block', true) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_11')) {
|
|
283
|
+
var _api$syncedBlock, _instance$data;
|
|
284
|
+
var syncBlockStore = api === null || api === void 0 || (_api$syncedBlock = api.syncedBlock) === null || _api$syncedBlock === void 0 || (_api$syncedBlock = _api$syncedBlock.sharedState.currentState()) === null || _api$syncedBlock === void 0 ? void 0 : _api$syncedBlock.syncBlockStore;
|
|
285
|
+
var instance = syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId);
|
|
286
|
+
var adfContent = instance === null || instance === void 0 || (_instance$data = instance.data) === null || _instance$data === void 0 ? void 0 : _instance$data.content;
|
|
287
|
+
if (adfContent && adfContent.length > 0) {
|
|
288
|
+
var _text = extractTextFromADFContent(adfContent);
|
|
289
|
+
if (_text) {
|
|
290
|
+
collectNodeMatch({
|
|
291
|
+
text: _text,
|
|
292
|
+
pos: pos
|
|
293
|
+
}, node);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
240
299
|
default:
|
|
241
300
|
break;
|
|
242
301
|
}
|
|
@@ -295,10 +354,13 @@ var nextIndex = exports.nextIndex = function nextIndex(currentIndex, total) {
|
|
|
295
354
|
var prevIndex = exports.prevIndex = function prevIndex(currentIndex, total) {
|
|
296
355
|
return (currentIndex - 1 + total) % total;
|
|
297
356
|
};
|
|
357
|
+
var isSyncBlock = function isSyncBlock(match) {
|
|
358
|
+
return match.nodeType === 'syncBlock';
|
|
359
|
+
};
|
|
298
360
|
var getSelectionForMatch = exports.getSelectionForMatch = function getSelectionForMatch(selection, doc, index, matches) {
|
|
299
361
|
var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
300
362
|
if (matches[index]) {
|
|
301
|
-
if (isExpandTitle(matches[index])) {
|
|
363
|
+
if (isExpandTitle(matches[index]) || isSyncBlock(matches[index])) {
|
|
302
364
|
return _state.NodeSelection.create(doc, matches[index].start);
|
|
303
365
|
}
|
|
304
366
|
return _state.TextSelection.create(doc, matches[index].start + offset);
|
|
@@ -4,9 +4,37 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
6
6
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
10
|
import { getGlobalTheme } from '@atlaskit/tokens';
|
|
9
11
|
import { searchMatchClass, selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass, selectedBlockSearchMatchClass, searchMatchExpandTitleClass, searchMatchTextClass } from '../../ui/styles';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Recursively extracts all text content from an ADF entity tree.
|
|
15
|
+
* Used to search inside reference sync blocks whose content lives outside the PM document.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export function extractTextFromADFContent(nodes) {
|
|
19
|
+
let result = '';
|
|
20
|
+
for (const node of nodes) {
|
|
21
|
+
var _node$attrs;
|
|
22
|
+
if ((node.type === 'expand' || node.type === 'nestedExpand') && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.title) {
|
|
23
|
+
result += node.attrs.title;
|
|
24
|
+
}
|
|
25
|
+
if (node.text != null) {
|
|
26
|
+
// Inline text node — concatenate directly (text already carries its own whitespace)
|
|
27
|
+
result += node.text;
|
|
28
|
+
} else if (node.content) {
|
|
29
|
+
// Block-level node — add a space separator to prevent false matches across block boundaries
|
|
30
|
+
if (result.length > 0) {
|
|
31
|
+
result += ' ';
|
|
32
|
+
}
|
|
33
|
+
result += extractTextFromADFContent(node.content);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
10
38
|
export function getSelectedText(selection) {
|
|
11
39
|
let text = '';
|
|
12
40
|
const selectedContent = selection.content().content;
|
|
@@ -26,7 +54,7 @@ export const createDecorations = (selectedIndex, matches) => matches.map(({
|
|
|
26
54
|
canReplace,
|
|
27
55
|
nodeType
|
|
28
56
|
}, i === selectedIndex));
|
|
29
|
-
const isElement = nodeType => ['blockCard', 'embedCard', 'inlineCard', 'status', 'mention', 'date'].includes(nodeType || '');
|
|
57
|
+
const isElement = nodeType => ['blockCard', 'embedCard', 'inlineCard', 'status', 'mention', 'date'].includes(nodeType || '') || nodeType === 'syncBlock' && editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_11');
|
|
30
58
|
const isExpandTitle = match => ['expand', 'nestedExpand'].includes(match.nodeType || '') && !match.canReplace;
|
|
31
59
|
export const createDecoration = (match, isSelected) => {
|
|
32
60
|
const {
|
|
@@ -233,6 +261,25 @@ export function findMatches({
|
|
|
233
261
|
case 'embedCard':
|
|
234
262
|
collectCardTitleMatch(node, pos);
|
|
235
263
|
break;
|
|
264
|
+
case 'syncBlock':
|
|
265
|
+
{
|
|
266
|
+
if (editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_11')) {
|
|
267
|
+
var _api$syncedBlock, _api$syncedBlock$shar, _instance$data;
|
|
268
|
+
const syncBlockStore = api === null || api === void 0 ? void 0 : (_api$syncedBlock = api.syncedBlock) === null || _api$syncedBlock === void 0 ? void 0 : (_api$syncedBlock$shar = _api$syncedBlock.sharedState.currentState()) === null || _api$syncedBlock$shar === void 0 ? void 0 : _api$syncedBlock$shar.syncBlockStore;
|
|
269
|
+
const instance = syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId);
|
|
270
|
+
const adfContent = instance === null || instance === void 0 ? void 0 : (_instance$data = instance.data) === null || _instance$data === void 0 ? void 0 : _instance$data.content;
|
|
271
|
+
if (adfContent && adfContent.length > 0) {
|
|
272
|
+
const text = extractTextFromADFContent(adfContent);
|
|
273
|
+
if (text) {
|
|
274
|
+
collectNodeMatch({
|
|
275
|
+
text,
|
|
276
|
+
pos
|
|
277
|
+
}, node);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
236
283
|
default:
|
|
237
284
|
break;
|
|
238
285
|
}
|
|
@@ -280,9 +327,10 @@ export function findSearchIndex(selectionPos, matches, backward = false) {
|
|
|
280
327
|
}
|
|
281
328
|
export const nextIndex = (currentIndex, total) => (currentIndex + 1) % total;
|
|
282
329
|
export const prevIndex = (currentIndex, total) => (currentIndex - 1 + total) % total;
|
|
330
|
+
const isSyncBlock = match => match.nodeType === 'syncBlock';
|
|
283
331
|
export const getSelectionForMatch = (selection, doc, index, matches, offset = 0) => {
|
|
284
332
|
if (matches[index]) {
|
|
285
|
-
if (isExpandTitle(matches[index])) {
|
|
333
|
+
if (isExpandTitle(matches[index]) || isSyncBlock(matches[index])) {
|
|
286
334
|
return NodeSelection.create(doc, matches[index].start);
|
|
287
335
|
}
|
|
288
336
|
return TextSelection.create(doc, matches[index].start + offset);
|
|
@@ -1,13 +1,53 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; } } }; }
|
|
3
|
+
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; } }
|
|
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; }
|
|
2
5
|
import classnames from 'classnames';
|
|
3
6
|
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
4
7
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
6
9
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
7
10
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
12
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
14
|
import { getGlobalTheme } from '@atlaskit/tokens';
|
|
10
15
|
import { searchMatchClass, selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass, selectedBlockSearchMatchClass, searchMatchExpandTitleClass, searchMatchTextClass } from '../../ui/styles';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Recursively extracts all text content from an ADF entity tree.
|
|
19
|
+
* Used to search inside reference sync blocks whose content lives outside the PM document.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export function extractTextFromADFContent(nodes) {
|
|
23
|
+
var result = '';
|
|
24
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
|
25
|
+
_step;
|
|
26
|
+
try {
|
|
27
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
28
|
+
var _node$attrs;
|
|
29
|
+
var node = _step.value;
|
|
30
|
+
if ((node.type === 'expand' || node.type === 'nestedExpand') && (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.title) {
|
|
31
|
+
result += node.attrs.title;
|
|
32
|
+
}
|
|
33
|
+
if (node.text != null) {
|
|
34
|
+
// Inline text node — concatenate directly (text already carries its own whitespace)
|
|
35
|
+
result += node.text;
|
|
36
|
+
} else if (node.content) {
|
|
37
|
+
// Block-level node — add a space separator to prevent false matches across block boundaries
|
|
38
|
+
if (result.length > 0) {
|
|
39
|
+
result += ' ';
|
|
40
|
+
}
|
|
41
|
+
result += extractTextFromADFContent(node.content);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_iterator.e(err);
|
|
46
|
+
} finally {
|
|
47
|
+
_iterator.f();
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
11
51
|
export function getSelectedText(selection) {
|
|
12
52
|
var text = '';
|
|
13
53
|
var selectedContent = selection.content().content;
|
|
@@ -31,7 +71,7 @@ export var createDecorations = function createDecorations(selectedIndex, matches
|
|
|
31
71
|
});
|
|
32
72
|
};
|
|
33
73
|
var isElement = function isElement(nodeType) {
|
|
34
|
-
return ['blockCard', 'embedCard', 'inlineCard', 'status', 'mention', 'date'].includes(nodeType || '');
|
|
74
|
+
return ['blockCard', 'embedCard', 'inlineCard', 'status', 'mention', 'date'].includes(nodeType || '') || nodeType === 'syncBlock' && editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_11');
|
|
35
75
|
};
|
|
36
76
|
var isExpandTitle = function isExpandTitle(match) {
|
|
37
77
|
return ['expand', 'nestedExpand'].includes(match.nodeType || '') && !match.canReplace;
|
|
@@ -223,6 +263,25 @@ export function findMatches(_ref2) {
|
|
|
223
263
|
case 'embedCard':
|
|
224
264
|
collectCardTitleMatch(node, pos);
|
|
225
265
|
break;
|
|
266
|
+
case 'syncBlock':
|
|
267
|
+
{
|
|
268
|
+
if (editorExperiment('platform_synced_block', true) && fg('platform_synced_block_patch_11')) {
|
|
269
|
+
var _api$syncedBlock, _instance$data;
|
|
270
|
+
var syncBlockStore = api === null || api === void 0 || (_api$syncedBlock = api.syncedBlock) === null || _api$syncedBlock === void 0 || (_api$syncedBlock = _api$syncedBlock.sharedState.currentState()) === null || _api$syncedBlock === void 0 ? void 0 : _api$syncedBlock.syncBlockStore;
|
|
271
|
+
var instance = syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId);
|
|
272
|
+
var adfContent = instance === null || instance === void 0 || (_instance$data = instance.data) === null || _instance$data === void 0 ? void 0 : _instance$data.content;
|
|
273
|
+
if (adfContent && adfContent.length > 0) {
|
|
274
|
+
var _text = extractTextFromADFContent(adfContent);
|
|
275
|
+
if (_text) {
|
|
276
|
+
collectNodeMatch({
|
|
277
|
+
text: _text,
|
|
278
|
+
pos: pos
|
|
279
|
+
}, node);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
226
285
|
default:
|
|
227
286
|
break;
|
|
228
287
|
}
|
|
@@ -281,10 +340,13 @@ export var nextIndex = function nextIndex(currentIndex, total) {
|
|
|
281
340
|
export var prevIndex = function prevIndex(currentIndex, total) {
|
|
282
341
|
return (currentIndex - 1 + total) % total;
|
|
283
342
|
};
|
|
343
|
+
var isSyncBlock = function isSyncBlock(match) {
|
|
344
|
+
return match.nodeType === 'syncBlock';
|
|
345
|
+
};
|
|
284
346
|
export var getSelectionForMatch = function getSelectionForMatch(selection, doc, index, matches) {
|
|
285
347
|
var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
286
348
|
if (matches[index]) {
|
|
287
|
-
if (isExpandTitle(matches[index])) {
|
|
349
|
+
if (isExpandTitle(matches[index]) || isSyncBlock(matches[index])) {
|
|
288
350
|
return NodeSelection.create(doc, matches[index].start);
|
|
289
351
|
}
|
|
290
352
|
return TextSelection.create(doc, matches[index].start + offset);
|
|
@@ -5,6 +5,7 @@ import type { CardPlugin } from '@atlaskit/editor-plugin-card';
|
|
|
5
5
|
import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
|
|
6
6
|
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
7
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
8
|
+
import type { SyncedBlockPlugin } from '@atlaskit/editor-plugin-synced-block';
|
|
8
9
|
import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
|
|
9
10
|
export type FindReplacePluginOptions = {
|
|
10
11
|
takeFullWidth: boolean;
|
|
@@ -15,7 +16,8 @@ export type FindReplacePluginDependencies = [
|
|
|
15
16
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
16
17
|
OptionalPlugin<MentionsPlugin>,
|
|
17
18
|
OptionalPlugin<CardPlugin>,
|
|
18
|
-
OptionalPlugin<ExpandPlugin
|
|
19
|
+
OptionalPlugin<ExpandPlugin>,
|
|
20
|
+
OptionalPlugin<SyncedBlockPlugin>
|
|
19
21
|
];
|
|
20
22
|
export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
|
|
21
23
|
actions: {
|
|
@@ -8,6 +8,19 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
8
8
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import type { FindReplacePlugin } from '../../findReplacePluginType';
|
|
10
10
|
import type { Match } from '../../types';
|
|
11
|
+
/**
|
|
12
|
+
* Recursively extracts all text content from an ADF entity tree.
|
|
13
|
+
* Used to search inside reference sync blocks whose content lives outside the PM document.
|
|
14
|
+
*/
|
|
15
|
+
type SimpleADFNode = {
|
|
16
|
+
type?: string;
|
|
17
|
+
attrs?: {
|
|
18
|
+
title?: string;
|
|
19
|
+
};
|
|
20
|
+
content?: SimpleADFNode[];
|
|
21
|
+
text?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function extractTextFromADFContent(nodes: SimpleADFNode[]): string;
|
|
11
24
|
export declare function getSelectedText(selection: TextSelection): string;
|
|
12
25
|
export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
|
|
13
26
|
export declare const createDecoration: (match: Match, isSelected?: Boolean) => Decoration;
|
|
@@ -5,6 +5,7 @@ import type { CardPlugin } from '@atlaskit/editor-plugin-card';
|
|
|
5
5
|
import type { ExpandPlugin } from '@atlaskit/editor-plugin-expand';
|
|
6
6
|
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
7
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
8
|
+
import type { SyncedBlockPlugin } from '@atlaskit/editor-plugin-synced-block';
|
|
8
9
|
import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
|
|
9
10
|
export type FindReplacePluginOptions = {
|
|
10
11
|
takeFullWidth: boolean;
|
|
@@ -15,7 +16,8 @@ export type FindReplacePluginDependencies = [
|
|
|
15
16
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
16
17
|
OptionalPlugin<MentionsPlugin>,
|
|
17
18
|
OptionalPlugin<CardPlugin>,
|
|
18
|
-
OptionalPlugin<ExpandPlugin
|
|
19
|
+
OptionalPlugin<ExpandPlugin>,
|
|
20
|
+
OptionalPlugin<SyncedBlockPlugin>
|
|
19
21
|
];
|
|
20
22
|
export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
|
|
21
23
|
actions: {
|
|
@@ -8,6 +8,19 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
8
8
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import type { FindReplacePlugin } from '../../findReplacePluginType';
|
|
10
10
|
import type { Match } from '../../types';
|
|
11
|
+
/**
|
|
12
|
+
* Recursively extracts all text content from an ADF entity tree.
|
|
13
|
+
* Used to search inside reference sync blocks whose content lives outside the PM document.
|
|
14
|
+
*/
|
|
15
|
+
type SimpleADFNode = {
|
|
16
|
+
type?: string;
|
|
17
|
+
attrs?: {
|
|
18
|
+
title?: string;
|
|
19
|
+
};
|
|
20
|
+
content?: SimpleADFNode[];
|
|
21
|
+
text?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function extractTextFromADFContent(nodes: SimpleADFNode[]): string;
|
|
11
24
|
export declare function getSelectedText(selection: TextSelection): string;
|
|
12
25
|
export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
|
|
13
26
|
export declare const createDecoration: (match: Match, isSelected?: Boolean) => Decoration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,18 +34,19 @@
|
|
|
34
34
|
"@atlaskit/editor-plugin-expand": "^11.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-mentions": "^12.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-primary-toolbar": "^11.0.0",
|
|
37
|
+
"@atlaskit/editor-plugin-synced-block": "^8.2.0",
|
|
37
38
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
38
39
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
39
40
|
"@atlaskit/form": "^15.5.0",
|
|
40
|
-
"@atlaskit/icon": "^34.
|
|
41
|
-
"@atlaskit/icon-lab": "^6.
|
|
41
|
+
"@atlaskit/icon": "^34.5.0",
|
|
42
|
+
"@atlaskit/icon-lab": "^6.8.0",
|
|
42
43
|
"@atlaskit/mention": "^25.0.0",
|
|
43
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
45
|
"@atlaskit/primitives": "^19.0.0",
|
|
45
46
|
"@atlaskit/textfield": "^8.3.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^78.0.0",
|
|
47
48
|
"@atlaskit/tokens": "^13.0.0",
|
|
48
|
-
"@atlaskit/tooltip": "^22.
|
|
49
|
+
"@atlaskit/tooltip": "^22.1.0",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"@emotion/react": "^11.7.1",
|
|
51
52
|
"classnames": "^2.2.5",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"react-intl": "^6.6.2"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
|
-
"@atlaskit/editor-common": "^114.
|
|
65
|
+
"@atlaskit/editor-common": "^114.26.0",
|
|
65
66
|
"react": "^18.2.0",
|
|
66
67
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
67
68
|
},
|
|
@@ -111,6 +112,9 @@
|
|
|
111
112
|
"platform-feature-flags": {
|
|
112
113
|
"platform_editor_toolbar_responsive_fixes": {
|
|
113
114
|
"type": "boolean"
|
|
115
|
+
},
|
|
116
|
+
"platform_synced_block_patch_11": {
|
|
117
|
+
"type": "boolean"
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
}
|