@atlaskit/editor-plugin-synced-block 5.2.0 → 5.2.2
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 +15 -0
- package/afm-jira/tsconfig.json +1 -1
- package/dist/cjs/editor-commands/index.js +10 -4
- package/dist/cjs/pm-plugins/menu-and-toolbar-experiences.js +267 -0
- package/dist/cjs/syncedBlockPlugin.js +21 -12
- package/dist/cjs/types/index.js +6 -3
- package/dist/cjs/ui/CreateSyncedBlockButton.js +2 -1
- package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +2 -1
- package/dist/cjs/ui/floating-toolbar.js +2 -1
- package/dist/es2019/editor-commands/index.js +10 -4
- package/dist/es2019/pm-plugins/menu-and-toolbar-experiences.js +261 -0
- package/dist/es2019/syncedBlockPlugin.js +19 -12
- package/dist/es2019/types/index.js +5 -2
- package/dist/es2019/ui/CreateSyncedBlockButton.js +2 -1
- package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +2 -1
- package/dist/es2019/ui/floating-toolbar.js +2 -1
- package/dist/esm/editor-commands/index.js +10 -4
- package/dist/esm/pm-plugins/menu-and-toolbar-experiences.js +260 -0
- package/dist/esm/syncedBlockPlugin.js +21 -12
- package/dist/esm/types/index.js +5 -2
- package/dist/esm/ui/CreateSyncedBlockButton.js +2 -1
- package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +2 -1
- package/dist/esm/ui/floating-toolbar.js +2 -1
- package/dist/types/editor-commands/index.d.ts +3 -1
- package/dist/types/pm-plugins/menu-and-toolbar-experiences.d.ts +12 -0
- package/dist/types/types/index.d.ts +5 -14
- package/dist/types-ts4.5/editor-commands/index.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/menu-and-toolbar-experiences.d.ts +12 -0
- package/dist/types-ts4.5/types/index.d.ts +5 -14
- package/package.json +4 -4
- package/dist/cjs/pm-plugins/experience-tracking/create-reference-experience.js +0 -113
- package/dist/cjs/pm-plugins/experience-tracking/create-source-experience.js +0 -169
- package/dist/cjs/pm-plugins/experience-tracking/delete-reference-experience.js +0 -175
- package/dist/cjs/pm-plugins/experience-tracking/delete-source-experience.js +0 -103
- package/dist/cjs/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +0 -61
- package/dist/cjs/pm-plugins/experience-tracking/provider-only-experiences.js +0 -128
- package/dist/cjs/pm-plugins/utils/experience-tracking-utils.js +0 -85
- package/dist/es2019/pm-plugins/experience-tracking/create-reference-experience.js +0 -109
- package/dist/es2019/pm-plugins/experience-tracking/create-source-experience.js +0 -166
- package/dist/es2019/pm-plugins/experience-tracking/delete-reference-experience.js +0 -181
- package/dist/es2019/pm-plugins/experience-tracking/delete-source-experience.js +0 -98
- package/dist/es2019/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +0 -46
- package/dist/es2019/pm-plugins/experience-tracking/provider-only-experiences.js +0 -127
- package/dist/es2019/pm-plugins/utils/experience-tracking-utils.js +0 -65
- package/dist/esm/pm-plugins/experience-tracking/create-reference-experience.js +0 -107
- package/dist/esm/pm-plugins/experience-tracking/create-source-experience.js +0 -163
- package/dist/esm/pm-plugins/experience-tracking/delete-reference-experience.js +0 -169
- package/dist/esm/pm-plugins/experience-tracking/delete-source-experience.js +0 -97
- package/dist/esm/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +0 -55
- package/dist/esm/pm-plugins/experience-tracking/provider-only-experiences.js +0 -122
- package/dist/esm/pm-plugins/utils/experience-tracking-utils.js +0 -79
- package/dist/types/pm-plugins/experience-tracking/create-reference-experience.d.ts +0 -10
- package/dist/types/pm-plugins/experience-tracking/create-source-experience.d.ts +0 -10
- package/dist/types/pm-plugins/experience-tracking/delete-reference-experience.d.ts +0 -13
- package/dist/types/pm-plugins/experience-tracking/delete-source-experience.d.ts +0 -12
- package/dist/types/pm-plugins/experience-tracking/get-experience-tracking-plugins.d.ts +0 -5
- package/dist/types/pm-plugins/experience-tracking/provider-only-experiences.d.ts +0 -3
- package/dist/types/pm-plugins/utils/experience-tracking-utils.d.ts +0 -9
- package/dist/types-ts4.5/pm-plugins/experience-tracking/create-reference-experience.d.ts +0 -10
- package/dist/types-ts4.5/pm-plugins/experience-tracking/create-source-experience.d.ts +0 -10
- package/dist/types-ts4.5/pm-plugins/experience-tracking/delete-reference-experience.d.ts +0 -13
- package/dist/types-ts4.5/pm-plugins/experience-tracking/delete-source-experience.d.ts +0 -12
- package/dist/types-ts4.5/pm-plugins/experience-tracking/get-experience-tracking-plugins.d.ts +0 -5
- package/dist/types-ts4.5/pm-plugins/experience-tracking/provider-only-experiences.d.ts +0 -3
- package/dist/types-ts4.5/pm-plugins/utils/experience-tracking-utils.d.ts +0 -9
|
@@ -8,8 +8,9 @@ import Lozenge from '@atlaskit/lozenge';
|
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
10
10
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
11
|
-
import { getExperienceTrackingPlugins } from './pm-plugins/experience-tracking/get-experience-tracking-plugins';
|
|
12
11
|
import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
|
|
12
|
+
import { getMenuAndToolbarExperiencesPlugin } from './pm-plugins/menu-and-toolbar-experiences';
|
|
13
|
+
import { SYNCED_BLOCK_BUTTON_TEST_ID } from './types';
|
|
13
14
|
import { getBlockMenuComponents } from './ui/block-menu-components';
|
|
14
15
|
import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
|
|
15
16
|
import { Flag } from './ui/Flag';
|
|
@@ -42,14 +43,18 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
42
43
|
plugin: function plugin(params) {
|
|
43
44
|
return createPlugin(config, params, syncBlockStore, api);
|
|
44
45
|
}
|
|
45
|
-
}].concat(_toConsumableArray(fg('platform_synced_block_dogfooding') ?
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
}].concat(_toConsumableArray(fg('platform_synced_block_dogfooding') ? [{
|
|
47
|
+
name: 'menuAndToolbarExperiencesPlugin',
|
|
48
|
+
plugin: function plugin() {
|
|
49
|
+
return getMenuAndToolbarExperiencesPlugin({
|
|
50
|
+
refs: refs,
|
|
51
|
+
dispatchAnalyticsEvent: function dispatchAnalyticsEvent(payload) {
|
|
52
|
+
var _api$analytics2;
|
|
53
|
+
return api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.fireAnalyticsEvent(payload);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}] : []));
|
|
53
58
|
},
|
|
54
59
|
commands: {
|
|
55
60
|
copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
|
|
@@ -57,13 +62,15 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
57
62
|
},
|
|
58
63
|
insertSyncedBlock: function insertSyncedBlock() {
|
|
59
64
|
return function (_ref2) {
|
|
65
|
+
var _api$analytics3;
|
|
60
66
|
var tr = _ref2.tr;
|
|
61
67
|
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
62
68
|
return null;
|
|
63
69
|
}
|
|
64
70
|
return createSyncedBlock({
|
|
65
71
|
tr: tr,
|
|
66
|
-
syncBlockStore: syncBlockStore
|
|
72
|
+
syncBlockStore: syncBlockStore,
|
|
73
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent
|
|
67
74
|
}) || null;
|
|
68
75
|
};
|
|
69
76
|
}
|
|
@@ -99,13 +106,15 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
99
106
|
});
|
|
100
107
|
},
|
|
101
108
|
action: function action(insert, state) {
|
|
109
|
+
var _api$analytics4;
|
|
102
110
|
return createSyncedBlock({
|
|
103
111
|
tr: state.tr,
|
|
104
112
|
syncBlockStore: syncBlockStore,
|
|
105
|
-
typeAheadInsert: insert
|
|
113
|
+
typeAheadInsert: insert,
|
|
114
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.fireAnalyticsEvent
|
|
106
115
|
});
|
|
107
116
|
},
|
|
108
|
-
testId: fg('platform_synced_block_dogfooding') ?
|
|
117
|
+
testId: fg('platform_synced_block_dogfooding') ? SYNCED_BLOCK_BUTTON_TEST_ID.quickInsertCreate : undefined
|
|
109
118
|
}];
|
|
110
119
|
},
|
|
111
120
|
floatingToolbar: function floatingToolbar(state, intl) {
|
package/dist/esm/types/index.js
CHANGED
|
@@ -6,6 +6,9 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
6
6
|
FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
|
|
7
7
|
return FLAG_ID;
|
|
8
8
|
}({});
|
|
9
|
-
export var
|
|
10
|
-
|
|
9
|
+
export var SYNCED_BLOCK_BUTTON_TEST_ID = {
|
|
10
|
+
primaryToolbarCreate: 'create-synced-block-toolbar-btn',
|
|
11
|
+
blockMenuCreate: 'create-synced-block-block-menu-btn',
|
|
12
|
+
quickInsertCreate: 'create-synced-block-quick-insert-btn',
|
|
13
|
+
syncedBlockToolbarReferenceDelete: 'reference-synced-block-delete-btn'
|
|
11
14
|
};
|
|
@@ -6,6 +6,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
6
6
|
import { ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
7
7
|
import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
|
|
8
8
|
import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
|
|
9
|
+
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
9
10
|
export var CreateSyncedBlockButton = function CreateSyncedBlockButton(_ref) {
|
|
10
11
|
var api = _ref.api;
|
|
11
12
|
var intl = useIntl();
|
|
@@ -44,7 +45,7 @@ export var CreateSyncedBlockButton = function CreateSyncedBlockButton(_ref) {
|
|
|
44
45
|
label: ""
|
|
45
46
|
}),
|
|
46
47
|
isDisabled: isDisabled,
|
|
47
|
-
testId:
|
|
48
|
+
testId: SYNCED_BLOCK_BUTTON_TEST_ID.primaryToolbarCreate,
|
|
48
49
|
onClick: onClick
|
|
49
50
|
}));
|
|
50
51
|
};
|
|
@@ -6,6 +6,7 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
6
6
|
import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
7
7
|
import Lozenge from '@atlaskit/lozenge';
|
|
8
8
|
import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
|
|
9
|
+
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
9
10
|
var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
|
|
10
11
|
var api = _ref.api;
|
|
11
12
|
var _useIntl = useIntl(),
|
|
@@ -42,7 +43,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
|
|
|
42
43
|
}),
|
|
43
44
|
onClick: onClick,
|
|
44
45
|
isDisabled: isOffline,
|
|
45
|
-
testId:
|
|
46
|
+
testId: SYNCED_BLOCK_BUTTON_TEST_ID.blockMenuCreate,
|
|
46
47
|
elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
|
|
47
48
|
appearance: "new"
|
|
48
49
|
}, formatMessage(blockMenuMessages.newLozenge))
|
|
@@ -12,6 +12,7 @@ import EditIcon from '@atlaskit/icon/core/edit';
|
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../editor-commands';
|
|
14
14
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
15
|
+
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
15
16
|
import { SyncedLocationDropdown } from './SyncedLocationDropdown';
|
|
16
17
|
export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore) {
|
|
17
18
|
var _api$decorations, _api$connectivity;
|
|
@@ -45,7 +46,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
45
46
|
title: formatMessage(commonMessages.delete),
|
|
46
47
|
onClick: removeSyncedBlock(api),
|
|
47
48
|
icon: DeleteIcon,
|
|
48
|
-
testId: fg('platform_synced_block_dogfooding') ?
|
|
49
|
+
testId: fg('platform_synced_block_dogfooding') ? SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete : undefined
|
|
49
50
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
50
51
|
items.push(deleteButton);
|
|
51
52
|
} else {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { Command, EditorCommand, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
5
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
5
6
|
type createSyncedBlockProps = {
|
|
7
|
+
fireAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
6
8
|
syncBlockStore: SyncBlockStoreManager;
|
|
7
9
|
tr: Transaction;
|
|
8
10
|
typeAheadInsert?: TypeAheadInsert;
|
|
9
11
|
};
|
|
10
|
-
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
|
|
12
|
+
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, fireAnalyticsEvent, }: createSyncedBlockProps) => false | Transaction;
|
|
11
13
|
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
|
|
12
14
|
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
13
15
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
type ExperienceOptions = {
|
|
4
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
5
|
+
refs: {
|
|
6
|
+
containerElement?: HTMLElement;
|
|
7
|
+
popupsMountPoint?: HTMLElement;
|
|
8
|
+
wrapperElement?: HTMLElement;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const getMenuAndToolbarExperiencesPlugin: ({ refs, dispatchAnalyticsEvent, }: ExperienceOptions) => SafePlugin<any>;
|
|
12
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DispatchAnalyticsEvent } from "@atlaskit/editor-common/analytics";
|
|
2
1
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
3
|
export declare enum FLAG_ID {
|
|
@@ -41,18 +40,10 @@ export type SyncBlockInfo = {
|
|
|
41
40
|
export type SyncBlockMap = {
|
|
42
41
|
[key: string]: SyncBlockInfo;
|
|
43
42
|
};
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
wrapperElement?: HTMLElement;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export type ProviderExperienceOptions = ExperienceOptions & {
|
|
53
|
-
syncBlockStore: SyncBlockStoreManager;
|
|
54
|
-
};
|
|
55
|
-
export declare const EXPERIENCE_ABORT_REASON: {
|
|
56
|
-
EDITOR_DESTROYED: string;
|
|
43
|
+
export declare const SYNCED_BLOCK_BUTTON_TEST_ID: {
|
|
44
|
+
readonly primaryToolbarCreate: "create-synced-block-toolbar-btn";
|
|
45
|
+
readonly blockMenuCreate: "create-synced-block-block-menu-btn";
|
|
46
|
+
readonly quickInsertCreate: "create-synced-block-quick-insert-btn";
|
|
47
|
+
readonly syncedBlockToolbarReferenceDelete: "reference-synced-block-delete-btn";
|
|
57
48
|
};
|
|
58
49
|
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { Command, EditorCommand, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
|
|
2
3
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
5
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
5
6
|
type createSyncedBlockProps = {
|
|
7
|
+
fireAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
6
8
|
syncBlockStore: SyncBlockStoreManager;
|
|
7
9
|
tr: Transaction;
|
|
8
10
|
typeAheadInsert?: TypeAheadInsert;
|
|
9
11
|
};
|
|
10
|
-
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
|
|
12
|
+
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, fireAnalyticsEvent, }: createSyncedBlockProps) => false | Transaction;
|
|
11
13
|
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
|
|
12
14
|
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
13
15
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
type ExperienceOptions = {
|
|
4
|
+
dispatchAnalyticsEvent: DispatchAnalyticsEvent;
|
|
5
|
+
refs: {
|
|
6
|
+
containerElement?: HTMLElement;
|
|
7
|
+
popupsMountPoint?: HTMLElement;
|
|
8
|
+
wrapperElement?: HTMLElement;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const getMenuAndToolbarExperiencesPlugin: ({ refs, dispatchAnalyticsEvent, }: ExperienceOptions) => SafePlugin<any>;
|
|
12
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DispatchAnalyticsEvent } from "@atlaskit/editor-common/analytics";
|
|
2
1
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
3
|
export declare enum FLAG_ID {
|
|
@@ -41,18 +40,10 @@ export type SyncBlockInfo = {
|
|
|
41
40
|
export type SyncBlockMap = {
|
|
42
41
|
[key: string]: SyncBlockInfo;
|
|
43
42
|
};
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
wrapperElement?: HTMLElement;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export type ProviderExperienceOptions = ExperienceOptions & {
|
|
53
|
-
syncBlockStore: SyncBlockStoreManager;
|
|
54
|
-
};
|
|
55
|
-
export declare const EXPERIENCE_ABORT_REASON: {
|
|
56
|
-
EDITOR_DESTROYED: string;
|
|
43
|
+
export declare const SYNCED_BLOCK_BUTTON_TEST_ID: {
|
|
44
|
+
readonly primaryToolbarCreate: "create-synced-block-toolbar-btn";
|
|
45
|
+
readonly blockMenuCreate: "create-synced-block-block-menu-btn";
|
|
46
|
+
readonly quickInsertCreate: "create-synced-block-quick-insert-btn";
|
|
47
|
+
readonly syncedBlockToolbarReferenceDelete: "reference-synced-block-delete-btn";
|
|
57
48
|
};
|
|
58
49
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@atlaskit/editor-plugin-selection": "^7.0.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "^7.2.0",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
43
|
-
"@atlaskit/editor-synced-block-provider": "^3.
|
|
43
|
+
"@atlaskit/editor-synced-block-provider": "^3.12.0",
|
|
44
44
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
45
45
|
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
46
46
|
"@atlaskit/flag": "^17.8.0",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
53
53
|
"@atlaskit/primitives": "^17.1.0",
|
|
54
54
|
"@atlaskit/spinner": "19.0.9",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^16.
|
|
56
|
-
"@atlaskit/tokens": "10.0
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^16.28.0",
|
|
56
|
+
"@atlaskit/tokens": "10.1.0",
|
|
57
57
|
"@atlaskit/tooltip": "^20.14.0",
|
|
58
58
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
59
59
|
"@babel/runtime": "^7.0.0",
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCreateReferenceExperiencePlugin = void 0;
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _experiences = require("@atlaskit/editor-common/experiences");
|
|
9
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var _types = require("../../types");
|
|
12
|
-
var _experienceTrackingUtils = require("../utils/experience-tracking-utils");
|
|
13
|
-
var isPastedFromFabricEditor = function isPastedFromFabricEditor(html) {
|
|
14
|
-
return !!html && html.indexOf('data-pm-slice="') >= 0;
|
|
15
|
-
};
|
|
16
|
-
var pluginKey = new _state.PluginKey('createReferenceSyncBlockExperience');
|
|
17
|
-
var START_METHOD = {
|
|
18
|
-
PASTE: 'paste',
|
|
19
|
-
UNDO: 'undo',
|
|
20
|
-
REDO: 'redo'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* This experience tracks when a reference sync block is inserted.
|
|
25
|
-
*
|
|
26
|
-
* Start: When user pastes a sync block from editor and createSyncedBlock is called
|
|
27
|
-
* Success: When the sync block is added to the DOM within 500ms of start
|
|
28
|
-
* Failure: When 500ms passes without the reference sync block being added to the DOM
|
|
29
|
-
*/
|
|
30
|
-
var getCreateReferenceExperiencePlugin = exports.getCreateReferenceExperiencePlugin = function getCreateReferenceExperiencePlugin(_ref) {
|
|
31
|
-
var refs = _ref.refs,
|
|
32
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
33
|
-
var experience = getCreateReferenceExperience({
|
|
34
|
-
refs: refs,
|
|
35
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
36
|
-
});
|
|
37
|
-
return new _safePlugin.SafePlugin({
|
|
38
|
-
key: pluginKey,
|
|
39
|
-
view: function view() {
|
|
40
|
-
return {
|
|
41
|
-
destroy: function destroy() {
|
|
42
|
-
experience.abort({
|
|
43
|
-
reason: _types.EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
props: {
|
|
49
|
-
handlePaste: function handlePaste(_view, rawEvent, slice) {
|
|
50
|
-
var _event$clipboardData;
|
|
51
|
-
var event = rawEvent;
|
|
52
|
-
var html = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('text/html');
|
|
53
|
-
|
|
54
|
-
// do not start on paste from renderer, because this flattens the content and does not create a reference block
|
|
55
|
-
if (isPastedFromFabricEditor(html)) {
|
|
56
|
-
slice.content.forEach(function (node) {
|
|
57
|
-
if (node.type.name === 'syncBlock' || node.type.name === 'bodiedSyncBlock') {
|
|
58
|
-
experience.start({
|
|
59
|
-
method: START_METHOD.PASTE
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
67
|
-
transactions.forEach(function (tr) {
|
|
68
|
-
var _wasSyncBlockDeletedO = (0, _experienceTrackingUtils.wasSyncBlockDeletedOrAddedByHistory)(tr, oldState, newState),
|
|
69
|
-
hasAddedSyncBlock = _wasSyncBlockDeletedO.hasAddedSyncBlock,
|
|
70
|
-
isUndo = _wasSyncBlockDeletedO.isUndo;
|
|
71
|
-
if (hasAddedSyncBlock) {
|
|
72
|
-
experience.start({
|
|
73
|
-
method: isUndo ? START_METHOD.UNDO : START_METHOD.REDO
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
var getCreateReferenceExperience = function getCreateReferenceExperience(_ref2) {
|
|
82
|
-
var refs = _ref2.refs,
|
|
83
|
-
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
84
|
-
return new _experiences.Experience(_analytics.ACTION_SUBJECT.SYNCED_BLOCK, {
|
|
85
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
86
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
87
|
-
checks: [new _experiences.ExperienceCheckTimeout({
|
|
88
|
-
durationMs: 500
|
|
89
|
-
}), new _experiences.ExperienceCheckDomMutation({
|
|
90
|
-
onDomMutation: function onDomMutation(_ref3) {
|
|
91
|
-
var mutations = _ref3.mutations;
|
|
92
|
-
var insertedResourceIds = (0, _experienceTrackingUtils.getAddedResourceIds)(mutations, '[data-prosemirror-node-name="syncBlock"]');
|
|
93
|
-
if (insertedResourceIds.length > 0) {
|
|
94
|
-
return {
|
|
95
|
-
status: 'success',
|
|
96
|
-
metadata: {
|
|
97
|
-
insertedResourceIds: insertedResourceIds
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
},
|
|
103
|
-
observeConfig: function observeConfig() {
|
|
104
|
-
return {
|
|
105
|
-
target: (0, _experienceTrackingUtils.getTarget)(refs.containerElement),
|
|
106
|
-
options: {
|
|
107
|
-
childList: true
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
})]
|
|
112
|
-
});
|
|
113
|
-
};
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCreateSourceExperiencePlugin = void 0;
|
|
7
|
-
var _bindEventListener = require("bind-event-listener");
|
|
8
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
|
-
var _experiences = require("@atlaskit/editor-common/experiences");
|
|
10
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
-
var _types = require("../../types");
|
|
13
|
-
var _experienceTrackingUtils = require("../utils/experience-tracking-utils");
|
|
14
|
-
var pluginKey = new _state.PluginKey('createSourceSyncBlockExperience');
|
|
15
|
-
var START_METHOD = {
|
|
16
|
-
BLOCK_MENU: 'block-menu',
|
|
17
|
-
PINNED_TOOLBAR: 'pinned-toolbar',
|
|
18
|
-
QUICK_INSERT: 'quick-insert'
|
|
19
|
-
};
|
|
20
|
-
var SYNCED_BLOCK_CREATE_BUTTON_IDS = ['create-synced-block-toolbar-btn', 'create-synced-block-block-menu-btn', 'create-synced-block-quick-insert-btn'];
|
|
21
|
-
var syncedBlockCreateButtonIds = new Set(SYNCED_BLOCK_CREATE_BUTTON_IDS);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* This experience tracks when a source sync block is inserted.
|
|
25
|
-
*
|
|
26
|
-
* Start: When user inserts a sync block via block menu, quick insert or pinned toolbar
|
|
27
|
-
* Success: When the sync block is added to the DOM within 3000ms of start
|
|
28
|
-
* Failure: When 3000ms passes without the source sync block being added to the DOM
|
|
29
|
-
*/
|
|
30
|
-
var getCreateSourceExperiencePlugin = exports.getCreateSourceExperiencePlugin = function getCreateSourceExperiencePlugin(_ref) {
|
|
31
|
-
var refs = _ref.refs,
|
|
32
|
-
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
33
|
-
syncBlockStore = _ref.syncBlockStore;
|
|
34
|
-
var popupsTargetEl;
|
|
35
|
-
var editorViewEl;
|
|
36
|
-
var getPopupsTarget = function getPopupsTarget() {
|
|
37
|
-
if (!popupsTargetEl) {
|
|
38
|
-
popupsTargetEl = refs.popupsMountPoint || refs.wrapperElement || (0, _experiences.getPopupContainerFromEditorView)(editorViewEl);
|
|
39
|
-
}
|
|
40
|
-
return popupsTargetEl;
|
|
41
|
-
};
|
|
42
|
-
var experience = getCreateSourceExperience({
|
|
43
|
-
refs: refs,
|
|
44
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
45
|
-
});
|
|
46
|
-
syncBlockStore.sourceManager.setCreateExperience(experience);
|
|
47
|
-
var unbindClickListener = (0, _bindEventListener.bind)(document, {
|
|
48
|
-
type: 'click',
|
|
49
|
-
listener: function listener(event) {
|
|
50
|
-
var target = event.target;
|
|
51
|
-
if (!target) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
var button = target.closest('button[data-testid]');
|
|
55
|
-
if (!button || !(button instanceof HTMLButtonElement)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
var testId = button.dataset.testid;
|
|
59
|
-
if (!isSyncedBlockCreateButtonId(testId)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
handleButtonClick(testId, experience);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
var unbindKeydownListener = (0, _bindEventListener.bind)(document, {
|
|
66
|
-
type: 'keydown',
|
|
67
|
-
listener: function listener(event) {
|
|
68
|
-
if (isEnterKey(event.key)) {
|
|
69
|
-
var typeaheadPopup = (0, _experiences.popupWithNestedElement)(getPopupsTarget(), '.fabric-editor-typeahead');
|
|
70
|
-
if (!typeaheadPopup || !(typeaheadPopup instanceof HTMLElement)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
var firstItem = typeaheadPopup.querySelector('[role="option"]');
|
|
74
|
-
if (!firstItem || !(firstItem instanceof HTMLElement)) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
var testId = firstItem.dataset.testid;
|
|
78
|
-
if (testId === 'create-synced-block-quick-insert-btn') {
|
|
79
|
-
experience.start({
|
|
80
|
-
method: START_METHOD.QUICK_INSERT
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
options: {
|
|
86
|
-
capture: true
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return new _safePlugin.SafePlugin({
|
|
90
|
-
key: pluginKey,
|
|
91
|
-
view: function view(editorView) {
|
|
92
|
-
editorViewEl = editorView.dom;
|
|
93
|
-
return {
|
|
94
|
-
destroy: function destroy() {
|
|
95
|
-
experience.abort({
|
|
96
|
-
reason: _types.EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
97
|
-
});
|
|
98
|
-
unbindClickListener();
|
|
99
|
-
unbindKeydownListener();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
var getCreateSourceExperience = function getCreateSourceExperience(_ref2) {
|
|
106
|
-
var refs = _ref2.refs,
|
|
107
|
-
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
108
|
-
return new _experiences.Experience(_analytics.ACTION_SUBJECT.SYNCED_BLOCK, {
|
|
109
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
110
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
111
|
-
checks: [new _experiences.ExperienceCheckTimeout({
|
|
112
|
-
durationMs: 3000
|
|
113
|
-
}), new _experiences.ExperienceCheckDomMutation({
|
|
114
|
-
onDomMutation: function onDomMutation(_ref3) {
|
|
115
|
-
var mutations = _ref3.mutations;
|
|
116
|
-
var createdResourceIds = (0, _experienceTrackingUtils.getAddedResourceIds)(mutations, '[data-prosemirror-node-name="bodiedSyncBlock"]');
|
|
117
|
-
if (createdResourceIds.length > 0) {
|
|
118
|
-
return {
|
|
119
|
-
status: 'success',
|
|
120
|
-
metadata: {
|
|
121
|
-
createdResourceIds: createdResourceIds
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
return undefined;
|
|
126
|
-
},
|
|
127
|
-
observeConfig: function observeConfig() {
|
|
128
|
-
return {
|
|
129
|
-
target: (0, _experienceTrackingUtils.getTarget)(refs.containerElement),
|
|
130
|
-
options: {
|
|
131
|
-
childList: true
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
})]
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
var isSyncedBlockCreateButtonId = function isSyncedBlockCreateButtonId(value) {
|
|
139
|
-
return !!value && syncedBlockCreateButtonIds.has(value);
|
|
140
|
-
};
|
|
141
|
-
var handleButtonClick = function handleButtonClick(testId, experience) {
|
|
142
|
-
switch (testId) {
|
|
143
|
-
case 'create-synced-block-toolbar-btn':
|
|
144
|
-
experience.start({
|
|
145
|
-
method: START_METHOD.PINNED_TOOLBAR
|
|
146
|
-
});
|
|
147
|
-
break;
|
|
148
|
-
case 'create-synced-block-block-menu-btn':
|
|
149
|
-
experience.start({
|
|
150
|
-
method: START_METHOD.BLOCK_MENU
|
|
151
|
-
});
|
|
152
|
-
break;
|
|
153
|
-
case 'create-synced-block-quick-insert-btn':
|
|
154
|
-
experience.start({
|
|
155
|
-
method: START_METHOD.QUICK_INSERT
|
|
156
|
-
});
|
|
157
|
-
break;
|
|
158
|
-
default:
|
|
159
|
-
{
|
|
160
|
-
// Exhaustiveness check: if a new SyncedBlockToolbarButtonId is added
|
|
161
|
-
// but not handled above, TypeScript will error here.
|
|
162
|
-
var _exhaustiveCheck = testId;
|
|
163
|
-
return _exhaustiveCheck;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
var isEnterKey = function isEnterKey(key) {
|
|
168
|
-
return key === 'Enter';
|
|
169
|
-
};
|