@atlaskit/editor-plugin-synced-block 5.0.0 → 5.1.1

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 (40) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-jira/tsconfig.json +3 -0
  4. package/afm-products/tsconfig.json +3 -0
  5. package/dist/cjs/editor-commands/index.js +7 -1
  6. package/dist/cjs/nodeviews/syncedBlock.js +7 -3
  7. package/dist/cjs/pm-plugins/experience-tracking/create-reference-experience.js +113 -0
  8. package/dist/cjs/pm-plugins/experience-tracking/create-source-experience.js +185 -0
  9. package/dist/cjs/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +31 -0
  10. package/dist/cjs/pm-plugins/main.js +18 -1
  11. package/dist/cjs/syncedBlockPlugin.js +21 -3
  12. package/dist/cjs/ui/CreateSyncedBlockButton.js +1 -0
  13. package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +1 -0
  14. package/dist/es2019/editor-commands/index.js +7 -1
  15. package/dist/es2019/nodeviews/syncedBlock.js +6 -3
  16. package/dist/es2019/pm-plugins/experience-tracking/create-reference-experience.js +105 -0
  17. package/dist/es2019/pm-plugins/experience-tracking/create-source-experience.js +179 -0
  18. package/dist/es2019/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +22 -0
  19. package/dist/es2019/pm-plugins/main.js +18 -1
  20. package/dist/es2019/syncedBlockPlugin.js +21 -3
  21. package/dist/es2019/ui/CreateSyncedBlockButton.js +1 -0
  22. package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +1 -0
  23. package/dist/esm/editor-commands/index.js +7 -1
  24. package/dist/esm/nodeviews/syncedBlock.js +6 -2
  25. package/dist/esm/pm-plugins/experience-tracking/create-reference-experience.js +106 -0
  26. package/dist/esm/pm-plugins/experience-tracking/create-source-experience.js +178 -0
  27. package/dist/esm/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +25 -0
  28. package/dist/esm/pm-plugins/main.js +18 -1
  29. package/dist/esm/syncedBlockPlugin.js +21 -3
  30. package/dist/esm/ui/CreateSyncedBlockButton.js +1 -0
  31. package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +1 -0
  32. package/dist/types/nodeviews/syncedBlock.d.ts +13 -0
  33. package/dist/types/pm-plugins/experience-tracking/create-reference-experience.d.ts +17 -0
  34. package/dist/types/pm-plugins/experience-tracking/create-source-experience.d.ts +21 -0
  35. package/dist/types/pm-plugins/experience-tracking/get-experience-tracking-plugins.d.ts +16 -0
  36. package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +13 -0
  37. package/dist/types-ts4.5/pm-plugins/experience-tracking/create-reference-experience.d.ts +17 -0
  38. package/dist/types-ts4.5/pm-plugins/experience-tracking/create-source-experience.d.ts +21 -0
  39. package/dist/types-ts4.5/pm-plugins/experience-tracking/get-experience-tracking-plugins.d.ts +16 -0
  40. package/package.json +12 -5
