@atlaskit/editor-plugin-find-replace 14.0.1 → 14.0.2
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/commands.js +5 -6
- package/dist/cjs/pm-plugins/plugin-factory.js +1 -2
- package/dist/cjs/pm-plugins/reducer.js +2 -3
- package/dist/cjs/pm-plugins/utils/batch-decorations.js +2 -7
- package/dist/cjs/pm-plugins/utils/index.js +83 -96
- package/dist/cjs/ui/Find.js +1 -4
- package/dist/cjs/ui/FindReplace.js +1 -2
- package/dist/cjs/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -4
- package/dist/cjs/ui/Replace.js +7 -15
- package/dist/es2019/pm-plugins/commands.js +5 -6
- package/dist/es2019/pm-plugins/plugin-factory.js +2 -3
- package/dist/es2019/pm-plugins/reducer.js +2 -3
- package/dist/es2019/pm-plugins/utils/batch-decorations.js +2 -7
- package/dist/es2019/pm-plugins/utils/index.js +93 -106
- package/dist/es2019/ui/Find.js +1 -4
- package/dist/es2019/ui/FindReplace.js +1 -2
- package/dist/es2019/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -4
- package/dist/es2019/ui/Replace.js +7 -15
- package/dist/esm/pm-plugins/commands.js +5 -6
- package/dist/esm/pm-plugins/plugin-factory.js +2 -3
- package/dist/esm/pm-plugins/reducer.js +2 -3
- package/dist/esm/pm-plugins/utils/batch-decorations.js +2 -7
- package/dist/esm/pm-plugins/utils/index.js +84 -97
- package/dist/esm/ui/Find.js +1 -4
- package/dist/esm/ui/FindReplace.js +1 -2
- package/dist/esm/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -4
- package/dist/esm/ui/Replace.js +7 -15
- package/package.json +3 -3
|
@@ -8,10 +8,9 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
8
8
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
10
10
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
11
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
12
|
import { getGlobalTheme } from '@atlaskit/tokens/get-global-theme';
|
|
14
|
-
import {
|
|
13
|
+
import { selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass, selectedBlockSearchMatchClass, searchMatchExpandTitleClass, searchMatchTextClass } from '../../ui/styles';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Recursively extracts all text content from an ADF entity tree.
|
|
@@ -79,32 +78,22 @@ export var createDecoration = function createDecoration(match, isSelected) {
|
|
|
79
78
|
var start = match.start,
|
|
80
79
|
end = match.end,
|
|
81
80
|
nodeType = match.nodeType;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
} else {
|
|
96
|
-
var _className2 = classnames(searchMatchTextClass, _defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
97
|
-
return Decoration.inline(start, end, {
|
|
98
|
-
class: _className2
|
|
99
|
-
});
|
|
100
|
-
}
|
|
81
|
+
var _getGlobalTheme = getGlobalTheme(),
|
|
82
|
+
colorMode = _getGlobalTheme.colorMode;
|
|
83
|
+
if (isElement(nodeType)) {
|
|
84
|
+
var className = classnames(blockSearchMatchClass, _defineProperty(_defineProperty({}, selectedBlockSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
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'));
|
|
90
|
+
return Decoration.node(start, end, {
|
|
91
|
+
class: _className
|
|
92
|
+
});
|
|
101
93
|
} else {
|
|
102
|
-
var
|
|
103
|
-
if (isSelected) {
|
|
104
|
-
_className3 += " ".concat(selectedSearchMatchClass);
|
|
105
|
-
}
|
|
94
|
+
var _className2 = classnames(searchMatchTextClass, _defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
106
95
|
return Decoration.inline(start, end, {
|
|
107
|
-
class:
|
|
96
|
+
class: _className2
|
|
108
97
|
});
|
|
109
98
|
}
|
|
110
99
|
};
|
|
@@ -138,8 +127,8 @@ export function findMatches(_ref2) {
|
|
|
138
127
|
matches.push({
|
|
139
128
|
start: pos + index,
|
|
140
129
|
end: pos + end,
|
|
141
|
-
canReplace:
|
|
142
|
-
nodeType:
|
|
130
|
+
canReplace: true,
|
|
131
|
+
nodeType: 'text'
|
|
143
132
|
});
|
|
144
133
|
index = text.indexOf(searchText, end);
|
|
145
134
|
}
|
|
@@ -207,83 +196,81 @@ export function findMatches(_ref2) {
|
|
|
207
196
|
} else {
|
|
208
197
|
collectTextMatch(textGrouping);
|
|
209
198
|
textGrouping = null;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
199
|
+
switch (node.type.name) {
|
|
200
|
+
case 'status':
|
|
201
|
+
collectNodeMatch({
|
|
202
|
+
text: node.attrs.text,
|
|
203
|
+
pos: pos
|
|
204
|
+
}, node);
|
|
205
|
+
break;
|
|
206
|
+
case 'date':
|
|
207
|
+
collectNodeMatch({
|
|
208
|
+
text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
|
|
209
|
+
pos: pos
|
|
210
|
+
}, node);
|
|
211
|
+
break;
|
|
212
|
+
case 'expand':
|
|
213
|
+
case 'nestedExpand':
|
|
214
|
+
collectNodeMatch({
|
|
215
|
+
text: node.attrs.title,
|
|
216
|
+
pos: pos
|
|
217
|
+
}, node);
|
|
218
|
+
break;
|
|
219
|
+
case 'mention':
|
|
220
|
+
var text;
|
|
221
|
+
if (node.attrs.text) {
|
|
222
|
+
text = node.attrs.text;
|
|
223
|
+
} else {
|
|
224
|
+
var _api$mention;
|
|
225
|
+
// the text may be sanitised from the node for privacy reasons
|
|
226
|
+
// so we need to use the mentionProvider to resolve it
|
|
227
|
+
var mentionProvider = api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.sharedState.currentState()) === null || _api$mention === void 0 ? void 0 : _api$mention.mentionProvider;
|
|
228
|
+
if (isResolvingMentionProvider(mentionProvider)) {
|
|
229
|
+
var nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
|
|
230
|
+
if (isPromise(nameDetail)) {
|
|
231
|
+
text = '@...';
|
|
232
|
+
} else {
|
|
233
|
+
if (nameDetail.status === MentionNameStatus.OK) {
|
|
234
|
+
text = "@".concat(nameDetail.name || '');
|
|
244
235
|
} else {
|
|
245
|
-
|
|
246
|
-
text = "@".concat(nameDetail.name || '');
|
|
247
|
-
} else {
|
|
248
|
-
text = '@_|unknown|_';
|
|
249
|
-
}
|
|
236
|
+
text = '@_|unknown|_';
|
|
250
237
|
}
|
|
251
238
|
}
|
|
252
239
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
240
|
+
}
|
|
241
|
+
if (text) {
|
|
242
|
+
collectNodeMatch({
|
|
243
|
+
text: text,
|
|
244
|
+
pos: pos
|
|
245
|
+
}, node);
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'inlineCard':
|
|
249
|
+
case 'blockCard':
|
|
250
|
+
case 'embedCard':
|
|
251
|
+
collectCardTitleMatch(node, pos);
|
|
252
|
+
break;
|
|
253
|
+
case 'syncBlock':
|
|
254
|
+
{
|
|
255
|
+
if (editorExperiment('platform_synced_block', true)) {
|
|
256
|
+
var _api$syncedBlock, _instance$data;
|
|
257
|
+
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;
|
|
258
|
+
var instance = syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId);
|
|
259
|
+
var adfContent = instance === null || instance === void 0 || (_instance$data = instance.data) === null || _instance$data === void 0 ? void 0 : _instance$data.content;
|
|
260
|
+
if (adfContent && adfContent.length > 0) {
|
|
261
|
+
var _text = extractTextFromADFContent(adfContent);
|
|
262
|
+
if (_text) {
|
|
263
|
+
collectNodeMatch({
|
|
264
|
+
text: _text,
|
|
265
|
+
pos: pos
|
|
266
|
+
}, node);
|
|
280
267
|
}
|
|
281
268
|
}
|
|
282
|
-
break;
|
|
283
269
|
}
|
|
284
|
-
default:
|
|
285
270
|
break;
|
|
286
|
-
|
|
271
|
+
}
|
|
272
|
+
default:
|
|
273
|
+
break;
|
|
287
274
|
}
|
|
288
275
|
}
|
|
289
276
|
});
|
package/dist/esm/ui/Find.js
CHANGED
|
@@ -22,7 +22,6 @@ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
22
22
|
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
23
23
|
import { Label } from '@atlaskit/form';
|
|
24
24
|
import TextLetterCaseIcon from '@atlaskit/icon-lab/core/text-letter-case';
|
|
25
|
-
import MatchCaseIcon from '@atlaskit/icon/core/text-style';
|
|
26
25
|
import Textfield from '@atlaskit/textfield';
|
|
27
26
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
28
27
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -139,11 +138,9 @@ var Find = /*#__PURE__*/function (_React$Component) {
|
|
|
139
138
|
}
|
|
140
139
|
});
|
|
141
140
|
_defineProperty(_this, "matchCaseIconEle", function (iconProps) {
|
|
142
|
-
return
|
|
141
|
+
return jsx(TextLetterCaseIcon, {
|
|
143
142
|
label: iconProps.label,
|
|
144
143
|
size: "small"
|
|
145
|
-
}) : jsx(MatchCaseIcon, {
|
|
146
|
-
label: _this.matchCase
|
|
147
144
|
});
|
|
148
145
|
});
|
|
149
146
|
var formatMessage = props.intl.formatMessage;
|
|
@@ -17,7 +17,6 @@ import React from 'react';
|
|
|
17
17
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
18
18
|
import { jsx } from '@emotion/react';
|
|
19
19
|
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
20
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
20
|
import Find from './Find';
|
|
22
21
|
import Replace from './Replace';
|
|
23
22
|
import { ruleStyles, wrapperPaddingStyles, wrapperStyles } from './ui-styles';
|
|
@@ -108,7 +107,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
108
107
|
css: ruleStyles,
|
|
109
108
|
id: "replace-hr-element"
|
|
110
109
|
}), jsx(Replace, {
|
|
111
|
-
canReplace:
|
|
110
|
+
canReplace: !!isReplaceable,
|
|
112
111
|
replaceText: replaceText,
|
|
113
112
|
onReplace: onReplace,
|
|
114
113
|
onReplaceAll: onReplaceAll,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useLayoutEffect, useState } from 'react';
|
|
3
3
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { blur, toggleMatchCase } from '../pm-plugins/commands';
|
|
6
5
|
import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
|
|
7
6
|
import FindReplaceDropdown from './FindReplaceDropdown';
|
|
@@ -147,12 +146,12 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
|
|
|
147
146
|
findText: findText,
|
|
148
147
|
index: index,
|
|
149
148
|
numMatches: matches.length,
|
|
150
|
-
isReplaceable:
|
|
151
|
-
numReplaceable:
|
|
149
|
+
isReplaceable: (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace,
|
|
150
|
+
numReplaceable:
|
|
152
151
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
153
152
|
matches.filter(function (match) {
|
|
154
153
|
return match.canReplace === true;
|
|
155
|
-
}).length
|
|
154
|
+
}).length,
|
|
156
155
|
replaceText: replaceText,
|
|
157
156
|
shouldFocus: shouldFocus,
|
|
158
157
|
popupsBoundariesElement: popupsBoundariesElement,
|
package/dist/esm/ui/Replace.js
CHANGED
|
@@ -10,7 +10,6 @@ import ChevronUpIcon from '@atlaskit/icon/core/chevron-up';
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
11
11
|
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
12
12
|
import Textfield from '@atlaskit/textfield';
|
|
13
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
13
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
15
14
|
|
|
16
15
|
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
@@ -25,13 +24,10 @@ var actionButtonContainerStyles = xcss({
|
|
|
25
24
|
paddingTop: 'space.200'
|
|
26
25
|
});
|
|
27
26
|
var actionButtonParentInlineStyles = xcss({
|
|
28
|
-
justifyContent: 'space-between',
|
|
29
|
-
flexDirection: 'row-reverse'
|
|
30
|
-
});
|
|
31
|
-
var actionButtonParentInlineStylesNew = xcss({
|
|
32
27
|
justifyContent: 'space-between',
|
|
33
28
|
flexDirection: 'row-reverse',
|
|
34
|
-
flexWrap: 'wrap'
|
|
29
|
+
flexWrap: 'wrap',
|
|
30
|
+
gap: 'space.075'
|
|
35
31
|
});
|
|
36
32
|
var actionButtonInlineStyles = xcss({
|
|
37
33
|
gap: 'space.075'
|
|
@@ -147,7 +143,7 @@ var Replace = function Replace(_ref) {
|
|
|
147
143
|
replaceText: replaceText
|
|
148
144
|
});
|
|
149
145
|
setIsHelperMessageVisible(true);
|
|
150
|
-
if (count.totalReplaceable
|
|
146
|
+
if (count.totalReplaceable) {
|
|
151
147
|
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
152
148
|
setReplaceCount(count.totalReplaceable);
|
|
153
149
|
} else {
|
|
@@ -218,7 +214,7 @@ var Replace = function Replace(_ref) {
|
|
|
218
214
|
resultsReplace.replace(SPACE_REGEX, "\xA0") : resultsReplace)), /*#__PURE__*/React.createElement(Box, {
|
|
219
215
|
xcss: actionButtonContainerStyles
|
|
220
216
|
}, /*#__PURE__*/React.createElement(Inline, {
|
|
221
|
-
xcss:
|
|
217
|
+
xcss: actionButtonParentInlineStyles
|
|
222
218
|
}, /*#__PURE__*/React.createElement(Inline, {
|
|
223
219
|
xcss: actionButtonInlineStyles
|
|
224
220
|
}, /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
|
|
@@ -259,18 +255,14 @@ var Replace = function Replace(_ref) {
|
|
|
259
255
|
testId: replaceAll,
|
|
260
256
|
id: "replaceAll-button",
|
|
261
257
|
onClick: handleReplaceAllClick,
|
|
262
|
-
isDisabled:
|
|
263
|
-
}, replaceAll)),
|
|
258
|
+
isDisabled: count.totalReplaceable === 0
|
|
259
|
+
}, replaceAll)), /*#__PURE__*/React.createElement(Inline, {
|
|
264
260
|
xcss: closeButtonInlineStyles
|
|
265
261
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
266
262
|
appearance: "subtle",
|
|
267
263
|
testId: closeFindReplaceDialog,
|
|
268
264
|
onClick: clearSearch
|
|
269
|
-
}, closeFindReplaceDialog))
|
|
270
|
-
appearance: "subtle",
|
|
271
|
-
testId: closeFindReplaceDialog,
|
|
272
|
-
onClick: clearSearch
|
|
273
|
-
}, closeFindReplaceDialog))));
|
|
265
|
+
}, closeFindReplaceDialog)))));
|
|
274
266
|
};
|
|
275
267
|
|
|
276
268
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.2",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"@atlaskit/form": "^16.1.0",
|
|
33
33
|
"@atlaskit/icon": "^37.3.0",
|
|
34
34
|
"@atlaskit/icon-lab": "^7.5.0",
|
|
35
|
-
"@atlaskit/mention": "^27.
|
|
35
|
+
"@atlaskit/mention": "^27.14.0",
|
|
36
36
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
37
37
|
"@atlaskit/primitives": "^22.2.0",
|
|
38
38
|
"@atlaskit/textfield": "^10.0.0",
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^144.0.0",
|
|
40
40
|
"@atlaskit/tokens": "^16.4.0",
|
|
41
41
|
"@atlaskit/tooltip": "^24.0.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|