@atlaskit/editor-core 188.5.0 → 188.5.2

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 (130) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -2
  3. package/dist/cjs/labs/next/presets/universal.js +1 -6
  4. package/dist/cjs/plugins/expand/index.js +0 -2
  5. package/dist/cjs/plugins/expand/nodeviews/index.js +37 -13
  6. package/dist/cjs/plugins/index.js +0 -7
  7. package/dist/cjs/ui/Addon/click-area-helper.js +9 -11
  8. package/dist/cjs/ui/ContentStyles/index.js +13 -13
  9. package/dist/cjs/utils/selection.js +12 -14
  10. package/dist/cjs/version-wrapper.js +1 -1
  11. package/dist/es2019/labs/next/presets/default.js +1 -1
  12. package/dist/es2019/labs/next/presets/universal.js +1 -6
  13. package/dist/es2019/plugins/expand/index.js +0 -2
  14. package/dist/es2019/plugins/expand/nodeviews/index.js +37 -13
  15. package/dist/es2019/plugins/index.js +0 -1
  16. package/dist/es2019/ui/Addon/click-area-helper.js +4 -6
  17. package/dist/es2019/ui/ContentStyles/index.js +1 -1
  18. package/dist/es2019/utils/selection.js +2 -17
  19. package/dist/es2019/version-wrapper.js +1 -1
  20. package/dist/esm/labs/next/presets/default.js +1 -1
  21. package/dist/esm/labs/next/presets/universal.js +1 -6
  22. package/dist/esm/plugins/expand/index.js +0 -2
  23. package/dist/esm/plugins/expand/nodeviews/index.js +37 -13
  24. package/dist/esm/plugins/index.js +0 -1
  25. package/dist/esm/ui/Addon/click-area-helper.js +4 -6
  26. package/dist/esm/ui/ContentStyles/index.js +1 -1
  27. package/dist/esm/utils/selection.js +2 -13
  28. package/dist/esm/version-wrapper.js +1 -1
  29. package/dist/types/labs/next/presets/default.d.ts +22 -8
  30. package/dist/types/plugins/expand/index.d.ts +1 -1
  31. package/dist/types/plugins/expand/nodeviews/index.d.ts +3 -2
  32. package/dist/types/plugins/index.d.ts +0 -1
  33. package/dist/types/utils/selection.d.ts +1 -4
  34. package/package.json +4 -3
  35. package/dist/cjs/plugins/selection/actions.js +0 -11
  36. package/dist/cjs/plugins/selection/commands.js +0 -257
  37. package/dist/cjs/plugins/selection/gap-cursor/actions.js +0 -272
  38. package/dist/cjs/plugins/selection/gap-cursor/direction.js +0 -23
  39. package/dist/cjs/plugins/selection/gap-cursor/selection.js +0 -30
  40. package/dist/cjs/plugins/selection/gap-cursor/styles.js +0 -17
  41. package/dist/cjs/plugins/selection/gap-cursor/utils/is-ignored.js +0 -12
  42. package/dist/cjs/plugins/selection/gap-cursor/utils/is-valid-target-node.js +0 -12
  43. package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +0 -103
  44. package/dist/cjs/plugins/selection/gap-cursor/utils.js +0 -137
  45. package/dist/cjs/plugins/selection/gap-cursor-selection.js +0 -37
  46. package/dist/cjs/plugins/selection/index.js +0 -65
  47. package/dist/cjs/plugins/selection/plugin-factory.js +0 -49
  48. package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +0 -92
  49. package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +0 -115
  50. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-keymap.js +0 -46
  51. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +0 -160
  52. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-plugin-key.js +0 -8
  53. package/dist/cjs/plugins/selection/pm-plugins/keymap.js +0 -16
  54. package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +0 -104
  55. package/dist/cjs/plugins/selection/reducer.js +0 -26
  56. package/dist/cjs/plugins/selection/types.js +0 -20
  57. package/dist/cjs/plugins/selection/utils.js +0 -280
  58. package/dist/cjs/selection-api/api.js +0 -27
  59. package/dist/es2019/plugins/selection/actions.js +0 -5
  60. package/dist/es2019/plugins/selection/commands.js +0 -250
  61. package/dist/es2019/plugins/selection/gap-cursor/actions.js +0 -270
  62. package/dist/es2019/plugins/selection/gap-cursor/direction.js +0 -15
  63. package/dist/es2019/plugins/selection/gap-cursor/selection.js +0 -1
  64. package/dist/es2019/plugins/selection/gap-cursor/styles.js +0 -145
  65. package/dist/es2019/plugins/selection/gap-cursor/utils/is-ignored.js +0 -1
  66. package/dist/es2019/plugins/selection/gap-cursor/utils/is-valid-target-node.js +0 -1
  67. package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +0 -94
  68. package/dist/es2019/plugins/selection/gap-cursor/utils.js +0 -124
  69. package/dist/es2019/plugins/selection/gap-cursor-selection.js +0 -2
  70. package/dist/es2019/plugins/selection/index.js +0 -51
  71. package/dist/es2019/plugins/selection/plugin-factory.js +0 -43
  72. package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +0 -89
  73. package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +0 -112
  74. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-keymap.js +0 -40
  75. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +0 -158
  76. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-plugin-key.js +0 -2
  77. package/dist/es2019/plugins/selection/pm-plugins/keymap.js +0 -10
  78. package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +0 -97
  79. package/dist/es2019/plugins/selection/reducer.js +0 -18
  80. package/dist/es2019/plugins/selection/types.js +0 -9
  81. package/dist/es2019/plugins/selection/utils.js +0 -233
  82. package/dist/es2019/selection-api/api.js +0 -20
  83. package/dist/esm/plugins/selection/actions.js +0 -5
  84. package/dist/esm/plugins/selection/commands.js +0 -251
  85. package/dist/esm/plugins/selection/gap-cursor/actions.js +0 -266
  86. package/dist/esm/plugins/selection/gap-cursor/direction.js +0 -15
  87. package/dist/esm/plugins/selection/gap-cursor/selection.js +0 -1
  88. package/dist/esm/plugins/selection/gap-cursor/styles.js +0 -10
  89. package/dist/esm/plugins/selection/gap-cursor/utils/is-ignored.js +0 -1
  90. package/dist/esm/plugins/selection/gap-cursor/utils/is-valid-target-node.js +0 -1
  91. package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +0 -97
  92. package/dist/esm/plugins/selection/gap-cursor/utils.js +0 -128
  93. package/dist/esm/plugins/selection/gap-cursor-selection.js +0 -2
  94. package/dist/esm/plugins/selection/index.js +0 -58
  95. package/dist/esm/plugins/selection/plugin-factory.js +0 -43
  96. package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +0 -86
  97. package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +0 -110
  98. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-keymap.js +0 -40
  99. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +0 -154
  100. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-plugin-key.js +0 -2
  101. package/dist/esm/plugins/selection/pm-plugins/keymap.js +0 -10
  102. package/dist/esm/plugins/selection/pm-plugins/selection-main.js +0 -98
  103. package/dist/esm/plugins/selection/reducer.js +0 -19
  104. package/dist/esm/plugins/selection/types.js +0 -9
  105. package/dist/esm/plugins/selection/utils.js +0 -241
  106. package/dist/esm/selection-api/api.js +0 -21
  107. package/dist/types/plugins/selection/actions.d.ts +0 -17
  108. package/dist/types/plugins/selection/commands.d.ts +0 -10
  109. package/dist/types/plugins/selection/gap-cursor/actions.d.ts +0 -25
  110. package/dist/types/plugins/selection/gap-cursor/direction.d.ts +0 -10
  111. package/dist/types/plugins/selection/gap-cursor/selection.d.ts +0 -1
  112. package/dist/types/plugins/selection/gap-cursor/styles.d.ts +0 -2
  113. package/dist/types/plugins/selection/gap-cursor/utils/is-ignored.d.ts +0 -1
  114. package/dist/types/plugins/selection/gap-cursor/utils/is-valid-target-node.d.ts +0 -1
  115. package/dist/types/plugins/selection/gap-cursor/utils/place-gap-cursor.d.ts +0 -2
  116. package/dist/types/plugins/selection/gap-cursor/utils.d.ts +0 -8
  117. package/dist/types/plugins/selection/gap-cursor-selection.d.ts +0 -2
  118. package/dist/types/plugins/selection/index.d.ts +0 -13
  119. package/dist/types/plugins/selection/plugin-factory.d.ts +0 -2
  120. package/dist/types/plugins/selection/pm-plugins/events/create-selection-between.d.ts +0 -4
  121. package/dist/types/plugins/selection/pm-plugins/events/keydown.d.ts +0 -2
  122. package/dist/types/plugins/selection/pm-plugins/gap-cursor-keymap.d.ts +0 -2
  123. package/dist/types/plugins/selection/pm-plugins/gap-cursor-main.d.ts +0 -6
  124. package/dist/types/plugins/selection/pm-plugins/gap-cursor-plugin-key.d.ts +0 -2
  125. package/dist/types/plugins/selection/pm-plugins/keymap.d.ts +0 -3
  126. package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +0 -7
  127. package/dist/types/plugins/selection/reducer.d.ts +0 -3
  128. package/dist/types/plugins/selection/types.d.ts +0 -12
  129. package/dist/types/plugins/selection/utils.d.ts +0 -58
  130. package/dist/types/selection-api/api.d.ts +0 -11
