@atlaskit/editor-plugin-loom 2.3.1 → 2.5.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,30 @@
1
1
  # @atlaskit/editor-plugin-loom
2
2
 
3
+ ## 2.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#124209](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124209)
8
+ [`8aa1792f12ed3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8aa1792f12ed3) -
9
+ bump @atlaskit/editor-prosemirror to 5.0.0, bump @atlaskit/adf-schema to 40.1.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 2.4.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#121606](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121606)
20
+ [`e06f32518241c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e06f32518241c) -
21
+ Added new action to loom plugin "insertLoom" which allows the user to insert a loom video into the
22
+ document.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies
27
+
3
28
  ## 2.3.1
4
29
 
5
30
  ### Patch Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.recordVideoFailed = exports.recordVideo = exports.insertVideo = exports.enableLoom = exports.disableLoom = void 0;
6
+ exports.recordVideoFailed = exports.recordVideo = exports.insertVideo = exports.insertLoom = exports.enableLoom = exports.disableLoom = void 0;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _pmPlugin = require("./pm-plugin");
9
9
  var enableLoom = exports.enableLoom = function enableLoom(_ref) {
@@ -83,4 +83,37 @@ var insertVideo = exports.insertVideo = function insertVideo(_ref9) {
83
83
  })(tr);
84
84
  return tr;
85
85
  };
86
+ };
87
+ var getPositions = function getPositions(tr, posType) {
88
+ var selection = tr.selection;
89
+ switch (posType) {
90
+ case 'current':
91
+ return {
92
+ from: selection.from,
93
+ to: selection.from
94
+ };
95
+ case 'start':
96
+ return {
97
+ from: 0,
98
+ to: 0
99
+ };
100
+ case 'end':
101
+ return {
102
+ from: tr.doc.content.size,
103
+ to: tr.doc.content.size
104
+ };
105
+ }
106
+ };
107
+ var insertLoom = exports.insertLoom = function insertLoom(editorView, api, video, positionType) {
108
+ var _api$hyperlink$action, _api$hyperlink;
109
+ if (!editorView) {
110
+ return false;
111
+ }
112
+ var state = editorView.state,
113
+ dispatch = editorView.dispatch;
114
+ var _getPositions = getPositions(state.tr, positionType),
115
+ from = _getPositions.from,
116
+ to = _getPositions.to;
117
+ return (_api$hyperlink$action = api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.actions.insertLink(_analytics.INPUT_METHOD.TYPEAHEAD, from, to, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
118
+ )(state, dispatch)) !== null && _api$hyperlink$action !== void 0 ? _api$hyperlink$action : false;
86
119
  };
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
11
  var _monitoring = require("@atlaskit/editor-common/monitoring");
12
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
12
13
  var _logo = require("@atlaskit/logo");
13
14
  var _commands = require("./commands");
14
15
  var _pmPlugin = require("./pm-plugin");
@@ -18,6 +19,13 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
18
19
  var config = _ref.config,
19
20
  api = _ref.api;
20
21
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
22
+
23
+ // Workaround since we want to insert a loom via the `hyperlink` plugin for now.
24
+ // The hyperlink plugin (and the card plugin) are deeply tied into using the Prosemirror Command
25
+ // Ideally one day we refactor those and we can remove this.
26
+ var editorViewRef = {
27
+ current: null
28
+ };
21
29
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
22
30
  var disabled = _ref2.disabled,
23
31
  appearance = _ref2.appearance;
