@atlaskit/editor-common 74.55.1 → 74.56.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 +12 -0
- package/dist/cjs/commands/index.js +7 -0
- package/dist/cjs/commands/insert-block.js +60 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/resizer/Resizer.js +6 -6
- package/dist/cjs/styles/shared/resizer.js +5 -3
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/create-wrap-selection-transaction.js +65 -0
- package/dist/cjs/utils/index.js +14 -0
- package/dist/cjs/utils/wrap-selection-in.js +25 -0
- package/dist/es2019/commands/index.js +2 -1
- package/dist/es2019/commands/insert-block.js +55 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/resizer/Resizer.js +4 -3
- package/dist/es2019/styles/shared/resizer.js +5 -4
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/create-wrap-selection-transaction.js +66 -0
- package/dist/es2019/utils/index.js +3 -1
- package/dist/es2019/utils/wrap-selection-in.js +19 -0
- package/dist/esm/commands/index.js +2 -1
- package/dist/esm/commands/insert-block.js +53 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/resizer/Resizer.js +3 -3
- package/dist/esm/styles/shared/resizer.js +3 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/create-wrap-selection-transaction.js +60 -0
- package/dist/esm/utils/index.js +3 -1
- package/dist/esm/utils/wrap-selection-in.js +19 -0
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/insert-block.d.ts +5 -0
- package/dist/types/styles/shared/resizer.d.ts +1 -0
- package/dist/types/utils/create-wrap-selection-transaction.d.ts +15 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/wrap-selection-in.d.ts +9 -0
- package/dist/types-ts4.5/commands/index.d.ts +1 -1
- package/dist/types-ts4.5/commands/insert-block.d.ts +5 -0
- package/dist/types-ts4.5/styles/shared/resizer.d.ts +1 -0
- package/dist/types-ts4.5/utils/create-wrap-selection-transaction.d.ts +15 -0
- package/dist/types-ts4.5/utils/index.d.ts +2 -0
- package/dist/types-ts4.5/utils/wrap-selection-in.d.ts +9 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.56.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`3542bead318`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3542bead318) - Move block type commands to next editor plugin actions
|
|
8
|
+
|
|
9
|
+
## 74.55.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`58f6154cd7c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/58f6154cd7c) - Use color.icon.danger colour token for resizer danger state, rename the danger className to avoid collisions and ensure danger state is only applied to tables when the table is selected
|
|
14
|
+
|
|
3
15
|
## 74.55.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -9,10 +9,17 @@ exports.clearEditorContent = exports.changeImageAlignment = void 0;
|
|
|
9
9
|
exports.createParagraphAtEnd = createParagraphAtEnd;
|
|
10
10
|
exports.createToggleBlockMarkOnRange = void 0;
|
|
11
11
|
exports.findCutBefore = findCutBefore;
|
|
12
|
+
Object.defineProperty(exports, "insertBlock", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _insertBlock.insertBlock;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
exports.toggleBlockMark = void 0;
|
|
13
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
20
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
21
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
22
|
+
var _insertBlock = require("./insert-block");
|
|
16
23
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
24
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
25
|
function addParagraphAtEnd(tr) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.insertBlock = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var insertBlock = function insertBlock(state, nodeType, start, end, attrs) {
|
|
10
|
+
// To ensure that match is done after HardBreak.
|
|
11
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
12
|
+
hardBreak = _state$schema$nodes.hardBreak,
|
|
13
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
14
|
+
listItem = _state$schema$nodes.listItem;
|
|
15
|
+
var $pos = state.doc.resolve(start);
|
|
16
|
+
if ($pos.nodeAfter.type !== hardBreak) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// To ensure no nesting is done. (unless we're inserting a codeBlock inside lists)
|
|
21
|
+
if ($pos.depth > 1 && !(nodeType === codeBlock && (0, _utils.hasParentNodeOfType)(listItem)(state.selection))) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Split at the start of autoformatting and delete formatting characters.
|
|
26
|
+
var tr = state.tr.delete(start, end).split(start);
|
|
27
|
+
var currentNode = tr.doc.nodeAt(start + 1);
|
|
28
|
+
|
|
29
|
+
// If node has more content split at the end of autoformatting.
|
|
30
|
+
var nodeHasMoreContent = false;
|
|
31
|
+
tr.doc.nodesBetween(start, start + currentNode.nodeSize, function (node, pos) {
|
|
32
|
+
if (!nodeHasMoreContent && node.type === hardBreak) {
|
|
33
|
+
nodeHasMoreContent = true;
|
|
34
|
+
tr = tr.split(pos + 1).delete(pos, pos + 1);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (nodeHasMoreContent) {
|
|
38
|
+
currentNode = tr.doc.nodeAt(start + 1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Create new node and fill with content of current node.
|
|
42
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
43
|
+
blockquote = _state$schema$nodes2.blockquote,
|
|
44
|
+
paragraph = _state$schema$nodes2.paragraph;
|
|
45
|
+
var content;
|
|
46
|
+
var depth;
|
|
47
|
+
if (nodeType === blockquote) {
|
|
48
|
+
depth = 3;
|
|
49
|
+
content = [paragraph.create({}, currentNode.content)];
|
|
50
|
+
} else {
|
|
51
|
+
depth = 2;
|
|
52
|
+
content = currentNode.content;
|
|
53
|
+
}
|
|
54
|
+
var newNode = nodeType.create(attrs, content);
|
|
55
|
+
|
|
56
|
+
// Add new node.
|
|
57
|
+
tr = tr.setSelection(new _state.NodeSelection(tr.doc.resolve(start + 1))).replaceSelectionWith(newNode).setSelection(new _state.TextSelection(tr.doc.resolve(start + depth)));
|
|
58
|
+
return tr;
|
|
59
|
+
};
|
|
60
|
+
exports.insertBlock = insertBlock;
|
|
@@ -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.56.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
|
|
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
-
var
|
|
14
|
+
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
15
15
|
var _reResizable = require("re-resizable");
|
|
16
16
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
17
17
|
var _resizer = require("../styles/shared/resizer");
|
|
@@ -88,8 +88,8 @@ function ResizerNext(props) {
|
|
|
88
88
|
handleResizeStop(originalState, delta);
|
|
89
89
|
}, [handleResizeStop]);
|
|
90
90
|
var handles = {
|
|
91
|
-
left: (0,
|
|
92
|
-
right: (0,
|
|
91
|
+
left: (0, _classnames2.default)(handleClassName !== null && handleClassName !== void 0 ? handleClassName : _resizer.resizerHandleClassName, 'left', handleHeightSize, handleAlignmentMethod),
|
|
92
|
+
right: (0, _classnames2.default)(handleClassName !== null && handleClassName !== void 0 ? handleClassName : _resizer.resizerHandleClassName, 'right', handleHeightSize, handleAlignmentMethod)
|
|
93
93
|
};
|
|
94
94
|
var baseHandleStyles = {
|
|
95
95
|
width: handlePositioning === 'adjacent' ? "var(--ds-space-100, 8px)" : "var(--ds-space-300, 24px)",
|
|
@@ -110,10 +110,10 @@ function ResizerNext(props) {
|
|
|
110
110
|
right: offset
|
|
111
111
|
}, handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles.right)
|
|
112
112
|
};
|
|
113
|
-
var resizerClassName = (0,
|
|
113
|
+
var resizerClassName = (0, _classnames2.default)(className, _resizer.resizerItemClassName, (0, _defineProperty2.default)({
|
|
114
114
|
'is-resizing': isResizing,
|
|
115
115
|
'display-handle': isHandleVisible
|
|
116
|
-
}, appearance);
|
|
116
|
+
}, _resizer.resizerDangerClassName, appearance === 'danger'));
|
|
117
117
|
var finalHandleComponent = (0, _react.useMemo)(function () {
|
|
118
118
|
if ((!handleHighlight || handleHighlight === 'none') && !handleTooltipContent && !handleComponent) {
|
|
119
119
|
return {
|
|
@@ -138,7 +138,7 @@ function ResizerNext(props) {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
var children = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
-
className: (0,
|
|
141
|
+
className: (0, _classnames2.default)(_resizer.resizerHandleTrackClassName, handleHighlight)
|
|
142
142
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
143
143
|
className: _resizer.resizerHandleThumbClassName
|
|
144
144
|
}));
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.resizerStyles = exports.resizerItemClassName = exports.resizerHandleZIndex = exports.resizerHandleTrackClassName = exports.resizerHandleThumbClassName = exports.resizerHandleClassName = void 0;
|
|
7
|
+
exports.resizerStyles = exports.resizerItemClassName = exports.resizerHandleZIndex = exports.resizerHandleTrackClassName = exports.resizerHandleThumbClassName = exports.resizerHandleClassName = exports.resizerDangerClassName = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
@@ -22,11 +22,13 @@ exports.resizerHandleClassName = resizerHandleClassName;
|
|
|
22
22
|
var resizerHandleTrackClassName = "".concat(resizerHandleClassName, "-track");
|
|
23
23
|
exports.resizerHandleTrackClassName = resizerHandleTrackClassName;
|
|
24
24
|
var resizerHandleThumbClassName = "".concat(resizerHandleClassName, "-thumb");
|
|
25
|
+
exports.resizerHandleThumbClassName = resizerHandleThumbClassName;
|
|
26
|
+
var resizerDangerClassName = "".concat(resizerHandleClassName, "-danger");
|
|
25
27
|
|
|
26
28
|
// akEditorSelectedNodeClassName from '@atlaskit/editor-shared-styles';
|
|
27
|
-
exports.
|
|
29
|
+
exports.resizerDangerClassName = resizerDangerClassName;
|
|
28
30
|
var akEditorSelectedNodeClassName = 'ak-editor-selected-node';
|
|
29
31
|
var resizerHandleZIndex = 99;
|
|
30
32
|
exports.resizerHandleZIndex = resizerHandleZIndex;
|
|
31
|
-
var resizerStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n will-change: width;\n\n &:hover,\n &.display-handle {\n & .", " {\n visibility: visible;\n opacity: 1;\n }\n }\n\n &.is-resizing {\n & .", " {\n background: ", ";\n }\n }\n\n &.
|
|
33
|
+
var resizerStyles = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n will-change: width;\n\n &:hover,\n &.display-handle {\n & .", " {\n visibility: visible;\n opacity: 1;\n }\n }\n\n &.is-resizing {\n & .", " {\n background: ", ";\n }\n }\n\n &.", " {\n & .", " {\n transition: none;\n background: ", ";\n }\n }\n }\n\n .", " {\n display: flex;\n visibility: hidden;\n opacity: 0;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n width: 7px;\n transition: visibility 0.2s, opacity 0.2s;\n\n /*\n NOTE: The below style is targeted at the div element added by the tooltip. We don't have any means of injecting styles\n into the tooltip\n */\n & div[role='presentation'] {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n /*\n Handle Positions\n */\n &.left {\n align-items: flex-start;\n }\n &.right {\n align-items: flex-end;\n }\n\n /*\n Handle Sizing\n */\n &.small {\n & .", " {\n height: 43px;\n }\n }\n &.medium {\n & .", " {\n height: 64px;\n }\n }\n &.large {\n & .", " {\n height: 96px;\n }\n }\n\n /*\n Handle Alignment\n */\n &.sticky {\n & .", " {\n position: sticky;\n top: ", ";\n bottom: ", ";\n }\n }\n\n &:hover {\n & .", " {\n background: ", ";\n }\n\n & .", " {\n visibility: visible;\n opacity: 0.5;\n }\n }\n }\n\n .", " {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n transition: background-color 0.2s;\n border-radius: 6px;\n\n background: ", ";\n }\n\n .", " {\n visibility: hidden;\n position: absolute;\n width: 7px;\n height: calc(100% - 24px);\n border-radius: 4px;\n opacity: 0;\n transition: background-color 0.2s, visibility 0.2s, opacity 0.2s;\n\n &.none {\n background: none;\n }\n\n &.shadow {\n background: ", ";\n }\n }\n\n .", " {\n & .", " {\n background: ", ";\n }\n }\n"])), resizerItemClassName, resizerHandleClassName, resizerHandleThumbClassName, "var(--ds-border-focused, ".concat(_colors.B200, ")"), resizerDangerClassName, resizerHandleThumbClassName, "var(--ds-icon-danger, ".concat(_editorSharedStyles.akEditorDeleteIconColor, ")"), resizerHandleClassName, resizerHandleThumbClassName, resizerHandleThumbClassName, resizerHandleThumbClassName, resizerHandleThumbClassName, "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)", resizerHandleThumbClassName, "var(--ds-border-focused, ".concat(_colors.B200, ")"), resizerHandleTrackClassName, resizerHandleThumbClassName, "var(--ds-border, ".concat(_colors.N60, ")"), resizerHandleTrackClassName, "var(--ds-background-selected, ".concat(_colors.B50, ")"), akEditorSelectedNodeClassName, resizerHandleThumbClassName, "var(--ds-border-focused, ".concat(_colors.B200, ")"));
|
|
32
34
|
exports.resizerStyles = resizerStyles;
|
|
@@ -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.56.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createWrapSelectionTransaction = createWrapSelectionTransaction;
|
|
7
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _editorCoreUtils = require("./editor-core-utils");
|
|
10
|
+
/**
|
|
11
|
+
* This function creates a new transaction that wraps the current selection
|
|
12
|
+
* in the specified node type if it results in a valid transaction.
|
|
13
|
+
* If not valid, it performs a safe insert operation.
|
|
14
|
+
*
|
|
15
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
16
|
+
* content that is already inside a panel with another panel
|
|
17
|
+
*/
|
|
18
|
+
function createWrapSelectionTransaction(_ref) {
|
|
19
|
+
var state = _ref.state,
|
|
20
|
+
type = _ref.type,
|
|
21
|
+
nodeAttributes = _ref.nodeAttributes;
|
|
22
|
+
var tr = state.tr;
|
|
23
|
+
var _state$schema$marks = state.schema.marks,
|
|
24
|
+
alignment = _state$schema$marks.alignment,
|
|
25
|
+
indentation = _state$schema$marks.indentation;
|
|
26
|
+
|
|
27
|
+
/** Alignment or Indentation is not valid inside block types */
|
|
28
|
+
var removeAlignTr = (0, _editorCoreUtils.removeBlockMarks)(state, [alignment, indentation]);
|
|
29
|
+
tr = removeAlignTr || tr;
|
|
30
|
+
|
|
31
|
+
/**Get range and wrapping needed for the selection*/
|
|
32
|
+
var _getWrappingOptions = getWrappingOptions(state, type, nodeAttributes),
|
|
33
|
+
range = _getWrappingOptions.range,
|
|
34
|
+
wrapping = _getWrappingOptions.wrapping;
|
|
35
|
+
if (wrapping) {
|
|
36
|
+
tr.wrap(range, wrapping).scrollIntoView();
|
|
37
|
+
} else {
|
|
38
|
+
/** We always want to append a block type */
|
|
39
|
+
(0, _utils.safeInsert)(type.createAndFill(nodeAttributes))(tr).scrollIntoView();
|
|
40
|
+
}
|
|
41
|
+
return tr;
|
|
42
|
+
}
|
|
43
|
+
function getWrappingOptions(state, type, nodeAttributes) {
|
|
44
|
+
var _state$selection = state.selection,
|
|
45
|
+
$from = _state$selection.$from,
|
|
46
|
+
$to = _state$selection.$to;
|
|
47
|
+
var range = $from.blockRange($to);
|
|
48
|
+
var isAllowedChild = true;
|
|
49
|
+
/**
|
|
50
|
+
* Added a check to avoid wrapping codeblock
|
|
51
|
+
*/
|
|
52
|
+
if (state.selection.empty) {
|
|
53
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
54
|
+
if (!isAllowedChild) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return isAllowedChild = node.type !== state.schema.nodes.codeBlock;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
var wrapping = isAllowedChild && range && (0, _transform.findWrapping)(range, type, nodeAttributes);
|
|
61
|
+
return {
|
|
62
|
+
range: range,
|
|
63
|
+
wrapping: wrapping
|
|
64
|
+
};
|
|
65
|
+
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -275,6 +275,12 @@ Object.defineProperty(exports, "createRule", {
|
|
|
275
275
|
return _inputRules.createRule;
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
|
+
Object.defineProperty(exports, "createWrapSelectionTransaction", {
|
|
279
|
+
enumerable: true,
|
|
280
|
+
get: function get() {
|
|
281
|
+
return _createWrapSelectionTransaction.createWrapSelectionTransaction;
|
|
282
|
+
}
|
|
283
|
+
});
|
|
278
284
|
Object.defineProperty(exports, "createWrappingJoinRule", {
|
|
279
285
|
enumerable: true,
|
|
280
286
|
get: function get() {
|
|
@@ -1003,6 +1009,12 @@ Object.defineProperty(exports, "withImageLoader", {
|
|
|
1003
1009
|
return _imageLoader.withImageLoader;
|
|
1004
1010
|
}
|
|
1005
1011
|
});
|
|
1012
|
+
Object.defineProperty(exports, "wrapSelectionIn", {
|
|
1013
|
+
enumerable: true,
|
|
1014
|
+
get: function get() {
|
|
1015
|
+
return _wrapSelectionIn.wrapSelectionIn;
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1006
1018
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
1007
1019
|
var _annotation = require("./annotation");
|
|
1008
1020
|
var _macro = require("./macro");
|
|
@@ -1054,6 +1066,8 @@ var _getPerformanceTiming = require("./performance/get-performance-timing");
|
|
|
1054
1066
|
var _countNodes = require("./count-nodes");
|
|
1055
1067
|
var _inputRules = require("./input-rules");
|
|
1056
1068
|
var _dedupe = require("./dedupe");
|
|
1069
|
+
var _createWrapSelectionTransaction = require("./create-wrap-selection-transaction");
|
|
1070
|
+
var _wrapSelectionIn = require("./wrap-selection-in");
|
|
1057
1071
|
// prosemirror-history does not export its plugin key
|
|
1058
1072
|
var pmHistoryPluginKey = 'history$';
|
|
1059
1073
|
exports.pmHistoryPluginKey = pmHistoryPluginKey;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.wrapSelectionIn = wrapSelectionIn;
|
|
7
|
+
var _createWrapSelectionTransaction = require("./create-wrap-selection-transaction");
|
|
8
|
+
/**
|
|
9
|
+
* Function will add wrapping node.
|
|
10
|
+
* 1. If currently selected blocks can be wrapped in the wrapper type it will wrap them.
|
|
11
|
+
* 2. If current block can not be wrapped inside wrapping block it will create a new block below selection,
|
|
12
|
+
* and set selection on it.
|
|
13
|
+
*/
|
|
14
|
+
function wrapSelectionIn(type) {
|
|
15
|
+
return function (state, dispatch) {
|
|
16
|
+
var tr = (0, _createWrapSelectionTransaction.createWrapSelectionTransaction)({
|
|
17
|
+
state: state,
|
|
18
|
+
type: type
|
|
19
|
+
});
|
|
20
|
+
if (dispatch) {
|
|
21
|
+
dispatch(tr);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
export const insertBlock = (state, nodeType, start, end, attrs) => {
|
|
4
|
+
// To ensure that match is done after HardBreak.
|
|
5
|
+
const {
|
|
6
|
+
hardBreak,
|
|
7
|
+
codeBlock,
|
|
8
|
+
listItem
|
|
9
|
+
} = state.schema.nodes;
|
|
10
|
+
const $pos = state.doc.resolve(start);
|
|
11
|
+
if ($pos.nodeAfter.type !== hardBreak) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// To ensure no nesting is done. (unless we're inserting a codeBlock inside lists)
|
|
16
|
+
if ($pos.depth > 1 && !(nodeType === codeBlock && hasParentNodeOfType(listItem)(state.selection))) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Split at the start of autoformatting and delete formatting characters.
|
|
21
|
+
let tr = state.tr.delete(start, end).split(start);
|
|
22
|
+
let currentNode = tr.doc.nodeAt(start + 1);
|
|
23
|
+
|
|
24
|
+
// If node has more content split at the end of autoformatting.
|
|
25
|
+
let nodeHasMoreContent = false;
|
|
26
|
+
tr.doc.nodesBetween(start, start + currentNode.nodeSize, (node, pos) => {
|
|
27
|
+
if (!nodeHasMoreContent && node.type === hardBreak) {
|
|
28
|
+
nodeHasMoreContent = true;
|
|
29
|
+
tr = tr.split(pos + 1).delete(pos, pos + 1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (nodeHasMoreContent) {
|
|
33
|
+
currentNode = tr.doc.nodeAt(start + 1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Create new node and fill with content of current node.
|
|
37
|
+
const {
|
|
38
|
+
blockquote,
|
|
39
|
+
paragraph
|
|
40
|
+
} = state.schema.nodes;
|
|
41
|
+
let content;
|
|
42
|
+
let depth;
|
|
43
|
+
if (nodeType === blockquote) {
|
|
44
|
+
depth = 3;
|
|
45
|
+
content = [paragraph.create({}, currentNode.content)];
|
|
46
|
+
} else {
|
|
47
|
+
depth = 2;
|
|
48
|
+
content = currentNode.content;
|
|
49
|
+
}
|
|
50
|
+
const newNode = nodeType.create(attrs, content);
|
|
51
|
+
|
|
52
|
+
// Add new node.
|
|
53
|
+
tr = tr.setSelection(new NodeSelection(tr.doc.resolve(start + 1))).replaceSelectionWith(newNode).setSelection(new TextSelection(tr.doc.resolve(start + depth)));
|
|
54
|
+
return tr;
|
|
55
|
+
};
|
|
@@ -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.56.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
|
|
@@ -3,7 +3,7 @@ import React, { useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { Resizable } from 're-resizable';
|
|
5
5
|
import Tooltip from '@atlaskit/tooltip';
|
|
6
|
-
import { resizerHandleClassName, resizerHandleThumbClassName, resizerHandleTrackClassName, resizerHandleZIndex, resizerItemClassName } from '../styles/shared/resizer';
|
|
6
|
+
import { resizerDangerClassName, resizerHandleClassName, resizerHandleThumbClassName, resizerHandleTrackClassName, resizerHandleZIndex, resizerItemClassName } from '../styles/shared/resizer';
|
|
7
7
|
export default function ResizerNext(props) {
|
|
8
8
|
const [isResizing, setIsResizing] = useState(false);
|
|
9
9
|
const resizable = useRef(null);
|
|
@@ -93,8 +93,9 @@ export default function ResizerNext(props) {
|
|
|
93
93
|
};
|
|
94
94
|
const resizerClassName = classnames(className, resizerItemClassName, {
|
|
95
95
|
'is-resizing': isResizing,
|
|
96
|
-
'display-handle': isHandleVisible
|
|
97
|
-
|
|
96
|
+
'display-handle': isHandleVisible,
|
|
97
|
+
[resizerDangerClassName]: appearance === 'danger'
|
|
98
|
+
});
|
|
98
99
|
const finalHandleComponent = useMemo(() => {
|
|
99
100
|
if ((!handleHighlight || handleHighlight === 'none') && !handleTooltipContent && !handleComponent) {
|
|
100
101
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import {
|
|
2
|
+
import { akEditorDeleteIconColor } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
import { B200, B50, N60 } from '@atlaskit/theme/colors';
|
|
4
4
|
/*
|
|
5
5
|
Styles in this file are based on
|
|
@@ -10,6 +10,7 @@ export const resizerItemClassName = 'resizer-item';
|
|
|
10
10
|
export const resizerHandleClassName = 'resizer-handle';
|
|
11
11
|
export const resizerHandleTrackClassName = `${resizerHandleClassName}-track`;
|
|
12
12
|
export const resizerHandleThumbClassName = `${resizerHandleClassName}-thumb`;
|
|
13
|
+
export const resizerDangerClassName = `${resizerHandleClassName}-danger`;
|
|
13
14
|
|
|
14
15
|
// akEditorSelectedNodeClassName from '@atlaskit/editor-shared-styles';
|
|
15
16
|
const akEditorSelectedNodeClassName = 'ak-editor-selected-node';
|
|
@@ -32,10 +33,10 @@ export const resizerStyles = css`
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
&.${resizerDangerClassName} {
|
|
36
37
|
& .${resizerHandleThumbClassName} {
|
|
37
38
|
transition: none;
|
|
38
|
-
background: ${`var(--ds-
|
|
39
|
+
background: ${`var(--ds-icon-danger, ${akEditorDeleteIconColor})`};
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -51,7 +52,7 @@ export const resizerStyles = css`
|
|
|
51
52
|
transition: visibility 0.2s, opacity 0.2s;
|
|
52
53
|
|
|
53
54
|
/*
|
|
54
|
-
NOTE: The below style is
|
|
55
|
+
NOTE: The below style is targeted at the div element added by the tooltip. We don't have any means of injecting styles
|
|
55
56
|
into the tooltip
|
|
56
57
|
*/
|
|
57
58
|
& div[role='presentation'] {
|
|
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
8
8
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
9
9
|
import Layer from '../Layer';
|
|
10
10
|
const packageName = "@atlaskit/editor-common";
|
|
11
|
-
const packageVersion = "74.
|
|
11
|
+
const packageVersion = "74.56.0";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
+
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { removeBlockMarks } from './editor-core-utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This function creates a new transaction that wraps the current selection
|
|
7
|
+
* in the specified node type if it results in a valid transaction.
|
|
8
|
+
* If not valid, it performs a safe insert operation.
|
|
9
|
+
*
|
|
10
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
11
|
+
* content that is already inside a panel with another panel
|
|
12
|
+
*/
|
|
13
|
+
export function createWrapSelectionTransaction({
|
|
14
|
+
state,
|
|
15
|
+
type,
|
|
16
|
+
nodeAttributes
|
|
17
|
+
}) {
|
|
18
|
+
let {
|
|
19
|
+
tr
|
|
20
|
+
} = state;
|
|
21
|
+
const {
|
|
22
|
+
alignment,
|
|
23
|
+
indentation
|
|
24
|
+
} = state.schema.marks;
|
|
25
|
+
|
|
26
|
+
/** Alignment or Indentation is not valid inside block types */
|
|
27
|
+
const removeAlignTr = removeBlockMarks(state, [alignment, indentation]);
|
|
28
|
+
tr = removeAlignTr || tr;
|
|
29
|
+
|
|
30
|
+
/**Get range and wrapping needed for the selection*/
|
|
31
|
+
const {
|
|
32
|
+
range,
|
|
33
|
+
wrapping
|
|
34
|
+
} = getWrappingOptions(state, type, nodeAttributes);
|
|
35
|
+
if (wrapping) {
|
|
36
|
+
tr.wrap(range, wrapping).scrollIntoView();
|
|
37
|
+
} else {
|
|
38
|
+
/** We always want to append a block type */
|
|
39
|
+
safeInsert(type.createAndFill(nodeAttributes))(tr).scrollIntoView();
|
|
40
|
+
}
|
|
41
|
+
return tr;
|
|
42
|
+
}
|
|
43
|
+
function getWrappingOptions(state, type, nodeAttributes) {
|
|
44
|
+
const {
|
|
45
|
+
$from,
|
|
46
|
+
$to
|
|
47
|
+
} = state.selection;
|
|
48
|
+
const range = $from.blockRange($to);
|
|
49
|
+
let isAllowedChild = true;
|
|
50
|
+
/**
|
|
51
|
+
* Added a check to avoid wrapping codeblock
|
|
52
|
+
*/
|
|
53
|
+
if (state.selection.empty) {
|
|
54
|
+
state.doc.nodesBetween($from.pos, $to.pos, node => {
|
|
55
|
+
if (!isAllowedChild) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return isAllowedChild = node.type !== state.schema.nodes.codeBlock;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const wrapping = isAllowedChild && range && findWrapping(range, type, nodeAttributes);
|
|
62
|
+
return {
|
|
63
|
+
range,
|
|
64
|
+
wrapping
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -193,4 +193,6 @@ export function isNodeEmpty(node) {
|
|
|
193
193
|
});
|
|
194
194
|
return !nonBlock.length && !block.filter(childNode => !!childNode.childCount && !(childNode.childCount === 1 && isEmptyParagraph(childNode.firstChild)) || childNode.isAtom).length;
|
|
195
195
|
}
|
|
196
|
-
export { dedupe } from './dedupe';
|
|
196
|
+
export { dedupe } from './dedupe';
|
|
197
|
+
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
198
|
+
export { wrapSelectionIn } from './wrap-selection-in';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
2
|
+
/**
|
|
3
|
+
* Function will add wrapping node.
|
|
4
|
+
* 1. If currently selected blocks can be wrapped in the wrapper type it will wrap them.
|
|
5
|
+
* 2. If current block can not be wrapped inside wrapping block it will create a new block below selection,
|
|
6
|
+
* and set selection on it.
|
|
7
|
+
*/
|
|
8
|
+
export function wrapSelectionIn(type) {
|
|
9
|
+
return function (state, dispatch) {
|
|
10
|
+
let tr = createWrapSelectionTransaction({
|
|
11
|
+
state,
|
|
12
|
+
type
|
|
13
|
+
});
|
|
14
|
+
if (dispatch) {
|
|
15
|
+
dispatch(tr);
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
export var insertBlock = function insertBlock(state, nodeType, start, end, attrs) {
|
|
4
|
+
// To ensure that match is done after HardBreak.
|
|
5
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
6
|
+
hardBreak = _state$schema$nodes.hardBreak,
|
|
7
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
8
|
+
listItem = _state$schema$nodes.listItem;
|
|
9
|
+
var $pos = state.doc.resolve(start);
|
|
10
|
+
if ($pos.nodeAfter.type !== hardBreak) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// To ensure no nesting is done. (unless we're inserting a codeBlock inside lists)
|
|
15
|
+
if ($pos.depth > 1 && !(nodeType === codeBlock && hasParentNodeOfType(listItem)(state.selection))) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Split at the start of autoformatting and delete formatting characters.
|
|
20
|
+
var tr = state.tr.delete(start, end).split(start);
|
|
21
|
+
var currentNode = tr.doc.nodeAt(start + 1);
|
|
22
|
+
|
|
23
|
+
// If node has more content split at the end of autoformatting.
|
|
24
|
+
var nodeHasMoreContent = false;
|
|
25
|
+
tr.doc.nodesBetween(start, start + currentNode.nodeSize, function (node, pos) {
|
|
26
|
+
if (!nodeHasMoreContent && node.type === hardBreak) {
|
|
27
|
+
nodeHasMoreContent = true;
|
|
28
|
+
tr = tr.split(pos + 1).delete(pos, pos + 1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (nodeHasMoreContent) {
|
|
32
|
+
currentNode = tr.doc.nodeAt(start + 1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Create new node and fill with content of current node.
|
|
36
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
37
|
+
blockquote = _state$schema$nodes2.blockquote,
|
|
38
|
+
paragraph = _state$schema$nodes2.paragraph;
|
|
39
|
+
var content;
|
|
40
|
+
var depth;
|
|
41
|
+
if (nodeType === blockquote) {
|
|
42
|
+
depth = 3;
|
|
43
|
+
content = [paragraph.create({}, currentNode.content)];
|
|
44
|
+
} else {
|
|
45
|
+
depth = 2;
|
|
46
|
+
content = currentNode.content;
|
|
47
|
+
}
|
|
48
|
+
var newNode = nodeType.create(attrs, content);
|
|
49
|
+
|
|
50
|
+
// Add new node.
|
|
51
|
+
tr = tr.setSelection(new NodeSelection(tr.doc.resolve(start + 1))).replaceSelectionWith(newNode).setSelection(new TextSelection(tr.doc.resolve(start + depth)));
|
|
52
|
+
return tr;
|
|
53
|
+
};
|
|
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
8
8
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
9
|
-
var packageVersion = "74.
|
|
9
|
+
var packageVersion = "74.56.0";
|
|
10
10
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
11
11
|
// Remove URL as it has UGC
|
|
12
12
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -9,7 +9,7 @@ import React, { useMemo, useRef, useState } from 'react';
|
|
|
9
9
|
import classnames from 'classnames';
|
|
10
10
|
import { Resizable } from 're-resizable';
|
|
11
11
|
import Tooltip from '@atlaskit/tooltip';
|
|
12
|
-
import { resizerHandleClassName, resizerHandleThumbClassName, resizerHandleTrackClassName, resizerHandleZIndex, resizerItemClassName } from '../styles/shared/resizer';
|
|
12
|
+
import { resizerDangerClassName, resizerHandleClassName, resizerHandleThumbClassName, resizerHandleTrackClassName, resizerHandleZIndex, resizerItemClassName } from '../styles/shared/resizer';
|
|
13
13
|
export default function ResizerNext(props) {
|
|
14
14
|
var _useState = useState(false),
|
|
15
15
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -100,10 +100,10 @@ export default function ResizerNext(props) {
|
|
|
100
100
|
right: offset
|
|
101
101
|
}, handleStyles === null || handleStyles === void 0 ? void 0 : handleStyles.right)
|
|
102
102
|
};
|
|
103
|
-
var resizerClassName = classnames(className, resizerItemClassName, {
|
|
103
|
+
var resizerClassName = classnames(className, resizerItemClassName, _defineProperty({
|
|
104
104
|
'is-resizing': isResizing,
|
|
105
105
|
'display-handle': isHandleVisible
|
|
106
|
-
}, appearance);
|
|
106
|
+
}, resizerDangerClassName, appearance === 'danger'));
|
|
107
107
|
var finalHandleComponent = useMemo(function () {
|
|
108
108
|
if ((!handleHighlight || handleHighlight === 'none') && !handleTooltipContent && !handleComponent) {
|
|
109
109
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import {
|
|
4
|
+
import { akEditorDeleteIconColor } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { B200, B50, N60 } from '@atlaskit/theme/colors';
|
|
6
6
|
/*
|
|
7
7
|
Styles in this file are based on
|
|
@@ -12,8 +12,9 @@ export var resizerItemClassName = 'resizer-item';
|
|
|
12
12
|
export var resizerHandleClassName = 'resizer-handle';
|
|
13
13
|
export var resizerHandleTrackClassName = "".concat(resizerHandleClassName, "-track");
|
|
14
14
|
export var resizerHandleThumbClassName = "".concat(resizerHandleClassName, "-thumb");
|
|
15
|
+
export var resizerDangerClassName = "".concat(resizerHandleClassName, "-danger");
|
|
15
16
|
|
|
16
17
|
// akEditorSelectedNodeClassName from '@atlaskit/editor-shared-styles';
|
|
17
18
|
var akEditorSelectedNodeClassName = 'ak-editor-selected-node';
|
|
18
19
|
export var resizerHandleZIndex = 99;
|
|
19
|
-
export var resizerStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n will-change: width;\n\n &:hover,\n &.display-handle {\n & .", " {\n visibility: visible;\n opacity: 1;\n }\n }\n\n &.is-resizing {\n & .", " {\n background: ", ";\n }\n }\n\n &.
|
|
20
|
+
export var resizerStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n will-change: width;\n\n &:hover,\n &.display-handle {\n & .", " {\n visibility: visible;\n opacity: 1;\n }\n }\n\n &.is-resizing {\n & .", " {\n background: ", ";\n }\n }\n\n &.", " {\n & .", " {\n transition: none;\n background: ", ";\n }\n }\n }\n\n .", " {\n display: flex;\n visibility: hidden;\n opacity: 0;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n width: 7px;\n transition: visibility 0.2s, opacity 0.2s;\n\n /*\n NOTE: The below style is targeted at the div element added by the tooltip. We don't have any means of injecting styles\n into the tooltip\n */\n & div[role='presentation'] {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n /*\n Handle Positions\n */\n &.left {\n align-items: flex-start;\n }\n &.right {\n align-items: flex-end;\n }\n\n /*\n Handle Sizing\n */\n &.small {\n & .", " {\n height: 43px;\n }\n }\n &.medium {\n & .", " {\n height: 64px;\n }\n }\n &.large {\n & .", " {\n height: 96px;\n }\n }\n\n /*\n Handle Alignment\n */\n &.sticky {\n & .", " {\n position: sticky;\n top: ", ";\n bottom: ", ";\n }\n }\n\n &:hover {\n & .", " {\n background: ", ";\n }\n\n & .", " {\n visibility: visible;\n opacity: 0.5;\n }\n }\n }\n\n .", " {\n content: ' ';\n display: flex;\n width: 3px;\n height: 64px;\n transition: background-color 0.2s;\n border-radius: 6px;\n\n background: ", ";\n }\n\n .", " {\n visibility: hidden;\n position: absolute;\n width: 7px;\n height: calc(100% - 24px);\n border-radius: 4px;\n opacity: 0;\n transition: background-color 0.2s, visibility 0.2s, opacity 0.2s;\n\n &.none {\n background: none;\n }\n\n &.shadow {\n background: ", ";\n }\n }\n\n .", " {\n & .", " {\n background: ", ";\n }\n }\n"])), resizerItemClassName, resizerHandleClassName, resizerHandleThumbClassName, "var(--ds-border-focused, ".concat(B200, ")"), resizerDangerClassName, resizerHandleThumbClassName, "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), resizerHandleClassName, resizerHandleThumbClassName, resizerHandleThumbClassName, resizerHandleThumbClassName, resizerHandleThumbClassName, "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)", resizerHandleThumbClassName, "var(--ds-border-focused, ".concat(B200, ")"), resizerHandleTrackClassName, resizerHandleThumbClassName, "var(--ds-border, ".concat(N60, ")"), resizerHandleTrackClassName, "var(--ds-background-selected, ".concat(B50, ")"), akEditorSelectedNodeClassName, resizerHandleThumbClassName, "var(--ds-border-focused, ".concat(B200, ")"));
|
|
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
|
|
|
18
18
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
19
19
|
import Layer from '../Layer';
|
|
20
20
|
var packageName = "@atlaskit/editor-common";
|
|
21
|
-
var packageVersion = "74.
|
|
21
|
+
var packageVersion = "74.56.0";
|
|
22
22
|
var halfFocusRing = 1;
|
|
23
23
|
var dropOffset = '0, 8';
|
|
24
24
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
+
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { removeBlockMarks } from './editor-core-utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This function creates a new transaction that wraps the current selection
|
|
7
|
+
* in the specified node type if it results in a valid transaction.
|
|
8
|
+
* If not valid, it performs a safe insert operation.
|
|
9
|
+
*
|
|
10
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
11
|
+
* content that is already inside a panel with another panel
|
|
12
|
+
*/
|
|
13
|
+
export function createWrapSelectionTransaction(_ref) {
|
|
14
|
+
var state = _ref.state,
|
|
15
|
+
type = _ref.type,
|
|
16
|
+
nodeAttributes = _ref.nodeAttributes;
|
|
17
|
+
var tr = state.tr;
|
|
18
|
+
var _state$schema$marks = state.schema.marks,
|
|
19
|
+
alignment = _state$schema$marks.alignment,
|
|
20
|
+
indentation = _state$schema$marks.indentation;
|
|
21
|
+
|
|
22
|
+
/** Alignment or Indentation is not valid inside block types */
|
|
23
|
+
var removeAlignTr = removeBlockMarks(state, [alignment, indentation]);
|
|
24
|
+
tr = removeAlignTr || tr;
|
|
25
|
+
|
|
26
|
+
/**Get range and wrapping needed for the selection*/
|
|
27
|
+
var _getWrappingOptions = getWrappingOptions(state, type, nodeAttributes),
|
|
28
|
+
range = _getWrappingOptions.range,
|
|
29
|
+
wrapping = _getWrappingOptions.wrapping;
|
|
30
|
+
if (wrapping) {
|
|
31
|
+
tr.wrap(range, wrapping).scrollIntoView();
|
|
32
|
+
} else {
|
|
33
|
+
/** We always want to append a block type */
|
|
34
|
+
safeInsert(type.createAndFill(nodeAttributes))(tr).scrollIntoView();
|
|
35
|
+
}
|
|
36
|
+
return tr;
|
|
37
|
+
}
|
|
38
|
+
function getWrappingOptions(state, type, nodeAttributes) {
|
|
39
|
+
var _state$selection = state.selection,
|
|
40
|
+
$from = _state$selection.$from,
|
|
41
|
+
$to = _state$selection.$to;
|
|
42
|
+
var range = $from.blockRange($to);
|
|
43
|
+
var isAllowedChild = true;
|
|
44
|
+
/**
|
|
45
|
+
* Added a check to avoid wrapping codeblock
|
|
46
|
+
*/
|
|
47
|
+
if (state.selection.empty) {
|
|
48
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
49
|
+
if (!isAllowedChild) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return isAllowedChild = node.type !== state.schema.nodes.codeBlock;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var wrapping = isAllowedChild && range && findWrapping(range, type, nodeAttributes);
|
|
56
|
+
return {
|
|
57
|
+
range: range,
|
|
58
|
+
wrapping: wrapping
|
|
59
|
+
};
|
|
60
|
+
}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -199,4 +199,6 @@ export function isNodeEmpty(node) {
|
|
|
199
199
|
return !!childNode.childCount && !(childNode.childCount === 1 && isEmptyParagraph(childNode.firstChild)) || childNode.isAtom;
|
|
200
200
|
}).length;
|
|
201
201
|
}
|
|
202
|
-
export { dedupe } from './dedupe';
|
|
202
|
+
export { dedupe } from './dedupe';
|
|
203
|
+
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
204
|
+
export { wrapSelectionIn } from './wrap-selection-in';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
2
|
+
/**
|
|
3
|
+
* Function will add wrapping node.
|
|
4
|
+
* 1. If currently selected blocks can be wrapped in the wrapper type it will wrap them.
|
|
5
|
+
* 2. If current block can not be wrapped inside wrapping block it will create a new block below selection,
|
|
6
|
+
* and set selection on it.
|
|
7
|
+
*/
|
|
8
|
+
export function wrapSelectionIn(type) {
|
|
9
|
+
return function (state, dispatch) {
|
|
10
|
+
var tr = createWrapSelectionTransaction({
|
|
11
|
+
state: state,
|
|
12
|
+
type: type
|
|
13
|
+
});
|
|
14
|
+
if (dispatch) {
|
|
15
|
+
dispatch(tr);
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -16,4 +16,4 @@ export declare const createToggleBlockMarkOnRange: <T extends {} = object>(markT
|
|
|
16
16
|
export declare const toggleBlockMark: <T extends {} = object>(markType: MarkType, getAttrs: (prevAttrs?: T | undefined, node?: PMNode) => false | T | undefined, allowedBlocks?: NodeType[] | ((schema: Schema, node: PMNode, parent: PMNode | null) => boolean) | undefined) => Command;
|
|
17
17
|
export declare const clearEditorContent: Command;
|
|
18
18
|
export declare function findCutBefore($pos: ResolvedPos): ResolvedPos | null;
|
|
19
|
-
export {};
|
|
19
|
+
export { insertBlock } from './insert-block';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const insertBlock: (state: EditorState, nodeType: NodeType, start: number, end: number, attrs?: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
} | undefined) => Transaction | null;
|
|
@@ -2,5 +2,6 @@ export declare const resizerItemClassName = "resizer-item";
|
|
|
2
2
|
export declare const resizerHandleClassName = "resizer-handle";
|
|
3
3
|
export declare const resizerHandleTrackClassName: string;
|
|
4
4
|
export declare const resizerHandleThumbClassName: string;
|
|
5
|
+
export declare const resizerDangerClassName: string;
|
|
5
6
|
export declare const resizerHandleZIndex = 99;
|
|
6
7
|
export declare const resizerStyles: import("@emotion/react").SerializedStyles;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
/**
|
|
4
|
+
* This function creates a new transaction that wraps the current selection
|
|
5
|
+
* in the specified node type if it results in a valid transaction.
|
|
6
|
+
* If not valid, it performs a safe insert operation.
|
|
7
|
+
*
|
|
8
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
9
|
+
* content that is already inside a panel with another panel
|
|
10
|
+
*/
|
|
11
|
+
export declare function createWrapSelectionTransaction({ state, type, nodeAttributes, }: {
|
|
12
|
+
state: EditorState;
|
|
13
|
+
type: NodeType;
|
|
14
|
+
nodeAttributes?: Record<string, any>;
|
|
15
|
+
}): import("prosemirror-state").Transaction;
|
|
@@ -80,3 +80,5 @@ export declare const isEmptyNode: (schema: Schema) => (node: PMNode) => boolean;
|
|
|
80
80
|
*/
|
|
81
81
|
export declare function isNodeEmpty(node?: PMNode): boolean;
|
|
82
82
|
export { dedupe } from './dedupe';
|
|
83
|
+
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
84
|
+
export { wrapSelectionIn } from './wrap-selection-in';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Command } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Function will add wrapping node.
|
|
5
|
+
* 1. If currently selected blocks can be wrapped in the wrapper type it will wrap them.
|
|
6
|
+
* 2. If current block can not be wrapped inside wrapping block it will create a new block below selection,
|
|
7
|
+
* and set selection on it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wrapSelectionIn(type: NodeType): Command;
|
|
@@ -16,4 +16,4 @@ export declare const createToggleBlockMarkOnRange: <T extends {} = object>(markT
|
|
|
16
16
|
export declare const toggleBlockMark: <T extends {} = object>(markType: MarkType, getAttrs: (prevAttrs?: T | undefined, node?: PMNode) => false | T | undefined, allowedBlocks?: NodeType[] | ((schema: Schema, node: PMNode, parent: PMNode | null) => boolean) | undefined) => Command;
|
|
17
17
|
export declare const clearEditorContent: Command;
|
|
18
18
|
export declare function findCutBefore($pos: ResolvedPos): ResolvedPos | null;
|
|
19
|
-
export {};
|
|
19
|
+
export { insertBlock } from './insert-block';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
export declare const insertBlock: (state: EditorState, nodeType: NodeType, start: number, end: number, attrs?: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
} | undefined) => Transaction | null;
|
|
@@ -2,5 +2,6 @@ export declare const resizerItemClassName = "resizer-item";
|
|
|
2
2
|
export declare const resizerHandleClassName = "resizer-handle";
|
|
3
3
|
export declare const resizerHandleTrackClassName: string;
|
|
4
4
|
export declare const resizerHandleThumbClassName: string;
|
|
5
|
+
export declare const resizerDangerClassName: string;
|
|
5
6
|
export declare const resizerHandleZIndex = 99;
|
|
6
7
|
export declare const resizerStyles: import("@emotion/react").SerializedStyles;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
/**
|
|
4
|
+
* This function creates a new transaction that wraps the current selection
|
|
5
|
+
* in the specified node type if it results in a valid transaction.
|
|
6
|
+
* If not valid, it performs a safe insert operation.
|
|
7
|
+
*
|
|
8
|
+
* Example of when wrapping might not be valid is when attempting to wrap
|
|
9
|
+
* content that is already inside a panel with another panel
|
|
10
|
+
*/
|
|
11
|
+
export declare function createWrapSelectionTransaction({ state, type, nodeAttributes, }: {
|
|
12
|
+
state: EditorState;
|
|
13
|
+
type: NodeType;
|
|
14
|
+
nodeAttributes?: Record<string, any>;
|
|
15
|
+
}): import("prosemirror-state").Transaction;
|
|
@@ -80,3 +80,5 @@ export declare const isEmptyNode: (schema: Schema) => (node: PMNode) => boolean;
|
|
|
80
80
|
*/
|
|
81
81
|
export declare function isNodeEmpty(node?: PMNode): boolean;
|
|
82
82
|
export { dedupe } from './dedupe';
|
|
83
|
+
export { createWrapSelectionTransaction } from './create-wrap-selection-transaction';
|
|
84
|
+
export { wrapSelectionIn } from './wrap-selection-in';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Command } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Function will add wrapping node.
|
|
5
|
+
* 1. If currently selected blocks can be wrapped in the wrapper type it will wrap them.
|
|
6
|
+
* 2. If current block can not be wrapped inside wrapping block it will create a new block below selection,
|
|
7
|
+
* and set selection on it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wrapSelectionIn(type: NodeType): Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "74.
|
|
3
|
+
"version": "74.56.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"@atlaskit/link-datasource": "^1.0.0",
|
|
103
103
|
"@atlaskit/link-picker": "^1.28.0",
|
|
104
104
|
"@atlaskit/media-card": "^76.1.0",
|
|
105
|
-
"@atlaskit/media-client": "^23.
|
|
105
|
+
"@atlaskit/media-client": "^23.2.0",
|
|
106
106
|
"@atlaskit/media-picker": "^66.2.0",
|
|
107
107
|
"@atlaskit/mention": "^22.1.0",
|
|
108
108
|
"@atlaskit/menu": "^1.10.0",
|