@atlaskit/editor-common 78.27.0 → 78.28.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 (55) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/cjs/extensibility/Extension/InlineExtension/index.js +6 -3
  3. package/dist/cjs/extensibility/Extension/InlineExtension/styles.js +9 -2
  4. package/dist/cjs/media/messages/comments.js +1 -1
  5. package/dist/cjs/media-single/CommentBadge.js +23 -3
  6. package/dist/cjs/messages/insert-block.js +4 -4
  7. package/dist/cjs/monitoring/error.js +1 -1
  8. package/dist/cjs/preset/{core-plugin.js → core-plugin/index.js} +15 -1
  9. package/dist/cjs/preset/core-plugin/requestDocument.js +62 -0
  10. package/dist/cjs/preset/core-plugin/types.js +5 -0
  11. package/dist/cjs/ui/DropList/index.js +1 -1
  12. package/dist/cjs/ui/MultiBodiedExtension/index.js +0 -3
  13. package/dist/es2019/extensibility/Extension/InlineExtension/index.js +7 -4
  14. package/dist/es2019/extensibility/Extension/InlineExtension/styles.js +8 -1
  15. package/dist/es2019/media/messages/comments.js +1 -1
  16. package/dist/es2019/media-single/CommentBadge.js +23 -4
  17. package/dist/es2019/messages/insert-block.js +4 -4
  18. package/dist/es2019/monitoring/error.js +1 -1
  19. package/dist/es2019/preset/{core-plugin.js → core-plugin/index.js} +15 -1
  20. package/dist/es2019/preset/core-plugin/requestDocument.js +51 -0
  21. package/dist/es2019/preset/core-plugin/types.js +1 -0
  22. package/dist/es2019/ui/DropList/index.js +1 -1
  23. package/dist/es2019/ui/MultiBodiedExtension/index.js +0 -3
  24. package/dist/esm/extensibility/Extension/InlineExtension/index.js +7 -4
  25. package/dist/esm/extensibility/Extension/InlineExtension/styles.js +8 -1
  26. package/dist/esm/media/messages/comments.js +1 -1
  27. package/dist/esm/media-single/CommentBadge.js +24 -4
  28. package/dist/esm/messages/insert-block.js +4 -4
  29. package/dist/esm/monitoring/error.js +1 -1
  30. package/dist/esm/preset/{core-plugin.js → core-plugin/index.js} +15 -1
  31. package/dist/esm/preset/core-plugin/requestDocument.js +54 -0
  32. package/dist/esm/preset/core-plugin/types.js +1 -0
  33. package/dist/esm/ui/DropList/index.js +1 -1
  34. package/dist/esm/ui/MultiBodiedExtension/index.js +0 -3
  35. package/dist/types/card/cardOptions.d.ts +6 -0
  36. package/dist/types/card/index.d.ts +1 -1
  37. package/dist/types/extensibility/Extension/InlineExtension/styles.d.ts +1 -1
  38. package/dist/types/media-single/CommentBadge.d.ts +4 -1
  39. package/dist/types/preset/core-plugin/index.d.ts +6 -0
  40. package/dist/types/preset/core-plugin/requestDocument.d.ts +7 -0
  41. package/dist/types/preset/core-plugin/types.d.ts +59 -0
  42. package/dist/types/preset/plugin-injection-api.d.ts +1 -1
  43. package/dist/types/types/next-editor-plugin.d.ts +2 -2
  44. package/dist/types-ts4.5/card/cardOptions.d.ts +6 -0
  45. package/dist/types-ts4.5/card/index.d.ts +1 -1
  46. package/dist/types-ts4.5/extensibility/Extension/InlineExtension/styles.d.ts +1 -1
  47. package/dist/types-ts4.5/media-single/CommentBadge.d.ts +4 -1
  48. package/dist/types-ts4.5/preset/core-plugin/index.d.ts +6 -0
  49. package/dist/types-ts4.5/preset/core-plugin/requestDocument.d.ts +7 -0
  50. package/dist/types-ts4.5/preset/core-plugin/types.d.ts +59 -0
  51. package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +2 -2
  52. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +2 -2
  53. package/package.json +4 -4
  54. package/dist/types/preset/core-plugin.d.ts +0 -39
  55. package/dist/types-ts4.5/preset/core-plugin.d.ts +0 -39