@@ -33,7 +41,10 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
33
41
  return {
34
42
  name: 'loom',
35
43
  actions: {
36
- recordVideo: _commands.recordVideo
44
+ recordVideo: _commands.recordVideo,
45
+ insertLoom: function insertLoom(video, positionType) {
46
+ return (0, _commands.insertLoom)(editorViewRef.current, api, video, positionType);
47
+ }
37
48
  },
38
49
  pmPlugins: function pmPlugins() {
39
50
  return [{
@@ -44,6 +55,22 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
44
55
  api: api
45
56
  });
46
57
  }
58
+ }, {
59
+ name: 'loomViewRefWorkaround',
60
+ plugin: function plugin() {
61
+ return new _safePlugin.SafePlugin({
62
+ view: function view(editorView) {
63
+ // Do not cleanup the editorViewRef on destroy
64
+ // because some functions may point to a stale
65
+ // reference and this means we will return null.
66
+ // EditorView is assumed to be stable so we do not need to
67
+ // cleanup.
68
+ // See: #hot-106316
69
+ editorViewRef.current = editorView;
70
+ return {};
71
+ }
72
+ });
73
+ }
47
74
  }];
48
75
  },
49
76
  getSharedState: function getSharedState(editorState) {
@@ -13,7 +13,10 @@ var _uiMenu = require("@atlaskit/editor-common/ui-menu");
13
13
  var _logo = require("@atlaskit/logo");
14
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
15
  var _commands = require("../commands");
16
- /** @jsx jsx */
16
+ /**
17
+ * @jsxRuntime classic
18
+ * @jsx jsx
19
+ */
17
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
18
21
 
19
22
  // This const is derived from the breakpoint where the toolbar hides its icons. It is used to hide the text in the AI button.
@@ -1,4 +1,4 @@
1
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { LoomPluginAction, loomPluginKey } from './pm-plugin';
3
3
  export const enableLoom = ({
4
4
  loomButton
@@ -77,4 +77,40 @@ export const insertVideo = ({
77
77
  }
78
78
  })(tr);
79
79
  return tr;
80
+ };
81
+ const getPositions = (tr, posType) => {
82
+ const selection = tr.selection;
83
+ switch (posType) {
84
+ case 'current':
85
+ return {
86
+ from: selection.from,
87
+ to: selection.from
88
+ };
89
+ case 'start':
90
+ return {
91
+ from: 0,
92
+ to: 0
93
+ };
94
+ case 'end':
95
+ return {
96
+ from: tr.doc.content.size,
97
+ to: tr.doc.content.size
98
+ };
99
+ }
100
+ };
101
+ export const insertLoom = (editorView, api, video, positionType) => {
102
+ var _api$hyperlink$action, _api$hyperlink;
103
+ if (!editorView) {
104
+ return false;
105
+ }
106
+ const {
107
+ state,
108
+ dispatch
109
+ } = editorView;
110
+ const {
111
+ from,
112
+ to
113
+ } = getPositions(state.tr, positionType);
114
+ return (_api$hyperlink$action = api === null || api === void 0 ? void 0 : (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.actions.insertLink(INPUT_METHOD.TYPEAHEAD, from, to, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
115
+ )(state, dispatch)) !== null && _api$hyperlink$action !== void 0 ? _api$hyperlink$action : false;
80
116
  };
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
4
  import { logException } from '@atlaskit/editor-common/monitoring';
5
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import { LoomIcon } from '@atlaskit/logo';
6
- import { recordVideo, recordVideoFailed } from './commands';
7
+ import { insertLoom, recordVideo, recordVideoFailed } from './commands';
7
8
  import { createPlugin, loomPluginKey } from './pm-plugin';
8
9
  import LoomToolbarButton from './ui/ToolbarButton';
9
10
  export const loomPlugin = ({
@@ -12,6 +13,13 @@ export const loomPlugin = ({
12
13
  }) => {
13
14
  var _api$analytics;
14
15
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
16
+
17
+ // Workaround since we want to insert a loom via the `hyperlink` plugin for now.
18
+ // The hyperlink plugin (and the card plugin) are deeply tied into using the Prosemirror Command
19
+ // Ideally one day we refactor those and we can remove this.
20
+ const editorViewRef = {
21
+ current: null
22
+ };
15
23
  const primaryToolbarComponent = ({
16
24
  disabled,
17
25
  appearance
@@ -28,7 +36,8 @@ export const loomPlugin = ({
28
36
  return {
29
37
  name: 'loom',
30
38
  actions: {
31
- recordVideo
39
+ recordVideo,
40
+ insertLoom: (video, positionType) => insertLoom(editorViewRef.current, api, video, positionType)
32
41
  },
33
42
  pmPlugins: () => [{
34
43
  name: 'loom',
@@ -36,6 +45,22 @@ export const loomPlugin = ({
36
45
  config,
37
46
  api
38
47
  })
48
+ }, {
49
+ name: 'loomViewRefWorkaround',
50
+ plugin: () => {
51
+ return new SafePlugin({
52
+ view: editorView => {
53
+ // Do not cleanup the editorViewRef on destroy
54
+ // because some functions may point to a stale
55
+ // reference and this means we will return null.
56
+ // EditorView is assumed to be stable so we do not need to
57
+ // cleanup.
58
+ // See: #hot-106316
59
+ editorViewRef.current = editorView;
60
+ return {};
61
+ }
62
+ });
63
+ }
39
64
  }],
40
65
  getSharedState(editorState) {
41
66
  if (!editorState) {
@@ -1,4 +1,7 @@
1
- /** @jsx jsx */
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
2
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
3
6
  import { jsx } from '@emotion/react';
4
7
  import { injectIntl } from 'react-intl-next';
@@ -1,4 +1,4 @@
1
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
1
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { LoomPluginAction, loomPluginKey } from './pm-plugin';
3
3
  export var enableLoom = function enableLoom(_ref) {
4
4
  var loomButton = _ref.loomButton;
@@ -77,4 +77,37 @@ export var insertVideo = function insertVideo(_ref9) {
77
77
  })(tr);
78
78
  return tr;
79
79
  };
80
+ };
81
+ var getPositions = function getPositions(tr, posType) {
82
+ var selection = tr.selection;
83
+ switch (posType) {
84
+ case 'current':
85
+ return {
86
+ from: selection.from,
87
+ to: selection.from
88
+ };
89
+ case 'start':
90
+ return {
91
+ from: 0,
92
+ to: 0
93
+ };
94
+ case 'end':
95
+ return {
96
+ from: tr.doc.content.size,
97
+ to: tr.doc.content.size
98
+ };
99
+ }
100
+ };
101
+ export var insertLoom = function insertLoom(editorView, api, video, positionType) {
102
+ var _api$hyperlink$action, _api$hyperlink;
103
+ if (!editorView) {
104
+ return false;
105
+ }
106
+ var state = editorView.state,
107
+ dispatch = editorView.dispatch;
108
+ var _getPositions = getPositions(state.tr, positionType),
109
+ from = _getPositions.from,
110
+ to = _getPositions.to;
111
+ return (_api$hyperlink$action = api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.actions.insertLink(INPUT_METHOD.TYPEAHEAD, from, to, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
112
+ )(state, dispatch)) !== null && _api$hyperlink$action !== void 0 ? _api$hyperlink$action : false;
80
113
  };
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
4
  import { logException } from '@atlaskit/editor-common/monitoring';
5
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import { LoomIcon } from '@atlaskit/logo';
6
- import { recordVideo, recordVideoFailed } from './commands';
7
+ import { insertLoom as _insertLoom, recordVideo, recordVideoFailed } from './commands';
7
8
  import { createPlugin, loomPluginKey } from './pm-plugin';
8
9
  import LoomToolbarButton from './ui/ToolbarButton';
9
10
  export var loomPlugin = function loomPlugin(_ref) {
@@ -11,6 +12,13 @@ export var loomPlugin = function loomPlugin(_ref) {
11
12
  var config = _ref.config,
12
13
  api = _ref.api;
13
14
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
15
+
16
+ // Workaround since we want to insert a loom via the `hyperlink` plugin for now.
17
+ // The hyperlink plugin (and the card plugin) are deeply tied into using the Prosemirror Command
18
+ // Ideally one day we refactor those and we can remove this.
19
+ var editorViewRef = {
20
+ current: null
21
+ };
14
22
  var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
15
23
  var disabled = _ref2.disabled,
16
24
  appearance = _ref2.appearance;
@@ -26,7 +34,10 @@ export var loomPlugin = function loomPlugin(_ref) {
26
34
  return {
27
35
  name: 'loom',
28
36
  actions: {
29
- recordVideo: recordVideo
37
+ recordVideo: recordVideo,
38
+ insertLoom: function insertLoom(video, positionType) {
39
+ return _insertLoom(editorViewRef.current, api, video, positionType);
40
+ }
30
41
  },
31
42
  pmPlugins: function pmPlugins() {
32
43
  return [{
@@ -37,6 +48,22 @@ export var loomPlugin = function loomPlugin(_ref) {
37
48
  api: api
38
49
  });
39
50
  }
51
+ }, {
52
+ name: 'loomViewRefWorkaround',
53
+ plugin: function plugin() {
54
+ return new SafePlugin({
55
+ view: function view(editorView) {
56
+ // Do not cleanup the editorViewRef on destroy
57
+ // because some functions may point to a stale
58
+ // reference and this means we will return null.
59
+ // EditorView is assumed to be stable so we do not need to
60
+ // cleanup.
61
+ // See: #hot-106316
62
+ editorViewRef.current = editorView;
63
+ return {};
64
+ }
65
+ });
66
+ }
40
67
  }];
41
68
  },
42
69
  getSharedState: function getSharedState(editorState) {
@@ -1,4 +1,7 @@
1
- /** @jsx jsx */
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
2
5
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
3
6
  import { jsx } from '@emotion/react';
4
7
  import { injectIntl } from 'react-intl-next';
@@ -1,7 +1,10 @@
1
1
  import type { SDKUnsupportedReasons } from '@loomhq/record-sdk';
2
- import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import type { EditorCommand } from '@atlaskit/editor-common/types';
4
- import type { VideoMeta } from './types';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { LoomPlugin } from './plugin';
7
+ import type { PositionType, VideoMeta } from './types';
5
8
  export declare const enableLoom: ({ loomButton }: {
6
9
  loomButton: HTMLButtonElement;
7
10
  }) => EditorCommand;
@@ -21,3 +24,4 @@ export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
21
24
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
22
25
  video: VideoMeta;
23
26
  }) => EditorCommand;
27
+ export declare const insertLoom: (editorView: EditorView | null, api: ExtractInjectionAPI<LoomPlugin> | undefined, video: VideoMeta, positionType: PositionType) => boolean;
@@ -6,7 +6,7 @@ import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
6
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
7
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
8
8
  import type { LoomPluginState } from './pm-plugin';
9
- import type { LoomPluginOptions } from './types';
9
+ import type { LoomPluginOptions, PositionType, VideoMeta } from './types';
10
10
  export type LoomPlugin = NextEditorPlugin<'loom', {
11
11
  pluginConfiguration: LoomPluginOptions;
12
12
  dependencies: [
@@ -21,6 +21,14 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
21
21
  inputMethod: INPUT_METHOD;
22
22
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
23
23
  }) => EditorCommand;
24
+ /**
25
+ * Insert loom into the document.
26
+ *
27
+ * @param video Video metadata (`sharedUrl` and `title`)
28
+ * @param positionType {'start' | 'end' | 'current'} Where you want to insert the loom
29
+ * @returns {boolean} If the loom was successfully inserted
30
+ */
31
+ insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
24
32
  };
25
33
  }>;
26
34
  export declare const loomPlugin: LoomPlugin;
@@ -9,6 +9,7 @@ type LoomClient = {
9
9
  onInsert: (videoMeta: VideoMeta) => void;
10
10
  }) => void;
11
11
  };
12
+ export type PositionType = 'start' | 'end' | 'current';
12
13
  export type LoomPluginErrorMessages = 'is-supported-failure' | 'failed-to-initialise' | 'api-key-not-provided';
13
14
  export type LoomSDKErrorMessages = 'incompatible-browser' | 'third-party-cookies-disabled' | 'no-media-streams-support';
14
15
  export type GetClientResult = {
@@ -196,7 +196,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
196
196
  }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>];
197
197
  sharedState: import("@atlaskit/editor-plugin-block-controls").BlockControlsSharedState;
198
198
  commands: {
199
- moveNode: (start: number, to: number) => import("@atlaskit/editor-common/types").EditorCommand;
199
+ moveNode: (start: number, to: number, inputMethod?: import("@atlaskit/editor-plugin-block-controls").MoveNodeMethod | undefined) => import("@atlaskit/editor-common/types").EditorCommand;
200
200
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: import("@atlaskit/editor-plugin-block-controls").HandleOptions) => import("@atlaskit/editor-common/types").EditorCommand;
201
201
  setNodeDragged: (posNumber: number, anchorName: string, nodeType: string) => import("@atlaskit/editor-common/types").EditorCommand;
202
202
  };
@@ -216,7 +216,18 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
216
216
  }, undefined>>];
217
217
  sharedState: import("@atlaskit/editor-plugin-card").CardPluginState | null;
218
218
  actions: import("@atlaskit/editor-common/card").CardPluginActions;
219
- }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>];
219
+ }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
220
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
221
+ dependencies: [];
222
+ pluginConfiguration?: {
223
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
224
+ } | undefined;
225
+ commands: {
226
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
227
+ };
228
+ }, {
229
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
230
+ } | undefined>>];
220
231
  actions: {
221
232
  hideLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").HideLinkToolbar;
222
233
  insertLink: import("@atlaskit/editor-plugin-hyperlink").InsertLink;
@@ -224,6 +235,8 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
224
235
  };
