@atlaskit/editor-core 187.17.5 → 187.17.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/plugins/base/pm-plugins/inline-cursor-target.js +7 -41
  3. package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
  4. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/es2019/plugins/base/pm-plugins/inline-cursor-target.js +9 -41
  8. package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
  9. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
  10. package/dist/es2019/version-wrapper.js +1 -1
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/esm/plugins/base/pm-plugins/inline-cursor-target.js +7 -41
  13. package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
  14. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
  15. package/dist/esm/version-wrapper.js +1 -1
  16. package/dist/esm/version.json +1 -1
  17. package/dist/types/extensibility.d.ts +0 -2
  18. package/dist/types/labs/next/presets/default.d.ts +0 -2
  19. package/dist/types/plugins/analytics/index.d.ts +0 -2
  20. package/dist/types/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
  21. package/dist/types/plugins/annotation/utils.d.ts +2 -5
  22. package/dist/types/plugins/base/pm-plugins/context-identifier.d.ts +1 -1
  23. package/dist/types/plugins/block-type/commands/block-type.d.ts +0 -2
  24. package/dist/types/plugins/block-type/pm-plugins/main.d.ts +6 -1
  25. package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +1 -1
  26. package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -2
  27. package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +5 -1
  28. package/dist/types/plugins/code-block/pm-plugins/main.d.ts +2 -1
  29. package/dist/types/plugins/code-block/utils.d.ts +1 -1
  30. package/dist/types/plugins/collab-edit/utils.d.ts +1 -5
  31. package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +10 -1
  32. package/dist/types/plugins/copy-button/toolbar.d.ts +0 -2
  33. package/dist/types/plugins/copy-button/utils.d.ts +1 -1
  34. package/dist/types/plugins/custom-autoformat/index.d.ts +2 -1
  35. package/dist/types/plugins/date/pm-plugins/main.d.ts +0 -2
  36. package/dist/types/plugins/expand/pm-plugins/main.d.ts +1 -1
  37. package/dist/types/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -2
  38. package/dist/types/plugins/extension/plugin-factory.d.ts +0 -2
  39. package/dist/types/plugins/extension/utils.d.ts +1 -1
  40. package/dist/types/plugins/find-replace/plugin.d.ts +0 -2
  41. package/dist/types/plugins/find-replace/utils/index.d.ts +1 -4
  42. package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +3 -1
  43. package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -2
  44. package/dist/types/plugins/media/commands/helpers.d.ts +1 -1
  45. package/dist/types/plugins/media/pm-plugins/alt-text/index.d.ts +1 -3
  46. package/dist/types/plugins/media/pm-plugins/linking/index.d.ts +0 -2
  47. package/dist/types/plugins/media/toolbar/utils.d.ts +1 -3
  48. package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +0 -1
  49. package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +0 -1
  50. package/dist/types/plugins/mobile-dimensions/plugin-factory.d.ts +0 -2
  51. package/dist/types/plugins/panel/utils.d.ts +1 -1
  52. package/dist/types/plugins/paste/pm-plugins/main.d.ts +1 -1
  53. package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -2
  54. package/dist/types/plugins/paste/util/index.d.ts +1 -1
  55. package/dist/types/plugins/selection/plugin-factory.d.ts +0 -2
  56. package/dist/types/plugins/selection/pm-plugins/gap-cursor-main.d.ts +1 -1
  57. package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
  58. package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +1 -2
  59. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  60. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  61. package/dist/types/utils/action.d.ts +1 -60
  62. package/dist/types/utils/list-commands.d.ts +0 -1
  63. package/dist/types-ts4.5/extensibility.d.ts +0 -2
  64. package/dist/types-ts4.5/labs/next/presets/default.d.ts +0 -2
  65. package/dist/types-ts4.5/plugins/analytics/index.d.ts +0 -2
  66. package/dist/types-ts4.5/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
  67. package/dist/types-ts4.5/plugins/annotation/utils.d.ts +2 -5
  68. package/dist/types-ts4.5/plugins/base/pm-plugins/context-identifier.d.ts +1 -1
  69. package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +0 -2
  70. package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +6 -1
  71. package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/main.d.ts +1 -1
  72. package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -2
  73. package/dist/types-ts4.5/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +8 -1
  74. package/dist/types-ts4.5/plugins/code-block/pm-plugins/main.d.ts +2 -1
  75. package/dist/types-ts4.5/plugins/code-block/utils.d.ts +1 -1
  76. package/dist/types-ts4.5/plugins/collab-edit/utils.d.ts +1 -5
  77. package/dist/types-ts4.5/plugins/copy-button/pm-plugins/main.d.ts +10 -1
  78. package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +0 -2
  79. package/dist/types-ts4.5/plugins/copy-button/utils.d.ts +1 -1
  80. package/dist/types-ts4.5/plugins/custom-autoformat/index.d.ts +2 -1
  81. package/dist/types-ts4.5/plugins/date/pm-plugins/main.d.ts +0 -2
  82. package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +1 -1
  83. package/dist/types-ts4.5/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -2
  84. package/dist/types-ts4.5/plugins/extension/plugin-factory.d.ts +0 -2
  85. package/dist/types-ts4.5/plugins/extension/utils.d.ts +1 -1
  86. package/dist/types-ts4.5/plugins/find-replace/plugin.d.ts +0 -2
  87. package/dist/types-ts4.5/plugins/find-replace/utils/index.d.ts +1 -4
  88. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +3 -1
  89. package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -2
  90. package/dist/types-ts4.5/plugins/media/commands/helpers.d.ts +1 -1
  91. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/index.d.ts +1 -3
  92. package/dist/types-ts4.5/plugins/media/pm-plugins/linking/index.d.ts +0 -2
  93. package/dist/types-ts4.5/plugins/media/toolbar/utils.d.ts +1 -3
  94. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +0 -1
  95. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/index.d.ts +0 -1
  96. package/dist/types-ts4.5/plugins/mobile-dimensions/plugin-factory.d.ts +0 -2
  97. package/dist/types-ts4.5/plugins/panel/utils.d.ts +1 -1
  98. package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +1 -1
  99. package/dist/types-ts4.5/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -2
  100. package/dist/types-ts4.5/plugins/paste/util/index.d.ts +1 -1
  101. package/dist/types-ts4.5/plugins/selection/plugin-factory.d.ts +0 -2
  102. package/dist/types-ts4.5/plugins/selection/pm-plugins/gap-cursor-main.d.ts +1 -1
  103. package/dist/types-ts4.5/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
  104. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +1 -2
  105. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  106. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  107. package/dist/types-ts4.5/utils/action.d.ts +1 -60
  108. package/dist/types-ts4.5/utils/list-commands.d.ts +0 -1
  109. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.17.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bdb69158e0a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bdb69158e0a) - [ED-13910] Bump ProseMirror libraries to match prosemirror-view@1.31.6 dependencies
