@atlaskit/editor-plugin-selection-extension 7.0.4 → 7.1.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,22 @@
1
1
  # @atlaskit/editor-plugin-selection-extension
2
2
 
3
+ ## 7.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`909d5392c27c2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/909d5392c27c2) -
8
+ Allow replaceWithAdf from selection extension to update doc in view mode
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 7.0.5
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 7.0.4
4
21
 
5
22
  ### Patch Changes
@@ -7,7 +7,7 @@ exports.replaceWithAdf = void 0;
7
7
  var _model = require("@atlaskit/editor-prosemirror/model");
8
8
  var _types = require("../../types");
9
9
  var _main = require("../main");
10
- var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf) {
10
+ var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf, api) {
11
11
  return function (state, dispatch) {
12
12
  var _selectionExtensionPl;
13
13
  var tr = state.tr,
@@ -26,7 +26,7 @@ var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf) {
26
26
  };
27
27
  }
28
28
  try {
29
- var _selectionExtensionPl2, _selectionExtensionPl3;
29
+ var _selectionExtensionPl2, _selectionExtensionPl3, _api$editorViewModeEf;
30
30
  var selectedNode = (_selectionExtensionPl2 = _main.selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl2 === void 0 ? void 0 : _selectionExtensionPl2.selectedNode;
31
31
  var nodePos = (_selectionExtensionPl3 = _main.selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl3 === void 0 ? void 0 : _selectionExtensionPl3.nodePos;
32
32
  if (!selectedNode || nodePos === undefined) {
@@ -35,8 +35,9 @@ var replaceWithAdf = exports.replaceWithAdf = function replaceWithAdf(nodeAdf) {
35
35
  var endPos = selectedNode.nodeSize + nodePos;
36
36
  var modifiedNode = _model.Node.fromJSON(schema, nodeAdf);
37
37
  modifiedNode.check();
38
- tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
39
- dispatch(tr);
38
+ var updatedTr = tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
39
+ // Allow this transaction in view mode and apply changes
40
+ dispatch((api === null || api === void 0 || (_api$editorViewModeEf = api.editorViewModeEffects) === null || _api$editorViewModeEf === void 0 ? void 0 : _api$editorViewModeEf.actions.allowViewModeTransaction(updatedTr)) || updatedTr);
40
41
  return {
41
42
  status: 'success'
42
43
  };
@@ -94,7 +94,7 @@ var selectionExtensionPlugin = exports.selectionExtensionPlugin = function selec
94
94
  var _editorViewRef$curren = editorViewRef.current,
95
95
  state = _editorViewRef$curren.state,
96
96
  dispatch = _editorViewRef$curren.dispatch;
97
- return (0, _replaceWithAdf2.replaceWithAdf)(nodeAdf)(state, dispatch);
97
+ return (0, _replaceWithAdf2.replaceWithAdf)(nodeAdf, api)(state, dispatch);
98
98
  },
99
99
  insertAdfAtEndOfDoc: function insertAdfAtEndOfDoc(nodeAdf) {
100
100
  if (!editorViewRef.current) {
@@ -1,7 +1,7 @@
1
1
  import { Node } from '@atlaskit/editor-prosemirror/model';
2
2
  import { SelectionExtensionActionTypes } from '../../types';
3
3
  import { selectionExtensionPluginKey } from '../main';
4
- export const replaceWithAdf = nodeAdf => (state, dispatch) => {
4
+ export const replaceWithAdf = (nodeAdf, api) => (state, dispatch) => {
5
5
  var _selectionExtensionPl;
6
6
  const {
7
7
  tr,
@@ -21,7 +21,7 @@ export const replaceWithAdf = nodeAdf => (state, dispatch) => {
21
21
  };
22
22
  }
23
23
  try {
24
- var _selectionExtensionPl2, _selectionExtensionPl3;
24
+ var _selectionExtensionPl2, _selectionExtensionPl3, _api$editorViewModeEf;
25
25
  const selectedNode = (_selectionExtensionPl2 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl2 === void 0 ? void 0 : _selectionExtensionPl2.selectedNode;
26
26
  const nodePos = (_selectionExtensionPl3 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl3 === void 0 ? void 0 : _selectionExtensionPl3.nodePos;
27
27
  if (!selectedNode || nodePos === undefined) {
@@ -30,8 +30,9 @@ export const replaceWithAdf = nodeAdf => (state, dispatch) => {
30
30
  const endPos = selectedNode.nodeSize + nodePos;
31
31
  const modifiedNode = Node.fromJSON(schema, nodeAdf);
32
32
  modifiedNode.check();
33
- tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
34
- dispatch(tr);
33
+ const updatedTr = tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
34
+ // Allow this transaction in view mode and apply changes
35
+ dispatch((api === null || api === void 0 ? void 0 : (_api$editorViewModeEf = api.editorViewModeEffects) === null || _api$editorViewModeEf === void 0 ? void 0 : _api$editorViewModeEf.actions.allowViewModeTransaction(updatedTr)) || updatedTr);
35
36
  return {
36
37
  status: 'success'
37
38
  };
@@ -82,7 +82,7 @@ export const selectionExtensionPlugin = ({
82
82
  state,
83
83
  dispatch
84
84
  } = editorViewRef.current;
85
- return replaceWithAdf(nodeAdf)(state, dispatch);
85
+ return replaceWithAdf(nodeAdf, api)(state, dispatch);
86
86
  },
87
87
  insertAdfAtEndOfDoc: nodeAdf => {
88
88
  if (!editorViewRef.current) {
@@ -1,7 +1,7 @@
1
1
  import { Node } from '@atlaskit/editor-prosemirror/model';
2
2
  import { SelectionExtensionActionTypes } from '../../types';
3
3
  import { selectionExtensionPluginKey } from '../main';
4
- export var replaceWithAdf = function replaceWithAdf(nodeAdf) {
4
+ export var replaceWithAdf = function replaceWithAdf(nodeAdf, api) {
5
5
  return function (state, dispatch) {
6
6
  var _selectionExtensionPl;
7
7
  var tr = state.tr,
@@ -20,7 +20,7 @@ export var replaceWithAdf = function replaceWithAdf(nodeAdf) {
20
20
  };
21
21
  }
22
22
  try {
23
- var _selectionExtensionPl2, _selectionExtensionPl3;
23
+ var _selectionExtensionPl2, _selectionExtensionPl3, _api$editorViewModeEf;
24
24
  var selectedNode = (_selectionExtensionPl2 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl2 === void 0 ? void 0 : _selectionExtensionPl2.selectedNode;
25
25
  var nodePos = (_selectionExtensionPl3 = selectionExtensionPluginKey.getState(state)) === null || _selectionExtensionPl3 === void 0 ? void 0 : _selectionExtensionPl3.nodePos;
26
26
  if (!selectedNode || nodePos === undefined) {
@@ -29,8 +29,9 @@ export var replaceWithAdf = function replaceWithAdf(nodeAdf) {
29
29
  var endPos = selectedNode.nodeSize + nodePos;
30
30
  var modifiedNode = Node.fromJSON(schema, nodeAdf);
31
31
  modifiedNode.check();
32
- tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
33
- dispatch(tr);
32
+ var updatedTr = tr.replaceWith(nodePos, endPos, modifiedNode).scrollIntoView();
33
+ // Allow this transaction in view mode and apply changes
34
+ dispatch((api === null || api === void 0 || (_api$editorViewModeEf = api.editorViewModeEffects) === null || _api$editorViewModeEf === void 0 ? void 0 : _api$editorViewModeEf.actions.allowViewModeTransaction(updatedTr)) || updatedTr);
34
35
  return {
35
36
  status: 'success'
36
37
  };
@@ -87,7 +87,7 @@ export var selectionExtensionPlugin = function selectionExtensionPlugin(_ref) {
87
87
  var _editorViewRef$curren = editorViewRef.current,
88
88
  state = _editorViewRef$curren.state,
89
89
  dispatch = _editorViewRef$curren.dispatch;
90
- return _replaceWithAdf(nodeAdf)(state, dispatch);
90
+ return _replaceWithAdf(nodeAdf, api)(state, dispatch);
91
91
  },
92
92
  insertAdfAtEndOfDoc: function insertAdfAtEndOfDoc(nodeAdf) {
93
93
  if (!editorViewRef.current) {
@@ -1,5 +1,6 @@
1
1
  import { type ADFEntity } from '@atlaskit/adf-utils/types';
2
- import type { CommandDispatch } from '@atlaskit/editor-common/types';
2
+ import type { CommandDispatch, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import type { SelectionExtensionPlugin } from '../../selectionExtensionPluginType';
4
5
  import { type ReplaceWithAdfResult } from '../../types';
5
- export declare const replaceWithAdf: (nodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => ReplaceWithAdfResult;
6
+ export declare const replaceWithAdf: (nodeAdf: ADFEntity, api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined) => (state: EditorState, dispatch: CommandDispatch) => ReplaceWithAdfResult;
@@ -3,6 +3,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
5
5
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
6
+ import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
6
7
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
8
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
8
9
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
@@ -29,6 +30,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
29
30
  dependencies: [
30
31
  OptionalPlugin<AnalyticsPlugin>,
31
32
  OptionalPlugin<EditorViewModePlugin>,
33
+ OptionalPlugin<EditorViewModeEffectsPlugin>,
32
34
  OptionalPlugin<PrimaryToolbarPlugin>,
33
35
  OptionalPlugin<UserPreferencesPlugin>,
34
36
  OptionalPlugin<UserIntentPlugin>,
@@ -1,5 +1,6 @@
1
1
  import { type ADFEntity } from '@atlaskit/adf-utils/types';
2
- import type { CommandDispatch } from '@atlaskit/editor-common/types';
2
+ import type { CommandDispatch, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
+ import type { SelectionExtensionPlugin } from '../../selectionExtensionPluginType';
4
5
  import { type ReplaceWithAdfResult } from '../../types';
5
- export declare const replaceWithAdf: (nodeAdf: ADFEntity) => (state: EditorState, dispatch: CommandDispatch) => ReplaceWithAdfResult;
6
+ export declare const replaceWithAdf: (nodeAdf: ADFEntity, api: ExtractInjectionAPI<SelectionExtensionPlugin> | undefined) => (state: EditorState, dispatch: CommandDispatch) => ReplaceWithAdfResult;
@@ -3,6 +3,7 @@ import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
5
5
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
6
+ import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
6
7
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
8
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
8
9
  import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
@@ -29,6 +30,7 @@ export type SelectionExtensionPlugin = NextEditorPlugin<'selectionExtension', {
29
30
  dependencies: [
30
31
  OptionalPlugin<AnalyticsPlugin>,
31
32
  OptionalPlugin<EditorViewModePlugin>,
33
+ OptionalPlugin<EditorViewModeEffectsPlugin>,
32
34
  OptionalPlugin<PrimaryToolbarPlugin>,
33
35
  OptionalPlugin<UserPreferencesPlugin>,
34
36
  OptionalPlugin<UserIntentPlugin>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-extension",
3
- "version": "7.0.4",
3
+ "version": "7.1.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",
@@ -37,32 +37,29 @@
37
37
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
38
38
  "@atlaskit/editor-plugin-block-menu": "^5.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
40
+ "@atlaskit/editor-plugin-editor-viewmode-effects": "^6.1.0",
40
41
  "@atlaskit/editor-plugin-primary-toolbar": "^7.0.0",
41
42
  "@atlaskit/editor-plugin-selection-toolbar": "^7.1.0",
42
43
  "@atlaskit/editor-plugin-toolbar": "^3.4.0",
43
44
  "@atlaskit/editor-plugin-user-preferences": "^4.0.0",
44
45
  "@atlaskit/editor-prosemirror": "7.0.0",
45
- "@atlaskit/editor-shared-styles": "^3.9.0",
46
+ "@atlaskit/editor-shared-styles": "^3.10.0",
46
47
  "@atlaskit/editor-tables": "^2.9.0",
47
48
  "@atlaskit/editor-toolbar": "^0.17.0",
48
49
  "@atlaskit/icon": "^29.0.0",
49
50
  "@atlaskit/platform-feature-flags": "^1.1.0",
50
51
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
51
- "@atlaskit/primitives": "^16.1.0",
52
- "@atlaskit/tmp-editor-statsig": "^13.35.0",
52
+ "@atlaskit/tmp-editor-statsig": "^14.1.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "lodash": "^4.17.21",
55
55
  "react-intl-next": "npm:react-intl@^5.18.1",
56
56
  "uuid": "^3.1.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^110.27.0",
59
+ "@atlaskit/editor-common": "^110.36.0",
60
60
  "react": "^18.2.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@af/integration-testing": "workspace:^",
64
- "@af/visual-regression": "workspace:^",
65
- "@atlaskit/ssr": "workspace:^",
66
63
  "@testing-library/react": "^13.4.0",
67
64
  "react-dom": "^18.2.0",
68
65
  "wait-for-expect": "^1.2.0"