@atlaskit/editor-common 74.38.0 → 74.39.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`021d5f488ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/021d5f488ec) - [ED-16733] Media Plugin Extractation - Move core commands to common entrypoint
8
+
9
+ ## 74.38.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`4cbae03c15c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4cbae03c15c) - Set maxWidth for ResizerNext to stop lable updating when reaching max width
14
+
3
15
  ## 74.38.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/commands",
3
+ "main": "../dist/cjs/commands/index.js",
4
+ "module": "../dist/esm/commands/index.js",
5
+ "module:es2019": "../dist/es2019/commands/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/commands/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/commands/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.addParagraphAtEnd = addParagraphAtEnd;
8
+ exports.clearEditorContent = exports.changeImageAlignment = void 0;
9
+ exports.createParagraphAtEnd = createParagraphAtEnd;
10
+ exports.toggleBlockMark = exports.createToggleBlockMarkOnRange = void 0;
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _state = require("@atlaskit/editor-prosemirror/state");
13
+ var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
14
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ function addParagraphAtEnd(tr) {
17
+ var paragraph = tr.doc.type.schema.nodes.paragraph,
18
+ doc = tr.doc;
19
+ if (doc.lastChild && !(doc.lastChild.type === paragraph && doc.lastChild.content.size === 0)) {
20
+ if (paragraph) {
21
+ tr.insert(doc.content.size, paragraph.createAndFill());
22
+ }
23
+ }
24
+ tr.setSelection(_state.TextSelection.create(tr.doc, tr.doc.content.size - 1));
25
+ tr.scrollIntoView();
26
+ }
27
+ function createParagraphAtEnd() {
28
+ return function (state, dispatch) {
29
+ var tr = state.tr;
30
+ addParagraphAtEnd(tr);
31
+ if (dispatch) {
32
+ dispatch(tr);
33
+ }
34
+ return true;
35
+ };
36
+ }
37
+ var changeImageAlignment = function changeImageAlignment(align) {
38
+ return function (state, dispatch) {
39
+ var _state$selection = state.selection,
40
+ from = _state$selection.from,
41
+ to = _state$selection.to;
42
+ var tr = state.tr;
43
+ state.doc.nodesBetween(from, to, function (node, pos) {
44
+ if (node.type === state.schema.nodes.mediaSingle) {
45
+ tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
46
+ layout: align === 'center' ? 'center' : "align-".concat(align)
47
+ }));
48
+ }
49
+ });
50
+ if (tr.docChanged && dispatch) {
51
+ dispatch(tr.scrollIntoView());
52
+ return true;
53
+ }
54
+ return false;
55
+ };
56
+ };
57
+ exports.changeImageAlignment = changeImageAlignment;
58
+ var createToggleBlockMarkOnRange = function createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks) {
59
+ return function (from, to, tr, state) {
60
+ var markApplied = false;
61
+ state.doc.nodesBetween(from, to, function (node, pos, parent) {
62
+ if (!node.type.isBlock) {
63
+ return false;
64
+ }
65
+ if ((!allowedBlocks || (Array.isArray(allowedBlocks) ? allowedBlocks.indexOf(node.type) > -1 : allowedBlocks(state.schema, node, parent))) && parent !== null && parent !== void 0 && parent.type.allowsMarkType(markType)) {
66
+ var oldMarks = node.marks.filter(function (mark) {
67
+ return mark.type === markType;
68
+ });
69
+ var _prevAttrs = oldMarks.length ? oldMarks[0].attrs : undefined;
70
+ var newAttrs = getAttrs(_prevAttrs, node);
71
+ if (newAttrs !== undefined) {
72
+ tr.setNodeMarkup(pos, node.type, node.attrs, node.marks.filter(function (mark) {
73
+ return !markType.excludes(mark.type);
74
+ }).concat(newAttrs === false ? [] : markType.create(newAttrs)));
75
+ markApplied = true;
76
+ }
77
+ }
78
+ return;
79
+ });
80
+ return markApplied;
81
+ };
82
+ };
83
+
84
+ /**
85
+ * Toggles block mark based on the return type of `getAttrs`.
86
+ * This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
87
+ * return `false` to remove the mark.
88
+ * return `undefined for no-op.
89
+ * return an `object` to update the mark.
90
+ */
91
+ exports.createToggleBlockMarkOnRange = createToggleBlockMarkOnRange;
92
+ var toggleBlockMark = function toggleBlockMark(markType, getAttrs, allowedBlocks) {
93
+ return function (state, dispatch) {
94
+ var markApplied = false;
95
+ var tr = state.tr;
96
+ var toggleBlockMarkOnRange = createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks);
97
+ if (state.selection instanceof _cellSelection.CellSelection) {
98
+ state.selection.forEachCell(function (cell, pos) {
99
+ markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
100
+ });
101
+ } else {
102
+ var _state$selection2 = state.selection,
103
+ from = _state$selection2.from,
104
+ to = _state$selection2.to;
105
+ markApplied = toggleBlockMarkOnRange(from, to, tr, state);
106
+ }
107
+ if (markApplied && tr.docChanged) {
108
+ if (dispatch) {
109
+ dispatch(tr.scrollIntoView());
110
+ }
111
+ return true;
112
+ }
113
+ return false;
114
+ };
115
+ };
116
+ exports.toggleBlockMark = toggleBlockMark;
117
+ var clearEditorContent = function clearEditorContent(state, dispatch) {
118
+ var tr = state.tr;
119
+ tr.replace(0, state.doc.nodeSize - 2);
120
+ tr.setSelection(_state.Selection.atStart(tr.doc));
121
+ if (dispatch) {
122
+ dispatch(tr);
123
+ return true;
124
+ }
125
+ return false;
126
+ };
127
+ exports.clearEditorContent = clearEditorContent;
@@ -97,7 +97,7 @@ var calcLegacyWideWidth = function calcLegacyWideWidth(containerWidth, origWidth
97
97
  };
