@atlaskit/editor-core 189.6.14 → 189.6.18
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 +14 -0
- package/dist/cjs/plugins/extension/ui/Extension/MultiBodiedExtension/index.js +9 -11
- package/dist/cjs/plugins/paste/handlers.js +8 -20
- package/dist/cjs/ui/Appearance/FullPage/StyledComponents.js +2 -2
- package/dist/cjs/utils/document-logger.js +2 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/extension/ui/Extension/MultiBodiedExtension/index.js +13 -11
- package/dist/es2019/plugins/paste/handlers.js +5 -17
- package/dist/es2019/ui/Appearance/FullPage/StyledComponents.js +6 -0
- package/dist/es2019/utils/document-logger.js +2 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/extension/ui/Extension/MultiBodiedExtension/index.js +10 -12
- package/dist/esm/plugins/paste/handlers.js +8 -20
- package/dist/esm/ui/Appearance/FullPage/StyledComponents.js +2 -2
- package/dist/esm/utils/document-logger.js +2 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 189.6.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 189.6.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#60504](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60504) [`fdd20fa0201f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fdd20fa0201f) - ED-21506: multiBodiedExtension- Fix issues with Renderer
|
|
14
|
+
- [#60178](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60178) [`4a4e9492f9f5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4a4e9492f9f5) - [ux] ED-20952 Keep source formatting for pasting paragraph related texts, except when pasted in Heading, code and annotation.
|
|
15
|
+
- [#60812](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60812) [`24cc390d82e9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/24cc390d82e9) - ED-21529 Adding response exception messages to MBE APIs
|
|
16
|
+
|
|
3
17
|
## 189.6.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -31,17 +31,16 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
31
31
|
var state = editorView.state,
|
|
32
32
|
dispatch = editorView.dispatch;
|
|
33
33
|
if (node.content.childCount >= node.attrs.maxFrames) {
|
|
34
|
-
|
|
35
|
-
return false;
|
|
34
|
+
throw new Error("Cannot add more than ".concat(node.attrs.maxFrames, " frames"));
|
|
36
35
|
}
|
|
37
36
|
var p = state.schema.nodes.paragraph.createAndFill({});
|
|
38
37
|
if (!p) {
|
|
39
|
-
|
|
38
|
+
throw new Error('Could not create paragraph');
|
|
40
39
|
}
|
|
41
40
|
var frame = state.schema.nodes.extensionFrame.createAndFill({}, [p]);
|
|
42
41
|
var pos = getPos();
|
|
43
42
|
if (typeof pos !== 'number' || !frame) {
|
|
44
|
-
|
|
43
|
+
throw new Error('Could not create frame or position not valid');
|
|
45
44
|
}
|
|
46
45
|
var insertAt = Math.min((pos || 1) + node.content.size, state.doc.content.size);
|
|
47
46
|
dispatch(state.tr.insert(insertAt, frame));
|
|
@@ -54,7 +53,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
54
53
|
var pos = getPos();
|
|
55
54
|
// TODO: Add child index validation here, don't trust this data
|
|
56
55
|
if (typeof pos !== 'number' || typeof index !== 'number') {
|
|
57
|
-
|
|
56
|
+
throw new Error('Position or index not valid');
|
|
58
57
|
}
|
|
59
58
|
var state = editorView.state,
|
|
60
59
|
dispatch = editorView.dispatch;
|
|
@@ -69,7 +68,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
69
68
|
var startFramePosition = $startNodePos.posAtIndex(index);
|
|
70
69
|
var maybeFrameNode = state.doc.nodeAt(startFramePosition);
|
|
71
70
|
if (!maybeFrameNode) {
|
|
72
|
-
|
|
71
|
+
throw new Error('Could not find frame node');
|
|
73
72
|
}
|
|
74
73
|
var endFramePosition = maybeFrameNode.content.size + startFramePosition;
|
|
75
74
|
var tr = state.tr;
|
|
@@ -82,7 +81,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
82
81
|
dispatch = editorView.dispatch;
|
|
83
82
|
var pos = getPos();
|
|
84
83
|
if (typeof pos !== 'number') {
|
|
85
|
-
|
|
84
|
+
throw new Error('Position not valid');
|
|
86
85
|
}
|
|
87
86
|
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
88
87
|
parameters: _objectSpread(_objectSpread({}, node.attrs.parameters), {}, {
|
|
@@ -106,7 +105,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
106
105
|
}, [node, editorView, getPos, updateActiveChild]);
|
|
107
106
|
return actions;
|
|
108
107
|
};
|
|
109
|
-
var navigationCSS = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n // make sure the user can't see a range selection inside the navigation\n // This is really important to keep the navigation working properly\n user-select: none;\n -webkit-user-modify: read-only;\n"])));
|
|
108
|
+
var navigationCSS = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n // make sure the user can't see a range selection inside the navigation\n // This is really important to keep the navigation working properly\n user-select: none;\n -webkit-user-modify: read-only;\n border: 1px solid ", ";\n background-color: ", ";\n"])), "var(--ds-border, ".concat(_colors.N40, ")"), "var(--ds-background-inverse-subtle, ".concat(_colors.N50, ")"));
|
|
110
109
|
var MultiBodiedExtension = function MultiBodiedExtension(_ref2) {
|
|
111
110
|
var node = _ref2.node,
|
|
112
111
|
handleContentDOMRef = _ref2.handleContentDOMRef,
|
|
@@ -120,9 +119,8 @@ var MultiBodiedExtension = function MultiBodiedExtension(_ref2) {
|
|
|
120
119
|
// Adding to avoid aliasing `this` for the callbacks
|
|
121
120
|
var updateActiveChild = _react2.default.useCallback(function (index) {
|
|
122
121
|
if (typeof index !== 'number') {
|
|
123
|
-
// TODO: Make sure we log this somewhere if this happens
|
|
124
122
|
setActiveChildIndex(0);
|
|
125
|
-
|
|
123
|
+
throw new Error('Index is not valid');
|
|
126
124
|
}
|
|
127
125
|
setActiveChildIndex(index);
|
|
128
126
|
return true;
|
|
@@ -139,7 +137,7 @@ var MultiBodiedExtension = function MultiBodiedExtension(_ref2) {
|
|
|
139
137
|
var articleRef = _react2.default.useCallback(function (node) {
|
|
140
138
|
return handleContentDOMRef(node);
|
|
141
139
|
}, [handleContentDOMRef]);
|
|
142
|
-
var containerCSS = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border: 1px solid ", ";\n
|
|
140
|
+
var containerCSS = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border: 1px solid ", ";\n min-height: 100px;\n .multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true'] {\n display: none;\n }\n\n .multiBodiedExtension-content-dom-wrapper\n > [data-extension-frame='true']:nth-of-type(", ") {\n border: 1px solid ", ";\n display: block;\n min-height: 100px;\n }\n "])), "var(--ds-border, ".concat(_colors.N30, ")"), activeChildIndex + 1, "var(--ds-border, ".concat(_colors.N50, ")"));
|
|
143
141
|
return (0, _react.jsx)("section", {
|
|
144
142
|
className: "multiBodiedExtension--container",
|
|
145
143
|
css: containerCSS,
|
|
@@ -404,7 +404,7 @@ function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
404
404
|
selection = state.tr.selection;
|
|
405
405
|
var _schema$marks = schema.marks,
|
|
406
406
|
codeMark = _schema$marks.code,
|
|
407
|
-
|
|
407
|
+
annotationMark = _schema$marks.annotation,
|
|
408
408
|
_schema$nodes2 = schema.nodes,
|
|
409
409
|
bulletList = _schema$nodes2.bulletList,
|
|
410
410
|
emoji = _schema$nodes2.emoji,
|
|
@@ -413,7 +413,6 @@ function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
413
413
|
listItem = _schema$nodes2.listItem,
|
|
414
414
|
mention = _schema$nodes2.mention,
|
|
415
415
|
orderedList = _schema$nodes2.orderedList,
|
|
416
|
-
paragraph = _schema$nodes2.paragraph,
|
|
417
416
|
text = _schema$nodes2.text;
|
|
418
417
|
if (!(selection instanceof _state.TextSelection)) {
|
|
419
418
|
return false;
|
|
@@ -425,29 +424,18 @@ function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
425
424
|
|
|
426
425
|
// special case for codeMark: will preserve mark only if codeMark is currently active
|
|
427
426
|
// won't preserve mark if cursor is on the edge on the mark (namely inactive)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
var isPlainTextSlice = slice.content.childCount === 1 && slice.content.firstChild.type === paragraph && slice.content.firstChild.content.childCount === 1 && slice.content.firstChild.firstChild.type === text;
|
|
432
|
-
|
|
433
|
-
// special case for plainTextSlice & linkMark: merge into existing link
|
|
434
|
-
if (isPlainTextSlice && linkMark.isInSet(selectionMarks) && selectionMarks.length === 1) {
|
|
435
|
-
var tr = (0, _history.closeHistory)(state.tr).replaceSelectionWith(slice.content.firstChild.firstChild, true).setStoredMarks(selectionMarks).scrollIntoView();
|
|
436
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, _analytics.INPUT_METHOD.CLIPBOARD);
|
|
437
|
-
if (dispatch) {
|
|
438
|
-
dispatch(tr);
|
|
439
|
-
}
|
|
440
|
-
return true;
|
|
441
|
-
}
|
|
427
|
+
var hasActiveCodeMark = codeMark && codeMark.isInSet(selectionMarks) && (0, _mark.anyMarkActive)(state, codeMark);
|
|
428
|
+
var hasAnnotationMark = annotationMark && annotationMark.isInSet(selectionMarks);
|
|
429
|
+
var selectionIsHeading = (0, _utils.hasParentNodeOfType)([heading])(state.selection);
|
|
442
430
|
|
|
443
431
|
// if the pasted data is one of the node types below
|
|
444
432
|
// we apply current selection marks to the pasted slice
|
|
445
|
-
if ((0, _util.hasOnlyNodesOfType)(bulletList, hardBreak, heading, listItem,
|
|
433
|
+
if ((0, _util.hasOnlyNodesOfType)(bulletList, hardBreak, heading, listItem, text, emoji, mention, orderedList)(slice) || selectionIsHeading || hasActiveCodeMark || hasAnnotationMark) {
|
|
446
434
|
var transformedSlice = (0, _util.applyTextMarksToSlice)(schema, selectionMarks)(slice);
|
|
447
|
-
var
|
|
448
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state,
|
|
435
|
+
var tr = (0, _history.closeHistory)(state.tr).replaceSelection(transformedSlice).setStoredMarks(selectionMarks).scrollIntoView();
|
|
436
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, _analytics.INPUT_METHOD.CLIPBOARD);
|
|
449
437
|
if (dispatch) {
|
|
450
|
-
dispatch(
|
|
438
|
+
dispatch(tr);
|
|
451
439
|
}
|
|
452
440
|
return true;
|
|
453
441
|
}
|
|
@@ -29,11 +29,11 @@ var sidebarArea = exports.sidebarArea = (0, _react.css)(_templateObject5 || (_te
|
|
|
29
29
|
|
|
30
30
|
// initially hide until we have a containerWidth and can properly size them,
|
|
31
31
|
// otherwise they can cause the editor width to extend which is non-recoverable
|
|
32
|
-
var editorContentAreaHideContainer = exports.editorContentAreaHideContainer = (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n display: none;\n }\n }\n"])));
|
|
32
|
+
var editorContentAreaHideContainer = exports.editorContentAreaHideContainer = (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n display: none;\n }\n .multiBodiedExtension--container {\n display: none;\n }\n }\n"])));
|
|
33
33
|
|
|
34
34
|
/* Prevent horizontal scroll on page in full width mode */
|
|
35
35
|
var editorContentAreaContainerStyle = function editorContentAreaContainerStyle(containerWidth) {
|
|
36
|
-
return (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n max-width: ", "px;\n }\n\n [data-layout-section] {\n max-width: ", "px;\n }\n }\n"])), containerWidth - TOTAL_PADDING - _consts.tableMarginFullWidthMode * 2, containerWidth - TOTAL_PADDING + _editorSharedStyles.akLayoutGutterOffset * 2);
|
|
36
|
+
return (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n max-width: ", "px;\n }\n .multiBodiedExtension--container {\n max-width: ", "px;\n }\n\n [data-layout-section] {\n max-width: ", "px;\n }\n }\n"])), containerWidth - TOTAL_PADDING - _consts.tableMarginFullWidthMode * 2, containerWidth - TOTAL_PADDING - _consts.tableMarginFullWidthMode * 2, containerWidth - TOTAL_PADDING + _editorSharedStyles.akLayoutGutterOffset * 2);
|
|
37
37
|
};
|
|
38
38
|
var editorContentAreaStyle = exports.editorContentAreaStyle = function editorContentAreaStyle(_ref) {
|
|
39
39
|
var layoutMaxWidth = _ref.layoutMaxWidth,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
|
|
3
3
|
import { jsx, css } from '@emotion/react';
|
|
4
|
-
import { N30 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { N30, N40, N50 } from '@atlaskit/theme/colors';
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
const useMultiBodiedExtensionActions = ({
|
|
7
7
|
updateActiveChild,
|
|
@@ -20,17 +20,16 @@ const useMultiBodiedExtensionActions = ({
|
|
|
20
20
|
dispatch
|
|
21
21
|
} = editorView;
|
|
22
22
|
if (node.content.childCount >= node.attrs.maxFrames) {
|
|
23
|
-
|
|
24
|
-
return false;
|
|
23
|
+
throw new Error(`Cannot add more than ${node.attrs.maxFrames} frames`);
|
|
25
24
|
}
|
|
26
25
|
const p = state.schema.nodes.paragraph.createAndFill({});
|
|
27
26
|
if (!p) {
|
|
28
|
-
|
|
27
|
+
throw new Error('Could not create paragraph');
|
|
29
28
|
}
|
|
30
29
|
const frame = state.schema.nodes.extensionFrame.createAndFill({}, [p]);
|
|
31
30
|
const pos = getPos();
|
|
32
31
|
if (typeof pos !== 'number' || !frame) {
|
|
33
|
-
|
|
32
|
+
throw new Error('Could not create frame or position not valid');
|
|
34
33
|
}
|
|
35
34
|
const insertAt = Math.min((pos || 1) + node.content.size, state.doc.content.size);
|
|
36
35
|
dispatch(state.tr.insert(insertAt, frame));
|
|
@@ -43,7 +42,7 @@ const useMultiBodiedExtensionActions = ({
|
|
|
43
42
|
const pos = getPos();
|
|
44
43
|
// TODO: Add child index validation here, don't trust this data
|
|
45
44
|
if (typeof pos !== 'number' || typeof index !== 'number') {
|
|
46
|
-
|
|
45
|
+
throw new Error('Position or index not valid');
|
|
47
46
|
}
|
|
48
47
|
const {
|
|
49
48
|
state,
|
|
@@ -60,7 +59,7 @@ const useMultiBodiedExtensionActions = ({
|
|
|
60
59
|
const startFramePosition = $startNodePos.posAtIndex(index);
|
|
61
60
|
const maybeFrameNode = state.doc.nodeAt(startFramePosition);
|
|
62
61
|
if (!maybeFrameNode) {
|
|
63
|
-
|
|
62
|
+
throw new Error('Could not find frame node');
|
|
64
63
|
}
|
|
65
64
|
const endFramePosition = maybeFrameNode.content.size + startFramePosition;
|
|
66
65
|
const tr = state.tr;
|
|
@@ -75,7 +74,7 @@ const useMultiBodiedExtensionActions = ({
|
|
|
75
74
|
} = editorView;
|
|
76
75
|
const pos = getPos();
|
|
77
76
|
if (typeof pos !== 'number') {
|
|
78
|
-
|
|
77
|
+
throw new Error('Position not valid');
|
|
79
78
|
}
|
|
80
79
|
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
81
80
|
...node.attrs,
|
|
@@ -108,6 +107,8 @@ const navigationCSS = css`
|
|
|
108
107
|
// This is really important to keep the navigation working properly
|
|
109
108
|
user-select: none;
|
|
110
109
|
-webkit-user-modify: read-only;
|
|
110
|
+
border: 1px solid ${`var(--ds-border, ${N40})`};
|
|
111
|
+
background-color: ${`var(--ds-background-inverse-subtle, ${N50})`};
|
|
111
112
|
`;
|
|
112
113
|
const MultiBodiedExtension = ({
|
|
113
114
|
node,
|
|
@@ -120,9 +121,8 @@ const MultiBodiedExtension = ({
|
|
|
120
121
|
// Adding to avoid aliasing `this` for the callbacks
|
|
121
122
|
const updateActiveChild = React.useCallback(index => {
|
|
122
123
|
if (typeof index !== 'number') {
|
|
123
|
-
// TODO: Make sure we log this somewhere if this happens
|
|
124
124
|
setActiveChildIndex(0);
|
|
125
|
-
|
|
125
|
+
throw new Error('Index is not valid');
|
|
126
126
|
}
|
|
127
127
|
setActiveChildIndex(index);
|
|
128
128
|
return true;
|
|
@@ -141,14 +141,16 @@ const MultiBodiedExtension = ({
|
|
|
141
141
|
}, [handleContentDOMRef]);
|
|
142
142
|
const containerCSS = css`
|
|
143
143
|
border: 1px solid ${`var(--ds-border, ${N30})`};
|
|
144
|
-
|
|
144
|
+
min-height: 100px;
|
|
145
145
|
.multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true'] {
|
|
146
146
|
display: none;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
.multiBodiedExtension-content-dom-wrapper
|
|
150
150
|
> [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1}) {
|
|
151
|
+
border: 1px solid ${`var(--ds-border, ${N50})`};
|
|
151
152
|
display: block;
|
|
153
|
+
min-height: 100px;
|
|
152
154
|
}
|
|
153
155
|
`;
|
|
154
156
|
return jsx("section", {
|
|
@@ -401,7 +401,7 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
401
401
|
const {
|
|
402
402
|
marks: {
|
|
403
403
|
code: codeMark,
|
|
404
|
-
|
|
404
|
+
annotation: annotationMark
|
|
405
405
|
},
|
|
406
406
|
nodes: {
|
|
407
407
|
bulletList,
|
|
@@ -411,7 +411,6 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
411
411
|
listItem,
|
|
412
412
|
mention,
|
|
413
413
|
orderedList,
|
|
414
|
-
paragraph,
|
|
415
414
|
text
|
|
416
415
|
}
|
|
417
416
|
} = schema;
|
|
@@ -425,24 +424,13 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
425
424
|
|
|
426
425
|
// special case for codeMark: will preserve mark only if codeMark is currently active
|
|
427
426
|
// won't preserve mark if cursor is on the edge on the mark (namely inactive)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const isPlainTextSlice = slice.content.childCount === 1 && slice.content.firstChild.type === paragraph && slice.content.firstChild.content.childCount === 1 && slice.content.firstChild.firstChild.type === text;
|
|
432
|
-
|
|
433
|
-
// special case for plainTextSlice & linkMark: merge into existing link
|
|
434
|
-
if (isPlainTextSlice && linkMark.isInSet(selectionMarks) && selectionMarks.length === 1) {
|
|
435
|
-
const tr = closeHistory(state.tr).replaceSelectionWith(slice.content.firstChild.firstChild, true).setStoredMarks(selectionMarks).scrollIntoView();
|
|
436
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
437
|
-
if (dispatch) {
|
|
438
|
-
dispatch(tr);
|
|
439
|
-
}
|
|
440
|
-
return true;
|
|
441
|
-
}
|
|
427
|
+
const hasActiveCodeMark = codeMark && codeMark.isInSet(selectionMarks) && anyMarkActive(state, codeMark);
|
|
428
|
+
const hasAnnotationMark = annotationMark && annotationMark.isInSet(selectionMarks);
|
|
429
|
+
const selectionIsHeading = hasParentNodeOfType([heading])(state.selection);
|
|
442
430
|
|
|
443
431
|
// if the pasted data is one of the node types below
|
|
444
432
|
// we apply current selection marks to the pasted slice
|
|
445
|
-
if (hasOnlyNodesOfType(bulletList, hardBreak, heading, listItem,
|
|
433
|
+
if (hasOnlyNodesOfType(bulletList, hardBreak, heading, listItem, text, emoji, mention, orderedList)(slice) || selectionIsHeading || hasActiveCodeMark || hasAnnotationMark) {
|
|
446
434
|
const transformedSlice = applyTextMarksToSlice(schema, selectionMarks)(slice);
|
|
447
435
|
const tr = closeHistory(state.tr).replaceSelection(transformedSlice).setStoredMarks(selectionMarks).scrollIntoView();
|
|
448
436
|
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
@@ -62,6 +62,9 @@ export const editorContentAreaHideContainer = css`
|
|
|
62
62
|
.extension-container {
|
|
63
63
|
display: none;
|
|
64
64
|
}
|
|
65
|
+
.multiBodiedExtension--container {
|
|
66
|
+
display: none;
|
|
67
|
+
}
|
|
65
68
|
}
|
|
66
69
|
`;
|
|
67
70
|
|
|
@@ -73,6 +76,9 @@ const editorContentAreaContainerStyle = containerWidth => css`
|
|
|
73
76
|
.extension-container {
|
|
74
77
|
max-width: ${containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2}px;
|
|
75
78
|
}
|
|
79
|
+
.multiBodiedExtension--container {
|
|
80
|
+
max-width: ${containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2}px;
|
|
81
|
+
}
|
|
76
82
|
|
|
77
83
|
[data-layout-section] {
|
|
78
84
|
max-width: ${containerWidth - TOTAL_PADDING + akLayoutGutterOffset * 2}px;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "189.6.
|
|
2
|
+
export const version = "189.6.18";
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
/** @jsx jsx */
|
|
8
8
|
|
|
9
9
|
import { jsx, css } from '@emotion/react';
|
|
10
|
-
import { N30 } from '@atlaskit/theme/colors';
|
|
10
|
+
import { N30, N40, N50 } from '@atlaskit/theme/colors';
|
|
11
11
|
import React, { useState } from 'react';
|
|
12
12
|
var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_ref) {
|
|
13
13
|
var updateActiveChild = _ref.updateActiveChild,
|
|
@@ -23,17 +23,16 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
23
23
|
var state = editorView.state,
|
|
24
24
|
dispatch = editorView.dispatch;
|
|
25
25
|
if (node.content.childCount >= node.attrs.maxFrames) {
|
|
26
|
-
|
|
27
|
-
return false;
|
|
26
|
+
throw new Error("Cannot add more than ".concat(node.attrs.maxFrames, " frames"));
|
|
28
27
|
}
|
|
29
28
|
var p = state.schema.nodes.paragraph.createAndFill({});
|
|
30
29
|
if (!p) {
|
|
31
|
-
|
|
30
|
+
throw new Error('Could not create paragraph');
|
|
32
31
|
}
|
|
33
32
|
var frame = state.schema.nodes.extensionFrame.createAndFill({}, [p]);
|
|
34
33
|
var pos = getPos();
|
|
35
34
|
if (typeof pos !== 'number' || !frame) {
|
|
36
|
-
|
|
35
|
+
throw new Error('Could not create frame or position not valid');
|
|
37
36
|
}
|
|
38
37
|
var insertAt = Math.min((pos || 1) + node.content.size, state.doc.content.size);
|
|
39
38
|
dispatch(state.tr.insert(insertAt, frame));
|
|
@@ -46,7 +45,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
46
45
|
var pos = getPos();
|
|
47
46
|
// TODO: Add child index validation here, don't trust this data
|
|
48
47
|
if (typeof pos !== 'number' || typeof index !== 'number') {
|
|
49
|
-
|
|
48
|
+
throw new Error('Position or index not valid');
|
|
50
49
|
}
|
|
51
50
|
var state = editorView.state,
|
|
52
51
|
dispatch = editorView.dispatch;
|
|
@@ -61,7 +60,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
61
60
|
var startFramePosition = $startNodePos.posAtIndex(index);
|
|
62
61
|
var maybeFrameNode = state.doc.nodeAt(startFramePosition);
|
|
63
62
|
if (!maybeFrameNode) {
|
|
64
|
-
|
|
63
|
+
throw new Error('Could not find frame node');
|
|
65
64
|
}
|
|
66
65
|
var endFramePosition = maybeFrameNode.content.size + startFramePosition;
|
|
67
66
|
var tr = state.tr;
|
|
@@ -74,7 +73,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
74
73
|
dispatch = editorView.dispatch;
|
|
75
74
|
var pos = getPos();
|
|
76
75
|
if (typeof pos !== 'number') {
|
|
77
|
-
|
|
76
|
+
throw new Error('Position not valid');
|
|
78
77
|
}
|
|
79
78
|
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
80
79
|
parameters: _objectSpread(_objectSpread({}, node.attrs.parameters), {}, {
|
|
@@ -98,7 +97,7 @@ var useMultiBodiedExtensionActions = function useMultiBodiedExtensionActions(_re
|
|
|
98
97
|
}, [node, editorView, getPos, updateActiveChild]);
|
|
99
98
|
return actions;
|
|
100
99
|
};
|
|
101
|
-
var navigationCSS = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n // make sure the user can't see a range selection inside the navigation\n // This is really important to keep the navigation working properly\n user-select: none;\n -webkit-user-modify: read-only;\n"])));
|
|
100
|
+
var navigationCSS = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n // make sure the user can't see a range selection inside the navigation\n // This is really important to keep the navigation working properly\n user-select: none;\n -webkit-user-modify: read-only;\n border: 1px solid ", ";\n background-color: ", ";\n"])), "var(--ds-border, ".concat(N40, ")"), "var(--ds-background-inverse-subtle, ".concat(N50, ")"));
|
|
102
101
|
var MultiBodiedExtension = function MultiBodiedExtension(_ref2) {
|
|
103
102
|
var node = _ref2.node,
|
|
104
103
|
handleContentDOMRef = _ref2.handleContentDOMRef,
|
|
@@ -112,9 +111,8 @@ var MultiBodiedExtension = function MultiBodiedExtension(_ref2) {
|
|
|
112
111
|
// Adding to avoid aliasing `this` for the callbacks
|
|
113
112
|
var updateActiveChild = React.useCallback(function (index) {
|
|
114
113
|
if (typeof index !== 'number') {
|
|
115
|
-
// TODO: Make sure we log this somewhere if this happens
|
|
116
114
|
setActiveChildIndex(0);
|
|
117
|
-
|
|
115
|
+
throw new Error('Index is not valid');
|
|
118
116
|
}
|
|
119
117
|
setActiveChildIndex(index);
|
|
120
118
|
return true;
|
|
@@ -131,7 +129,7 @@ var MultiBodiedExtension = function MultiBodiedExtension(_ref2) {
|
|
|
131
129
|
var articleRef = React.useCallback(function (node) {
|
|
132
130
|
return handleContentDOMRef(node);
|
|
133
131
|
}, [handleContentDOMRef]);
|
|
134
|
-
var containerCSS = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n
|
|
132
|
+
var containerCSS = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n min-height: 100px;\n .multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true'] {\n display: none;\n }\n\n .multiBodiedExtension-content-dom-wrapper\n > [data-extension-frame='true']:nth-of-type(", ") {\n border: 1px solid ", ";\n display: block;\n min-height: 100px;\n }\n "])), "var(--ds-border, ".concat(N30, ")"), activeChildIndex + 1, "var(--ds-border, ".concat(N50, ")"));
|
|
135
133
|
return jsx("section", {
|
|
136
134
|
className: "multiBodiedExtension--container",
|
|
137
135
|
css: containerCSS,
|
|
@@ -383,7 +383,7 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
383
383
|
selection = state.tr.selection;
|
|
384
384
|
var _schema$marks = schema.marks,
|
|
385
385
|
codeMark = _schema$marks.code,
|
|
386
|
-
|
|
386
|
+
annotationMark = _schema$marks.annotation,
|
|
387
387
|
_schema$nodes2 = schema.nodes,
|
|
388
388
|
bulletList = _schema$nodes2.bulletList,
|
|
389
389
|
emoji = _schema$nodes2.emoji,
|
|
@@ -392,7 +392,6 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
392
392
|
listItem = _schema$nodes2.listItem,
|
|
393
393
|
mention = _schema$nodes2.mention,
|
|
394
394
|
orderedList = _schema$nodes2.orderedList,
|
|
395
|
-
paragraph = _schema$nodes2.paragraph,
|
|
396
395
|
text = _schema$nodes2.text;
|
|
397
396
|
if (!(selection instanceof TextSelection)) {
|
|
398
397
|
return false;
|
|
@@ -404,29 +403,18 @@ export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
|
404
403
|
|
|
405
404
|
// special case for codeMark: will preserve mark only if codeMark is currently active
|
|
406
405
|
// won't preserve mark if cursor is on the edge on the mark (namely inactive)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
var isPlainTextSlice = slice.content.childCount === 1 && slice.content.firstChild.type === paragraph && slice.content.firstChild.content.childCount === 1 && slice.content.firstChild.firstChild.type === text;
|
|
411
|
-
|
|
412
|
-
// special case for plainTextSlice & linkMark: merge into existing link
|
|
413
|
-
if (isPlainTextSlice && linkMark.isInSet(selectionMarks) && selectionMarks.length === 1) {
|
|
414
|
-
var tr = closeHistory(state.tr).replaceSelectionWith(slice.content.firstChild.firstChild, true).setStoredMarks(selectionMarks).scrollIntoView();
|
|
415
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
416
|
-
if (dispatch) {
|
|
417
|
-
dispatch(tr);
|
|
418
|
-
}
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
406
|
+
var hasActiveCodeMark = codeMark && codeMark.isInSet(selectionMarks) && anyMarkActive(state, codeMark);
|
|
407
|
+
var hasAnnotationMark = annotationMark && annotationMark.isInSet(selectionMarks);
|
|
408
|
+
var selectionIsHeading = hasParentNodeOfType([heading])(state.selection);
|
|
421
409
|
|
|
422
410
|
// if the pasted data is one of the node types below
|
|
423
411
|
// we apply current selection marks to the pasted slice
|
|
424
|
-
if (hasOnlyNodesOfType(bulletList, hardBreak, heading, listItem,
|
|
412
|
+
if (hasOnlyNodesOfType(bulletList, hardBreak, heading, listItem, text, emoji, mention, orderedList)(slice) || selectionIsHeading || hasActiveCodeMark || hasAnnotationMark) {
|
|
425
413
|
var transformedSlice = applyTextMarksToSlice(schema, selectionMarks)(slice);
|
|
426
|
-
var
|
|
427
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state,
|
|
414
|
+
var tr = closeHistory(state.tr).replaceSelection(transformedSlice).setStoredMarks(selectionMarks).scrollIntoView();
|
|
415
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
428
416
|
if (dispatch) {
|
|
429
|
-
dispatch(
|
|
417
|
+
dispatch(tr);
|
|
430
418
|
}
|
|
431
419
|
return true;
|
|
432
420
|
}
|
|
@@ -22,11 +22,11 @@ export var sidebarArea = css(_templateObject5 || (_templateObject5 = _taggedTemp
|
|
|
22
22
|
|
|
23
23
|
// initially hide until we have a containerWidth and can properly size them,
|
|
24
24
|
// otherwise they can cause the editor width to extend which is non-recoverable
|
|
25
|
-
export var editorContentAreaHideContainer = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n display: none;\n }\n }\n"])));
|
|
25
|
+
export var editorContentAreaHideContainer = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n display: none;\n }\n .multiBodiedExtension--container {\n display: none;\n }\n }\n"])));
|
|
26
26
|
|
|
27
27
|
/* Prevent horizontal scroll on page in full width mode */
|
|
28
28
|
var editorContentAreaContainerStyle = function editorContentAreaContainerStyle(containerWidth) {
|
|
29
|
-
return css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n max-width: ", "px;\n }\n\n [data-layout-section] {\n max-width: ", "px;\n }\n }\n"])), containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2, containerWidth - TOTAL_PADDING + akLayoutGutterOffset * 2);
|
|
29
|
+
return css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n .fabric-editor--full-width-mode {\n .pm-table-container,\n .code-block,\n .extension-container {\n max-width: ", "px;\n }\n .multiBodiedExtension--container {\n max-width: ", "px;\n }\n\n [data-layout-section] {\n max-width: ", "px;\n }\n }\n"])), containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2, containerWidth - TOTAL_PADDING - tableMarginFullWidthMode * 2, containerWidth - TOTAL_PADDING + akLayoutGutterOffset * 2);
|
|
30
30
|
};
|
|
31
31
|
export var editorContentAreaStyle = function editorContentAreaStyle(_ref) {
|
|
32
32
|
var layoutMaxWidth = _ref.layoutMaxWidth,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "189.6.
|
|
2
|
+
export var version = "189.6.18";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "189.6.
|
|
3
|
+
"version": "189.6.18",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@atlaskit/analytics-next-stable-react-context": "1.0.1",
|
|
48
48
|
"@atlaskit/avatar": "^21.4.0",
|
|
49
49
|
"@atlaskit/avatar-group": "^9.4.0",
|
|
50
|
-
"@atlaskit/button": "^
|
|
50
|
+
"@atlaskit/button": "^17.0.0",
|
|
51
51
|
"@atlaskit/checkbox": "^13.0.0",
|
|
52
52
|
"@atlaskit/date": "^0.10.0",
|
|
53
53
|
"@atlaskit/datetime-picker": "^13.0.3",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@atlaskit/icon": "^22.0.0",
|
|
124
124
|
"@atlaskit/logo": "^13.14.0",
|
|
125
125
|
"@atlaskit/media-card": "^77.6.0",
|
|
126
|
-
"@atlaskit/media-client": "^26.
|
|
126
|
+
"@atlaskit/media-client": "^26.1.0",
|
|
127
127
|
"@atlaskit/media-common": "^11.0.0",
|
|
128
128
|
"@atlaskit/mention": "^22.1.0",
|
|
129
129
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"@atlaskit/textfield": "^6.0.0",
|
|
141
141
|
"@atlaskit/theme": "^12.6.0",
|
|
142
142
|
"@atlaskit/toggle": "^13.0.0",
|
|
143
|
-
"@atlaskit/tokens": "^1.
|
|
143
|
+
"@atlaskit/tokens": "^1.30.0",
|
|
144
144
|
"@atlaskit/tooltip": "^18.0.0",
|
|
145
145
|
"@atlaskit/ufo": "^0.2.0",
|
|
146
146
|
"@atlaskit/width-detector": "^4.1.0",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"@atlassian/editor-extension-link-create": "^1.0.0",
|
|
196
196
|
"@atlassian/feature-flags-test-utils": "^0.1.1",
|
|
197
197
|
"@atlassian/link-picker-plugins": "^24.0.0",
|
|
198
|
-
"@atlassian/search-provider": "2.4.
|
|
198
|
+
"@atlassian/search-provider": "2.4.11",
|
|
199
199
|
"@atlassian/ufo": "^0.2.0",
|
|
200
200
|
"@emotion/jest": "^11.8.0",
|
|
201
201
|
"@storybook/addon-knobs": "^5.3.18",
|