@atlaskit/editor-core 191.0.8 → 191.0.9

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.
Files changed (127) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/afm-cc/tsconfig.json +3 -3
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/presets/universal.js +2 -1
  5. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  6. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/plugins/index.js +0 -1
  9. package/dist/es2019/presets/universal.js +2 -1
  10. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  11. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  12. package/dist/es2019/version-wrapper.js +1 -1
  13. package/dist/esm/plugins/index.js +0 -1
  14. package/dist/esm/presets/universal.js +2 -1
  15. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  16. package/dist/esm/ui/ContentStyles/index.js +1 -1
  17. package/dist/esm/version-wrapper.js +1 -1
  18. package/dist/types/plugins/index.d.ts +0 -1
  19. package/dist/types/types/editor-props.d.ts +1 -1
  20. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  21. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  22. package/package.json +4 -8
  23. package/dist/cjs/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -166
  24. package/dist/cjs/plugins/find-replace/actions.js +0 -19
  25. package/dist/cjs/plugins/find-replace/commands-with-analytics.js +0 -101
  26. package/dist/cjs/plugins/find-replace/commands.js +0 -255
  27. package/dist/cjs/plugins/find-replace/index.js +0 -94
  28. package/dist/cjs/plugins/find-replace/keymap.js +0 -24
  29. package/dist/cjs/plugins/find-replace/plugin-key.js +0 -8
  30. package/dist/cjs/plugins/find-replace/plugin.js +0 -138
  31. package/dist/cjs/plugins/find-replace/reducer.js +0 -61
  32. package/dist/cjs/plugins/find-replace/styles.js +0 -16
  33. package/dist/cjs/plugins/find-replace/types.js +0 -5
  34. package/dist/cjs/plugins/find-replace/ui/Find.js +0 -308
  35. package/dist/cjs/plugins/find-replace/ui/FindReplace.js +0 -103
  36. package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -132
  37. package/dist/cjs/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -76
  38. package/dist/cjs/plugins/find-replace/ui/Replace.js +0 -174
  39. package/dist/cjs/plugins/find-replace/ui/styles.js +0 -44
  40. package/dist/cjs/plugins/find-replace/utils/batch-decorations.js +0 -310
  41. package/dist/cjs/plugins/find-replace/utils/commands.js +0 -16
  42. package/dist/cjs/plugins/find-replace/utils/index.js +0 -290
  43. package/dist/cjs/utils/array.js +0 -13
  44. package/dist/es2019/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -153
  45. package/dist/es2019/plugins/find-replace/actions.js +0 -13
  46. package/dist/es2019/plugins/find-replace/commands-with-analytics.js +0 -72
  47. package/dist/es2019/plugins/find-replace/commands.js +0 -240
  48. package/dist/es2019/plugins/find-replace/index.js +0 -89
  49. package/dist/es2019/plugins/find-replace/keymap.js +0 -16
  50. package/dist/es2019/plugins/find-replace/plugin-key.js +0 -2
  51. package/dist/es2019/plugins/find-replace/plugin.js +0 -117
  52. package/dist/es2019/plugins/find-replace/reducer.js +0 -56
  53. package/dist/es2019/plugins/find-replace/styles.js +0 -17
  54. package/dist/es2019/plugins/find-replace/types.js +0 -1
  55. package/dist/es2019/plugins/find-replace/ui/Find.js +0 -284
  56. package/dist/es2019/plugins/find-replace/ui/FindReplace.js +0 -78
  57. package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -122
  58. package/dist/es2019/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -50
  59. package/dist/es2019/plugins/find-replace/ui/Replace.js +0 -152
  60. package/dist/es2019/plugins/find-replace/ui/styles.js +0 -48
  61. package/dist/es2019/plugins/find-replace/utils/batch-decorations.js +0 -189
  62. package/dist/es2019/plugins/find-replace/utils/commands.js +0 -6
  63. package/dist/es2019/plugins/find-replace/utils/index.js +0 -249
  64. package/dist/es2019/utils/array.js +0 -3
  65. package/dist/esm/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -157
  66. package/dist/esm/plugins/find-replace/actions.js +0 -13
  67. package/dist/esm/plugins/find-replace/commands-with-analytics.js +0 -95
  68. package/dist/esm/plugins/find-replace/commands.js +0 -248
  69. package/dist/esm/plugins/find-replace/index.js +0 -87
  70. package/dist/esm/plugins/find-replace/keymap.js +0 -18
  71. package/dist/esm/plugins/find-replace/plugin-key.js +0 -2
  72. package/dist/esm/plugins/find-replace/plugin.js +0 -133
  73. package/dist/esm/plugins/find-replace/reducer.js +0 -54
  74. package/dist/esm/plugins/find-replace/styles.js +0 -10
  75. package/dist/esm/plugins/find-replace/types.js +0 -1
  76. package/dist/esm/plugins/find-replace/ui/Find.js +0 -302
  77. package/dist/esm/plugins/find-replace/ui/FindReplace.js +0 -97
  78. package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -126
  79. package/dist/esm/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -69
  80. package/dist/esm/plugins/find-replace/ui/Replace.js +0 -168
  81. package/dist/esm/plugins/find-replace/ui/styles.js +0 -37
  82. package/dist/esm/plugins/find-replace/utils/batch-decorations.js +0 -304
  83. package/dist/esm/plugins/find-replace/utils/commands.js +0 -10
  84. package/dist/esm/plugins/find-replace/utils/index.js +0 -280
  85. package/dist/esm/utils/array.js +0 -7
  86. package/dist/types/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +0 -4
  87. package/dist/types/plugins/find-replace/actions.d.ts +0 -64
  88. package/dist/types/plugins/find-replace/commands-with-analytics.d.ts +0 -27
  89. package/dist/types/plugins/find-replace/commands.d.ts +0 -12
  90. package/dist/types/plugins/find-replace/index.d.ts +0 -3
  91. package/dist/types/plugins/find-replace/keymap.d.ts +0 -4
  92. package/dist/types/plugins/find-replace/plugin-key.d.ts +0 -3
  93. package/dist/types/plugins/find-replace/plugin.d.ts +0 -6
  94. package/dist/types/plugins/find-replace/reducer.d.ts +0 -4
  95. package/dist/types/plugins/find-replace/styles.d.ts +0 -3
  96. package/dist/types/plugins/find-replace/types.d.ts +0 -79
  97. package/dist/types/plugins/find-replace/ui/Find.d.ts +0 -71
  98. package/dist/types/plugins/find-replace/ui/FindReplace.d.ts +0 -43
  99. package/dist/types/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +0 -21
  100. package/dist/types/plugins/find-replace/ui/FindReplaceTooltipButton.d.ts +0 -18
  101. package/dist/types/plugins/find-replace/ui/Replace.d.ts +0 -27
  102. package/dist/types/plugins/find-replace/ui/styles.d.ts +0 -6
  103. package/dist/types/plugins/find-replace/utils/batch-decorations.d.ts +0 -36
  104. package/dist/types/plugins/find-replace/utils/commands.d.ts +0 -2
  105. package/dist/types/plugins/find-replace/utils/index.d.ts +0 -49
  106. package/dist/types/utils/array.d.ts +0 -1
  107. package/dist/types-ts4.5/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +0 -4
  108. package/dist/types-ts4.5/plugins/find-replace/actions.d.ts +0 -64
  109. package/dist/types-ts4.5/plugins/find-replace/commands-with-analytics.d.ts +0 -27
  110. package/dist/types-ts4.5/plugins/find-replace/commands.d.ts +0 -12
  111. package/dist/types-ts4.5/plugins/find-replace/index.d.ts +0 -3
  112. package/dist/types-ts4.5/plugins/find-replace/keymap.d.ts +0 -4
  113. package/dist/types-ts4.5/plugins/find-replace/plugin-key.d.ts +0 -3
  114. package/dist/types-ts4.5/plugins/find-replace/plugin.d.ts +0 -6
  115. package/dist/types-ts4.5/plugins/find-replace/reducer.d.ts +0 -4
  116. package/dist/types-ts4.5/plugins/find-replace/styles.d.ts +0 -3
  117. package/dist/types-ts4.5/plugins/find-replace/types.d.ts +0 -79
  118. package/dist/types-ts4.5/plugins/find-replace/ui/Find.d.ts +0 -71
  119. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplace.d.ts +0 -43
  120. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +0 -21
  121. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceTooltipButton.d.ts +0 -18
  122. package/dist/types-ts4.5/plugins/find-replace/ui/Replace.d.ts +0 -27
  123. package/dist/types-ts4.5/plugins/find-replace/ui/styles.d.ts +0 -6
  124. package/dist/types-ts4.5/plugins/find-replace/utils/batch-decorations.d.ts +0 -36
  125. package/dist/types-ts4.5/plugins/find-replace/utils/commands.d.ts +0 -2
  126. package/dist/types-ts4.5/plugins/find-replace/utils/index.d.ts +0 -49
  127. package/dist/types-ts4.5/utils/array.d.ts +0 -1