98
98
 
99
99
  /**
100
- * Calculate maximum width allowed for media single in new experience
100
+ * Calculate maximum width allowed for media single node in fix-width editor in new experience
101
101
  * @param containerWidth width of editor container
102
102
  */
103
103
  var calcMediaSingleMaxWidth = function calcMediaSingleMaxWidth(containerWidth) {
@@ -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.38.0";
19
+ var packageVersion = "74.39.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
@@ -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.38.0";
27
+ var packageVersion = "74.39.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -95,16 +95,6 @@ var getEffectiveFullWidth = function getEffectiveFullWidth(containerWidth, fullW
95
95
  }
96
96
  return "".concat((0, _mediaSingle.calcMediaSingleMaxWidth)(containerWidth), "px");
97
97
  };
98
- var calcMaxWidthWhenResizing = function calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode) {
99
- if (isNestedNode) {
100
- return '100%';
101
- }
102
- // non-nested node can resize up to full width
103
- return getEffectiveFullWidth(containerWidth, fullWidthMode);
104
- };
105
- var calcMaxWidthWhenNotResizing = function calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth) {
106
- return "".concat(Math.min(mediaSingleWidth, containerWidth - _editorSharedStyles.akEditorGutterPadding * 2), "px");
107
- };
108
98
  function calcMargin(layout) {
109
99
  switch (layout) {
110
100
  case 'wrap-right':
@@ -141,7 +131,7 @@ var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref) {
141
131
  isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
142
132
  _ref$isNestedNode = _ref.isNestedNode,
143
133
  isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
144
- 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 /* Handles responsiveness of non-nested, not-resizing nodes in editor */\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' && (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n min-width: 100%;\n "]))), calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "&[class*='is-resizing'] {\n .new-file-experience-wrapper {\n box-shadow: none !important;\n }\n\n max-width: ".concat(calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode), ";\n\n ").concat(_utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), !isNestedNode && "max-width: ".concat(layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth), ";\n\n ").concat(_utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set in old experience\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
134
+ 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' && (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n min-width: 100%;\n "]))), 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 && "".concat(_utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set by ResizerNext inline style\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
145
135
  };
146
136
  exports.MediaSingleDimensionHelper = MediaSingleDimensionHelper;
147
137
  var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
@@ -21,7 +21,7 @@ var nonWrappedLayouts = ['center', 'wide', 'full-width'];
21
21
  exports.nonWrappedLayouts = nonWrappedLayouts;
22
22
  var floatingLayouts = ['wrap-left', 'wrap-right'];
23
23
  exports.floatingLayouts = floatingLayouts;
24
- var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
24
+ var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos, includeMoreParentNodeTypes) {
25
25
  if (typeof pos !== 'number' || isNaN(pos) || !view) {
26
26
  return false;
27
27
  }
@@ -29,8 +29,11 @@ var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, p
29
29
  var _view$state$schema$no = view.state.schema.nodes,
30
30
  expand = _view$state$schema$no.expand,
31
31
  nestedExpand = _view$state$schema$no.nestedExpand,
32
- layoutColumn = _view$state$schema$no.layoutColumn;
33
- return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, [expand, nestedExpand, layoutColumn]);
32
+ layoutColumn = _view$state$schema$no.layoutColumn,
33
+ tableCell = _view$state$schema$no.tableCell,
34
+ listItem = _view$state$schema$no.listItem;
35
+ var parentNodeTypes = [expand, nestedExpand, layoutColumn];
36
+ return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, includeMoreParentNodeTypes ? [].concat(parentNodeTypes, [tableCell, listItem]) : parentNodeTypes);
34
37
  };