8
+ - Updated dependencies
9
+
3
10
  ## 187.17.5
4
11
 
5
12
  ### Patch Changes
@@ -50,24 +50,18 @@ var _default = function _default() {
50
50
  node.setAttribute('aria-hidden', 'true');
51
51
  node.appendChild(document.createTextNode(_utils.ZERO_WIDTH_SPACE));
52
52
  node.className = 'cursor-target';
53
- return _view.Decoration.widget(selection.from, node, {
53
+ var $from = selection.$from;
54
+ var rightPosition = $from.pos;
55
+ var leftPosition = $from.posAtIndex(Math.max($from.index() - 1, 0));
56
+ var widgetPos = side === 'left' ? leftPosition : rightPosition;
57
+ return _view.Decoration.widget(widgetPos, node, {
54
58
  raw: true,
55
- side: side === 'left' ? -1 : 1,
56
59
  key: 'inlineCursor'
57
60
  });
58
61
  };
59
62
 
60
- // Create editable decoration widgets either side of the cursor to allow
61
- // text input.
62
- // We check beforeInput events below to prevent content
63
- // being added to the decorations.
64
- //
65
- // This prevents issues with the cursor disappearing
66
- // or appearing in the wrong place when;
67
- // - positioned between inline nodes (chrome + firefox)
68
- // - positioned between the beginning of another node and an inline node (firefox)
69
- // - positioned between an inline node and the end of a node (chrome)
70
- if (!_utils.browser.safari && (hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
63
+ // Create editable decoration widgets around the current inline node to allow proper cursor navigation.
64
+ if ((hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
71
65
  return {
72
66
  cursorTarget: {
73
67
  decorations: [createWidget('left'), createWidget('right')],
@@ -78,34 +72,6 @@ var _default = function _default() {
78
72
  }
79
73
  };
80
74
  }
81
-
82
- // Only create one widget on the left or right of the cursor in Safari.
83
- // This is to prevent the left key from being blocked when at the start of a paragraph,
84
- // and the right key from being blocked when at the end of a paragraph. This also
85
- // improves click and drag selections, making it easier to select the first node.
86
- if (_utils.browser.safari) {
87
- if (isAtEndAndInlineNodeViewBefore || hasInlineNodeViewBefore && hasInlineNodeViewAfter) {
88
- return {
89
- cursorTarget: {
90
- decorations: [createWidget('left')],
91
- positions: {
92
- from: $from.pos,
93
- to: $to.pos
94
- }
95
- }
96
- };
97
- } else if (isAtStartAndInlineNodeViewAfter) {
98
- return {
99
- cursorTarget: {
100
- decorations: [createWidget('right')],
101
- positions: {
102
- from: $from.pos,
103
- to: $to.pos
104
- }
105
- }
106
- };
107
- }
108
- }
109
75
  }
110
76
  return {
111
77
  cursorTarget: undefined
@@ -15,9 +15,6 @@ var serializePlaceholderNode = function serializePlaceholderNode(node) {
15
15
 
16
16
  // the inline node api test suite requires the following class name
17
17
  element.classList.add('placeholderView-content-wrap');
18
- if (_utils.browser.gecko) {
19
- element.setAttribute('contenteditable', 'true');
20
- }
21
18
  element.innerText = _utils.ZERO_WIDTH_SPACE;
22
19
  var elementChildren = document.createElement('span');
23
20
  elementChildren.classList.add('pm-placeholder__text');
@@ -94,24 +94,38 @@ var plugin = new _safePlugin.SafePlugin({
94
94
  }
95
95
  return null;
96
96
  },
97
- // there's no space between top level nodes and the wrapping ProseMirror contenteditable area and handleClick won't capture clicks, there's nothing to click on
98
- // it handles only attempts to set gap cursor for nested nodes, where we have space between parent and child nodes
99
- // top level nodes are handled by <ClickAreaBlock>
100
- handleClick: function handleClick(view, position, event) {
97
+ handleClick: function handleClick(view, nodePos, event) {
98
+ var _$pos$parent;
101
99
  var posAtCoords = view.posAtCoords({
102
100
  left: event.clientX,
103
101
  top: event.clientY
104
102
  });
105
-
106
- // this helps to ignore all of the clicks outside of the parent (e.g. nodeView controls)
107
- if (posAtCoords && posAtCoords.inside !== position && !(0, _utils2.isIgnoredClick)(event.target)) {
108
- // max available space between parent and child from the left side in px
109
- // this ensures the correct side of the gap cursor in case of clicking in between two block nodes
110
- var leftSideOffsetX = 20;
111
- var side = event.offsetX > leftSideOffsetX ? _selection.Side.RIGHT : _selection.Side.LEFT;
112
- return (0, _actions.setGapCursorAtPos)(position, side)(view.state, view.dispatch);
103
+ if (!posAtCoords || (0, _utils2.isIgnoredClick)(event.target)) {
104
+ return false;
113
105
  }
114
- return false;
106
+ var isInsideTheTarget = posAtCoords.pos === posAtCoords.inside;
107
+ if (isInsideTheTarget) {
108
+ return false;
109
+ }
110
+ var leftSideOffsetX = 20;
111
+ var side = event.offsetX > leftSideOffsetX ? _selection.Side.RIGHT : _selection.Side.LEFT;
112
+ var $pos = view.state.doc.resolve(nodePos);
113
+ // In the new prosemirror-view posAtCoords is not returning a precise value for our media nodes
114
+ if (((_$pos$parent = $pos.parent) === null || _$pos$parent === void 0 ? void 0 : _$pos$parent.type.name) === 'mediaSingle') {
115
+ var $insidePos = view.state.doc.resolve(Math.max(posAtCoords.inside, 0));
116
+ // We don't have GapCursors problems when the node target is inside the root level
117
+ if ($insidePos.depth <= 1) {
118
+ return false;
119
+ }
120
+ var mediaGapCursor = !$pos.nodeBefore ? $pos.before() : $pos.after();
121
+ return (0, _actions.setGapCursorAtPos)(mediaGapCursor, side)(view.state, view.dispatch);
122
+ }
123
+ var docSize = view.state.doc.content.size;
124
+ var nodeInside = posAtCoords.inside <= 0 || posAtCoords.inside > docSize ? null : view.state.doc.nodeAt(posAtCoords.inside);
125
+ if (nodeInside !== null && nodeInside !== void 0 && nodeInside.isAtom) {
126
+ return false;
127
+ }
128
+ return (0, _actions.setGapCursorAtPos)(nodePos, side)(view.state, view.dispatch);
115
129
  },
116
130
  handleDOMEvents: {
117
131
  /**
@@ -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.17.5";
9
+ var version = "187.17.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": "187.17.5",
3
+ "version": "187.17.6",
4
4
  "sideEffects": false
5
5
  }
@@ -44,24 +44,20 @@ export default (() => {
44
44
  node.setAttribute('aria-hidden', 'true');
45
45
  node.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
46
46
  node.className = 'cursor-target';
47
- return Decoration.widget(selection.from, node, {
47
+ const {
48
+ $from
49
+ } = selection;
50
+ const rightPosition = $from.pos;
51
+ const leftPosition = $from.posAtIndex(Math.max($from.index() - 1, 0));
52
+ const widgetPos = side === 'left' ? leftPosition : rightPosition;
53
+ return Decoration.widget(widgetPos, node, {
48
54
  raw: true,
49
- side: side === 'left' ? -1 : 1,
50
55
  key: 'inlineCursor'
51
56
  });
52
57
  };
53
58
 
54
- // Create editable decoration widgets either side of the cursor to allow
55
- // text input.
56
- // We check beforeInput events below to prevent content
57
- // being added to the decorations.
58
- //
59
- // This prevents issues with the cursor disappearing
60
- // or appearing in the wrong place when;
61
- // - positioned between inline nodes (chrome + firefox)
62
- // - positioned between the beginning of another node and an inline node (firefox)
63
- // - positioned between an inline node and the end of a node (chrome)
64
- if (!browser.safari && (hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
59
+ // Create editable decoration widgets around the current inline node to allow proper cursor navigation.
60
+ if ((hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
65
61
  return {
66
62
  cursorTarget: {
67
63
  decorations: [createWidget('left'), createWidget('right')],
@@ -72,34 +68,6 @@ export default (() => {
72
68
  }
73
69
  };
74
70
  }
75
-
76
- // Only create one widget on the left or right of the cursor in Safari.
77
- // This is to prevent the left key from being blocked when at the start of a paragraph,
78
- // and the right key from being blocked when at the end of a paragraph. This also
79
- // improves click and drag selections, making it easier to select the first node.
80
- if (browser.safari) {
81
- if (isAtEndAndInlineNodeViewBefore || hasInlineNodeViewBefore && hasInlineNodeViewAfter) {
82
- return {
83
- cursorTarget: {
84
- decorations: [createWidget('left')],
85
- positions: {
86
- from: $from.pos,
87
- to: $to.pos
88
- }
89
- }
90
- };
91
- } else if (isAtStartAndInlineNodeViewAfter) {
92
- return {
93
- cursorTarget: {
94
- decorations: [createWidget('right')],
95
- positions: {
96
- from: $from.pos,
97
- to: $to.pos
98
- }
99
- }
100
- };
101
- }
102
- }
103
71
  }
104
72
  return {
105
73
  cursorTarget: undefined
@@ -6,9 +6,6 @@ const serializePlaceholderNode = node => {
6
6
 
7
7
  // the inline node api test suite requires the following class name
8
8
  element.classList.add('placeholderView-content-wrap');
9
- if (browser.gecko) {
10
- element.setAttribute('contenteditable', 'true');
11
- }
12
9
  element.innerText = ZERO_WIDTH_SPACE;
13
10
  const elementChildren = document.createElement('span');
14
11
  elementChildren.classList.add('pm-placeholder__text');
@@ -89,24 +89,38 @@ const plugin = new SafePlugin({
89
89
  }
90
90
  return null;
91
91
  },
92
- // there's no space between top level nodes and the wrapping ProseMirror contenteditable area and handleClick won't capture clicks, there's nothing to click on
93
- // it handles only attempts to set gap cursor for nested nodes, where we have space between parent and child nodes
94
- // top level nodes are handled by <ClickAreaBlock>
95
- handleClick(view, position, event) {
92
+ handleClick(view, nodePos, event) {
93
+ var _$pos$parent;
96
94
  const posAtCoords = view.posAtCoords({
97
95
  left: event.clientX,
98
96
  top: event.clientY
99
97
  });
100
-
101
- // this helps to ignore all of the clicks outside of the parent (e.g. nodeView controls)
102
- if (posAtCoords && posAtCoords.inside !== position && !isIgnoredClick(event.target)) {
103
- // max available space between parent and child from the left side in px
104
- // this ensures the correct side of the gap cursor in case of clicking in between two block nodes
105
- const leftSideOffsetX = 20;
106
- const side = event.offsetX > leftSideOffsetX ? Side.RIGHT : Side.LEFT;
107
- return setGapCursorAtPos(position, side)(view.state, view.dispatch);
98
+ if (!posAtCoords || isIgnoredClick(event.target)) {
99
+ return false;
100
+ }
101
+ const isInsideTheTarget = posAtCoords.pos === posAtCoords.inside;
102
+ if (isInsideTheTarget) {
103
+ return false;
104
+ }
105
+ const leftSideOffsetX = 20;
106
+ const side = event.offsetX > leftSideOffsetX ? Side.RIGHT : Side.LEFT;
107
+ const $pos = view.state.doc.resolve(nodePos);
108
+ // In the new prosemirror-view posAtCoords is not returning a precise value for our media nodes
109
+ if (((_$pos$parent = $pos.parent) === null || _$pos$parent === void 0 ? void 0 : _$pos$parent.type.name) === 'mediaSingle') {
110
+ const $insidePos = view.state.doc.resolve(Math.max(posAtCoords.inside, 0));
111
+ // We don't have GapCursors problems when the node target is inside the root level
112
+ if ($insidePos.depth <= 1) {
113
+ return false;
114
+ }
115
+ const mediaGapCursor = !$pos.nodeBefore ? $pos.before() : $pos.after();
116
+ return setGapCursorAtPos(mediaGapCursor, side)(view.state, view.dispatch);
117
+ }
118
+ const docSize = view.state.doc.content.size;
119
+ const nodeInside = posAtCoords.inside <= 0 || posAtCoords.inside > docSize ? null : view.state.doc.nodeAt(posAtCoords.inside);
120
+ if (nodeInside !== null && nodeInside !== void 0 && nodeInside.isAtom) {
121
+ return false;
108
122
  }
109
- return false;
123
+ return setGapCursorAtPos(nodePos, side)(view.state, view.dispatch);
110
124
  },
111
125
  handleDOMEvents: {
112
126
  /**
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.17.5";
2
+ export const version = "187.17.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": "187.17.5",
3
+ "version": "187.17.6",
4
4
  "sideEffects": false
5
5
  }
@@ -42,24 +42,18 @@ export default (function () {
42
42
  node.setAttribute('aria-hidden', 'true');
43
43
  node.appendChild(document.createTextNode(ZERO_WIDTH_SPACE));
44
44
  node.className = 'cursor-target';
45
- return Decoration.widget(selection.from, node, {
45
+ var $from = selection.$from;
46
+ var rightPosition = $from.pos;
47
+ var leftPosition = $from.posAtIndex(Math.max($from.index() - 1, 0));
48
+ var widgetPos = side === 'left' ? leftPosition : rightPosition;
49
+ return Decoration.widget(widgetPos, node, {
46
50
  raw: true,
47
- side: side === 'left' ? -1 : 1,
48
51
  key: 'inlineCursor'
49
52
  });
50
53
  };
51
54
 
52
- // Create editable decoration widgets either side of the cursor to allow
53
- // text input.
54
- // We check beforeInput events below to prevent content
55
- // being added to the decorations.
56
- //
57
- // This prevents issues with the cursor disappearing
58
- // or appearing in the wrong place when;
59
- // - positioned between inline nodes (chrome + firefox)
60
- // - positioned between the beginning of another node and an inline node (firefox)
61
- // - positioned between an inline node and the end of a node (chrome)
62
- if (!browser.safari && (hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
55
+ // Create editable decoration widgets around the current inline node to allow proper cursor navigation.
56
+ if ((hasInlineNodeViewAfter || isAtEndAndInlineNodeViewBefore) && (hasInlineNodeViewBefore || isAtStartAndInlineNodeViewAfter)) {
63
57
  return {
64
58
  cursorTarget: {
65
59
  decorations: [createWidget('left'), createWidget('right')],
@@ -70,34 +64,6 @@ export default (function () {
70
64
  }
71
65
  };
72
66
  }
73
-
74
- // Only create one widget on the left or right of the cursor in Safari.
75
- // This is to prevent the left key from being blocked when at the start of a paragraph,
76
- // and the right key from being blocked when at the end of a paragraph. This also
77
- // improves click and drag selections, making it easier to select the first node.
78
- if (browser.safari) {
79
- if (isAtEndAndInlineNodeViewBefore || hasInlineNodeViewBefore && hasInlineNodeViewAfter) {
80
- return {
81
- cursorTarget: {
82
- decorations: [createWidget('left')],
83
- positions: {
84
- from: $from.pos,
85
- to: $to.pos
86
- }
87
- }
88
- };
89
- } else if (isAtStartAndInlineNodeViewAfter) {
90
- return {
91
- cursorTarget: {
92
- decorations: [createWidget('right')],
93
- positions: {
94
- from: $from.pos,
95
- to: $to.pos
96
- }
97
- }
98
- };
99
- }
100
- }
101
67
  }
102
68
  return {
103
69
  cursorTarget: undefined
@@ -8,9 +8,6 @@ var serializePlaceholderNode = function serializePlaceholderNode(node) {
8
8
 
9
9
  // the inline node api test suite requires the following class name
10
10
  element.classList.add('placeholderView-content-wrap');
11
- if (browser.gecko) {
12
- element.setAttribute('contenteditable', 'true');
13
- }
14
11
  element.innerText = ZERO_WIDTH_SPACE;
15
12
  var elementChildren = document.createElement('span');
16
13
  elementChildren.classList.add('pm-placeholder__text');
@@ -88,24 +88,38 @@ var plugin = new SafePlugin({
88
88
  }
89
89
  return null;
90
90
  },
91
- // there's no space between top level nodes and the wrapping ProseMirror contenteditable area and handleClick won't capture clicks, there's nothing to click on
92
- // it handles only attempts to set gap cursor for nested nodes, where we have space between parent and child nodes
93
- // top level nodes are handled by <ClickAreaBlock>
94
- handleClick: function handleClick(view, position, event) {
91
+ handleClick: function handleClick(view, nodePos, event) {
92
+ var _$pos$parent;
95
93
  var posAtCoords = view.posAtCoords({
96
94
  left: event.clientX,
97
95
  top: event.clientY
98
96
  });
99
-
100
- // this helps to ignore all of the clicks outside of the parent (e.g. nodeView controls)
101
- if (posAtCoords && posAtCoords.inside !== position && !isIgnoredClick(event.target)) {
102
- // max available space between parent and child from the left side in px
103
- // this ensures the correct side of the gap cursor in case of clicking in between two block nodes
104
- var leftSideOffsetX = 20;
105
- var side = event.offsetX > leftSideOffsetX ? Side.RIGHT : Side.LEFT;
106
- return setGapCursorAtPos(position, side)(view.state, view.dispatch);
97
+ if (!posAtCoords || isIgnoredClick(event.target)) {
98
+ return false;
107
99
  }
108
- return false;
100
+ var isInsideTheTarget = posAtCoords.pos === posAtCoords.inside;
101
+ if (isInsideTheTarget) {
102
+ return false;
103
+ }
104
+ var leftSideOffsetX = 20;
105
+ var side = event.offsetX > leftSideOffsetX ? Side.RIGHT : Side.LEFT;
106
+ var $pos = view.state.doc.resolve(nodePos);
107
+ // In the new prosemirror-view posAtCoords is not returning a precise value for our media nodes
108
+ if (((_$pos$parent = $pos.parent) === null || _$pos$parent === void 0 ? void 0 : _$pos$parent.type.name) === 'mediaSingle') {
109
+ var $insidePos = view.state.doc.resolve(Math.max(posAtCoords.inside, 0));
110
+ // We don't have GapCursors problems when the node target is inside the root level
111
+ if ($insidePos.depth <= 1) {
112
+ return false;
113
+ }
114
+ var mediaGapCursor = !$pos.nodeBefore ? $pos.before() : $pos.after();
115
+ return setGapCursorAtPos(mediaGapCursor, side)(view.state, view.dispatch);
116
+ }
117
+ var docSize = view.state.doc.content.size;
118
+ var nodeInside = posAtCoords.inside <= 0 || posAtCoords.inside > docSize ? null : view.state.doc.nodeAt(posAtCoords.inside);
119
+ if (nodeInside !== null && nodeInside !== void 0 && nodeInside.isAtom) {
120
+ return false;
121
+ }
122
+ return setGapCursorAtPos(nodePos, side)(view.state, view.dispatch);
109
123
  },
110
124
  handleDOMEvents: {
111
125
  /**
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.17.5";
2
+ export var version = "187.17.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": "187.17.5",
3
+ "version": "187.17.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../typings/prosemirror-state.d.ts" />
3
1
  export { getChangedNodes } from './utils/document';
4
2
  export { validateNodes } from './utils/nodes';
5
3
  export { toJSON } from './utils';
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
4
2
  import type { PastePluginOptions } from '../../../plugins/paste';
5
3
  import type { BasePluginOptions } from '../../../plugins/base';
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import analyticsPlugin from './plugin';
4
2
  export { ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION, BROWSER_FREEZE_INTERACTION_TYPE, EVENT_TYPE, FULL_WIDTH_MODE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, MODE, PasteContents, PasteSources, PasteTypes, PLATFORMS, PUNC, SYMBOL, TABLE_ACTION, TABLE_BREAKOUT, TRIGGER_METHOD, USER_CONTEXT, DELETE_DIRECTION, LIST_TEXT_SCENARIOS, fireAnalyticsEvent, getAnalyticsEventsFromTransaction, } from '@atlaskit/editor-common/analytics';
5
3
  export type { AnalyticsDispatch, AnalyticsEventPayload, AnalyticsEventPayloadWithChannel, CommonListAnalyticsAttributes, CreateLinkInlineDialogActionType, CreateLinkInlineDialogEventPayload, ErrorEventPayload, ErrorEventAttributes, FormatEventPayload, GeneralEventPayload, InputMethodInsertLink, InputMethodInsertMedia, InsertEventPayload, MediaAltTextActionType, MediaEventPayload, MediaLinkAEP, PASTE_ACTION_SUBJECT_ID, PasteContent, PasteEventPayload, PasteSource, PasteType, SubstituteEventPayload, TableEventPayload, FireAnalyticsCallback, FireAnalyticsEvent, } from '@atlaskit/editor-common/analytics';
@@ -1,4 +1,2 @@
1
- /// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import type { InlineCommentPluginState } from './types';
4
2
  export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: InlineCommentPluginState | ((state: import("prosemirror-state").EditorState) => InlineCommentPluginState)) => import("prosemirror-state").SafeStateField<InlineCommentPluginState>, createCommand: <A = import("./types").InlineCommentAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
@@ -1,4 +1,3 @@
1
- /// <reference path="../../../../../../../typings/prosemirror.d.ts" />
2
1
  import type { ResolvedPos, Mark, Node, Slice, Schema } from '@atlaskit/editor-prosemirror/model';
3
2
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
4
3
  import { PluginKey, TextSelection, AllSelection } from '@atlaskit/editor-prosemirror/state';
@@ -12,11 +11,9 @@ import type { AnalyticsEventPayloadCallback } from '../analytics/utils';
12
11
  * Finds the marks in the nodes to the left and right.
13
12
  * @param $pos Position to center search around
14
13
  */
15
- export declare const surroundingMarks: ($pos: ResolvedPos) => Mark[][];
14
+ export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[];
16
15
  export declare const getAllAnnotations: (doc: Node) => string[];
17
- export declare const addDraftDecoration: (start: number, end: number) => Decoration<{
18
- [key: string]: any;
19
- } & import("prosemirror-view").InlineDecorationSpec>;
16
+ export declare const addDraftDecoration: (start: number, end: number) => Decoration;
20
17
  export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
21
18
  export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
22
19
  /**
@@ -9,5 +9,5 @@ export interface PluginState {
9
9
  contextIdentifierProvider?: ContextIdentifierProvider;
10
10
  }
11
11
  export declare const getContextIdentifier: (state?: EditorState) => ContextIdentifierProvider | undefined;
12
- declare const _default: (dispatch: Dispatch, providerFactory?: ProviderFactory) => SafePlugin<any>;
12
+ declare const _default: (dispatch: Dispatch, providerFactory?: ProviderFactory) => SafePlugin<{}>;
13
13
  export default _default;
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
2
  import type { NodeType } from '@atlaskit/editor-prosemirror/model';
5
3
  import type { HeadingLevelsAndNormalText, Command } from '@atlaskit/editor-common/types';
@@ -9,4 +9,9 @@ export type BlockTypeState = {
9
9
  availableWrapperBlockTypes: BlockType[];
10
10
  };
11
11
  export declare const pluginKey: PluginKey<BlockTypeState>;
12
- export declare const createPlugin: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<BlockTypeState>;
12
+ export declare const createPlugin: (editorAnalyticsApi: EditorAnalyticsAPI | undefined, dispatch: (eventName: string | PluginKey, data: any) => void, lastNodeMustBeParagraph?: boolean) => SafePlugin<{
13
+ currentBlockType: BlockType;
14
+ blockTypesDisabled: boolean;
15
+ availableBlockTypes: BlockType[];
16
+ availableWrapperBlockTypes: BlockType[];
17
+ }>;
@@ -2,4 +2,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { EditorProps, PMPluginFactoryParams } from '../../../types';
3
3
  export declare const createPlugin: ({ dispatch, getIntl }: PMPluginFactoryParams, { appearance }: {
4
4
  appearance: EditorProps['appearance'];
5
- }) => SafePlugin<any>;
5
+ }) => SafePlugin<import("./types").CodeBidiWarningPluginState>;
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
2
  import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
5
3
  export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("./types").CodeBidiWarningPluginState | ((state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState)) => import("prosemirror-state").SafeStateField<import("./types").CodeBidiWarningPluginState>, getPluginState: (state: import("prosemirror-state").EditorState) => import("./types").CodeBidiWarningPluginState;
@@ -2,6 +2,10 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare const copySelectionPluginKey: PluginKey<any>;
5
- export declare function codeBlockCopySelectionPlugin(): SafePlugin<any>;
5
+ type CodeBlockCopySelectionPluginState = {
6
+ decorationStartAndEnd?: [start: number, end: number];
7
+ };
8
+ export declare function codeBlockCopySelectionPlugin(): SafePlugin<CodeBlockCopySelectionPluginState>;
6
9
  export declare function provideVisualFeedbackForCopyButton(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
7
10
  export declare function removeVisualFeedbackForCopyButton(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
11
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { IntlShape } from 'react-intl-next';
3
3
  import type { EditorProps } from '../../../types';
4
+ import type { CodeBlockState } from './main-state';
4
5
  export declare const createPlugin: ({ useLongPressSelection, getIntl, appearance, allowCompositionInputOverride, }: {
5
6
  useLongPressSelection?: boolean | undefined;
6
7
  getIntl: () => IntlShape;
7
8
  appearance: EditorProps['appearance'];
8
9
  allowCompositionInputOverride?: boolean | undefined;
9
- }) => SafePlugin<any>;
10
+ }) => SafePlugin<CodeBlockState>;
@@ -3,4 +3,4 @@ import { Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare function transformSliceToJoinAdjacentCodeBlocks(slice: Slice): Slice;
5
5
  export declare const transformSingleLineCodeBlockToCodeMark: (slice: Slice, schema: Schema) => Slice;
6
- export declare const findCodeBlock: (state: EditorState, selection?: Selection | null) => import("prosemirror-utils").ContentNodeWithPos | undefined;
6
+ export declare const findCodeBlock: (state: EditorState, selection?: Selection | null) => import("prosemirror-utils/dist/types").FindResult;
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
2
  import type { EditorView, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
3
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
@@ -15,9 +13,7 @@ export declare const getAvatarColor: (str: string) => {
15
13
  color: Color;
16
14
  };
17
15
  export declare const findPointers: (id: string, decorations: DecorationSet) => Decoration[];
18
- export declare const createTelepointers: (from: number, to: number, sessionId: string, isSelection: boolean, initial: string) => Decoration<{
19
- [key: string]: any;
20
- }>[];
16
+ export declare const createTelepointers: (from: number, to: number, sessionId: string, isSelection: boolean, initial: string) => Decoration[];
21
17
  export declare const replaceDocument: (doc: any, state: EditorState, version?: number, options?: CollabEditOptions, reserveCursor?: boolean) => import("prosemirror-state").Transaction;
22
18
  export declare const scrollToCollabCursor: (editorView: EditorView, participants: CollabParticipant[], sessionId: string | undefined, index: number) => void;
23
19
  export declare const getPositionOfTelepointer: (sessionId: string, decorationSet: DecorationSet) => undefined | number;
@@ -1,3 +1,12 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare function copyButtonPlugin(): SafePlugin<any>;
2
+ import type { MarkType } from '@atlaskit/editor-prosemirror/model';
3
+ type CopyButtonPluginState = {
4
+ copied: boolean;
5
+ markSelection?: {
6
+ start: number;
7
+ end: number;
8
+ markType: MarkType;
9
+ };
10
+ };
11
+ export declare function copyButtonPlugin(): SafePlugin<CopyButtonPluginState>;
3
12
  export default copyButtonPlugin;
@@ -1,5 +1,3 @@
1
- /// <reference path="../../../../../../../typings/prosemirror.d.ts" />
2
- /// <reference path="../../../../../../../typings/prosemirror-state.d.ts" />
3
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
2
  import type { Command } from '../../../src/types';
5
3
  import type { FloatingToolbarButton, FloatingToolbarItem, MarkOptions, NodeOptions } from '@atlaskit/editor-common/types';