@atlaskit/editor-common 74.44.1 → 74.45.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 +7 -0
- package/dist/cjs/mark/commands.js +21 -26
- package/dist/cjs/media-single/constants.js +3 -1
- package/dist/cjs/media-single/index.js +6 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/selection/index.js +36 -0
- package/dist/cjs/selection/utils.js +46 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/index.js +150 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/mark/commands.js +21 -28
- package/dist/es2019/mark/index.js +1 -1
- package/dist/es2019/media-single/constants.js +1 -0
- package/dist/es2019/media-single/index.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/selection/index.js +1 -1
- package/dist/es2019/selection/utils.js +52 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/index.js +139 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/mark/commands.js +21 -26
- package/dist/esm/mark/index.js +1 -1
- package/dist/esm/media-single/constants.js +1 -0
- package/dist/esm/media-single/index.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/selection/index.js +1 -1
- package/dist/esm/selection/utils.js +40 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/index.js +141 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/mark/commands.d.ts +4 -4
- package/dist/types/mark/index.d.ts +1 -1
- package/dist/types/media-single/constants.d.ts +1 -0
- package/dist/types/media-single/index.d.ts +1 -1
- package/dist/types/selection/index.d.ts +1 -1
- package/dist/types/selection/utils.d.ts +9 -2
- package/dist/types/utils/index.d.ts +17 -0
- package/dist/types/utils/input-rules.d.ts +3 -2
- package/dist/types-ts4.5/mark/commands.d.ts +4 -4
- package/dist/types-ts4.5/mark/index.d.ts +1 -1
- package/dist/types-ts4.5/media-single/constants.d.ts +1 -0
- package/dist/types-ts4.5/media-single/index.d.ts +1 -1
- package/dist/types-ts4.5/selection/index.d.ts +1 -1
- package/dist/types-ts4.5/selection/utils.d.ts +9 -2
- package/dist/types-ts4.5/utils/index.d.ts +17 -0
- package/dist/types-ts4.5/utils/input-rules.d.ts +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.45.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`43c51e0a282`](https://bitbucket.org/atlassian/atlassian-frontend/commits/43c51e0a282) - [ED-19431] Migrate all text-formatting plugin actions over to plugin commands
|
|
8
|
+
- [`8375e041861`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8375e041861) - [ED-16733] Extract common functions used by media plugin to editor-common
|
|
9
|
+
|
|
3
10
|
## 74.44.1
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -129,19 +129,19 @@ var entireSelectionContainsMark = function entireSelectionContainsMark(mark, doc
|
|
|
129
129
|
return onlyContainsMark;
|
|
130
130
|
};
|
|
131
131
|
var toggleMarkInRange = function toggleMarkInRange(mark) {
|
|
132
|
-
return function (
|
|
133
|
-
var tr =
|
|
134
|
-
if (
|
|
132
|
+
return function (_ref2) {
|
|
133
|
+
var tr = _ref2.tr;
|
|
134
|
+
if (tr.selection instanceof _cellSelection.CellSelection) {
|
|
135
135
|
var removeMark = true;
|
|
136
136
|
var cells = [];
|
|
137
|
-
|
|
137
|
+
tr.selection.forEachCell(function (cell, cellPos) {
|
|
138
138
|
cells.push({
|
|
139
139
|
node: cell,
|
|
140
140
|
pos: cellPos
|
|
141
141
|
});
|
|
142
142
|
var from = cellPos;
|
|
143
143
|
var to = cellPos + cell.nodeSize;
|
|
144
|
-
removeMark && (removeMark = entireSelectionContainsMark(mark,
|
|
144
|
+
removeMark && (removeMark = entireSelectionContainsMark(mark, tr.doc, from, to));
|
|
145
145
|
});
|
|
146
146
|
for (var i = cells.length - 1; i >= 0; i--) {
|
|
147
147
|
var cell = cells[i];
|
|
@@ -150,52 +150,47 @@ var toggleMarkInRange = function toggleMarkInRange(mark) {
|
|
|
150
150
|
applyMarkOnRange(from, to, removeMark, mark, tr);
|
|
151
151
|
}
|
|
152
152
|
} else {
|
|
153
|
-
var
|
|
154
|
-
$from =
|
|
155
|
-
$to =
|
|
153
|
+
var _tr$selection = tr.selection,
|
|
154
|
+
$from = _tr$selection.$from,
|
|
155
|
+
$to = _tr$selection.$to;
|
|
156
156
|
// We decide to remove the mark only if the entire selection contains the mark
|
|
157
157
|
// Examples with *bold* text
|
|
158
158
|
// Scenario 1: Selection contains both bold and non-bold text -> bold entire selection
|
|
159
159
|
// Scenario 2: Selection contains only bold text -> un-bold entire selection
|
|
160
160
|
// Scenario 3: Selection contains no bold text -> bold entire selection
|
|
161
|
-
var _removeMark = entireSelectionContainsMark(mark,
|
|
161
|
+
var _removeMark = entireSelectionContainsMark(mark, tr.doc, $from.pos, $to.pos);
|
|
162
162
|
applyMarkOnRange($from.pos, $to.pos, _removeMark, mark, tr);
|
|
163
163
|
}
|
|
164
164
|
if (tr.docChanged) {
|
|
165
|
-
|
|
166
|
-
dispatch(tr);
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
165
|
+
return tr;
|
|
169
166
|
}
|
|
170
|
-
return
|
|
167
|
+
return null;
|
|
171
168
|
};
|
|
172
169
|
};
|
|
173
170
|
|
|
174
171
|
/**
|
|
175
|
-
* A
|
|
176
|
-
*
|
|
172
|
+
* A custom version of the ProseMirror toggleMark, where we only toggle marks
|
|
173
|
+
* on text nodes in the selection rather than all inline nodes.
|
|
177
174
|
* @param markType
|
|
178
175
|
* @param attrs
|
|
179
176
|
*/
|
|
180
177
|
var toggleMark = function toggleMark(markType, attrs) {
|
|
181
|
-
return function (
|
|
178
|
+
return function (_ref3) {
|
|
179
|
+
var tr = _ref3.tr;
|
|
182
180
|
var mark = markType.create(attrs);
|
|
183
181
|
|
|
184
182
|
// For cursor selections we can use the default behaviour.
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
if (mark.isInSet(state.storedMarks || state.selection.$cursor.marks())) {
|
|
183
|
+
if (tr.selection instanceof _state.TextSelection && tr.selection.$cursor) {
|
|
184
|
+
if (mark.isInSet(tr.storedMarks || tr.selection.$cursor.marks())) {
|
|
188
185
|
tr.removeStoredMark(mark);
|
|
189
186
|
} else {
|
|
190
187
|
tr.addStoredMark(mark);
|
|
191
188
|
}
|
|
192
|
-
|
|
193
|
-
dispatch(tr);
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
return false;
|
|
189
|
+
return tr;
|
|
197
190
|
}
|
|
198
|
-
return toggleMarkInRange(mark)(
|
|
191
|
+
return toggleMarkInRange(mark)({
|
|
192
|
+
tr: tr
|
|
193
|
+
});
|
|
199
194
|
};
|
|
200
195
|
};
|
|
201
196
|
exports.toggleMark = toggleMark;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.wrappedLayouts = exports.MEDIA_SINGLE_SNAP_GAP = exports.MEDIA_SINGLE_MIN_PIXEL_WIDTH = exports.MEDIA_SINGLE_HIGHLIGHT_GAP = exports.MEDIA_SINGLE_HANDLE_MARGIN = exports.MEDIA_SINGLE_GUTTER_SIZE = exports.Layout = exports.DEFAULT_ROUNDING_INTERVAL = exports.DEFAULT_IMAGE_WIDTH = exports.DEFAULT_IMAGE_HEIGHT = void 0;
|
|
6
|
+
exports.wrappedLayouts = exports.MEDIA_SINGLE_SNAP_GAP = exports.MEDIA_SINGLE_RESIZE_THROTTLE_TIME = exports.MEDIA_SINGLE_MIN_PIXEL_WIDTH = exports.MEDIA_SINGLE_HIGHLIGHT_GAP = exports.MEDIA_SINGLE_HANDLE_MARGIN = exports.MEDIA_SINGLE_GUTTER_SIZE = exports.Layout = exports.DEFAULT_ROUNDING_INTERVAL = exports.DEFAULT_IMAGE_WIDTH = exports.DEFAULT_IMAGE_HEIGHT = void 0;
|
|
7
7
|
var MEDIA_SINGLE_MIN_PIXEL_WIDTH = 24;
|
|
8
8
|
exports.MEDIA_SINGLE_MIN_PIXEL_WIDTH = MEDIA_SINGLE_MIN_PIXEL_WIDTH;
|
|
9
9
|
var MEDIA_SINGLE_SNAP_GAP = 3;
|
|
@@ -18,6 +18,8 @@ var DEFAULT_IMAGE_WIDTH = 250;
|
|
|
18
18
|
exports.DEFAULT_IMAGE_WIDTH = DEFAULT_IMAGE_WIDTH;
|
|
19
19
|
var DEFAULT_IMAGE_HEIGHT = 200;
|
|
20
20
|
exports.DEFAULT_IMAGE_HEIGHT = DEFAULT_IMAGE_HEIGHT;
|
|
21
|
+
var MEDIA_SINGLE_RESIZE_THROTTLE_TIME = 100;
|
|
22
|
+
exports.MEDIA_SINGLE_RESIZE_THROTTLE_TIME = MEDIA_SINGLE_RESIZE_THROTTLE_TIME;
|
|
21
23
|
var Layout = /*#__PURE__*/function (Layout) {
|
|
22
24
|
Layout["FULL_WIDTH"] = "full-width";
|
|
23
25
|
Layout["WIDE"] = "wide";
|
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "MEDIA_SINGLE_MIN_PIXEL_WIDTH", {
|
|
|
33
33
|
return _constants.MEDIA_SINGLE_MIN_PIXEL_WIDTH;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "MEDIA_SINGLE_RESIZE_THROTTLE_TIME", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _constants.MEDIA_SINGLE_RESIZE_THROTTLE_TIME;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "MEDIA_SINGLE_SNAP_GAP", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function get() {
|
|
@@ -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 = "74.
|
|
19
|
+
var packageVersion = "74.45.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
|
|
@@ -33,6 +33,36 @@ Object.defineProperty(exports, "Side", {
|
|
|
33
33
|
return _selection.Side;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "atTheBeginningOfBlock", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _utils2.atTheBeginningOfBlock;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "atTheBeginningOfDoc", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _utils2.atTheBeginningOfDoc;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "atTheEndOfBlock", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _utils2.atTheEndOfBlock;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "atTheEndOfDoc", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _utils2.atTheEndOfDoc;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "endPositionOfParent", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _utils2.endPositionOfParent;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
36
66
|
Object.defineProperty(exports, "isIgnored", {
|
|
37
67
|
enumerable: true,
|
|
38
68
|
get: function get() {
|
|
@@ -57,6 +87,12 @@ Object.defineProperty(exports, "isValidTargetNode", {
|
|
|
57
87
|
return _utils.isValidTargetNode;
|
|
58
88
|
}
|
|
59
89
|
});
|
|
90
|
+
Object.defineProperty(exports, "startPositionOfParent", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _utils2.startPositionOfParent;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
60
96
|
var _types = require("./types");
|
|
61
97
|
var _selection = require("./gap-cursor/selection");
|
|
62
98
|
var _utils = require("./gap-cursor/utils");
|
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.atTheBeginningOfBlock = atTheBeginningOfBlock;
|
|
7
|
+
exports.atTheBeginningOfDoc = atTheBeginningOfDoc;
|
|
8
|
+
exports.atTheEndOfBlock = atTheEndOfBlock;
|
|
9
|
+
exports.atTheEndOfDoc = atTheEndOfDoc;
|
|
10
|
+
exports.endPositionOfParent = endPositionOfParent;
|
|
6
11
|
exports.isSelectionAtStartOfNode = exports.isSelectionAtEndOfNode = void 0;
|
|
12
|
+
exports.startPositionOfParent = startPositionOfParent;
|
|
13
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
+
var _selection = require("./gap-cursor/selection");
|
|
7
15
|
var isSelectionAtStartOfNode = function isSelectionAtStartOfNode($pos, parentNode) {
|
|
8
16
|
if (!parentNode) {
|
|
9
17
|
return false;
|
|
@@ -35,4 +43,41 @@ var isSelectionAtEndOfNode = function isSelectionAtEndOfNode($pos, parentNode) {
|
|
|
35
43
|
}
|
|
36
44
|
return true;
|
|
37
45
|
};
|
|
38
|
-
exports.isSelectionAtEndOfNode = isSelectionAtEndOfNode;
|
|
46
|
+
exports.isSelectionAtEndOfNode = isSelectionAtEndOfNode;
|
|
47
|
+
function atTheEndOfDoc(state) {
|
|
48
|
+
var selection = state.selection,
|
|
49
|
+
doc = state.doc;
|
|
50
|
+
return doc.nodeSize - selection.$to.pos - 2 === selection.$to.depth;
|
|
51
|
+
}
|
|
52
|
+
function atTheBeginningOfDoc(state) {
|
|
53
|
+
var selection = state.selection;
|
|
54
|
+
return selection.$from.pos === selection.$from.depth;
|
|
55
|
+
}
|
|
56
|
+
function atTheEndOfBlock(state) {
|
|
57
|
+
var selection = state.selection;
|
|
58
|
+
var $to = selection.$to;
|
|
59
|
+
if (selection instanceof _selection.GapCursorSelection) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (selection instanceof _state.NodeSelection && selection.node.isBlock) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return endPositionOfParent($to) === $to.pos + 1;
|
|
66
|
+
}
|
|
67
|
+
function atTheBeginningOfBlock(state) {
|
|
68
|
+
var selection = state.selection;
|
|
69
|
+
var $from = selection.$from;
|
|
70
|
+
if (selection instanceof _selection.GapCursorSelection) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (selection instanceof _state.NodeSelection && selection.node.isBlock) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return startPositionOfParent($from) === $from.pos;
|
|
77
|
+
}
|
|
78
|
+
function startPositionOfParent(resolvedPos) {
|
|
79
|
+
return resolvedPos.start(resolvedPos.depth);
|
|
80
|
+
}
|
|
81
|
+
function endPositionOfParent(resolvedPos) {
|
|
82
|
+
return resolvedPos.end(resolvedPos.depth) + 1;
|
|
83
|
+
}
|
|
@@ -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 = "74.
|
|
27
|
+
var packageVersion = "74.45.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -184,6 +184,7 @@ Object.defineProperty(exports, "canRenderDatasource", {
|
|
|
184
184
|
return _datasource.canRenderDatasource;
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
|
+
exports.checkNodeDown = checkNodeDown;
|
|
187
188
|
Object.defineProperty(exports, "clearMeasure", {
|
|
188
189
|
enumerable: true,
|
|
189
190
|
get: function get() {
|
|
@@ -292,6 +293,7 @@ Object.defineProperty(exports, "findChangedNodesFromTransaction", {
|
|
|
292
293
|
return _nodes.findChangedNodesFromTransaction;
|
|
293
294
|
}
|
|
294
295
|
});
|
|
296
|
+
exports.findFarthestParentNode = void 0;
|
|
295
297
|
Object.defineProperty(exports, "findFilepaths", {
|
|
296
298
|
enumerable: true,
|
|
297
299
|
get: function get() {
|
|
@@ -496,6 +498,7 @@ Object.defineProperty(exports, "insertNewLineWithAnalytics", {
|
|
|
496
498
|
return _commands.insertNewLineWithAnalytics;
|
|
497
499
|
}
|
|
498
500
|
});
|
|
501
|
+
exports.insideTableCell = void 0;
|
|
499
502
|
Object.defineProperty(exports, "isBulletList", {
|
|
500
503
|
enumerable: true,
|
|
501
504
|
get: function get() {
|
|
@@ -514,6 +517,7 @@ Object.defineProperty(exports, "isEmptyDocument", {
|
|
|
514
517
|
return _document.isEmptyDocument;
|
|
515
518
|
}
|
|
516
519
|
});
|
|
520
|
+
exports.isEmptyNode = void 0;
|
|
517
521
|
Object.defineProperty(exports, "isEmptyParagraph", {
|
|
518
522
|
enumerable: true,
|
|
519
523
|
get: function get() {
|
|
@@ -544,6 +548,7 @@ Object.defineProperty(exports, "isInLayoutColumn", {
|
|
|
544
548
|
return _editorCoreUtils.isInLayoutColumn;
|
|
545
549
|
}
|
|
546
550
|
});
|
|
551
|
+
exports.isInListItem = void 0;
|
|
547
552
|
Object.defineProperty(exports, "isLastItemMediaGroup", {
|
|
548
553
|
enumerable: true,
|
|
549
554
|
get: function get() {
|
|
@@ -586,6 +591,7 @@ Object.defineProperty(exports, "isNodeBeforeMediaNode", {
|
|
|
586
591
|
return _nodes.isNodeBeforeMediaNode;
|
|
587
592
|
}
|
|
588
593
|
});
|
|
594
|
+
exports.isNodeEmpty = isNodeEmpty;
|
|
589
595
|
Object.defineProperty(exports, "isNodeSelectedOrInRange", {
|
|
590
596
|
enumerable: true,
|
|
591
597
|
get: function get() {
|
|
@@ -640,6 +646,7 @@ Object.defineProperty(exports, "isRichMediaInsideOfBlockNode", {
|
|
|
640
646
|
return _richMediaUtils.isRichMediaInsideOfBlockNode;
|
|
641
647
|
}
|
|
642
648
|
});
|
|
649
|
+
exports.isSelectionInsideLastNodeInDocument = isSelectionInsideLastNodeInDocument;
|
|
643
650
|
Object.defineProperty(exports, "isSupportedInParent", {
|
|
644
651
|
enumerable: true,
|
|
645
652
|
get: function get() {
|
|
@@ -948,6 +955,7 @@ Object.defineProperty(exports, "withImageLoader", {
|
|
|
948
955
|
return _imageLoader.withImageLoader;
|
|
949
956
|
}
|
|
950
957
|
});
|
|
958
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
951
959
|
var _annotation = require("./annotation");
|
|
952
960
|
var _macro = require("./macro");
|
|
953
961
|
var _browser = _interopRequireDefault(require("./browser"));
|
|
@@ -1005,4 +1013,146 @@ function shallowEqual() {
|
|
|
1005
1013
|
return keys1.length === keys2.length && keys1.reduce(function (acc, key) {
|
|
1006
1014
|
return acc && obj1[key] === obj2[key];
|
|
1007
1015
|
}, true);
|
|
1016
|
+
}
|
|
1017
|
+
function isSelectionInsideLastNodeInDocument(selection) {
|
|
1018
|
+
var docNode = selection.$anchor.node(0);
|
|
1019
|
+
var rootNode = selection.$anchor.node(1);
|
|
1020
|
+
return docNode.lastChild === rootNode;
|
|
1021
|
+
}
|
|
1022
|
+
var isInListItem = function isInListItem(state) {
|
|
1023
|
+
return (0, _utils.hasParentNodeOfType)(state.schema.nodes.listItem)(state.selection);
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Find the farthest node given a condition
|
|
1028
|
+
* @param predicate Function to check the node
|
|
1029
|
+
*/
|
|
1030
|
+
exports.isInListItem = isInListItem;
|
|
1031
|
+
var findFarthestParentNode = function findFarthestParentNode(predicate) {
|
|
1032
|
+
return function ($pos) {
|
|
1033
|
+
var candidate = null;
|
|
1034
|
+
for (var i = $pos.depth; i > 0; i--) {
|
|
1035
|
+
var _node = $pos.node(i);
|
|
1036
|
+
if (predicate(_node)) {
|
|
1037
|
+
candidate = {
|
|
1038
|
+
pos: i > 0 ? $pos.before(i) : 0,
|
|
1039
|
+
start: $pos.start(i),
|
|
1040
|
+
depth: i,
|
|
1041
|
+
node: _node
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
return candidate;
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
exports.findFarthestParentNode = findFarthestParentNode;
|
|
1049
|
+
var insideTableCell = function insideTableCell(state) {
|
|
1050
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
1051
|
+
tableCell = _state$schema$nodes.tableCell,
|
|
1052
|
+
tableHeader = _state$schema$nodes.tableHeader;
|
|
1053
|
+
return (0, _utils.hasParentNodeOfType)([tableCell, tableHeader])(state.selection);
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
|
|
1058
|
+
*/
|
|
1059
|
+
exports.insideTableCell = insideTableCell;
|
|
1060
|
+
function findAncestorPosition(doc, pos) {
|
|
1061
|
+
var nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
|
|
1062
|
+
if (pos.depth === 1) {
|
|
1063
|
+
return pos;
|
|
1064
|
+
}
|
|
1065
|
+
var node = pos.node(pos.depth);
|
|
1066
|
+
var newPos = pos;
|
|
1067
|
+
while (pos.depth >= 1) {
|
|
1068
|
+
pos = doc.resolve(pos.before(pos.depth));
|
|
1069
|
+
node = pos.node(pos.depth);
|
|
1070
|
+
if (node && nestableBlocks.indexOf(node.type.name) !== -1) {
|
|
1071
|
+
newPos = pos;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return newPos;
|
|
1075
|
+
}
|
|
1076
|
+
function checkNodeDown(selection, doc, filter) {
|
|
1077
|
+
var ancestorDepth = findAncestorPosition(doc, selection.$to).depth;
|
|
1078
|
+
|
|
1079
|
+
// Top level node
|
|
1080
|
+
if (ancestorDepth === 0) {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
var res = doc.resolve(selection.$to.after(ancestorDepth));
|
|
1084
|
+
return res.nodeAfter ? filter(res.nodeAfter) : false;
|
|
1085
|
+
}
|
|
1086
|
+
var isEmptyNode = function isEmptyNode(schema) {
|
|
1087
|
+
var _schema$nodes = schema.nodes,
|
|
1088
|
+
doc = _schema$nodes.doc,
|
|
1089
|
+
paragraph = _schema$nodes.paragraph,
|
|
1090
|
+
codeBlock = _schema$nodes.codeBlock,
|
|
1091
|
+
blockquote = _schema$nodes.blockquote,
|
|
1092
|
+
panel = _schema$nodes.panel,
|
|
1093
|
+
heading = _schema$nodes.heading,
|
|
1094
|
+
listItem = _schema$nodes.listItem,
|
|
1095
|
+
bulletList = _schema$nodes.bulletList,
|
|
1096
|
+
orderedList = _schema$nodes.orderedList,
|
|
1097
|
+
taskList = _schema$nodes.taskList,
|
|
1098
|
+
taskItem = _schema$nodes.taskItem,
|
|
1099
|
+
decisionList = _schema$nodes.decisionList,
|
|
1100
|
+
decisionItem = _schema$nodes.decisionItem,
|
|
1101
|
+
media = _schema$nodes.media,
|
|
1102
|
+
mediaGroup = _schema$nodes.mediaGroup,
|
|
1103
|
+
mediaSingle = _schema$nodes.mediaSingle;
|
|
1104
|
+
var innerIsEmptyNode = function innerIsEmptyNode(node) {
|
|
1105
|
+
switch (node.type) {
|
|
1106
|
+
case media:
|
|
1107
|
+
case mediaGroup:
|
|
1108
|
+
case mediaSingle:
|
|
1109
|
+
return false;
|
|
1110
|
+
case paragraph:
|
|
1111
|
+
case codeBlock:
|
|
1112
|
+
case heading:
|
|
1113
|
+
case taskItem:
|
|
1114
|
+
case decisionItem:
|
|
1115
|
+
return node.content.size === 0;
|
|
1116
|
+
case blockquote:
|
|
1117
|
+
case panel:
|
|
1118
|
+
case listItem:
|
|
1119
|
+
return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
|
|
1120
|
+
case bulletList:
|
|
1121
|
+
case orderedList:
|
|
1122
|
+
return node.content.size === 4 && innerIsEmptyNode(node.content.firstChild);
|
|
1123
|
+
case taskList:
|
|
1124
|
+
case decisionList:
|
|
1125
|
+
return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
|
|
1126
|
+
case doc:
|
|
1127
|
+
var isEmpty = true;
|
|
1128
|
+
node.content.forEach(function (child) {
|
|
1129
|
+
isEmpty = isEmpty && innerIsEmptyNode(child);
|
|
1130
|
+
});
|
|
1131
|
+
return isEmpty;
|
|
1132
|
+
default:
|
|
1133
|
+
return isNodeEmpty(node);
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
return innerIsEmptyNode;
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Checks if a node has any content. Ignores node that only contain empty block nodes.
|
|
1141
|
+
*/
|
|
1142
|
+
exports.isEmptyNode = isEmptyNode;
|
|
1143
|
+
function isNodeEmpty(node) {
|
|
1144
|
+
if (node && node.textContent) {
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
if (!node || !node.childCount || node.childCount === 1 && (0, _editorCoreUtils.isEmptyParagraph)(node.firstChild)) {
|
|
1148
|
+
return true;
|
|
1149
|
+
}
|
|
1150
|
+
var block = [];
|
|
1151
|
+
var nonBlock = [];
|
|
1152
|
+
node.forEach(function (child) {
|
|
1153
|
+
child.isInline ? nonBlock.push(child) : block.push(child);
|
|
1154
|
+
});
|
|
1155
|
+
return !nonBlock.length && !block.filter(function (childNode) {
|
|
1156
|
+
return !!childNode.childCount && !(childNode.childCount === 1 && (0, _editorCoreUtils.isEmptyParagraph)(childNode.firstChild)) || childNode.isAtom;
|
|
1157
|
+
}).length;
|
|
1008
1158
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -132,21 +132,20 @@ const entireSelectionContainsMark = (mark, doc, fromPos, toPos) => {
|
|
|
132
132
|
});
|
|
133
133
|
return onlyContainsMark;
|
|
134
134
|
};
|
|
135
|
-
const toggleMarkInRange = mark => (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (state.selection instanceof CellSelection) {
|
|
135
|
+
const toggleMarkInRange = mark => ({
|
|
136
|
+
tr
|
|
137
|
+
}) => {
|
|
138
|
+
if (tr.selection instanceof CellSelection) {
|
|
140
139
|
let removeMark = true;
|
|
141
140
|
const cells = [];
|
|
142
|
-
|
|
141
|
+
tr.selection.forEachCell((cell, cellPos) => {
|
|
143
142
|
cells.push({
|
|
144
143
|
node: cell,
|
|
145
144
|
pos: cellPos
|
|
146
145
|
});
|
|
147
146
|
const from = cellPos;
|
|
148
147
|
const to = cellPos + cell.nodeSize;
|
|
149
|
-
removeMark && (removeMark = entireSelectionContainsMark(mark,
|
|
148
|
+
removeMark && (removeMark = entireSelectionContainsMark(mark, tr.doc, from, to));
|
|
150
149
|
});
|
|
151
150
|
for (let i = cells.length - 1; i >= 0; i--) {
|
|
152
151
|
const cell = cells[i];
|
|
@@ -158,48 +157,42 @@ const toggleMarkInRange = mark => (state, dispatch) => {
|
|
|
158
157
|
const {
|
|
159
158
|
$from,
|
|
160
159
|
$to
|
|
161
|
-
} =
|
|
160
|
+
} = tr.selection;
|
|
162
161
|
// We decide to remove the mark only if the entire selection contains the mark
|
|
163
162
|
// Examples with *bold* text
|
|
164
163
|
// Scenario 1: Selection contains both bold and non-bold text -> bold entire selection
|
|
165
164
|
// Scenario 2: Selection contains only bold text -> un-bold entire selection
|
|
166
165
|
// Scenario 3: Selection contains no bold text -> bold entire selection
|
|
167
|
-
const removeMark = entireSelectionContainsMark(mark,
|
|
166
|
+
const removeMark = entireSelectionContainsMark(mark, tr.doc, $from.pos, $to.pos);
|
|
168
167
|
applyMarkOnRange($from.pos, $to.pos, removeMark, mark, tr);
|
|
169
168
|
}
|
|
170
169
|
if (tr.docChanged) {
|
|
171
|
-
|
|
172
|
-
dispatch(tr);
|
|
173
|
-
}
|
|
174
|
-
return true;
|
|
170
|
+
return tr;
|
|
175
171
|
}
|
|
176
|
-
return
|
|
172
|
+
return null;
|
|
177
173
|
};
|
|
178
174
|
|
|
179
175
|
/**
|
|
180
|
-
* A
|
|
181
|
-
*
|
|
176
|
+
* A custom version of the ProseMirror toggleMark, where we only toggle marks
|
|
177
|
+
* on text nodes in the selection rather than all inline nodes.
|
|
182
178
|
* @param markType
|
|
183
179
|
* @param attrs
|
|
184
180
|
*/
|
|
185
|
-
export const toggleMark = (markType, attrs) => (
|
|
181
|
+
export const toggleMark = (markType, attrs) => ({
|
|
182
|
+
tr
|
|
183
|
+
}) => {
|
|
186
184
|
const mark = markType.create(attrs);
|
|
187
185
|
|
|
188
186
|
// For cursor selections we can use the default behaviour.
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
tr
|
|
192
|
-
} = state;
|
|
193
|
-
if (mark.isInSet(state.storedMarks || state.selection.$cursor.marks())) {
|
|
187
|
+
if (tr.selection instanceof TextSelection && tr.selection.$cursor) {
|
|
188
|
+
if (mark.isInSet(tr.storedMarks || tr.selection.$cursor.marks())) {
|
|
194
189
|
tr.removeStoredMark(mark);
|
|
195
190
|
} else {
|
|
196
191
|
tr.addStoredMark(mark);
|
|
197
192
|
}
|
|
198
|
-
|
|
199
|
-
dispatch(tr);
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
return false;
|
|
193
|
+
return tr;
|
|
203
194
|
}
|
|
204
|
-
return toggleMarkInRange(mark)(
|
|
195
|
+
return toggleMarkInRange(mark)({
|
|
196
|
+
tr
|
|
197
|
+
});
|
|
205
198
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { transformSmartCharsMentionsAndEmojis, applyMarkOnRange,
|
|
1
|
+
export { transformSmartCharsMentionsAndEmojis, applyMarkOnRange, filterChildrenBetween, toggleMark } from './commands';
|
|
2
2
|
export { anyMarkActive } from './text-formatting';
|
|
@@ -5,6 +5,7 @@ export const MEDIA_SINGLE_HANDLE_MARGIN = 12;
|
|
|
5
5
|
export const MEDIA_SINGLE_GUTTER_SIZE = MEDIA_SINGLE_HANDLE_MARGIN * 2;
|
|
6
6
|
export const DEFAULT_IMAGE_WIDTH = 250;
|
|
7
7
|
export const DEFAULT_IMAGE_HEIGHT = 200;
|
|
8
|
+
export const MEDIA_SINGLE_RESIZE_THROTTLE_TIME = 100;
|
|
8
9
|
export let Layout = /*#__PURE__*/function (Layout) {
|
|
9
10
|
Layout["FULL_WIDTH"] = "full-width";
|
|
10
11
|
Layout["WIDE"] = "wide";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts } from './constants';
|
|
1
|
+
export { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, MEDIA_SINGLE_GUTTER_SIZE, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, Layout as MediaSingleLayout, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, wrappedLayouts } from './constants';
|
|
2
2
|
export { getMediaSinglePixelWidth, calcMediaSinglePixelWidth, calcMediaSingleMaxWidth, getMediaSingleInitialWidth, calculateOffsetLeft, roundToNearest } from './utils';
|
|
@@ -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 = "74.
|
|
3
|
+
const packageVersion = "74.45.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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { RelativeSelectionPos } from './types';
|
|
2
2
|
export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
|
|
3
3
|
export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
|
|
4
|
-
export {
|
|
4
|
+
export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
|