@atlaskit/editor-common 74.55.2 → 74.56.1
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/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/MediaSingle/index.js +2 -1
- package/dist/cjs/ui/MediaSingle/styled.js +5 -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/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/MediaSingle/index.js +2 -1
- package/dist/es2019/ui/MediaSingle/styled.js +13 -6
- 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/ui/DropList/index.js +1 -1
- package/dist/esm/ui/MediaSingle/index.js +2 -1
- package/dist/esm/ui/MediaSingle/styled.js +5 -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/ui/MediaSingle/styled.d.ts +1 -1
- 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/ui/MediaSingle/styled.d.ts +1 -1
- 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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.56.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2c12cd28cb8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2c12cd28cb8) - Enforce scale-down approach for wide media single node in renderer
|
|
8
|
+
|
|
9
|
+
## 74.56.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`3542bead318`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3542bead318) - Move block type commands to next editor plugin actions
|
|
14
|
+
|
|
3
15
|
## 74.55.2
|
|
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.1";
|
|
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
|
|
@@ -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.1";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -99,7 +99,8 @@ function MediaSingle(_ref) {
|
|
|
99
99
|
layout: layout,
|
|
100
100
|
containerWidth: containerWidth,
|
|
101
101
|
mediaSingleWidth: mediaSingleWidth,
|
|
102
|
-
fullWidthMode: fullWidthMode
|
|
102
|
+
fullWidthMode: fullWidthMode,
|
|
103
|
+
isExtendedResizeExperienceOn: isPixelWidth
|
|
103
104
|
}),
|
|
104
105
|
"data-layout": layout,
|
|
105
106
|
"data-width": mediaSingleWidth,
|
|
@@ -124,7 +124,11 @@ var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref) {
|
|
|
124
124
|
isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
|
|
125
125
|
_ref$isNestedNode = _ref.isNestedNode,
|
|
126
126
|
isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
|
|
127
|
-
return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' &&
|
|
127
|
+
return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] &,\n li & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), isExtendedResizeExperienceOn ? "".concat(mediaSingleWidth || width, "px") : mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' &&
|
|
128
|
+
/* This causes issues for new experience where we don't strip layout attributes
|
|
129
|
+
when copying top-level node and pasting into a table/layout,
|
|
130
|
+
because full-width layout will remain, causing node to be edge-to-edge */
|
|
131
|
+
!isExtendedResizeExperienceOn && (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n min-width: 100%;\n "]))), isExtendedResizeExperienceOn ? "".concat(containerWidth, "px") : calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "&[class*='is-resizing'] {\n .new-file-experience-wrapper {\n box-shadow: none !important;\n }\n\n ".concat(!isNestedNode && _utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), isNestedNode ? /* Make nested node appear responsives when resizing table cell */"max-width: 100%;" : "".concat(_utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);"), float(layout), calcMargin(layout), isImageAligned(layout));
|
|
128
132
|
};
|
|
129
133
|
exports.MediaSingleDimensionHelper = MediaSingleDimensionHelper;
|
|
130
134
|
var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
|
|
@@ -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.1";
|
|
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
|
|
@@ -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.1";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -103,21 +103,27 @@ export const MediaSingleDimensionHelper = ({
|
|
|
103
103
|
pctWidth,
|
|
104
104
|
mediaSingleWidth,
|
|
105
105
|
width,
|
|
106
|
+
// original media width
|
|
106
107
|
isExtendedResizeExperienceOn,
|
|
107
108
|
isNestedNode = false
|
|
108
109
|
}) => css`
|
|
109
110
|
/* For nested rich media items, set max-width to 100% */
|
|
110
111
|
tr &,
|
|
111
112
|
[data-layout-column] &,
|
|
112
|
-
[data-node-type='expand']
|
|
113
|
+
[data-node-type='expand'] &,
|
|
114
|
+
li & {
|
|
113
115
|
max-width: 100%;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
width: ${mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized)};
|
|
117
|
-
${layout === 'full-width' &&
|
|
118
|
+
width: ${isExtendedResizeExperienceOn ? `${mediaSingleWidth || width}px` : mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized)};
|
|
119
|
+
${layout === 'full-width' &&
|
|
120
|
+
/* This causes issues for new experience where we don't strip layout attributes
|
|
121
|
+
when copying top-level node and pasting into a table/layout,
|
|
122
|
+
because full-width layout will remain, causing node to be edge-to-edge */
|
|
123
|
+
!isExtendedResizeExperienceOn && css`
|
|
118
124
|
min-width: 100%;
|
|
119
125
|
`}
|
|
120
|
-
max-width: ${calcMaxWidth(layout, containerWidth)};
|
|
126
|
+
max-width: ${isExtendedResizeExperienceOn ? `${containerWidth}px` : calcMaxWidth(layout, containerWidth)};
|
|
121
127
|
|
|
122
128
|
${isExtendedResizeExperienceOn && `&[class*='is-resizing'] {
|
|
123
129
|
.new-file-experience-wrapper {
|
|
@@ -129,8 +135,9 @@ export const MediaSingleDimensionHelper = ({
|
|
|
129
135
|
}`}
|
|
130
136
|
|
|
131
137
|
&[class*='not-resizing'] {
|
|
132
|
-
${
|
|
133
|
-
|
|
138
|
+
${isNestedNode ? /* Make nested node appear responsives when resizing table cell */
|
|
139
|
+
`max-width: 100%;` : `${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
|
|
140
|
+
transform: translateX(-50%);`}`}
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
float: ${float(layout)};
|
|
@@ -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.1";
|
|
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
|
|
@@ -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.1";
|
|
22
22
|
var halfFocusRing = 1;
|
|
23
23
|
var dropOffset = '0, 8';
|
|
24
24
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -89,7 +89,8 @@ export default function MediaSingle(_ref) {
|
|
|
89
89
|
layout: layout,
|
|
90
90
|
containerWidth: containerWidth,
|
|
91
91
|
mediaSingleWidth: mediaSingleWidth,
|
|
92
|
-
fullWidthMode: fullWidthMode
|
|
92
|
+
fullWidthMode: fullWidthMode,
|
|
93
|
+
isExtendedResizeExperienceOn: isPixelWidth
|
|
93
94
|
}),
|
|
94
95
|
"data-layout": layout,
|
|
95
96
|
"data-width": mediaSingleWidth,
|
|
@@ -115,7 +115,11 @@ export var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref
|
|
|
115
115
|
isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
|
|
116
116
|
_ref$isNestedNode = _ref.isNestedNode,
|
|
117
117
|
isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
|
|
118
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' &&
|
|
118
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] &,\n li & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), isExtendedResizeExperienceOn ? "".concat(mediaSingleWidth || width, "px") : mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' &&
|
|
119
|
+
/* This causes issues for new experience where we don't strip layout attributes
|
|
120
|
+
when copying top-level node and pasting into a table/layout,
|
|
121
|
+
because full-width layout will remain, causing node to be edge-to-edge */
|
|
122
|
+
!isExtendedResizeExperienceOn && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 100%;\n "]))), isExtendedResizeExperienceOn ? "".concat(containerWidth, "px") : calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "&[class*='is-resizing'] {\n .new-file-experience-wrapper {\n box-shadow: none !important;\n }\n\n ".concat(!isNestedNode && nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), isNestedNode ? /* Make nested node appear responsives when resizing table cell */"max-width: 100%;" : "".concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);"), float(layout), calcMargin(layout), isImageAligned(layout));
|
|
119
123
|
};
|
|
120
124
|
var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
|
|
121
125
|
var hasFallbackContainer = _ref2.hasFallbackContainer,
|
|
@@ -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;
|
|
@@ -25,7 +25,7 @@ export interface MediaSingleWrapperProps {
|
|
|
25
25
|
layout: MediaSingleLayout;
|
|
26
26
|
/**
|
|
27
27
|
* @private
|
|
28
|
-
* @deprecated Use {@link MediaSingleWrapperProps
|
|
28
|
+
* @deprecated Use {@link MediaSingleWrapperProps["mediaSingleWidth"]} instead.
|
|
29
29
|
* Cleanup ticket: https://product-fabric.atlassian.net/browse/ED-19076
|
|
30
30
|
*/
|
|
31
31
|
pctWidth?: number;
|
|
@@ -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;
|
|
@@ -25,7 +25,7 @@ export interface MediaSingleWrapperProps {
|
|
|
25
25
|
layout: MediaSingleLayout;
|
|
26
26
|
/**
|
|
27
27
|
* @private
|
|
28
|
-
* @deprecated Use {@link MediaSingleWrapperProps
|
|
28
|
+
* @deprecated Use {@link MediaSingleWrapperProps["mediaSingleWidth"]} instead.
|
|
29
29
|
* Cleanup ticket: https://product-fabric.atlassian.net/browse/ED-19076
|
|
30
30
|
*/
|
|
31
31
|
pctWidth?: number;
|
|
@@ -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