@atlaskit/editor-plugin-find-replace 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/pm-plugins/commands.js +5 -6
- package/dist/cjs/pm-plugins/plugin-factory.js +1 -2
- package/dist/cjs/pm-plugins/reducer.js +2 -3
- package/dist/cjs/pm-plugins/utils/batch-decorations.js +2 -7
- package/dist/cjs/pm-plugins/utils/index.js +83 -96
- package/dist/cjs/ui/Find.js +1 -4
- package/dist/cjs/ui/FindReplace.js +1 -2
- package/dist/cjs/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -4
- package/dist/cjs/ui/Replace.js +7 -15
- package/dist/es2019/pm-plugins/commands.js +5 -6
- package/dist/es2019/pm-plugins/plugin-factory.js +2 -3
- package/dist/es2019/pm-plugins/reducer.js +2 -3
- package/dist/es2019/pm-plugins/utils/batch-decorations.js +2 -7
- package/dist/es2019/pm-plugins/utils/index.js +93 -106
- package/dist/es2019/ui/Find.js +1 -4
- package/dist/es2019/ui/FindReplace.js +1 -2
- package/dist/es2019/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -4
- package/dist/es2019/ui/Replace.js +7 -15
- package/dist/esm/pm-plugins/commands.js +5 -6
- package/dist/esm/pm-plugins/plugin-factory.js +2 -3
- package/dist/esm/pm-plugins/reducer.js +2 -3
- package/dist/esm/pm-plugins/utils/batch-decorations.js +2 -7
- package/dist/esm/pm-plugins/utils/index.js +84 -97
- package/dist/esm/ui/Find.js +1 -4
- package/dist/esm/ui/FindReplace.js +1 -2
- package/dist/esm/ui/FindReplaceDropDownOrToolbarButtonWithState.js +3 -4
- package/dist/esm/ui/Replace.js +7 -15
- package/package.json +4 -4
|
@@ -4,10 +4,9 @@ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
6
6
|
import { isPromise, MentionNameStatus } from '@atlaskit/mention/types';
|
|
7
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
8
|
import { getGlobalTheme } from '@atlaskit/tokens/get-global-theme';
|
|
10
|
-
import {
|
|
9
|
+
import { selectedSearchMatchClass, blockSearchMatchClass, darkModeSearchMatchClass, selectedBlockSearchMatchClass, searchMatchExpandTitleClass, searchMatchTextClass } from '../../ui/styles';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Recursively extracts all text content from an ADF entity tree.
|
|
@@ -61,40 +60,30 @@ export const createDecoration = (match, isSelected) => {
|
|
|
61
60
|
end,
|
|
62
61
|
nodeType
|
|
63
62
|
} = match;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
} else {
|
|
85
|
-
const className = classnames(searchMatchTextClass, {
|
|
86
|
-
[selectedSearchMatchClass]: isSelected,
|
|
87
|
-
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
88
|
-
});
|
|
89
|
-
return Decoration.inline(start, end, {
|
|
90
|
-
class: className
|
|
91
|
-
});
|
|
92
|
-
}
|
|
63
|
+
const {
|
|
64
|
+
colorMode
|
|
65
|
+
} = getGlobalTheme();
|
|
66
|
+
if (isElement(nodeType)) {
|
|
67
|
+
const className = classnames(blockSearchMatchClass, {
|
|
68
|
+
[selectedBlockSearchMatchClass]: isSelected,
|
|
69
|
+
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
70
|
+
});
|
|
71
|
+
return Decoration.node(start, end, {
|
|
72
|
+
class: className
|
|
73
|
+
});
|
|
74
|
+
} else if (isExpandTitle(match)) {
|
|
75
|
+
const className = classnames(searchMatchExpandTitleClass, {
|
|
76
|
+
[selectedSearchMatchClass]: isSelected,
|
|
77
|
+
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
78
|
+
});
|
|
79
|
+
return Decoration.node(start, end, {
|
|
80
|
+
class: className
|
|
81
|
+
});
|
|
93
82
|
} else {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
83
|
+
const className = classnames(searchMatchTextClass, {
|
|
84
|
+
[selectedSearchMatchClass]: isSelected,
|
|
85
|
+
[darkModeSearchMatchClass]: colorMode === 'dark'
|
|
86
|
+
});
|
|
98
87
|
return Decoration.inline(start, end, {
|
|
99
88
|
class: className
|
|
100
89
|
});
|
|
@@ -134,8 +123,8 @@ export function findMatches({
|
|
|
134
123
|
matches.push({
|
|
135
124
|
start: pos + index,
|
|
136
125
|
end: pos + end,
|
|
137
|
-
canReplace:
|
|
138
|
-
nodeType:
|
|
126
|
+
canReplace: true,
|
|
127
|
+
nodeType: 'text'
|
|
139
128
|
});
|
|
140
129
|
index = text.indexOf(searchText, end);
|
|
141
130
|
}
|
|
@@ -205,83 +194,81 @@ export function findMatches({
|
|
|
205
194
|
} else {
|
|
206
195
|
collectTextMatch(textGrouping);
|
|
207
196
|
textGrouping = null;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
197
|
+
switch (node.type.name) {
|
|
198
|
+
case 'status':
|
|
199
|
+
collectNodeMatch({
|
|
200
|
+
text: node.attrs.text,
|
|
201
|
+
pos
|
|
202
|
+
}, node);
|
|
203
|
+
break;
|
|
204
|
+
case 'date':
|
|
205
|
+
collectNodeMatch({
|
|
206
|
+
text: timestampToString(node.attrs.timestamp, getIntl ? getIntl() : null),
|
|
207
|
+
pos
|
|
208
|
+
}, node);
|
|
209
|
+
break;
|
|
210
|
+
case 'expand':
|
|
211
|
+
case 'nestedExpand':
|
|
212
|
+
collectNodeMatch({
|
|
213
|
+
text: node.attrs.title,
|
|
214
|
+
pos
|
|
215
|
+
}, node);
|
|
216
|
+
break;
|
|
217
|
+
case 'mention':
|
|
218
|
+
let text;
|
|
219
|
+
if (node.attrs.text) {
|
|
220
|
+
text = node.attrs.text;
|
|
221
|
+
} else {
|
|
222
|
+
var _api$mention, _api$mention$sharedSt;
|
|
223
|
+
// the text may be sanitised from the node for privacy reasons
|
|
224
|
+
// so we need to use the mentionProvider to resolve it
|
|
225
|
+
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;
|
|
226
|
+
if (isResolvingMentionProvider(mentionProvider)) {
|
|
227
|
+
const nameDetail = mentionProvider.resolveMentionName(node.attrs.id);
|
|
228
|
+
if (isPromise(nameDetail)) {
|
|
229
|
+
text = '@...';
|
|
230
|
+
} else {
|
|
231
|
+
if (nameDetail.status === MentionNameStatus.OK) {
|
|
232
|
+
text = `@${nameDetail.name || ''}`;
|
|
242
233
|
} else {
|
|
243
|
-
|
|
244
|
-
text = `@${nameDetail.name || ''}`;
|
|
245
|
-
} else {
|
|
246
|
-
text = '@_|unknown|_';
|
|
247
|
-
}
|
|
234
|
+
text = '@_|unknown|_';
|
|
248
235
|
}
|
|
249
236
|
}
|
|
250
237
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
238
|
+
}
|
|
239
|
+
if (text) {
|
|
240
|
+
collectNodeMatch({
|
|
241
|
+
text,
|
|
242
|
+
pos
|
|
243
|
+
}, node);
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
case 'inlineCard':
|
|
247
|
+
case 'blockCard':
|
|
248
|
+
case 'embedCard':
|
|
249
|
+
collectCardTitleMatch(node, pos);
|
|
250
|
+
break;
|
|
251
|
+
case 'syncBlock':
|
|
252
|
+
{
|
|
253
|
+
if (editorExperiment('platform_synced_block', true)) {
|
|
254
|
+
var _api$syncedBlock, _api$syncedBlock$shar, _instance$data;
|
|
255
|
+
const syncBlockStore = api === null || api === void 0 ? void 0 : (_api$syncedBlock = api.syncedBlock) === null || _api$syncedBlock === void 0 ? void 0 : (_api$syncedBlock$shar = _api$syncedBlock.sharedState.currentState()) === null || _api$syncedBlock$shar === void 0 ? void 0 : _api$syncedBlock$shar.syncBlockStore;
|
|
256
|
+
const instance = syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.referenceManager.getFromCache(node.attrs.resourceId);
|
|
257
|
+
const adfContent = instance === null || instance === void 0 ? void 0 : (_instance$data = instance.data) === null || _instance$data === void 0 ? void 0 : _instance$data.content;
|
|
258
|
+
if (adfContent && adfContent.length > 0) {
|
|
259
|
+
const text = extractTextFromADFContent(adfContent);
|
|
260
|
+
if (text) {
|
|
261
|
+
collectNodeMatch({
|
|
262
|
+
text,
|
|
263
|
+
pos
|
|
264
|
+
}, node);
|
|
278
265
|
}
|
|
279
266
|
}
|
|
280
|
-
break;
|
|
281
267
|
}
|
|
282
|
-
default:
|
|
283
268
|
break;
|
|
284
|
-
|
|
269
|
+
}
|
|
270
|
+
default:
|
|
271
|
+
break;
|
|
285
272
|
}
|
|
286
273
|
}
|
|
287
274
|
});
|
package/dist/es2019/ui/Find.js
CHANGED
|
@@ -15,7 +15,6 @@ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
15
15
|
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
16
16
|
import { Label } from '@atlaskit/form';
|
|
17
17
|
import TextLetterCaseIcon from '@atlaskit/icon-lab/core/text-letter-case';
|
|
18
|
-
import MatchCaseIcon from '@atlaskit/icon/core/text-style';
|
|
19
18
|
import Textfield from '@atlaskit/textfield';
|
|
20
19
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
20
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
@@ -130,11 +129,9 @@ class Find extends React.Component {
|
|
|
130
129
|
}
|
|
131
130
|
});
|
|
132
131
|
_defineProperty(this, "matchCaseIconEle", iconProps => {
|
|
133
|
-
return
|
|
132
|
+
return jsx(TextLetterCaseIcon, {
|
|
134
133
|
label: iconProps.label,
|
|
135
134
|
size: "small"
|
|
136
|
-
}) : jsx(MatchCaseIcon, {
|
|
137
|
-
label: this.matchCase
|
|
138
135
|
});
|
|
139
136
|
});
|
|
140
137
|
const {
|
|
@@ -10,7 +10,6 @@ import React from 'react';
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports
|
|
11
11
|
import { jsx } from '@emotion/react';
|
|
12
12
|
import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
|
|
13
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
13
|
import Find from './Find';
|
|
15
14
|
import Replace from './Replace';
|
|
16
15
|
import { ruleStyles, wrapperPaddingStyles, wrapperStyles } from './ui-styles';
|
|
@@ -96,7 +95,7 @@ class FindReplace extends React.PureComponent {
|
|
|
96
95
|
css: ruleStyles,
|
|
97
96
|
id: "replace-hr-element"
|
|
98
97
|
}), jsx(Replace, {
|
|
99
|
-
canReplace:
|
|
98
|
+
canReplace: !!isReplaceable,
|
|
100
99
|
replaceText: replaceText,
|
|
101
100
|
onReplace: onReplace,
|
|
102
101
|
onReplaceAll: onReplaceAll,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useLayoutEffect, useState } from 'react';
|
|
2
2
|
import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
3
|
import { blur, toggleMatchCase } from '../pm-plugins/commands';
|
|
5
4
|
import { activateWithAnalytics, cancelSearchWithAnalytics, findNextWithAnalytics, findPrevWithAnalytics, findWithAnalytics, replaceAllWithAnalytics, replaceWithAnalytics } from '../pm-plugins/commands-with-analytics';
|
|
6
5
|
import FindReplaceDropdown from './FindReplaceDropdown';
|
|
@@ -141,10 +140,10 @@ const FindReplaceToolbarButtonWithState = ({
|
|
|
141
140
|
findText: findText,
|
|
142
141
|
index: index,
|
|
143
142
|
numMatches: matches.length,
|
|
144
|
-
isReplaceable:
|
|
145
|
-
numReplaceable:
|
|
143
|
+
isReplaceable: (_matches$index = matches[index]) === null || _matches$index === void 0 ? void 0 : _matches$index.canReplace,
|
|
144
|
+
numReplaceable:
|
|
146
145
|
// eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
|
|
147
|
-
matches.filter(match => match.canReplace === true).length
|
|
146
|
+
matches.filter(match => match.canReplace === true).length,
|
|
148
147
|
replaceText: replaceText,
|
|
149
148
|
shouldFocus: shouldFocus,
|
|
150
149
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -9,7 +9,6 @@ import ChevronUpIcon from '@atlaskit/icon/core/chevron-up';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
|
|
10
10
|
import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
|
|
11
11
|
import Textfield from '@atlaskit/textfield';
|
|
12
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
12
|
import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
|
|
14
13
|
|
|
15
14
|
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
@@ -24,13 +23,10 @@ const actionButtonContainerStyles = xcss({
|
|
|
24
23
|
paddingTop: 'space.200'
|
|
25
24
|
});
|
|
26
25
|
const actionButtonParentInlineStyles = xcss({
|
|
27
|
-
justifyContent: 'space-between',
|
|
28
|
-
flexDirection: 'row-reverse'
|
|
29
|
-
});
|
|
30
|
-
const actionButtonParentInlineStylesNew = xcss({
|
|
31
26
|
justifyContent: 'space-between',
|
|
32
27
|
flexDirection: 'row-reverse',
|
|
33
|
-
flexWrap: 'wrap'
|
|
28
|
+
flexWrap: 'wrap',
|
|
29
|
+
gap: 'space.075'
|
|
34
30
|
});
|
|
35
31
|
const actionButtonInlineStyles = xcss({
|
|
36
32
|
gap: 'space.075'
|
|
@@ -127,7 +123,7 @@ const Replace = ({
|
|
|
127
123
|
replaceText
|
|
128
124
|
});
|
|
129
125
|
setIsHelperMessageVisible(true);
|
|
130
|
-
if (count.totalReplaceable
|
|
126
|
+
if (count.totalReplaceable) {
|
|
131
127
|
triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
|
|
132
128
|
setReplaceCount(count.totalReplaceable);
|
|
133
129
|
} else {
|
|
@@ -197,7 +193,7 @@ const Replace = ({
|
|
|
197
193
|
resultsReplace.replace(SPACE_REGEX, '\u00a0') : resultsReplace)), /*#__PURE__*/React.createElement(Box, {
|
|
198
194
|
xcss: actionButtonContainerStyles
|
|
199
195
|
}, /*#__PURE__*/React.createElement(Inline, {
|
|
200
|
-
xcss:
|
|
196
|
+
xcss: actionButtonParentInlineStyles
|
|
201
197
|
}, /*#__PURE__*/React.createElement(Inline, {
|
|
202
198
|
xcss: actionButtonInlineStyles
|
|
203
199
|
}, /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
|
|
@@ -234,18 +230,14 @@ const Replace = ({
|
|
|
234
230
|
testId: replaceAll,
|
|
235
231
|
id: "replaceAll-button",
|
|
236
232
|
onClick: handleReplaceAllClick,
|
|
237
|
-
isDisabled:
|
|
238
|
-
}, replaceAll)),
|
|
233
|
+
isDisabled: count.totalReplaceable === 0
|
|
234
|
+
}, replaceAll)), /*#__PURE__*/React.createElement(Inline, {
|
|
239
235
|
xcss: closeButtonInlineStyles
|
|
240
236
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
241
237
|
appearance: "subtle",
|
|
242
238
|
testId: closeFindReplaceDialog,
|
|
243
239
|
onClick: clearSearch
|
|
244
|
-
}, closeFindReplaceDialog))
|
|
245
|
-
appearance: "subtle",
|
|
246
|
-
testId: closeFindReplaceDialog,
|
|
247
|
-
onClick: clearSearch
|
|
248
|
-
}, closeFindReplaceDialog))));
|
|
240
|
+
}, closeFindReplaceDialog)))));
|
|
249
241
|
};
|
|
250
242
|
|
|
251
243
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
3
|
import { FindReplaceActionTypes } from './actions';
|
|
5
4
|
import { createCommand, getPluginState } from './plugin-factory';
|
|
6
5
|
import { createDecoration, findClosestMatch, findDecorationFromMatch, findMatches, findSearchIndex, getSelectedText, getSelectionForMatch, nextIndex, prevIndex, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
|
|
@@ -27,7 +26,7 @@ export var activate = function activate() {
|
|
|
27
26
|
getIntl: getIntl,
|
|
28
27
|
api: api
|
|
29
28
|
});
|
|
30
|
-
index =
|
|
29
|
+
index = findClosestMatch(selection.from, matches);
|
|
31
30
|
}
|
|
32
31
|
return {
|
|
33
32
|
type: FindReplaceActionTypes.ACTIVATE,
|
|
@@ -51,7 +50,7 @@ export var find = function find(editorView, containerElement, keyword) {
|
|
|
51
50
|
getIntl: getIntl,
|
|
52
51
|
api: api
|
|
53
52
|
}) : [];
|
|
54
|
-
var index =
|
|
53
|
+
var index = findClosestMatch(selection.from, matches);
|
|
55
54
|
|
|
56
55
|
// we can't just apply all the decorations to highlight the search results at once
|
|
57
56
|
// as if there are a lot ProseMirror cries :'(
|
|
@@ -81,7 +80,7 @@ export var find = function find(editorView, containerElement, keyword) {
|
|
|
81
80
|
}) : [];
|
|
82
81
|
if (matches.length > 0) {
|
|
83
82
|
var _api$expand;
|
|
84
|
-
var index =
|
|
83
|
+
var index = findClosestMatch(selection.from, matches);
|
|
85
84
|
var newSelection = getSelectionForMatch(tr.selection, tr.doc, index, matches);
|
|
86
85
|
api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.commands.toggleExpandWithMatch(newSelection)({
|
|
87
86
|
tr: tr
|
|
@@ -188,7 +187,7 @@ export var replace = function replace(replaceText) {
|
|
|
188
187
|
index = _getPluginState6.index,
|
|
189
188
|
findText = _getPluginState6.findText;
|
|
190
189
|
if (matches[index]) {
|
|
191
|
-
if (!matches[index].canReplace
|
|
190
|
+
if (!matches[index].canReplace) {
|
|
192
191
|
return tr;
|
|
193
192
|
}
|
|
194
193
|
var _matches$index = matches[index],
|
|
@@ -210,7 +209,7 @@ export var replaceAll = function replaceAll(replaceText) {
|
|
|
210
209
|
}, function (tr, state) {
|
|
211
210
|
var pluginState = getPluginState(state);
|
|
212
211
|
pluginState.matches.forEach(function (match) {
|
|
213
|
-
if (!match.canReplace
|
|
212
|
+
if (!match.canReplace) {
|
|
214
213
|
return tr;
|
|
215
214
|
}
|
|
216
215
|
tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
|
|
@@ -4,11 +4,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
4
4
|
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; }
|
|
5
5
|
import { pluginFactory, stepHasSlice } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
7
|
import { initialState } from './main';
|
|
9
8
|
import { findReplacePluginKey } from './plugin-key';
|
|
10
9
|
import reducer from './reducer';
|
|
11
|
-
import { createDecorations, findClosestMatch, findDecorationFromMatch, findMatches,
|
|
10
|
+
import { createDecorations, findClosestMatch, findDecorationFromMatch, findMatches, findUniqueItemsIn, getSelectionForMatch, isMatchAffectedByStep, removeDecorationsFromSet, removeMatchesFromSet } from './utils';
|
|
12
11
|
var handleDocChanged = function handleDocChanged(tr, pluginState) {
|
|
13
12
|
var _api$expand;
|
|
14
13
|
var isActive = pluginState.isActive,
|
|
@@ -93,7 +92,7 @@ var handleDocChanged = function handleDocChanged(tr, pluginState) {
|
|
|
93
92
|
});
|
|
94
93
|
}
|
|
95
94
|
if (newIndex === undefined || newIndex === -1) {
|
|
96
|
-
newIndex =
|
|
95
|
+
newIndex = findClosestMatch(tr.selection.from, newMatches);
|
|
97
96
|
}
|
|
98
97
|
var newSelectedMatch = newMatches[newIndex];
|
|
99
98
|
decorationSet = removeMatchesFromSet(decorationSet, [selectedMatch, newSelectedMatch], tr.doc);
|
|
@@ -1,7 +1,6 @@
|
|
|
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 { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
4
|
import { FindReplaceActionTypes } from './actions';
|
|
6
5
|
var reducer = function reducer(getInitialState) {
|
|
7
6
|
return function (state, action) {
|
|
@@ -40,10 +39,10 @@ var reducer = function reducer(getInitialState) {
|
|
|
40
39
|
case FindReplaceActionTypes.CANCEL:
|
|
41
40
|
var getIntl = state.getIntl,
|
|
42
41
|
api = state.api;
|
|
43
|
-
return
|
|
42
|
+
return _objectSpread(_objectSpread({}, getInitialState()), {}, {
|
|
44
43
|
getIntl: getIntl,
|
|
45
44
|
api: api
|
|
46
|
-
})
|
|
45
|
+
});
|
|
47
46
|
case FindReplaceActionTypes.BLUR:
|
|
48
47
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
49
48
|
shouldFocus: false
|
|
@@ -2,7 +2,6 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
5
|
import { getPluginState } from '../plugin-factory';
|
|
7
6
|
import { createDecorations, findDecorationFromMatch } from './index';
|
|
8
7
|
|
|
@@ -243,7 +242,7 @@ var BatchDecorations = /*#__PURE__*/function () {
|
|
|
243
242
|
return {
|
|
244
243
|
viewportStartPos: viewportStartPos,
|
|
245
244
|
viewportEndPos: viewportEndPos,
|
|
246
|
-
startPos:
|
|
245
|
+
startPos: 0,
|
|
247
246
|
endPos: editorView.state.doc.nodeSize
|
|
248
247
|
};
|
|
249
248
|
}
|
|
@@ -254,11 +253,7 @@ var BatchDecorations = /*#__PURE__*/function () {
|
|
|
254
253
|
top: y,
|
|
255
254
|
left: x
|
|
256
255
|
});
|
|
257
|
-
|
|
258
|
-
return startPos ? startPos.pos : 0;
|
|
259
|
-
} else {
|
|
260
|
-
return startPos ? startPos.pos : 1;
|
|
261
|
-
}
|
|
256
|
+
return startPos ? startPos.pos : 0;
|
|
262
257
|
}
|
|
263
258
|
}, {
|
|
264
259
|
key: "getEndPos",
|