35
38
  exports.isRichMediaInsideOfBlockNode = isRichMediaInsideOfBlockNode;
36
39
  var alignAttributes = function alignAttributes(layout, oldAttrs) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.38.0",
3
+ "version": "74.39.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,115 @@
1
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
+ export function addParagraphAtEnd(tr) {
4
+ const {
5
+ doc: {
6
+ type: {
7
+ schema: {
8
+ nodes: {
9
+ paragraph
10
+ }
11
+ }
12
+ }
13
+ },
14
+ doc
15
+ } = tr;
16
+ if (doc.lastChild && !(doc.lastChild.type === paragraph && doc.lastChild.content.size === 0)) {
17
+ if (paragraph) {
18
+ tr.insert(doc.content.size, paragraph.createAndFill());
19
+ }
20
+ }
21
+ tr.setSelection(TextSelection.create(tr.doc, tr.doc.content.size - 1));
22
+ tr.scrollIntoView();
23
+ }
24
+ export function createParagraphAtEnd() {
25
+ return function (state, dispatch) {
26
+ const {
27
+ tr
28
+ } = state;
29
+ addParagraphAtEnd(tr);
30
+ if (dispatch) {
31
+ dispatch(tr);
32
+ }
33
+ return true;
34
+ };
35
+ }
36
+ export const changeImageAlignment = align => (state, dispatch) => {
37
+ const {
38
+ from,
39
+ to
40
+ } = state.selection;
41
+ const tr = state.tr;
42
+ state.doc.nodesBetween(from, to, (node, pos) => {
43
+ if (node.type === state.schema.nodes.mediaSingle) {
44
+ tr.setNodeMarkup(pos, undefined, {
45
+ ...node.attrs,
46
+ layout: align === 'center' ? 'center' : `align-${align}`
47
+ });
48
+ }
49
+ });
50
+ if (tr.docChanged && dispatch) {
51
+ dispatch(tr.scrollIntoView());
52
+ return true;
53
+ }
54
+ return false;
55
+ };
56
+ export const createToggleBlockMarkOnRange = (markType, getAttrs, allowedBlocks) => (from, to, tr, state) => {
57
+ let markApplied = false;
58
+ state.doc.nodesBetween(from, to, (node, pos, parent) => {
59
+ if (!node.type.isBlock) {
60
+ return false;
61
+ }
62
+ if ((!allowedBlocks || (Array.isArray(allowedBlocks) ? allowedBlocks.indexOf(node.type) > -1 : allowedBlocks(state.schema, node, parent))) && parent !== null && parent !== void 0 && parent.type.allowsMarkType(markType)) {
63
+ const oldMarks = node.marks.filter(mark => mark.type === markType);
64
+ const prevAttrs = oldMarks.length ? oldMarks[0].attrs : undefined;
65
+ const newAttrs = getAttrs(prevAttrs, node);
66
+ if (newAttrs !== undefined) {
67
+ tr.setNodeMarkup(pos, node.type, node.attrs, node.marks.filter(mark => !markType.excludes(mark.type)).concat(newAttrs === false ? [] : markType.create(newAttrs)));
68
+ markApplied = true;
69
+ }
70
+ }
71
+ return;
72
+ });
73
+ return markApplied;
74
+ };
75
+
76
+ /**
77
+ * Toggles block mark based on the return type of `getAttrs`.
78
+ * This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
79
+ * return `false` to remove the mark.
80
+ * return `undefined for no-op.
81
+ * return an `object` to update the mark.
82
+ */
83
+ export const toggleBlockMark = (markType, getAttrs, allowedBlocks) => (state, dispatch) => {
84
+ let markApplied = false;
85
+ const tr = state.tr;
86
+ const toggleBlockMarkOnRange = createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks);
87
+ if (state.selection instanceof CellSelection) {
88
+ state.selection.forEachCell((cell, pos) => {
89
+ markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
90
+ });
91
+ } else {
92
+ const {
93
+ from,
94
+ to
95
+ } = state.selection;
96
+ markApplied = toggleBlockMarkOnRange(from, to, tr, state);
97
+ }
98
+ if (markApplied && tr.docChanged) {
99
+ if (dispatch) {
100
+ dispatch(tr.scrollIntoView());
101
+ }
102
+ return true;
103
+ }
104
+ return false;
105
+ };
106
+ export const clearEditorContent = (state, dispatch) => {
107
+ const tr = state.tr;
108
+ tr.replace(0, state.doc.nodeSize - 2);
109
+ tr.setSelection(Selection.atStart(tr.doc));
110
+ if (dispatch) {
111
+ dispatch(tr);
112
+ return true;
113
+ }
114
+ return false;
115
+ };
@@ -84,7 +84,7 @@ const calcLegacyWideWidth = (containerWidth, origWidth, contentWidth) => {
84
84
  };