@@ -8,7 +8,7 @@ import { useSharedPluginState } from '../../../hooks';
8
8
  import { createWidthContext, WidthContext } from '../../../ui';
9
9
  import ExtensionLozenge from '../Lozenge';
10
10
  import { overlay } from '../styles';
11
- import { inlineWrapperStyels, wrapperStyle } from './styles';
11
+ import { inlineWrapperStyles, wrapperStyle } from './styles';
12
12
  var InlineExtension = function InlineExtension(props) {
13
13
  var node = props.node,
14
14
  pluginInjectionApi = props.pluginInjectionApi,
@@ -20,9 +20,12 @@ var InlineExtension = function InlineExtension(props) {
20
20
  var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width']),
21
21
  widthState = _useSharedPluginState.widthState;
22
22
  var hasChildren = !!children;
23
- var classNames = classnames('extension-container', 'inline', 'with-overlay', {
23
+ var classNames = classnames('extension-container', 'inline', {
24
+ 'with-overlay': !showMacroInteractionDesignUpdates,
24
25
  'with-children': hasChildren,
25
- 'with-danger-overlay': showMacroInteractionDesignUpdates
26
+ 'with-danger-overlay': showMacroInteractionDesignUpdates,
27
+ 'with-border': showMacroInteractionDesignUpdates,
28
+ 'with-hover-border': showMacroInteractionDesignUpdates && isNodeHovered
26
29
  });
27
30
  var rendererContainerWidth = widthState ? widthState.width - akEditorGutterPadding * 2 : 0;
28
31
  var extendedInlineExtension = getBooleanFF('platform.editor.inline_extension.extended_lcqdn') || false;
@@ -38,7 +41,7 @@ var InlineExtension = function InlineExtension(props) {
38
41
  showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates
39
42
  }), jsx("div", {
40
43
  "data-testid": "inline-extension-wrapper",
41
- css: [wrapperStyle, extendedInlineExtension && inlineWrapperStyels],
44
+ css: [wrapperStyle, extendedInlineExtension && inlineWrapperStyles],
42
45
  className: classNames,
43
46
  onMouseEnter: function onMouseEnter() {
44
47
  return handleMouseEvent(true);
@@ -1,4 +1,5 @@
1
1
  import { css } from '@emotion/react';
2
+ import { N500 } from '@atlaskit/theme/colors';
2
3
  import { wrapperDefault } from '../styles';
3
4
  export var wrapperStyle = css(wrapperDefault, {
4
5
  cursor: 'pointer',
@@ -16,9 +17,15 @@ export var wrapperStyle = css(wrapperDefault, {
16
17
  '&.with-children': {
17
18
  padding: 0,
18
19
  background: "var(--ds-background-neutral-subtle, white)"
20
+ },
21
+ '&.with-border': {
22
+ border: "1px solid transparent" // adding this so macro doesn't jump when hover border is shown
23
+ },
24
+ '&.with-hover-border': {
25
+ border: "1px solid ".concat("var(--ds-border-input, ".concat(N500, ")"))
19
26
  }
20
27
  });
21
- export var inlineWrapperStyels = css({
28
+ export var inlineWrapperStyles = css({
22
29
  maxWidth: '100%',
23
30
  'tr &': {
24
31
  maxWidth: 'inherit'
@@ -7,7 +7,7 @@ export var commentMessages = defineMessages({
7
7
  },
8
8
  viewCommentsOnMedia: {
9
9
  id: 'fabric.editor.viewCommentOnMedia',
10
- defaultMessage: 'View comment',
10
+ defaultMessage: 'View comments',
11
11
  description: 'View a existing comment for this media (image/video)'
12
12
  },
13
13
  viewAndAddCommentsOnMedia: {
@@ -1,12 +1,13 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /** @jsx jsx */
3
- import { useEffect, useState } from 'react';
3
+ import { useEffect, useMemo, useState } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import debounce from 'lodash/debounce';
6
6
  import { CustomThemeButton } from '@atlaskit/button';
7
7
  import { akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
8
8
  import CommentIcon from '@atlaskit/icon/glyph/comment';
9
9
  import { layers } from '@atlaskit/theme/constants';
10
+ import Tooltip from '@atlaskit/tooltip';
10
11
  import { commentMessages as messages } from '../media';
11
12
  var commentBadgeWrapper = css({
12
13
  position: 'absolute',
@@ -28,15 +29,19 @@ export var CommentBadge = function CommentBadge(_ref) {
28
29
  var intl = _ref.intl,
29
30
  width = _ref.width,
30
31
  height = _ref.height,
32
+ _ref$status = _ref.status,
33
+ status = _ref$status === void 0 ? 'default' : _ref$status,
31
34
  mediaElement = _ref.mediaElement,
32
35
  onClick = _ref.onClick,
36
+ onMouseEnter = _ref.onMouseEnter,
37
+ onMouseLeave = _ref.onMouseLeave,
33
38
  _ref$isEditor = _ref.isEditor,
34
39
  isEditor = _ref$isEditor === void 0 ? false : _ref$isEditor;
35
40
  var _useState = useState(getBadgeSize(width, height)),
36
41
  _useState2 = _slicedToArray(_useState, 2),
37
42
  badgeSize = _useState2[0],
38
43
  setBadgeSize = _useState2[1];
39
- var title = intl.formatMessage(messages.viewAndAddCommentsOnMedia);
44
+ var title = intl.formatMessage(messages.viewCommentsOnMedia);
40
45
  useEffect(function () {
41
46
  var observer = new ResizeObserver(debounce(function (entries) {
42
47
  var _entries = _slicedToArray(entries, 1),
@@ -54,21 +59,36 @@ export var CommentBadge = function CommentBadge(_ref) {
54
59
  };
55
60
  }, [mediaElement]);
56
61
  var badgeDimensions = badgeSize === 'medium' ? '24px' : '16px';
62
+ var colourToken = useMemo(function () {
63
+ switch (status) {
64
+ case 'active':
65
+ return "var(--ds-background-accent-yellow-subtlest-pressed, #F5CD47)";
66
+ case 'entered':
67
+ return "var(--ds-background-accent-yellow-subtlest-hovered, #F8E6A0)";
68
+ default:
69
+ return "var(--ds-background-accent-yellow-subtlest, #FFF7D6)";
70
+ }
71
+ }, [status]);
57
72
  return jsx("div", {
58
73
  css: isEditor ? [commentBadgeWrapper, commentBadgeEditorOverrides] : commentBadgeWrapper
74
+ }, jsx(Tooltip, {
75
+ position: "top",
76
+ content: title
59
77
  }, jsx(CustomThemeButton, {
60
78
  style: {
61
79
  height: badgeDimensions,
62
80
  width: badgeDimensions,
63
- background: "var(--ds-background-accent-yellow-subtler, #F8E6A0)",
81
+ background: colourToken,
64
82
  display: 'flex',
65
83
  justifyContent: 'center',
66
84
  alignItems: 'center'
67
85
  },
68
86
  onClick: onClick,
87
+ onMouseEnter: onMouseEnter,
88
+ onMouseLeave: onMouseLeave,
69
89
  iconAfter: jsx(CommentIcon, {
70
90
  label: title,
71
91
  size: badgeSize
72
92
  })
73
- }));
93
+ })));
74
94
  };
@@ -192,8 +192,8 @@ export var toolbarInsertBlockMessages = defineMessages({
192
192
  },
193
193
  recordVideo: {
194
194
  id: 'fabric.editor.recordVideo',
195
- defaultMessage: 'Record video',
196
- description: 'Record video using Loom'
195
+ defaultMessage: 'Record a Loom video',
196
+ description: 'Record a Loom video'
197
197
  },
198
198
  addLoomVideo: {
199
199
  id: 'fabric.editor.addLoomVideo',
@@ -202,7 +202,7 @@ export var toolbarInsertBlockMessages = defineMessages({
202
202
  },
203
203
  recordVideoDescription: {
204
204
  id: 'fabric.editor.recordVideo.description',
205
- defaultMessage: 'Record video using Loom',
206
- description: 'Record video using Loom'
205
+ defaultMessage: 'Record your screen and camera',
206
+ description: 'Record your screen and camera'
207
207
  }
208
208
  });
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "78.27.0";
9
+ var packageVersion = "78.28.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
@@ -1,4 +1,5 @@
1
- import { editorCommandToPMCommand } from './editor-commands';
1
+ import { editorCommandToPMCommand } from '../editor-commands';
2
+ import { scheduleDocumentRequest } from './requestDocument';
2
3
  /**
3
4
  * Core plugin that is always included in the preset.
4
5
  * Allows for executing `EditorCommand` and other core functionality.
@@ -35,6 +36,19 @@ export var corePlugin = function corePlugin(_ref) {
35
36
  }
36
37
  editorView.dom.blur();
37
38
  return true;
39
+ },
40
+ requestDocument: function requestDocument(onReceive, options) {
41
+ var _config$getEditorView;
42
+ var view = (_config$getEditorView = config === null || config === void 0 ? void 0 : config.getEditorView()) !== null && _config$getEditorView !== void 0 ? _config$getEditorView : null;
43
+ scheduleDocumentRequest(view, onReceive, options === null || options === void 0 ? void 0 : options.transformer);
44
+ },
45
+ createTransformer: function createTransformer(cb) {
46
+ var _config$getEditorView2;
47
+ var view = (_config$getEditorView2 = config === null || config === void 0 ? void 0 : config.getEditorView()) !== null && _config$getEditorView2 !== void 0 ? _config$getEditorView2 : null;
48
+ if (!(view !== null && view !== void 0 && view.state.schema)) {
49
+ return undefined;
50
+ }
51
+ return cb(view === null || view === void 0 ? void 0 : view.state.schema);
38
52
  }
39
53
  }
40
54
  };
@@ -0,0 +1,54 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
+ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ var transformer = new JSONTransformer();
5
+ export function toJSON(node) {
6
+ return transformer.encode(node);
7
+ }
8
+
9
+ /**
10
+ * This throttles the callback with requestIdleCallback.
11
+ */
12
+ function createThrottleSchedule(callback) {
13
+ var frameId;
14
+ var lastArgs;
15
+ var wrapperFn = function wrapperFn() {
16
+ var _globalThis$requestId;
17
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
18
+ args[_key] = arguments[_key];
19
+ }
20
+ lastArgs = args;
21
+ if (frameId) {
22
+ return;
23
+ }
24
+
25
+ // If `requestIdleCallback` doesn't exist - fallback to `requestAnimationFrame`
26
+ var delayFunction = (_globalThis$requestId = globalThis.requestIdleCallback) !== null && _globalThis$requestId !== void 0 ? _globalThis$requestId : globalThis.requestAnimationFrame;
27
+ frameId = delayFunction(function () {
28
+ frameId = undefined;
29
+ if (lastArgs) {
30
+ callback.apply(void 0, _toConsumableArray(lastArgs));
31
+ }
32
+ }, {
33
+ timeout: 100
34
+ });
35
+ };
36
+ return wrapperFn;
37
+ }
38
+ export var scheduleDocumentRequest = createThrottleSchedule(returnDocumentRequest);
39
+ function returnDocumentRequest(editorView, callback, transformer) {
40
+ var _editorView$state;
41
+ var _ref = (_editorView$state = editorView === null || editorView === void 0 ? void 0 : editorView.state) !== null && _editorView$state !== void 0 ? _editorView$state : {},
42
+ doc = _ref.doc,
43
+ schema = _ref.schema;
44
+ if (!doc || !schema) {
45
+ return undefined;
46
+ }
47
+ var json = toJSON(doc);
48
+ if (typeof transformer === 'undefined') {
49
+ callback(json);
50
+ } else {
51
+ var nodeSanitized = PMNode.fromJSON(schema, json);
52
+ callback(transformer.encode(nodeSanitized));
53
+ }
54
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -17,7 +17,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
17
17
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
18
18
  import Layer from '../Layer';
19
19
  var packageName = "@atlaskit/editor-common";
20
- var packageVersion = "78.27.0";
20
+ var packageVersion = "78.28.0";
21
21
  var halfFocusRing = 1;
22
22
  var dropOffset = '0, 8';
23
23
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,7 +1,6 @@
1
1
  /** @jsx jsx */
2
2
 
3
3
  import { css } from '@emotion/react';
4
- import { N30, N40 } from '@atlaskit/theme/colors';
5
4
  // Wraps the navigation bar and extensionFrames
6
5
  var mbeExtensionContainer = css({
7
6
  background: 'transparent !important',
@@ -34,7 +33,6 @@ var mbeNavigation = css({
34
33
  borderTopRightRadius: "var(--ds-border-radius, 3px)",
35
34
  userSelect: 'none',
36
35
  WebkitUserModify: 'read-only',
37
- border: "1px solid ".concat("var(--ds-border, ".concat(N40, ")")),
38
36
  borderBottom: 'none !important',
39
37
  background: "var(--ds-surface, white)",
40
38
  marginLeft: "var(--ds-space-100, 8px)",
@@ -49,7 +47,6 @@ var mbeNavigation = css({
49
47
  });
50
48
  var extensionFrameContent = css({
51
49
  padding: "var(--ds-space-100, 8px)".concat(" !important"),
52
- border: "1px solid ".concat("var(--ds-border, ".concat(N30, ")")),
53
50
  display: 'block',
54
51
  minHeight: '100px',
55
52
  background: "var(--ds-surface, white)",
@@ -1,5 +1,10 @@
1
+ import type { MouseEvent } from 'react';
1
2
  import type { CardProps } from '@atlaskit/smart-card';
2
3
  import type { Providers } from '../provider-factory';
4
+ export type OnClickCallback = ({ event, url, }: {
5
+ event: MouseEvent<HTMLAnchorElement>;
6
+ url?: string;
7
+ }) => void;
3
8
  export interface CardOptions {
4
9
  provider?: Providers['cardProvider'];
5
10
  resolveBeforeMacros?: string[];
@@ -18,6 +23,7 @@ export interface CardOptions {
18
23
  allowAlignment?: boolean;
19
24
  allowWrapping?: boolean;
20
25
  showUpgradeDiscoverability?: boolean;
26
+ onClickCallback?: OnClickCallback;
21
27
  /**
22
28
  * Customises the outbound link to configure user preferences
23
29
  */
@@ -1,4 +1,4 @@
1
- export type { CardOptions } from './cardOptions';
1
+ export type { CardOptions, OnClickCallback } from './cardOptions';
2
2
  export { addLinkMetadata, getLinkMetadataFromTransaction, commandWithMetadata, } from './utils';
3
3
  export { default as buildLayoutButtons, alignmentIcons, wrappingIcons, layoutToMessages, } from './MediaAndEmbedsToolbar';
4
4
  export type { IconMap, LayoutIcon } from './MediaAndEmbedsToolbar';
@@ -1,2 +1,2 @@
1
1
  export declare const wrapperStyle: import("@emotion/react").SerializedStyles;
2
- export declare const inlineWrapperStyels: import("@emotion/react").SerializedStyles;
2
+ export declare const inlineWrapperStyles: import("@emotion/react").SerializedStyles;
@@ -5,8 +5,11 @@ export type CommentBadgeProps = {
5
5
  intl: IntlShape;
6
6
  width?: number;
7
7
  height?: number;
8
+ status?: 'default' | 'entered' | 'active';
8
9
  mediaElement?: HTMLElement | null;
9
10
  onClick: (e: React.MouseEvent) => void;
11
+ onMouseEnter?: (e: React.MouseEvent) => void;
12
+ onMouseLeave?: (e: React.MouseEvent) => void;
10
13
  isEditor?: boolean;
11
14
  };
12
- export declare const CommentBadge: ({ intl, width, height, mediaElement, onClick, isEditor, }: CommentBadgeProps) => jsx.JSX.Element;
15
+ export declare const CommentBadge: ({ intl, width, height, status, mediaElement, onClick, onMouseEnter, onMouseLeave, isEditor, }: CommentBadgeProps) => jsx.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { CorePlugin } from './types';
2
+ /**
3
+ * Core plugin that is always included in the preset.
4
+ * Allows for executing `EditorCommand` and other core functionality.
5
+ */
6
+ export declare const corePlugin: CorePlugin;
@@ -0,0 +1,7 @@
1
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { Transformer } from '../../types';
5
+ import type { InferTransformerResultCallback } from './types';
6
+ export declare function toJSON(node: PMNode): JSONDocNode;
7
+ export declare const scheduleDocumentRequest: <GenericTransformer extends Transformer<any> | undefined>(editorView: EditorView | null, callback: InferTransformerResultCallback<Transformer<any>>, transformer?: Transformer<any> | undefined) => void;
@@ -0,0 +1,59 @@
1
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { EditorCommand, NextEditorPlugin, Transformer } from '../../types';
5
+ export type CorePlugin = NextEditorPlugin<'core', {
6
+ pluginConfiguration: {
7
+ getEditorView: () => EditorView | undefined;
8
+ };
9
+ actions: {
10
+ /**
11
+ * Dispatches an EditorCommand to ProseMirror
12
+ *
13
+ * @param command A function (EditorCommand | undefined) that takes an object containing a `Transaction` and returns a `Transaction` if it
14
+ * is successful or `null` if it shouldn't be dispatched.
15
+ * @returns (boolean) if the command was successful in dispatching
16
+ */
17
+ execute: (command: EditorCommand | undefined) => boolean;
18
+ /**
19
+ * Focuses the editor.
20
+ *
21
+ * Calls the focus method of the `EditorView` and scrolls the
22
+ * current selection into view.
23
+ *
24
+ * @returns (boolean) if the focus was successful
25
+ */
26
+ focus: () => boolean;
27
+ /**
28
+ * Blurs the editor.
29
+ *
30
+ * Calls blur on the editor DOM element.
31
+ *
32
+ * @returns (boolean) if the blur was successful
33
+ */
34
+ blur: () => boolean;
35
+ /**
36
+ * Request the editor document.
37
+ * The document will return when available. If called multiple times it will throttle and return the
38
+ * latest document when ready.
39
+ *
40
+ * A transformer can be created using `createTransformer`.
41
+ *
42
+ * @param onReceive Callback to handle the document. Document type based on the transformer.
43
+ * @param options Pass a transformer for the document to be transformed into a different format.
44
+ */
45
+ requestDocument<GenericTransformer extends Transformer<any> = Transformer<JSONDocNode>>(onReceive: (document: TransformerResult<GenericTransformer> | undefined) => void, options?: {
46
+ transformer?: GenericTransformer;
47
+ }): void;
48
+ /**
49
+ * Create a transformer
50
+ *
51
+ * @param schema Schema of the document
52
+ * @returns Transformer which can be used to request a document
53
+ */
54
+ createTransformer<Format>(cb: (schema: Schema) => Transformer<Format>): Transformer<Format> | undefined;
55
+ };
56
+ }>;
57
+ export type TransformerResult<GenericTransformer = Transformer<JSONDocNode>> = GenericTransformer extends Transformer<infer Content> ? Content : JSONDocNode;
58
+ export type InferTransformerResultCallback<T extends Transformer<any> | undefined> = (doc: T extends Transformer<infer U> ? TransformerResult<U> : TransformerResult<JSONDocNode>) => void;
59
+ export type DefaultTransformerResultCallback = (doc: TransformerResult<JSONDocNode> | undefined) => void;
@@ -39,7 +39,7 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
39
39
  private commandsAPI;
40
40
  private plugins;
41
41
  constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
42
- api<T extends NextEditorPlugin<any, any>>(): import("../types/next-editor-plugin").PublicPluginAPI<[NextEditorPlugin<T extends import("./core-plugin").CorePlugin<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>, ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("./core-plugin").CorePlugin<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("./core-plugin").CorePlugin<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [] : []]>;
42
+ api<T extends NextEditorPlugin<any, any>>(): import("../types/next-editor-plugin").PublicPluginAPI<[NextEditorPlugin<T extends import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>, ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [] : []]>;
43
43
  onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void;
44
44
  onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
45
45
  private addPlugin;
@@ -5,7 +5,7 @@
5
5
  * are put together - but for now `Builder` & `Preset` aim to beinterchangeable.
6
6
  */
7
7
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
- import type { CorePlugin } from '../preset/core-plugin';
8
+ import type { CorePlugin } from '../preset/core-plugin/types';
9
9
  import type { EditorCommand, EditorCommandWithMetadata } from './editor-command';
10
10
  import type { EditorPlugin } from './editor-plugin';
11
11
  type IsAny<T> = 0 extends 1 & T ? true : false;
@@ -97,7 +97,7 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
97
97
  commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
98
98
  };
99
99
  export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
100
- [Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> | undefined : never;
100
+ [Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<'core', any> ? PluginDependenciesAPI<Plugin> : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> | undefined : never;
101
101
  };
102
102
  export type PluginWithConfiguration<Plugin> = undefined extends ExtractPluginConfiguration<Plugin> ? [Plugin, ExtractPluginConfiguration<Plugin>?] : [Plugin, ExtractPluginConfiguration<Plugin>];
103
103
  export type MaybePluginName<T extends string> = [T];
@@ -1,5 +1,10 @@
1
+ import type { MouseEvent } from 'react';
1
2
  import type { CardProps } from '@atlaskit/smart-card';
2
3
  import type { Providers } from '../provider-factory';
4
+ export type OnClickCallback = ({ event, url, }: {
5
+ event: MouseEvent<HTMLAnchorElement>;
6
+ url?: string;
7
+ }) => void;
3
8
  export interface CardOptions {
4
9
  provider?: Providers['cardProvider'];
5
10
  resolveBeforeMacros?: string[];
@@ -18,6 +23,7 @@ export interface CardOptions {
18
23
  allowAlignment?: boolean;
19
24
  allowWrapping?: boolean;
20
25
  showUpgradeDiscoverability?: boolean;
26
+ onClickCallback?: OnClickCallback;
21
27
  /**
22
28
  * Customises the outbound link to configure user preferences
23
29
  */
@@ -1,4 +1,4 @@
1
- export type { CardOptions } from './cardOptions';
1
+ export type { CardOptions, OnClickCallback } from './cardOptions';
2
2
  export { addLinkMetadata, getLinkMetadataFromTransaction, commandWithMetadata, } from './utils';
3
3
  export { default as buildLayoutButtons, alignmentIcons, wrappingIcons, layoutToMessages, } from './MediaAndEmbedsToolbar';
4
4
  export type { IconMap, LayoutIcon } from './MediaAndEmbedsToolbar';
@@ -1,2 +1,2 @@
1
1
  export declare const wrapperStyle: import("@emotion/react").SerializedStyles;
2
- export declare const inlineWrapperStyels: import("@emotion/react").SerializedStyles;
2
+ export declare const inlineWrapperStyles: import("@emotion/react").SerializedStyles;
@@ -5,8 +5,11 @@ export type CommentBadgeProps = {
5
5
  intl: IntlShape;
6
6
  width?: number;
7
7
  height?: number;
8
+ status?: 'default' | 'entered' | 'active';
8
9
  mediaElement?: HTMLElement | null;
9
10
  onClick: (e: React.MouseEvent) => void;
11
+ onMouseEnter?: (e: React.MouseEvent) => void;
12
+ onMouseLeave?: (e: React.MouseEvent) => void;
10
13
  isEditor?: boolean;
11
14
  };
12
- export declare const CommentBadge: ({ intl, width, height, mediaElement, onClick, isEditor, }: CommentBadgeProps) => jsx.JSX.Element;
15
+ export declare const CommentBadge: ({ intl, width, height, status, mediaElement, onClick, onMouseEnter, onMouseLeave, isEditor, }: CommentBadgeProps) => jsx.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { CorePlugin } from './types';
2
+ /**
3
+ * Core plugin that is always included in the preset.
4
+ * Allows for executing `EditorCommand` and other core functionality.
5
+ */
6
+ export declare const corePlugin: CorePlugin;
@@ -0,0 +1,7 @@
1
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { Transformer } from '../../types';
5
+ import type { InferTransformerResultCallback } from './types';
6
+ export declare function toJSON(node: PMNode): JSONDocNode;
7
+ export declare const scheduleDocumentRequest: <GenericTransformer extends Transformer<any> | undefined>(editorView: EditorView | null, callback: InferTransformerResultCallback<Transformer<any>>, transformer?: Transformer<any> | undefined) => void;
@@ -0,0 +1,59 @@
1
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ import type { Schema } from '@atlaskit/editor-prosemirror/model';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import type { EditorCommand, NextEditorPlugin, Transformer } from '../../types';
5
+ export type CorePlugin = NextEditorPlugin<'core', {
6
+ pluginConfiguration: {
7
+ getEditorView: () => EditorView | undefined;
8
+ };
9
+ actions: {
10
+ /**
11
+ * Dispatches an EditorCommand to ProseMirror
12
+ *
13
+ * @param command A function (EditorCommand | undefined) that takes an object containing a `Transaction` and returns a `Transaction` if it
14
+ * is successful or `null` if it shouldn't be dispatched.
15
+ * @returns (boolean) if the command was successful in dispatching
16
+ */
17
+ execute: (command: EditorCommand | undefined) => boolean;
18
+ /**
19
+ * Focuses the editor.
20
+ *
21
+ * Calls the focus method of the `EditorView` and scrolls the
22
+ * current selection into view.
23
+ *
24
+ * @returns (boolean) if the focus was successful
25
+ */
26
+ focus: () => boolean;
27
+ /**
28
+ * Blurs the editor.
29
+ *
30
+ * Calls blur on the editor DOM element.
31
+ *
32
+ * @returns (boolean) if the blur was successful
33
+ */
34
+ blur: () => boolean;
35
+ /**
36
+ * Request the editor document.
37
+ * The document will return when available. If called multiple times it will throttle and return the
38
+ * latest document when ready.
39
+ *
40
+ * A transformer can be created using `createTransformer`.
41
+ *
42
+ * @param onReceive Callback to handle the document. Document type based on the transformer.
43
+ * @param options Pass a transformer for the document to be transformed into a different format.
44
+ */
45
+ requestDocument<GenericTransformer extends Transformer<any> = Transformer<JSONDocNode>>(onReceive: (document: TransformerResult<GenericTransformer> | undefined) => void, options?: {
46
+ transformer?: GenericTransformer;
47
+ }): void;
48
+ /**
49
+ * Create a transformer
50
+ *
51
+ * @param schema Schema of the document
52
+ * @returns Transformer which can be used to request a document
53
+ */
54
+ createTransformer<Format>(cb: (schema: Schema) => Transformer<Format>): Transformer<Format> | undefined;
55
+ };
56
+ }>;
57
+ export type TransformerResult<GenericTransformer = Transformer<JSONDocNode>> = GenericTransformer extends Transformer<infer Content> ? Content : JSONDocNode;
58
+ export type InferTransformerResultCallback<T extends Transformer<any> | undefined> = (doc: T extends Transformer<infer U> ? TransformerResult<U> : TransformerResult<JSONDocNode>) => void;
59
+ export type DefaultTransformerResultCallback = (doc: TransformerResult<JSONDocNode> | undefined) => void;
@@ -40,8 +40,8 @@ export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefin
40
40
  private plugins;
41
41
  constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps);
42
42
  api<T extends NextEditorPlugin<any, any>>(): import("../types/next-editor-plugin").PublicPluginAPI<[
43
- NextEditorPlugin<T extends import("./core-plugin").CorePlugin<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>,
44
- ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("./core-plugin").CorePlugin<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("./core-plugin").CorePlugin<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [
43
+ NextEditorPlugin<T extends import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>,
44
+ ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("../types/next-editor-plugin").NextEditorPluginFunctionOptionalConfigDefinition<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [
45
45
  ] : [
46
46
  ]
47
47
  ]>;
@@ -5,7 +5,7 @@
5
5
  * are put together - but for now `Builder` & `Preset` aim to beinterchangeable.
6
6
  */
7
7
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
8
- import type { CorePlugin } from '../preset/core-plugin';
8
+ import type { CorePlugin } from '../preset/core-plugin/types';
9
9
  import type { EditorCommand, EditorCommandWithMetadata } from './editor-command';
10
10
  import type { EditorPlugin } from './editor-plugin';
11
11
  type IsAny<T> = 0 extends 1 & T ? true : false;
@@ -103,7 +103,7 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
103
103
  commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
104
104
  };
105
105
  export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
106
- [Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> | undefined : never;
106
+ [Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<'core', any> ? PluginDependenciesAPI<Plugin> : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> | undefined : never;
107
107
  };
108
108
  export type PluginWithConfiguration<Plugin> = undefined extends ExtractPluginConfiguration<Plugin> ? [
109
109
  Plugin,