@atlaskit/editor-common 74.49.3 → 74.50.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/commands/index.js +28 -2
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/selection/gap-cursor/utils/setGapCursorSelection.js +11 -0
  5. package/dist/cjs/selection/index.js +7 -0
  6. package/dist/cjs/ui/DropList/index.js +1 -1
  7. package/dist/es2019/commands/index.js +25 -1
  8. package/dist/es2019/monitoring/error.js +1 -1
  9. package/dist/es2019/selection/gap-cursor/utils/setGapCursorSelection.js +7 -0
  10. package/dist/es2019/selection/index.js +1 -0
  11. package/dist/es2019/ui/DropList/index.js +1 -1
  12. package/dist/esm/commands/index.js +25 -1
  13. package/dist/esm/monitoring/error.js +1 -1
  14. package/dist/esm/selection/gap-cursor/utils/setGapCursorSelection.js +5 -0
  15. package/dist/esm/selection/index.js +1 -0
  16. package/dist/esm/ui/DropList/index.js +1 -1
  17. package/dist/types/commands/index.d.ts +2 -1
  18. package/dist/types/selection/gap-cursor/selection.d.ts +3 -2
  19. package/dist/types/selection/gap-cursor/utils/is-ignored.d.ts +1 -1
  20. package/dist/types/selection/gap-cursor/utils/is-valid-target-node.d.ts +1 -1
  21. package/dist/types/selection/gap-cursor/utils/setGapCursorSelection.d.ts +3 -0
  22. package/dist/types/selection/index.d.ts +1 -0
  23. package/dist/types-ts4.5/commands/index.d.ts +2 -1
  24. package/dist/types-ts4.5/selection/gap-cursor/selection.d.ts +3 -2
  25. package/dist/types-ts4.5/selection/gap-cursor/utils/is-ignored.d.ts +1 -1
  26. package/dist/types-ts4.5/selection/gap-cursor/utils/is-valid-target-node.d.ts +1 -1
  27. package/dist/types-ts4.5/selection/gap-cursor/utils/setGapCursorSelection.d.ts +3 -0
  28. package/dist/types-ts4.5/selection/index.d.ts +1 -0
  29. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.50.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8e9c21af71d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8e9c21af71d) - Extracting list plugin code from editor-core to @atlaskit/editor-plugin-list.
8
+
3
9
  ## 74.49.3
4
10
 
5
11
  ### Patch Changes
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.addParagraphAtEnd = addParagraphAtEnd;
8
8
  exports.clearEditorContent = exports.changeImageAlignment = void 0;
9
9
  exports.createParagraphAtEnd = createParagraphAtEnd;
10
- exports.toggleBlockMark = exports.createToggleBlockMarkOnRange = void 0;
10
+ exports.createToggleBlockMarkOnRange = void 0;
11
+ exports.findCutBefore = findCutBefore;
12
+ exports.toggleBlockMark = void 0;
11
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
14
  var _state = require("@atlaskit/editor-prosemirror/state");
13
15
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
@@ -124,4 +126,28 @@ var clearEditorContent = function clearEditorContent(state, dispatch) {
124
126
  }
125
127
  return false;
126
128
  };
127
- exports.clearEditorContent = clearEditorContent;
129
+
130
+ // https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L90
131
+ // Keep going left up the tree, without going across isolating boundaries, until we
132
+ // can go along the tree at that same level
133
+ //
134
+ // You can think of this as, if you could construct each document like we do in the tests,
135
+ // return the position of the first ) backwards from the current selection.
136
+ exports.clearEditorContent = clearEditorContent;
137
+ function findCutBefore($pos) {
138
+ // parent is non-isolating, so we can look across this boundary
139
+ if (!$pos.parent.type.spec.isolating) {
140
+ // search up the tree from the pos's *parent*
141
+ for (var i = $pos.depth - 1; i >= 0; i--) {
142
+ // starting from the inner most node's parent, find out
143
+ // if we're not its first child
144
+ if ($pos.index(i) > 0) {
145
+ return $pos.doc.resolve($pos.before(i + 1));
146
+ }
147
+ if ($pos.node(i).type.spec.isolating) {
148
+ break;
149
+ }
150
+ }
151
+ }
152
+ return null;
153
+ }
@@ -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.49.3";
19
+ var packageVersion = "74.50.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
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setGapCursorSelection = setGapCursorSelection;
7
+ var _selection = require("../selection");
8
+ function setGapCursorSelection(view, pos, side) {
9
+ var state = view.state;
10
+ view.dispatch(state.tr.setSelection(new _selection.GapCursorSelection(state.doc.resolve(pos), side)));
11
+ }
@@ -87,6 +87,12 @@ Object.defineProperty(exports, "isValidTargetNode", {
87
87
  return _utils.isValidTargetNode;
88
88
  }
89
89
  });
