@atlaskit/editor-plugin-selection-extension 3.2.1 → 3.3.1
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 +20 -0
- package/dist/cjs/pm-plugins/main.js +7 -0
- package/dist/cjs/selectionExtensionPlugin.js +4 -3
- package/dist/es2019/pm-plugins/main.js +8 -0
- package/dist/es2019/selectionExtensionPlugin.js +4 -3
- package/dist/esm/pm-plugins/main.js +7 -0
- package/dist/esm/selectionExtensionPlugin.js +4 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/selectionExtensionPluginType.d.ts +2 -2
- package/dist/types/types/index.d.ts +4 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +2 -2
- package/dist/types-ts4.5/types/index.d.ts +4 -1
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 3.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#191736](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191736)
|
|
8
|
+
[`5c91794777225`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5c91794777225) -
|
|
9
|
+
Clear activeExtension when selection changed
|
|
10
|
+
|
|
11
|
+
## 3.3.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#191056](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191056)
|
|
16
|
+
[`ecf381c9ee85c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ecf381c9ee85c) -
|
|
17
|
+
Update isDisabled prop as boolean type in dynamic configuration
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 3.2.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _types = require("../types");
|
|
13
14
|
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; }
|
|
14
15
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -54,6 +55,12 @@ var createPlugin = exports.createPlugin = function createPlugin() {
|
|
|
54
55
|
startTrackChanges: false // Reset the flag to stop tracking after the document has changed
|
|
55
56
|
});
|
|
56
57
|
}
|
|
58
|
+
// clear activeExtension if the selection has changed and not empty
|
|
59
|
+
if (tr.selectionSet && !tr.selection.empty && (0, _platformFeatureFlags.fg)('platform_editor_clear_active_extension_fix')) {
|
|
60
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
61
|
+
activeExtension: undefined // Clear active extension on selection change
|
|
62
|
+
});
|
|
63
|
+
}
|
|
57
64
|
return pluginState;
|
|
58
65
|
}
|
|
59
66
|
}
|
|
@@ -181,14 +181,15 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
181
181
|
};
|
|
182
182
|
var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(extension, rank) {
|
|
183
183
|
var _extension$isDisabled;
|
|
184
|
+
var disabled = (extension === null || extension === void 0 ? void 0 : extension.isDisabled) instanceof Function ? extension === null || extension === void 0 || (_extension$isDisabled = extension.isDisabled) === null || _extension$isDisabled === void 0 ? void 0 : _extension$isDisabled.call(extension, {
|
|
185
|
+
selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
|
|
186
|
+
}) : extension === null || extension === void 0 ? void 0 : extension.isDisabled;
|
|
184
187
|
return {
|
|
185
188
|
title: extension.name,
|
|
186
189
|
icon: extension.icon ? /*#__PURE__*/_react.default.createElement(extension.icon, {
|
|
187
190
|
label: ''
|
|
188
191
|
}) : undefined,
|
|
189
|
-
disabled:
|
|
190
|
-
selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
|
|
191
|
-
}),
|
|
192
|
+
disabled: disabled,
|
|
192
193
|
rank: rank,
|
|
193
194
|
onClick: function onClick() {
|
|
194
195
|
editorViewRef.current && handleOnExtensionClick(editorViewRef.current)(extension);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { SelectionExtensionActionTypes } from '../types';
|
|
5
6
|
export const selectionExtensionPluginKey = new PluginKey('selectionExtensionPlugin');
|
|
6
7
|
export const createPlugin = () => {
|
|
@@ -47,6 +48,13 @@ export const createPlugin = () => {
|
|
|
47
48
|
startTrackChanges: false // Reset the flag to stop tracking after the document has changed
|
|
48
49
|
};
|
|
49
50
|
}
|
|
51
|
+
// clear activeExtension if the selection has changed and not empty
|
|
52
|
+
if (tr.selectionSet && !tr.selection.empty && fg('platform_editor_clear_active_extension_fix')) {
|
|
53
|
+
return {
|
|
54
|
+
...pluginState,
|
|
55
|
+
activeExtension: undefined // Clear active extension on selection change
|
|
56
|
+
};
|
|
57
|
+
}
|
|
50
58
|
return pluginState;
|
|
51
59
|
}
|
|
52
60
|
}
|
|
@@ -180,14 +180,15 @@ export const selectionExtensionPlugin = ({
|
|
|
180
180
|
};
|
|
181
181
|
const convertExtensionToDropdownMenuItem = (extension, rank) => {
|
|
182
182
|
var _extension$isDisabled;
|
|
183
|
+
const disabled = (extension === null || extension === void 0 ? void 0 : extension.isDisabled) instanceof Function ? extension === null || extension === void 0 ? void 0 : (_extension$isDisabled = extension.isDisabled) === null || _extension$isDisabled === void 0 ? void 0 : _extension$isDisabled.call(extension, {
|
|
184
|
+
selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
|
|
185
|
+
}) : extension === null || extension === void 0 ? void 0 : extension.isDisabled;
|
|
183
186
|
return {
|
|
184
187
|
title: extension.name,
|
|
185
188
|
icon: extension.icon ? /*#__PURE__*/React.createElement(extension.icon, {
|
|
186
189
|
label: ''
|
|
187
190
|
}) : undefined,
|
|
188
|
-
disabled
|
|
189
|
-
selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
|
|
190
|
-
}),
|
|
191
|
+
disabled,
|
|
191
192
|
rank,
|
|
192
193
|
onClick: () => {
|
|
193
194
|
editorViewRef.current && handleOnExtensionClick(editorViewRef.current)(extension);
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { SelectionExtensionActionTypes } from '../types';
|
|
8
9
|
export var selectionExtensionPluginKey = new PluginKey('selectionExtensionPlugin');
|
|
9
10
|
export var createPlugin = function createPlugin() {
|
|
@@ -47,6 +48,12 @@ export var createPlugin = function createPlugin() {
|
|
|
47
48
|
startTrackChanges: false // Reset the flag to stop tracking after the document has changed
|
|
48
49
|
});
|
|
49
50
|
}
|
|
51
|
+
// clear activeExtension if the selection has changed and not empty
|
|
52
|
+
if (tr.selectionSet && !tr.selection.empty && fg('platform_editor_clear_active_extension_fix')) {
|
|
53
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
54
|
+
activeExtension: undefined // Clear active extension on selection change
|
|
55
|
+
});
|
|
56
|
+
}
|
|
50
57
|
return pluginState;
|
|
51
58
|
}
|
|
52
59
|
}
|
|
@@ -174,14 +174,15 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
174
174
|
};
|
|
175
175
|
var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(extension, rank) {
|
|
176
176
|
var _extension$isDisabled;
|
|
177
|
+
var disabled = (extension === null || extension === void 0 ? void 0 : extension.isDisabled) instanceof Function ? extension === null || extension === void 0 || (_extension$isDisabled = extension.isDisabled) === null || _extension$isDisabled === void 0 ? void 0 : _extension$isDisabled.call(extension, {
|
|
178
|
+
selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
|
|
179
|
+
}) : extension === null || extension === void 0 ? void 0 : extension.isDisabled;
|
|
177
180
|
return {
|
|
178
181
|
title: extension.name,
|
|
179
182
|
icon: extension.icon ? /*#__PURE__*/React.createElement(extension.icon, {
|
|
180
183
|
label: ''
|
|
181
184
|
}) : undefined,
|
|
182
|
-
disabled:
|
|
183
|
-
selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
|
|
184
|
-
}),
|
|
185
|
+
disabled: disabled,
|
|
185
186
|
rank: rank,
|
|
186
187
|
onClick: function onClick() {
|
|
187
188
|
editorViewRef.current && handleOnExtensionClick(editorViewRef.current)(extension);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { selectionExtensionPlugin } from './selectionExtensionPlugin';
|
|
2
2
|
export type { SelectionExtensionPlugin } from './selectionExtensionPluginType';
|
|
3
|
-
export type { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, } from './types';
|
|
3
|
+
export type { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, DynamicSelectionExtension, } from './types';
|
|
@@ -3,7 +3,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
|
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
5
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
6
|
-
import type { LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
6
|
+
import type { DynamicSelectionExtension, LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
7
7
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
8
8
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
9
9
|
dependencies: [
|
|
@@ -14,7 +14,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
14
14
|
sharedState: SelectionExtensionPluginState | null;
|
|
15
15
|
commands: {
|
|
16
16
|
setActiveExtension: ({ extension, selection, }: {
|
|
17
|
-
extension: SelectionExtension;
|
|
17
|
+
extension: SelectionExtension | DynamicSelectionExtension;
|
|
18
18
|
selection: SelectionExtensionSelectionInfo;
|
|
19
19
|
}) => EditorCommand;
|
|
20
20
|
clearActiveExtension: () => EditorCommand;
|
|
@@ -36,6 +36,9 @@ export type SelectionExtension = {
|
|
|
36
36
|
onClick?: (params: SelectionExtensionCallbackOptions) => void;
|
|
37
37
|
component?: React.ComponentType<SelectionExtensionComponentProps>;
|
|
38
38
|
};
|
|
39
|
+
export type DynamicSelectionExtension = Omit<SelectionExtension, 'isDisabled'> & {
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
};
|
|
39
42
|
export type SelectionPointer = {
|
|
40
43
|
pointer: string;
|
|
41
44
|
position?: number;
|
|
@@ -48,7 +51,7 @@ export type SelectionExtensionFnOptions = {
|
|
|
48
51
|
selectedNodeAdf: ADFEntity;
|
|
49
52
|
selectionRanges: SelectionRange[];
|
|
50
53
|
};
|
|
51
|
-
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) =>
|
|
54
|
+
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) => DynamicSelectionExtension;
|
|
52
55
|
export type SelectionExtensionConfig = SelectionExtension | SelectionExtensionFn;
|
|
53
56
|
export type SelectionExtensions = {
|
|
54
57
|
firstParty?: SelectionExtensionConfig[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { selectionExtensionPlugin } from './selectionExtensionPlugin';
|
|
2
2
|
export type { SelectionExtensionPlugin } from './selectionExtensionPluginType';
|
|
3
|
-
export type { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, } from './types';
|
|
3
|
+
export type { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, DynamicSelectionExtension, } from './types';
|
|
@@ -3,7 +3,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
|
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
5
5
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
6
|
-
import type { LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
6
|
+
import type { DynamicSelectionExtension, LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
7
7
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
8
8
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
9
9
|
dependencies: [
|
|
@@ -14,7 +14,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
14
14
|
sharedState: SelectionExtensionPluginState | null;
|
|
15
15
|
commands: {
|
|
16
16
|
setActiveExtension: ({ extension, selection, }: {
|
|
17
|
-
extension: SelectionExtension;
|
|
17
|
+
extension: SelectionExtension | DynamicSelectionExtension;
|
|
18
18
|
selection: SelectionExtensionSelectionInfo;
|
|
19
19
|
}) => EditorCommand;
|
|
20
20
|
clearActiveExtension: () => EditorCommand;
|
|
@@ -36,6 +36,9 @@ export type SelectionExtension = {
|
|
|
36
36
|
onClick?: (params: SelectionExtensionCallbackOptions) => void;
|
|
37
37
|
component?: React.ComponentType<SelectionExtensionComponentProps>;
|
|
38
38
|
};
|
|
39
|
+
export type DynamicSelectionExtension = Omit<SelectionExtension, 'isDisabled'> & {
|
|
40
|
+
isDisabled?: boolean;
|
|
41
|
+
};
|
|
39
42
|
export type SelectionPointer = {
|
|
40
43
|
pointer: string;
|
|
41
44
|
position?: number;
|
|
@@ -48,7 +51,7 @@ export type SelectionExtensionFnOptions = {
|
|
|
48
51
|
selectedNodeAdf: ADFEntity;
|
|
49
52
|
selectionRanges: SelectionRange[];
|
|
50
53
|
};
|
|
51
|
-
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) =>
|
|
54
|
+
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) => DynamicSelectionExtension;
|
|
52
55
|
export type SelectionExtensionConfig = SelectionExtension | SelectionExtensionFn;
|
|
53
56
|
export type SelectionExtensions = {
|
|
54
57
|
firstParty?: SelectionExtensionConfig[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "editor-plugin-selection-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
"@atlaskit/editor-plugin-selection-toolbar": "^4.2.0",
|
|
43
43
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
44
44
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
45
|
-
"@atlaskit/icon": "^27.
|
|
45
|
+
"@atlaskit/icon": "^27.7.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/primitives": "^14.10.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^9.16.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"lodash": "^4.17.21",
|
|
51
51
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
52
52
|
"uuid": "^3.1.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@atlaskit/editor-common": "^107.
|
|
55
|
+
"@atlaskit/editor-common": "^107.12.0",
|
|
56
56
|
"react": "^18.2.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
@@ -104,6 +104,9 @@
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"platform-feature-flags": {
|
|
107
|
+
"platform_editor_clear_active_extension_fix": {
|
|
108
|
+
"type": "boolean"
|
|
109
|
+
},
|
|
107
110
|
"platform_editor_selection_extension_api_v2": {
|
|
108
111
|
"type": "boolean"
|
|
109
112
|
}
|