@atlaskit/editor-plugin-selection-extension 7.1.2 → 7.2.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 +19 -0
- package/dist/cjs/pm-plugins/actions/replaceWithAdf.js +3 -2
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/ui/toolbar-components/MenuItem.js +9 -1
- package/dist/es2019/pm-plugins/actions/replaceWithAdf.js +3 -2
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/ui/toolbar-components/MenuItem.js +9 -1
- package/dist/esm/pm-plugins/actions/replaceWithAdf.js +3 -2
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/ui/toolbar-components/MenuItem.js +9 -1
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types-ts4.5/types/index.d.ts +6 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 7.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ed556ceff1790`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ed556ceff1790) -
|
|
8
|
+
Update selectionExtension config to accept lozenge in menu button
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 7.1.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`096e1ff839aa4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/096e1ff839aa4) -
|
|
19
|
+
Clean up `platform_editor_clear_active_extension_fix` feature gate
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 7.1.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.replaceWithAdf = void 0;
|
|
7
7
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
9
|
var _types = require("../../types");
|
|
9
10
|
var _main = require("../main");
|
|
10
11
|
var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf, api) {
|
|
@@ -32,7 +33,7 @@ var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf, a
|
|
|
32
33
|
if (!selectedNode || nodePos === undefined) {
|
|
33
34
|
throw new Error('No selected node or node position found');
|
|
34
35
|
}
|
|
35
|
-
var endPos = selectedNode.
|
|
36
|
+
var endPos = selectedNode.type.name === 'doc' && (0, _platformFeatureFlags.fg)('platform_editor_selection_extension_improvement') ? nodePos + selectedNode.content.size : nodePos + selectedNode.nodeSize;
|
|
36
37
|
var modifiedNode = _model.Node.fromJSON(schema, nodeAdf);
|
|
37
38
|
modifiedNode.check();
|
|
38
39
|
var updatedTr = tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
|
|
@@ -41,7 +42,7 @@ var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf, a
|
|
|
41
42
|
return {
|
|
42
43
|
status: 'success'
|
|
43
44
|
};
|
|
44
|
-
} catch (
|
|
45
|
+
} catch (_unused) {
|
|
45
46
|
dispatch(tr);
|
|
46
47
|
return {
|
|
47
48
|
status: 'failed-to-replace'
|
|
@@ -9,7 +9,6 @@ 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");
|
|
13
12
|
var _types = require("../types");
|
|
14
13
|
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; }
|
|
15
14
|
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; }
|
|
@@ -56,7 +55,7 @@ var createPlugin = exports.createPlugin = function createPlugin() {
|
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
// clear activeExtension if the selection has changed and not empty
|
|
59
|
-
if (tr.selectionSet && !tr.selection.empty
|
|
58
|
+
if (tr.selectionSet && !tr.selection.empty) {
|
|
60
59
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
61
60
|
activeExtension: undefined // Clear active extension on selection change
|
|
62
61
|
});
|
|
@@ -8,6 +8,9 @@ exports.MenuItem = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
10
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
+
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
|
+
var _compiled = require("@atlaskit/primitives/compiled");
|
|
11
14
|
var _main = require("../../pm-plugins/main");
|
|
12
15
|
var _utils = require("../../pm-plugins/utils");
|
|
13
16
|
var _types = require("../../types");
|
|
@@ -53,6 +56,11 @@ var MenuItem = exports.MenuItem = function MenuItem(_ref) {
|
|
|
53
56
|
}),
|
|
54
57
|
onClick: onClickHandle(extension),
|
|
55
58
|
isDisabled: extension.isDisabled
|
|
56
|
-
}, extension.label)
|
|
59
|
+
}, extension.label, extension.lozenge && (0, _platformFeatureFlags.fg)('platform_editor_selection_extension_lozenge') && /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
60
|
+
as: "span",
|
|
61
|
+
paddingInline: "space.100"
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
63
|
+
appearance: 'new'
|
|
64
|
+
}, extension.lozenge.label)));
|
|
57
65
|
}));
|
|
58
66
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { SelectionExtensionActionTypes } from '../../types';
|
|
3
4
|
import { selectionExtensionPluginKey } from '../main';
|
|
4
5
|
export const replaceWithAdf = (nodeAdf, api) => (state, dispatch) => {
|
|
@@ -27,7 +28,7 @@ export const replaceWithAdf = (nodeAdf, api) => (state, dispatch) => {
|
|
|
27
28
|
if (!selectedNode || nodePos === undefined) {
|
|
28
29
|
throw new Error('No selected node or node position found');
|
|
29
30
|
}
|
|
30
|
-
const endPos = selectedNode.
|
|
31
|
+
const endPos = selectedNode.type.name === 'doc' && fg('platform_editor_selection_extension_improvement') ? nodePos + selectedNode.content.size : nodePos + selectedNode.nodeSize;
|
|
31
32
|
const modifiedNode = Node.fromJSON(schema, nodeAdf);
|
|
32
33
|
modifiedNode.check();
|
|
33
34
|
const updatedTr = tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
|
|
@@ -36,7 +37,7 @@ export const replaceWithAdf = (nodeAdf, api) => (state, dispatch) => {
|
|
|
36
37
|
return {
|
|
37
38
|
status: 'success'
|
|
38
39
|
};
|
|
39
|
-
} catch
|
|
40
|
+
} catch {
|
|
40
41
|
dispatch(tr);
|
|
41
42
|
return {
|
|
42
43
|
status: 'failed-to-replace'
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import { SelectionExtensionActionTypes } from '../types';
|
|
6
5
|
export const selectionExtensionPluginKey = new PluginKey('selectionExtensionPlugin');
|
|
7
6
|
export const createPlugin = () => {
|
|
@@ -49,7 +48,7 @@ export const createPlugin = () => {
|
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
// clear activeExtension if the selection has changed and not empty
|
|
52
|
-
if (tr.selectionSet && !tr.selection.empty
|
|
51
|
+
if (tr.selectionSet && !tr.selection.empty) {
|
|
53
52
|
return {
|
|
54
53
|
...pluginState,
|
|
55
54
|
activeExtension: undefined // Clear active extension on selection change
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import Lozenge from '@atlaskit/lozenge';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
4
7
|
import { selectionExtensionPluginKey } from '../../pm-plugins/main';
|
|
5
8
|
import { getSelectionAdfInfoNew, getSelectionTextInfo } from '../../pm-plugins/utils';
|
|
6
9
|
import { SelectionExtensionActionTypes } from '../../types';
|
|
@@ -48,6 +51,11 @@ export const MenuItem = ({
|
|
|
48
51
|
}),
|
|
49
52
|
onClick: onClickHandle(extension),
|
|
50
53
|
isDisabled: extension.isDisabled
|
|
51
|
-
}, extension.label)
|
|
54
|
+
}, extension.label, extension.lozenge && fg('platform_editor_selection_extension_lozenge') && /*#__PURE__*/React.createElement(Box, {
|
|
55
|
+
as: "span",
|
|
56
|
+
paddingInline: "space.100"
|
|
57
|
+
}, /*#__PURE__*/React.createElement(Lozenge, {
|
|
58
|
+
appearance: 'new'
|
|
59
|
+
}, extension.lozenge.label)));
|
|
52
60
|
}));
|
|
53
61
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { SelectionExtensionActionTypes } from '../../types';
|
|
3
4
|
import { selectionExtensionPluginKey } from '../main';
|
|
4
5
|
export var replaceWithAdf = function replaceWithAdf(nodeAdf, api) {
|
|
@@ -26,7 +27,7 @@ export var replaceWithAdf = function replaceWithAdf(nodeAdf, api) {
|
|
|
26
27
|
if (!selectedNode || nodePos === undefined) {
|
|
27
28
|
throw new Error('No selected node or node position found');
|
|
28
29
|
}
|
|
29
|
-
var endPos = selectedNode.
|
|
30
|
+
var endPos = selectedNode.type.name === 'doc' && fg('platform_editor_selection_extension_improvement') ? nodePos + selectedNode.content.size : nodePos + selectedNode.nodeSize;
|
|
30
31
|
var modifiedNode = Node.fromJSON(schema, nodeAdf);
|
|
31
32
|
modifiedNode.check();
|
|
32
33
|
var updatedTr = tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
|
|
@@ -35,7 +36,7 @@ export var replaceWithAdf = function replaceWithAdf(nodeAdf, api) {
|
|
|
35
36
|
return {
|
|
36
37
|
status: 'success'
|
|
37
38
|
};
|
|
38
|
-
} catch (
|
|
39
|
+
} catch (_unused) {
|
|
39
40
|
dispatch(tr);
|
|
40
41
|
return {
|
|
41
42
|
status: 'failed-to-replace'
|
|
@@ -4,7 +4,6 @@ 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';
|
|
8
7
|
import { SelectionExtensionActionTypes } from '../types';
|
|
9
8
|
export var selectionExtensionPluginKey = new PluginKey('selectionExtensionPlugin');
|
|
10
9
|
export var createPlugin = function createPlugin() {
|
|
@@ -49,7 +48,7 @@ export var createPlugin = function createPlugin() {
|
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
50
|
// clear activeExtension if the selection has changed and not empty
|
|
52
|
-
if (tr.selectionSet && !tr.selection.empty
|
|
51
|
+
if (tr.selectionSet && !tr.selection.empty) {
|
|
53
52
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
54
53
|
activeExtension: undefined // Clear active extension on selection change
|
|
55
54
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
3
3
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import Lozenge from '@atlaskit/lozenge';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
4
7
|
import { selectionExtensionPluginKey } from '../../pm-plugins/main';
|
|
5
8
|
import { getSelectionAdfInfoNew, getSelectionTextInfo } from '../../pm-plugins/utils';
|
|
6
9
|
import { SelectionExtensionActionTypes } from '../../types';
|
|
@@ -46,6 +49,11 @@ export var MenuItem = function MenuItem(_ref) {
|
|
|
46
49
|
}),
|
|
47
50
|
onClick: onClickHandle(extension),
|
|
48
51
|
isDisabled: extension.isDisabled
|
|
49
|
-
}, extension.label)
|
|
52
|
+
}, extension.label, extension.lozenge && fg('platform_editor_selection_extension_lozenge') && /*#__PURE__*/React.createElement(Box, {
|
|
53
|
+
as: "span",
|
|
54
|
+
paddingInline: "space.100"
|
|
55
|
+
}, /*#__PURE__*/React.createElement(Lozenge, {
|
|
56
|
+
appearance: 'new'
|
|
57
|
+
}, extension.lozenge.label)));
|
|
50
58
|
}));
|
|
51
59
|
};
|
|
@@ -155,6 +155,12 @@ export type ExtensionMenuItemConfiguration = {
|
|
|
155
155
|
}>>;
|
|
156
156
|
isDisabled?: boolean;
|
|
157
157
|
label: string;
|
|
158
|
+
/**
|
|
159
|
+
* Optional lozenge to display next to the label in the menu
|
|
160
|
+
*/
|
|
161
|
+
lozenge?: {
|
|
162
|
+
label: string;
|
|
163
|
+
};
|
|
158
164
|
onClick?: () => void;
|
|
159
165
|
/**
|
|
160
166
|
* Optional menu-section to declare grouping - only used for menu items
|
|
@@ -155,6 +155,12 @@ export type ExtensionMenuItemConfiguration = {
|
|
|
155
155
|
}>>;
|
|
156
156
|
isDisabled?: boolean;
|
|
157
157
|
label: string;
|
|
158
|
+
/**
|
|
159
|
+
* Optional lozenge to display next to the label in the menu
|
|
160
|
+
*/
|
|
161
|
+
lozenge?: {
|
|
162
|
+
label: string;
|
|
163
|
+
};
|
|
158
164
|
onClick?: () => void;
|
|
159
165
|
/**
|
|
160
166
|
* Optional menu-section to declare grouping - only used for menu items
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.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",
|
|
@@ -47,16 +47,18 @@
|
|
|
47
47
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
48
48
|
"@atlaskit/editor-toolbar": "^0.18.0",
|
|
49
49
|
"@atlaskit/icon": "^29.0.0",
|
|
50
|
+
"@atlaskit/lozenge": "^13.1.0",
|
|
50
51
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
51
52
|
"@atlaskit/platform-feature-flags-react": "^0.4.0",
|
|
52
|
-
"@atlaskit/
|
|
53
|
+
"@atlaskit/primitives": "^16.4.0",
|
|
54
|
+
"@atlaskit/tmp-editor-statsig": "^14.6.0",
|
|
53
55
|
"@babel/runtime": "^7.0.0",
|
|
54
56
|
"lodash": "^4.17.21",
|
|
55
57
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
56
58
|
"uuid": "^3.1.0"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^110.
|
|
61
|
+
"@atlaskit/editor-common": "^110.38.0",
|
|
60
62
|
"react": "^18.2.0"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
@@ -103,10 +105,10 @@
|
|
|
103
105
|
}
|
|
104
106
|
},
|
|
105
107
|
"platform-feature-flags": {
|
|
106
|
-
"
|
|
108
|
+
"platform_editor_use_preferences_plugin": {
|
|
107
109
|
"type": "boolean"
|
|
108
110
|
},
|
|
109
|
-
"
|
|
111
|
+
"platform_editor_selection_extension_lozenge": {
|
|
110
112
|
"type": "boolean"
|
|
111
113
|
},
|
|
112
114
|
"platform_editor_selection_extension_improvement": {
|