@atlaskit/editor-core 191.0.8 → 191.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +13 -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/Comment/Comment.js +6 -3
  6. package/dist/cjs/ui/Appearance/Comment/Toolbar.js +19 -6
  7. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  8. package/dist/cjs/ui/ContentStyles/index.js +1 -1
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/plugins/index.js +0 -1
  11. package/dist/es2019/presets/universal.js +2 -1
  12. package/dist/es2019/ui/Appearance/Comment/Comment.js +6 -3
  13. package/dist/es2019/ui/Appearance/Comment/Toolbar.js +38 -6
  14. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  15. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  16. package/dist/es2019/version-wrapper.js +1 -1
  17. package/dist/esm/plugins/index.js +0 -1
  18. package/dist/esm/presets/universal.js +2 -1
  19. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -3
  20. package/dist/esm/ui/Appearance/Comment/Toolbar.js +19 -6
  21. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +1 -1
  22. package/dist/esm/ui/ContentStyles/index.js +1 -1
  23. package/dist/esm/version-wrapper.js +1 -1
  24. package/dist/types/plugins/index.d.ts +0 -1
  25. package/dist/types/types/editor-props.d.ts +1 -1
  26. package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +2 -1
  27. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  28. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  29. package/dist/types-ts4.5/ui/Appearance/Comment/Toolbar.d.ts +2 -1
  30. package/package.json +6 -10
  31. package/dist/cjs/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -166
  32. package/dist/cjs/plugins/find-replace/actions.js +0 -19
  33. package/dist/cjs/plugins/find-replace/commands-with-analytics.js +0 -101
  34. package/dist/cjs/plugins/find-replace/commands.js +0 -255
  35. package/dist/cjs/plugins/find-replace/index.js +0 -94
  36. package/dist/cjs/plugins/find-replace/keymap.js +0 -24
  37. package/dist/cjs/plugins/find-replace/plugin-key.js +0 -8
  38. package/dist/cjs/plugins/find-replace/plugin.js +0 -138
  39. package/dist/cjs/plugins/find-replace/reducer.js +0 -61
  40. package/dist/cjs/plugins/find-replace/styles.js +0 -16
  41. package/dist/cjs/plugins/find-replace/types.js +0 -5
  42. package/dist/cjs/plugins/find-replace/ui/Find.js +0 -308
  43. package/dist/cjs/plugins/find-replace/ui/FindReplace.js +0 -103
  44. package/dist/cjs/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -132
  45. package/dist/cjs/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -76
  46. package/dist/cjs/plugins/find-replace/ui/Replace.js +0 -174
  47. package/dist/cjs/plugins/find-replace/ui/styles.js +0 -44
  48. package/dist/cjs/plugins/find-replace/utils/batch-decorations.js +0 -310
  49. package/dist/cjs/plugins/find-replace/utils/commands.js +0 -16
  50. package/dist/cjs/plugins/find-replace/utils/index.js +0 -290
  51. package/dist/cjs/utils/array.js +0 -13
  52. package/dist/es2019/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -153
  53. package/dist/es2019/plugins/find-replace/actions.js +0 -13
  54. package/dist/es2019/plugins/find-replace/commands-with-analytics.js +0 -72
  55. package/dist/es2019/plugins/find-replace/commands.js +0 -240
  56. package/dist/es2019/plugins/find-replace/index.js +0 -89
  57. package/dist/es2019/plugins/find-replace/keymap.js +0 -16
  58. package/dist/es2019/plugins/find-replace/plugin-key.js +0 -2
  59. package/dist/es2019/plugins/find-replace/plugin.js +0 -117
  60. package/dist/es2019/plugins/find-replace/reducer.js +0 -56
  61. package/dist/es2019/plugins/find-replace/styles.js +0 -17
  62. package/dist/es2019/plugins/find-replace/types.js +0 -1
  63. package/dist/es2019/plugins/find-replace/ui/Find.js +0 -284
  64. package/dist/es2019/plugins/find-replace/ui/FindReplace.js +0 -78
  65. package/dist/es2019/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -122
  66. package/dist/es2019/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -50
  67. package/dist/es2019/plugins/find-replace/ui/Replace.js +0 -152
  68. package/dist/es2019/plugins/find-replace/ui/styles.js +0 -48
  69. package/dist/es2019/plugins/find-replace/utils/batch-decorations.js +0 -189
  70. package/dist/es2019/plugins/find-replace/utils/commands.js +0 -6
  71. package/dist/es2019/plugins/find-replace/utils/index.js +0 -249
  72. package/dist/es2019/utils/array.js +0 -3
  73. package/dist/esm/plugins/find-replace/FindReplaceToolbarButtonWithState.js +0 -157
  74. package/dist/esm/plugins/find-replace/actions.js +0 -13
  75. package/dist/esm/plugins/find-replace/commands-with-analytics.js +0 -95
  76. package/dist/esm/plugins/find-replace/commands.js +0 -248
  77. package/dist/esm/plugins/find-replace/index.js +0 -87
  78. package/dist/esm/plugins/find-replace/keymap.js +0 -18
  79. package/dist/esm/plugins/find-replace/plugin-key.js +0 -2
  80. package/dist/esm/plugins/find-replace/plugin.js +0 -133
  81. package/dist/esm/plugins/find-replace/reducer.js +0 -54
  82. package/dist/esm/plugins/find-replace/styles.js +0 -10
  83. package/dist/esm/plugins/find-replace/types.js +0 -1
  84. package/dist/esm/plugins/find-replace/ui/Find.js +0 -302
  85. package/dist/esm/plugins/find-replace/ui/FindReplace.js +0 -97
  86. package/dist/esm/plugins/find-replace/ui/FindReplaceToolbarButton.js +0 -126
  87. package/dist/esm/plugins/find-replace/ui/FindReplaceTooltipButton.js +0 -69
  88. package/dist/esm/plugins/find-replace/ui/Replace.js +0 -168
  89. package/dist/esm/plugins/find-replace/ui/styles.js +0 -37
  90. package/dist/esm/plugins/find-replace/utils/batch-decorations.js +0 -304
  91. package/dist/esm/plugins/find-replace/utils/commands.js +0 -10
  92. package/dist/esm/plugins/find-replace/utils/index.js +0 -280
  93. package/dist/esm/utils/array.js +0 -7
  94. package/dist/types/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +0 -4
  95. package/dist/types/plugins/find-replace/actions.d.ts +0 -64
  96. package/dist/types/plugins/find-replace/commands-with-analytics.d.ts +0 -27
  97. package/dist/types/plugins/find-replace/commands.d.ts +0 -12
  98. package/dist/types/plugins/find-replace/index.d.ts +0 -3
  99. package/dist/types/plugins/find-replace/keymap.d.ts +0 -4
  100. package/dist/types/plugins/find-replace/plugin-key.d.ts +0 -3
  101. package/dist/types/plugins/find-replace/plugin.d.ts +0 -6
  102. package/dist/types/plugins/find-replace/reducer.d.ts +0 -4
  103. package/dist/types/plugins/find-replace/styles.d.ts +0 -3
  104. package/dist/types/plugins/find-replace/types.d.ts +0 -79
  105. package/dist/types/plugins/find-replace/ui/Find.d.ts +0 -71
  106. package/dist/types/plugins/find-replace/ui/FindReplace.d.ts +0 -43
  107. package/dist/types/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +0 -21
  108. package/dist/types/plugins/find-replace/ui/FindReplaceTooltipButton.d.ts +0 -18
  109. package/dist/types/plugins/find-replace/ui/Replace.d.ts +0 -27
  110. package/dist/types/plugins/find-replace/ui/styles.d.ts +0 -6
  111. package/dist/types/plugins/find-replace/utils/batch-decorations.d.ts +0 -36
  112. package/dist/types/plugins/find-replace/utils/commands.d.ts +0 -2
  113. package/dist/types/plugins/find-replace/utils/index.d.ts +0 -49
  114. package/dist/types/utils/array.d.ts +0 -1
  115. package/dist/types-ts4.5/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +0 -4
  116. package/dist/types-ts4.5/plugins/find-replace/actions.d.ts +0 -64
  117. package/dist/types-ts4.5/plugins/find-replace/commands-with-analytics.d.ts +0 -27
  118. package/dist/types-ts4.5/plugins/find-replace/commands.d.ts +0 -12
  119. package/dist/types-ts4.5/plugins/find-replace/index.d.ts +0 -3
  120. package/dist/types-ts4.5/plugins/find-replace/keymap.d.ts +0 -4
  121. package/dist/types-ts4.5/plugins/find-replace/plugin-key.d.ts +0 -3
  122. package/dist/types-ts4.5/plugins/find-replace/plugin.d.ts +0 -6
  123. package/dist/types-ts4.5/plugins/find-replace/reducer.d.ts +0 -4
  124. package/dist/types-ts4.5/plugins/find-replace/styles.d.ts +0 -3
  125. package/dist/types-ts4.5/plugins/find-replace/types.d.ts +0 -79
  126. package/dist/types-ts4.5/plugins/find-replace/ui/Find.d.ts +0 -71
  127. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplace.d.ts +0 -43
  128. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceToolbarButton.d.ts +0 -21
  129. package/dist/types-ts4.5/plugins/find-replace/ui/FindReplaceTooltipButton.d.ts +0 -18
  130. package/dist/types-ts4.5/plugins/find-replace/ui/Replace.d.ts +0 -27
  131. package/dist/types-ts4.5/plugins/find-replace/ui/styles.d.ts +0 -6
  132. package/dist/types-ts4.5/plugins/find-replace/utils/batch-decorations.d.ts +0 -36
  133. package/dist/types-ts4.5/plugins/find-replace/utils/commands.d.ts +0 -2
  134. package/dist/types-ts4.5/plugins/find-replace/utils/index.d.ts +0 -49
  135. package/dist/types-ts4.5/utils/array.d.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "191.0.8",
