@atlaskit/editor-plugin-code-block 3.5.9 → 3.5.11
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
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 3.5.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.5.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#170778](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170778)
|
|
14
|
+
[`2202b03e196ad`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2202b03e196ad) -
|
|
15
|
+
[ux] [ED-25407] FF cleanup - platform_editor_utilize_linebreakreplacement
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.5.9
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -9,7 +9,6 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
9
9
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _utils3 = require("./utils");
|
|
14
13
|
var deleteCurrentItem = function deleteCurrentItem($from) {
|
|
15
14
|
return function (tr) {
|
|
@@ -25,42 +24,16 @@ var setTextSelection = function setTextSelection(pos) {
|
|
|
25
24
|
return tr;
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
// This method converts the code block with a Paragraph, while replacing it's
|
|
30
|
-
// newline `\n` characters with `hardBreak`s to ensure that they are retained in the
|
|
31
|
-
// rendered output. `prosemirror-transform` v1.74 introduced new behaviour for
|
|
32
|
-
// `setBlockType` which means we can't use it here without losing whitespace
|
|
33
|
-
// https://github.com/ProseMirror/prosemirror-transform/blob/master/CHANGELOG.md#174-2023-07-28
|
|
34
|
-
var replaceWithParagraph = function replaceWithParagraph(node, nodePos, $cursor, state, dispatch) {
|
|
35
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
36
|
-
paragraph = _state$schema$nodes.paragraph,
|
|
37
|
-
hardBreak = _state$schema$nodes.hardBreak;
|
|
38
|
-
var nodeLines = node.textContent.split('\n');
|
|
39
|
-
var tr = state.tr;
|
|
40
|
-
var newNodes = [];
|
|
41
|
-
nodeLines.forEach(function (line, index) {
|
|
42
|
-
if (index > 0) {
|
|
43
|
-
newNodes.push(hardBreak.create());
|
|
44
|
-
}
|
|
45
|
-
if (line) {
|
|
46
|
-
newNodes.push(state.schema.text(line));
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
var newParagraph = paragraph.createChecked([], newNodes);
|
|
50
|
-
tr.replaceWith(nodePos, nodePos + node.nodeSize, newParagraph);
|
|
51
|
-
setTextSelection($cursor.pos)(tr);
|
|
52
|
-
dispatch(tr);
|
|
53
|
-
};
|
|
54
27
|
function keymapPlugin(schema) {
|
|
55
28
|
return (0, _keymap.keymap)({
|
|
56
29
|
Backspace: function Backspace(state, dispatch) {
|
|
57
30
|
var $cursor = (0, _utils3.getCursor)(state.selection);
|
|
58
|
-
var _state$schema$
|
|
59
|
-
codeBlock = _state$schema$
|
|
60
|
-
listItem = _state$schema$
|
|
61
|
-
table = _state$schema$
|
|
62
|
-
layoutColumn = _state$schema$
|
|
63
|
-
paragraph = _state$schema$
|
|
31
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
32
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
33
|
+
listItem = _state$schema$nodes.listItem,
|
|
34
|
+
table = _state$schema$nodes.table,
|
|
35
|
+
layoutColumn = _state$schema$nodes.layoutColumn,
|
|
36
|
+
paragraph = _state$schema$nodes.paragraph;
|
|
64
37
|
if (!$cursor || $cursor.parent.type !== codeBlock || !dispatch) {
|
|
65
38
|
return false;
|
|
66
39
|
}
|
|
@@ -69,11 +42,7 @@ function keymapPlugin(schema) {
|
|
|
69
42
|
if (!node) {
|
|
70
43
|
return false;
|
|
71
44
|
}
|
|
72
|
-
|
|
73
|
-
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
74
|
-
} else {
|
|
75
|
-
replaceWithParagraph(node.node, node.pos, $cursor, state, dispatch);
|
|
76
|
-
}
|
|
45
|
+
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
77
46
|
return true;
|
|
78
47
|
}
|
|
79
48
|
if ($cursor.node && (0, _utils.isEmptyNode)(schema)($cursor.node()) && ((0, _utils2.hasParentNodeOfType)(layoutColumn)(state.selection) || (0, _utils2.hasParentNodeOfType)(table)(state.selection))) {
|
|
@@ -2,7 +2,6 @@ import { isEmptyNode } from '@atlaskit/editor-common/utils';
|
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { getCursor } from './utils';
|
|
7
6
|
const deleteCurrentItem = $from => tr => {
|
|
8
7
|
return tr.delete($from.before($from.depth), $from.after($from.depth));
|
|
@@ -14,35 +13,6 @@ const setTextSelection = pos => tr => {
|
|
|
14
13
|
}
|
|
15
14
|
return tr;
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
// This method converts the code block with a Paragraph, while replacing it's
|
|
19
|
-
// newline `\n` characters with `hardBreak`s to ensure that they are retained in the
|
|
20
|
-
// rendered output. `prosemirror-transform` v1.74 introduced new behaviour for
|
|
21
|
-
// `setBlockType` which means we can't use it here without losing whitespace
|
|
22
|
-
// https://github.com/ProseMirror/prosemirror-transform/blob/master/CHANGELOG.md#174-2023-07-28
|
|
23
|
-
const replaceWithParagraph = (node, nodePos, $cursor, state, dispatch) => {
|
|
24
|
-
const {
|
|
25
|
-
paragraph,
|
|
26
|
-
hardBreak
|
|
27
|
-
} = state.schema.nodes;
|
|
28
|
-
const nodeLines = node.textContent.split('\n');
|
|
29
|
-
const {
|
|
30
|
-
tr
|
|
31
|
-
} = state;
|
|
32
|
-
const newNodes = [];
|
|
33
|
-
nodeLines.forEach((line, index) => {
|
|
34
|
-
if (index > 0) {
|
|
35
|
-
newNodes.push(hardBreak.create());
|
|
36
|
-
}
|
|
37
|
-
if (line) {
|
|
38
|
-
newNodes.push(state.schema.text(line));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const newParagraph = paragraph.createChecked([], newNodes);
|
|
42
|
-
tr.replaceWith(nodePos, nodePos + node.nodeSize, newParagraph);
|
|
43
|
-
setTextSelection($cursor.pos)(tr);
|
|
44
|
-
dispatch(tr);
|
|
45
|
-
};
|
|
46
16
|
export function keymapPlugin(schema) {
|
|
47
17
|
return keymap({
|
|
48
18
|
Backspace: (state, dispatch) => {
|
|
@@ -62,11 +32,7 @@ export function keymapPlugin(schema) {
|
|
|
62
32
|
if (!node) {
|
|
63
33
|
return false;
|
|
64
34
|
}
|
|
65
|
-
|
|
66
|
-
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
67
|
-
} else {
|
|
68
|
-
replaceWithParagraph(node.node, node.pos, $cursor, state, dispatch);
|
|
69
|
-
}
|
|
35
|
+
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
70
36
|
return true;
|
|
71
37
|
}
|
|
72
38
|
if ($cursor.node && isEmptyNode(schema)($cursor.node()) && (hasParentNodeOfType(layoutColumn)(state.selection) || hasParentNodeOfType(table)(state.selection))) {
|
|
@@ -2,7 +2,6 @@ import { isEmptyNode } from '@atlaskit/editor-common/utils';
|
|
|
2
2
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { getCursor } from './utils';
|
|
7
6
|
var deleteCurrentItem = function deleteCurrentItem($from) {
|
|
8
7
|
return function (tr) {
|
|
@@ -18,42 +17,16 @@ var setTextSelection = function setTextSelection(pos) {
|
|
|
18
17
|
return tr;
|
|
19
18
|
};
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
// This method converts the code block with a Paragraph, while replacing it's
|
|
23
|
-
// newline `\n` characters with `hardBreak`s to ensure that they are retained in the
|
|
24
|
-
// rendered output. `prosemirror-transform` v1.74 introduced new behaviour for
|
|
25
|
-
// `setBlockType` which means we can't use it here without losing whitespace
|
|
26
|
-
// https://github.com/ProseMirror/prosemirror-transform/blob/master/CHANGELOG.md#174-2023-07-28
|
|
27
|
-
var replaceWithParagraph = function replaceWithParagraph(node, nodePos, $cursor, state, dispatch) {
|
|
28
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
29
|
-
paragraph = _state$schema$nodes.paragraph,
|
|
30
|
-
hardBreak = _state$schema$nodes.hardBreak;
|
|
31
|
-
var nodeLines = node.textContent.split('\n');
|
|
32
|
-
var tr = state.tr;
|
|
33
|
-
var newNodes = [];
|
|
34
|
-
nodeLines.forEach(function (line, index) {
|
|
35
|
-
if (index > 0) {
|
|
36
|
-
newNodes.push(hardBreak.create());
|
|
37
|
-
}
|
|
38
|
-
if (line) {
|
|
39
|
-
newNodes.push(state.schema.text(line));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var newParagraph = paragraph.createChecked([], newNodes);
|
|
43
|
-
tr.replaceWith(nodePos, nodePos + node.nodeSize, newParagraph);
|
|
44
|
-
setTextSelection($cursor.pos)(tr);
|
|
45
|
-
dispatch(tr);
|
|
46
|
-
};
|
|
47
20
|
export function keymapPlugin(schema) {
|
|
48
21
|
return keymap({
|
|
49
22
|
Backspace: function Backspace(state, dispatch) {
|
|
50
23
|
var $cursor = getCursor(state.selection);
|
|
51
|
-
var _state$schema$
|
|
52
|
-
codeBlock = _state$schema$
|
|
53
|
-
listItem = _state$schema$
|
|
54
|
-
table = _state$schema$
|
|
55
|
-
layoutColumn = _state$schema$
|
|
56
|
-
paragraph = _state$schema$
|
|
24
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
25
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
26
|
+
listItem = _state$schema$nodes.listItem,
|
|
27
|
+
table = _state$schema$nodes.table,
|
|
28
|
+
layoutColumn = _state$schema$nodes.layoutColumn,
|
|
29
|
+
paragraph = _state$schema$nodes.paragraph;
|
|
57
30
|
if (!$cursor || $cursor.parent.type !== codeBlock || !dispatch) {
|
|
58
31
|
return false;
|
|
59
32
|
}
|
|
@@ -62,11 +35,7 @@ export function keymapPlugin(schema) {
|
|
|
62
35
|
if (!node) {
|
|
63
36
|
return false;
|
|
64
37
|
}
|
|
65
|
-
|
|
66
|
-
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
67
|
-
} else {
|
|
68
|
-
replaceWithParagraph(node.node, node.pos, $cursor, state, dispatch);
|
|
69
|
-
}
|
|
38
|
+
dispatch(state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, []).setBlockType($cursor.pos, $cursor.pos, paragraph));
|
|
70
39
|
return true;
|
|
71
40
|
}
|
|
72
41
|
if ($cursor.node && isEmptyNode(schema)($cursor.node()) && (hasParentNodeOfType(layoutColumn)(state.selection) || hasParentNodeOfType(table)(state.selection))) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.11",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
35
|
"@atlaskit/code": "^15.6.0",
|
|
36
|
-
"@atlaskit/editor-common": "^
|
|
36
|
+
"@atlaskit/editor-common": "^96.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
38
38
|
"@atlaskit/editor-plugin-composition": "^1.2.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
@@ -104,9 +104,6 @@
|
|
|
104
104
|
},
|
|
105
105
|
"editor_code_wrapping_perf_improvement_ed-25141": {
|
|
106
106
|
"type": "boolean"
|
|
107
|
-
},
|
|
108
|
-
"platform_editor_utilize_linebreakreplacement": {
|
|
109
|
-
"type": "boolean"
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
109
|
}
|