@@ -1,272 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.shouldSkipGapCursor = exports.setSelectionTopLevelBlocks = exports.setGapCursorAtPos = exports.setCursorForTopLevelBlocks = exports.hasGapCursorPlugin = exports.deleteNode = exports.arrow = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var _utils = require("@atlaskit/editor-prosemirror/utils");
9
- var _direction = require("./direction");
10
- var _selection = require("./selection");
11
- var _utils2 = require("./utils");
12
- var _isValidTargetNode = require("./utils/is-valid-target-node");
13
- var _selection2 = require("@atlaskit/editor-common/selection");
14
- var _gapCursorPluginKey = require("../pm-plugins/gap-cursor-plugin-key");
15
- var _utils3 = require("@atlaskit/editor-common/utils");
16
- var shouldSkipGapCursor = exports.shouldSkipGapCursor = function shouldSkipGapCursor(direction, state, $pos) {
17
- var _$pos$nodeBefore;
18
- var doc = state.doc,
19
- schema = state.schema;
20
- switch (direction) {
21
- case _direction.Direction.UP:
22
- if ((0, _selection2.atTheBeginningOfDoc)(state)) {
23
- return false;
24
- }
25
- return (0, _utils3.isPositionNearTableRow)($pos, schema, 'before') || (0, _utils2.isTextBlockNearPos)(doc, schema, $pos, -1) || (0, _utils3.isNodeBeforeMediaNode)($pos, state);
26
- case _direction.Direction.DOWN:
27
- return (0, _selection2.atTheEndOfDoc)(state) || (0, _utils2.isTextBlockNearPos)(doc, schema, $pos, 1) || (0, _utils3.isPositionNearTableRow)($pos, schema, 'after') || ((_$pos$nodeBefore = $pos.nodeBefore) === null || _$pos$nodeBefore === void 0 ? void 0 : _$pos$nodeBefore.type.name) === 'text' && !$pos.nodeAfter // end of a paragraph
28
- ;
29
-
30
- default:
31
- return false;
32
- }
33
- };
34
-
35
- // These cases should be handled using the handleMediaGapCursor function
36
- function shouldHandleMediaGapCursor(dir, state) {
37
- var _selection$$from$node;
38
- var selection = state.selection;
39
- var upArrowFromGapCursorIntoMedia = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.UP && selection.$from.nodeBefore && (0, _utils3.isMediaNode)(selection.$from.nodeBefore);
40
- var downArrowFromGapCursorIntoMediaGroup = selection instanceof _selection.GapCursorSelection && dir === _direction.Direction.DOWN && ((_selection$$from$node = selection.$from.nodeAfter) === null || _selection$$from$node === void 0 ? void 0 : _selection$$from$node.type.name) === 'mediaGroup';
41
- return upArrowFromGapCursorIntoMedia || downArrowFromGapCursorIntoMediaGroup;
42
- }
43
-
44
- // Handle media gap cursor for up/down arrow into media nodes
45
- // Should check this case by using shouldHandleMediaGapCursor first
46
- function handleMediaGapCursor(dir, state) {
47
- var selection = state.selection,
48
- tr = state.tr;
49
- var $pos = (0, _direction.isBackward)(dir) ? selection.$from : selection.$to;
50
- if (dir === _direction.Direction.UP && selection.$from.nodeBefore && (0, _utils3.isMediaNode)(selection.$from.nodeBefore)) {
51
- var _tr$doc$nodeAt;
52
- var nodeBeforePos = (0, _utils.findPositionOfNodeBefore)(tr.selection);
53
- if (nodeBeforePos && selection.side === 'right' && ((_tr$doc$nodeAt = tr.doc.nodeAt(nodeBeforePos)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.type.name) === 'mediaSingle') {
54
- tr.setSelection(new _state.NodeSelection(tr.doc.resolve(nodeBeforePos))).scrollIntoView();
55
- } else if (nodeBeforePos || nodeBeforePos === 0) {
56
- tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(nodeBeforePos), _selection.Side.LEFT)).scrollIntoView();
57
- }
58
- }
59
- if (dir === _direction.Direction.DOWN && selection.$from.nodeAfter) {
60
- var nodeAfterPos = selection.side === 'right' ? $pos.pos : $pos.pos + selection.$from.nodeAfter.nodeSize;
61
- if (nodeAfterPos) {
62
- tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(nodeAfterPos), _selection.Side.LEFT)).scrollIntoView();
63
- }
64
- }
65
- return tr;
66
- }
67
- var arrow = exports.arrow = function arrow(dir, endOfTextblock) {
68
- return function (state, dispatch, view) {
69
- var doc = state.doc,
70
- selection = state.selection,
71
- tr = state.tr;
72
- var $pos = (0, _direction.isBackward)(dir) ? selection.$from : selection.$to;
73
- var mustMove = selection.empty;
74
-
75
- // start from text selection
76
- if (selection instanceof _state.TextSelection) {
77
- // if cursor is in the middle of a text node, do nothing
78
- if (!endOfTextblock || !endOfTextblock(dir.toString())) {
79
- return false;
80
- }
81
-
82
- // UP/DOWN jumps to the nearest texblock skipping gapcursor whenever possible
83
- if (shouldSkipGapCursor(dir, state, $pos)) {
84
- return false;
85
- }
86
-
87
- // otherwise resolve previous/next position
88
- $pos = doc.resolve((0, _direction.isBackward)(dir) ? $pos.before() : $pos.after());
89
- mustMove = false;
90
- }
91
- if (selection instanceof _state.NodeSelection) {
92
- if (selection.node.isInline) {
93
- return false;
94
- }
95
- if (dir === _direction.Direction.UP && !(0, _selection2.atTheBeginningOfDoc)(state) && !(0, _utils3.isNodeBeforeMediaNode)($pos, state) || dir === _direction.Direction.DOWN) {
96
- // We dont add gap cursor on node selections going up and down
97
- // Except we do if we're going up for a block node which is the
98
- // first node in the document OR the node before is a media node
99
- return false;
100
- }
101
- }
102
-
103
- // Handle media gap cursor for up/down arrow into media nodes
104
- if (shouldHandleMediaGapCursor(dir, state)) {
105
- var updatedTr = handleMediaGapCursor(dir, state);
106
- if (dispatch) {
107
- dispatch(updatedTr);
108
- }
109
- return true;
110
- }
111
-
112
- // when jumping between block nodes at the same depth, we need to reverse cursor without changing ProseMirror position
113
- if (selection instanceof _selection.GapCursorSelection &&
114
- // next node allow gap cursor position
115
- (0, _isValidTargetNode.isValidTargetNode)((0, _direction.isBackward)(dir) ? $pos.nodeBefore : $pos.nodeAfter) && (
116
- // gap cursor changes block node
117
- (0, _direction.isBackward)(dir) && selection.side === _selection.Side.LEFT || (0, _direction.isForward)(dir) && selection.side === _selection.Side.RIGHT)) {
118
- // reverse cursor position
119
- if (dispatch) {
120
- dispatch(tr.setSelection(new _selection.GapCursorSelection($pos, selection.side === _selection.Side.RIGHT ? _selection.Side.LEFT : _selection.Side.RIGHT)).scrollIntoView());
121
- }
122
- return true;
123
- }
124
- if (view) {
125
- var domAtPos = view.domAtPos.bind(view);
126
- var target = (0, _utils.findDomRefAtPos)($pos.pos, domAtPos);
127
- if (target && target.textContent === _utils3.ZERO_WIDTH_SPACE) {
128
- return false;
129
- }
130
- }
131
- var nextSelection = _selection.GapCursorSelection.findFrom($pos, (0, _direction.isBackward)(dir) ? -1 : 1, mustMove);
132
- if (!nextSelection) {
133
- return false;
134
- }
135
- if (!(0, _isValidTargetNode.isValidTargetNode)((0, _direction.isForward)(dir) ? nextSelection.$from.nodeBefore : nextSelection.$from.nodeAfter)) {
136
- // reverse cursor position
137
- if (dispatch) {
138
- dispatch(tr.setSelection(new _selection.GapCursorSelection(nextSelection.$from, (0, _direction.isForward)(dir) ? _selection.Side.LEFT : _selection.Side.RIGHT)).scrollIntoView());
139
- }
140
- return true;
141
- }
142
- if (dispatch) {
143
- dispatch(tr.setSelection(nextSelection).scrollIntoView());
144
- }
145
- return true;
146
- };
147
- };
148
- var deleteNode = exports.deleteNode = function deleteNode(dir) {
149
- return function (state, dispatch) {
150
- if (state.selection instanceof _selection.GapCursorSelection) {
151
- var _state$selection = state.selection,
152
- $from = _state$selection.$from,
153
- $anchor = _state$selection.$anchor;
154
- var tr = state.tr;
155
- if ((0, _direction.isBackward)(dir)) {
156
- if (state.selection.side === 'left') {
157
- tr.setSelection(new _selection.GapCursorSelection($anchor, _selection.Side.RIGHT));
158
- if (dispatch) {
159
- dispatch(tr);
160
- }
161
- return true;
162
- }
163
- tr = (0, _utils.removeNodeBefore)(state.tr);
164
- } else if ($from.nodeAfter) {
165
- tr = tr.delete($from.pos, $from.pos + $from.nodeAfter.nodeSize);
166
- }
167
- if (dispatch) {
168
- dispatch(tr.setSelection(_state.Selection.near(tr.doc.resolve(tr.mapping.map(state.selection.$from.pos)))).scrollIntoView());
169
- }
170
- return true;
171
- }
172
- return false;
173
- };
174
- };
175
- var setGapCursorAtPos = exports.setGapCursorAtPos = function setGapCursorAtPos(position) {
176
- var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _selection.Side.LEFT;
177
- return function (state, dispatch) {
178
- // @see ED-6231
179
- if (position > state.doc.content.size) {
180
- return false;
181
- }
182
- var $pos = state.doc.resolve(position);
183
- if (_selection.GapCursorSelection.valid($pos)) {
184
- if (dispatch) {
185
- dispatch(state.tr.setSelection(new _selection.GapCursorSelection($pos, side)));
186
- }
187
- return true;
188
- }
189
- return false;
190
- };
191
- };
192
-
193
- // This function captures clicks outside of the ProseMirror contentEditable area
194
- // see also description of "handleClick" in gap-cursor pm-plugin
195
- var captureCursorCoords = function captureCursorCoords(event, editorRef, posAtCoords, tr) {
196
- var rect = editorRef.getBoundingClientRect();
197
-
198
- // capture clicks before the first block element
199
- if (event.clientY < rect.top) {
200
- return {
201
- position: 0,
202
- side: _selection.Side.LEFT
203
- };
204
- }
205
- if (rect.left > 0) {
206
- // calculate start position of a node that is vertically at the same level
207
- var _coords = posAtCoords({
208
- left: rect.left,
209
- top: event.clientY
210
- });
211
- if (_coords && _coords.inside > -1) {
212
- var $from = tr.doc.resolve(_coords.inside);
213
- var start = $from.before(1);
214
- var side = event.clientX < rect.left ? _selection.Side.LEFT : _selection.Side.RIGHT;
215
- var position;
216
- if (side === _selection.Side.LEFT) {
217
- position = start;
218
- } else {
219
- var node = tr.doc.nodeAt(start);
220
- if (node) {
221
- position = start + node.nodeSize;
222
- }
223
- }
224
- return {
225
- position: position,
226
- side: side
227
- };
228
- }
229
- }
230
- return null;
231
- };
232
- var setSelectionTopLevelBlocks = exports.setSelectionTopLevelBlocks = function setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused) {
233
- var cursorCoords = captureCursorCoords(event, editorRef, posAtCoords, tr);
234
- if (!cursorCoords) {
235
- return;
236
- }
237
- var $pos = cursorCoords.position !== undefined ? tr.doc.resolve(cursorCoords.position) : null;
238
- if ($pos === null) {
239
- return;
240
- }
241
- var isGapCursorAllowed = cursorCoords.side === _selection.Side.LEFT ? (0, _isValidTargetNode.isValidTargetNode)($pos.nodeAfter) : (0, _isValidTargetNode.isValidTargetNode)($pos.nodeBefore);
242
- if (isGapCursorAllowed && _selection.GapCursorSelection.valid($pos)) {
243
- // 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
244
- if (tr.selection instanceof _selection.GapCursorSelection) {
245
- tr.setSelection(_state.Selection.near($pos));
246
- } else {
247
- tr.setSelection(new _selection.GapCursorSelection($pos, cursorCoords.side));
248
- }
249
- }
250
- // try to set text selection if the editor isnt focused
251
- // if the editor is focused, we are most likely dragging a selection outside.
252
- else if (editorFocused === false) {
253
- var selectionTemp = _state.Selection.findFrom($pos, cursorCoords.side === _selection.Side.LEFT ? 1 : -1, true);
254
- if (selectionTemp) {
255
- tr.setSelection(selectionTemp);
256
- }
257
- }
258
- };
259
- var setCursorForTopLevelBlocks = exports.setCursorForTopLevelBlocks = function setCursorForTopLevelBlocks(event, editorRef, posAtCoords, editorFocused) {
260
- return function (state, dispatch) {
261
- var tr = state.tr;
262
- setSelectionTopLevelBlocks(tr, event, editorRef, posAtCoords, editorFocused);
263
- if (tr.selectionSet && dispatch) {
264
- dispatch(tr);
265
- return true;
266
- }
267
- return false;
268
- };
269
- };
270
- var hasGapCursorPlugin = exports.hasGapCursorPlugin = function hasGapCursorPlugin(state) {
271
- return Boolean(_gapCursorPluginKey.gapCursorPluginKey.get(state));
272
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Direction = void 0;
7
- exports.isBackward = isBackward;
8
- exports.isForward = isForward;
9
- var Direction = exports.Direction = /*#__PURE__*/function (Direction) {
10
- Direction["UP"] = "up";
11
- Direction["RIGHT"] = "right";
12
- Direction["DOWN"] = "down";
13
- Direction["LEFT"] = "left";
14
- Direction["BACKWARD"] = "backward";
15
- Direction["FORWARD"] = "forward";
16
- return Direction;
17
- }({});
18
- function isBackward(dir) {
19
- return [Direction.UP, Direction.LEFT, Direction.BACKWARD].indexOf(dir) !== -1;
20
- }
21
- function isForward(dir) {
22
- return [Direction.RIGHT, Direction.DOWN, Direction.FORWARD].indexOf(dir) !== -1;
23
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "GapBookmark", {
7
- enumerable: true,
8
- get: function get() {
9
- return _selection.GapBookmark;
10
- }
11
- });
12
- Object.defineProperty(exports, "GapCursorSelection", {
13
- enumerable: true,
14
- get: function get() {
15
- return _selection.GapCursorSelection;
16
- }
17
- });
18
- Object.defineProperty(exports, "JSON_ID", {
19
- enumerable: true,
20
- get: function get() {
21
- return _selection.JSON_ID;
22
- }
23
- });
24
- Object.defineProperty(exports, "Side", {
25
- enumerable: true,
26
- get: function get() {
27
- return _selection.Side;
28
- }
29
- });
30
- var _selection = require("@atlaskit/editor-common/selection");
@@ -1,17 +0,0 @@
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);
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "isIgnored", {
7
- enumerable: true,
8
- get: function get() {
9
- return _selection.isIgnored;
10
- }
11
- });
12
- var _selection = require("@atlaskit/editor-common/selection");
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "isValidTargetNode", {
7
- enumerable: true,
8
- get: function get() {
9
- return _selection.isValidTargetNode;
10
- }
11
- });
12
- var _selection = require("@atlaskit/editor-common/selection");
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.toDOM = void 0;
8
- var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
9
- var _utils = require("../utils");
10
- var _selection = require("@atlaskit/editor-common/selection");
11
- /**
12
- * We have a couple of nodes that require us to compute style
13
- * on different elements, ideally all nodes should be able to
14
- * compute the appropriate styles based on their wrapper.
15
- */
16
- var nestedCases = {
17
- 'tableView-content-wrap': 'table',
18
- 'mediaSingleView-content-wrap': '.rich-media-item',
19
- 'bodiedExtensionView-content-wrap': '.extension-container',
20
- 'embedCardView-content-wrap': '.rich-media-item',
21
- 'datasourceView-content-wrap': '.datasourceView-content-inner-wrap'
22
- };
23
- var computeNestedStyle = function computeNestedStyle(dom) {
24
- var foundKey = Object.keys(nestedCases).find(function (className) {
25
- return dom.classList.contains(className);
26
- });
27
- var nestedSelector = foundKey && nestedCases[foundKey];
28
- if (nestedSelector) {
29
- var nestedElement = dom.querySelector(nestedSelector);
30
- if (nestedElement) {
31
- return window.getComputedStyle(nestedElement);
32
- }
33
- }
34
- };
35
- var measureHeight = function measureHeight(style) {
36
- return measureValue(style, ['height', 'padding-top', 'padding-bottom', 'border-top-width', 'border-bottom-width']);
37
- };
38
- var measureWidth = function measureWidth(style) {
39
- return measureValue(style, ['width', 'padding-left', 'padding-right', 'border-left-width', 'border-right-width']);
40
- };
41
- var measureValue = function measureValue(style, measureValues) {
42
- var _measureValues = (0, _toArray2.default)(measureValues),
43
- base = _measureValues[0],
44
- contentBoxValues = _measureValues.slice(1);
45
- var measures = [style.getPropertyValue(base)];
46
- var boxSizing = style.getPropertyValue('box-sizing');
47
- if (boxSizing === 'content-box') {
48
- contentBoxValues.forEach(function (value) {
49
- measures.push(style.getPropertyValue(value));
50
- });
51
- }
52
- var result = 0;
53
- for (var i = 0; i < measures.length; i++) {
54
- result += parseFloat(measures[i]);
55
- }
56
- return result;
57
- };
58
- var mutateElementStyle = function mutateElementStyle(element, style, side) {
59
- element.style.transform = style.getPropertyValue('transform');
60
- if ((0, _utils.isLeftCursor)(side)) {
61
- element.style.width = style.getPropertyValue('width');
62
- element.style.marginLeft = style.getPropertyValue('margin-left');
63
- } else {
64
- var marginRight = parseFloat(style.getPropertyValue('margin-right'));
65
- if (marginRight > 0) {
66
- element.style.marginLeft = "-".concat(Math.abs(marginRight), "px");
67
- } else {
68
- element.style.paddingRight = "".concat(Math.abs(marginRight), "px");
69
- }
70
- }
71
- };
72
- var toDOM = exports.toDOM = function toDOM(view, getPos) {
73
- var selection = view.state.selection;
74
- var $from = selection.$from,
75
- side = selection.side;
76
- var isRightCursor = side === _selection.Side.RIGHT;
77
- var node = isRightCursor ? $from.nodeBefore : $from.nodeAfter;
78
- var nodeStart = getPos();
79
- // @ts-ignore - [unblock prosemirror bump] nodeStart can be undefined
80
- var dom = view.nodeDOM(nodeStart);
81
- var element = document.createElement('span');
82
- element.className = "ProseMirror-gapcursor ".concat(isRightCursor ? '-right' : '-left');
83
- element.appendChild(document.createElement('span'));
84
- if (dom instanceof HTMLElement && element.firstChild) {
85
- var style = computeNestedStyle(dom) || window.getComputedStyle(dom);
86
- var gapCursor = element.firstChild;
87
- gapCursor.style.height = "".concat(measureHeight(style), "px");
88
- var layoutMode = node && (0, _utils.getLayoutModeFromTargetNode)(node);
89
-
90
- // TODO remove this table specific piece. need to figure out margin collapsing logic
91
- if (nodeStart !== 0 || layoutMode || (node === null || node === void 0 ? void 0 : node.type.name) === 'table') {
92
- gapCursor.style.marginTop = style.getPropertyValue('margin-top');
93
- }
94
- if (layoutMode) {
95
- gapCursor.setAttribute('layout', layoutMode);
96
- var breakoutModeStyle = (0, _utils.getComputedStyleForLayoutMode)(dom, node, style);
97
- gapCursor.style.width = "".concat(measureWidth(breakoutModeStyle), "px");
98
- } else {
99
- mutateElementStyle(gapCursor, style, selection.side);
100
- }
101
- }
102
- return element;
103
- };
@@ -1,137 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getComputedStyleForLayoutMode = void 0;
7
- exports.getLayoutModeFromTargetNode = getLayoutModeFromTargetNode;
8
- exports.getMediaNearPos = getMediaNearPos;
9
- exports.isTextBlockNearPos = exports.isLeftCursor = exports.isIgnoredClick = void 0;
10
- var _styles = require("@atlaskit/editor-common/styles");
11
- var _selection = require("./selection");
12
- var _mediaSingle = require("@atlaskit/editor-common/media-single");
13
- var isLeftCursor = exports.isLeftCursor = function isLeftCursor(side) {
14
- return side === _selection.Side.LEFT;
15
- };
16
- function getMediaNearPos(doc, $pos, schema) {
17
- var dir = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
18
- var $currentPos = $pos;
19
- var currentNode = null;
20
- var _schema$nodes = schema.nodes,
21
- mediaSingle = _schema$nodes.mediaSingle,
22
- media = _schema$nodes.media,
23
- mediaGroup = _schema$nodes.mediaGroup;
24
- do {
25
- $currentPos = doc.resolve(dir === -1 ? $currentPos.before() : $currentPos.after());
26
- if (!$currentPos) {
27
- return null;
28
- }
29
- currentNode = (dir === -1 ? $currentPos.nodeBefore : $currentPos.nodeAfter) || $currentPos.parent;
30
- if (!currentNode || currentNode.type === schema.nodes.doc) {
31
- return null;
32
- }
33
- if (currentNode.type === mediaSingle || currentNode.type === media || currentNode.type === mediaGroup) {
34
- return currentNode;
35
- }
36
- } while ($currentPos.depth > 0);
37
- return null;
38
- }
39
- var isTextBlockNearPos = exports.isTextBlockNearPos = function isTextBlockNearPos(doc, schema, $pos, dir) {
40
- var $currentPos = $pos;
41
- var currentNode = dir === -1 ? $currentPos.nodeBefore : $currentPos.nodeAfter;
42
-
43
- // If next node is a text or a text block bail out early.
44
- if (currentNode && (currentNode.isTextblock || currentNode.isText)) {
45
- return true;
46
- }
47
- while ($currentPos.depth > 0) {
48
- $currentPos = doc.resolve(dir === -1 ? $currentPos.before() : $currentPos.after());
49
- if (!$currentPos) {
50
- return false;
51
- }
52
- currentNode = (dir === -1 ? $currentPos.nodeBefore : $currentPos.nodeAfter) || $currentPos.parent;
53
- if (!currentNode || currentNode.type === schema.nodes.doc) {
54
- return false;
55
- }
56
- if (currentNode.isTextblock) {
57
- return true;
58
- }
59
- }
60
- var childNode = currentNode;
61
- while (childNode && childNode.firstChild) {
62
- childNode = childNode.firstChild;
63
- if (childNode && (childNode.isTextblock || childNode.isText)) {
64
- return true;
65
- }
66
- }
67
- return false;
68
- };
69
- function getLayoutModeFromTargetNode(node) {
70
- var layout;
71
- if (node.attrs.layout) {
72
- layout = node.attrs.layout;
73
- }
74
- if (node.marks && node.marks.length) {
75
- layout = (node.marks.find(function (mark) {
76
- return mark.type.name === 'breakout';
77
- }) || {
78
- attrs: {
79
- mode: ''
80
- }
81
- }).attrs.mode;
82
- }
83
- if (node.type.name === 'table' && node.attrs.width) {
84
- layout = 'fixed-width';
85
- }
86
- if (['wide', 'full-width', 'fixed-width'].indexOf(layout) === -1) {
87
- return '';
88
- }
89
- return layout;
90
- }
91
- var isIgnoredClick = exports.isIgnoredClick = function isIgnoredClick(elem) {
92
- if (elem.nodeName === 'BUTTON' || elem.closest('button')) {
93
- return true;
94
- }
95
-
96
- // check if we're clicking an image caption placeholder
97
- if (elem.closest("[data-id=\"".concat(_mediaSingle.CAPTION_PLACEHOLDER_ID, "\"]"))) {
98
- return true;
99
- }
100
-
101
- // check if target node has a parent table node
102
- var tableWrap;
103
- var node = elem;
104
- while (node) {
105
- if (node.className && (node.getAttribute('class') || '').indexOf(_styles.TableSharedCssClassName.TABLE_CONTAINER) > -1) {
106
- tableWrap = node;
107
- break;
108
- }
109
- node = node.parentNode;
110
- }
111
- if (tableWrap) {
112
- var rowControls = tableWrap.querySelector(".".concat(_styles.TableSharedCssClassName.TABLE_ROW_CONTROLS_WRAPPER));
113
- var isColumnControlsDecoration = elem && elem.classList && elem.classList.contains(_styles.TableSharedCssClassName.TABLE_COLUMN_CONTROLS_DECORATIONS);
114
- return rowControls && rowControls.contains(elem) || isColumnControlsDecoration;
115
- }
116
-
117
- // Check if unsupported node selection
118
- // (without this, selection requires double clicking in FF due to posAtCoords differences)
119
- if (elem.closest(".".concat(_styles.UnsupportedSharedCssClassName.BLOCK_CONTAINER))) {
120
- return true;
121
- }
122
- return false;
123
- };
124
-
125
- /*
126
- Calculates custom style for breakout mode
127
- Mainly to handle table width to include the numbered column width as well
128
- */
129
- var getComputedStyleForLayoutMode = exports.getComputedStyleForLayoutMode = function getComputedStyleForLayoutMode(dom, node, style) {
130
- if (node && node.type.name === 'table') {
131
- var tableContainer = dom.querySelector('.pm-table-container');
132
- if (tableContainer) {
133
- return window.getComputedStyle(tableContainer);
134
- }
135
- }
136
- return style;
137
- };
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "GapCursorSelection", {
7
- enumerable: true,
8
- get: function get() {
9
- return _selection.GapCursorSelection;
10
- }
11
- });
12
- Object.defineProperty(exports, "Side", {
13
- enumerable: true,
14
- get: function get() {
15
- return _selection.Side;
16
- }
17
- });
18
- Object.defineProperty(exports, "hasGapCursorPlugin", {
19
- enumerable: true,
20
- get: function get() {
21
- return _actions.hasGapCursorPlugin;
22
- }
23
- });
24
- Object.defineProperty(exports, "setCursorForTopLevelBlocks", {
25
- enumerable: true,
26
- get: function get() {
27
- return _actions.setCursorForTopLevelBlocks;
28
- }
29
- });
30
- Object.defineProperty(exports, "setSelectionTopLevelBlocks", {
31
- enumerable: true,
32
- get: function get() {
33
- return _actions.setSelectionTopLevelBlocks;
34
- }
35
- });
36
- var _selection = require("@atlaskit/editor-common/selection");
37
- var _actions = require("./gap-cursor/actions");