@atlaskit/editor-plugin-synced-block 6.0.45 → 6.0.47
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 +18 -0
- package/dist/cjs/pm-plugins/main.js +75 -0
- package/dist/cjs/pm-plugins/utils/handle-bodied-sync-block-creation.js +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/Flag.js +5 -1
- package/dist/es2019/pm-plugins/main.js +75 -0
- package/dist/es2019/pm-plugins/utils/handle-bodied-sync-block-creation.js +1 -1
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/Flag.js +5 -0
- package/dist/esm/pm-plugins/main.js +75 -0
- package/dist/esm/pm-plugins/utils/handle-bodied-sync-block-creation.js +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/Flag.js +5 -1
- package/dist/types/pm-plugins/utils/ignore-dom-event.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/utils/ignore-dom-event.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 6.0.47
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 6.0.46
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`20b51bc2e61a4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/20b51bc2e61a4) -
|
|
14
|
+
Remove duplicate source synced blocks when inserting block templates with existing resourceIds and
|
|
15
|
+
show error flag
|
|
16
|
+
- [`15deee785151b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/15deee785151b) -
|
|
17
|
+
EDITOR-6174 Pass node to createBodiedSyncBlockNode to cache content on creation, preventing false
|
|
18
|
+
unsaved changes on page refresh
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 6.0.45
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -17,6 +17,7 @@ var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
|
17
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
18
18
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
19
19
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
20
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
20
21
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
21
22
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
22
23
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
@@ -576,11 +577,85 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
576
577
|
_ret = _loop();
|
|
577
578
|
if (_ret) return _ret.v;
|
|
578
579
|
}
|
|
580
|
+
|
|
581
|
+
// Detect and remove duplicate bodiedSyncBlock resourceIds.
|
|
582
|
+
// When a block template containing a source sync block is inserted into the
|
|
583
|
+
// same document, it creates a duplicate with the same resourceId. We keep the
|
|
584
|
+
// first occurrence and delete subsequent duplicates entirely (including their
|
|
585
|
+
// contents), since a document must not contain two source sync blocks with the
|
|
586
|
+
// same resourceId.
|
|
579
587
|
} catch (err) {
|
|
580
588
|
_iterator2.e(err);
|
|
581
589
|
} finally {
|
|
582
590
|
_iterator2.f();
|
|
583
591
|
}
|
|
592
|
+
if (trs.some(function (tr) {
|
|
593
|
+
return tr.docChanged && !tr.getMeta('isRemote');
|
|
594
|
+
}) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_8')) {
|
|
595
|
+
// Quick check: only walk the full document when at least one
|
|
596
|
+
// transaction inserted a source synced block. This avoids an
|
|
597
|
+
// expensive descendants() traversal on every local edit.
|
|
598
|
+
var hasInsertedSourceBlock = trs.some(function (tr) {
|
|
599
|
+
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
return tr.steps.some(function (step) {
|
|
603
|
+
if (!(step instanceof _transform.ReplaceStep || step instanceof _transform.ReplaceAroundStep) || !('slice' in step)) {
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
var _ref0 = step,
|
|
607
|
+
slice = _ref0.slice;
|
|
608
|
+
var found = false;
|
|
609
|
+
slice.content.descendants(function (node) {
|
|
610
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node) && node.attrs.resourceId) {
|
|
611
|
+
found = true;
|
|
612
|
+
}
|
|
613
|
+
return false;
|
|
614
|
+
});
|
|
615
|
+
return found;
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
if (!hasInsertedSourceBlock) {
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
var seenResourceIds = new Set();
|
|
622
|
+
var duplicates = [];
|
|
623
|
+
newState.doc.descendants(function (node, pos) {
|
|
624
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node) && node.attrs.resourceId) {
|
|
625
|
+
if (seenResourceIds.has(node.attrs.resourceId)) {
|
|
626
|
+
duplicates.push({
|
|
627
|
+
pos: pos,
|
|
628
|
+
nodeSize: node.nodeSize
|
|
629
|
+
});
|
|
630
|
+
} else {
|
|
631
|
+
seenResourceIds.add(node.attrs.resourceId);
|
|
632
|
+
}
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
if (duplicates.length > 0) {
|
|
637
|
+
var tr = newState.tr;
|
|
638
|
+
|
|
639
|
+
// Delete in reverse document order so positions remain valid
|
|
640
|
+
for (var i = duplicates.length - 1; i >= 0; i--) {
|
|
641
|
+
var dup = duplicates[i];
|
|
642
|
+
tr.delete(dup.pos, dup.pos + dup.nodeSize);
|
|
643
|
+
}
|
|
644
|
+
tr.setMeta('addToHistory', false);
|
|
645
|
+
(0, _utils2.deferDispatch)(function () {
|
|
646
|
+
var _api$core;
|
|
647
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref1) {
|
|
648
|
+
var tr = _ref1.tr;
|
|
649
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
650
|
+
activeFlag: {
|
|
651
|
+
id: _types.FLAG_ID.DUPLICATE_SOURCE_SYNC_BLOCK
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
return tr;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
584
659
|
return null;
|
|
585
660
|
}
|
|
586
661
|
});
|
|
@@ -99,7 +99,7 @@ var handleBodiedSyncBlockCreation = exports.handleBodiedSyncBlockCreation = func
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
|
-
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, function (success) {
|
|
102
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, node.node, function (success) {
|
|
103
103
|
if (success) {
|
|
104
104
|
var _api$core4, _api$core5;
|
|
105
105
|
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref3) {
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var FLAG_ID = exports.FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
14
14
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
15
15
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
16
16
|
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
17
|
+
FLAG_ID["DUPLICATE_SOURCE_SYNC_BLOCK"] = "duplicate-source-sync-block";
|
|
17
18
|
return FLAG_ID;
|
|
18
19
|
}({});
|
|
19
20
|
var SYNCED_BLOCK_BUTTON_TEST_ID = exports.SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/cjs/ui/Flag.js
CHANGED
|
@@ -21,7 +21,7 @@ var _types = require("../types");
|
|
|
21
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
-
var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
24
|
+
var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
25
25
|
title: _messages.syncBlockMessages.failToDeleteTitle,
|
|
26
26
|
description: _messages.syncBlockMessages.failToDeleteWhenOfflineDescription,
|
|
27
27
|
type: 'error'
|
|
@@ -56,6 +56,10 @@ var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _d
|
|
|
56
56
|
title: _messages.syncBlockMessages.inlineExtensionInSyncBlockTitle,
|
|
57
57
|
description: _messages.syncBlockMessages.inlineExtensionInSyncBlockDescription,
|
|
58
58
|
type: 'error'
|
|
59
|
+
}), _types.FLAG_ID.DUPLICATE_SOURCE_SYNC_BLOCK, {
|
|
60
|
+
title: _messages.syncBlockMessages.duplicateSourceSyncBlockTitle,
|
|
61
|
+
description: _messages.syncBlockMessages.duplicateSourceSyncBlockDescription,
|
|
62
|
+
type: 'error'
|
|
59
63
|
});
|
|
60
64
|
var Flag = exports.Flag = function Flag(_ref) {
|
|
61
65
|
var api = _ref.api;
|
|
@@ -7,6 +7,7 @@ import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@
|
|
|
7
7
|
import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
9
9
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
+
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
10
11
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
11
12
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
12
13
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -526,6 +527,80 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
526
527
|
}
|
|
527
528
|
}
|
|
528
529
|
}
|
|
530
|
+
|
|
531
|
+
// Detect and remove duplicate bodiedSyncBlock resourceIds.
|
|
532
|
+
// When a block template containing a source sync block is inserted into the
|
|
533
|
+
// same document, it creates a duplicate with the same resourceId. We keep the
|
|
534
|
+
// first occurrence and delete subsequent duplicates entirely (including their
|
|
535
|
+
// contents), since a document must not contain two source sync blocks with the
|
|
536
|
+
// same resourceId.
|
|
537
|
+
if (trs.some(tr => tr.docChanged && !tr.getMeta('isRemote')) && fg('platform_synced_block_patch_8')) {
|
|
538
|
+
// Quick check: only walk the full document when at least one
|
|
539
|
+
// transaction inserted a source synced block. This avoids an
|
|
540
|
+
// expensive descendants() traversal on every local edit.
|
|
541
|
+
const hasInsertedSourceBlock = trs.some(tr => {
|
|
542
|
+
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
return tr.steps.some(step => {
|
|
546
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep) || !('slice' in step)) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
const {
|
|
550
|
+
slice
|
|
551
|
+
} = step;
|
|
552
|
+
let found = false;
|
|
553
|
+
slice.content.descendants(node => {
|
|
554
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node) && node.attrs.resourceId) {
|
|
555
|
+
found = true;
|
|
556
|
+
}
|
|
557
|
+
return false;
|
|
558
|
+
});
|
|
559
|
+
return found;
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
if (!hasInsertedSourceBlock) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
const seenResourceIds = new Set();
|
|
566
|
+
const duplicates = [];
|
|
567
|
+
newState.doc.descendants((node, pos) => {
|
|
568
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node) && node.attrs.resourceId) {
|
|
569
|
+
if (seenResourceIds.has(node.attrs.resourceId)) {
|
|
570
|
+
duplicates.push({
|
|
571
|
+
pos,
|
|
572
|
+
nodeSize: node.nodeSize
|
|
573
|
+
});
|
|
574
|
+
} else {
|
|
575
|
+
seenResourceIds.add(node.attrs.resourceId);
|
|
576
|
+
}
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
if (duplicates.length > 0) {
|
|
581
|
+
const {
|
|
582
|
+
tr
|
|
583
|
+
} = newState;
|
|
584
|
+
|
|
585
|
+
// Delete in reverse document order so positions remain valid
|
|
586
|
+
for (let i = duplicates.length - 1; i >= 0; i--) {
|
|
587
|
+
const dup = duplicates[i];
|
|
588
|
+
tr.delete(dup.pos, dup.pos + dup.nodeSize);
|
|
589
|
+
}
|
|
590
|
+
tr.setMeta('addToHistory', false);
|
|
591
|
+
deferDispatch(() => {
|
|
592
|
+
var _api$core;
|
|
593
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
594
|
+
tr
|
|
595
|
+
}) => tr.setMeta(syncedBlockPluginKey, {
|
|
596
|
+
activeFlag: {
|
|
597
|
+
id: FLAG_ID.DUPLICATE_SOURCE_SYNC_BLOCK
|
|
598
|
+
}
|
|
599
|
+
}));
|
|
600
|
+
});
|
|
601
|
+
return tr;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
529
604
|
return null;
|
|
530
605
|
}
|
|
531
606
|
});
|
|
@@ -91,7 +91,7 @@ export const handleBodiedSyncBlockCreation = (bodiedSyncBlockAdded, editorState,
|
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
-
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, success => {
|
|
94
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, node.node, success => {
|
|
95
95
|
if (success) {
|
|
96
96
|
var _api$core4, _api$core5;
|
|
97
97
|
api === null || api === void 0 ? void 0 : (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute(({
|
|
@@ -8,6 +8,7 @@ export let FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
8
8
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
9
9
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
10
10
|
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
11
|
+
FLAG_ID["DUPLICATE_SOURCE_SYNC_BLOCK"] = "duplicate-source-sync-block";
|
|
11
12
|
return FLAG_ID;
|
|
12
13
|
}({});
|
|
13
14
|
export const SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/es2019/ui/Flag.js
CHANGED
|
@@ -53,6 +53,11 @@ const flagMap = {
|
|
|
53
53
|
title: messages.inlineExtensionInSyncBlockTitle,
|
|
54
54
|
description: messages.inlineExtensionInSyncBlockDescription,
|
|
55
55
|
type: 'error'
|
|
56
|
+
},
|
|
57
|
+
[FLAG_ID.DUPLICATE_SOURCE_SYNC_BLOCK]: {
|
|
58
|
+
title: messages.duplicateSourceSyncBlockTitle,
|
|
59
|
+
description: messages.duplicateSourceSyncBlockDescription,
|
|
60
|
+
type: 'error'
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
63
|
export const Flag = ({
|
|
@@ -15,6 +15,7 @@ import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@
|
|
|
15
15
|
import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
16
16
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
17
17
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
18
|
+
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
18
19
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
19
20
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
20
21
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
@@ -569,11 +570,85 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
569
570
|
_ret = _loop();
|
|
570
571
|
if (_ret) return _ret.v;
|
|
571
572
|
}
|
|
573
|
+
|
|
574
|
+
// Detect and remove duplicate bodiedSyncBlock resourceIds.
|
|
575
|
+
// When a block template containing a source sync block is inserted into the
|
|
576
|
+
// same document, it creates a duplicate with the same resourceId. We keep the
|
|
577
|
+
// first occurrence and delete subsequent duplicates entirely (including their
|
|
578
|
+
// contents), since a document must not contain two source sync blocks with the
|
|
579
|
+
// same resourceId.
|
|
572
580
|
} catch (err) {
|
|
573
581
|
_iterator2.e(err);
|
|
574
582
|
} finally {
|
|
575
583
|
_iterator2.f();
|
|
576
584
|
}
|
|
585
|
+
if (trs.some(function (tr) {
|
|
586
|
+
return tr.docChanged && !tr.getMeta('isRemote');
|
|
587
|
+
}) && fg('platform_synced_block_patch_8')) {
|
|
588
|
+
// Quick check: only walk the full document when at least one
|
|
589
|
+
// transaction inserted a source synced block. This avoids an
|
|
590
|
+
// expensive descendants() traversal on every local edit.
|
|
591
|
+
var hasInsertedSourceBlock = trs.some(function (tr) {
|
|
592
|
+
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
return tr.steps.some(function (step) {
|
|
596
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep) || !('slice' in step)) {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
var _ref0 = step,
|
|
600
|
+
slice = _ref0.slice;
|
|
601
|
+
var found = false;
|
|
602
|
+
slice.content.descendants(function (node) {
|
|
603
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node) && node.attrs.resourceId) {
|
|
604
|
+
found = true;
|
|
605
|
+
}
|
|
606
|
+
return false;
|
|
607
|
+
});
|
|
608
|
+
return found;
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
if (!hasInsertedSourceBlock) {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
var seenResourceIds = new Set();
|
|
615
|
+
var duplicates = [];
|
|
616
|
+
newState.doc.descendants(function (node, pos) {
|
|
617
|
+
if (syncBlockStore.sourceManager.isSourceBlock(node) && node.attrs.resourceId) {
|
|
618
|
+
if (seenResourceIds.has(node.attrs.resourceId)) {
|
|
619
|
+
duplicates.push({
|
|
620
|
+
pos: pos,
|
|
621
|
+
nodeSize: node.nodeSize
|
|
622
|
+
});
|
|
623
|
+
} else {
|
|
624
|
+
seenResourceIds.add(node.attrs.resourceId);
|
|
625
|
+
}
|
|
626
|
+
return false;
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
if (duplicates.length > 0) {
|
|
630
|
+
var tr = newState.tr;
|
|
631
|
+
|
|
632
|
+
// Delete in reverse document order so positions remain valid
|
|
633
|
+
for (var i = duplicates.length - 1; i >= 0; i--) {
|
|
634
|
+
var dup = duplicates[i];
|
|
635
|
+
tr.delete(dup.pos, dup.pos + dup.nodeSize);
|
|
636
|
+
}
|
|
637
|
+
tr.setMeta('addToHistory', false);
|
|
638
|
+
deferDispatch(function () {
|
|
639
|
+
var _api$core;
|
|
640
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref1) {
|
|
641
|
+
var tr = _ref1.tr;
|
|
642
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
643
|
+
activeFlag: {
|
|
644
|
+
id: FLAG_ID.DUPLICATE_SOURCE_SYNC_BLOCK
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
return tr;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
577
652
|
return null;
|
|
578
653
|
}
|
|
579
654
|
});
|
|
@@ -92,7 +92,7 @@ export var handleBodiedSyncBlockCreation = function handleBodiedSyncBlockCreatio
|
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
|
-
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, function (success) {
|
|
95
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, node.node, function (success) {
|
|
96
96
|
if (success) {
|
|
97
97
|
var _api$core4, _api$core5;
|
|
98
98
|
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref3) {
|
package/dist/esm/types/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
8
8
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
9
9
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
10
10
|
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
11
|
+
FLAG_ID["DUPLICATE_SOURCE_SYNC_BLOCK"] = "duplicate-source-sync-block";
|
|
11
12
|
return FLAG_ID;
|
|
12
13
|
}({});
|
|
13
14
|
export var SYNCED_BLOCK_BUTTON_TEST_ID = {
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -12,7 +12,7 @@ import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
|
|
|
12
12
|
import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
|
|
13
13
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
14
14
|
import { FLAG_ID } from '../types';
|
|
15
|
-
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
15
|
+
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
16
16
|
title: messages.failToDeleteTitle,
|
|
17
17
|
description: messages.failToDeleteWhenOfflineDescription,
|
|
18
18
|
type: 'error'
|
|
@@ -47,6 +47,10 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_d
|
|
|
47
47
|
title: messages.inlineExtensionInSyncBlockTitle,
|
|
48
48
|
description: messages.inlineExtensionInSyncBlockDescription,
|
|
49
49
|
type: 'error'
|
|
50
|
+
}), FLAG_ID.DUPLICATE_SOURCE_SYNC_BLOCK, {
|
|
51
|
+
title: messages.duplicateSourceSyncBlockTitle,
|
|
52
|
+
description: messages.duplicateSourceSyncBlockDescription,
|
|
53
|
+
type: 'error'
|
|
50
54
|
});
|
|
51
55
|
export var Flag = function Flag(_ref) {
|
|
52
56
|
var api = _ref.api;
|
|
@@ -5,4 +5,4 @@ import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
|
|
|
5
5
|
*
|
|
6
6
|
* @returns true if should ignore event happens within bodiedSyncBlock node when offline
|
|
7
7
|
*/
|
|
8
|
-
export declare const shouldIgnoreDomEvent: (view: EditorView, event: MouseEvent | PointerEvent, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) =>
|
|
8
|
+
export declare const shouldIgnoreDomEvent: (view: EditorView, event: MouseEvent | PointerEvent, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => boolean | undefined;
|
|
@@ -10,7 +10,8 @@ export declare enum FLAG_ID {
|
|
|
10
10
|
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
|
|
11
11
|
CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block",
|
|
12
12
|
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block",
|
|
13
|
-
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block"
|
|
13
|
+
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block",
|
|
14
|
+
DUPLICATE_SOURCE_SYNC_BLOCK = "duplicate-source-sync-block"
|
|
14
15
|
}
|
|
15
16
|
type FlagConfig = {
|
|
16
17
|
id: FLAG_ID;
|
|
@@ -5,4 +5,4 @@ import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
|
|
|
5
5
|
*
|
|
6
6
|
* @returns true if should ignore event happens within bodiedSyncBlock node when offline
|
|
7
7
|
*/
|
|
8
|
-
export declare const shouldIgnoreDomEvent: (view: EditorView, event: MouseEvent | PointerEvent, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) =>
|
|
8
|
+
export declare const shouldIgnoreDomEvent: (view: EditorView, event: MouseEvent | PointerEvent, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => boolean | undefined;
|
|
@@ -10,7 +10,8 @@ export declare enum FLAG_ID {
|
|
|
10
10
|
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
|
|
11
11
|
CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block",
|
|
12
12
|
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block",
|
|
13
|
-
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block"
|
|
13
|
+
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block",
|
|
14
|
+
DUPLICATE_SOURCE_SYNC_BLOCK = "duplicate-source-sync-block"
|
|
14
15
|
}
|
|
15
16
|
type FlagConfig = {
|
|
16
17
|
id: FLAG_ID;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.47",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^52.4.0",
|
|
32
|
-
"@atlaskit/button": "23.
|
|
32
|
+
"@atlaskit/button": "23.11.0",
|
|
33
33
|
"@atlaskit/dropdown-menu": "16.8.6",
|
|
34
34
|
"@atlaskit/editor-json-transformer": "^8.31.0",
|
|
35
35
|
"@atlaskit/editor-plugin-analytics": "^8.0.0",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@atlaskit/modal-dialog": "^14.14.0",
|
|
54
54
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
55
55
|
"@atlaskit/primitives": "^18.1.0",
|
|
56
|
-
"@atlaskit/spinner": "19.0
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^54.
|
|
56
|
+
"@atlaskit/spinner": "19.1.0",
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^54.5.0",
|
|
58
58
|
"@atlaskit/tokens": "11.4.3",
|
|
59
59
|
"@atlaskit/tooltip": "^21.1.0",
|
|
60
60
|
"@atlaskit/visually-hidden": "^3.0.0",
|