@atlaskit/editor-plugin-selection-extension 3.4.4 → 3.4.5
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 +7 -0
- package/dist/cjs/pm-plugins/utils/index.js +38 -16
- package/dist/cjs/selectionExtensionPlugin.js +11 -0
- package/dist/es2019/pm-plugins/utils/index.js +35 -14
- package/dist/es2019/selectionExtensionPlugin.js +15 -1
- package/dist/esm/pm-plugins/utils/index.js +35 -15
- package/dist/esm/selectionExtensionPlugin.js +12 -1
- package/dist/types/pm-plugins/utils/index.d.ts +6 -3
- package/dist/types/selectionExtensionPluginType.d.ts +3 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/utils/index.d.ts +6 -3
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +3 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 3.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fa1ff19077d8b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa1ff19077d8b) -
|
|
8
|
+
Update getSelectionAdf api to return adf fragment under flag
|
|
9
|
+
|
|
3
10
|
## 3.4.4
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -4,14 +4,22 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.getFragmentInfoFromSelection = void 0;
|
|
8
|
+
exports.getSelectionAdfInfo = getSelectionAdfInfo;
|
|
9
|
+
exports.validateSelectedNode = exports.getSelectionTextInfo = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
11
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
9
13
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
14
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
17
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
18
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
13
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
20
|
var _getBoundingBoxFromSelection = require("../../ui/getBoundingBoxFromSelection");
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
15
23
|
var getSelectedRect = function getSelectedRect(selection) {
|
|
16
24
|
var $anchorCell = selection.$anchorCell,
|
|
17
25
|
$headCell = selection.$headCell;
|
|
@@ -33,7 +41,7 @@ var getSelectionInfoFromSameNode = function getSelectionInfoFromSameNode(selecti
|
|
|
33
41
|
},
|
|
34
42
|
end: {
|
|
35
43
|
pointer: "/content/".concat($from.index(), "/text"),
|
|
36
|
-
position: $to.parentOffset
|
|
44
|
+
position: $to.parentOffset
|
|
37
45
|
}
|
|
38
46
|
}],
|
|
39
47
|
nodePos: $from.before() // position before the selection
|
|
@@ -80,11 +88,32 @@ var getSelectionTextInfo = exports.getSelectionTextInfo = function getSelectionT
|
|
|
80
88
|
coords: coords
|
|
81
89
|
};
|
|
82
90
|
};
|
|
83
|
-
var
|
|
91
|
+
var getFragmentInfoFromSelection = exports.getFragmentInfoFromSelection = function getFragmentInfoFromSelection(state) {
|
|
92
|
+
var schema = state.schema,
|
|
93
|
+
selection = state.selection;
|
|
94
|
+
var slice = selection.content();
|
|
95
|
+
var newDoc;
|
|
96
|
+
try {
|
|
97
|
+
var _schema = state.schema;
|
|
98
|
+
var doc = _schema.node('doc', null, [_schema.node('paragraph', null, [])]);
|
|
99
|
+
var transform = new _transform.Transform(doc);
|
|
100
|
+
newDoc = transform.replaceRange(0, 2, slice).doc;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
newDoc = schema.nodes.doc.createChecked({}, _model.Fragment.empty);
|
|
103
|
+
(0, _monitoring.logException)(error, {
|
|
104
|
+
location: 'editor-plugin-selection-extension'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
var serializer = new _editorJsonTransformer.JSONTransformer();
|
|
108
|
+
var selectedNodeAdf = serializer.encodeNode(newDoc);
|
|
109
|
+
return {
|
|
110
|
+
selectedNodeAdf: selectedNodeAdf
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
function getSelectionAdfInfo(state) {
|
|
84
114
|
var selection = state.selection;
|
|
85
115
|
var selectionInfo = {
|
|
86
116
|
selectedNode: selection.$from.node(),
|
|
87
|
-
selectionRanges: [],
|
|
88
117
|
nodePos: selection.$from.before() // default to the position before the selection
|
|
89
118
|
};
|
|
90
119
|
if (selection instanceof _state.TextSelection) {
|
|
@@ -99,18 +128,11 @@ var getSelectionAdfInfo = exports.getSelectionAdfInfo = function getSelectionAdf
|
|
|
99
128
|
selectionInfo = getSelectionInfoFromCellSelection(selection);
|
|
100
129
|
}
|
|
101
130
|
var serializer = new _editorJsonTransformer.JSONTransformer();
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
selectedNodeAdf: selectedNodeAdf,
|
|
109
|
-
selectionRanges: selectionRanges,
|
|
110
|
-
selectedNode: selectedNode,
|
|
111
|
-
nodePos: nodePos
|
|
112
|
-
};
|
|
113
|
-
};
|
|
131
|
+
var selectedNodeAdf = serializer.encodeNode(selectionInfo.selectedNode);
|
|
132
|
+
return _objectSpread(_objectSpread({}, selectionInfo), {}, {
|
|
133
|
+
selectedNodeAdf: selectedNodeAdf
|
|
134
|
+
});
|
|
135
|
+
}
|
|
114
136
|
var validateSelectedNode = exports.validateSelectedNode = function validateSelectedNode(selectedNodeAdf, selectedNode) {
|
|
115
137
|
var serializer = new _editorJsonTransformer.JSONTransformer();
|
|
116
138
|
var selectedNodeAdfFromState = serializer.encodeNode(selectedNode);
|
|
@@ -127,6 +127,17 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
127
127
|
selectionRanges: selectionRanges
|
|
128
128
|
};
|
|
129
129
|
},
|
|
130
|
+
getDocumentFromSelection: function getDocumentFromSelection() {
|
|
131
|
+
if (!editorViewRef.current) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
var state = editorViewRef.current.state;
|
|
135
|
+
var _getFragmentInfoFromS = (0, _utils.getFragmentInfoFromSelection)(state),
|
|
136
|
+
selectedNodeAdf = _getFragmentInfoFromS.selectedNodeAdf;
|
|
137
|
+
return {
|
|
138
|
+
selectedNodeAdf: selectedNodeAdf
|
|
139
|
+
};
|
|
140
|
+
},
|
|
130
141
|
getSelectionText: function getSelectionText() {
|
|
131
142
|
if (!editorViewRef.current) {
|
|
132
143
|
return null;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import isEqual from 'lodash/isEqual';
|
|
2
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
2
3
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
4
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
5
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { Transform } from '@atlaskit/editor-prosemirror/transform';
|
|
4
7
|
import { akEditorFullPageToolbarHeight } from '@atlaskit/editor-shared-styles';
|
|
5
8
|
import { CellSelection, TableMap } from '@atlaskit/editor-tables';
|
|
6
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -30,7 +33,7 @@ const getSelectionInfoFromSameNode = selection => {
|
|
|
30
33
|
},
|
|
31
34
|
end: {
|
|
32
35
|
pointer: `/content/${$from.index()}/text`,
|
|
33
|
-
position: $to.parentOffset
|
|
36
|
+
position: $to.parentOffset
|
|
34
37
|
}
|
|
35
38
|
}],
|
|
36
39
|
nodePos: $from.before() // position before the selection
|
|
@@ -81,11 +84,36 @@ export const getSelectionTextInfo = (view, api) => {
|
|
|
81
84
|
coords
|
|
82
85
|
};
|
|
83
86
|
};
|
|
84
|
-
export const
|
|
87
|
+
export const getFragmentInfoFromSelection = state => {
|
|
88
|
+
const {
|
|
89
|
+
schema,
|
|
90
|
+
selection
|
|
91
|
+
} = state;
|
|
92
|
+
const slice = selection.content();
|
|
93
|
+
let newDoc;
|
|
94
|
+
try {
|
|
95
|
+
const {
|
|
96
|
+
schema
|
|
97
|
+
} = state;
|
|
98
|
+
const doc = schema.node('doc', null, [schema.node('paragraph', null, [])]);
|
|
99
|
+
const transform = new Transform(doc);
|
|
100
|
+
newDoc = transform.replaceRange(0, 2, slice).doc;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
newDoc = schema.nodes.doc.createChecked({}, Fragment.empty);
|
|
103
|
+
logException(error, {
|
|
104
|
+
location: 'editor-plugin-selection-extension'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const serializer = new JSONTransformer();
|
|
108
|
+
const selectedNodeAdf = serializer.encodeNode(newDoc);
|
|
109
|
+
return {
|
|
110
|
+
selectedNodeAdf
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export function getSelectionAdfInfo(state) {
|
|
85
114
|
const selection = state.selection;
|
|
86
115
|
let selectionInfo = {
|
|
87
116
|
selectedNode: selection.$from.node(),
|
|
88
|
-
selectionRanges: [],
|
|
89
117
|
nodePos: selection.$from.before() // default to the position before the selection
|
|
90
118
|
};
|
|
91
119
|
if (selection instanceof TextSelection) {
|
|
@@ -102,19 +130,12 @@ export const getSelectionAdfInfo = state => {
|
|
|
102
130
|
selectionInfo = getSelectionInfoFromCellSelection(selection);
|
|
103
131
|
}
|
|
104
132
|
const serializer = new JSONTransformer();
|
|
105
|
-
const
|
|
106
|
-
selectionRanges,
|
|
107
|
-
selectedNode,
|
|
108
|
-
nodePos
|
|
109
|
-
} = selectionInfo;
|
|
110
|
-
const selectedNodeAdf = serializer.encodeNode(selectedNode);
|
|
133
|
+
const selectedNodeAdf = serializer.encodeNode(selectionInfo.selectedNode);
|
|
111
134
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
selectedNode,
|
|
115
|
-
nodePos
|
|
135
|
+
...selectionInfo,
|
|
136
|
+
selectedNodeAdf
|
|
116
137
|
};
|
|
117
|
-
}
|
|
138
|
+
}
|
|
118
139
|
export const validateSelectedNode = (selectedNodeAdf, selectedNode) => {
|
|
119
140
|
const serializer = new JSONTransformer();
|
|
120
141
|
const selectedNodeAdfFromState = serializer.encodeNode(selectedNode);
|
|
@@ -6,7 +6,7 @@ import { insertSmartLinks } from './pm-plugins/actions';
|
|
|
6
6
|
import { insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
7
7
|
import { replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
8
8
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
9
|
-
import { getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
|
|
9
|
+
import { getFragmentInfoFromSelection, getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
|
|
10
10
|
import { SelectionExtensionActionTypes } from './types';
|
|
11
11
|
import { SelectionExtensionComponentWrapper } from './ui/extension/SelectionExtensionComponentWrapper';
|
|
12
12
|
import { getMenuItemExtensions, getToolbarItemExtensions } from './ui/extensions';
|
|
@@ -120,6 +120,20 @@ export const selectionExtensionPlugin = ({
|
|
|
120
120
|
selectionRanges
|
|
121
121
|
};
|
|
122
122
|
},
|
|
123
|
+
getDocumentFromSelection: () => {
|
|
124
|
+
if (!editorViewRef.current) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const {
|
|
128
|
+
state
|
|
129
|
+
} = editorViewRef.current;
|
|
130
|
+
const {
|
|
131
|
+
selectedNodeAdf
|
|
132
|
+
} = getFragmentInfoFromSelection(state);
|
|
133
|
+
return {
|
|
134
|
+
selectedNodeAdf
|
|
135
|
+
};
|
|
136
|
+
},
|
|
123
137
|
getSelectionText: () => {
|
|
124
138
|
if (!editorViewRef.current) {
|
|
125
139
|
return null;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
1
4
|
import isEqual from 'lodash/isEqual';
|
|
5
|
+
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
2
6
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
7
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { Transform } from '@atlaskit/editor-prosemirror/transform';
|
|
4
10
|
import { akEditorFullPageToolbarHeight } from '@atlaskit/editor-shared-styles';
|
|
5
11
|
import { CellSelection, TableMap } from '@atlaskit/editor-tables';
|
|
6
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -26,7 +32,7 @@ var getSelectionInfoFromSameNode = function getSelectionInfoFromSameNode(selecti
|
|
|
26
32
|
},
|
|
27
33
|
end: {
|
|
28
34
|
pointer: "/content/".concat($from.index(), "/text"),
|
|
29
|
-
position: $to.parentOffset
|
|
35
|
+
position: $to.parentOffset
|
|
30
36
|
}
|
|
31
37
|
}],
|
|
32
38
|
nodePos: $from.before() // position before the selection
|
|
@@ -73,11 +79,32 @@ export var getSelectionTextInfo = function getSelectionTextInfo(view, api) {
|
|
|
73
79
|
coords: coords
|
|
74
80
|
};
|
|
75
81
|
};
|
|
76
|
-
export var
|
|
82
|
+
export var getFragmentInfoFromSelection = function getFragmentInfoFromSelection(state) {
|
|
83
|
+
var schema = state.schema,
|
|
84
|
+
selection = state.selection;
|
|
85
|
+
var slice = selection.content();
|
|
86
|
+
var newDoc;
|
|
87
|
+
try {
|
|
88
|
+
var _schema = state.schema;
|
|
89
|
+
var doc = _schema.node('doc', null, [_schema.node('paragraph', null, [])]);
|
|
90
|
+
var transform = new Transform(doc);
|
|
91
|
+
newDoc = transform.replaceRange(0, 2, slice).doc;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
newDoc = schema.nodes.doc.createChecked({}, Fragment.empty);
|
|
94
|
+
logException(error, {
|
|
95
|
+
location: 'editor-plugin-selection-extension'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
var serializer = new JSONTransformer();
|
|
99
|
+
var selectedNodeAdf = serializer.encodeNode(newDoc);
|
|
100
|
+
return {
|
|
101
|
+
selectedNodeAdf: selectedNodeAdf
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export function getSelectionAdfInfo(state) {
|
|
77
105
|
var selection = state.selection;
|
|
78
106
|
var selectionInfo = {
|
|
79
107
|
selectedNode: selection.$from.node(),
|
|
80
|
-
selectionRanges: [],
|
|
81
108
|
nodePos: selection.$from.before() // default to the position before the selection
|
|
82
109
|
};
|
|
83
110
|
if (selection instanceof TextSelection) {
|
|
@@ -92,18 +119,11 @@ export var getSelectionAdfInfo = function getSelectionAdfInfo(state) {
|
|
|
92
119
|
selectionInfo = getSelectionInfoFromCellSelection(selection);
|
|
93
120
|
}
|
|
94
121
|
var serializer = new JSONTransformer();
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
selectedNodeAdf: selectedNodeAdf,
|
|
102
|
-
selectionRanges: selectionRanges,
|
|
103
|
-
selectedNode: selectedNode,
|
|
104
|
-
nodePos: nodePos
|
|
105
|
-
};
|
|
106
|
-
};
|
|
122
|
+
var selectedNodeAdf = serializer.encodeNode(selectionInfo.selectedNode);
|
|
123
|
+
return _objectSpread(_objectSpread({}, selectionInfo), {}, {
|
|
124
|
+
selectedNodeAdf: selectedNodeAdf
|
|
125
|
+
});
|
|
126
|
+
}
|
|
107
127
|
export var validateSelectedNode = function validateSelectedNode(selectedNodeAdf, selectedNode) {
|
|
108
128
|
var serializer = new JSONTransformer();
|
|
109
129
|
var selectedNodeAdfFromState = serializer.encodeNode(selectedNode);
|
|
@@ -7,7 +7,7 @@ import { insertSmartLinks as _insertSmartLinks } from './pm-plugins/actions';
|
|
|
7
7
|
import { insertAdfAtEndOfDoc as _insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
8
8
|
import { replaceWithAdf as _replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
9
9
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
10
|
-
import { getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
|
|
10
|
+
import { getFragmentInfoFromSelection, getSelectionAdfInfo, getSelectionTextInfo } from './pm-plugins/utils';
|
|
11
11
|
import { SelectionExtensionActionTypes } from './types';
|
|
12
12
|
import { SelectionExtensionComponentWrapper } from './ui/extension/SelectionExtensionComponentWrapper';
|
|
13
13
|
import { getMenuItemExtensions, getToolbarItemExtensions } from './ui/extensions';
|
|
@@ -120,6 +120,17 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
120
120
|
selectionRanges: selectionRanges
|
|
121
121
|
};
|
|
122
122
|
},
|
|
123
|
+
getDocumentFromSelection: function getDocumentFromSelection() {
|
|
124
|
+
if (!editorViewRef.current) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
var state = editorViewRef.current.state;
|
|
128
|
+
var _getFragmentInfoFromS = getFragmentInfoFromSelection(state),
|
|
129
|
+
selectedNodeAdf = _getFragmentInfoFromS.selectedNodeAdf;
|
|
130
|
+
return {
|
|
131
|
+
selectedNodeAdf: selectedNodeAdf
|
|
132
|
+
};
|
|
133
|
+
},
|
|
123
134
|
getSelectionText: function getSelectionText() {
|
|
124
135
|
if (!editorViewRef.current) {
|
|
125
136
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { SelectionExtensionPlugin } from '../../selectionExtensionPluginType';
|
|
@@ -8,11 +8,14 @@ import type { SelectionExtensionSelectionInfo } from '../../types';
|
|
|
8
8
|
import { type SelectionRange } from '../../types';
|
|
9
9
|
type SelectionInfo = {
|
|
10
10
|
selectedNodeAdf: ADFEntity;
|
|
11
|
-
selectionRanges
|
|
11
|
+
selectionRanges?: SelectionRange[];
|
|
12
12
|
selectedNode: PMNode;
|
|
13
13
|
nodePos: number;
|
|
14
14
|
};
|
|
15
15
|
export declare const getSelectionTextInfo: (view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const getFragmentInfoFromSelection: (state: EditorState) => {
|
|
17
|
+
selectedNodeAdf: ADFEntity;
|
|
18
|
+
};
|
|
19
|
+
export declare function getSelectionAdfInfo(state: EditorState): SelectionInfo;
|
|
17
20
|
export declare const validateSelectedNode: (selectedNodeAdf: ADFEntity, selectedNode: PMNode) => boolean;
|
|
18
21
|
export {};
|
|
@@ -31,6 +31,9 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
31
31
|
replaceWithAdf: (nodeAdf: ADFEntity) => ReplaceWithAdfResult;
|
|
32
32
|
insertAdfAtEndOfDoc: (nodeAdf: ADFEntity) => InsertAdfAtEndOfDocResult;
|
|
33
33
|
getSelectionAdf: () => SelectionAdfResult;
|
|
34
|
+
getDocumentFromSelection: () => {
|
|
35
|
+
selectedNodeAdf?: ADFEntity;
|
|
36
|
+
} | null;
|
|
34
37
|
getSelectionText: () => SelectionTextResult;
|
|
35
38
|
};
|
|
36
39
|
}>;
|
|
@@ -48,7 +48,7 @@ export type SelectionRange = {
|
|
|
48
48
|
};
|
|
49
49
|
export type SelectionExtensionFnOptions = {
|
|
50
50
|
selectedNodeAdf: ADFEntity;
|
|
51
|
-
selectionRanges
|
|
51
|
+
selectionRanges?: SelectionRange[];
|
|
52
52
|
};
|
|
53
53
|
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) => DynamicSelectionExtension;
|
|
54
54
|
export type SelectionExtensionConfig = SelectionExtension | SelectionExtensionFn;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { SelectionExtensionPlugin } from '../../selectionExtensionPluginType';
|
|
@@ -8,11 +8,14 @@ import type { SelectionExtensionSelectionInfo } from '../../types';
|
|
|
8
8
|
import { type SelectionRange } from '../../types';
|
|
9
9
|
type SelectionInfo = {
|
|
10
10
|
selectedNodeAdf: ADFEntity;
|
|
11
|
-
selectionRanges
|
|
11
|
+
selectionRanges?: SelectionRange[];
|
|
12
12
|
selectedNode: PMNode;
|
|
13
13
|
nodePos: number;
|
|
14
14
|
};
|
|
15
15
|
export declare const getSelectionTextInfo: (view: EditorView, api?: ExtractInjectionAPI<SelectionExtensionPlugin>) => SelectionExtensionSelectionInfo;
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const getFragmentInfoFromSelection: (state: EditorState) => {
|
|
17
|
+
selectedNodeAdf: ADFEntity;
|
|
18
|
+
};
|
|
19
|
+
export declare function getSelectionAdfInfo(state: EditorState): SelectionInfo;
|
|
17
20
|
export declare const validateSelectedNode: (selectedNodeAdf: ADFEntity, selectedNode: PMNode) => boolean;
|
|
18
21
|
export {};
|
|
@@ -31,6 +31,9 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
31
31
|
replaceWithAdf: (nodeAdf: ADFEntity) => ReplaceWithAdfResult;
|
|
32
32
|
insertAdfAtEndOfDoc: (nodeAdf: ADFEntity) => InsertAdfAtEndOfDocResult;
|
|
33
33
|
getSelectionAdf: () => SelectionAdfResult;
|
|
34
|
+
getDocumentFromSelection: () => {
|
|
35
|
+
selectedNodeAdf?: ADFEntity;
|
|
36
|
+
} | null;
|
|
34
37
|
getSelectionText: () => SelectionTextResult;
|
|
35
38
|
};
|
|
36
39
|
}>;
|
|
@@ -48,7 +48,7 @@ export type SelectionRange = {
|
|
|
48
48
|
};
|
|
49
49
|
export type SelectionExtensionFnOptions = {
|
|
50
50
|
selectedNodeAdf: ADFEntity;
|
|
51
|
-
selectionRanges
|
|
51
|
+
selectionRanges?: SelectionRange[];
|
|
52
52
|
};
|
|
53
53
|
export type SelectionExtensionFn = ({ selectedNodeAdf, selectionRanges, }: SelectionExtensionFnOptions) => DynamicSelectionExtension;
|
|
54
54
|
export type SelectionExtensionConfig = SelectionExtension | SelectionExtensionFn;
|
package/package.json
CHANGED