@atlaskit/editor-plugin-selection-extension 3.3.1 → 3.4.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 +8 -0
- package/dist/cjs/pm-plugins/actions/insertAdfAtEndOfDoc.js +27 -0
- package/dist/cjs/pm-plugins/actions/replaceWithAdf.js +50 -0
- package/dist/cjs/selectionExtensionPlugin.js +24 -0
- package/dist/es2019/pm-plugins/actions/insertAdfAtEndOfDoc.js +21 -0
- package/dist/es2019/pm-plugins/actions/replaceWithAdf.js +44 -0
- package/dist/es2019/selectionExtensionPlugin.js +26 -0
- package/dist/esm/pm-plugins/actions/insertAdfAtEndOfDoc.js +21 -0
- package/dist/esm/pm-plugins/actions/replaceWithAdf.js +44 -0
- package/dist/esm/selectionExtensionPlugin.js +24 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pm-plugins/actions/insertAdfAtEndOfDoc.d.ts +5 -0
- package/dist/types/pm-plugins/actions/replaceWithAdf.d.ts +5 -0
- package/dist/types/selectionExtensionPluginType.d.ts +3 -1
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/actions/insertAdfAtEndOfDoc.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/actions/replaceWithAdf.d.ts +5 -0
- package/dist/types-ts4.5/selectionExtensionPluginType.d.ts +3 -1
- package/dist/types-ts4.5/types/index.d.ts +7 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-extension
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#193092](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/193092)
|
|
8
|
+
[`1e21bb09f7d00`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1e21bb09f7d00) -
|
|
9
|
+
new api to insert ADF at the bottom of document
|
|
10
|
+
|
|
3
11
|
## 3.3.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.insertAdfAtEndOfDoc = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var insertAdfAtEndOfDoc = exports.insertAdfAtEndOfDoc = function insertAdfAtEndOfDoc(nodeAdf) {
|
|
9
|
+
return function (state, dispatch) {
|
|
10
|
+
var tr = state.tr,
|
|
11
|
+
schema = state.schema;
|
|
12
|
+
try {
|
|
13
|
+
var docEnd = state.doc.content.size;
|
|
14
|
+
var modifiedNode = _model.Node.fromJSON(schema, nodeAdf);
|
|
15
|
+
modifiedNode.check();
|
|
16
|
+
tr.insert(tr.mapping.map(docEnd), modifiedNode).scrollIntoView();
|
|
17
|
+
dispatch(tr);
|
|
18
|
+
return {
|
|
19
|
+
status: 'success'
|
|
20
|
+
};
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return {
|
|
23
|
+
status: 'failed'
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.replaceWithAdf = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
+
var _types = require("../../types");
|
|
9
|
+
var _main = require("../main");
|
|
10
|
+
var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf) {
|
|
11
|
+
return function (state, dispatch) {
|
|
12
|
+
var _selectionExtensionPl;
|
|
13
|
+
var tr = state.tr,
|
|
14
|
+
schema = state.schema;
|
|
15
|
+
|
|
16
|
+
// we need to track if any changes were made since user click the toolbar button
|
|
17
|
+
var docChangedAfterClick = ((_selectionExtensionPl = _main.selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl === void 0 ? void 0 : _selectionExtensionPl.docChangedAfterClick) || false;
|
|
18
|
+
tr.setMeta(_main.selectionExtensionPluginKey, {
|
|
19
|
+
type: _types.SelectionExtensionActionTypes.START_TRACK_CHANGES,
|
|
20
|
+
startTrackChanges: false // Reset the flag when starting to track changes
|
|
21
|
+
});
|
|
22
|
+
if (docChangedAfterClick) {
|
|
23
|
+
dispatch(tr);
|
|
24
|
+
return {
|
|
25
|
+
status: 'document-changed'
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
var _selectionExtensionPl2, _selectionExtensionPl3;
|
|
30
|
+
var selectedNode = (_selectionExtensionPl2 = _main.selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl2 === void 0 ? void 0 : _selectionExtensionPl2.selectedNode;
|
|
31
|
+
var nodePos = (_selectionExtensionPl3 = _main.selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl3 === void 0 ? void 0 : _selectionExtensionPl3.nodePos;
|
|
32
|
+
if (!selectedNode || nodePos === undefined) {
|
|
33
|
+
throw new Error('No selected node or node position found');
|
|
34
|
+
}
|
|
35
|
+
var endPos = selectedNode.nodeSize + nodePos;
|
|
36
|
+
var modifiedNode = _model.Node.fromJSON(schema, nodeAdf);
|
|
37
|
+
modifiedNode.check();
|
|
38
|
+
tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
|
|
39
|
+
dispatch(tr);
|
|
40
|
+
return {
|
|
41
|
+
status: 'success'
|
|
42
|
+
};
|
|
43
|
+
} catch (error) {
|
|
44
|
+
dispatch(tr);
|
|
45
|
+
return {
|
|
46
|
+
status: 'failed-to-replace'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -11,6 +11,8 @@ var _messages = require("@atlaskit/editor-common/messages");
|
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
13
|
var _actions = require("./pm-plugins/actions");
|
|
14
|
+
var _insertAdfAtEndOfDoc2 = require("./pm-plugins/actions/insertAdfAtEndOfDoc");
|
|
15
|
+
var _replaceWithAdf2 = require("./pm-plugins/actions/replaceWithAdf");
|
|
14
16
|
var _main = require("./pm-plugins/main");
|
|
15
17
|
var _utils = require("./pm-plugins/utils");
|
|
16
18
|
var _types = require("./types");
|
|
@@ -64,6 +66,28 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
|
|
|
64
66
|
state = _editorViewRef$curren.state,
|
|
65
67
|
dispatch = _editorViewRef$curren.dispatch;
|
|
66
68
|
return (0, _actions.insertSmartLinks)(linkInsertionOptions, selectedNodeAdf)(state, dispatch);
|
|
69
|
+
},
|
|
70
|
+
replaceWithAdf: function replaceWithAdf(nodeAdf) {
|
|
71
|
+
if (!editorViewRef.current) {
|
|
72
|
+
return {
|
|
73
|
+
status: 'failed-to-replace'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var _editorViewRef$curren2 = editorViewRef.current,
|
|
77
|
+
state = _editorViewRef$curren2.state,
|
|
78
|
+
dispatch = _editorViewRef$curren2.dispatch;
|
|
79
|
+
return (0, _replaceWithAdf2.replaceWithAdf)(nodeAdf)(state, dispatch);
|
|
80
|
+
},
|
|
81
|
+
insertAdfAtEndOfDoc: function insertAdfAtEndOfDoc(nodeAdf) {
|
|
82
|
+
if (!editorViewRef.current) {
|
|
83
|
+
return {
|
|
84
|
+
status: 'failed'
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
var _editorViewRef$curren3 = editorViewRef.current,
|
|
88
|
+
state = _editorViewRef$curren3.state,
|
|
89
|
+
dispatch = _editorViewRef$curren3.dispatch;
|
|
90
|
+
return (0, _insertAdfAtEndOfDoc2.insertAdfAtEndOfDoc)(nodeAdf)(state, dispatch);
|
|
67
91
|
}
|
|
68
92
|
},
|
|
69
93
|
contentComponent: function contentComponent(_ref4) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export const insertAdfAtEndOfDoc = nodeAdf => (state, dispatch) => {
|
|
3
|
+
const {
|
|
4
|
+
tr,
|
|
5
|
+
schema
|
|
6
|
+
} = state;
|
|
7
|
+
try {
|
|
8
|
+
const docEnd = state.doc.content.size;
|
|
9
|
+
const modifiedNode = Node.fromJSON(schema, nodeAdf);
|
|
10
|
+
modifiedNode.check();
|
|
11
|
+
tr.insert(tr.mapping.map(docEnd), modifiedNode).scrollIntoView();
|
|
12
|
+
dispatch(tr);
|
|
13
|
+
return {
|
|
14
|
+
status: 'success'
|
|
15
|
+
};
|
|
16
|
+
} catch (error) {
|
|
17
|
+
return {
|
|
18
|
+
status: 'failed'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { SelectionExtensionActionTypes } from '../../types';
|
|
3
|
+
import { selectionExtensionPluginKey } from '../main';
|
|
4
|
+
export const replaceWithAdf = nodeAdf => (state, dispatch) => {
|
|
5
|
+
var _selectionExtensionPl;
|
|
6
|
+
const {
|
|
7
|
+
tr,
|
|
8
|
+
schema
|
|
9
|
+
} = state;
|
|
10
|
+
|
|
11
|
+
// we need to track if any changes were made since user click the toolbar button
|
|
12
|
+
const docChangedAfterClick = ((_selectionExtensionPl = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl === void 0 ? void 0 : _selectionExtensionPl.docChangedAfterClick) || false;
|
|
13
|
+
tr.setMeta(selectionExtensionPluginKey, {
|
|
14
|
+
type: SelectionExtensionActionTypes.START_TRACK_CHANGES,
|
|
15
|
+
startTrackChanges: false // Reset the flag when starting to track changes
|
|
16
|
+
});
|
|
17
|
+
if (docChangedAfterClick) {
|
|
18
|
+
dispatch(tr);
|
|
19
|
+
return {
|
|
20
|
+
status: 'document-changed'
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
var _selectionExtensionPl2, _selectionExtensionPl3;
|
|
25
|
+
const selectedNode = (_selectionExtensionPl2 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl2 === void 0 ? void 0 : _selectionExtensionPl2.selectedNode;
|
|
26
|
+
const nodePos = (_selectionExtensionPl3 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl3 === void 0 ? void 0 : _selectionExtensionPl3.nodePos;
|
|
27
|
+
if (!selectedNode || nodePos === undefined) {
|
|
28
|
+
throw new Error('No selected node or node position found');
|
|
29
|
+
}
|
|
30
|
+
const endPos = selectedNode.nodeSize + nodePos;
|
|
31
|
+
const modifiedNode = Node.fromJSON(schema, nodeAdf);
|
|
32
|
+
modifiedNode.check();
|
|
33
|
+
tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
|
|
34
|
+
dispatch(tr);
|
|
35
|
+
return {
|
|
36
|
+
status: 'success'
|
|
37
|
+
};
|
|
38
|
+
} catch (error) {
|
|
39
|
+
dispatch(tr);
|
|
40
|
+
return {
|
|
41
|
+
status: 'failed-to-replace'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -3,6 +3,8 @@ import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { insertSmartLinks } from './pm-plugins/actions';
|
|
6
|
+
import { insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
7
|
+
import { replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
6
8
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
7
9
|
import { getSelectionInfo } from './pm-plugins/utils';
|
|
8
10
|
import { SelectionExtensionActionTypes } from './types';
|
|
@@ -56,6 +58,30 @@ export const selectionExtensionPlugin = ({
|
|
|
56
58
|
dispatch
|
|
57
59
|
} = editorViewRef.current;
|
|
58
60
|
return insertSmartLinks(linkInsertionOptions, selectedNodeAdf)(state, dispatch);
|
|
61
|
+
},
|
|
62
|
+
replaceWithAdf: nodeAdf => {
|
|
63
|
+
if (!editorViewRef.current) {
|
|
64
|
+
return {
|
|
65
|
+
status: 'failed-to-replace'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const {
|
|
69
|
+
state,
|
|
70
|
+
dispatch
|
|
71
|
+
} = editorViewRef.current;
|
|
72
|
+
return replaceWithAdf(nodeAdf)(state, dispatch);
|
|
73
|
+
},
|
|
74
|
+
insertAdfAtEndOfDoc: nodeAdf => {
|
|
75
|
+
if (!editorViewRef.current) {
|
|
76
|
+
return {
|
|
77
|
+
status: 'failed'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const {
|
|
81
|
+
state,
|
|
82
|
+
dispatch
|
|
83
|
+
} = editorViewRef.current;
|
|
84
|
+
return insertAdfAtEndOfDoc(nodeAdf)(state, dispatch);
|
|
59
85
|
}
|
|
60
86
|
},
|
|
61
87
|
contentComponent: ({
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export var insertAdfAtEndOfDoc = function insertAdfAtEndOfDoc(nodeAdf) {
|
|
3
|
+
return function (state, dispatch) {
|
|
4
|
+
var tr = state.tr,
|
|
5
|
+
schema = state.schema;
|
|
6
|
+
try {
|
|
7
|
+
var docEnd = state.doc.content.size;
|
|
8
|
+
var modifiedNode = Node.fromJSON(schema, nodeAdf);
|
|
9
|
+
modifiedNode.check();
|
|
10
|
+
tr.insert(tr.mapping.map(docEnd), modifiedNode).scrollIntoView();
|
|
11
|
+
dispatch(tr);
|
|
12
|
+
return {
|
|
13
|
+
status: 'success'
|
|
14
|
+
};
|
|
15
|
+
} catch (error) {
|
|
16
|
+
return {
|
|
17
|
+
status: 'failed'
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { SelectionExtensionActionTypes } from '../../types';
|
|
3
|
+
import { selectionExtensionPluginKey } from '../main';
|
|
4
|
+
export var replaceWithAdf = function replaceWithAdf(nodeAdf) {
|
|
5
|
+
return function (state, dispatch) {
|
|
6
|
+
var _selectionExtensionPl;
|
|
7
|
+
var tr = state.tr,
|
|
8
|
+
schema = state.schema;
|
|
9
|
+
|
|
10
|
+
// we need to track if any changes were made since user click the toolbar button
|
|
11
|
+
var docChangedAfterClick = ((_selectionExtensionPl = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl === void 0 ? void 0 : _selectionExtensionPl.docChangedAfterClick) || false;
|
|
12
|
+
tr.setMeta(selectionExtensionPluginKey, {
|
|
13
|
+
type: SelectionExtensionActionTypes.START_TRACK_CHANGES,
|
|
14
|
+
startTrackChanges: false // Reset the flag when starting to track changes
|
|
15
|
+
});
|
|
16
|
+
if (docChangedAfterClick) {
|
|
17
|
+
dispatch(tr);
|
|
18
|
+
return {
|
|
19
|
+
status: 'document-changed'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
var _selectionExtensionPl2, _selectionExtensionPl3;
|
|
24
|
+
var selectedNode = (_selectionExtensionPl2 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl2 === void 0 ? void 0 : _selectionExtensionPl2.selectedNode;
|
|
25
|
+
var nodePos = (_selectionExtensionPl3 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl3 === void 0 ? void 0 : _selectionExtensionPl3.nodePos;
|
|
26
|
+
if (!selectedNode || nodePos === undefined) {
|
|
27
|
+
throw new Error('No selected node or node position found');
|
|
28
|
+
}
|
|
29
|
+
var endPos = selectedNode.nodeSize + nodePos;
|
|
30
|
+
var modifiedNode = Node.fromJSON(schema, nodeAdf);
|
|
31
|
+
modifiedNode.check();
|
|
32
|
+
tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
|
|
33
|
+
dispatch(tr);
|
|
34
|
+
return {
|
|
35
|
+
status: 'success'
|
|
36
|
+
};
|
|
37
|
+
} catch (error) {
|
|
38
|
+
dispatch(tr);
|
|
39
|
+
return {
|
|
40
|
+
status: 'failed-to-replace'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -4,6 +4,8 @@ import { selectionExtensionMessages } from '@atlaskit/editor-common/messages';
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { insertSmartLinks as _insertSmartLinks } from './pm-plugins/actions';
|
|
7
|
+
import { insertAdfAtEndOfDoc as _insertAdfAtEndOfDoc } from './pm-plugins/actions/insertAdfAtEndOfDoc';
|
|
8
|
+
import { replaceWithAdf as _replaceWithAdf } from './pm-plugins/actions/replaceWithAdf';
|
|
7
9
|
import { createPlugin, selectionExtensionPluginKey } from './pm-plugins/main';
|
|
8
10
|
import { getSelectionInfo } from './pm-plugins/utils';
|
|
9
11
|
import { SelectionExtensionActionTypes } from './types';
|
|
@@ -57,6 +59,28 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
|
|
|
57
59
|
state = _editorViewRef$curren.state,
|
|
58
60
|
dispatch = _editorViewRef$curren.dispatch;
|
|
59
61
|
return _insertSmartLinks(linkInsertionOptions, selectedNodeAdf)(state, dispatch);
|
|
62
|
+
},
|
|
63
|
+
replaceWithAdf: function replaceWithAdf(nodeAdf) {
|
|
64
|
+
if (!editorViewRef.current) {
|
|
65
|
+
return {
|
|
66
|
+
status: 'failed-to-replace'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
var _editorViewRef$curren2 = editorViewRef.current,
|
|
70
|
+
state = _editorViewRef$curren2.state,
|
|
71
|
+
dispatch = _editorViewRef$curren2.dispatch;
|
|
72
|
+
return _replaceWithAdf(nodeAdf)(state, dispatch);
|
|
73
|
+
},
|
|
74
|
+
insertAdfAtEndOfDoc: function insertAdfAtEndOfDoc(nodeAdf) {
|
|
75
|
+
if (!editorViewRef.current) {
|
|
76
|
+
return {
|
|
77
|
+
status: 'failed'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var _editorViewRef$curren3 = editorViewRef.current,
|
|
81
|
+
state = _editorViewRef$curren3.state,
|
|
82
|
+
dispatch = _editorViewRef$curren3.dispatch;
|
|
83
|
+
return _insertAdfAtEndOfDoc(nodeAdf)(state, dispatch);
|
|
60
84
|
}
|
|
61
85
|
},
|
|
62
86
|
contentComponent: function contentComponent(_ref4) {
|
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, DynamicSelectionExtension, } from './types';
|
|
3
|
+
export type { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, DynamicSelectionExtension, ReplaceWithAdfResult, InsertAdfAtEndOfDocResult, } from './types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { CommandDispatch } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type InsertAdfAtEndOfDocResult } from '../../types';
|
|
5
|
+
export declare const insertAdfAtEndOfDoc: (nodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => InsertAdfAtEndOfDocResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { CommandDispatch } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type ReplaceWithAdfResult } from '../../types';
|
|
5
|
+
export declare const replaceWithAdf: (nodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => ReplaceWithAdfResult;
|
|
@@ -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 { DynamicSelectionExtension, LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
6
|
+
import type { DynamicSelectionExtension, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
7
7
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
8
8
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
9
9
|
dependencies: [
|
|
@@ -24,5 +24,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
24
24
|
status: 'success' | 'error';
|
|
25
25
|
message?: string;
|
|
26
26
|
};
|
|
27
|
+
replaceWithAdf: (nodeAdf: ADFEntity) => ReplaceWithAdfResult;
|
|
28
|
+
insertAdfAtEndOfDoc: (nodeAdf: ADFEntity) => InsertAdfAtEndOfDocResult;
|
|
27
29
|
};
|
|
28
30
|
}>;
|
|
@@ -110,4 +110,11 @@ export type SelectionExtensionPluginState = {
|
|
|
110
110
|
startTrackChanges?: boolean;
|
|
111
111
|
docChangedAfterClick?: boolean;
|
|
112
112
|
};
|
|
113
|
+
export type ReplaceWithAdfStatus = 'success' | 'document-changed' | 'failed-to-replace';
|
|
114
|
+
export type ReplaceWithAdfResult = {
|
|
115
|
+
status: ReplaceWithAdfStatus;
|
|
116
|
+
};
|
|
117
|
+
export type InsertAdfAtEndOfDocResult = {
|
|
118
|
+
status: 'success' | 'failed';
|
|
119
|
+
};
|
|
113
120
|
export {};
|
|
@@ -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, DynamicSelectionExtension, } from './types';
|
|
3
|
+
export type { SelectionExtensionComponentProps, SelectionExtensionPluginOptions, SelectionExtension, LinkInsertionOption, SelectionExtensionPluginState, SelectionExtensionSelectionInfo, DynamicSelectionExtension, ReplaceWithAdfResult, InsertAdfAtEndOfDocResult, } from './types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { CommandDispatch } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type InsertAdfAtEndOfDocResult } from '../../types';
|
|
5
|
+
export declare const insertAdfAtEndOfDoc: (nodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => InsertAdfAtEndOfDocResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ADFEntity } from '@atlaskit/adf-utils/types';
|
|
2
|
+
import type { CommandDispatch } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type ReplaceWithAdfResult } from '../../types';
|
|
5
|
+
export declare const replaceWithAdf: (nodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => ReplaceWithAdfResult;
|
|
@@ -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 { DynamicSelectionExtension, LinkInsertionOption, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
6
|
+
import type { DynamicSelectionExtension, InsertAdfAtEndOfDocResult, LinkInsertionOption, ReplaceWithAdfResult, SelectionExtension, SelectionExtensionPluginOptions, SelectionExtensionPluginState, SelectionExtensionSelectionInfo } from './types';
|
|
7
7
|
export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
8
8
|
pluginConfiguration: SelectionExtensionPluginOptions | undefined;
|
|
9
9
|
dependencies: [
|
|
@@ -24,5 +24,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
|
|
|
24
24
|
status: 'success' | 'error';
|
|
25
25
|
message?: string;
|
|
26
26
|
};
|
|
27
|
+
replaceWithAdf: (nodeAdf: ADFEntity) => ReplaceWithAdfResult;
|
|
28
|
+
insertAdfAtEndOfDoc: (nodeAdf: ADFEntity) => InsertAdfAtEndOfDocResult;
|
|
27
29
|
};
|
|
28
30
|
}>;
|
|
@@ -110,4 +110,11 @@ export type SelectionExtensionPluginState = {
|
|
|
110
110
|
startTrackChanges?: boolean;
|
|
111
111
|
docChangedAfterClick?: boolean;
|
|
112
112
|
};
|
|
113
|
+
export type ReplaceWithAdfStatus = 'success' | 'document-changed' | 'failed-to-replace';
|
|
114
|
+
export type ReplaceWithAdfResult = {
|
|
115
|
+
status: ReplaceWithAdfStatus;
|
|
116
|
+
};
|
|
117
|
+
export type InsertAdfAtEndOfDocResult = {
|
|
118
|
+
status: 'success' | 'failed';
|
|
119
|
+
};
|
|
113
120
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-extension",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.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,10 +42,10 @@
|
|
|
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.8.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
|
-
"@atlaskit/primitives": "^14.
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
47
|
+
"@atlaskit/primitives": "^14.11.0",
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^9.17.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",
|