@atlaskit/editor-core 187.3.0 → 187.3.4

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
+ ## 187.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`dbc45526d36`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dbc45526d36) - ED-18879 prevent cursor from appearing at incorrect position after IME composition
8
+
3
9
  ## 187.3.0
4
10
 
5
11
  ### Minor Changes
@@ -6,28 +6,35 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isComposing = exports.default = void 0;
7
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
8
  var _prosemirrorState = require("prosemirror-state");
9
+ var _utils = require("@atlaskit/editor-common/utils");
9
10
  var compositionPluginKey = new _prosemirrorState.PluginKey('compositionPlugin');
10
11
  var isComposing = function isComposing(state) {
11
12
  var _compositionPluginKey;
12
13
  return !!((_compositionPluginKey = compositionPluginKey.getState(state)) !== null && _compositionPluginKey !== void 0 && _compositionPluginKey.isComposing);
13
14
  };
14
15
  exports.isComposing = isComposing;
16
+ var isLinux = function isLinux() {
17
+ return navigator.userAgent.indexOf('Linux') >= 0;
18
+ };
15
19
  var _default = function _default() {
16
20
  return new _safePlugin.SafePlugin({
17
21
  key: compositionPluginKey,
18
22
  state: {
19
23
  init: function init() {
20
24
  return {
21
- isComposing: false
25
+ isComposing: false,
26
+ zeroWidthSpacePos: undefined
22
27
  };
23
28
  },
24
29
  apply: function apply(tr, value) {
25
30
  var isComposing = tr.getMeta(compositionPluginKey);
31
+ var zeroWidthSpacePos = tr.getMeta('zeroWidthSpacePos');
26
32
  if (typeof isComposing === 'undefined') {
27
33
  return value;
28
34
  }
29
35
  return {
30
- isComposing: isComposing
36
+ isComposing: isComposing,
37
+ zeroWidthSpacePos: zeroWidthSpacePos
31
38
  };
32
39
  }
33
40
  },
@@ -36,12 +43,28 @@ var _default = function _default() {
36
43
  compositionstart: function compositionstart(view, event) {
37
44
  var tr = view.state.tr;
38
45
  tr.setMeta(compositionPluginKey, true);
46
+
47
+ // only apply for linux and cursor is at start of line
48
+ if (isLinux() && view.state.selection.$from.parentOffset === 0) {
49
+ tr.insertText(_utils.ZERO_WIDTH_SPACE);
50
+
51
+ // remember the position of inserted zero width space
52
+ tr.setMeta('zeroWidthSpacePos', view.state.selection.$from.pos);
53
+ }
39
54
  view.dispatch(tr);
40
55
  return false;
41
56
  },
42
57
  compositionend: function compositionend(view, event) {
43
58
  var tr = view.state.tr;
44
59
  tr.setMeta(compositionPluginKey, false);
60
+ if (isLinux()) {
61
+ var _compositionPluginKey2;
62
+ var zeroWidthSpacePos = (_compositionPluginKey2 = compositionPluginKey.getState(view.state)) === null || _compositionPluginKey2 === void 0 ? void 0 : _compositionPluginKey2.zeroWidthSpacePos;
63
+ if (typeof zeroWidthSpacePos !== 'undefined') {
64
+ tr.deleteRange(zeroWidthSpacePos, zeroWidthSpacePos + 1);
65
+ }
66
+ tr.setMeta('zeroWidthSpacePos', undefined);
67
+ }
45
68
  view.dispatch(tr);
46
69
  return false;
47
70
  }
@@ -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 = "187.3.0";
9
+ var version = "187.3.4";
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": "187.3.0",
3
+ "version": "187.3.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,23 +1,28 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from 'prosemirror-state';
3
+ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
4
  const compositionPluginKey = new PluginKey('compositionPlugin');
4
5
  export const isComposing = state => {
5
6
  var _compositionPluginKey;
6
7
  return !!((_compositionPluginKey = compositionPluginKey.getState(state)) !== null && _compositionPluginKey !== void 0 && _compositionPluginKey.isComposing);
7
8
  };
9
+ const isLinux = () => navigator.userAgent.indexOf('Linux') >= 0;
8
10
  export default (() => new SafePlugin({
9
11
  key: compositionPluginKey,
10
12
  state: {
11
13
  init: () => ({
12
- isComposing: false
14
+ isComposing: false,
15
+ zeroWidthSpacePos: undefined
13
16
  }),
14
17
  apply: (tr, value) => {
15
18
  const isComposing = tr.getMeta(compositionPluginKey);
19
+ const zeroWidthSpacePos = tr.getMeta('zeroWidthSpacePos');
16
20
  if (typeof isComposing === 'undefined') {
17
21
  return value;
18
22
  }
19
23
  return {
20
- isComposing
24
+ isComposing,
25
+ zeroWidthSpacePos
21
26
  };
22
27
  }
23
28
  },
@@ -28,6 +33,14 @@ export default (() => new SafePlugin({
28
33
  tr
29
34
  } = view.state;
30
35
  tr.setMeta(compositionPluginKey, true);
36
+
37
+ // only apply for linux and cursor is at start of line
38
+ if (isLinux() && view.state.selection.$from.parentOffset === 0) {
39
+ tr.insertText(ZERO_WIDTH_SPACE);
40
+
41
+ // remember the position of inserted zero width space
42
+ tr.setMeta('zeroWidthSpacePos', view.state.selection.$from.pos);
43
+ }
31
44
  view.dispatch(tr);
32
45
  return false;
33
46
  },
@@ -36,6 +49,14 @@ export default (() => new SafePlugin({
36
49
  tr
37
50
  } = view.state;
38
51
  tr.setMeta(compositionPluginKey, false);
52
+ if (isLinux()) {
53
+ var _compositionPluginKey2;
54
+ const zeroWidthSpacePos = (_compositionPluginKey2 = compositionPluginKey.getState(view.state)) === null || _compositionPluginKey2 === void 0 ? void 0 : _compositionPluginKey2.zeroWidthSpacePos;
55
+ if (typeof zeroWidthSpacePos !== 'undefined') {
56
+ tr.deleteRange(zeroWidthSpacePos, zeroWidthSpacePos + 1);
57
+ }
58
+ tr.setMeta('zeroWidthSpacePos', undefined);
59
+ }
39
60
  view.dispatch(tr);
40
61
  return false;
41
62
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.3.0";
2
+ export const version = "187.3.4";
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": "187.3.0",
3
+ "version": "187.3.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,26 +1,33 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from 'prosemirror-state';
3
+ import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
3
4
  var compositionPluginKey = new PluginKey('compositionPlugin');
4
5
  export var isComposing = function isComposing(state) {
5
6
  var _compositionPluginKey;
6
7
  return !!((_compositionPluginKey = compositionPluginKey.getState(state)) !== null && _compositionPluginKey !== void 0 && _compositionPluginKey.isComposing);
7
8
  };
9
+ var isLinux = function isLinux() {
10
+ return navigator.userAgent.indexOf('Linux') >= 0;
11
+ };
8
12
  export default (function () {
9
13
  return new SafePlugin({
10
14
  key: compositionPluginKey,
11
15
  state: {
12
16
  init: function init() {
13
17
  return {
14
- isComposing: false
18
+ isComposing: false,
19
+ zeroWidthSpacePos: undefined
15
20
  };
16
21
  },
17
22
  apply: function apply(tr, value) {
18
23
  var isComposing = tr.getMeta(compositionPluginKey);
24
+ var zeroWidthSpacePos = tr.getMeta('zeroWidthSpacePos');
19
25
  if (typeof isComposing === 'undefined') {
20
26
  return value;
21
27
  }
22
28
  return {
23
- isComposing: isComposing
29
+ isComposing: isComposing,
30
+ zeroWidthSpacePos: zeroWidthSpacePos
24
31
  };
25
32
  }
26
33
  },
@@ -29,12 +36,28 @@ export default (function () {
29
36
  compositionstart: function compositionstart(view, event) {
30
37
  var tr = view.state.tr;
31
38
  tr.setMeta(compositionPluginKey, true);
39
+
40
+ // only apply for linux and cursor is at start of line
41
+ if (isLinux() && view.state.selection.$from.parentOffset === 0) {
42
+ tr.insertText(ZERO_WIDTH_SPACE);
43
+
44
+ // remember the position of inserted zero width space
45
+ tr.setMeta('zeroWidthSpacePos', view.state.selection.$from.pos);
46
+ }
32
47
  view.dispatch(tr);
33
48
  return false;
34
49
  },
35
50
  compositionend: function compositionend(view, event) {
36
51
  var tr = view.state.tr;
37
52
  tr.setMeta(compositionPluginKey, false);
53
+ if (isLinux()) {
54
+ var _compositionPluginKey2;
55
+ var zeroWidthSpacePos = (_compositionPluginKey2 = compositionPluginKey.getState(view.state)) === null || _compositionPluginKey2 === void 0 ? void 0 : _compositionPluginKey2.zeroWidthSpacePos;
56
+ if (typeof zeroWidthSpacePos !== 'undefined') {
57
+ tr.deleteRange(zeroWidthSpacePos, zeroWidthSpacePos + 1);
58
+ }
59
+ tr.setMeta('zeroWidthSpacePos', undefined);
60
+ }
38
61
  view.dispatch(tr);
39
62
  return false;
40
63
  }
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.3.0";
2
+ export var version = "187.3.4";
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": "187.3.0",
3
+ "version": "187.3.4",
4
4
  "sideEffects": false
5
5
  }
@@ -2,6 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { EditorState } from 'prosemirror-state';
3
3
  interface CompositionPluginState {
4
4
  isComposing: boolean;
5
+ zeroWidthSpacePos?: number;
5
6
  }
6
7
  export declare const isComposing: (state: EditorState) => boolean;
7
8
  declare const _default: () => SafePlugin<CompositionPluginState>;
@@ -2,6 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { EditorState } from 'prosemirror-state';
3
3
  interface CompositionPluginState {
4
4
  isComposing: boolean;
5
+ zeroWidthSpacePos?: number;
5
6
  }
6
7
  export declare const isComposing: (state: EditorState) => boolean;
7
8
  declare const _default: () => SafePlugin<CompositionPluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.3.0",
3
+ "version": "187.3.4",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -157,7 +157,7 @@
157
157
  "@atlaskit/inline-dialog": "^13.6.0",
158
158
  "@atlaskit/link-analytics": "^8.2.0",
159
159
  "@atlaskit/link-provider": "^1.6.0",
160
- "@atlaskit/link-test-helpers": "^4.1.0",
160
+ "@atlaskit/link-test-helpers": "^4.2.0",
161
161
  "@atlaskit/media-core": "^34.1.0",
162
162
  "@atlaskit/media-integration-test-helpers": "^3.0.0",
163
163
  "@atlaskit/media-test-helpers": "^33.0.0",