@atlaskit/editor-common 74.33.0 → 74.34.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 (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/keymaps/index.js +8 -1
  3. package/dist/cjs/keymaps/keymap.js +38 -0
  4. package/dist/cjs/monitoring/error.js +1 -1
  5. package/dist/cjs/ui/DropList/index.js +1 -1
  6. package/dist/cjs/utils/commands.js +180 -15
  7. package/dist/cjs/utils/editor-core-utils.js +53 -3
  8. package/dist/cjs/utils/index.js +48 -0
  9. package/dist/cjs/utils/input-rules.js +48 -2
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/keymaps/index.js +3 -2
  12. package/dist/es2019/keymaps/keymap.js +33 -0
  13. package/dist/es2019/monitoring/error.js +1 -1
  14. package/dist/es2019/ui/DropList/index.js +1 -1
  15. package/dist/es2019/utils/commands.js +173 -2
  16. package/dist/es2019/utils/editor-core-utils.js +46 -1
  17. package/dist/es2019/utils/index.js +3 -3
  18. package/dist/es2019/utils/input-rules.js +45 -0
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/keymaps/index.js +3 -2
  21. package/dist/esm/keymaps/keymap.js +33 -0
  22. package/dist/esm/monitoring/error.js +1 -1
  23. package/dist/esm/ui/DropList/index.js +1 -1
  24. package/dist/esm/utils/commands.js +170 -14
  25. package/dist/esm/utils/editor-core-utils.js +47 -0
  26. package/dist/esm/utils/index.js +3 -3
  27. package/dist/esm/utils/input-rules.js +44 -0
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/keymaps/index.d.ts +1 -0
  30. package/dist/types/keymaps/keymap.d.ts +11 -0
  31. package/dist/types/types/block-type.d.ts +1 -0
  32. package/dist/types/types/index.d.ts +1 -1
  33. package/dist/types/utils/commands.d.ts +11 -5
  34. package/dist/types/utils/editor-core-utils.d.ts +7 -2
  35. package/dist/types/utils/index.d.ts +3 -3
  36. package/dist/types/utils/input-rules.d.ts +12 -4
  37. package/dist/types-ts4.5/keymaps/index.d.ts +1 -0
  38. package/dist/types-ts4.5/keymaps/keymap.d.ts +11 -0
  39. package/dist/types-ts4.5/types/block-type.d.ts +1 -0
  40. package/dist/types-ts4.5/types/index.d.ts +1 -1
  41. package/dist/types-ts4.5/utils/commands.d.ts +11 -5
  42. package/dist/types-ts4.5/utils/editor-core-utils.d.ts +7 -2
  43. package/dist/types-ts4.5/utils/index.d.ts +3 -3
  44. package/dist/types-ts4.5/utils/input-rules.d.ts +12 -4
  45. package/package.json +4 -3
@@ -3,7 +3,7 @@ export { getExtensionLozengeData } from './macro';
3
3
  export { default as browser } from './browser';
4
4
  export { default as ErrorReporter } from './error-reporter';
5
5
  export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC } from './date';
6
- export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn } from './editor-core-utils';
6
+ export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween } from './editor-core-utils';
7
7
  export { withImageLoader } from './imageLoader';
8
8
  export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle } from './breakout';
9
9
  export { findChangedNodesFromTransaction, validNode, validateNodes, isType, isParagraph, isText, isLinkMark, SelectedState, isNodeSelectedOrInRange, isSupportedInParent, isMediaNode, isNodeBeforeMediaNode } from './nodes';
@@ -45,7 +45,7 @@ export { nodesBetweenChanged, getStepRange, isEmptyDocument, processRawValue, ha
45
45
  export { floatingLayouts, isRichMediaInsideOfBlockNode, calculateSnapPoints, alignAttributes, nonWrappedLayouts } from './rich-media-utils';
46
46
  export { sanitizeNodeForPrivacy } from './filter/privacy-filter';
47
47
  export { canRenderDatasource } from './datasource';
48
- export { filterCommand, walkPrevNode, walkNextNode, isEmptySelectionAtStart, isEmptySelectionAtEnd, insertContentDeleteRange, deleteEmptyParagraphAndMoveBlockUp } from './commands';
48
+ export { filterCommand, isEmptySelectionAtStart, isEmptySelectionAtEnd, insertContentDeleteRange, deleteEmptyParagraphAndMoveBlockUp, insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, createParagraphNear, walkNextNode, walkPrevNode } from './commands';
49
49
  export function shallowEqual() {
50
50
  var obj1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
51
51
  var obj2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -55,4 +55,4 @@ export function shallowEqual() {
55
55
  return acc && obj1[key] === obj2[key];
56
56
  }, true);
57
57
  }
