@atlaskit/editor-plugin-synced-block 8.1.2 → 8.2.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 +13 -0
- package/dist/cjs/editor-actions/index.js +4 -1
- package/dist/cjs/pm-plugins/main.js +11 -0
- package/dist/cjs/syncedBlockPlugin.js +3 -0
- package/dist/es2019/editor-actions/index.js +3 -0
- package/dist/es2019/pm-plugins/main.js +11 -0
- package/dist/es2019/syncedBlockPlugin.js +4 -1
- package/dist/esm/editor-actions/index.js +3 -0
- package/dist/esm/pm-plugins/main.js +11 -0
- package/dist/esm/syncedBlockPlugin.js +4 -1
- package/dist/types/editor-actions/index.d.ts +1 -0
- package/dist/types/syncedBlockPluginType.d.ts +8 -0
- package/dist/types-ts4.5/editor-actions/index.d.ts +1 -0
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +8 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 8.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`c5fc2c5fb9fd1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c5fc2c5fb9fd1) -
|
|
8
|
+
Add discardUnpublishedSyncBlocks action to clean up orphaned synced blocks when user cancels
|
|
9
|
+
editing. Fetches block statuses from the backend on editor init and deletes all blocks with
|
|
10
|
+
'unpublished' status on cancel.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 8.1.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.flushSyncBlocks = exports.flushBodiedSyncBlocks = void 0;
|
|
6
|
+
exports.flushSyncBlocks = exports.flushBodiedSyncBlocks = exports.discardUnpublishedSyncBlocks = void 0;
|
|
7
7
|
var flushBodiedSyncBlocks = exports.flushBodiedSyncBlocks = function flushBodiedSyncBlocks(syncBlockStore) {
|
|
8
8
|
return syncBlockStore.sourceManager.flush();
|
|
9
9
|
};
|
|
10
10
|
var flushSyncBlocks = exports.flushSyncBlocks = function flushSyncBlocks(syncBlockStore) {
|
|
11
11
|
return syncBlockStore.referenceManager.flush();
|
|
12
|
+
};
|
|
13
|
+
var discardUnpublishedSyncBlocks = exports.discardUnpublishedSyncBlocks = function discardUnpublishedSyncBlocks(syncBlockStore) {
|
|
14
|
+
return syncBlockStore.sourceManager.discardUnpublishedBlocks();
|
|
12
15
|
};
|
|
@@ -290,6 +290,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
290
290
|
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
|
+
|
|
294
|
+
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
295
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
296
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
297
|
+
}
|
|
293
298
|
}
|
|
294
299
|
return {
|
|
295
300
|
selectionDecorationSet: (0, _selectionDecorations.calculateDecorations)(instance.doc, instance.selection, instance.schema),
|
|
@@ -508,6 +513,12 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
508
513
|
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
509
514
|
}
|
|
510
515
|
});
|
|
516
|
+
|
|
517
|
+
// Fetch statuses for remotely-added source sync blocks
|
|
518
|
+
// so we can identify unpublished blocks on cancel
|
|
519
|
+
if (sourceSyncBlockNodes.length > 0 && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_10')) {
|
|
520
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
521
|
+
}
|
|
511
522
|
var syncBlockNodes = referenceSyncBlockNodes.map(function (nodeInfo) {
|
|
512
523
|
return nodeInfo.node;
|
|
513
524
|
}).filter(function (node) {
|
|
@@ -90,6 +90,9 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
90
90
|
},
|
|
91
91
|
flushSyncedBlocks: function flushSyncedBlocks() {
|
|
92
92
|
return (0, _editorActions.flushSyncBlocks)(syncBlockStore);
|
|
93
|
+
},
|
|
94
|
+
discardUnpublishedSyncBlocks: function discardUnpublishedSyncBlocks() {
|
|
95
|
+
return (0, _editorActions.discardUnpublishedSyncBlocks)(syncBlockStore);
|
|
93
96
|
}
|
|
94
97
|
},
|
|
95
98
|
pluginsOptions: {
|
|
@@ -3,4 +3,7 @@ export const flushBodiedSyncBlocks = syncBlockStore => {
|
|
|
3
3
|
};
|
|
4
4
|
export const flushSyncBlocks = syncBlockStore => {
|
|
5
5
|
return syncBlockStore.referenceManager.flush();
|
|
6
|
+
};
|
|
7
|
+
export const discardUnpublishedSyncBlocks = syncBlockStore => {
|
|
8
|
+
return syncBlockStore.sourceManager.discardUnpublishedBlocks();
|
|
6
9
|
};
|
|
@@ -257,6 +257,11 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
257
257
|
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
|
+
|
|
261
|
+
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
262
|
+
if (fg('platform_synced_block_patch_10')) {
|
|
263
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
264
|
+
}
|
|
260
265
|
}
|
|
261
266
|
return {
|
|
262
267
|
selectionDecorationSet: calculateDecorations(instance.doc, instance.selection, instance.schema),
|
|
@@ -474,6 +479,12 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
474
479
|
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
475
480
|
}
|
|
476
481
|
});
|
|
482
|
+
|
|
483
|
+
// Fetch statuses for remotely-added source sync blocks
|
|
484
|
+
// so we can identify unpublished blocks on cancel
|
|
485
|
+
if (sourceSyncBlockNodes.length > 0 && fg('platform_synced_block_patch_10')) {
|
|
486
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
487
|
+
}
|
|
477
488
|
const syncBlockNodes = referenceSyncBlockNodes.map(nodeInfo => nodeInfo.node).filter(node => node !== undefined);
|
|
478
489
|
syncBlockStore.referenceManager.fetchSyncBlocksData(convertPMNodesToSyncBlockNodes(syncBlockNodes));
|
|
479
490
|
}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
-
import { flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
5
|
+
import { flushBodiedSyncBlocks, flushSyncBlocks, discardUnpublishedSyncBlocks } from './editor-actions';
|
|
6
6
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
7
7
|
import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
|
|
8
8
|
import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
|
|
@@ -77,6 +77,9 @@ export const syncedBlockPlugin = ({
|
|
|
77
77
|
},
|
|
78
78
|
flushSyncedBlocks: () => {
|
|
79
79
|
return flushSyncBlocks(syncBlockStore);
|
|
80
|
+
},
|
|
81
|
+
discardUnpublishedSyncBlocks: () => {
|
|
82
|
+
return discardUnpublishedSyncBlocks(syncBlockStore);
|
|
80
83
|
}
|
|
81
84
|
},
|
|
82
85
|
pluginsOptions: {
|
|
@@ -3,4 +3,7 @@ export var flushBodiedSyncBlocks = function flushBodiedSyncBlocks(syncBlockStore
|
|
|
3
3
|
};
|
|
4
4
|
export var flushSyncBlocks = function flushSyncBlocks(syncBlockStore) {
|
|
5
5
|
return syncBlockStore.referenceManager.flush();
|
|
6
|
+
};
|
|
7
|
+
export var discardUnpublishedSyncBlocks = function discardUnpublishedSyncBlocks(syncBlockStore) {
|
|
8
|
+
return syncBlockStore.sourceManager.discardUnpublishedBlocks();
|
|
6
9
|
};
|
|
@@ -283,6 +283,11 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
283
283
|
syncBlockStore.sourceManager.updateSyncBlockData(node, false);
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
|
+
|
|
287
|
+
// Fetch statuses from the backend so we can identify unpublished blocks on cancel
|
|
288
|
+
if (fg('platform_synced_block_patch_10')) {
|
|
289
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
290
|
+
}
|
|
286
291
|
}
|
|
287
292
|
return {
|
|
288
293
|
selectionDecorationSet: calculateDecorations(instance.doc, instance.selection, instance.schema),
|
|
@@ -501,6 +506,12 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
501
506
|
syncBlockStore.sourceManager.updateSyncBlockData(nodeInfo.node, tr.getMeta('isRemote'));
|
|
502
507
|
}
|
|
503
508
|
});
|
|
509
|
+
|
|
510
|
+
// Fetch statuses for remotely-added source sync blocks
|
|
511
|
+
// so we can identify unpublished blocks on cancel
|
|
512
|
+
if (sourceSyncBlockNodes.length > 0 && fg('platform_synced_block_patch_10')) {
|
|
513
|
+
syncBlockStore.sourceManager.fetchAndCacheStatuses();
|
|
514
|
+
}
|
|
504
515
|
var syncBlockNodes = referenceSyncBlockNodes.map(function (nodeInfo) {
|
|
505
516
|
return nodeInfo.node;
|
|
506
517
|
}).filter(function (node) {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
-
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
5
|
+
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks, discardUnpublishedSyncBlocks as _discardUnpublishedSyncBlocks } from './editor-actions';
|
|
6
6
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
7
7
|
import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
|
|
8
8
|
import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
|
|
@@ -83,6 +83,9 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
83
83
|
},
|
|
84
84
|
flushSyncedBlocks: function flushSyncedBlocks() {
|
|
85
85
|
return flushSyncBlocks(syncBlockStore);
|
|
86
|
+
},
|
|
87
|
+
discardUnpublishedSyncBlocks: function discardUnpublishedSyncBlocks() {
|
|
88
|
+
return _discardUnpublishedSyncBlocks(syncBlockStore);
|
|
86
89
|
}
|
|
87
90
|
},
|
|
88
91
|
pluginsOptions: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
2
2
|
export declare const flushBodiedSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
|
|
3
3
|
export declare const flushSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
|
|
4
|
+
export declare const discardUnpublishedSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
|
|
@@ -58,6 +58,14 @@ export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOption
|
|
|
58
58
|
}
|
|
59
59
|
export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
60
60
|
actions: {
|
|
61
|
+
/**
|
|
62
|
+
* Delete all source sync blocks with 'unpublished' status.
|
|
63
|
+
* Used to clean up orphaned blocks when a user cancels editing
|
|
64
|
+
* without saving.
|
|
65
|
+
*
|
|
66
|
+
* @returns true if all deletions succeeded, false otherwise
|
|
67
|
+
*/
|
|
68
|
+
discardUnpublishedSyncBlocks: () => Promise<boolean>;
|
|
61
69
|
/**
|
|
62
70
|
* Save content of bodiedSyncBlock nodes in local cache to backend.
|
|
63
71
|
* This action allows bodiedSyncBlock to be saved in sync with product saving experience
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
2
2
|
export declare const flushBodiedSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
|
|
3
3
|
export declare const flushSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
|
|
4
|
+
export declare const discardUnpublishedSyncBlocks: (syncBlockStore: SyncBlockStoreManager) => Promise<boolean>;
|
|
@@ -58,6 +58,14 @@ export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOption
|
|
|
58
58
|
}
|
|
59
59
|
export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
60
60
|
actions: {
|
|
61
|
+
/**
|
|
62
|
+
* Delete all source sync blocks with 'unpublished' status.
|
|
63
|
+
* Used to clean up orphaned blocks when a user cancels editing
|
|
64
|
+
* without saving.
|
|
65
|
+
*
|
|
66
|
+
* @returns true if all deletions succeeded, false otherwise
|
|
67
|
+
*/
|
|
68
|
+
discardUnpublishedSyncBlocks: () => Promise<boolean>;
|
|
61
69
|
/**
|
|
62
70
|
* Save content of bodiedSyncBlock nodes in local cache to backend.
|
|
63
71
|
* This action allows bodiedSyncBlock to be saved in sync with product saving experience
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/editor-plugin-user-intent": "^8.0.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
46
|
-
"@atlaskit/editor-synced-block-provider": "^6.
|
|
46
|
+
"@atlaskit/editor-synced-block-provider": "^6.4.0",
|
|
47
47
|
"@atlaskit/editor-toolbar": "^1.0.0",
|
|
48
48
|
"@atlaskit/flag": "^17.11.0",
|
|
49
49
|
"@atlaskit/icon": "34.3.0",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
55
55
|
"@atlaskit/primitives": "^19.0.0",
|
|
56
56
|
"@atlaskit/spinner": "19.1.2",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^74.
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^74.5.0",
|
|
58
58
|
"@atlaskit/tokens": "13.0.2",
|
|
59
59
|
"@atlaskit/tooltip": "^21.2.0",
|
|
60
|
-
"@atlaskit/visually-hidden": "^3.
|
|
60
|
+
"@atlaskit/visually-hidden": "^3.1.0",
|
|
61
61
|
"@babel/runtime": "^7.0.0",
|
|
62
62
|
"@compiled/react": "^0.20.0",
|
|
63
63
|
"bind-event-listener": "^3.0.0",
|
|
64
64
|
"date-fns": "^2.17.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@atlaskit/editor-common": "^114.
|
|
67
|
+
"@atlaskit/editor-common": "^114.18.0",
|
|
68
68
|
"react": "^18.2.0",
|
|
69
69
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
70
70
|
},
|