@atlaskit/editor-plugin-find-replace 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-find-replace
2
2
 
3
+ ## 2.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#131023](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131023)
14
+ [`05f7d6e19eb6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05f7d6e19eb6d) -
15
+ Added activateFindReplace action to findReplacePlugin to activate Find and Replace popup
16
+ - Updated dependencies
17
+
3
18
  ## 2.0.5
4
19
 
5
20
  ### Patch Changes
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.findReplacePlugin = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _analytics = require("@atlaskit/editor-common/analytics");
10
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
9
11
  var _types = require("@atlaskit/editor-common/types");
10
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
13
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
14
+ var _commands = require("./pm-plugins/commands");
15
+ var _commandsWithAnalytics = require("./pm-plugins/commands-with-analytics");
12
16
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
13
17
  var _main = require("./pm-plugins/main");
14
18
  var _pluginKey = require("./pm-plugins/plugin-key");
@@ -17,6 +21,9 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
17
21
  var _api$primaryToolbar;
18
22
  var props = _ref.config,
19
23
  api = _ref.api;
24
+ var editorViewRef = {
25
+ current: null
26
+ };
20
27
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
21
28
  var popupsBoundariesElement = _ref2.popupsBoundariesElement,
22
29
  popupsMountPoint = _ref2.popupsMountPoint,
@@ -51,7 +58,7 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
51
58
  return {
52
59
  name: 'findReplace',
53
60
  pmPlugins: function pmPlugins() {
54
- return [{
61
+ var plugins = [{
55
62
  name: 'findReplace',
56
63
  plugin: function plugin(_ref3) {
57
64
  var dispatch = _ref3.dispatch;
@@ -64,6 +71,26 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
64
71
  return (0, _keymap.default)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
65
72
  }
66
73
  }];
74
+ if ((0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
75
+ exposure: false
76
+ })) {
77
+ plugins.push({
78
+ name: 'findReplaceEditorViewReferencePlugin',
79
+ plugin: function plugin() {
80
+ return new _safePlugin.SafePlugin({
81
+ view: function view(editorView) {
82
+ editorViewRef.current = editorView;
83
+ return {
84
+ destroy: function destroy() {
85
+ editorViewRef.current = null;
86
+ }
87
+ };
88
+ }
89
+ });
90
+ }
91
+ });
92
+ }
93
+ return plugins;
67
94
  },
68
95
  getSharedState: function getSharedState(editorState) {
69
96
  if (!editorState) {
@@ -90,6 +117,24 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
90
117
  isToolbarReducedSpacing: isToolbarReducedSpacing,
91
118
  api: api
92
119
  });
120
+ },
121
+ activateFindReplace: function activateFindReplace(triggerMethod) {
122
+ var _api$analytics2;
123
+ if (!editorViewRef.current) {
124
+ return false;
125
+ }
126
+ var _editorViewRef$curren = editorViewRef.current,
127
+ state = _editorViewRef$curren.state,
128
+ dispatch = _editorViewRef$curren.dispatch;
129
+ if (api !== null && api !== void 0 && (_api$analytics2 = api.analytics) !== null && _api$analytics2 !== void 0 && _api$analytics2.actions) {
130
+ var _api$analytics3;
131
+ (0, _commandsWithAnalytics.activateWithAnalytics)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)({
132
+ triggerMethod: triggerMethod || _analytics.TRIGGER_METHOD.EXTERNAL
133
+ })(state, dispatch);
134
+ } else {
135
+ (0, _commands.activate)()(state, dispatch);
136
+ }
137
+ return true;
93
138
  }
94
139
  },
95
140
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
@@ -134,6 +134,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
134
134
  findTyped: this.state.findTyped,
135
135
  setFindTyped: this.setFindTyped
136
136
  }), (0, _react2.jsx)("hr", {
137
+ role: "presentation",
137
138
  css: _uiStyles.ruleStyles,
138
139
  id: "replace-hr-element"
139
140
  }), (0, _react2.jsx)(_Replace.default, {
@@ -1,7 +1,11 @@
1
1
  import React from 'react';
2
+ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
4
  import { ToolbarSize } from '@atlaskit/editor-common/types';
3
5
  import { fg } from '@atlaskit/platform-feature-flags';
4
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
+ import { activate } from './pm-plugins/commands';
8
+ import { activateWithAnalytics } from './pm-plugins/commands-with-analytics';
5
9
  import keymapPlugin from './pm-plugins/keymap';
6
10
  import { createPlugin } from './pm-plugins/main';
7
11
  import { findReplacePluginKey } from './pm-plugins/plugin-key';
@@ -11,6 +15,9 @@ export const findReplacePlugin = ({
11
15
  api
12
16
  }) => {
13
17
  var _api$primaryToolbar;
18
+ const editorViewRef = {
19
+ current: null
20
+ };
14
21
  const primaryToolbarComponent = ({
15
22
  popupsBoundariesElement,
16
23
  popupsMountPoint,
@@ -46,7 +53,7 @@ export const findReplacePlugin = ({
46
53
  return {
47
54
  name: 'findReplace',
48
55
  pmPlugins() {
49
- return [{
56
+ const plugins = [{
50
57
  name: 'findReplace',
51
58
  plugin: ({
52
59
  dispatch
@@ -58,6 +65,26 @@ export const findReplacePlugin = ({
58
65
  return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
59
66
  }
60
67
  }];
68
+ if (editorExperiment('platform_editor_controls', 'variant1', {
69
+ exposure: false
70
+ })) {
71
+ plugins.push({
72
+ name: 'findReplaceEditorViewReferencePlugin',
73
+ plugin: () => {
74
+ return new SafePlugin({
75
+ view: editorView => {
76
+ editorViewRef.current = editorView;
77
+ return {
78
+ destroy: () => {
79
+ editorViewRef.current = null;
80
+ }
81
+ };
82
+ }
83
+ });
84
+ }
85
+ });
86
+ }
87
+ return plugins;
61
88
  },
62
89
  getSharedState(editorState) {
63
90
  if (!editorState) {
@@ -85,6 +112,25 @@ export const findReplacePlugin = ({
85
112
  isToolbarReducedSpacing: isToolbarReducedSpacing,
86
113
  api: api
87
114
  });
115
+ },
116
+ activateFindReplace: triggerMethod => {
117
+ var _api$analytics2;
118
+ if (!editorViewRef.current) {
119
+ return false;
120
+ }
121
+ const {
122
+ state,
123
+ dispatch
124
+ } = editorViewRef.current;
125
+ if (api !== null && api !== void 0 && (_api$analytics2 = api.analytics) !== null && _api$analytics2 !== void 0 && _api$analytics2.actions) {
126
+ var _api$analytics3;
127
+ activateWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)({
128
+ triggerMethod: triggerMethod || TRIGGER_METHOD.EXTERNAL
129
+ })(state, dispatch);
130
+ } else {
131
+ activate()(state, dispatch);
132
+ }
133
+ return true;
88
134
  }
89
135
  },
90
136
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
@@ -112,6 +112,7 @@ class FindReplace extends React.PureComponent {
112
112
  findTyped: this.state.findTyped,
113
113
  setFindTyped: this.setFindTyped
114
114
  }), jsx("hr", {
115
+ role: "presentation",
115
116
  css: ruleStyles,
116
117
  id: "replace-hr-element"
117
118
  }), jsx(Replace, {
@@ -1,7 +1,11 @@
1
1
  import React from 'react';
2
+ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
4
  import { ToolbarSize } from '@atlaskit/editor-common/types';
3
5
  import { fg } from '@atlaskit/platform-feature-flags';
4
6
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
+ import { activate } from './pm-plugins/commands';
8
+ import { activateWithAnalytics } from './pm-plugins/commands-with-analytics';
5
9
  import keymapPlugin from './pm-plugins/keymap';
6
10
  import { createPlugin } from './pm-plugins/main';
7
11
  import { findReplacePluginKey } from './pm-plugins/plugin-key';
@@ -10,6 +14,9 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
10
14
  var _api$primaryToolbar;
11
15
  var props = _ref.config,
12
16
  api = _ref.api;
17
+ var editorViewRef = {
18
+ current: null
19
+ };
13
20
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
14
21
  var popupsBoundariesElement = _ref2.popupsBoundariesElement,
15
22
  popupsMountPoint = _ref2.popupsMountPoint,
@@ -44,7 +51,7 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
44
51
  return {
45
52
  name: 'findReplace',
46
53
  pmPlugins: function pmPlugins() {
47
- return [{
54
+ var plugins = [{
48
55
  name: 'findReplace',
49
56
  plugin: function plugin(_ref3) {
50
57
  var dispatch = _ref3.dispatch;
@@ -57,6 +64,26 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
57
64
  return keymapPlugin(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
58
65
  }
59
66
  }];
67
+ if (editorExperiment('platform_editor_controls', 'variant1', {
68
+ exposure: false
69
+ })) {
70
+ plugins.push({
71
+ name: 'findReplaceEditorViewReferencePlugin',
72
+ plugin: function plugin() {
73
+ return new SafePlugin({
74
+ view: function view(editorView) {
75
+ editorViewRef.current = editorView;
76
+ return {
77
+ destroy: function destroy() {
78
+ editorViewRef.current = null;
79
+ }
80
+ };
81
+ }
82
+ });
83
+ }
84
+ });
85
+ }
86
+ return plugins;
60
87
  },
61
88
  getSharedState: function getSharedState(editorState) {
62
89
  if (!editorState) {
@@ -83,6 +110,24 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
83
110
  isToolbarReducedSpacing: isToolbarReducedSpacing,
84
111
  api: api
85
112
  });
113
+ },
114
+ activateFindReplace: function activateFindReplace(triggerMethod) {
115
+ var _api$analytics2;
116
+ if (!editorViewRef.current) {
117
+ return false;
118
+ }
119
+ var _editorViewRef$curren = editorViewRef.current,
120
+ state = _editorViewRef$curren.state,
121
+ dispatch = _editorViewRef$curren.dispatch;
122
+ if (api !== null && api !== void 0 && (_api$analytics2 = api.analytics) !== null && _api$analytics2 !== void 0 && _api$analytics2.actions) {
123
+ var _api$analytics3;
124
+ activateWithAnalytics(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)({
125
+ triggerMethod: triggerMethod || TRIGGER_METHOD.EXTERNAL
126
+ })(state, dispatch);
127
+ } else {
128
+ activate()(state, dispatch);
129
+ }
130
+ return true;
86
131
  }
87
132
  },
88
133
  primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
@@ -132,6 +132,7 @@ var FindReplace = /*#__PURE__*/function (_React$PureComponent) {
132
132
  findTyped: this.state.findTyped,
133
133
  setFindTyped: this.setFindTyped
134
134
  }), jsx("hr", {
135
+ role: "presentation",
135
136
  css: ruleStyles,
136
137
  id: "replace-hr-element"
137
138
  }), jsx(Replace, {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
5
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
@@ -17,6 +18,7 @@ export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
17
18
  dependencies: FindReplacePluginDependencies;
18
19
  actions: {
19
20
  getToolbarButton: (params: FindReplaceToolbarButtonActionProps) => React.ReactNode;
21
+ activateFindReplace: (triggerMethod?: TRIGGER_METHOD.SHORTCUT | TRIGGER_METHOD.TOOLBAR | TRIGGER_METHOD.EXTERNAL) => boolean;
20
22
  };
21
23
  }>;
22
24
  export {};
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI, TRIGGER_METHOD } from '@atlaskit/editor-common
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  export declare const activateWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, }: {
5
- triggerMethod: TRIGGER_METHOD.SHORTCUT | TRIGGER_METHOD.TOOLBAR;
5
+ triggerMethod: TRIGGER_METHOD.SHORTCUT | TRIGGER_METHOD.TOOLBAR | TRIGGER_METHOD.EXTERNAL;
6
6
  }) => Command;
7
7
  export declare const findWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ editorView, containerElement, keyword, }: {
8
8
  editorView: EditorView;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
2
3
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
5
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
@@ -17,6 +18,7 @@ export type FindReplacePlugin = NextEditorPlugin<'findReplace', {
17
18
  dependencies: FindReplacePluginDependencies;
18
19
  actions: {
19
20
  getToolbarButton: (params: FindReplaceToolbarButtonActionProps) => React.ReactNode;
21
+ activateFindReplace: (triggerMethod?: TRIGGER_METHOD.SHORTCUT | TRIGGER_METHOD.TOOLBAR | TRIGGER_METHOD.EXTERNAL) => boolean;
20
22
  };
21
23
  }>;
22
24
  export {};
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI, TRIGGER_METHOD } from '@atlaskit/editor-common
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  export declare const activateWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ triggerMethod, }: {
5
- triggerMethod: TRIGGER_METHOD.SHORTCUT | TRIGGER_METHOD.TOOLBAR;
5
+ triggerMethod: TRIGGER_METHOD.SHORTCUT | TRIGGER_METHOD.TOOLBAR | TRIGGER_METHOD.EXTERNAL;
6
6
  }) => Command;
7
7
  export declare const findWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ editorView, containerElement, keyword, }: {
8
8
  editorView: EditorView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-find-replace",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "find replace plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,19 +32,19 @@
32
32
  "./styles": "./src/ui/styles.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/button": "^21.1.0",
35
+ "@atlaskit/button": "^22.0.0",
36
36
  "@atlaskit/editor-common": "^102.13.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
38
38
  "@atlaskit/editor-plugin-primary-toolbar": "^3.1.0",
39
39
  "@atlaskit/editor-prosemirror": "7.0.0",
40
40
  "@atlaskit/editor-shared-styles": "^3.4.0",
41
41
  "@atlaskit/form": "^12.0.0",
42
- "@atlaskit/icon": "^25.0.0",
42
+ "@atlaskit/icon": "^25.2.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
44
  "@atlaskit/primitives": "^14.2.0",
45
45
  "@atlaskit/textfield": "^8.0.0",
46
46
  "@atlaskit/theme": "^18.0.0",
47
- "@atlaskit/tmp-editor-statsig": "^4.2.0",
47
+ "@atlaskit/tmp-editor-statsig": "^4.4.0",
48
48
  "@atlaskit/tokens": "^4.5.0",
49
49
  "@atlaskit/tooltip": "^20.0.0",
50
50
  "@babel/runtime": "^7.0.0",