58
- export { inputRuleWithAnalytics } from './input-rules';
58
+ export { inputRuleWithAnalytics, createWrappingJoinRule, createRule } from './input-rules';
@@ -1,6 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
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 { closeHistory } from '@atlaskit/editor-prosemirror/history';
5
+ import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
6
+ import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '../analytics';
4
7
  // Roughly based on atlassian-frontend/packages/editor/editor-core/src/utils/input-rules.ts but with the Editor Analytics API that's injected in plugins
5
8
  export var inputRuleWithAnalytics = function inputRuleWithAnalytics(getPayload, analyticsApi) {
6
9
  return function (originalRule) {
@@ -15,4 +18,45 @@ export var inputRuleWithAnalytics = function inputRuleWithAnalytics(getPayload,
15
18
  onHandlerApply: onHandlerApply
16
19
  });
17
20
  };
21
+ };
22
+ export var createWrappingJoinRule = function createWrappingJoinRule(_ref) {
23
+ var match = _ref.match,
24
+ nodeType = _ref.nodeType,
25
+ getAttrs = _ref.getAttrs,
26
+ joinPredicate = _ref.joinPredicate;
27
+ var handler = function handler(state, match, start, end) {
28
+ var attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
29
+ var tr = state.tr;
30
+ var fixedStart = Math.max(start, 1);
31
+ tr.delete(fixedStart, end);
32
+ var $start = tr.doc.resolve(fixedStart);
33
+ var range = $start.blockRange();
34
+ var wrapping = range && findWrapping(range, nodeType, attrs);
35
+ if (!wrapping || !range) {
36
+ return null;
37
+ }
38
+ var parentNodePosMapped = tr.mapping.map(range.start);
39
+ var parentNode = tr.doc.nodeAt(parentNodePosMapped);
40
+ var lastWrap = wrapping[wrapping.length - 1];
41
+ if (parentNode && lastWrap) {
42
+ var allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
43
+ tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
44
+ }
45
+ tr.wrap(range, wrapping);
46
+ var before = tr.doc.resolve(fixedStart - 1).nodeBefore;
47
+ if (before && before.type === nodeType && canJoin(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
48
+ tr.join(fixedStart - 1);
49
+ }
50
+ return tr;
51
+ };
52
+ return createRule(match, handler);
53
+ };
54
+ export var createRule = function createRule(match, handler) {
55
+ return {
56
+ match: match,
57
+ handler: handler,
58
+ onHandlerApply: function onHandlerApply(_state, tr) {
59
+ closeHistory(tr);
60
+ }
61
+ };
18
62
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.33.0",
3
+ "version": "74.34.0",
4
4
  "sideEffects": false
5
5
  }
@@ -89,3 +89,4 @@ export declare function bindKeymapWithCommand(shortcut: string, cmd: Command, ke
89
89
  }): void;
90
90
  export declare function findKeyMapForBrowser(keyMap: Keymap): string | undefined;
91
91
  export { DOWN, HEADING_KEYS, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, LEFT, RIGHT, UP, } from './consts';
92
+ export { keymap } from './keymap';
@@ -0,0 +1,11 @@
1
+ import { SafePlugin } from '../safe-plugin';
2
+ /**
3
+ * A workaround for mostly Cyrillic but should have a positive affect
4
+ * on other languages / layouts. Attempts a similar approach to OS X.
5
+ * @see ED-7310
6
+ * @see https://github.com/ProseMirror/prosemirror/issues/957
7
+ * @param bindings
8
+ */
9
+ export declare function keymap(bindings: {
10
+ [key: string]: any;
11
+ }): SafePlugin<any>;
@@ -1,3 +1,4 @@
1
1
  export type HeadingLevels = 1 | 2 | 3 | 4 | 5 | 6;
2
2
  export type NormalTextLevel = 0;
3
3
  export type HeadingLevelsAndNormalText = HeadingLevels | NormalTextLevel;