3
+ "version": "191.1.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/avatar": "^21.4.0",
49
49
  "@atlaskit/avatar-group": "^9.5.0",
50
50
  "@atlaskit/button": "^17.2.0",
51
- "@atlaskit/editor-common": "^76.38.0",
51
+ "@atlaskit/editor-common": "^76.39.0",
52
52
  "@atlaskit/editor-json-transformer": "^8.10.0",
53
53
  "@atlaskit/editor-plugin-alignment": "^0.1.0",
54
54
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
@@ -80,6 +80,7 @@
80
80
  "@atlaskit/editor-plugin-extension": "^0.5.0",
81
81
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
82
82
  "@atlaskit/editor-plugin-feedback-dialog": "^0.1.0",
83
+ "@atlaskit/editor-plugin-find-replace": "^0.1.0",
83
84
  "@atlaskit/editor-plugin-floating-toolbar": "^0.7.0",
84
85
  "@atlaskit/editor-plugin-focus": "^0.2.0",
85
86
  "@atlaskit/editor-plugin-fragment": "^0.1.0",
@@ -106,7 +107,7 @@
106
107
  "@atlaskit/editor-plugin-rule": "^0.1.0",
107
108
  "@atlaskit/editor-plugin-save-on-enter": "^0.1.0",
108
109
  "@atlaskit/editor-plugin-scroll-into-view": "^0.1.0",