225
236
  commands: {
226
237
  showLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").ShowLinkToolbar;
238
+ updateLink: (href: string, text: string) => import("@atlaskit/editor-common/types").EditorCommand;
239
+ removeLink: () => import("@atlaskit/editor-common/types").EditorCommand;
227
240
  };
228
241
  sharedState: import("@atlaskit/editor-common/link").HyperlinkState | undefined;
229
242
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"primaryToolbar", {
@@ -241,6 +254,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
241
254
  inputMethod: INPUT_METHOD;
242
255
  editorAnalyticsAPI: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI | undefined;
243
256
  }) => import("@atlaskit/editor-common/types").EditorCommand;
257
+ insertLoom: (video: import("..").VideoMeta, positionType: import("../types").PositionType) => boolean;
244
258
  };
245
259
  }> | undefined;
246
260
  } & WrappedComponentProps>> & {
@@ -438,7 +452,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
438
452
  }, import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions>>];
439
453
  sharedState: import("@atlaskit/editor-plugin-block-controls").BlockControlsSharedState;
440
454
  commands: {
441
- moveNode: (start: number, to: number) => import("@atlaskit/editor-common/types").EditorCommand;
455
+ moveNode: (start: number, to: number, inputMethod?: import("@atlaskit/editor-plugin-block-controls").MoveNodeMethod | undefined) => import("@atlaskit/editor-common/types").EditorCommand;
442
456
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: import("@atlaskit/editor-plugin-block-controls").HandleOptions) => import("@atlaskit/editor-common/types").EditorCommand;
443
457
  setNodeDragged: (posNumber: number, anchorName: string, nodeType: string) => import("@atlaskit/editor-common/types").EditorCommand;
