@atlaskit/editor-plugin-find-replace 2.0.5 → 2.0.6
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 +9 -0
- package/dist/cjs/findReplacePlugin.js +46 -1
- package/dist/es2019/findReplacePlugin.js +47 -1
- package/dist/esm/findReplacePlugin.js +46 -1
- package/dist/types/findReplacePluginType.d.ts +2 -0
- package/dist/types/pm-plugins/commands-with-analytics.d.ts +1 -1
- package/dist/types-ts4.5/findReplacePluginType.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/commands-with-analytics.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-find-replace
|
|
2
2
|
|
|
3
|
+
## 2.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#131023](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131023)
|
|
8
|
+
[`05f7d6e19eb6d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05f7d6e19eb6d) -
|
|
9
|
+
Added activateFindReplace action to findReplacePlugin to activate Find and Replace popup
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 2.0.5
|
|
4
13
|
|
|
5
14
|
### 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
|
-
|
|
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,
|
|
@@ -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
|
-
|
|
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,
|
|
@@ -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
|
-
|
|
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,
|
|
@@ -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.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
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.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^4.3.0",
|
|
48
48
|
"@atlaskit/tokens": "^4.5.0",
|
|
49
49
|
"@atlaskit/tooltip": "^20.0.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|