85
85
 
86
86
  /**
87
- * Calculate maximum width allowed for media single in new experience
87
+ * Calculate maximum width allowed for media single node in fix-width editor in new experience
88
88
  * @param containerWidth width of editor container
89
89
  */
90
90
  export const calcMediaSingleMaxWidth = containerWidth => {
@@ -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.38.0";
3
+ const packageVersion = "74.39.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
@@ -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.38.0";
11
+ const packageVersion = "74.39.0";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
- import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
5
+ import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
6
6
  import { calcMediaSingleMaxWidth } from '../../media-single';
7
7
  import { nonWrappedLayouts } from '../../utils';
8
8
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
@@ -78,16 +78,6 @@ const getEffectiveFullWidth = (containerWidth, fullWidthMode) => {
78
78
  }
79
79
  return `${calcMediaSingleMaxWidth(containerWidth)}px`;
80
80
  };
81
- const calcMaxWidthWhenResizing = (containerWidth, fullWidthMode, isNestedNode) => {
82
- if (isNestedNode) {
83
- return '100%';
84
- }
85
- // non-nested node can resize up to full width
86
- return getEffectiveFullWidth(containerWidth, fullWidthMode);
87
- };
88
- const calcMaxWidthWhenNotResizing = (containerWidth, mediaSingleWidth) => {
89
- return `${Math.min(mediaSingleWidth, containerWidth - akEditorGutterPadding * 2)}px`;
90
- };
91
81
  function calcMargin(layout) {
92
82
  switch (layout) {
93
83
  case 'wrap-right':
@@ -135,25 +125,21 @@ export const MediaSingleDimensionHelper = ({
135
125
  min-width: 100%;
136
126
  `}
137
127
  max-width: ${calcMaxWidth(layout, containerWidth)};
128
+
138
129
  ${isExtendedResizeExperienceOn && `&[class*='is-resizing'] {
139
130
  .new-file-experience-wrapper {
140
131
  box-shadow: none !important;
141
132
  }
142
133
 
143
- max-width: ${calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode)};
144
-
145
- ${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
134
+ ${!isNestedNode && nonWrappedLayouts.includes(layout) && `margin-left: 50%;
146
135
  transform: translateX(-50%);`}
147
136
  }`}
148
137
 
149
- /* Handles responsiveness of non-nested, not-resizing nodes in editor */
150
138
  &[class*='not-resizing'] {
151
- ${!isNestedNode && `max-width: ${layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth)};
152
-
153
- ${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
139
+ ${!isNestedNode && `${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
154
140
  transform: translateX(-50%);`}
155
141
 
156
- // override min-width to counteract max-width set in old experience
142
+ // override min-width to counteract max-width set by ResizerNext inline style
157
143
  ${layout === 'full-width' && `min-width: ${getEffectiveFullWidth(containerWidth, fullWidthMode)} !important;`};`}
158
144
  }
159
145
 
@@ -6,7 +6,7 @@ export const shouldAddDefaultWrappedWidth = (layout, width, lineLength) => {
6
6
  };
7
7
  export const nonWrappedLayouts = ['center', 'wide', 'full-width'];
8
8
  export const floatingLayouts = ['wrap-left', 'wrap-right'];
9
- export const isRichMediaInsideOfBlockNode = (view, pos) => {
9
+ export const isRichMediaInsideOfBlockNode = (view, pos, includeMoreParentNodeTypes) => {
10
10
  if (typeof pos !== 'number' || isNaN(pos) || !view) {
11
11
  return false;
12
12
  }
@@ -14,9 +14,12 @@ export const isRichMediaInsideOfBlockNode = (view, pos) => {
14
14
  const {
15
15
  expand,
16
16
  nestedExpand,
17
- layoutColumn
17
+ layoutColumn,
18
+ tableCell,
19
+ listItem
18
20
  } = view.state.schema.nodes;
19
- return !!findParentNodeOfTypeClosestToPos($pos, [expand, nestedExpand, layoutColumn]);
21
+ const parentNodeTypes = [expand, nestedExpand, layoutColumn];
22
+ return !!findParentNodeOfTypeClosestToPos($pos, includeMoreParentNodeTypes ? [...parentNodeTypes, tableCell, listItem] : parentNodeTypes);
20
23
  };
21
24
  export const alignAttributes = (layout, oldAttrs, gridSize = 12, originalWidth, lineLength) => {
22
25
  let width = oldAttrs.width;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.38.0",
3
+ "version": "74.39.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,113 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
+ export function addParagraphAtEnd(tr) {
7
+ var paragraph = tr.doc.type.schema.nodes.paragraph,
8
+ doc = tr.doc;
9
+ if (doc.lastChild && !(doc.lastChild.type === paragraph && doc.lastChild.content.size === 0)) {
10
+ if (paragraph) {
11
+ tr.insert(doc.content.size, paragraph.createAndFill());
12
+ }
13
+ }
14
+ tr.setSelection(TextSelection.create(tr.doc, tr.doc.content.size - 1));
15
+ tr.scrollIntoView();
16
+ }
17
+ export function createParagraphAtEnd() {
18
+ return function (state, dispatch) {
19
+ var tr = state.tr;
20
+ addParagraphAtEnd(tr);
21
+ if (dispatch) {
22
+ dispatch(tr);
23
+ }
24
+ return true;
25
+ };
26
+ }
27
+ export var changeImageAlignment = function changeImageAlignment(align) {
28
+ return function (state, dispatch) {
29
+ var _state$selection = state.selection,
30
+ from = _state$selection.from,
31
+ to = _state$selection.to;
32
+ var tr = state.tr;
33
+ state.doc.nodesBetween(from, to, function (node, pos) {
34
+ if (node.type === state.schema.nodes.mediaSingle) {
35
+ tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
36
+ layout: align === 'center' ? 'center' : "align-".concat(align)
37
+ }));
38
+ }
39
+ });
40
+ if (tr.docChanged && dispatch) {
41
+ dispatch(tr.scrollIntoView());
42
+ return true;
43
+ }
44
+ return false;
45
+ };
46
+ };
47
+ export var createToggleBlockMarkOnRange = function createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks) {
48
+ return function (from, to, tr, state) {
49
+ var markApplied = false;
50
+ state.doc.nodesBetween(from, to, function (node, pos, parent) {
51
+ if (!node.type.isBlock) {
52
+ return false;
53
+ }
54
+ if ((!allowedBlocks || (Array.isArray(allowedBlocks) ? allowedBlocks.indexOf(node.type) > -1 : allowedBlocks(state.schema, node, parent))) && parent !== null && parent !== void 0 && parent.type.allowsMarkType(markType)) {
55
+ var oldMarks = node.marks.filter(function (mark) {
56
+ return mark.type === markType;
57
+ });
58
+ var _prevAttrs = oldMarks.length ? oldMarks[0].attrs : undefined;
59
+ var newAttrs = getAttrs(_prevAttrs, node);
60
+ if (newAttrs !== undefined) {
61
+ tr.setNodeMarkup(pos, node.type, node.attrs, node.marks.filter(function (mark) {
62
+ return !markType.excludes(mark.type);
63
+ }).concat(newAttrs === false ? [] : markType.create(newAttrs)));
64
+ markApplied = true;
65
+ }
66
+ }
67
+ return;
68
+ });
69
+ return markApplied;
70
+ };
71
+ };
72
+
73
+ /**
74
+ * Toggles block mark based on the return type of `getAttrs`.
75
+ * This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
76
+ * return `false` to remove the mark.
77
+ * return `undefined for no-op.
78
+ * return an `object` to update the mark.
79
+ */
80
+ export var toggleBlockMark = function toggleBlockMark(markType, getAttrs, allowedBlocks) {
81
+ return function (state, dispatch) {
82
+ var markApplied = false;
83
+ var tr = state.tr;
84
+ var toggleBlockMarkOnRange = createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks);
85
+ if (state.selection instanceof CellSelection) {
86
+ state.selection.forEachCell(function (cell, pos) {
87
+ markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
88
+ });
89
+ } else {
90
+ var _state$selection2 = state.selection,
91
+ from = _state$selection2.from,
92
+ to = _state$selection2.to;
93
+ markApplied = toggleBlockMarkOnRange(from, to, tr, state);
94
+ }
95
+ if (markApplied && tr.docChanged) {
96
+ if (dispatch) {
97
+ dispatch(tr.scrollIntoView());
98
+ }
99
+ return true;
100
+ }
101
+ return false;
102
+ };
103
+ };
104
+ export var clearEditorContent = function clearEditorContent(state, dispatch) {
105
+ var tr = state.tr;
106
+ tr.replace(0, state.doc.nodeSize - 2);
107
+ tr.setSelection(Selection.atStart(tr.doc));
108
+ if (dispatch) {
109
+ dispatch(tr);
110
+ return true;
111
+ }
112
+ return false;
113
+ };
@@ -87,7 +87,7 @@ var calcLegacyWideWidth = function calcLegacyWideWidth(containerWidth, origWidth
87
87
  };
88
88
 
89
89
  /**
90
- * Calculate maximum width allowed for media single in new experience
90
+ * Calculate maximum width allowed for media single node in fix-width editor in new experience
91
91
  * @param containerWidth width of editor container
92
92
  */
93
93
  export var calcMediaSingleMaxWidth = function calcMediaSingleMaxWidth(containerWidth) {
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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.38.0";
9
+ var packageVersion = "74.39.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
@@ -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.38.0";
21
+ var packageVersion = "74.39.0";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -6,7 +6,7 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
6
 
7
7
  import React from 'react';
8
8
  import { css, jsx } from '@emotion/react';
9
- import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
9
+ import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { calcMediaSingleMaxWidth } from '../../media-single';
11
11
  import { nonWrappedLayouts } from '../../utils';
12
12
  import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
@@ -86,16 +86,6 @@ var getEffectiveFullWidth = function getEffectiveFullWidth(containerWidth, fullW
86
86
  }
87
87
  return "".concat(calcMediaSingleMaxWidth(containerWidth), "px");
88
88
  };
89
- var calcMaxWidthWhenResizing = function calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode) {
90
- if (isNestedNode) {
91
- return '100%';
92
- }
93
- // non-nested node can resize up to full width
94
- return getEffectiveFullWidth(containerWidth, fullWidthMode);
95
- };
96
- var calcMaxWidthWhenNotResizing = function calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth) {
97
- return "".concat(Math.min(mediaSingleWidth, containerWidth - akEditorGutterPadding * 2), "px");
98
- };
99
89
  function calcMargin(layout) {
100
90
  switch (layout) {
101
91
  case 'wrap-right':
@@ -132,7 +122,7 @@ export var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref
132
122
  isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
133
123
  _ref$isNestedNode = _ref.isNestedNode,
134
124
  isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
135
- 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 /* Handles responsiveness of non-nested, not-resizing nodes in editor */\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' && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 100%;\n "]))), calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "&[class*='is-resizing'] {\n .new-file-experience-wrapper {\n box-shadow: none !important;\n }\n\n max-width: ".concat(calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode), ";\n\n ").concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), !isNestedNode && "max-width: ".concat(layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth), ";\n\n ").concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set in old experience\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
125
+ 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' && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 100%;\n "]))), 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 && "".concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set by ResizerNext inline style\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
136
126
  };
137
127
  var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
138
128
  var hasFallbackContainer = _ref2.hasFallbackContainer,
@@ -9,7 +9,7 @@ export var shouldAddDefaultWrappedWidth = function shouldAddDefaultWrappedWidth(
9
9
  };
10
10
  export var nonWrappedLayouts = ['center', 'wide', 'full-width'];
11
11
  export var floatingLayouts = ['wrap-left', 'wrap-right'];
12
- export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
12
+ export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos, includeMoreParentNodeTypes) {
13
13
  if (typeof pos !== 'number' || isNaN(pos) || !view) {
14
14
  return false;
15
15
  }
@@ -17,8 +17,11 @@ export var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(
17
17
  var _view$state$schema$no = view.state.schema.nodes,
18
18
  expand = _view$state$schema$no.expand,
19
19
  nestedExpand = _view$state$schema$no.nestedExpand,
20
- layoutColumn = _view$state$schema$no.layoutColumn;
21
- return !!findParentNodeOfTypeClosestToPos($pos, [expand, nestedExpand, layoutColumn]);
20
+ layoutColumn = _view$state$schema$no.layoutColumn,
21
+ tableCell = _view$state$schema$no.tableCell,
22
+ listItem = _view$state$schema$no.listItem;
23
+ var parentNodeTypes = [expand, nestedExpand, layoutColumn];
24
+ return !!findParentNodeOfTypeClosestToPos($pos, includeMoreParentNodeTypes ? [].concat(parentNodeTypes, [tableCell, listItem]) : parentNodeTypes);
22
25
  };
23
26
  export var alignAttributes = function alignAttributes(layout, oldAttrs) {
24
27
  var gridSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.38.0",
3
+ "version": "74.39.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,18 @@
1
+ import type { MarkType, NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { Command } from '../types/command';
4
+ type AlignmentState = 'start' | 'end' | 'center';
5
+ export declare function addParagraphAtEnd(tr: Transaction): void;
6
+ export declare function createParagraphAtEnd(): Command;
7
+ export declare const changeImageAlignment: (align?: AlignmentState) => Command;
8
+ export declare const createToggleBlockMarkOnRange: <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) => (from: number, to: number, tr: Transaction, state: EditorState) => boolean;
9
+ /**
10
+ * Toggles block mark based on the return type of `getAttrs`.
11
+ * This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
12
+ * return `false` to remove the mark.
13
+ * return `undefined for no-op.
14
+ * return an `object` to update the mark.
15
+ */
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
+ export declare const clearEditorContent: Command;
18
+ export {};
@@ -34,7 +34,7 @@ export interface calcMediaSinglePixelWidthProps {
34
34
  */
35
35
  export declare const calcMediaSinglePixelWidth: ({ width, widthType, origWidth, layout, contentWidth, containerWidth, gutterOffset, }: calcMediaSinglePixelWidthProps) => number;
36
36
  /**
37
- * Calculate maximum width allowed for media single in new experience
37
+ * Calculate maximum width allowed for media single node in fix-width editor in new experience
38
38
  * @param containerWidth width of editor container
39
39
  */
40
40
  export declare const calcMediaSingleMaxWidth: (containerWidth: number) => number;
@@ -4,6 +4,6 @@ import { SnapPointsProps } from '../types';
4
4
  export declare const shouldAddDefaultWrappedWidth: (layout: RichMediaLayout, width?: number, lineLength?: number) => boolean | 0 | undefined;
5
5
  export declare const nonWrappedLayouts: RichMediaLayout[];
6
6
  export declare const floatingLayouts: string[];
7
- export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean) => boolean;
7
+ export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean, includeMoreParentNodeTypes?: boolean) => boolean;
8
8
  export declare const alignAttributes: (layout: RichMediaLayout, oldAttrs: RichMediaAttributes, gridSize: number | undefined, originalWidth: number, lineLength?: number) => RichMediaAttributes;
9
9
  export declare function calculateSnapPoints({ $pos, akEditorWideLayoutWidth, allowBreakoutSnapPoints, containerWidth, gridSize, gridWidth, insideInlineLike, insideLayout, isVideoFile, lineLength, offsetLeft, wrappedLayout, }: SnapPointsProps): number[];
@@ -0,0 +1,18 @@
1
+ import type { MarkType, NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { Command } from '../types/command';
4
+ type AlignmentState = 'start' | 'end' | 'center';
5
+ export declare function addParagraphAtEnd(tr: Transaction): void;
6
+ export declare function createParagraphAtEnd(): Command;
7
+ export declare const changeImageAlignment: (align?: AlignmentState) => Command;
8
+ export declare const createToggleBlockMarkOnRange: <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) => (from: number, to: number, tr: Transaction, state: EditorState) => boolean;
9
+ /**
10
+ * Toggles block mark based on the return type of `getAttrs`.
11
+ * This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
12
+ * return `false` to remove the mark.
13
+ * return `undefined for no-op.
14
+ * return an `object` to update the mark.
15
+ */
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
+ export declare const clearEditorContent: Command;
18
+ export {};
@@ -34,7 +34,7 @@ export interface calcMediaSinglePixelWidthProps {
34
34
  */
35
35
  export declare const calcMediaSinglePixelWidth: ({ width, widthType, origWidth, layout, contentWidth, containerWidth, gutterOffset, }: calcMediaSinglePixelWidthProps) => number;
36
36
  /**
37
- * Calculate maximum width allowed for media single in new experience
37
+ * Calculate maximum width allowed for media single node in fix-width editor in new experience
38
38
  * @param containerWidth width of editor container
39
39
  */
40
40
  export declare const calcMediaSingleMaxWidth: (containerWidth: number) => number;
@@ -4,6 +4,6 @@ import { SnapPointsProps } from '../types';
4
4
  export declare const shouldAddDefaultWrappedWidth: (layout: RichMediaLayout, width?: number, lineLength?: number) => boolean | 0 | undefined;
5
5
  export declare const nonWrappedLayouts: RichMediaLayout[];
6
6
  export declare const floatingLayouts: string[];
7
- export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean) => boolean;
7
+ export declare const isRichMediaInsideOfBlockNode: (view: EditorView, pos: number | boolean, includeMoreParentNodeTypes?: boolean) => boolean;
8
8
  export declare const alignAttributes: (layout: RichMediaLayout, oldAttrs: RichMediaAttributes, gridSize: number | undefined, originalWidth: number, lineLength?: number) => RichMediaAttributes;
9
9
  export declare function calculateSnapPoints({ $pos, akEditorWideLayoutWidth, allowBreakoutSnapPoints, containerWidth, gridSize, gridWidth, insideInlineLike, insideLayout, isVideoFile, lineLength, offsetLeft, wrappedLayout, }: SnapPointsProps): number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.38.0",
3
+ "version": "74.39.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/"
@@ -76,6 +76,7 @@
76
76
  "./quick-insert": "./src/quick-insert/index.ts",
77
77
  "./link": "./src/link/index.ts",
78
78
  "./mark": "./src/mark/index.ts",
79
+ "./commands": "./src/commands/index.ts",
79
80
  "./lists": "./src/lists/index.ts"
80
81
  },
81
82
  "dependencies": {