@atlaskit/editor-plugin-synced-block 8.3.3 → 8.3.5
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/AGENTS.md +1 -2
- package/CHANGELOG.md +14 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +7 -25
- package/dist/cjs/nodeviews/syncedBlock.js +1 -4
- package/dist/cjs/pm-plugins/main.js +54 -60
- package/dist/cjs/pm-plugins/menu-and-toolbar-experiences.js +10 -19
- package/dist/cjs/pm-plugins/utils/utils.js +3 -10
- package/dist/cjs/syncedBlockPlugin.js +1 -7
- package/dist/cjs/ui/DeleteConfirmationModal.js +29 -93
- package/dist/cjs/ui/SyncBlockLabel.js +1 -4
- package/dist/cjs/ui/SyncedLocationDropdown.js +2 -2
- package/dist/cjs/ui/floating-toolbar.js +1 -2
- package/dist/cjs/ui/quick-insert.js +2 -3
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +7 -23
- package/dist/es2019/nodeviews/syncedBlock.js +1 -4
- package/dist/es2019/pm-plugins/main.js +42 -48
- package/dist/es2019/pm-plugins/menu-and-toolbar-experiences.js +7 -19
- package/dist/es2019/pm-plugins/utils/utils.js +3 -11
- package/dist/es2019/syncedBlockPlugin.js +1 -7
- package/dist/es2019/ui/DeleteConfirmationModal.js +36 -77
- package/dist/es2019/ui/SyncBlockLabel.js +1 -4
- package/dist/es2019/ui/SyncedLocationDropdown.js +2 -2
- package/dist/es2019/ui/floating-toolbar.js +1 -2
- package/dist/es2019/ui/quick-insert.js +2 -2
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +7 -25
- package/dist/esm/nodeviews/syncedBlock.js +1 -4
- package/dist/esm/pm-plugins/main.js +54 -60
- package/dist/esm/pm-plugins/menu-and-toolbar-experiences.js +10 -19
- package/dist/esm/pm-plugins/utils/utils.js +3 -11
- package/dist/esm/syncedBlockPlugin.js +1 -7
- package/dist/esm/ui/DeleteConfirmationModal.js +29 -93
- package/dist/esm/ui/SyncBlockLabel.js +1 -4
- package/dist/esm/ui/SyncedLocationDropdown.js +2 -2
- package/dist/esm/ui/floating-toolbar.js +1 -2
- package/dist/esm/ui/quick-insert.js +2 -3
- package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +1 -3
- package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +1 -3
- package/docs/0-intro.tsx +1 -1
- package/package.json +6 -21
- package/dist/cjs/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.js +0 -35
- package/dist/es2019/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.js +0 -27
- package/dist/esm/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.js +0 -28
- package/dist/types/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.d.ts +0 -6
- package/dist/types-ts4.5/nodeviews/bodiedSyncBlockNodeWithToDOMFixed.d.ts +0 -6
|
@@ -4,7 +4,6 @@ import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages'
|
|
|
4
4
|
import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
5
5
|
import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
|
|
6
6
|
import { Text } from '@atlaskit/primitives/compiled';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
7
|
import Tooltip from '@atlaskit/tooltip';
|
|
9
8
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
10
9
|
import { formatElapsedTime } from './utils/time';
|
|
@@ -70,9 +69,7 @@ const SyncBlockLabelComponent = ({
|
|
|
70
69
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
71
70
|
,
|
|
72
71
|
className: SyncBlockLabelSharedCssClassName.labelClassName,
|
|
73
|
-
"aria-describedby":
|
|
74
|
-
exposure: true
|
|
75
|
-
}) ? undefined : ariaDescribedById
|
|
72
|
+
"aria-describedby": isSource || isUnsyncedBlock ? undefined : ariaDescribedById
|
|
76
73
|
}, /*#__PURE__*/React.createElement(BlockSyncedIcon, {
|
|
77
74
|
color: "var(--ds-icon-subtle, #505258)",
|
|
78
75
|
size: "small",
|
|
@@ -262,7 +262,7 @@ export const processReferenceData = (referenceData, intl) => {
|
|
|
262
262
|
});
|
|
263
263
|
for (const references of sourceInfoMap.values()) {
|
|
264
264
|
if (references.length > 1) {
|
|
265
|
-
references.forEach((reference, index) => reference.title = `${reference.title === '' && reference.hasAccess
|
|
265
|
+
references.forEach((reference, index) => reference.title = `${reference.title === '' && reference.hasAccess ? formatMessage(messages.syncedLocationDropdownUntitledPage) : reference.title}: ${formatMessage(messages.syncedLocationDropdownTitleBlockIndex, {
|
|
266
266
|
index: index + 1
|
|
267
267
|
})}`);
|
|
268
268
|
}
|
|
@@ -381,7 +381,7 @@ const DropdownContent = ({
|
|
|
381
381
|
count: `${referenceData.length > 99 ? '99+' : referenceData.length}`
|
|
382
382
|
})
|
|
383
383
|
}, referenceData.map(reference => {
|
|
384
|
-
const title = reference.title === '' && reference.hasAccess
|
|
384
|
+
const title = reference.title === '' && reference.hasAccess ? formatMessage(messages.syncedLocationDropdownUntitledPage) : reference.title || reference.url || '';
|
|
385
385
|
return /*#__PURE__*/React.createElement("div", {
|
|
386
386
|
key: reference.title,
|
|
387
387
|
className: ax(["_2ll012x7"])
|
|
@@ -9,7 +9,6 @@ import CopyIcon from '@atlaskit/icon/core/copy';
|
|
|
9
9
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
10
10
|
import EditIcon from '@atlaskit/icon/core/edit';
|
|
11
11
|
import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
|
|
12
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
12
|
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock, unsync } from '../editor-commands';
|
|
14
13
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
15
14
|
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
@@ -83,7 +82,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
|
|
|
83
82
|
var _syncBlockInstance$da;
|
|
84
83
|
return /*#__PURE__*/React.createElement(Button, {
|
|
85
84
|
areAnyNewToolbarFlagsEnabled: true,
|
|
86
|
-
disabled:
|
|
85
|
+
disabled: (syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.status) === 'unpublished',
|
|
87
86
|
icon: /*#__PURE__*/React.createElement(LinkBrokenIcon, {
|
|
88
87
|
label: ""
|
|
89
88
|
}),
|
|
@@ -20,8 +20,8 @@ export const getQuickInsertConfig = (config, api, syncBlockStore) => {
|
|
|
20
20
|
id: 'syncBlock',
|
|
21
21
|
title: formatMessage(blockTypeMessages.syncedBlock),
|
|
22
22
|
description: formatMessage(blockTypeMessages.syncedBlockDescription),
|
|
23
|
-
priority:
|
|
24
|
-
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect',
|
|
23
|
+
priority: 400,
|
|
24
|
+
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect', 'create'],
|
|
25
25
|
isDisabledOffline: true,
|
|
26
26
|
keyshortcut: '',
|
|
27
27
|
lozenge: /*#__PURE__*/React.createElement("span", {
|
|
@@ -12,7 +12,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
12
12
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
13
13
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
14
14
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
15
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
15
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
17
16
|
import { SyncBlockLabel } from '../ui/SyncBlockLabel';
|
|
18
17
|
var toDOMOld = function toDOMOld() {
|
|
@@ -165,14 +164,13 @@ var toDOM = function toDOM(node) {
|
|
|
165
164
|
}, 0]];
|
|
166
165
|
};
|
|
167
166
|
export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
168
|
-
function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI
|
|
167
|
+
function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI) {
|
|
169
168
|
var _this4 = this;
|
|
170
169
|
_classCallCheck(this, BodiedSyncBlock);
|
|
171
170
|
this.node = node;
|
|
172
171
|
this.view = view;
|
|
173
172
|
this.getPos = getPos;
|
|
174
173
|
this.api = api;
|
|
175
|
-
this.syncBlockStore = syncBlockStore;
|
|
176
174
|
this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
|
|
177
175
|
var _DOMSerializer$render2 = DOMSerializer.renderSpec(document, toDOM(this.node)),
|
|
178
176
|
dom = _DOMSerializer$render2.dom,
|
|
@@ -198,12 +196,8 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
198
196
|
this.handleConnectivityModeChange();
|
|
199
197
|
this.handleViewModeChange();
|
|
200
198
|
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
if (!fg('platform_synced_block_update_refactor')) {
|
|
204
|
-
var _this$syncedBlockStor;
|
|
205
|
-
(_this$syncedBlockStor = this.syncedBlockStore) === null || _this$syncedBlockStor === void 0 || _this$syncedBlockStor.sourceManager.updateSyncBlockData(node, false);
|
|
206
|
-
}
|
|
199
|
+
// Cache is populated in state.init() and updated in appendTransaction,
|
|
200
|
+
// so no additional updateSyncBlockData call is needed here.
|
|
207
201
|
}
|
|
208
202
|
return _createClass(BodiedSyncBlock, [{
|
|
209
203
|
key: "updateContentEditable",
|
|
@@ -246,26 +240,15 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
246
240
|
});
|
|
247
241
|
}
|
|
248
242
|
}
|
|
249
|
-
}, {
|
|
250
|
-
key: "syncedBlockStore",
|
|
251
|
-
get: function get() {
|
|
252
|
-
var _this$api$syncedBlock2, _this$api1;
|
|
253
|
-
return (_this$api$syncedBlock2 = (_this$api1 = this.api) === null || _this$api1 === void 0 || (_this$api1 = _this$api1.syncedBlock.sharedState) === null || _this$api1 === void 0 || (_this$api1 = _this$api1.currentState()) === null || _this$api1 === void 0 ? void 0 : _this$api1.syncBlockStore) !== null && _this$api$syncedBlock2 !== void 0 ? _this$api$syncedBlock2 : this.syncBlockStore;
|
|
254
|
-
}
|
|
255
243
|
}, {
|
|
256
244
|
key: "update",
|
|
257
245
|
value: function update(node) {
|
|
258
246
|
if (this.node.type !== node.type) {
|
|
259
247
|
return false;
|
|
260
248
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (!fg('platform_synced_block_update_refactor')) {
|
|
265
|
-
var _this$syncedBlockStor2;
|
|
266
|
-
(_this$syncedBlockStor2 = this.syncedBlockStore) === null || _this$syncedBlockStor2 === void 0 || _this$syncedBlockStor2.sourceManager.updateSyncBlockData(node, false);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
249
|
+
|
|
250
|
+
// Cache updates are handled in appendTransaction where we can
|
|
251
|
+
// filter out non-user changes (remote collab, table auto-scale, etc.)
|
|
269
252
|
this.node = node;
|
|
270
253
|
return true;
|
|
271
254
|
}
|
|
@@ -289,9 +272,8 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
289
272
|
}();
|
|
290
273
|
export var bodiedSyncBlockNodeView = function bodiedSyncBlockNodeView(props) {
|
|
291
274
|
var api = props.api,
|
|
292
|
-
syncBlockStore = props.syncBlockStore,
|
|
293
275
|
nodeViewPortalProviderAPI = props.pmPluginFactoryParams.nodeViewPortalProviderAPI;
|
|
294
276
|
return function (node, view, getPos) {
|
|
295
|
-
return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI
|
|
277
|
+
return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI);
|
|
296
278
|
};
|
|
297
279
|
};
|
|
@@ -14,7 +14,6 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
|
14
14
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
15
15
|
import { SyncBlockSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
|
|
16
16
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
17
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
18
17
|
import { removeSyncedBlockAtPos } from '../editor-commands';
|
|
19
18
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
20
19
|
export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
@@ -61,9 +60,7 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
61
60
|
}, {
|
|
62
61
|
key: "update",
|
|
63
62
|
value: function update(node, decorations, innerDecorations) {
|
|
64
|
-
return _superPropGet(SyncBlock, "update", this, 3)([node, decorations, innerDecorations,
|
|
65
|
-
exposure: true
|
|
66
|
-
}) ? this.validUpdate : undefined]);
|
|
63
|
+
return _superPropGet(SyncBlock, "update", this, 3)([node, decorations, innerDecorations, this.validUpdate]);
|
|
67
64
|
}
|
|
68
65
|
}, {
|
|
69
66
|
key: "render",
|
|
@@ -362,18 +362,14 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
362
362
|
|
|
363
363
|
// Populate source sync block cache from initial document
|
|
364
364
|
// When fg is ON, this replaces the constructor call in the nodeview
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
373
|
-
if (fg('platform_synced_block_patch_10')) {
|
|
374
|
-
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
365
|
+
instance.doc.forEach(function (node) {
|
|
366
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
367
|
+
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
375
368
|
}
|
|
376
|
-
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
372
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
377
373
|
}
|
|
378
374
|
|
|
379
375
|
// Read initial shared-state signals for status decorations
|
|
@@ -686,7 +682,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
686
682
|
}
|
|
687
683
|
}
|
|
688
684
|
var viewMode = api === null || api === void 0 || (_api$editorViewMode4 = api.editorViewMode) === null || _api$editorViewMode4 === void 0 || (_api$editorViewMode4 = _api$editorViewMode4.sharedState.currentState()) === null || _api$editorViewMode4 === void 0 ? void 0 : _api$editorViewMode4.mode;
|
|
689
|
-
if (viewMode === 'view'
|
|
685
|
+
if (viewMode === 'view') {
|
|
690
686
|
return true;
|
|
691
687
|
}
|
|
692
688
|
var isOffline = isOfflineMode(api === null || api === void 0 || (_api$connectivity5 = api.connectivity) === null || _api$connectivity5 === void 0 || (_api$connectivity5 = _api$connectivity5.sharedState.currentState()) === null || _api$connectivity5 === void 0 ? void 0 : _api$connectivity5.mode);
|
|
@@ -703,40 +699,39 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
703
699
|
}
|
|
704
700
|
});
|
|
705
701
|
}
|
|
706
|
-
if (fg('platform_synced_block_update_refactor')) {
|
|
707
|
-
// if doc changed and it's a remote transaction, check if any synced block were added,
|
|
708
|
-
// and if so, for source synced blocks, ensure we update the cache with them
|
|
709
|
-
// and for reference synced blocks, ensure we fetch the data from the server
|
|
710
|
-
if (tr.docChanged && tr.getMeta('isRemote')) {
|
|
711
|
-
var _trackSyncBlocks4 = trackSyncBlocks(function (node) {
|
|
712
|
-
return syncBlockStore.isSyncBlock(node);
|
|
713
|
-
}, tr, state),
|
|
714
|
-
_added = _trackSyncBlocks4.added;
|
|
715
|
-
var sourceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
716
|
-
return nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node);
|
|
717
|
-
});
|
|
718
|
-
var referenceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
719
|
-
return nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node);
|
|
720
|
-
});
|
|
721
|
-
sourceSyncBlockNodes.forEach(function (nodeInfo) {
|
|
722
|
-
var _nodeInfo$attrs2;
|
|
723
|
-
if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
|
|
724
|
-
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
702
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
703
|
+
// if doc changed and it's a remote transaction, check if any synced block were added,
|
|
704
|
+
// and if so, for source synced blocks, ensure we update the cache with them
|
|
705
|
+
// and for reference synced blocks, ensure we fetch the data from the server
|
|
706
|
+
if (tr.docChanged && tr.getMeta('isRemote')) {
|
|
707
|
+
var _trackSyncBlocks4 = trackSyncBlocks(function (node) {
|
|
708
|
+
return syncBlockStore.isSyncBlock(node);
|
|
709
|
+
}, tr, state),
|
|
710
|
+
_added = _trackSyncBlocks4.added;
|
|
711
|
+
var sourceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
712
|
+
return nodeInfo.node && syncBlockStore.sourceManager.isSourceBlock(nodeInfo.node);
|
|
713
|
+
});
|
|
714
|
+
var referenceSyncBlockNodes = _added.filter(function (nodeInfo) {
|
|
715
|
+
return nodeInfo.node && syncBlockStore.referenceManager.isReferenceBlock(nodeInfo.node);
|
|
716
|
+
});
|
|
717
|
+
sourceSyncBlockNodes.forEach(function (nodeInfo) {
|
|
718
|
+
var _nodeInfo$attrs2;
|
|
719
|
+
if ((_nodeInfo$attrs2 = nodeInfo.attrs) !== null && _nodeInfo$attrs2 !== void 0 && _nodeInfo$attrs2.resourceId && nodeInfo.node) {
|
|
720
|
+
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
732
721
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
syncBlockStore.
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
// Fetch statuses for remotely-added source sync blocks
|
|
725
|
+
// so we can identify unpublished blocks on cancel
|
|
726
|
+
if (sourceSyncBlockNodes.length > 0) {
|
|
727
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
739
728
|
}
|
|
729
|
+
var syncBlockNodes = referenceSyncBlockNodes.map(function (nodeInfo) {
|
|
730
|
+
return nodeInfo.node;
|
|
731
|
+
}).filter(function (node) {
|
|
732
|
+
return node !== undefined;
|
|
733
|
+
});
|
|
734
|
+
syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
|
|
740
735
|
}
|
|
741
736
|
if (!tr.docChanged || Boolean(tr.getMeta('isRemote')) || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
742
737
|
return true;
|
|
@@ -778,26 +773,25 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
778
773
|
}
|
|
779
774
|
}
|
|
780
775
|
var viewMode = api === null || api === void 0 || (_api$editorViewMode5 = api.editorViewMode) === null || _api$editorViewMode5 === void 0 || (_api$editorViewMode5 = _api$editorViewMode5.sharedState.currentState()) === null || _api$editorViewMode5 === void 0 ? void 0 : _api$editorViewMode5.mode;
|
|
781
|
-
if (viewMode === 'view'
|
|
776
|
+
if (viewMode === 'view') {
|
|
782
777
|
return null;
|
|
783
778
|
}
|
|
784
779
|
|
|
785
|
-
// Update source sync block cache for user-initiated changes only
|
|
786
|
-
//
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
780
|
+
// Update source sync block cache for user-initiated changes only.
|
|
781
|
+
// Cache updates are handled here instead of in the nodeview update() so we
|
|
782
|
+
// can filter out non-user changes (remote collab, dirty programmatic txns).
|
|
783
|
+
var isUserChange = function isUserChange(tr) {
|
|
784
|
+
return tr.docChanged && !isDirtyTransaction(tr) && !tr.getMeta('isRemote');
|
|
785
|
+
};
|
|
786
|
+
var hasSourceBlockEdit = trs.some(function (tr) {
|
|
787
|
+
return isUserChange(tr) && hasEditInSyncBlock(tr, oldState);
|
|
788
|
+
});
|
|
789
|
+
if (hasSourceBlockEdit) {
|
|
790
|
+
newState.doc.forEach(function (node) {
|
|
791
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
792
|
+
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
793
|
+
}
|
|
793
794
|
});
|
|
794
|
-
if (hasSourceBlockEdit) {
|
|
795
|
-
newState.doc.forEach(function (node) {
|
|
796
|
-
if (syncBlockStore.sourceManager.isSourceBlock(node)) {
|
|
797
|
-
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
795
|
}
|
|
802
796
|
trs.filter(function (tr) {
|
|
803
797
|
return tr.docChanged;
|
|
@@ -848,7 +842,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
848
842
|
}
|
|
849
843
|
if (trs.some(function (tr) {
|
|
850
844
|
return tr.docChanged && !tr.getMeta('isRemote');
|
|
851
|
-
})
|
|
845
|
+
})) {
|
|
852
846
|
// Quick check: only walk the full document when at least one
|
|
853
847
|
// transaction inserted a source synced block. This avoids an
|
|
854
848
|
// expensive descendants() traversal on every local edit.
|
|
@@ -4,7 +4,6 @@ import { ACTION, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
|
4
4
|
import { Experience, EXPERIENCE_ID, ExperienceCheckDomMutation, ExperienceCheckTimeout, getNodeQuery, getPopupContainerFromEditorView, popupWithNestedElement, getSelectionAncestorDOM } from '@atlaskit/editor-common/experiences';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
8
|
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
10
9
|
import { syncedBlockPluginKey } from './main';
|
|
@@ -12,7 +11,6 @@ var TIMEOUT_DURATION = 30000;
|
|
|
12
11
|
var pluginKey = new PluginKey('syncedBlockMenuAndToolbarExperience');
|
|
13
12
|
var SYNCED_BLOCK_BUTTON_TEST_IDS = Object.values(SYNCED_BLOCK_BUTTON_TEST_ID);
|
|
14
13
|
var syncedBlockButtonIds = new Set(SYNCED_BLOCK_BUTTON_TEST_IDS);
|
|
15
|
-
var targetEl;
|
|
16
14
|
export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperiencesPlugin(_ref) {
|
|
17
15
|
var refs = _ref.refs,
|
|
18
16
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
@@ -139,7 +137,7 @@ export var getMenuAndToolbarExperiencesPlugin = function getMenuAndToolbarExperi
|
|
|
139
137
|
if (!typeaheadPopup || !(typeaheadPopup instanceof HTMLElement)) {
|
|
140
138
|
return;
|
|
141
139
|
}
|
|
142
|
-
var targetElement =
|
|
140
|
+
var targetElement = typeaheadPopup.querySelector('[role="option"][aria-selected="true"]');
|
|
143
141
|
if (!targetElement || !(targetElement instanceof HTMLElement)) {
|
|
144
142
|
return;
|
|
145
143
|
}
|
|
@@ -296,16 +294,6 @@ var handleButtonClick = function handleButtonClick(_ref2) {
|
|
|
296
294
|
var isEnterKey = function isEnterKey(key) {
|
|
297
295
|
return key === 'Enter';
|
|
298
296
|
};
|
|
299
|
-
var getTarget = function getTarget(containerElement) {
|
|
300
|
-
if (!targetEl) {
|
|
301
|
-
var element = containerElement === null || containerElement === void 0 ? void 0 : containerElement.querySelector('.ProseMirror');
|
|
302
|
-
if (!element || !(element instanceof HTMLElement)) {
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
targetEl = element;
|
|
306
|
-
}
|
|
307
|
-
return targetEl;
|
|
308
|
-
};
|
|
309
297
|
var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs, editorViewRef) {
|
|
310
298
|
return new ExperienceCheckDomMutation({
|
|
311
299
|
onDomMutation: function onDomMutation(_ref3) {
|
|
@@ -320,17 +308,20 @@ var syncedBlockAddedToDomCheck = function syncedBlockAddedToDomCheck(refs, edito
|
|
|
320
308
|
observeConfig: function observeConfig() {
|
|
321
309
|
var _editorViewRef$curren2;
|
|
322
310
|
return [{
|
|
323
|
-
target:
|
|
311
|
+
target: editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren2 = editorViewRef.current) === null || _editorViewRef$curren2 === void 0 ? void 0 : _editorViewRef$curren2.dom,
|
|
324
312
|
options: {
|
|
325
313
|
childList: true
|
|
326
314
|
}
|
|
327
|
-
}
|
|
315
|
+
},
|
|
316
|
+
// When wrapping a node with breakout mark with sync block, breakout dom is reused
|
|
317
|
+
// hence we need to observe subtree to catch sync block mutation
|
|
318
|
+
{
|
|
328
319
|
target: getSelectionAncestorDOM(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
|
|
329
320
|
options: {
|
|
330
321
|
childList: true,
|
|
331
322
|
subtree: true
|
|
332
323
|
}
|
|
333
|
-
}]
|
|
324
|
+
}];
|
|
334
325
|
}
|
|
335
326
|
});
|
|
336
327
|
};
|
|
@@ -356,17 +347,17 @@ var referenceSyncBlockRemovedFromDomCheck = function referenceSyncBlockRemovedFr
|
|
|
356
347
|
observeConfig: function observeConfig() {
|
|
357
348
|
var _editorViewRef$curren3;
|
|
358
349
|
return [{
|
|
359
|
-
target:
|
|
350
|
+
target: editorViewRef === null || editorViewRef === void 0 || (_editorViewRef$curren3 = editorViewRef.current) === null || _editorViewRef$curren3 === void 0 ? void 0 : _editorViewRef$curren3.dom,
|
|
360
351
|
options: {
|
|
361
352
|
childList: true
|
|
362
353
|
}
|
|
363
|
-
}
|
|
354
|
+
}, {
|
|
364
355
|
target: getSelectionAncestorDOM(editorViewRef === null || editorViewRef === void 0 ? void 0 : editorViewRef.current),
|
|
365
356
|
options: {
|
|
366
357
|
childList: true,
|
|
367
358
|
subtree: true
|
|
368
359
|
}
|
|
369
|
-
}]
|
|
360
|
+
}];
|
|
370
361
|
}
|
|
371
362
|
});
|
|
372
363
|
};
|
|
@@ -2,8 +2,6 @@ import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
9
7
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
@@ -97,9 +95,7 @@ var _fragmentContainsExtension = function fragmentContainsExtension(fragment) {
|
|
|
97
95
|
if (found) {
|
|
98
96
|
return;
|
|
99
97
|
}
|
|
100
|
-
if (
|
|
101
|
-
exposure: true
|
|
102
|
-
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
98
|
+
if (EXTENSION_NODES.has(node.type.name)) {
|
|
103
99
|
found = true;
|
|
104
100
|
} else if (node.content.size) {
|
|
105
101
|
if (_fragmentContainsExtension(node.content)) {
|
|
@@ -160,17 +156,13 @@ export var wasExtensionInsertedInBodiedSyncBlock = function wasExtensionInserted
|
|
|
160
156
|
if (resourceId !== undefined) {
|
|
161
157
|
return false;
|
|
162
158
|
}
|
|
163
|
-
if (
|
|
164
|
-
exposure: true
|
|
165
|
-
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
159
|
+
if (EXTENSION_NODES.has(node.type.name)) {
|
|
166
160
|
var _$pos = tr.doc.resolve(pos);
|
|
167
161
|
var _parent = findParentNodeOfTypeClosestToPos(_$pos, bodiedSyncBlock);
|
|
168
162
|
if (_parent !== null && _parent !== void 0 && _parent.node.attrs.resourceId) {
|
|
169
163
|
var mappedPos = tr.mapping.invert().map(pos);
|
|
170
164
|
var nodeBefore = state.doc.nodeAt(mappedPos);
|
|
171
|
-
if (!nodeBefore || (
|
|
172
|
-
exposure: true
|
|
173
|
-
}) ? EXTENSION_NODES.has(nodeBefore.type.name) : nodeBefore.type.name !== 'inlineExtension')) {
|
|
165
|
+
if (!nodeBefore || EXTENSION_NODES.has(nodeBefore.type.name)) {
|
|
174
166
|
resourceId = _parent.node.attrs.resourceId;
|
|
175
167
|
return false;
|
|
176
168
|
}
|
|
@@ -4,10 +4,8 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
|
|
|
4
4
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
5
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
6
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
7
|
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks, discardUnpublishedSyncBlocks as _discardUnpublishedSyncBlocks } from './editor-actions';
|
|
9
8
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
10
|
-
import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
|
|
11
9
|
import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
|
|
12
10
|
import { getMenuAndToolbarExperiencesPlugin } from './pm-plugins/menu-and-toolbar-experiences';
|
|
13
11
|
import { getBlockMenuComponents } from './ui/block-menu-components';
|
|
@@ -76,11 +74,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
|
|
|
76
74
|
node: syncBlock
|
|
77
75
|
}, {
|
|
78
76
|
name: 'bodiedSyncBlock',
|
|
79
|
-
node:
|
|
80
|
-
exposure: true
|
|
81
|
-
}) ?
|
|
82
|
-
// delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
|
|
83
|
-
bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
|
|
77
|
+
node: bodiedSyncBlock
|
|
84
78
|
}];
|
|
85
79
|
},
|
|
86
80
|
pmPlugins: function pmPlugins() {
|