@atlaskit/editor-plugin-find-replace 2.7.1 → 2.8.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 +23 -0
- package/dist/cjs/pm-plugins/commands.js +5 -5
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/reducer.js +2 -2
- package/dist/cjs/pm-plugins/utils/batch-decorations.js +7 -2
- package/dist/cjs/pm-plugins/utils/index.js +102 -54
- package/dist/cjs/ui/FindReplace.js +3 -2
- package/dist/cjs/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -3
- package/dist/cjs/ui/Replace.js +3 -3
- package/dist/cjs/ui/ReplaceNext.js +3 -3
- package/dist/cjs/ui/styles.js +50 -1
- package/dist/es2019/pm-plugins/commands.js +5 -5
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/reducer.js +2 -2
- package/dist/es2019/pm-plugins/utils/batch-decorations.js +7 -2
- package/dist/es2019/pm-plugins/utils/index.js +102 -55
- package/dist/es2019/ui/FindReplace.js +3 -2
- package/dist/es2019/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -3
- package/dist/es2019/ui/Replace.js +3 -3
- package/dist/es2019/ui/ReplaceNext.js +3 -3
- package/dist/es2019/ui/styles.js +99 -0
- package/dist/esm/pm-plugins/commands.js +5 -5
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/reducer.js +2 -2
- package/dist/esm/pm-plugins/utils/batch-decorations.js +7 -2
- package/dist/esm/pm-plugins/utils/index.js +102 -55
- package/dist/esm/ui/FindReplace.js +3 -2
- package/dist/esm/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -3
- package/dist/esm/ui/Replace.js +3 -3
- package/dist/esm/ui/ReplaceNext.js +3 -3
- package/dist/esm/ui/styles.js +49 -0
- package/dist/types/findReplacePluginType.d.ts +3 -1
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/pm-plugins/utils/index.d.ts +3 -6
- package/dist/types/types/index.d.ts +3 -1
- package/dist/types/ui/styles.d.ts +3 -0
- package/dist/types-ts4.5/findReplacePluginType.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +3 -6
- package/dist/types-ts4.5/types/index.d.ts +3 -1
- package/dist/types-ts4.5/ui/styles.d.ts +3 -0
- package/package.json +8 -12
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import classnames from 'classnames';
|
|
1
3
|
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
2
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
5
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
6
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
5
7
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
|
+
import { getGlobalTheme } from '@atlaskit/tokens';
|
|
10
|
+
import { searchMatchClass, selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass } from '../../ui/styles';
|
|
8
11
|
export function getSelectedText(selection) {
|
|
9
12
|
var text = '';
|
|
10
13
|
var selectedContent = selection.content().content;
|
|
@@ -16,18 +19,37 @@ export function getSelectedText(selection) {
|
|
|
16
19
|
export var createDecorations = function createDecorations(selectedIndex, matches) {
|
|
17
20
|
return matches.map(function (_ref, i) {
|
|
18
21
|
var start = _ref.start,
|
|
19
|
-
end = _ref.end
|
|
20
|
-
|
|
22
|
+
end = _ref.end,
|
|
23
|
+
nodeType = _ref.nodeType;
|
|
24
|
+
return createDecoration(start, end, i === selectedIndex, nodeType);
|
|
21
25
|
});
|
|
22
26
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
var isBlock = function isBlock(nodeType) {
|
|
28
|
+
return nodeType === 'blockCard' || nodeType === 'embedCard';
|
|
29
|
+
};
|
|
30
|
+
export var createDecoration = function createDecoration(start, end, isSelected, nodeType) {
|
|
31
|
+
if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
32
|
+
var _getGlobalTheme = getGlobalTheme(),
|
|
33
|
+
colorMode = _getGlobalTheme.colorMode;
|
|
34
|
+
var className = classnames(searchMatchClass, _defineProperty(_defineProperty(_defineProperty({}, selectedSearchMatchClass, isSelected), blockSearchMatchClass, isBlock(nodeType)), darkModeSearchMatchClass, colorMode === 'dark'));
|
|
35
|
+
if (isBlock(nodeType)) {
|
|
36
|
+
return Decoration.node(start, end, {
|
|
37
|
+
class: className
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
return Decoration.inline(start, end, {
|
|
41
|
+
class: className
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
var _className = searchMatchClass;
|
|
46
|
+
if (isSelected) {
|
|
47
|
+
_className += " ".concat(selectedSearchMatchClass);
|
|
48
|
+
}
|
|
49
|
+
return Decoration.inline(start, end, {
|
|
50
|
+
class: _className
|
|
51
|
+
});
|
|
27
52
|
}
|
|
28
|
-
return Decoration.inline(start, end, {
|
|
29
|
-
class: className
|
|
30
|
-
});
|
|
31
53
|
};
|
|
32
54
|
export function findMatches(_ref2) {
|
|
33
55
|
var content = _ref2.content,
|
|
@@ -59,7 +81,8 @@ export function findMatches(_ref2) {
|
|
|
59
81
|
matches.push({
|
|
60
82
|
start: pos + index,
|
|
61
83
|
end: pos + end,
|
|
62
|
-
canReplace:
|
|
84
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined,
|
|
85
|
+
nodeType: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? 'text' : undefined
|
|
63
86
|
});
|
|
64
87
|
index = text.indexOf(searchText, end);
|
|
65
88
|
}
|
|
@@ -70,14 +93,8 @@ export function findMatches(_ref2) {
|
|
|
70
93
|
}
|
|
71
94
|
var pos = textGrouping.pos;
|
|
72
95
|
var text = textGrouping.text;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (shouldMatchCase) {
|
|
76
|
-
text = text.toUpperCase();
|
|
77
|
-
} else {
|
|
78
|
-
text = text.toLowerCase();
|
|
79
|
-
searchText = searchText.toLowerCase();
|
|
80
|
-
}
|
|
96
|
+
if (shouldMatchCase) {
|
|
97
|
+
text = text.toUpperCase();
|
|
81
98
|
} else {
|
|
82
99
|
text = text.toLowerCase();
|
|
83
100
|
searchText = searchText.toLowerCase();
|
|
@@ -88,11 +105,12 @@ export function findMatches(_ref2) {
|
|
|
88
105
|
matches.push({
|
|
89
106
|
start: start,
|
|
90
107
|
end: start + nodeSize,
|
|
91
|
-
canReplace: false
|
|
108
|
+
canReplace: false,
|
|
109
|
+
nodeType: 'status'
|
|
92
110
|
});
|
|
93
111
|
}
|
|
94
112
|
};
|
|
95
|
-
var
|
|
113
|
+
var collectNodeMatch = function collectNodeMatch(textGrouping, node) {
|
|
96
114
|
if (!textGrouping) {
|
|
97
115
|
return;
|
|
98
116
|
}
|
|
@@ -107,9 +125,37 @@ export function findMatches(_ref2) {
|
|
|
107
125
|
var start = pos;
|
|
108
126
|
matches.push({
|
|
109
127
|
start: start,
|
|
110
|
-
end: start + nodeSize,
|
|
111
|
-
canReplace: false
|
|
128
|
+
end: start + node.nodeSize,
|
|
129
|
+
canReplace: false,
|
|
130
|
+
nodeType: node.type.name
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var collectCardTitleMatch = function collectCardTitleMatch(node, pos) {
|
|
135
|
+
var _api$card;
|
|
136
|
+
var cards = api === null || api === void 0 || (_api$card = api.card) === null || _api$card === void 0 || (_api$card = _api$card.sharedState.currentState()) === null || _api$card === void 0 ? void 0 : _api$card.cards;
|
|
137
|
+
if (cards) {
|
|
138
|
+
var relevantCard = cards.find(function (card) {
|
|
139
|
+
return card.url === node.attrs.url;
|
|
112
140
|
});
|
|
141
|
+
var title = relevantCard === null || relevantCard === void 0 ? void 0 : relevantCard.title;
|
|
142
|
+
if (relevantCard) {
|
|
143
|
+
if (title) {
|
|
144
|
+
collectNodeMatch({
|
|
145
|
+
text: title,
|
|
146
|
+
pos: pos
|
|
147
|
+
}, node);
|
|
148
|
+
} else {
|
|
149
|
+
// when there is no title, e.g. in an error case like unauthorized
|
|
150
|
+
// the link card just shows the entire url as the title in inline card
|
|
151
|
+
if (node.type.name === 'inlineCard') {
|
|
152
|
+
collectNodeMatch({
|
|
153
|
+
text: node.attrs.url,
|
|
154
|
+
pos: pos
|
|
155
|
+
}, node);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
113
159
|
}
|
|
114
160
|
};
|
|
115
161
|
if (searchTextLength > 0) {
|
|
@@ -126,7 +172,7 @@ export function findMatches(_ref2) {
|
|
|
126
172
|
} else {
|
|
127
173
|
collectTextMatch(textGrouping);
|
|
128
174
|
textGrouping = null;
|
|
129
|
-
if (
|
|
175
|
+
if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
130
176
|
switch (node.type.name) {
|
|
131
177
|
case 'status':
|
|
132
178
|
collectStatusMatch({
|
|
@@ -135,43 +181,44 @@ export function findMatches(_ref2) {
|
|
|
135
181
|
}, node.nodeSize);
|
|
136
182
|
break;
|
|
137
183
|
case 'date':
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}, node.nodeSize);
|
|
143
|
-
}
|
|
184
|
+
collectNodeMatch({
|
|
185
|
+
text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
|
|
186
|
+
pos: pos
|
|
187
|
+
}, node);
|
|
144
188
|
break;
|
|
145
189
|
case 'mention':
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
190
|
+
var text;
|
|
191
|
+
if (node.attrs.text) {
|
|
192
|
+
text = node.attrs.text;
|
|
193
|
+
} else {
|
|
194
|
+
var _api$mention;
|
|
195
|
+
// the text may be sanitised from the node for privacy reasons
|
|
196
|
+
// so we need to use the mentionProvider to resolve it
|
|
197
|
+
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;
|
|
198
|
+
if (isResolvingMentionProvider(mentionProvider)) {
|
|
199
|
+
var nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
|
|
200
|
+
if (isPromise(nameDetail)) {
|
|
201
|
+
text = '@...';
|
|
202
|
+
} else {
|
|
203
|
+
if (nameDetail.status === MentionNameStatus.OK) {
|
|
204
|
+
text = "@".concat(nameDetail.name || '');
|
|
159
205
|
} else {
|
|
160
|
-
|
|
161
|
-
text = "@".concat(nameDetail.name || '');
|
|
162
|
-
} else {
|
|
163
|
-
text = '@_|unknown|_';
|
|
164
|
-
}
|
|
206
|
+
text = '@_|unknown|_';
|
|
165
207
|
}
|
|
166
208
|
}
|
|
167
209
|
}
|
|
168
|
-
if (text) {
|
|
169
|
-
collectDateOrMentionMatch({
|
|
170
|
-
text: text,
|
|
171
|
-
pos: pos
|
|
172
|
-
}, node.nodeSize);
|
|
173
|
-
}
|
|
174
210
|
}
|
|
211
|
+
if (text) {
|
|
212
|
+
collectNodeMatch({
|
|
213
|
+
text: text,
|
|
214
|
+
pos: pos
|
|
215
|
+
}, node);
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
case 'inlineCard':
|
|
219
|
+
case 'blockCard':
|
|
220
|
+
case 'embedCard':
|
|
221
|
+
collectCardTitleMatch(node, pos);
|
|
175
222
|
break;
|
|
176
223
|
default:
|
|
177
224
|
break;
|
|
@@ -17,6 +17,7 @@ import React from 'react';
|
|
|
17
17
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
18
|
import { jsx } from '@emotion/react';
|
|
19
19
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
20
21
|
import Find from './Find';
|
|
21
22
|
import Replace from './Replace';
|
|
22
23
|
import ReplaceNext from './ReplaceNext';
|
|
@@ -146,7 +147,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
146
147
|
css: ruleStyles,
|
|
147
148
|
id: "replace-hr-element"
|
|
148
149
|
}), fg('editor_a11y_refactor_find_replace_style') ? jsx(ReplaceNext, {
|
|
149
|
-
canReplace:
|
|
150
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
150
151
|
replaceText: replaceText,
|
|
151
152
|
onReplace: onReplace,
|
|
152
153
|
onReplaceAll: onReplaceAll,
|
|
@@ -161,7 +162,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
161
162
|
setFindTyped: this.setFindTyped,
|
|
162
163
|
focusToolbarButton: focusToolbarButton
|
|
163
164
|
}) : jsx(Replace, {
|
|
164
|
-
canReplace:
|
|
165
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
165
166
|
replaceText: replaceText,
|
|
166
167
|
onReplace: onReplace,
|
|
167
168
|
onReplaceAll: onReplaceAll,
|
|
@@ -2,7 +2,7 @@ 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
4
|
import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
6
|
import { blur, toggleMatchCase } from '../pm-plugins/commands';
|
|
7
7
|
import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
|
|
8
8
|
import FindReplaceDropdown from './FindReplaceDropdown';
|
|
@@ -178,8 +178,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
|
|
|
178
178
|
findText: findText,
|
|
179
179
|
index: index,
|
|
180
180
|
numMatches: matches.length,
|
|
181
|
-
isReplaceable:
|
|
182
|
-
numReplaceable:
|
|
181
|
+
isReplaceable: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
|
|
182
|
+
numReplaceable: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? matches.filter(function (match) {
|
|
183
183
|
return match.canReplace === true;
|
|
184
184
|
}).length : undefined,
|
|
185
185
|
replaceText: replaceText,
|
package/dist/esm/ui/Replace.js
CHANGED
|
@@ -22,9 +22,9 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
22
22
|
import { Label, ValidMessage } from '@atlaskit/form';
|
|
23
23
|
import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
|
|
24
24
|
import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
|
|
25
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
26
25
|
import { Inline, xcss } from '@atlaskit/primitives';
|
|
27
26
|
import Textfield from '@atlaskit/textfield';
|
|
27
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
28
28
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
29
29
|
import { nextPreviousItemStyles, orderOneStyles, orderZeroStyles, sectionWrapperJustified, sectionWrapperStyles, sectionWrapperStylesAlternate, textFieldWrapper } from './ui-styles';
|
|
30
30
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -97,7 +97,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
97
97
|
_this.setState({
|
|
98
98
|
isHelperMessageVisible: true
|
|
99
99
|
});
|
|
100
|
-
if (_this.props.count.totalReplaceable &&
|
|
100
|
+
if (_this.props.count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
101
101
|
_this.triggerSuccessReplacementMessageUpdate(_this.props.count.totalReplaceable);
|
|
102
102
|
_this.setState({
|
|
103
103
|
replaceCount: _this.props.count.totalReplaceable
|
|
@@ -297,7 +297,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
297
297
|
testId: this.replaceAll,
|
|
298
298
|
id: "replaceAll-button",
|
|
299
299
|
onClick: this.handleReplaceAllClick,
|
|
300
|
-
isDisabled:
|
|
300
|
+
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
301
301
|
}, this.replaceAll))), jsx("div", {
|
|
302
302
|
css: orderZeroStyles
|
|
303
303
|
}, jsx(Button, {
|
|
@@ -7,9 +7,9 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
7
7
|
import { ValidMessage } from '@atlaskit/form';
|
|
8
8
|
import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
|
|
9
9
|
import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
|
|
10
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
12
11
|
import Textfield from '@atlaskit/textfield';
|
|
12
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
13
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
14
14
|
var replaceContainerStyles = xcss({
|
|
15
15
|
padding: 'space.100'
|
|
@@ -135,7 +135,7 @@ var Replace = function Replace(_ref) {
|
|
|
135
135
|
replaceText: replaceText
|
|
136
136
|
});
|
|
137
137
|
setIsHelperMessageVisible(true);
|
|
138
|
-
if (count.totalReplaceable &&
|
|
138
|
+
if (count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
139
139
|
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
140
140
|
setReplaceCount(count.totalReplaceable);
|
|
141
141
|
} else {
|
|
@@ -240,7 +240,7 @@ var Replace = function Replace(_ref) {
|
|
|
240
240
|
testId: replaceAll,
|
|
241
241
|
id: "replaceAll-button",
|
|
242
242
|
onClick: handleReplaceAllClick,
|
|
243
|
-
isDisabled:
|
|
243
|
+
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
244
244
|
}, replaceAll)), /*#__PURE__*/React.createElement(Button, {
|
|
245
245
|
appearance: "subtle",
|
|
246
246
|
testId: closeFindReplaceDialog,
|
package/dist/esm/ui/styles.js
CHANGED
|
@@ -10,10 +10,59 @@ import { css } from '@emotion/react';
|
|
|
10
10
|
import { N40A, N50A, N60A } from '@atlaskit/theme/colors';
|
|
11
11
|
export var searchMatchClass = 'search-match';
|
|
12
12
|
export var selectedSearchMatchClass = 'selected-search-match';
|
|
13
|
+
export var blockSearchMatchClass = 'search-match-block';
|
|
14
|
+
export var darkModeSearchMatchClass = 'search-match-dark';
|
|
13
15
|
export var findReplaceStyles = css(_defineProperty(_defineProperty({}, ".".concat(searchMatchClass), {
|
|
14
16
|
borderRadius: '3px',
|
|
15
17
|
backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
|
|
16
18
|
boxShadow: "var(--ds-shadow-raised, ".concat("0 1px 1px 0 ".concat(N50A, ", 0 0 1px 0 ").concat(N60A), ")") + ', inset 0 0 0 1px ' + "var(--ds-border-input, ".concat("".concat(N40A), ")")
|
|
17
19
|
}), ".".concat(selectedSearchMatchClass), {
|
|
18
20
|
backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
|
|
21
|
+
}));
|
|
22
|
+
export var findReplaceStylesNew = css(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ".".concat(searchMatchClass), {
|
|
23
|
+
borderRadius: '3px',
|
|
24
|
+
backgroundColor: "var(--ds-background-accent-teal-subtlest, #E7F9FF)",
|
|
25
|
+
boxShadow: "var(--ds-shadow-raised, 0 1px 1px 0 rgba(9, 30, 66, 0.25), 0 0 1px 0 rgba(9, 30, 66, 0.31))".concat(", inset 0 0 0 1px ", "var(--ds-border-input, #8590A2)")
|
|
26
|
+
}), ".".concat(selectedSearchMatchClass), {
|
|
27
|
+
backgroundColor: "var(--ds-background-accent-teal-subtle, #6CC3E0)"
|
|
28
|
+
}), ".".concat(blockSearchMatchClass), {
|
|
29
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
30
|
+
'[data-smart-link-container="true"], .loader-wrapper>div::after': {
|
|
31
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-subtler, #F8E6A0)", "\n\t\t\t")
|
|
32
|
+
}
|
|
33
|
+
}), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass), {
|
|
34
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
35
|
+
'[data-smart-link-container="true"], .loader-wrapper>div::after': {
|
|
36
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)", "\n\t\t\t")
|
|
37
|
+
}
|
|
38
|
+
}), ".".concat(blockSearchMatchClass, ".ak-editor-selected-node"), {
|
|
39
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
40
|
+
'.loader-wrapper>div::after': {
|
|
41
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-subtler, #F8E6A0)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
|
|
42
|
+
}
|
|
43
|
+
}), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".ak-editor-selected-node"), {
|
|
44
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
45
|
+
'[data-smart-link-container="true"], .loader-wrapper>div::after': {
|
|
46
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-subtler-pressed, #E2B203)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
|
|
47
|
+
}
|
|
48
|
+
}), ".".concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass), {
|
|
49
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
50
|
+
'[data-smart-link-container="true"], .loader-wrapper>div::after': {
|
|
51
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-bolder-pressed, #533F04)", "\n\t\t\t")
|
|
52
|
+
}
|
|
53
|
+
}), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass), {
|
|
54
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
55
|
+
'[data-smart-link-container="true"], .loader-wrapper>div::after': {
|
|
56
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)", "\n\t\t\t")
|
|
57
|
+
}
|
|
58
|
+
}), ".".concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass, ".ak-editor-selected-node"), {
|
|
59
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
60
|
+
'.loader-wrapper>div::after': {
|
|
61
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 5px ", "var(--ds-background-accent-yellow-bolder-pressed, #533F04)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
|
|
62
|
+
}
|
|
63
|
+
}), ".".concat(selectedSearchMatchClass, ".").concat(blockSearchMatchClass, ".").concat(darkModeSearchMatchClass, ".ak-editor-selected-node"), {
|
|
64
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
65
|
+
'[data-smart-link-container="true"], .loader-wrapper>div::after': {
|
|
66
|
+
boxShadow: "\n\t\t\tinset 0 0 0 1px ".concat("var(--ds-background-accent-yellow-bolder, #946F00)", ",\n\t\t\tinset 0 0 0 4px ", "var(--ds-background-accent-yellow-bolder-hovered, #7F5F01)", ",\n\t\t\t0 0 0 1px ", "var(--ds-border-selected, #0C66E4)", "\n\t\t\t")
|
|
67
|
+
}
|
|
19
68
|
}));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
+
import type { CardPlugin } from '@atlaskit/editor-plugin-card';
|
|
5
6
|
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
6
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
7
8
|
import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
|
|
@@ -12,7 +13,8 @@ export type FindReplacePluginOptions = {
|
|
|
12
13
|
export type FindReplacePluginDependencies = [
|
|
13
14
|
OptionalPlugin<AnalyticsPlugin>,
|
|
14
15
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
15
|
-
OptionalPlugin<MentionsPlugin
|
|
16
|
+
OptionalPlugin<MentionsPlugin>,
|
|
17
|
+
OptionalPlugin<CardPlugin>
|
|
16
18
|
];
|
|
17
19
|
export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
|
|
18
20
|
pluginConfiguration: FindReplacePluginOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { FindReplacePlugin } from '../findReplacePluginType';
|
|
3
|
+
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { FindReplacePlugin } from '../findReplacePluginType';
|
|
5
5
|
import type { FindReplacePluginState } from '../types';
|
|
6
6
|
export declare const initialState: FindReplacePluginState;
|
|
7
7
|
export declare const createPlugin: (dispatch: Dispatch, getIntl: PMPluginFactoryParams['getIntl'], api?: ExtractInjectionAPI<FindReplacePlugin>) => SafePlugin<FindReplacePluginState>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Fragment, Node as PmNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { ReadonlyTransaction, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -9,11 +9,8 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
9
9
|
import { FindReplacePlugin } from '../../findReplacePluginType';
|
|
10
10
|
import type { Match } from '../../types';
|
|
11
11
|
export declare function getSelectedText(selection: TextSelection): string;
|
|
12
|
-
export declare const createDecorations: (selectedIndex: number, matches:
|
|
13
|
-
|
|
14
|
-
end: number;
|
|
15
|
-
}[]) => Decoration[];
|
|
16
|
-
export declare const createDecoration: (start: number, end: number, isSelected?: boolean) => Decoration;
|
|
12
|
+
export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
|
|
13
|
+
export declare const createDecoration: (start: number, end: number, isSelected?: Boolean, nodeType?: string) => Decoration;
|
|
17
14
|
type FindMatchesType = {
|
|
18
15
|
content: PmNode | Fragment;
|
|
19
16
|
searchText: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -49,6 +49,8 @@ export type Match = {
|
|
|
49
49
|
end: number;
|
|
50
50
|
/** Boolean for whether the match can be replaced */
|
|
51
51
|
canReplace?: boolean;
|
|
52
|
+
/** Type of the node of the match */
|
|
53
|
+
nodeType?: string;
|
|
52
54
|
};
|
|
53
55
|
export type TextGrouping = {
|
|
54
56
|
/** The concatenated text across nodes */
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const searchMatchClass = "search-match";
|
|
2
2
|
export declare const selectedSearchMatchClass = "selected-search-match";
|
|
3
|
+
export declare const blockSearchMatchClass = "search-match-block";
|
|
4
|
+
export declare const darkModeSearchMatchClass = "search-match-dark";
|
|
3
5
|
export declare const findReplaceStyles: import("@emotion/react").SerializedStyles;
|
|
6
|
+
export declare const findReplaceStylesNew: import("@emotion/react").SerializedStyles;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
+
import type { CardPlugin } from '@atlaskit/editor-plugin-card';
|
|
5
6
|
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
6
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
7
8
|
import type { FindReplacePluginState, FindReplaceToolbarButtonActionProps } from './types';
|
|
@@ -12,7 +13,8 @@ export type FindReplacePluginOptions = {
|
|
|
12
13
|
export type FindReplacePluginDependencies = [
|
|
13
14
|
OptionalPlugin<AnalyticsPlugin>,
|
|
14
15
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
15
|
-
OptionalPlugin<MentionsPlugin
|
|
16
|
+
OptionalPlugin<MentionsPlugin>,
|
|
17
|
+
OptionalPlugin<CardPlugin>
|
|
16
18
|
];
|
|
17
19
|
export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
|
|
18
20
|
pluginConfiguration: FindReplacePluginOptions;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
4
|
-
import { FindReplacePlugin } from '../findReplacePluginType';
|
|
3
|
+
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { FindReplacePlugin } from '../findReplacePluginType';
|
|
5
5
|
import type { FindReplacePluginState } from '../types';
|
|
6
6
|
export declare const initialState: FindReplacePluginState;
|
|
7
7
|
export declare const createPlugin: (dispatch: Dispatch, getIntl: PMPluginFactoryParams['getIntl'], api?: ExtractInjectionAPI<FindReplacePlugin>) => SafePlugin<FindReplacePluginState>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { Fragment, Node as PmNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import type { ReadonlyTransaction, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -9,11 +9,8 @@ import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
9
9
|
import { FindReplacePlugin } from '../../findReplacePluginType';
|
|
10
10
|
import type { Match } from '../../types';
|
|
11
11
|
export declare function getSelectedText(selection: TextSelection): string;
|
|
12
|
-
export declare const createDecorations: (selectedIndex: number, matches:
|
|
13
|
-
|
|
14
|
-
end: number;
|
|
15
|
-
}[]) => Decoration[];
|
|
16
|
-
export declare const createDecoration: (start: number, end: number, isSelected?: boolean) => Decoration;
|
|
12
|
+
export declare const createDecorations: (selectedIndex: number, matches: Match[]) => Decoration[];
|
|
13
|
+
export declare const createDecoration: (start: number, end: number, isSelected?: Boolean, nodeType?: string) => Decoration;
|
|
17
14
|
type FindMatchesType = {
|
|
18
15
|
content: PmNode | Fragment;
|
|
19
16
|
searchText: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntlShape } from 'react-intl-next';
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -49,6 +49,8 @@ export type Match = {
|
|
|
49
49
|
end: number;
|
|
50
50
|
/** Boolean for whether the match can be replaced */
|
|
51
51
|
canReplace?: boolean;
|
|
52
|
+
/** Type of the node of the match */
|
|
53
|
+
nodeType?: string;
|
|
52
54
|
};
|
|
53
55
|
export type TextGrouping = {
|
|
54
56
|
/** The concatenated text across nodes */
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const searchMatchClass = "search-match";
|
|
2
2
|
export declare const selectedSearchMatchClass = "selected-search-match";
|
|
3
|
+
export declare const blockSearchMatchClass = "search-match-block";
|
|
4
|
+
export declare const darkModeSearchMatchClass = "search-match-dark";
|
|
3
5
|
export declare const findReplaceStyles: import("@emotion/react").SerializedStyles;
|
|
6
|
+
export declare const findReplaceStylesNew: import("@emotion/react").SerializedStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,31 +33,33 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/button": "^23.2.0",
|
|
36
|
-
"@atlaskit/editor-common": "^107.
|
|
36
|
+
"@atlaskit/editor-common": "^107.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
38
|
+
"@atlaskit/editor-plugin-card": "^6.6.0",
|
|
38
39
|
"@atlaskit/editor-plugin-mentions": "^4.7.0",
|
|
39
40
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
40
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
42
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
42
43
|
"@atlaskit/form": "^12.0.0",
|
|
43
|
-
"@atlaskit/icon": "^27.
|
|
44
|
+
"@atlaskit/icon": "^27.2.0",
|
|
44
45
|
"@atlaskit/mention": "^24.2.0",
|
|
45
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
47
|
"@atlaskit/primitives": "^14.9.0",
|
|
47
48
|
"@atlaskit/textfield": "^8.0.0",
|
|
48
49
|
"@atlaskit/theme": "^18.0.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^8.
|
|
50
|
-
"@atlaskit/tokens": "^5.
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^8.2.0",
|
|
51
|
+
"@atlaskit/tokens": "^5.4.0",
|
|
51
52
|
"@atlaskit/tooltip": "^20.3.0",
|
|
52
53
|
"@babel/runtime": "^7.0.0",
|
|
53
54
|
"@emotion/react": "^11.7.1",
|
|
55
|
+
"classnames": "^2.2.5",
|
|
54
56
|
"lodash": "^4.17.21",
|
|
55
57
|
"raf-schd": "^4.0.3"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
60
|
"@af/visual-regression": "workspace:^",
|
|
59
61
|
"@atlaskit/editor-plugin-block-type": "^5.2.0",
|
|
60
|
-
"@atlaskit/editor-plugin-text-formatting": "^2.
|
|
62
|
+
"@atlaskit/editor-plugin-text-formatting": "^2.4.0",
|
|
61
63
|
"@testing-library/react": "^13.4.0",
|
|
62
64
|
"@testing-library/user-event": "^14.4.3",
|
|
63
65
|
"mockdate": "^3.0.5",
|
|
@@ -117,12 +119,6 @@
|
|
|
117
119
|
},
|
|
118
120
|
"editor_a11y_refactor_find_replace_style": {
|
|
119
121
|
"type": "boolean"
|
|
120
|
-
},
|
|
121
|
-
"platform_editor_find_and_replace_1": {
|
|
122
|
-
"type": "boolean"
|
|
123
|
-
},
|
|
124
|
-
"platform_editor_find_and_replace_part_2": {
|
|
125
|
-
"type": "boolean"
|
|
126
122
|
}
|
|
127
123
|
}
|
|
128
124
|
}
|