444
458
  };
@@ -458,7 +472,18 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
458
472
  }, undefined>>];
459
473
  sharedState: import("@atlaskit/editor-plugin-card").CardPluginState | null;
460
474
  actions: import("@atlaskit/editor-common/card").CardPluginActions;
461
- }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>];
475
+ }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
476
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
477
+ dependencies: [];
478
+ pluginConfiguration?: {
479
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
480
+ } | undefined;
481
+ commands: {
482
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
483
+ };
484
+ }, {
485
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
486
+ } | undefined>>];
462
487
  actions: {
463
488
  hideLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").HideLinkToolbar;
464
489
  insertLink: import("@atlaskit/editor-plugin-hyperlink").InsertLink;
@@ -466,6 +491,8 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
466
491
  };
467
492
  commands: {
468
493
  showLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").ShowLinkToolbar;
494
+ updateLink: (href: string, text: string) => import("@atlaskit/editor-common/types").EditorCommand;
495
+ removeLink: () => import("@atlaskit/editor-common/types").EditorCommand;
469
496
  };
470
497
  sharedState: import("@atlaskit/editor-common/link").HyperlinkState | undefined;
471
498
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"primaryToolbar", {
@@ -483,6 +510,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
483
510
  inputMethod: INPUT_METHOD;
484
511
  editorAnalyticsAPI: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI | undefined;
485
512
  }) => import("@atlaskit/editor-common/types").EditorCommand;