90
+ Object.defineProperty(exports, "setGapCursorSelection", {
91
+ enumerable: true,
92
+ get: function get() {
93
+ return _setGapCursorSelection.setGapCursorSelection;
94
+ }
95
+ });
90
96
  Object.defineProperty(exports, "startPositionOfParent", {
91
97
  enumerable: true,
92
98
  get: function get() {
@@ -96,4 +102,5 @@ Object.defineProperty(exports, "startPositionOfParent", {
96
102
  var _types = require("./types");
97
103
  var _selection = require("./gap-cursor/selection");
98
104
  var _utils = require("./gap-cursor/utils");
105
+ var _setGapCursorSelection = require("./gap-cursor/utils/setGapCursorSelection");
99
106
  var _utils2 = require("./utils");
@@ -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.49.3";
27
+ var packageVersion = "74.50.0";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -112,4 +112,28 @@ export const clearEditorContent = (state, dispatch) => {
112
112
  return true;
113
113
  }
114
114
  return false;
115
- };
115
+ };
116
+
117
+ // https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L90
118
+ // Keep going left up the tree, without going across isolating boundaries, until we
119
+ // can go along the tree at that same level
120
+ //
121
+ // You can think of this as, if you could construct each document like we do in the tests,
122
+ // return the position of the first ) backwards from the current selection.
123
+ export function findCutBefore($pos) {
124
+ // parent is non-isolating, so we can look across this boundary
125
+ if (!$pos.parent.type.spec.isolating) {
126
+ // search up the tree from the pos's *parent*
127
+ for (let i = $pos.depth - 1; i >= 0; i--) {
128
+ // starting from the inner most node's parent, find out
129
+ // if we're not its first child
130
+ if ($pos.index(i) > 0) {
131
+ return $pos.doc.resolve($pos.before(i + 1));
132
+ }
133
+ if ($pos.node(i).type.spec.isolating) {
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ return null;
139
+ }
@@ -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.49.3";
3
+ const packageVersion = "74.50.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
@@ -0,0 +1,7 @@
1
+ import { GapCursorSelection } from '../selection';
2
+ export function setGapCursorSelection(view, pos, side) {
3
+ const {
4
+ state
5
+ } = view;
6
+ view.dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), side)));
7
+ }
@@ -1,4 +1,5 @@
1
1
  export { RelativeSelectionPos } from './types';
2
2
  export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
3
3
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
4
+ export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
4
5
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
@@ -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.49.3";
11
+ const packageVersion = "74.50.0";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -110,4 +110,28 @@ export var clearEditorContent = function clearEditorContent(state, dispatch) {
110
110
  return true;
111
111
  }
112
112
  return false;
113
- };
113
+ };
114
+
115
+ // https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L90
116
+ // Keep going left up the tree, without going across isolating boundaries, until we
117
+ // can go along the tree at that same level
118
+ //
119
+ // You can think of this as, if you could construct each document like we do in the tests,
120
+ // return the position of the first ) backwards from the current selection.
121
+ export function findCutBefore($pos) {
122
+ // parent is non-isolating, so we can look across this boundary
123
+ if (!$pos.parent.type.spec.isolating) {
124
+ // search up the tree from the pos's *parent*
125
+ for (var i = $pos.depth - 1; i >= 0; i--) {
126
+ // starting from the inner most node's parent, find out
127
+ // if we're not its first child
128
+ if ($pos.index(i) > 0) {
129
+ return $pos.doc.resolve($pos.before(i + 1));
130
+ }
131
+ if ($pos.node(i).type.spec.isolating) {
132
+ break;
133
+ }
134
+ }
135
+ }
136
+ return null;
137
+ }
@@ -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.49.3";
9
+ var packageVersion = "74.50.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
@@ -0,0 +1,5 @@
1
+ import { GapCursorSelection } from '../selection';
2
+ export function setGapCursorSelection(view, pos, side) {
3
+ var state = view.state;
4
+ view.dispatch(state.tr.setSelection(new GapCursorSelection(state.doc.resolve(pos), side)));
5
+ }
@@ -1,4 +1,5 @@
1
1
  export { RelativeSelectionPos } from './types';
