@atlaskit/editor-plugin-find-replace 2.7.0 → 2.7.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 +16 -0
- package/dist/cjs/pm-plugins/commands.js +3 -3
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/pm-plugins/reducer.js +2 -2
- package/dist/cjs/pm-plugins/utils/index.js +31 -41
- 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/es2019/pm-plugins/commands.js +3 -3
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/pm-plugins/reducer.js +2 -2
- package/dist/es2019/pm-plugins/utils/index.js +31 -41
- 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/esm/pm-plugins/commands.js +3 -3
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/pm-plugins/reducer.js +2 -2
- package/dist/esm/pm-plugins/utils/index.js +31 -41
- 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/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/pm-plugins/utils/index.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/package.json +6 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-find-replace
|
|
2
2
|
|
|
3
|
+
## 2.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#176094](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/176094)
|
|
8
|
+
[`09e338a3d7dab`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/09e338a3d7dab) -
|
|
9
|
+
[ED-28357] move find&replace work from behind feature gates to the new experiment
|
|
10
|
+
platform_editor_find_and_replace_improvements
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 2.7.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 2.7.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -7,7 +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
|
|
10
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
11
|
var _actions = require("./actions");
|
|
12
12
|
var _pluginFactory = require("./plugin-factory");
|
|
13
13
|
var _utils = require("./utils");
|
|
@@ -178,7 +178,7 @@ var replace = exports.replace = function replace(replaceText) {
|
|
|
178
178
|
index = _getPluginState6.index,
|
|
179
179
|
findText = _getPluginState6.findText;
|
|
180
180
|
if (matches[index]) {
|
|
181
|
-
if (!matches[index].canReplace && (0,
|
|
181
|
+
if (!matches[index].canReplace && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
182
182
|
return tr;
|
|
183
183
|
}
|
|
184
184
|
var _matches$index = matches[index],
|
|
@@ -200,7 +200,7 @@ var replaceAll = exports.replaceAll = function replaceAll(replaceText) {
|
|
|
200
200
|
}, function (tr, state) {
|
|
201
201
|
var pluginState = (0, _pluginFactory.getPluginState)(state);
|
|
202
202
|
pluginState.matches.forEach(function (match) {
|
|
203
|
-
if (!match.canReplace && (0,
|
|
203
|
+
if (!match.canReplace && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
204
204
|
return tr;
|
|
205
205
|
}
|
|
206
206
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
@@ -8,7 +8,7 @@ exports.initialState = exports.createPlugin = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
-
var
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
12
|
var _pluginFactory = require("./plugin-factory");
|
|
13
13
|
var _pluginKey = require("./plugin-key");
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -27,7 +27,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
27
27
|
return new _safePlugin.SafePlugin({
|
|
28
28
|
key: _pluginKey.findReplacePluginKey,
|
|
29
29
|
state: (0, _pluginFactory.createPluginState)(dispatch, function () {
|
|
30
|
-
return (0,
|
|
30
|
+
return (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
|
|
31
31
|
getIntl: getIntl,
|
|
32
32
|
api: api
|
|
33
33
|
}) : _objectSpread({}, initialState);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
10
10
|
var _actions = require("./actions");
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -47,7 +47,7 @@ var reducer = function reducer(getInitialState) {
|
|
|
47
47
|
case _actions.FindReplaceActionTypes.CANCEL:
|
|
48
48
|
var getIntl = state.getIntl,
|
|
49
49
|
api = state.api;
|
|
50
|
-
return (0,
|
|
50
|
+
return (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, getInitialState()), {}, {
|
|
51
51
|
getIntl: getIntl,
|
|
52
52
|
api: api
|
|
53
53
|
}) : getInitialState();
|
|
@@ -13,7 +13,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
13
13
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
14
14
|
var _resource = require("@atlaskit/mention/resource");
|
|
15
15
|
var _types = require("@atlaskit/mention/types");
|
|
16
|
-
var
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
17
|
var _styles = require("../../ui/styles");
|
|
18
18
|
function getSelectedText(selection) {
|
|
19
19
|
var text = '';
|
|
@@ -69,7 +69,7 @@ function findMatches(_ref2) {
|
|
|
69
69
|
matches.push({
|
|
70
70
|
start: pos + index,
|
|
71
71
|
end: pos + end,
|
|
72
|
-
canReplace: (0,
|
|
72
|
+
canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined
|
|
73
73
|
});
|
|
74
74
|
index = text.indexOf(searchText, end);
|
|
75
75
|
}
|
|
@@ -80,14 +80,8 @@ function findMatches(_ref2) {
|
|
|
80
80
|
}
|
|
81
81
|
var pos = textGrouping.pos;
|
|
82
82
|
var text = textGrouping.text;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (shouldMatchCase) {
|
|
86
|
-
text = text.toUpperCase();
|
|
87
|
-
} else {
|
|
88
|
-
text = text.toLowerCase();
|
|
89
|
-
searchText = searchText.toLowerCase();
|
|
90
|
-
}
|
|
83
|
+
if (shouldMatchCase) {
|
|
84
|
+
text = text.toUpperCase();
|
|
91
85
|
} else {
|
|
92
86
|
text = text.toLowerCase();
|
|
93
87
|
searchText = searchText.toLowerCase();
|
|
@@ -136,7 +130,7 @@ function findMatches(_ref2) {
|
|
|
136
130
|
} else {
|
|
137
131
|
collectTextMatch(textGrouping);
|
|
138
132
|
textGrouping = null;
|
|
139
|
-
if ((0,
|
|
133
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
140
134
|
switch (node.type.name) {
|
|
141
135
|
case 'status':
|
|
142
136
|
collectStatusMatch({
|
|
@@ -145,42 +139,38 @@ function findMatches(_ref2) {
|
|
|
145
139
|
}, node.nodeSize);
|
|
146
140
|
break;
|
|
147
141
|
case 'date':
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}, node.nodeSize);
|
|
153
|
-
}
|
|
142
|
+
collectDateOrMentionMatch({
|
|
143
|
+
text: (0, _utils.timestampToString)(node.attrs.timestamp, getIntl ? getIntl() : null),
|
|
144
|
+
pos: pos
|
|
145
|
+
}, node.nodeSize);
|
|
154
146
|
break;
|
|
155
147
|
case 'mention':
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
148
|
+
var text;
|
|
149
|
+
if (node.attrs.text) {
|
|
150
|
+
text = node.attrs.text;
|
|
151
|
+
} else {
|
|
152
|
+
var _api$mention;
|
|
153
|
+
// the text may be sanitised from the node for privacy reasons
|
|
154
|
+
// so we need to use the mentionProvider to resolve it
|
|
155
|
+
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;
|
|
156
|
+
if ((0, _resource.isResolvingMentionProvider)(mentionProvider)) {
|
|
157
|
+
var nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
|
|
158
|
+
if ((0, _types.isPromise)(nameDetail)) {
|
|
159
|
+
text = '@...';
|
|
160
|
+
} else {
|
|
161
|
+
if (nameDetail.status === _types.MentionNameStatus.OK) {
|
|
162
|
+
text = "@".concat(nameDetail.name || '');
|
|
169
163
|
} else {
|
|
170
|
-
|
|
171
|
-
text = "@".concat(nameDetail.name || '');
|
|
172
|
-
} else {
|
|
173
|
-
text = '@_|unknown|_';
|
|
174
|
-
}
|
|
164
|
+
text = '@_|unknown|_';
|
|
175
165
|
}
|
|
176
166
|
}
|
|
177
167
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
168
|
+
}
|
|
169
|
+
if (text) {
|
|
170
|
+
collectDateOrMentionMatch({
|
|
171
|
+
text: text,
|
|
172
|
+
pos: pos
|
|
173
|
+
}, node.nodeSize);
|
|
184
174
|
}
|
|
185
175
|
break;
|
|
186
176
|
default:
|
|
@@ -14,6 +14,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
var _react2 = require("@emotion/react");
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
18
|
var _Find = _interopRequireDefault(require("./Find"));
|
|
18
19
|
var _Replace = _interopRequireDefault(require("./Replace"));
|
|
19
20
|
var _ReplaceNext = _interopRequireDefault(require("./ReplaceNext"));
|
|
@@ -148,7 +149,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
148
149
|
css: _uiStyles.ruleStyles,
|
|
149
150
|
id: "replace-hr-element"
|
|
150
151
|
}), (0, _platformFeatureFlags.fg)('editor_a11y_refactor_find_replace_style') ? (0, _react2.jsx)(_ReplaceNext.default, {
|
|
151
|
-
canReplace: (0,
|
|
152
|
+
canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
152
153
|
replaceText: replaceText,
|
|
153
154
|
onReplace: onReplace,
|
|
154
155
|
onReplaceAll: onReplaceAll,
|
|
@@ -163,7 +164,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
163
164
|
setFindTyped: this.setFindTyped,
|
|
164
165
|
focusToolbarButton: focusToolbarButton
|
|
165
166
|
}) : (0, _react2.jsx)(_Replace.default, {
|
|
166
|
-
canReplace: (0,
|
|
167
|
+
canReplace: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
167
168
|
replaceText: replaceText,
|
|
168
169
|
onReplace: onReplace,
|
|
169
170
|
onReplaceAll: onReplaceAll,
|
|
@@ -10,7 +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
|
|
13
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
14
|
var _commands = require("../pm-plugins/commands");
|
|
15
15
|
var _commandsWithAnalytics = require("../pm-plugins/commands-with-analytics");
|
|
16
16
|
var _FindReplaceDropdown = _interopRequireDefault(require("./FindReplaceDropdown"));
|
|
@@ -186,8 +186,8 @@ var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithSta
|
|
|
186
186
|
findText: findText,
|
|
187
187
|
index: index,
|
|
188
188
|
numMatches: matches.length,
|
|
189
|
-
isReplaceable: (0,
|
|
190
|
-
numReplaceable: (0,
|
|
189
|
+
isReplaceable: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace : undefined,
|
|
190
|
+
numReplaceable: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? matches.filter(function (match) {
|
|
191
191
|
return match.canReplace === true;
|
|
192
192
|
}).length : undefined,
|
|
193
193
|
replaceText: replaceText,
|
package/dist/cjs/ui/Replace.js
CHANGED
|
@@ -21,9 +21,9 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
21
21
|
var _form = require("@atlaskit/form");
|
|
22
22
|
var _chevronDownHipchatChevronDown = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down"));
|
|
23
23
|
var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up"));
|
|
24
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
24
|
var _primitives = require("@atlaskit/primitives");
|
|
26
25
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
26
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
27
27
|
var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
|
|
28
28
|
var _uiStyles = require("./ui-styles");
|
|
29
29
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -102,7 +102,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
102
102
|
_this.setState({
|
|
103
103
|
isHelperMessageVisible: true
|
|
104
104
|
});
|
|
105
|
-
if (_this.props.count.totalReplaceable && (0,
|
|
105
|
+
if (_this.props.count.totalReplaceable && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
106
106
|
_this.triggerSuccessReplacementMessageUpdate(_this.props.count.totalReplaceable);
|
|
107
107
|
_this.setState({
|
|
108
108
|
replaceCount: _this.props.count.totalReplaceable
|
|
@@ -302,7 +302,7 @@ var Replace = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
302
302
|
testId: this.replaceAll,
|
|
303
303
|
id: "replaceAll-button",
|
|
304
304
|
onClick: this.handleReplaceAllClick,
|
|
305
|
-
isDisabled: (0,
|
|
305
|
+
isDisabled: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
306
306
|
}, this.replaceAll))), (0, _react2.jsx)("div", {
|
|
307
307
|
css: _uiStyles.orderZeroStyles
|
|
308
308
|
}, (0, _react2.jsx)(_new.default, {
|
|
@@ -15,9 +15,9 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
15
15
|
var _form = require("@atlaskit/form");
|
|
16
16
|
var _chevronDownHipchatChevronDown = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down"));
|
|
17
17
|
var _chevronUpHipchatChevronUp = _interopRequireDefault(require("@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up"));
|
|
18
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
18
|
var _primitives = require("@atlaskit/primitives");
|
|
20
19
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
20
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
21
21
|
var _FindReplaceTooltipButton = require("./FindReplaceTooltipButton");
|
|
22
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
23
23
|
var replaceContainerStyles = (0, _primitives.xcss)({
|
|
@@ -144,7 +144,7 @@ var Replace = function Replace(_ref) {
|
|
|
144
144
|
replaceText: replaceText
|
|
145
145
|
});
|
|
146
146
|
setIsHelperMessageVisible(true);
|
|
147
|
-
if (count.totalReplaceable && (0,
|
|
147
|
+
if (count.totalReplaceable && (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
148
148
|
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
149
149
|
setReplaceCount(count.totalReplaceable);
|
|
150
150
|
} else {
|
|
@@ -249,7 +249,7 @@ var Replace = function Replace(_ref) {
|
|
|
249
249
|
testId: replaceAll,
|
|
250
250
|
id: "replaceAll-button",
|
|
251
251
|
onClick: handleReplaceAllClick,
|
|
252
|
-
isDisabled: (0,
|
|
252
|
+
isDisabled: (0, _expValEquals.expValEquals)('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
253
253
|
}, replaceAll)), /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
254
254
|
appearance: "subtle",
|
|
255
255
|
testId: closeFindReplaceDialog,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import {
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { FindReplaceActionTypes } from './actions';
|
|
5
5
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
6
6
|
import { createDecoration, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
|
|
@@ -174,7 +174,7 @@ export const replace = replaceText => withScrollIntoView(createCommand(state =>
|
|
|
174
174
|
findText
|
|
175
175
|
} = getPluginState(state);
|
|
176
176
|
if (matches[index]) {
|
|
177
|
-
if (!matches[index].canReplace &&
|
|
177
|
+
if (!matches[index].canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
178
178
|
return tr;
|
|
179
179
|
}
|
|
180
180
|
const {
|
|
@@ -195,7 +195,7 @@ export const replaceAll = replaceText => createCommand({
|
|
|
195
195
|
}, (tr, state) => {
|
|
196
196
|
const pluginState = getPluginState(state);
|
|
197
197
|
pluginState.matches.forEach(match => {
|
|
198
|
-
if (!match.canReplace &&
|
|
198
|
+
if (!match.canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
199
199
|
return tr;
|
|
200
200
|
}
|
|
201
201
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import {
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
5
5
|
import { findReplacePluginKey } from './plugin-key';
|
|
6
6
|
export const initialState = {
|
|
@@ -16,7 +16,7 @@ export const initialState = {
|
|
|
16
16
|
export const createPlugin = (dispatch, getIntl, api) => {
|
|
17
17
|
return new SafePlugin({
|
|
18
18
|
key: findReplacePluginKey,
|
|
19
|
-
state: createPluginState(dispatch, () =>
|
|
19
|
+
state: createPluginState(dispatch, () => expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? {
|
|
20
20
|
...initialState,
|
|
21
21
|
getIntl,
|
|
22
22
|
api
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
2
|
import { FindReplaceActionTypes } from './actions';
|
|
3
3
|
const reducer = getInitialState => (state, action) => {
|
|
4
4
|
switch (action.type) {
|
|
@@ -43,7 +43,7 @@ const reducer = getInitialState => (state, action) => {
|
|
|
43
43
|
getIntl,
|
|
44
44
|
api
|
|
45
45
|
} = state;
|
|
46
|
-
return
|
|
46
|
+
return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? {
|
|
47
47
|
...getInitialState(),
|
|
48
48
|
getIntl,
|
|
49
49
|
api
|
|
@@ -3,7 +3,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
5
5
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
6
|
-
import {
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
7
|
import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
|
|
8
8
|
export function getSelectedText(selection) {
|
|
9
9
|
let text = '';
|
|
@@ -60,7 +60,7 @@ export function findMatches({
|
|
|
60
60
|
matches.push({
|
|
61
61
|
start: pos + index,
|
|
62
62
|
end: pos + end,
|
|
63
|
-
canReplace:
|
|
63
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined
|
|
64
64
|
});
|
|
65
65
|
index = text.indexOf(searchText, end);
|
|
66
66
|
}
|
|
@@ -75,14 +75,8 @@ export function findMatches({
|
|
|
75
75
|
let {
|
|
76
76
|
text
|
|
77
77
|
} = textGrouping;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (shouldMatchCase) {
|
|
81
|
-
text = text.toUpperCase();
|
|
82
|
-
} else {
|
|
83
|
-
text = text.toLowerCase();
|
|
84
|
-
searchText = searchText.toLowerCase();
|
|
85
|
-
}
|
|
78
|
+
if (shouldMatchCase) {
|
|
79
|
+
text = text.toUpperCase();
|
|
86
80
|
} else {
|
|
87
81
|
text = text.toLowerCase();
|
|
88
82
|
searchText = searchText.toLowerCase();
|
|
@@ -135,7 +129,7 @@ export function findMatches({
|
|
|
135
129
|
} else {
|
|
136
130
|
collectTextMatch(textGrouping);
|
|
137
131
|
textGrouping = null;
|
|
138
|
-
if (
|
|
132
|
+
if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
139
133
|
switch (node.type.name) {
|
|
140
134
|
case 'status':
|
|
141
135
|
collectStatusMatch({
|
|
@@ -144,42 +138,38 @@ export function findMatches({
|
|
|
144
138
|
}, node.nodeSize);
|
|
145
139
|
break;
|
|
146
140
|
case 'date':
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}, node.nodeSize);
|
|
152
|
-
}
|
|
141
|
+
collectDateOrMentionMatch({
|
|
142
|
+
text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
|
|
143
|
+
pos
|
|
144
|
+
}, node.nodeSize);
|
|
153
145
|
break;
|
|
154
146
|
case 'mention':
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
147
|
+
let text;
|
|
148
|
+
if (node.attrs.text) {
|
|
149
|
+
text = node.attrs.text;
|
|
150
|
+
} else {
|
|
151
|
+
var _api$mention, _api$mention$sharedSt;
|
|
152
|
+
// the text may be sanitised from the node for privacy reasons
|
|
153
|
+
// so we need to use the mentionProvider to resolve it
|
|
154
|
+
const mentionProvider = api === null || api === void 0 ? void 0 : (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : (_api$mention$sharedSt = _api$mention.sharedState.currentState()) === null || _api$mention$sharedSt === void 0 ? void 0 : _api$mention$sharedSt.mentionProvider;
|
|
155
|
+
if (isResolvingMentionProvider(mentionProvider)) {
|
|
156
|
+
const nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
|
|
157
|
+
if (isPromise(nameDetail)) {
|
|
158
|
+
text = '@...';
|
|
159
|
+
} else {
|
|
160
|
+
if (nameDetail.status === MentionNameStatus.OK) {
|
|
161
|
+
text = `@${nameDetail.name || ''}`;
|
|
168
162
|
} else {
|
|
169
|
-
|
|
170
|
-
text = `@${nameDetail.name || ''}`;
|
|
171
|
-
} else {
|
|
172
|
-
text = '@_|unknown|_';
|
|
173
|
-
}
|
|
163
|
+
text = '@_|unknown|_';
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
166
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
167
|
+
}
|
|
168
|
+
if (text) {
|
|
169
|
+
collectDateOrMentionMatch({
|
|
170
|
+
text,
|
|
171
|
+
pos
|
|
172
|
+
}, node.nodeSize);
|
|
183
173
|
}
|
|
184
174
|
break;
|
|
185
175
|
default:
|
|
@@ -10,6 +10,7 @@ import React from 'react';
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { jsx } from '@emotion/react';
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
14
|
import Find from './Find';
|
|
14
15
|
import Replace from './Replace';
|
|
15
16
|
import ReplaceNext from './ReplaceNext';
|
|
@@ -126,7 +127,7 @@ class FindReplace extends React.PureComponent {
|
|
|
126
127
|
css: ruleStyles,
|
|
127
128
|
id: "replace-hr-element"
|
|
128
129
|
}), fg('editor_a11y_refactor_find_replace_style') ? jsx(ReplaceNext, {
|
|
129
|
-
canReplace:
|
|
130
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
130
131
|
replaceText: replaceText,
|
|
131
132
|
onReplace: onReplace,
|
|
132
133
|
onReplaceAll: onReplaceAll,
|
|
@@ -141,7 +142,7 @@ class FindReplace extends React.PureComponent {
|
|
|
141
142
|
setFindTyped: this.setFindTyped,
|
|
142
143
|
focusToolbarButton: focusToolbarButton
|
|
143
144
|
}) : jsx(Replace, {
|
|
144
|
-
canReplace:
|
|
145
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
|
|
145
146
|
replaceText: replaceText,
|
|
146
147
|
onReplace: onReplace,
|
|
147
148
|
onReplaceAll: onReplaceAll,
|
|
@@ -1,7 +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 {
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
5
|
import { blur, toggleMatchCase } from '../pm-plugins/commands';
|
|
6
6
|
import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
|
|
7
7
|
import FindReplaceDropdown from './FindReplaceDropdown';
|
|
@@ -173,8 +173,8 @@ const FindReplaceToolbarButtonWithState = ({
|
|
|
173
173
|
findText: findText,
|
|
174
174
|
index: index,
|
|
175
175
|
numMatches: matches.length,
|
|
176
|
-
isReplaceable:
|
|
177
|
-
numReplaceable:
|
|
176
|
+
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,
|
|
177
|
+
numReplaceable: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? matches.filter(match => match.canReplace === true).length : undefined,
|
|
178
178
|
replaceText: replaceText,
|
|
179
179
|
shouldFocus: shouldFocus,
|
|
180
180
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -15,9 +15,9 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
15
15
|
import { Label, ValidMessage } from '@atlaskit/form';
|
|
16
16
|
import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
|
|
17
17
|
import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
|
|
18
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
18
|
import { Inline, xcss } from '@atlaskit/primitives';
|
|
20
19
|
import Textfield from '@atlaskit/textfield';
|
|
20
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
21
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
22
22
|
import { nextPreviousItemStyles, orderOneStyles, orderZeroStyles, sectionWrapperJustified, sectionWrapperStyles, sectionWrapperStylesAlternate, textFieldWrapper } from './ui-styles';
|
|
23
23
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -83,7 +83,7 @@ class Replace extends React.PureComponent {
|
|
|
83
83
|
this.setState({
|
|
84
84
|
isHelperMessageVisible: true
|
|
85
85
|
});
|
|
86
|
-
if (this.props.count.totalReplaceable &&
|
|
86
|
+
if (this.props.count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
87
87
|
this.triggerSuccessReplacementMessageUpdate(this.props.count.totalReplaceable);
|
|
88
88
|
this.setState({
|
|
89
89
|
replaceCount: this.props.count.totalReplaceable
|
|
@@ -279,7 +279,7 @@ class Replace extends React.PureComponent {
|
|
|
279
279
|
testId: this.replaceAll,
|
|
280
280
|
id: "replaceAll-button",
|
|
281
281
|
onClick: this.handleReplaceAllClick,
|
|
282
|
-
isDisabled:
|
|
282
|
+
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
283
283
|
}, this.replaceAll))), jsx("div", {
|
|
284
284
|
css: orderZeroStyles
|
|
285
285
|
}, jsx(Button, {
|
|
@@ -6,9 +6,9 @@ import { findReplaceMessages as messages } from '@atlaskit/editor-common/message
|
|
|
6
6
|
import { ValidMessage } from '@atlaskit/form';
|
|
7
7
|
import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
|
|
8
8
|
import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
|
|
9
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
9
|
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
11
10
|
import Textfield from '@atlaskit/textfield';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
12
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
13
13
|
const replaceContainerStyles = xcss({
|
|
14
14
|
padding: 'space.100'
|
|
@@ -115,7 +115,7 @@ const Replace = ({
|
|
|
115
115
|
replaceText
|
|
116
116
|
});
|
|
117
117
|
setIsHelperMessageVisible(true);
|
|
118
|
-
if (count.totalReplaceable &&
|
|
118
|
+
if (count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
119
119
|
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
120
120
|
setReplaceCount(count.totalReplaceable);
|
|
121
121
|
} else {
|
|
@@ -215,7 +215,7 @@ const Replace = ({
|
|
|
215
215
|
testId: replaceAll,
|
|
216
216
|
id: "replaceAll-button",
|
|
217
217
|
onClick: handleReplaceAllClick,
|
|
218
|
-
isDisabled:
|
|
218
|
+
isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
|
|
219
219
|
}, replaceAll)), /*#__PURE__*/React.createElement(Button, {
|
|
220
220
|
appearance: "subtle",
|
|
221
221
|
testId: closeFindReplaceDialog,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import {
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
4
|
import { FindReplaceActionTypes } from './actions';
|
|
5
5
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
6
6
|
import { createDecoration, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
|
|
@@ -171,7 +171,7 @@ export var replace = function replace(replaceText) {
|
|
|
171
171
|
index = _getPluginState6.index,
|
|
172
172
|
findText = _getPluginState6.findText;
|
|
173
173
|
if (matches[index]) {
|
|
174
|
-
if (!matches[index].canReplace &&
|
|
174
|
+
if (!matches[index].canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
175
175
|
return tr;
|
|
176
176
|
}
|
|
177
177
|
var _matches$index = matches[index],
|
|
@@ -193,7 +193,7 @@ export var replaceAll = function replaceAll(replaceText) {
|
|
|
193
193
|
}, function (tr, state) {
|
|
194
194
|
var pluginState = getPluginState(state);
|
|
195
195
|
pluginState.matches.forEach(function (match) {
|
|
196
|
-
if (!match.canReplace &&
|
|
196
|
+
if (!match.canReplace && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
197
197
|
return tr;
|
|
198
198
|
}
|
|
199
199
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import {
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
7
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
8
8
|
import { findReplacePluginKey } from './plugin-key';
|
|
9
9
|
export var initialState = {
|
|
@@ -20,7 +20,7 @@ export var createPlugin = function createPlugin(dispatch, getIntl, api) {
|
|
|
20
20
|
return new SafePlugin({
|
|
21
21
|
key: findReplacePluginKey,
|
|
22
22
|
state: createPluginState(dispatch, function () {
|
|
23
|
-
return
|
|
23
|
+
return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, initialState), {}, {
|
|
24
24
|
getIntl: getIntl,
|
|
25
25
|
api: api
|
|
26
26
|
}) : _objectSpread({}, initialState);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
import {
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
5
|
import { FindReplaceActionTypes } from './actions';
|
|
6
6
|
var reducer = function reducer(getInitialState) {
|
|
7
7
|
return function (state, action) {
|
|
@@ -40,7 +40,7 @@ var reducer = function reducer(getInitialState) {
|
|
|
40
40
|
case FindReplaceActionTypes.CANCEL:
|
|
41
41
|
var getIntl = state.getIntl,
|
|
42
42
|
api = state.api;
|
|
43
|
-
return
|
|
43
|
+
return expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? _objectSpread(_objectSpread({}, getInitialState()), {}, {
|
|
44
44
|
getIntl: getIntl,
|
|
45
45
|
api: api
|
|
46
46
|
}) : getInitialState();
|
|
@@ -3,7 +3,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
5
5
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
6
|
-
import {
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
7
|
import { searchMatchClass, selectedSearchMatchClass } from '../../ui/styles';
|
|
8
8
|
export function getSelectedText(selection) {
|
|
9
9
|
var text = '';
|
|
@@ -59,7 +59,7 @@ export function findMatches(_ref2) {
|
|
|
59
59
|
matches.push({
|
|
60
60
|
start: pos + index,
|
|
61
61
|
end: pos + end,
|
|
62
|
-
canReplace:
|
|
62
|
+
canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? true : undefined
|
|
63
63
|
});
|
|
64
64
|
index = text.indexOf(searchText, end);
|
|
65
65
|
}
|
|
@@ -70,14 +70,8 @@ export function findMatches(_ref2) {
|
|
|
70
70
|
}
|
|
71
71
|
var pos = textGrouping.pos;
|
|
72
72
|
var text = textGrouping.text;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (shouldMatchCase) {
|
|
76
|
-
text = text.toUpperCase();
|
|
77
|
-
} else {
|
|
78
|
-
text = text.toLowerCase();
|
|
79
|
-
searchText = searchText.toLowerCase();
|
|
80
|
-
}
|
|
73
|
+
if (shouldMatchCase) {
|
|
74
|
+
text = text.toUpperCase();
|
|
81
75
|
} else {
|
|
82
76
|
text = text.toLowerCase();
|
|
83
77
|
searchText = searchText.toLowerCase();
|
|
@@ -126,7 +120,7 @@ export function findMatches(_ref2) {
|
|
|
126
120
|
} else {
|
|
127
121
|
collectTextMatch(textGrouping);
|
|
128
122
|
textGrouping = null;
|
|
129
|
-
if (
|
|
123
|
+
if (expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
|
|
130
124
|
switch (node.type.name) {
|
|
131
125
|
case 'status':
|
|
132
126
|
collectStatusMatch({
|
|
@@ -135,42 +129,38 @@ export function findMatches(_ref2) {
|
|
|
135
129
|
}, node.nodeSize);
|
|
136
130
|
break;
|
|
137
131
|
case 'date':
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}, node.nodeSize);
|
|
143
|
-
}
|
|
132
|
+
collectDateOrMentionMatch({
|
|
133
|
+
text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
|
|
134
|
+
pos: pos
|
|
135
|
+
}, node.nodeSize);
|
|
144
136
|
break;
|
|
145
137
|
case 'mention':
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
138
|
+
var text;
|
|
139
|
+
if (node.attrs.text) {
|
|
140
|
+
text = node.attrs.text;
|
|
141
|
+
} else {
|
|
142
|
+
var _api$mention;
|
|
143
|
+
// the text may be sanitised from the node for privacy reasons
|
|
144
|
+
// so we need to use the mentionProvider to resolve it
|
|
145
|
+
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;
|
|
146
|
+
if (isResolvingMentionProvider(mentionProvider)) {
|
|
147
|
+
var nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
|
|
148
|
+
if (isPromise(nameDetail)) {
|
|
149
|
+
text = '@...';
|
|
150
|
+
} else {
|
|
151
|
+
if (nameDetail.status === MentionNameStatus.OK) {
|
|
152
|
+
text = "@".concat(nameDetail.name || '');
|
|
159
153
|
} else {
|
|
160
|
-
|
|
161
|
-
text = "@".concat(nameDetail.name || '');
|
|
162
|
-
} else {
|
|
163
|
-
text = '@_|unknown|_';
|
|
164
|
-
}
|
|
154
|
+
text = '@_|unknown|_';
|
|
165
155
|
}
|
|
166
156
|
}
|
|
167
157
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
158
|
+
}
|
|
159
|
+
if (text) {
|
|
160
|
+
collectDateOrMentionMatch({
|
|
161
|
+
text: text,
|
|
162
|
+
pos: pos
|
|
163
|
+
}, node.nodeSize);
|
|
174
164
|
}
|
|
175
165
|
break;
|
|
176
166
|
default:
|
|
@@ -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,
|
|
@@ -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';
|
|
@@ -22,7 +22,7 @@ type FindMatchesType = {
|
|
|
22
22
|
getIntl?: () => IntlShape;
|
|
23
23
|
api?: ExtractInjectionAPI<FindReplacePlugin>;
|
|
24
24
|
};
|
|
25
|
-
export declare function findMatches({ content, searchText, shouldMatchCase, contentIndex, getIntl, api }: FindMatchesType): Match[];
|
|
25
|
+
export declare function findMatches({ content, searchText, shouldMatchCase, contentIndex, getIntl, api, }: FindMatchesType): Match[];
|
|
26
26
|
/**
|
|
27
27
|
* Finds index of first item in matches array that comes after user's cursor pos.
|
|
28
28
|
* If `backward` is `true`, finds index of first item that comes before instead.
|
|
@@ -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';
|
|
@@ -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';
|
|
@@ -22,7 +22,7 @@ type FindMatchesType = {
|
|
|
22
22
|
getIntl?: () => IntlShape;
|
|
23
23
|
api?: ExtractInjectionAPI<FindReplacePlugin>;
|
|
24
24
|
};
|
|
25
|
-
export declare function findMatches({ content, searchText, shouldMatchCase, contentIndex, getIntl, api }: FindMatchesType): Match[];
|
|
25
|
+
export declare function findMatches({ content, searchText, shouldMatchCase, contentIndex, getIntl, api, }: FindMatchesType): Match[];
|
|
26
26
|
/**
|
|
27
27
|
* Finds index of first item in matches array that comes after user's cursor pos.
|
|
28
28
|
* If `backward` is `true`, finds index of first item that comes before instead.
|
|
@@ -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';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,21 +33,21 @@
|
|
|
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
38
|
"@atlaskit/editor-plugin-mentions": "^4.7.0",
|
|
39
39
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
42
42
|
"@atlaskit/form": "^12.0.0",
|
|
43
|
-
"@atlaskit/icon": "^27.
|
|
43
|
+
"@atlaskit/icon": "^27.1.0",
|
|
44
44
|
"@atlaskit/mention": "^24.2.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
46
|
"@atlaskit/primitives": "^14.9.0",
|
|
47
47
|
"@atlaskit/textfield": "^8.0.0",
|
|
48
48
|
"@atlaskit/theme": "^18.0.0",
|
|
49
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
50
|
-
"@atlaskit/tokens": "^5.
|
|
49
|
+
"@atlaskit/tmp-editor-statsig": "^8.2.0",
|
|
50
|
+
"@atlaskit/tokens": "^5.4.0",
|
|
51
51
|
"@atlaskit/tooltip": "^20.3.0",
|
|
52
52
|
"@babel/runtime": "^7.0.0",
|
|
53
53
|
"@emotion/react": "^11.7.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@af/visual-regression": "workspace:^",
|
|
59
59
|
"@atlaskit/editor-plugin-block-type": "^5.2.0",
|
|
60
|
-
"@atlaskit/editor-plugin-text-formatting": "^2.
|
|
60
|
+
"@atlaskit/editor-plugin-text-formatting": "^2.4.0",
|
|
61
61
|
"@testing-library/react": "^13.4.0",
|
|
62
62
|
"@testing-library/user-event": "^14.4.3",
|
|
63
63
|
"mockdate": "^3.0.5",
|
|
@@ -117,12 +117,6 @@
|
|
|
117
117
|
},
|
|
118
118
|
"editor_a11y_refactor_find_replace_style": {
|
|
119
119
|
"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
120
|
}
|
|
127
121
|
}
|
|
128
122
|
}
|