513
+ insertLoom: (video: import("..").VideoMeta, positionType: import("../types").PositionType) => boolean;
486
514
  };
487
515
  }> | undefined;
488
516
  } & WrappedComponentProps>;
@@ -1,7 +1,10 @@
1
1
  import type { SDKUnsupportedReasons } from '@loomhq/record-sdk';
2
- import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import type { EditorCommand } from '@atlaskit/editor-common/types';
4
- import type { VideoMeta } from './types';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
+ import type { LoomPlugin } from './plugin';
7
+ import type { PositionType, VideoMeta } from './types';
5
8
  export declare const enableLoom: ({ loomButton }: {
6
9
  loomButton: HTMLButtonElement;
7
10
  }) => EditorCommand;
@@ -21,3 +24,4 @@ export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
21
24
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
22
25
  video: VideoMeta;
23
26
  }) => EditorCommand;
27
+ export declare const insertLoom: (editorView: EditorView | null, api: ExtractInjectionAPI<LoomPlugin> | undefined, video: VideoMeta, positionType: PositionType) => boolean;
@@ -6,7 +6,7 @@ import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
6
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
7
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
8
8
  import type { LoomPluginState } from './pm-plugin';
9
- import type { LoomPluginOptions } from './types';
9
+ import type { LoomPluginOptions, PositionType, VideoMeta } from './types';
10
10
  export type LoomPlugin = NextEditorPlugin<'loom', {
11
11
  pluginConfiguration: LoomPluginOptions;
12
12
  dependencies: [
@@ -21,6 +21,14 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
21
21
  inputMethod: INPUT_METHOD;
22
22
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
23
23
  }) => EditorCommand;
