@atlaskit/editor-plugin-block-menu 3.1.5 → 3.1.6
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 +8 -0
- package/dist/cjs/ui/copy-block.js +17 -1
- package/dist/es2019/ui/copy-block.js +17 -1
- package/dist/esm/ui/copy-block.js +17 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-menu
|
|
2
2
|
|
|
3
|
+
## 3.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f1e12e7cf00ba`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f1e12e7cf00ba) -
|
|
8
|
+
ED-29083: Fixed copying code block only copy texts
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 3.1.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -33,7 +33,7 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
|
33
33
|
var schema = selection.$from.doc.type.schema;
|
|
34
34
|
// for texts and inline nodes
|
|
35
35
|
if (selection instanceof _state.TextSelection) {
|
|
36
|
-
var _fragment;
|
|
36
|
+
var _fragment, _fragment2;
|
|
37
37
|
var fragment = selection === null || selection === void 0 ? void 0 : selection.content().content;
|
|
38
38
|
if (!fragment) {
|
|
39
39
|
return;
|
|
@@ -46,6 +46,15 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
|
46
46
|
var layoutContent = layoutColumnNode === null || layoutColumnNode === void 0 ? void 0 : layoutColumnNode.firstChild;
|
|
47
47
|
fragment = (layoutContent === null || layoutContent === void 0 ? void 0 : layoutContent.content) || _model.Fragment.empty;
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
// if text is inside of an expand, the selection contains an expand for some reason
|
|
51
|
+
// the expandNode always and only have one child, no matter how much contents are inside the expand,
|
|
52
|
+
// and the one child is the line that is being selected, so we can use the .firstChild again
|
|
53
|
+
if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && fragment.firstChild.type.name === 'expand') {
|
|
54
|
+
var expandNode = fragment.firstChild;
|
|
55
|
+
var actualNodeToCopy = expandNode.firstChild;
|
|
56
|
+
fragment = _model.Fragment.from(actualNodeToCopy) || _model.Fragment.empty;
|
|
57
|
+
}
|
|
49
58
|
var domNode = toDOMFromFragment(fragment, schema);
|
|
50
59
|
var div = document.createElement('div');
|
|
51
60
|
div.appendChild(domNode);
|
|
@@ -66,6 +75,13 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
|
66
75
|
// for other nodes
|
|
67
76
|
if (selection instanceof _state.NodeSelection) {
|
|
68
77
|
var _nodeType = selection.node.type;
|
|
78
|
+
|
|
79
|
+
// code block is a special case where it is a block node but has inlineContent to true,
|
|
80
|
+
// When nodeType.inlineContent is true, it will be treated as an inline node in the copyDomNode function,
|
|
81
|
+
// but we want to treat it as a block node when copying, hence setting it to false here
|
|
82
|
+
if (selection.node.type.name === 'codeBlock') {
|
|
83
|
+
_nodeType.inlineContent = false;
|
|
84
|
+
}
|
|
69
85
|
var _domNode2 = (0, _copyButton.toDOM)(selection.node, schema);
|
|
70
86
|
(0, _copyButton.copyDomNode)(_domNode2, _nodeType, selection);
|
|
71
87
|
}
|
|
@@ -28,7 +28,7 @@ const CopyBlockMenuItem = ({
|
|
|
28
28
|
const schema = selection.$from.doc.type.schema;
|
|
29
29
|
// for texts and inline nodes
|
|
30
30
|
if (selection instanceof TextSelection) {
|
|
31
|
-
var _fragment;
|
|
31
|
+
var _fragment, _fragment2;
|
|
32
32
|
let fragment = selection === null || selection === void 0 ? void 0 : selection.content().content;
|
|
33
33
|
if (!fragment) {
|
|
34
34
|
return;
|
|
@@ -41,6 +41,15 @@ const CopyBlockMenuItem = ({
|
|
|
41
41
|
const layoutContent = layoutColumnNode === null || layoutColumnNode === void 0 ? void 0 : layoutColumnNode.firstChild;
|
|
42
42
|
fragment = (layoutContent === null || layoutContent === void 0 ? void 0 : layoutContent.content) || Fragment.empty;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
// if text is inside of an expand, the selection contains an expand for some reason
|
|
46
|
+
// the expandNode always and only have one child, no matter how much contents are inside the expand,
|
|
47
|
+
// and the one child is the line that is being selected, so we can use the .firstChild again
|
|
48
|
+
if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && fragment.firstChild.type.name === 'expand') {
|
|
49
|
+
const expandNode = fragment.firstChild;
|
|
50
|
+
const actualNodeToCopy = expandNode.firstChild;
|
|
51
|
+
fragment = Fragment.from(actualNodeToCopy) || Fragment.empty;
|
|
52
|
+
}
|
|
44
53
|
const domNode = toDOMFromFragment(fragment, schema);
|
|
45
54
|
const div = document.createElement('div');
|
|
46
55
|
div.appendChild(domNode);
|
|
@@ -61,6 +70,13 @@ const CopyBlockMenuItem = ({
|
|
|
61
70
|
// for other nodes
|
|
62
71
|
if (selection instanceof NodeSelection) {
|
|
63
72
|
const nodeType = selection.node.type;
|
|
73
|
+
|
|
74
|
+
// code block is a special case where it is a block node but has inlineContent to true,
|
|
75
|
+
// When nodeType.inlineContent is true, it will be treated as an inline node in the copyDomNode function,
|
|
76
|
+
// but we want to treat it as a block node when copying, hence setting it to false here
|
|
77
|
+
if (selection.node.type.name === 'codeBlock') {
|
|
78
|
+
nodeType.inlineContent = false;
|
|
79
|
+
}
|
|
64
80
|
const domNode = toDOM(selection.node, schema);
|
|
65
81
|
copyDomNode(domNode, nodeType, selection);
|
|
66
82
|
}
|
|
@@ -26,7 +26,7 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
|
26
26
|
var schema = selection.$from.doc.type.schema;
|
|
27
27
|
// for texts and inline nodes
|
|
28
28
|
if (selection instanceof TextSelection) {
|
|
29
|
-
var _fragment;
|
|
29
|
+
var _fragment, _fragment2;
|
|
30
30
|
var fragment = selection === null || selection === void 0 ? void 0 : selection.content().content;
|
|
31
31
|
if (!fragment) {
|
|
32
32
|
return;
|
|
@@ -39,6 +39,15 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
|
39
39
|
var layoutContent = layoutColumnNode === null || layoutColumnNode === void 0 ? void 0 : layoutColumnNode.firstChild;
|
|
40
40
|
fragment = (layoutContent === null || layoutContent === void 0 ? void 0 : layoutContent.content) || Fragment.empty;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
// if text is inside of an expand, the selection contains an expand for some reason
|
|
44
|
+
// the expandNode always and only have one child, no matter how much contents are inside the expand,
|
|
45
|
+
// and the one child is the line that is being selected, so we can use the .firstChild again
|
|
46
|
+
if ((_fragment2 = fragment) !== null && _fragment2 !== void 0 && _fragment2.firstChild && fragment.firstChild.type.name === 'expand') {
|
|
47
|
+
var expandNode = fragment.firstChild;
|
|
48
|
+
var actualNodeToCopy = expandNode.firstChild;
|
|
49
|
+
fragment = Fragment.from(actualNodeToCopy) || Fragment.empty;
|
|
50
|
+
}
|
|
42
51
|
var domNode = toDOMFromFragment(fragment, schema);
|
|
43
52
|
var div = document.createElement('div');
|
|
44
53
|
div.appendChild(domNode);
|
|
@@ -59,6 +68,13 @@ var CopyBlockMenuItem = function CopyBlockMenuItem(_ref) {
|
|
|
59
68
|
// for other nodes
|
|
60
69
|
if (selection instanceof NodeSelection) {
|
|
61
70
|
var _nodeType = selection.node.type;
|
|
71
|
+
|
|
72
|
+
// code block is a special case where it is a block node but has inlineContent to true,
|
|
73
|
+
// When nodeType.inlineContent is true, it will be treated as an inline node in the copyDomNode function,
|
|
74
|
+
// but we want to treat it as a block node when copying, hence setting it to false here
|
|
75
|
+
if (selection.node.type.name === 'codeBlock') {
|
|
76
|
+
_nodeType.inlineContent = false;
|
|
77
|
+
}
|
|
62
78
|
var _domNode2 = toDOM(selection.node, schema);
|
|
63
79
|
copyDomNode(_domNode2, _nodeType, selection);
|
|
64
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-menu",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"description": "BlockMenu plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@atlaskit/icon-lab": "^5.7.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
44
|
"@atlaskit/primitives": "^14.14.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^12.23.0",
|
|
46
46
|
"@atlaskit/tokens": "^6.3.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^109.
|
|
50
|
+
"@atlaskit/editor-common": "^109.8.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
53
53
|
},
|