109
- "@atlaskit/editor-plugin-selection": "^0.1.0",
110
+ "@atlaskit/editor-plugin-selection": "^0.2.0",
110
111
  "@atlaskit/editor-plugin-selection-toolbar": "^0.1.0",
111
112
  "@atlaskit/editor-plugin-status": "^0.2.0",
112
113
  "@atlaskit/editor-plugin-submit-editor": "^0.1.0",
@@ -129,7 +130,6 @@
129
130
  "@atlaskit/platform-feature-flags": "^0.2.0",
130
131
  "@atlaskit/spinner": "^16.0.0",
131
132
  "@atlaskit/task-decision": "^17.9.0",
132
- "@atlaskit/textfield": "^6.0.0",
133
133
  "@atlaskit/theme": "^12.6.0",
134
134
  "@atlaskit/tokens": "^1.33.0",
135
135
  "@atlaskit/tooltip": "^18.1.0",
@@ -143,7 +143,6 @@
143
143
  "lodash": "^4.17.21",
144
144
  "memoize-one": "^6.0.0",
145
145
  "prop-types": "^15.5.10",
146
- "raf-schd": "^4.0.3",
147
146
  "react-loadable": "^5.1.0",
148
147
  "react-transition-group": "^4.4.1",
149
148
  "uuid": "^3.1.0"
@@ -163,7 +162,7 @@
163
162
  "@atlaskit/analytics-listeners": "^8.9.0",
164
163
  "@atlaskit/checkbox": "^13.0.0",
165
164
  "@atlaskit/code": "^15.1.0",
166
- "@atlaskit/collab-provider": "9.21.2",
165
+ "@atlaskit/collab-provider": "9.21.3",
167
166
  "@atlaskit/dropdown-menu": "^12.1.0",
168
167
  "@atlaskit/editor-extension-dropbox": "^0.4.0",
169
168
  "@atlaskit/editor-palette": "1.5.2",
@@ -185,7 +184,7 @@
185
184
  "@atlaskit/visual-regression": "*",
186
185
  "@atlassian/adf-schema-json": "^1.0.7",
187
186
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
188
- "@atlassian/editor-extension-link-create": "^1.1.0",
187
+ "@atlassian/editor-extension-link-create": "^1.2.0",
189
188
  "@atlassian/feature-flags-test-utils": "^0.1.1",
190
189
  "@atlassian/link-picker-plugins": "^24.0.0",
191
190
  "@atlassian/search-provider": "2.4.11",
@@ -304,9 +303,6 @@
304
303
  "platform.editor.paste-options-toolbar": {
305
304
  "type": "boolean"
306
305
  },