4
+ export type AllowedBlockTypes = 'heading' | 'blockquote' | 'hardBreak' | 'codeBlock';
@@ -39,6 +39,6 @@ export type { SnapPointsProps } from './resizable-media-single';
39
39
  export type { BreakoutMode } from './breakout';
40
40
  export type { DatasourceModalType } from './datasource';
41
41
  export type { ImageUploadPluginReferenceEventBase, ImageUploadPluginReferenceEventDragEvent, ImageUploadPluginReferenceEventClipboardEvent, ImageUploadPluginReferenceEvent, } from './image-upload-reference-event';
42
- export type { HeadingLevels, NormalTextLevel, HeadingLevelsAndNormalText, } from './block-type';
42
+ export type { AllowedBlockTypes, HeadingLevels, NormalTextLevel, HeadingLevelsAndNormalText, } from './block-type';
43
43
  export type { ColumnResizingPluginState } from './tables';
44
44
  export type { InputRuleHandler, OnHandlerApply, InputRuleWrapper, } from './input-rules';
@@ -1,13 +1,12 @@
1
- import type { Fragment, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import { Fragment, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { Command } from '../types';
3
+ import { EditorAnalyticsAPI } from '../analytics';
4
+ import type { Command, Predicate } from '../types';
5
5
  export type WalkNode = {
6
6
  $pos: ResolvedPos;
7
7
  foundNode: boolean;
8
8
  };
9
- type Predicate = (state: EditorState, view?: EditorView) => boolean;
10
- declare const filter: (predicates: Predicate[] | Predicate, cmd: Command) => Command;
9
+ export declare const filter: (predicates: Predicate[] | Predicate, cmd: Command) => Command;
11
10
  /**
12
11
  * Walk forwards from a position until we encounter the (inside) start of
13
12
  * the next node, or reach the end of the document.
@@ -22,6 +21,13 @@ export declare const walkNextNode: ($startPos: ResolvedPos) => WalkNode;
22
21
  * @param $startPos Position to start walking from.
23
22
  */
24
23
  export declare const walkPrevNode: ($startPos: ResolvedPos) => WalkNode;
24
+ export declare function insertNewLine(): Command;
25
+ export declare const insertNewLineWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
26
+ export declare const createNewParagraphAbove: Command;
27
+ export declare const createNewParagraphBelow: Command;
28
+ export declare function createParagraphNear(append?: boolean): Command;
29
+ export declare function atTheEndOfDoc(state: EditorState): boolean;
30
+ export declare function atTheBeginningOfDoc(state: EditorState): boolean;
25
31
  /**
26
32
  * If the selection is empty, is inside a paragraph node and `canNextNodeMoveUp` is true then delete current paragraph
27
33
  * and move the node below it up. The selection will be retained, to be placed in the moved node.
@@ -1,5 +1,5 @@
1
- import { Node, NodeType, Slice } from '@atlaskit/editor-prosemirror/model';
2
- import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
1
+ import { MarkType, Node, NodeType, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import { EditorState, Selection, TextSelection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import { Step } from '@atlaskit/editor-prosemirror/transform';
4
4
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  /**
@@ -27,3 +27,8 @@ export declare function setTextSelection(view: EditorView, anchor: number, head?
27
27
  export declare function nonNullable<T>(value: T): value is NonNullable<T>;
28
28
  export declare const isValidPosition: (pos: number | undefined, state: EditorState) => boolean;
29
29
  export declare const isInLayoutColumn: (state: EditorState) => boolean;
30
+ export declare function filterChildrenBetween(doc: Node, from: number, to: number, predicate: (node: Node, pos: number, parent: Node | null) => boolean | undefined): {
31
+ node: Node;
32
+ pos: number;
33
+ }[];
34
+ export declare const removeBlockMarks: (state: EditorState, marks: Array<MarkType | undefined>) => Transaction | undefined;
@@ -6,7 +6,7 @@ export { default as ErrorReporter } from './error-reporter';
6
6
  export type { ErrorReportingHandler } from './error-reporter';
7
7
  export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC, } from './date';
8
8
  export type { Date } from './date';
9
- export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, } from './editor-core-utils';
9
+ export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween, } from './editor-core-utils';
10
10
  export { withImageLoader } from './imageLoader';
11
11
  export type { ImageLoaderProps, ImageLoaderState, ImageStatus, } from './imageLoader';
12
12
  export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle, } from './breakout';
@@ -55,7 +55,7 @@ export { nodesBetweenChanged, getStepRange, isEmptyDocument, processRawValue, ha
55
55
  export { floatingLayouts, isRichMediaInsideOfBlockNode, calculateSnapPoints, alignAttributes, nonWrappedLayouts, } from './rich-media-utils';
56
56
  export { sanitizeNodeForPrivacy } from './filter/privacy-filter';
57
57
  export { canRenderDatasource } from './datasource';
58
- export { filterCommand, walkPrevNode, walkNextNode, isEmptySelectionAtStart, isEmptySelectionAtEnd, insertContentDeleteRange, deleteEmptyParagraphAndMoveBlockUp, } from './commands';
58
+ export { filterCommand, isEmptySelectionAtStart, isEmptySelectionAtEnd, insertContentDeleteRange, deleteEmptyParagraphAndMoveBlockUp, insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, createParagraphNear, walkNextNode, walkPrevNode, } from './commands';
59
59
  export type { WalkNode } from './commands';
60
60
  export declare function shallowEqual(obj1?: any, obj2?: any): boolean;
61
- export { inputRuleWithAnalytics } from './input-rules';
61
+ export { inputRuleWithAnalytics, createWrappingJoinRule, createRule, } from './input-rules';
@@ -1,7 +1,15 @@
1
- import type { EditorState } from 'prosemirror-state';
2
- import type { EditorAnalyticsAPI } from '../analytics';
3
- import type { AnalyticsEventPayload } from '../analytics/types';
4
- import type { InputRuleWrapper } from '../types/input-rules';
1
+ import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import { type AnalyticsEventPayload, type EditorAnalyticsAPI, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '../analytics';
4
+ import { InputRuleHandler, InputRuleWrapper } from '../types';
5
5
  type GetPayload = AnalyticsEventPayload | ((state: EditorState, matchResult: RegExpExecArray) => AnalyticsEventPayload);
6
6
  export declare const inputRuleWithAnalytics: (getPayload: GetPayload, analyticsApi: EditorAnalyticsAPI | undefined) => (originalRule: InputRuleWrapper) => InputRuleWrapper;
7
+ type WrappingRuleProps = {
8
+ match: RegExp;
9
+ nodeType: NodeType;
10
+ getAttrs?: Record<string, any> | ((matchResult: RegExpExecArray) => Record<string, any>);
11
+ joinPredicate?: (matchResult: RegExpExecArray, node: PMNode, joinScenario: JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST) => boolean;
12
+ };
13
+ export declare const createWrappingJoinRule: ({ match, nodeType, getAttrs, joinPredicate, }: WrappingRuleProps) => InputRuleWrapper;
14
+ export declare const createRule: (match: RegExp, handler: InputRuleHandler) => InputRuleWrapper;
7
15
  export {};
@@ -89,3 +89,4 @@ export declare function bindKeymapWithCommand(shortcut: string, cmd: Command, ke
89
89
  }): void;
90
90
  export declare function findKeyMapForBrowser(keyMap: Keymap): string | undefined;
91
91
  export { DOWN, HEADING_KEYS, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, LEFT, RIGHT, UP, } from './consts';
92
+ export { keymap } from './keymap';
@@ -0,0 +1,11 @@
1
+ import { SafePlugin } from '../safe-plugin';
2
+ /**
3
+ * A workaround for mostly Cyrillic but should have a positive affect
4
+ * on other languages / layouts. Attempts a similar approach to OS X.
5
+ * @see ED-7310
6
+ * @see https://github.com/ProseMirror/prosemirror/issues/957
7
+ * @param bindings
8
+ */
9
+ export declare function keymap(bindings: {
10
+ [key: string]: any;
11
+ }): SafePlugin<any>;
@@ -1,3 +1,4 @@
1
1
  export type HeadingLevels = 1 | 2 | 3 | 4 | 5 | 6;
2
2
  export type NormalTextLevel = 0;
3
3
  export type HeadingLevelsAndNormalText = HeadingLevels | NormalTextLevel;
4
+ export type AllowedBlockTypes = 'heading' | 'blockquote' | 'hardBreak' | 'codeBlock';
@@ -39,6 +39,6 @@ export type { SnapPointsProps } from './resizable-media-single';
39
39
  export type { BreakoutMode } from './breakout';
40
40
  export type { DatasourceModalType } from './datasource';
41
41
  export type { ImageUploadPluginReferenceEventBase, ImageUploadPluginReferenceEventDragEvent, ImageUploadPluginReferenceEventClipboardEvent, ImageUploadPluginReferenceEvent, } from './image-upload-reference-event';
42
- export type { HeadingLevels, NormalTextLevel, HeadingLevelsAndNormalText, } from './block-type';
42
+ export type { AllowedBlockTypes, HeadingLevels, NormalTextLevel, HeadingLevelsAndNormalText, } from './block-type';
43
43
  export type { ColumnResizingPluginState } from './tables';
44
44
  export type { InputRuleHandler, OnHandlerApply, InputRuleWrapper, } from './input-rules';
@@ -1,13 +1,12 @@
1
- import type { Fragment, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
1
+ import { Fragment, Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
4
- import type { Command } from '../types';
3
+ import { EditorAnalyticsAPI } from '../analytics';
4
+ import type { Command, Predicate } from '../types';
5
5
  export type WalkNode = {
6
6
  $pos: ResolvedPos;
7
7
  foundNode: boolean;
8
8
  };
9
- type Predicate = (state: EditorState, view?: EditorView) => boolean;
10
- declare const filter: (predicates: Predicate[] | Predicate, cmd: Command) => Command;
9
+ export declare const filter: (predicates: Predicate[] | Predicate, cmd: Command) => Command;
11
10
  /**
12
11
  * Walk forwards from a position until we encounter the (inside) start of
13
12
  * the next node, or reach the end of the document.
@@ -22,6 +21,13 @@ export declare const walkNextNode: ($startPos: ResolvedPos) => WalkNode;
22
21
  * @param $startPos Position to start walking from.
23
22
  */
24
23
  export declare const walkPrevNode: ($startPos: ResolvedPos) => WalkNode;
24
+ export declare function insertNewLine(): Command;
25
+ export declare const insertNewLineWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
26
+ export declare const createNewParagraphAbove: Command;
27
+ export declare const createNewParagraphBelow: Command;
28
+ export declare function createParagraphNear(append?: boolean): Command;
29
+ export declare function atTheEndOfDoc(state: EditorState): boolean;
30
+ export declare function atTheBeginningOfDoc(state: EditorState): boolean;
25
31
  /**
26
32
  * If the selection is empty, is inside a paragraph node and `canNextNodeMoveUp` is true then delete current paragraph
27
33
  * and move the node below it up. The selection will be retained, to be placed in the moved node.
@@ -1,5 +1,5 @@
1
- import { Node, NodeType, Slice } from '@atlaskit/editor-prosemirror/model';
2
- import { EditorState, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
1
+ import { MarkType, Node, NodeType, Slice } from '@atlaskit/editor-prosemirror/model';
2
+ import { EditorState, Selection, TextSelection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import { Step } from '@atlaskit/editor-prosemirror/transform';
4
4
  import { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  /**
@@ -27,3 +27,8 @@ export declare function setTextSelection(view: EditorView, anchor: number, head?
27
27
  export declare function nonNullable<T>(value: T): value is NonNullable<T>;
28
28
  export declare const isValidPosition: (pos: number | undefined, state: EditorState) => boolean;
29
29
  export declare const isInLayoutColumn: (state: EditorState) => boolean;
30
+ export declare function filterChildrenBetween(doc: Node, from: number, to: number, predicate: (node: Node, pos: number, parent: Node | null) => boolean | undefined): {
31
+ node: Node;
32
+ pos: number;
33
+ }[];
34
+ export declare const removeBlockMarks: (state: EditorState, marks: Array<MarkType | undefined>) => Transaction | undefined;
@@ -6,7 +6,7 @@ export { default as ErrorReporter } from './error-reporter';
6
6
  export type { ErrorReportingHandler } from './error-reporter';
7
7
  export { isPastDate, timestampToIsoFormat, timestampToString, timestampToTaskContext, timestampToUTCDate, todayTimestampInUTC, } from './date';
8
8
  export type { Date } from './date';
9
- export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, } from './editor-core-utils';
9
+ export { isElementInTableCell, isTextSelection, isLastItemMediaGroup, setNodeSelection, setTextSelection, nonNullable, stepAddsOneOf, stepHasSlice, extractSliceFromStep, isValidPosition, isEmptyParagraph, isInLayoutColumn, removeBlockMarks, filterChildrenBetween, } from './editor-core-utils';
10
10
  export { withImageLoader } from './imageLoader';
11
11
  export type { ImageLoaderProps, ImageLoaderState, ImageStatus, } from './imageLoader';
12
12
  export { absoluteBreakoutWidth, calcBreakoutWidth, calcWideWidth, breakoutConsts, calculateBreakoutStyles, calcBreakoutWidthPx, getNextBreakoutMode, getTitle, } from './breakout';
@@ -55,7 +55,7 @@ export { nodesBetweenChanged, getStepRange, isEmptyDocument, processRawValue, ha
55
55
  export { floatingLayouts, isRichMediaInsideOfBlockNode, calculateSnapPoints, alignAttributes, nonWrappedLayouts, } from './rich-media-utils';
56
56
  export { sanitizeNodeForPrivacy } from './filter/privacy-filter';
57
57
  export { canRenderDatasource } from './datasource';
58
- export { filterCommand, walkPrevNode, walkNextNode, isEmptySelectionAtStart, isEmptySelectionAtEnd, insertContentDeleteRange, deleteEmptyParagraphAndMoveBlockUp, } from './commands';
58
+ export { filterCommand, isEmptySelectionAtStart, isEmptySelectionAtEnd, insertContentDeleteRange, deleteEmptyParagraphAndMoveBlockUp, insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, createParagraphNear, walkNextNode, walkPrevNode, } from './commands';
59
59
  export type { WalkNode } from './commands';
60
60
  export declare function shallowEqual(obj1?: any, obj2?: any): boolean;
61
- export { inputRuleWithAnalytics } from './input-rules';
61
+ export { inputRuleWithAnalytics, createWrappingJoinRule, createRule, } from './input-rules';
@@ -1,7 +1,15 @@
1
- import type { EditorState } from 'prosemirror-state';
2
- import type { EditorAnalyticsAPI } from '../analytics';
3
- import type { AnalyticsEventPayload } from '../analytics/types';
4
- import type { InputRuleWrapper } from '../types/input-rules';
1
+ import type { NodeType, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
3
+ import { type AnalyticsEventPayload, type EditorAnalyticsAPI, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '../analytics';
4
+ import { InputRuleHandler, InputRuleWrapper } from '../types';
5
5
  type GetPayload = AnalyticsEventPayload | ((state: EditorState, matchResult: RegExpExecArray) => AnalyticsEventPayload);
6
6
  export declare const inputRuleWithAnalytics: (getPayload: GetPayload, analyticsApi: EditorAnalyticsAPI | undefined) => (originalRule: InputRuleWrapper) => InputRuleWrapper;
7
+ type WrappingRuleProps = {
8
+ match: RegExp;
9
+ nodeType: NodeType;
10
+ getAttrs?: Record<string, any> | ((matchResult: RegExpExecArray) => Record<string, any>);
11
+ joinPredicate?: (matchResult: RegExpExecArray, node: PMNode, joinScenario: JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST) => boolean;
12
+ };
13
+ export declare const createWrappingJoinRule: ({ match, nodeType, getAttrs, joinPredicate, }: WrappingRuleProps) => InputRuleWrapper;
14
+ export declare const createRule: (match: RegExp, handler: InputRuleHandler) => InputRuleWrapper;
7
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.33.0",
3
+ "version": "74.34.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/"
@@ -110,7 +110,7 @@
110
110
  "@atlaskit/spinner": "^15.5.0",
111
111
  "@atlaskit/task-decision": "^17.7.0",
112
112
  "@atlaskit/theme": "^12.5.0",
113
- "@atlaskit/tokens": "^1.13.0",
113
+ "@atlaskit/tokens": "^1.14.0",
114
114
  "@atlaskit/tooltip": "^17.8.0",
115
115
  "@atlaskit/ufo": "^0.2.0",
116
116
  "@atlaskit/width-detector": "^4.1.0",
@@ -131,7 +131,8 @@
131
131
  "raf-schd": "^4.0.3",
132
132
  "re-resizable": "6.0.0",
133
133
  "react-loadable": "^5.1.0",
134
- "rusha": "^0.8.13"
134
+ "rusha": "^0.8.13",
135
+ "w3c-keyname": "^2.1.0"
135
136
  },
136
137
  "peerDependencies": {
137
138
  "@atlaskit/media-core": "^34.1.2",