@@ -0,0 +1,178 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { bind } from 'bind-event-listener';
3
+ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
4
+ import { Experience, ExperienceCheckDomMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView, popupWithNestedElement } from '@atlaskit/editor-common/experiences';
5
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
7
+ var pluginKey = new PluginKey('createSourceSyncBlockExperience');
8
+ var ABORT_REASON = {
9
+ EDITOR_DESTROYED: 'editor-destroyed'
10
+ };
11
+ var START_METHOD = {
12
+ BLOCK_MENU: 'block-menu',
13
+ PINNED_TOOLBAR: 'pinned-toolbar',
14
+ QUICK_INSERT: 'quick-insert'
15
+ };
16
+ var SYNCED_BLOCK_CREATE_BUTTON_IDS = ['create-synced-block-toolbar-btn', 'create-synced-block-block-menu-btn', 'create-synced-block-quick-insert-btn'];
17
+ var syncedBlockCreateButtonIds = new Set(SYNCED_BLOCK_CREATE_BUTTON_IDS);
18
+
19
+ /**
20
+ * This experience tracks when a source sync block is inserted.
21
+ *
22
+ * Start: When user inserts a sync block via block menu, quick insert or pinned toolbar
23
+ * Success: When the sync block is added to the DOM within 2000ms of start
24
+ * Failure: When 500ms passes without the source sync block being added to the DOM
25
+ */
26
+ export var getCreateSourceExperiencePlugin = function getCreateSourceExperiencePlugin(_ref) {
27
+ var refs = _ref.refs,
28
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
29
+ syncBlockStore = _ref.syncBlockStore;
30
+ var popupsTargetEl;
31
+ var editorViewEl;
32
+ var getPopupsTarget = function getPopupsTarget() {
33
+ if (!popupsTargetEl) {
34
+ popupsTargetEl = refs.popupsMountPoint || refs.wrapperElement || getPopupContainerFromEditorView(editorViewEl);
35
+ }
36
+ return popupsTargetEl;
37
+ };
38
+ var experience = getCreateSourceExperience({
39
+ refs: refs,
40
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
41
+ syncBlockStore: syncBlockStore
42
+ });
43
+ syncBlockStore.sourceManager.setCreateExperience(experience);
44
+ var unbindClickListener = bind(document, {
45
+ type: 'click',
46
+ listener: function listener(event) {
47
+ var target = event.target;
48
+ if (!target) {
49
+ return;
50
+ }
51
+ var button = target.closest('button[data-testid]');
52
+ if (!button || !(button instanceof HTMLButtonElement)) {
53
+ return;
54
+ }
55
+ var testId = button.dataset.testid;
56
+ if (!isSyncedBlockCreateButtonId(testId)) {
57
+ return;
58
+ }
59
+ handleButtonClick(testId, experience);
60
+ }
61
+ });
62
+ var unbindKeydownListener = bind(document, {
63
+ type: 'keydown',
64
+ listener: function listener(event) {
65
+ if (isEnterKey(event.key)) {
66
+ var typeaheadPopup = popupWithNestedElement(getPopupsTarget(), '.fabric-editor-typeahead');
67
+ if (!typeaheadPopup || !(typeaheadPopup instanceof HTMLElement)) {
68
+ return;
69
+ }
70
+ var firstItem = typeaheadPopup.querySelector('[role="option"]');
71
+ if (!firstItem || !(firstItem instanceof HTMLElement)) {
72
+ return;
73
+ }
74
+ var testId = firstItem.dataset.testid;
75
+ if (testId === 'create-synced-block-quick-insert-btn') {
76
+ experience.start({
77
+ method: START_METHOD.QUICK_INSERT
78
+ });
79
+ }
80
+ }
81
+ },
82
+ options: {
83
+ capture: true
84
+ }
85
+ });
86
+ return new SafePlugin({
87
+ key: pluginKey,
88
+ view: function view(editorView) {
89
+ editorViewEl = editorView.dom;
90
+ return {
91
+ destroy: function destroy() {
92
+ experience.abort({
93
+ reason: ABORT_REASON.EDITOR_DESTROYED
94
+ });
95
+ unbindClickListener();
96
+ unbindKeydownListener();
97
+ }
98
+ };
99
+ }
100
+ });
101
+ };
102
+ var getCreateSourceExperience = function getCreateSourceExperience(_ref2) {
103
+ var refs = _ref2.refs,
104
+ dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
105
+ return new Experience(ACTION_SUBJECT.SYNCED_BLOCK, {
106
+ actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
107
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
108
+ checks: [new ExperienceCheckTimeout({
109
+ durationMs: 2000
110
+ }), new ExperienceCheckDomMutation({
111
+ onDomMutation: function onDomMutation(_ref3) {
112
+ var mutations = _ref3.mutations;
113
+ if (mutations.some(isSourceSyncBlockAddedInMutation)) {
114
+ return {
115
+ status: 'success'
116
+ };
117
+ }
118
+ return undefined;
119
+ },
120
+ observeConfig: function observeConfig() {
121
+ var _refs$containerElemen;
122
+ var proseMirrorElement = (_refs$containerElemen = refs.containerElement) === null || _refs$containerElemen === void 0 ? void 0 : _refs$containerElemen.querySelector('.ProseMirror');
123
+ if (!proseMirrorElement || !(proseMirrorElement instanceof HTMLElement)) {
124
+ return null;
125
+ }
126
+ return {
127
+ target: proseMirrorElement,
128
+ options: {
129
+ childList: true
130
+ }
131
+ };
132
+ }
133
+ })]
134
+ });
135
+ };
136
+ var isSyncedBlockCreateButtonId = function isSyncedBlockCreateButtonId(value) {
137
+ return !!value && syncedBlockCreateButtonIds.has(value);
138
+ };
139
+ var handleButtonClick = function handleButtonClick(testId, experience) {
140
+ switch (testId) {
141
+ case 'create-synced-block-toolbar-btn':
142
+ experience.start({
143
+ method: START_METHOD.PINNED_TOOLBAR
144
+ });
145
+ break;
146
+ case 'create-synced-block-block-menu-btn':
147
+ experience.start({
148
+ method: START_METHOD.BLOCK_MENU
149
+ });
150
+ break;
151
+ case 'create-synced-block-quick-insert-btn':
152
+ experience.start({
153
+ method: START_METHOD.QUICK_INSERT
154
+ });
155
+ break;
156
+ default:
157
+ {
158
+ // Exhaustiveness check: if a new SyncedBlockToolbarButtonId is added
159
+ // but not handled above, TypeScript will error here.
160
+ var _exhaustiveCheck = testId;
161
+ return _exhaustiveCheck;
162
+ }
163
+ }
164
+ };
165
+ var isEnterKey = function isEnterKey(key) {
166
+ return key === 'Enter';
167
+ };
168
+ var isSourceSyncBlockAddedInMutation = function isSourceSyncBlockAddedInMutation(_ref4) {
169
+ var type = _ref4.type,
170
+ addedNodes = _ref4.addedNodes;
171
+ return type === 'childList' && _toConsumableArray(addedNodes).some(isSourceSyncBlockNode);
172
+ };
173
+ var isSourceSyncBlockNode = function isSourceSyncBlockNode(node) {
174
+ if (!(node instanceof HTMLElement)) {
175
+ return false;
176
+ }
177
+ return !!node.querySelector('[data-prosemirror-node-name="bodiedSyncBlock"]');
178
+ };
@@ -0,0 +1,25 @@
1
+ import { getCreateReferenceExperiencePlugin } from "./create-reference-experience";
2
+ import { getCreateSourceExperiencePlugin } from "./create-source-experience";
3
+ export var getExperienceTrackingPlugins = function getExperienceTrackingPlugins(_ref) {
4
+ var refs = _ref.refs,
5
+ dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
6
+ syncBlockStore = _ref.syncBlockStore;
7
+ return [{
8
+ name: 'createReferenceSyncedBlockExperiencePlugin',
9
+ plugin: function plugin() {
10
+ return getCreateReferenceExperiencePlugin({
11
+ refs: refs,
12
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent
13
+ });
14
+ }
15
+ }, {
16
+ name: 'createSourceSyncedBlockExperiencePlugin',
17
+ plugin: function plugin() {
18
+ return getCreateSourceExperiencePlugin({
19
+ refs: refs,
20
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
21
+ syncBlockStore: syncBlockStore
22
+ });
23
+ }
24
+ }];
25
+ };
@@ -12,8 +12,10 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
12
12
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
13
13
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
14
14
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
16
17
  import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
