@atlaskit/editor-core 185.16.5 → 185.16.6

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,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 185.16.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1901ebeafcb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1901ebeafcb) - [ux] Fix expand title selection bug
8
+
3
9
  ## 185.16.5
4
10
 
5
11
  ### Patch Changes
@@ -143,7 +143,7 @@ var focusTitle = function focusTitle(pos) {
143
143
  var dom = editorView.domAtPos(pos);
144
144
  var expandWrapper = dom.node.parentElement;
145
145
  if (expandWrapper) {
146
- setSelectionInsideExpand(state, dispatch, editorView);
146
+ setSelectionInsideExpand(pos)(state, dispatch, editorView);
147
147
  var input = expandWrapper.querySelector('input');
148
148
  if (input) {
149
149
  input.focus();
@@ -157,16 +157,19 @@ var focusTitle = function focusTitle(pos) {
157
157
 
158
158
  // Used to clear any node or cell selection when expand title is focused
159
159
  exports.focusTitle = focusTitle;
160
- var setSelectionInsideExpand = function setSelectionInsideExpand(state, dispatch, editorView) {
161
- var tr = state.tr,
162
- doc = state.doc,
163
- selection = state.selection;
164
- if (editorView && !editorView.hasFocus()) {
165
- editorView.focus();
166
- }
167
- if (dispatch) {
168
- dispatch(tr.setSelection(_prosemirrorState.TextSelection.create(doc, selection.from)));
169
- }
170
- return true;
160
+ var setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
161
+ return function (state, dispatch, editorView) {
162
+ if (editorView) {
163
+ if (!editorView.hasFocus()) {
164
+ editorView.focus();
165
+ }
166
+ var sel = _prosemirrorState.Selection.findFrom(editorView.state.doc.resolve(expandPos), 1, true);
167
+ if (sel && dispatch) {
168
+ dispatch(editorView.state.tr.setSelection(sel));
169
+ }
170
+ return true;
171
+ }
172
+ return false;
173
+ };
171
174
  };
172
175
  exports.setSelectionInsideExpand = setSelectionInsideExpand;
@@ -72,7 +72,10 @@ var ExpandNodeView = /*#__PURE__*/function () {
72
72
  state = _this$view.state,
73
73
  dispatch = _this$view.dispatch;
74
74
  (0, _commands2.setSelectionRelativeToNode)(_types.RelativeSelectionPos.Start)(state, dispatch);
75
- (0, _commands.setSelectionInsideExpand)(state, dispatch, _this.view);
75
+ var pos = _this.getPos();
76
+ if (typeof pos === 'number') {
77
+ (0, _commands.setSelectionInsideExpand)(pos)(state, dispatch, _this.view);
78
+ }
76
79
  _this.input.focus();
77
80
  }
78
81
  });
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "185.16.5";
9
+ var version = "185.16.6";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.16.5",
3
+ "version": "185.16.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { TextSelection } from 'prosemirror-state';
1
+ import { Selection } from 'prosemirror-state';
2
2
  import { findTable } from '@atlaskit/editor-tables/utils';
3
3
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, PLATFORMS, MODE } from '../analytics';
4
4
  import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
@@ -120,7 +120,7 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
120
120
  const dom = editorView.domAtPos(pos);
121
121
  const expandWrapper = dom.node.parentElement;
122
122
  if (expandWrapper) {
123
- setSelectionInsideExpand(state, dispatch, editorView);
123
+ setSelectionInsideExpand(pos)(state, dispatch, editorView);
124
124
  const input = expandWrapper.querySelector('input');
125
125
  if (input) {
126
126
  input.focus();
@@ -132,17 +132,16 @@ export const focusTitle = pos => (state, dispatch, editorView) => {
132
132
  };
133
133
 
134
134
  // Used to clear any node or cell selection when expand title is focused
135
- export const setSelectionInsideExpand = (state, dispatch, editorView) => {
136
- const {
137
- tr,
138
- doc,
139
- selection
140
- } = state;
141
- if (editorView && !editorView.hasFocus()) {
142
- editorView.focus();
143
- }
144
- if (dispatch) {
145
- dispatch(tr.setSelection(TextSelection.create(doc, selection.from)));
135
+ export const setSelectionInsideExpand = expandPos => (state, dispatch, editorView) => {
136
+ if (editorView) {
137
+ if (!editorView.hasFocus()) {
138
+ editorView.focus();
139
+ }
140
+ const sel = Selection.findFrom(editorView.state.doc.resolve(expandPos), 1, true);
141
+ if (sel && dispatch) {
142
+ dispatch(editorView.state.tr.setSelection(sel));
143
+ }
144
+ return true;
146
145
  }
147
- return true;
146
+ return false;
148
147
  };
@@ -59,7 +59,10 @@ export class ExpandNodeView {
59
59
  dispatch
60
60
  } = this.view;
61
61
  setSelectionRelativeToNode(RelativeSelectionPos.Start)(state, dispatch);
62
- setSelectionInsideExpand(state, dispatch, this.view);
62
+ const pos = this.getPos();
63
+ if (typeof pos === 'number') {
64
+ setSelectionInsideExpand(pos)(state, dispatch, this.view);
65
+ }
63
66
  this.input.focus();
64
67
  }
65
68
  });
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.16.5";
2
+ export const version = "185.16.6";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.16.5",
3
+ "version": "185.16.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- import { TextSelection } from 'prosemirror-state';
4
+ import { Selection } from 'prosemirror-state';
5
5
  import { findTable } from '@atlaskit/editor-tables/utils';
6
6
  import { addAnalytics, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE, PLATFORMS, MODE } from '../analytics';
7
7
  import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
@@ -129,7 +129,7 @@ export var focusTitle = function focusTitle(pos) {
129
129
  var dom = editorView.domAtPos(pos);
130
130
  var expandWrapper = dom.node.parentElement;
131
131
  if (expandWrapper) {
132
- setSelectionInsideExpand(state, dispatch, editorView);
132
+ setSelectionInsideExpand(pos)(state, dispatch, editorView);
133
133
  var input = expandWrapper.querySelector('input');
134
134
  if (input) {
135
135
  input.focus();
@@ -142,15 +142,18 @@ export var focusTitle = function focusTitle(pos) {
142
142
  };
143
143
 
144
144
  // Used to clear any node or cell selection when expand title is focused
145
- export var setSelectionInsideExpand = function setSelectionInsideExpand(state, dispatch, editorView) {
146
- var tr = state.tr,
147
- doc = state.doc,
148
- selection = state.selection;
149
- if (editorView && !editorView.hasFocus()) {
150
- editorView.focus();
151
- }
152
- if (dispatch) {
153
- dispatch(tr.setSelection(TextSelection.create(doc, selection.from)));
154
- }
155
- return true;
145
+ export var setSelectionInsideExpand = function setSelectionInsideExpand(expandPos) {
146
+ return function (state, dispatch, editorView) {
147
+ if (editorView) {
148
+ if (!editorView.hasFocus()) {
149
+ editorView.focus();
150
+ }
151
+ var sel = Selection.findFrom(editorView.state.doc.resolve(expandPos), 1, true);
152
+ if (sel && dispatch) {
153
+ dispatch(editorView.state.tr.setSelection(sel));
154
+ }
155
+ return true;
156
+ }
157
+ return false;
158
+ };
156
159
  };
@@ -64,7 +64,10 @@ export var ExpandNodeView = /*#__PURE__*/function () {
64
64
  state = _this$view.state,
65
65
  dispatch = _this$view.dispatch;
66
66
  setSelectionRelativeToNode(RelativeSelectionPos.Start)(state, dispatch);
67
- setSelectionInsideExpand(state, dispatch, _this.view);
67
+ var pos = _this.getPos();
68
+ if (typeof pos === 'number') {
69
+ setSelectionInsideExpand(pos)(state, dispatch, _this.view);
70
+ }
68
71
  _this.input.focus();
69
72
  }
70
73
  });
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "185.16.5";
2
+ export var version = "185.16.6";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.16.5",
3
+ "version": "185.16.6",
4
4
  "sideEffects": false
5
5
  }
@@ -9,4 +9,4 @@ export declare const toggleExpandExpanded: (pos: number, nodeType: NodeType) =>
9
9
  export declare const createExpandNode: (state: EditorState) => PMNode | null;
10
10
  export declare const insertExpand: Command;
11
11
  export declare const focusTitle: (pos: number) => Command;
12
- export declare const setSelectionInsideExpand: Command;
12
+ export declare const setSelectionInsideExpand: (expandPos: number) => Command;
@@ -9,4 +9,4 @@ export declare const toggleExpandExpanded: (pos: number, nodeType: NodeType) =>
9
9
  export declare const createExpandNode: (state: EditorState) => PMNode | null;
10
10
  export declare const insertExpand: Command;
11
11
  export declare const focusTitle: (pos: number) => Command;
12
- export declare const setSelectionInsideExpand: Command;
12
+ export declare const setSelectionInsideExpand: (expandPos: number) => Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.16.5",
3
+ "version": "185.16.6",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"