@atlaskit/editor-plugin-find-replace 2.3.0 → 2.4.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 +19 -0
- package/dist/cjs/pm-plugins/commands.js +7 -0
- package/dist/cjs/ui/FindReplace.js +3 -2
- package/dist/cjs/ui/FindReplaceDropDownOrToolbarButtonWithState.js +6 -1
- package/dist/cjs/ui/FindReplaceDropdown.js +3 -1
- package/dist/cjs/ui/FindReplaceToolbarButton.js +3 -1
- package/dist/cjs/ui/Replace.js +13 -5
- package/dist/cjs/ui/ReplaceNext.js +10 -3
- package/dist/es2019/pm-plugins/commands.js +7 -0
- package/dist/es2019/ui/FindReplace.js +3 -2
- package/dist/es2019/ui/FindReplaceDropDownOrToolbarButtonWithState.js +4 -1
- package/dist/es2019/ui/FindReplaceDropdown.js +3 -1
- package/dist/es2019/ui/FindReplaceToolbarButton.js +3 -1
- package/dist/es2019/ui/Replace.js +13 -5
- package/dist/es2019/ui/ReplaceNext.js +10 -3
- package/dist/esm/pm-plugins/commands.js +7 -0
- package/dist/esm/ui/FindReplace.js +3 -2
- package/dist/esm/ui/FindReplaceDropDownOrToolbarButtonWithState.js +6 -1
- package/dist/esm/ui/FindReplaceDropdown.js +3 -1
- package/dist/esm/ui/FindReplaceToolbarButton.js +3 -1
- package/dist/esm/ui/Replace.js +13 -5
- package/dist/esm/ui/ReplaceNext.js +10 -3
- package/dist/types/ui/FindReplace.d.ts +2 -0
- package/dist/types/ui/FindReplaceDropdown.d.ts +2 -0
- package/dist/types/ui/FindReplaceToolbarButton.d.ts +1 -0
- package/dist/types/ui/Replace.d.ts +1 -0
- package/dist/types/ui/ReplaceNext.d.ts +1 -0
- package/dist/types-ts4.5/ui/FindReplace.d.ts +2 -0
- package/dist/types-ts4.5/ui/FindReplaceDropdown.d.ts +2 -0
- package/dist/types-ts4.5/ui/FindReplaceToolbarButton.d.ts +1 -0
- package/dist/types-ts4.5/ui/Replace.d.ts +1 -0
- package/dist/types-ts4.5/ui/ReplaceNext.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-find-replace
|
|
2
2
|
|
|
3
|
+
## 2.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#167734](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/167734)
|
|
8
|
+
[`74e7440fe9307`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/74e7440fe9307) -
|
|
9
|
+
[ux] [ED-27959] this change is disabling the Replace/ Replace All functionality for non-text
|
|
10
|
+
matches with the platform_editor_find_and_replace_1 flag enabled
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 2.3.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.3.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.toggleMatchCase = exports.replaceAll = exports.replace = exports.removeDecorations = exports.findPrevious = exports.findNext = exports.find = exports.cancelSearch = exports.blur = exports.addDecorations = exports.activate = void 0;
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
9
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _actions = require("./actions");
|
|
11
12
|
var _pluginFactory = require("./plugin-factory");
|
|
12
13
|
var _utils = require("./utils");
|
|
@@ -153,6 +154,9 @@ var replace = exports.replace = function replace(replaceText) {
|
|
|
153
154
|
index = _getPluginState6.index,
|
|
154
155
|
findText = _getPluginState6.findText;
|
|
155
156
|
if (matches[index]) {
|
|
157
|
+
if (!matches[index].canReplace && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
|
|
158
|
+
return tr;
|
|
159
|
+
}
|
|
156
160
|
var _matches$index = matches[index],
|
|
157
161
|
start = _matches$index.start,
|
|
158
162
|
end = _matches$index.end;
|
|
@@ -172,6 +176,9 @@ var replaceAll = exports.replaceAll = function replaceAll(replaceText) {
|
|
|
172
176
|
}, function (tr, state) {
|
|
173
177
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
174
178
|
pluginState.matches.forEach(function (match) {
|
|
179
|
+
if (!match.canReplace && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
|
|
180
|
+
return tr;
|
|
181
|
+
}
|
|
175
182
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
176
183
|
});
|
|
177
184
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -107,6 +107,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
107
107
|
var _this$props = this.props,
|
|
108
108
|
findText = _this$props.findText,
|
|
109
109
|
count = _this$props.count,
|
|
110
|
+
isReplaceable = _this$props.isReplaceable,
|
|
110
111
|
shouldFocus = _this$props.shouldFocus,
|
|
111
112
|
onFind = _this$props.onFind,
|
|
112
113
|
onFindBlur = _this$props.onFindBlur,
|
|
@@ -147,7 +148,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
147
148
|
css: _uiStyles.ruleStyles,
|
|
148
149
|
id: "replace-hr-element"
|
|
149
150
|
}), (0, _platformFeatureFlags.fg)('editor_a11y_refactor_find_replace_style') ? (0, _react2.jsx)(_ReplaceNext.default, {
|
|
150
|
-
canReplace: count.total > 0,
|
|
151
|
+
canReplace: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
|
|
151
152
|
replaceText: replaceText,
|
|
152
153
|
onReplace: onReplace,
|
|
153
154
|
onReplaceAll: onReplaceAll,
|
|
@@ -162,7 +163,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
162
163
|
setFindTyped: this.setFindTyped,
|
|
163
164
|
focusToolbarButton: focusToolbarButton
|
|
164
165
|
}) : (0, _react2.jsx)(_Replace.default, {
|
|
165
|
-
canReplace: count.total > 0,
|
|
166
|
+
canReplace: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
|
|
166
167
|
replaceText: replaceText,
|
|
167
168
|
onReplace: onReplace,
|
|
168
169
|
onReplaceAll: onReplaceAll,
|
|
@@ -10,6 +10,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _commands = require("../pm-plugins/commands");
|
|
14
15
|
var _commandsWithAnalytics = require("../pm-plugins/commands-with-analytics");
|
|
15
16
|
var _FindReplaceDropdown = _interopRequireDefault(require("./FindReplaceDropdown"));
|
|
@@ -72,7 +73,7 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
72
73
|
};
|
|
73
74
|
});
|
|
74
75
|
var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithState(_ref2) {
|
|
75
|
-
var _api$analytics;
|
|
76
|
+
var _api$analytics, _matches$index;
|
|
76
77
|
var popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
77
78
|
popupsMountPoint = _ref2.popupsMountPoint,
|
|
78
79
|
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
@@ -185,6 +186,10 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
|
|
|
185
186
|
findText: findText,
|
|
186
187
|
index: index,
|
|
187
188
|
numMatches: matches.length,
|
|
189
|
+
isReplaceable: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
|
|
190
|
+
numReplaceable: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? matches.filter(function (match) {
|
|
191
|
+
return match.canReplace === true;
|
|
192
|
+
}).length : undefined,
|
|
188
193
|
replaceText: replaceText,
|
|
189
194
|
shouldFocus: shouldFocus,
|
|
190
195
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -27,6 +27,7 @@ var FindReplaceDropdown = function FindReplaceDropdown(props) {
|
|
|
27
27
|
index = props.index,
|
|
28
28
|
numMatches = props.numMatches,
|
|
29
29
|
popupsMountPoint = props.popupsMountPoint,
|
|
30
|
+
numReplaceable = props.numReplaceable,
|
|
30
31
|
onCancel = props.onCancel;
|
|
31
32
|
if (!popupsMountPoint) {
|
|
32
33
|
return null;
|
|
@@ -59,7 +60,8 @@ var FindReplaceDropdown = function FindReplaceDropdown(props) {
|
|
|
59
60
|
replaceText: replaceText,
|
|
60
61
|
count: {
|
|
61
62
|
index: index,
|
|
62
|
-
total: numMatches
|
|
63
|
+
total: numMatches,
|
|
64
|
+
totalReplaceable: numReplaceable
|
|
63
65
|
}
|
|
64
66
|
// Ignored via go/ees005
|
|
65
67
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -106,6 +106,7 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
106
106
|
isActive = _this$props.isActive,
|
|
107
107
|
index = _this$props.index,
|
|
108
108
|
numMatches = _this$props.numMatches,
|
|
109
|
+
numReplaceable = _this$props.numReplaceable,
|
|
109
110
|
formatMessage = _this$props.intl.formatMessage,
|
|
110
111
|
takeFullWidth = _this$props.takeFullWidth,
|
|
111
112
|
_this$props$isButtonH = _this$props.isButtonHidden,
|
|
@@ -187,7 +188,8 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
187
188
|
replaceText: replaceText,
|
|
188
189
|
count: {
|
|
189
190
|
index: index,
|
|
190
|
-
total: numMatches
|
|
191
|
+
total: numMatches,
|
|
192
|
+
totalReplaceable: numReplaceable
|
|
191
193
|
},
|
|
192
194
|
focusToolbarButton: this.focusToolbarButton
|
|
193
195
|
// Ignored via go/ees005
|
package/dist/cjs/ui/Replace.js
CHANGED
|
@@ -21,6 +21,7 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
21
21
|
var _form = require("@atlaskit/form");
|
|
22
22
|
var _chevronDownHipchatChevronDown = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-down--hipchat-chevron-down"));
|
|
23
23
|
var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-up--hipchat-chevron-up"));
|
|
24
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
25
|
var _primitives = require("@atlaskit/primitives");
|
|
25
26
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
26
27
|
var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
|
|
@@ -101,10 +102,17 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
101
102
|
_this.setState({
|
|
102
103
|
isHelperMessageVisible: true
|
|
103
104
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
if (_this.props.count.totalReplaceable && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
|
|
106
|
+
_this.triggerSuccessReplacementMessageUpdate(_this.props.count.totalReplaceable);
|
|
107
|
+
_this.setState({
|
|
108
|
+
replaceCount: _this.props.count.totalReplaceable
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
_this.triggerSuccessReplacementMessageUpdate(_this.props.count.total);
|
|
112
|
+
_this.setState({
|
|
113
|
+
replaceCount: _this.props.count.total
|
|
114
|
+
});
|
|
115
|
+
}
|
|
108
116
|
_this.props.setFindTyped(false);
|
|
109
117
|
});
|
|
110
118
|
});
|
|
@@ -284,7 +292,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
284
292
|
testId: this.replaceAll,
|
|
285
293
|
id: "replaceAll-button",
|
|
286
294
|
onClick: this.handleReplaceAllClick,
|
|
287
|
-
isDisabled: !canReplace
|
|
295
|
+
isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
|
|
288
296
|
}, this.replaceAll))), (0, _react2.jsx)("div", {
|
|
289
297
|
css: _uiStyles.orderZeroStyles
|
|
290
298
|
}, (0, _react2.jsx)(_new.default, {
|
|
@@ -15,6 +15,7 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
15
15
|
var _form = require("@atlaskit/form");
|
|
16
16
|
var _chevronDownHipchatChevronDown = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-down--hipchat-chevron-down"));
|
|
17
17
|
var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/utility/migration/chevron-up--hipchat-chevron-up"));
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
19
|
var _primitives = require("@atlaskit/primitives");
|
|
19
20
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
20
21
|
var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
|
|
@@ -143,8 +144,14 @@ var Replace = function Replace(_ref) {
|
|
|
143
144
|
replaceText: replaceText
|
|
144
145
|
});
|
|
145
146
|
setIsHelperMessageVisible(true);
|
|
146
|
-
|
|
147
|
-
|
|
147
|
+
if (count.totalReplaceable && (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
|
|
148
|
+
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
149
|
+
setReplaceCount(count.totalReplaceable);
|
|
150
|
+
} else {
|
|
151
|
+
triggerSuccessReplacementMessageUpdate(count.total);
|
|
152
|
+
setReplaceCount(count.total);
|
|
153
|
+
}
|
|
154
|
+
;
|
|
148
155
|
setFindTyped(false);
|
|
149
156
|
});
|
|
150
157
|
};
|
|
@@ -233,7 +240,7 @@ var Replace = function Replace(_ref) {
|
|
|
233
240
|
testId: replaceAll,
|
|
234
241
|
id: "replaceAll-button",
|
|
235
242
|
onClick: handleReplaceAllClick,
|
|
236
|
-
isDisabled: !canReplace
|
|
243
|
+
isDisabled: (0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
|
|
237
244
|
}, replaceAll)), /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
238
245
|
appearance: "subtle",
|
|
239
246
|
testId: closeFindReplaceDialog,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { FindReplaceActionTypes } from './actions';
|
|
4
5
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
5
6
|
import { createDecoration, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
|
|
@@ -149,6 +150,9 @@ export const replace = replaceText => withScrollIntoView(createCommand(state =>
|
|
|
149
150
|
findText
|
|
150
151
|
} = getPluginState(state);
|
|
151
152
|
if (matches[index]) {
|
|
153
|
+
if (!matches[index].canReplace && fg('platform_editor_find_and_replace_1')) {
|
|
154
|
+
return tr;
|
|
155
|
+
}
|
|
152
156
|
const {
|
|
153
157
|
start,
|
|
154
158
|
end
|
|
@@ -167,6 +171,9 @@ export const replaceAll = replaceText => createCommand({
|
|
|
167
171
|
}, (tr, state) => {
|
|
168
172
|
const pluginState = getPluginState(state);
|
|
169
173
|
pluginState.matches.forEach(match => {
|
|
174
|
+
if (!match.canReplace && fg('platform_editor_find_and_replace_1')) {
|
|
175
|
+
return tr;
|
|
176
|
+
}
|
|
170
177
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
171
178
|
});
|
|
172
179
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -84,6 +84,7 @@ class FindReplace extends React.PureComponent {
|
|
|
84
84
|
const {
|
|
85
85
|
findText,
|
|
86
86
|
count,
|
|
87
|
+
isReplaceable,
|
|
87
88
|
shouldFocus,
|
|
88
89
|
onFind,
|
|
89
90
|
onFindBlur,
|
|
@@ -125,7 +126,7 @@ class FindReplace extends React.PureComponent {
|
|
|
125
126
|
css: ruleStyles,
|
|
126
127
|
id: "replace-hr-element"
|
|
127
128
|
}), fg('editor_a11y_refactor_find_replace_style') ? jsx(ReplaceNext, {
|
|
128
|
-
canReplace: count.total > 0,
|
|
129
|
+
canReplace: fg('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
|
|
129
130
|
replaceText: replaceText,
|
|
130
131
|
onReplace: onReplace,
|
|
131
132
|
onReplaceAll: onReplaceAll,
|
|
@@ -140,7 +141,7 @@ class FindReplace extends React.PureComponent {
|
|
|
140
141
|
setFindTyped: this.setFindTyped,
|
|
141
142
|
focusToolbarButton: focusToolbarButton
|
|
142
143
|
}) : jsx(Replace, {
|
|
143
|
-
canReplace: count.total > 0,
|
|
144
|
+
canReplace: fg('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
|
|
144
145
|
replaceText: replaceText,
|
|
145
146
|
onReplace: onReplace,
|
|
146
147
|
onReplaceAll: onReplaceAll,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useLayoutEffect, useState } from 'react';
|
|
2
2
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { blur, toggleMatchCase } from '../pm-plugins/commands';
|
|
5
6
|
import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
|
|
6
7
|
import FindReplaceDropdown from './FindReplaceDropdown';
|
|
@@ -74,7 +75,7 @@ const FindReplaceToolbarButtonWithState = ({
|
|
|
74
75
|
isButtonHidden,
|
|
75
76
|
doesNotHaveButton
|
|
76
77
|
}) => {
|
|
77
|
-
var _api$analytics;
|
|
78
|
+
var _api$analytics, _matches$index;
|
|
78
79
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
79
80
|
const {
|
|
80
81
|
shouldMatchCase,
|
|
@@ -172,6 +173,8 @@ const FindReplaceToolbarButtonWithState = ({
|
|
|
172
173
|
findText: findText,
|
|
173
174
|
index: index,
|
|
174
175
|
numMatches: matches.length,
|
|
176
|
+
isReplaceable: fg('platform_editor_find_and_replace_1') ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
|
|
177
|
+
numReplaceable: fg('platform_editor_find_and_replace_1') ? matches.filter(match => match.canReplace === true).length : undefined,
|
|
175
178
|
replaceText: replaceText,
|
|
176
179
|
shouldFocus: shouldFocus,
|
|
177
180
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -21,6 +21,7 @@ const FindReplaceDropdown = props => {
|
|
|
21
21
|
index,
|
|
22
22
|
numMatches,
|
|
23
23
|
popupsMountPoint,
|
|
24
|
+
numReplaceable,
|
|
24
25
|
onCancel
|
|
25
26
|
} = props;
|
|
26
27
|
if (!popupsMountPoint) {
|
|
@@ -54,7 +55,8 @@ const FindReplaceDropdown = props => {
|
|
|
54
55
|
replaceText: replaceText,
|
|
55
56
|
count: {
|
|
56
57
|
index,
|
|
57
|
-
total: numMatches
|
|
58
|
+
total: numMatches,
|
|
59
|
+
totalReplaceable: numReplaceable
|
|
58
60
|
}
|
|
59
61
|
// Ignored via go/ees005
|
|
60
62
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -94,6 +94,7 @@ class FindReplaceToolbarButton extends React.PureComponent {
|
|
|
94
94
|
isActive,
|
|
95
95
|
index,
|
|
96
96
|
numMatches,
|
|
97
|
+
numReplaceable,
|
|
97
98
|
intl: {
|
|
98
99
|
formatMessage
|
|
99
100
|
},
|
|
@@ -177,7 +178,8 @@ class FindReplaceToolbarButton extends React.PureComponent {
|
|
|
177
178
|
replaceText: replaceText,
|
|
178
179
|
count: {
|
|
179
180
|
index,
|
|
180
|
-
total: numMatches
|
|
181
|
+
total: numMatches,
|
|
182
|
+
totalReplaceable: numReplaceable
|
|
181
183
|
},
|
|
182
184
|
focusToolbarButton: this.focusToolbarButton
|
|
183
185
|
// Ignored via go/ees005
|
|
@@ -15,6 +15,7 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
15
15
|
import { Label, ValidMessage } from '@atlaskit/form';
|
|
16
16
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down--hipchat-chevron-down';
|
|
17
17
|
import ChevronUpIcon from '@atlaskit/icon/utility/migration/chevron-up--hipchat-chevron-up';
|
|
18
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { Inline, xcss } from '@atlaskit/primitives';
|
|
19
20
|
import Textfield from '@atlaskit/textfield';
|
|
20
21
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -82,10 +83,17 @@ class Replace extends React.PureComponent {
|
|
|
82
83
|
this.setState({
|
|
83
84
|
isHelperMessageVisible: true
|
|
84
85
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (this.props.count.totalReplaceable && fg('platform_editor_find_and_replace_1')) {
|
|
87
|
+
this.triggerSuccessReplacementMessageUpdate(this.props.count.totalReplaceable);
|
|
88
|
+
this.setState({
|
|
89
|
+
replaceCount: this.props.count.totalReplaceable
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
this.triggerSuccessReplacementMessageUpdate(this.props.count.total);
|
|
93
|
+
this.setState({
|
|
94
|
+
replaceCount: this.props.count.total
|
|
95
|
+
});
|
|
96
|
+
}
|
|
89
97
|
this.props.setFindTyped(false);
|
|
90
98
|
}));
|
|
91
99
|
_defineProperty(this, "handleCompositionStart", () => {
|
|
@@ -265,7 +273,7 @@ class Replace extends React.PureComponent {
|
|
|
265
273
|
testId: this.replaceAll,
|
|
266
274
|
id: "replaceAll-button",
|
|
267
275
|
onClick: this.handleReplaceAllClick,
|
|
268
|
-
isDisabled: !canReplace
|
|
276
|
+
isDisabled: fg('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
|
|
269
277
|
}, this.replaceAll))), jsx("div", {
|
|
270
278
|
css: orderZeroStyles
|
|
271
279
|
}, jsx(Button, {
|
|
@@ -6,6 +6,7 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
6
6
|
import { ValidMessage } from '@atlaskit/form';
|
|
7
7
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down--hipchat-chevron-down';
|
|
8
8
|
import ChevronUpIcon from '@atlaskit/icon/utility/migration/chevron-up--hipchat-chevron-up';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
10
11
|
import Textfield from '@atlaskit/textfield';
|
|
11
12
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -114,8 +115,14 @@ const Replace = ({
|
|
|
114
115
|
replaceText
|
|
115
116
|
});
|
|
116
117
|
setIsHelperMessageVisible(true);
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
if (count.totalReplaceable && fg('platform_editor_find_and_replace_1')) {
|
|
119
|
+
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
120
|
+
setReplaceCount(count.totalReplaceable);
|
|
121
|
+
} else {
|
|
122
|
+
triggerSuccessReplacementMessageUpdate(count.total);
|
|
123
|
+
setReplaceCount(count.total);
|
|
124
|
+
}
|
|
125
|
+
;
|
|
119
126
|
setFindTyped(false);
|
|
120
127
|
});
|
|
121
128
|
const handleCompositionStart = () => {
|
|
@@ -203,7 +210,7 @@ const Replace = ({
|
|
|
203
210
|
testId: replaceAll,
|
|
204
211
|
id: "replaceAll-button",
|
|
205
212
|
onClick: handleReplaceAllClick,
|
|
206
|
-
isDisabled: !canReplace
|
|
213
|
+
isDisabled: fg('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
|
|
207
214
|
}, replaceAll)), /*#__PURE__*/React.createElement(Button, {
|
|
208
215
|
appearance: "subtle",
|
|
209
216
|
testId: closeFindReplaceDialog,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { FindReplaceActionTypes } from './actions';
|
|
4
5
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
5
6
|
import { createDecoration, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
|
|
@@ -146,6 +147,9 @@ export var replace = function replace(replaceText) {
|
|
|
146
147
|
index = _getPluginState6.index,
|
|
147
148
|
findText = _getPluginState6.findText;
|
|
148
149
|
if (matches[index]) {
|
|
150
|
+
if (!matches[index].canReplace && fg('platform_editor_find_and_replace_1')) {
|
|
151
|
+
return tr;
|
|
152
|
+
}
|
|
149
153
|
var _matches$index = matches[index],
|
|
150
154
|
start = _matches$index.start,
|
|
151
155
|
end = _matches$index.end;
|
|
@@ -165,6 +169,9 @@ export var replaceAll = function replaceAll(replaceText) {
|
|
|
165
169
|
}, function (tr, state) {
|
|
166
170
|
var pluginState = getPluginState(state);
|
|
167
171
|
pluginState.matches.forEach(function (match) {
|
|
172
|
+
if (!match.canReplace && fg('platform_editor_find_and_replace_1')) {
|
|
173
|
+
return tr;
|
|
174
|
+
}
|
|
168
175
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
169
176
|
});
|
|
170
177
|
tr.setMeta('scrollIntoView', false);
|
|
@@ -105,6 +105,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
105
105
|
var _this$props = this.props,
|
|
106
106
|
findText = _this$props.findText,
|
|
107
107
|
count = _this$props.count,
|
|
108
|
+
isReplaceable = _this$props.isReplaceable,
|
|
108
109
|
shouldFocus = _this$props.shouldFocus,
|
|
109
110
|
onFind = _this$props.onFind,
|
|
110
111
|
onFindBlur = _this$props.onFindBlur,
|
|
@@ -145,7 +146,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
145
146
|
css: ruleStyles,
|
|
146
147
|
id: "replace-hr-element"
|
|
147
148
|
}), fg('editor_a11y_refactor_find_replace_style') ? jsx(ReplaceNext, {
|
|
148
|
-
canReplace: count.total > 0,
|
|
149
|
+
canReplace: fg('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
|
|
149
150
|
replaceText: replaceText,
|
|
150
151
|
onReplace: onReplace,
|
|
151
152
|
onReplaceAll: onReplaceAll,
|
|
@@ -160,7 +161,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
160
161
|
setFindTyped: this.setFindTyped,
|
|
161
162
|
focusToolbarButton: focusToolbarButton
|
|
162
163
|
}) : jsx(Replace, {
|
|
163
|
-
canReplace: count.total > 0,
|
|
164
|
+
canReplace: fg('platform_editor_find_and_replace_1') ? !!isReplaceable : count.total > 0,
|
|
164
165
|
replaceText: replaceText,
|
|
165
166
|
onReplace: onReplace,
|
|
166
167
|
onReplaceAll: onReplaceAll,
|
|
@@ -2,6 +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 { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { blur, toggleMatchCase } from '../pm-plugins/commands';
|
|
6
7
|
import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
|
|
7
8
|
import FindReplaceDropdown from './FindReplaceDropdown';
|
|
@@ -64,7 +65,7 @@ var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
|
64
65
|
};
|
|
65
66
|
});
|
|
66
67
|
var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithState(_ref2) {
|
|
67
|
-
var _api$analytics;
|
|
68
|
+
var _api$analytics, _matches$index;
|
|
68
69
|
var popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
69
70
|
popupsMountPoint = _ref2.popupsMountPoint,
|
|
70
71
|
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
@@ -177,6 +178,10 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
|
|
|
177
178
|
findText: findText,
|
|
178
179
|
index: index,
|
|
179
180
|
numMatches: matches.length,
|
|
181
|
+
isReplaceable: fg('platform_editor_find_and_replace_1') ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
|
|
182
|
+
numReplaceable: fg('platform_editor_find_and_replace_1') ? matches.filter(function (match) {
|
|
183
|
+
return match.canReplace === true;
|
|
184
|
+
}).length : undefined,
|
|
180
185
|
replaceText: replaceText,
|
|
181
186
|
shouldFocus: shouldFocus,
|
|
182
187
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -20,6 +20,7 @@ var FindReplaceDropdown = function FindReplaceDropdown(props) {
|
|
|
20
20
|
index = props.index,
|
|
21
21
|
numMatches = props.numMatches,
|
|
22
22
|
popupsMountPoint = props.popupsMountPoint,
|
|
23
|
+
numReplaceable = props.numReplaceable,
|
|
23
24
|
onCancel = props.onCancel;
|
|
24
25
|
if (!popupsMountPoint) {
|
|
25
26
|
return null;
|
|
@@ -52,7 +53,8 @@ var FindReplaceDropdown = function FindReplaceDropdown(props) {
|
|
|
52
53
|
replaceText: replaceText,
|
|
53
54
|
count: {
|
|
54
55
|
index: index,
|
|
55
|
-
total: numMatches
|
|
56
|
+
total: numMatches,
|
|
57
|
+
totalReplaceable: numReplaceable
|
|
56
58
|
}
|
|
57
59
|
// Ignored via go/ees005
|
|
58
60
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
@@ -101,6 +101,7 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
101
101
|
isActive = _this$props.isActive,
|
|
102
102
|
index = _this$props.index,
|
|
103
103
|
numMatches = _this$props.numMatches,
|
|
104
|
+
numReplaceable = _this$props.numReplaceable,
|
|
104
105
|
formatMessage = _this$props.intl.formatMessage,
|
|
105
106
|
takeFullWidth = _this$props.takeFullWidth,
|
|
106
107
|
_this$props$isButtonH = _this$props.isButtonHidden,
|
|
@@ -182,7 +183,8 @@ var FindReplaceToolbarButton = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
182
183
|
replaceText: replaceText,
|
|
183
184
|
count: {
|
|
184
185
|
index: index,
|
|
185
|
-
total: numMatches
|
|
186
|
+
total: numMatches,
|
|
187
|
+
totalReplaceable: numReplaceable
|
|
186
188
|
},
|
|
187
189
|
focusToolbarButton: this.focusToolbarButton
|
|
188
190
|
// Ignored via go/ees005
|
package/dist/esm/ui/Replace.js
CHANGED
|
@@ -22,6 +22,7 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
22
22
|
import { Label, ValidMessage } from '@atlaskit/form';
|
|
23
23
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down--hipchat-chevron-down';
|
|
24
24
|
import ChevronUpIcon from '@atlaskit/icon/utility/migration/chevron-up--hipchat-chevron-up';
|
|
25
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
import { Inline, xcss } from '@atlaskit/primitives';
|
|
26
27
|
import Textfield from '@atlaskit/textfield';
|
|
27
28
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -96,10 +97,17 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
96
97
|
_this.setState({
|
|
97
98
|
isHelperMessageVisible: true
|
|
98
99
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
if (_this.props.count.totalReplaceable && fg('platform_editor_find_and_replace_1')) {
|
|
101
|
+
_this.triggerSuccessReplacementMessageUpdate(_this.props.count.totalReplaceable);
|
|
102
|
+
_this.setState({
|
|
103
|
+
replaceCount: _this.props.count.totalReplaceable
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
_this.triggerSuccessReplacementMessageUpdate(_this.props.count.total);
|
|
107
|
+
_this.setState({
|
|
108
|
+
replaceCount: _this.props.count.total
|
|
109
|
+
});
|
|
110
|
+
}
|
|
103
111
|
_this.props.setFindTyped(false);
|
|
104
112
|
});
|
|
105
113
|
});
|
|
@@ -279,7 +287,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
279
287
|
testId: this.replaceAll,
|
|
280
288
|
id: "replaceAll-button",
|
|
281
289
|
onClick: this.handleReplaceAllClick,
|
|
282
|
-
isDisabled: !canReplace
|
|
290
|
+
isDisabled: fg('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
|
|
283
291
|
}, this.replaceAll))), jsx("div", {
|
|
284
292
|
css: orderZeroStyles
|
|
285
293
|
}, jsx(Button, {
|
|
@@ -7,6 +7,7 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
7
7
|
import { ValidMessage } from '@atlaskit/form';
|
|
8
8
|
import ChevronDownIcon from '@atlaskit/icon/utility/migration/chevron-down--hipchat-chevron-down';
|
|
9
9
|
import ChevronUpIcon from '@atlaskit/icon/utility/migration/chevron-up--hipchat-chevron-up';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
11
12
|
import Textfield from '@atlaskit/textfield';
|
|
12
13
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -134,8 +135,14 @@ var Replace = function Replace(_ref) {
|
|
|
134
135
|
replaceText: replaceText
|
|
135
136
|
});
|
|
136
137
|
setIsHelperMessageVisible(true);
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
if (count.totalReplaceable && fg('platform_editor_find_and_replace_1')) {
|
|
139
|
+
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
140
|
+
setReplaceCount(count.totalReplaceable);
|
|
141
|
+
} else {
|
|
142
|
+
triggerSuccessReplacementMessageUpdate(count.total);
|
|
143
|
+
setReplaceCount(count.total);
|
|
144
|
+
}
|
|
145
|
+
;
|
|
139
146
|
setFindTyped(false);
|
|
140
147
|
});
|
|
141
148
|
};
|
|
@@ -224,7 +231,7 @@ var Replace = function Replace(_ref) {
|
|
|
224
231
|
testId: replaceAll,
|
|
225
232
|
id: "replaceAll-button",
|
|
226
233
|
onClick: handleReplaceAllClick,
|
|
227
|
-
isDisabled: !canReplace
|
|
234
|
+
isDisabled: fg('platform_editor_find_and_replace_1') ? count.totalReplaceable === 0 : !canReplace
|
|
228
235
|
}, replaceAll)), /*#__PURE__*/React.createElement(Button, {
|
|
229
236
|
appearance: "subtle",
|
|
230
237
|
testId: closeFindReplaceDialog,
|
|
@@ -6,6 +6,8 @@ export interface FindReplaceDropdownProps extends Omit<FindReplaceProps, 'count'
|
|
|
6
6
|
index: number;
|
|
7
7
|
numMatches: number;
|
|
8
8
|
isActive: boolean;
|
|
9
|
+
isReplaceable?: boolean;
|
|
10
|
+
numReplaceable?: number;
|
|
9
11
|
popupsMountPoint?: HTMLElement;
|
|
10
12
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
11
13
|
}
|
|
@@ -10,6 +10,7 @@ export interface FindReplaceToolbarButtonProps extends Omit<FindReplaceProps, 'c
|
|
|
10
10
|
index: number;
|
|
11
11
|
numMatches: number;
|
|
12
12
|
isActive: boolean;
|
|
13
|
+
numReplaceable?: number;
|
|
13
14
|
onActivate: () => void;
|
|
14
15
|
isReducedSpacing?: boolean;
|
|
15
16
|
popupsMountPoint?: HTMLElement;
|
|
@@ -6,6 +6,8 @@ export interface FindReplaceDropdownProps extends Omit<FindReplaceProps, 'count'
|
|
|
6
6
|
index: number;
|
|
7
7
|
numMatches: number;
|
|
8
8
|
isActive: boolean;
|
|
9
|
+
isReplaceable?: boolean;
|
|
10
|
+
numReplaceable?: number;
|
|
9
11
|
popupsMountPoint?: HTMLElement;
|
|
10
12
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
11
13
|
}
|
|
@@ -10,6 +10,7 @@ export interface FindReplaceToolbarButtonProps extends Omit<FindReplaceProps, 'c
|
|
|
10
10
|
index: number;
|
|
11
11
|
numMatches: number;
|
|
12
12
|
isActive: boolean;
|
|
13
|
+
numReplaceable?: number;
|
|
13
14
|
onActivate: () => void;
|
|
14
15
|
isReducedSpacing?: boolean;
|
|
15
16
|
popupsMountPoint?: HTMLElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/button": "^23.2.0",
|
|
36
|
-
"@atlaskit/editor-common": "^106.
|
|
36
|
+
"@atlaskit/editor-common": "^106.5.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/primitives": "^14.8.0",
|
|
45
45
|
"@atlaskit/textfield": "^8.0.0",
|
|
46
46
|
"@atlaskit/theme": "^18.0.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^6.1.0",
|
|
48
48
|
"@atlaskit/tokens": "^5.1.0",
|
|
49
49
|
"@atlaskit/tooltip": "^20.3.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|