18
+ import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
17
19
  import { FLAG_ID } from '../types';
18
20
  import { handleBodiedSyncBlockRemoval } from './utils/handle-bodied-sync-block-removal';
19
21
  import { shouldIgnoreDomEvent } from './utils/ignore-dom-event';
@@ -77,7 +79,22 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
77
79
  },
78
80
  props: {
79
81
  nodeViews: {
80
- syncBlock: lazySyncBlockView({
82
+ syncBlock: fg('platform_synced_block_dogfooding') ? function (node, view, getPos, _decorations) {
83
+ // To support SSR, pass `syncBlockStore` here
84
+ // and do not use lazy loading.
85
+ // We cannot start rendering and then load `syncBlockStore` asynchronously,
86
+ // because obtaining it is asynchronous (sharedPluginState.currentState() is delayed).
87
+ return new SyncBlockView({
88
+ api: api,
89
+ options: options,
90
+ node: node,
91
+ view: view,
92
+ getPos: getPos,
93
+ portalProviderAPI: pmPluginFactoryParams.portalProviderAPI,
94
+ eventDispatcher: pmPluginFactoryParams.eventDispatcher,
95
+ syncBlockStore: syncBlockStore
96
+ }).init();
97
+ } : lazySyncBlockView({
81
98
  options: options,
82
99
  pmPluginFactoryParams: pmPluginFactoryParams,
83
100
  api: api
@@ -1,11 +1,14 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import React from 'react';
2
3
  import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
3
4
  import { blockTypeMessages } from '@atlaskit/editor-common/messages';
4
5
  import { IconSyncBlock } from '@atlaskit/editor-common/quick-insert';
5
6
  import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
6
7
  import Lozenge from '@atlaskit/lozenge';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
7
9
  import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
8
10
  import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
11
+ import { getExperienceTrackingPlugins } from './pm-plugins/experience-tracking/get-experience-tracking-plugins';
9
12
  import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
10
13
  import { getBlockMenuComponents } from './ui/block-menu-components';
11
14
  import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
@@ -17,6 +20,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
17
20
  var _api$analytics, _api$blockMenu, _config$enableSourceC, _api$toolbar, _config$enableSourceC2;
18
21
  var config = _ref.config,
19
22
  api = _ref.api;
23
+ var refs = {};
20
24
  var syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider);
21
25
  syncBlockStore.setFireAnalyticsEvent(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent);
22
26
  api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
@@ -38,7 +42,14 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
38
42
  plugin: function plugin(params) {
39
43
  return createPlugin(config, params, syncBlockStore, api);
40
44
  }
41
- }];
45
+ }].concat(_toConsumableArray(fg('platform_synced_block_dogfooding') ? getExperienceTrackingPlugins({
46
+ refs: refs,
47
+ dispatchAnalyticsEvent: function dispatchAnalyticsEvent(payload) {
48
+ var _api$analytics2;
49
+ return api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent(payload);
50
+ },
51
+ syncBlockStore: syncBlockStore
52
+ }) : []));
42
53
  },