@@ -1,284 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
- import React from 'react';
4
- import { jsx } from '@emotion/react';
5
- import { defineMessages, injectIntl } from 'react-intl-next';
6
- import debounce from 'lodash/debounce';
7
- import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
8
- import ChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
9
- import ChevronUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-up';
10
- import MatchCaseIcon from '@atlaskit/icon/glyph/emoji/keyboard';
11
- import Textfield from '@atlaskit/textfield';
12
- import { countStyles, countWrapperStyles, sectionWrapperStyles } from './styles';
13
- import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
14
- import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
15
- import rafSchd from 'raf-schd';
16
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
17
- export const FIND_DEBOUNCE_MS = 100;
18
- const messages = defineMessages({
19
- find: {
20
- id: 'fabric.editor.find',
21
- defaultMessage: 'Find',
22
- description: 'The word or phrase to search for on the document'
23
- },
24
- matchCase: {
25
- id: 'fabric.editor.matchCase',
26
- defaultMessage: 'Match case',
27
- description: 'Toggle whether should also match case when searching for text'
28
- },
29
- findNext: {
30
- id: 'fabric.editor.findNext',
31
- defaultMessage: 'Find next',
32
- description: 'Locate the next occurrence of the word or phrase that was searched for'
33
- },
34
- findPrevious: {
35
- id: 'fabric.editor.findPrevious',
36
- defaultMessage: 'Find previous',
37
- description: 'Locate the previous occurrence of the word or phrase that was searched for'
38
- },
39
- closeFindReplaceDialog: {
40
- id: 'fabric.editor.closeFindReplaceDialog',
41
- defaultMessage: 'Close',
42
- description: 'Cancel search and close the "Find and Replace" dialog'
43
- },
44
- noResultsFound: {
45
- id: 'fabric.editor.noResultsFound',
46
- defaultMessage: 'No results',
47
- description: 'No matches were found for the word or phrase that was searched for'
48
- },
49
- resultsCount: {
50
- id: 'fabric.editor.resultsCount',
51
- description: 'Text for selected search match position and total results count',
52
- defaultMessage: '{selectedMatchPosition} of {totalResultsCount}'
53
- }
54
- });
55
- class Find extends React.Component {
56
- constructor(props) {
57
- super(props);
58
- _defineProperty(this, "findTextfieldRef", /*#__PURE__*/React.createRef());
59
- _defineProperty(this, "isComposing", false);
60
- _defineProperty(this, "syncFindText", onSynced => {
61
- var _this$state;
62
- // If the external prop findText changes and we aren't in a composition we should update to
63
- // use the external prop value.
64
- //
65
- // An example of where this may happen is when a find occurs through the user selecting some text
66
- // and pressing Mod-f.
67
- if (!this.isComposing && this.props.findText !== ((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.localFindText)) {
68
- this.updateFindValue(this.props.findText || '', onSynced);
69
- }
70
- });
71
- _defineProperty(this, "focusFindTextfield", () => {
72
- const input = this.findTextfieldRef.current;
73
- if (this.props.shouldFocus && input) {
74
- input.select();
75
- }
76
- });
77
- _defineProperty(this, "handleFindChange", event => {
78
- this.updateFindValue(event.target.value);
79
- });
80
- // debounce (vs throttle) to not block typing inside find input while onFind runs
81
- _defineProperty(this, "debouncedFind", debounce(value => {
82
- this.props.onFind(value);
83
- }, FIND_DEBOUNCE_MS));
84
- _defineProperty(this, "updateFindValue", (value, onSynced) => {
85
- this.setState({
86
- localFindText: value
87
- }, () => {
88
- if (this.isComposing) {
89
- return;
90
- }
91
- onSynced && onSynced();
92
- this.debouncedFind(value);
93
- });
94
- });
95
- // throtlle between animation frames gives better experience on Enter compared to arbitrary value
96
- // it adjusts based on performance (and document size)
97
- _defineProperty(this, "handleFindKeyDownThrottled", rafSchd(event => {
98
- if (event.key === 'Enter') {
99
- if (event.shiftKey) {
100
- this.props.onFindPrev({
101
- triggerMethod: TRIGGER_METHOD.KEYBOARD
102
- });
103
- } else {
104
- this.props.onFindNext({
105
- triggerMethod: TRIGGER_METHOD.KEYBOARD
106
- });
107
- }
108
- } else if (event.key === 'ArrowDown') {
109
- // we want to move focus between find & replace texfields when user hits up/down arrows
110
- this.props.onArrowDown();
111
- }
112
- }));
113
- _defineProperty(this, "handleFindKeyDown", event => {
114
- if (this.isComposing) {
115
- return;
116
- }
117
- event.persist();
118
- this.handleFindKeyDownThrottled(event);
119
- });
120
- _defineProperty(this, "handleFindKeyUp", () => {
121
- this.handleFindKeyDownThrottled.cancel();
122
- });
123
- _defineProperty(this, "handleFindNextClick", ref => {
124
- if (this.isComposing) {
125
- return;
126
- }
127
- this.props.onFindNext({
128
- triggerMethod: TRIGGER_METHOD.BUTTON
129
- });
130
- });
131
- _defineProperty(this, "handleFindPrevClick", ref => {
132
- if (this.isComposing) {
133
- return;
134
- }
135
- this.props.onFindPrev({
136
- triggerMethod: TRIGGER_METHOD.BUTTON
137
- });
138
- });
139
- _defineProperty(this, "handleCompositionStart", () => {
140
- this.isComposing = true;
141
- });
142
- _defineProperty(this, "handleCompositionEnd", event => {
143
- this.isComposing = false;
144
- // type for React.CompositionEvent doesn't set type for target correctly
145
- this.updateFindValue(event.target.value);
146
- });
147
- _defineProperty(this, "clearSearch", () => {
148
- this.props.onCancel({
149
- triggerMethod: TRIGGER_METHOD.BUTTON
150
- });
151
- });
152
- _defineProperty(this, "handleMatchCaseClick", buttonRef => {
153
- if (this.props.allowMatchCase && this.props.onToggleMatchCase) {
154
- this.props.onToggleMatchCase();
155
- this.props.onFind(this.props.findText);
156
- }
157
- });
158
- const {
159
- intl: {
160
- formatMessage
161
- }
162
- } = props;
163
- this.find = formatMessage(messages.find);
164
- this.closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
165
- this.noResultsFound = formatMessage(messages.noResultsFound);
166
- this.findNext = formatMessage(messages.findNext);
167
- this.findPrevious = formatMessage(messages.findPrevious);
168
- this.matchCase = formatMessage(messages.matchCase);
169
- this.matchCaseIcon = jsx(MatchCaseIcon, {
170
- label: this.matchCase
171
- });
172
- this.findNextIcon = jsx(ChevronDownIcon, {
173
- label: this.findNext
174
- });
175
- this.findPrevIcon = jsx(ChevronUpIcon, {
176
- label: this.findPrevious
177
- });
178
- this.closeIcon = jsx(EditorCloseIcon, {
179
- label: this.closeFindReplaceDialog
180
- });
181
-
182
- // We locally manage the value of the input inside this component in order to support compositions.
183
- // This requires some additional work inside componentDidUpdate to ensure we support changes that
184
- // occur to this value which do not originate from this component.
185
- this.state = {
186
- localFindText: ''
187
- };
188
- }
189
- componentDidMount() {
190
- this.props.onFindTextfieldRefSet(this.findTextfieldRef);
191
-
192
- // focus initially on dialog mount if there is no find text provided
193
- if (!this.props.findText) {
194
- this.focusFindTextfield();
195
- }
196
- this.syncFindText(() => {
197
- // focus after input is synced if find text provided
198
- if (this.props.findText) {
199
- this.focusFindTextfield();
200
- }
201
- });
202
- }
203
- componentDidUpdate(prevProps) {
204
- // focus on update if find text did not change
205
- if (!getBooleanFF('platform.editor.a11y-find-replace')) {
206
- var _this$state2;
207
- if (this.props.findText === ((_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : _this$state2.localFindText)) {
208
- this.focusFindTextfield();
209
- }
210
- if (this.props.findText !== prevProps.findText) {
211
- this.syncFindText(() => {
212
- // focus after input is synced if find text provided
213
- if (this.props.findText) {
214
- this.focusFindTextfield();
215
- }
216
- });
217
- }
218
- }
219
- }
220
- componentWillUnmount() {
221
- this.debouncedFind.cancel();
222
- this.handleFindKeyDownThrottled.cancel();
223
- }
224
- render() {
225
- const {
226
- findText,
227
- count,
228
- allowMatchCase,
229
- shouldMatchCase,
230
- intl: {
231
- formatMessage
232
- }
233
- } = this.props;
234
- const resultsCount = formatMessage(messages.resultsCount, {
235
- selectedMatchPosition: count.index + 1,
236
- totalResultsCount: count.total
237
- });
238
- return jsx("div", {
239
- css: sectionWrapperStyles
240
- }, jsx(Textfield, {
241
- name: "find",
242
- appearance: "none",
243
- placeholder: this.find,
244
- value: this.state.localFindText,
245
- ref: this.findTextfieldRef,
246
- autoComplete: "off",
247
- onChange: this.handleFindChange,
248
- onKeyDown: this.handleFindKeyDown,
249
- onKeyUp: this.handleFindKeyUp,
250
- onBlur: this.props.onFindBlur,
251
- onCompositionStart: this.handleCompositionStart,
252
- onCompositionEnd: this.handleCompositionEnd
253
- }), jsx("div", {
254
- css: countWrapperStyles,
255
- "aria-live": "polite"
256
- }, findText && jsx("span", {
257
- "data-testid": "textfield-count",
258
- css: countStyles
259
- }, count.total === 0 ? this.noResultsFound : resultsCount)), allowMatchCase && jsx(FindReplaceTooltipButton, {
260
- title: this.matchCase,
261
- icon: this.matchCaseIcon,
262
- onClick: this.handleMatchCaseClick,
263
- isPressed: shouldMatchCase
264
- }), jsx(FindReplaceTooltipButton, {
265
- title: this.findNext,
266
- icon: this.findNextIcon,
267
- keymapDescription: 'Enter',
268
- onClick: this.handleFindNextClick,
269
- disabled: count.total <= 1
270
- }), jsx(FindReplaceTooltipButton, {
271
- title: this.findPrevious,
272
- icon: this.findPrevIcon,
273
- keymapDescription: 'Shift Enter',
274
- onClick: this.handleFindPrevClick,
275
- disabled: count.total <= 1
276
- }), jsx(FindReplaceTooltipButton, {
277
- title: this.closeFindReplaceDialog,
278
- icon: this.closeIcon,
279
- keymapDescription: 'Escape',
280
- onClick: this.clearSearch
281
- }));
282
- }
283
- }
284
- export default injectIntl(Find);
@@ -1,78 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
- import React from 'react';
4
- import { jsx } from '@emotion/react';
5
- import Find from './Find';
6
- import Replace from './Replace';
7
- import { ruleStyles, wrapperStyles } from './styles';
8
- class FindReplace extends React.PureComponent {
9
- constructor(...args) {
10
- super(...args);
11
- _defineProperty(this, "findTextfield", null);
12
- _defineProperty(this, "replaceTextfield", null);
13
- _defineProperty(this, "setFindTextfieldRef", findTextfieldRef => {
14
- this.findTextfield = findTextfieldRef.current;
15
- });
16
- _defineProperty(this, "setReplaceTextfieldRef", replaceTextfieldRef => {
17
- this.replaceTextfield = replaceTextfieldRef.current;
18
- });
19
- _defineProperty(this, "setFocusToFind", () => {
20
- if (this.findTextfield) {
21
- this.findTextfield.focus();
22
- }
23
- });
24
- _defineProperty(this, "setFocusToReplace", () => {
25
- if (this.replaceTextfield) {
26
- this.replaceTextfield.focus();
27
- }
28
- });
29
- }
30
- render() {
31
- const {
32
- findText,
33
- count,
34
- shouldFocus,
35
- onFind,
36
- onFindBlur,
37
- onFindNext,
38
- onFindPrev,
39
- onCancel,
40
- replaceText,
41
- onReplace,
42
- onReplaceAll,
43
- dispatchAnalyticsEvent,
44
- allowMatchCase,
45
- shouldMatchCase,
46
- onToggleMatchCase
47
- } = this.props;
48
- return jsx("div", {
49
- css: wrapperStyles
50
- }, jsx(Find, {
51
- allowMatchCase: allowMatchCase,
52
- shouldMatchCase: shouldMatchCase,
53
- onToggleMatchCase: onToggleMatchCase,
54
- findText: findText,
55
- count: count,
56
- shouldFocus: shouldFocus,
57
- onFind: onFind,
58
- onFindBlur: onFindBlur,
59
- onFindPrev: onFindPrev,
60
- onFindNext: onFindNext,
61
- onFindTextfieldRefSet: this.setFindTextfieldRef,
62
- onCancel: onCancel,
63
- onArrowDown: this.setFocusToReplace
64
- }), jsx("hr", {
65
- css: ruleStyles,
66
- id: "replace-hr-element"
67
- }), jsx(Replace, {
68
- canReplace: count.total > 0,
69
- replaceText: replaceText,
70
- onReplace: onReplace,
71
- onReplaceAll: onReplaceAll,
72
- onReplaceTextfieldRefSet: this.setReplaceTextfieldRef,
73
- onArrowUp: this.setFocusToFind,
74
- dispatchAnalyticsEvent: dispatchAnalyticsEvent
75
- }));
76
- }
77
- }
78
- export default FindReplace;
@@ -1,122 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- /** @jsx jsx */
4
- import React from 'react';
5
- import { css, jsx } from '@emotion/react';
6
- import { defineMessages, injectIntl } from 'react-intl-next';
7
- import { akEditorFloatingPanelZIndex, akEditorMobileMaxWidth } from '@atlaskit/editor-shared-styles';
8
- import { ToolbarButton, TOOLBAR_BUTTON } from '@atlaskit/editor-common/ui-menu';
9
- import { Dropdown, ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
10
- import EditorSearchIcon from '@atlaskit/icon/glyph/editor/search';
11
- import FindReplace from './FindReplace';
12
- import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
13
- import { ToolTipContent, findKeymapByDescription, tooltip } from '../../../keymaps';
14
- import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
15
- const toolbarButtonWrapper = css`
16
- display: flex;
17
- flex: 1 1 auto;
18
- flex-grow: 0;
19
- justify-content: flex-end;
20
- align-items: center;
21
- padding: 0 ${"var(--ds-space-100, 8px)"};
22
- @media (max-width: ${akEditorMobileMaxWidth}px) {
23
- justify-content: center;
24
- padding: 0;
25
- }
26
- `;
27
- const toolbarButtonWrapperFullWith = css`
28
- flex-grow: 1;
29
- `;
30
- const wrapper = css`
31
- display: flex;
32
- flex-direction: column;
33
- `;
34
- const messages = defineMessages({
35
- findReplaceToolbarButton: {
36
- id: 'fabric.editor.findReplaceToolbarButton',
37
- defaultMessage: 'Find and replace',
38
- description: '"Find" highlights all instances of a word or phrase on the document, and "Replace" changes one or all of those instances to something else'
39
- }
40
- });
41
- class FindReplaceToolbarButton extends React.PureComponent {
42
- constructor(...args) {
43
- super(...args);
44
- _defineProperty(this, "toggleOpen", () => {
45
- if (this.props.isActive) {
46
- this.props.onCancel({
47
- triggerMethod: TRIGGER_METHOD.TOOLBAR
48
- });
49
- } else {
50
- this.props.onActivate();
51
- }
52
- });
53
- }
54
- render() {
55
- const {
56
- popupsMountPoint,
57
- popupsBoundariesElement,
58
- popupsScrollableElement,
59
- isReducedSpacing,
60
- findText,
61
- replaceText,
62
- isActive,
63
- index,
64
- numMatches,
65
- intl: {
66
- formatMessage
67
- },
68
- takeFullWidth
69
- } = this.props;
70
- const title = formatMessage(messages.findReplaceToolbarButton);
71
- const stackBelowOtherEditorFloatingPanels = akEditorFloatingPanelZIndex - 1;
72
- const keymap = findKeymapByDescription('Find');
73
- return jsx("div", {
74
- css: [toolbarButtonWrapper, takeFullWidth && toolbarButtonWrapperFullWith]
75
- }, jsx(Dropdown, {
76
- mountTo: popupsMountPoint,
77
- boundariesElement: popupsBoundariesElement,
78
- scrollableElement: popupsScrollableElement,
79
- isOpen: isActive,
80
- handleEscapeKeydown: () => {
81
- if (isActive) {
82
- this.props.onCancel({
83
- triggerMethod: TRIGGER_METHOD.KEYBOARD
84
- });
85
- }
86
- },
87
- fitWidth: 352,
88
- zIndex: stackBelowOtherEditorFloatingPanels,
89
- arrowKeyNavigationProviderOptions: {
90
- type: ArrowKeyNavigationType.MENU,
91
- disableArrowKeyNavigation: true
92
- },
93
- trigger: jsx(ToolbarButton, {
94
- buttonId: TOOLBAR_BUTTON.FIND_REPLACE,
95
- spacing: isReducedSpacing ? 'none' : 'default',
96
- selected: isActive,
97
- title: jsx(ToolTipContent, {
98
- description: title,
99
- keymap: keymap
100
- }),
101
- iconBefore: jsx(EditorSearchIcon, {
102
- label: title
103
- }),
104
- onClick: this.toggleOpen,
105
- "aria-expanded": isActive,
106
- "aria-haspopup": true,
107
- "aria-label": keymap ? tooltip(keymap, title) : title,
108
- "aria-keyshortcuts": getAriaKeyshortcuts(keymap)
109
- })
110
- }, jsx("div", {
111
- css: wrapper
112
- }, jsx(FindReplace, _extends({
113
- findText: findText,
114
- replaceText: replaceText,
115
- count: {
116
- index,
117
- total: numMatches
118
- }
119
- }, this.props)))));
120
- }
121
- }
122
- export default injectIntl(FindReplaceToolbarButton);
@@ -1,50 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import React from 'react';
4
- import Tooltip from '@atlaskit/tooltip';
5
- import { ToolTipContent, findKeymapByDescription } from '@atlaskit/editor-common/keymaps';
6
- import Button from '@atlaskit/button/standard-button';
7
- export class FindReplaceTooltipButton extends React.PureComponent {
8
- constructor(...args) {
9
- super(...args);
10
- _defineProperty(this, "buttonRef", /*#__PURE__*/React.createRef());
11
- _defineProperty(this, "handleClick", () => {
12
- this.props.onClick(this.buttonRef);
13
- });
14
- }
15
- render() {
16
- const {
17
- title,
18
- icon,
19
- keymapDescription,
20
- disabled,
21
- isPressed
22
- } = this.props;
23
- const pressedProps = {
24
- ...(typeof isPressed === 'boolean' && {
25
- 'aria-pressed': isPressed
26
- })
27
- };
28
- return /*#__PURE__*/React.createElement(Tooltip, {
29
- content: /*#__PURE__*/React.createElement(ToolTipContent, {
30
- description: title,
31
- keymap: findKeymapByDescription(keymapDescription)
32
- }),
33
- hideTooltipOnClick: true,
34
- position: 'top'
35
- }, /*#__PURE__*/React.createElement(Button, _extends({
36
- label: title,
37
- appearance: "subtle",
38
- testId: title,
39
- ref: this.buttonRef,
40
- iconBefore: icon,
41
- isDisabled: disabled,
42
- onClick: this.handleClick,
43
- isSelected: isPressed,
44
- shouldFitContainer: true
45
- }, pressedProps)));
46
- }
47
- }
48
- _defineProperty(FindReplaceTooltipButton, "defaultProps", {
49
- keymapDescription: 'no-keymap'
50
- });
@@ -1,152 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /** @jsx jsx */
3
- import React from 'react';
4
- import { jsx } from '@emotion/react';
5
- import Button from '@atlaskit/button/standard-button';
6
- import { defineMessages, injectIntl } from 'react-intl-next';
7
- import Textfield from '@atlaskit/textfield';
8
- import { sectionWrapperStyles, replaceSectionButtonStyles } from './styles';
9
- import { EVENT_TYPE, ACTION, ACTION_SUBJECT, TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
10
- const messages = defineMessages({
11
- replaceWith: {
12
- id: 'fabric.editor.replaceWith',
13
- defaultMessage: 'Replace with',
14
- description: 'The value that will replace the word or phrase that was searched for'
15
- },
16
- replace: {
17
- id: 'fabric.editor.replace',
18
- defaultMessage: 'Replace',
19
- description: 'Replace only the currently selected instance of the word or phrase'
20
- },
21
- replaceAll: {
22
- id: 'fabric.editor.replaceAll',
23
- defaultMessage: 'Replace all',
24
- description: 'Replace all instances of the word or phrase throughout the entire document'
25
- }
26
- });
27
- class Replace extends React.PureComponent {
28
- constructor(props) {
29
- super(props);
30
- _defineProperty(this, "replaceTextfieldRef", /*#__PURE__*/React.createRef());
31
- _defineProperty(this, "skipWhileComposing", fn => {
32
- if (this.state.isComposing) {
33
- return;
34
- }
35
- fn();
36
- });
37
- _defineProperty(this, "handleReplaceClick", () => this.skipWhileComposing(() => {
38
- this.props.onReplace({
39
- triggerMethod: TRIGGER_METHOD.BUTTON,
40
- replaceText: this.state.replaceText
41
- });
42
- }));
43
- _defineProperty(this, "handleReplaceChange", event => this.skipWhileComposing(() => {
44
- this.updateReplaceValue(event.target.value);
45
- }));
46
- _defineProperty(this, "updateReplaceValue", replaceText => {
47
- const {
48
- dispatchAnalyticsEvent
49
- } = this.props;
50
- if (dispatchAnalyticsEvent) {
51
- dispatchAnalyticsEvent({
52
- eventType: EVENT_TYPE.TRACK,
53
- action: ACTION.CHANGED_REPLACEMENT_TEXT,
54
- actionSubject: ACTION_SUBJECT.FIND_REPLACE_DIALOG
55
- });
56
- }
57
- this.setState({
58
- replaceText
59
- });
60
- });
61
- _defineProperty(this, "handleReplaceKeyDown", event => this.skipWhileComposing(() => {
62
- if (event.key === 'Enter') {
63
- this.props.onReplace({
64
- triggerMethod: TRIGGER_METHOD.KEYBOARD,
65
- replaceText: this.state.replaceText
66
- });
67
- } else if (event.key === 'ArrowUp') {
68
- // we want to move focus between find & replace texfields when user hits up/down arrows
69
- this.props.onArrowUp();
70
- }
71
- }));
72
- _defineProperty(this, "handleReplaceAllClick", () => this.skipWhileComposing(() => {
73
- this.props.onReplaceAll({
74
- replaceText: this.state.replaceText
75
- });
76
- }));
77
- _defineProperty(this, "handleCompositionStart", () => {
78
- this.setState({
79
- isComposing: true
80
- });
81
- });
82
- _defineProperty(this, "handleCompositionEnd", event => {
83
- this.setState({
84
- isComposing: false
85
- });
86
- // type for React.CompositionEvent doesn't set type for target correctly
87
- this.updateReplaceValue(event.target.value);
88
- });
89
- const {
90
- replaceText: _replaceText,
91
- intl: {
92
- formatMessage
93
- }
94
- } = props;
95
- this.state = {
96
- replaceText: _replaceText || '',
97
- isComposing: false
98
- };
99
- this.replaceWith = formatMessage(messages.replaceWith);
100
- this.replace = formatMessage(messages.replace);
101
- this.replaceAll = formatMessage(messages.replaceAll);
102
- }
103
- componentDidMount() {
104
- this.props.onReplaceTextfieldRefSet(this.replaceTextfieldRef);
105
- }
106
- componentDidUpdate({
107
- replaceText: prevReplaceText
108
- }) {
109
- const {
110
- replaceText
111
- } = this.props;
112
- if (replaceText && replaceText !== prevReplaceText) {
113
- this.setState({
114
- replaceText,
115
- isComposing: false
116
- });
117
- }
118
- }
119
- render() {
120
- const {
121
- replaceText
122
- } = this.state;
123
- const {
124
- canReplace
125
- } = this.props;
126
- return jsx("div", {
127
- css: sectionWrapperStyles
128
- }, jsx(Textfield, {
129
- name: "replace",
130
- appearance: "none",
131
- placeholder: this.replaceWith,
132
- defaultValue: replaceText,
133
- ref: this.replaceTextfieldRef,
134
- autoComplete: "off",
135
- onChange: this.handleReplaceChange,
136
- onKeyDown: this.handleReplaceKeyDown,
137
- onCompositionStart: this.handleCompositionStart,
138
- onCompositionEnd: this.handleCompositionEnd
139
- }), jsx(Button, {
140
- css: replaceSectionButtonStyles,
141
- testId: this.replace,
142
- onClick: this.handleReplaceClick,
143
- isDisabled: !canReplace
144
- }, this.replace), jsx(Button, {
145
- css: replaceSectionButtonStyles,
146
- testId: this.replaceAll,
147
- onClick: this.handleReplaceAllClick,
148
- isDisabled: !canReplace
149
- }, this.replaceAll));
150
- }
151
- }
152
- export default injectIntl(Replace);