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