307
- "platform.editor.a11y-find-replace": {
308
- "type": "boolean"
309
- },
310
306
  "platform.editor.menu.group-items": {
311
307
  "type": "boolean",
312
308
  "referenceOnly": "true"
@@ -1,166 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _commandsWithAnalytics = require("./commands-with-analytics");
12
- var _commands = require("./commands");
13
- var _FindReplaceToolbarButton = _interopRequireDefault(require("./ui/FindReplaceToolbarButton"));
14
- var _analytics = require("@atlaskit/editor-common/analytics");
15
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
- // light implementation of useSharedPluginState(). This is due to findreplace
18
- // being the only plugin that previously used WithPluginState with
19
- // debounce=false. That was implemented because of text sync issues
20
- // between editor & findreplace dialog.
21
- // To address under ENGHEALTH-5853
22
- var useSharedPluginStateNoDebounce = function useSharedPluginStateNoDebounce(api) {
23
- var _useState = (0, _react.useState)(api === null || api === void 0 ? void 0 : api.findReplace.sharedState.currentState()),
24
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
25
- state = _useState2[0],
26
- setState = _useState2[1];
27
- (0, _react.useLayoutEffect)(function () {
28
- var unsub = api === null || api === void 0 ? void 0 : api.findReplace.sharedState.onChange(function (_ref) {
29
- var nextSharedState = _ref.nextSharedState;
30
- setState(nextSharedState);
31
- });
32
- return function () {
33
- unsub === null || unsub === void 0 || unsub();
34
- };
35
- }, [api]);
36
- return {
37
- findReplaceState: state
38
- };
39
- };
40
- var FindReplaceToolbarButtonWithState = function FindReplaceToolbarButtonWithState(_ref2) {
41
- var _api$analytics;
42
- var popupsBoundariesElement = _ref2.popupsBoundariesElement,
43
- popupsMountPoint = _ref2.popupsMountPoint,
44
- popupsScrollableElement = _ref2.popupsScrollableElement,
45
- isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
46
- editorView = _ref2.editorView,
47
- containerElement = _ref2.containerElement,
48
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
49
- featureFlags = _ref2.featureFlags,
50
- takeFullWidth = _ref2.takeFullWidth,
51
- api = _ref2.api;
52
- var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
53
- var _useSharedPluginState = useSharedPluginStateNoDebounce(api),
54
- findReplaceState = _useSharedPluginState.findReplaceState;
55
- if (!editorView) {
56
- return null;
57
- }
58
-
59
- // we need the editor to be in focus for scrollIntoView() to work
60
- // so we focus it while we run the command, then put focus back into
61
- // whatever element was previously focused in find replace component
62
- var runWithEditorFocused = function runWithEditorFocused(fn) {
63
- var activeElement = document.activeElement;
64
- editorView.focus();
65
- fn();
66
- activeElement === null || activeElement === void 0 || activeElement.focus();
67
- };
68
- var dispatchCommand = function dispatchCommand(cmd) {
69
- var state = editorView.state,
70
- dispatch = editorView.dispatch;
71
- cmd(state, dispatch);
72
- };
73
- var handleActivate = function handleActivate() {
74
- runWithEditorFocused(function () {
75
- return dispatchCommand((0, _commandsWithAnalytics.activateWithAnalytics)(editorAnalyticsAPI)({
76
- triggerMethod: _analytics.TRIGGER_METHOD.TOOLBAR
77
- }));
78
- });
79
- };
80
- var handleFind = function handleFind(keyword) {
81
- runWithEditorFocused(function () {
82
- return dispatchCommand((0, _commandsWithAnalytics.findWithAnalytics)(editorAnalyticsAPI)({
83
- editorView: editorView,
84
- containerElement: containerElement,
85
- keyword: keyword
86
- }));
87
- });
88
- };
89
- var handleFindNext = function handleFindNext(_ref3) {
90
- var triggerMethod = _ref3.triggerMethod;
91
- runWithEditorFocused(function () {
92
- return dispatchCommand((0, _commandsWithAnalytics.findNextWithAnalytics)(editorAnalyticsAPI)({
93
- triggerMethod: triggerMethod
94
- }));
95
- });
96
- };
97
- var handleFindPrev = function handleFindPrev(_ref4) {
98
- var triggerMethod = _ref4.triggerMethod;
99
- runWithEditorFocused(function () {
100
- return dispatchCommand((0, _commandsWithAnalytics.findPrevWithAnalytics)(editorAnalyticsAPI)({
101
- triggerMethod: triggerMethod
102
- }));
103
- });
104
- };
105
- var handleReplace = function handleReplace(_ref5) {
106
- var triggerMethod = _ref5.triggerMethod,
107
- replaceText = _ref5.replaceText;
108
- runWithEditorFocused(function () {
109
- return dispatchCommand((0, _commandsWithAnalytics.replaceWithAnalytics)(editorAnalyticsAPI)({
110
- triggerMethod: triggerMethod,
111
- replaceText: replaceText
112
- }));
113
- });
114
- };
115
- var handleReplaceAll = function handleReplaceAll(_ref6) {
116
- var replaceText = _ref6.replaceText;
117
- runWithEditorFocused(function () {
118
- return dispatchCommand((0, _commandsWithAnalytics.replaceAllWithAnalytics)(editorAnalyticsAPI)({
119
- replaceText: replaceText
120
- }));
121
- });
122
- };
123
- var handleFindBlur = function handleFindBlur() {
124
- dispatchCommand((0, _commands.blur)());
125
- };
126
- var handleCancel = function handleCancel(_ref7) {
127
- var triggerMethod = _ref7.triggerMethod;
128
- dispatchCommand((0, _commandsWithAnalytics.cancelSearchWithAnalytics)(editorAnalyticsAPI)({
129
- triggerMethod: triggerMethod
130
- }));
131
- editorView.focus();
132
- };
133
- var handleToggleMatchCase = function handleToggleMatchCase() {
134
- dispatchCommand((0, _commands.toggleMatchCase)());
135
- };
136
- var findReplaceMatchCase = featureFlags.findReplaceMatchCase;
137
- if (!findReplaceState) {
138
- return null;
139
- }
140
- return /*#__PURE__*/_react.default.createElement(_FindReplaceToolbarButton.default, {
141
- allowMatchCase: findReplaceMatchCase,
142
- shouldMatchCase: findReplaceState.shouldMatchCase,
143
- onToggleMatchCase: handleToggleMatchCase,
144
- isActive: findReplaceState.isActive,
145
- findText: findReplaceState.findText,
146
- index: findReplaceState.index,
147
- numMatches: findReplaceState.matches.length,
148
- replaceText: findReplaceState.replaceText,
149
- shouldFocus: findReplaceState.shouldFocus,
150
- popupsBoundariesElement: popupsBoundariesElement,
151
- popupsMountPoint: popupsMountPoint,
152
- popupsScrollableElement: popupsScrollableElement,
153
- isReducedSpacing: !!isToolbarReducedSpacing,
154
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
155
- onFindBlur: handleFindBlur,
156
- onCancel: handleCancel,
157
- onActivate: handleActivate,
158
- onFind: handleFind,
159
- onFindNext: handleFindNext,
160
- onFindPrev: handleFindPrev,
161
- onReplace: handleReplace,
162
- onReplaceAll: handleReplaceAll,
163
- takeFullWidth: !!takeFullWidth
164
- });
165
- };
166
- var _default = exports.default = /*#__PURE__*/_react.default.memo(FindReplaceToolbarButtonWithState);
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.FindReplaceActionTypes = void 0;
7
- var FindReplaceActionTypes = exports.FindReplaceActionTypes = /*#__PURE__*/function (FindReplaceActionTypes) {
8
- FindReplaceActionTypes["ACTIVATE"] = "ACTIVATE";
9
- FindReplaceActionTypes["FIND"] = "FIND";
10
- FindReplaceActionTypes["UPDATE_DECORATIONS"] = "UPDATE_DECORATIONS";
11
- FindReplaceActionTypes["FIND_NEXT"] = "FIND_NEXT";
12
- FindReplaceActionTypes["FIND_PREVIOUS"] = "FIND_PREVIOUS";
13
- FindReplaceActionTypes["REPLACE"] = "REPLACE";
14
- FindReplaceActionTypes["REPLACE_ALL"] = "REPLACE_ALL";
15
- FindReplaceActionTypes["CANCEL"] = "CANCEL";
16
- FindReplaceActionTypes["BLUR"] = "BLUR";
17
- FindReplaceActionTypes["TOGGLE_MATCH_CASE"] = "TOGGLE_MATCH_CASE";
18
- return FindReplaceActionTypes;
19
- }({});
@@ -1,101 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.replaceWithAnalytics = exports.replaceAllWithAnalytics = exports.findWithAnalytics = exports.findPrevWithAnalytics = exports.findNextWithAnalytics = exports.cancelSearchWithAnalytics = exports.activateWithAnalytics = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var _analytics = require("@atlaskit/editor-common/analytics");
9
- var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
10
- var _commands = require("./commands");
11
- var activateWithAnalytics = exports.activateWithAnalytics = function activateWithAnalytics(editorAnalyticsAPI) {
12
- return function (_ref) {
13
- var triggerMethod = _ref.triggerMethod;
14
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, function (state) {
15
- return {
16
- eventType: _analytics.EVENT_TYPE.UI,
17
- action: _analytics.ACTION.ACTIVATED,
18
- actionSubject: _analytics.ACTION_SUBJECT.FIND_REPLACE_DIALOG,
19
- attributes: {
20
- inputMethod: state.selection instanceof _state.TextSelection && !state.selection.empty ? _analytics.INPUT_METHOD.PREFILL : _analytics.INPUT_METHOD.KEYBOARD,
21
- triggerMethod: triggerMethod
22
- }
23
- };
24
- })((0, _commands.activate)());
25
- };
26
- };
27
- var findWithAnalytics = exports.findWithAnalytics = function findWithAnalytics(editorAnalyticsAPI) {
28
- return function (_ref2) {
29
- var editorView = _ref2.editorView,
30
- containerElement = _ref2.containerElement,
31
- keyword = _ref2.keyword;
32
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
33
- eventType: _analytics.EVENT_TYPE.TRACK,
34
- action: _analytics.ACTION.FIND_PERFORMED,
35
- actionSubject: _analytics.ACTION_SUBJECT.TEXT
36
- })((0, _commands.find)(editorView, containerElement, keyword));
37
- };
38
- };
39
- var findNextWithAnalytics = exports.findNextWithAnalytics = function findNextWithAnalytics(editorAnalyticsAPI) {
40
- return function (_ref3) {
41
- var triggerMethod = _ref3.triggerMethod;
42
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
43
- eventType: _analytics.EVENT_TYPE.TRACK,
44
- action: _analytics.ACTION.FIND_NEXT_PERFORMED,
45
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
46
- attributes: {
47
- triggerMethod: triggerMethod
48
- }
49
- })((0, _commands.findNext)());
50
- };
51
- };
52
- var findPrevWithAnalytics = exports.findPrevWithAnalytics = function findPrevWithAnalytics(editorAnalyticsAPI) {
53
- return function (_ref4) {
54
- var triggerMethod = _ref4.triggerMethod;
55
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
56
- eventType: _analytics.EVENT_TYPE.TRACK,
57
- action: _analytics.ACTION.FIND_PREV_PERFORMED,
58
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
59
- attributes: {
60
- triggerMethod: triggerMethod
61
- }
62
- })((0, _commands.findPrevious)());
63
- };
64
- };
65
- var replaceWithAnalytics = exports.replaceWithAnalytics = function replaceWithAnalytics(editorAnalyticsAPI) {
66
- return function (_ref5) {
67
- var triggerMethod = _ref5.triggerMethod,
68
- replaceText = _ref5.replaceText;
69
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
70
- eventType: _analytics.EVENT_TYPE.TRACK,
71
- action: _analytics.ACTION.REPLACED_ONE,
72
- actionSubject: _analytics.ACTION_SUBJECT.TEXT,
73
- attributes: {
74
- triggerMethod: triggerMethod
75
- }
76
- })((0, _commands.replace)(replaceText));
77
- };
78
- };
79
- var replaceAllWithAnalytics = exports.replaceAllWithAnalytics = function replaceAllWithAnalytics(editorAnalyticsAPI) {
80
- return function (_ref6) {
81
- var replaceText = _ref6.replaceText;
82
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
83
- eventType: _analytics.EVENT_TYPE.TRACK,
84
- action: _analytics.ACTION.REPLACED_ALL,
85
- actionSubject: _analytics.ACTION_SUBJECT.TEXT
86
- })((0, _commands.replaceAll)(replaceText));
87
- };
88
- };
89
- var cancelSearchWithAnalytics = exports.cancelSearchWithAnalytics = function cancelSearchWithAnalytics(editorAnalyticsAPI) {
90
- return function (_ref7) {
91
- var triggerMethod = _ref7.triggerMethod;
92
- return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
93
- eventType: _analytics.EVENT_TYPE.UI,
94
- action: _analytics.ACTION.DEACTIVATED,
95
- actionSubject: _analytics.ACTION_SUBJECT.FIND_REPLACE_DIALOG,
96
- attributes: {
97
- triggerMethod: triggerMethod
98
- }
99
- })((0, _commands.cancelSearch)());
100
- };
101
- };
@@ -1,255 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.toggleMatchCase = exports.replaceAll = exports.replace = exports.removeDecorations = exports.findPrevious = exports.findNext = exports.find = exports.cancelSearch = exports.blur = exports.addDecorations = exports.activate = void 0;
8
- var _state = require("@atlaskit/editor-prosemirror/state");
9
- var _view = require("@atlaskit/editor-prosemirror/view");
10
- var _plugin = require("./plugin");
11
- var _actions = require("./actions");
12
- var _utils = require("./utils");
13
- var _commands = require("./utils/commands");
14
- var _batchDecorations = _interopRequireDefault(require("./utils/batch-decorations"));
15
- var activate = exports.activate = function activate() {
16
- return (0, _plugin.createCommand)(function (state) {
17
- var selection = state.selection;
18
- var findText;
19
- var matches;
20
- var index;
21
-
22
- // if user has selected text and hit cmd-f, set that as the keyword
23
- if (selection instanceof _state.TextSelection && !selection.empty) {
24
- findText = (0, _utils.getSelectedText)(selection);
25
- var _getPluginState = (0, _plugin.getPluginState)(state),
26
- shouldMatchCase = _getPluginState.shouldMatchCase;
27
- matches = (0, _utils.findMatches)(state.doc, findText, shouldMatchCase);
28
- index = (0, _utils.findSearchIndex)(selection.from, matches);
29
- }
30
- return {
31
- type: _actions.FindReplaceActionTypes.ACTIVATE,
32
- findText: findText,
33
- matches: matches,
34
- index: index
35
- };
36
- });
37
- };
38
- var find = exports.find = function find(editorView, containerElement, keyword) {
39
- return (0, _commands.withScrollIntoView)((0, _plugin.createCommand)(function (state) {
40
- var selection = state.selection;
41
- var _getPluginState2 = (0, _plugin.getPluginState)(state),
42
- shouldMatchCase = _getPluginState2.shouldMatchCase;
43
- var matches = keyword !== undefined ? (0, _utils.findMatches)(state.doc, keyword, shouldMatchCase) : [];
44
- var index = (0, _utils.findSearchIndex)(selection.from, matches);
45
-
46
- // we can't just apply all the decorations to highlight the search results at once
47
- // as if there are a lot ProseMirror cries :'(
48
- _batchDecorations.default.applyAllSearchDecorations(editorView, containerElement, function (decorations) {
49
- return addDecorations(decorations)(editorView.state, editorView.dispatch);
50
- }, function (decorations) {
51
- return removeDecorations(decorations)(editorView.state, editorView.dispatch);
52
- });
53
- return {
54
- type: _actions.FindReplaceActionTypes.FIND,
55
- findText: keyword || '',
56
- matches: matches,
57
- index: index
58
- };
59
- }, function (tr, state) {
60
- var selection = state.selection;
61
- var _getPluginState3 = (0, _plugin.getPluginState)(state),
62
- shouldMatchCase = _getPluginState3.shouldMatchCase;
63
- var matches = keyword !== undefined ? (0, _utils.findMatches)(state.doc, keyword, shouldMatchCase) : [];
64
- if (matches.length > 0) {
65
- var index = (0, _utils.findSearchIndex)(selection.from, matches);
66
- return tr.setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, index, matches));
67
- }
68
- return tr;
69
- }));
70
- };
71
- var findNext = exports.findNext = function findNext() {
72
- return (0, _commands.withScrollIntoView)((0, _plugin.createCommand)(function (state) {
73
- return findInDirection(state, 'next');
74
- }, function (tr, state) {
75
- var _getPluginState4 = (0, _plugin.getPluginState)(state),
76
- matches = _getPluginState4.matches,
77
- index = _getPluginState4.index;
78
- // can't use index from plugin state because if the cursor has moved, it will still be the
79
- // OLD index (the find next operation should look for the first match forward starting
80
- // from the current cursor position)
81
- var searchIndex = (0, _utils.findSearchIndex)(state.selection.from, matches);
82
- if (searchIndex === index) {
83
- // cursor has not moved, so we just want to find the next in matches array
84
- searchIndex = (0, _utils.nextIndex)(searchIndex, matches.length);
85
- }
86
- return tr.setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, searchIndex, matches));
87
- }));
88
- };
89
- var findPrevious = exports.findPrevious = function findPrevious() {
90
- return (0, _commands.withScrollIntoView)((0, _plugin.createCommand)(function (state) {
91
- return findInDirection(state, 'previous');
92
- }, function (tr, state) {
93
- var _getPluginState5 = (0, _plugin.getPluginState)(state),
94
- matches = _getPluginState5.matches;
95
- // can't use index from plugin state because if the cursor has moved, it will still be the
96
- // OLD index (the find prev operation should look for the first match backward starting
97
- // from the current cursor position)
98
- var searchIndex = (0, _utils.findSearchIndex)(state.selection.from, matches, true);
99
- return tr.setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, searchIndex, matches));
100
- }));
101
- };
102
- var findInDirection = function findInDirection(state, dir) {
103
- var pluginState = (0, _plugin.getPluginState)(state);
104
- var matches = pluginState.matches,
105
- findText = pluginState.findText;
106
- var decorationSet = pluginState.decorationSet,
107
- index = pluginState.index;
108
- if (findText) {
109
- var searchIndex = (0, _utils.findSearchIndex)(state.selection.from, matches, dir === 'previous');
110
- // compare index from plugin state and index of first match forward from cursor position
111
- if (index === searchIndex) {
112
- // normal case, cycling through matches
113
- index = dir === 'next' ? (0, _utils.nextIndex)(index, matches.length) : (0, _utils.prevIndex)(index, matches.length);
114
- } else {
115
- // cursor has moved
116
- index = searchIndex;
117
- }
118
- decorationSet = updateSelectedHighlight(state, index);
119
- }
120
- return {
121
- type: dir === 'next' ? _actions.FindReplaceActionTypes.FIND_NEXT : _actions.FindReplaceActionTypes.FIND_PREVIOUS,
122
- index: index,
123
- decorationSet: decorationSet
124
- };
125
- };
126
- var replace = exports.replace = function replace(replaceText) {
127
- return (0, _commands.withScrollIntoView)((0, _plugin.createCommand)(function (state) {
128
- var pluginState = (0, _plugin.getPluginState)(state);
129
- var findText = pluginState.findText;
130
- var decorationSet = pluginState.decorationSet,
131
- matches = pluginState.matches,
132
- index = pluginState.index;
133
- decorationSet = updateSelectedHighlight(state, (0, _utils.nextIndex)(index, matches.length));
134
- if (replaceText.toLowerCase().indexOf(findText.toLowerCase()) === -1) {
135
- decorationSet = (0, _utils.removeMatchesFromSet)(decorationSet, [matches[index]], state.doc);
136
- matches.splice(index, 1);
137
- if (index > matches.length - 1) {
138
- index = 0;
139
- }
140
- } else {
141
- index = (0, _utils.nextIndex)(index, matches.length);
142
- }
143
- return {
144
- type: _actions.FindReplaceActionTypes.REPLACE,
145
- replaceText: replaceText,
146
- decorationSet: decorationSet,
147
- matches: matches,
148
- index: index
149
- };
150
- }, function (tr, state) {
151
- var _getPluginState6 = (0, _plugin.getPluginState)(state),
152
- matches = _getPluginState6.matches,
153
- index = _getPluginState6.index,
154
- findText = _getPluginState6.findText;
155
- if (matches[index]) {
156
- var _matches$index = matches[index],
157
- start = _matches$index.start,
158
- end = _matches$index.end;
159
- var newIndex = (0, _utils.nextIndex)(index, matches.length);
160
- tr.insertText(replaceText, start, end).setSelection((0, _utils.getSelectionForMatch)(tr.selection, tr.doc, newIndex, matches, newIndex === 0 ? 0 : replaceText.length - findText.length));
161
- }
162
- return tr;
163
- }));
164
- };
165
- var replaceAll = exports.replaceAll = function replaceAll(replaceText) {
166
- return (0, _plugin.createCommand)({
167
- type: _actions.FindReplaceActionTypes.REPLACE_ALL,
168
- replaceText: replaceText,
169
- decorationSet: _view.DecorationSet.empty,
170
- matches: [],
171
- index: 0
172
- }, function (tr, state) {
173
- var pluginState = (0, _plugin.getPluginState)(state);
174
- pluginState.matches.forEach(function (match) {
175
- tr.insertText(replaceText, tr.mapping.map(match.start), tr.mapping.map(match.end));
176
- });
177
- tr.setMeta('scrollIntoView', false);
178
- return tr;
179
- });
180
- };
181
- var addDecorations = exports.addDecorations = function addDecorations(decorations) {
182
- return (0, _plugin.createCommand)(function (state) {
183
- var _getPluginState7 = (0, _plugin.getPluginState)(state),
184
- decorationSet = _getPluginState7.decorationSet;
185
- return {
186
- type: _actions.FindReplaceActionTypes.UPDATE_DECORATIONS,
187
- decorationSet: decorationSet.add(state.doc, decorations)
188
- };
189
- });
190
- };
191
- var removeDecorations = exports.removeDecorations = function removeDecorations(decorations) {
192
- return (0, _plugin.createCommand)(function (state) {
193
- var _getPluginState8 = (0, _plugin.getPluginState)(state),
194
- decorationSet = _getPluginState8.decorationSet;
195
- return {
196
- type: _actions.FindReplaceActionTypes.UPDATE_DECORATIONS,
197
- decorationSet: (0, _utils.removeDecorationsFromSet)(decorationSet, decorations, state.doc)
198
- };
199
- });
200
- };
201
- var cancelSearch = exports.cancelSearch = function cancelSearch() {
202
- return (0, _plugin.createCommand)(function () {
203
- _batchDecorations.default.stop();
204
- return {
205
- type: _actions.FindReplaceActionTypes.CANCEL
206
- };
207
- });
208
- };
209
- var blur = exports.blur = function blur() {
210
- return (0, _plugin.createCommand)({
211
- type: _actions.FindReplaceActionTypes.BLUR
212
- });
213
- };
214
- var toggleMatchCase = exports.toggleMatchCase = function toggleMatchCase() {
215
- return (0, _plugin.createCommand)({
216
- type: _actions.FindReplaceActionTypes.TOGGLE_MATCH_CASE
217
- });
218
- };
219
- var updateSelectedHighlight = function updateSelectedHighlight(state, nextSelectedIndex) {
220
- var _getPluginState9 = (0, _plugin.getPluginState)(state),
221
- decorationSet = _getPluginState9.decorationSet,
222
- index = _getPluginState9.index,
223
- matches = _getPluginState9.matches;
224
- var currentSelectedMatch = matches[index];
225
- var nextSelectedMatch = matches[nextSelectedIndex];
226
- if (index === nextSelectedIndex) {
227
- return decorationSet;
228
- }
229
- var currentSelectedDecoration = (0, _utils.findDecorationFromMatch)(decorationSet, currentSelectedMatch);
230
- var nextSelectedDecoration = (0, _utils.findDecorationFromMatch)(decorationSet, nextSelectedMatch);
231
-
232
- // Update decorations so the current selected match becomes a normal match
233
- // and the next selected gets the selected styling
234
- var decorationsToRemove = [];
235
- if (currentSelectedDecoration) {
236
- decorationsToRemove.push(currentSelectedDecoration);
237
- }
238
- if (nextSelectedDecoration) {
239
- decorationsToRemove.push(nextSelectedDecoration);
240
- }
241
- if (decorationsToRemove.length > 0) {
242
- // removeDecorationsFromSet depends on decorations being pre-sorted
243
- decorationsToRemove.sort(function (a, b) {
244
- return a.from < b.from ? -1 : 1;
245
- });
246
- decorationSet = (0, _utils.removeDecorationsFromSet)(decorationSet, decorationsToRemove, state.doc);
247
- }
248
- if (currentSelectedMatch) {
249
- decorationSet = decorationSet.add(state.doc, [(0, _utils.createDecoration)(currentSelectedMatch.start, currentSelectedMatch.end)]);
250
- }
251
- if (nextSelectedMatch) {
252
- decorationSet = decorationSet.add(state.doc, [(0, _utils.createDecoration)(nextSelectedMatch.start, nextSelectedMatch.end, true)]);
253
- }
254
- return decorationSet;
255
- };