@atlaskit/editor-common 76.7.0 → 76.8.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,11 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 76.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#40750](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40750) [`fc19a7b9edd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fc19a7b9edd) - [ED-19875] Extraction of Editor Core's Selection Plugin into independent package '@atlaskit/editor-plugin-selection'.
8
+
3
9
  ## 76.7.0
4
10
 
5
11
  ### Minor Changes
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "76.7.0";
19
+ var packageVersion = "76.8.0";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setSelectionTopLevelBlocks = exports.setGapCursorAtPos = void 0;
7
+ var _state = require("@atlaskit/editor-prosemirror/state");
8
+ var _selection = require("./selection");
9
+ var _isValidTargetNode = require("./utils/is-valid-target-node");
10
+ // This function captures clicks outside of the ProseMirror contentEditable area
11
+ // see also description of "handleClick" in gap-cursor pm-plugin
12
+ var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr) {
13
+ var rect = editorRef.getBoundingClientRect();
14
+
15
+ // capture clicks before the first block element
16
+ if (event.clientY < rect.top) {
17
+ return {
18
+ position: 0,
19
+ side: _selection.Side.LEFT
20
+ };
21
+ }
22
+ if (rect.left > 0) {
23
+ // calculate start position of a node that is vertically at the same level
24
+ var _coords = posAtCoords({
25
+ left: rect.left,
26
+ top: event.clientY
27
+ });
28
+ if (_coords && _coords.inside > -1) {
29
+ var $from = tr.doc.resolve(_coords.inside);
30
+ var start = $from.before(1);
31
+ var side = event.clientX < rect.left ? _selection.Side.LEFT : _selection.Side.RIGHT;
32
+ var position;
33
+ if (side === _selection.Side.LEFT) {
34
+ position = start;
35
+ } else {
36
+ var node = tr.doc.nodeAt(start);
37
+ if (node) {
38
+ position = start + node.nodeSize;
39
+ }
40
+ }
41
+ return {
42
+ position: position,
43
+ side: side
44
+ };
45
+ }
46
+ }
47
+ return null;
48
+ };
49
+ var setSelectionTopLevelBlocks = exports.setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused) {
50
+ var cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
51
+ if (!cursorCoords) {
52
+ return;
53
+ }
54
+ var $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
55
+ if ($pos === null) {
56
+ return;
57
+ }
58
+ var isGapCursorAllowed = cursorCoords.side === _selection.Side.LEFT ? (0, _isValidTargetNode.isValidTargetNode)($pos.nodeAfter) : (0, _isValidTargetNode.isValidTargetNode)($pos.nodeBefore);
59
+ if (isGapCursorAllowed && _selection.GapCursorSelection.valid($pos)) {
60
+ // this forces PM to re-render the decoration node if we change the side of the gap cursor, it doesn't do it by default
61
+ if (tr.selection instanceof _selection.GapCursorSelection) {
62
+ tr.setSelection(_state.Selection.near($pos));
63
+ } else {
64
+ tr.setSelection(new _selection.GapCursorSelection($pos, cursorCoords.side));
65
+ }
66
+ }
67
+ // try to set text selection if the editor isnt focused
68
+ // if the editor is focused, we are most likely dragging a selection outside.
69
+ else if (editorFocused === false) {
70
+ var selectionTemp = _state.Selection.findFrom($pos, cursorCoords.side === _selection.Side.LEFT ? 1 : -1, true);
71
+ if (selectionTemp) {
72
+ tr.setSelection(selectionTemp);
73
+ }
74
+ }
75
+ };
76
+ var setGapCursorAtPos = exports.setGapCursorAtPos = function setGapCursorAtPos(position) {
77
+ var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _selection.Side.LEFT;
78
+ return function (state, dispatch) {
79
+ // @see ED-6231
80
+ if (position > state.doc.content.size) {
81
+ return false;
82
+ }
83
+ var $pos = state.doc.resolve(position);
84
+ if (_selection.GapCursorSelection.valid($pos)) {
85
+ if (dispatch) {
86
+ dispatch(state.tr.setSelection(new _selection.GapCursorSelection($pos, side)));
87
+ }
88
+ return true;
89
+ }
90
+ return false;
91
+ };
92
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.hideCaretModifier = exports.gapCursorStyles = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _react = require("@emotion/react");
10
+ var _templateObject, _templateObject2;
11
+ var gapCursorBlink = (0, _react.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n from, to {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n"])));
12
+ var hideCaretModifier = exports.hideCaretModifier = 'ProseMirror-hide-gapcursor';
13
+ var gapCursor = '.ProseMirror-gapcursor';
14
+ var prosemirrorwidget = '.ProseMirror-widget';
15
+ var wrapLeft = '[layout="wrap-left"]';
16
+ var wrapRight = '[layout="wrap-right"]';
17
+ var gapCursorStyles = exports.gapCursorStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n /* =============== GAP CURSOR ================== */\n .ProseMirror {\n &.", " {\n caret-color: transparent;\n }\n\n ", " {\n display: none;\n pointer-events: none;\n position: relative;\n\n & span {\n caret-color: transparent;\n position: absolute;\n height: 100%;\n width: 100%;\n display: block;\n }\n\n & span::after {\n animation: 1s ", " step-end infinite;\n border-left: 1px solid;\n content: '';\n display: block;\n position: absolute;\n top: 0;\n height: 100%;\n }\n &.-left span::after {\n left: -3px;\n }\n &.-right span::after {\n right: -3px;\n }\n & span[layout='full-width'],\n & span[layout='wide'],\n & span[layout='fixed-width'] {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n &", " {\n float: right;\n }\n\n /* fix vertical alignment of gap cursor */\n &:first-of-type + ul,\n &:first-of-type + span + ul,\n &:first-of-type + ol,\n &:first-of-type + span + ol,\n &:first-of-type + pre,\n &:first-of-type + span + pre,\n &:first-of-type + blockquote,\n &:first-of-type + span + blockquote {\n margin-top: 0;\n }\n }\n &.ProseMirror-focused ", " {\n display: block;\n border-color: transparent;\n }\n }\n\n /* This hack below is for two images aligned side by side */\n ", "", " + span + ", ",\n ", "", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " {\n clear: none;\n }\n\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div {\n margin-right: 0;\n margin-left: 0;\n margin-bottom: 0;\n }\n\n ", " + ", ",\n ", " + ", " {\n float: left;\n }\n\n ", " + ", " + span + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after {\n visibility: hidden;\n display: block;\n font-size: 0;\n content: ' ';\n clear: both;\n height: 0;\n }\n\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + *,\n ", " + ", " + span + * {\n margin-top: 0;\n }\n"])), hideCaretModifier, gapCursor, gapCursorBlink, wrapRight, gapCursor, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, wrapLeft, gapCursor, wrapRight, gapCursor, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, prosemirrorwidget, gapCursor, prosemirrorwidget, gapCursor);
@@ -64,10 +64,22 @@ Object.defineProperty(exports, "endPositionOfParent", {
64
64
  return _utils3.endPositionOfParent;
65
65
  }
66
66
  });
67
+ Object.defineProperty(exports, "gapCursorStyles", {
68
+ enumerable: true,
69
+ get: function get() {
70
+ return _styles.gapCursorStyles;
71
+ }
72
+ });
67
73
  exports.getAllSelectionAnalyticsPayload = getAllSelectionAnalyticsPayload;
68
74
  exports.getCellSelectionAnalyticsPayload = getCellSelectionAnalyticsPayload;
69
75
  exports.getNodeSelectionAnalyticsPayload = getNodeSelectionAnalyticsPayload;
70
76
  exports.getRangeSelectionAnalyticsPayload = getRangeSelectionAnalyticsPayload;
77
+ Object.defineProperty(exports, "hideCaretModifier", {
78
+ enumerable: true,
79
+ get: function get() {
80
+ return _styles.hideCaretModifier;
81
+ }
82
+ });
71
83
  Object.defineProperty(exports, "isIgnored", {
72
84
  enumerable: true,
73
85
  get: function get() {
@@ -93,12 +105,24 @@ Object.defineProperty(exports, "isValidTargetNode", {
93
105
  }
94
106
  });
95
107
  exports.selectNode = void 0;
108
+ Object.defineProperty(exports, "setGapCursorAtPos", {
109
+ enumerable: true,
110
+ get: function get() {
111
+ return _actions.setGapCursorAtPos;
112
+ }
113
+ });
96
114
  Object.defineProperty(exports, "setGapCursorSelection", {
97
115
  enumerable: true,
98
116
  get: function get() {
99
117
  return _setGapCursorSelection.setGapCursorSelection;
100
118
  }
101
119
  });
120
+ Object.defineProperty(exports, "setSelectionTopLevelBlocks", {
121
+ enumerable: true,
122
+ get: function get() {
123
+ return _actions.setSelectionTopLevelBlocks;
124
+ }
125
+ });
102
126
  Object.defineProperty(exports, "startPositionOfParent", {
103
127
  enumerable: true,
104
128
  get: function get() {
@@ -111,8 +135,10 @@ var _utils = require("@atlaskit/editor-tables/utils");
111
135
  var _analytics = require("../analytics");
112
136
  var _types = require("./types");
113
137
  var _selection = require("./gap-cursor/selection");
138
+ var _actions = require("./gap-cursor/actions");
114
139
  var _utils2 = require("./gap-cursor/utils");
115
140
  var _setGapCursorSelection = require("./gap-cursor/utils/setGapCursorSelection");
141
+ var _styles = require("./gap-cursor/styles");
116
142
  var _utils3 = require("./utils");
117
143
  function getNodeSelectionAnalyticsPayload(selection) {
118
144
  if (selection instanceof _state.NodeSelection) {
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "76.7.0";
27
+ var packageVersion = "76.8.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -9,13 +9,17 @@ exports.isElementInTableCell = void 0;
9
9
  exports.isEmptyParagraph = isEmptyParagraph;
10
10
  exports.isValidPosition = exports.isTextSelection = exports.isLastItemMediaGroup = exports.isInLayoutColumn = void 0;
11
11
  exports.nonNullable = nonNullable;
12
- exports.setNodeSelection = exports.removeBlockMarks = void 0;
12
+ exports.removeBlockMarks = void 0;
13
+ exports.setAllSelection = setAllSelection;
14
+ exports.setCellSelection = setCellSelection;
15
+ exports.setNodeSelection = void 0;
13
16
  exports.setTextSelection = setTextSelection;
14
17
  exports.stepAddsOneOf = stepAddsOneOf;
15
18
  exports.stepHasSlice = void 0;
16
19
  var _state = require("@atlaskit/editor-prosemirror/state");
17
20
  var _transform = require("@atlaskit/editor-prosemirror/transform");
18
21
  var _utils = require("@atlaskit/editor-prosemirror/utils");
22
+ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
19
23
  var _dom = require("./dom");
20
24
  /**
21
25
  * Checks if node is an empty paragraph.
@@ -81,6 +85,17 @@ function setTextSelection(view, anchor, head) {
81
85
  var tr = state.tr.setSelection(_state.TextSelection.create(state.doc, anchor, head));
82
86
  dispatch(tr);
83
87
  }
88
+ function setAllSelection(view) {
89
+ var state = view.state,
90
+ dispatch = view.dispatch;
91
+ var tr = state.tr.setSelection(new _state.AllSelection(view.state.doc));
92
+ dispatch(tr);
93
+ }
94
+ function setCellSelection(view, anchor, head) {
95
+ var state = view.state,
96
+ dispatch = view.dispatch;
97
+ dispatch(state.tr.setSelection(_cellSelection.CellSelection.create(state.doc, anchor, head)));
98
+ }
84
99
  function nonNullable(value) {
85
100
  return value !== null && value !== undefined;
86
101
  }
@@ -871,6 +871,18 @@ Object.defineProperty(exports, "sanitizeNodeForPrivacy", {
871
871
  return _privacyFilter.sanitizeNodeForPrivacy;
872
872
  }
873
873
  });
874
+ Object.defineProperty(exports, "setAllSelection", {
875
+ enumerable: true,
876
+ get: function get() {
877
+ return _editorCoreUtils.setAllSelection;
878
+ }
879
+ });
880
+ Object.defineProperty(exports, "setCellSelection", {
881
+ enumerable: true,
882
+ get: function get() {
883
+ return _editorCoreUtils.setCellSelection;
884
+ }
885
+ });
874
886
  Object.defineProperty(exports, "setNodeSelection", {
875
887
  enumerable: true,
876
888
  get: function get() {
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "76.7.0";
3
+ const packageVersion = "76.8.0";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -0,0 +1,84 @@
1
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import { GapCursorSelection, Side } from './selection';
3
+ import { isValidTargetNode } from './utils/is-valid-target-node';
4
+
5
+ // This function captures clicks outside of the ProseMirror contentEditable area
6
+ // see also description of "handleClick" in gap-cursor pm-plugin
7
+ const captureCursorCoords = (event, editorRef, posAtCoords, tr) => {
8
+ const rect = editorRef.getBoundingClientRect();
9
+
10
+ // capture clicks before the first block element
11
+ if (event.clientY < rect.top) {
12
+ return {
13
+ position: 0,
14
+ side: Side.LEFT
15
+ };
16
+ }
17
+ if (rect.left > 0) {
18
+ // calculate start position of a node that is vertically at the same level
19
+ const coords = posAtCoords({
20
+ left: rect.left,
21
+ top: event.clientY
22
+ });
23
+ if (coords && coords.inside > -1) {
24
+ const $from = tr.doc.resolve(coords.inside);
25
+ const start = $from.before(1);
26
+ const side = event.clientX < rect.left ? Side.LEFT : Side.RIGHT;
27
+ let position;
28
+ if (side === Side.LEFT) {
29
+ position = start;
30
+ } else {
31
+ const node = tr.doc.nodeAt(start);
32
+ if (node) {
33
+ position = start + node.nodeSize;
34
+ }
35
+ }
36
+ return {
37
+ position,
38
+ side
39
+ };
40
+ }
41
+ }
42
+ return null;
43
+ };
44
+ export const setSelectionTopLevelBlocks = (tr, event, editorRef, posAtCoords, editorFocused) => {
45
+ const cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
46
+ if (!cursorCoords) {
47
+ return;
48
+ }
49
+ const $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
50
+ if ($pos === null) {
51
+ return;
52
+ }
53
+ const isGapCursorAllowed = cursorCoords.side === Side.LEFT ? isValidTargetNode($pos.nodeAfter) : isValidTargetNode($pos.nodeBefore);
54
+ if (isGapCursorAllowed && GapCursorSelection.valid($pos)) {
55
+ // this forces PM to re-render the decoration node if we change the side of the gap cursor, it doesn't do it by default
56
+ if (tr.selection instanceof GapCursorSelection) {
57
+ tr.setSelection(Selection.near($pos));
58
+ } else {
59
+ tr.setSelection(new GapCursorSelection($pos, cursorCoords.side));
60
+ }
61
+ }
62
+ // try to set text selection if the editor isnt focused
63
+ // if the editor is focused, we are most likely dragging a selection outside.
64
+ else if (editorFocused === false) {
65
+ const selectionTemp = Selection.findFrom($pos, cursorCoords.side === Side.LEFT ? 1 : -1, true);
66
+ if (selectionTemp) {
67
+ tr.setSelection(selectionTemp);
68
+ }
69
+ }
70
+ };
71
+ export const setGapCursorAtPos = (position, side = Side.LEFT) => (state, dispatch) => {
72
+ // @see ED-6231
73
+ if (position > state.doc.content.size) {
74
+ return false;
75
+ }
76
+ const $pos = state.doc.resolve(position);
77
+ if (GapCursorSelection.valid($pos)) {
78
+ if (dispatch) {
79
+ dispatch(state.tr.setSelection(new GapCursorSelection($pos, side)));
80
+ }
81
+ return true;
82
+ }
83
+ return false;
84
+ };
@@ -0,0 +1,145 @@
1
+ import { css, keyframes } from '@emotion/react';
2
+ const gapCursorBlink = keyframes`
3
+ from, to {
4
+ opacity: 0;
5
+ }
6
+ 50% {
7
+ opacity: 1;
8
+ }
9
+ `;
10
+ export const hideCaretModifier = 'ProseMirror-hide-gapcursor';
11
+ const gapCursor = '.ProseMirror-gapcursor';
12
+ const prosemirrorwidget = '.ProseMirror-widget';
13
+ const wrapLeft = '[layout="wrap-left"]';
14
+ const wrapRight = '[layout="wrap-right"]';
15
+ export const gapCursorStyles = css`
16
+ /* =============== GAP CURSOR ================== */
17
+ .ProseMirror {
18
+ &.${hideCaretModifier} {
19
+ caret-color: transparent;
20
+ }
21
+
22
+ ${gapCursor} {
23
+ display: none;
24
+ pointer-events: none;
25
+ position: relative;
26
+
27
+ & span {
28
+ caret-color: transparent;
29
+ position: absolute;
30
+ height: 100%;
31
+ width: 100%;
32
+ display: block;
33
+ }
34
+
35
+ & span::after {
36
+ animation: 1s ${gapCursorBlink} step-end infinite;
37
+ border-left: 1px solid;
38
+ content: '';
39
+ display: block;
40
+ position: absolute;
41
+ top: 0;
42
+ height: 100%;
43
+ }
44
+ &.-left span::after {
45
+ left: -3px;
46
+ }
47
+ &.-right span::after {
48
+ right: -3px;
49
+ }
50
+ & span[layout='full-width'],
51
+ & span[layout='wide'],
52
+ & span[layout='fixed-width'] {
53
+ margin-left: 50%;
54
+ transform: translateX(-50%);
55
+ }
56
+ &${wrapRight} {
57
+ float: right;
58
+ }
59
+
60
+ /* fix vertical alignment of gap cursor */
61
+ &:first-of-type + ul,
62
+ &:first-of-type + span + ul,
63
+ &:first-of-type + ol,
64
+ &:first-of-type + span + ol,
65
+ &:first-of-type + pre,
66
+ &:first-of-type + span + pre,
67
+ &:first-of-type + blockquote,
68
+ &:first-of-type + span + blockquote {
69
+ margin-top: 0;
70
+ }
71
+ }
72
+ &.ProseMirror-focused ${gapCursor} {
73
+ display: block;
74
+ border-color: transparent;
75
+ }
76
+ }
77
+
78
+ /* This hack below is for two images aligned side by side */
79
+ ${gapCursor}${wrapLeft} + span + ${wrapLeft},
80
+ ${gapCursor}${wrapRight} + span + ${wrapRight},
81
+ ${gapCursor} + ${wrapLeft} + ${wrapRight},
82
+ ${gapCursor} + ${wrapLeft} + span + ${wrapRight},
83
+ ${gapCursor} + ${wrapRight} + ${wrapLeft},
84
+ ${gapCursor} + ${wrapRight} + span + ${wrapLeft},
85
+ ${wrapLeft} + ${gapCursor} + ${wrapRight},
86
+ ${wrapLeft} + ${gapCursor} + span ${wrapRight},
87
+ ${wrapRight} + ${gapCursor} + ${wrapLeft},
88
+ ${wrapRight} + ${gapCursor} + span + ${wrapLeft},
89
+ ${wrapLeft} + ${gapCursor} {
90
+ clear: none;
91
+ }
92
+
93
+ ${wrapLeft} + ${gapCursor} + ${wrapRight} > div,
94
+ ${wrapLeft} + ${gapCursor} + span + ${wrapRight} > div,
95
+ ${wrapRight} + ${gapCursor} + ${wrapLeft} > div,
96
+ ${wrapRight} + ${gapCursor} + span + ${wrapLeft} > div,
97
+ ${gapCursor} + ${wrapRight} + ${wrapLeft} > div,
98
+ ${gapCursor} + ${wrapRight} + span + ${wrapLeft} > div,
99
+ ${gapCursor} + ${wrapLeft} + ${wrapRight} > div,
100
+ ${gapCursor} + ${wrapLeft} + span + ${wrapRight} > div {
101
+ margin-right: 0;
102
+ margin-left: 0;
103
+ margin-bottom: 0;
104
+ }
105
+
106
+ ${wrapLeft} + ${gapCursor},
107
+ ${wrapRight} + ${gapCursor} {
108
+ float: left;
109
+ }
110
+
111
+ ${gapCursor} + ${wrapLeft} + span + ${wrapRight}::after,
112
+ ${gapCursor} + ${wrapRight} + span + ${wrapLeft}::after,
113
+ ${wrapLeft} + ${gapCursor} + ${wrapRight}::after,
114
+ ${wrapLeft} + ${gapCursor} + span + ${wrapRight}::after,
115
+ ${wrapRight} + ${gapCursor} + ${wrapLeft}::after,
116
+ ${wrapRight} + ${gapCursor} + span + ${wrapLeft}::after {
117
+ visibility: hidden;
118
+ display: block;
119
+ font-size: 0;
120
+ content: ' ';
121
+ clear: both;
122
+ height: 0;
123
+ }
124
+
125
+ ${wrapLeft} + ${gapCursor} + ${wrapRight} + *,
126
+ ${wrapLeft} + ${gapCursor} + ${wrapRight} + span + *,
127
+ ${wrapRight} + ${gapCursor} + ${wrapLeft} + *,
128
+ ${wrapRight} + ${gapCursor} + ${wrapLeft} + span + *,
129
+ ${wrapLeft} + ${gapCursor} + span + ${wrapRight} + *,
130
+ ${wrapRight} + ${gapCursor} + span + ${wrapLeft} + *,
131
+ ${gapCursor} + ${wrapLeft} + span + ${wrapRight} + *,
132
+ ${gapCursor} + ${wrapRight} + span + ${wrapLeft} + *,
133
+ ${wrapLeft} + ${gapCursor} + ${wrapRight} + * > *,
134
+ ${wrapLeft} + ${gapCursor} + ${wrapRight} + span + * > *,
135
+ ${wrapRight} + ${gapCursor} + ${wrapLeft} + * > *,
136
+ ${wrapRight} + ${gapCursor} + ${wrapLeft} + span + * > *,
137
+ ${wrapLeft} + ${gapCursor} + span + ${wrapRight} + * > *,
138
+ ${wrapRight} + ${gapCursor} + span + ${wrapLeft} + * > *,
139
+ ${gapCursor} + ${wrapLeft} + span + ${wrapRight} + * > *,
140
+ ${gapCursor} + ${wrapRight} + span + ${wrapLeft} + * > *,
141
+ ${prosemirrorwidget} + ${gapCursor} + *,
142
+ ${prosemirrorwidget} + ${gapCursor} + span + * {
143
+ margin-top: 0;
144
+ }
145
+ `;
@@ -4,8 +4,10 @@ import { selectedRect } from '@atlaskit/editor-tables/utils';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
5
5
  export { RelativeSelectionPos } from './types';
6
6
  export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
7
+ export { setSelectionTopLevelBlocks, setGapCursorAtPos } from './gap-cursor/actions';
7
8
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
8
9
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
10
+ export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
9
11
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
10
12
  export function getNodeSelectionAnalyticsPayload(selection) {
11
13
  if (selection instanceof NodeSelection) {
@@ -9,7 +9,7 @@ import { themed } from '@atlaskit/theme/components';
9
9
  import { borderRadius } from '@atlaskit/theme/constants';
10
10
  import Layer from '../Layer';
11
11
  const packageName = "@atlaskit/editor-common";
12
- const packageVersion = "76.7.0";
12
+ const packageVersion = "76.8.0";
13
13
  const halfFocusRing = 1;
14
14
  const dropOffset = '0, 8';
15
15
  class DropList extends Component {
@@ -1,6 +1,7 @@
1
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
1
+ import { AllSelection, NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
3
3
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
5
  import { closest } from './dom';
5
6
 
6
7
  /**
@@ -69,6 +70,21 @@ export function setTextSelection(view, anchor, head) {
69
70
  const tr = state.tr.setSelection(TextSelection.create(state.doc, anchor, head));
70
71
  dispatch(tr);
71
72
  }
73
+ export function setAllSelection(view) {
74
+ const {
75
+ state,
76
+ dispatch
77
+ } = view;
78
+ const tr = state.tr.setSelection(new AllSelection(view.state.doc));
79
+ dispatch(tr);
80
+ }
81
+ export function setCellSelection(view, anchor, head) {
82
+ const {
83
+ state,
84
+ dispatch
85
+ } = view;
86
+ dispatch(state.tr.setSelection(CellSelection.create(state.doc, anchor, head)));
87
+ }
72
88
  export function nonNullable(value) {
73
89
  return value !== null && value !== undefined;
74
90
  }
@@ -6,7 +6,7 @@ export { getExtensionLozengeData } from './macro';
6
6
  export { default as browser } from './browser';
7
7
  export { default as ErrorReporter } from './error-reporter';
8
8
  export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC } from './date';
9
- export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
9
+ export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, setAllSelection, setCellSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
10
10
  export { withImageLoader } from './imageLoader';
11
11
  export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle } from './breakout';
12
12
  export { findChangedNodesFromTransaction, validNode, validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "76.7.0";
9
+ var packageVersion = "76.8.0";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -0,0 +1,87 @@
1
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import { GapCursorSelection, Side } from './selection';
3
+ import { isValidTargetNode } from './utils/is-valid-target-node';
4
+
5
+ // This function captures clicks outside of the ProseMirror contentEditable area
6
+ // see also description of "handleClick" in gap-cursor pm-plugin
7
+ var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr) {
8
+ var rect = editorRef.getBoundingClientRect();
9
+
10
+ // capture clicks before the first block element
11
+ if (event.clientY < rect.top) {
12
+ return {
13
+ position: 0,
14
+ side: Side.LEFT
15
+ };
16
+ }
17
+ if (rect.left > 0) {
18
+ // calculate start position of a node that is vertically at the same level
19
+ var _coords = posAtCoords({
20
+ left: rect.left,
21
+ top: event.clientY
22
+ });
23
+ if (_coords && _coords.inside > -1) {
24
+ var $from = tr.doc.resolve(_coords.inside);
25
+ var start = $from.before(1);
26
+ var side = event.clientX < rect.left ? Side.LEFT : Side.RIGHT;
27
+ var position;
28
+ if (side === Side.LEFT) {
29
+ position = start;
30
+ } else {
31
+ var node = tr.doc.nodeAt(start);
32
+ if (node) {
33
+ position = start + node.nodeSize;
34
+ }
35
+ }
36
+ return {
37
+ position: position,
38
+ side: side
39
+ };
40
+ }
41
+ }
42
+ return null;
43
+ };
44
+ export var setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused) {
45
+ var cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
46
+ if (!cursorCoords) {
47
+ return;
48
+ }
49
+ var $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
50
+ if ($pos === null) {
51
+ return;
52
+ }
53
+ var isGapCursorAllowed = cursorCoords.side === Side.LEFT ? isValidTargetNode($pos.nodeAfter) : isValidTargetNode($pos.nodeBefore);
54
+ if (isGapCursorAllowed && GapCursorSelection.valid($pos)) {
55
+ // this forces PM to re-render the decoration node if we change the side of the gap cursor, it doesn't do it by default
56
+ if (tr.selection instanceof GapCursorSelection) {
57
+ tr.setSelection(Selection.near($pos));
58
+ } else {
59
+ tr.setSelection(new GapCursorSelection($pos, cursorCoords.side));
60
+ }
61
+ }
62
+ // try to set text selection if the editor isnt focused
63
+ // if the editor is focused, we are most likely dragging a selection outside.
64
+ else if (editorFocused === false) {
65
+ var selectionTemp = Selection.findFrom($pos, cursorCoords.side === Side.LEFT ? 1 : -1, true);
66
+ if (selectionTemp) {
67
+ tr.setSelection(selectionTemp);
68
+ }
69
+ }
70
+ };
71
+ export var setGapCursorAtPos = function setGapCursorAtPos(position) {
72
+ var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Side.LEFT;
73
+ return function (state, dispatch) {
74
+ // @see ED-6231
75
+ if (position > state.doc.content.size) {
76
+ return false;
77
+ }
78
+ var $pos = state.doc.resolve(position);
79
+ if (GapCursorSelection.valid($pos)) {
80
+ if (dispatch) {
81
+ dispatch(state.tr.setSelection(new GapCursorSelection($pos, side)));
82
+ }
83
+ return true;
84
+ }
85
+ return false;
86
+ };
87
+ };
@@ -0,0 +1,10 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2;
3
+ import { css, keyframes } from '@emotion/react';
4
+ var gapCursorBlink = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from, to {\n opacity: 0;\n }\n 50% {\n opacity: 1;\n }\n"])));
5
+ export var hideCaretModifier = 'ProseMirror-hide-gapcursor';
6
+ var gapCursor = '.ProseMirror-gapcursor';
7
+ var prosemirrorwidget = '.ProseMirror-widget';
8
+ var wrapLeft = '[layout="wrap-left"]';
9
+ var wrapRight = '[layout="wrap-right"]';
10
+ export var gapCursorStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /* =============== GAP CURSOR ================== */\n .ProseMirror {\n &.", " {\n caret-color: transparent;\n }\n\n ", " {\n display: none;\n pointer-events: none;\n position: relative;\n\n & span {\n caret-color: transparent;\n position: absolute;\n height: 100%;\n width: 100%;\n display: block;\n }\n\n & span::after {\n animation: 1s ", " step-end infinite;\n border-left: 1px solid;\n content: '';\n display: block;\n position: absolute;\n top: 0;\n height: 100%;\n }\n &.-left span::after {\n left: -3px;\n }\n &.-right span::after {\n right: -3px;\n }\n & span[layout='full-width'],\n & span[layout='wide'],\n & span[layout='fixed-width'] {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n &", " {\n float: right;\n }\n\n /* fix vertical alignment of gap cursor */\n &:first-of-type + ul,\n &:first-of-type + span + ul,\n &:first-of-type + ol,\n &:first-of-type + span + ol,\n &:first-of-type + pre,\n &:first-of-type + span + pre,\n &:first-of-type + blockquote,\n &:first-of-type + span + blockquote {\n margin-top: 0;\n }\n }\n &.ProseMirror-focused ", " {\n display: block;\n border-color: transparent;\n }\n }\n\n /* This hack below is for two images aligned side by side */\n ", "", " + span + ", ",\n ", "", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " {\n clear: none;\n }\n\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div {\n margin-right: 0;\n margin-left: 0;\n margin-bottom: 0;\n }\n\n ", " + ", ",\n ", " + ", " {\n float: left;\n }\n\n ", " + ", " + span + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after {\n visibility: hidden;\n display: block;\n font-size: 0;\n content: ' ';\n clear: both;\n height: 0;\n }\n\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + *,\n ", " + ", " + span + * {\n margin-top: 0;\n }\n"])), hideCaretModifier, gapCursor, gapCursorBlink, wrapRight, gapCursor, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, wrapLeft, gapCursor, wrapRight, gapCursor, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, prosemirrorwidget, gapCursor, prosemirrorwidget, gapCursor);
@@ -4,8 +4,10 @@ import { selectedRect } from '@atlaskit/editor-tables/utils';
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../analytics';
5
5
  export { RelativeSelectionPos } from './types';
6
6
  export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
7
+ export { setSelectionTopLevelBlocks, setGapCursorAtPos } from './gap-cursor/actions';
7
8
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
8
9
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
10
+ export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
9
11
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
10
12
  export function getNodeSelectionAnalyticsPayload(selection) {
11
13
  if (selection instanceof NodeSelection) {
@@ -19,7 +19,7 @@ import { themed } from '@atlaskit/theme/components';
19
19
  import { borderRadius } from '@atlaskit/theme/constants';
20
20
  import Layer from '../Layer';
21
21
  var packageName = "@atlaskit/editor-common";
22
- var packageVersion = "76.7.0";
22
+ var packageVersion = "76.8.0";
23
23
  var halfFocusRing = 1;
24
24
  var dropOffset = '0, 8';
25
25
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,6 +1,7 @@
1
- import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
1
+ import { AllSelection, NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
3
3
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
4
5
  import { closest } from './dom';
5
6
 
6
7
  /**
@@ -67,6 +68,17 @@ export function setTextSelection(view, anchor, head) {
67
68
  var tr = state.tr.setSelection(TextSelection.create(state.doc, anchor, head));
68
69
  dispatch(tr);
69
70
  }
71
+ export function setAllSelection(view) {
72
+ var state = view.state,
73
+ dispatch = view.dispatch;
74
+ var tr = state.tr.setSelection(new AllSelection(view.state.doc));
75
+ dispatch(tr);
76
+ }
77
+ export function setCellSelection(view, anchor, head) {
78
+ var state = view.state,
79
+ dispatch = view.dispatch;
80
+ dispatch(state.tr.setSelection(CellSelection.create(state.doc, anchor, head)));
81
+ }
70
82
  export function nonNullable(value) {
71
83
  return value !== null && value !== undefined;
72
84
  }
@@ -6,7 +6,7 @@ export { getExtensionLozengeData } from './macro';
6
6
  export { default as browser } from './browser';
7
7
  export { default as ErrorReporter } from './error-reporter';
8
8
  export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC } from './date';
9
- export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
9
+ export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, setAllSelection, setCellSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
10
10
  export { withImageLoader } from './imageLoader';
11
11
  export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle } from './breakout';
12
12
  export { findChangedNodesFromTransaction, validNode, validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
@@ -0,0 +1,11 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Command } from '../../types';
3
+ import { Side } from './selection';
4
+ export declare const setSelectionTopLevelBlocks: (tr: Transaction, event: React.MouseEvent<any>, editorRef: HTMLElement, posAtCoords: (coords: {
5
+ left: number;
6
+ top: number;
7
+ }) => {
8
+ pos: number;
9
+ inside: number;
10
+ } | null | void, editorFocused: boolean) => void;
11
+ export declare const setGapCursorAtPos: (position: number, side?: Side) => Command;
@@ -0,0 +1,2 @@
1
+ export declare const hideCaretModifier = "ProseMirror-hide-gapcursor";
2
+ export declare const gapCursorStyles: import("@emotion/react").SerializedStyles;
@@ -4,10 +4,12 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { AnalyticsEventPayload } from '../analytics';
5
5
  import type { Command } from '../types';
6
6
  export { RelativeSelectionPos } from './types';
7
- export type { SelectionPluginState, EditorSelectionAPI, SelectionPluginOptions, SelectionSharedState, } from './types';
7
+ export type { SelectionPluginState, EditorSelectionAPI, SelectionPluginOptions, SelectionSharedState, SetSelectionRelativeToNode, } from './types';
8
8
  export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
9
+ export { setSelectionTopLevelBlocks, setGapCursorAtPos, } from './gap-cursor/actions';
9
10
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
10
11
  export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
12
+ export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles';
11
13
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
12
14
  export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
13
15
  export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined;
@@ -18,11 +18,12 @@ export interface SelectionPluginState {
18
18
  */
19
19
  selectionRelativeToNode?: RelativeSelectionPos;
20
20
  }
21
+ export type SetSelectionRelativeToNode = (props: {
22
+ selectionRelativeToNode?: RelativeSelectionPos;
23
+ selection?: Selection | null;
24
+ }) => (state: EditorState) => Transaction;
21
25
  export type EditorSelectionAPI = {
22
- setSelectionRelativeToNode: (props: {
23
- selectionRelativeToNode?: RelativeSelectionPos;
24
- selection?: Selection | null;
25
- }) => (state: EditorState) => Transaction;
26
+ setSelectionRelativeToNode: SetSelectionRelativeToNode;
26
27
  getSelectionPluginState: (state: EditorState) => SelectionPluginState;
27
28
  };
28
29
  export interface SelectionPluginOptions extends LongPressSelectionPluginOptions {
@@ -17,5 +17,5 @@ export type OpenChangedEvent = {
17
17
  isOpen: boolean;
18
18
  event: MouseEvent | KeyboardEvent;
19
19
  };
20
- declare const _default: import("react").ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "key" | "id" | "children" | "testId" | "position" | "analyticsContext" | "shouldFitContainer" | "onPositioned" | "isOpen" | "trigger" | "onOpenChange"> & import("react").RefAttributes<any>>;
20
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<Omit<Props, keyof WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "key" | "id" | "children" | "position" | "testId" | "analyticsContext" | "shouldFitContainer" | "onPositioned" | "isOpen" | "trigger" | "onOpenChange"> & import("react").RefAttributes<any>>;
21
21
  export default _default;
@@ -1,7 +1,8 @@
1
- import { MarkType, Node, NodeType, Slice } from '@atlaskit/editor-prosemirror/model';
2
- import { EditorState, Selection, TextSelection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import { Step } from '@atlaskit/editor-prosemirror/transform';
4
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { MarkType, Node, NodeType, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
4
+ import type { Step } from '@atlaskit/editor-prosemirror/transform';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
6
  /**
6
7
  * Checks if node is an empty paragraph.
7
8
  */
@@ -24,6 +25,8 @@ export declare const isElementInTableCell: (element: HTMLElement | null) => HTML
24
25
  export declare const isLastItemMediaGroup: (node: Node) => boolean;
25
26
  export declare const setNodeSelection: (view: EditorView, pos: number) => void;
26
27
  export declare function setTextSelection(view: EditorView, anchor: number, head?: number): void;
28
+ export declare function setAllSelection(view: EditorView): void;
29
+ export declare function setCellSelection(view: EditorView, anchor: number, head?: number): void;
27
30
  export declare function nonNullable<T>(value: T): value is NonNullable<T>;
28
31
  export declare const isValidPosition: (pos: number | undefined, state: EditorState) => boolean;
29
32
  export declare const isInLayoutColumn: (state: EditorState) => boolean;
@@ -9,7 +9,7 @@ export { default as ErrorReporter } from './error-reporter';
9
9
  export type { ErrorReportingHandler } from './error-reporter';
10
10
  export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC, } from './date';
11
11
  export type { Date } from './date';
12
- export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween, } from './editor-core-utils';
12
+ export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, setAllSelection, setCellSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween, } from './editor-core-utils';
13
13
  export { withImageLoader } from './imageLoader';
14
14
  export type { ImageLoaderProps, ImageLoaderState, ImageStatus, } from './imageLoader';
15
15
  export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle, } from './breakout';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "76.7.0",
3
+ "version": "76.8.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"