43
54
  commands: {
44
55
  copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
@@ -93,14 +104,21 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
93
104
  syncBlockStore: syncBlockStore,
94
105
  typeAheadInsert: insert
95
106
  });
96
- }
107
+ },
108
+ testId: fg('platform_synced_block_dogfooding') ? 'create-synced-block-quick-insert-btn' : undefined
97
109
  }];
98
110
  },
99
111
  floatingToolbar: function floatingToolbar(state, intl) {
100
112
  return getToolbarConfig(state, intl, api, syncBlockStore);
101
113
  }
102
114
  },
103
- contentComponent: function contentComponent() {
115
+ contentComponent: function contentComponent(_ref4) {
116
+ var containerElement = _ref4.containerElement,
117
+ wrapperElement = _ref4.wrapperElement,
118
+ popupsMountPoint = _ref4.popupsMountPoint;
119
+ refs.containerElement = containerElement || undefined;
120
+ refs.popupsMountPoint = popupsMountPoint || undefined;
121
+ refs.wrapperElement = wrapperElement || undefined;
104
122
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SyncBlockRefresher, {
105
123
  syncBlockStoreManager: syncBlockStore,
106
124
  api: api
@@ -44,6 +44,7 @@ export var CreateSyncedBlockButton = function CreateSyncedBlockButton(_ref) {
44
44
  label: ""
45
45
  }),
46
46
  isDisabled: isDisabled,
47
+ testId: "create-synced-block-toolbar-btn",
47
48
  onClick: onClick
48
49
  }));
49
50
  };
@@ -42,6 +42,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
42
42
  }),
43
43
  onClick: onClick,
44
44
  isDisabled: isOffline,
45
+ testId: "create-synced-block-block-menu-btn",
45
46
  elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
46
47
  appearance: "new"