24
+ /**
25
+ * Insert loom into the document.
26
+ *
27
+ * @param video Video metadata (`sharedUrl` and `title`)
28
+ * @param positionType {'start' | 'end' | 'current'} Where you want to insert the loom
29
+ * @returns {boolean} If the loom was successfully inserted
30
+ */
31
+ insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
24
32
  };
25
33
  }>;
26
34
  export declare const loomPlugin: LoomPlugin;
@@ -9,6 +9,7 @@ type LoomClient = {
9
9
  onInsert: (videoMeta: VideoMeta) => void;
10
10
  }) => void;
11
11
  };
12
+ export type PositionType = 'start' | 'end' | 'current';
12
13
  export type LoomPluginErrorMessages = 'is-supported-failure' | 'failed-to-initialise' | 'api-key-not-provided';
13
14
  export type LoomSDKErrorMessages = 'incompatible-browser' | 'third-party-cookies-disabled' | 'no-media-streams-support';
14
15
  export type GetClientResult = {
@@ -245,7 +245,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
245
245
  ];
246
246
  sharedState: import("@atlaskit/editor-plugin-block-controls").BlockControlsSharedState;
247
247
  commands: {
248
- moveNode: (start: number, to: number) => import("@atlaskit/editor-common/types").EditorCommand;
248
+ moveNode: (start: number, to: number, inputMethod?: import("@atlaskit/editor-plugin-block-controls").MoveNodeMethod | undefined) => import("@atlaskit/editor-common/types").EditorCommand;
249
249
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: import("@atlaskit/editor-plugin-block-controls").HandleOptions) => import("@atlaskit/editor-common/types").EditorCommand;
250
250
  setNodeDragged: (posNumber: number, anchorName: string, nodeType: string) => import("@atlaskit/editor-common/types").EditorCommand;