2
2
  export { GapCursorSelection, Side, JSON_ID, GapBookmark } from './gap-cursor/selection';
3
3
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
4
+ export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
4
5
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent } from './utils';
@@ -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.49.3";
21
+ var packageVersion = "74.50.0";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,4 +1,4 @@
1
- import type { MarkType, NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { MarkType, NodeType, Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { Command } from '../types/command';
4
4
  type AlignmentState = 'start' | 'end' | 'center';
@@ -15,4 +15,5 @@ export declare const createToggleBlockMarkOnRange: <T extends {} = object>(markT
15
15
  */
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
+ export declare function findCutBefore($pos: ResolvedPos): ResolvedPos | null;
18
19
  export {};
@@ -1,6 +1,7 @@
1
- import { Node as PMNode, ResolvedPos, Slice } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import { Slice } from '@atlaskit/editor-prosemirror/model';
2
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
3
- import { Mapping } from '@atlaskit/editor-prosemirror/transform';
4
+ import type { Mapping } from '@atlaskit/editor-prosemirror/transform';
4
5
  export declare enum Side {
5
6
  LEFT = "left",
6
7
  RIGHT = "right"
@@ -1,2 +1,2 @@
1
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare const isIgnored: (node?: PMNode | null) => boolean;
@@ -1,2 +1,2 @@
1
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare const isValidTargetNode: (node?: PMNode | null) => boolean;
@@ -0,0 +1,3 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { Side } from '../selection';
3
+ export declare function setGapCursorSelection(view: EditorView, pos: number, side: Side): void;
@@ -2,4 +2,5 @@ export { RelativeSelectionPos } from './types';
2
2
  export type { SelectionPluginState, EditorSelectionAPI } from './types';
3
3
  export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
4
4
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
5
+ export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
5
6
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
@@ -1,4 +1,4 @@
1
- import type { MarkType, NodeType, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
1
+ import type { MarkType, NodeType, Node as PMNode, ResolvedPos, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { Command } from '../types/command';
4
4
  type AlignmentState = 'start' | 'end' | 'center';
@@ -15,4 +15,5 @@ export declare const createToggleBlockMarkOnRange: <T extends {} = object>(markT
15
15
  */
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
+ export declare function findCutBefore($pos: ResolvedPos): ResolvedPos | null;
18
19
  export {};
@@ -1,6 +1,7 @@
1
- import { Node as PMNode, ResolvedPos, Slice } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ import { Slice } from '@atlaskit/editor-prosemirror/model';
2
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
3
- import { Mapping } from '@atlaskit/editor-prosemirror/transform';
4
+ import type { Mapping } from '@atlaskit/editor-prosemirror/transform';
4
5
  export declare enum Side {
5
6
  LEFT = "left",
6
7
  RIGHT = "right"
@@ -1,2 +1,2 @@
1
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare const isIgnored: (node?: PMNode | null) => boolean;
@@ -1,2 +1,2 @@
1
- import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  export declare const isValidTargetNode: (node?: PMNode | null) => boolean;
@@ -0,0 +1,3 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ import type { Side } from '../selection';
3
+ export declare function setGapCursorSelection(view: EditorView, pos: number, side: Side): void;
@@ -2,4 +2,5 @@ export { RelativeSelectionPos } from './types';
2
2
  export type { SelectionPluginState, EditorSelectionAPI } from './types';
3
3
  export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection';
4
4
  export { isIgnored, isValidTargetNode } from './gap-cursor/utils';
5
+ export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection';
5
6
  export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.49.3",
3
+ "version": "74.50.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/"