47
48
  }, formatMessage(blockMenuMessages.newLozenge))
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
@@ -5,6 +6,7 @@ import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-vie
5
6
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
6
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
+ import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
8
10
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
9
11
  export interface SyncBlockNodeViewProps extends ReactComponentProps {
10
12
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
@@ -14,8 +16,19 @@ export interface SyncBlockNodeViewProps extends ReactComponentProps {
14
16
  node: PMNode;
15
17
  options: SyncedBlockPluginOptions | undefined;
16
18
  portalProviderAPI: PortalProviderAPI;
19
+ syncBlockStore?: SyncBlockStoreManager;
17
20
  view: EditorView;
18
21
  }
22
+ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
23
+ private options;
24
+ private api?;
25
+ private syncBlockStore?;
26
+ constructor(props: SyncBlockNodeViewProps);
27
+ unsubscribe: (() => void) | undefined;
28
+ createDomRef(): HTMLElement;
29
+ render(): React.JSX.Element | null;
30
+ destroy(): void;
31
+ }
19
32
  export interface SyncBlockNodeViewProperties {
20
33
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
21
34
  options: SyncedBlockPluginOptions | undefined;
@@ -0,0 +1,17 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ type CreateReferenceExperienceOptions = {
4
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
5
+ refs: {
6
+ containerElement?: HTMLElement;
7
+ };
8
+ };
9
+ /**
10
+ * This experience tracks when a reference sync block is inserted.
11
+ *
12
+ * Start: When user pastes a sync block from editor and createSyncedBlock is called
13
+ * Success: When the sync block is added to the DOM within 500ms of start
14
+ * Failure: When 500ms passes without the reference sync block being added to the DOM
15
+ */
16
+ export declare const getCreateReferenceExperiencePlugin: ({ refs, dispatchAnalyticsEvent, }: CreateReferenceExperienceOptions) => SafePlugin<any>;
17
+ export {};
@@ -0,0 +1,21 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
+ type CreateSourceExperienceOptions = {
5
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
6
+ refs: {
7
+ containerElement?: HTMLElement;
8
+ popupsMountPoint?: HTMLElement;
9
+ wrapperElement?: HTMLElement;
10
+ };
11
+ syncBlockStore: SyncBlockStoreManager;
12
+ };
13
+ /**
14
+ * This experience tracks when a source sync block is inserted.
15
+ *
16
+ * Start: When user inserts a sync block via block menu, quick insert or pinned toolbar
17
+ * Success: When the sync block is added to the DOM within 2000ms of start
18
+ * Failure: When 500ms passes without the source sync block being added to the DOM
19
+ */
20
+ export declare const getCreateSourceExperiencePlugin: ({ refs, dispatchAnalyticsEvent, syncBlockStore, }: CreateSourceExperienceOptions) => SafePlugin<any>;
21
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { DispatchAnalyticsEvent } from "@atlaskit/editor-common/analytics";
2
+ import type { SyncBlockStoreManager } from "@atlaskit/editor-synced-block-provider";
3
+ type ExperienceTrackingPluginsProps = {
4
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
5
+ refs: {
6
+ containerElement?: HTMLElement;
7
+ popupsMountPoint?: HTMLElement;
8
+ wrapperElement?: HTMLElement;
9
+ };
10
+ syncBlockStore: SyncBlockStoreManager;
11
+ };
12
+ export declare const getExperienceTrackingPlugins: ({ refs, dispatchAnalyticsEvent, syncBlockStore }: ExperienceTrackingPluginsProps) => {
13
+ name: string;
14
+ plugin: () => import("@atlaskit/editor-common/safe-plugin").SafePlugin<any>;
15
+ }[];
16
+ export {};
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
@@ -5,6 +6,7 @@ import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-vie
5
6
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
6
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
+ import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
8
10
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
9
11
  export interface SyncBlockNodeViewProps extends ReactComponentProps {
10
12
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
@@ -14,8 +16,19 @@ export interface SyncBlockNodeViewProps extends ReactComponentProps {
14
16
  node: PMNode;
15
17
  options: SyncedBlockPluginOptions | undefined;
16
18
  portalProviderAPI: PortalProviderAPI;
19
+ syncBlockStore?: SyncBlockStoreManager;
17
20
  view: EditorView;
18
21
  }
22
+ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
23
+ private options;
24
+ private api?;
25
+ private syncBlockStore?;
26
+ constructor(props: SyncBlockNodeViewProps);
27
+ unsubscribe: (() => void) | undefined;
28
+ createDomRef(): HTMLElement;
29
+ render(): React.JSX.Element | null;
30
+ destroy(): void;
31
+ }
19
32
  export interface SyncBlockNodeViewProperties {
20
33
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
21
34
  options: SyncedBlockPluginOptions | undefined;
@@ -0,0 +1,17 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ type CreateReferenceExperienceOptions = {
4
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
5
+ refs: {
6
+ containerElement?: HTMLElement;
7
+ };
8
+ };
9
+ /**
10
+ * This experience tracks when a reference sync block is inserted.
11
+ *
12
+ * Start: When user pastes a sync block from editor and createSyncedBlock is called
13
+ * Success: When the sync block is added to the DOM within 500ms of start
14
+ * Failure: When 500ms passes without the reference sync block being added to the DOM
15
+ */
16
+ export declare const getCreateReferenceExperiencePlugin: ({ refs, dispatchAnalyticsEvent, }: CreateReferenceExperienceOptions) => SafePlugin<any>;
17
+ export {};
@@ -0,0 +1,21 @@
1
+ import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
+ type CreateSourceExperienceOptions = {
5
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
6
+ refs: {
7
+ containerElement?: HTMLElement;
8
+ popupsMountPoint?: HTMLElement;
9
+ wrapperElement?: HTMLElement;
10
+ };
11
+ syncBlockStore: SyncBlockStoreManager;
12
+ };
13
+ /**
14
+ * This experience tracks when a source sync block is inserted.
15
+ *
16
+ * Start: When user inserts a sync block via block menu, quick insert or pinned toolbar
17
+ * Success: When the sync block is added to the DOM within 2000ms of start
18
+ * Failure: When 500ms passes without the source sync block being added to the DOM
19
+ */
20
+ export declare const getCreateSourceExperiencePlugin: ({ refs, dispatchAnalyticsEvent, syncBlockStore, }: CreateSourceExperienceOptions) => SafePlugin<any>;
21
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { DispatchAnalyticsEvent } from "@atlaskit/editor-common/analytics";
2
+ import type { SyncBlockStoreManager } from "@atlaskit/editor-synced-block-provider";
3
+ type ExperienceTrackingPluginsProps = {
4
+ dispatchAnalyticsEvent: DispatchAnalyticsEvent;
5
+ refs: {
6
+ containerElement?: HTMLElement;
7
+ popupsMountPoint?: HTMLElement;
8
+ wrapperElement?: HTMLElement;
9
+ };
10
+ syncBlockStore: SyncBlockStoreManager;
11
+ };
12
+ export declare const getExperienceTrackingPlugins: ({ refs, dispatchAnalyticsEvent, syncBlockStore }: ExperienceTrackingPluginsProps) => {
13
+ name: string;
14
+ plugin: () => import("@atlaskit/editor-common/safe-plugin").SafePlugin<any>;
15
+ }[];
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.0.0",
3
+ "version": "5.1.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,11 +35,11 @@
35
35
  "@atlaskit/editor-plugin-block-menu": "^6.0.0",
36
36
  "@atlaskit/editor-plugin-connectivity": "7.0.0",
37
37
  "@atlaskit/editor-plugin-decorations": "^7.0.0",
38
- "@atlaskit/editor-plugin-floating-toolbar": "^9.0.0",
38
+ "@atlaskit/editor-plugin-floating-toolbar": "^9.1.0",
39
39
  "@atlaskit/editor-plugin-selection": "^7.0.0",
40
40
  "@atlaskit/editor-prosemirror": "^7.2.0",
41
41
  "@atlaskit/editor-shared-styles": "^3.10.0",
42
- "@atlaskit/editor-synced-block-provider": "^3.0.0",
42
+ "@atlaskit/editor-synced-block-provider": "^3.4.0",
43
43
  "@atlaskit/editor-tables": "^2.9.0",
44
44
  "@atlaskit/editor-toolbar": "^0.18.0",
45
45
  "@atlaskit/flag": "^17.7.0",
@@ -47,16 +47,18 @@
47
47
  "@atlaskit/icon-lab": "^5.13.0",
48
48
  "@atlaskit/lozenge": "^13.3.0",
49
49
  "@atlaskit/modal-dialog": "^14.9.0",
50
+ "@atlaskit/platform-feature-flags": "^1.1.0",
50
51
  "@atlaskit/primitives": "^17.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^16.3.0",
52
+ "@atlaskit/tmp-editor-statsig": "^16.4.0",
52
53
  "@atlaskit/tokens": "9.0.0",
53
54
  "@atlaskit/tooltip": "^20.11.0",
54
55
  "@atlaskit/visually-hidden": "^3.0.0",
55
56
  "@babel/runtime": "^7.0.0",
57
+ "bind-event-listener": "^3.0.0",
56
58
  "react-intl-next": "npm:react-intl@^5.18.1"
57
59
  },
58
60
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^111.0.0",
61
+ "@atlaskit/editor-common": "^111.2.0",
60
62
  "react": "^18.2.0"
61
63
  },
62
64
  "devDependencies": {
@@ -97,5 +99,10 @@
97
99
  "import-no-extraneous-disable-for-examples-and-docs"
98
100
  ]
99
101
  }
102
+ },
103
+ "platform-feature-flags": {
104
+ "platform_synced_block_dogfooding": {
105
+ "type": "boolean"
106
+ }
100
107
  }
101
108
  }