251
251
  };
@@ -269,7 +269,20 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
269
269
  ];
270
270
  sharedState: import("@atlaskit/editor-plugin-card").CardPluginState | null;
271
271
  actions: import("@atlaskit/editor-common/card").CardPluginActions;
272
- }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>
272
+ }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>,
273
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
274
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
275
+ dependencies: [
276
+ ];
277
+ pluginConfiguration?: {
278
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
279
+ } | undefined;
280
+ commands: {
281
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
282
+ };
283
+ }, {
284
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
285
+ } | undefined>>
273
286
  ];
274
287
  actions: {
275
288
  hideLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").HideLinkToolbar;
@@ -278,6 +291,8 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
278
291
  };
279
292
  commands: {
280
293
  showLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").ShowLinkToolbar;
294
+ updateLink: (href: string, text: string) => import("@atlaskit/editor-common/types").EditorCommand;
295
+ removeLink: () => import("@atlaskit/editor-common/types").EditorCommand;
281
296
  };
282
297
  sharedState: import("@atlaskit/editor-common/link").HyperlinkState | undefined;
283
298
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>,
@@ -297,6 +312,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
297
312
  inputMethod: INPUT_METHOD;
298
313
  editorAnalyticsAPI: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI | undefined;
299
314
  }) => import("@atlaskit/editor-common/types").EditorCommand;
315
+ insertLoom: (video: import("..").VideoMeta, positionType: import("../types").PositionType) => boolean;
300
316
  };
301
317
  }> | undefined;
302
318
  } & WrappedComponentProps>> & {
@@ -543,7 +559,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
543
559
  ];
544
560
  sharedState: import("@atlaskit/editor-plugin-block-controls").BlockControlsSharedState;
545
561
  commands: {
546
- moveNode: (start: number, to: number) => import("@atlaskit/editor-common/types").EditorCommand;
562
+ moveNode: (start: number, to: number, inputMethod?: import("@atlaskit/editor-plugin-block-controls").MoveNodeMethod | undefined) => import("@atlaskit/editor-common/types").EditorCommand;
547
563
  showDragHandleAt: (pos: number, anchorName: string, nodeType: string, handleOptions?: import("@atlaskit/editor-plugin-block-controls").HandleOptions) => import("@atlaskit/editor-common/types").EditorCommand;
548
564
  setNodeDragged: (posNumber: number, anchorName: string, nodeType: string) => import("@atlaskit/editor-common/types").EditorCommand;
549
565
  };
@@ -567,7 +583,20 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
567
583
  ];
568
584
  sharedState: import("@atlaskit/editor-plugin-card").CardPluginState | null;
569
585
  actions: import("@atlaskit/editor-common/card").CardPluginActions;
570
- }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>
586
+ }, import("@atlaskit/editor-plugin-card").CardPluginOptions>>,
587
+ import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"editorViewMode", {
588
+ sharedState: import("@atlaskit/editor-plugin-editor-viewmode").EditorViewModePluginState | null;
589
+ dependencies: [
590
+ ];
591
+ pluginConfiguration?: {
592
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
593
+ } | undefined;
594
+ commands: {
595
+ updateViewMode: (mode: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode) => import("@atlaskit/editor-common/types").EditorCommand;
596
+ };
597
+ }, {
598
+ mode?: import("@atlaskit/editor-plugin-editor-viewmode").ViewMode | undefined;
599
+ } | undefined>>
571
600
  ];
