@atlaskit/editor-plugin-synced-block 24.0.6 → 24.0.7
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 +10 -0
- package/dist/cjs/ui/SyncedLocationDropdown.js +17 -10
- package/dist/cjs/ui/floating-toolbar.js +1 -0
- package/dist/es2019/ui/SyncedLocationDropdown.js +8 -3
- package/dist/es2019/ui/floating-toolbar.js +1 -0
- package/dist/esm/ui/SyncedLocationDropdown.js +17 -10
- package/dist/esm/ui/floating-toolbar.js +1 -0
- package/dist/types/ui/SyncedLocationDropdown.d.ts +3 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 24.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`63c2a47db7f66`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/63c2a47db7f66) -
|
|
8
|
+
Pass the current editor document into the lookup for synced locations behind
|
|
9
|
+
platform_editor_blocks_patch_12, including references added, removed, or unsynced before saving.
|
|
10
|
+
Reconcile saved references with the current document, preserving locations on other documents.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 24.0.6
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -551,6 +551,7 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
551
551
|
};
|
|
552
552
|
var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref8) {
|
|
553
553
|
var syncBlockStore = _ref8.syncBlockStore,
|
|
554
|
+
doc = _ref8.doc,
|
|
554
555
|
resourceId = _ref8.resourceId,
|
|
555
556
|
intl = _ref8.intl,
|
|
556
557
|
isSource = _ref8.isSource,
|
|
@@ -566,7 +567,8 @@ var SyncedLocationDropdownWithCount = exports.SyncedLocationDropdownWithCount =
|
|
|
566
567
|
isSource: isSource,
|
|
567
568
|
localId: localId,
|
|
568
569
|
resourceId: resourceId,
|
|
569
|
-
syncBlockStore: syncBlockStore
|
|
570
|
+
syncBlockStore: syncBlockStore,
|
|
571
|
+
doc: doc
|
|
570
572
|
}),
|
|
571
573
|
fetchStatus = _useReferenceData.fetchStatus,
|
|
572
574
|
locations = _useReferenceData.locations;
|
|
@@ -706,24 +708,29 @@ var DropdownContent = function DropdownContent(_ref1) {
|
|
|
706
708
|
};
|
|
707
709
|
var useReferenceData = function useReferenceData(_ref11) {
|
|
708
710
|
var syncBlockStore = _ref11.syncBlockStore,
|
|
711
|
+
doc = _ref11.doc,
|
|
709
712
|
resourceId = _ref11.resourceId,
|
|
710
713
|
intl = _ref11.intl,
|
|
711
714
|
isSource = _ref11.isSource,
|
|
712
715
|
localId = _ref11.localId;
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}),
|
|
716
|
+
// Refresh locations when the toolbar opens, rather than on every document edit.
|
|
717
|
+
var _useState9 = (0, _react.useState)(doc),
|
|
716
718
|
_useState0 = (0, _slicedToArray2.default)(_useState9, 1),
|
|
717
|
-
|
|
719
|
+
docAtMount = _useState0[0];
|
|
718
720
|
var _useState1 = (0, _react.useState)(function () {
|
|
721
|
+
return isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId);
|
|
722
|
+
}),
|
|
723
|
+
_useState10 = (0, _slicedToArray2.default)(_useState1, 1),
|
|
724
|
+
isNewSourceBlock = _useState10[0];
|
|
725
|
+
var _useState11 = (0, _react.useState)(function () {
|
|
719
726
|
return {
|
|
720
727
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
721
728
|
locations: EMPTY_LOCATIONS
|
|
722
729
|
};
|
|
723
730
|
}),
|
|
724
|
-
|
|
725
|
-
state =
|
|
726
|
-
setState =
|
|
731
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
732
|
+
state = _useState12[0],
|
|
733
|
+
setState = _useState12[1];
|
|
727
734
|
(0, _react.useEffect)(function () {
|
|
728
735
|
var isCurrentRequest = true;
|
|
729
736
|
setState({
|
|
@@ -737,7 +744,7 @@ var useReferenceData = function useReferenceData(_ref11) {
|
|
|
737
744
|
while (1) switch (_context2.prev = _context2.next) {
|
|
738
745
|
case 0:
|
|
739
746
|
_context2.next = 1;
|
|
740
|
-
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
747
|
+
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource, docAtMount);
|
|
741
748
|
case 1:
|
|
742
749
|
response = _context2.sent;
|
|
743
750
|
if (isCurrentRequest) {
|
|
@@ -777,7 +784,7 @@ var useReferenceData = function useReferenceData(_ref11) {
|
|
|
777
784
|
return function () {
|
|
778
785
|
isCurrentRequest = false;
|
|
779
786
|
};
|
|
780
|
-
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock]);
|
|
787
|
+
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock, docAtMount]);
|
|
781
788
|
return {
|
|
782
789
|
fetchStatus: state.fetchStatus,
|
|
783
790
|
locations: state.locations
|
|
@@ -87,6 +87,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
87
87
|
return /*#__PURE__*/_react.default.createElement(_SyncedLocationDropdown.SyncedLocationDropdownWithCount, {
|
|
88
88
|
key: "".concat(resourceId, ":").concat(localId, ":").concat(isBodiedSyncBlock),
|
|
89
89
|
syncBlockStore: syncBlockStore,
|
|
90
|
+
doc: state.doc,
|
|
90
91
|
resourceId: resourceId,
|
|
91
92
|
localId: localId,
|
|
92
93
|
intl: intl,
|
|
@@ -510,6 +510,7 @@ const EditorPositionedSyncedLocationDropdown = ({
|
|
|
510
510
|
};
|
|
511
511
|
export const SyncedLocationDropdownWithCount = ({
|
|
512
512
|
syncBlockStore,
|
|
513
|
+
doc,
|
|
513
514
|
resourceId,
|
|
514
515
|
intl,
|
|
515
516
|
isSource,
|
|
@@ -526,7 +527,8 @@ export const SyncedLocationDropdownWithCount = ({
|
|
|
526
527
|
isSource,
|
|
527
528
|
localId,
|
|
528
529
|
resourceId,
|
|
529
|
-
syncBlockStore
|
|
530
|
+
syncBlockStore,
|
|
531
|
+
doc
|
|
530
532
|
});
|
|
531
533
|
const referenceCount = useMemo(() => {
|
|
532
534
|
switch (locations.kind) {
|
|
@@ -633,11 +635,14 @@ const DropdownContent = ({
|
|
|
633
635
|
};
|
|
634
636
|
const useReferenceData = ({
|
|
635
637
|
syncBlockStore,
|
|
638
|
+
doc,
|
|
636
639
|
resourceId,
|
|
637
640
|
intl,
|
|
638
641
|
isSource,
|
|
639
642
|
localId
|
|
640
643
|
}) => {
|
|
644
|
+
// Refresh locations when the toolbar opens, rather than on every document edit.
|
|
645
|
+
const [docAtMount] = useState(doc);
|
|
641
646
|
const [isNewSourceBlock] = useState(() => isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId));
|
|
642
647
|
const [state, setState] = useState(() => ({
|
|
643
648
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
@@ -650,7 +655,7 @@ const useReferenceData = ({
|
|
|
650
655
|
locations: EMPTY_LOCATIONS
|
|
651
656
|
});
|
|
652
657
|
const getReferenceData = async () => {
|
|
653
|
-
const response = await syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
658
|
+
const response = await syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource, docAtMount);
|
|
654
659
|
if (!isCurrentRequest) {
|
|
655
660
|
return;
|
|
656
661
|
}
|
|
@@ -673,7 +678,7 @@ const useReferenceData = ({
|
|
|
673
678
|
return () => {
|
|
674
679
|
isCurrentRequest = false;
|
|
675
680
|
};
|
|
676
|
-
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock]);
|
|
681
|
+
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock, docAtMount]);
|
|
677
682
|
return {
|
|
678
683
|
fetchStatus: state.fetchStatus,
|
|
679
684
|
locations: state.locations
|
|
@@ -85,6 +85,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage, o
|
|
|
85
85
|
return /*#__PURE__*/React.createElement(SyncedLocationDropdownWithCount, {
|
|
86
86
|
key: `${resourceId}:${localId}:${isBodiedSyncBlock}`,
|
|
87
87
|
syncBlockStore: syncBlockStore,
|
|
88
|
+
doc: state.doc,
|
|
88
89
|
resourceId: resourceId,
|
|
89
90
|
localId: localId,
|
|
90
91
|
intl: intl,
|
|
@@ -543,6 +543,7 @@ var EditorPositionedSyncedLocationDropdown = function EditorPositionedSyncedLoca
|
|
|
543
543
|
};
|
|
544
544
|
export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWithCount(_ref8) {
|
|
545
545
|
var syncBlockStore = _ref8.syncBlockStore,
|
|
546
|
+
doc = _ref8.doc,
|
|
546
547
|
resourceId = _ref8.resourceId,
|
|
547
548
|
intl = _ref8.intl,
|
|
548
549
|
isSource = _ref8.isSource,
|
|
@@ -558,7 +559,8 @@ export var SyncedLocationDropdownWithCount = function SyncedLocationDropdownWith
|
|
|
558
559
|
isSource: isSource,
|
|
559
560
|
localId: localId,
|
|
560
561
|
resourceId: resourceId,
|
|
561
|
-
syncBlockStore: syncBlockStore
|
|
562
|
+
syncBlockStore: syncBlockStore,
|
|
563
|
+
doc: doc
|
|
562
564
|
}),
|
|
563
565
|
fetchStatus = _useReferenceData.fetchStatus,
|
|
564
566
|
locations = _useReferenceData.locations;
|
|
@@ -698,24 +700,29 @@ var DropdownContent = function DropdownContent(_ref1) {
|
|
|
698
700
|
};
|
|
699
701
|
var useReferenceData = function useReferenceData(_ref11) {
|
|
700
702
|
var syncBlockStore = _ref11.syncBlockStore,
|
|
703
|
+
doc = _ref11.doc,
|
|
701
704
|
resourceId = _ref11.resourceId,
|
|
702
705
|
intl = _ref11.intl,
|
|
703
706
|
isSource = _ref11.isSource,
|
|
704
707
|
localId = _ref11.localId;
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}),
|
|
708
|
+
// Refresh locations when the toolbar opens, rather than on every document edit.
|
|
709
|
+
var _useState9 = useState(doc),
|
|
708
710
|
_useState0 = _slicedToArray(_useState9, 1),
|
|
709
|
-
|
|
711
|
+
docAtMount = _useState0[0];
|
|
710
712
|
var _useState1 = useState(function () {
|
|
713
|
+
return isSource && syncBlockStore.sourceManager.isNewSourceBlock(resourceId);
|
|
714
|
+
}),
|
|
715
|
+
_useState10 = _slicedToArray(_useState1, 1),
|
|
716
|
+
isNewSourceBlock = _useState10[0];
|
|
717
|
+
var _useState11 = useState(function () {
|
|
711
718
|
return {
|
|
712
719
|
fetchStatus: isNewSourceBlock ? 'success' : 'loading',
|
|
713
720
|
locations: EMPTY_LOCATIONS
|
|
714
721
|
};
|
|
715
722
|
}),
|
|
716
|
-
|
|
717
|
-
state =
|
|
718
|
-
setState =
|
|
723
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
724
|
+
state = _useState12[0],
|
|
725
|
+
setState = _useState12[1];
|
|
719
726
|
useEffect(function () {
|
|
720
727
|
var isCurrentRequest = true;
|
|
721
728
|
setState({
|
|
@@ -729,7 +736,7 @@ var useReferenceData = function useReferenceData(_ref11) {
|
|
|
729
736
|
while (1) switch (_context2.prev = _context2.next) {
|
|
730
737
|
case 0:
|
|
731
738
|
_context2.next = 1;
|
|
732
|
-
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource);
|
|
739
|
+
return syncBlockStore.fetchReferencesSourceInfo(resourceId, localId, isSource, docAtMount);
|
|
733
740
|
case 1:
|
|
734
741
|
response = _context2.sent;
|
|
735
742
|
if (isCurrentRequest) {
|
|
@@ -769,7 +776,7 @@ var useReferenceData = function useReferenceData(_ref11) {
|
|
|
769
776
|
return function () {
|
|
770
777
|
isCurrentRequest = false;
|
|
771
778
|
};
|
|
772
|
-
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock]);
|
|
779
|
+
}, [syncBlockStore, resourceId, intl, isSource, localId, isNewSourceBlock, docAtMount]);
|
|
773
780
|
return {
|
|
774
781
|
fetchStatus: state.fetchStatus,
|
|
775
782
|
locations: state.locations
|
|
@@ -80,6 +80,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
80
80
|
return /*#__PURE__*/React.createElement(SyncedLocationDropdownWithCount, {
|
|
81
81
|
key: "".concat(resourceId, ":").concat(localId, ":").concat(isBodiedSyncBlock),
|
|
82
82
|
syncBlockStore: syncBlockStore,
|
|
83
|
+
doc: state.doc,
|
|
83
84
|
resourceId: resourceId,
|
|
84
85
|
localId: localId,
|
|
85
86
|
intl: intl,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl';
|
|
2
2
|
import type { FloatingToolbarCustomRenderContext } from '@atlaskit/editor-common/types/floating-toolbar';
|
|
3
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-editor-plugin';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
4
5
|
import type { ReferencesSourceInfo } from '@atlaskit/editor-synced-block-provider/common/types';
|
|
5
6
|
import type { SyncBlockSourceInfo } from '@atlaskit/editor-synced-block-provider/providers/types';
|
|
6
7
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider/syncBlockStoreManager';
|
|
7
8
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
8
9
|
interface Props {
|
|
9
10
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
11
|
+
doc?: PMNode;
|
|
10
12
|
floatingToolbarRenderContext?: FloatingToolbarCustomRenderContext;
|
|
11
13
|
intl: IntlShape;
|
|
12
14
|
isSource: boolean;
|
|
@@ -35,5 +37,5 @@ export type SyncedLocationItem = {
|
|
|
35
37
|
export declare const processReferenceData: (referenceData: ReferencesSourceInfo['references'], intl: IntlShape) => SyncBlockSourceInfo[];
|
|
36
38
|
export declare const buildFieldAwareItems: (referenceData: ReferencesSourceInfo['references'], formatMessage: IntlShape['formatMessage']) => SyncedLocationItem[];
|
|
37
39
|
export declare const SyncedLocationDropdown: ({ syncBlockStore, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
38
|
-
export declare const SyncedLocationDropdownWithCount: ({ syncBlockStore, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
40
|
+
export declare const SyncedLocationDropdownWithCount: ({ syncBlockStore, doc, resourceId, intl, isSource, localId, api, floatingToolbarRenderContext, }: Props) => JSX.Element;
|
|
39
41
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.7",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/editor-plugin-user-intent": "^24.0.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^4.4.0",
|
|
44
|
-
"@atlaskit/editor-synced-block-provider": "^22.
|
|
44
|
+
"@atlaskit/editor-synced-block-provider": "^22.1.0",
|
|
45
45
|
"@atlaskit/editor-toolbar": "^2.8.0",
|
|
46
46
|
"@atlaskit/flag": "^19.0.0",
|
|
47
47
|
"@atlaskit/icon": "38.0.2",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"memoize-one": "^6.0.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@atlaskit/editor-common": "^130.
|
|
68
|
+
"@atlaskit/editor-common": "^130.4.0",
|
|
69
69
|
"react": "^18.2.0 || ^19.2.0",
|
|
70
70
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
71
71
|
},
|