@atlaskit/editor-plugin-synced-block 5.3.8 → 5.3.9
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 +9 -0
- package/dist/cjs/editor-commands/index.js +22 -0
- package/dist/cjs/pm-plugins/utils/utils.js +32 -1
- package/dist/cjs/ui/SyncBlockRendererWrapper.js +3 -2
- package/dist/es2019/editor-commands/index.js +22 -0
- package/dist/es2019/pm-plugins/utils/utils.js +32 -0
- package/dist/es2019/ui/SyncBlockRendererWrapper.js +3 -2
- package/dist/esm/editor-commands/index.js +22 -0
- package/dist/esm/pm-plugins/utils/utils.js +31 -0
- package/dist/esm/ui/SyncBlockRendererWrapper.js +3 -2
- package/dist/types/pm-plugins/utils/utils.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 5.3.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8782c30447091`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8782c30447091) -
|
|
8
|
+
[ux] EDITOR-4756 Fix convert to synced block logic by expanding selection to block range before
|
|
9
|
+
conversion
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 5.3.8
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -30,6 +30,17 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
30
30
|
var paragraphNode = paragraph.createAndFill({});
|
|
31
31
|
var newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
32
32
|
if (!newBodiedSyncBlockNode) {
|
|
33
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
34
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
|
|
35
|
+
action: _analytics.ACTION.ERROR,
|
|
36
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
37
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
38
|
+
attributes: {
|
|
39
|
+
error: 'Create and fill for empty content failed'
|
|
40
|
+
},
|
|
41
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
42
|
+
});
|
|
43
|
+
}
|
|
33
44
|
return false;
|
|
34
45
|
}
|
|
35
46
|
|
|
@@ -60,6 +71,17 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
60
71
|
var _attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
61
72
|
var _newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(_attrs, conversionInfo.contentToInclude);
|
|
62
73
|
if (!_newBodiedSyncBlockNode) {
|
|
74
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
75
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
|
|
76
|
+
action: _analytics.ACTION.ERROR,
|
|
77
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
78
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
79
|
+
attributes: {
|
|
80
|
+
error: 'Create and fill for content failed'
|
|
81
|
+
},
|
|
82
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
83
|
+
});
|
|
84
|
+
}
|
|
63
85
|
return false;
|
|
64
86
|
}
|
|
65
87
|
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sliceFullyContainsNode = exports.isBodiedSyncBlockNode = exports.findSyncBlockOrBodiedSyncBlock = exports.findSyncBlock = exports.findBodiedSyncBlock = exports.canBeConvertedToSyncBlock = void 0;
|
|
6
|
+
exports.sliceFullyContainsNode = exports.isBodiedSyncBlockNode = exports.findSyncBlockOrBodiedSyncBlock = exports.findSyncBlock = exports.findBodiedSyncBlock = exports.canBeConvertedToSyncBlockOld = exports.canBeConvertedToSyncBlockNew = exports.canBeConvertedToSyncBlock = void 0;
|
|
7
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
7
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
9
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
11
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
13
|
var findSyncBlock = exports.findSyncBlock = function findSyncBlock(schema, selection) {
|
|
12
14
|
var syncBlock = schema.nodes.syncBlock;
|
|
13
15
|
return (0, _utils.findSelectedNodeOfType)(syncBlock)(selection);
|
|
@@ -32,6 +34,9 @@ var UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedExt
|
|
|
32
34
|
* or false if conversion is not possible
|
|
33
35
|
*/
|
|
34
36
|
var canBeConvertedToSyncBlock = exports.canBeConvertedToSyncBlock = function canBeConvertedToSyncBlock(selection) {
|
|
37
|
+
return (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? canBeConvertedToSyncBlockNew(selection) : canBeConvertedToSyncBlockOld(selection);
|
|
38
|
+
};
|
|
39
|
+
var canBeConvertedToSyncBlockOld = exports.canBeConvertedToSyncBlockOld = function canBeConvertedToSyncBlockOld(selection) {
|
|
35
40
|
var schema = selection.$from.doc.type.schema;
|
|
36
41
|
var nodes = schema.nodes;
|
|
37
42
|
var from = selection.from;
|
|
@@ -70,6 +75,32 @@ var canBeConvertedToSyncBlock = exports.canBeConvertedToSyncBlock = function can
|
|
|
70
75
|
to: to
|
|
71
76
|
};
|
|
72
77
|
};
|
|
78
|
+
var canBeConvertedToSyncBlockNew = exports.canBeConvertedToSyncBlockNew = function canBeConvertedToSyncBlockNew(selection) {
|
|
79
|
+
var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(selection),
|
|
80
|
+
$from = _expandSelectionToBlo.$from,
|
|
81
|
+
range = _expandSelectionToBlo.range;
|
|
82
|
+
if (!range) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
var from = range.start;
|
|
86
|
+
var to = range.end;
|
|
87
|
+
var canBeConverted = true;
|
|
88
|
+
$from.doc.nodesBetween(from, to, function (node) {
|
|
89
|
+
if (UNSUPPORTED_NODE_TYPES.has(node.type.name)) {
|
|
90
|
+
canBeConverted = false;
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (!canBeConverted) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
var contentToInclude = removeBreakoutMarks($from.doc.slice(from, to).content);
|
|
98
|
+
return {
|
|
99
|
+
contentToInclude: contentToInclude,
|
|
100
|
+
from: from,
|
|
101
|
+
to: to
|
|
102
|
+
};
|
|
103
|
+
};
|
|
73
104
|
var removeBreakoutMarks = function removeBreakoutMarks(content) {
|
|
74
105
|
var nodes = [];
|
|
75
106
|
|
|
@@ -11,7 +11,7 @@ var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider
|
|
|
11
11
|
var _SyncBlockLabel = require("./SyncBlockLabel");
|
|
12
12
|
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
13
13
|
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
14
|
-
var _syncBlockFetchResult, _syncBlockFetchResult2;
|
|
14
|
+
var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3;
|
|
15
15
|
var syncedBlockRenderer = _ref.syncedBlockRenderer,
|
|
16
16
|
useFetchSyncBlockData = _ref.useFetchSyncBlockData,
|
|
17
17
|
useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
|
|
@@ -20,7 +20,8 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
20
20
|
var syncBlockFetchResult = useFetchSyncBlockData();
|
|
21
21
|
var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
|
|
22
22
|
var contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 || (_syncBlockFetchResult = _syncBlockFetchResult.data) === null || _syncBlockFetchResult === void 0 ? void 0 : _syncBlockFetchResult.contentUpdatedAt;
|
|
23
|
-
var
|
|
23
|
+
var isUnpublishedBlock = ((_syncBlockFetchResult2 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult2 === void 0 || (_syncBlockFetchResult2 = _syncBlockFetchResult2.data) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.status) === 'unpublished';
|
|
24
|
+
var isUnsyncedBlock = isUnpublishedBlock || (syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult3 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult3 === void 0 || (_syncBlockFetchResult3 = _syncBlockFetchResult3.error) === null || _syncBlockFetchResult3 === void 0 ? void 0 : _syncBlockFetchResult3.type) === _editorSyncedBlockProvider.SyncBlockError.NotFound;
|
|
24
25
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
25
26
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
26
27
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -30,6 +30,17 @@ export const createSyncedBlock = ({
|
|
|
30
30
|
const paragraphNode = paragraph.createAndFill({});
|
|
31
31
|
const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
32
32
|
if (!newBodiedSyncBlockNode) {
|
|
33
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
34
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
|
|
35
|
+
action: ACTION.ERROR,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
37
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
38
|
+
attributes: {
|
|
39
|
+
error: 'Create and fill for empty content failed'
|
|
40
|
+
},
|
|
41
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
42
|
+
});
|
|
43
|
+
}
|
|
33
44
|
return false;
|
|
34
45
|
}
|
|
35
46
|
|
|
@@ -60,6 +71,17 @@ export const createSyncedBlock = ({
|
|
|
60
71
|
const attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
61
72
|
const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, conversionInfo.contentToInclude);
|
|
62
73
|
if (!newBodiedSyncBlockNode) {
|
|
74
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
75
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
|
|
76
|
+
action: ACTION.ERROR,
|
|
77
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
78
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
79
|
+
attributes: {
|
|
80
|
+
error: 'Create and fill for content failed'
|
|
81
|
+
},
|
|
82
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
83
|
+
});
|
|
84
|
+
}
|
|
63
85
|
return false;
|
|
64
86
|
}
|
|
65
87
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
5
|
import { CellSelection, findTable } from '@atlaskit/editor-tables';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
export const findSyncBlock = (schema, selection) => {
|
|
6
8
|
const {
|
|
7
9
|
syncBlock
|
|
@@ -26,6 +28,9 @@ const UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedE
|
|
|
26
28
|
* or false if conversion is not possible
|
|
27
29
|
*/
|
|
28
30
|
export const canBeConvertedToSyncBlock = selection => {
|
|
31
|
+
return fg('platform_synced_block_dogfooding') ? canBeConvertedToSyncBlockNew(selection) : canBeConvertedToSyncBlockOld(selection);
|
|
32
|
+
};
|
|
33
|
+
export const canBeConvertedToSyncBlockOld = selection => {
|
|
29
34
|
const schema = selection.$from.doc.type.schema;
|
|
30
35
|
const {
|
|
31
36
|
nodes
|
|
@@ -66,6 +71,33 @@ export const canBeConvertedToSyncBlock = selection => {
|
|
|
66
71
|
to
|
|
67
72
|
};
|
|
68
73
|
};
|
|
74
|
+
export const canBeConvertedToSyncBlockNew = selection => {
|
|
75
|
+
const {
|
|
76
|
+
$from,
|
|
77
|
+
range
|
|
78
|
+
} = expandSelectionToBlockRange(selection);
|
|
79
|
+
if (!range) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const from = range.start;
|
|
83
|
+
const to = range.end;
|
|
84
|
+
let canBeConverted = true;
|
|
85
|
+
$from.doc.nodesBetween(from, to, node => {
|
|
86
|
+
if (UNSUPPORTED_NODE_TYPES.has(node.type.name)) {
|
|
87
|
+
canBeConverted = false;
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (!canBeConverted) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const contentToInclude = removeBreakoutMarks($from.doc.slice(from, to).content);
|
|
95
|
+
return {
|
|
96
|
+
contentToInclude,
|
|
97
|
+
from,
|
|
98
|
+
to
|
|
99
|
+
};
|
|
100
|
+
};
|
|
69
101
|
const removeBreakoutMarks = content => {
|
|
70
102
|
const nodes = [];
|
|
71
103
|
|
|
@@ -10,11 +10,12 @@ const SyncBlockRendererWrapperComponent = ({
|
|
|
10
10
|
localId,
|
|
11
11
|
api
|
|
12
12
|
}) => {
|
|
13
|
-
var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3, _syncBlockFetchResult4;
|
|
13
|
+
var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3, _syncBlockFetchResult4, _syncBlockFetchResult5, _syncBlockFetchResult6;
|
|
14
14
|
const syncBlockFetchResult = useFetchSyncBlockData();
|
|
15
15
|
const title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
|
|
16
16
|
const contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 ? void 0 : (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 ? void 0 : (_syncBlockFetchResult2 = _syncBlockFetchResult.data) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.contentUpdatedAt;
|
|
17
|
-
const
|
|
17
|
+
const isUnpublishedBlock = ((_syncBlockFetchResult3 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult3 === void 0 ? void 0 : (_syncBlockFetchResult4 = _syncBlockFetchResult3.data) === null || _syncBlockFetchResult4 === void 0 ? void 0 : _syncBlockFetchResult4.status) === 'unpublished';
|
|
18
|
+
const isUnsyncedBlock = isUnpublishedBlock || (syncBlockFetchResult === null || syncBlockFetchResult === void 0 ? void 0 : (_syncBlockFetchResult5 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult5 === void 0 ? void 0 : (_syncBlockFetchResult6 = _syncBlockFetchResult5.error) === null || _syncBlockFetchResult6 === void 0 ? void 0 : _syncBlockFetchResult6.type) === SyncBlockError.NotFound;
|
|
18
19
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
19
20
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
20
21
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -24,6 +24,17 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
24
24
|
var paragraphNode = paragraph.createAndFill({});
|
|
25
25
|
var newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
26
26
|
if (!newBodiedSyncBlockNode) {
|
|
27
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
28
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
|
|
29
|
+
action: ACTION.ERROR,
|
|
30
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
31
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
32
|
+
attributes: {
|
|
33
|
+
error: 'Create and fill for empty content failed'
|
|
34
|
+
},
|
|
35
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
36
|
+
});
|
|
37
|
+
}
|
|
27
38
|
return false;
|
|
28
39
|
}
|
|
29
40
|
|
|
@@ -54,6 +65,17 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
54
65
|
var _attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
55
66
|
var _newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(_attrs, conversionInfo.contentToInclude);
|
|
56
67
|
if (!_newBodiedSyncBlockNode) {
|
|
68
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
69
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
|
|
70
|
+
action: ACTION.ERROR,
|
|
71
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
72
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
73
|
+
attributes: {
|
|
74
|
+
error: 'Create and fill for content failed'
|
|
75
|
+
},
|
|
76
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
77
|
+
});
|
|
78
|
+
}
|
|
57
79
|
return false;
|
|
58
80
|
}
|
|
59
81
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expandSelectionToBlockRange } from '@atlaskit/editor-common/selection';
|
|
1
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
5
|
import { CellSelection, findTable } from '@atlaskit/editor-tables';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
export var findSyncBlock = function findSyncBlock(schema, selection) {
|
|
6
8
|
var syncBlock = schema.nodes.syncBlock;
|
|
7
9
|
return findSelectedNodeOfType(syncBlock)(selection);
|
|
@@ -26,6 +28,9 @@ var UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedExt
|
|
|
26
28
|
* or false if conversion is not possible
|
|
27
29
|
*/
|
|
28
30
|
export var canBeConvertedToSyncBlock = function canBeConvertedToSyncBlock(selection) {
|
|
31
|
+
return fg('platform_synced_block_dogfooding') ? canBeConvertedToSyncBlockNew(selection) : canBeConvertedToSyncBlockOld(selection);
|
|
32
|
+
};
|
|
33
|
+
export var canBeConvertedToSyncBlockOld = function canBeConvertedToSyncBlockOld(selection) {
|
|
29
34
|
var schema = selection.$from.doc.type.schema;
|
|
30
35
|
var nodes = schema.nodes;
|
|
31
36
|
var from = selection.from;
|
|
@@ -64,6 +69,32 @@ export var canBeConvertedToSyncBlock = function canBeConvertedToSyncBlock(select
|
|
|
64
69
|
to: to
|
|
65
70
|
};
|
|
66
71
|
};
|
|
72
|
+
export var canBeConvertedToSyncBlockNew = function canBeConvertedToSyncBlockNew(selection) {
|
|
73
|
+
var _expandSelectionToBlo = expandSelectionToBlockRange(selection),
|
|
74
|
+
$from = _expandSelectionToBlo.$from,
|
|
75
|
+
range = _expandSelectionToBlo.range;
|
|
76
|
+
if (!range) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
var from = range.start;
|
|
80
|
+
var to = range.end;
|
|
81
|
+
var canBeConverted = true;
|
|
82
|
+
$from.doc.nodesBetween(from, to, function (node) {
|
|
83
|
+
if (UNSUPPORTED_NODE_TYPES.has(node.type.name)) {
|
|
84
|
+
canBeConverted = false;
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (!canBeConverted) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
var contentToInclude = removeBreakoutMarks($from.doc.slice(from, to).content);
|
|
92
|
+
return {
|
|
93
|
+
contentToInclude: contentToInclude,
|
|
94
|
+
from: from,
|
|
95
|
+
to: to
|
|
96
|
+
};
|
|
97
|
+
};
|
|
67
98
|
var removeBreakoutMarks = function removeBreakoutMarks(content) {
|
|
68
99
|
var nodes = [];
|
|
69
100
|
|
|
@@ -4,7 +4,7 @@ import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
|
|
|
4
4
|
import { SyncBlockLabel } from './SyncBlockLabel';
|
|
5
5
|
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
6
6
|
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
7
|
-
var _syncBlockFetchResult, _syncBlockFetchResult2;
|
|
7
|
+
var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3;
|
|
8
8
|
var syncedBlockRenderer = _ref.syncedBlockRenderer,
|
|
9
9
|
useFetchSyncBlockData = _ref.useFetchSyncBlockData,
|
|
10
10
|
useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
|
|
@@ -13,7 +13,8 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
13
13
|
var syncBlockFetchResult = useFetchSyncBlockData();
|
|
14
14
|
var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
|
|
15
15
|
var contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 || (_syncBlockFetchResult = _syncBlockFetchResult.data) === null || _syncBlockFetchResult === void 0 ? void 0 : _syncBlockFetchResult.contentUpdatedAt;
|
|
16
|
-
var
|
|
16
|
+
var isUnpublishedBlock = ((_syncBlockFetchResult2 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult2 === void 0 || (_syncBlockFetchResult2 = _syncBlockFetchResult2.data) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.status) === 'unpublished';
|
|
17
|
+
var isUnsyncedBlock = isUnpublishedBlock || (syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult3 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult3 === void 0 || (_syncBlockFetchResult3 = _syncBlockFetchResult3.error) === null || _syncBlockFetchResult3 === void 0 ? void 0 : _syncBlockFetchResult3.type) === SyncBlockError.NotFound;
|
|
17
18
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
18
19
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
19
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
@@ -20,4 +20,6 @@ export interface SyncBlockConversionInfo {
|
|
|
20
20
|
* or false if conversion is not possible
|
|
21
21
|
*/
|
|
22
22
|
export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
23
|
+
export declare const canBeConvertedToSyncBlockOld: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
24
|
+
export declare const canBeConvertedToSyncBlockNew: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
23
25
|
export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boolean;
|
|
@@ -20,4 +20,6 @@ export interface SyncBlockConversionInfo {
|
|
|
20
20
|
* or false if conversion is not possible
|
|
21
21
|
*/
|
|
22
22
|
export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
23
|
+
export declare const canBeConvertedToSyncBlockOld: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
24
|
+
export declare const canBeConvertedToSyncBlockNew: (selection: Selection) => SyncBlockConversionInfo | false;
|
|
23
25
|
export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boolean;
|