@atlaskit/editor-plugin-selection-extension 3.2.0 → 3.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-selection-extension
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#191056](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/191056)
8
+ [`ecf381c9ee85c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ecf381c9ee85c) -
9
+ Update isDisabled prop as boolean type in dynamic configuration
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 3.2.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [#189233](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/189233)
20
+ [`0fe3ab9a767d5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0fe3ab9a767d5) -
21
+ FG cleanup for platform_editor_fix_get_selection_state_mismatch
22
+ - Updated dependencies
23
+
3
24
  ## 3.2.0
4
25
 
5
26
  ### Minor Changes
@@ -130,8 +130,7 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
130
130
  var currentSelection = view.state.selection;
131
131
  var from = currentSelection.from,
132
132
  to = currentSelection.to;
133
- var currentState = (0, _platformFeatureFlags.fg)('platform_editor_fix_get_selection_state_mismatch') ? view.state : state;
134
- var text = currentState.doc.textBetween(from, to, '\n');
133
+ var text = view.state.doc.textBetween(from, to, '\n');
135
134
  var coords = (0, _getBoundingBoxFromSelection.getBoundingBoxFromSelection)(view, from, to);
136
135
  return {
137
136
  text: text,
@@ -182,14 +181,15 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
182
181
  };
183
182
  var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(extension, rank) {
184
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;
185
187
  return {
186
188
  title: extension.name,
187
189
  icon: extension.icon ? /*#__PURE__*/_react.default.createElement(extension.icon, {
188
190
  label: ''
189
191
  }) : undefined,
190
- disabled: extension === null || extension === void 0 || (_extension$isDisabled = extension.isDisabled) === null || _extension$isDisabled === void 0 ? void 0 : _extension$isDisabled.call(extension, {
191
- selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
192
- }),
192
+ disabled: disabled,
193
193
  rank: rank,
194
194
  onClick: function onClick() {
195
195
  editorViewRef.current && handleOnExtensionClick(editorViewRef.current)(extension);
@@ -129,8 +129,7 @@ export const selectionExtensionPlugin = ({
129
129
  from,
130
130
  to
131
131
  } = currentSelection;
132
- const currentState = fg('platform_editor_fix_get_selection_state_mismatch') ? view.state : state;
133
- const text = currentState.doc.textBetween(from, to, '\n');
132
+ const text = view.state.doc.textBetween(from, to, '\n');
134
133
  const coords = getBoundingBoxFromSelection(view, from, to);
135
134
  return {
136
135
  text,
@@ -181,14 +180,15 @@ export const selectionExtensionPlugin = ({
181
180
  };
182
181
  const convertExtensionToDropdownMenuItem = (extension, rank) => {
183
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;
184
186
  return {
185
187
  title: extension.name,
186
188
  icon: extension.icon ? /*#__PURE__*/React.createElement(extension.icon, {
187
189
  label: ''
188
190
  }) : undefined,
189
- disabled: extension === null || extension === void 0 ? void 0 : (_extension$isDisabled = extension.isDisabled) === null || _extension$isDisabled === void 0 ? void 0 : _extension$isDisabled.call(extension, {
190
- selection: editorViewRef.current ? getSelection(editorViewRef.current) : undefined
191
- }),
191
+ disabled,
192
192
  rank,
193
193
  onClick: () => {
194
194
  editorViewRef.current && handleOnExtensionClick(editorViewRef.current)(extension);
@@ -123,8 +123,7 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
123
123
  var currentSelection = view.state.selection;
124
124
  var from = currentSelection.from,
125
125
  to = currentSelection.to;
126
- var currentState = fg('platform_editor_fix_get_selection_state_mismatch') ? view.state : state;
127
- var text = currentState.doc.textBetween(from, to, '\n');
126
+ var text = view.state.doc.textBetween(from, to, '\n');
128
127
  var coords = getBoundingBoxFromSelection(view, from, to);
129
128
  return {
130
129
  text: text,
@@ -175,14 +174,15 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
175
174
  };
176
175
  var convertExtensionToDropdownMenuItem = function convertExtensionToDropdownMenuItem(extension, rank) {
177
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;
178
180
  return {
179
181
  title: extension.name,
180
182
  icon: extension.icon ? /*#__PURE__*/React.createElement(extension.icon, {
181
183
  label: ''
182
184
  }) : undefined,
183
- disabled: extension === null || extension === 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
- }),
185
+ disabled: disabled,
186
186
  rank: rank,
187
187
  onClick: function onClick() {
188
188
  editorViewRef.current && handleOnExtensionClick(editorViewRef.current)(extension);
@@ -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) => SelectionExtension;
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) => SelectionExtension;
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.2.0",
3
+ "version": "3.3.0",
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.5.0",
45
+ "@atlaskit/icon": "^27.6.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
47
  "@atlaskit/primitives": "^14.10.0",
48
- "@atlaskit/tmp-editor-statsig": "^9.9.0",
48
+ "@atlaskit/tmp-editor-statsig": "^9.12.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.9.0",
55
+ "@atlaskit/editor-common": "^107.12.0",
56
56
  "react": "^18.2.0"
57
57
  },
58
58
  "devDependencies": {
@@ -106,9 +106,6 @@
106
106
  "platform-feature-flags": {
107
107
  "platform_editor_selection_extension_api_v2": {
108
108
  "type": "boolean"
109
- },
110
- "platform_editor_fix_get_selection_state_mismatch": {
111
- "type": "boolean"
112
109
  }
113
110
  }
114
111
  }