572
601
  actions: {
573
602
  hideLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").HideLinkToolbar;
@@ -576,6 +605,8 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
576
605
  };
577
606
  commands: {
578
607
  showLinkToolbar: import("@atlaskit/editor-plugin-hyperlink").ShowLinkToolbar;
608
+ updateLink: (href: string, text: string) => import("@atlaskit/editor-common/types").EditorCommand;
609
+ removeLink: () => import("@atlaskit/editor-common/types").EditorCommand;
579
610
  };
580
611
  sharedState: import("@atlaskit/editor-common/link").HyperlinkState | undefined;
581
612
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>,
@@ -595,6 +626,7 @@ declare const _default: import("react").FC<import("react-intl-next").WithIntlPro
595
626
  inputMethod: INPUT_METHOD;
596
627
  editorAnalyticsAPI: import("@atlaskit/editor-common/analytics").EditorAnalyticsAPI | undefined;
597
628
  }) => import("@atlaskit/editor-common/types").EditorCommand;
629
+ insertLoom: (video: import("..").VideoMeta, positionType: import("../types").PositionType) => boolean;
598
630
  };
599
631
  }> | undefined;
600
632
  } & WrappedComponentProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-loom",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "Loom plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,12 +36,12 @@
36
36
  ".": "./src/index.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@atlaskit/editor-common": "^86.0.0",
40
- "@atlaskit/editor-plugin-analytics": "^1.4.0",
41
- "@atlaskit/editor-plugin-hyperlink": "^2.3.0",
42
- "@atlaskit/editor-plugin-primary-toolbar": "^1.2.0",
43
- "@atlaskit/editor-plugin-width": "^1.1.0",
44
- "@atlaskit/editor-prosemirror": "4.0.1",
39
+ "@atlaskit/editor-common": "^86.8.0",
40
+ "@atlaskit/editor-plugin-analytics": "^1.6.0",
41
+ "@atlaskit/editor-plugin-hyperlink": "^2.6.0",
42
+ "@atlaskit/editor-plugin-primary-toolbar": "^1.3.0",
43
+ "@atlaskit/editor-plugin-width": "^1.2.0",
44
+ "@atlaskit/editor-prosemirror": "5.0.1",
45
45
  "@atlaskit/logo": "^14.1.0",
46
46
  "@atlaskit/platform-feature-flags": "0.3.0",
47
47
  "@babel/runtime": "^7.0.0",
@@ -58,14 +58,14 @@
58
58
  }
59
59
  },
60
60
  "devDependencies": {
61
- "@atlaskit/editor-plugin-base": "^1.7.0",
62
- "@atlaskit/editor-plugin-card": "^2.6.0",
63
- "@atlaskit/editor-plugin-copy-button": "^1.1.0",
64
- "@atlaskit/editor-plugin-decorations": "^1.1.0",
65
- "@atlaskit/editor-plugin-editor-disabled": "^1.1.0",
66
- "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
67
- "@atlaskit/editor-plugin-floating-toolbar": "^1.7.0",
68
- "@atlaskit/editor-plugin-grid": "^1.1.0",
61
+ "@atlaskit/editor-plugin-base": "^1.9.0",
62
+ "@atlaskit/editor-plugin-card": "^2.8.0",
63
+ "@atlaskit/editor-plugin-copy-button": "^1.2.0",
64
+ "@atlaskit/editor-plugin-decorations": "^1.2.0",
65
+ "@atlaskit/editor-plugin-editor-disabled": "^1.2.0",
66
+ "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
67
+ "@atlaskit/editor-plugin-floating-toolbar": "^1.9.0",
68
+ "@atlaskit/editor-plugin-grid": "^1.2.0",
69
69
  "@testing-library/react": "^12.1.5",
70
70
  "@testing-library/user-event": "^14.4.3",
71
71
  "raf-stub": "^2.0.1",